]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
HT fixups
authorJohannes Berg <johannes@sipsolutions.net>
Tue, 8 Dec 2009 08:58:20 +0000 (09:58 +0100)
committerJohannes Berg <johannes@sipsolutions.net>
Tue, 8 Dec 2009 08:58:20 +0000 (09:58 +0100)
info.c
iw.h
scan.c
util.c

diff --git a/info.c b/info.c
index 9de7458375319d5447e0918c415aeb886df57573..4a86377077d4a74948bd6bdd5db03baffce412b5 100644 (file)
--- a/info.c
+++ b/info.c
@@ -21,24 +21,6 @@ static void print_flag(const char *name, int *open)
        *open = 1;
 }
 
-static void print_mcs_index(unsigned char *mcs)
-{
-       unsigned int mcs_bit;
-
-       for (mcs_bit = 0; mcs_bit <= 76; mcs_bit++) {
-               unsigned int mcs_octet = mcs_bit/8;
-               unsigned int MCS_RATE_BIT = 1 << mcs_bit % 8;
-               bool mcs_rate_idx_set;
-
-               mcs_rate_idx_set = !!(mcs[mcs_octet] & MCS_RATE_BIT);
-
-               if (!mcs_rate_idx_set)
-                       continue;
-
-               printf("\t\t\tMCS index %d\n", mcs_bit);
-       }
-}
-
 static int print_phy_handler(struct nl_msg *msg, void *arg)
 {
        struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
@@ -107,14 +89,10 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
                        unsigned char *mcs = nla_data(tb_band[NL80211_BAND_ATTR_HT_MCS_SET]);
                        bool tx_mcs_set_defined, tx_mcs_set_equal, tx_unequal_modulation;
 
-                       printf("\t\tHT MCS set:");
-                       print_mcs_set(mcs);
-                       printf("\n");
-
                        max_rx_supp_data_rate = ((mcs[10] >> 8) & ((mcs[11] & 0x3) << 8));
                        tx_mcs_set_defined = !!(mcs[12] & (1 << 0));
                        tx_mcs_set_equal = !(mcs[12] & (1 << 1));
-                       tx_max_num_spatial_streams = (mcs[12] & ((1 << 2) | (1 << 3))) + 1;
+                       tx_max_num_spatial_streams = ((mcs[12] >> 2) & 3) + 1;
                        tx_unequal_modulation = !!(mcs[12] & (1 << 4));
 
                        if (max_rx_supp_data_rate)
@@ -126,22 +104,22 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
                                        printf("\t\tHT TX/RX MCS rate indexes supported:\n");
                                        print_mcs_index(&mcs[0]);
                                } else {
-                                       printf("\t\tHT RX MCS rate indexes supported:\n");
+                                       printf("\t\tHT RX MCS rate indexes supported:");
                                        print_mcs_index(&mcs[0]);
 
                                        if (tx_unequal_modulation)
-                                               printf("TX unequal modulation supported\n");
+                                               printf("\t\tTX unequal modulation supported\n");
                                        else
-                                               printf("TX unequal modulation not supported\n");
+                                               printf("\t\tTX unequal modulation not supported\n");
 
-                                       printf("\t\tHT TX Max spatiel streams: %d\n",
+                                       printf("\t\tHT TX Max spatial streams: %d\n",
                                                tx_max_num_spatial_streams);
 
                                        printf("\t\tHT TX MCS rate indexes supported may differ\n");
                                }
                        }
                        else {
-                               printf("\t\tHT RX MCS rate indexes supported:\n");
+                               printf("\t\tHT RX MCS rate indexes supported:");
                                print_mcs_index(&mcs[0]);
                                printf("\t\tHT TX MCS rates indexes are undefined\n");
                        }
diff --git a/iw.h b/iw.h
index a7545610db1f8ea56f7d55d1b7c0d9a01642f8d4..f480dbd1c5f977a97e1763edab5bf373dd84d3af 100644 (file)
--- a/iw.h
+++ b/iw.h
@@ -120,7 +120,7 @@ void mac_addr_n2a(char *mac_addr, unsigned char *arg);
 
 int parse_keys(struct nl_msg *msg, char **argv, int argc);
 
-void print_mcs_set(const uint8_t *data);
+void print_mcs_index(__u8 *mcs);
 void print_ampdu_length(__u8 exponent);
 void print_ampdu_spacing(__u8 spacing);
 void print_ht_capability(__u16 cap);
diff --git a/scan.c b/scan.c
index bf2ec551f0362d6d3e9f686257fb49bc2a4def53..16bb5464caecef37e80a2d2ed696aff10489f85e 100644 (file)
--- a/scan.c
+++ b/scan.c
@@ -447,8 +447,7 @@ static void print_ht_capa(const uint8_t type, uint8_t len, const uint8_t *data)
                __u8 asel_cap;
        } __attribute__((packed)) ht_cap;
        struct ht_cap_data *htc = &ht_cap;
-       __u8 ampdu_exponent, ampdu_spacing, bit;
-       __u32 i;
+       __u8 ampdu_exponent, ampdu_spacing;
        bool tx_rx_mcs_equal = false;
 
        if (len != 26) {
@@ -468,32 +467,14 @@ static void print_ht_capa(const uint8_t type, uint8_t len, const uint8_t *data)
        ampdu_spacing = (htc->ampdu_params >> 2) & 0x3;
        print_ampdu_spacing(ampdu_spacing);
 
-       /* This is the whole MCS set, which is 16 bytes */
-       printf("\t\tMCS set:");
-       data+=2;
-       print_mcs_set(data);
-       printf("\n");
-
        if (htc->mcs_set.tx_rx_mcs_defined && htc->mcs_set.tx_rx_mcs_not_equal)
                tx_rx_mcs_equal = true;
        if (tx_rx_mcs_equal)
-               printf("\t\tSupported TX/RX MCS Indexes:\n");
+               printf("\t\tSupported TX/RX MCS Indexes:");
        else
-               printf("\t\tSupported RX MCS Indexes:\n");
-       /*
-        * Parses the RX MCS rates. Only 10 bits correspond to actual MCS rates
-        * MCS [0-76]
-        */
-       for (i = 0; i < 10; i++) {
-               for (bit = 0; bit < 8; bit++) {
-                       /* Only bits 0-76 are valid, bits 76-79 are reserved */
-                       if (((i * 8) + bit) > 76)
-                               break;
-                       if (htc->mcs_set.rx_mcs_bitmask[i] & BIT(bit))
-                               printf("\t\t\tMCS Index %d\n",
-                                      (i * 8) + bit);
-               }
-       }
+               printf("\t\tSupported RX MCS Indexes:");
+
+       print_mcs_index(htc->mcs_set.rx_mcs_bitmask);
 
        if (!htc->mcs_set.tx_rx_mcs_defined) {
                /* This is actually quite common */
diff --git a/util.c b/util.c
index f017b883834d7844e75d3ae287c07daf72c084c9..50ea9f51f96711240ac8a36a8702ad698d2025d4 100644 (file)
--- a/util.c
+++ b/util.c
@@ -293,13 +293,38 @@ int parse_keys(struct nl_msg *msg, char **argv, int argc)
        return 2;
 }
 
-void print_mcs_set(const uint8_t *data)
+void print_mcs_index(__u8 *mcs)
 {
-       unsigned int i;
+       unsigned int mcs_bit, prev_bit = -2, prev_cont = 0;
+
+       for (mcs_bit = 0; mcs_bit <= 76; mcs_bit++) {
+               unsigned int mcs_octet = mcs_bit/8;
+               unsigned int MCS_RATE_BIT = 1 << mcs_bit % 8;
+               bool mcs_rate_idx_set;
+
+               mcs_rate_idx_set = !!(mcs[mcs_octet] & MCS_RATE_BIT);
+
+               if (!mcs_rate_idx_set)
+                       continue;
+
+               if (prev_bit != mcs_bit - 1) {
+                       if (prev_bit != -2)
+                               printf("%d, ", prev_bit);
+                       else
+                               printf(" ");
+                       printf("%d", mcs_bit);
+                       prev_cont = 0;
+               } else if (!prev_cont) {
+                       printf("-");
+                       prev_cont = 1;
+               }
+
+               prev_bit = mcs_bit;
+       }
 
-        for (i = 15; i != 0; i--) {
-                printf(" %.2x", data[i]);
-        }
+       if (prev_cont)
+               printf("%d", prev_bit);
+       printf("\n");
 }
 
 /*
@@ -337,7 +362,7 @@ static const char *print_ampdu_space(__u8 space)
 
 void print_ampdu_length(__u8 exponent)
 {
-       __u8 max_ampdu_length;
+       __u32 max_ampdu_length;
 
        max_ampdu_length = compute_ampdu_length(exponent);