From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: rjarry@redhat.com, cfontain@redhat.com,
Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
Nithin Dabilpuram <ndabilpuram@marvell.com>,
Kiran Kumar K <kirankumark@marvell.com>,
Sunil Kumar Kori <skori@marvell.com>,
Satha Rao <skoteshwar@marvell.com>,
Harman Kalra <hkalra@marvell.com>,
Thomas Monjalon <thomas@monjalon.net>
Subject: [PATCH v4 02/10] ethdev: skip VMDq pools unless configured
Date: Thu, 9 Jul 2026 18:02:38 +0200 [thread overview]
Message-ID: <20260709160247.1798575-3-david.marchand@redhat.com> (raw)
In-Reply-To: <20260709160247.1798575-1-david.marchand@redhat.com>
The mac_addr_add API describes that only the 0 pool should be passed
unless VMDq has been enabled, though there was no validation so far.
Add such a check, then cleanup the MAC related operations (adding,
removing, restoring).
As a side effect, the net/cnxk does not need to manually reset the
mac_pool_sel[] array.
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
Changes since v3:
- updated doxygen comments,
Changes since v2:
- added an entry in release notes,
- fixed duplicate mac address handling for !vmdq,
- rewrote update of eth_dev_mac_restore to isolate the !vmdq case,
---
doc/guides/rel_notes/release_26_07.rst | 2 +
drivers/net/cnxk/cnxk_ethdev_ops.c | 1 -
lib/ethdev/rte_ethdev.c | 52 ++++++++++++++++++--------
lib/ethdev/rte_ethdev.h | 2 +-
4 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/doc/guides/rel_notes/release_26_07.rst b/doc/guides/rel_notes/release_26_07.rst
index 5e9178d36b..8e4e02e587 100644
--- a/doc/guides/rel_notes/release_26_07.rst
+++ b/doc/guides/rel_notes/release_26_07.rst
@@ -319,6 +319,8 @@ API Changes
* At port configuration time, the number of VMDq pools advertised by a driver is now used to
validate VMDq related Rx and Tx modes (``RTE_ETH_MQ_RX_VMDQ_FLAG``, ``RTE_ETH_MQ_TX_VMDQ_DCB``,
``RTE_ETH_MQ_TX_VMDQ_ONLY``).
+ * A check was added in ``rte_eth_dev_mac_addr_add`` to validate that the ``pool`` parameter is 0
+ when VMDq is not configured.
* **mlx5: promoted driver event and steering management APIs from experimental to stable.**
diff --git a/drivers/net/cnxk/cnxk_ethdev_ops.c b/drivers/net/cnxk/cnxk_ethdev_ops.c
index 0ea3d7e89f..c002a93fe1 100644
--- a/drivers/net/cnxk/cnxk_ethdev_ops.c
+++ b/drivers/net/cnxk/cnxk_ethdev_ops.c
@@ -1240,7 +1240,6 @@ cnxk_nix_mc_addr_list_configure(struct rte_eth_dev *eth_dev, struct rte_ether_ad
/* Update address in NIC data structure */
rte_ether_addr_copy(&mc_addr_set[i], &data->mac_addrs[j]);
rte_ether_addr_copy(&mc_addr_set[i], &dev->dmac_addrs[j]);
- data->mac_pool_sel[j] = RTE_BIT64(0);
}
roc_nix_npc_promisc_ena_dis(nix, true);
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index 9e305d98c1..f20cc514a3 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1677,7 +1677,7 @@ eth_dev_mac_restore(struct rte_eth_dev *dev,
{
struct rte_ether_addr *addr;
uint16_t i;
- uint32_t pool = 0;
+ uint32_t pool;
uint64_t pool_mask;
/* replay MAC address configuration including default MAC */
@@ -1685,9 +1685,11 @@ eth_dev_mac_restore(struct rte_eth_dev *dev,
if (dev->dev_ops->mac_addr_set != NULL)
dev->dev_ops->mac_addr_set(dev, addr);
else if (dev->dev_ops->mac_addr_add != NULL)
- dev->dev_ops->mac_addr_add(dev, addr, 0, pool);
+ dev->dev_ops->mac_addr_add(dev, addr, 0, 0);
if (dev->dev_ops->mac_addr_add != NULL) {
+ bool vmdq = (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_VMDQ_FLAG) != 0;
+
for (i = 1; i < dev_info->max_mac_addrs; i++) {
addr = &dev->data->mac_addrs[i];
@@ -1695,15 +1697,19 @@ eth_dev_mac_restore(struct rte_eth_dev *dev,
if (rte_is_zero_ether_addr(addr))
continue;
- pool = 0;
- pool_mask = dev->data->mac_pool_sel[i];
-
- do {
- if (pool_mask & UINT64_C(1))
- dev->dev_ops->mac_addr_add(dev, addr, i, pool);
- pool_mask >>= 1;
- pool++;
- } while (pool_mask);
+ if (!vmdq) {
+ dev->dev_ops->mac_addr_add(dev, addr, i, 0);
+ } else {
+ pool = 0;
+ pool_mask = dev->data->mac_pool_sel[i];
+
+ do {
+ if (pool_mask & UINT64_C(1))
+ dev->dev_ops->mac_addr_add(dev, addr, i, pool);
+ pool_mask >>= 1;
+ pool++;
+ } while (pool_mask);
+ }
}
}
}
@@ -5414,8 +5420,9 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *addr,
uint32_t pool)
{
struct rte_eth_dev *dev;
- int index;
uint64_t pool_mask;
+ bool vmdq;
+ int index;
int ret;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
@@ -5440,6 +5447,12 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *addr,
RTE_ETHDEV_LOG_LINE(ERR, "Pool ID must be 0-%d", RTE_ETH_64_POOLS - 1);
return -EINVAL;
}
+ vmdq = (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_VMDQ_FLAG) != 0;
+ if (!vmdq && pool != 0) {
+ RTE_ETHDEV_LOG_LINE(ERR, "Port %u: VMDq is not configured (pool %d)",
+ port_id, pool);
+ return -EINVAL;
+ }
index = eth_dev_get_mac_addr_index(port_id, addr);
if (index < 0) {
@@ -5450,6 +5463,9 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *addr,
return -ENOSPC;
}
} else {
+ if (!vmdq)
+ return 0;
+
pool_mask = dev->data->mac_pool_sel[index];
/* Check if both MAC address and pool is already there, and do nothing */
@@ -5464,8 +5480,10 @@ rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *addr,
/* Update address in NIC data structure */
rte_ether_addr_copy(addr, &dev->data->mac_addrs[index]);
- /* Update pool bitmap in NIC data structure */
- dev->data->mac_pool_sel[index] |= RTE_BIT64(pool);
+ if (vmdq) {
+ /* Update pool bitmap in NIC data structure */
+ dev->data->mac_pool_sel[index] |= RTE_BIT64(pool);
+ }
}
ret = eth_err(port_id, ret);
@@ -5510,8 +5528,10 @@ rte_eth_dev_mac_addr_remove(uint16_t port_id, struct rte_ether_addr *addr)
/* Update address in NIC data structure */
rte_ether_addr_copy(&null_mac_addr, &dev->data->mac_addrs[index]);
- /* reset pool bitmap */
- dev->data->mac_pool_sel[index] = 0;
+ if ((dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_VMDQ_FLAG) != 0) {
+ /* reset pool bitmap */
+ dev->data->mac_pool_sel[index] = 0;
+ }
rte_ethdev_trace_mac_addr_remove(port_id, addr);
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index ee400b386f..e2a5ba1549 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -4636,7 +4636,7 @@ int rte_eth_dev_priority_flow_ctrl_set(uint16_t port_id,
* - (-ENODEV) if *port* is invalid.
* - (-EIO) if device is removed.
* - (-ENOSPC) if no more MAC addresses can be added.
- * - (-EINVAL) if MAC address is invalid.
+ * - (-EINVAL) if MAC address is invalid or a non 0 pool was passed but VMDq is not enabled.
*/
int rte_eth_dev_mac_addr_add(uint16_t port_id, struct rte_ether_addr *mac_addr,
uint32_t pool);
--
2.54.0
next prev parent reply other threads:[~2026-07-09 16:03 UTC|newest]
Thread overview: 62+ 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 ` David Marchand [this message]
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 ` [PATCH v4 09/10] net/mlx5: use bitset for tracking MAC addresses David Marchand
2026-07-09 16:02 ` [PATCH v4 10/10] net/mlx5: accept more unicast " David Marchand
2026-07-10 6:44 ` David Marchand
2026-07-10 7:48 ` David Marchand
2026-07-23 12:41 ` [PATCH v5 00/10] Remove limitations coming from legacy VMDq David Marchand
2026-07-23 12:41 ` [PATCH v5 01/10] ethdev: check VMDq availability David Marchand
2026-07-23 12:41 ` [PATCH v5 02/10] ethdev: skip VMDq pools unless configured David Marchand
2026-07-23 12:41 ` [PATCH v5 03/10] ethdev: hide VMDq internal sizes David Marchand
2026-07-23 12:41 ` [PATCH v5 04/10] net/iavf: accept up to 32k unicast MAC addresses David Marchand
2026-07-23 12:41 ` [PATCH v5 05/10] net/iavf: fix duplicate MAC addresses install David Marchand
2026-07-23 12:41 ` [PATCH v5 06/10] net/mlx5: remove MAC addresses flush helper on Linux David Marchand
2026-07-23 12:41 ` [PATCH v5 07/10] net/mlx5: remove redundant MAC address index checks David Marchand
2026-07-23 12:41 ` [PATCH v5 08/10] net/mlx5: pass maximum number of unicast MAC to common code David Marchand
2026-07-23 17:35 ` Stephen Hemminger
2026-07-23 12:41 ` [PATCH v5 09/10] net/mlx5: use bitset for tracking MAC addresses David Marchand
2026-07-23 12:41 ` [PATCH v5 10/10] net/mlx5: accept more unicast " 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-3-david.marchand@redhat.com \
--to=david.marchand@redhat.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=cfontain@redhat.com \
--cc=dev@dpdk.org \
--cc=hkalra@marvell.com \
--cc=kirankumark@marvell.com \
--cc=ndabilpuram@marvell.com \
--cc=rjarry@redhat.com \
--cc=skori@marvell.com \
--cc=skoteshwar@marvell.com \
--cc=thomas@monjalon.net \
/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