5cce4936e14f2d8d0973b4b1eef6235cfc1df2d8
[openwrt/staging/hauke.git] /
1 From: Chaitanya T K <chaitanya.mgit@gmail.com>
2 Date: Mon, 27 Jun 2016 15:23:26 +0530
3 Subject: [PATCH] mac80211: minstrel: Enable STBC and LDPC for VHT Rates
4
5 If peer support reception of STBC and LDPC, enable them for better
6 performance.
7
8 Signed-off-by: Chaitanya TK <chaitanya.mgit@gmail.com>
9 ---
10
11 --- a/include/linux/ieee80211.h
12 +++ b/include/linux/ieee80211.h
13 @@ -1659,6 +1659,7 @@ struct ieee80211_mu_edca_param_set {
14 #define IEEE80211_VHT_CAP_RXSTBC_3 0x00000300
15 #define IEEE80211_VHT_CAP_RXSTBC_4 0x00000400
16 #define IEEE80211_VHT_CAP_RXSTBC_MASK 0x00000700
17 +#define IEEE80211_VHT_CAP_RXSTBC_SHIFT 8
18 #define IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE 0x00000800
19 #define IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE 0x00001000
20 #define IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT 13
21 --- a/net/mac80211/rc80211_minstrel_ht.c
22 +++ b/net/mac80211/rc80211_minstrel_ht.c
23 @@ -1136,13 +1136,14 @@ minstrel_ht_update_caps(void *priv, stru
24 struct minstrel_ht_sta_priv *msp = priv_sta;
25 struct minstrel_ht_sta *mi = &msp->ht;
26 struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
27 - u16 sta_cap = sta->ht_cap.cap;
28 + u16 ht_cap = sta->ht_cap.cap;
29 struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
30 int use_vht;
31 int n_supported = 0;
32 int ack_dur;
33 int stbc;
34 int i;
35 + bool ldpc = false;
36
37 /* fall back to the old minstrel for legacy stations */
38 if (!sta->ht_cap.ht_supported)
39 @@ -1180,16 +1181,24 @@ minstrel_ht_update_caps(void *priv, stru
40 }
41 mi->sample_tries = 4;
42
43 - /* TODO tx_flags for vht - ATM the RC API is not fine-grained enough */
44 if (!use_vht) {
45 - stbc = (sta_cap & IEEE80211_HT_CAP_RX_STBC) >>
46 + stbc = (ht_cap & IEEE80211_HT_CAP_RX_STBC) >>
47 IEEE80211_HT_CAP_RX_STBC_SHIFT;
48 - mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
49
50 - if (sta_cap & IEEE80211_HT_CAP_LDPC_CODING)
51 - mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
52 + if (ht_cap & IEEE80211_HT_CAP_LDPC_CODING)
53 + ldpc = true;
54 + } else {
55 + stbc = (vht_cap->cap & IEEE80211_VHT_CAP_RXSTBC_MASK) >>
56 + IEEE80211_VHT_CAP_RXSTBC_SHIFT;
57 +
58 + if (vht_cap->cap & IEEE80211_VHT_CAP_RXLDPC)
59 + ldpc = true;
60 }
61
62 + mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
63 + if (ldpc)
64 + mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
65 +
66 for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
67 u32 gflags = minstrel_mcs_groups[i].flags;
68 int bw, nss;
69 @@ -1202,10 +1211,10 @@ minstrel_ht_update_caps(void *priv, stru
70
71 if (gflags & IEEE80211_TX_RC_SHORT_GI) {
72 if (gflags & IEEE80211_TX_RC_40_MHZ_WIDTH) {
73 - if (!(sta_cap & IEEE80211_HT_CAP_SGI_40))
74 + if (!(ht_cap & IEEE80211_HT_CAP_SGI_40))
75 continue;
76 } else {
77 - if (!(sta_cap & IEEE80211_HT_CAP_SGI_20))
78 + if (!(ht_cap & IEEE80211_HT_CAP_SGI_20))
79 continue;
80 }
81 }