iwinfo: nl80211: use new path lookup function for nl80211_phy_idx_from_uci_path
[project/iwinfo.git] / iwinfo_nl80211.c
index 5990c782184063483d7fc0512a45b6c84c071e74..8decdb0ad9be06d528650d76bbcb5e3cef6f9d1c 100644 (file)
@@ -233,52 +233,99 @@ static struct nl80211_msg_conveyor * nl80211_ctl(int cmd, int flags)
        return nl80211_new(nls->nlctrl, cmd, flags);
 }
 
-static int nl80211_phy_idx_from_uci_path(struct uci_section *s)
+static const char *nl80211_phy_path_str(const char *phyname)
 {
-       size_t linklen, pathlen;
-       char buf[128], *link;
+       static char path[PATH_MAX];
+       const char *prefix = "/sys/devices/";
+       int prefix_len = strlen(prefix);
+       int buf_len, offset;
        struct dirent *e;
-       const char *path;
-       int idx = -1;
+       char buf[128], *link;
+       int phy_id;
+       int seq = 0;
        DIR *d;
 
-       path = uci_lookup_option_string(uci_ctx, s, "path");
-       if (!path)
-               return -1;
+       if (strncmp(phyname, "phy", 3) != 0)
+               return NULL;
 
-       if ((d = opendir("/sys/class/ieee80211")) != NULL)
-       {
-               while ((e = readdir(d)) != NULL)
-               {
-                       snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/device", e->d_name);
+       phy_id = atoi(phyname + 3);
+       buf_len = snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/device", phyname);
+       link = realpath(buf, path);
+       if (!link)
+               return NULL;
 
-                       link = realpath(buf, NULL);
+       if (strncmp(link, prefix, prefix_len) != 0)
+               return NULL;
 
-                       if (link == NULL)
-                               continue;
+       link += prefix_len;
 
-                       linklen = strlen(link);
-                       pathlen = strlen(path);
+       prefix = "platform/";
+       prefix_len = strlen(prefix);
+       if (!strncmp(link, prefix, prefix_len) && strstr(link, "/pci"))
+               link += prefix_len;
 
-                       if (pathlen >= linklen || strcmp(link + (linklen - pathlen), path))
-                               linklen = 0;
+       snprintf(buf + buf_len, sizeof(buf) - buf_len, "/ieee80211");
+       d = opendir(buf);
+       if (!d)
+               return link;
 
-                       free(link);
+       while ((e = readdir(d)) != NULL) {
+               int cur_id;
 
-                       if (linklen == 0)
-                               continue;
+               if (strncmp(e->d_name, "phy", 3) != 0)
+                       continue;
 
-                       snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", e->d_name);
+               cur_id = atoi(e->d_name + 3);
+               if (cur_id >= phy_id)
+                       continue;
 
-                       idx = nl80211_readint(buf);
+               seq++;
+       }
 
-                       if (idx >= 0)
-                               break;
-               }
+       closedir(d);
 
-               closedir(d);
+       if (!seq)
+               return link;
+
+       offset = link - path + strlen(link);
+       snprintf(path + offset, sizeof(path) - offset, "+%d", seq);
+
+       return link;
+}
+
+static int nl80211_phy_idx_from_uci_path(struct uci_section *s)
+{
+       char buf[128];
+       struct dirent *e;
+       const char *path, *cur_path;
+       int idx = -1;
+       DIR *d;
+
+       path = uci_lookup_option_string(uci_ctx, s, "path");
+       if (!path)
+               return -1;
+
+       d = opendir("/sys/class/ieee80211");
+       if (!d)
+               return -1;
+
+       while ((e = readdir(d)) != NULL) {
+               cur_path = nl80211_phy_path_str(e->d_name);
+               if (!cur_path)
+                       continue;
+
+               if (strcmp(cur_path, path) != 0)
+                       continue;
+
+               snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", e->d_name);
+               idx = nl80211_readint(buf);
+
+               if (idx >= 0)
+                       break;
        }
 
+       closedir(d);
+
        return idx;
 }
 
@@ -1262,6 +1309,56 @@ static int nl80211_get_frequency(const char *ifname, int *buf)
        return (*buf == 0) ? -1 : 0;
 }
 
+static int nl80211_get_center_freq1_cb(struct nl_msg *msg, void *arg)
+{
+       int *freq = arg;
+       struct nlattr **tb = nl80211_parse(msg);
+
+       if (tb[NL80211_ATTR_CENTER_FREQ1])
+               *freq = nla_get_u32(tb[NL80211_ATTR_CENTER_FREQ1]);
+
+       return NL_SKIP;
+}
+
+static int nl80211_get_center_freq1(const char *ifname, int *buf)
+{
+       char *res;
+
+       /* try to find frequency from interface info */
+       res = nl80211_phy2ifname(ifname);
+       *buf = 0;
+
+       nl80211_request(res ? res : ifname, NL80211_CMD_GET_INTERFACE, 0,
+                       nl80211_get_center_freq1_cb, buf);
+
+       return (*buf == 0) ? -1 : 0;
+}
+
+static int nl80211_get_center_freq2_cb(struct nl_msg *msg, void *arg)
+{
+       int *freq = arg;
+       struct nlattr **tb = nl80211_parse(msg);
+
+       if (tb[NL80211_ATTR_CENTER_FREQ2])
+               *freq = nla_get_u32(tb[NL80211_ATTR_CENTER_FREQ2]);
+
+       return NL_SKIP;
+}
+
+static int nl80211_get_center_freq2(const char *ifname, int *buf)
+{
+       char *res;
+
+       /* try to find frequency from interface info */
+       res = nl80211_phy2ifname(ifname);
+       *buf = 0;
+
+       nl80211_request(res ? res : ifname, NL80211_CMD_GET_INTERFACE, 0,
+                       nl80211_get_center_freq2_cb, buf);
+
+       return (*buf == 0) ? -1 : 0;
+}
+
 static int nl80211_get_channel(const char *ifname, int *buf)
 {
        if (!nl80211_get_frequency(ifname, buf))
@@ -1273,6 +1370,28 @@ static int nl80211_get_channel(const char *ifname, int *buf)
        return -1;
 }
 
+static int nl80211_get_center_chan1(const char *ifname, int *buf)
+{
+       if (!nl80211_get_center_freq1(ifname, buf))
+       {
+               *buf = nl80211_freq2channel(*buf);
+               return 0;
+       }
+
+       return -1;
+}
+
+static int nl80211_get_center_chan2(const char *ifname, int *buf)
+{
+       if (!nl80211_get_center_freq2(ifname, buf))
+       {
+               *buf = nl80211_freq2channel(*buf);
+               return 0;
+       }
+
+       return -1;
+}
+
 static int nl80211_get_txpower_cb(struct nl_msg *msg, void *arg)
 {
        int *buf = arg;
@@ -1582,10 +1701,11 @@ static struct {
        { "WEP-40",  IWINFO_CIPHER_WEP40 },
        { "NONE",    IWINFO_CIPHER_NONE },
        { "TKIP",    IWINFO_CIPHER_TKIP },
-       { "CCMP",    IWINFO_CIPHER_CCMP }
+       { "CCMP",    IWINFO_CIPHER_CCMP },
+       { "GCMP",    IWINFO_CIPHER_GCMP }
 };
 
-static void parse_wpa_ciphers(const char *str, uint8_t *ciphers)
+static void parse_wpa_ciphers(const char *str, uint16_t *ciphers)
 {
        int i;
        size_t l;
@@ -1796,7 +1916,19 @@ static void nl80211_parse_rateinfo(struct nlattr **ri,
        else if (ri[NL80211_RATE_INFO_BITRATE])
                re->rate = nla_get_u16(ri[NL80211_RATE_INFO_BITRATE]) * 100;
 
-       if (ri[NL80211_RATE_INFO_VHT_MCS])
+       if (ri[NL80211_RATE_INFO_HE_MCS])
+       {
+               re->is_he = 1;
+               re->mcs = nla_get_u8(ri[NL80211_RATE_INFO_HE_MCS]);
+
+               if (ri[NL80211_RATE_INFO_HE_NSS])
+                       re->nss = nla_get_u8(ri[NL80211_RATE_INFO_HE_NSS]);
+               if (ri[NL80211_RATE_INFO_HE_GI])
+                       re->he_gi = nla_get_u8(ri[NL80211_RATE_INFO_HE_GI]);
+               if (ri[NL80211_RATE_INFO_HE_DCM])
+                       re->he_dcm = nla_get_u8(ri[NL80211_RATE_INFO_HE_DCM]);
+       }
+       else if (ri[NL80211_RATE_INFO_VHT_MCS])
        {
                re->is_vht = 1;
                re->mcs = nla_get_u8(ri[NL80211_RATE_INFO_VHT_MCS]);
@@ -2306,6 +2438,20 @@ static void nl80211_get_scanlist_ie(struct nlattr **bss,
                                iwinfo_parse_rsn(&e->crypto, ie + 6, ie[1] - 4,
                                                 IWINFO_CIPHER_TKIP, IWINFO_KMGMT_PSK);
                        break;
+               case 61: /* HT oeration */
+                       if (ie[1] >= 3) {
+                               e->ht_chan_info.primary_chan = ie[2];
+                               e->ht_chan_info.secondary_chan_off = ie[3] & 0x3;
+                               e->ht_chan_info.chan_width = (ie[4] & 0x4)>>2;
+                       }
+                       break;
+               case 192: /* VHT operation */
+                       if (ie[1] >= 3) {
+                               e->vht_chan_info.chan_width = ie[2];
+                               e->vht_chan_info.center_chan_1 = ie[3];
+                               e->vht_chan_info.center_chan_2 = ie[4];
+                       }
+                       break;
                }
 
                ielen -= ie[1] + 2;
@@ -2854,8 +3000,73 @@ struct nl80211_modes
        bool ok;
        uint32_t hw;
        uint32_t ht;
+
+       uint32_t nl_freq;
+       uint16_t nl_ht;
+       uint32_t nl_vht;
+       uint16_t he_phy_cap[6];
 };
 
+static int nl80211_eval_modelist(struct nl80211_modes *m)
+{
+       /* Treat any nonzero capability as 11n */
+       if (m->nl_ht > 0)
+       {
+               m->hw |= IWINFO_80211_N;
+               m->ht |= IWINFO_HTMODE_HT20;
+
+               if (m->nl_ht & (1 << 1))
+                       m->ht |= IWINFO_HTMODE_HT40;
+       }
+
+       if (m->he_phy_cap[0] != 0) {
+               m->hw |= IWINFO_80211_AX;
+               m->ht |= IWINFO_HTMODE_HE20;
+
+               if (m->he_phy_cap[0] & BIT(9))
+                       m->ht |= IWINFO_HTMODE_HE40;
+               if (m->he_phy_cap[0] & BIT(10))
+                       m->ht |= IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80;
+               if (m->he_phy_cap[0] & BIT(11))
+                       m->ht |= IWINFO_HTMODE_HE160;
+               if (m->he_phy_cap[0] & BIT(12))
+                       m->ht |= IWINFO_HTMODE_HE160 | IWINFO_HTMODE_HE80_80;
+       }
+
+       if (m->nl_freq < 2485)
+       {
+               m->hw |= IWINFO_80211_B;
+               m->hw |= IWINFO_80211_G;
+       }
+       else if (m->nl_vht)
+       {
+               /* Treat any nonzero capability as 11ac */
+               if (m->nl_vht > 0)
+               {
+                       m->hw |= IWINFO_80211_AC;
+                       m->ht |= IWINFO_HTMODE_VHT20 | IWINFO_HTMODE_VHT40 | IWINFO_HTMODE_VHT80;
+
+                       switch ((m->nl_vht >> 2) & 3)
+                       {
+                       case 2:
+                               m->ht |= IWINFO_HTMODE_VHT80_80;
+                               /* fall through */
+
+                       case 1:
+                               m->ht |= IWINFO_HTMODE_VHT160;
+                       }
+               }
+       }
+       else if (m->nl_freq >= 56160)
+       {
+               m->hw |= IWINFO_80211_AD;
+       }
+       else if (!(m->hw & IWINFO_80211_AC))
+       {
+               m->hw |= IWINFO_80211_A;
+       }
+}
+
 static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg)
 {
        struct nl80211_modes *m = arg;
@@ -2875,60 +3086,43 @@ static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg)
                                  nla_data(band), nla_len(band), NULL);
 
                        if (bands[NL80211_BAND_ATTR_HT_CAPA])
-                               caps = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]);
-
-                       /* Treat any nonzero capability as 11n */
-                       if (caps > 0)
-                       {
-                               m->hw |= IWINFO_80211_N;
-                               m->ht |= IWINFO_HTMODE_HT20;
-
-                               if (caps & (1 << 1))
-                                       m->ht |= IWINFO_HTMODE_HT40;
+                               m->nl_ht = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]);
+
+                       if (bands[NL80211_BAND_ATTR_VHT_CAPA])
+                               m->nl_vht = nla_get_u32(bands[NL80211_BAND_ATTR_VHT_CAPA]);
+
+                       if (bands[NL80211_BAND_ATTR_IFTYPE_DATA]) {
+                               struct nlattr *tb[NL80211_BAND_IFTYPE_ATTR_MAX + 1];
+                               struct nlattr *nl_iftype;
+                               int rem_band;
+                               int len;
+
+                               nla_for_each_nested(nl_iftype, bands[NL80211_BAND_ATTR_IFTYPE_DATA], rem_band) {
+                                       nla_parse(tb, NL80211_BAND_IFTYPE_ATTR_MAX,
+                                                 nla_data(nl_iftype), nla_len(nl_iftype), NULL);
+                                       if (tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]) {
+                                               len = nla_len(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]);
+
+                                               if (len > sizeof(m->he_phy_cap) - 1)
+                                                       len = sizeof(m->he_phy_cap) - 1;
+                                               memcpy(&((__u8 *)m->he_phy_cap)[1],
+                                                       nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]),
+                                                       len);
+                                       }
+                               }
                        }
 
-                       nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS],
-                                           freqs_remain)
-                       {
-                               nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
-                                         nla_data(freq), nla_len(freq), NULL);
-
-                               if (!freqs[NL80211_FREQUENCY_ATTR_FREQ])
-                                       continue;
-
-                               if (nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]) < 2485)
-                               {
-                                       m->hw |= IWINFO_80211_B;
-                                       m->hw |= IWINFO_80211_G;
-                               }
-                               else if (bands[NL80211_BAND_ATTR_VHT_CAPA])
+                       if (bands[NL80211_BAND_ATTR_FREQS]) {
+                               nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS],
+                                                   freqs_remain)
                                {
-                                       vht_caps = nla_get_u32(bands[NL80211_BAND_ATTR_VHT_CAPA]);
+                                       nla_parse(freqs, NL80211_FREQUENCY_ATTR_MAX,
+                                               nla_data(freq), nla_len(freq), NULL);
 
-                                       /* Treat any nonzero capability as 11ac */
-                                       if (vht_caps > 0)
-                                       {
-                                               m->hw |= IWINFO_80211_AC;
-                                               m->ht |= IWINFO_HTMODE_VHT20 | IWINFO_HTMODE_VHT40 | IWINFO_HTMODE_VHT80;
-
-                                               switch ((vht_caps >> 2) & 3)
-                                               {
-                                               case 2:
-                                                       m->ht |= IWINFO_HTMODE_VHT80_80;
-                                                       /* fall through */
-
-                                               case 1:
-                                                       m->ht |= IWINFO_HTMODE_VHT160;
-                                               }
-                                       }
-                               }
-                               else if (nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]) >= 56160)
-                               {
-                                       m->hw |= IWINFO_80211_AD;
-                               }
-                               else if (!(m->hw & IWINFO_80211_AC))
-                               {
-                                       m->hw |= IWINFO_80211_A;
+                                       if (!freqs[NL80211_FREQUENCY_ATTR_FREQ])
+                                               continue;
+
+                                       m->nl_freq = nla_get_u32(freqs[NL80211_FREQUENCY_ATTR_FREQ]);
                                }
                        }
                }
@@ -2941,39 +3135,126 @@ static int nl80211_get_modelist_cb(struct nl_msg *msg, void *arg)
 
 static int nl80211_get_hwmodelist(const char *ifname, int *buf)
 {
-       struct nl80211_modes m = { 0 };
+       struct nl80211_msg_conveyor *cv;
+       struct nl80211_modes m = {};
+       uint32_t features = nl80211_get_protocol_features(ifname);
+       int flags;
 
-       if (nl80211_request(ifname, NL80211_CMD_GET_WIPHY, 0,
-                           nl80211_get_modelist_cb, &m))
+       flags = features & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP ? NLM_F_DUMP : 0;
+       cv = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, flags);
+       if (!cv)
                goto out;
 
-       if (!m.ok)
-               goto out;
+       NLA_PUT_FLAG(cv->msg, NL80211_ATTR_SPLIT_WIPHY_DUMP);
+       if (nl80211_send(cv, nl80211_get_modelist_cb, &m))
+               goto nla_put_failure;
+
+       nl80211_eval_modelist(&m);
 
        *buf = m.hw;
+
        return 0;
 
+nla_put_failure:
+       nl80211_free(cv);
 out:
-       *buf = 0;
        return -1;
 }
 
+struct chan_info {
+       int width;
+       int mode;
+};
+
+static int nl80211_get_htmode_cb(struct nl_msg *msg, void *arg)
+{
+       struct nlattr **tb = nl80211_parse(msg);
+       struct nlattr *cur;
+       struct chan_info *chn = arg;
+
+       if ((cur = tb[NL80211_ATTR_CHANNEL_WIDTH]))
+               chn->width = nla_get_u32(cur);
+
+       if ((cur = tb[NL80211_ATTR_BSS_HT_OPMODE]))
+               chn->mode = nla_get_u32(cur);
+
+       return NL_SKIP;
+}
+
+static int nl80211_get_htmode(const char *ifname, int *buf)
+{
+       struct chan_info chn = { .width = 0, .mode = 0 };
+       char *res;
+       int err;
+
+       res = nl80211_phy2ifname(ifname);
+       *buf = 0;
+
+       err =  nl80211_request(res ? res : ifname,
+                               NL80211_CMD_GET_INTERFACE, 0,
+                               nl80211_get_htmode_cb, &chn);
+       if (err)
+               return -1;
+
+       switch (chn.width) {
+       case NL80211_CHAN_WIDTH_20:
+               if (chn.mode == -1)
+                       *buf = IWINFO_HTMODE_VHT20;
+               else
+                       *buf = IWINFO_HTMODE_HT20;
+               break;
+       case NL80211_CHAN_WIDTH_40:
+               if (chn.mode == -1)
+                       *buf = IWINFO_HTMODE_VHT40;
+               else
+                       *buf = IWINFO_HTMODE_HT40;
+               break;
+       case NL80211_CHAN_WIDTH_80:
+               *buf = IWINFO_HTMODE_VHT80;
+               break;
+       case NL80211_CHAN_WIDTH_80P80:
+               *buf = IWINFO_HTMODE_VHT80_80;
+               break;
+       case NL80211_CHAN_WIDTH_160:
+               *buf = IWINFO_HTMODE_VHT160;
+               break;
+       case NL80211_CHAN_WIDTH_5:
+       case NL80211_CHAN_WIDTH_10:
+       case NL80211_CHAN_WIDTH_20_NOHT:
+               *buf = IWINFO_HTMODE_NOHT;
+               break;
+       default:
+               return -1;
+       }
+
+       return 0;
+}
+
 static int nl80211_get_htmodelist(const char *ifname, int *buf)
 {
-       struct nl80211_modes m = { 0 };
+       struct nl80211_msg_conveyor *cv;
+       struct nl80211_modes m = {};
+       uint32_t features = nl80211_get_protocol_features(ifname);
+       int flags;
 
-       if (nl80211_request(ifname, NL80211_CMD_GET_WIPHY, 0,
-                           nl80211_get_modelist_cb, &m))
+       flags = features & NL80211_PROTOCOL_FEATURE_SPLIT_WIPHY_DUMP ? NLM_F_DUMP : 0;
+       cv = nl80211_msg(ifname, NL80211_CMD_GET_WIPHY, flags);
+       if (!cv)
                goto out;
 
-       if (!m.ok)
-               goto out;
+       NLA_PUT_FLAG(cv->msg, NL80211_ATTR_SPLIT_WIPHY_DUMP);
+       if (nl80211_send(cv, nl80211_get_modelist_cb, &m))
+               goto nla_put_failure;
+
+       nl80211_eval_modelist(&m);
 
        *buf = m.ht;
+
        return 0;
 
+nla_put_failure:
+       nl80211_free(cv);
 out:
-       *buf = 0;
        return -1;
 }
 
@@ -3040,6 +3321,65 @@ static int nl80211_get_mbssid_support(const char *ifname, int *buf)
        return 0;
 }
 
+static int nl80211_hardware_id_from_fdt(struct iwinfo_hardware_id *id, const char *ifname)
+{
+       char *phy, compat[64], path[PATH_MAX];
+       int i;
+
+       /* Try to determine the phy name from the given interface */
+       phy = nl80211_ifname2phy(ifname);
+
+       snprintf(path, sizeof(path), "/sys/class/%s/%s/device/of_node/compatible",
+                phy ? "ieee80211" : "net", phy ? phy : ifname);
+
+       if (nl80211_readstr(path, compat, sizeof(compat)) <= 0)
+               return -1;
+
+       if (!strcmp(compat, "qca,ar9130-wmac")) {
+               id->vendor_id = 0x168c;
+               id->device_id = 0x0029;
+               id->subsystem_vendor_id = 0x168c;
+               id->subsystem_device_id = 0x9130;
+       } else if (!strcmp(compat, "qca,ar9330-wmac")) {
+               id->vendor_id = 0x168c;
+               id->device_id = 0x0030;
+               id->subsystem_vendor_id = 0x168c;
+               id->subsystem_device_id = 0x9330;
+       } else if (!strcmp(compat, "qca,ar9340-wmac")) {
+               id->vendor_id = 0x168c;
+               id->device_id = 0x0030;
+               id->subsystem_vendor_id = 0x168c;
+               id->subsystem_device_id = 0x9340;
+       } else if (!strcmp(compat, "qca,qca9530-wmac")) {
+               id->vendor_id = 0x168c;
+               id->device_id = 0x0033;
+               id->subsystem_vendor_id = 0x168c;
+               id->subsystem_device_id = 0x9530;
+       } else if (!strcmp(compat, "qca,qca9550-wmac")) {
+               id->vendor_id = 0x168c;
+               id->device_id = 0x0033;
+               id->subsystem_vendor_id = 0x168c;
+               id->subsystem_device_id = 0x9550;
+       } else if (!strcmp(compat, "qca,qca9560-wmac")) {
+               id->vendor_id = 0x168c;
+               id->device_id = 0x0033;
+               id->subsystem_vendor_id = 0x168c;
+               id->subsystem_device_id = 0x9560;
+       } else if (!strcmp(compat, "qcom,ipq4019-wifi")) {
+               id->vendor_id = 0x168c;
+               id->device_id = 0x003c;
+               id->subsystem_vendor_id = 0x168c;
+               id->subsystem_device_id = 0x4019;
+       } else if (!strcmp(compat, "mediatek,mt7622-wmac")) {
+               id->vendor_id = 0x14c3;
+               id->device_id = 0x7622;
+               id->subsystem_vendor_id = 0x14c3;
+               id->subsystem_device_id = 0x7622;
+       }
+       return (id->vendor_id && id->device_id) ? 0 : -1;
+}
+
+
 static int nl80211_get_hardware_id(const char *ifname, char *buf)
 {
        struct iwinfo_hardware_id *id = (struct iwinfo_hardware_id *)buf;
@@ -3068,6 +3408,11 @@ static int nl80211_get_hardware_id(const char *ifname, char *buf)
                        *lookup[i].dest = strtoul(num, NULL, 16);
        }
 
+       /* Failed to obtain hardware IDs, try FDT */
+       if (id->vendor_id == 0 || id->device_id == 0)
+               if (!nl80211_hardware_id_from_fdt(id, ifname))
+                       return 0;
+
        /* Failed to obtain hardware IDs, search board config */
        if (id->vendor_id == 0 || id->device_id == 0)
                return iwinfo_hardware_id_from_mtd(id);
@@ -3131,10 +3476,27 @@ static int nl80211_lookup_phyname(const char *section, char *buf)
        return 0;
 }
 
+static int nl80211_phy_path(const char *phyname, const char **path)
+{
+       if (strncmp(phyname, "phy", 3) != 0)
+               return -1;
+
+       if (strchr(phyname, '/'))
+               return -1;
+
+       *path = nl80211_phy_path_str(phyname);
+       if (!*path)
+               return -1;
+
+       return 0;
+}
+
 const struct iwinfo_ops nl80211_ops = {
        .name             = "nl80211",
        .probe            = nl80211_probe,
        .channel          = nl80211_get_channel,
+       .center_chan1     = nl80211_get_center_chan1,
+       .center_chan2     = nl80211_get_center_chan2,
        .frequency        = nl80211_get_frequency,
        .frequency_offset = nl80211_get_frequency_offset,
        .txpower          = nl80211_get_txpower,
@@ -3147,6 +3509,7 @@ const struct iwinfo_ops nl80211_ops = {
        .mbssid_support   = nl80211_get_mbssid_support,
        .hwmodelist       = nl80211_get_hwmodelist,
        .htmodelist       = nl80211_get_htmodelist,
+       .htmode           = nl80211_get_htmode,
        .mode             = nl80211_get_mode,
        .ssid             = nl80211_get_ssid,
        .bssid            = nl80211_get_bssid,
@@ -3162,5 +3525,6 @@ const struct iwinfo_ops nl80211_ops = {
        .countrylist      = nl80211_get_countrylist,
        .survey           = nl80211_get_survey,
        .lookup_phy       = nl80211_lookup_phyname,
+       .phy_path         = nl80211_phy_path,
        .close            = nl80211_close
 };