iwinfo: fix hwmodelist reporting for broadcom wl
authorHauke Mehrtens <hauke@hauke-m.de>
Mon, 11 Nov 2013 21:54:25 +0000 (21:54 +0000)
committerHauke Mehrtens <hauke@hauke-m.de>
Mon, 11 Nov 2013 21:54:25 +0000 (21:54 +0000)
Modify the hwmodelist reporting for broadcom devices to include
proper reporting of 802.11n support.

Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
SVN-Revision: 38745

package/network/utils/iwinfo/src/include/iwinfo/api/broadcom.h
package/network/utils/iwinfo/src/iwinfo_wl.c

index 50eedd9e49559ec07681111dcb80c057f9304714..c7aa33e41524980fff9ecdb89b9c59b3cc7c1da7 100644 (file)
@@ -26,7 +26,7 @@
 #define WLC_IOCTL_MAGIC                                0x14e46c77
 #define        WLC_IOCTL_MAXLEN                        8192
 
-#define WLC_CNTRY_BUF_SZ               4
+#define WLC_CNTRY_BUF_SZ                       4
 
 #define WLC_GET_MAGIC                          0
 #define WLC_GET_RATE                           12
 #define WLC_GET_BSSID                          23
 #define WLC_GET_SSID                           25
 #define WLC_GET_CHANNEL                                29
+#define WLC_GET_PHYTYPE                        39
 #define WLC_GET_PASSIVE                        48
 #define WLC_GET_COUNTRY                                83
 #define WLC_GET_REVINFO                                98
-#define WLC_GET_AP                                     117
+#define WLC_GET_AP                             117
 #define WLC_GET_RSSI                           127
 #define WLC_GET_WSEC                           133
 #define WLC_GET_PHY_NOISE                      135
 #define WLC_GET_BSS_INFO                       136
+#define WLC_GET_BANDLIST                       140
 #define WLC_GET_ASSOCLIST                      159
 #define WLC_GET_WPA_AUTH                       164
-#define WLC_GET_COUNTRY_LIST           261
-#define WLC_GET_VAR                                    262
+#define WLC_GET_COUNTRY_LIST                   261
+#define WLC_GET_VAR                            262
+
+#define WLC_PHY_TYPE_A                         0
+#define WLC_PHY_TYPE_B                         1
+#define WLC_PHY_TYPE_G                         2
+#define WLC_PHY_TYPE_N                         4
+#define WLC_PHY_TYPE_LP                                5
+
+#define WLC_BAND_5G                            1
+#define WLC_BAND_2G                            2
+#define WLC_BAND_ALL                           3
 
 
 struct wl_ether_addr {
@@ -117,6 +129,9 @@ typedef struct wlc_rev_info {
        uint            ucoderev;       /* microcode version */
        uint            bus;            /* bus type */
        uint            chipnum;        /* chip number */
+       uint            phytype;        /* phy type */
+       uint            phyrev;         /* phy revision */
+       uint            anarev;         /* anacore rev */
 } wlc_rev_info_t;
 
 typedef struct wl_country_list {
index 0a1439bb893aeaa541dab7123f5617da80ec6b8a..f5f0d4be78884c65a7ec388f04ef8f54c4bda888 100644 (file)
@@ -583,7 +583,46 @@ int wl_get_countrylist(const char *ifname, char *buf, int *len)
 
 int wl_get_hwmodelist(const char *ifname, int *buf)
 {
-       return wext_get_hwmodelist(ifname, buf);
+       int phytype;
+       uint i, band[WLC_BAND_ALL], bands;
+
+       if (!wl_ioctl(ifname, WLC_GET_PHYTYPE, &phytype, sizeof(phytype)) &&
+               !wl_ioctl(ifname, WLC_GET_BANDLIST, band, sizeof(band)))
+       {
+               switch (phytype)
+               {
+                       case WLC_PHY_TYPE_A:
+                               *buf = IWINFO_80211_A;
+                               break;
+                       case WLC_PHY_TYPE_B:
+                               *buf = IWINFO_80211_B;
+                               break;
+                       case WLC_PHY_TYPE_LP:
+                       case WLC_PHY_TYPE_G:
+                       case WLC_PHY_TYPE_N:
+                               bands = 0;
+                               for (i = 1; i <= band[0]; i++)
+                               {
+                                       bands |= band[i];
+                               }
+                               *buf = 0;
+                               if (bands & WLC_BAND_5G)
+                                       *buf |= IWINFO_80211_A;
+                               if (bands & WLC_BAND_2G)
+                               {
+                                       *buf |= IWINFO_80211_B;
+                                       *buf |= IWINFO_80211_G;
+                               }
+                               if (phytype == WLC_PHY_TYPE_N)
+                                       *buf |= IWINFO_80211_N;
+                               break;
+                       default:
+                               return -1;
+                               break;
+               }
+                       return 0;
+       }
+       return -1;
 }
 
 int wl_get_mbssid_support(const char *ifname, int *buf)