@@ -1050,6 +1050,10 @@ ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate)
return (rate->idx >> 4) + 1;
}
+void ieee80211_rate_get_rate_info(const struct ieee80211_tx_rate *rate,
+ struct wiphy *wiphy, u8 band,
+ struct rate_info *rate_info);
+
/**
* struct ieee80211_tx_info - skb transmit information
*
@@ -4870,3 +4870,38 @@ void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos)
*len_pos = elem_len;
}
+
+
+void ieee80211_rate_get_rate_info(const struct ieee80211_tx_rate *rate,
+ struct wiphy *wiphy, u8 band,
+ struct rate_info *rate_info)
+{
+ memset(rate_info, 0, sizeof(struct rate_info));
+
+ if (rate->flags & IEEE80211_TX_RC_MCS) { /* 802.11n */
+ rate_info->flags |= RATE_INFO_FLAGS_MCS;
+ rate_info->mcs = rate->idx;
+ } else if (rate->flags & IEEE80211_TX_RC_VHT_MCS) { /* 802.11ac */
+ rate_info->flags |= RATE_INFO_FLAGS_VHT_MCS;
+ rate_info->mcs = ieee80211_rate_get_vht_mcs(rate);
+ rate_info->nss = ieee80211_rate_get_vht_nss(rate);
+ } else { /* 802.11a/b/g */
+ rate_info->legacy = wiphy->bands[band]->bitrates[rate->idx].bitrate;
+ rate_info->bw = RATE_INFO_BW_20;
+ return;
+ }
+
+ if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
+ rate_info->bw = RATE_INFO_BW_40;
+ else if (rate->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
+ rate_info->bw = RATE_INFO_BW_80;
+ else if (rate->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
+ rate_info->bw = RATE_INFO_BW_160;
+ else
+ rate_info->bw = RATE_INFO_BW_20;
+
+ if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
+ rate_info->flags |= RATE_INFO_FLAGS_SHORT_GI;
+
+}
+EXPORT_SYMBOL(ieee80211_rate_get_rate_info);
This patch adds an utility function to mac80211 for conversion between ieee80211_tx_rate (mac80211.h) and rate_info (cfg80211.h). struct ieee80211_tx_rate is space limited to annotate rates up to IEEE 802.11ac. The new struct rate_info is able to annotate IEEE 802.11ax rates and beyond. Several drivers internally still use ieee80211_tx_rate but mac80211 expects rate_info in struct ieee80211_rate_status. This struct is in turn required to allow, e.g., tx-power status report or dynamic number of mrr stages. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> --- include/net/mac80211.h | 4 ++++ net/mac80211/util.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+)