lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 15 Jan 2020 13:54:49 +0000
From:   Jérôme Pouiller <Jerome.Pouiller@...abs.com>
To:     "devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
        "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Kalle Valo <kvalo@...eaurora.org>,
        "David S . Miller" <davem@...emloft.net>,
        Jérôme Pouiller <Jerome.Pouiller@...abs.com>
Subject: [PATCH v2 32/65] staging: wfx: simplify
 hif_mib_uc_mc_bc_data_frame_condition

From: Jérôme Pouiller <jerome.pouiller@...abs.com>

The current API defines bitfields. It is not very convenient. Prefer to
use bitmasks.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@...abs.com>
---
 drivers/staging/wfx/hif_api_mib.h | 14 ++++----------
 drivers/staging/wfx/hif_tx_mib.h  |  9 +++------
 drivers/staging/wfx/sta.c         |  4 ++--
 3 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/wfx/hif_api_mib.h b/drivers/staging/wfx/hif_api_mib.h
index 1603b3074bf7..e0ef0337e01c 100644
--- a/drivers/staging/wfx/hif_api_mib.h
+++ b/drivers/staging/wfx/hif_api_mib.h
@@ -181,19 +181,13 @@ struct hif_mib_ipv6_addr_data_frame_condition {
 	u8    i_pv6_address[HIF_API_IPV6_ADDRESS_SIZE];
 } __packed;
 
-union hif_addr_type {
-	u8 value;
-	struct {
-		u8    type_unicast:1;
-		u8    type_multicast:1;
-		u8    type_broadcast:1;
-		u8    reserved:5;
-	} bits;
-};
+#define HIF_FILTER_UNICAST   0x1
+#define HIF_FILTER_MULTICAST 0x2
+#define HIF_FILTER_BROADCAST 0x4
 
 struct hif_mib_uc_mc_bc_data_frame_condition {
 	u8    condition_idx;
-	union hif_addr_type param;
+	u8    allowed_frames;
 	u8    reserved[2];
 } __packed;
 
diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h
index 4d171e6cfc9a..6e8b050cbc25 100644
--- a/drivers/staging/wfx/hif_tx_mib.h
+++ b/drivers/staging/wfx/hif_tx_mib.h
@@ -246,15 +246,12 @@ static inline int hif_set_mac_addr_condition(struct wfx_vif *wvif,
 			     arg, sizeof(*arg));
 }
 
-// FIXME: use a bitfield instead of 3 boolean values
-static inline int hif_set_uc_mc_bc_condition(struct wfx_vif *wvif, int idx,
-					     bool unic, bool multic, bool broadc)
+static inline int hif_set_uc_mc_bc_condition(struct wfx_vif *wvif,
+					     int idx, u8 allowed_frames)
 {
 	struct hif_mib_uc_mc_bc_data_frame_condition val = {
 		.condition_idx = idx,
-		.param.bits.type_unicast = unic,
-		.param.bits.type_multicast = multic,
-		.param.bits.type_broadcast = broadc,
+		.allowed_frames = allowed_frames,
 	};
 
 	return hif_write_mib(wvif->wdev, wvif->id,
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 79285927c7bf..1c1b5a6c2474 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -142,8 +142,8 @@ static int wfx_set_mcast_filter(struct wfx_vif *wvif,
 		config.mac_cond |= 1 << i;
 	}
 
-	// Accept unicast and broadcast
-	ret = hif_set_uc_mc_bc_condition(wvif, 0, true, false, true);
+	ret = hif_set_uc_mc_bc_condition(wvif, 0, HIF_FILTER_UNICAST |
+						  HIF_FILTER_BROADCAST);
 	if (ret)
 		return ret;
 
-- 
2.25.0

Powered by blists - more mailing lists