From patchwork Tue Dec 17 16:15:33 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: 11298105 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 866936C1 for ; Tue, 17 Dec 2019 16:16:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A91D21835 for ; Tue, 17 Dec 2019 16:16:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="gcVj3wbA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729191AbfLQQQJ (ORCPT ); Tue, 17 Dec 2019 11:16:09 -0500 Received: from mail-dm6nam12on2072.outbound.protection.outlook.com ([40.107.243.72]:33729 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729143AbfLQQQH (ORCPT ); Tue, 17 Dec 2019 11:16:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i7vRipy14vfywrxmPySUuyYONoDMSf0v+iLQpZadMAoYoljN85Tbam7LomX+ydwl1M+DUc1hULP0KMRToSmypHu9VMf3mR+tTQ+uQQQiI3/Qgve8QI7SE+W4anbYpvvF5MX+PLsIeHPPrj0KqfnXB34JIxYJ0lUQKeVy4eS0dN1ccw07a/M00+zTNa5whBzEwGwUplQ6mdS6/OKX7+OYOtzlFORxWoWmvQed3T0C2gjHFJK4TNyF43jLnLWnUWqOvaNGfhM9A5y17G+jTQ9NzdkzsC8cbAdtqn4WjelHiLG3IbcSk7oxOwK7Xc/960FVrugJY6P6N1dU1kHBDVQHOA== 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=kDlT1we7iUloIGeD2+QPkjZvQgP8SkCL4bnHISJpnvQ=; b=XrC0B31FDAmdpcr+j+kxrIyc8D3HUl8jZ8kra9VF1xHyUvlBMoVTxRsOd9/lC+7Rp1W2hpu45O4fDYsSYrh9K1grhIFX8Kg55t2H49vNrbxxRzeqnRnmOLo10bMTVon3mg/fuv3lRPVUF9GRtu0ly0cYaiFgfSrKASwP0ZhL2vq7XCfKxd/sBO+OOMGT5SMQmBuf5iy4PsMYVnEnis79N7jYMpjHDKKFp5BrAkwrBgt1/DK6XF9E39sAzzIECSOHgkvKaLp9jPCRUc4+3JfF1oSCfjRI+Mg+S2BOnnMKpGXabMaiFt+Ta8kEpLMiEOIXYdoyg8hlW5LJReH4zrOkzA== 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=kDlT1we7iUloIGeD2+QPkjZvQgP8SkCL4bnHISJpnvQ=; b=gcVj3wbANwXkewBloBMUF9EuSw1EFYLbHxlAXgdoSrwCSKE9fdvJ2nyhVgHPWNq0dBrfl7jAVZTkbvDAih/gFCrZKCCUaU12GMKmLFXa8GFgETt7LBUWP0SBvE/SHuzgo0yRstGrYHNywD60uHXajxoFvdGzMfjliQumgSwmHQE= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB4477.namprd11.prod.outlook.com (52.135.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.17; Tue, 17 Dec 2019 16:15:56 +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; Tue, 17 Dec 2019 16:15:56 +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 v2 48/55] staging: wfx: introduce update_probe_tmpl() Thread-Topic: [PATCH v2 48/55] staging: wfx: introduce update_probe_tmpl() Thread-Index: AQHVtPU1dd3K0gcNdECLeABwaV69EQ== Date: Tue, 17 Dec 2019 16:15:33 +0000 Message-ID: <20191217161318.31402-49-Jerome.Pouiller@silabs.com> References: <20191217161318.31402-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20191217161318.31402-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0174.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::18) 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.24.0 x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2fea9b41-b5f0-4122-8369-08d7830c57de x-ms-traffictypediagnostic: MN2PR11MB4477: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1443; x-forefront-prvs: 02543CD7CD x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(346002)(396003)(136003)(366004)(39860400002)(199004)(189003)(1076003)(66574012)(186003)(107886003)(8676002)(6506007)(86362001)(478600001)(85182001)(5660300002)(81156014)(26005)(15650500001)(4326008)(6486002)(8936002)(316002)(110136005)(54906003)(64756008)(66446008)(66946007)(2616005)(66556008)(66476007)(85202003)(36756003)(6512007)(2906002)(52116002)(6666004)(71200400001)(81166006);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB4477;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: 3Os7X0pLblDRQ2Gk1X7kusWGlptHvRYX19BLcK81hl9yIVQ10C91YQJTZFoFG6Z0A4ziX6sR/4XnjB0SFUj5xI1buQfnTQn/Z6FPl8CksXb2c8Fs3d2YGGLGeNE/fvQUX1QDXCCsTo6p9qNr1Wo1pBWGrxJlq+UMUOf1xGR1qHGSLXRiFhjAYGTHfzUDmdSSGDvuzR6mLtKkGG3pD47Hab6ttQL3AtIm6z+IOZJat4F6TQfJmwK2NdyNmVdwnEGsUnUZ+5SpvPi+AkQ3Ew+nZTuuX6lQs3Zce8IP2KIou0n7Jwr/YgkBYE+95BF/IcDlCIHbLKVYHpzXNFb85n30BoYRo+WL4aWo1D7YlQbxY9zY2aI9iOf3FU8ZzN75edfpDzJwXDLhtbyvaZVKuuKmOyHIVak02arTMWrHcpbztrRgKGtCbLJbjN9H1pefJBmW Content-ID: MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fea9b41-b5f0-4122-8369-08d7830c57de X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2019 16:15:33.4870 (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: bfET/4ZuttNtER363muqfh/5qioEDwADxFVlK9So9w5pud00vL6EaLmTpiUmb8exhipySLK/QnyW5jmXW4qX9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4477 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller Simplify wfx_hw_scan() by splitting out the update of the probe request. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/scan.c | 59 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c index 122da87bbf92..8b184efad0cf 100644 --- a/drivers/staging/wfx/scan.c +++ b/drivers/staging/wfx/scan.c @@ -49,6 +49,27 @@ static int wfx_scan_start(struct wfx_vif *wvif, return 0; } +static int update_probe_tmpl(struct wfx_vif *wvif, + struct cfg80211_scan_request *req) +{ + struct hif_mib_template_frame *tmpl; + struct sk_buff *skb; + + skb = ieee80211_probereq_get(wvif->wdev->hw, wvif->vif->addr, + NULL, 0, req->ie_len); + if (!skb) + return -ENOMEM; + + skb_put_data(skb, req->ie, req->ie_len); + skb_push(skb, 4); + tmpl = (struct hif_mib_template_frame *)skb->data; + tmpl->frame_type = HIF_TMPLT_PRBREQ; + tmpl->frame_length = cpu_to_le16(skb->len - 4); + hif_set_template_frame(wvif, tmpl); + dev_kfree_skb(skb); + return 0; +} + int wfx_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_scan_request *hw_req) @@ -56,9 +77,7 @@ int wfx_hw_scan(struct ieee80211_hw *hw, struct wfx_dev *wdev = hw->priv; struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; struct cfg80211_scan_request *req = &hw_req->req; - struct sk_buff *skb; int i, ret; - struct hif_mib_template_frame *p; if (!wvif) return -EINVAL; @@ -72,29 +91,15 @@ int wfx_hw_scan(struct ieee80211_hw *hw, if (req->n_ssids > HIF_API_MAX_NB_SSIDS) return -EINVAL; - skb = ieee80211_probereq_get(hw, wvif->vif->addr, NULL, 0, req->ie_len); - if (!skb) - return -ENOMEM; - - if (req->ie_len) - memcpy(skb_put(skb, req->ie_len), req->ie, req->ie_len); - mutex_lock(&wdev->conf_mutex); - p = (struct hif_mib_template_frame *)skb_push(skb, 4); - p->frame_type = HIF_TMPLT_PRBREQ; - p->frame_length = cpu_to_le16(skb->len - 4); - ret = hif_set_template_frame(wvif, p); - skb_pull(skb, 4); - - if (!ret) - /* Host want to be the probe responder. */ - ret = wfx_fwd_probe_req(wvif, true); - if (ret) { - mutex_unlock(&wdev->conf_mutex); - dev_kfree_skb(skb); - return ret; - } + ret = update_probe_tmpl(wvif, req); + if (ret) + goto failed; + + ret = wfx_fwd_probe_req(wvif, true); + if (ret) + goto failed; wfx_tx_lock_flush(wdev); @@ -114,13 +119,11 @@ int wfx_hw_scan(struct ieee80211_hw *hw, dst->ssid_length = req->ssids[i].ssid_len; ++wvif->scan.n_ssids; } + schedule_work(&wvif->scan.work); +failed: mutex_unlock(&wdev->conf_mutex); - - if (skb) - dev_kfree_skb(skb); - schedule_work(&wvif->scan.work); - return 0; + return ret; } void wfx_scan_work(struct work_struct *work)