From patchwork Tue May 26 17:18:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 1298254 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=silabs.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-silabs-onmicrosoft-com header.b=jSnzVkYH; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49WggW19FCz9sSd for ; Wed, 27 May 2020 03:19:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389020AbgEZRTJ (ORCPT ); Tue, 26 May 2020 13:19:09 -0400 Received: from mail-bn8nam11on2083.outbound.protection.outlook.com ([40.107.236.83]:48578 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388955AbgEZRTH (ORCPT ); Tue, 26 May 2020 13:19:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hpsTL2tNHiNUC/gxBy1ptww6Fx9eKQyOo0lpYIe6YDslPWJcUzDprjpIElUE9m6UX7OBlxt460+d1eoQ0E89uJXB8LziAC6uIZlbSZxXJaAwFzqtExNWnyjPhUq0Y1IRY9uu7zKeOA30d4tlPB64wGLSQN95XZr5Jwe/miZ8hxIYtKmkkGHqQ0qS9Zb8O97BF6oPkZRzWbUcedd1O1gdwrJ2zmvcm/Sgj4W/LeJWpYwCdg51EXfWOhN55zCeJoAUwvrgCIOqp2DWKSDuEmX3eZsuAKDEQKqfD5yHIpSedTwSQejmLRaq/n2VgsHygc0I0kDbR7NeGXmzSd0uhoZ9aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tFgvxQnFloxqef1n9Pi21c3KsNyEjNSPr82jw3HJFKw=; b=Vii+CGUik+gQIAezwtm27GR3wnNuc2ydRzG7uB0yAp+oPVCXY2xG+Z1Zfsx/RzuU7oqB6D2LS/R862X4kR5bgI9dX2EojTZEvxJ+oNrWzBAy5gThcayHkSr8OBm2Lq1qMdqUUdhcL0HFW+V023UsnXjVJ2/jN+Yc6Boe3w8QkDqtPzV4tBo2aS6fro/9e4iP064ufCP8gpA8EXNh/ovujJy/kJ6Kr1n+3iWHdAZaDYsKLNBgNXedGcqnB81UIEzOKb7KvmR782KBCwg2DFJzj4b1f3ob68ywN6bxXdzVcgSooGrBMHKFaw6lyRfGJ/URlx2CsFSdP6Npzlt+L0uU5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tFgvxQnFloxqef1n9Pi21c3KsNyEjNSPr82jw3HJFKw=; b=jSnzVkYHeKGgtyjqMu23p4YjQ7FyNtTayHYpxuX9gF5/lHYk1WR3U/+Zeox9zlwwNt4L5nyKrP+yeOYaO6yqTVHfDUWfhHc1zwDc0AeRDSl+jFjt2JKDNw9c6MDIu64NU2HFVhKNO+0Xo8bObIj2iG6PTaj+kxdSMn27jtxg6os= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none;driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) by SN6PR11MB2750.namprd11.prod.outlook.com (2603:10b6:805:54::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.25; Tue, 26 May 2020 17:18:52 +0000 Received: from SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::c504:2d66:a8f7:2336]) by SN6PR11MB2718.namprd11.prod.outlook.com ([fe80::c504:2d66:a8f7:2336%7]) with mapi id 15.20.3021.029; Tue, 26 May 2020 17:18:52 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH 07/10] staging: wfx: add support for set/get ps_timeout Date: Tue, 26 May 2020 19:18:18 +0200 Message-Id: <20200526171821.934581-8-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526171821.934581-1-Jerome.Pouiller@silabs.com> References: <20200526171821.934581-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: PR1PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:102::20) To SN6PR11MB2718.namprd11.prod.outlook.com (2603:10b6:805:63::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.home (2a01:e35:2435:66a0:544b:f17b:7ae8:fb7) by PR1PR01CA0007.eurprd01.prod.exchangelabs.com (2603:10a6:102::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.17 via Frontend Transport; Tue, 26 May 2020 17:18:50 +0000 X-Mailer: git-send-email 2.26.2 X-Originating-IP: [2a01:e35:2435:66a0:544b:f17b:7ae8:fb7] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b36aa818-c34b-4330-7270-08d80198dc92 X-MS-TrafficTypeDiagnostic: SN6PR11MB2750: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 041517DFAB X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZlQrJdO8J+Zr1V3pOAiRmF7PM+Yea4pqpKWg2DhMUOFNiUZziMCnGkAhpx18oyRi8tYTbA1ZJFQNXO8uRPjCzHuyJKNH+vng29FcAR9/8+t3namm8GehMJYf92q6n6fc/Lqgh1Bqmh4cTsLnWkIxVjPoHsK7rn45eXW1IudWdMWQ6uIgCkq2ljcEST0fLMlsldJ3nd42ZtIHkU60ckbQBn5+6cUc9iyu4uK6KjFEs12579pzDXDpwk5kyiB0pPQ7f5ly2jpWgf3yYWpwwhxnDWS7rf+mnYSZbd+W2UBlOZmuGL523qEKGhvOfnbBvT+Q X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2718.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(396003)(376002)(366004)(39860400002)(136003)(346002)(4326008)(6512007)(316002)(8676002)(8936002)(2616005)(6486002)(2906002)(107886003)(1076003)(86362001)(6666004)(186003)(16526019)(5660300002)(66574014)(36756003)(54906003)(66556008)(478600001)(8886007)(6506007)(66946007)(66476007)(52116002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: WXg8QpZbGkgLZv1tCa/22xJcHAxx8cFy8P/8gC1E9u5uI/f2xkCqB6lu1/TRXPym+PYfWdtia0dLcfi/A94U62JjUl9LPw7t4QUeBMwzymoVv27JvaHc7AQXDjXSFIQPQJne0M16h9kv5miK4tWLPFAowgNC9aGfzcqudQvOwFPh76dpA+U6ih7OEDinnmDpGHFMVE4V5w2vUgUJQ+bIEbEuZhHGzP3kobcdlTfazuly3yPksCF0VT3d5mePAvkGM3ZEDg9FphX4gl9i5RaQMjmu20b/E3yHKHX8vTH7M0fEZqeZzeSc9hl9QtpqrnqD85ddYCutyaFOXCoK0uudcjQmFvzPMV9K9xV5/Q9cY+GwjIoWh/PP4qIfQet6tzcZa/1CpAO5B9y41KVUpvYbWxp9GO05KCxjotcGsT/v60Yd474uew9Xx8fTiJOrIUEeQAel9koF/mNIJdnKztRNzUxYBaw1M5pVkjTdJb62yIieJbgUDn6WuAb51gj9TslGM1M58VyxJ/a5cY7kW+dRWBwkIMm65sNB00tdZriXml8= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: b36aa818-c34b-4330-7270-08d80198dc92 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2020 17:18:52.1896 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cUwg/MyLcZiW0vpJNke4fO4Tx0cAOEJwJqQ6jEgtIWfu5laLArBE4bhVG2AwX73a2nuUHwVNLbkys221G7ggZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2750 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller In some advanced usage or debug scenarios, it could interesting to change the value of ps_timeout or eventually to force use of PS-Poll frames. The wext API (used by iwconfig) provide a way to change ps_timeout. However, this API is obsolete and it seems a little weird to use (it seems it doesn't apply the changes, so the user have to disable then re-enable de power save) On side of nl80211, there is no way to change the ps_timeout. This patch provides a vendor extension to nl80211 to change the value of ps_timeout. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/Makefile | 3 +- drivers/staging/wfx/main.c | 4 +++ drivers/staging/wfx/nl80211_vendor.c | 49 ++++++++++++++++++++++++++++ drivers/staging/wfx/nl80211_vendor.h | 44 +++++++++++++++++++++++++ drivers/staging/wfx/sta.c | 9 +++-- drivers/staging/wfx/sta.h | 2 ++ drivers/staging/wfx/wfx.h | 1 + 7 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 drivers/staging/wfx/nl80211_vendor.c create mode 100644 drivers/staging/wfx/nl80211_vendor.h diff --git a/drivers/staging/wfx/Makefile b/drivers/staging/wfx/Makefile index 0e0cc982ceab2..2d34a02853226 100644 --- a/drivers/staging/wfx/Makefile +++ b/drivers/staging/wfx/Makefile @@ -18,7 +18,8 @@ wfx-y := \ key.o \ main.o \ sta.o \ - debug.o + debug.o \ + nl80211_vendor.o wfx-$(CONFIG_SPI) += bus_spi.o wfx-$(subst m,y,$(CONFIG_MMC)) += bus_sdio.o diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c index 6bd96f4763884..11f6bc6fa3394 100644 --- a/drivers/staging/wfx/main.c +++ b/drivers/staging/wfx/main.c @@ -34,6 +34,7 @@ #include "secure_link.h" #include "hif_tx_mib.h" #include "hif_api_cmd.h" +#include "nl80211_vendor.h" #define WFX_PDS_MAX_SIZE 1500 @@ -312,6 +313,9 @@ struct wfx_dev *wfx_init_common(struct device *dev, sizeof(struct hif_msg) + sizeof(struct hif_req_tx) + 4 /* alignment */ + 8 /* TKIP IV */; + + hw->wiphy->n_vendor_commands = ARRAY_SIZE(wfx_nl80211_vendor_commands); + hw->wiphy->vendor_commands = wfx_nl80211_vendor_commands; hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP); diff --git a/drivers/staging/wfx/nl80211_vendor.c b/drivers/staging/wfx/nl80211_vendor.c new file mode 100644 index 0000000000000..ec2fd2d73885f --- /dev/null +++ b/drivers/staging/wfx/nl80211_vendor.c @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Extra commands for nl80211 interface. + * + * Copyright (c) 2020, Silicon Laboratories, Inc. + */ +#include "nl80211_vendor.h" +#include "wfx.h" +#include "sta.h" + +int wfx_nl_ps_timeout(struct wiphy *wiphy, struct wireless_dev *widev, + const void *data, int data_len) +{ + int reply_size = nla_total_size(sizeof(u32)); + struct nlattr *tb[WFX_NL80211_ATTR_MAX]; + struct ieee80211_vif *vif; + struct wfx_vif *wvif; + struct sk_buff *msg; + int rc, ps_timeout; + + rc = nla_parse(tb, WFX_NL80211_ATTR_MAX - 1, data, data_len, + wfx_nl_policy, NULL); + if (rc) + return rc; + vif = wdev_to_ieee80211_vif(widev); + if (!vif) + return -ENODEV; + wvif = (struct wfx_vif *)vif->drv_priv; + + if (tb[WFX_NL80211_ATTR_PS_TIMEOUT]) { + wvif->force_ps_timeout = + nla_get_s32(tb[WFX_NL80211_ATTR_PS_TIMEOUT]); + wfx_update_pm(wvif); + } + + msg = cfg80211_vendor_cmd_alloc_reply_skb(wiphy, reply_size); + if (!msg) + return -ENOMEM; + ps_timeout = wfx_get_ps_timeout(wvif, NULL); + rc = nla_put_s32(msg, WFX_NL80211_ATTR_PS_TIMEOUT, ps_timeout); + if (rc) + goto error; + return cfg80211_vendor_cmd_reply(msg); + +error: + kfree_skb(msg); + return rc; +} + diff --git a/drivers/staging/wfx/nl80211_vendor.h b/drivers/staging/wfx/nl80211_vendor.h new file mode 100644 index 0000000000000..c069330e240a9 --- /dev/null +++ b/drivers/staging/wfx/nl80211_vendor.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Extra commands for nl80211 interface. + * + * Copyright (c) 2020, Silicon Laboratories, Inc. + */ +#ifndef WFX_NL80211_VENDOR_H +#define WFX_NL80211_VENDOR_H + +#include +#include + +#include "hif_api_general.h" + +#define WFX_NL80211_ID 0x90fd9f + +int wfx_nl_ps_timeout(struct wiphy *wiphy, struct wireless_dev *widev, + const void *data, int data_len); + +enum { + WFX_NL80211_SUBCMD_PS_TIMEOUT = 0x10, +}; + +enum { + WFX_NL80211_ATTR_PS_TIMEOUT = 1, + WFX_NL80211_ATTR_MAX +}; + +static const struct nla_policy wfx_nl_policy[WFX_NL80211_ATTR_MAX] = { + [WFX_NL80211_ATTR_PS_TIMEOUT] = NLA_POLICY_RANGE(NLA_S32, -1, 127), +}; + +static const struct wiphy_vendor_command wfx_nl80211_vendor_commands[] = { + { + .info.vendor_id = WFX_NL80211_ID, + .info.subcmd = WFX_NL80211_SUBCMD_PS_TIMEOUT, + .flags = WIPHY_VENDOR_CMD_NEED_WDEV, + .policy = wfx_nl_policy, + .doit = wfx_nl_ps_timeout, + .maxattr = WFX_NL80211_ATTR_MAX - 1, + }, +}; + +#endif /* WFX_NL80211_VENDOR_H */ diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 12e8a5b638f11..7f0bb8eb78660 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -217,14 +217,18 @@ int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *enable_ps) // are differents. if (enable_ps) *enable_ps = true; - if (wvif->bss_not_support_ps_poll) + if (wvif->force_ps_timeout > -1) + return wvif->force_ps_timeout; + else if (wvif->bss_not_support_ps_poll) return 30; else return 0; } if (enable_ps) *enable_ps = wvif->vif->bss_conf.ps; - if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps) + if (wvif->force_ps_timeout > -1) + return wvif->force_ps_timeout; + else if (wvif->vif->bss_conf.assoc && wvif->vif->bss_conf.ps) return conf->dynamic_ps_timeout; else return -1; @@ -788,6 +792,7 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) wvif->vif = vif; wvif->wdev = wdev; + wvif->force_ps_timeout = -1; wvif->link_id_map = 1; // link-id 0 is reserved for multicast INIT_WORK(&wvif->update_tim_work, wfx_update_tim_work); INIT_DELAYED_WORK(&wvif->beacon_loss_work, wfx_beacon_loss_work); diff --git a/drivers/staging/wfx/sta.h b/drivers/staging/wfx/sta.h index 8a20ad9ae017e..8220d31184c8c 100644 --- a/drivers/staging/wfx/sta.h +++ b/drivers/staging/wfx/sta.h @@ -69,9 +69,11 @@ void wfx_cooling_timeout_work(struct work_struct *work); void wfx_suspend_hot_dev(struct wfx_dev *wdev, enum sta_notify_cmd cmd); void wfx_suspend_resume_mc(struct wfx_vif *wvif, enum sta_notify_cmd cmd); void wfx_event_report_rssi(struct wfx_vif *wvif, u8 raw_rcpi_rssi); +int wfx_update_pm(struct wfx_vif *wvif); // Other Helpers void wfx_reset(struct wfx_vif *wvif); +int wfx_get_ps_timeout(struct wfx_vif *wvif, bool *force_ps); u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates); #endif /* WFX_STA_H */ diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 73e216733ce4f..ef68aa4086e01 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -92,6 +92,7 @@ struct wfx_vif { bool scan_abort; struct ieee80211_scan_request *scan_req; + int force_ps_timeout; bool bss_not_support_ps_poll; struct work_struct update_pm_work; struct completion set_pm_mode_complete;