From patchwork Thu May 31 09:11:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10440565 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 548866035E for ; Thu, 31 May 2018 09:11:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C138290A1 for ; Thu, 31 May 2018 09:11:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F4CF291B9; Thu, 31 May 2018 09:11:37 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, 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 549FE290A1 for ; Thu, 31 May 2018 09:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754281AbeEaJLe (ORCPT ); Thu, 31 May 2018 05:11:34 -0400 Received: from mail-by2nam01on0082.outbound.protection.outlook.com ([104.47.34.82]:40832 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754187AbeEaJLZ (ORCPT ); Thu, 31 May 2018 05:11:25 -0400 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:X-MS-Exchange-SenderADCheck; bh=nJaGmDLPWjQoem/cqEekfBkGRL8wX8aPNpsceKgRpnQ=; b=W+xfwIxycPrU6wzTvCH59q1UIbk18imvG75w/hfkndy24VuxY4Ob/LMDvGo7S3WfBYeNhprDxemI9Y9VN6xqc+56rBUQ7waSKZnxW5dKGrHl0BPUlrKK7eq0x+YTvmi4N8+Gy1fohb+3nFrg9EsnjZ5cWK4YGgX9m+4syuPtCwY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; Received: from bars.quantenna.com (195.182.157.78) by BY2PR05MB1926.namprd05.prod.outlook.com (2a01:111:e400:58f7::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.820.5; Thu, 31 May 2018 09:11:22 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Andrey Shevchenko , Sergei Maksimenko Subject: [PATCH 5/6] qtnfmac: add support for PTA configuration Date: Thu, 31 May 2018 12:11:01 +0300 Message-Id: <20180531091102.28666-6-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180531091102.28666-1-sergey.matyukevich.os@quantenna.com> References: <20180531091102.28666-1-sergey.matyukevich.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: AM6PR0102CA0019.eurprd01.prod.exchangelabs.com (2603:10a6:209:14::32) To BY2PR05MB1926.namprd05.prod.outlook.com (2a01:111:e400:58f7::12) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:BY2PR05MB1926; X-Microsoft-Exchange-Diagnostics: 1; BY2PR05MB1926; 3:tlyLcU9HaEu9uvPb0tUe+ihUh2IV7WybX4ukhSSDIzPbI8swH/MqPKtTlmDZfg7vZ9dtSVcFogUsPj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K+1LvAz9tIABSDEPcerSHCg786Fl1UsZIaqbzxB+TD6r1OsSWpvrYNd3qVY7H019oYK1Xq4ePKLjdCx4xSMy7dacX7wRO27RkkBha4VlTGqydaLaupuvUIzyHGqwO7Qjy9TWi5o22Uysy9nvtWWslzXEBMxusBwgNcOzEYcT3Njy/Xs5Dm2m2gHGyQDPi8AT9ySfsjcpsoraeC64PuROQtTO4LmNP/Rdw3X4PirYa6GhGl4YHoc/XvvCNJ3vK3NFMVgQ/G3nKvFuBXF0BjHVFGyKPjNE; 4:KWIl9sJ/ppMsnHa+2NH83NDJOaCg4EuCM4Z7EoDH2YOsq8ADc5cEf6GokoFhvxVylkD/f3GxAbJUbdmcxB9sWEfy9hfe/aJJQRk9EOGe893T6QMPZsD8pEQ5f77pIG7b/B+7/do05Avvk7WeaNOTt/h7TBUPZmEvlO+Hn3fxHBW65COvtyticA0piuXlzMH2uJlO4YDSCNshT9a0fl0/Os5EGUgzH79UosndKdJt7a/tsEnqaL9g/rPTLUn5FrvbrhxGQDuBL6Is8t4jOSV/+g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:BY2PR05MB1926; BCL:0; PCL:0; RULEID:; SRVR:BY2PR05MB1926; X-Forefront-PRVS: 06891E23FB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(376002)(366004)(39850400004)(396003)(39380400002)(346002)(199004)(189003)(52116002)(2906002)(68736007)(6116002)(6916009)(59450400001)(48376002)(3846002)(11346002)(2351001)(106356001)(7696005)(2616005)(476003)(81156014)(53936002)(76176011)(105586002)(956004)(2361001)(1076002)(26005)(16526019)(186003)(386003)(6666003)(36756003)(5660300001)(81166006)(51416003)(8936002)(478600001)(8676002)(54906003)(16586007)(86362001)(6486002)(50226002)(316002)(53416004)(446003)(25786009)(50466002)(69596002)(7736002)(47776003)(486006)(305945005)(107886003)(4326008)(97736004)(103116003)(66066001)(2004002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR05MB1926; H:bars.quantenna.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR05MB1926; 23:ehgillxgUJCOw++4PWWeTc3v683R8otCTit5EqkYP?= =?us-ascii?Q?pRxHEjUNqG+b3P+YUtajgtg3FvHC1Dg3czw49cARFZCxTE34uOmcnAn8w/bo?= =?us-ascii?Q?TFjdabA5VP/yPVku8g6bYdbvHfIT10dKx71R4TvnK6nbSAL00bFLjWmGTMzy?= =?us-ascii?Q?1NMP7sREay093MUvrnxAxgn5JWSt7X4gfL+ghFk234iCQ2irrss62DmFTCOJ?= =?us-ascii?Q?pc/+RqoQ1Z3XvGg2h/hvtXt94XbynAVp9ufIEOjUIZ0ieYKWEqL/I5ByAjOm?= =?us-ascii?Q?NULfG+L870F698GhMU9mmqP+RkfdBCbH2HjIRYOOh//ISJ4tZA9kD2lXUWDQ?= =?us-ascii?Q?SV2z7iOQOozhKPyuE/o2zKhpa71E+7uXC61pHMTBPbq2Bgae7bqIK3+p3YfJ?= =?us-ascii?Q?S+kD3KOndTqu4+Gmxg0SUv3dVKuIAw9vDx7QuWIWei513ZWt1huu25oHs89a?= =?us-ascii?Q?W2ITfGkriou0C+0ZukqbODmAKJ+0cGtA0RWWzDJvUMIN7Pab1BwgND1W2rgK?= =?us-ascii?Q?dY17ix/04nphWcxh4O1jVDZHCjsW2Ju9FmAFFnB7KueHIa1t4EiRv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4KZWaITrha7XO72zQjrYeRC0305?= X-Microsoft-Antispam-Message-Info: MUvTraOo6rkMLjarhwAYINBLUoibSgbLfCdr3Luhqbj0kP8eh2elNiqMHreM59YNczAbrCvDy9i+9Rlj9meomAwaH50mHVvZ3ejwTf74z7yDmi04mShWmujGkCkiXzt98gezOnshDS4NgB+2hL8qMaxw1l5tfzKgZAvtk7NSQYzTl2eATCk9JOoYU7SNUF+D X-Microsoft-Exchange-Diagnostics: 1; BY2PR05MB1926; 6:asB4n+R0FOo4Bq/q33ujipUoDhwmPAL/WfEsQIEqaEKzOcoykByoUfz/2VHoV7hsNmdbfhSOlJSgsDOHtgZiBYF+Qcg4ZlTwsws7GERq8aaviYYG5ZPRqTb1pvITxOFWqZN1VRhbHXwVEMzZhmEHy/A/pFNeI7qLoik0Pg2O62rqcifDu0DKHIpckW+CllNUli7IkCR9HQHfMYDMPAFS+k8ubmf6gfbJqf/OP9KxlZ7T4MEhO8QvE/NUDNLakvPQF32d/T5itAN42KLUYv5y2ngdDeUoh6bpiduXEGICJerJ0ytGjWWU+p84VlYj/4HbQL9F5u8Oc5PVrRr+JUOpWOf6fm/a56RPnzZILeZiB/l0E5WciNlamcc9WN50Y0bNR+n9jJyLCV7YxfKIvkh/FmxL0mgy8YIa7p3INjZm0uWfPCGWSzYTlPV+J5WrBs+gdZO4U4MQwp0pZXL5dic8rQ==; 5:ccsLAAmyjriUf5w77j7jgcAnEQ8dZutTkDSUhWPMEknvXx6Ew3J9O5nyVPoXWtfZrcU1OhwrHS38+oSa+/hGLW+KFcZnUfXgKpx5bu/fTmRmCsYtPxt63TKgQTHehjU95izvBpcF2Z+ctTC3cMiPq62MJB/gIJJMrkAcrQ/2HWg=; 24:JJOLPRknj7kAZ9y40WvPhNA2rXvlvryHwQV73JKDVs/N0a4Ktg6jKbztzChAMYvQquoBzGZ5tvW3Rh+FGCHCfQS2sxjF1qtkP+8Bla/D6Pc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR05MB1926; 7:CB+vzU2glgt6FDAxsvNmuA5UrQCsiAKIQErhQzgE8ZdrSAlHaNSn8eqLbhG2JDC7hRBRxeBHbrXrIcYz5MF0d0CxO/51pxTvR5EM5TATjw/h9894ovXkH11bz3wdDVN2c0TXlGYcbQ/+RMVKx2RCxzhXbpvsjyvZ0DVl/loqvSXTnUCmDCVwj2dq3uPJSL7gD28PBzr2LwVRLw5vB5KM5xFkwMhFHmvgG28oPi1gNf5kZ1fkQPrkn3gs8OCCLHoP X-MS-Office365-Filtering-Correlation-Id: 054207ac-9a71-4bea-b1ac-08d5c6d67b90 X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2018 09:11:22.9334 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 054207ac-9a71-4bea-b1ac-08d5c6d67b90 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR05MB1926 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: Andrey Shevchenko Implement support for PTA (Packet Traffic Arbitration) configuration. The PTA mechanism is used to coordinate sharing of the medium between WiFi and other 2.4 wireless networks, e.g. Bluetooth or ZigBee. This patch implements core infrastructure and vendor specific commands to control PTA functionality in firmware. Signed-off-by: Andrey Shevchenko --- drivers/net/wireless/quantenna/qtnfmac/Makefile | 4 +- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 4 + drivers/net/wireless/quantenna/qtnfmac/commands.c | 51 ++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.h | 3 +- drivers/net/wireless/quantenna/qtnfmac/qlink.h | 60 +++++++++ drivers/net/wireless/quantenna/qtnfmac/vendor.c | 145 ++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/vendor.h | 35 ++++++ 7 files changed, 299 insertions(+), 3 deletions(-) create mode 100644 drivers/net/wireless/quantenna/qtnfmac/vendor.c create mode 100644 drivers/net/wireless/quantenna/qtnfmac/vendor.h diff --git a/drivers/net/wireless/quantenna/qtnfmac/Makefile b/drivers/net/wireless/quantenna/qtnfmac/Makefile index 97f760a3d599..9e058617d694 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/Makefile +++ b/drivers/net/wireless/quantenna/qtnfmac/Makefile @@ -15,8 +15,8 @@ qtnfmac-objs += \ cfg80211.o \ event.o \ util.o \ - qlink_util.o - + qlink_util.o \ + vendor.o # obj-$(CONFIG_QTNFMAC_PEARL_PCIE) += qtnfmac_pearl_pcie.o diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c index 307ab5c59bfd..956852748cb1 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c @@ -26,6 +26,7 @@ #include "core.h" #include "util.h" #include "bus.h" +#include "vendor.h" /* Supported rates to be advertised to the cfg80211 */ static struct ieee80211_rate qtnf_rates_2g[] = { @@ -1052,6 +1053,9 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) sizeof(wiphy->fw_version)); wiphy->hw_version = hw_info->hw_version; + wiphy->vendor_commands = qtnf_vendor_cmds; + wiphy->n_vendor_commands = qtnf_vendor_get_cmds_number(); + ret = wiphy_register(wiphy); if (ret < 0) goto out; diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index 10836695c5f5..45a2effa3eab 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -22,6 +22,7 @@ #include "qlink_util.h" #include "bus.h" #include "commands.h" +#include "vendor.h" static int qtnf_cmd_check_reply_header(const struct qlink_resp *resp, u16 cmd_id, u8 mac_id, u8 vif_id, @@ -2831,3 +2832,53 @@ int qtnf_cmd_send_pm_set(const struct qtnf_vif *vif, u8 pm_mode, int timeout) qtnf_bus_unlock(bus); return ret; } + +int qtnf_cmd_setget_pta_param(struct qtnf_wmac *mac, + int param_id, bool set_op, int *param_val) +{ + struct sk_buff *cmd_skb; + struct qlink_cmd_pta_param *cmd; + const struct qlink_resp_pta_param *resp; + struct sk_buff *resp_skb = NULL; + u16 res_code; + int ret; + + if (!param_val) + return -EINVAL; + + cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, QLINK_VIFID_RSVD, + QLINK_CMD_PTA_PARAM, + sizeof(*cmd)); + if (!cmd_skb) + return -ENOMEM; + + cmd = (struct qlink_cmd_pta_param *)cmd_skb->data; + cmd->pta_param_id = param_id; + if (set_op) { + cmd->set_op = 1; + cmd->pta_param_value = cpu_to_le32(*param_val); + } else { + cmd->set_op = 0; + } + + qtnf_bus_lock(mac->bus); + ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, + &res_code, sizeof(*resp), NULL); + qtnf_bus_unlock(mac->bus); + + if (ret) + goto out; + + if (res_code != QLINK_CMD_RESULT_OK) { + pr_err("cmd exec failed: 0x%x\n", res_code); + ret = -EFAULT; + goto out; + } + + resp = (const struct qlink_resp_pta_param *)resp_skb->data; + + *param_val = le32_to_cpu(resp->pta_param_value); +out: + consume_skb(resp_skb); + return ret; +} diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.h b/drivers/net/wireless/quantenna/qtnfmac/commands.h index 03a57e37a665..59e86db5e982 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.h +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h @@ -77,5 +77,6 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif, int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif, const struct cfg80211_acl_data *params); int qtnf_cmd_send_pm_set(const struct qtnf_vif *vif, u8 pm_mode, int timeout); - +int qtnf_cmd_setget_pta_param(struct qtnf_wmac *mac, + int param_id, bool set_op, int *param_val); #endif /* QLINK_COMMANDS_H_ */ diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index 8fbef67fbbb8..582d82ceaeef 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h @@ -258,6 +258,7 @@ enum qlink_cmd_type { QLINK_CMD_CONNECT = 0x0060, QLINK_CMD_DISCONNECT = 0x0061, QLINK_CMD_PM_SET = 0x0062, + QLINK_CMD_PTA_PARAM = 0x0064, }; /** @@ -694,6 +695,52 @@ struct qlink_cmd_pm_set { u8 pm_mode; } __packed; +/** + * enum qlink_pta_mode - Packet Traffic Arbiter operating modes + * + * @QLINK_PTA_MODE_DISABLED: PTA is disabled + * @QLINK_PTA_MODE_2_WIRE: enable PTA 2-wire mode + */ +enum qlink_pta_mode { + QLINK_PTA_MODE_DISABLED = 0, + QLINK_PTA_MODE_2_WIRE = 2 +}; + +/** + * enum qlink_pta_param - parameters to configure Packet Traffic Arbiter block + * + * @QLINK_PTA_PARAM_MODE: PTA operating mode. Supported parameter + * values are defined by &enum qlink_pta_mode + * @QLINK_PTA_PARAM_REQ_POL: request polarity, (0 or 1). + * @QLINK_PTA_PARAM_GNT_POL: grant polarity, (0 or 1). + * @QLINK_PTA_PARAM_REQ_TIMEOUT: request timeout, ms. + * @QLINK_PTA_PARAM_GNT_TIMEOUT: grant timeout, ms. + * @QLINK_PTA_PARAM_IFS_TIMEOUT: IFS timeout, ms. + */ +enum qlink_pta_param { + QLINK_PTA_PARAM_MODE = 0, + QLINK_PTA_PARAM_REQ_POL, + QLINK_PTA_PARAM_GNT_POL, + QLINK_PTA_PARAM_REQ_TIMEOUT, + QLINK_PTA_PARAM_GNT_TIMEOUT, + QLINK_PTA_PARAM_IFS_TIMEOUT +}; + +/** + * struct qlink_cmd_pta_param - data for QLINK_CMD_PTA_PARAM command + * + * @pta_param_id: identifies PTA parameter, one of &enum qlink_pta_param + * @set_op: set or get operation flag (0 - get, 1 - set) + * @pta_param_value: value of PTA parameter to set + */ +struct qlink_cmd_pta_param { + struct qlink_cmd chdr; + u8 pta_param_id; + u8 set_op; + u8 rsvd[2]; + __le32 pta_param_value; +} __packed; + /* QLINK Command Responses messages related definitions */ @@ -895,6 +942,19 @@ struct qlink_resp_channel_get { struct qlink_chandef chan; } __packed; +/** + * struct qlink_resp_pta_param - response for QLINK_CMD_PTA_PARAM command + * + * @pta_param_id: identifies PTA parameter, one of &enum qlink_pta_param + * @pta_param_value: value of PTA parameter + */ +struct qlink_resp_pta_param { + struct qlink_resp rhdr; + u8 pta_param_id; + u8 rsvd[3]; + __le32 pta_param_value; +} __packed; + /* QLINK Events messages related definitions */ diff --git a/drivers/net/wireless/quantenna/qtnfmac/vendor.c b/drivers/net/wireless/quantenna/qtnfmac/vendor.c new file mode 100644 index 000000000000..dbd290632e8b --- /dev/null +++ b/drivers/net/wireless/quantenna/qtnfmac/vendor.c @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2018 Quantenna Communications, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include +#include +#include +#include "qlink.h" +#include "commands.h" +#include "vendor.h" + +static int +qtnf_vendor_parse_pta_param_id(const void *data, int len, int *param_id) +{ + struct nlattr *attr; + + attr = nla_find((const struct nlattr *)data, len, + QTNF_VENDOR_ATTR_PTA_PARAM_ID); + if (!attr) { + pr_err("attribute does not exist\n"); + return -ENOENT; + } + + if (nla_len(attr) != sizeof(u8)) { + pr_err("invalid attribute type\n"); + return -EINVAL; + } + + *param_id = nla_get_u8(attr); + + return 0; +} + +static int +qtnf_vendor_parse_pta_param_val(const void *data, int len, int *param_val) +{ + struct nlattr *attr; + + attr = nla_find((const struct nlattr *)data, len, + QTNF_VENDOR_ATTR_PTA_PARAM_VAL); + if (!attr) { + pr_err("attribute does not exist\n"); + return -EINVAL; + } + + if (nla_len(attr) != sizeof(s32)) { + pr_err("invalid attribute type\n"); + return -EINVAL; + } + + *param_val = nla_get_s32(attr); + + return 0; +} + +static int +qtnf_vendor_cmd_set_pta_param(struct wiphy *wiphy, + struct wireless_dev *wdev, + const void *data, int data_len) +{ + struct qtnf_wmac *mac = wiphy_priv(wiphy); + int param_id; + int param_val; + int ret; + + ret = qtnf_vendor_parse_pta_param_id(data, data_len, ¶m_id); + if (ret) + return ret; + + ret = qtnf_vendor_parse_pta_param_val(data, data_len, ¶m_val); + if (ret) + return ret; + + ret = qtnf_cmd_setget_pta_param(mac, param_id, true, ¶m_val); + return ret; +} + +static int +qtnf_vendor_cmd_get_pta_param(struct wiphy *wiphy, + struct wireless_dev *wdev, + const void *data, int data_len) +{ + struct qtnf_wmac *mac = wiphy_priv(wiphy); + struct sk_buff *reply; + int param_id; + int param_val; + int approx_size; + int ret; + + ret = qtnf_vendor_parse_pta_param_id(data, data_len, ¶m_id); + if (ret) + return ret; + + ret = qtnf_cmd_setget_pta_param(mac, param_id, false, ¶m_val); + if (ret) + return ret; + + approx_size = nla_total_size(sizeof(s32)); + reply = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, approx_size); + + if (!reply) + return -ENOMEM; + + nla_put_u8(reply, QTNF_VENDOR_ATTR_PTA_PARAM_ID, param_id); + nla_put_s32(reply, QTNF_VENDOR_ATTR_PTA_PARAM_VAL, param_val); + + ret = cfg80211_vendor_cmd_reply(reply); + + return ret; +} + +const struct wiphy_vendor_command qtnf_vendor_cmds[] = { + { + { + .vendor_id = QTNF_OUI, + .subcmd = QTNF_VENDOR_CMD_SET_PTA_PARAM + }, + .flags = 0, + .doit = qtnf_vendor_cmd_set_pta_param + }, + { + { + .vendor_id = QTNF_OUI, + .subcmd = QTNF_VENDOR_CMD_GET_PTA_PARAM + }, + .flags = 0, + .doit = qtnf_vendor_cmd_get_pta_param + }, +}; + +int qtnf_vendor_get_cmds_number(void) +{ + return ARRAY_SIZE(qtnf_vendor_cmds); +} diff --git a/drivers/net/wireless/quantenna/qtnfmac/vendor.h b/drivers/net/wireless/quantenna/qtnfmac/vendor.h new file mode 100644 index 000000000000..d1bb662f8eb4 --- /dev/null +++ b/drivers/net/wireless/quantenna/qtnfmac/vendor.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018 Quantenna Communications, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef QTNFMAC_VENDOR_H +#define QTNFMAC_VENDOR_H + +#define QTNF_OUI 0x002686 + +enum qtnf_vendor_cmd { + QTNF_VENDOR_CMD_SET_PTA_PARAM = 0x1, + QTNF_VENDOR_CMD_GET_PTA_PARAM = 0x2, +}; + +enum qtnf_vendor_attr_pta_param { + QTNF_VENDOR_ATTR_PTA_PARAM_ID = 1, + QTNF_VENDOR_ATTR_PTA_PARAM_VAL = 2 +}; + +extern const struct wiphy_vendor_command qtnf_vendor_cmds[]; +int qtnf_vendor_get_cmds_number(void); + +#endif /* QTNFMAC_VENDOR_H */