From patchwork Wed Jan 15 12:12:19 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: 11333897 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 2F336138D for ; Wed, 15 Jan 2020 12:12:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E573D24679 for ; Wed, 15 Jan 2020 12:12:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="HPnl98zI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730612AbgAOMMg (ORCPT ); Wed, 15 Jan 2020 07:12:36 -0500 Received: from mail-co1nam11on2084.outbound.protection.outlook.com ([40.107.220.84]:24056 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730218AbgAOMMf (ORCPT ); Wed, 15 Jan 2020 07:12:35 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TDb7t2/chHtMSNwo7HMctUnWKXCbIqyS4hBR+EjI7lVBznUmtbPFKkvPEcVqwBcpkIXwKYAfdX2TqSKJQc8RRqM1iAoZWyEcy8naVPXzmhFAt6UKlVF1H2D3OnecD0/auUMkmw5ySwh5d6pcgcvJzHTlXbZUsvMYIeQbdGb+LaN1TuKvhL39Oe1ekpb0PKPCtDpSkgtN8j0UkEtN8huGMe+ihmqdXRnzuVXBYB59lBO0DG2FftO9VM+qAN3PZUXNsqQ0bXLq61lJFv0RgPuWcRrwR/SthVAZSZq0QJ3aVToNI11HKc7YzihNvsirPiLAdgDGBN32v+AfAAXiuMkpJA== 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=1xbX4O+7DVFKMuBoAyyVIDQfYyePPJ696cihc2JM5rQ=; b=H4OgCiYbIV8ssY0mbwgvRNlUWXooz+btXC9TPSn7AYg8omiNpLBWtnFeTjgg7dhGrnx8812OV7lDbnaZ4nhqSFUQQxRPquB93JzFH1AbRO3VONaqLtXocvBcSYMhAvrY26yfRqyLALmHjj9U7gLTYS2kAvJHbQzgF+K8S2vXEMkYhrNsiF8fRrdBeK5VCZpqX2OlZdcXua3cbL1xh/dJYYlAnnhZScANU0HyS9TbxcNR34YdN8lGDg9hJf6q9lxv4XamBBBSMreBbgLjXUEO1cBqpSGvSTmr9017FqxOKXi3kacUqbOaOeTLdf04nmAiTB07pcy71EVLhv1+X9zQjg== 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=1xbX4O+7DVFKMuBoAyyVIDQfYyePPJ696cihc2JM5rQ=; b=HPnl98zI9D3+4ajNmxlUQ5qPpW/CZbNBkuLyHT6rf8vsd7sMVMrVhdwTq7NijAhZldM2Y71Japn9Fc8atLbiVKtpjV9H7vm1mzhMJZV7ml7kFgFIkMizdRwFOlw6cd7+/ecKy2T/ZM3yll5gTPMrTVjrwVvrXXRsZYA9OjGU7x0= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB3934.namprd11.prod.outlook.com (10.255.180.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20; Wed, 15 Jan 2020 12:12:19 +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:19 +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:18 +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 08/65] staging: wfx: simplify hif_set_arp_ipv4_filter() usage Thread-Topic: [PATCH 08/65] staging: wfx: simplify hif_set_arp_ipv4_filter() usage Thread-Index: AQHVy50Im5dbQg2Lpke2wSUOQkIzGw== Date: Wed, 15 Jan 2020 12:12:19 +0000 Message-ID: <20200115121041.10863-9-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: 76e85dbf-9094-4dc8-e8a9-08d799b42afc x-ms-traffictypediagnostic: MN2PR11MB3934: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2887; x-forefront-prvs: 02830F0362 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39850400004)(396003)(136003)(376002)(366004)(346002)(199004)(189003)(54906003)(110136005)(86362001)(956004)(107886003)(2616005)(316002)(36756003)(71200400001)(52116002)(7696005)(478600001)(8936002)(81156014)(8676002)(4326008)(81166006)(6486002)(2906002)(26005)(66946007)(16526019)(186003)(5660300002)(66574012)(1076003)(66556008)(64756008)(66446008)(85182001)(66476007)(85202003);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB3934;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: IAo2YqZ3fTzQUGOIq/OTHNXGlZCfy2ZlmN/OeSJCfK5bdCN1VAn6OV/pUu6ki/segQ+ID6xo9aB+33y6CX8Dgjw5xHn2qypGt5FWUG3oCAiwPFdzRLHsnKihl1dZmg2plUy+KxKn+hOcRrk1kh+5p/HBPP4kuKZ2QwYkh9KiFK/1MNhFN8dtD15atd3gQQU0VEYOSY3R41PKdnvP6XhJWI/cJW6D1/CWMHjVhP9JKY70HRrEDpuDA5tSKtO+s6Ms3hesxByNL27U2Es7Lc9Ag9c3HOHCHSPupy08HkYROpS4kZFLktHRoQTo5yUHOM4/7kDTcqEZeStq9asqKpHnETbw3xqDkDcLs2oGi1Tg1SksYAMDtm0+B4TNeaXi7Hn2zdur1C2WBC3m9QtZbQq4iWHMuH89M9SFdTUZ81+ok1YwEptK8xBHoB6lvkb+eUGM Content-ID: <521C4DC7DEED7941AC74B1AA443CFAEA@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76e85dbf-9094-4dc8-e8a9-08d799b42afc X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2020 12:12:19.2384 (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: hIyWPtxxfEeTQLJ05lV7wfL/4wmHhwTUK2hf81vt3Q4QFqmOrwjRPGmHRNPqflbFVfMTvyZ5T+OpIgCqPnK+Xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3934 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_mib_arp_ip_addr_table come from hardware API. It is not intended to be manipulated in upper layers of the driver. In add, current code for hif_set_arp_ipv4_filter() is too dumb. It should pack data using the hardware representation instead of leaving all work to the caller. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_tx_mib.h | 16 +++++++++++++--- drivers/staging/wfx/sta.c | 25 +++++++------------------ 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index a8082508fbfd..a325c870b4ea 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -260,12 +260,22 @@ static inline int hif_keep_alive_period(struct wfx_vif *wvif, int period) &arg, sizeof(arg)); }; -static inline int hif_set_arp_ipv4_filter(struct wfx_vif *wvif, - struct hif_mib_arp_ip_addr_table *fp) +static inline int hif_set_arp_ipv4_filter(struct wfx_vif *wvif, int idx, + __be32 *addr) { + struct hif_mib_arp_ip_addr_table arg = { + .condition_idx = idx, + .arp_enable = HIF_ARP_NS_FILTERING_DISABLE, + }; + + if (addr) { + // Caution: type of addr is __be32 + memcpy(arg.ipv4_address, addr, sizeof(arg.ipv4_address)); + arg.arp_enable = HIF_ARP_NS_FILTERING_ENABLE; + } return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_ARP_IP_ADDRESSES_TABLE, - fp, sizeof(*fp)); + &arg, sizeof(arg)); } static inline int hif_use_multi_tx_conf(struct wfx_dev *wdev, diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 339acbce96fb..8c55089b1ea4 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -915,30 +915,19 @@ void wfx_bss_info_changed(struct ieee80211_hw *hw, struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv; bool do_join = false; int i; - int nb_arp_addr; mutex_lock(&wdev->conf_mutex); /* TODO: BSS_CHANGED_QOS */ if (changed & BSS_CHANGED_ARP_FILTER) { - struct hif_mib_arp_ip_addr_table filter = { }; - - nb_arp_addr = info->arp_addr_cnt; - if (nb_arp_addr <= 0 || nb_arp_addr > HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES) - nb_arp_addr = 0; - for (i = 0; i < HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES; i++) { - filter.condition_idx = i; - if (i < nb_arp_addr) { - // Caution: type of arp_addr_list[i] is __be32 - memcpy(filter.ipv4_address, - &info->arp_addr_list[i], - sizeof(filter.ipv4_address)); - filter.arp_enable = HIF_ARP_NS_FILTERING_ENABLE; - } else { - filter.arp_enable = HIF_ARP_NS_FILTERING_DISABLE; - } - hif_set_arp_ipv4_filter(wvif, &filter); + __be32 *arp_addr = &info->arp_addr_list[i]; + + if (info->arp_addr_cnt > HIF_MAX_ARP_IP_ADDRTABLE_ENTRIES) + arp_addr = NULL; + if (i >= info->arp_addr_cnt) + arp_addr = NULL; + hif_set_arp_ipv4_filter(wvif, i, arp_addr); } }