From patchwork Thu Aug 2 10:40:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10553471 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-2.web.codeaurora.org (Postfix) with ESMTP id 030B51822 for ; Thu, 2 Aug 2018 10:41:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F128D2BBC9 for ; Thu, 2 Aug 2018 10:41:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECF952BC0E; Thu, 2 Aug 2018 10:41:04 +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 C1D9E2BC11 for ; Thu, 2 Aug 2018 10:41:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbeHBMbg (ORCPT ); Thu, 2 Aug 2018 08:31:36 -0400 Received: from mail-eopbgr680082.outbound.protection.outlook.com ([40.107.68.82]:18793 "EHLO NAM04-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726739AbeHBMbf (ORCPT ); Thu, 2 Aug 2018 08:31:35 -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=5CNOiJy/qzE2nv3OToaLd8CoEWFRkF6EZkE9Udh3unQ=; b=n6d1U1Nq32ern2R1KqIrtydVg3kOVCd182oA4GcAnSu58WA194ycsGf/ExLUi9WEX9xfu8xQm9ddk4klxq4TDxbHZWHyh2OwoODJifH6S0VNWJqQgxq551NY9mDc7wn8c2DOwQviVkXOAuwQga7Kcsp/ed3Cpv7q8S5giILRkMk= Received: from bars.quantenna.com (195.182.157.78) by DM6PR05MB4602.namprd05.prod.outlook.com (2603:10b6:5:16::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1017.8; Thu, 2 Aug 2018 10:40:55 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Andrey Shevchenko , Sergey Matyukevich Subject: [PATCH v2] qtnfmac: implement basic WoWLAN support Date: Thu, 2 Aug 2018 13:40:43 +0300 Message-Id: <20180802104043.32068-1-sergey.matyukevich.os@quantenna.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Originating-IP: [195.182.157.78] X-ClientProxiedBy: AM5PR0202CA0019.eurprd02.prod.outlook.com (2603:10a6:203:69::29) To DM6PR05MB4602.namprd05.prod.outlook.com (2603:10b6:5:16::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd767627-36c8-444c-6c51-08d5f8646dab X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:DM6PR05MB4602; X-Microsoft-Exchange-Diagnostics: 1;DM6PR05MB4602;3:ntAFQPe29rPTvq0LR3xGu3K2vgeyeuaabgax97t31PKvfeXHG68UwTlC2Tt56/l7kXpJBoGR9Rf7ZxsYqRIwzfixlODPi4xPzn/MLQH/iGW2mh2Og1t8Mxo1evAkd/Pv8sqNtMYSccltOfcQIZCU4EIEOoHkpBQwcgt6q03IxEeqBp9PhjRQPNxNqdI0VLoz/KgfjEB5YCgpBf/wFfyZCbMF44F9G2SXe8Elnw/4Ksw33Y9qdBqUO67HpTn4Zl/C;25:PDqvF02kr+DJ9ldJdHq7+tfDKbf/bb46VpJCWFOI32nmzpSqvM8XrbybwqmaQGw3CnEbHFTgzHzVvxpd/P/IREqhs4etHgzNg597dXKugZOFmSYYJoOJT7XIn6zmpLDyo2UuLdnXe7VFPcMj3rHMOiGDKEx4I33yqsV4MJQYwV9laKz4sNsnDKttwXkWpOcsBo746Y4SKZHxWgMAtJOzz1pgNCGD+f7Iml+G719oEh8nJv7lPRwCKOkKnohFbO4Gc+0Nf7//5KB0+Ffyn2kH/VEO4ExMgST1UnTs/qqklfK6c2UgdAZFycdwxy7nW9ptS9VLphmozJvDCCQd0ISF8Q==;31:u3XjPX7oMy4tujwJbHVaTitbhxFtOdkRJuEnCpwMy5YCTCKSPZ5uMj1k99POAHbvG4xpyblLnJhDzBtYAGLsn/mcDAW9EUfy6vZXY1nejQLjtowBBZpJD7J6xoV+WET+XLOkYKXelEZV+F2pvbu6Y2M+MZpBaponsfVz0L0sXKSGfpxtcsrYCpMyZbIEhn28TPdHeD4dk6E8K89q1TWUzacIV+WK1VdjmxAMtGxxQ8o= X-MS-TrafficTypeDiagnostic: DM6PR05MB4602: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=sergey.matyukevich.os@quantenna.com; X-Microsoft-Exchange-Diagnostics: 1;DM6PR05MB4602;20:qJKf6WnscxvVuVTyloXo84ffSILmKg3Vn0FqmaEo23ioogiRrUhg67yjEzEwQ017x4YPtovwijp1z6JciIHdH6ISRUPyXcsnDYQfbmCKiW4J5NlKGbz91TUP+zORT6sN2Ib8OpCUygpfNFUByJ+4sWOjFawnlzAEsnIptkmF8VzAhvoshZOCiVn27O4JjTglxCWdFHapRMunDv5WF7p8ImaNyldBIRQDjfk/DPMLSraxCdIQqXBogBvPLkCYIyZ24YHPobc5ZEm4s9/cMHXFU0AuhwAWSqOVPq8CbZIZbESVlhtJTIfz22vEJSmBDL90GJxs51ecFhRkAuCdg+kB+B31WKyGf3VkHRwUWy/+sxiU7UmeYbSwAxOVKaX1eyP8bDbY3GRLLmVHMFtYP/Y+g4KbGaqTVjOfWGI5eEx4l7ZxiuL/5HIHCehXatYhG9xf7PvNDigVQBFHHdoiKTbHXS9TgYQ8RVhqYitwoUTKmJuLIs6YZDdfXxlEFxTAeSjC;4:iNkmkhD/l+33xc3eDg2tacECfAmRI041JiDDmQ69GRBxkeHgcz07hpuvdu8AhLhOteT0rQaddhcchQwqARQTIUhd0oGbX1xxiCqgBStU+fE24h6FPPHL644M+wFjwq9YJjsz5xPhouP/SJgCtdMx1W5bOzv8voRdf32XPMNiqK/46NACIATmUauSt8D+/lW6JaRXQ4m2rqXyDoSqT59Qh8N4l72j8FQr9o37jYxkp43cZpSxi9LcftnKQ2Mrd5TjpWcAlcNTlecFL4Gx5zgeLA== 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)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(149027)(150027)(6041310)(20161123564045)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:DM6PR05MB4602;BCL:0;PCL:0;RULEID:;SRVR:DM6PR05MB4602; X-Forefront-PRVS: 07521929C1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(39850400004)(366004)(136003)(396003)(346002)(189003)(199004)(186003)(2361001)(16526019)(53936002)(7736002)(2351001)(386003)(68736007)(6486002)(14444005)(86362001)(47776003)(66066001)(50226002)(97736004)(69596002)(305945005)(26005)(7696005)(52116002)(51416003)(486006)(36756003)(1076002)(54906003)(8936002)(316002)(476003)(8676002)(956004)(2616005)(16586007)(3846002)(4326008)(6116002)(107886003)(53416004)(106356001)(6916009)(81166006)(478600001)(48376002)(105586002)(50466002)(103116003)(5660300001)(81156014)(6666003)(2906002)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR05MB4602;H:bars.quantenna.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: quantenna.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: 1;DM6PR05MB4602;23:QFg0GMxs4frvPjNaR7AEVm3a1Lf7512r06fFYApz/yQn/T9YFlTLrUT70DqAI/GGQUN6zFGiuBdTKplF71fRb+ICSIA0Eqtoywgr5Qv9ksW18q/7mLwmapi+IqV9/JYwnzgFe5bCY5w7pNy+HZEsSBwYuYUdBiD3VkoQQDcmAc8dIpI0CAmtM93PAY2oYrGYH3uP+sAsCEsVOuzK3q5mlzg4ltXR1CNuOtN6nh6GBCZlZb++dCee5k3VIOpVz8APe7C4vCy3k4uhq3Av7fVBD32HekdDlsXY7psDuDLHINWwkXRczYCBsnwKZp0jwJ6M8Gs+VmBRf7PIRYHmJMFbsM+XRCrbNx0RWi4s48wzlWUL170kev/ERNofCwUmIIYPw89Yc3b3y6hEdSM5bELUMTTt7xyfOcG4zTYhB5wZq0iRmzqi7L+7F9ycxGjaYkXwI5SYOb5K5mzt/mj6jRIIcwUmC9Yuj4iA4+z7SK9uFGoisq8ho6xK9pJT/eezdJljdNOWKBCmQgoXTA6jC9qTInje09UQJqr8wEyJsn63/VXbSAKd7WWqPU4c7DHwkGrWKEJJuMt9Q6wpfPdHzmoCPP5pSX1KLSJ65NE2TcFyoUk7QNFngVnVbEDhNdW6enc6zv7RsbWu9QNSGXyme+o3paBZ2Mph4a8QXh9hR0ZlnSVt51Ki+oPyCGMaolpHHxSqGT8g3/uZjqlwuA57upGdkp7drABgyGt78nFZQUFDz+ZBh5uCQ6qP4smXqkGqjF1CDRvbSxl2Zoy6QxtJ57fIuJ4JJgo1MDVdrtGlL8QDdAisc9MahHLKB/fNFoehTqcAYcOAH54kjCKC7KOf9C3PuxGI7s/z0v75gGHH1tNY/52JQhSqCbgEZfZMGh17rHSVflZVbY0w0mSFFmQ4fQT9AzikEFwHWSbY7inGEL7ssOpTCDSvMQYSTKIzKhhEtJHJ2JlKELFY7p8u88dGP2Y3M2i1BW2gqanPE34Z6chy6pIhpnqykLblpd51VIt7pEsrazwwuhAsncmcpEOWvdnn2qe0XqXsJszUYWUXYiYyRcYNymZm1PrUIQcj655qFRRHOuD16LW4InfDi4MLd+Pmliy7xB8kqL26j6HKYzwjQzfX4Wtz1y7yg81CD6UH1VWVOgDRpKbC3sK8GujUeGsIrYsvm1rp8XE+zKQI8qNxUo781wlinVKg9dvC2HXf62dp8rGxvK2ukqpr+zh//RssxRNPS/rklWmK2biKnAMYQiUmpHERigsC5gilHcSSdSu0 X-Microsoft-Antispam-Message-Info: uatqbVW3V+5i0MQiGpQnTv/mmTKhzR651pZHf4CAWM6pjbuUjZMAOF2zx74KEtUb7MgiyPHXndioocqADEaUEyN40T0NSTAc29S7njkKwQweAM6omYxL0oVPZempbujeMHrBPqGe0E0GVdpPQzU/hneaZHMsxAwXH6ATyD/vQoQekrO9nW5hFhOkwwwpzWuZG/5k73eVtYn3Z0vrgQHB+H6AuGGEbaLeASXIjJ+Ha412TNMmlnw+8TLt7IE3lzOfBSU8nXPYbkfekjGArzXXAhWVgNRVvPOzlt0W7PuldSGdzMeQrdpTcetncyWuGwJSJMF8VtTtrzlKU54vlouBNRgCwnmlh1/GaPbrZdZh6Aw= X-Microsoft-Exchange-Diagnostics: 1;DM6PR05MB4602;6:2yEfRtaIiaPpZz28K3tkfzutrunpjGYmFa7G1piRuKb5LgWLHHQFGVLz1UPp4oTTo8HdiGxaycJJrKO59th52LHevJYhWJgUkeOHuGmfDvYsyFE1z8eT22TRol+eGK1ikSUAKzbn1PNpjo3yFiPKRp1zNF70yW/+PHewMbtJE+j8ZEvb/GjN8UcTi8tmFYmYROXp9GF4rcaNk3LMpQqUZXg2DSxjwGuPdFuKEkfEp/17mU451QDkmq8dqNdwKz+VTmlLTMIenel5x0sC7O2dYkdUPr6nrWwAQI7bga4rB61RwjkTazB4JGPMuLWHMWpzRCFn+HCDPF59bFNRhmESGZu/oWbBIZ4yvmO8aguEd+0B36MliSdEFfvcjNcuyoSNDmYEnKvEEGVMavYNWk3P5fWOufOSmdvm8eOIPg4D3wkygYY48WbXqp2ViIgTjHnABFf07UwqiejM6dqxl7oUew==;5:3EWdUS9mLCKCGGk2Q+5anobColEOtLPua4sGwNgrIHw6H04vDOyaZ8lxO80QqVBR8M0pFVNC3jljskjaHgLGdxR66F2s0RTQEze1DdCSf2T5vgYGIN+ZoUCmSnp0c/sj/RWHgCb9WnhgXhRThfSfjKllj1jjvAm3AKMpTm0DDtE=;7:S9Tm0OVMnf8GdLYK/ecfUniTl/UJkWVE/dGEmQfAZuwimaJvldUtMwK8Pxl0k6O1uJG/KwW0Xp4JFRFd2sMCZC0VTRqmN6dpMFfrrVCeYD8RbDb24AdX2YkTJx+vweK2seXNDz7hw2MNOzhHXYiZieqhEkjyPPEdokB3PD4JaahEORrEP16WVIw1HpfeYxcxkYsaZb/wLNYLUsEElLFnxT3yvmLQjCaOjH4y61x53Wzf+MlzWsGJtAKw3N23NXpy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2018 10:40:55.3735 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd767627-36c8-444c-6c51-08d5f8646dab X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a355dbce-62b4-4789-9446-c1d5582180ff X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR05MB4602 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 This patch implements basic WoWLAN support in qtnfmac driver, including processing of WoWLAN features reported by firmware and implementation of cfg80211 suspend/resume/wakeup callbacks. Currently the following WoWLAN triggers are supported: disconnect, magic packet, custom pattern packet. Signed-off-by: Sergey Matyukevich --- Hello Kalle and all, The first four patches from the original patch set has been accepted. So the changes for v2 are as follows: - drop patch with vendor speicific commands for PTA -- to be clarified and resend separately - rebase WoWLAN patch on top of wireless-drivers-next Regards, Sergey drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 76 +++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.c | 112 ++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.h | 2 + drivers/net/wireless/quantenna/qtnfmac/core.c | 1 + drivers/net/wireless/quantenna/qtnfmac/core.h | 1 + drivers/net/wireless/quantenna/qtnfmac/qlink.h | 56 +++++++++++ 6 files changed, 248 insertions(+) diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c index 0032fa9fdddd..4aa332f4646b 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c @@ -859,6 +859,72 @@ static int qtnf_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, return ret; } +#ifdef CONFIG_PM +static int qtnf_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wowlan) +{ + struct qtnf_wmac *mac = wiphy_priv(wiphy); + struct qtnf_vif *vif; + int ret = 0; + + vif = qtnf_mac_get_base_vif(mac); + if (!vif) { + pr_err("MAC%u: primary VIF is not configured\n", mac->macid); + ret = -EFAULT; + goto exit; + } + + if (!wowlan) { + pr_debug("WoWLAN triggers are not enabled\n"); + qtnf_virtual_intf_cleanup(vif->netdev); + goto exit; + } + + qtnf_scan_done(vif->mac, true); + + ret = qtnf_cmd_send_wowlan_set(vif, wowlan); + if (ret) { + pr_err("MAC%u: failed to set WoWLAN triggers\n", + mac->macid); + goto exit; + } + +exit: + return ret; +} + +static int qtnf_resume(struct wiphy *wiphy) +{ + struct qtnf_wmac *mac = wiphy_priv(wiphy); + struct qtnf_vif *vif; + int ret = 0; + + vif = qtnf_mac_get_base_vif(mac); + if (!vif) { + pr_err("MAC%u: primary VIF is not configured\n", mac->macid); + ret = -EFAULT; + goto exit; + } + + ret = qtnf_cmd_send_wowlan_set(vif, NULL); + if (ret) { + pr_err("MAC%u: failed to reset WoWLAN triggers\n", + mac->macid); + goto exit; + } + +exit: + return ret; +} + +static void qtnf_set_wakeup(struct wiphy *wiphy, bool enabled) +{ + struct qtnf_wmac *mac = wiphy_priv(wiphy); + struct qtnf_bus *bus = mac->bus; + + device_set_wakeup_enable(bus->dev, enabled); +} +#endif + static struct cfg80211_ops qtn_cfg80211_ops = { .add_virtual_intf = qtnf_add_virtual_intf, .change_virtual_intf = qtnf_change_virtual_intf, @@ -886,6 +952,11 @@ static struct cfg80211_ops qtn_cfg80211_ops = { .start_radar_detection = qtnf_start_radar_detection, .set_mac_acl = qtnf_set_mac_acl, .set_power_mgmt = qtnf_set_power_mgmt, +#ifdef CONFIG_PM + .suspend = qtnf_suspend, + .resume = qtnf_resume, + .set_wakeup = qtnf_set_wakeup, +#endif }; static void qtnf_cfg80211_reg_notifier(struct wiphy *wiphy_in, @@ -1038,6 +1109,11 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac) if (hw_info->hw_capab & QLINK_HW_CAPAB_SCAN_RANDOM_MAC_ADDR) wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR; +#ifdef CONFIG_PM + if (macinfo->wowlan) + wiphy->wowlan = macinfo->wowlan; +#endif + if (hw_info->hw_capab & QLINK_HW_CAPAB_REG_UPDATE) { wiphy->regulatory_flags |= REGULATORY_STRICT_REG | REGULATORY_CUSTOM_REG; diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index 7942261961d6..ae9e77300533 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -1138,6 +1138,37 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus, return 0; } +static void +qtnf_parse_wowlan_info(struct qtnf_wmac *mac, + const struct qlink_wowlan_capab_data *wowlan) +{ + struct qtnf_mac_info *mac_info = &mac->macinfo; + const struct qlink_wowlan_support *data1; + struct wiphy_wowlan_support *supp; + + supp = kzalloc(sizeof(*supp), GFP_KERNEL); + if (!supp) + return; + + switch (le16_to_cpu(wowlan->version)) { + case 0x1: + data1 = (struct qlink_wowlan_support *)wowlan->data; + + supp->flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT; + supp->n_patterns = le32_to_cpu(data1->n_patterns); + supp->pattern_max_len = le32_to_cpu(data1->pattern_max_len); + supp->pattern_min_len = le32_to_cpu(data1->pattern_min_len); + + mac_info->wowlan = supp; + break; + default: + pr_warn("MAC%u: unsupported WoWLAN version 0x%x\n", + mac->macid, le16_to_cpu(wowlan->version)); + kfree(supp); + break; + } +} + static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, const u8 *tlv_buf, size_t tlv_buf_size) { @@ -1147,6 +1178,7 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, const struct qlink_iface_comb_num *comb_num; const struct qlink_iface_limit_record *rec; const struct qlink_iface_limit *lim; + const struct qlink_wowlan_capab_data *wowlan; u16 rec_len; u16 tlv_type; u16 tlv_value_len; @@ -1255,7 +1287,31 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, ext_capa_mask = (u8 *)tlv->val; ext_capa_mask_len = tlv_value_len; break; + case QTN_TLV_ID_WOWLAN_CAPAB: + if (tlv_value_len < sizeof(*wowlan)) + return -EINVAL; + + wowlan = (void *)tlv->val; + if (!le16_to_cpu(wowlan->len)) { + pr_warn("MAC%u: skip empty WoWLAN data\n", + mac->macid); + break; + } + + rec_len = sizeof(*wowlan) + le16_to_cpu(wowlan->len); + if (unlikely(tlv_value_len != rec_len)) { + pr_warn("MAC%u: WoWLAN data size mismatch\n", + mac->macid); + return -EINVAL; + } + + kfree(mac->macinfo.wowlan); + mac->macinfo.wowlan = NULL; + qtnf_parse_wowlan_info(mac, wowlan); + break; default: + pr_warn("MAC%u: unknown TLV type %u\n", + mac->macid, tlv_type); break; } @@ -2831,3 +2887,59 @@ 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_send_wowlan_set(const struct qtnf_vif *vif, + const struct cfg80211_wowlan *wowl) +{ + struct qtnf_bus *bus = vif->mac->bus; + struct sk_buff *cmd_skb; + u16 res_code = QLINK_CMD_RESULT_OK; + struct qlink_cmd_wowlan_set *cmd; + u32 triggers = 0; + int count = 0; + int ret = 0; + + cmd_skb = qtnf_cmd_alloc_new_cmdskb(vif->mac->macid, vif->vifid, + QLINK_CMD_WOWLAN_SET, sizeof(*cmd)); + if (!cmd_skb) + return -ENOMEM; + + qtnf_bus_lock(bus); + + cmd = (struct qlink_cmd_wowlan_set *)cmd_skb->data; + + if (wowl) { + if (wowl->disconnect) + triggers |= QLINK_WOWLAN_TRIG_DISCONNECT; + + if (wowl->magic_pkt) + triggers |= QLINK_WOWLAN_TRIG_MAGIC_PKT; + + if (wowl->n_patterns && wowl->patterns) { + triggers |= QLINK_WOWLAN_TRIG_PATTERN_PKT; + while (count < wowl->n_patterns) { + qtnf_cmd_skb_put_tlv_arr(cmd_skb, + QTN_TLV_ID_WOWLAN_PATTERN, + wowl->patterns[count].pattern, + wowl->patterns[count].pattern_len); + count++; + } + } + } + + cmd->triggers = cpu_to_le32(triggers); + + 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 03a57e37a665..1ac41156c192 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.h +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h @@ -77,5 +77,7 @@ 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_send_wowlan_set(const struct qtnf_vif *vif, + const struct cfg80211_wowlan *wowl); #endif /* QLINK_COMMANDS_H_ */ diff --git a/drivers/net/wireless/quantenna/qtnfmac/core.c b/drivers/net/wireless/quantenna/qtnfmac/core.c index c318340e1bd5..19abbc4e23e0 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.c +++ b/drivers/net/wireless/quantenna/qtnfmac/core.c @@ -495,6 +495,7 @@ static void qtnf_core_mac_detach(struct qtnf_bus *bus, unsigned int macid) qtnf_mac_iface_comb_free(mac); kfree(mac->macinfo.extended_capabilities); kfree(mac->macinfo.extended_capabilities_mask); + kfree(mac->macinfo.wowlan); 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 c4808f1ba8b0..a1e338a1f055 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/core.h +++ b/drivers/net/wireless/quantenna/qtnfmac/core.h @@ -110,6 +110,7 @@ struct qtnf_mac_info { u8 *extended_capabilities; u8 *extended_capabilities_mask; u8 extended_capabilities_len; + struct wiphy_wowlan_support *wowlan; }; struct qtnf_chan_stats { diff --git a/drivers/net/wireless/quantenna/qtnfmac/qlink.h b/drivers/net/wireless/quantenna/qtnfmac/qlink.h index 8fbef67fbbb8..99d37e3efba6 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_WOWLAN_SET = 0x0063, }; /** @@ -694,6 +695,30 @@ struct qlink_cmd_pm_set { u8 pm_mode; } __packed; +/** + * enum qlink_wowlan_trigger + * + * @QLINK_WOWLAN_TRIG_DISCONNECT: wakeup on disconnect + * @QLINK_WOWLAN_TRIG_MAGIC_PKT: wakeup on magic packet + * @QLINK_WOWLAN_TRIG_PATTERN_PKT: wakeup on user-defined packet + */ +enum qlink_wowlan_trigger { + QLINK_WOWLAN_TRIG_DISCONNECT = BIT(0), + QLINK_WOWLAN_TRIG_MAGIC_PKT = BIT(1), + QLINK_WOWLAN_TRIG_PATTERN_PKT = BIT(2), +}; + +/** + * struct qlink_cmd_wowlan_set - data for QLINK_CMD_WOWLAN_SET command + * + * @triggers: requested bitmask of WoWLAN triggers + */ +struct qlink_cmd_wowlan_set { + struct qlink_cmd chdr; + __le32 triggers; + u8 data[0]; +} __packed; + /* QLINK Command Responses messages related definitions */ @@ -1122,6 +1147,8 @@ enum qlink_tlv_id { QTN_TLV_ID_UBOOT_VER = 0x0407, QTN_TLV_ID_RANDOM_MAC_ADDR = 0x0408, QTN_TLV_ID_MAX_SCAN_SSIDS = 0x0409, + QTN_TLV_ID_WOWLAN_CAPAB = 0x0410, + QTN_TLV_ID_WOWLAN_PATTERN = 0x0411, }; struct qlink_tlv_hdr { @@ -1409,4 +1436,33 @@ struct qlink_random_mac_addr { u8 mac_addr_mask[ETH_ALEN]; } __packed; +/** + * struct qlink_wowlan_capab_data - data for QTN_TLV_ID_WOWLAN_CAPAB TLV + * + * WoWLAN capabilities supported by cards. + * + * @version: version of WoWLAN data structure, to ensure backward + * compatibility for firmwares with limited WoWLAN support + * @len: Total length of WoWLAN data + * @data: supported WoWLAN features + */ +struct qlink_wowlan_capab_data { + __le16 version; + __le16 len; + u8 data[0]; +} __packed; + +/** + * struct qlink_wowlan_support - supported WoWLAN capabilities + * + * @n_patterns: number of supported wakeup patterns + * @pattern_max_len: maximum length of each pattern + * @pattern_min_len: minimum length of each pattern + */ +struct qlink_wowlan_support { + __le32 n_patterns; + __le32 pattern_max_len; + __le32 pattern_min_len; +} __packed; + #endif /* _QTN_QLINK_H_ */