Clean up VHT configuration validation
There is no need to use runtime call to find_first_bit() to determine shift amount for a constant integer. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
b0f33467a5
commit
9ae52e7034
2 changed files with 11 additions and 6 deletions
|
@ -852,16 +852,16 @@ static int ieee80211ac_cap_check(u32 hw, u32 conf, u32 cap, const char *name)
|
|||
}
|
||||
|
||||
|
||||
static int ieee80211ac_cap_check_max(u32 hw, u32 conf, u32 cap,
|
||||
static int ieee80211ac_cap_check_max(u32 hw, u32 conf, u32 mask,
|
||||
unsigned int shift,
|
||||
const char *name)
|
||||
{
|
||||
u32 hw_max = hw & cap;
|
||||
u32 conf_val = conf & cap;
|
||||
u32 hw_max = hw & mask;
|
||||
u32 conf_val = conf & mask;
|
||||
|
||||
if (conf_val > hw_max) {
|
||||
int offset = find_first_bit(cap);
|
||||
wpa_printf(MSG_ERROR, "Configured VHT capability [%s] exceeds max value supported by the driver (%d > %d)",
|
||||
name, conf_val >> offset, hw_max >> offset);
|
||||
name, conf_val >> shift, hw_max >> shift);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
@ -884,7 +884,8 @@ static int ieee80211ac_supported_vht_capab(struct hostapd_iface *iface)
|
|||
|
||||
#define VHT_CAP_CHECK_MAX(cap) \
|
||||
do { \
|
||||
if (!ieee80211ac_cap_check_max(hw, conf, cap, #cap)) \
|
||||
if (!ieee80211ac_cap_check_max(hw, conf, cap, cap ## _SHIFT, \
|
||||
#cap)) \
|
||||
return 0; \
|
||||
} while (0)
|
||||
|
||||
|
|
|
@ -799,6 +799,7 @@ struct ieee80211_ampe_ie {
|
|||
#define VHT_CAP_MAX_MPDU_LENGTH_7991 ((u32) BIT(0))
|
||||
#define VHT_CAP_MAX_MPDU_LENGTH_11454 ((u32) BIT(1))
|
||||
#define VHT_CAP_MAX_MPDU_LENGTH_MASK ((u32) BIT(0) | BIT(1))
|
||||
#define VHT_CAP_MAX_MPDU_LENGTH_MASK_SHIFT 0
|
||||
#define VHT_CAP_SUPP_CHAN_WIDTH_160MHZ ((u32) BIT(2))
|
||||
#define VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ ((u32) BIT(3))
|
||||
#define VHT_CAP_SUPP_CHAN_WIDTH_MASK ((u32) BIT(2) | BIT(3))
|
||||
|
@ -812,13 +813,16 @@ struct ieee80211_ampe_ie {
|
|||
#define VHT_CAP_RXSTBC_4 ((u32) BIT(10))
|
||||
#define VHT_CAP_RXSTBC_MASK ((u32) BIT(8) | BIT(9) | \
|
||||
BIT(10))
|
||||
#define VHT_CAP_RXSTBC_MASK_SHIFT 8
|
||||
#define VHT_CAP_SU_BEAMFORMER_CAPABLE ((u32) BIT(11))
|
||||
#define VHT_CAP_SU_BEAMFORMEE_CAPABLE ((u32) BIT(12))
|
||||
#define VHT_CAP_BEAMFORMEE_STS_MAX ((u32) BIT(13) | \
|
||||
BIT(14) | BIT(15))
|
||||
#define VHT_CAP_BEAMFORMEE_STS_MAX_SHIFT 13
|
||||
#define VHT_CAP_BEAMFORMEE_STS_OFFSET 13
|
||||
#define VHT_CAP_SOUNDING_DIMENSION_MAX ((u32) BIT(16) | \
|
||||
BIT(17) | BIT(18))
|
||||
#define VHT_CAP_SOUNDING_DIMENSION_MAX_SHIFT 16
|
||||
#define VHT_CAP_SOUNDING_DIMENSION_OFFSET 16
|
||||
#define VHT_CAP_MU_BEAMFORMER_CAPABLE ((u32) BIT(19))
|
||||
#define VHT_CAP_MU_BEAMFORMEE_CAPABLE ((u32) BIT(20))
|
||||
|
|
Loading…
Reference in a new issue