From patchwork Thu May 31 09:11:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Matyukevich X-Patchwork-Id: 10440567 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 BC455602BF for ; Thu, 31 May 2018 09:11:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B589E290A1 for ; Thu, 31 May 2018 09:11:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A826D291B9; Thu, 31 May 2018 09:11:41 +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 C4F5A290A1 for ; Thu, 31 May 2018 09:11:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754285AbeEaJLj (ORCPT ); Thu, 31 May 2018 05:11:39 -0400 Received: from mail-by2nam01on0054.outbound.protection.outlook.com ([104.47.34.54]:62994 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754093AbeEaJLa (ORCPT ); Thu, 31 May 2018 05:11:30 -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=8LeOxbIAv7X7eQbdO1EYs59fNH1da5s1n64/9dPXi/c=; b=mOC9IjadVageOfSn+avqt5fWUTBXHJY+AnffLVZFR5p3OJyVwO8eRwsTxnnUwb/L1qtJKFifKZ/WawmXaGbrhZx9CIYoB6QXOIRtGYY1FXMOHJovNrr7uNyLpmRdPlnAEPqWBgwnUOrvh7Ba88X9uKQBcjku+p4HUikbL73wZS8= 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:24 +0000 From: Sergey Matyukevich To: linux-wireless@vger.kernel.org Cc: Igor Mitsyanko , Andrey Shevchenko , Sergei Maksimenko , Sergey Matyukevich Subject: [PATCH 6/6] qtnfmac: implement basic WoWLAN support Date: Thu, 31 May 2018 12:11:02 +0300 Message-Id: <20180531091102.28666-7-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:JE7yVtwO6v/Lnps6MnZw1erLDFEsf61VX6lfaPEo7H+qh/znWYC7wnaQl9sjJ2+jPET6i8+JwDheMs4/hDXAUgKEmWBbgabm80L1UnPXn4GwPoNUq6Q1c43vWM9J8qV0UWntw36xfRH/XOXQeQZ7UfpSVR1WVAz5Q+ZUGj9pKHq5Gxz5EARE60sxMxxyve2bBW2TlBs2NubltAp28BPcYP102NVXeCcsGz0r3ao8VjBEXcHgf+wg/Y1pdjUbRiAN; 25:tkkdXeWCQsw/pZo4HRZ01xV8t6U8w7snhvanxoULHybljNw1rJppHxKpJyIfYVLZN6MpSpol6Pl0TBSDu/VrDbiYidl1SHb69KpJue+yTF5zkZZsj/BaJLuu81S/X5JIQ3ynyJJpzI+3FgQ6lXZfhzOLp5ikA1cJJlatWZ0Rqjxbajh6zC7nmmzlfX3xrCHeZSNHdVGUybwnQV2NIRChGe2L4mgn6GyWQQhGPdS3U07XzznqiMQVh+i/bUUNmVynXxjNx5Zi/zjZn2FiR/4lKK4K+SPJ9hjQwTV+YyhlI/LzirKXGL1w2VjBFRcTBfVnvC7w+OAyt6dLnZUHIMxTsg==; 31:1ztyHq3Q+G4GCBtIBG5umV9/RRCTz1wNwsqc634yjlZ9VuQFHn6vEwlF4r5zn+fneQ/ROS5T9DaIch1lCsrdq3B1dOh7jmJd7WpF2tPfICsdRxWJtgD/SAuIm5GIysRy9f7qHnVk2pMIhV5NyzZtu+gwIix61rZty7dGjPwnsBWkImV5HQlIOmfgPA7+MbI4uGup9ZnhgzfldAKu0VTkRqcWLRjbHfaMS1pF5+bF0O0= X-MS-TrafficTypeDiagnostic: BY2PR05MB1926: X-Microsoft-Exchange-Diagnostics: 1; BY2PR05MB1926; 20:9A7V5piTFqRIBLVBaiREgPga7oyETXhyByVIfp5AG9MLRnG/gbYLbRY2glTPmHf1iCvJSfVGq7lM3XEThYKAwYaHEowidPkLOzgLlOmqKrn7fu5I9IO1aIe2zj1r/sYciFmWwOMt0gTgi51uuEW0ghAEflb0RWKKnTiH4wKsK2A6RxQnZK+ttdN/44VuZBDXYfnBrRn6PEvVILO+Yg18aCeEgTNndIO+nscY0hPljEzJHdbGlrW2dt8nNUyDcTJu/OaIU5ljzZXb7HUyTAej7YIZgemJfk7zZd4iS9CzXO2FdAdSwP77CqYVtnqPPQdvc/Ehs2FvkL+bgluDW2zrKrERrMsPPyoxKN4yaSX8YXfQqUZw5S7/LbQwRufvl4Ql8EBiFflRXYbI8lwqhyUdlDThhQ8jb0pfHFBT2qe3PlRqs3uMUiJ/6wVjN6doz46GumH3YYvcfG6dnS6R00CXRtCPB46Hmnc/h6F7Np1p+2uIsWoodzTThFl+Jgbp7nb/; 4:CeZQjUM+0OoW/U6fidrtp7Z/BQ5GiRUMLhr7QssMqy68wGTEi6ofY1xRSTHEkQj3W5hEscvdDQjFaOaYpt3mvmo1Ga8sHNGE/ShAwiTiDqQQ3oyQ8rIQIs9MHILc/PAac5ZAMMIDHZjgjYB5uc1etuZEmI6bQx0jlW/cG79e3W1KcOsqOJgMnWJyDu7J2Rk5ps2b+i73fjDSP3P6SCinnbRuE4oFqkJql6PQAQPRFteZXIImsMj7A1LOacvLWSP4yvj6VjK3VJeHbiUnlzwVMA== 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)(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)(575784001)(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); 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:4t51kt0ZsFunforstFVaJyccZRdWbGgZSF1r8xXxO?= =?us-ascii?Q?i9Aw5ikbmkpXVx6bOykIwaHyiHBBIj8ieqD5sG54moiqP+q6vYqFgFebO0BS?= =?us-ascii?Q?ApbYvJwVa/Y2u6snqNVbIRlJwUltYQCr0wTUa0aSZceLG/NdknolfybNUhCV?= =?us-ascii?Q?MPTbpD9NU4u4wBSWzYxabY/bUI6wKCf2nmc24KoLOc8HIyHMbSpTnYz1HOAY?= =?us-ascii?Q?fUPAxAUZR1XwbLdMZqsNzTWeDPWgrhZtGcBCA2f3LJRVLOoMZciMXUAPA6dK?= =?us-ascii?Q?b1WrQWmQmWlq0aVWxUcPHn/CjR/rRLKBgZNLtoWKN0BHTMGojKr+w5o+jpSo?= =?us-ascii?Q?MfmRGOaGXhtKlvxzE31sC++syZ/TK6OqGLhYB+pompV//IKAuNFQE8cFDBdU?= =?us-ascii?Q?T5rtQV7bPfGmfMXZHCZU4ZWKzYW5kocQf5Q5AG5ndS1T0zT1qKfjjptSkO0k?= =?us-ascii?Q?vouGQziSZaehLZ4MPGYe3t58H7lOrfd9mu6WYgFlwof4dEY1DXhmt7+nVu49?= =?us-ascii?Q?qQacfji7KDDcqaK6PRrWyeqefFoQxwwJp2NcyIhTXi8f/s94lsTtA4pONwyi?= =?us-ascii?Q?KCrF1YsgbrZYGwOiiJVQepVvxcqs4RCHlxoCFGvVBpt0usPGdZ7LJGy2xfXr?= =?us-ascii?Q?1q4dywbXYMOd+Fnz8XqwtOcqyGMOjvilyUtHlx4ujOgr4vMU2JIHg0P6D1Tp?= =?us-ascii?Q?AbWV/Ddm0plfu4OGwkd/8aOlyUSRw4tqPYEn5CAdteKlImp8mAqiIMLumYTD?= =?us-ascii?Q?9s3aEjfdOdId0WLTyh+tL9nwkI874DRTtaRdDewganXrQ7TygPxbAChghHeK?= =?us-ascii?Q?ucOcDS/Bzx5Lq+qO/t33u6uEQr164+8kRT7UXBBGsbdXUml+s49agYYmSwz9?= =?us-ascii?Q?/Hj1SvMH8QEpAXB8SdAWKTmZDv4V7rMzyW0B4DBcZfT0X58rhBy37rzBOr1N?= =?us-ascii?Q?ShGINYV6+srWFlT63ec+ixR9nJBSa1zaMCUubtKYUtSHJGQbUILFXYio7Pd7?= =?us-ascii?Q?8COJyWiLBWfYpsgHHlPxvE5sholDXsTA8il5KAlw3UgXzFI1pl4cU49hEVHc?= =?us-ascii?Q?t7om8UcZd49VR5KDiAyrwXN8GyTlzrp5sdApPfWEzO5rkTzZ+tybBc/hu73H?= =?us-ascii?Q?LptlaJr3r9e/OJ253bsfjNnP0BMBXEFlvVmHljrr0qCJMe+rYR3HHz5fXLS4?= =?us-ascii?Q?uOgJ8alUqKgleMmuaxDYRuIIkZaeAwOlNKm4pmShFXrhJcIP94GT0gkDjPnk?= =?us-ascii?Q?w8Iv250z2p7gWhnsv4Yx8rUKWgt26Ko2ErGd1wBEFd7Em4a+jkl2V8azExYc?= =?us-ascii?Q?BROdl7DUboY2LGCeqbDFmhBjhvJ0SY95CM06X30nm0r7px0XysEuOdoQ93JU?= =?us-ascii?Q?AQEefOztlVq7K18ncfpoMyIt4A=3D?= X-Microsoft-Antispam-Message-Info: 5ilGCtDLIXk134G+1Zb2bSfghE98NltpEWri3zWd9UTIYszWvFtAj6ScgZW1GQiECLxgIvScZB42j2qCPXpyvUIDO4ni53mDSActZ6MDAUQlbgzwf2OeE2JliKVOMXkAEQJvoB+w0RZjKMYE+etSQuq9ZmJUHdn0Q23jdRMx1hZN0eA2437ozPc8bvggLZ0m X-Microsoft-Exchange-Diagnostics: 1; BY2PR05MB1926; 6:LhPlAOHtIYB0kVmT5zKtJ6pyhSji48SNhrKd/r182GPWs+bizX7i4DZu9Q3o9dnxRAt7ZBy/ROjd7hHUBEaRSPGNaIu4QVxmGHAvux75yZPpiQG4jk+ptfHAGYxkAlRztsNH0Bq3tHVJL+6f/25Lgs89MUxW57bcnlH0f//GxAVg9w/2fbLT3dnxpA0ppFkH1+5ZoXIPKptY7bEGW2YcvHnjZ7/GNFOJZFXxXGjflUN57HhQ9xv1maTLslMeqe10tK7snS3beLvkmCne1b17bf/6aWfIg0WA7NsvBxR+YjN0MPFCjx6M2QBj7E/x0FPQl3YUv4TQfjJ87wFLkDRtg8+azYCkCkrsMD2LDfZSCyIUt48kGG3D3OoqpNdd/rPMlhdAVaJuG3VH80NAsy2+JlZS1nZc3LuQJquxc9Vlp4d7PgTDU7FrKpBsixtz7QfMkyb8zG6QCp8svq40JS+jZw==; 5:9rDdTPCSShBr2NDQbSR1YkUAbI4HhsfbhdTeNMGXoQCDzC6RqR9IetMAKnOQuNYPg9vcu7CEWlIFbiVOdqZg9apnuyU+R0F2TY5SzghSzNXUluN1Kq32YnpUWZgtLy0On2ELs/J+o912YwEf7RP6YDLgkF4Wm8o2w/b48ZfF1XM=; 24:NCwiBSLomUJQKN7wNhw/6UaNEEKBp8E00QwLzJJmtFojaWB4KT2fXYnhkztD7MldrX0DkKCD86hlWjoLAAD4dpiv5iRb+5btN7syCvndTKs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR05MB1926; 7:ey9ATHxtIk6PjAt4UAKO42Btl24cHItc8Nff8518kN2ckC/qTkubD5SGDsdqpCVSE5tF0Oa+yGxJ2EjJVDwO07rHPhSPZz6d1iSiyYFYIOgWiQd6XWQw4kdGQ6BJtyry4/PQHbffMi0oPyR8CY0TlVlZV9LHWLhnjfSKoh2EYkMvXJLF+wZtRb5doh4XJdW4NT/BVWQypMHbWeUh+lkJOgHi2wS7Jjf0LJzpTQ3S8Zr2RBwFUBtNWXXvd205sLQH X-MS-Office365-Filtering-Correlation-Id: 361fbbf3-ae71-44d4-4a9e-08d5c6d67cb5 X-OriginatorOrg: quantenna.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2018 09:11:24.6358 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 361fbbf3-ae71-44d4-4a9e-08d5c6d67cb5 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 This patch implements core 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 --- drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | 76 +++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.c | 112 ++++++++++++++++++++++ drivers/net/wireless/quantenna/qtnfmac/commands.h | 3 + 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, 249 insertions(+) diff --git a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c index 956852748cb1..c0d5ca37168b 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c +++ b/drivers/net/wireless/quantenna/qtnfmac/cfg80211.c @@ -861,6 +861,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, @@ -888,6 +954,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, @@ -1040,6 +1111,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 45a2effa3eab..d9540edf78de 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c @@ -1139,6 +1139,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) { @@ -1148,6 +1179,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; @@ -1256,7 +1288,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; } @@ -2882,3 +2938,59 @@ int qtnf_cmd_setget_pta_param(struct qtnf_wmac *mac, consume_skb(resp_skb); 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 59e86db5e982..08cb98e8ba7f 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.h +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.h @@ -79,4 +79,7 @@ int qtnf_cmd_set_mac_acl(const struct qtnf_vif *vif, 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); +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 582d82ceaeef..8823ab12ac3a 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, QLINK_CMD_PTA_PARAM = 0x0064, }; @@ -741,6 +742,30 @@ struct qlink_cmd_pta_param { __le32 pta_param_value; } __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 */ @@ -1182,6 +1207,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 { @@ -1469,4 +1496,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_ */