From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: rjarry@redhat.com, cfontain@redhat.com,
Dariusz Sosnowski <dsosnowski@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>,
Matan Azrad <matan@nvidia.com>
Subject: [PATCH v4 09/10] net/mlx5: use bitset for tracking MAC addresses
Date: Thu, 9 Jul 2026 18:02:45 +0200 [thread overview]
Message-ID: <20260709160247.1798575-10-david.marchand@redhat.com> (raw)
In-Reply-To: <20260709160247.1798575-1-david.marchand@redhat.com>
EAL provides bitset that does the same as this set of mlx5 macros.
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
drivers/common/mlx5/mlx5_common.h | 16 ----------------
drivers/net/mlx5/linux/mlx5_os.c | 8 ++++----
drivers/net/mlx5/mlx5.h | 3 ++-
drivers/net/mlx5/mlx5_trigger.c | 2 +-
drivers/net/mlx5/windows/mlx5_os.c | 8 ++++----
5 files changed, 11 insertions(+), 26 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h
index dbc06aff7e..71985794fa 100644
--- a/drivers/common/mlx5/mlx5_common.h
+++ b/drivers/common/mlx5/mlx5_common.h
@@ -30,22 +30,6 @@
#define MLX5_PCI_DRIVER_NAME "mlx5_pci"
#define MLX5_AUXILIARY_DRIVER_NAME "mlx5_auxiliary"
-/* Bit-field manipulation. */
-#define BITFIELD_DECLARE(bf, type, size) \
- type bf[(((size_t)(size) / (sizeof(type) * CHAR_BIT)) + \
- !!((size_t)(size) % (sizeof(type) * CHAR_BIT)))]
-#define BITFIELD_DEFINE(bf, type, size) \
- BITFIELD_DECLARE((bf), type, (size)) = { 0 }
-#define BITFIELD_SET(bf, b) \
- (void)((bf)[((b) / (sizeof((bf)[0]) * CHAR_BIT))] |= \
- ((size_t)1 << ((b) % (sizeof((bf)[0]) * CHAR_BIT))))
-#define BITFIELD_RESET(bf, b) \
- (void)((bf)[((b) / (sizeof((bf)[0]) * CHAR_BIT))] &= \
- ~((size_t)1 << ((b) % (sizeof((bf)[0]) * CHAR_BIT))))
-#define BITFIELD_ISSET(bf, b) \
- !!(((bf)[((b) / (sizeof((bf)[0]) * CHAR_BIT))] & \
- ((size_t)1 << ((b) % (sizeof((bf)[0]) * CHAR_BIT)))))
-
/*
* Helper macros to work around __VA_ARGS__ limitations in a C99 compliant
* manner.
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 5b6e45df2a..1cad6e1091 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -3384,7 +3384,7 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
mlx5_nl_mac_addr_remove(priv->nl_socket_route,
mlx5_ifindex(dev),
&dev->data->mac_addrs[index]);
- BITFIELD_RESET(priv->mac_own, index);
+ rte_bitset_clear(priv->mac_own, index);
}
/**
@@ -3413,7 +3413,7 @@ mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
mlx5_ifindex(dev),
mac);
if (!ret)
- BITFIELD_SET(priv->mac_own, index);
+ rte_bitset_set(priv->mac_own, index);
return ret;
}
@@ -3498,12 +3498,12 @@ mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)
int i;
for (i = MLX5_MAX_MAC_ADDRESSES - 1; i >= 0; --i) {
- if (BITFIELD_ISSET(priv->mac_own, i)) {
+ if (rte_bitset_test(priv->mac_own, i)) {
if (vf)
mlx5_nl_mac_addr_remove(priv->nl_socket_route,
mlx5_ifindex(dev),
&dev->data->mac_addrs[i]);
- BITFIELD_RESET(priv->mac_own, i);
+ rte_bitset_clear(priv->mac_own, i);
}
}
}
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 3ad8bad02f..f7ba8df108 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -14,6 +14,7 @@
#include <rte_pci.h>
#include <rte_ether.h>
+#include <rte_bitset.h>
#include <ethdev_driver.h>
#include <rte_rwlock.h>
#include <rte_interrupts.h>
@@ -2018,7 +2019,7 @@ struct mlx5_priv {
uint32_t dev_port; /* Device port number. */
struct rte_pci_device *pci_dev; /* Backend PCI device. */
struct rte_ether_addr mac[MLX5_MAX_MAC_ADDRESSES]; /* MAC addresses. */
- BITFIELD_DECLARE(mac_own, uint64_t, MLX5_MAX_MAC_ADDRESSES);
+ RTE_BITSET_DECLARE(mac_own, MLX5_MAX_MAC_ADDRESSES);
/* Bit-field of MAC addresses owned by the PMD. */
uint16_t vlan_filter[MLX5_MAX_VLAN_IDS]; /* VLAN filters table. */
unsigned int vlan_filter_n; /* Number of configured VLAN filters. */
diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c
index 25847c8ba2..e41e4643e0 100644
--- a/drivers/net/mlx5/mlx5_trigger.c
+++ b/drivers/net/mlx5/mlx5_trigger.c
@@ -1907,7 +1907,7 @@ mlx5_traffic_enable(struct rte_eth_dev *dev)
/* Add flows for unicast and multicast mac addresses added by API. */
if (!memcmp(mac, &cmp, sizeof(*mac)) ||
- !BITFIELD_ISSET(priv->mac_own, i) ||
+ !rte_bitset_test(priv->mac_own, i) ||
(dev->data->all_multicast && rte_is_multicast_ether_addr(mac)))
continue;
memcpy(&unicast.hdr.dst_addr.addr_bytes,
diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c
index 9acfa8ec84..15de5c22a9 100644
--- a/drivers/net/mlx5/windows/mlx5_os.c
+++ b/drivers/net/mlx5/windows/mlx5_os.c
@@ -699,8 +699,8 @@ mlx5_os_mac_addr_flush(struct rte_eth_dev *dev)
int i;
for (i = MLX5_MAX_MAC_ADDRESSES - 1; i >= 0; --i) {
- if (BITFIELD_ISSET(priv->mac_own, i))
- BITFIELD_RESET(priv->mac_own, i);
+ if (rte_bitset_test(priv->mac_own, i))
+ rte_bitset_clear(priv->mac_own, i);
}
}
@@ -719,7 +719,7 @@ mlx5_os_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
struct mlx5_priv *priv = dev->data->dev_private;
if (index < MLX5_MAX_MAC_ADDRESSES)
- BITFIELD_RESET(priv->mac_own, index);
+ rte_bitset_clear(priv->mac_own, index);
}
/**
@@ -757,7 +757,7 @@ mlx5_os_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac,
return -ENOTSUP;
}
/* Mark this MAC address as owned by the PMD */
- BITFIELD_SET(priv->mac_own, index);
+ rte_bitset_set(priv->mac_own, index);
return 0;
}
--
2.54.0
next prev parent reply other threads:[~2026-07-09 16:04 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 9:18 [PATCH 0/4] Remove limitations coming from legacy VMDq David Marchand
2026-04-03 9:18 ` [PATCH 1/4] ethdev: skip VMDq pools unless configured David Marchand
2026-06-01 9:30 ` Andrew Rybchenko
2026-04-03 9:18 ` [PATCH 2/4] ethdev: announce VMDq capability David Marchand
2026-04-06 22:22 ` Kishore Padmanabha
2026-04-29 14:18 ` David Marchand
2026-05-18 22:12 ` Kishore Padmanabha
2026-06-01 9:32 ` Andrew Rybchenko
2026-04-03 9:18 ` [PATCH 3/4] ethdev: hide VMDq internal sizes David Marchand
2026-06-01 9:34 ` Andrew Rybchenko
2026-04-03 9:18 ` [PATCH 4/4] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-04-05 18:47 ` [PATCH 0/4] Remove limitations coming from legacy VMDq Stephen Hemminger
2026-04-29 14:22 ` David Marchand
2026-05-06 12:35 ` [PATCH v2 0/5] " David Marchand
2026-05-06 12:35 ` [PATCH v2 1/5] ethdev: skip VMDq pools unless configured David Marchand
2026-06-01 9:35 ` Andrew Rybchenko
2026-05-06 12:35 ` [PATCH v2 2/5] ethdev: announce VMDq capability David Marchand
2026-06-01 9:36 ` Andrew Rybchenko
2026-05-06 12:35 ` [PATCH v2 3/5] ethdev: hide VMDq internal sizes David Marchand
2026-05-06 12:35 ` [PATCH v2 4/5] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-05-06 12:35 ` [PATCH v2 5/5] net/iavf: fix duplicate MAC addresses install David Marchand
2026-05-07 2:51 ` [PATCH v2 0/5] Remove limitations coming from legacy VMDq Stephen Hemminger
2026-05-10 15:03 ` David Marchand
2026-05-10 17:03 ` [PATCH v3 " David Marchand
2026-05-10 17:03 ` [PATCH v3 1/5] ethdev: check VMDq availability David Marchand
2026-06-01 9:38 ` Andrew Rybchenko
2026-05-10 17:03 ` [PATCH v3 2/5] ethdev: skip VMDq pools unless configured David Marchand
2026-06-01 9:38 ` Andrew Rybchenko
2026-05-10 17:03 ` [PATCH v3 3/5] ethdev: hide VMDq internal sizes David Marchand
2026-06-01 9:39 ` Andrew Rybchenko
2026-05-10 17:03 ` [PATCH v3 4/5] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-05-12 14:41 ` Stephen Hemminger
2026-05-27 13:25 ` David Marchand
2026-05-10 17:03 ` [PATCH v3 5/5] net/iavf: fix duplicate MAC addresses install David Marchand
2026-07-09 16:02 ` [PATCH v4 00/10] Remove limitations coming from legacy VMDq David Marchand
2026-07-09 16:02 ` [PATCH v4 01/10] ethdev: check VMDq availability David Marchand
2026-07-09 16:02 ` [PATCH v4 02/10] ethdev: skip VMDq pools unless configured David Marchand
2026-07-09 16:02 ` [PATCH v4 03/10] ethdev: hide VMDq internal sizes David Marchand
2026-07-09 16:02 ` [PATCH v4 04/10] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-07-09 16:02 ` [PATCH v4 05/10] net/iavf: fix duplicate MAC addresses install David Marchand
2026-07-13 13:12 ` Loftus, Ciara
2026-07-13 14:10 ` David Marchand
2026-07-14 9:23 ` Loftus, Ciara
2026-07-09 16:02 ` [PATCH v4 06/10] net/mlx5: remove MAC addresses flush helper on Linux David Marchand
2026-07-09 16:02 ` [PATCH v4 07/10] net/mlx5: remove redundant MAC address index checks David Marchand
2026-07-09 16:02 ` [PATCH v4 08/10] net/mlx5: pass maximum number of unicast MAC to common code David Marchand
2026-07-09 16:02 ` David Marchand [this message]
2026-07-09 16:02 ` [PATCH v4 10/10] net/mlx5: accept more unicast MAC addresses David Marchand
2026-07-10 6:44 ` David Marchand
2026-07-10 7:48 ` David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260709160247.1798575-10-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=bingz@nvidia.com \
--cc=cfontain@redhat.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rjarry@redhat.com \
--cc=suanmingm@nvidia.com \
--cc=viacheslavo@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox