From patchwork Mon Dec 16 17:03:55 2019 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: 11294777 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 842BE1580 for ; Mon, 16 Dec 2019 17:08:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E9B720717 for ; Mon, 16 Dec 2019 17:08:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="nY19Qlgk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727283AbfLPRIl (ORCPT ); Mon, 16 Dec 2019 12:08:41 -0500 Received: from mail-eopbgr690050.outbound.protection.outlook.com ([40.107.69.50]:60371 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727849AbfLPRG5 (ORCPT ); Mon, 16 Dec 2019 12:06:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MhYCp3RZaAypP9t+TwTNVYQZ+31ILH28cB14RqskeBZipkggYDbAjKm5Z+s9qN5o2yO8ZorDI50i++kJaNyvurpaf6unwJrgECynasTS9eDh+hpzN525e4FXCOh1RPHbm/TkaTbiTk/Rs0XTXR2FHQkKI/znV0PE6U65MWxfdURV2/GQLWdlLKhKr2LS078MrHz3fzeMVZHfKhfcVS2M32+ScfX95M3YOKDWjrnGZfEEq/IQklTfVuSqVtCSONjZ+eb/fTuVyJE8OvGLu9kzXbuTccTzMPBItybvnV2rEtX7dbz+sMlVuTro10FG1cje1F1NMNVA4OANjTB8X4jZQQ== 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=LKokqRbCvMB90/LU4bnck62DAjSzKvABlk0gli1+IDI=; b=WaTluUt1HyX5BDq1/FA42AnoWXQ+wLen20BEMUaK97F5jbrz/TPbHQ291T3E3oYwWqmWf+20jK2rVwekEs6dQP2xui5Dd5QvVDcWlaQlHuT3wtSsYT3W1XNLcTN/UvosJiQZETXop0A/MBPE5b1nKbzJ38LVjT/N04qslQ2gOt0Gv3oesePNl36geffBZNnmqImIIBy7UnxWsJYE0GWlRdmvl5+Vnotu+GBmQTs3p64TXcvFfBYAde9HzNuDw+N9vdUn0XFBMTV3ywF0lI0MiAsVi1LT+Mm75gC6fhoKgCTPpHI736FNfp6r5GGmlnBHUs6AmSiQ5O+CljzHaIy1IA== 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=LKokqRbCvMB90/LU4bnck62DAjSzKvABlk0gli1+IDI=; b=nY19QlgkspnDphKHhnzEsg83RPjE1J7RhtjEPmBiDuCrpFCL809Hnpq+QvNsc3zDJbbG7jXA3X1GyEl2Gb435gIYHEu7eWWVT+VCt8DJ7InEcm/syKXQq2j96qjS9fzrCLp2KIH38QMgi8VwoYObJqxSTRomMab2AzMgvfSkptI= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB4142.namprd11.prod.outlook.com (20.179.149.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.15; Mon, 16 Dec 2019 17:06:44 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf%4]) with mapi id 15.20.2538.019; Mon, 16 Dec 2019 17:06:44 +0000 From: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= 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 43/55] staging: wfx: simplify hif_set_edca_queue_params() usage Thread-Topic: [PATCH 43/55] staging: wfx: simplify hif_set_edca_queue_params() usage Thread-Index: AQHVtDLMFy8LEFq+KkG0dshbJfvNyg== Date: Mon, 16 Dec 2019 17:03:55 +0000 Message-ID: <20191216170302.29543-44-Jerome.Pouiller@silabs.com> References: <20191216170302.29543-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20191216170302.29543-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8834fd11-e68f-485a-651d-08d7824a53f9 x-ms-traffictypediagnostic: MN2PR11MB4142: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-forefront-prvs: 02530BD3AA x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(346002)(136003)(376002)(39850400004)(199004)(189003)(6512007)(71200400001)(91956017)(6486002)(8676002)(2906002)(54906003)(81166006)(81156014)(186003)(76116006)(478600001)(36756003)(85182001)(85202003)(6666004)(66556008)(66476007)(66446008)(64756008)(1076003)(66574012)(316002)(2616005)(4326008)(6506007)(26005)(8936002)(110136005)(5660300002)(107886003)(66946007)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB4142;H:MN2PR11MB4063.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: OYnngvnvb3Ski5S53PTGtpXo374XCcVcCXmwChgydwtcsgaH6AQ2ormTCoymjdxtYBCznSjKbvsQjNRJ7HB1Y0DeCBv/DdgJcP9iVm1I0U/Y1EiEXEc4n0EDKCSZXwPR9PmJ6FpbcwBPptifE75rScZm6gM61vrf9qKSxzdItAGmiMStJSIyylNBeFP2nKyG98u1CjD/aHNdNl6SzAE+J2woC4gZ06yjCZe47C/2TE9WwzOrIjDq2tr7moVKe2kNyfriIQ/weEzI0arZncDJyMcbLS8NaSKpmZ7KaE/JJq72pcFxOtAut2rcY7B9yqgTmHZ7jDjhJIitV7YDQzbwIFVikjVoGXnOq7GBCMvDH3wwJGCjRIcdCCFjVILuPG8t2h+Ji16NFKhUt6DXW2KBtv5rBcdQ7ju/0jQRWpkN+jiu1bqRXFPlEjImgyRBbJMS Content-ID: <2A5490171187CC4A8E01757592B314A3@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8834fd11-e68f-485a-651d-08d7824a53f9 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Dec 2019 17:03:55.8023 (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: uxYgptWwliyYQztNPuD6gDoIjXsXJAHR8k75mOANzj9JdVJDv/C+oNKj/30NJBIhg/qZUxR+SGDt2PbqXShUTw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4142 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller The struct hif_req_edca_queue_params comes from hardware API. It is not intended to be manipulated in upper layers of the driver. So, this patch: 1. relocate the handling of this struct in hif_set_edca_queue_params() (the low level function) 2. replace it in wfx_vif by the mac80211 equivalent: struct ieee80211_tx_queue_params Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_tx.c | 20 +++++++++++++------- drivers/staging/wfx/hif_tx.h | 5 +++-- drivers/staging/wfx/queue.c | 6 +++--- drivers/staging/wfx/sta.c | 18 ++---------------- drivers/staging/wfx/wfx.h | 4 +++- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index 9cbf9d916f5f..259b49b99098 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -340,19 +340,25 @@ int hif_remove_key(struct wfx_dev *wdev, int idx) return ret; } -int hif_set_edca_queue_params(struct wfx_vif *wvif, - const struct hif_req_edca_queue_params *arg) +int hif_set_edca_queue_params(struct wfx_vif *wvif, u16 queue, + const struct ieee80211_tx_queue_params *arg) { int ret; struct hif_msg *hif; struct hif_req_edca_queue_params *body = wfx_alloc_hif(sizeof(*body), &hif); - // NOTE: queues numerotation are not the same between WFx and Linux - memcpy(body, arg, sizeof(*body)); - cpu_to_le16s(&body->cw_min); - cpu_to_le16s(&body->cw_max); - cpu_to_le16s(&body->tx_op_limit); + WARN_ON(arg->aifs > 255); + body->aifsn = arg->aifs; + body->cw_min = cpu_to_le16(arg->cw_min); + body->cw_max = cpu_to_le16(arg->cw_max); + body->tx_op_limit = cpu_to_le16(arg->txop * USEC_PER_TXOP); + body->queue_id = 3 - queue; + // API 2.0 has changed queue IDs values + if (wfx_api_older_than(wvif->wdev, 2, 0) && queue == IEEE80211_AC_BE) + body->queue_id = HIF_QUEUE_ID_BACKGROUND; + if (wfx_api_older_than(wvif->wdev, 2, 0) && queue == IEEE80211_AC_BK) + body->queue_id = HIF_QUEUE_ID_BESTEFFORT; wfx_fill_header(hif, wvif->id, HIF_REQ_ID_EDCA_QUEUE_PARAMS, sizeof(*body)); ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h index bb5860ee6542..d88019421fbc 100644 --- a/drivers/staging/wfx/hif_tx.h +++ b/drivers/staging/wfx/hif_tx.h @@ -12,6 +12,7 @@ #include "hif_api_cmd.h" +struct ieee80211_tx_queue_params; struct wfx_dev; struct wfx_vif; @@ -52,8 +53,8 @@ int hif_set_bss_params(struct wfx_vif *wvif, const struct hif_req_set_bss_params *arg); int hif_add_key(struct wfx_dev *wdev, const struct hif_req_add_key *arg); int hif_remove_key(struct wfx_dev *wdev, int idx); -int hif_set_edca_queue_params(struct wfx_vif *wvif, - const struct hif_req_edca_queue_params *arg); +int hif_set_edca_queue_params(struct wfx_vif *wvif, u16 queue, + const struct ieee80211_tx_queue_params *arg); int hif_start(struct wfx_vif *wvif, const struct hif_req_start *arg); int hif_beacon_transmit(struct wfx_vif *wvif, bool enable); int hif_map_link(struct wfx_vif *wvif, u8 *mac_addr, int flags, int sta_id); diff --git a/drivers/staging/wfx/queue.c b/drivers/staging/wfx/queue.c index 16216afe6cfc..abfbad7c9f75 100644 --- a/drivers/staging/wfx/queue.c +++ b/drivers/staging/wfx/queue.c @@ -443,7 +443,7 @@ static int wfx_get_prio_queue(struct wfx_vif *wvif, { static const int urgent = BIT(WFX_LINK_ID_AFTER_DTIM) | BIT(WFX_LINK_ID_UAPSD); - struct hif_req_edca_queue_params *edca; + const struct ieee80211_tx_queue_params *edca; unsigned int score, best = -1; int winner = -1; int i; @@ -458,7 +458,7 @@ static int wfx_get_prio_queue(struct wfx_vif *wvif, if (!queued) continue; *total += queued; - score = ((edca->aifsn + edca->cw_min) << 16) + + score = ((edca->aifs + edca->cw_min) << 16) + ((edca->cw_max - edca->cw_min) * (get_random_int() & 0xFFFF)); if (score < best && (winner < 0 || i != 3)) { @@ -595,7 +595,7 @@ struct hif_msg *wfx_tx_queues_get(struct wfx_dev *wdev) wvif->pspoll_mask &= ~BIT(tx_priv->raw_link_id); /* allow bursting if txop is set */ - if (wvif->edca_params[queue_num].tx_op_limit) + if (wvif->edca_params[queue_num].txop) burst = (int)wfx_tx_queue_get_num_queued(queue, tx_allowed_mask) + 1; else burst = 1; diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 3504b6b3515e..19ca13543a25 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -17,7 +17,6 @@ #include "hif_tx.h" #include "hif_tx_mib.h" -#define TXOP_UNIT 32 #define HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES 2 static u32 wfx_rate_mask_to_hw(struct wfx_dev *wdev, u32 rates) @@ -322,26 +321,13 @@ int wfx_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, { struct wfx_dev *wdev = hw->priv; struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; - struct hif_req_edca_queue_params *edca; WARN_ON(queue >= hw->queues); mutex_lock(&wdev->conf_mutex); assign_bit(queue, &wvif->uapsd_mask, params->uapsd); - edca = &wvif->edca_params[queue]; - edca->aifsn = params->aifs; - edca->cw_min = params->cw_min; - edca->cw_max = params->cw_max; - edca->tx_op_limit = params->txop * TXOP_UNIT; - edca->allowed_medium_time = 0; - edca->queue_id = 3 - queue; - // API 2.0 has changed queue IDs values - if (wfx_api_older_than(wdev, 2, 0) && queue == IEEE80211_AC_BE) - edca->queue_id = HIF_QUEUE_ID_BACKGROUND; - if (wfx_api_older_than(wdev, 2, 0) && queue == IEEE80211_AC_BK) - edca->queue_id = HIF_QUEUE_ID_BESTEFFORT; - hif_set_edca_queue_params(wvif, edca); - + memcpy(&wvif->edca_params[queue], params, sizeof(*params)); + hif_set_edca_queue_params(wvif, queue, params); if (wvif->vif->type == NL80211_IFTYPE_STATION) { hif_set_uapsd_info(wvif, wvif->uapsd_mask); if (wvif->setbssparams_done && wvif->state == WFX_STATE_STA) diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h index 5a2f8af17eb7..f396a502283e 100644 --- a/drivers/staging/wfx/wfx.h +++ b/drivers/staging/wfx/wfx.h @@ -26,6 +26,8 @@ #include "hif_tx.h" #include "hif_api_general.h" +#define USEC_PER_TXOP 32 // see struct ieee80211_tx_queue_params + struct hwbus_ops; struct wfx_dev { @@ -114,7 +116,7 @@ struct wfx_vif { bool setbssparams_done; struct wfx_ht_info ht_info; unsigned long uapsd_mask; - struct hif_req_edca_queue_params edca_params[IEEE80211_NUM_ACS]; + struct ieee80211_tx_queue_params edca_params[IEEE80211_NUM_ACS]; struct hif_req_set_bss_params bss_params; struct work_struct bss_params_work; struct work_struct set_cts_work;