qtnfmac: fill wiphy's extended capabilities
authorVasily Ulyanov <vulyanov@quantenna.com>
Tue, 19 Dec 2017 11:28:53 +0000 (14:28 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 9 Jan 2018 12:11:21 +0000 (14:11 +0200)
These are needed to inform userspace about features the hardware
supports (e.g. BSS Transition Management 802.11v)

Signed-off-by: Vasily Ulyanov <vulyanov@quantenna.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/quantenna/qtnfmac/commands.c
drivers/net/wireless/quantenna/qtnfmac/core.c
drivers/net/wireless/quantenna/qtnfmac/core.h
drivers/net/wireless/quantenna/qtnfmac/qlink.h

index 7089f3eb7a870169905a7d416d6326b78eba8ea5..839e86b998379885be57464f1ce76d7a31c96df8 100644 (file)
@@ -1029,6 +1029,10 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,
        struct qlink_iface_comb_num *comb;
        size_t tlv_full_len;
        const struct qlink_tlv_hdr *tlv;
+       u8 *ext_capa = NULL;
+       u8 *ext_capa_mask = NULL;
+       u8 ext_capa_len = 0;
+       u8 ext_capa_mask_len = 0;
 
        mac->macinfo.n_limits = 0;
 
@@ -1092,6 +1096,18 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,
                        if (limits[rec].types)
                                rec++;
                        break;
+               case WLAN_EID_EXT_CAPABILITY:
+                       if (unlikely(tlv_value_len > U8_MAX))
+                               return -EINVAL;
+                       ext_capa = (u8 *)tlv->val;
+                       ext_capa_len = tlv_value_len;
+                       break;
+               case QTN_TLV_ID_EXT_CAPABILITY_MASK:
+                       if (unlikely(tlv_value_len > U8_MAX))
+                               return -EINVAL;
+                       ext_capa_mask = (u8 *)tlv->val;
+                       ext_capa_mask_len = tlv_value_len;
+                       break;
                default:
                        break;
                }
@@ -1112,6 +1128,34 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,
                return -EINVAL;
        }
 
+       if (ext_capa_len != ext_capa_mask_len) {
+               pr_err("MAC%u: ext_capa/_mask lengths mismatch: %u != %u\n",
+                      mac->macid, ext_capa_len, ext_capa_mask_len);
+               return -EINVAL;
+       }
+
+       if (ext_capa_len > 0) {
+               ext_capa = kmemdup(ext_capa, ext_capa_len, GFP_KERNEL);
+               if (!ext_capa)
+                       return -ENOMEM;
+
+               ext_capa_mask =
+                       kmemdup(ext_capa_mask, ext_capa_mask_len, GFP_KERNEL);
+               if (!ext_capa_mask) {
+                       kfree(ext_capa);
+                       return -ENOMEM;
+               }
+       } else {
+               ext_capa = NULL;
+               ext_capa_mask = NULL;
+       }
+
+       kfree(mac->macinfo.extended_capabilities);
+       kfree(mac->macinfo.extended_capabilities_mask);
+       mac->macinfo.extended_capabilities = ext_capa;
+       mac->macinfo.extended_capabilities_mask = ext_capa_mask;
+       mac->macinfo.extended_capabilities_len = ext_capa_len;
+
        return 0;
 }
 
index 518a2fe927f70fbd74d3565bc82e39c311a82e61..ccd982b1c9579fe99570b9da8cfa0f55f1bd1706 100644 (file)
@@ -381,6 +381,8 @@ static void qtnf_core_mac_detach(struct qtnf_bus *bus, unsigned int macid)
        }
 
        kfree(mac->macinfo.limits);
+       kfree(mac->macinfo.extended_capabilities);
+       kfree(mac->macinfo.extended_capabilities_mask);
        kfree(wiphy->iface_combinations);
        wiphy_free(wiphy);
        bus->mac[macid] = NULL;
index 8e42d1bdc65f6336b8dd46fd08152f5fa34d7f5c..d7e295efb07d2caf0591b20a2625ec8757d8ffb8 100644 (file)
@@ -106,6 +106,9 @@ struct qtnf_mac_info {
        struct ieee80211_vht_cap vht_cap_mod_mask;
        struct ieee80211_iface_limit *limits;
        size_t n_limits;
+       u8 *extended_capabilities;
+       u8 *extended_capabilities_mask;
+       u8 extended_capabilities_len;
 };
 
 struct qtnf_chan_stats {
index 1f150be988206c43bfabb484fff591d651e1820c..f4d7d1603e3c4f78dc179ef5f5a6c91071fe3458 100644 (file)
@@ -1020,6 +1020,7 @@ enum qlink_tlv_id {
        QTN_TLV_ID_KEY                  = 0x0302,
        QTN_TLV_ID_SEQ                  = 0x0303,
        QTN_TLV_ID_IE_SET               = 0x0305,
+       QTN_TLV_ID_EXT_CAPABILITY_MASK  = 0x0306,
 };
 
 struct qlink_tlv_hdr {