Commit 6a9e8b60 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-restore-the-structure-of-driver-facing-qcfg-api'

Jakub Kicinski says:

====================
net: restore the structure of driver-facing qcfg API

The goal of qcfg objects is to let us seamlessly support new use cases
without modifying all the drivers. We want to pull all the logic of
combining configuration supplied via different interfaces into the core
and present the drivers with a flat queue-by-queue configuration.
Additionally we want to separate the current effective configuration
from the user intent (default vs user setting vs memory provider setting).

Restructure the recently added code to re-introduce the pieces that
are missing compared to the old RFC:
https://lore.kernel.org/20250421222827.283737-1-kuba@kernel.org
Namely:
 - the netdev_queue_config() helper
 - queue config validation callback

I hopefully removed all the more "out there" parts of the RFC.
====================

Link: https://patch.msgid.link/20260122005113.2476634-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 56f9058e b33006eb
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -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;
@@ -15983,8 +15983,12 @@ static void bnxt_queue_default_qcfg(struct net_device *dev,
	qcfg->rx_page_size = BNXT_RX_PAGE_SIZE;
}

static int bnxt_validate_qcfg(struct bnxt *bp, struct netdev_queue_config *qcfg)
static int bnxt_validate_qcfg(struct net_device *dev,
			      struct netdev_queue_config *qcfg,
			      struct netlink_ext_ack *extack)
{
	struct bnxt *bp = netdev_priv(dev);

	/* Older chips need MSS calc so rx_page_size is not supported */
	if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS) &&
	    qcfg->rx_page_size != BNXT_RX_PAGE_SIZE)
@@ -16012,10 +16016,6 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
	if (!bp->rx_ring)
		return -ENETDOWN;

	rc = bnxt_validate_qcfg(bp, qcfg);
	if (rc < 0)
		return rc;

	rxr = &bp->rx_ring[idx];
	clone = qmem;
	memcpy(clone, rxr, sizeof(*rxr));
@@ -16311,9 +16311,13 @@ static const struct netdev_queue_mgmt_ops bnxt_queue_mgmt_ops = {
	.ndo_queue_start	= bnxt_queue_start,
	.ndo_queue_stop		= bnxt_queue_stop,
	.ndo_default_qcfg	= bnxt_queue_default_qcfg,
	.ndo_validate_qcfg	= bnxt_validate_qcfg,
	.supported_params	= QCFG_RX_PAGE_SIZE,
};

static const struct netdev_queue_mgmt_ops bnxt_queue_mgmt_ops_unsupp = {
};

static void bnxt_remove_one(struct pci_dev *pdev)
{
	struct net_device *dev = pci_get_drvdata(pdev);
@@ -16966,9 +16970,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)

	if (BNXT_SUPPORTS_NTUPLE_VNIC(bp))
		bp->rss_cap |= BNXT_RSS_CAP_MULTI_RSS_CTX;

	dev->queue_mgmt_ops = &bnxt_queue_mgmt_ops_unsupp;
	if (BNXT_SUPPORTS_QUEUE_API(bp))
		dev->queue_mgmt_ops = &bnxt_queue_mgmt_ops;
	dev->request_ops_lock = true;
	dev->netmem_tx = true;

	rc = register_netdev(dev);
+16 −1
Original line number Diff line number Diff line
@@ -139,7 +139,16 @@ enum {
 * @ndo_queue_get_dma_dev: Get dma device for zero-copy operations to be used
 *			   for this queue. Return NULL on error.
 *
 * @ndo_default_qcfg:	Populate queue config struct with defaults. Optional.
 * @ndo_default_qcfg:	(Optional) Populate queue config struct with defaults.
 *			Queue config structs are passed to this helper before
 *			the user-requested settings are applied.
 *
 * @ndo_validate_qcfg: (Optional) Check if queue config is supported.
 *			Called when configuration affecting a queue may be
 *			changing, either due to NIC-wide config, or config
 *			scoped to the queue at a specified index.
 *			When NIC-wide config is changed the callback will
 *			be invoked for all queues.
 *
 * @supported_params:	Bitmask of supported parameters, see QCFG_*.
 *
@@ -164,12 +173,18 @@ struct netdev_queue_mgmt_ops {
				  int idx);
	void	(*ndo_default_qcfg)(struct net_device *dev,
				    struct netdev_queue_config *qcfg);
	int	(*ndo_validate_qcfg)(struct net_device *dev,
				     struct netdev_queue_config *qcfg,
				     struct netlink_ext_ack *extack);
	struct device *	(*ndo_queue_get_dma_dev)(struct net_device *dev,
						 int idx);

	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);

/**
+1 −0
Original line number Diff line number Diff line
@@ -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
+0 −17
Original line number Diff line number Diff line
@@ -11282,21 +11282,6 @@ static void netdev_free_phy_link_topology(struct net_device *dev)
	}
}

static void init_rx_queue_cfgs(struct net_device *dev)
{
	const struct netdev_queue_mgmt_ops *qops = dev->queue_mgmt_ops;
	struct netdev_rx_queue *rxq;
	int i;

	if (!qops || !qops->ndo_default_qcfg)
		return;

	for (i = 0; i < dev->num_rx_queues; i++) {
		rxq = __netif_get_rx_queue(dev, i);
		qops->ndo_default_qcfg(dev, &rxq->qcfg);
	}
}

/**
 * register_netdevice() - register a network device
 * @dev: device to register
@@ -11342,8 +11327,6 @@ int register_netdevice(struct net_device *dev)
	if (!dev->name_node)
		goto out;

	init_rx_queue_cfgs(dev);

	/* Init, if this function is available */
	if (dev->netdev_ops->ndo_init) {
		ret = dev->netdev_ops->ndo_init(dev);
+5 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@

struct net;
struct netlink_ext_ack;
struct netdev_queue_config;
struct cpumask;

/* Random bits of netdevice that don't need to be exposed */
@@ -91,6 +92,10 @@ extern struct rw_semaphore dev_addr_sem;
extern struct list_head net_todo_list;
void netdev_run_todo(void);

int netdev_queue_config_validate(struct net_device *dev, int rxq_idx,
				 struct netdev_queue_config *qcfg,
				 struct netlink_ext_ack *extack);

/* netdev management, shared between various uAPI entry points */
struct netdev_name_node {
	struct hlist_node hlist;
Loading