From patchwork Sat Feb 10 14:04:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10210503 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 DA1AD602D8 for ; Sat, 10 Feb 2018 14:04:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA297286CF for ; Sat, 10 Feb 2018 14:04:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE90C29920; Sat, 10 Feb 2018 14:04:46 +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 8C0C0286CF for ; Sat, 10 Feb 2018 14:04:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751725AbeBJOEn (ORCPT ); Sat, 10 Feb 2018 09:04:43 -0500 Received: from mail-by2nam03on0056.outbound.protection.outlook.com ([104.47.42.56]:51356 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750832AbeBJOEk (ORCPT ); Sat, 10 Feb 2018 09:04:40 -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=ooqY1gsw0QYssgAyZ8LNEkBuNsYFdyj9nOlb74SVGCs=; b=Q0QdKC7hUQvnjagl6uVeOWmEXGyje+ZOMykF+kVoANDOozz5RKs04BfGjr6NqYzSmSKfH/Zs8zSlXn4/IciUO2iElFtIaLMa+OAfqC9Aa3j0ibNKZr0xfwQQJmii0Y1MNAhHzSj9wMMwBLIGUDoB1VIAPVVRx0cI2jiLtdwZLnk= Received: from bars.quantenna.com (195.182.157.78) by SN1PR05MB1936.namprd05.prod.outlook.com (10.162.132.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.3; Sat, 10 Feb 2018 14:04:37 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Avinash Patil , Sergei Maksimenko Subject: [PATCH v2 4/4] qtnfmac: enable networked standby mode on device inactivity Date: Sat, 10 Feb 2018 17:04:20 +0300 Message-Id: <20180210140420.17013-5-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180210140420.17013-1-sergey.matyukevich.os@quantenna.com> References: <20180210140420.17013-1-sergey.matyukevich.os@quantenna.com> MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: AM6PR0402CA0007.eurprd04.prod.outlook.com (52.133.16.20) To SN1PR05MB1936.namprd05.prod.outlook.com (10.162.132.14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e67bac24-eb9b-478b-31dd-08d5708f394b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:SN1PR05MB1936; X-Microsoft-Exchange-Diagnostics: 1; SN1PR05MB1936; 3:HKB1NSikN6dRLTdBKQlvtVVMZs1rBT84Cuxw/HX/veZ5JDCP5OgI9zEhaC+Cw38DMm7SUkvr7V6/nIEouI3Q/u6bYI5bNUXxm2uuFCTm/0XtkhR8ZRTkaQZtDyyJFM1YMSx4kC//qx/iCvYQIaEUD5preN0q4tcjPz3L99kZIV2Sh5lhL/mYlDjsLTxe6pasqrKjrzpY9X9lNwZlf4xqHcscHLeP36x58oX8ZWhZlZowaF6CyhjajoZaLbxuFctl; 25:P+ZH1hy7SpiHEvO914tjSsC/vE4uoF/H3uCxgNwo9pyZbogUAKPWdj9e8miLHUZLPIPJYigWgI55SiBtv3T9pi3W/yY137ByZKKtstPjjxd5KAtGKtwKE47VIwyzMqE968kwSWcRpbRzRdVroUAgmHvROkDgARpzldO74HWQf/YTD3zPX3galXE3g1fUEW+ZzL+lcrPXiqRm9VXAp/ZXThusMI+yDArpWJlHd0tqXUmk5/7/wNZUxvCraEOtUHX7ln33CeD2KJEklKI4uuGef47k/0afDtHbhO+XwrbnGwQxS+Zh9wgfHyIqyLOMSIF+BdQx7izRJTPDh5FIRbBH6Q==; 31:JOjLj2AKdIleH/sx1v1M0FwQ9215wTN83Z6WB+CsXQ1sgO4uGdi7k88AIp1V4vQms0bRwptVvtm8TveYedKiJi2ofoeUeXlsNmL208eWV8gq7AgisILe8H0YmRCbJ23jRSR5dypgyhT6qgtqQTGe3C0b90R6cHDQoD9bervcRP7GGxLPPRyNEapFACNxWOsQ+SsQNq+/dYwHhoGixtrSz49P3a6r1hRbJtCJZyKhSYM= X-MS-TrafficTypeDiagnostic: SN1PR05MB1936: X-Microsoft-Exchange-Diagnostics: 1; SN1PR05MB1936; 20:tNwwrc0IELbMuY1mkmAVzU2/j/d4ok2Q7oYdlfmDptdOl53/LC7Ji86Clndkhe11Q87HF9xb9GZ66+9VmHXfKZV1jGHUePISlgQOUqeMsjhtbn5rKErT3ybW+Fed55kW5FgVu3bHeFXw4nAKgIVGOPcTrP+Fwy99AvGEdrp+PoDeTmqVcXaMwcS7baKjsACjWQcBUYEq2MIa4pBY+19J5E70KObNdkNjgo5Iwlr/cdJznIBeCi4C8VQ3t2vB+x95I+bCsleTLOwyR7jyOr3gKrMq5dBU0Zj99iVe8DSvVPNwya6TYcXK2VXHXcRQ1AaXHAeMLUtGYKD6yhHI6dKBinthAeNO43EnXX4ZMvyLVsvnJDieojLehwCl77ixTQqOlHnQ9gkkf8WQ/D/PM+HwG73w3YWbcPC82jBKLITG4B3djHKhiQSS7TJ7mGVC0jv3uZg69EZRFP0ML1lIZVQU5n8T2fxSMNgHnplRrBj9TAzlPkuGoMv1tfgO4zO28FGT; 4:nI3jKNlvCBuLDbB+f9F3rnZfc5a0n0okcPvPgBUUVWqZ3hiNoLhBMeQRTjrqhHPqccXsbmz6iUAeDddXH7+hb7zzAQ7WvxsBC/jJcccDfrH8KQ+TgKfjraMm+1VhXNPrwaPMiDEd0mEFgBYNNUnMyLmzUYS7mXv+fDsn5lv7pDCuIkAmGsdgKF0o94QXCz2yLXQKc8pkZ6nR1FOX2Sjotg+GZh4osZjG/wBtWk9v09P+yJ+xV+EjUU7CfGg9j5MTT7ltIPp8KD6vYLgYyV4U/g== 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)(3002001)(10201501046)(93006095)(93001095)(3231101)(2400082)(944501161)(6041288)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:SN1PR05MB1936; BCL:0; PCL:0; RULEID:; SRVR:SN1PR05MB1936; X-Forefront-PRVS: 057906460E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39380400002)(39840400004)(396003)(346002)(366004)(199004)(189003)(478600001)(54906003)(68736007)(386003)(26005)(76176011)(16586007)(105586002)(66066001)(59450400001)(16526019)(186003)(6346003)(53936002)(51416003)(7696005)(52116002)(107886003)(6916009)(2950100002)(6666003)(5660300001)(36756003)(97736004)(316002)(25786009)(4326008)(6486002)(48376002)(2361001)(2906002)(81156014)(106356001)(81166006)(1076002)(47776003)(8676002)(2351001)(86362001)(3846002)(6116002)(5890100001)(50466002)(69596002)(7736002)(305945005)(8936002)(50226002)(53416004)(103116003); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR05MB1936; 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) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR05MB1936; 23:kdOtt/FFfahmABtwO9HhrJo/33aq6lF7UUsu12c/f?= =?us-ascii?Q?32gu0r6fpp06VL7qV+rLkwerAo3lPZvuwXkXV/nET7BRSTaqkCseiWmSHquH?= =?us-ascii?Q?mpa9xcCU1cG5MtVwo1TKG0ILoStTzYZRB6kwedSUR+6riDmf0Af3e/AZmwTy?= =?us-ascii?Q?Ryy3RTwzw7TSzPOD9XVIIOOFu5kLAlGV9TNllNrCbjndd1BGy6AToRr4xJ74?= =?us-ascii?Q?8wo3H2Wyt4mNHnjav8PVdzUI4ozHpzPUPBR0Q6MKz3sCOLN0OKRhnATKLvbv?= =?us-ascii?Q?eU1n27VHlUb3e2fNmPkz174maBuUc5btpuidFLrJbXLe1pIDX3h07gkbEMlb?= =?us-ascii?Q?Hg7tEuFrE9Pb0pR08S7qvyQdWpK/xhQCURQEnqnSz78Mij62sNqsytRme3ax?= =?us-ascii?Q?HAqesz8kzsuPIM02Rz1xJy9EfvrZlysATmx+Eob1AcHhAc0Rrx5cSqd5DEv9?= =?us-ascii?Q?DQTYHUS+zsTY02bS7QUiegge1V+EI0QUN53n7w9bnFM3a+nED7WaHmgxBLbH?= =?us-ascii?Q?zXYMvUzTa3LzvTgMKBnLXo7sy1DJB9SqRg7G+N6QVkAgwt/CcHMGOCJfftLo?= =?us-ascii?Q?S+gSrUsd5FuDleffylkQza5Y6JP3exSWsYSb2jHBO0kZQ49nnjZwIjT0VsYs?= =?us-ascii?Q?q9wHrRQUMJFe4TytJK4JHUJtEuR+yP3nUvqL/eyNWL/hObU8a/UPgpCSAHhV?= =?us-ascii?Q?6fKpUkc4lIVyRLWv6me1oOupWLBEV8W5KzYq1sZUcVHhUYtBBTBeUpheTxzv?= =?us-ascii?Q?P2hM7mVON1NSoFT//r9U3fZYeVsOdonshbpT9F+u7XB74cRjXxkbvlp68mgp?= =?us-ascii?Q?07EVXKZ8v3viThH/4BkdvmTSbCeU88aSA2ghnkaqXB6jcLbIMM53wog8qKCd?= =?us-ascii?Q?ciDmj35l5Ajghy4eQ8Mc6sATXnBigmTNu38AXuX5aY49JpcqA/IL5Zl8WDDB?= =?us-ascii?Q?E9hPxz6hOtZ1tY05qxu/njnsclAE3cvO0emnFIf4V7M4qPl746HReyupNGu6?= =?us-ascii?Q?id05ea/MsIrNgX0QfII09XLJSvxhB1NVmwRZ1gnpZs5YBBeD3HNDZaM9C+N0?= =?us-ascii?Q?tX/AAXsgls/e/u1Yr3Sis0jkoXZK5or+KYed2Eiz9sYH6UgJlSu5V2DhjyHU?= =?us-ascii?Q?metaDcz9UkY2IMJSHAuNUrlplWLi88RSkn+lNFz5l6kGY4fZIngjv86oFvMU?= =?us-ascii?Q?sPIFc2XCcMvPAppNQYjwElBimy/kUo3VGAYdULyT3xLHEuF/Y3sN5hCxUxc6?= =?us-ascii?Q?LQzH8mEtWJxEIjNlmitn+SPCrz/sVe2rJhxn10wFwZ7hB+Dswqd1vqzc2Kiw?= =?us-ascii?Q?PDjihYPIonRu/T5DZn9X44=3D?= X-Microsoft-Exchange-Diagnostics: 1; SN1PR05MB1936; 6:c+OYXiRCe1dorYvsss3zkRutH1NvA0Sfb4GZbRmH7Rp97lExXqZH8lIHFJFjv/F2yh3MhZn9V5wXaKFbb6BCpGYYSXz4dHDgyw9ikddv49GVEH/gH5abQ3gKKOG0utF2k2py/P50nTbcSeTsanwr5gC1DoKj0hFeNNdLJboXLtxLx6aXP7zyfx3tShnWMYtypnz6dks65He/QANDj5mk8O12r7o8kYVXZ21syLKtJ/8m4C0Et81WxMen0Oi0dZAuu9kCPfSr1ZuwMjNE1XJGWIJS4Vz+aRTvDWgVlagdXWONn0kYzv3FL1243p8lwy+/Lj3OYMCQA2mQLoZKa/y9d9Jj+CGtKR1HBJ0p6JY1nLs=; 5:gSlHs21zoyxedPXN1Z6Fyc4Pc1SocdcHNZ+RrnEu3SpIK47dHQtroH0/yAOH4ppg0YmsTI1RUGcYltgt4PAjrsr/Q3g+kLpOXvLWRUNXLOx9fQRjwNjluHnGsiqdKUKre9iu8LUvPMOFIYsoMJ/Ls0D81FDsu27MVg1ZA+qgRF0=; 24:iAFuVfHpNlKRaaCdfpPvZf0/zGVQy8zRVhSYtCHLZycl1aqKk0W4Ztd75MXM4S3uSUKD0/83vdJQaxDst9Qtdn/2pGhQ3ZXaAT8m/S1ZpZo=; 7:XUchrzroLSjhzmJ4CjBLhjLFtaL/H0mfAQzcGrQmo0pp6yv/Cp7YY5VJHhtHqmdktSUB8m5JL08dUMYhgQFoE2JNAu1X1Qb8CtbAIgA5WbcsluPmA7H5zW/p/V+bKnxnZwo40c7qu+H0d2YJSL0lFPONmDFoxlZoiLzA+g2XYzJnH0eGLGVXb5gMG9X6OG3mlgEdR2Pph10R8hwut/lBemuVM1eDiOxzHCLHL+6ofoJSfYN5MqjsXn/uA6YLRG6/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2018 14:04:37.6812 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e67bac24-eb9b-478b-31dd-08d5708f394b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR05MB1936 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: Sergei Maksimenko Enable support of networked standby mode (NSM) on qsr10g devices. Networked standby is a power saving mode when the device keeps all existing network connections and returns to full power mode on a network activity. When enabled, device enters standby mode after 15 min of inactivity (no associated stations or no trattic). This period can be changed by setting sysfs attribute standby_timeout (0 disables NSM support). A module parameter auto_standby (defaults to 1) controls enabling NSM support on module loading. Signed-off-by: Sergei Maksimenko --- drivers/net/wireless/quantenna/qtnfmac/bus.h | 1 + drivers/net/wireless/quantenna/qtnfmac/commands.c | 33 ++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.h | 1 + drivers/net/wireless/quantenna/qtnfmac/core.c | 77 +++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/core.h | 2 + drivers/net/wireless/quantenna/qtnfmac/qlink.h | 30 +++++++++ 6 files changed, 144 insertions(+) diff --git a/drivers/net/wireless/quantenna/qtnfmac/bus.h b/drivers/net/wireless/quantenna/qtnfmac/bus.h index 0a1604683bab..7a27ffc6c7a7 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/bus.h +++ b/drivers/net/wireless/quantenna/qtnfmac/bus.h @@ -65,6 +65,7 @@ struct qtnf_bus { struct work_struct event_work; struct mutex bus_lock; /* lock during command/event processing */ struct dentry *dbg_dir; + u32 standby_timeout; /* bus private data */ char bus_priv[0] __aligned(sizeof(void *)); }; diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index deca0060eb27..1e730c9fa371 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -2753,3 +2753,36 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif, return ret; } + +int qtnf_cmd_send_pm_set(struct qtnf_bus *bus, u8 pm_mode, u32 timeout) +{ + struct sk_buff *cmd_skb; + u16 res_code = QLINK_CMD_RESULT_OK; + struct qlink_cmd_pm_set *cmd; + int ret = 0; + + cmd_skb = qtnf_cmd_alloc_new_cmdskb(QLINK_MACID_RSVD, QLINK_VIFID_RSVD, + QLINK_CMD_PM_SET, sizeof(*cmd)); + if (!cmd_skb) + return -ENOMEM; + + cmd = (struct qlink_cmd_pm_set *)cmd_skb->data; + cmd->pm_mode = pm_mode; + cmd->pm_standby_timer = cpu_to_le32(timeout); + + qtnf_bus_lock(bus); + + ret = qtnf_cmd_send(bus, cmd_skb, &res_code); + + if (unlikely(ret)) + goto out; + + if (unlikely(res_code != QLINK_CMD_RESULT_OK)) { + pr_err("cmd exec failed: 0x%.4X\n", res_code); + ret = -EFAULT; + } + +out: + qtnf_bus_unlock(bus); + return ret; +} diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.h b/drivers/net/wireless/quantenna/qtnfmac/commands.h index 69a7d56f7e58..a06e6a96c35d 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.h +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h @@ -81,5 +81,6 @@ int qtnf_cmd_start_cac(const struct qtnf_vif *vif, u32 cac_time_ms); int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif, const struct cfg80211_acl_data *params); +int qtnf_cmd_send_pm_set(struct qtnf_bus *bus, u8 pm_mode, u32 timeout); #endif /* QLINK_COMMANDS_H_ */ diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c index cf26c15a84f8..10c4e3ea2404 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.c +++ b/drivers/net/wireless/quantenna/qtnfmac/core.c @@ -26,6 +26,10 @@ #include "event.h" #include "util.h" +static bool auto_standby = true; +module_param(auto_standby, bool, 0644); +MODULE_PARM_DESC(auto_standby, "set to 0 to disable auto standby mode"); + #define QTNF_DMP_MAX_LEN 48 #define QTNF_PRIMARY_VIF_IDX 0 @@ -552,6 +556,53 @@ static int qtnf_core_mac_attach(struct qtnf_bus *bus, unsigned int macid) return ret; } +static ssize_t qtnf_pm_standby_timeout_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct qtnf_bus *bus = dev_get_drvdata(dev); + + sprintf(buf, "%u\n", bus->standby_timeout); + return strlen(buf); +} + +static ssize_t qtnf_pm_standby_timeout_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct qtnf_bus *bus = dev_get_drvdata(dev); + int timeout; + + if (count < 1) + goto out; + + if (kstrtoint(buf, 0, &timeout)) + goto out; + + if (timeout < 0) + timeout = 0; + else if (timeout > S32_MAX) + timeout = S32_MAX; + + if (timeout == bus->standby_timeout) + goto out; + + if (timeout) { + if (!qtnf_cmd_send_pm_set(bus, QLINK_PM_AUTO_STANDBY, + timeout)) + bus->standby_timeout = timeout; + } else { + if (!qtnf_cmd_send_pm_set(bus, QLINK_PM_OFF, 0)) + bus->standby_timeout = 0; + } + +out: + return (ssize_t)count; +} + +static DEVICE_ATTR(standby_timeout, 0644, qtnf_pm_standby_timeout_show, + qtnf_pm_standby_timeout_store); + int qtnf_core_attach(struct qtnf_bus *bus) { unsigned int i; @@ -608,6 +659,25 @@ int qtnf_core_attach(struct qtnf_bus *bus) } } + if (auto_standby) { + bus->standby_timeout = QTNF_DEFAULT_STANDBY_TIMER; + ret = qtnf_cmd_send_pm_set(bus, QLINK_PM_AUTO_STANDBY, + bus->standby_timeout); + if (ret) + bus->standby_timeout = 0; + } else { + bus->standby_timeout = 0; + ret = qtnf_cmd_send_pm_set(bus, QLINK_PM_OFF, 0); + } + + if (ret) { + pr_err("failed to init PM auto standby: %d\n", ret); + /* Do not cancel init when PM mode not configured */ + } + + if (device_create_file(bus->dev, &dev_attr_standby_timeout)) + pr_err("failed to init sysfs standby control file: %d\n", ret); + return 0; error: @@ -620,6 +690,13 @@ EXPORT_SYMBOL_GPL(qtnf_core_attach); void qtnf_core_detach(struct qtnf_bus *bus) { unsigned int macid; + int ret; + + device_remove_file(bus->dev, &dev_attr_standby_timeout); + + ret = qtnf_cmd_send_pm_set(bus, QLINK_PM_OFF, 0); + if (ret) + pr_err("failed to deinit NSM: %d\n", ret); qtnf_bus_data_rx_stop(bus); diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.h b/drivers/net/wireless/quantenna/qtnfmac/core.h index 3b884c80b6ab..9386f09e1fab 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.h +++ b/drivers/net/wireless/quantenna/qtnfmac/core.h @@ -52,6 +52,8 @@ #define QTNF_DEF_WDOG_TIMEOUT 5 #define QTNF_TX_TIMEOUT_TRSHLD 100 +#define QTNF_DEFAULT_STANDBY_TIMER (15 * 60) + extern const struct net_device_ops qtnf_netdev_ops; struct qtnf_bus; diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index 9bf3ae4d1b3b..ee3c65ca7148 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/qlink.h +++ b/drivers/net/wireless/quantenna/qtnfmac/qlink.h @@ -251,6 +251,7 @@ enum qlink_cmd_type { QLINK_CMD_CHAN_STATS = 0x0054, QLINK_CMD_CONNECT = 0x0060, QLINK_CMD_DISCONNECT = 0x0061, + QLINK_CMD_PM_SET = 0x0062, }; /** @@ -663,6 +664,35 @@ struct qlink_acl_data { struct qlink_mac_address mac_addrs[0]; } __packed; +/** + * enum qlink_pm_mode - Power Management mode + * + * @QLINK_PM_OFF: normal mode, no power saving enabled + * @QLINK_PM_AUTO_STANDBY: Automatic Network Standby Mode - when there is no + * traffic for the certain period, device enters power saving mode without + * disconnecting peers. Device will wake up automatically on a new + * association or data frames to TX/RX. Standby mode is activated on each + * radio interface individually, based on traffic on it. When all the + * radios enter standby mode, device informs RC via MSI. + */ +enum qlink_pm_mode { + QLINK_PM_OFF = 0, + QLINK_PM_AUTO_STANDBY = 1, +}; + +/** + * struct qlink_cmd_pm_set - data for QLINK_CMD_PM_SET command + * + * @pm_standby timer: period of network inactivity in seconds before + * putting a radio in standby mode + * @pm_mode: power management mode + */ +struct qlink_cmd_pm_set { + struct qlink_cmd chdr; + __le32 pm_standby_timer; + u8 pm_mode; +} __packed; + /* QLINK Command Responses messages related definitions */