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))
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;
{ "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;
}
break;
- case 11: /* BSS Load */
- iwinfo_parse_bss_load(e, ie + 2);
- break;
-
case 48: /* RSN */
iwinfo_parse_rsn(&e->crypto, ie + 2, ie[1],
IWINFO_CIPHER_CCMP, IWINFO_KMGMT_8021x);
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;
m->ht |= IWINFO_HTMODE_HT40;
}
+ if (bands[NL80211_BAND_ATTR_IFTYPE_DATA]) {
+ struct nlattr *tb[NL80211_BAND_IFTYPE_ATTR_MAX + 1];
+ uint16_t phy_cap[6] = { 0 };
+ struct nlattr *nl_iftype;
+ int rem_band;
+ int len;
+
+ m->hw |= IWINFO_80211_AX;
+ m->ht |= IWINFO_HTMODE_HE20;
+
+ 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(phy_cap) - 1)
+ len = sizeof(phy_cap) - 1;
+ memcpy(&((__u8 *)phy_cap)[1],
+ nla_data(tb[NL80211_BAND_IFTYPE_ATTR_HE_CAP_PHY]),
+ len);
+ }
+
+ if (phy_cap[0] & BIT(9))
+ m->ht |= IWINFO_HTMODE_HE40;
+ if (phy_cap[0] & BIT(10))
+ m->ht |= IWINFO_HTMODE_HE40 | IWINFO_HTMODE_HE80;
+ if (phy_cap[0] & BIT(11))
+ m->ht |= IWINFO_HTMODE_HE160;
+ if (phy_cap[0] & BIT(12))
+ m->ht |= IWINFO_HTMODE_HE160 | IWINFO_HTMODE_HE80_80;
+ }
+ }
+
nla_for_each_nested(freq, bands[NL80211_BAND_ATTR_FREQS],
freqs_remain)
{
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;
*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);
.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,