net80211 / LinuxKPI 802.11: correct enum ieee80211_sta_rx_bw

When moving the enum from LinuxKPI to net80211 it got adjusted to be
used in net80211 style in order to use it with a print_mask (%b).
Turns out that change broke assumptions given the minimum value of
BW_20 no longer was 0.  Adjust it back to a plain enum starting at 0
and use an inline function to convert to value names.

Pointy hat to:	bz
Fixes:		ca389486a9
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D48375
This commit is contained in:
Bjoern A. Zeeb 2024-12-29 08:07:48 +00:00
parent 5fdc4824a5
commit 2c8b0d6205
4 changed files with 25 additions and 13 deletions

View file

@ -294,9 +294,9 @@ _db_show_sta(const struct ieee80211_node *ni)
db_printf("\thtcap %b htparam 0x%x htctlchan %u ht2ndchan %u\n",
ni->ni_htcap, IEEE80211_HTCAP_BITS,
ni->ni_htparam, ni->ni_htctlchan, ni->ni_ht2ndchan);
db_printf("\thtopmode 0x%x htstbc 0x%x chw %b\n",
db_printf("\thtopmode 0x%x htstbc 0x%x chw %d (%s)\n",
ni->ni_htopmode, ni->ni_htstbc,
ni->ni_chw, IEEE80211_NI_CHW_BITS);
ni->ni_chw, ieee80211_ni_chw_to_str(ni->ni_chw));
/* XXX ampdu state */
for (i = 0; i < WME_NUM_TID; i++)

View file

@ -2604,8 +2604,8 @@ ht_recv_action_ht_txchwidth(struct ieee80211_node *ni,
IEEE80211_STA_RX_BW_40 : IEEE80211_STA_RX_BW_20;
IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, ni,
"%s: HT txchwidth, width %b%s",
__func__, chw, IEEE80211_NI_CHW_BITS, ni->ni_chw != chw ? "*" : "");
"%s: HT txchwidth, width %d%s (%s)", __func__,
chw, ni->ni_chw != chw ? "*" : "", ieee80211_ni_chw_to_str(chw));
if (chw != ni->ni_chw) {
/* XXX does this need to change the ht40 station count? */
ni->ni_chw = chw;

View file

@ -2672,9 +2672,9 @@ ieee80211_dump_node(struct ieee80211_node_table *nt __unused,
printf("\thtcap %x htparam %x htctlchan %u ht2ndchan %u\n",
ni->ni_htcap, ni->ni_htparam,
ni->ni_htctlchan, ni->ni_ht2ndchan);
printf("\thtopmode %x htstbc %x htchw %b\n",
printf("\thtopmode %x htstbc %x htchw %d (%s)\n",
ni->ni_htopmode, ni->ni_htstbc,
ni->ni_chw, IEEE80211_NI_CHW_BITS);
ni->ni_chw, ieee80211_ni_chw_to_str(ni->ni_chw));
printf("\tvhtcap %x freq1 %d freq2 %d vhtbasicmcs %x\n",
ni->ni_vhtcap, (int) ni->ni_vht_chan1, (int) ni->ni_vht_chan2,
(int) ni->ni_vht_basicmcs);

View file

@ -115,17 +115,29 @@ enum ieee80211_mesh_mlstate {
* flags. This allows us to keep the uint8_t slot for ni_chw in
* struct ieee80211_node and means we do not have to sync to the value for
* LinuxKPI.
*
* NB: BW_20 needs to 0 and values need to be sorted! Cannot make it
* bitfield-alike for use with %b.
*/
enum ieee80211_sta_rx_bw {
IEEE80211_STA_RX_BW_20 = 0x01,
IEEE80211_STA_RX_BW_40 = 0x02,
IEEE80211_STA_RX_BW_80 = 0x04,
IEEE80211_STA_RX_BW_160 = 0x08,
IEEE80211_STA_RX_BW_320 = 0x10,
IEEE80211_STA_RX_BW_20 = 0x00,
IEEE80211_STA_RX_BW_40,
IEEE80211_STA_RX_BW_80,
IEEE80211_STA_RX_BW_160,
IEEE80211_STA_RX_BW_320,
} __packed;
#define IEEE80211_NI_CHW_BITS \
"\20\1BW_20\2BW_40\3BW_80\4BW_160\5BW_320"
static inline const char *
ieee80211_ni_chw_to_str(enum ieee80211_sta_rx_bw bw)
{
switch (bw) {
case IEEE80211_STA_RX_BW_20: return ("BW_20");
case IEEE80211_STA_RX_BW_40: return ("BW_40");
case IEEE80211_STA_RX_BW_80: return ("BW_80");
case IEEE80211_STA_RX_BW_160: return ("BW_160");
case IEEE80211_STA_RX_BW_320: return ("BW_320");
}
}
/*
* Node specific information. Note that drivers are expected