From patchwork Mon Jan 22 12:46:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10178457 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2290360224 for ; Mon, 22 Jan 2018 12:47:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20A0428236 for ; Mon, 22 Jan 2018 12:47:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15A102823E; Mon, 22 Jan 2018 12:47:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5533281DB for ; Mon, 22 Jan 2018 12:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751150AbeAVMrL (ORCPT ); Mon, 22 Jan 2018 07:47:11 -0500 Received: from mail-bl2nam02on0084.outbound.protection.outlook.com ([104.47.38.84]:56768 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751004AbeAVMrI (ORCPT ); Mon, 22 Jan 2018 07:47:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantenna.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Slvt+ZmBvDwbelOawgE0uVhzmc2y4ereUHo8f5A0G0E=; b=HbEoT8NOguQiGSUNnuMuvd1K7BG1Z2tzZyDkdYBWWyIrAmZXBdTN2XuBzASa5Bh9E++ppUySASxFwhbQkj8Ql7XkGyqHjoIzD/4AR3BGZpoq4B2Q9XkYYUny54UjYD5KiqJpP3gfov6I7fVuqsWu0dUeTMbQftPH7R2nj6d7rHQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; Received: from bars.quantenna.com (195.182.157.78) by CY1PR05MB1931.namprd05.prod.outlook.com (10.162.216.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.5; Mon, 22 Jan 2018 12:47:05 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Avinash Patil , Sergey Matyukevich Subject: [PATCH 06/11] qtnfmac: modify supported interface combinations Date: Mon, 22 Jan 2018 15:46:29 +0300 Message-Id: <20180122124634.8430-7-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180122124634.8430-1-sergey.matyukevich.os@quantenna.com> References: <20180122124634.8430-1-sergey.matyukevich.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: VI1PR08CA0220.eurprd08.prod.outlook.com (10.170.234.157) To CY1PR05MB1931.namprd05.prod.outlook.com (10.162.216.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2d6cecf1-5e19-456a-2875-08d561963e7b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020); SRVR:CY1PR05MB1931; X-Microsoft-Exchange-Diagnostics: 1; CY1PR05MB1931; 3:MOwfqm+KwooJPd4qCqvPmC5POFXCgmURETn9bpN7g4e/liHm96ki4k37k9SGa1k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S/dcZidJEFsaxyFHnswRBDAn3XOOzDHRrd2nwc0owE73faYIIzpt/H2PdtMXflYMYIvia7uemBtwETmIV56VjH5PTs6EBNjR/CBa7HWEPSnomsRKmIIJ6bGBn9o+eVhzjRCpt/YyTipIGI2e0ldHHw44Wmk2CFW1rsAhmivMEzCcZLeo4ct0zquRKoNUpkV+49kU9XQD39N29vkBkP7t8f/gfnF7hQzjAwCjh/e1H79BGGMXc5YQsYn9TmJWZhev9RYi4D5xZ5yiZxR10KkDTCqdypgZSu7zv72VQHr3GZ4; 4:ggCd9V8pUPqyNXSTZSK/HK8o3BTAOFLVLlZdv0rdHW+ZeV/hxOy6B6XJepAVFldsTct2EAYVWO6+qzd+CrOwR7lSbXU2vmVdVca1rV7DqocrIGs9yB8HezDzZsm+TpDs6QDqJ6XeGrGrXHvywN9y49IA+O6Xcl9MxiGm1P463RDWxS4fSbe/zBcw4ygIRtDIOvFyzjldyCugovJ5T64IhtdD0l/ym5EYJYkNvFg3oD+fEcjdvjp5h+P6Fevz8bNpCP7Evr+sbdvfGd73EbVqgg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231023)(2400081)(944501161)(10201501046)(3002001)(93006095)(93001095)(6041288)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:CY1PR05MB1931; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY1PR05MB1931; X-Forefront-PRVS: 0560A2214D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39840400004)(396003)(366004)(346002)(39380400002)(199004)(189003)(2351001)(25786009)(52116002)(1076002)(6116002)(26005)(59450400001)(2361001)(36756003)(4326008)(76176011)(107886003)(478600001)(8676002)(8936002)(50226002)(7736002)(81166006)(6916009)(6666003)(2950100002)(305945005)(2906002)(106356001)(105586002)(68736007)(6486002)(81156014)(53936002)(48376002)(66066001)(16526018)(5890100001)(47776003)(103116003)(97736004)(50466002)(5660300001)(3846002)(386003)(16586007)(316002)(51416003)(7696005)(53416004)(54906003)(69596002)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR05MB1931; H:bars.quantenna.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR05MB1931; 23:X89JCczw3hztDv/cA08LbQE2AS2ZRRs3KYJQ8l8VB?= =?us-ascii?Q?RUMp5xPJthYRMPPqsEVAwrSKwHHs6rZvvgGmIXvjFBBCum/Ov0ibA2BtEcPm?= =?us-ascii?Q?t28DX1ufy/jDztmtOKjyhLCXy9XnGjFMp+9pIc9+7O8hHGcx/BZ6IJrKG3sm?= =?us-ascii?Q?lTUBb6pY1oJdE9tn2JYRzgW5RHXgkY55WQkbvkI5+jBPISBKISkWC6fKXU9n?= =?us-ascii?Q?nl98FuQqaTTDjMJYE8Jq2HBBfyPCkwWkPCoUjiY2jkOxAPW2/mVPH8g3qohF?= =?us-ascii?Q?w8QbBq3VHr4jgwOCq7uW9mk1FVYkJzooGDdDrbodvzxXjHUZ/lj4ngUuq4Wk?= =?us-ascii?Q?8kuAupb1bW1D5jt7lTyAgyyUi7FZwR0BKgN9ryrQgEiK0e/v5G9JakjInA5T?= =?us-ascii?Q?ziNqUlGan6z6+qIdGVut8sww6s6odGMZTBZusYcZt01GLIrUgqBjgtl9CNGi?= =?us-ascii?Q?WmeQ5qNwO+/d6UcFO2vaN/HhTz4pYCGjgOKi9iPsVTr4CFuWzbeX3wngl8C2?= =?us-ascii?Q?OZ2YWwV2ZLkb+zW5k86Zn5WOsCyTnq6k5fg9q3SKZKHf5Rgw7zUolSqpLFAZ?= =?us-ascii?Q?IWDBJja07rnLxXTICvdR2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kMmir6zvLKbHOuF6S5E97xJPuC0eqTsqhk9K4f84oFYpwI7m0GxsOyhLJLyU3TQ+F+7i7ZqLtHmpbl/MeiyFoe6b8L5Tu0XEcTuSt3TI8BKy4R/bUTYbKRGjzAFnfUNlBZ+Dd//SiE5JC/796EgajR/Nvdl4eliKriXFf71QOZDlSJq/uyLSEJfeWH1vUcEy8=; 5:pq6eOTsMFNWwwynS/TUyASTkJjZ1/NpIeeTsnMfdUxlFXUFJ1FTOdfxlpP80GdOHSl0Ez8XVQn3tPevUQGy11WecOKxRbsGcAEvPQSKdug4/CXQmUfDvHKDxwwCcyeH8oUtOBkWkyCbem34rA5BBkFT/whGHeP22DMO02lIdIz8=; 24:GaObzZl41Xy+UidnT5AT2zR14UlmohsPmwNOolbqbEFsnZ4Bm1soXi+3W+9jOZ28lnxONJHmgjd0FKaA3nbE3SoOO5QSIx33mLYcT2ADhYw=; 7:Fx29/rPTrWVg/OZGMVyBZEDX8ZZSVif3CImWp5gtdNZslS9oxjGntgmYvEMM5FdBcDcdKMIvgwik6JAQUIw6Jp8gaksI0BfFVyD0d6eZnIh3/48hya/3ms0WXnfcxuGkttd/fwOvQuV7vD38UMCZFCqzn8pcncGx1H4q2u05EQYJ8FBK9x0T0D3NN4h3zk1S9PDl51Mw7MkNgQWYfdnynn7zkE06pFunvY0qmRn0cVxLcznCSqy+uOb0cP+RByF9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2018 12:47:05.1227 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d6cecf1-5e19-456a-2875-08d561963e7b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR05MB1931 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update existing code handling configuration of supported interface combinations. Current implementation is not complete since it does not report multiple interface combinations which are incompatible with each other. Instead current implementation packs all the supported combinations into single entry. In fact currently qsr10g wireless card supports the following two distinct interface combinations: 1. STA/repeater: 1 STA and/or 1 AP { { .max = 1, .types = NL80211_IFTYPE_AP}, { .max = 1, .types = NL80211_IFTYPE_STA}, } 2. AP/mBSS { { .max = 8, .types = NL80211_IFTYPE_AP}, } The list of supported configuration is reported by firmware during wireless card bring-up. Communication protocol between firmware and host has been updated accordingly in order to accommodate passing multiple interface combination entries. Signed-off-by: Sergey Matyukevich --- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 53 +++++------ drivers/net/wireless/quantenna/qtnfmac/commands.c | 102 ++++++++++++++-------- drivers/net/wireless/quantenna/qtnfmac/core.c | 20 ++++- drivers/net/wireless/quantenna/qtnfmac/core.h | 5 +- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 11 ++- 5 files changed, 115 insertions(+), 76 deletions(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c index 03f819076197..78e8968ab3c7 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c @@ -876,29 +876,29 @@ struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus) return wiphy; } -static int qtnf_wiphy_setup_if_comb(struct wiphy *wiphy, - struct ieee80211_iface_combination *if_comb, - const struct qtnf_mac_info *mac_info) +static int +qtnf_wiphy_setup_if_comb(struct wiphy *wiphy, struct qtnf_mac_info *mac_info) { - size_t max_interfaces = 0; + struct ieee80211_iface_combination *if_comb; + size_t n_if_comb; u16 interface_modes = 0; - size_t i; + size_t i, j; + + if_comb = mac_info->if_comb; + n_if_comb = mac_info->n_if_comb; - if (unlikely(!mac_info->limits || !mac_info->n_limits)) + if (!if_comb || !n_if_comb) return -ENOENT; - if_comb->limits = mac_info->limits; - if_comb->n_limits = mac_info->n_limits; + for (i = 0; i < n_if_comb; i++) { + if_comb[i].radar_detect_widths = mac_info->radar_detect_widths; - for (i = 0; i < mac_info->n_limits; i++) { - max_interfaces += mac_info->limits[i].max; - interface_modes |= mac_info->limits[i].types; + for (j = 0; j < if_comb[i].n_limits; j++) + interface_modes |= if_comb[i].limits[j].types; } - if_comb->num_different_channels = 1; - if_comb->beacon_int_infra_match = true; - if_comb->max_interfaces = max_interfaces; - if_comb->radar_detect_widths = mac_info->radar_detect_widths; + wiphy->iface_combinations = if_comb; + wiphy->n_iface_combinations = n_if_comb; wiphy->interface_modes = interface_modes; return 0; @@ -907,7 +907,6 @@ static int qtnf_wiphy_setup_if_comb(struct wiphy *wiphy, int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) { struct wiphy *wiphy = priv_to_wiphy(mac); - struct ieee80211_iface_combination *iface_comb = NULL; int ret; if (!wiphy) { @@ -915,14 +914,6 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) return -EFAULT; } - iface_comb = kzalloc(sizeof(*iface_comb), GFP_KERNEL); - if (!iface_comb) - return -ENOMEM; - - ret = qtnf_wiphy_setup_if_comb(wiphy, iface_comb, &mac->macinfo); - if (ret) - goto out; - wiphy->frag_threshold = mac->macinfo.frag_thr; wiphy->rts_threshold = mac->macinfo.rts_thr; wiphy->retry_short = mac->macinfo.sretry_limit; @@ -934,11 +925,12 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) wiphy->mgmt_stypes = qtnf_mgmt_stypes; wiphy->max_remain_on_channel_duration = 5000; wiphy->max_acl_mac_addrs = mac->macinfo.max_acl_mac_addrs; - - wiphy->iface_combinations = iface_comb; - wiphy->n_iface_combinations = 1; wiphy->max_num_csa_counters = 2; + ret = qtnf_wiphy_setup_if_comb(wiphy, &mac->macinfo); + if (ret) + goto out; + /* Initialize cipher suits */ wiphy->cipher_suites = qtnf_cipher_suites; wiphy->n_cipher_suites = ARRAY_SIZE(qtnf_cipher_suites); @@ -987,12 +979,7 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) ret = regulatory_hint(wiphy, hw_info->rd->alpha2); out: - if (ret) { - kfree(iface_comb); - return ret; - } - - return 0; + return ret; } void qtnf_netdev_updown(struct net_device *ndev, bool up) diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index 2017532477c9..2820b0318c6a 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -1116,19 +1116,22 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus, static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, const u8 *tlv_buf, size_t tlv_buf_size) { - struct ieee80211_iface_limit *limits = NULL; - const struct qlink_iface_limit *limit_record; - size_t record_count = 0, rec = 0; - u16 tlv_type, tlv_value_len; - struct qlink_iface_comb_num *comb; + struct ieee80211_iface_combination *comb = NULL; + size_t n_comb = 0; + struct ieee80211_iface_limit *limits; + const struct qlink_iface_comb_num *comb_num; + const struct qlink_iface_limit_record *rec; + const struct qlink_iface_limit *lim; + u16 rec_len; + u16 tlv_type; + u16 tlv_value_len; 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; + int i = 0; tlv = (const struct qlink_tlv_hdr *)tlv_buf; while (tlv_buf_size >= sizeof(struct qlink_tlv_hdr)) { @@ -1143,52 +1146,77 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, switch (tlv_type) { case QTN_TLV_ID_NUM_IFACE_COMB: - if (unlikely(tlv_value_len != sizeof(*comb))) + if (tlv_value_len != sizeof(*comb_num)) return -EINVAL; - comb = (void *)tlv->val; - record_count = le16_to_cpu(comb->iface_comb_num); + comb_num = (void *)tlv->val; + + /* free earlier iface comb memory */ + qtnf_mac_iface_comb_free(mac); - mac->macinfo.n_limits = record_count; - /* free earlier iface limits memory */ - kfree(mac->macinfo.limits); - mac->macinfo.limits = - kzalloc(sizeof(*mac->macinfo.limits) * - record_count, GFP_KERNEL); + mac->macinfo.n_if_comb = + le32_to_cpu(comb_num->iface_comb_num); - if (unlikely(!mac->macinfo.limits)) + mac->macinfo.if_comb = + kcalloc(mac->macinfo.n_if_comb, + sizeof(*mac->macinfo.if_comb), + GFP_KERNEL); + + if (!mac->macinfo.if_comb) return -ENOMEM; - limits = mac->macinfo.limits; + comb = mac->macinfo.if_comb; + + pr_debug("MAC%u: %zu iface combinations\n", + mac->macid, mac->macinfo.n_if_comb); + break; case QTN_TLV_ID_IFACE_LIMIT: - if (unlikely(!limits)) { - pr_warn("MAC%u: limits are not inited\n", + if (unlikely(!comb)) { + pr_warn("MAC%u: no combinations advertised\n", mac->macid); return -EINVAL; } - if (unlikely(tlv_value_len != sizeof(*limit_record))) { - pr_warn("MAC%u: record size mismatch\n", + if (n_comb >= mac->macinfo.n_if_comb) { + pr_warn("MAC%u: combinations count exceeded\n", mac->macid); - return -EINVAL; + n_comb++; + break; } - limit_record = (void *)tlv->val; - limits[rec].max = le16_to_cpu(limit_record->max_num); - limits[rec].types = qlink_iface_type_to_nl_mask( - le16_to_cpu(limit_record->type)); + rec = (void *)tlv->val; + rec_len = sizeof(*rec) + rec->n_limits * sizeof(*lim); - /* supported modes: STA, AP */ - limits[rec].types &= BIT(NL80211_IFTYPE_AP) | - BIT(NL80211_IFTYPE_AP_VLAN) | - BIT(NL80211_IFTYPE_STATION); + if (unlikely(tlv_value_len != rec_len)) { + pr_warn("MAC%u: record %zu size mismatch\n", + mac->macid, n_comb); + return -EINVAL; + } - pr_debug("MAC%u: MAX: %u; TYPES: %.4X\n", mac->macid, - limits[rec].max, limits[rec].types); + limits = kzalloc(sizeof(*limits) * rec->n_limits, + GFP_KERNEL); + if (!limits) + return -ENOMEM; + + comb[n_comb].num_different_channels = + rec->num_different_channels; + comb[n_comb].max_interfaces = + le16_to_cpu(rec->max_interfaces); + comb[n_comb].n_limits = rec->n_limits; + comb[n_comb].limits = limits; + + for (i = 0; i < rec->n_limits; i++) { + lim = &rec->limits[i]; + limits[i].max = le16_to_cpu(lim->max_num); + limits[i].types = + qlink_iface_type_to_nl_mask(le16_to_cpu(lim->type)); + pr_debug("MAC%u: comb[%zu]: MAX:%u TYPES:%.4X\n", + mac->macid, n_comb, + limits[i].max, limits[i].types); + } - if (limits[rec].types) - rec++; + n_comb++; break; case WLAN_EID_EXT_CAPABILITY: if (unlikely(tlv_value_len > U8_MAX)) @@ -1216,9 +1244,9 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, return -EINVAL; } - if (mac->macinfo.n_limits != rec) { + if (mac->macinfo.n_if_comb != n_comb) { pr_err("MAC%u: combination mismatch: reported=%zu parsed=%zu\n", - mac->macid, mac->macinfo.n_limits, rec); + mac->macid, mac->macinfo.n_if_comb, n_comb); return -EINVAL; } diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c index 1acbe30dfc66..b1344d0731d7 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.c +++ b/drivers/net/wireless/quantenna/qtnfmac/core.c @@ -262,6 +262,23 @@ struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac) return vif; } +void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac) +{ + struct ieee80211_iface_combination *comb; + int i; + + if (mac->macinfo.if_comb) { + for (i = 0; i < mac->macinfo.n_if_comb; i++) { + comb = &mac->macinfo.if_comb[i]; + kfree(comb->limits); + comb->limits = NULL; + } + + kfree(mac->macinfo.if_comb); + mac->macinfo.if_comb = NULL; + } +} + static void qtnf_vif_reset_handler(struct work_struct *work) { struct qtnf_vif *vif = container_of(work, struct qtnf_vif, reset_work); @@ -420,10 +437,9 @@ static void qtnf_core_mac_detach(struct qtnf_bus *bus, unsigned int macid) wiphy->bands[band] = NULL; } - kfree(mac->macinfo.limits); + qtnf_mac_iface_comb_free(mac); kfree(mac->macinfo.extended_capabilities); kfree(mac->macinfo.extended_capabilities_mask); - kfree(wiphy->iface_combinations); wiphy_free(wiphy); bus->mac[macid] = NULL; } diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h index e47198cbcceb..29f38bd3b491 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.h +++ b/drivers/net/wireless/quantenna/qtnfmac/core.h @@ -108,8 +108,8 @@ struct qtnf_mac_info { u32 max_acl_mac_addrs; struct ieee80211_ht_cap ht_cap_mod_mask; struct ieee80211_vht_cap vht_cap_mod_mask; - struct ieee80211_iface_limit *limits; - size_t n_limits; + struct ieee80211_iface_combination *if_comb; + size_t n_if_comb; u8 *extended_capabilities; u8 *extended_capabilities_mask; u8 extended_capabilities_len; @@ -151,6 +151,7 @@ struct qtnf_hw_info { struct qtnf_vif *qtnf_mac_get_free_vif(struct qtnf_wmac *mac); struct qtnf_vif *qtnf_mac_get_base_vif(struct qtnf_wmac *mac); +void qtnf_mac_iface_comb_free(struct qtnf_wmac *mac); struct wiphy *qtnf_wiphy_allocate(struct qtnf_bus *bus); int qtnf_core_net_attach(struct qtnf_wmac *mac, struct qtnf_vif *priv, const char *name, unsigned char name_assign_type); diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index 51cadd2a43f0..9bf3ae4d1b3b 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h @@ -1092,13 +1092,20 @@ struct qlink_tlv_hdr { u8 val[0]; } __packed; +struct qlink_iface_comb_num { + __le32 iface_comb_num; +} __packed; + struct qlink_iface_limit { __le16 max_num; __le16 type; } __packed; -struct qlink_iface_comb_num { - __le16 iface_comb_num; +struct qlink_iface_limit_record { + __le16 max_interfaces; + u8 num_different_channels; + u8 n_limits; + struct qlink_iface_limit limits[0]; } __packed; #define QLINK_RSSI_OFFSET 120