The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=31a8b9782dc354ebd735db7036d7945f160b2527
commit 31a8b9782dc354ebd735db7036d7945f160b2527 Author: Adrian Chadd <adr...@freebsd.org> AuthorDate: 2024-12-27 03:30:22 +0000 Commit: Adrian Chadd <adr...@freebsd.org> CommitDate: 2025-01-17 16:04:58 +0000 iwm: update rate tables from OpenBSD These are from an earlier version of the driver (22-Oct-2021) which I started to sync against back in 2021. These pull in the rest of the VHT and HT rates. Since that driver has functioning 802.11n support, it makes a good intermediary checkpoint. Locally tested: * 7260, STA mode, 11g and 11a modes Differential Revision: https://reviews.freebsd.org/D48209 Obtained from: OpenBSD (at a6e25c727a2214219715b51ba6af2221d7e0d674, 22-Oct-2021) --- sys/dev/iwm/if_iwm.c | 62 +++++++++++++++++++++++++++++++++++-------------- sys/dev/iwm/if_iwmreg.h | 24 +++++++++++-------- 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c index c8eb46ed9795..15ef139fd5a5 100644 --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -197,32 +197,60 @@ _Static_assert(nitems(iwm_nvm_channels_8000) <= IWM_NUM_CHANNELS_8000, #define IWM_NUM_2GHZ_CHANNELS 14 #define IWM_N_HW_ADDR_MASK 0xF -/* - * XXX For now, there's simply a fixed set of rate table entries - * that are populated. - */ const struct iwm_rate { - uint8_t rate; + uint16_t rate; uint8_t plcp; + uint8_t ht_plcp; } iwm_rates[] = { - { 2, IWM_RATE_1M_PLCP }, - { 4, IWM_RATE_2M_PLCP }, - { 11, IWM_RATE_5M_PLCP }, - { 22, IWM_RATE_11M_PLCP }, - { 12, IWM_RATE_6M_PLCP }, - { 18, IWM_RATE_9M_PLCP }, - { 24, IWM_RATE_12M_PLCP }, - { 36, IWM_RATE_18M_PLCP }, - { 48, IWM_RATE_24M_PLCP }, - { 72, IWM_RATE_36M_PLCP }, - { 96, IWM_RATE_48M_PLCP }, - { 108, IWM_RATE_54M_PLCP }, + /* Legacy */ /* HT */ + { 2, IWM_RATE_1M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 4, IWM_RATE_2M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 11, IWM_RATE_5M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 22, IWM_RATE_11M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 12, IWM_RATE_6M_PLCP, IWM_RATE_HT_SISO_MCS_0_PLCP }, + { 18, IWM_RATE_9M_PLCP, IWM_RATE_HT_SISO_MCS_INV_PLCP }, + { 24, IWM_RATE_12M_PLCP, IWM_RATE_HT_SISO_MCS_1_PLCP }, + { 26, IWM_RATE_INVM_PLCP, IWM_RATE_HT_MIMO2_MCS_8_PLCP }, + { 36, IWM_RATE_18M_PLCP, IWM_RATE_HT_SISO_MCS_2_PLCP }, + { 48, IWM_RATE_24M_PLCP, IWM_RATE_HT_SISO_MCS_3_PLCP }, + { 52, IWM_RATE_INVM_PLCP, IWM_RATE_HT_MIMO2_MCS_9_PLCP }, + { 72, IWM_RATE_36M_PLCP, IWM_RATE_HT_SISO_MCS_4_PLCP }, + { 78, IWM_RATE_INVM_PLCP, IWM_RATE_HT_MIMO2_MCS_10_PLCP }, + { 96, IWM_RATE_48M_PLCP, IWM_RATE_HT_SISO_MCS_5_PLCP }, + { 104, IWM_RATE_INVM_PLCP, IWM_RATE_HT_MIMO2_MCS_11_PLCP }, + { 108, IWM_RATE_54M_PLCP, IWM_RATE_HT_SISO_MCS_6_PLCP }, + { 128, IWM_RATE_INVM_PLCP, IWM_RATE_HT_SISO_MCS_7_PLCP }, + { 156, IWM_RATE_INVM_PLCP, IWM_RATE_HT_MIMO2_MCS_12_PLCP }, + { 208, IWM_RATE_INVM_PLCP, IWM_RATE_HT_MIMO2_MCS_13_PLCP }, + { 234, IWM_RATE_INVM_PLCP, IWM_RATE_HT_MIMO2_MCS_14_PLCP }, + { 260, IWM_RATE_INVM_PLCP, IWM_RATE_HT_MIMO2_MCS_15_PLCP }, }; #define IWM_RIDX_CCK 0 #define IWM_RIDX_OFDM 4 #define IWM_RIDX_MAX (nitems(iwm_rates)-1) #define IWM_RIDX_IS_CCK(_i_) ((_i_) < IWM_RIDX_OFDM) #define IWM_RIDX_IS_OFDM(_i_) ((_i_) >= IWM_RIDX_OFDM) +#define IWM_RVAL_IS_OFDM(_i_) ((_i_) >= 12 && (_i_) != 22) + +/* Convert an MCS index into an iwm_rates[] index. */ +const int iwm_mcs2ridx[] = { + IWM_RATE_MCS_0_INDEX, + IWM_RATE_MCS_1_INDEX, + IWM_RATE_MCS_2_INDEX, + IWM_RATE_MCS_3_INDEX, + IWM_RATE_MCS_4_INDEX, + IWM_RATE_MCS_5_INDEX, + IWM_RATE_MCS_6_INDEX, + IWM_RATE_MCS_7_INDEX, + IWM_RATE_MCS_8_INDEX, + IWM_RATE_MCS_9_INDEX, + IWM_RATE_MCS_10_INDEX, + IWM_RATE_MCS_11_INDEX, + IWM_RATE_MCS_12_INDEX, + IWM_RATE_MCS_13_INDEX, + IWM_RATE_MCS_14_INDEX, + IWM_RATE_MCS_15_INDEX, +}; struct iwm_nvm_section { uint16_t length; diff --git a/sys/dev/iwm/if_iwmreg.h b/sys/dev/iwm/if_iwmreg.h index d9c7bb7a89f9..296d07bc4b31 100644 --- a/sys/dev/iwm/if_iwmreg.h +++ b/sys/dev/iwm/if_iwmreg.h @@ -4481,9 +4481,7 @@ struct iwm_beacon_filter_cmd { #define IWM_RATE_HT_SISO_MCS_9_PLCP IWM_RATE_HT_SISO_MCS_INV_PLCP /* - * These serve as indexes into - * struct iwm_rate_info fw_rate_idx_to_plcp[IWM_RATE_COUNT]; - * TODO: avoid overlap between legacy and HT rates + * These serve as indexes into struct iwm_rate iwm_rates[IWM_RIDX_MAX]. */ enum { IWM_RATE_1M_INDEX = 0, @@ -4500,28 +4498,34 @@ enum { IWM_RATE_9M_INDEX, IWM_RATE_12M_INDEX, IWM_RATE_MCS_1_INDEX = IWM_RATE_12M_INDEX, + IWM_RATE_MCS_8_INDEX, + IWM_FIRST_HT_MIMO2_RATE = IWM_RATE_MCS_8_INDEX, IWM_RATE_18M_INDEX, IWM_RATE_MCS_2_INDEX = IWM_RATE_18M_INDEX, IWM_RATE_24M_INDEX, IWM_RATE_MCS_3_INDEX = IWM_RATE_24M_INDEX, + IWM_RATE_MCS_9_INDEX, IWM_RATE_36M_INDEX, IWM_RATE_MCS_4_INDEX = IWM_RATE_36M_INDEX, + IWM_RATE_MCS_10_INDEX, IWM_RATE_48M_INDEX, IWM_RATE_MCS_5_INDEX = IWM_RATE_48M_INDEX, + IWM_RATE_MCS_11_INDEX, IWM_RATE_54M_INDEX, IWM_RATE_MCS_6_INDEX = IWM_RATE_54M_INDEX, IWM_LAST_NON_HT_RATE = IWM_RATE_54M_INDEX, - IWM_RATE_60M_INDEX, - IWM_RATE_MCS_7_INDEX = IWM_RATE_60M_INDEX, - IWM_LAST_HT_RATE = IWM_RATE_MCS_7_INDEX, - IWM_RATE_MCS_8_INDEX, - IWM_RATE_MCS_9_INDEX, + IWM_RATE_MCS_7_INDEX, + IWM_LAST_HT_SISO_RATE = IWM_RATE_MCS_7_INDEX, + IWM_RATE_MCS_12_INDEX, + IWM_RATE_MCS_13_INDEX, + IWM_RATE_MCS_14_INDEX, + IWM_RATE_MCS_15_INDEX, + IWM_LAST_HT_RATE = IWM_RATE_MCS_15_INDEX, IWM_LAST_VHT_RATE = IWM_RATE_MCS_9_INDEX, IWM_RATE_COUNT_LEGACY = IWM_LAST_NON_HT_RATE + 1, - IWM_RATE_COUNT = IWM_LAST_VHT_RATE + 1, + IWM_RATE_COUNT = IWM_LAST_HT_RATE + 1, }; - #define IWM_RATE_BIT_MSK(r) (1 << (IWM_RATE_##r##M_INDEX)) /* fw API values for legacy bit rates, both OFDM and CCK */