Message ID | 20220920104032.496697-5-jelonek.jonas@gmail.com |
---|---|
State | New |
Headers | show |
Series | mac80211: add TPC support in control path | expand |
On Tue, 2022-09-20 at 12:40 +0200, Jonas Jelonek wrote: > 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(+) > > diff --git a/include/net/mac80211.h b/include/net/mac80211.h > index c4b55c7273ed..f17a03caa361 100644 > --- a/include/net/mac80211.h > +++ b/include/net/mac80211.h > @@ -1051,6 +1051,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 > * > diff --git a/net/mac80211/util.c b/net/mac80211/util.c > index 0ea5d50091dc..c76dc255bec3 100644 > --- a/net/mac80211/util.c > +++ b/net/mac80211/util.c > @@ -4867,3 +4867,38 @@ void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos) > > *len_pos = elem_len; > } > + > + nit: use just one blank line. johannes > +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 */ what about HE/EHT? johannes
> On 12. Jan 2023, at 11:26, Johannes Berg <johannes@sipsolutions.net> wrote: > >> +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 */ > > what about HE/EHT? ieee80211_tx_rate uses an s8 for rate/MCS index, so only up to VHT rates fit in there. For rates above VHT, rate_info is needed, thus are are no HE/EHT rates occuring in ieee80211_tx_rate. Same applies to your comment on the hwsim conversion. Jonas
On Thu, 2023-01-19 at 12:31 +0100, Jonas Jelonek wrote: > > On 12. Jan 2023, at 11:26, Johannes Berg <johannes@sipsolutions.net> > > wrote: > > > > > +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 */ > > > > what about HE/EHT? > > ieee80211_tx_rate uses an s8 for rate/MCS index, so only up to VHT > rates fit in there. > For rates above VHT, rate_info is needed, thus are are no HE/EHT rates > occuring in > ieee80211_tx_rate. Same applies to your comment on the hwsim > conversion. I guess I should've read the commit message more closely ;-) But please add kernel-doc to the function; both in general it'd be good to have, and in particular explaining that this is more for older drivers I guess? johannes
> On 19. Jan 2023, at 12:35, Johannes Berg <johannes@sipsolutions.net> wrote: > > On Thu, 2023-01-19 at 12:31 +0100, Jonas Jelonek wrote: >>> On 12. Jan 2023, at 11:26, Johannes Berg <johannes@sipsolutions.net> >>> wrote: >>> >>>> +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 */ >>> >>> what about HE/EHT? >> >> ieee80211_tx_rate uses an s8 for rate/MCS index, so only up to VHT >> rates fit in there. >> For rates above VHT, rate_info is needed, thus are are no HE/EHT rates >> occuring in >> ieee80211_tx_rate. Same applies to your comment on the hwsim >> conversion. > > I guess I should've read the commit message more closely ;-) > > But please add kernel-doc to the function; both in general it'd be good > to have, and in particular explaining that this is more for older > drivers I guess? I will add that in my next RFC version to make sure this is clear. Jonas
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index c4b55c7273ed..f17a03caa361 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1051,6 +1051,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 * diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 0ea5d50091dc..c76dc255bec3 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -4867,3 +4867,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(+)