From patchwork Tue Dec 19 11:28:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10123097 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 455BB6019C for ; Tue, 19 Dec 2017 11:29:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43A7229280 for ; Tue, 19 Dec 2017 11:29:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38987292A2; Tue, 19 Dec 2017 11:29:53 +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 6B68529280 for ; Tue, 19 Dec 2017 11:29:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967050AbdLSL3u (ORCPT ); Tue, 19 Dec 2017 06:29:50 -0500 Received: from mail-by2nam03on0052.outbound.protection.outlook.com ([104.47.42.52]:40224 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965110AbdLSL3l (ORCPT ); Tue, 19 Dec 2017 06:29:41 -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=zPJ9Q5Lfpu2HTtCATBAjIFTBXEdkGmuafN64qnQUxFE=; b=FSM6GUcjB1KTKWe1yRLfFtDnrnsdNlIc141Yf+x8Gds/DRbFad9k2IMemC5v1Ig4WFu0Fj1anRWIcKTOMNOo0kJRxpF8WNBT5eLeA8CxSWVWSyz5lLXSXUv/7ble7ZuBEbupmBuspjKt8J3YByt9sUJf0CJfNc+n8/zI7ZngEY0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; Received: from bars.quantenna.com (195.182.157.78) by BLUPR05MB1923.namprd05.prod.outlook.com (10.162.224.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.10; Tue, 19 Dec 2017 11:29:28 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Avinash Patil , Vasily Ulyanov Subject: [PATCH v2 10/10] qtnfmac: support MAC address based access control Date: Tue, 19 Dec 2017 14:28:56 +0300 Message-Id: <20171219112856.22463-11-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171219112856.22463-1-sergey.matyukevich.os@quantenna.com> References: <20171219112856.22463-1-sergey.matyukevich.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: AM6PR0502CA0022.eurprd05.prod.outlook.com (52.133.16.163) To BLUPR05MB1923.namprd05.prod.outlook.com (10.162.224.13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf63abcd-d487-4a31-8e70-08d546d3c4c9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307); SRVR:BLUPR05MB1923; X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB1923; 3:cVrKB6EbtzkX81sFCdQS824LVJxOEv4Qcq4i8QeTBHpFT/faQLxTRPuFQEzW4eyquGheIvMfHfTml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8ptVbKHvOjduPxRB39p5biTzgKkSW/xpGb1/RPUEzCjwGMQdYovnbzR+0OyO0kdkogKdj/aCbWGjpJvg8QHPHn7VPdHjUKhrXh6lF/zl+NqcOkAQqkQYdz2OfTT+3XJDH+Zw3AjfM4l/mAxVLRVtY96d+9rfc7+VyxcyrfSZDru8rtI+KkR1w0YRbUaWvkRUXnOqUI6wAti1Eep0QemJNCYGm4Lqbk8oL9jedOsTBE/GfT3OWBSVwanEFVr1rZJtnWXOJCub7E9dDahQtPJ7hHaEr4iezGtTMDN7p; 4:0a9J8wgkIxUmAPXE/uclnEn7QKDDZ4vgTugJ+iJshUc2Vvs9hwR1S05D707PIAWXr/ETkj+pP3SsYHnwsw0UiqxpTDYqmCexOsMOKvQgrfoEX82/BDLM6CM3tzvmvotghuEBgJPXk1Wv5T4V2WAZ/+jeALvG/RV2ajpL3Oj9i/4m7R5Z9hk62rwCjDOigEx/5HwCFJZaGxYekYetOhSQNvpoFZ8leCOWIz8GhTZjlcydESob8VL3DmvBqpUIVUCKjNxE4xCVJSbx4lU9Temf9g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(3002001)(3231023)(10201501046)(93006095)(93001095)(6041248)(20161123560025)(20161123564025)(20161123558100)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(6072148)(201708071742011); SRVR:BLUPR05MB1923; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BLUPR05MB1923; X-Forefront-PRVS: 052670E5A4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(39840400004)(346002)(396003)(189003)(199004)(48376002)(68736007)(50466002)(59450400001)(5660300001)(2950100002)(6666003)(6916009)(316002)(52116002)(76176011)(386003)(7696005)(97736004)(51416003)(16526018)(16586007)(107886003)(25786009)(575784001)(54906003)(4326008)(69596002)(86362001)(53936002)(2906002)(81156014)(103116003)(6486002)(2361001)(2351001)(478600001)(8676002)(50226002)(1076002)(8936002)(7736002)(81166006)(66066001)(47776003)(106356001)(105586002)(3846002)(36756003)(6116002)(305945005)(53416004); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR05MB1923; H:bars.quantenna.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BLUPR05MB1923; 23:EQ4XlzY4yt2r8PuBKBS//T7lP0pSZbbl+Isk8dCtT?= =?us-ascii?Q?E5GFAYmXUe1kbDzxuPfDUt0tW5cyQThWtOAiicawGSMREa4/mc2IwNGf1vmJ?= =?us-ascii?Q?ocHJHBHHPtHGKZdGceYKrbUL9KOSwO+qFbBq2JJTsHMNAora06gzpzSnlCu7?= =?us-ascii?Q?AL0rT+OJU59ONzFFL0fKI+zE4/5fLifttMbIcZsjwncCNWuYEbsMUG3rc3/a?= =?us-ascii?Q?sqg4d2DESSptOVY3qxgPA4Z6Uvopp/s0gl9ku47soq+nJoguSQr1WJnANSj4?= =?us-ascii?Q?gmyCoH1bhwDLa7MmioJziXCj7U5Gg0X2WAsOfYyZFTP8/njLuA8YeiQuk34I?= =?us-ascii?Q?a6i85xmckyqQqUFBEG0IKSbrqM3/sMHvfXLUpFmkXy16Ux3KRaAviy7xXG4R?= =?us-ascii?Q?g5IVkHJo7zMnIk5EGLMKVg65PJIyVzvh4pe5QHJ0slSv1oXClx0+eFh/KuKx?= =?us-ascii?Q?Hm26WS0sJzQtoeXnFW6DXFBZWs1KaXzcCbe3wAqnf5o5nid57j8G/YI/8mvY?= =?us-ascii?Q?jLW3Nc3Rgdd6jMcjXNCirVY9ia95got6ND3yR8Ooe/HSd1ZsA9wLrd3Z3r8o?= =?us-ascii?Q?YjG3HaztLpvsOb3lOD6D784xFgCpggiLSYgDB1YBO28v0JfoCN2mVJ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qr/pRXKArLez3wo9hyjQq39JoHlrmyA61UQ1kKFsFOPe+QiEmLCLNO4YvU9IEi9XnJ50hAIl3m65REm+vitKpLow9y07ZprepB4MU=; 5:imlnGjGp2IJiKzmEXdt9fbyxhvG0CXeKdUKI0IwMxrLs2WwZCirSkhKldQTWLKWZagvDRLi/fDuYKB/XwOAQDTlItV8YDnnTtiKZ6+0irPMOO/E6xehaAcgwaWu2DfI4gaTPKrXVA5StjfDYGdIPitLZzzBdgi6TMOkIDxzVT2E=; 24:H6EiZ8c25O6eWVtULUIgwfy244OoO3rTt8x9YJeSw5wlaqCmeMHWDoRFY6d7WNbbDjr76WiI/cAF9S6eUK+2M2Jf53wP0U5xuXvrzNXQ670=; 7:vVJpTXowiM8RcPzkEjQosZMufPcuWa3llX0Yha1bu934SOAVaUSZ0z2KuNjASb76pbrDcbSOZV9SimVveO3gfpPsKkLilorfUNl8xpMYGL8Nm+u8NRz62dsj94cSMG9cTiKdsT0bKUWMQ0cGnD2t8C0BnJmxBNTecg6askDvHH8OPlmi19rTCCATI+/NDrPqY7LAUsP3NpT3mEMcNFOEBRzmxoazTOYJfLcKbBLOnmuhlSFy+W+nVQC0DF3ZFl34 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2017 11:29:28.8098 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf63abcd-d487-4a31-8e70-08d546d3c4c9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR05MB1923 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 From: Vasily Ulyanov This allows a running AP to blacklist STAs by their MAC addresses respecting the configured policy (either accept or deny unless listed). It can be setup on .start_ap or with .set_mac_acl commands. Signed-off-by: Vasily Ulyanov --- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 16 ++++++ drivers/net/wireless/quantenna/qtnfmac/commands.c | 62 ++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.h | 2 + drivers/net/wireless/quantenna/qtnfmac/core.h | 1 + drivers/net/wireless/quantenna/qtnfmac/qlink.h | 37 ++++++++++++- .../net/wireless/quantenna/qtnfmac/qlink_util.c | 18 +++++++ .../net/wireless/quantenna/qtnfmac/qlink_util.h | 2 + 7 files changed, 137 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c index cedb18e04bc2..abf10996c26a 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c @@ -778,6 +778,20 @@ static int qtnf_start_radar_detection(struct wiphy *wiphy, return ret; } +static int qtnf_set_mac_acl(struct wiphy *wiphy, + struct net_device *dev, + const struct cfg80211_acl_data *params) +{ + struct qtnf_vif *vif = qtnf_netdev_get_priv(dev); + int ret; + + ret = qtnf_cmd_set_mac_acl(vif, params); + if (ret) + pr_err("%s: failed to set mac ACL ret=%d\n", dev->name, ret); + + return ret; +} + static struct cfg80211_ops qtn_cfg80211_ops = { .add_virtual_intf = qtnf_add_virtual_intf, .change_virtual_intf = qtnf_change_virtual_intf, @@ -803,6 +817,7 @@ static struct cfg80211_ops qtn_cfg80211_ops = { .get_channel = qtnf_get_channel, .channel_switch = qtnf_channel_switch, .start_radar_detection = qtnf_start_radar_detection, + .set_mac_acl = qtnf_set_mac_acl, }; static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in, @@ -918,6 +933,7 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) wiphy->max_scan_ie_len = QTNF_MAX_VSIE_LEN; 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; diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index 38b9c1078058..6ffe4837bbdb 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -162,6 +162,14 @@ static void qtnf_cmd_tlv_ie_set_add(struct sk_buff *cmd_skb, u8 frame_type, memcpy(tlv->ie_data, buf, len); } +static inline size_t qtnf_cmd_acl_data_size(const struct cfg80211_acl_data *acl) +{ + size_t size = sizeof(struct qlink_acl_data) + + acl->n_acl_entries * sizeof(struct qlink_mac_address); + + return size; +} + static bool qtnf_cmd_start_ap_can_fit(const struct qtnf_vif *vif, const struct cfg80211_ap_settings *s) { @@ -178,6 +186,9 @@ static bool qtnf_cmd_start_ap_can_fit(const struct qtnf_vif *vif, if (cfg80211_chandef_valid(&s->chandef)) len += sizeof(struct qlink_tlv_chandef); + if (s->acl) + len += qtnf_cmd_acl_data_size(s->acl); + if (len > (sizeof(struct qlink_cmd) + QTNF_MAX_CMD_BUF_SIZE)) { pr_err("VIF%u.%u: can not fit AP settings: %u\n", vif->mac->macid, vif->vifid, len); @@ -283,6 +294,16 @@ int qtnf_cmd_send_start_ap(struct qtnf_vif *vif, memcpy(tlv->val, s->vht_cap, sizeof(*s->vht_cap)); } + if (s->acl) { + size_t acl_size = qtnf_cmd_acl_data_size(s->acl); + struct qlink_tlv_hdr *tlv = + skb_put(cmd_skb, sizeof(*tlv) + acl_size); + + tlv->type = cpu_to_le16(QTN_TLV_ID_ACL_DATA); + tlv->len = cpu_to_le16(acl_size); + qlink_acl_data_cfg2q(s->acl, (struct qlink_acl_data *)tlv->val); + } + qtnf_bus_lock(vif->mac->bus); ret = qtnf_cmd_send(vif->mac->bus, cmd_skb, &res_code); @@ -1206,6 +1227,7 @@ qtnf_cmd_resp_proc_mac_info(struct qtnf_wmac *mac, mac_info->radar_detect_widths = qlink_chan_width_mask_to_nl(le16_to_cpu( resp_info->radar_detect_widths)); + mac_info->max_acl_mac_addrs = le32_to_cpu(resp_info->max_acl_mac_addrs); memcpy(&mac_info->ht_cap_mod_mask, &resp_info->ht_cap_mod_mask, sizeof(mac_info->ht_cap_mod_mask)); @@ -2609,3 +2631,43 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif, return ret; } + +int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif, + const struct cfg80211_acl_data *params) +{ + struct qtnf_bus *bus = vif->mac->bus; + struct sk_buff *cmd_skb; + struct qlink_cmd_set_mac_acl *cmd; + u16 res_code; + int ret; + + cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, + QLINK_CMD_SET_MAC_ACL, + sizeof(*cmd) + + qtnf_cmd_acl_data_size(params)); + if (unlikely(!cmd_skb)) + return -ENOMEM; + + cmd = (struct qlink_cmd_set_mac_acl *)cmd_skb->data; + qlink_acl_data_cfg2q(params, &cmd->acl); + + qtnf_bus_lock(bus); + ret = qtnf_cmd_send(bus, cmd_skb, &res_code); + qtnf_bus_unlock(bus); + + if (unlikely(ret)) + return ret; + + switch (res_code) { + case QLINK_CMD_RESULT_OK: + break; + case QLINK_CMD_RESULT_INVALID: + ret = -EINVAL; + break; + default: + ret = -EOPNOTSUPP; + break; + } + + return ret; +} diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.h b/drivers/net/wireless/quantenna/qtnfmac/commands.h index 07a957af9a58..69a7d56f7e58 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.h +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h @@ -79,5 +79,7 @@ int qtnf_cmd_get_channel(struct qtnf_vif *vif, struct cfg80211_chan_def *chdef); int qtnf_cmd_start_cac(const struct qtnf_vif *vif, const struct cfg80211_chan_def *chdef, u32 cac_time_ms); +int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif, + const struct cfg80211_acl_data *params); #endif /* QLINK_COMMANDS_H_ */ diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h index e7bd21ed371b..c10900162297 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.h +++ b/drivers/net/wireless/quantenna/qtnfmac/core.h @@ -103,6 +103,7 @@ struct qtnf_mac_info { u8 sretry_limit; u8 coverage_class; u8 radar_detect_widths; + 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; diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index 5d98000b0f5b..6a1f960228a1 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h @@ -19,7 +19,7 @@ #include -#define QLINK_PROTO_VER 9 +#define QLINK_PROTO_VER 10 #define QLINK_MACID_RSVD 0xFF #define QLINK_VIFID_RSVD 0xFF @@ -239,6 +239,7 @@ enum qlink_cmd_type { QLINK_CMD_START_CAC = 0x001D, QLINK_CMD_START_AP = 0x0021, QLINK_CMD_STOP_AP = 0x0022, + QLINK_CMD_SET_MAC_ACL = 0x0023, QLINK_CMD_GET_STA_INFO = 0x0030, QLINK_CMD_ADD_KEY = 0x0040, QLINK_CMD_DEL_KEY = 0x0041, @@ -640,6 +641,38 @@ struct qlink_cmd_start_cac { __le32 cac_time_ms; } __packed; +enum qlink_acl_policy { + QLINK_ACL_POLICY_ACCEPT_UNLESS_LISTED, + QLINK_ACL_POLICY_DENY_UNLESS_LISTED, +}; + +struct qlink_mac_address { + u8 addr[ETH_ALEN]; +} __packed; + +/** + * struct qlink_acl_data - ACL data + * + * @policy: filter policy, one of &enum qlink_acl_policy. + * @num_entries: number of MAC addresses in array. + * @mac_address: MAC addresses array. + */ +struct qlink_acl_data { + __le32 policy; + __le32 num_entries; + struct qlink_mac_address mac_addrs[0]; +} __packed; + +/** + * struct qlink_cmd_set_mac_acl - data for QLINK_CMD_SET_MAC_ACL command + * + * @acl: ACL data. + */ +struct qlink_cmd_set_mac_acl { + struct qlink_cmd chdr; + struct qlink_acl_data acl; +} __packed; + /* QLINK Command Responses messages related definitions */ @@ -701,6 +734,7 @@ struct qlink_resp_get_mac_info { struct ieee80211_ht_cap ht_cap_mod_mask; __le16 max_ap_assoc_sta; __le16 radar_detect_widths; + __le32 max_acl_mac_addrs; u8 bands_cap; u8 rsvd[1]; u8 var_info[0]; @@ -1049,6 +1083,7 @@ enum qlink_tlv_id { QTN_TLV_ID_SEQ = 0x0303, QTN_TLV_ID_IE_SET = 0x0305, QTN_TLV_ID_EXT_CAPABILITY_MASK = 0x0306, + QTN_TLV_ID_ACL_DATA = 0x0307, }; struct qlink_tlv_hdr { diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c index 19981d6440b6..aeeda81b09ea 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.c @@ -176,3 +176,21 @@ bool qtnf_utils_is_bit_set(const u8 *arr, unsigned int bit, return arr[idx] & mask; } + +void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl, + struct qlink_acl_data *qacl) +{ + switch (acl->acl_policy) { + case NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: + qacl->policy = + cpu_to_le32(QLINK_ACL_POLICY_ACCEPT_UNLESS_LISTED); + break; + case NL80211_ACL_POLICY_DENY_UNLESS_LISTED: + qacl->policy = cpu_to_le32(QLINK_ACL_POLICY_DENY_UNLESS_LISTED); + break; + } + + qacl->num_entries = cpu_to_le32(acl->n_acl_entries); + memcpy(qacl->mac_addrs, acl->mac_addrs, + acl->n_acl_entries * sizeof(*qacl->mac_addrs)); +} diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h index 6c24561eb41f..54caeb38917c 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink_util.h @@ -71,5 +71,7 @@ void qlink_chandef_cfg2q(const struct cfg80211_chan_def *chdef, enum qlink_hidden_ssid qlink_hidden_ssid_nl2q(enum nl80211_hidden_ssid nl_val); bool qtnf_utils_is_bit_set(const u8 *arr, unsigned int bit, unsigned int arr_max_len); +void qlink_acl_data_cfg2q(const struct cfg80211_acl_data *acl, + struct qlink_acl_data *qacl); #endif /* _QTN_FMAC_QLINK_UTIL_H_ */