From patchwork Fri Apr 10 13:32:26 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: 221281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0F10C2BA2B for ; Fri, 10 Apr 2020 13:34:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67492214D8 for ; Fri, 10 Apr 2020 13:34:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="f2qVbwnH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726839AbgDJNdW (ORCPT ); Fri, 10 Apr 2020 09:33:22 -0400 Received: from mail-dm6nam12on2082.outbound.protection.outlook.com ([40.107.243.82]:31903 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726767AbgDJNdQ (ORCPT ); Fri, 10 Apr 2020 09:33:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bduK8uy3N04M7SiuGQwTm/wM7fNphrNXlQhJlf1ruA2z4OP8Lwj+Hj8NdPe8MQPk0uwEQKoyeY/qaXGc5Oy3Renc6byVfgEUK7vO0GFQxSKd0vvnmdQqnYukNzr/KBHY6ZnKSr8u3NnA5BRwaN+guIRvi51CEcOaqwrYFodn0B0IR50xdTo9WNBWx4aSKFlwqAljK1dau1xzfX3iGKuLiDiEQI8/lq/kvp6zZXKoccM6lBGveKI6hNpgRQhp+HfT2i/hl4tLURsueTwre62Dcif0EXxrwy6I2wrr8SLfoQO6WBvyV/3GgK3sUDFX65nqOjAnQjYL2jYPB2OlfMTR4w== 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=p2izc7uyB5xdqbmiVLnM3cS7LoKZSmt7UicKL5cibTs=; b=hRJ0IuqX8hmj1n2rx/nHym4bJjCiP8UK7cPL2YEj/cUQncmxcgsjGoNmF9VSvEU87zsYTrCiYFcUVeGiz/+m7uH+UFxf5YWqyNa3ThRgGCY7qsFweZYf2k+XuPz6vcYW83mJD2AUOqF5YzvabdRlVBwPwdMeRIhwoRy3p0vzZGtTfOMTvvcC/V2jXnfh/s0YV4R6xQlnSNCC27/S/9u1TgYJE+6ZhB9dMpvASazLhWSYTmZCqysG1qEyA9DmZnOsuFiigJOhltTARGHA2E6kHGCYbf6e5PUnEg/r7XCJiTs6AGKO9sHm684rCiHy8ATxZHHgsaxojoDSLB/6d6p9cg== 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=p2izc7uyB5xdqbmiVLnM3cS7LoKZSmt7UicKL5cibTs=; b=f2qVbwnHgMfFENAXWlnAgVT2c9x7bfImmfPyukAwZimlvtjiDK5Wh0EYtQxfS9Nx2KpTCkwjcS8QA01RZ+k6ZfAn3ub9bOPfGxPBzapxshRWzIdA2XSNnAGlMl5266K+Y8G3GsHXHmPtzyzZE9Rny4/KIlgjQiCTY4XZajPcQl0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; Received: from MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) by MN2PR11MB4398.namprd11.prod.outlook.com (2603:10b6:208:18b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.20; Fri, 10 Apr 2020 13:33:10 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::3d0a:d9ac:3df4:8b1]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::3d0a:d9ac:3df4:8b1%6]) with mapi id 15.20.2878.021; Fri, 10 Apr 2020 13:33:10 +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 06/19] staging: wfx: change the way the station associate to an AP Date: Fri, 10 Apr 2020 15:32:26 +0200 Message-Id: <20200410133239.438347-7-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200410133239.438347-1-Jerome.Pouiller@silabs.com> References: <20200410133239.438347-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: DM5PR15CA0056.namprd15.prod.outlook.com (2603:10b6:3:ae::18) To MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (2a01:e35:2435:66a0:1265:30ff:fefd:6e7f) by DM5PR15CA0056.namprd15.prod.outlook.com (2603:10b6:3:ae::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.15 via Frontend Transport; Fri, 10 Apr 2020 13:33:08 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [2a01:e35:2435:66a0:1265:30ff:fefd:6e7f] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1715a438-8244-456e-579f-08d7dd53b60c X-MS-TrafficTypeDiagnostic: MN2PR11MB4398: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-Forefront-PRVS: 0369E8196C X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB4063.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10009020)(366004)(346002)(396003)(136003)(39850400004)(376002)(107886003)(81156014)(54906003)(8676002)(86362001)(1076003)(6666004)(8936002)(4326008)(52116002)(66574012)(7696005)(316002)(66556008)(66946007)(186003)(478600001)(2906002)(6486002)(2616005)(66476007)(16526019)(5660300002)(36756003); DIR:OUT; SFP:1101; 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: 4IpcuRAfME5f/oY1B1+lf4jQ66ACBmKUN2cKQmnnpxRhrJvrcGUV0ZP/HGYGcLwK/3d4zHlF2NXR/5d6UyrAVodX3BDGhJ04XVcx7UTe3vGpn9meiXMO54CrCnijkJBcx7u3rnILKJptR3/DjJP9JFHtkSp1T+HRwdANhshjFWUl1wzTaJDNRXgpUujfc1FDfXvo0A71lCgJhIM7i6OpUu+uQzexSVwB/JmOJH17rjDiwyfTeqaUa3bp0aXi50sAURhZ48X1USYUd7GXqbE7CbrJKVS9S+dV9fO9i0bbVKx5RJ8mzm1JBvvDj3vpLIixKqGBcicNkkcaSYf3uP5mxJH2Lam/tTwt/A/c/ejNhug04lqag2bMwQESgdzTjvTHDZWXBTOW+J8y6VE2HcmZW8HZKyGaTp6Q2K1pUDWc9kpQ5MWbv26hOtR4ryt2GpHb X-MS-Exchange-AntiSpam-MessageData: hmE3p0LxZk++jlaLwS3aTA1o0BauyVz1gyJgC4XURkUElJCLClPgTWQroFRcr2SQ+XeKPRJMNJTK4j8gix0GbQGnOvqw36zSQJEpCUZb2bK5zHo9z9qcVauGKL7Mf/3plOAiItjsyItdnuXBugOisUnrDbYdZjoJAYNFUv/q4zaSP9nc0jSk9P08Lu0JIRk3vf6c/O2C0MDtZMzdbP/2UQ== X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1715a438-8244-456e-579f-08d7dd53b60c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2020 13:33:10.4549 (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: Tbs+oXfWTrSN+fYAq36Rx3cTr/j8YjYt55aeCVxxJRlfnTJFG6Q7f51fo7wDkWR7NsHSFtk+us51LacQn8ZRGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4398 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller Chipset need two steps to associate with an AP: 1. it start receiving beacon from the AP (done with wfx_do_join()) 2. it sent the association request (done with wfx_join_finalize()) The join request (see hif_join()) contains basic rates, beacon interval and bssid to connect, so we trig on these events for the first step. The second step is obviously associated to the event BSS_CHANGED_ASSOC. Note that conf_mutex is now easier to manage. It is held by wfx_bss_info_changed() and inner functions does not need to lock it. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/sta.c | 62 +++++++++++---------------------------- 1 file changed, 17 insertions(+), 45 deletions(-) diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 1e7ff2ba33d8..acbbc3a44733 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -471,16 +471,11 @@ static void wfx_do_join(struct wfx_vif *wvif) int ssidlen = 0; wfx_tx_lock_flush(wvif->wdev); - mutex_lock(&wvif->wdev->conf_mutex); - - if (wvif->state) - wfx_do_unjoin(wvif); bss = cfg80211_get_bss(wvif->wdev->hw->wiphy, wvif->channel, conf->bssid, NULL, 0, IEEE80211_BSS_TYPE_ANY, IEEE80211_PRIVACY_ANY); if (!bss && !conf->ibss_joined) { - mutex_unlock(&wvif->wdev->conf_mutex); wfx_tx_unlock(wvif->wdev); return; } @@ -530,7 +525,6 @@ static void wfx_do_join(struct wfx_vif *wvif) wfx_update_filtering(wvif); } wfx_tx_unlock(wvif->wdev); - mutex_unlock(&wvif->wdev->conf_mutex); } int wfx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, @@ -653,6 +647,7 @@ static void wfx_join_finalize(struct wfx_vif *wvif, hif_set_association_mode(wvif, info); if (!info->ibss_joined) { + wvif->state = WFX_STATE_STA; hif_keep_alive_period(wvif, 30 /* sec */); hif_set_bss_params(wvif, &wvif->bss_params); hif_set_beacon_wakeup_period(wvif, info->dtim_period, @@ -681,7 +676,6 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, { struct wfx_dev *wdev = hw->priv; struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; - bool do_join = false; int i; mutex_lock(&wdev->conf_mutex); @@ -699,6 +693,14 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, } } + if (changed & BSS_CHANGED_BASIC_RATES || + changed & BSS_CHANGED_BEACON_INT || + changed & BSS_CHANGED_BSSID) { + if (vif->type == NL80211_IFTYPE_STATION || + vif->type == NL80211_IFTYPE_ADHOC) + wfx_do_join(wvif); + } + if (changed & BSS_CHANGED_AP_PROBE_RESP || changed & BSS_CHANGED_BEACON) wfx_upload_ap_templates(wvif); @@ -718,41 +720,14 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, wfx_tx_unlock(wdev); } - if (changed & BSS_CHANGED_ASSOC && !info->assoc && - (wvif->state == WFX_STATE_STA || wvif->state == WFX_STATE_IBSS)) { - wfx_do_unjoin(wvif); - } else { - if (changed & BSS_CHANGED_BEACON_INT) { - if (info->ibss_joined) - do_join = true; - } - - if (changed & BSS_CHANGED_BSSID) - do_join = true; - - if (changed & BSS_CHANGED_ASSOC || - changed & BSS_CHANGED_BSSID || - changed & BSS_CHANGED_IBSS || - changed & BSS_CHANGED_BASIC_RATES || - changed & BSS_CHANGED_HT) { - if (info->assoc) { - if (wvif->state < WFX_STATE_PRE_STA) { - ieee80211_connection_loss(vif); - mutex_unlock(&wdev->conf_mutex); - return; - } else if (wvif->state == WFX_STATE_PRE_STA) { - wvif->state = WFX_STATE_STA; - } - } else { - do_join = true; - } - - if (info->assoc || info->ibss_joined) - wfx_join_finalize(wvif, info); - else - memset(&wvif->bss_params, 0, - sizeof(wvif->bss_params)); - } + if (changed & BSS_CHANGED_ASSOC) { + if (info->assoc || info->ibss_joined) + wfx_join_finalize(wvif, info); + else if (!info->assoc && vif->type == NL80211_IFTYPE_STATION) + wfx_do_unjoin(wvif); + else + dev_warn(wdev->dev, "%s: misunderstood change: ASSOC\n", + __func__); } if (changed & BSS_CHANGED_ASSOC || @@ -783,9 +758,6 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, wfx_update_pm(wvif); mutex_unlock(&wdev->conf_mutex); - - if (do_join) - wfx_do_join(wvif); } static int wfx_update_tim(struct wfx_vif *wvif)