* [PATCH 1/2] hash: fix maybe-uninitialized warning on minsize build
@ 2026-11-23 6:13 Cheryl Bansal
2026-11-23 6:13 ` [PATCH 2/2] bus/pci: add selective BAR mapping support Cheryl Bansal
0 siblings, 1 reply; 4+ messages in thread
From: Cheryl Bansal @ 2026-11-23 6:13 UTC (permalink / raw)
To: Yipeng Wang, Sameh Gobriel, Bruce Richardson, Vladimir Medvedkin,
Chenbo Xia, Nipun Gupta
Cc: dev, stable, Cheryl Bansal
With --buildtype=minsize and -Werror, gcc reports that slot_id may be
used uninitialized in alloc_slot(). This is a false positive: every
path either returns EMPTY_SLOT or assigns slot_id before use.
Initialize slot_id to EMPTY_SLOT to silence the warning.
Fixes: 5915699153d7 ("hash: fix scaling by reducing contention")
Cc: stable@dpdk.org
Signed-off-by: Cheryl Bansal <cheryl.bansal@altera.com>
---
.mailmap | 1 +
lib/hash/rte_cuckoo_hash.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/.mailmap b/.mailmap
index a0096fb97a..5146a4fa2b 100644
--- a/.mailmap
+++ b/.mailmap
@@ -288,6 +288,7 @@ Chenna Arnoori <chenna.arnoori@broadcom.com>
Chenxingyu Wang <wangchenxingyu@huawei.com>
Chenxu Di <chenxux.di@intel.com>
Chenyu Huang <chenyux.huang@intel.com>
+Cheryl Bansal <cheryl.bansal@altera.com>
Cheryl Houser <chouser@vmware.com>
Chinh Cao <chinh.t.cao@intel.com>
Chintu Hetam <rometoroam@gmail.com>
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 5d495ae973..47ea909d38 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1298,7 +1298,7 @@ static inline uint32_t
alloc_slot(const struct rte_hash *h, struct lcore_cache *cached_free_slots)
{
unsigned int n_slots;
- uint32_t slot_id;
+ uint32_t slot_id = EMPTY_SLOT;
if (h->use_local_cache) {
/* Try to get a free slot from the local cache */
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] bus/pci: add selective BAR mapping support
2026-11-23 6:13 [PATCH 1/2] hash: fix maybe-uninitialized warning on minsize build Cheryl Bansal
@ 2026-11-23 6:13 ` Cheryl Bansal
2026-11-23 7:57 ` David Marchand
0 siblings, 1 reply; 4+ messages in thread
From: Cheryl Bansal @ 2026-11-23 6:13 UTC (permalink / raw)
To: Yipeng Wang, Sameh Gobriel, Bruce Richardson, Vladimir Medvedkin,
Chenbo Xia, Nipun Gupta
Cc: dev, stable, Cheryl Bansal
Drivers that only need a subset of PCI BARs still pay the cost of
mapping every valid BAR. There is no bus-level way to select which
BARs are mapped without changing each PMD.
Add the bar_mask PCI bus argument to select which BARs to map. If it
is omitted, all valid BARs are mapped. A zero mask, a value outside
BAR0-BAR5, or a malformed value is rejected. The argument is parsed
from bus_str so it is not passed to PMDs. UIO and VFIO map slots are
indexed by BAR number so primary and secondary processes stay
consistent when some BARs are skipped.
Example: -a bus=pci,addr=0000:01:00.0,bar_mask=0x05
Signed-off-by: Cheryl Bansal <cheryl.bansal@altera.com>
---
doc/guides/prog_guide/devargs.rst | 13 +++++++
doc/guides/rel_notes/release_26_11.rst | 6 +++
drivers/bus/pci/linux/pci_vfio.c | 7 ++++
drivers/bus/pci/pci_common.c | 46 +++++++++++++++++++++++
drivers/bus/pci/pci_common_uio.c | 52 ++++++++++++++------------
drivers/bus/pci/pci_params.c | 2 +
drivers/bus/pci/private.h | 16 ++++++++
7 files changed, 118 insertions(+), 24 deletions(-)
diff --git a/doc/guides/prog_guide/devargs.rst b/doc/guides/prog_guide/devargs.rst
index c8a7224aa0..dc30f3a487 100644
--- a/doc/guides/prog_guide/devargs.rst
+++ b/doc/guides/prog_guide/devargs.rst
@@ -82,6 +82,19 @@ The above example will pass ``representor=[0-3]`` devarg
only to device corresponding to PCI address ``0000:02:00.0``,
and only if it is managed by ``ice`` driver.
+PCI bus arguments include:
+
+* ``addr``: PCI address of the device (BDF).
+* ``bar_mask``: bitmask of BARs to map (bits 0-5 for BAR0-BAR5).
+ If omitted, all valid BARs are mapped.
+ A zero mask, a value outside BAR0-BAR5, or a malformed value is rejected.
+
+.. code-block:: none
+
+ bus=pci,addr=0000:01:00.0,bar_mask=0x05
+
+The above example maps BAR0 and BAR2 only for the given PCI device.
+
Simplified syntax
~~~~~~~~~~~~~~~~~
diff --git a/doc/guides/rel_notes/release_26_11.rst b/doc/guides/rel_notes/release_26_11.rst
index 10ab2355ae..90dc79ee16 100644
--- a/doc/guides/rel_notes/release_26_11.rst
+++ b/doc/guides/rel_notes/release_26_11.rst
@@ -58,6 +58,12 @@ New Features
the kernel driver is the generic ``vfio-platform``,
which carries no device identity in its name.
+* **Added selective PCI BAR mapping.**
+
+ Added the PCI bus argument ``bar_mask`` to select which BARs to map.
+ If omitted, all valid BARs are mapped.
+ Example: ``-a bus=pci,addr=0000:01:00.0,bar_mask=0x05``.
+
* **Added 1.6T link speed to ethdev.**
Added the 1.6 Tb/s Ethernet link speed,
diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index 4363d7ff2c..1046d84c36 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -738,6 +738,7 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)
struct mapped_pci_resource *vfio_res = NULL;
struct mapped_pci_res_list *vfio_res_list =
RTE_TAILQ_CAST(dev_vfio_tailq.head, mapped_pci_res_list);
+ uint8_t bar_mask = pci_get_bar_mask(dev);
struct pci_map *maps;
@@ -814,6 +815,9 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)
struct vfio_info_cap_header *hdr;
struct vfio_region_info_cap_sparse_mmap *sparse;
+ if ((bar_mask & (1 << i)) == 0)
+ continue;
+
ret = pci_vfio_get_region_info(vfio_dev_fd, ®, i);
if (ret < 0) {
PCI_LOG(ERR, "%s cannot get device region info error %i (%s)",
@@ -1018,6 +1022,9 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)
int
pci_vfio_map_resource(struct rte_pci_device *dev)
{
+ if (RTE_PCI_DEVICE_INTERNAL(dev)->bar_mask_err != 0)
+ return -EINVAL;
+
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
return pci_vfio_map_resource_primary(dev);
else
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 3770b4ad75..f36e66a48d 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -3,6 +3,7 @@
* Copyright 2013-2014 6WIND S.A.
*/
+#include <errno.h>
#include <string.h>
#include <inttypes.h>
#include <stdint.h>
@@ -25,6 +26,7 @@
#include <rte_string_fns.h>
#include <rte_common.h>
#include <rte_devargs.h>
+#include <rte_kvargs.h>
#include <rte_tailq.h>
#include "private.h"
@@ -78,15 +80,59 @@ pci_asprintf(char **buffer, const char *format, ...)
}
#endif /* RTE_EXEC_ENV_WINDOWS */
+/* Parse bar_mask from bus_str. Absent => 0 (map all). Invalid => -EINVAL. */
+static int
+pci_parse_bar_mask(const struct rte_devargs *devargs, uint8_t *mask)
+{
+ struct rte_kvargs *kvargs;
+ const char *bar_mask_str;
+ unsigned long val;
+ char *endptr;
+
+ *mask = 0;
+ if (devargs == NULL || devargs->bus_str == NULL)
+ return 0;
+
+ kvargs = rte_kvargs_parse(devargs->bus_str, NULL);
+ if (kvargs == NULL) {
+ PCI_LOG(ERR, "cannot parse bus arguments: %s",
+ devargs->bus_str);
+ return -EINVAL;
+ }
+
+ bar_mask_str = rte_kvargs_get(kvargs, PCI_BAR_MASK_ARG);
+ if (bar_mask_str == NULL) {
+ rte_kvargs_free(kvargs);
+ return 0;
+ }
+
+ errno = 0;
+ val = strtoul(bar_mask_str, &endptr, 0);
+ if (errno != 0 || endptr == bar_mask_str || *endptr != '\0' ||
+ val == 0 || val > PCI_BAR_MASK_ALL) {
+ PCI_LOG(ERR, "Invalid bar_mask value '%s'", bar_mask_str);
+ rte_kvargs_free(kvargs);
+ return -EINVAL;
+ }
+
+ *mask = (uint8_t)val;
+ rte_kvargs_free(kvargs);
+ return 0;
+}
+
void
pci_common_set(struct rte_pci_device *dev)
{
+ struct rte_pci_device_internal *pdev = RTE_PCI_DEVICE_INTERNAL(dev);
+
/* Each device has its internal, canonical name set. */
rte_pci_device_name(&dev->addr,
dev->name, sizeof(dev->name));
dev->device.name = dev->name;
dev->device.devargs = rte_bus_find_devargs(&rte_pci_bus, dev->name);
+ pdev->bar_mask_err = pci_parse_bar_mask(dev->device.devargs,
+ &pdev->bar_mask);
if (dev->bus_info != NULL ||
asprintf(&dev->bus_info, "vendor_id=%"PRIx16", device_id=%"PRIx16,
diff --git a/drivers/bus/pci/pci_common_uio.c b/drivers/bus/pci/pci_common_uio.c
index 52a10f806a..19d8df5d1d 100644
--- a/drivers/bus/pci/pci_common_uio.c
+++ b/drivers/bus/pci/pci_common_uio.c
@@ -27,7 +27,7 @@ EAL_REGISTER_TAILQ(rte_uio_tailq)
static int
pci_uio_map_secondary(struct rte_pci_device *dev)
{
- int fd, i = 0, j, res_idx;
+ int fd, i, j;
struct mapped_pci_resource *uio_res;
struct mapped_pci_res_list *uio_res_list =
RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
@@ -38,15 +38,11 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
if (rte_pci_addr_cmp(&uio_res->pci_addr, &dev->addr))
continue;
- /* Map all BARs */
- for (res_idx = 0; res_idx != PCI_MAX_RESOURCE; res_idx++) {
- /* skip empty BAR */
- if (dev->mem_resource[res_idx].phys_addr == 0)
+ /* Replay primary mappings (indexed by BAR) */
+ for (i = 0; i != PCI_MAX_RESOURCE; i++) {
+ if (uio_res->maps[i].size == 0)
continue;
- if (i >= uio_res->nb_maps)
- return -1;
-
/*
* open devname, to mmap it
*/
@@ -80,9 +76,7 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
}
return -1;
}
- dev->mem_resource[res_idx].addr = mapaddr;
-
- i++;
+ dev->mem_resource[i].addr = mapaddr;
}
return 0;
}
@@ -95,11 +89,15 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
int
pci_uio_map_resource(struct rte_pci_device *dev)
{
- int i, map_idx = 0, ret;
+ int i, ret;
uint64_t phaddr;
struct mapped_pci_resource *uio_res = NULL;
struct mapped_pci_res_list *uio_res_list =
RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
+ uint8_t bar_mask = pci_get_bar_mask(dev);
+
+ if (RTE_PCI_DEVICE_INTERNAL(dev)->bar_mask_err != 0)
+ return -EINVAL;
/* allocate uio resource */
ret = pci_uio_alloc_resource(dev, &uio_res);
@@ -110,31 +108,34 @@ pci_uio_map_resource(struct rte_pci_device *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return pci_uio_map_secondary(dev);
- /* Map all BARs */
+ /* Index maps[] by BAR number */
for (i = 0; i != PCI_MAX_RESOURCE; i++) {
+ if ((bar_mask & (1 << i)) == 0)
+ continue;
+
/* skip empty BAR */
phaddr = dev->mem_resource[i].phys_addr;
if (phaddr == 0)
continue;
ret = pci_uio_map_resource_by_index(dev, i,
- uio_res, map_idx);
+ uio_res, i);
if (ret)
goto error;
-
- map_idx++;
}
- uio_res->nb_maps = map_idx;
+ uio_res->nb_maps = PCI_MAX_RESOURCE;
TAILQ_INSERT_TAIL(uio_res_list, uio_res, next);
return 0;
error:
- for (i = 0; i < map_idx; i++) {
- pci_unmap_resource(uio_res->maps[i].addr,
- (size_t)uio_res->maps[i].size);
- rte_free(uio_res->maps[i].path);
+ for (i = 0; i < PCI_MAX_RESOURCE; i++) {
+ if (uio_res->maps[i].addr != NULL) {
+ pci_unmap_resource(uio_res->maps[i].addr,
+ (size_t)uio_res->maps[i].size);
+ rte_free(uio_res->maps[i].path);
+ }
}
pci_uio_free_resource(dev, uio_res);
return -1;
@@ -149,6 +150,8 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)
return;
for (i = 0; i != uio_res->nb_maps; i++) {
+ if (uio_res->maps[i].addr == NULL)
+ continue;
pci_unmap_resource(uio_res->maps[i].addr,
(size_t)uio_res->maps[i].size);
if (rte_eal_process_type() == RTE_PROC_PRIMARY)
@@ -166,10 +169,11 @@ pci_uio_remap_resource(struct rte_pci_device *dev)
if (dev == NULL)
return -1;
- /* Remap all BARs */
+ /* Remap mapped BARs only */
for (i = 0; i != PCI_MAX_RESOURCE; i++) {
- /* skip empty BAR */
- if (dev->mem_resource[i].phys_addr == 0)
+ /* skip empty or unmapped BAR */
+ if (dev->mem_resource[i].phys_addr == 0 ||
+ dev->mem_resource[i].addr == NULL)
continue;
map_address = mmap(dev->mem_resource[i].addr,
(size_t)dev->mem_resource[i].len,
diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c
index 6cbd98b4c8..4fe148b0a1 100644
--- a/drivers/bus/pci/pci_params.c
+++ b/drivers/bus/pci/pci_params.c
@@ -17,11 +17,13 @@
enum pci_params {
RTE_PCI_PARAM_ADDR,
+ RTE_PCI_PARAM_BAR_MASK,
RTE_PCI_PARAM_MAX,
};
static const char * const pci_params_keys[] = {
[RTE_PCI_PARAM_ADDR] = "addr",
+ [RTE_PCI_PARAM_BAR_MASK] = PCI_BAR_MASK_ARG,
[RTE_PCI_PARAM_MAX] = NULL,
};
diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h
index f266a1b04d..0806822602 100644
--- a/drivers/bus/pci/private.h
+++ b/drivers/bus/pci/private.h
@@ -43,8 +43,24 @@ struct rte_pci_device_internal {
struct rte_pci_device device;
/* PCI regions provided by e.g. VFIO. */
struct rte_pci_region region[RTE_MAX_PCI_REGIONS];
+ int bar_mask_err; /* nonzero if bar_mask was present but invalid */
+ uint8_t bar_mask; /* 0 = map all BARs */
};
+#define PCI_BAR_MASK_ARG "bar_mask"
+#define PCI_BAR_MASK_ALL ((1U << PCI_MAX_RESOURCE) - 1)
+
+static inline uint8_t
+pci_get_bar_mask(struct rte_pci_device *dev)
+{
+ struct rte_pci_device_internal *pdev = RTE_PCI_DEVICE_INTERNAL(dev);
+ uint8_t mask = pdev->bar_mask;
+
+ if (mask == 0)
+ mask = PCI_BAR_MASK_ALL;
+ return mask;
+}
+
/**
* Scan the content of the PCI bus, and the devices in the devices
* list
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] bus/pci: add selective BAR mapping support
2026-11-23 6:13 ` [PATCH 2/2] bus/pci: add selective BAR mapping support Cheryl Bansal
@ 2026-11-23 7:57 ` David Marchand
2026-11-23 17:03 ` Stephen Hemminger
0 siblings, 1 reply; 4+ messages in thread
From: David Marchand @ 2026-11-23 7:57 UTC (permalink / raw)
To: Cheryl Bansal
Cc: Yipeng Wang, Sameh Gobriel, Bruce Richardson, Vladimir Medvedkin,
Chenbo Xia, Nipun Gupta, dev, Thomas Monjalon
On Mon, 23 Nov 2026 at 07:13, Cheryl Bansal <cheryl.bansal@altera.com> wrote:
>
> Drivers that only need a subset of PCI BARs still pay the cost of
> mapping every valid BAR. There is no bus-level way to select which
> BARs are mapped without changing each PMD.
>
> Add the bar_mask PCI bus argument to select which BARs to map. If it
> is omitted, all valid BARs are mapped. A zero mask, a value outside
> BAR0-BAR5, or a malformed value is rejected. The argument is parsed
> from bus_str so it is not passed to PMDs. UIO and VFIO map slots are
> indexed by BAR number so primary and secondary processes stay
> consistent when some BARs are skipped.
>
> Example: -a bus=pci,addr=0000:01:00.0,bar_mask=0x05
>
> Signed-off-by: Cheryl Bansal <cheryl.bansal@altera.com>
Clearly too late for 26.11.
And don't Cc: stable.
Adding a devargs looks like a bad idea.
Why should a user know about such an internal consideration?
A change in the internal PCI bus API seems a better direction.
I wonder, which DPDK in-tree driver would benefit from this change?
--
David Marchand
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] bus/pci: add selective BAR mapping support
2026-11-23 7:57 ` David Marchand
@ 2026-11-23 17:03 ` Stephen Hemminger
0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2026-11-23 17:03 UTC (permalink / raw)
To: David Marchand
Cc: Cheryl Bansal, Yipeng Wang, Sameh Gobriel, Bruce Richardson,
Vladimir Medvedkin, Chenbo Xia, Nipun Gupta, dev, Thomas Monjalon
On Mon, 23 Nov 2026 08:57:45 +0100
David Marchand <david.marchand@redhat.com> wrote:
> On Mon, 23 Nov 2026 at 07:13, Cheryl Bansal <cheryl.bansal@altera.com> wrote:
> >
> > Drivers that only need a subset of PCI BARs still pay the cost of
> > mapping every valid BAR. There is no bus-level way to select which
> > BARs are mapped without changing each PMD.
> >
> > Add the bar_mask PCI bus argument to select which BARs to map. If it
> > is omitted, all valid BARs are mapped. A zero mask, a value outside
> > BAR0-BAR5, or a malformed value is rejected. The argument is parsed
> > from bus_str so it is not passed to PMDs. UIO and VFIO map slots are
> > indexed by BAR number so primary and secondary processes stay
> > consistent when some BARs are skipped.
> >
> > Example: -a bus=pci,addr=0000:01:00.0,bar_mask=0x05
> >
> > Signed-off-by: Cheryl Bansal <cheryl.bansal@altera.com>
>
> Clearly too late for 26.11.
> And don't Cc: stable.
>
>
> Adding a devargs looks like a bad idea.
> Why should a user know about such an internal consideration?
>
> A change in the internal PCI bus API seems a better direction.
>
> I wonder, which DPDK in-tree driver would benefit from this change?
>
>
Agree. Too late for 26.11 and devargs is not the best way to handle.
I wonder if bus API could allow probe to reject a device?
How does Linux and FreeBSD handle it?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-23 17:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 6:13 [PATCH 1/2] hash: fix maybe-uninitialized warning on minsize build Cheryl Bansal
2026-11-23 6:13 ` [PATCH 2/2] bus/pci: add selective BAR mapping support Cheryl Bansal
2026-11-23 7:57 ` David Marchand
2026-11-23 17:03 ` Stephen Hemminger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox