From patchwork Wed Jan 15 13:54:44 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: 1223540 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=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; 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=WYVIRL53; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47yTVL6BRlz9sSk for ; Thu, 16 Jan 2020 01:00:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729748AbgAOOAK (ORCPT ); Wed, 15 Jan 2020 09:00:10 -0500 Received: from mail-eopbgr770053.outbound.protection.outlook.com ([40.107.77.53]:11386 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729504AbgAONyr (ORCPT ); Wed, 15 Jan 2020 08:54:47 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k2VvN2ZMXMv2GpTv1VwYZWS0sHgcI8ko++GkLPB6EShnEtbU6Smit40ofHbatUTvY8SbZnTtSnMrOKwrJWb25lpgSw6grL7DBylq7CUErykp9g3Y1w3I2QYB+7o3ZVJMnquHBgXjssOlNw9SOzkgwtDThzn+VXrogO1xm8PHw0SGPfK7JyEKMlWpb7hCswUpX+LTXKQjd1TfwRqVI5evZ0cJy/zRf34mud5N47OMyBzFpY87tWu44fOGTP7oerCWZtZAufiH21P1yFSIbE80jXo7yeGigF89gEOpHaxg7bu60jWuKjsYMZh+mMTcbBIPEb39a9JrWLHrnFtybQ+mbg== 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=lh4Sgj/UN1E/Qd8hmHGGL7HIEuTRhUu+NasuAtyaxyw=; b=k7ZOh3a9fyRuZFZwujpu9jtQg+BVVe1H7oaazGUW02vJezfMVmpPRwcJDIBT49eaBTqr0fxvAvNt5+irLfES2/6S4r4pLFHjgkdQh34BAkxA00EqdqF1gspgHtyMB8cMu9pQnMzpNmAPR65/zrWFqJJOVLD+cP6T+1RlAIOh8xd7R9+SYRh27DEMmMTVYYI1aMvD5DVJVFmxm1xoiHk/t/LulXxakWYK6HaEtHYjDz0BT7C96PJEx3Pe4Mh5OnMYGsyinrFfE9KPOVwetuPcVJfHhpAdNm78cUqQtAydt9jaKN2HjOG33nWKUYsgt0Uzp8hnMHEcIaOnhFm0oKFvpA== 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=lh4Sgj/UN1E/Qd8hmHGGL7HIEuTRhUu+NasuAtyaxyw=; b=WYVIRL53YEcxyOeTLO5nQYEjhZA5OmdUD3z7DJT1oGzz5VkGDGzQ4oGKXawiaWWUKLB3cS6389bK+v4+4Lmvoou8I6R7mx9cCDUyyWCfjmDWemmN2bghqUq2vx5T1i7YHlYqz6nXyXl1eRGQhkz1Dmr5pmj/ueFJeGKd4XdxZws= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB3661.namprd11.prod.outlook.com (20.178.252.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.18; Wed, 15 Jan 2020 13:54:45 +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.2623.018; Wed, 15 Jan 2020 13:54:45 +0000 Received: from pc-42.home (2a01:e35:8bf5:66a0:3dbe:4cb5:6059:a948) by PR2P264CA0008.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.18 via Frontend Transport; Wed, 15 Jan 2020 13:54:43 +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?SsOpcsO0bWUgUG91?= =?utf-8?q?iller?= Subject: [PATCH v2 29/65] staging: wfx: simplify hif_join() Thread-Topic: [PATCH v2 29/65] staging: wfx: simplify hif_join() Thread-Index: AQHVy6tXquCrSDEORkeaA5ycct2Rrw== Date: Wed, 15 Jan 2020 13:54:44 +0000 Message-ID: <20200115135338.14374-30-Jerome.Pouiller@silabs.com> References: <20200115135338.14374-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20200115135338.14374-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR2P264CA0008.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::20) To MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.25.0 x-originating-ip: [2a01:e35:8bf5:66a0:3dbe:4cb5:6059:a948] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a200b61c-5c96-4d7d-e1c7-08d799c27a1a x-ms-traffictypediagnostic: MN2PR11MB3661: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3173; x-forefront-prvs: 02830F0362 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(396003)(136003)(346002)(366004)(199004)(189003)(8886007)(6486002)(316002)(54906003)(71200400001)(36756003)(6506007)(66476007)(66446008)(66946007)(110136005)(8676002)(81166006)(81156014)(478600001)(86362001)(2616005)(4326008)(66574012)(2906002)(107886003)(1076003)(16526019)(186003)(85202003)(5660300002)(6512007)(52116002)(64756008)(66556008)(85182001)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR11MB3661; 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: F2LMhS+T2ONX6Xn89JBoFXGIxV3toVnamorFxhmBq1ieOfcsP4ATyjVgfozsSa7tFdVy4lVPIPN8VRFLyqJJKsmWkWfr9B20pFv5iujJzHcwxFrgxLR2Zal2lt7DaQ5Hpveqp9Ou15fSTdKNoPTWnKjeZ2qUeLG0TMpoPnCY1Rs3k92GETF+9faQ6YoqHPTepDEewSLvuP35nt7Tas1I7suGhBtI34re0Tekd47iNBakYJrnuVKXgZk7l/Px7iZAE23kktzPKyCGQmDuZbpPj44BA5oTwHv14ckrKnBBqXFFEJppk7dgy8oLl/xriK1Ux5ODeeuKOX1DGl7OKvlVBV7xNDrOw6fzcUxz/CQuYRBaSIBRqbqvyiEY1s+cSdJpAjXKiS74Ke9y0lZP3EgBvGxFAievz0bxL2KiQbZAFbc30kXtl04Ku3sJCm7on/Tu Content-ID: <4EE34D735786754AACA3310B6DF3A509@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: a200b61c-5c96-4d7d-e1c7-08d799c27a1a X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 13:54:44.9310 (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: UyuXiyIMcnyeAx2GXGhhjRAF5Xsc73il+duY3sYyfpE3Qk2mym0G/6ZJhJg9kONYmMiuPR+bRiRmyk0I7h7cYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3661 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller The structure hif_req_join come from hardware API. It is not intended to be manipulated in upper layers of the driver. In add, current code for hif_join() is too dumb. It should pack data with hardware representation instead of leaving all work to the caller. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_tx.c | 25 ++++++++++++++------ drivers/staging/wfx/hif_tx.h | 3 ++- drivers/staging/wfx/sta.c | 45 ++++++++---------------------------- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c index 32eeba2fca47..2428363371fa 100644 --- a/drivers/staging/wfx/hif_tx.c +++ b/drivers/staging/wfx/hif_tx.c @@ -288,18 +288,29 @@ int hif_stop_scan(struct wfx_vif *wvif) return ret; } -int hif_join(struct wfx_vif *wvif, const struct hif_req_join *arg) +int hif_join(struct wfx_vif *wvif, const struct ieee80211_bss_conf *conf, + const struct ieee80211_channel *channel, const u8 *ssidie) { int ret; struct hif_msg *hif; struct hif_req_join *body = wfx_alloc_hif(sizeof(*body), &hif); - memcpy(body, arg, sizeof(struct hif_req_join)); - cpu_to_le16s(&body->channel_number); - cpu_to_le16s(&body->atim_window); - cpu_to_le32s(&body->ssid_length); - cpu_to_le32s(&body->beacon_interval); - cpu_to_le32s(&body->basic_rate_set); + WARN_ON(!conf->basic_rates); + body->infrastructure_bss_mode = !conf->ibss_joined; + body->short_preamble = conf->use_short_preamble; + if (channel && channel->flags & IEEE80211_CHAN_NO_IR) + body->probe_for_join = 0; + else + body->probe_for_join = 1; + body->channel_number = cpu_to_le16(channel->hw_value); + body->beacon_interval = cpu_to_le32(conf->beacon_int); + body->basic_rate_set = + cpu_to_le32(wfx_rate_mask_to_hw(wvif->wdev, conf->basic_rates)); + memcpy(body->bssid, conf->bssid, sizeof(body->bssid)); + if (!conf->ibss_joined && ssidie) { + body->ssid_length = cpu_to_le32(ssidie[1]); + memcpy(body->ssid, &ssidie[2], ssidie[1]); + } wfx_fill_header(hif, wvif->id, HIF_REQ_ID_JOIN, sizeof(*body)); ret = wfx_cmd_send(wvif->wdev, hif, NULL, 0, false); kfree(hif); diff --git a/drivers/staging/wfx/hif_tx.h b/drivers/staging/wfx/hif_tx.h index 924b889cad0a..20977e461718 100644 --- a/drivers/staging/wfx/hif_tx.h +++ b/drivers/staging/wfx/hif_tx.h @@ -45,7 +45,8 @@ int hif_write_mib(struct wfx_dev *wdev, int vif_id, u16 mib_id, int hif_scan(struct wfx_vif *wvif, struct cfg80211_scan_request *req80211, int chan_start, int chan_num); int hif_stop_scan(struct wfx_vif *wvif); -int hif_join(struct wfx_vif *wvif, const struct hif_req_join *arg); +int hif_join(struct wfx_vif *wvif, const struct ieee80211_bss_conf *conf, + const struct ieee80211_channel *channel, const u8 *ssidie); int hif_set_pm(struct wfx_vif *wvif, bool ps, int dynamic_ps_timeout); int hif_set_bss_params(struct wfx_vif *wvif, const struct hif_req_set_bss_params *arg); diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 395a282346b1..30c62e3b3716 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -512,32 +512,19 @@ static void wfx_set_mfp(struct wfx_vif *wvif, static void wfx_do_join(struct wfx_vif *wvif) { - const u8 *bssid; + int ret; + const u8 *ssidie; struct ieee80211_bss_conf *conf = &wvif->vif->bss_conf; struct cfg80211_bss *bss = NULL; - struct hif_req_join join = { - .infrastructure_bss_mode = !conf->ibss_joined, - .short_preamble = conf->use_short_preamble, - .probe_for_join = 1, - .atim_window = 0, - .basic_rate_set = wfx_rate_mask_to_hw(wvif->wdev, - conf->basic_rates), - }; wfx_tx_lock_flush(wvif->wdev); - if (wvif->channel->flags & IEEE80211_CHAN_NO_IR) - join.probe_for_join = 0; - if (wvif->state) wfx_do_unjoin(wvif); - bssid = wvif->vif->bss_conf.bssid; - bss = cfg80211_get_bss(wvif->wdev->hw->wiphy, wvif->channel, - bssid, NULL, 0, + conf->bssid, NULL, 0, IEEE80211_BSS_TYPE_ANY, IEEE80211_PRIVACY_ANY); - if (!bss && !conf->ibss_joined) { wfx_tx_unlock(wvif->wdev); return; @@ -545,29 +532,15 @@ static void wfx_do_join(struct wfx_vif *wvif) mutex_lock(&wvif->wdev->conf_mutex); - /* Sanity check basic rates */ - if (!join.basic_rate_set) - join.basic_rate_set = 7; - /* Sanity check beacon interval */ if (!wvif->beacon_int) wvif->beacon_int = 1; - join.beacon_interval = wvif->beacon_int; - join.channel_number = wvif->channel->hw_value; - memcpy(join.bssid, bssid, sizeof(join.bssid)); - - if (!conf->ibss_joined) { - const u8 *ssidie; - - rcu_read_lock(); + rcu_read_lock(); + if (!conf->ibss_joined) ssidie = ieee80211_bss_get_ie(bss, WLAN_EID_SSID); - if (ssidie) { - join.ssid_length = ssidie[1]; - memcpy(join.ssid, &ssidie[2], join.ssid_length); - } - rcu_read_unlock(); - } + else + ssidie = NULL; wfx_tx_flush(wvif->wdev); @@ -578,7 +551,9 @@ static void wfx_do_join(struct wfx_vif *wvif) /* Perform actual join */ wvif->wdev->tx_burst_idx = -1; - if (hif_join(wvif, &join)) { + ret = hif_join(wvif, conf, wvif->channel, ssidie); + rcu_read_unlock(); + if (ret) { ieee80211_connection_loss(wvif->vif); wvif->join_complete_status = -1; /* Tx lock still held, unjoin will clear it. */