summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2026-01-21 16:51:09 -0800
committerJakub Kicinski <kuba@kernel.org>2026-01-23 11:49:01 -0800
commitb9ac2c60a3ad445fa81289aac5adc06b8c1b1d57 (patch)
tree91d55ad8fdb19d75bbc317db7f2d6c3fcefc7665
parent1410c7416dc343f15e9b7152eabddbdbe483002d (diff)
net: introduce a trivial netdev_queue_config()
We may choose to extend or reimplement the logic which renders the per-queue config. The drivers should not poke directly into the queue state. Add a helper for drivers to use when they want to query the config for a specific queue. Link: https://patch.msgid.link/20260122005113.2476634-3-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c6
-rw-r--r--include/net/netdev_queues.h3
-rw-r--r--net/core/Makefile1
-rw-r--r--net/core/netdev_config.c32
4 files changed, 39 insertions, 3 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 0b95100a7c36..d57e833ce690 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4326,12 +4326,12 @@ static void bnxt_init_ring_struct(struct bnxt *bp)
for (i = 0; i < bp->cp_nr_rings; i++) {
struct bnxt_napi *bnapi = bp->bnapi[i];
+ struct netdev_queue_config qcfg;
struct bnxt_ring_mem_info *rmem;
struct bnxt_cp_ring_info *cpr;
struct bnxt_rx_ring_info *rxr;
struct bnxt_tx_ring_info *txr;
struct bnxt_ring_struct *ring;
- struct netdev_rx_queue *rxq;
if (!bnapi)
continue;
@@ -4349,8 +4349,8 @@ static void bnxt_init_ring_struct(struct bnxt *bp)
if (!rxr)
goto skip_rx;
- rxq = __netif_get_rx_queue(bp->dev, i);
- rxr->rx_page_size = rxq->qcfg.rx_page_size;
+ netdev_queue_config(bp->dev, i, &qcfg);
+ rxr->rx_page_size = qcfg.rx_page_size;
ring = &rxr->rx_ring_struct;
rmem = &ring->ring_mem;
diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
index 2ab3eae8e8c3..725bf69ef86c 100644
--- a/include/net/netdev_queues.h
+++ b/include/net/netdev_queues.h
@@ -170,6 +170,9 @@ struct netdev_queue_mgmt_ops {
unsigned int supported_params;
};
+void netdev_queue_config(struct net_device *dev, int rxq,
+ struct netdev_queue_config *qcfg);
+
bool netif_rxq_has_unreadable_mp(struct net_device *dev, int idx);
/**
diff --git a/net/core/Makefile b/net/core/Makefile
index 9ef2099c5426..d643a5a7fd18 100644
--- a/net/core/Makefile
+++ b/net/core/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_NETDEV_ADDR_LIST_TEST) += dev_addr_lists_test.o
obj-y += net-sysfs.o
obj-y += hotdata.o
+obj-y += netdev_config.o
obj-y += netdev_rx_queue.o
obj-y += netdev_queues.o
obj-$(CONFIG_PAGE_POOL) += page_pool.o page_pool_user.o
diff --git a/net/core/netdev_config.c b/net/core/netdev_config.c
new file mode 100644
index 000000000000..562087bd30c8
--- /dev/null
+++ b/net/core/netdev_config.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/netdevice.h>
+#include <net/netdev_queues.h>
+#include <net/netdev_rx_queue.h>
+
+/**
+ * netdev_queue_config() - get configuration for a given queue
+ * @dev: net_device instance
+ * @rxq_idx: index of the queue of interest
+ * @qcfg: queue configuration struct (output)
+ *
+ * Render the configuration for a given queue. This helper should be used
+ * by drivers which support queue configuration to retrieve config for
+ * a particular queue.
+ *
+ * @qcfg is an output parameter and is always fully initialized by this
+ * function. Some values may not be set by the user, drivers may either
+ * deal with the "unset" values in @qcfg, or provide the callback
+ * to populate defaults in queue_management_ops.
+ */
+void netdev_queue_config(struct net_device *dev, int rxq_idx,
+ struct netdev_queue_config *qcfg)
+{
+ struct netdev_queue_config *stored;
+
+ memset(qcfg, 0, sizeof(*qcfg));
+
+ stored = &__netif_get_rx_queue(dev, rxq_idx)->qcfg;
+ qcfg->rx_page_size = stored->rx_page_size;
+}
+EXPORT_SYMBOL(netdev_queue_config);