]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Clean up VHT configuration validation
authorJouni Malinen <j@w1.fi>
Sun, 14 Dec 2014 17:00:38 +0000 (19:00 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 14 Dec 2014 17:00:38 +0000 (19:00 +0200)
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>
src/ap/hw_features.c
src/common/ieee802_11_defs.h

index 318c12a36ec9a65f7cba039c658e744dfec75857..f959215d43b457b3a4505cdee58d291762aa041e 100644 (file)
@@ -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)
 
index 191bed2231bf450bb4174ddb3b81f4a53c2841e6..dfe0fafd3ad11d69e181682a42067c57ad6c66c6 100644 (file)
@@ -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))