Re: [PATCH] mac80211: minstrel: Enable STBC and LDPC for VHT Rates

2016-06-29 Thread Karl Beldan
On Mon, Jun 27, 2016 at 9:53 AM, Chaitanya TK  wrote:
> From: Chaitanya T K 
>
> If peer support reception of STBC and LDPC, enable them for better
> performance.
>
> Signed-off-by: Chaitanya TK 
> ---
>  include/linux/ieee80211.h  |1 +
>  net/mac80211/rc80211_minstrel_ht.c |   25 +
>  2 files changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
> index b118744..4d01130 100644
> --- a/include/linux/ieee80211.h
> +++ b/include/linux/ieee80211.h
> @@ -1550,6 +1550,7 @@ struct ieee80211_vht_operation {
>  #define IEEE80211_VHT_CAP_RXSTBC_3 0x0300
>  #define IEEE80211_VHT_CAP_RXSTBC_4 0x0400
>  #define IEEE80211_VHT_CAP_RXSTBC_MASK  0x0700
> +#define IEEE80211_VHT_CAP_RXSTBC_SHIFT 8
>  #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE
> 0x0800
>  #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE
> 0x1000
>  #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT  13
> diff --git a/net/mac80211/rc80211_minstrel_ht.c 
> b/net/mac80211/rc80211_minstrel_ht.c
> index 30fbabf..e2fcdea 100644
> --- a/net/mac80211/rc80211_minstrel_ht.c
> +++ b/net/mac80211/rc80211_minstrel_ht.c
> @@ -1166,13 +1166,14 @@ minstrel_ht_update_caps(void *priv, struct 
> ieee80211_supported_band *sband,
> struct minstrel_ht_sta_priv *msp = priv_sta;
> struct minstrel_ht_sta *mi = &msp->ht;
> struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
> -   u16 sta_cap = sta->ht_cap.cap;
> +   u16 ht_cap = sta->ht_cap.cap;
> struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
> int use_vht;
> int n_supported = 0;
> int ack_dur;
> int stbc;
> int i;
> +   bool ldpc;
>
> /* fall back to the old minstrel for legacy stations */
> if (!sta->ht_cap.ht_supported)
> @@ -1210,16 +1211,24 @@ minstrel_ht_update_caps(void *priv, struct 
> ieee80211_supported_band *sband,
> }
> mi->sample_tries = 4;
>
> -   /* TODO tx_flags for vht - ATM the RC API is not fine-grained enough 
> */
> if (!use_vht) {
> -   stbc = (sta_cap & IEEE80211_HT_CAP_RX_STBC) >>
> +   stbc = (ht_cap & IEEE80211_HT_CAP_RX_STBC) >>
> IEEE80211_HT_CAP_RX_STBC_SHIFT;
> -   mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
>
> -   if (sta_cap & IEEE80211_HT_CAP_LDPC_CODING)
> -   mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
> +   if (ht_cap & IEEE80211_HT_CAP_LDPC_CODING)
> +   ldpc = true;
> +   } else {
> +   stbc = (vht_cap->cap & IEEE80211_VHT_CAP_RXSTBC_MASK) >>
> +   IEEE80211_VHT_CAP_RXSTBC_SHIFT;
> +
> +   if (vht_cap->cap & IEEE80211_VHT_CAP_RXLDPC)
> +   ldpc = true;
> }
>
> +   mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
> +   if (ldpc)
> +   mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
> +

Here you are using ldpc uninitialized.


As for the idea, ldpc and stbc support/enable in HT and VHT being
independant and tx_flags being shared by all the info.rates, you
cannot use it as you are trying to (e.g. you might end up asking lower
layers to send stbc/vht with a hw only supporting stbc/ht or/and
trying to send stbc/vht with inappropriate advertised vht caps).
This stems from the STBC/LDPC CTL flags being a
mac80211_tx_info_flags, this is what should be changed.


Regards,
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: skip legacy rate mask handling for VHT rates

2014-11-15 Thread Karl Beldan
On Sat, Nov 15, 2014 at 03:48:54AM +0100, Felix Fietkau wrote:
> The rate mask code currently assumes that a rate is legacy if
> IEEE80211_TX_RC_MCS is not set. This might be the cause of bogus VHT
> rates being reported with minstrel_ht.
> 
> Signed-off-by: Felix Fietkau 
> ---
>  net/mac80211/rate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
> index 6081329..f6fea67f 100644
> --- a/net/mac80211/rate.c
> +++ b/net/mac80211/rate.c
> @@ -385,7 +385,7 @@ static void rate_idx_match_mask(struct ieee80211_tx_rate 
> *rate,
>   *rate = alt_rate;
>   return;
>   }
> - } else {
> + } else if (!(rate->flags & IEEE80211_TX_RC_VHT_MCS)) {
>   /* handle legacy rates */
>   if (rate_idx_match_legacy_mask(rate, sband->n_bitrates, mask))
>   return;

Does it fix things on your side Jouni ?
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-11-14 Thread Karl Beldan
On Fri, Nov 14, 2014 at 07:36:48PM +0200, Jouni Malinen wrote:
> On Fri, Nov 14, 2014 at 06:18:32PM +0100, Karl Beldan wrote:
> > Yes, only with iw and nothing fancy, I also have had it running on some 
> > boards for some weeks as is and with rfc version for more than a year at
> > work (minstrel not the whole tree).
> > I guess I can take the tip of wireless-testing but can you give your
> > HEAD though ?
> 
> It looks like pretty much any snapshot between master-2014-11-04 and now
> is affected.. Anyway, the current master snapshot in my tests was
> 0e204e2422876c18034ca960c4fccf727a02a5c1.
> 

I tried to trigger the warning with it and nfc_p2p_* (even looping with
stop.sh; start.sh; run-tests.py nfc_p2p_*), to no avail, the tests are
successful and 0 warning.
I'll see if anything stands out in the code tomorrow.
 
Karl

> > > For example, with nfc_p2p_go_neg test case:
> > 
> > Have you reproduced it with other testcases (maybe more regular so that
> > I can get my hands on it faster) ?
> > Is it also happening when VHT support is not advertized by upper layers
> > ?
> 
> This seems to be specific to exact timing of frames since the same issue
> does not show up in non-NFC P2P test cases. So no, this does not show up
> with anything else than the nfc_p2p_* test cases (well, at least not in
> my desktop+kvm setup; YMMV with other CPU speeds that could potentially
> affect timing):
> nfc_p2p_go_neg
> nfc_p2p_go_neg_reverse
> nfc_p2p_ip_addr_assignment
> nfc_p2p_static_handover_tagdev_client
> nfc_p2p_static_handover_tagdev_client_group_iface
> nfc_p2p_static_handover_tagdev_go
> 
> I'd assume the key here is in P2P with NFC trigger having the fastest
> possible connection process due to all the optimizations in channel
> selection on WPS (which is those EAPOL Data frames that hit these rate
> selection issues immediately after association).
> 
> That said, if you use the tests/hwsim scripts from
> git://w1.fi/hostap.git there should be no difference on running some of
> these cases vs. something more regular..
> 
> If you have not used these test scripts previously, you can find more
> information about the setup here:
> http://w1.fi/cgit/hostap/plain/tests/hwsim/README
> http://w1.fi/cgit/hostap/plain/tests/hwsim/vm/README
> 
> -- 
> Jouni MalinenPGP id EFC895FA
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-11-14 Thread Karl Beldan
On Fri, Nov 14, 2014 at 07:36:48PM +0200, Jouni Malinen wrote:
> On Fri, Nov 14, 2014 at 06:18:32PM +0100, Karl Beldan wrote:
> > Yes, only with iw and nothing fancy, I also have had it running on some 
> > boards for some weeks as is and with rfc version for more than a year at
> > work (minstrel not the whole tree).
> > I guess I can take the tip of wireless-testing but can you give your
> > HEAD though ?
> 
> It looks like pretty much any snapshot between master-2014-11-04 and now
> is affected.. Anyway, the current master snapshot in my tests was
> 0e204e2422876c18034ca960c4fccf727a02a5c1.
> 
> > > For example, with nfc_p2p_go_neg test case:
> > 
> > Have you reproduced it with other testcases (maybe more regular so that
> > I can get my hands on it faster) ?
> > Is it also happening when VHT support is not advertized by upper layers
> > ?
> 
> This seems to be specific to exact timing of frames since the same issue
> does not show up in non-NFC P2P test cases. So no, this does not show up
> with anything else than the nfc_p2p_* test cases (well, at least not in
> my desktop+kvm setup; YMMV with other CPU speeds that could potentially
> affect timing):
> nfc_p2p_go_neg
> nfc_p2p_go_neg_reverse
> nfc_p2p_ip_addr_assignment
> nfc_p2p_static_handover_tagdev_client
> nfc_p2p_static_handover_tagdev_client_group_iface
> nfc_p2p_static_handover_tagdev_go
> 
> I'd assume the key here is in P2P with NFC trigger having the fastest
> possible connection process due to all the optimizations in channel
> selection on WPS (which is those EAPOL Data frames that hit these rate
> selection issues immediately after association).
> 
> That said, if you use the tests/hwsim scripts from
> git://w1.fi/hostap.git there should be no difference on running some of
> these cases vs. something more regular..
> 
> If you have not used these test scripts previously, you can find more
> information about the setup here:
> http://w1.fi/cgit/hostap/plain/tests/hwsim/README
> http://w1.fi/cgit/hostap/plain/tests/hwsim/vm/README
> 

Ok, thanks for your pointers Jouni, I should get back to you soon.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-11-14 Thread Karl Beldan
Hi,

On Fri, Nov 14, 2014 at 06:43:28PM +0200, Jouni Malinen wrote:
> On Tue, Oct 21, 2014 at 10:38:38AM +0200, Karl Beldan wrote:
> > When the new CONFIG_MAC80211_RC_MINSTREL_VHT is not set (default 'N'),
> > there is no behavioral change including in sampling and MCS_GROUP_RATES
> > remains 8.
> > Otherwise MCS_GROUP_RATES is 10, and a module parameter *vht_only*
> > (default 'true'), restricts the rates selection to VHT when vht is
> > supported.
> 
> Have you tested this with mac80211_hwsim? I'm seeing number of issues in

Yes, only with iw and nothing fancy, I also have had it running on some 
boards for some weeks as is and with rfc version for more than a year at
work (minstrel not the whole tree).
I guess I can take the tip of wireless-testing but can you give your
HEAD though ?

> hwsim test cases with CONFIG_MAC80211_RC_MINSTREL_VHT=y with
> wireless-testing.git. These disappear if I disable this build option.
> 
> For example, with nfc_p2p_go_neg test case:
> 

Have you reproduced it with other testcases (maybe more regular so that
I can get my hands on it faster) ?
Is it also happening when VHT support is not advertized by upper layers
?


Rgds,
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: minstrel_ht: do not always skip ht rates vht_only is true

2014-10-24 Thread Karl Beldan
On Fri, Oct 24, 2014 at 04:30:35PM +0200, Johannes Berg wrote:
> On Fri, 2014-10-24 at 14:34 +0200, Karl Beldan wrote:
> > From: Karl Beldan 
> > 
> > When CONFIG_MAC80211_RC_MINSTREL_VHT is set, the module param
> > minstrel_vht_only tells minstrel_ht whether to allow the mix of ht rates
> > with vht rates.
> > ATM, minstrel_ht skips ht rates when minstrel_vht_only is true, but it does
> > that even if vht is not supported, which makes the sta rates fallback to
> > legacy as no ht rate gets enabled.
> 
> Applied (as is)
> 
Ok, thanks.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/4] add VHT support to minstrel_ht

2014-10-24 Thread Karl Beldan
On Sat, Oct 18, 2014 at 11:11:48PM +0530, Krishna Chaitanya wrote:
> On Sat, Oct 18, 2014 at 10:43 PM, Karl Beldan  wrote:
> >
> > From: Karl Beldan 
> >
> >
> > Karl Beldan (4):
> >   mac80211: minstrel_ht: Increase the range of handled rate indexes
> >   mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs
> >   mac80211: minstrel_ht: include type (cck/ht) in rates flag
> >   mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz
> > v2:
> > - typo in Kconfig
> > - adjust room in debugfs rc_stats buffer
> > - add a module param to mix ht rates with vht ones
> > - default to 3SS instead of 2SS (with "mac80211: minstrel_ht: macros
> >   adjustments for future VHT_GROUPs")
> > - use common MINSTREL_MAX_STREAMS both for VHT and HT so that we can get
> >   rid of the 'MINSTREL_MAX_STREAMS >= 3' checks for minstrel_mcs_groups
> > v3:
> > - put module param *vht_only* under CONFIG_MAC80211_RC_MINSTREL_VHT
> >
> >  net/mac80211/Kconfig   |   7 +
> >  net/mac80211/rc80211_minstrel_ht.c | 292 
> > +++--
> >  net/mac80211/rc80211_minstrel_ht.h |  38 +++-
> >  net/mac80211/rc80211_minstrel_ht_debugfs.c |  32 ++--
> >  4 files changed, 290 insertions(+), 79 deletions(-)
> >
> > --
> >
> We have been using you patches for some time and they do the work well.
I know you've be using it with your IP but have you by any chance tried
using it with iwlmvm ?
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: minstrel_ht: do not always skip ht rates vht_only is true

2014-10-24 Thread Karl Beldan
On Fri, Oct 24, 2014 at 02:34:49PM +0200, Karl Beldan wrote:
> From: Karl Beldan 
> 
> When CONFIG_MAC80211_RC_MINSTREL_VHT is set, the module param
> minstrel_vht_only tells minstrel_ht whether to allow the mix of ht rates
> with vht rates.
> ATM, minstrel_ht skips ht rates when minstrel_vht_only is true, but it does
> that even if vht is not supported, which makes the sta rates fallback to
> legacy as no ht rate gets enabled.
> 
> Fixes: 9208247d74bc ("mac80211: minstrel_ht: add basic support for VHT rates 
> <= 3SS@80MHz")
> Signed-off-by: Karl Beldan 
> ---

This sneaked in between v4 and v5 when reformatting the code for 80ch.
v5:
- fix some checkpatch complaints this, leaves 2 false positives
  "ERROR: Macros with complex values should be enclosed in parenthesis"
  in array initialization
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211: minstrel_ht: do not always skip ht rates vht_only is true

2014-10-24 Thread Karl Beldan
From: Karl Beldan 

When CONFIG_MAC80211_RC_MINSTREL_VHT is set, the module param
minstrel_vht_only tells minstrel_ht whether to allow the mix of ht rates
with vht rates.
ATM, minstrel_ht skips ht rates when minstrel_vht_only is true, but it does
that even if vht is not supported, which makes the sta rates fallback to
legacy as no ht rate gets enabled.

Fixes: 9208247d74bc ("mac80211: minstrel_ht: add basic support for VHT rates <= 
3SS@80MHz")
Signed-off-by: Karl Beldan 
---
 net/mac80211/rc80211_minstrel_ht.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index 481..c50fd94 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -1193,7 +1193,7 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
/* HT rate */
if (gflags & IEEE80211_TX_RC_MCS) {
 #ifdef CONFIG_MAC80211_RC_MINSTREL_VHT
-   if (minstrel_vht_only)
+   if (use_vht && minstrel_vht_only)
continue;
 #endif
mi->groups[i].supported = mcs->rx_mask[nss - 1];
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-10-24 Thread Karl Beldan
Hi,

On Tue, Oct 21, 2014 at 10:38:38AM +0200, Karl Beldan wrote:
> From: Karl Beldan 
> 
> @@ -1026,13 +1184,47 @@ minstrel_ht_update_caps(void *priv, struct 
> ieee80211_supported_band *sband,
>   sta->bandwidth < IEEE80211_STA_RX_BW_40)
>   continue;
>  
> + nss = minstrel_mcs_groups[i].streams;
> +
>   /* Mark MCS > 7 as unsupported if STA is in static SMPS mode */
> - if (sta->smps_mode == IEEE80211_SMPS_STATIC &&
> - minstrel_mcs_groups[i].streams > 1)
> + if (sta->smps_mode == IEEE80211_SMPS_STATIC && nss > 1)
> + continue;
> +
> + /* HT rate */
> + if (gflags & IEEE80211_TX_RC_MCS) {
> +#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT
> + if (minstrel_vht_only)
> + continue;
> +#endif

When reformatting for 80chars I introduced a pb, the test should be 
'if (use_vht && minstrel_vht_only)' instead.
The consequence is VHT-unable devices with
CONFIG_MAC80211_RC_MINSTREL_VHT set won't have HT rates enabled.
Johannes can you squash it in or should I send you a patch ?

 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211: minstrel_ht: use group flags instead of index to display rates

2014-10-22 Thread Karl Beldan
From: Karl Beldan 

When displaying a rate through debugfs minstrel_ht guesses its flags
comparing group indexes.  Since 3ec373c421b6 ("mac80211: minstrel_ht:
include type (cck/ht) in rates flag"), the rate flags of interest are
present in the mcs_group-s, so use it.
While improving the code, this also fixes a smatch false positive
"error: testing array offset 'i' after use" in minstrel_ht_stats_dump.
This warning only triggers after 9208247d74bc ("mac80211: minstrel_ht:
add basic support for VHT rates <= 3SS@80MHz") with
CONFIG_MAC80211_RC_MINSTREL_VHT unset because then MINSTREL_VHT_GROUP_0
is above MINSTREL_GROUPS_NB and smatch only barks when the "testing
array offset" seems to prevent possible out of bonds accesses (which
does not happen here since i < ARRAY_SIZE(mi->groups)).

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht_debugfs.c | 28 
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c 
b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index 52bb6ef..20c676b 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -22,16 +22,19 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, 
char *p)
unsigned int j, tp, prob, eprob;
char htmode = '2';
char gimode = 'L';
+   u32 gflags;
 
if (!mi->groups[i].supported)
return p;
 
mg = &minstrel_mcs_groups[i];
-   if (mg->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
+   gflags = mg->flags;
+
+   if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH)
htmode = '4';
-   else if (mg->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
+   else if (gflags & IEEE80211_TX_RC_80_MHZ_WIDTH)
htmode = '8';
-   if (mg->flags & IEEE80211_TX_RC_SHORT_GI)
+   if (gflags & IEEE80211_TX_RC_SHORT_GI)
gimode = 'S';
 
for (j = 0; j < MCS_GROUP_RATES; j++) {
@@ -42,12 +45,12 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, 
char *p)
if (!(mi->groups[i].supported & BIT(j)))
continue;
 
-   if (i == MINSTREL_CCK_GROUP)
-   p += sprintf(p, " CCK/%cP   ", j < 4 ? 'L' : 'S');
-   else if (i >= MINSTREL_VHT_GROUP_0)
+   if (gflags & IEEE80211_TX_RC_MCS)
+   p += sprintf(p, " HT%c0/%cGI ", htmode, gimode);
+   else if (gflags & IEEE80211_TX_RC_VHT_MCS)
p += sprintf(p, "VHT%c0/%cGI ", htmode, gimode);
else
-   p += sprintf(p, " HT%c0/%cGI ", htmode, gimode);
+   p += sprintf(p, " CCK/%cP   ", j < 4 ? 'L' : 'S');
 
*(p++) = (idx == mi->max_tp_rate[0]) ? 'A' : ' ';
*(p++) = (idx == mi->max_tp_rate[1]) ? 'B' : ' ';
@@ -55,13 +58,14 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, 
char *p)
*(p++) = (idx == mi->max_tp_rate[3]) ? 'D' : ' ';
*(p++) = (idx == mi->max_prob_rate) ? 'P' : ' ';
 
-   if (i == MINSTREL_CCK_GROUP) {
-   int r = bitrates[j % 4];
-   p += sprintf(p, " %2u.%1uM ", r / 10, r % 10);
-   } else if (i >= MINSTREL_VHT_GROUP_0) {
+   if (gflags & IEEE80211_TX_RC_MCS) {
+   p += sprintf(p, " MCS%-2u ", (mg->streams - 1) * 8 + j);
+   } else if (gflags & IEEE80211_TX_RC_VHT_MCS) {
p += sprintf(p, " MCS%-1u/%1u", j, mg->streams);
} else {
-   p += sprintf(p, " MCS%-2u ", (mg->streams - 1) * 8 + j);
+   int r = bitrates[j % 4];
+
+   p += sprintf(p, " %2u.%1uM ", r / 10, r % 10);
}
 
tp = mr->cur_tp / 10;
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 0/4] add VHT support to minstrel_ht

2014-10-22 Thread Karl Beldan
On Wed, Oct 22, 2014 at 04:07:31PM +0200, Johannes Berg wrote:
> On Wed, 2014-10-22 at 15:54 +0200, Karl Beldan wrote:
> > On Tue, Oct 21, 2014 at 08:47:26PM +0200, Johannes Berg wrote:
> > > On Tue, 2014-10-21 at 17:26 +0200, Karl Beldan wrote:
> > > 
> > > > I still don't know why I don't see the smatch array warnings here, I
> > > > guess I'll live with that for now.
> > > 
> > > I'm hoping Dan will eventually pick up on it ;-)
> > > 
> > smatch is good, I get your warnings now when unsetting
> > MAC80211_RC_MINSTREL_VHT. I did not click until after checking
> > checking smatch's check_overflow.c, when there's a use after check, it
> > only barks when the indexes checked are out of bounds.
> 
> Wait, are you saying it *is* out of bounds when VHT isn't turned on?
> 

The smatch warning pops on
{
if (!(mi->groups[i].supported & BIT(j)))
continue;
...
else if (i >= MINSTREL_VHT_GROUP_0)
}

MINSTREL_VHT_GROUP_0 is out of bonds (not i which remains <
ARRAY_SIZE(mi->groups)).

 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 0/4] add VHT support to minstrel_ht

2014-10-22 Thread Karl Beldan
On Tue, Oct 21, 2014 at 08:47:26PM +0200, Johannes Berg wrote:
> On Tue, 2014-10-21 at 17:26 +0200, Karl Beldan wrote:
> 
> > I still don't know why I don't see the smatch array warnings here, I
> > guess I'll live with that for now.
> 
> I'm hoping Dan will eventually pick up on it ;-)
> 
smatch is good, I get your warnings now when unsetting
MAC80211_RC_MINSTREL_VHT. I did not click until after checking
checking smatch's check_overflow.c, when there's a use after check, it
only barks when the indexes checked are out of bounds.

As for the false positive, now we can check the flags instead of doing
comparisons on the indexes, it'd be cleaner and spare this warning,
maybe I should send something.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 0/4] add VHT support to minstrel_ht

2014-10-21 Thread Karl Beldan
On Mon, Oct 20, 2014 at 09:33:17PM +0200, Johannes Berg wrote:
> On Mon, 2014-10-20 at 17:34 +0200, Karl Beldan wrote:
> > > Indeed, will resending only 4/4 do ?
> 
> Sure.
> 
> > > >   CHECK   
> > > > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht_debugfs.c
> > > > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht_debugfs.c:47
> > > >  minstrel_ht_stats_dump() error: testing array offset 'i' after use.
> > > > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht_debugfs.c:61
> > > >  minstrel_ht_stats_dump() error: testing array offset 'i' after use.
> > > > 
> > > > Here I'm not sure, seems like it's a false positive maybe? The array
> > > > seems large enough for everything that's going on here.
> > > > 
> > > False positive.
> > > I am using CF="-Wsparse-all" and I don't get those warnings with sparse
> > > 0.4.5, I'll update.
> > > 
> > I don't get those with smatch either .. what options are you using ?
> > Thanks for the pass.
> 
> I'm using smatch git as of today (5167af76ad64) with no special
> arguments. I have a script called "sparse" that does just this:
> 
> sparse-real -Wshadow "$@" || exit 100
> smatch -p=kernel "$@" || exit 200
> 
I still don't know why I don't see the smatch array warnings here, I
guess I'll live with that for now.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 0/4] add VHT support to minstrel_ht

2014-10-21 Thread Karl Beldan
On Mon, Oct 20, 2014 at 09:40:35PM +0200, Johannes Berg wrote:
> On Mon, 2014-10-20 at 21:33 +0200, Johannes Berg wrote:
> > On Mon, 2014-10-20 at 17:34 +0200, Karl Beldan wrote:
> > > > Indeed, will resending only 4/4 do ?
> > 
> > Sure.
> 
> I merged patches 1-3 now.
> 
Thanks.
 
karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-10-21 Thread Karl Beldan
From: Karl Beldan 

When the new CONFIG_MAC80211_RC_MINSTREL_VHT is not set (default 'N'),
there is no behavioral change including in sampling and MCS_GROUP_RATES
remains 8.
Otherwise MCS_GROUP_RATES is 10, and a module parameter *vht_only*
(default 'true'), restricts the rates selection to VHT when vht is
supported.

Regarding the debugfs stats buffer:
It is explicitly increased from 8k to 32k to fit every rates incl. when
both ht and vht rates are enabled, as for the format, before:
type   rate tpt eprob *prob ret  *ok(*cum)ok(  cum)
HT20/LGI ABCDP MCS0 0.0   0.0   0.0   10(   0) 0(0)
after:
 type   rate  tpt eprob *prob ret  *ok(*cum)ok(  cum)
 HT20/LGI ABCDP MCS0  0.0   0.0   0.0   10(   0) 0(0)
VHT40/LGI   MCS5/20.0   0.0   0.0   00(   0) 0(    0)

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---

v2:
- typo in Kconfig
- adjust room in debugfs rc_stats buffer
- add a module param to mix ht rates with vht ones
- default to 3SS instead of 2SS (with "mac80211: minstrel_ht: macros
  adjustments for future VHT_GROUPs")
- use common MINSTREL_MAX_STREAMS both for VHT and HT so that we can get
  rid of the 'MINSTREL_MAX_STREAMS >= 3' checks for minstrel_mcs_groups
v3:
- put module param *vht_only* under CONFIG_MAC80211_RC_MINSTREL_VHT
v4:
- rebase on v2 of "mac80211: minstrels: fix buffer overflow in HT debugfs 
rc_stats"
v5:
- fix some checkpatch complaints this, leaves 2 false positives 
  "ERROR: Macros with complex values should be enclosed in parenthesis"
  in array initialization
v6:
- s/u16/__le16/ addressing Johannes' sparse pass

 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 216 +++--
 net/mac80211/rc80211_minstrel_ht.h |  17 ++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  23 +--
 4 files changed, 241 insertions(+), 22 deletions(-)

diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index aeb6a48..e8049ed 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -33,6 +33,13 @@ config MAC80211_RC_MINSTREL_HT
---help---
  This option enables the 'minstrel_ht' TX rate control algorithm
 
+config MAC80211_RC_MINSTREL_VHT
+   bool "Minstrel 802.11ac support" if EXPERT
+   depends on MAC80211_RC_MINSTREL_HT
+   default n
+   ---help---
+ This option enables vht in the 'minstrel_ht' TX rate control algorithm
+
 choice
prompt "Default rate control algorithm"
depends on MAC80211_HAS_RC
diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index e760d3d..481 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "rate.h"
@@ -36,6 +37,7 @@
 
 #define BW_20  0
 #define BW_40  1
+#define BW_80  2
 
 /*
  * Define group sort order: HT40 -> SGI -> #streams
@@ -66,6 +68,47 @@
}   \
 }
 
+#define VHT_GROUP_IDX(_streams, _sgi, _bw) \
+   (MINSTREL_VHT_GROUP_0 + \
+MINSTREL_MAX_STREAMS * 2 * (_bw) + \
+MINSTREL_MAX_STREAMS * (_sgi) +\
+(_streams) - 1)
+
+#define BW2VBPS(_bw, r3, r2, r1)   \
+   (_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1)
+
+#define VHT_GROUP(_streams, _sgi, _bw) \
+   [VHT_GROUP_IDX(_streams, _sgi, _bw)] = {\
+   .streams = _streams,\
+   .flags =\
+   IEEE80211_TX_RC_VHT_MCS |   \
+   (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \
+   (_bw == BW_80 ? IEEE80211_TX_RC_80_MHZ_WIDTH :  \
+_bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),  \
+   .duration = {   \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw,  117,  54,  26)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw,  234, 108,  52)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw,  351, 162,  78)), \
+   MCS_DURATION(_streams, _sgi,   

Re: [PATCH v5 0/4] add VHT support to minstrel_ht

2014-10-20 Thread Karl Beldan
On Mon, Oct 20, 2014 at 05:13:02PM +0200, Karl Beldan wrote:
> On Mon, Oct 20, 2014 at 04:49:06PM +0200, Johannes Berg wrote:
> > On Mon, 2014-10-20 at 15:45 +0200, Karl Beldan wrote:
> > > From: Karl Beldan 
> > > 
> > > Hi,
> > > 
> > > Varka Bhadram reported checkpatch is noisy on this series.
> > > I made another pass which affects [2/4](trivially) and [4/4].
> > > This could have been a patch on top of what Felix acked, I hope you
> > > won't bother too much.
> > 
> > This series introduces the following new sparse/smatch complaints:
> > 
> >   CHECK   /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c
> > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c:246:18: 
> > warning: cast to restricted __le16
> > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c:1227:49: 
> > warning: incorrect type in argument 3 (different base types)
> > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c:1227:49:
> > expected unsigned short [unsigned] [usertype] mcs_map
> > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c:1227:49:
> > got restricted __le16 [usertype] tx_mcs_map
> > 
> > Here it looks like the argument to minstrel_get_valid_vht_rates() should
> > be declared __le16.
> > 
> Indeed, will resending only 4/4 do ?
> 
> >   CHECK   
> > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht_debugfs.c
> > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht_debugfs.c:47 
> > minstrel_ht_stats_dump() error: testing array offset 'i' after use.
> > /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht_debugfs.c:61 
> > minstrel_ht_stats_dump() error: testing array offset 'i' after use.
> > 
> > Here I'm not sure, seems like it's a false positive maybe? The array
> > seems large enough for everything that's going on here.
> > 
> False positive.
> I am using CF="-Wsparse-all" and I don't get those warnings with sparse
> 0.4.5, I'll update.
> 
I don't get those with smatch either .. what options are you using ?
Thanks for the pass.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v5 0/4] add VHT support to minstrel_ht

2014-10-20 Thread Karl Beldan
On Mon, Oct 20, 2014 at 04:49:06PM +0200, Johannes Berg wrote:
> On Mon, 2014-10-20 at 15:45 +0200, Karl Beldan wrote:
> > From: Karl Beldan 
> > 
> > Hi,
> > 
> > Varka Bhadram reported checkpatch is noisy on this series.
> > I made another pass which affects [2/4](trivially) and [4/4].
> > This could have been a patch on top of what Felix acked, I hope you
> > won't bother too much.
> 
> This series introduces the following new sparse/smatch complaints:
> 
>   CHECK   /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c
> /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c:246:18: 
> warning: cast to restricted __le16
> /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c:1227:49: 
> warning: incorrect type in argument 3 (different base types)
> /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c:1227:49:
> expected unsigned short [unsigned] [usertype] mcs_map
> /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht.c:1227:49:
> got restricted __le16 [usertype] tx_mcs_map
> 
> Here it looks like the argument to minstrel_get_valid_vht_rates() should
> be declared __le16.
> 
Indeed, will resending only 4/4 do ?

>   CHECK   
> /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht_debugfs.c
> /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht_debugfs.c:47 
> minstrel_ht_stats_dump() error: testing array offset 'i' after use.
> /home/johannes/sys/wireless/net/mac80211/rc80211_minstrel_ht_debugfs.c:61 
> minstrel_ht_stats_dump() error: testing array offset 'i' after use.
> 
> Here I'm not sure, seems like it's a false positive maybe? The array
> seems large enough for everything that's going on here.
> 
False positive.
I am using CF="-Wsparse-all" and I don't get those warnings with sparse
0.4.5, I'll update.

 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 4/4] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

When the new CONFIG_MAC80211_RC_MINSTREL_VHT is not set (default 'N'),
there is no behavioral change including in sampling and MCS_GROUP_RATES
remains 8.
Otherwise MCS_GROUP_RATES is 10, and a module parameter *vht_only*
(default 'true'), restricts the rates selection to VHT when vht is
supported.

Regarding the debugfs stats buffer:
It is explicitly increased from 8k to 32k to fit every rates incl. when
both ht and vht rates are enabled, as for the format, before:
type   rate tpt eprob *prob ret  *ok(*cum)ok(  cum)
HT20/LGI ABCDP MCS0 0.0   0.0   0.0   10(   0) 0(0)
after:
 type   rate  tpt eprob *prob ret  *ok(*cum)ok(  cum)
 HT20/LGI ABCDP MCS0  0.0   0.0   0.0   10(   0) 0(0)
VHT40/LGI   MCS5/20.0   0.0   0.0   00(   0) 0(    0)

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 216 +++--
 net/mac80211/rc80211_minstrel_ht.h |  17 ++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  23 +--
 4 files changed, 241 insertions(+), 22 deletions(-)

diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index aeb6a48..e8049ed 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -33,6 +33,13 @@ config MAC80211_RC_MINSTREL_HT
---help---
  This option enables the 'minstrel_ht' TX rate control algorithm
 
+config MAC80211_RC_MINSTREL_VHT
+   bool "Minstrel 802.11ac support" if EXPERT
+   depends on MAC80211_RC_MINSTREL_HT
+   default n
+   ---help---
+ This option enables vht in the 'minstrel_ht' TX rate control algorithm
+
 choice
prompt "Default rate control algorithm"
depends on MAC80211_HAS_RC
diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index e760d3d..bd5acc0 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "rate.h"
@@ -36,6 +37,7 @@
 
 #define BW_20  0
 #define BW_40  1
+#define BW_80  2
 
 /*
  * Define group sort order: HT40 -> SGI -> #streams
@@ -66,6 +68,47 @@
}   \
 }
 
+#define VHT_GROUP_IDX(_streams, _sgi, _bw) \
+   (MINSTREL_VHT_GROUP_0 + \
+MINSTREL_MAX_STREAMS * 2 * (_bw) + \
+MINSTREL_MAX_STREAMS * (_sgi) +\
+(_streams) - 1)
+
+#define BW2VBPS(_bw, r3, r2, r1)   \
+   (_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1)
+
+#define VHT_GROUP(_streams, _sgi, _bw) \
+   [VHT_GROUP_IDX(_streams, _sgi, _bw)] = {\
+   .streams = _streams,\
+   .flags =\
+   IEEE80211_TX_RC_VHT_MCS |   \
+   (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \
+   (_bw == BW_80 ? IEEE80211_TX_RC_80_MHZ_WIDTH :  \
+_bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),  \
+   .duration = {   \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw,  117,  54,  26)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw,  234, 108,  52)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw,  351, 162,  78)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw,  468, 216, 104)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw,  702, 324, 156)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw,  936, 432, 208)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw, 1053, 486, 234)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw, 1170, 540, 260)), \
+   MCS_DURATION(_streams, _sgi,\
+BW2VBPS(_bw, 1404, 648, 312)), \
+   MCS_DURATION(_streams,

[PATCH v5 2/4] mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

No functional change.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 51 +++---
 net/mac80211/rc80211_minstrel_ht.h | 15 +++--
 net/mac80211/rc80211_minstrel_ht_debugfs.c | 10 +++---
 3 files changed, 42 insertions(+), 34 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index ccec718..a48eb76 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -34,12 +34,16 @@
 /* Transmit duration for the raw data part of an average sized packet */
 #define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, 
MCS_NSYMS((streams) * (bps)))
 
+#define BW_20  0
+#define BW_40  1
+
 /*
  * Define group sort order: HT40 -> SGI -> #streams
  */
 #define GROUP_IDX(_streams, _sgi, _ht40)   \
+   MINSTREL_HT_GROUP_0 +   \
MINSTREL_MAX_STREAMS * 2 * _ht40 +  \
-   MINSTREL_MAX_STREAMS * _sgi +   \
+   MINSTREL_MAX_STREAMS * _sgi +   \
_streams - 1
 
 /* MCS rate information for an MCS group */
@@ -76,13 +80,13 @@
CCK_ACK_DURATION(55, _short),   \
CCK_ACK_DURATION(110, _short)
 
-#define CCK_GROUP  \
-   [MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS] = { \
-   .streams = 0,   \
-   .duration = {   \
-   CCK_DURATION_LIST(false),   \
-   CCK_DURATION_LIST(true) \
-   }   \
+#define CCK_GROUP  \
+   [MINSTREL_CCK_GROUP] = {\
+   .streams = 0,   \
+   .duration = {   \
+   CCK_DURATION_LIST(false),   \
+   CCK_DURATION_LIST(true) \
+   }   \
}
 
 /*
@@ -91,38 +95,36 @@
  * use.
  *
  * Sortorder has to be fixed for GROUP_IDX macro to be applicable:
- * HT40 -> SGI -> #streams
+ * BW -> SGI -> #streams
  */
 const struct mcs_group minstrel_mcs_groups[] = {
-   MCS_GROUP(1, 0, 0),
-   MCS_GROUP(2, 0, 0),
+   MCS_GROUP(1, 0, BW_20),
+   MCS_GROUP(2, 0, BW_20),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 0, 0),
+   MCS_GROUP(3, 0, BW_20),
 #endif
 
-   MCS_GROUP(1, 1, 0),
-   MCS_GROUP(2, 1, 0),
+   MCS_GROUP(1, 1, BW_20),
+   MCS_GROUP(2, 1, BW_20),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 1, 0),
+   MCS_GROUP(3, 1, BW_20),
 #endif
 
-   MCS_GROUP(1, 0, 1),
-   MCS_GROUP(2, 0, 1),
+   MCS_GROUP(1, 0, BW_40),
+   MCS_GROUP(2, 0, BW_40),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 0, 1),
+   MCS_GROUP(3, 0, BW_40),
 #endif
 
-   MCS_GROUP(1, 1, 1),
-   MCS_GROUP(2, 1, 1),
+   MCS_GROUP(1, 1, BW_40),
+   MCS_GROUP(2, 1, BW_40),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 1, 1),
+   MCS_GROUP(3, 1, BW_40),
 #endif
 
-   /* must be last */
CCK_GROUP
 };
 
-#define MINSTREL_CCK_GROUP (ARRAY_SIZE(minstrel_mcs_groups) - 1)
 
 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly;
 
@@ -971,8 +973,7 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
if (!sta->ht_cap.ht_supported)
goto use_legacy;
 
-   BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) !=
-   MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS + 1);
+   BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) != MINSTREL_GROUPS_NB);
 
msp->is_ht = true;
memset(mi, 0, sizeof(*mi));
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 8b54e89..e747ac6 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -13,8 +13,17 @@
  * The number of streams can be changed to 2 to reduce code
  * size and memory footprint.
  */
-#define MINSTREL_MAX_STREAMS   3
-#define MINSTREL_STREAM_GROUPS 4
+#define MINSTREL_MAX_STREAMS   3
+#define MINSTREL_HT_STREAM_GROUPS  4 /* BW(=2) * SGI(=2) */
+
+#define MINSTREL_HT_GROUPS_NB  (MINSTREL_MAX_STREAMS * \
+MINSTREL_HT_STREAM_GROUPS)
+#define MINSTREL_CCK_GROUPS_NB 1
+#define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB +\
+MINSTREL_CCK_GROUPS_NB)
+
+#define MINSTREL_HT_GROUP_00
+#define MINSTREL_CCK_GROUP (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)
 
 #define MCS_GROUP_RATES8
 
@@ -80,7 +89,7 @@ struct minstrel_ht_sta {
u8 cck_supported_short;
 
/* MCS rate group info and statistics */
-   s

[PATCH v5 3/4] mac80211: minstrel_ht: include type (cck/ht) in rates flag

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

ATM, we grep cck rates idx with idx / MCS_GROUP_RATES ==
MINSTREL_CCK_GROUP.
Matching neither-cck-non-ht rates could be done by replacing '==' with
'>', however it would be less versatile or explicit.
This will allow to match VHT rates with IEEE80211_TX_RC_VHT_MCS.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index a48eb76..e760d3d 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -51,6 +51,7 @@
[GROUP_IDX(_streams, _sgi, _ht40)] = {  \
.streams = _streams,\
.flags =\
+   IEEE80211_TX_RC_MCS |   \
(_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \
(_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0), \
.duration = {   \
@@ -83,6 +84,7 @@
 #define CCK_GROUP  \
[MINSTREL_CCK_GROUP] = {\
.streams = 0,   \
+   .flags = 0, \
.duration = {   \
CCK_DURATION_LIST(false),   \
CCK_DURATION_LIST(true) \
@@ -716,7 +718,7 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi,
const struct mcs_group *group = &minstrel_mcs_groups[index / 
MCS_GROUP_RATES];
struct minstrel_rate_stats *mr;
u8 idx;
-   u16 flags;
+   u16 flags = group->flags;
 
mr = minstrel_get_ratestats(mi, index);
if (!mr->retry_updated)
@@ -732,13 +734,10 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi,
ratetbl->rate[offset].count_rts = mr->retry_count_rtscts;
}
 
-   if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
+   if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP)
idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
-   flags = 0;
-   } else {
+   else
idx = index % MCS_GROUP_RATES + (group->streams - 1) * 8;
-   flags = IEEE80211_TX_RC_MCS | group->flags;
-   }
 
if (offset > 0) {
ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
@@ -918,13 +917,12 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta 
*sta, void *priv_sta,
if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
rate->idx = mp->cck_rates[idx];
-   rate->flags = 0;
-   return;
+   } else {
+   rate->idx = sample_idx % MCS_GROUP_RATES +
+   (sample_group->streams - 1) * 8;
}
 
-   rate->idx = sample_idx % MCS_GROUP_RATES +
-   (sample_group->streams - 1) * 8;
-   rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
+   rate->flags = sample_group->flags;
 }
 
 static void
@@ -1006,14 +1004,16 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
 
for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
+   u32 gflags = minstrel_mcs_groups[i].flags;
+
mi->groups[i].supported = 0;
if (i == MINSTREL_CCK_GROUP) {
minstrel_ht_update_cck(mp, mi, sband, sta);
continue;
}
 
-   if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_SHORT_GI) {
-   if (minstrel_mcs_groups[i].flags & 
IEEE80211_TX_RC_40_MHZ_WIDTH) {
+   if (gflags & IEEE80211_TX_RC_SHORT_GI) {
+   if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
if (!(sta_cap & IEEE80211_HT_CAP_SGI_40))
continue;
} else {
@@ -1022,7 +1022,7 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
}
}
 
-   if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH 
&&
+   if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH &&
sta->bandwidth < IEEE80211_STA_RX_BW_40)
continue;
 
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 0/4] add VHT support to minstrel_ht

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

Hi,

Varka Bhadram reported checkpatch is noisy on this series.
I made another pass which affects [2/4](trivially) and [4/4].
This could have been a patch on top of what Felix acked, I hope you
won't bother too much.
Thanks for reviewing,

Karl Beldan (4):
  mac80211: minstrel_ht: Increase the range of handled rate indexes
  mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs
  mac80211: minstrel_ht: include type (cck/ht) in rates flag
  mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz
v2:
- typo in Kconfig
- adjust room in debugfs rc_stats buffer
- add a module param to mix ht rates with vht ones
- default to 3SS instead of 2SS (with "mac80211: minstrel_ht: macros
  adjustments for future VHT_GROUPs")
- use common MINSTREL_MAX_STREAMS both for VHT and HT so that we can get
  rid of the 'MINSTREL_MAX_STREAMS >= 3' checks for minstrel_mcs_groups
v3:
- put module param *vht_only* under CONFIG_MAC80211_RC_MINSTREL_VHT
v4:
- rebase on v2 of "mac80211: minstrels: fix buffer overflow in HT debugfs 
rc_stats"
v5:
- fix some checkpatch complaints this, leaves 2 false positives 
  "ERROR: Macros with complex values should be enclosed in parenthesis"
  in array initialization

 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 311 +++--
 net/mac80211/rc80211_minstrel_ht.h |  40 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  33 +--
 4 files changed, 309 insertions(+), 82 deletions(-)

-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 1/4] mac80211: minstrel_ht: Increase the range of handled rate indexes

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

Since 5935839ad735 ("mac80211: improve minstrel_ht rate sorting by
throughput & probability"), the rate indexes are manipulated via u8's
and hence allow for a maximum of 256 mcs_group entries in
minstrel_mcs_groups.

ATM, minstrel_ht advertizes support up to 3HTSS@40MHz, consuming:
8(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)), i.e. 104 entries.

Support for 3VHTSS@80MHz will require:
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)) +
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*3(BW)), i.e. 130 + 180 entries.

This change moves from u8s to u16s where necessary.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 16 
 net/mac80211/rc80211_minstrel_ht.h |  8 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index 17ef54a..ccec718 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -240,8 +240,8 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, 
int rate)
  * MCS groups, CCK rates do not provide aggregation and are therefore at last.
  */
 static void
-minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u8 index,
-  u8 *tp_list)
+minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
+  u16 *tp_list)
 {
int cur_group, cur_idx, cur_thr, cur_prob;
int tmp_group, tmp_idx, tmp_thr, tmp_prob;
@@ -278,7 +278,7 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, 
u8 index,
  * Find and set the topmost probability rate per sta and per group
  */
 static void
-minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u8 index)
+minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
 {
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
@@ -321,8 +321,8 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, 
u8 index)
  */
 static void
 minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
-u8 tmp_mcs_tp_rate[MAX_THR_RATES],
-u8 tmp_cck_tp_rate[MAX_THR_RATES])
+u16 tmp_mcs_tp_rate[MAX_THR_RATES],
+u16 tmp_cck_tp_rate[MAX_THR_RATES])
 {
unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp;
int i;
@@ -386,8 +386,8 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi)
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
int group, i, j;
-   u8 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
-   u8 tmp_cck_tp_rate[MAX_THR_RATES], index;
+   u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
+   u16 tmp_cck_tp_rate[MAX_THR_RATES], index;
 
if (mi->ampdu_packets > 0) {
mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
@@ -517,7 +517,7 @@ minstrel_next_sample_idx(struct minstrel_ht_sta *mi)
 }
 
 static void
-minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u8 *idx, bool primary)
+minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u16 *idx, bool primary)
 {
int group, orig_group;
 
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 01570e0..8b54e89 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -34,8 +34,8 @@ struct minstrel_mcs_group_data {
u8 supported;
 
/* sorted rate set within a MCS group*/
-   u8 max_group_tp_rate[MAX_THR_RATES];
-   u8 max_group_prob_rate;
+   u16 max_group_tp_rate[MAX_THR_RATES];
+   u16 max_group_prob_rate;
 
/* MCS rate statistics */
struct minstrel_rate_stats rates[MCS_GROUP_RATES];
@@ -52,8 +52,8 @@ struct minstrel_ht_sta {
unsigned int avg_ampdu_len;
 
/* overall sorted rate set */
-   u8 max_tp_rate[MAX_THR_RATES];
-   u8 max_prob_rate;
+   u16 max_tp_rate[MAX_THR_RATES];
+   u16 max_prob_rate;
 
/* time of last status update */
unsigned long stats_update;
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 0/4] add VHT support to minstrel_ht

2014-10-20 Thread Karl Beldan
Hi Varka Bhadram,

On Mon, Oct 20, 2014 at 02:31:31PM +0530, Varka Bhadram wrote:
> Hi Karl Beldan,
> 
> On 10/20/2014 02:25 PM, Karl Beldan wrote:
> >From: Karl Beldan 
> >
> >Hi,
> >
> >This is just a respin rebased on v2 of "mac80211: minstrels: fix buffer
> >overflow in HT debugfs" which only affects 4/4.
> >
> >Karl Beldan (4):
> >   mac80211: minstrel_ht: Increase the range of handled rate indexes
> >   mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs
> >   mac80211: minstrel_ht: include type (cck/ht) in rates flag
> >   mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz
> >v2:
> >- typo in Kconfig
> >- adjust room in debugfs rc_stats buffer
> >- add a module param to mix ht rates with vht ones
> >- default to 3SS instead of 2SS (with "mac80211: minstrel_ht: macros
> >   adjustments for future VHT_GROUPs")
> >- use common MINSTREL_MAX_STREAMS both for VHT and HT so that we can get
> >   rid of the 'MINSTREL_MAX_STREAMS >= 3' checks for minstrel_mcs_groups
> >v3:
> >- put module param *vht_only* under CONFIG_MAC80211_RC_MINSTREL_VHT
> >v4:
> >- rebase on v2 of "mac80211: minstrels: fix buffer overflow in HT debugfs 
> >rc_stats"
> >
> >  net/mac80211/Kconfig   |   7 +
> >  net/mac80211/rc80211_minstrel_ht.c | 292 
> > +++--
> >  net/mac80211/rc80211_minstrel_ht.h |  38 +++-
> >  net/mac80211/rc80211_minstrel_ht_debugfs.c |  32 ++--
> >  4 files changed, 290 insertions(+), 79 deletions(-)
> >
> Check patch errors on this series.. run checkpatch.pl on this series.
> 
Same report as previous series.

Except format warnings there are 2
"ERROR: Macros with complex values should be enclosed in parenthesis",
which fit with current style.

However I too think this series can be improved wrt checkpatch report
and I'll send another version, thanks for pointing that out.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v4 0/4] add VHT support to minstrel_ht

2014-10-20 Thread Karl Beldan
Felix, I added your Acks in the patches but git-send-email did not send
them to the Acked-by addresses.
 
Karl

On Mon, Oct 20, 2014 at 10:55:38AM +0200, Karl Beldan wrote:
> From: Karl Beldan 
> 
> Hi,
> 
> This is just a respin rebased on v2 of "mac80211: minstrels: fix buffer
> overflow in HT debugfs" which only affects 4/4.
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/4] mac80211: minstrel_ht: Increase the range of handled rate indexes

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

Since 5935839ad735 ("mac80211: improve minstrel_ht rate sorting by
throughput & probability"), the rate indexes are manipulated via u8's
and hence allow for a maximum of 256 mcs_group entries in
minstrel_mcs_groups.

ATM, minstrel_ht advertizes support up to 3HTSS@40MHz, consuming:
8(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)), i.e. 104 entries.

Support for 3VHTSS@80MHz will require:
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)) +
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*3(BW)), i.e. 130 + 180 entries.

This change moves from u8s to u16s where necessary.

Signed-off-by: Karl Beldan 
Acked-by: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 16 
 net/mac80211/rc80211_minstrel_ht.h |  8 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index 17ef54a..ccec718 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -240,8 +240,8 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, 
int rate)
  * MCS groups, CCK rates do not provide aggregation and are therefore at last.
  */
 static void
-minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u8 index,
-  u8 *tp_list)
+minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
+  u16 *tp_list)
 {
int cur_group, cur_idx, cur_thr, cur_prob;
int tmp_group, tmp_idx, tmp_thr, tmp_prob;
@@ -278,7 +278,7 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, 
u8 index,
  * Find and set the topmost probability rate per sta and per group
  */
 static void
-minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u8 index)
+minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
 {
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
@@ -321,8 +321,8 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, 
u8 index)
  */
 static void
 minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
-u8 tmp_mcs_tp_rate[MAX_THR_RATES],
-u8 tmp_cck_tp_rate[MAX_THR_RATES])
+u16 tmp_mcs_tp_rate[MAX_THR_RATES],
+u16 tmp_cck_tp_rate[MAX_THR_RATES])
 {
unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp;
int i;
@@ -386,8 +386,8 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi)
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
int group, i, j;
-   u8 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
-   u8 tmp_cck_tp_rate[MAX_THR_RATES], index;
+   u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
+   u16 tmp_cck_tp_rate[MAX_THR_RATES], index;
 
if (mi->ampdu_packets > 0) {
mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
@@ -517,7 +517,7 @@ minstrel_next_sample_idx(struct minstrel_ht_sta *mi)
 }
 
 static void
-minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u8 *idx, bool primary)
+minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u16 *idx, bool primary)
 {
int group, orig_group;
 
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 01570e0..8b54e89 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -34,8 +34,8 @@ struct minstrel_mcs_group_data {
u8 supported;
 
/* sorted rate set within a MCS group*/
-   u8 max_group_tp_rate[MAX_THR_RATES];
-   u8 max_group_prob_rate;
+   u16 max_group_tp_rate[MAX_THR_RATES];
+   u16 max_group_prob_rate;
 
/* MCS rate statistics */
struct minstrel_rate_stats rates[MCS_GROUP_RATES];
@@ -52,8 +52,8 @@ struct minstrel_ht_sta {
unsigned int avg_ampdu_len;
 
/* overall sorted rate set */
-   u8 max_tp_rate[MAX_THR_RATES];
-   u8 max_prob_rate;
+   u16 max_tp_rate[MAX_THR_RATES];
+   u16 max_prob_rate;
 
/* time of last status update */
unsigned long stats_update;
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 3/4] mac80211: minstrel_ht: include type (cck/ht) in rates flag

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

ATM, we grep cck rates idx with idx / MCS_GROUP_RATES ==
MINSTREL_CCK_GROUP.
Matching neither-cck-non-ht rates could be done by replacing '==' with
'>', however it would be less versatile or explicit.
This will allow to match VHT rates with IEEE80211_TX_RC_VHT_MCS.

Signed-off-by: Karl Beldan 
Acked-by: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index a48eb76..e760d3d 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -51,6 +51,7 @@
[GROUP_IDX(_streams, _sgi, _ht40)] = {  \
.streams = _streams,\
.flags =\
+   IEEE80211_TX_RC_MCS |   \
(_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \
(_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0), \
.duration = {   \
@@ -83,6 +84,7 @@
 #define CCK_GROUP  \
[MINSTREL_CCK_GROUP] = {\
.streams = 0,   \
+   .flags = 0, \
.duration = {   \
CCK_DURATION_LIST(false),   \
CCK_DURATION_LIST(true) \
@@ -716,7 +718,7 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi,
const struct mcs_group *group = &minstrel_mcs_groups[index / 
MCS_GROUP_RATES];
struct minstrel_rate_stats *mr;
u8 idx;
-   u16 flags;
+   u16 flags = group->flags;
 
mr = minstrel_get_ratestats(mi, index);
if (!mr->retry_updated)
@@ -732,13 +734,10 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi,
ratetbl->rate[offset].count_rts = mr->retry_count_rtscts;
}
 
-   if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
+   if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP)
idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
-   flags = 0;
-   } else {
+   else
idx = index % MCS_GROUP_RATES + (group->streams - 1) * 8;
-   flags = IEEE80211_TX_RC_MCS | group->flags;
-   }
 
if (offset > 0) {
ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
@@ -918,13 +917,12 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta 
*sta, void *priv_sta,
if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
rate->idx = mp->cck_rates[idx];
-   rate->flags = 0;
-   return;
+   } else {
+   rate->idx = sample_idx % MCS_GROUP_RATES +
+   (sample_group->streams - 1) * 8;
}
 
-   rate->idx = sample_idx % MCS_GROUP_RATES +
-   (sample_group->streams - 1) * 8;
-   rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
+   rate->flags = sample_group->flags;
 }
 
 static void
@@ -1006,14 +1004,16 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
 
for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
+   u32 gflags = minstrel_mcs_groups[i].flags;
+
mi->groups[i].supported = 0;
if (i == MINSTREL_CCK_GROUP) {
minstrel_ht_update_cck(mp, mi, sband, sta);
continue;
}
 
-   if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_SHORT_GI) {
-   if (minstrel_mcs_groups[i].flags & 
IEEE80211_TX_RC_40_MHZ_WIDTH) {
+   if (gflags & IEEE80211_TX_RC_SHORT_GI) {
+   if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
if (!(sta_cap & IEEE80211_HT_CAP_SGI_40))
continue;
} else {
@@ -1022,7 +1022,7 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
}
}
 
-   if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH 
&&
+   if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH &&
sta->bandwidth < IEEE80211_STA_RX_BW_40)
continue;
 
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 0/4] add VHT support to minstrel_ht

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

Hi,

This is just a respin rebased on v2 of "mac80211: minstrels: fix buffer
overflow in HT debugfs" which only affects 4/4.

Karl Beldan (4):
  mac80211: minstrel_ht: Increase the range of handled rate indexes
  mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs
  mac80211: minstrel_ht: include type (cck/ht) in rates flag
  mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz
v2:
- typo in Kconfig
- adjust room in debugfs rc_stats buffer
- add a module param to mix ht rates with vht ones
- default to 3SS instead of 2SS (with "mac80211: minstrel_ht: macros
  adjustments for future VHT_GROUPs")
- use common MINSTREL_MAX_STREAMS both for VHT and HT so that we can get
  rid of the 'MINSTREL_MAX_STREAMS >= 3' checks for minstrel_mcs_groups
v3:
- put module param *vht_only* under CONFIG_MAC80211_RC_MINSTREL_VHT
v4:
- rebase on v2 of "mac80211: minstrels: fix buffer overflow in HT debugfs 
rc_stats"

 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 292 +++--
 net/mac80211/rc80211_minstrel_ht.h |  38 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  32 ++--
 4 files changed, 290 insertions(+), 79 deletions(-)

-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 2/4] mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

No functional change.

Signed-off-by: Karl Beldan 
Acked-by: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 51 +++---
 net/mac80211/rc80211_minstrel_ht.h | 14 ++--
 net/mac80211/rc80211_minstrel_ht_debugfs.c | 10 +++---
 3 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index ccec718..a48eb76 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -34,12 +34,16 @@
 /* Transmit duration for the raw data part of an average sized packet */
 #define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, 
MCS_NSYMS((streams) * (bps)))
 
+#define BW_20  0
+#define BW_40  1
+
 /*
  * Define group sort order: HT40 -> SGI -> #streams
  */
 #define GROUP_IDX(_streams, _sgi, _ht40)   \
+   MINSTREL_HT_GROUP_0 +   \
MINSTREL_MAX_STREAMS * 2 * _ht40 +  \
-   MINSTREL_MAX_STREAMS * _sgi +   \
+   MINSTREL_MAX_STREAMS * _sgi +   \
_streams - 1
 
 /* MCS rate information for an MCS group */
@@ -76,13 +80,13 @@
CCK_ACK_DURATION(55, _short),   \
CCK_ACK_DURATION(110, _short)
 
-#define CCK_GROUP  \
-   [MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS] = { \
-   .streams = 0,   \
-   .duration = {   \
-   CCK_DURATION_LIST(false),   \
-   CCK_DURATION_LIST(true) \
-   }   \
+#define CCK_GROUP  \
+   [MINSTREL_CCK_GROUP] = {\
+   .streams = 0,   \
+   .duration = {   \
+   CCK_DURATION_LIST(false),   \
+   CCK_DURATION_LIST(true) \
+   }   \
}
 
 /*
@@ -91,38 +95,36 @@
  * use.
  *
  * Sortorder has to be fixed for GROUP_IDX macro to be applicable:
- * HT40 -> SGI -> #streams
+ * BW -> SGI -> #streams
  */
 const struct mcs_group minstrel_mcs_groups[] = {
-   MCS_GROUP(1, 0, 0),
-   MCS_GROUP(2, 0, 0),
+   MCS_GROUP(1, 0, BW_20),
+   MCS_GROUP(2, 0, BW_20),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 0, 0),
+   MCS_GROUP(3, 0, BW_20),
 #endif
 
-   MCS_GROUP(1, 1, 0),
-   MCS_GROUP(2, 1, 0),
+   MCS_GROUP(1, 1, BW_20),
+   MCS_GROUP(2, 1, BW_20),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 1, 0),
+   MCS_GROUP(3, 1, BW_20),
 #endif
 
-   MCS_GROUP(1, 0, 1),
-   MCS_GROUP(2, 0, 1),
+   MCS_GROUP(1, 0, BW_40),
+   MCS_GROUP(2, 0, BW_40),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 0, 1),
+   MCS_GROUP(3, 0, BW_40),
 #endif
 
-   MCS_GROUP(1, 1, 1),
-   MCS_GROUP(2, 1, 1),
+   MCS_GROUP(1, 1, BW_40),
+   MCS_GROUP(2, 1, BW_40),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 1, 1),
+   MCS_GROUP(3, 1, BW_40),
 #endif
 
-   /* must be last */
CCK_GROUP
 };
 
-#define MINSTREL_CCK_GROUP (ARRAY_SIZE(minstrel_mcs_groups) - 1)
 
 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly;
 
@@ -971,8 +973,7 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
if (!sta->ht_cap.ht_supported)
goto use_legacy;
 
-   BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) !=
-   MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS + 1);
+   BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) != MINSTREL_GROUPS_NB);
 
msp->is_ht = true;
memset(mi, 0, sizeof(*mi));
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 8b54e89..7b46592 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -13,8 +13,16 @@
  * The number of streams can be changed to 2 to reduce code
  * size and memory footprint.
  */
-#define MINSTREL_MAX_STREAMS   3
-#define MINSTREL_STREAM_GROUPS 4
+#define MINSTREL_MAX_STREAMS   3
+#define MINSTREL_HT_STREAM_GROUPS  4 /* BW(=2) * SGI(=2) */
+
+#define MINSTREL_HT_GROUPS_NB  (MINSTREL_MAX_STREAMS * 
MINSTREL_HT_STREAM_GROUPS)
+#define MINSTREL_CCK_GROUPS_NB 1
+#define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB +\
+MINSTREL_CCK_GROUPS_NB)
+
+#define MINSTREL_HT_GROUP_00
+#define MINSTREL_CCK_GROUP (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)
 
 #define MCS_GROUP_RATES8
 
@@ -80,7 +88,7 @@ struct minstrel_ht_sta {
u8 cck_supported_short;
 
/* MCS rate group info and statistics */
-   struct minstrel_mcs_gr

[PATCH v4 4/4] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

When the new CONFIG_MAC80211_RC_MINSTREL_VHT is not set (default 'N'),
there is no behavioral change including in sampling and MCS_GROUP_RATES
remains 8.
Otherwise MCS_GROUP_RATES is 10, and a module parameter *vht_only*
(default 'true'), restricts the rates selection to VHT when vht is
supported.

Regarding the debugfs stats buffer:
It is explicitly increased from 8k to 32k to fit every rates incl. when
both ht and vht rates are enabled, as for the format, before:
type   rate tpt eprob *prob ret  *ok(*cum)ok(  cum)
HT20/LGI ABCDP MCS0 0.0   0.0   0.0   10(   0) 0(0)
after:
 type   rate  tpt eprob *prob ret  *ok(*cum)ok(  cum)
 HT20/LGI ABCDP MCS0  0.0   0.0   0.0   10(   0) 0(0)
VHT40/LGI   MCS5/20.0   0.0   0.0   00(   0) 0(    0)

Signed-off-by: Karl Beldan 
Acked-by: Felix Fietkau 
---
 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 197 +++--
 net/mac80211/rc80211_minstrel_ht.h |  16 ++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  22 +++-
 4 files changed, 223 insertions(+), 19 deletions(-)

diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index aeb6a48..e8049ed 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -33,6 +33,13 @@ config MAC80211_RC_MINSTREL_HT
---help---
  This option enables the 'minstrel_ht' TX rate control algorithm
 
+config MAC80211_RC_MINSTREL_VHT
+   bool "Minstrel 802.11ac support" if EXPERT
+   depends on MAC80211_RC_MINSTREL_HT
+   default n
+   ---help---
+ This option enables vht in the 'minstrel_ht' TX rate control algorithm
+
 choice
prompt "Default rate control algorithm"
depends on MAC80211_HAS_RC
diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index e760d3d..772cff9 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "rate.h"
@@ -36,6 +37,7 @@
 
 #define BW_20  0
 #define BW_40  1
+#define BW_80  2
 
 /*
  * Define group sort order: HT40 -> SGI -> #streams
@@ -66,6 +68,37 @@
}   \
 }
 
+#define VHT_GROUP_IDX(_streams, _sgi, _bw) \
+   (MINSTREL_VHT_GROUP_0 + \
+MINSTREL_MAX_STREAMS * 2 * (_bw) + \
+MINSTREL_MAX_STREAMS * (_sgi) +\
+(_streams) - 1)
+
+#define BW2VBPS(_bw, r3, r2, r1)   
\
+   (_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1)
+
+#define VHT_GROUP(_streams, _sgi, _bw) 
\
+   [VHT_GROUP_IDX(_streams, _sgi, _bw)] = {
\
+   .streams = _streams,
\
+   .flags =
\
+   IEEE80211_TX_RC_VHT_MCS |   
\
+   (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | 
\
+   (_bw == BW_80 ? IEEE80211_TX_RC_80_MHZ_WIDTH :  
\
+_bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),  
\
+   .duration = {   
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  117,  54,  26)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  234, 108,  52)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  351, 162,  78)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  468, 216, 104)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  702, 324, 156)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  936, 432, 208)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1053, 486, 234)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1170, 540, 260)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1404, 648, 312)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1560, 720, 346))  
\
+   }   
\
+}
+
 #define CCK_DURATION(_bitrate, _short, _len)   \
(1000 * (10 /* SIFS */ +\
 (_short ? 72 + 24 : 144 + 48) +\
@@ -91,6 +124,12 @@
}   \
}
 
+#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT
+static bool minstrel_vht_only = true;
+module_param(minstrel_vht_only, bool,

[PATCH v2] mac80211: minstrels: fix buffer overflow in HT debugfs rc_stats

2014-10-20 Thread Karl Beldan
From: Karl Beldan 

ATM an HT rc_stats line is 106 chars.
Times 8(MCS_GROUP_RATES)*3(SS)*2(GI)*2(BW) + CCK(4), i.e. x100, this is
well above the current 8192 - sizeof(*ms) currently allocated.

Fix this by squeezing the output as follows (not that we're short on
memory but this also improves readability and range, the new format adds
one more digit to *ok/*cum and ok/cum):

- Before (HT) (106 ch):
type   rate throughput  ewma prob   this prob  retry   this 
succ/attempt   successattempts
CCK/LP  5.5M   0.00.0 0.0  0  
0(  0) 0   0
HT20/LGI ABCDP MCS00.00.0 0.0  1  
0(  0) 0   0
- After (75 ch):
type   rate tpt eprob *prob ret  *ok(*cum)ok(  cum)
CCK/LP  5.5M0.0   0.0   0.0   00(   0) 0(0)
HT20/LGI ABCDP MCS0 0.0   0.0   0.0   10(   0) 0(0)

- Align non-HT format Before (non-HT) (83 ch):
rate  throughput  ewma prob  this prob  this succ/attempt   success
attempts
ABCDP  6 0.00.00.0 0(  0) 0 
  0
  54 0.00.00.0 0(  0) 0 
  0
- After (61 ch):
rate  tpt eprob *prob  *ok(*cum)ok(  cum)
ABCDP  1  0.0   0.0   0.00(   0) 0(0)
  54  0.0   0.0   0.00(   0) 0(0)

*This also adds dynamic checks for overflow, lowers the size of the
non-HT request (allowing > 30 entries) and replaces the buddy-rounded
allocations (s/sizeof(*ms) + 8192/8192).

Signed-off-by: Karl Beldan 
Acked-by: Felix Fietkau 
---

v2:
- s/WARN_ON(ms->len > X - sizeof(*ms))/WARN_ON(ms->len + sizeof(*ms) > X)/

 net/mac80211/rc80211_minstrel_debugfs.c| 12 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c | 13 -
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_debugfs.c 
b/net/mac80211/rc80211_minstrel_debugfs.c
index edde723..2acab1b 100644
--- a/net/mac80211/rc80211_minstrel_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_debugfs.c
@@ -62,14 +62,14 @@ minstrel_stats_open(struct inode *inode, struct file *file)
unsigned int i, tp, prob, eprob;
char *p;
 
-   ms = kmalloc(sizeof(*ms) + 4096, GFP_KERNEL);
+   ms = kmalloc(2048, GFP_KERNEL);
if (!ms)
return -ENOMEM;
 
file->private_data = ms;
p = ms->buf;
-   p += sprintf(p, "rate  throughput  ewma prob  this prob  "
-   "this succ/attempt   successattempts\n");
+   p += sprintf(p, "rate  tpt eprob *prob"
+   "  *ok(*cum)ok(  cum)\n");
for (i = 0; i < mi->n_rates; i++) {
struct minstrel_rate *mr = &mi->r[i];
struct minstrel_rate_stats *mrs = &mi->r[i].stats;
@@ -86,8 +86,8 @@ minstrel_stats_open(struct inode *inode, struct file *file)
prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
eprob = MINSTREL_TRUNC(mrs->probability * 1000);
 
-   p += sprintf(p, "  %6u.%1u   %6u.%1u   %6u.%1u"
-   "   %3u(%3u)  %8llu%8llu\n",
+   p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u"
+   " %4u(%4u) %9llu(%9llu)\n",
tp / 10, tp % 10,
eprob / 10, eprob % 10,
prob / 10, prob % 10,
@@ -102,6 +102,8 @@ minstrel_stats_open(struct inode *inode, struct file *file)
mi->sample_packets);
ms->len = p - ms->buf;
 
+   WARN_ON(ms->len + sizeof(*ms) > 2048);
+
return 0;
 }
 
diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c 
b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index a72ad46..d537bec 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -63,8 +63,8 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, 
char *p)
prob = MINSTREL_TRUNC(mr->cur_prob * 1000);
eprob = MINSTREL_TRUNC(mr->probability * 1000);
 
-   p += sprintf(p, "  %6u.%1u   %6u.%1u%6u.%1u"
-   "%3u%3u(%3u)  %8llu%8llu\n",
+   p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u "
+   "%3u %4u(%4u) %9llu(%9llu)\n",
tp / 10, tp % 10,
eprob / 10, eprob % 10,
prob / 10, prob % 10,
@@ -96,14 +96,15 @@ minstrel_ht_stats_open(struct inode *inode, struct file 
*file)
return ret;
}
 

Re: [PATCH] mac80211: minstrels: fix buffer overflow in HT debugfs rc_stats

2014-10-19 Thread Karl Beldan
Hi,

If that's not too late I'd like to fix some coding style, replace:

On Fri, Oct 17, 2014 at 08:34:00PM +0200, Karl Beldan wrote:
> From: Karl Beldan 
> @@ -102,6 +102,8 @@ minstrel_stats_open(struct inode *inode, struct file 
> *file)
>   mi->sample_packets);
>   ms->len = p - ms->buf;
>  
> + WARN_ON(ms->len > 2048 - sizeof(*ms));

with:
WARN_ON(ms->len + sizeof(*ms) > 2048);
and,

> @@ -118,6 +119,8 @@ minstrel_ht_stats_open(struct inode *inode, struct file 
> *file)
>   MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
>   ms->len = p - ms->buf;
>  
> + WARN_ON(ms->len > 8192 - sizeof(*ms));

with:
WARN_ON(ms->len + sizeof(*ms) > 8192);

This would require rebasing "[PATCH v3 4/4] mac80211: minstrel_ht: add
basic support for VHT rates <= 3SS@80MHz", and send 

[PATCH v2] mac80211: minstrels: fix buffer overflow in HT debugfs
[PATCH v4 1/4] mac80211: minstrel_ht: Increase the range of handled
[PATCH v4 2/4] mac80211: minstrel_ht: macros adjustments for future
[PATCH v4 3/4] mac80211: minstrel_ht: include type (cck/ht) in rates
[PATCH v4 4/4] mac80211: minstrel_ht: add basic support for VHT rates

Is it ok ?
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/4] add VHT support to minstrel_ht

2014-10-18 Thread Karl Beldan
On Sat, Oct 18, 2014 at 11:11:48PM +0530, Krishna Chaitanya wrote:
> On Sat, Oct 18, 2014 at 10:43 PM, Karl Beldan  wrote:
> >
> > From: Karl Beldan 
> >
> >
> > Karl Beldan (4):
> >   mac80211: minstrel_ht: Increase the range of handled rate indexes
> >   mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs
> >   mac80211: minstrel_ht: include type (cck/ht) in rates flag
> >   mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz
> > v2:
> > - typo in Kconfig
> > - adjust room in debugfs rc_stats buffer
> > - add a module param to mix ht rates with vht ones
> > - default to 3SS instead of 2SS (with "mac80211: minstrel_ht: macros
> >   adjustments for future VHT_GROUPs")
> > - use common MINSTREL_MAX_STREAMS both for VHT and HT so that we can get
> >   rid of the 'MINSTREL_MAX_STREAMS >= 3' checks for minstrel_mcs_groups
> > v3:
> > - put module param *vht_only* under CONFIG_MAC80211_RC_MINSTREL_VHT
> >
> >  net/mac80211/Kconfig   |   7 +
> >  net/mac80211/rc80211_minstrel_ht.c | 292 
> > +++--
> >  net/mac80211/rc80211_minstrel_ht.h |  38 +++-
> >  net/mac80211/rc80211_minstrel_ht_debugfs.c |  32 ++--
> >  4 files changed, 290 insertions(+), 79 deletions(-)
> >
> > --
> >
> We have been using you patches for some time and they do the work well.
> Except for the sampling holes, where we were needed to add some
> supported checks.
Maybe you missed f12140c "mac80211: minstrel_ht: do not sample
unsupported rates"? I posted it about the same time as the vht rfc a
year ago. Thanks for the feedback.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/4] mac80211: minstrel_ht: Increase the range of handled rate indexes

2014-10-18 Thread Karl Beldan
From: Karl Beldan 

Since 5935839ad735 ("mac80211: improve minstrel_ht rate sorting by
throughput & probability"), the rate indexes are manipulated via u8's
and hence allow for a maximum of 256 mcs_group entries in
minstrel_mcs_groups.

ATM, minstrel_ht advertizes support up to 3HTSS@40MHz, consuming:
8(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)), i.e. 104 entries.

Support for 3VHTSS@80MHz will require:
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)) +
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*3(BW)), i.e. 130 + 180 entries.

This change moves from u8s to u16s where necessary.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 16 
 net/mac80211/rc80211_minstrel_ht.h |  8 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index 17ef54a..ccec718 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -240,8 +240,8 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, 
int rate)
  * MCS groups, CCK rates do not provide aggregation and are therefore at last.
  */
 static void
-minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u8 index,
-  u8 *tp_list)
+minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
+  u16 *tp_list)
 {
int cur_group, cur_idx, cur_thr, cur_prob;
int tmp_group, tmp_idx, tmp_thr, tmp_prob;
@@ -278,7 +278,7 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, 
u8 index,
  * Find and set the topmost probability rate per sta and per group
  */
 static void
-minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u8 index)
+minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
 {
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
@@ -321,8 +321,8 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, 
u8 index)
  */
 static void
 minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
-u8 tmp_mcs_tp_rate[MAX_THR_RATES],
-u8 tmp_cck_tp_rate[MAX_THR_RATES])
+u16 tmp_mcs_tp_rate[MAX_THR_RATES],
+u16 tmp_cck_tp_rate[MAX_THR_RATES])
 {
unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp;
int i;
@@ -386,8 +386,8 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi)
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
int group, i, j;
-   u8 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
-   u8 tmp_cck_tp_rate[MAX_THR_RATES], index;
+   u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
+   u16 tmp_cck_tp_rate[MAX_THR_RATES], index;
 
if (mi->ampdu_packets > 0) {
mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
@@ -517,7 +517,7 @@ minstrel_next_sample_idx(struct minstrel_ht_sta *mi)
 }
 
 static void
-minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u8 *idx, bool primary)
+minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u16 *idx, bool primary)
 {
int group, orig_group;
 
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 01570e0..8b54e89 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -34,8 +34,8 @@ struct minstrel_mcs_group_data {
u8 supported;
 
/* sorted rate set within a MCS group*/
-   u8 max_group_tp_rate[MAX_THR_RATES];
-   u8 max_group_prob_rate;
+   u16 max_group_tp_rate[MAX_THR_RATES];
+   u16 max_group_prob_rate;
 
/* MCS rate statistics */
struct minstrel_rate_stats rates[MCS_GROUP_RATES];
@@ -52,8 +52,8 @@ struct minstrel_ht_sta {
unsigned int avg_ampdu_len;
 
/* overall sorted rate set */
-   u8 max_tp_rate[MAX_THR_RATES];
-   u8 max_prob_rate;
+   u16 max_tp_rate[MAX_THR_RATES];
+   u16 max_prob_rate;
 
/* time of last status update */
unsigned long stats_update;
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/4] mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs

2014-10-18 Thread Karl Beldan
From: Karl Beldan 

No functional change.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 51 +++---
 net/mac80211/rc80211_minstrel_ht.h | 14 ++--
 net/mac80211/rc80211_minstrel_ht_debugfs.c | 10 +++---
 3 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index ccec718..a48eb76 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -34,12 +34,16 @@
 /* Transmit duration for the raw data part of an average sized packet */
 #define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, 
MCS_NSYMS((streams) * (bps)))
 
+#define BW_20  0
+#define BW_40  1
+
 /*
  * Define group sort order: HT40 -> SGI -> #streams
  */
 #define GROUP_IDX(_streams, _sgi, _ht40)   \
+   MINSTREL_HT_GROUP_0 +   \
MINSTREL_MAX_STREAMS * 2 * _ht40 +  \
-   MINSTREL_MAX_STREAMS * _sgi +   \
+   MINSTREL_MAX_STREAMS * _sgi +   \
_streams - 1
 
 /* MCS rate information for an MCS group */
@@ -76,13 +80,13 @@
CCK_ACK_DURATION(55, _short),   \
CCK_ACK_DURATION(110, _short)
 
-#define CCK_GROUP  \
-   [MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS] = { \
-   .streams = 0,   \
-   .duration = {   \
-   CCK_DURATION_LIST(false),   \
-   CCK_DURATION_LIST(true) \
-   }   \
+#define CCK_GROUP  \
+   [MINSTREL_CCK_GROUP] = {\
+   .streams = 0,   \
+   .duration = {   \
+   CCK_DURATION_LIST(false),   \
+   CCK_DURATION_LIST(true) \
+   }   \
}
 
 /*
@@ -91,38 +95,36 @@
  * use.
  *
  * Sortorder has to be fixed for GROUP_IDX macro to be applicable:
- * HT40 -> SGI -> #streams
+ * BW -> SGI -> #streams
  */
 const struct mcs_group minstrel_mcs_groups[] = {
-   MCS_GROUP(1, 0, 0),
-   MCS_GROUP(2, 0, 0),
+   MCS_GROUP(1, 0, BW_20),
+   MCS_GROUP(2, 0, BW_20),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 0, 0),
+   MCS_GROUP(3, 0, BW_20),
 #endif
 
-   MCS_GROUP(1, 1, 0),
-   MCS_GROUP(2, 1, 0),
+   MCS_GROUP(1, 1, BW_20),
+   MCS_GROUP(2, 1, BW_20),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 1, 0),
+   MCS_GROUP(3, 1, BW_20),
 #endif
 
-   MCS_GROUP(1, 0, 1),
-   MCS_GROUP(2, 0, 1),
+   MCS_GROUP(1, 0, BW_40),
+   MCS_GROUP(2, 0, BW_40),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 0, 1),
+   MCS_GROUP(3, 0, BW_40),
 #endif
 
-   MCS_GROUP(1, 1, 1),
-   MCS_GROUP(2, 1, 1),
+   MCS_GROUP(1, 1, BW_40),
+   MCS_GROUP(2, 1, BW_40),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 1, 1),
+   MCS_GROUP(3, 1, BW_40),
 #endif
 
-   /* must be last */
CCK_GROUP
 };
 
-#define MINSTREL_CCK_GROUP (ARRAY_SIZE(minstrel_mcs_groups) - 1)
 
 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly;
 
@@ -971,8 +973,7 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
if (!sta->ht_cap.ht_supported)
goto use_legacy;
 
-   BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) !=
-   MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS + 1);
+   BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) != MINSTREL_GROUPS_NB);
 
msp->is_ht = true;
memset(mi, 0, sizeof(*mi));
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 8b54e89..7b46592 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -13,8 +13,16 @@
  * The number of streams can be changed to 2 to reduce code
  * size and memory footprint.
  */
-#define MINSTREL_MAX_STREAMS   3
-#define MINSTREL_STREAM_GROUPS 4
+#define MINSTREL_MAX_STREAMS   3
+#define MINSTREL_HT_STREAM_GROUPS  4 /* BW(=2) * SGI(=2) */
+
+#define MINSTREL_HT_GROUPS_NB  (MINSTREL_MAX_STREAMS * 
MINSTREL_HT_STREAM_GROUPS)
+#define MINSTREL_CCK_GROUPS_NB 1
+#define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB +\
+MINSTREL_CCK_GROUPS_NB)
+
+#define MINSTREL_HT_GROUP_00
+#define MINSTREL_CCK_GROUP (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)
 
 #define MCS_GROUP_RATES8
 
@@ -80,7 +88,7 @@ struct minstrel_ht_sta {
u8 cck_supported_short;
 
/* MCS rate group info and statistics */
-   struct minstrel_mcs_gr

[PATCH v3 4/4] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-10-18 Thread Karl Beldan
From: Karl Beldan 

When the new CONFIG_MAC80211_RC_MINSTREL_VHT is not set (default 'N'),
there is no behavioral change including in sampling and MCS_GROUP_RATES
remains 8.
Otherwise MCS_GROUP_RATES is 10, and a module parameter *vht_only*
(default 'true'), restricts the rates selection to VHT when vht is
supported.

Regarding the debugfs stats buffer:
It is explicitly increased from 8k to 32k to fit every rates incl. when
both ht and vht rates are enabled, as for the format, before:
type   rate tpt eprob *prob ret  *ok(*cum)ok(  cum)
HT20/LGI ABCDP MCS0 0.0   0.0   0.0   10(   0) 0(0)
after:
 type   rate  tpt eprob *prob ret  *ok(*cum)ok(  cum)
 HT20/LGI ABCDP MCS0  0.0   0.0   0.0   10(   0) 0(0)
VHT40/LGI   MCS5/20.0   0.0   0.0   00(   0) 0(    0)

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 197 +++--
 net/mac80211/rc80211_minstrel_ht.h |  16 ++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  22 +++-
 4 files changed, 223 insertions(+), 19 deletions(-)

diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index aeb6a48..e8049ed 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -33,6 +33,13 @@ config MAC80211_RC_MINSTREL_HT
---help---
  This option enables the 'minstrel_ht' TX rate control algorithm
 
+config MAC80211_RC_MINSTREL_VHT
+   bool "Minstrel 802.11ac support" if EXPERT
+   depends on MAC80211_RC_MINSTREL_HT
+   default n
+   ---help---
+ This option enables vht in the 'minstrel_ht' TX rate control algorithm
+
 choice
prompt "Default rate control algorithm"
depends on MAC80211_HAS_RC
diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index e760d3d..772cff9 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "rate.h"
@@ -36,6 +37,7 @@
 
 #define BW_20  0
 #define BW_40  1
+#define BW_80  2
 
 /*
  * Define group sort order: HT40 -> SGI -> #streams
@@ -66,6 +68,37 @@
}   \
 }
 
+#define VHT_GROUP_IDX(_streams, _sgi, _bw) \
+   (MINSTREL_VHT_GROUP_0 + \
+MINSTREL_MAX_STREAMS * 2 * (_bw) + \
+MINSTREL_MAX_STREAMS * (_sgi) +\
+(_streams) - 1)
+
+#define BW2VBPS(_bw, r3, r2, r1)   
\
+   (_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1)
+
+#define VHT_GROUP(_streams, _sgi, _bw) 
\
+   [VHT_GROUP_IDX(_streams, _sgi, _bw)] = {
\
+   .streams = _streams,
\
+   .flags =
\
+   IEEE80211_TX_RC_VHT_MCS |   
\
+   (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | 
\
+   (_bw == BW_80 ? IEEE80211_TX_RC_80_MHZ_WIDTH :  
\
+_bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),  
\
+   .duration = {   
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  117,  54,  26)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  234, 108,  52)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  351, 162,  78)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  468, 216, 104)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  702, 324, 156)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  936, 432, 208)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1053, 486, 234)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1170, 540, 260)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1404, 648, 312)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1560, 720, 346))  
\
+   }   
\
+}
+
 #define CCK_DURATION(_bitrate, _short, _len)   \
(1000 * (10 /* SIFS */ +\
 (_short ? 72 + 24 : 144 + 48) +\
@@ -91,6 +124,12 @@
}   \
}
 
+#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT
+static bool minstrel_vht_only = true;
+module_param(minstrel_vht_only, bool, 0644);
+M

[PATCH v3 0/4] add VHT support to minstrel_ht

2014-10-18 Thread Karl Beldan
From: Karl Beldan 


Karl Beldan (4):
  mac80211: minstrel_ht: Increase the range of handled rate indexes
  mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs
  mac80211: minstrel_ht: include type (cck/ht) in rates flag
  mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz
v2:
- typo in Kconfig
- adjust room in debugfs rc_stats buffer
- add a module param to mix ht rates with vht ones
- default to 3SS instead of 2SS (with "mac80211: minstrel_ht: macros
  adjustments for future VHT_GROUPs")
- use common MINSTREL_MAX_STREAMS both for VHT and HT so that we can get
  rid of the 'MINSTREL_MAX_STREAMS >= 3' checks for minstrel_mcs_groups
v3:
- put module param *vht_only* under CONFIG_MAC80211_RC_MINSTREL_VHT

 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 292 +++--
 net/mac80211/rc80211_minstrel_ht.h |  38 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  32 ++--
 4 files changed, 290 insertions(+), 79 deletions(-)

-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/4] mac80211: minstrel_ht: include type (cck/ht) in rates flag

2014-10-18 Thread Karl Beldan
From: Karl Beldan 

ATM, we grep cck rates idx with idx / MCS_GROUP_RATES ==
MINSTREL_CCK_GROUP.
Matching neither-cck-non-ht rates could be done by replacing '==' with
'>', however it would be less versatile or explicit.
This will allow to match VHT rates with IEEE80211_TX_RC_VHT_MCS.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index a48eb76..e760d3d 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -51,6 +51,7 @@
[GROUP_IDX(_streams, _sgi, _ht40)] = {  \
.streams = _streams,\
.flags =\
+   IEEE80211_TX_RC_MCS |   \
(_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \
(_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0), \
.duration = {   \
@@ -83,6 +84,7 @@
 #define CCK_GROUP  \
[MINSTREL_CCK_GROUP] = {\
.streams = 0,   \
+   .flags = 0, \
.duration = {   \
CCK_DURATION_LIST(false),   \
CCK_DURATION_LIST(true) \
@@ -716,7 +718,7 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi,
const struct mcs_group *group = &minstrel_mcs_groups[index / 
MCS_GROUP_RATES];
struct minstrel_rate_stats *mr;
u8 idx;
-   u16 flags;
+   u16 flags = group->flags;
 
mr = minstrel_get_ratestats(mi, index);
if (!mr->retry_updated)
@@ -732,13 +734,10 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi,
ratetbl->rate[offset].count_rts = mr->retry_count_rtscts;
}
 
-   if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
+   if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP)
idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
-   flags = 0;
-   } else {
+   else
idx = index % MCS_GROUP_RATES + (group->streams - 1) * 8;
-   flags = IEEE80211_TX_RC_MCS | group->flags;
-   }
 
if (offset > 0) {
ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
@@ -918,13 +917,12 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta 
*sta, void *priv_sta,
if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
rate->idx = mp->cck_rates[idx];
-   rate->flags = 0;
-   return;
+   } else {
+   rate->idx = sample_idx % MCS_GROUP_RATES +
+   (sample_group->streams - 1) * 8;
}
 
-   rate->idx = sample_idx % MCS_GROUP_RATES +
-   (sample_group->streams - 1) * 8;
-   rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
+   rate->flags = sample_group->flags;
 }
 
 static void
@@ -1006,14 +1004,16 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
 
for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
+   u32 gflags = minstrel_mcs_groups[i].flags;
+
mi->groups[i].supported = 0;
if (i == MINSTREL_CCK_GROUP) {
minstrel_ht_update_cck(mp, mi, sband, sta);
continue;
}
 
-   if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_SHORT_GI) {
-   if (minstrel_mcs_groups[i].flags & 
IEEE80211_TX_RC_40_MHZ_WIDTH) {
+   if (gflags & IEEE80211_TX_RC_SHORT_GI) {
+   if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
if (!(sta_cap & IEEE80211_HT_CAP_SGI_40))
continue;
} else {
@@ -1022,7 +1022,7 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
}
}
 
-   if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH 
&&
+   if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH &&
sta->bandwidth < IEEE80211_STA_RX_BW_40)
continue;
 
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH v2 4/4] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-10-18 Thread Karl Beldan
In v3 the moduleparam minstrel_vht_only should go under
CONFIG_MAC80211_RC_MINSTREL_VHT.

On Fri, Oct 17, 2014 at 09:50:59PM +0200, Karl Beldan wrote:
> @@ -91,6 +124,10 @@
>   }   \
>   }
>  
> +static bool minstrel_vht_only = true;
> +module_param(minstrel_vht_only, bool, 0644);
> +MODULE_PARM_DESC(minstrel_vht_only, "Use only VHT rates when VHT is 
> supported by sta.");
> +
Here,

> @@ -1012,6 +1155,9 @@ minstrel_ht_update_caps(void *priv, struct 
> ieee80211_supported_band *sband,
>   continue;
>   }
>  
> + if (minstrel_vht_only && !(gflags & IEEE80211_TX_RC_VHT_MCS))
> + continue;
> +
and there.

 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH v2 0/4] add VHT support to minstrel_ht

2014-10-17 Thread Karl Beldan
From: Karl Beldan 

(Sorry for spamming, Felix's address was mangled.)

Hi,

This is a split version of the VHT support addition to minstrel.
Thanks for reviewing,

Karl Beldan (4):
  mac80211: minstrel_ht: Increase the range of handled rate indexes
  mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs
  mac80211: minstrel_ht: include type (cck/ht) in rates flag
  mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz
v2:
- typo in Kconfig
- adjust room in debugfs rc_stats buffer
- add a module param to mix ht rates with vht ones
- default to 3SS instead of 2SS (with "mac80211: minstrel_ht: macros
  adjustments for future VHT_GROUPs")
- use common MINSTREL_MAX_STREAMS both for VHT and HT so that we can get
  rid of the 'MINSTREL_MAX_STREAMS >= 3' checks for minstrel_mcs_groups

 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 288 +++--
 net/mac80211/rc80211_minstrel_ht.h |  38 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  32 ++--
 4 files changed, 286 insertions(+), 79 deletions(-)

-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH v2 2/4] mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs

2014-10-17 Thread Karl Beldan
From: Karl Beldan 

No functional change.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 51 +++---
 net/mac80211/rc80211_minstrel_ht.h | 14 ++--
 net/mac80211/rc80211_minstrel_ht_debugfs.c | 10 +++---
 3 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index ccec718..a48eb76 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -34,12 +34,16 @@
 /* Transmit duration for the raw data part of an average sized packet */
 #define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, 
MCS_NSYMS((streams) * (bps)))
 
+#define BW_20  0
+#define BW_40  1
+
 /*
  * Define group sort order: HT40 -> SGI -> #streams
  */
 #define GROUP_IDX(_streams, _sgi, _ht40)   \
+   MINSTREL_HT_GROUP_0 +   \
MINSTREL_MAX_STREAMS * 2 * _ht40 +  \
-   MINSTREL_MAX_STREAMS * _sgi +   \
+   MINSTREL_MAX_STREAMS * _sgi +   \
_streams - 1
 
 /* MCS rate information for an MCS group */
@@ -76,13 +80,13 @@
CCK_ACK_DURATION(55, _short),   \
CCK_ACK_DURATION(110, _short)
 
-#define CCK_GROUP  \
-   [MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS] = { \
-   .streams = 0,   \
-   .duration = {   \
-   CCK_DURATION_LIST(false),   \
-   CCK_DURATION_LIST(true) \
-   }   \
+#define CCK_GROUP  \
+   [MINSTREL_CCK_GROUP] = {\
+   .streams = 0,   \
+   .duration = {   \
+   CCK_DURATION_LIST(false),   \
+   CCK_DURATION_LIST(true) \
+   }   \
}
 
 /*
@@ -91,38 +95,36 @@
  * use.
  *
  * Sortorder has to be fixed for GROUP_IDX macro to be applicable:
- * HT40 -> SGI -> #streams
+ * BW -> SGI -> #streams
  */
 const struct mcs_group minstrel_mcs_groups[] = {
-   MCS_GROUP(1, 0, 0),
-   MCS_GROUP(2, 0, 0),
+   MCS_GROUP(1, 0, BW_20),
+   MCS_GROUP(2, 0, BW_20),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 0, 0),
+   MCS_GROUP(3, 0, BW_20),
 #endif
 
-   MCS_GROUP(1, 1, 0),
-   MCS_GROUP(2, 1, 0),
+   MCS_GROUP(1, 1, BW_20),
+   MCS_GROUP(2, 1, BW_20),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 1, 0),
+   MCS_GROUP(3, 1, BW_20),
 #endif
 
-   MCS_GROUP(1, 0, 1),
-   MCS_GROUP(2, 0, 1),
+   MCS_GROUP(1, 0, BW_40),
+   MCS_GROUP(2, 0, BW_40),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 0, 1),
+   MCS_GROUP(3, 0, BW_40),
 #endif
 
-   MCS_GROUP(1, 1, 1),
-   MCS_GROUP(2, 1, 1),
+   MCS_GROUP(1, 1, BW_40),
+   MCS_GROUP(2, 1, BW_40),
 #if MINSTREL_MAX_STREAMS >= 3
-   MCS_GROUP(3, 1, 1),
+   MCS_GROUP(3, 1, BW_40),
 #endif
 
-   /* must be last */
CCK_GROUP
 };
 
-#define MINSTREL_CCK_GROUP (ARRAY_SIZE(minstrel_mcs_groups) - 1)
 
 static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES] __read_mostly;
 
@@ -971,8 +973,7 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
if (!sta->ht_cap.ht_supported)
goto use_legacy;
 
-   BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) !=
-   MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS + 1);
+   BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) != MINSTREL_GROUPS_NB);
 
msp->is_ht = true;
memset(mi, 0, sizeof(*mi));
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 8b54e89..7b46592 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -13,8 +13,16 @@
  * The number of streams can be changed to 2 to reduce code
  * size and memory footprint.
  */
-#define MINSTREL_MAX_STREAMS   3
-#define MINSTREL_STREAM_GROUPS 4
+#define MINSTREL_MAX_STREAMS   3
+#define MINSTREL_HT_STREAM_GROUPS  4 /* BW(=2) * SGI(=2) */
+
+#define MINSTREL_HT_GROUPS_NB  (MINSTREL_MAX_STREAMS * 
MINSTREL_HT_STREAM_GROUPS)
+#define MINSTREL_CCK_GROUPS_NB 1
+#define MINSTREL_GROUPS_NB (MINSTREL_HT_GROUPS_NB +\
+MINSTREL_CCK_GROUPS_NB)
+
+#define MINSTREL_HT_GROUP_00
+#define MINSTREL_CCK_GROUP (MINSTREL_HT_GROUP_0 + MINSTREL_HT_GROUPS_NB)
 
 #define MCS_GROUP_RATES8
 
@@ -80,7 +88,7 @@ struct minstrel_ht_sta {
u8 cck_supported_short;
 
/* MCS rate group info and statistics */
-   struct minstrel_mcs_gr

[RESEND PATCH v2 3/4] mac80211: minstrel_ht: include type (cck/ht) in rates flag

2014-10-17 Thread Karl Beldan
From: Karl Beldan 

ATM, we grep cck rates idx with idx / MCS_GROUP_RATES ==
MINSTREL_CCK_GROUP.
Matching neither-cck-non-ht rates could be done by replacing '==' with
'>', however it would be less versatile or explicit.
This will allow to match VHT rates with IEEE80211_TX_RC_VHT_MCS.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index a48eb76..e760d3d 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -51,6 +51,7 @@
[GROUP_IDX(_streams, _sgi, _ht40)] = {  \
.streams = _streams,\
.flags =\
+   IEEE80211_TX_RC_MCS |   \
(_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \
(_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0), \
.duration = {   \
@@ -83,6 +84,7 @@
 #define CCK_GROUP  \
[MINSTREL_CCK_GROUP] = {\
.streams = 0,   \
+   .flags = 0, \
.duration = {   \
CCK_DURATION_LIST(false),   \
CCK_DURATION_LIST(true) \
@@ -716,7 +718,7 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi,
const struct mcs_group *group = &minstrel_mcs_groups[index / 
MCS_GROUP_RATES];
struct minstrel_rate_stats *mr;
u8 idx;
-   u16 flags;
+   u16 flags = group->flags;
 
mr = minstrel_get_ratestats(mi, index);
if (!mr->retry_updated)
@@ -732,13 +734,10 @@ minstrel_ht_set_rate(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi,
ratetbl->rate[offset].count_rts = mr->retry_count_rtscts;
}
 
-   if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
+   if (index / MCS_GROUP_RATES == MINSTREL_CCK_GROUP)
idx = mp->cck_rates[index % ARRAY_SIZE(mp->cck_rates)];
-   flags = 0;
-   } else {
+   else
idx = index % MCS_GROUP_RATES + (group->streams - 1) * 8;
-   flags = IEEE80211_TX_RC_MCS | group->flags;
-   }
 
if (offset > 0) {
ratetbl->rate[offset].count = ratetbl->rate[offset].count_rts;
@@ -918,13 +917,12 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta 
*sta, void *priv_sta,
if (sample_idx / MCS_GROUP_RATES == MINSTREL_CCK_GROUP) {
int idx = sample_idx % ARRAY_SIZE(mp->cck_rates);
rate->idx = mp->cck_rates[idx];
-   rate->flags = 0;
-   return;
+   } else {
+   rate->idx = sample_idx % MCS_GROUP_RATES +
+   (sample_group->streams - 1) * 8;
}
 
-   rate->idx = sample_idx % MCS_GROUP_RATES +
-   (sample_group->streams - 1) * 8;
-   rate->flags = IEEE80211_TX_RC_MCS | sample_group->flags;
+   rate->flags = sample_group->flags;
 }
 
 static void
@@ -1006,14 +1004,16 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
 
for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
+   u32 gflags = minstrel_mcs_groups[i].flags;
+
mi->groups[i].supported = 0;
if (i == MINSTREL_CCK_GROUP) {
minstrel_ht_update_cck(mp, mi, sband, sta);
continue;
}
 
-   if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_SHORT_GI) {
-   if (minstrel_mcs_groups[i].flags & 
IEEE80211_TX_RC_40_MHZ_WIDTH) {
+   if (gflags & IEEE80211_TX_RC_SHORT_GI) {
+   if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
if (!(sta_cap & IEEE80211_HT_CAP_SGI_40))
continue;
} else {
@@ -1022,7 +1022,7 @@ minstrel_ht_update_caps(void *priv, struct 
ieee80211_supported_band *sband,
}
}
 
-   if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH 
&&
+   if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH &&
sta->bandwidth < IEEE80211_STA_RX_BW_40)
continue;
 
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH v2 1/4] mac80211: minstrel_ht: Increase the range of handled rate indexes

2014-10-17 Thread Karl Beldan
From: Karl Beldan 

Since 5935839ad735 ("mac80211: improve minstrel_ht rate sorting by
throughput & probability"), the rate indexes are manipulated via u8's
and hence allow for a maximum of 256 mcs_group entries in
minstrel_mcs_groups.

ATM, minstrel_ht advertizes support up to 3HTSS@40MHz, consuming:
8(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)), i.e. 104 entries.

Support for 3VHTSS@80MHz will require:
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)) +
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*3(BW)), i.e. 130 + 180 entries.

This change moves from u8s to u16s where necessary.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 16 
 net/mac80211/rc80211_minstrel_ht.h |  8 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index 17ef54a..ccec718 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -240,8 +240,8 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, 
int rate)
  * MCS groups, CCK rates do not provide aggregation and are therefore at last.
  */
 static void
-minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u8 index,
-  u8 *tp_list)
+minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
+  u16 *tp_list)
 {
int cur_group, cur_idx, cur_thr, cur_prob;
int tmp_group, tmp_idx, tmp_thr, tmp_prob;
@@ -278,7 +278,7 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, 
u8 index,
  * Find and set the topmost probability rate per sta and per group
  */
 static void
-minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u8 index)
+minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
 {
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
@@ -321,8 +321,8 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, 
u8 index)
  */
 static void
 minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
-u8 tmp_mcs_tp_rate[MAX_THR_RATES],
-u8 tmp_cck_tp_rate[MAX_THR_RATES])
+u16 tmp_mcs_tp_rate[MAX_THR_RATES],
+u16 tmp_cck_tp_rate[MAX_THR_RATES])
 {
unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp;
int i;
@@ -386,8 +386,8 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi)
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
int group, i, j;
-   u8 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
-   u8 tmp_cck_tp_rate[MAX_THR_RATES], index;
+   u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
+   u16 tmp_cck_tp_rate[MAX_THR_RATES], index;
 
if (mi->ampdu_packets > 0) {
mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
@@ -517,7 +517,7 @@ minstrel_next_sample_idx(struct minstrel_ht_sta *mi)
 }
 
 static void
-minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u8 *idx, bool primary)
+minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u16 *idx, bool primary)
 {
int group, orig_group;
 
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 01570e0..8b54e89 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -34,8 +34,8 @@ struct minstrel_mcs_group_data {
u8 supported;
 
/* sorted rate set within a MCS group*/
-   u8 max_group_tp_rate[MAX_THR_RATES];
-   u8 max_group_prob_rate;
+   u16 max_group_tp_rate[MAX_THR_RATES];
+   u16 max_group_prob_rate;
 
/* MCS rate statistics */
struct minstrel_rate_stats rates[MCS_GROUP_RATES];
@@ -52,8 +52,8 @@ struct minstrel_ht_sta {
unsigned int avg_ampdu_len;
 
/* overall sorted rate set */
-   u8 max_tp_rate[MAX_THR_RATES];
-   u8 max_prob_rate;
+   u16 max_tp_rate[MAX_THR_RATES];
+   u16 max_prob_rate;
 
/* time of last status update */
unsigned long stats_update;
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH v2 4/4] mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz

2014-10-17 Thread Karl Beldan
From: Karl Beldan 

When the new CONFIG_MAC80211_RC_MINSTREL_VHT is not set (default 'N'),
there is no behavioral change including in sampling and MCS_GROUP_RATES
remains 8.
Otherwise MCS_GROUP_RATES is 10, and a module parameter *vht_only*
(default 'true'), restricts the rates selection to VHT when vht is
supported.

Regarding the debugfs stats buffer:
It is explicitly increased from 8k to 32k to fit every rates incl. when
both ht and vht rates are enabled, as for the format, before:
type   rate tpt eprob *prob ret  *ok(*cum)ok(  cum)
HT20/LGI ABCDP MCS0 0.0   0.0   0.0   10(   0) 0(0)
after:
 type   rate  tpt eprob *prob ret  *ok(*cum)ok(  cum)
 HT20/LGI ABCDP MCS0  0.0   0.0   0.0   10(   0) 0(0)
VHT40/LGI   MCS5/20.0   0.0   0.0   00(   0) 0(    0)

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/Kconfig   |   7 ++
 net/mac80211/rc80211_minstrel_ht.c | 193 +++--
 net/mac80211/rc80211_minstrel_ht.h |  16 ++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  22 ++--
 4 files changed, 219 insertions(+), 19 deletions(-)

diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index aeb6a48..e8049ed 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -33,6 +33,13 @@ config MAC80211_RC_MINSTREL_HT
---help---
  This option enables the 'minstrel_ht' TX rate control algorithm
 
+config MAC80211_RC_MINSTREL_VHT
+   bool "Minstrel 802.11ac support" if EXPERT
+   depends on MAC80211_RC_MINSTREL_HT
+   default n
+   ---help---
+ This option enables vht in the 'minstrel_ht' TX rate control algorithm
+
 choice
prompt "Default rate control algorithm"
depends on MAC80211_HAS_RC
diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index e760d3d..07e9320 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "rate.h"
@@ -36,6 +37,7 @@
 
 #define BW_20  0
 #define BW_40  1
+#define BW_80  2
 
 /*
  * Define group sort order: HT40 -> SGI -> #streams
@@ -66,6 +68,37 @@
}   \
 }
 
+#define VHT_GROUP_IDX(_streams, _sgi, _bw) \
+   (MINSTREL_VHT_GROUP_0 + \
+MINSTREL_MAX_STREAMS * 2 * (_bw) + \
+MINSTREL_MAX_STREAMS * (_sgi) +\
+(_streams) - 1)
+
+#define BW2VBPS(_bw, r3, r2, r1)   
\
+   (_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1)
+
+#define VHT_GROUP(_streams, _sgi, _bw) 
\
+   [VHT_GROUP_IDX(_streams, _sgi, _bw)] = {
\
+   .streams = _streams,
\
+   .flags =
\
+   IEEE80211_TX_RC_VHT_MCS |   
\
+   (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | 
\
+   (_bw == BW_80 ? IEEE80211_TX_RC_80_MHZ_WIDTH :  
\
+_bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),  
\
+   .duration = {   
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  117,  54,  26)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  234, 108,  52)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  351, 162,  78)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  468, 216, 104)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  702, 324, 156)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  936, 432, 208)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1053, 486, 234)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1170, 540, 260)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1404, 648, 312)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1560, 720, 346))  
\
+   }   
\
+}
+
 #define CCK_DURATION(_bitrate, _short, _len)   \
(1000 * (10 /* SIFS */ +\
 (_short ? 72 + 24 : 144 + 48) +\
@@ -91,6 +124,10 @@
}   \
}
 
+static bool minstrel_vht_only = true;
+module_param(minstrel_vht_only, bool, 0644);
+MODULE_PARM_DESC(minstrel_vht_onl

[PATCH v2 1/4] mac80211: minstrel_ht: Increase the range of handled rate indexes

2014-10-17 Thread Karl Beldan
From: Karl Beldan 

Since 5935839ad735 ("mac80211: improve minstrel_ht rate sorting by
throughput & probability"), the rate indexes are manipulated via u8's
and hence allow for a maximum of 256 mcs_group entries in
minstrel_mcs_groups.

ATM, minstrel_ht advertizes support up to 3HTSS@40MHz, consuming:
8(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)), i.e. 104 entries.

Support for 3VHTSS@80MHz will require:
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*2(BW)+1(CCK)) +
10(MCS_GROUP_RATES) * (3(SS)*2(GI)*3(BW)), i.e. 130 + 180 entries.

This change moves from u8s to u16s where necessary.

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---
 net/mac80211/rc80211_minstrel_ht.c | 16 
 net/mac80211/rc80211_minstrel_ht.h |  8 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index 17ef54a..ccec718 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -240,8 +240,8 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, 
int rate)
  * MCS groups, CCK rates do not provide aggregation and are therefore at last.
  */
 static void
-minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u8 index,
-  u8 *tp_list)
+minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
+  u16 *tp_list)
 {
int cur_group, cur_idx, cur_thr, cur_prob;
int tmp_group, tmp_idx, tmp_thr, tmp_prob;
@@ -278,7 +278,7 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, 
u8 index,
  * Find and set the topmost probability rate per sta and per group
  */
 static void
-minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u8 index)
+minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
 {
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
@@ -321,8 +321,8 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, 
u8 index)
  */
 static void
 minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
-u8 tmp_mcs_tp_rate[MAX_THR_RATES],
-u8 tmp_cck_tp_rate[MAX_THR_RATES])
+u16 tmp_mcs_tp_rate[MAX_THR_RATES],
+u16 tmp_cck_tp_rate[MAX_THR_RATES])
 {
unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp;
int i;
@@ -386,8 +386,8 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi)
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
int group, i, j;
-   u8 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
-   u8 tmp_cck_tp_rate[MAX_THR_RATES], index;
+   u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
+   u16 tmp_cck_tp_rate[MAX_THR_RATES], index;
 
if (mi->ampdu_packets > 0) {
mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
@@ -517,7 +517,7 @@ minstrel_next_sample_idx(struct minstrel_ht_sta *mi)
 }
 
 static void
-minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u8 *idx, bool primary)
+minstrel_downgrade_rate(struct minstrel_ht_sta *mi, u16 *idx, bool primary)
 {
int group, orig_group;
 
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 01570e0..8b54e89 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -34,8 +34,8 @@ struct minstrel_mcs_group_data {
u8 supported;
 
/* sorted rate set within a MCS group*/
-   u8 max_group_tp_rate[MAX_THR_RATES];
-   u8 max_group_prob_rate;
+   u16 max_group_tp_rate[MAX_THR_RATES];
+   u16 max_group_prob_rate;
 
/* MCS rate statistics */
struct minstrel_rate_stats rates[MCS_GROUP_RATES];
@@ -52,8 +52,8 @@ struct minstrel_ht_sta {
unsigned int avg_ampdu_len;
 
/* overall sorted rate set */
-   u8 max_tp_rate[MAX_THR_RATES];
-   u8 max_prob_rate;
+   u16 max_tp_rate[MAX_THR_RATES];
+   u16 max_prob_rate;
 
/* time of last status update */
unsigned long stats_update;
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/4] add VHT support to minstrel_ht

2014-10-17 Thread Karl Beldan
From: Karl Beldan 

Hi,

This is a split version of the VHT support addition to minstrel.
Thanks for reviewing,

Karl Beldan (4):
  mac80211: minstrel_ht: Increase the range of handled rate indexes
  mac80211: minstrel_ht: macros adjustments for future VHT_GROUPs
  mac80211: minstrel_ht: include type (cck/ht) in rates flag
  mac80211: minstrel_ht: add basic support for VHT rates <= 3SS@80MHz
v2:
- typo in Kconfig
- adjust room in debugfs rc_stats buffer
- add a module param to mix ht rates with vht ones
- default to 3SS instead of 2SS (with "mac80211: minstrel_ht: macros
  adjustments for future VHT_GROUPs")
- use common MINSTREL_MAX_STREAMS both for VHT and HT so that we can get
  rid of the 'MINSTREL_MAX_STREAMS >= 3' checks for minstrel_mcs_groups

 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 288 +++--
 net/mac80211/rc80211_minstrel_ht.h |  38 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  32 ++--
 4 files changed, 286 insertions(+), 79 deletions(-)

-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211: minstrels: fix buffer overflow in HT debugfs rc_stats

2014-10-17 Thread Karl Beldan
From: Karl Beldan 

ATM an HT rc_stats line is 106 chars.
Times 8(MCS_GROUP_RATES)*3(SS)*2(GI)*2(BW) + CCK(4), i.e. x100, this is
well above the current 8192 - sizeof(*ms) currently allocated.

Fix this by squeezing the output as follows (not that we're short on
memory but this also improves readability and range, the new format adds
one more digit to *ok/*cum and ok/cum):

- Before (HT) (106 ch):
type   rate throughput  ewma prob   this prob  retry   this 
succ/attempt   successattempts
CCK/LP  5.5M   0.00.0 0.0  0  
0(  0) 0   0
HT20/LGI ABCDP MCS00.00.0 0.0  1  
0(  0) 0   0
- After (75 ch):
type   rate tpt eprob *prob ret  *ok(*cum)ok(  cum)
CCK/LP  5.5M0.0   0.0   0.0   00(   0) 0(0)
HT20/LGI ABCDP MCS0 0.0   0.0   0.0   10(   0) 0(0)

- Align non-HT format Before (non-HT) (83 ch):
rate  throughput  ewma prob  this prob  this succ/attempt   success
attempts
ABCDP  6 0.00.00.0 0(  0) 0 
  0
  54 0.00.00.0 0(  0) 0 
  0
- After (61 ch):
rate  tpt eprob *prob  *ok(*cum)ok(  cum)
ABCDP  1  0.0   0.0   0.00(   0) 0(0)
  54  0.0   0.0   0.00(   0) 0(0)

*This also adds dynamic checks for overflow, lowers the size of the
non-HT request (allowing > 30 entries) and replaces the buddy-rounded
allocations (s/sizeof(*ms) + 8192/8192).

Signed-off-by: Karl Beldan 
Cc: Felix Fietkau 
---


Send this one-line patch to stable ?
-   ms = kmalloc(sizeof(*ms) + 8192, GFP_KERNEL);
+   ms = kmalloc(16384, GFP_KERNEL);


 net/mac80211/rc80211_minstrel_debugfs.c| 12 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c | 13 -
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/net/mac80211/rc80211_minstrel_debugfs.c 
b/net/mac80211/rc80211_minstrel_debugfs.c
index edde723..b33be0f 100644
--- a/net/mac80211/rc80211_minstrel_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_debugfs.c
@@ -62,14 +62,14 @@ minstrel_stats_open(struct inode *inode, struct file *file)
unsigned int i, tp, prob, eprob;
char *p;
 
-   ms = kmalloc(sizeof(*ms) + 4096, GFP_KERNEL);
+   ms = kmalloc(2048, GFP_KERNEL);
if (!ms)
return -ENOMEM;
 
file->private_data = ms;
p = ms->buf;
-   p += sprintf(p, "rate  throughput  ewma prob  this prob  "
-   "this succ/attempt   successattempts\n");
+   p += sprintf(p, "rate  tpt eprob *prob"
+   "  *ok(*cum)ok(  cum)\n");
for (i = 0; i < mi->n_rates; i++) {
struct minstrel_rate *mr = &mi->r[i];
struct minstrel_rate_stats *mrs = &mi->r[i].stats;
@@ -86,8 +86,8 @@ minstrel_stats_open(struct inode *inode, struct file *file)
prob = MINSTREL_TRUNC(mrs->cur_prob * 1000);
eprob = MINSTREL_TRUNC(mrs->probability * 1000);
 
-   p += sprintf(p, "  %6u.%1u   %6u.%1u   %6u.%1u"
-   "   %3u(%3u)  %8llu%8llu\n",
+   p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u"
+   " %4u(%4u) %9llu(%9llu)\n",
tp / 10, tp % 10,
eprob / 10, eprob % 10,
prob / 10, prob % 10,
@@ -102,6 +102,8 @@ minstrel_stats_open(struct inode *inode, struct file *file)
mi->sample_packets);
ms->len = p - ms->buf;
 
+   WARN_ON(ms->len > 2048 - sizeof(*ms));
+
return 0;
 }
 
diff --git a/net/mac80211/rc80211_minstrel_ht_debugfs.c 
b/net/mac80211/rc80211_minstrel_ht_debugfs.c
index a72ad46..b51b4ec 100644
--- a/net/mac80211/rc80211_minstrel_ht_debugfs.c
+++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
@@ -63,8 +63,8 @@ minstrel_ht_stats_dump(struct minstrel_ht_sta *mi, int i, 
char *p)
prob = MINSTREL_TRUNC(mr->cur_prob * 1000);
eprob = MINSTREL_TRUNC(mr->probability * 1000);
 
-   p += sprintf(p, "  %6u.%1u   %6u.%1u%6u.%1u"
-   "%3u%3u(%3u)  %8llu%8llu\n",
+   p += sprintf(p, " %4u.%1u %3u.%1u %3u.%1u "
+   "%3u %4u(%4u) %9llu(%9llu)\n",
tp / 10, tp % 10,
eprob / 10, eprob % 10,
prob / 10, prob % 10,
@@ -96,14 +96,15 @@ minstrel_ht_stats_open(struct inode *inode, struct file 
*file)

[PATCH v2] mac80211: fix typo in starting baserate for rts_cts_rate_idx

2014-10-13 Thread Karl Beldan
From: Karl Beldan 

It affects non-(V)HT rates and can lead to selecting an rts_cts rate
that is not a basic rate or way superior to the reference rate (ATM
rates[0] used for the 1st attempt of the protected frame data).

E.g, assuming drivers register growing (bitrate) sorted tables of
ieee80211_rate-s, having :
- rates[0].idx == d'2 and basic_rates == b'10100
will select rts_cts idx b'10011 & ~d'(BIT(2)-1), i.e. 1, likewise
- rates[0].idx == d'2 and basic_rates == b'10001
will select rts_cts idx b'1
The first is not a basic rate and the second is > rates[0].

Also, wrt severity of the addressed misbehavior, ATM we only have one
rts_cts_rate_idx rather than one per rate table entry, so this idx might
still point to bitrates > rates[1..MAX_RATES].

Fixes: 5253ffb8c9e1 ("mac80211: always pick a basic rate to tx RTS/CTS for 
pre-HT rates")
Cc: sta...@vger.kernel.org
Signed-off-by: Karl Beldan 
---
 net/mac80211/rate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 8fdadfd..6081329 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -448,7 +448,7 @@ static void rate_fixup_ratelist(struct ieee80211_vif *vif,
 */
if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
u32 basic_rates = vif->bss_conf.basic_rates;
-   s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0;
+   s8 baserate = basic_rates ? ffs(basic_rates) - 1 : 0;
 
rate = &sband->bitrates[rates[0].idx];
 
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: fix typo in starting baserate for rts_cts_rate_idx

2014-10-13 Thread Karl Beldan
Properly cc'ing stable (I used kernel.org instead of vger.kernel.org).

On Mon, Oct 13, 2014 at 11:48:12AM +0200, Karl Beldan wrote:
> From: Karl Beldan 
> 
> It affects non-(V)HT rates and can lead to selecting an rts_cts rate
> that is not a basic rate or way superior to the reference rate (ATM
> rates[0] used for the 1st attempt of the protected frame data).
> 
> E.g, assuming drivers register growing (bitrate) sorted tables of
> ieee80211_rate-s, having :
> - rates[0].idx == d'2 and basic_rates == b'10100
> will select rts_cts idx b'10011 & ~d'(BIT(2)-1), i.e. 1, likewise
> - rates[0].idx == d'2 and basic_rates == b'10001
> will select rts_cts idx b'1
> The first is not a basic rate and the second is > rates[0].
> 
> Also, wrt severity of the addressed misbehavior, ATM we only have one
> rts_cts_rate_idx rather than one per rate table entry, so this idx might
> still point to bitrates > rates[1..MAX_RATES].
> 
> Fixes: 5253ffb8 ("mac80211: always pick a basic rate to tx RTS/CTS for pre-HT 
> rates")
> Signed-off-by: Karl Beldan 
> ---
>  net/mac80211/rate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
> index 8fdadfd..6081329 100644
> --- a/net/mac80211/rate.c
> +++ b/net/mac80211/rate.c
> @@ -448,7 +448,7 @@ static void rate_fixup_ratelist(struct ieee80211_vif *vif,
>*/
>   if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
>   u32 basic_rates = vif->bss_conf.basic_rates;
> - s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0;
> + s8 baserate = basic_rates ? ffs(basic_rates) - 1 : 0;
>  
>   rate = &sband->bitrates[rates[0].idx];
>  
> -- 
> 2.0.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211: fix typo in starting baserate for rts_cts_rate_idx

2014-10-13 Thread Karl Beldan
From: Karl Beldan 

It affects non-(V)HT rates and can lead to selecting an rts_cts rate
that is not a basic rate or way superior to the reference rate (ATM
rates[0] used for the 1st attempt of the protected frame data).

E.g, assuming drivers register growing (bitrate) sorted tables of
ieee80211_rate-s, having :
- rates[0].idx == d'2 and basic_rates == b'10100
will select rts_cts idx b'10011 & ~d'(BIT(2)-1), i.e. 1, likewise
- rates[0].idx == d'2 and basic_rates == b'10001
will select rts_cts idx b'1
The first is not a basic rate and the second is > rates[0].

Also, wrt severity of the addressed misbehavior, ATM we only have one
rts_cts_rate_idx rather than one per rate table entry, so this idx might
still point to bitrates > rates[1..MAX_RATES].

Fixes: 5253ffb8 ("mac80211: always pick a basic rate to tx RTS/CTS for pre-HT 
rates")
Signed-off-by: Karl Beldan 
---
 net/mac80211/rate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 8fdadfd..6081329 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -448,7 +448,7 @@ static void rate_fixup_ratelist(struct ieee80211_vif *vif,
 */
if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
u32 basic_rates = vif->bss_conf.basic_rates;
-   s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0;
+   s8 baserate = basic_rates ? ffs(basic_rates) - 1 : 0;
 
rate = &sband->bitrates[rates[0].idx];
 
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] cfg80211: set the rates mask in connection probes over specified freq

2014-10-10 Thread Karl Beldan
On Fri, Oct 10, 2014 at 05:11:31PM +0200, Johannes Berg wrote:
> On Fri, 2014-10-10 at 17:10 +0200, Johannes Berg wrote:
> > On Thu, 2014-10-09 at 22:49 +0200, Karl Beldan wrote:
> > 
> > > > Either way - is it worth for 3.18/stable?
> > > > 
> > > Your call.
> > 
> > I've seen no complaints, and you haven't indicated that you'd like to
> > see it in older kernels, so I've applied it to mac80211-next.
> 
> With a memory leak fix :)
> 
Arf yes, thanks !
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211/trivial: fix typo in starting baserate for rts_cts_rate_idx

2014-10-09 Thread Karl Beldan
On Thu, Oct 09, 2014 at 05:22:21PM +0200, Johannes Berg wrote:
> On Thu, 2014-10-09 at 16:45 +0200, Karl Beldan wrote:
> 
> > > > The typo is clearly showing but the faulty behavior clearly demands more
> > > > detail indeed.
> > > > 
> > > > It affects non-(V)HT rates and can lead to selecting an rts_cts rate
> > > > that is not a basic rate or way superior to the reference rate (ATM
> > > > rates[0] used for the 1st attempt of the protected frame data).
> > > > E.g, assuming the drivers register growing (bitrate) sorted
> > > > ieee80211_rate tables, having :
> > > > - rates[0].idx == d'2 and basic_rates == b'10100
> > > > will select rts_cts idx b'10011 & ~d'(BIT(2)-1), i.e. 1, likewise
> > > > - rates[0].idx == d'2 and basic_rates == b'10001 
> > > > will select rts_cts idx b'1
> > > > The first is not a basic rate and the second is > rates[0].
> > > > 
> > > > I hope it clarifies things enough.
> > > 
> > > Well, I'm still not sure which tree I should put it in, I guess?
> > > 
> > 
> > All I can say is that nor this faulty behavior nor the correspond fix
> > are likely to cause a crash (we always tx registered rates).
> 
> But it's still pretty misbehaving, no? That IMHO warrants fixing and
> even cc stable.
> 
Also, for the record, ATM we have only one rts_cts rate. A way to handle
every retry rates is still missing, along with (V)HT rates.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] cfg80211: set the rates mask in connection probes over specified freq

2014-10-09 Thread Karl Beldan
On Thu, Oct 09, 2014 at 08:36:33PM +0200, Johannes Berg wrote:
> Heh, so I guess this goes way back ... what does it actually affect
> really though? only connections with iw, which should really not be done
> that much? potentially wpa_s with wext, though I'm not even sure that
> works?
> 
For wext I wouldn't know.

> Either way - is it worth for 3.18/stable?
> 
Your call.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211/trivial: fix typo in starting baserate for rts_cts_rate_idx

2014-10-09 Thread Karl Beldan
On Thu, Oct 09, 2014 at 05:22:21PM +0200, Johannes Berg wrote:
> On Thu, 2014-10-09 at 16:45 +0200, Karl Beldan wrote:
> 
> > > > The typo is clearly showing but the faulty behavior clearly demands more
> > > > detail indeed.
> > > > 
> > > > It affects non-(V)HT rates and can lead to selecting an rts_cts rate
> > > > that is not a basic rate or way superior to the reference rate (ATM
> > > > rates[0] used for the 1st attempt of the protected frame data).
> > > > E.g, assuming the drivers register growing (bitrate) sorted
> > > > ieee80211_rate tables, having :
> > > > - rates[0].idx == d'2 and basic_rates == b'10100
> > > > will select rts_cts idx b'10011 & ~d'(BIT(2)-1), i.e. 1, likewise
> > > > - rates[0].idx == d'2 and basic_rates == b'10001 
> > > > will select rts_cts idx b'1
> > > > The first is not a basic rate and the second is > rates[0].
> > > > 
> > > > I hope it clarifies things enough.
> > > 
> > > Well, I'm still not sure which tree I should put it in, I guess?
> > > 
> > 
> > All I can say is that nor this faulty behavior nor the correspond fix
> > are likely to cause a crash (we always tx registered rates).
> 
> But it's still pretty misbehaving, no? That IMHO warrants fixing and
> even cc stable.
> 
> johannes

You'd like me to reword with these details in a v2 and cc stable or ?
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] cfg80211: set the rates mask in connection probes over specified freq

2014-10-09 Thread Karl Beldan
On Thu, Oct 09, 2014 at 03:26:02PM +0200, Johannes Berg wrote:
> On Thu, 2014-10-09 at 15:00 +0200, Karl Beldan wrote:
> > On Thu, Oct 09, 2014 at 11:32:57AM +0200, Johannes Berg wrote:
> > > On Tue, 2014-10-07 at 11:42 +0200, Karl Beldan wrote:
> > > > From: Karl Beldan 
> > > > 
> > > > ATM, specifying the frequency when connecting sends a void 'supported
> > > > rates' EID.
> > > 
> > > Seems like this should be a stable fix?
> > > 
> > Indeed, I forgot to Cc stable.
> 
> Ok, I guess I can just add it.
> 
> Then again, maybe you can make a bit more verbose commit log, and check
> what broke it?
> 
After a glimpse before leaving FWIU :

- 6829c878 Jul 2009 - "cfg80211: emulate connect with auth/assoc"
original code for 'cmd'
ieee80211_build_preq_ies takes supported rates from sband->bitrates[].
- 8dcb2003 Aug 2010 - "mac80211: Filter ProbeReq SuppRates based on TX
rate mask"
ieee80211_build_preq_ies takes a rate mask, hw_scan uses -1/sw_scan uses
sdata->rc_rateidx_mask.
- 34850ab2 Jul 2011 - "cfg80211: allow userspace to control supported
rates in scan" add a "bitmap of rates to advertise" in the scan request.
- 85a237fe Jul 2011 - "mac80211: implement scan supported rates"
take the rate mask from 'cmd'
- 3965ac00 Sep 2011 - "wireless: Fix rate mask for scan request"
fix rate mask when 'cmd' has params.channel


.. and rate mask remains unset when 'cmd' has params.channel
So I guess it started showing after 85a237fe, but the original cmd never
filled a rate mask which started existing only after 34850ab ..

 
Karl

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211/trivial: fix typo in starting baserate for rts_cts_rate_idx

2014-10-09 Thread Karl Beldan
On Thu, Oct 09, 2014 at 04:15:03PM +0200, Johannes Berg wrote:
> On Thu, 2014-10-09 at 16:06 +0200, Karl Beldan wrote:
> > On Thu, Oct 09, 2014 at 11:06:26AM +0200, Johannes Berg wrote:
> > > On Tue, 2014-10-07 at 15:53 +0200, Karl Beldan wrote:
> > > > From: Karl Beldan 
> > > 
> > > Is that really trivial? It seems to have some impact on the code, but I
> > > can't right now say exactly what the impact is. Can you describe it and
> > > say whether I should add it to mac80211 or mac80211-next? For "trivial"
> > > I'd probably say mac80211-next, but this might be more important than
> > > that?
> > > 
> > The typo is clearly showing but the faulty behavior clearly demands more
> > detail indeed.
> > 
> > It affects non-(V)HT rates and can lead to selecting an rts_cts rate
> > that is not a basic rate or way superior to the reference rate (ATM
> > rates[0] used for the 1st attempt of the protected frame data).
> > E.g, assuming the drivers register growing (bitrate) sorted
> > ieee80211_rate tables, having :
> > - rates[0].idx == d'2 and basic_rates == b'10100
> > will select rts_cts idx b'10011 & ~d'(BIT(2)-1), i.e. 1, likewise
> > - rates[0].idx == d'2 and basic_rates == b'10001 
> > will select rts_cts idx b'1
> > The first is not a basic rate and the second is > rates[0].
> > 
> > I hope it clarifies things enough.
> 
> Well, I'm still not sure which tree I should put it in, I guess?
> 

All I can say is that nor this faulty behavior nor the correspond fix
are likely to cause a crash (we always tx registered rates).
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211/trivial: fix typo in starting baserate for rts_cts_rate_idx

2014-10-09 Thread Karl Beldan
On Thu, Oct 09, 2014 at 11:06:26AM +0200, Johannes Berg wrote:
> On Tue, 2014-10-07 at 15:53 +0200, Karl Beldan wrote:
> > From: Karl Beldan 
> 
> Is that really trivial? It seems to have some impact on the code, but I
> can't right now say exactly what the impact is. Can you describe it and
> say whether I should add it to mac80211 or mac80211-next? For "trivial"
> I'd probably say mac80211-next, but this might be more important than
> that?
> 
The typo is clearly showing but the faulty behavior clearly demands more
detail indeed.

It affects non-(V)HT rates and can lead to selecting an rts_cts rate
that is not a basic rate or way superior to the reference rate (ATM
rates[0] used for the 1st attempt of the protected frame data).
E.g, assuming the drivers register growing (bitrate) sorted
ieee80211_rate tables, having :
- rates[0].idx == d'2 and basic_rates == b'10100
will select rts_cts idx b'10011 & ~d'(BIT(2)-1), i.e. 1, likewise
- rates[0].idx == d'2 and basic_rates == b'10001 
will select rts_cts idx b'1
The first is not a basic rate and the second is > rates[0].

I hope it clarifies things enough.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] cfg80211: set the rates mask in connection probes over specified freq

2014-10-09 Thread Karl Beldan
On Thu, Oct 09, 2014 at 11:32:57AM +0200, Johannes Berg wrote:
> On Tue, 2014-10-07 at 11:42 +0200, Karl Beldan wrote:
> > From: Karl Beldan 
> > 
> > ATM, specifying the frequency when connecting sends a void 'supported
> > rates' EID.
> 
> Seems like this should be a stable fix?
> 
Indeed, I forgot to Cc stable.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: minstrel_ht: fix MCS_GROUP_RATES usage

2014-10-09 Thread Karl Beldan
On Thu, Oct 09, 2014 at 10:58:21AM +0200, Johannes Berg wrote:
> On Mon, 2014-09-29 at 02:36 +0200, Karl Beldan wrote:
> > From: Karl Beldan 
> > 
> > Commit 4441e8e9 ("mac80211: improve minstrel_ht rate sorting by
> > throughput & probability") 
> 
> That commit ID doesn't exist? Anyway, I fixed it.
> 
> I applied the patch - but to mac80211-next since presumably you want to
> build on this and it doesn't matter much on mac80211.
> 
Thanks, this was a locally git-applied commit ID.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211/trivial: fix typo in starting baserate for rts_cts_rate_idx

2014-10-07 Thread Karl Beldan
From: Karl Beldan 

Fixes: 5253ffb8 ("mac80211: always pick a basic rate to tx RTS/CTS for pre-HT 
rates")
Signed-off-by: Karl Beldan 
---
 net/mac80211/rate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
index 8fdadfd..6081329 100644
--- a/net/mac80211/rate.c
+++ b/net/mac80211/rate.c
@@ -448,7 +448,7 @@ static void rate_fixup_ratelist(struct ieee80211_vif *vif,
 */
if (!(rates[0].flags & IEEE80211_TX_RC_MCS)) {
u32 basic_rates = vif->bss_conf.basic_rates;
-   s8 baserate = basic_rates ? ffs(basic_rates - 1) : 0;
+   s8 baserate = basic_rates ? ffs(basic_rates) - 1 : 0;
 
rate = &sband->bitrates[rates[0].idx];
 
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cfg80211: set the rates mask in connection probes over specified freq

2014-10-07 Thread Karl Beldan
From: Karl Beldan 

ATM, specifying the frequency when connecting sends a void 'supported
rates' EID.

Signed-off-by: Karl Beldan 
---
 net/wireless/sme.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 8bbeeb3..2ebc54b 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -80,9 +80,16 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
if (!request)
return -ENOMEM;
 
-   if (wdev->conn->params.channel)
+   if (wdev->conn->params.channel) {
+   enum ieee80211_band band = wdev->conn->params.channel->band;
+   struct ieee80211_supported_band *sband =
+   wdev->wiphy->bands[band];
+
+   if (!sband)
+   return -EINVAL;
request->channels[0] = wdev->conn->params.channel;
-   else {
+   request->rates[band] = (1 << sband->n_bitrates) - 1;
+   } else {
int i = 0, j;
enum ieee80211_band band;
struct ieee80211_supported_band *bands;
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] mac80211: improve minstrel_ht rate sorting by throughput & probability

2014-10-07 Thread Karl Beldan
Hi,

On Tue, Sep 09, 2014 at 11:22:14PM +0200, Thomas Huehn wrote:
> @@ -260,13 +399,14 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, 
> struct minstrel_ht_sta *mi)
>   mi->sample_slow = 0;
>   mi->sample_count = 0;
>  
> - for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
> - bool mg_rates_valid = false;
> + /* Initialize global rate indexes */
> + for(j = 0; j < MAX_THR_RATES; j++){
> + tmp_mcs_tp_rate[j] = 0;
> + tmp_cck_tp_rate[j] = 0;
> + }
>  

Pb if a driver doesn't support the first entry it. 
Maybe using a mi->min_ridx set in minstrel_ht_update_caps would be
practical.

> @@ -274,24 +414,16 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, 
> struct minstrel_ht_sta *mi)
>  
>   mi->sample_count++;
>  
> + /* (re)Initialize group rate indexes */
> + for(j = 0; j < MAX_THR_RATES; j++)
> + tmp_group_tp_rate[j] = group;
> +

You meant group * MCS_GROUP_RATES, no ?
And group * MCS_GROUP_RATES + ffs(mg->supported) - 1 would be correct
but this corner case is not easily triggerable, ATM.

-- 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: minstrel_ht: add basic support for VHT rates <= 80MHz@NSS2

2014-09-29 Thread Karl Beldan
Unless I can spare some space in rc_stats, v2 will need an increase in
minstrel_debugfs_info buffer (ATM 1 line is > 100 chars).
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] mac80211: minstrel_ht: add basic support for VHT rates <= 80MHz@NSS2

2014-09-29 Thread Karl Beldan
On Mon, Sep 29, 2014 at 01:46:15PM +0200, Felix Fietkau wrote:
> On 2014-09-29 02:38, Karl Beldan wrote:
> > diff --git a/net/mac80211/rc80211_minstrel_ht.h 
> > b/net/mac80211/rc80211_minstrel_ht.h
> > index 01570e0..7856062 100644
> > --- a/net/mac80211/rc80211_minstrel_ht.h
> > +++ b/net/mac80211/rc80211_minstrel_ht.h
> > @@ -13,10 +13,33 @@
> >   * The number of streams can be changed to 2 to reduce code
> >   * size and memory footprint.
> >   */
> > -#define MINSTREL_MAX_STREAMS   3
> > -#define MINSTREL_STREAM_GROUPS 4
> > +#ifdef CONFIG_MAC80211_RC_MINSTREL_VHT
> > +#define MINSTREL_VHT_MAX_STREAMS   2
> > +#else
> > +#define MINSTREL_VHT_MAX_STREAMS   0
> > +#endif
> > +#define MINSTREL_VHT_STREAM_GROUPS 6 /* BW(=3) * SGI(=2) */
> > +
> > +#define MINSTREL_HT_MAX_STREAMS3
> > +#define MINSTREL_HT_STREAM_GROUPS  4 /* BW(=2) * SGI(=2) */
> I think we should get rid of MINSTREL_*_MAX_STREAMS instead of expanding
> its use to VHT.
> 

You mean having a common hardcoded value for both ?
After 4441e8e9 the minstrel rate indexes have to be u8-s and having this
common param > 2 would require something like:

{{{
diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index 41522c7..c3d9136 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -346,8 +364,8 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, 
int rate)
  * MCS groups, CCK rates do not provide aggregation and are therefore at last.
  */
 static void
-minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u8 index,
-  u8 *tp_list)
+minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, u16 index,
+  u16 *tp_list)
 {
int cur_group, cur_idx, cur_thr, cur_prob;
int tmp_group, tmp_idx, tmp_thr, tmp_prob;
@@ -384,7 +402,7 @@ minstrel_ht_sort_best_tp_rates(struct minstrel_ht_sta *mi, 
u8 index,
  * Find and set the topmost probability rate per sta and per group
  */
 static void
-minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u8 index)
+minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, u16 index)
 {
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
@@ -427,8 +445,8 @@ minstrel_ht_set_best_prob_rate(struct minstrel_ht_sta *mi, 
u8 index)
  */
 static void
 minstrel_ht_assign_best_tp_rates(struct minstrel_ht_sta *mi,
-u8 tmp_mcs_tp_rate[MAX_THR_RATES],
-u8 tmp_cck_tp_rate[MAX_THR_RATES])
+u16 tmp_mcs_tp_rate[MAX_THR_RATES],
+u16 tmp_cck_tp_rate[MAX_THR_RATES])
 {
unsigned int tmp_group, tmp_idx, tmp_cck_tp, tmp_mcs_tp;
int i;
@@ -492,8 +510,8 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi)
struct minstrel_mcs_group_data *mg;
struct minstrel_rate_stats *mr;
int group, i, j;
-   u8 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
-   u8 tmp_cck_tp_rate[MAX_THR_RATES], index;
+   u16 tmp_mcs_tp_rate[MAX_THR_RATES], tmp_group_tp_rate[MAX_THR_RATES];
+   u16 tmp_cck_tp_rate[MAX_THR_RATES], index;

if (mi->ampdu_packets > 0) {
mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
diff --git a/net/mac80211/rc80211_minstrel_ht.h 
b/net/mac80211/rc80211_minstrel_ht.h
index 7856062..354e076 100644
--- a/net/mac80211/rc80211_minstrel_ht.h
+++ b/net/mac80211/rc80211_minstrel_ht.h
@@ -57,8 +57,8 @@ struct minstrel_mcs_group_data {
u16 supported;

/* sorted rate set within a MCS group*/
-   u8 max_group_tp_rate[MAX_THR_RATES];
-   u8 max_group_prob_rate;
+   u16 max_group_tp_rate[MAX_THR_RATES];
+   u16 max_group_prob_rate;

/* MCS rate statistics */
struct minstrel_rate_stats rates[MCS_GROUP_RATES];
@@ -75,8 +75,8 @@ struct minstrel_ht_sta {
unsigned int avg_ampdu_len;

/* overall sorted rate set */
-   u8 max_tp_rate[MAX_THR_RATES];
-   u8 max_prob_rate;
+   u16 max_tp_rate[MAX_THR_RATES];
+   u16 max_prob_rate;

/* time of last status update */
unsigned long stats_update;
}}}

With this I could not advertise the patch overhead-less when not setting
MAC80211_RC_MINSTREL_VHT, too invasive for a simple step to feel the
limits of the present implementation and a way to test vht tx path.

But maybe that's not what you had in mind for MINSTREL_*_MAX_STREAMS ?
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mac80211: minstrel_ht: add basic support for VHT rates <= 80MHz@NSS2

2014-09-28 Thread Karl Beldan
From: Karl Beldan 

When the new CONFIG_MAC80211_RC_MINSTREL_VHT is not set, there is no
behavioral change including in sampling and MCS_GROUP_RATES remains 8.
When it is, MCS_GROUP_RATES is 10 and we restrict to VHT rates for stats
readability (though it is possible to use both HT and VHT (unset
vht_only)).
---
 net/mac80211/Kconfig   |   7 +
 net/mac80211/rc80211_minstrel_ht.c | 263 +++--
 net/mac80211/rc80211_minstrel_ht.h |  33 +++-
 net/mac80211/rc80211_minstrel_ht_debugfs.c |  30 ++--
 4 files changed, 261 insertions(+), 72 deletions(-)

diff --git a/net/mac80211/Kconfig b/net/mac80211/Kconfig
index aeb6a48..39095a9 100644
--- a/net/mac80211/Kconfig
+++ b/net/mac80211/Kconfig
@@ -33,6 +33,13 @@ config MAC80211_RC_MINSTREL_HT
---help---
  This option enables the 'minstrel_ht' TX rate control algorithm
 
+config MAC80211_RC_MINSTREL_VHT
+   bool "Minstrel 802.11vht support" if EXPERT
+   depends on MAC80211_RC_MINSTREL_HT
+   default n
+   ---help---
+ This option enables vht in the 'minstrel_ht' TX rate control algorithm
+
 choice
prompt "Default rate control algorithm"
depends on MAC80211_HAS_RC
diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index 17ef54a..41522c7 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -34,12 +34,17 @@
 /* Transmit duration for the raw data part of an average sized packet */
 #define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, 
MCS_NSYMS((streams) * (bps)))
 
+#define BW_20  0
+#define BW_40  1
+#define BW_80  2
+
 /*
  * Define group sort order: HT40 -> SGI -> #streams
  */
 #define GROUP_IDX(_streams, _sgi, _ht40)   \
-   MINSTREL_MAX_STREAMS * 2 * _ht40 +  \
-   MINSTREL_MAX_STREAMS * _sgi +   \
+   MINSTREL_HT_GROUP_0 +   \
+   MINSTREL_HT_MAX_STREAMS * 2 * _ht40 +   \
+   MINSTREL_HT_MAX_STREAMS * _sgi +\
_streams - 1
 
 /* MCS rate information for an MCS group */
@@ -47,6 +52,7 @@
[GROUP_IDX(_streams, _sgi, _ht40)] = {  \
.streams = _streams,\
.flags =\
+   IEEE80211_TX_RC_MCS |   \
(_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | \
(_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0), \
.duration = {   \
@@ -61,6 +67,38 @@
}   \
 }
 
+#define VHT_GROUP_IDX(_streams, _sgi, _bw) \
+   (MINSTREL_VHT_GROUP_0 + \
+MINSTREL_VHT_MAX_STREAMS * 2 * (_bw) + \
+MINSTREL_VHT_MAX_STREAMS * (_sgi) +\
+(_streams) - 1)
+
+#define BW2VBPS(_bw, r3, r2, r1)   
\
+   (_bw == BW_80 ? r3 : _bw == BW_40 ? r2 : r1)
+
+#define VHT_GROUP(_streams, _sgi, _bw) 
\
+   [VHT_GROUP_IDX(_streams, _sgi, _bw)] = {
\
+   .streams = _streams,
\
+   .flags =
\
+   IEEE80211_TX_RC_VHT_MCS |   
\
+   (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) | 
\
+   (_bw == BW_80 ? IEEE80211_TX_RC_80_MHZ_WIDTH :  
\
+_bw == BW_40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),  
\
+   .duration = {   
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  117,  54,  26)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  234, 108,  52)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  351, 162,  78)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  468, 216, 104)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  702, 324, 156)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw,  936, 432, 208)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1053, 486, 234)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1170, 540, 260)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1404, 648, 312)), 
\
+   MCS_DURATION(_streams, _sgi, BW2VBPS(_bw, 1560, 720, 346))  
\
+   }   
\
+}
+
+
 #define CCK_DURATION(_bitrate, _short,

[PATCH] mac80211: minstrel_ht: fix MCS_GROUP_RATES usage

2014-09-28 Thread Karl Beldan
From: Karl Beldan 

Commit 4441e8e9 ("mac80211: improve minstrel_ht rate sorting by
throughput & probability") replaced the constant 8 with MCS_GROUP_RATES
when getting the number of streams of an HT MCS. See commit 7a5e3fa2
("mac80211: minstrel_ht: replace some occurences of MCS_GROUP_RATES").

Signed-off-by: Karl Beldan 
---
 net/mac80211/rc80211_minstrel_ht.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/rc80211_minstrel_ht.c 
b/net/mac80211/rc80211_minstrel_ht.c
index df90ce2..17ef54a 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -135,7 +135,7 @@ minstrel_ht_update_rates(struct minstrel_priv *mp, struct 
minstrel_ht_sta *mi);
 static int
 minstrel_ht_get_group_idx(struct ieee80211_tx_rate *rate)
 {
-   return GROUP_IDX((rate->idx / MCS_GROUP_RATES) + 1,
+   return GROUP_IDX((rate->idx / 8) + 1,
 !!(rate->flags & IEEE80211_TX_RC_SHORT_GI),
 !!(rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH));
 }
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/2] mac80211: improve minstrel_ht rate sorting by throughput & probability

2014-09-28 Thread Karl Beldan
On Tue, Sep 09, 2014 at 11:22:14PM +0200, Thomas Huehn wrote:
> This patch improves the way minstrel_ht sorts rates according to throughput
> and success probability. 3 FOR-loops across the entire rate and mcs group set
> in function minstrel_ht_update_stats() which where used to determine the
> fastest, second fastest and most robust rate are reduced to 2 FOR-loop.
> 
> The sorted list of rates according throughput is extended to the best four
> rates as we need them in upcoming joint rate and power control. The sorting
> is done via the new function minstrel_ht_sort_best_tp_rates(). The annotation
> of those 4 best throughput rates in the debugfs file rc-stats is changes to:
> "A,B,C,D", where A is the fastest rate and C the 4th fastest.
> 
> ---
> v2: fix coding style issues, thx the Felix Fietkau
> 
> Signed-off-by: Thomas Huehn 
> Tested-by: Stefan Venz 
> ---
>  net/mac80211/rc80211_minstrel_ht.c | 303 
> +++--
>  net/mac80211/rc80211_minstrel_ht.h |  19 +-
>  net/mac80211/rc80211_minstrel_ht_debugfs.c |  10 +-
>  3 files changed, 213 insertions(+), 119 deletions(-)
> 
> diff --git a/net/mac80211/rc80211_minstrel_ht.c 
> b/net/mac80211/rc80211_minstrel_ht.c
> index 85c1e74..df90ce2 100644
> --- a/net/mac80211/rc80211_minstrel_ht.c
> +++ b/net/mac80211/rc80211_minstrel_ht.c
> @@ -135,7 +135,7 @@ minstrel_ht_update_rates(struct minstrel_priv *mp, struct 
> minstrel_ht_sta *mi);
>  static int
>  minstrel_ht_get_group_idx(struct ieee80211_tx_rate *rate)
>  {
> - return GROUP_IDX((rate->idx / 8) + 1,
> + return GROUP_IDX((rate->idx / MCS_GROUP_RATES) + 1,
>!!(rate->flags & IEEE80211_TX_RC_SHORT_GI),
>!!(rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH));
>  }

Hi,

Here you should have kept 8, GROUP_IDX requires the number of streams.
I will rebase the vht RFC I sent a year ago tonight and also send the
fix for 7a5e3fa breakage.
 
Karl
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html