From patchwork Wed Jan 15 12:12:47 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: 11333903 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 7D2FF17EA for ; Wed, 15 Jan 2020 12:13:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4817924671 for ; Wed, 15 Jan 2020 12:13:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="AFpXz8FT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731011AbgAOMND (ORCPT ); Wed, 15 Jan 2020 07:13:03 -0500 Received: from mail-bn7nam10on2047.outbound.protection.outlook.com ([40.107.92.47]:27390 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730909AbgAOMMy (ORCPT ); Wed, 15 Jan 2020 07:12:54 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UOfvYWqLe3RYbVxRB3aCNpKXsxc7srhoU6qER8pC4MEaMwmgSB37gkoJNgtJKPgdvx2TQUq+QIjLKEdaxcQX0SMgsLJdgtZ6e48MVRGfKiru2/Iijsryi9KPf4X4yW+axcEYdSjuXdKiMcFiE9LyS6C6AFSJny8WY2wiQbHquSFz2SE2QeRhhx3FOFjM4zTFmKO3i/kJZ2IFGQ8p+kmJ6PeS5uxiMjKtDIu31sT63++EIi9Dne7cDjLEKDWYmj7mO3Vd1D9g7+IyorxCwW5pwUZv/8jptTSTYLUZtupK/Uhz8U8hSjUqv8roaEq5Nt/0IoAxo0abIvXDxCo5f4RmEw== 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=ClC2R0B1Y4NTspszJaKIQB6TBdVvSs5nXMgxP+tdgHweL108zrbn8ocYcnTjzXEvVfX7lu3+0x1LsgDNtKUcVj6S+5SvwuVx+666HEfoJtRmQwqfscKG2jLeeXugTYU4cv8Gy8J5+V/nHkLTDqXWOo8FMo517lwFIKze5O3a5z3fZOu8PP5qwMCW459DXY6eDCWvicR9kwxaO2ZbX600o7sD+2SKKnr78H3/mChuHOc0/bA0AIqvtCDzXUhWFfrG09tQADCJ9IPrW7Z9jqviDHPT8vEykCBz/FhG+cB40sQj755mJj/81eC9ewNZaYe5fyt4PWdKVGOgiWRa43tAEg== 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=AFpXz8FT5txLxDzJ63zBNh5MqIg6nQksSMY+Mt0AZzrxc9FuP+C0YG2TxbKOyw91VIvecgUI2wgrW/CTye+f/as24xF7IsDZ0f29sC+VVj7czi75aUsTeqlDwkV7M7kjo84MZXRgSsi+NDZX9lCtT7BzHBTxdNL4ADb4jro9gi4= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB4096.namprd11.prod.outlook.com (20.179.150.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2623.10; Wed, 15 Jan 2020 12:12:48 +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 12:12:48 +0000 Received: from pc-42.silabs.com (37.71.187.125) by PR2PR09CA0009.eurprd09.prod.outlook.com (2603:10a6:101:16::21) 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 12:12:46 +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 29/65] staging: wfx: simplify hif_join() Thread-Topic: [PATCH 29/65] staging: wfx: simplify hif_join() Thread-Index: AQHVy50Zs0mNUkjhK0qvoyD02QNuJw== Date: Wed, 15 Jan 2020 12:12:47 +0000 Message-ID: <20200115121041.10863-30-Jerome.Pouiller@silabs.com> References: <20200115121041.10863-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20200115121041.10863-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR2PR09CA0009.eurprd09.prod.outlook.com (2603:10a6:101:16::21) 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: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 833d5f0c-9616-423b-8eee-08d799b43c0f x-ms-traffictypediagnostic: MN2PR11MB4096: 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)(396003)(346002)(39860400002)(366004)(376002)(136003)(199004)(189003)(85202003)(66946007)(66446008)(66476007)(2906002)(107886003)(66556008)(1076003)(66574012)(64756008)(5660300002)(8936002)(6486002)(186003)(26005)(8676002)(316002)(81156014)(36756003)(52116002)(2616005)(7696005)(478600001)(16526019)(956004)(54906003)(110136005)(86362001)(71200400001)(85182001)(4326008)(81166006);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB4096;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: JDr1x/pOs94axCuPEgKl52vpYBWLCjKQCjeTrqtwkXlCLifJW4T0+DaBLGVxdRiXaGjZDb1gDeJVxWLy2WCH7ILJTBhqLAjRTiTOgN5jDu228YGSr5Fxz0oDDTmMGKWK0VrQ3ppLKhtiAdmy/MYKL69IAN+FruV5zqRgHwfbuCd05c5igSpZOXAB0VvK+9tQG9GRa40ZMqJ3gyxGl5lQDkH90W1xq4H2MTWkNvhmpU9P+7QDmDcDMpG5V/Fe10sL5FX6ri6JDSG+j8JkfHagdiU3Qf4euoJ+h5z9Nl7sXVitr6S5glvgjUeC8AEHgcZunYblEwNvbMfEkR4HjaXYpQTWH3fH9KAbME0S9fbpPiXEfwUr+XPA7cXgllFEEkCOdFWTpZTJMVHn6sJWJcT+jhmQ8xus11KssBLDD+54USk485FkeIAlN7MA1U+Ry1+v Content-ID: <28619855DCD0364BAEBE9BABCB52E6AE@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 833d5f0c-9616-423b-8eee-08d799b43c0f X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 12:12:47.8739 (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: RKhoGkWLKE1C5k3wt0yVbiX5d0tkxe2hbTs6WqDiUdl4+BopVKuGGZVe28N9rN38d4n/iXEX1cakEAEm5GNyFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4096 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 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. */