From patchwork Mon Nov 13 10:28:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10055531 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 CEBF46029B for ; Mon, 13 Nov 2017 10:28:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A9DD29362 for ; Mon, 13 Nov 2017 10:28:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F7DA29364; Mon, 13 Nov 2017 10:28: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 C27B129362 for ; Mon, 13 Nov 2017 10:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752363AbdKMK2u (ORCPT ); Mon, 13 Nov 2017 05:28:50 -0500 Received: from mail-sn1nam01on0085.outbound.protection.outlook.com ([104.47.32.85]:59533 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752313AbdKMK2m (ORCPT ); Mon, 13 Nov 2017 05:28:42 -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=EH94Si7RbmTVgU6qARoFZ8AKDMjVCpinXEpcvBCOkkw=; b=CmJRkrGBZ6CwMDanR9fSZY66JtuhSQtzlKeBivdCSaGAkXVpRN/yTQlcDvb9YL3YOan1E8o2hRRwZF/CmIyb3GRR0Zq9mYcoq8fiF2FMsxcQhZJGqCoJ5KTJnku0cvLmZ3y436GTRb2zKvb4V0aq/B/CbE7hzWCFq7djHzMGstM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; Received: from bars.quantenna.com (195.182.157.78) by BLUPR05MB1924.namprd05.prod.outlook.com (10.162.224.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.239.4; Mon, 13 Nov 2017 10:28:39 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Avinash Patil , Vasily Ulyanov Subject: [PATCH 10/10] qtnfmac: support MAC address based access control Date: Mon, 13 Nov 2017 13:28:15 +0300 Message-Id: <20171113102815.11254-11-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171113102815.11254-1-sergey.matyukevich.os@quantenna.com> References: <20171113102815.11254-1-sergey.matyukevich.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: AM5P190CA0007.EURP190.PROD.OUTLOOK.COM (10.161.47.148) To BLUPR05MB1924.namprd05.prod.outlook.com (10.162.224.14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f749fbf6-12b1-41c3-ed30-08d52a814ec4 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:BLUPR05MB1924; X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB1924; 3:lT+RJIJm2EJHwS57XClfVWevd4+9KAiMo59KtcvSK3GLyx9Jc4fjQFamRqYiRRqGG8968qHlm22C04Iu75N4krEDtlEunLsbGFRofC5O4S5p3wewQI0RqAinlLiQXnCZVy71kRpN8xh9iqh62Tj58Vlmu3Lq+FKh/sblpUYTKsxdN7hj8kmoeupSL5x1IdgNTH8/vZrF2zw+RIblWxjEYveQzIWpAw3XvHTn8sVQ0EAA4dYC4ERrjPABTdbikuQ3; 25:7a1VLLY7U4Q/iXimAoqlHTV1veLMIrz3IY65rIFOOyBr/wj+HS6o8Oc4YgrqHm35f56OSW4OAx52lF8pLKFByd3zwmItrkd2hBwIAOINykHZ7EG1GHt7V2G9z78PF2md+y4g5TBH6a3VNsVEpMjyMbYEJ3k4cvSsge1/MfMy1oJ5m5l5odqGc8IKUzw6abWh/YROH0Aq1RY/+GZweewFLg2z1+srZpngj9f7ZZGRjf/oHEvwxn/P7yY9SOXRACtvPj4cqi6h5y150UB1YDWCUQooDDlgcvM4x+cdxU5Al4QyuPV5zVty7mDmjeRkFytuvZzTzjfrNtw2N+9180uoC9yVdXEEfxtzvEud+7sgbo0=; 31:7d9Y7bKr8MUV2+lDPH3MTLQ+Amn4BwMwI+29VQbH9dxNBqWC30Tvg6Ggr3sTYmKEEkBTGehx/tFcrptivcl1osAZ2V9771eeUfXb2fg0YcPMFEY1z+wjAK7ALpA5kh9dAkVogW6qYwU9dCFzGHsn96cnyPq8FKq4E05Tw117LXzw7KevnBDz0LBgPAViq9GFZSiRPfs0gFUaNv98WT9h7PlgBwn4lOzLU/IODn4OELo= X-MS-TrafficTypeDiagnostic: BLUPR05MB1924: X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB1924; 20:59uMoejnoXkG4yiVdMEGeZtt5W88EaCGC//XbAQly0wPD0tiQaA4PTUjl25W0V20Tyf9jiLPHHqRepMjNzQ0bzH3xCShpo1FTgsixqd+ESZfkZ7xNwJXSFozyEHFz/Z1FWeC4BAg0irjPUBKL3nxhgMTHb/AHfceS2f7ikGoZtj9O/6Vx6aHnC95jvEtJ+DQsdIDA2soyMpkcuoyM4Ixz87gJXLnTEdkvDkFPJQtTTRdS4DgXCO6N68Zfa+UC2ppRYT1wQVftPk65NRgnUGEZ/IN6VYSDLKnwAOb5pD+lY/3/7kqhmFS//XNJ4by6R4pdazrH7u5el0b7sAU4vyf8c5dtlv9ycsG5S0/sfOoeWJTmFqkuLfdVj1gge3k8Sr3HK91dA/Raz5wZNjJ/uZwFTXoNIyBi8VrYQyCrjDpqUEZNlYKkcQbqxwdyN+7vA5vqjPfzADRylPzhoXwnBdN8NsWrEFeiWKuGWhWu0YST/CO41u3dsZk/cIohTn3yh7w; 4:Mzx0sDEBnTrb4bOOZAXDqSweOYAjm2yI8FevGTsoDg22SoMK/OASkumutFwp2bKGwV6bUip4gd1Bg8dpgTFxBgEJcKu0iVGrySqPMmDN2yH4eb9pebZ49C2QkmjHM2wvMG30TEYonvpPM65UonBFX79wtN6PVhuJAT1TnSuCUkWRwGqMSN6+VUyfXPNx+Tf3W8LCWnTuZcjgkiVB6AaGiwYNNM3fh6gDMbew00HPmPUFLE6irxI0JIZc4qt0Yxm+HForYSGmbcSTosgrMKiOmA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(3231022)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123564025)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BLUPR05MB1924; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BLUPR05MB1924; X-Forefront-PRVS: 0490BBA1F0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(39830400002)(346002)(199003)(189002)(5660300001)(107886003)(47776003)(105586002)(50226002)(54906003)(66066001)(53936002)(2361001)(76176999)(316002)(6486002)(6916009)(50986999)(97736004)(4326008)(33646002)(5003940100001)(106356001)(2906002)(6666003)(2950100002)(25786009)(101416001)(16526018)(189998001)(81166006)(81156014)(86362001)(575784001)(8676002)(6116002)(3846002)(478600001)(68736007)(53416004)(48376002)(7736002)(50466002)(2351001)(16586007)(103116003)(69596002)(36756003)(305945005)(1076002)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR05MB1924; 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; BLUPR05MB1924; 23:J4xhFyufmgdeLSIJnK/XfCRMwbOIvzlucq175Et2H?= =?us-ascii?Q?Lpt2hYL7P9fVjk2RG96rsPtJ9QdGDR1pe4NGJt07pJ84Op1ZeCi7B/9XWTrw?= =?us-ascii?Q?twvFuIDRNPD87gSed0f5ppwT+/L5lQMAdkxq/P2TcGhFx8xrdL7ylCiUQowi?= =?us-ascii?Q?nyCNWpYqAcQXsVhFTemSC46gjzosUSpBJKz4tLz6+sJZwq7JbtL1GOqyEr5r?= =?us-ascii?Q?CWGkRsp15FqUe2qMaEm7fIo+3/ZZWYDxnvhAS1bNX+ogjBLNDWOjKBrfo9o+?= =?us-ascii?Q?rDC4w7YVsJC5qoUfhh0IEKcxdpnxyl/UugWB6OzeTtSpxiGMMvDQ7lJ9i5SR?= =?us-ascii?Q?GphJgXbPFqwYOBQhtF/0JFv+vjPoudOMn2uS91FxwbE5vtBBTOKvXC8LbF3m?= =?us-ascii?Q?3hpfe6Y58cxDDuiXrGb3Xb6HGOhjOOw5nv0updnVW/TbPxJy3Vfbm2+tb536?= =?us-ascii?Q?FrTSg59dRai/EFA8iyr8hlOqE1Kszg0STigwHqgpxbr9dtCgC7H6rfP9CaDN?= =?us-ascii?Q?S+kgvaPaFfENrVDHmiInJyxhCatAfw2uZzRbCe8GIXlO3Y7wZiEWZ3fB62AM?= =?us-ascii?Q?W2num6GGZWamuOfdRVtEfPk3e+CEAuBx+8IGSrj0J3W/QOTxjGsnXz9I6XJA?= =?us-ascii?Q?6Zc578pzTgp2ZAER/HmXZUjGW4u58o4Yvq2RjDyNy759Ujrr3KNPO3EwzLVc?= =?us-ascii?Q?MWVkfMn8EL1nXoY1c86pJBkuymEBBMEMxHxpoPqAFBjrKq2rChrIcLSpgt2l?= =?us-ascii?Q?oIrJH4vQvALV1LSYl2BtM0uhB0ZuuQLKUOePRL8dws4xYqCCTfPwg/8ulqRP?= =?us-ascii?Q?sXk1/swIrYP9Vi/avJJCmxkbLKNZyED+S9y6cI7voSv4Aba+pdc7QvFX2d3E?= =?us-ascii?Q?44/i/HDKEZrM+dMrQeaxYTfrHJfIjn5HF+lnSGXafbre/STIGAZjdxnsqOZy?= =?us-ascii?Q?oG3GFuhJ+qXpJOAkXnuwsxKDH5puE9D3lyLqFUmPRdb6YjortgRp5A4RLKxh?= =?us-ascii?Q?jEJKe+5DnlinTRgoWLcueVsCRIKt982g994fXscDE4h4spU91BWHLzwJnJM9?= =?us-ascii?Q?X9HXXMun885Gvxix9ztlc7HWITEBAKI2jEK/E72pJ/0c1R6fPR+TMIgGafFA?= =?us-ascii?Q?vmhu9raNz0Tps7vbPWz0zta9omlc1gD/YE7whEgW/HsFxmrJPAUfN6bBKeTb?= =?us-ascii?Q?NocpvCp1wwZ3UrbVuM91I5YX52++nrigZbHqfe07BA0WkOGg0WLqAHGVTkbH?= =?us-ascii?Q?mqB5UYvE7zBrmKGXvI=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB1924; 6:Kk8A9XYuQXwOQ0NEeqCuhSaH9B725J3v66EeBvYIKQq7hoLTIanAwukUeRfSDzmgw7WoLi9LPyRPayUCrXq7Jt+jZ/Ac6an+Wf2kp7onfMun6zwfuTNAZAz9r9ySb5YVioz3Htw1EZHVydKkvsPJhA8Hfp5xRt8rZ+gqOZRYqSkDXIjWte2Zmt7TPhWwoh92b5RZC4W8cu7XdoVZnUgEgUVJ0f2oCook8u0Vro3Bdr/9f3pgZcHhmn8tFWRMt6XU7N9j9Uv7JRde7DIdVhc4mtGCTHJd9FCVm5u8tSai18zJ31SkTE4pkU45uV6uvupB0OzH0AXd3eFEeSzEpZFfHisLu3By7ZO4Vj8bf7PS3RU=; 5:pWaJqoEzFn3oSz73q/SysnC17V0gn5KOK+8mJdi0GKz3miJMidIMvelAIWnPGZmZ6Hc+HKl1en4a5t/l8PAm00P5LgMBqHicONNsir/qh99ym99AAOVPFBv20xs9yEd86Xhipxk8pL7vmNa4GTYzZK9tFfODUWVH4WIW//95wTI=; 24:Y+FEmoUip+TZ6ZJZrdJoGlyFtT0mr8CFZ8KHGnjB4x3ouPglkF/H1fbuZ7xLTUFTOCO9erBPOD7yDIwiS86VBxSa3KyGIfbhkYAOxNBhaUs=; 7:CtsydcJlLYBwOJvQZWxjSnMw7sWomtUljWXBpQO4Pqgc89Ah/MzVcp4scWOcbdXV8e/Oyscb4jZBsOvnCVQCVPSM8+JJZ8t47WGGZ2kS8G6ewz5zFJTl8DtxfP3/Mj7T2v0HIoMRsvrlEe5S2rTZpTsLUtXsKg1bMxqcCEG0pe80Yf9eeDZTnUiOYO67WOZ+J9jTnbiq49pRIw0U4ssA+Id+IVRt83MfvDPz7XWQn53kPWW57xiKH85wxne/LEOs SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2017 10:28:39.5187 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f749fbf6-12b1-41c3-ed30-08d52a814ec4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR05MB1924 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 | 19 +++++++ 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, 140 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c index 452def343ad3..89dc9cab647d 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; @@ -932,6 +948,9 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) WIPHY_FLAG_AP_UAPSD | WIPHY_FLAG_HAS_CHANNEL_SWITCH; + if (wiphy->max_acl_mac_addrs > 0) + wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME; + wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2; 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_ */