* [PATCH net-next 1/8] ibmveth: Prepare MQ RX adapter data structures
2026-11-19 0:07 [PATCH net-next 0/8] ibmveth: prepare the RX path for multi-queue Mingming Cao
@ 2026-11-19 0:07 ` Mingming Cao
2026-11-19 0:07 ` [PATCH net-next 2/8] ibmveth: Refactor RX resource allocation for MQ RX bring-up Mingming Cao
` (6 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Mingming Cao @ 2026-11-19 0:07 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
The RX path keeps one NAPI, one RX queue, one buffer list and one set
of buffer pools.
Turn those into arrays indexed by queue so the rest of this series can
pass a queue index without a layout rewrite.
IBMVETH_MAX_RX_QUEUES is 1 and every user is switched to index 0, so
there is no behavior change. num_rx_queues (set to 1 at probe) is added
for the later patches.
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 238 +++++++++++++++--------------
drivers/net/ethernet/ibm/ibmveth.h | 14 +-
2 files changed, 136 insertions(+), 116 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 05d6b60cd187..fc50036d5d26 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -101,7 +101,9 @@ static struct ibmveth_stat ibmveth_stats[] = {
/* simple methods of getting data from the current rxq entry */
static inline u32 ibmveth_rxq_flags(struct ibmveth_adapter *adapter)
{
- return be32_to_cpu(adapter->rx_queue.queue_addr[adapter->rx_queue.index].flags_off);
+ struct ibmveth_rx_q *rxq = &adapter->rx_queue[0];
+
+ return be32_to_cpu(rxq->queue_addr[rxq->index].flags_off);
}
static inline int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter)
@@ -112,7 +114,7 @@ static inline int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter)
static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter)
{
- return ibmveth_rxq_toggle(adapter) == adapter->rx_queue.toggle;
+ return ibmveth_rxq_toggle(adapter) == adapter->rx_queue[0].toggle;
}
static inline int ibmveth_rxq_buffer_valid(struct ibmveth_adapter *adapter)
@@ -132,14 +134,17 @@ static inline int ibmveth_rxq_large_packet(struct ibmveth_adapter *adapter)
static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter)
{
- return be32_to_cpu(adapter->rx_queue.queue_addr[adapter->rx_queue.index].length);
+ struct ibmveth_rx_q *rxq = &adapter->rx_queue[0];
+
+ return be32_to_cpu(rxq->queue_addr[rxq->index].length);
}
static u64 ibmveth_rxq_correlator(struct ibmveth_adapter *adapter)
{
- unsigned int idx = adapter->rx_queue.index;
+ struct ibmveth_rx_q *rxq = &adapter->rx_queue[0];
+ unsigned int idx = rxq->index;
- return READ_ONCE(adapter->rx_queue.queue_addr[idx].correlator);
+ return READ_ONCE(rxq->queue_addr[idx].correlator);
}
static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter)
@@ -393,7 +398,7 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter,
*/
static void ibmveth_update_rx_no_buffer(struct ibmveth_adapter *adapter)
{
- __be64 *p = adapter->buffer_list_addr + 4096 - 8;
+ __be64 *p = adapter->buffer_list_addr[0] + 4096 - 8;
adapter->rx_no_buffer = be64_to_cpup(p);
}
@@ -406,7 +411,7 @@ static void ibmveth_replenish_task(struct ibmveth_adapter *adapter)
adapter->replenish_task_cycles++;
for (i = (IBMVETH_NUM_BUFF_POOLS - 1); i >= 0; i--) {
- struct ibmveth_buff_pool *pool = &adapter->rx_buff_pool[i];
+ struct ibmveth_buff_pool *pool = &adapter->rx_buff_pool[0][i];
if (pool->active &&
(atomic_read(&pool->available) < pool->threshold))
@@ -459,8 +464,8 @@ static bool ibmveth_rxq_correlator_valid(struct ibmveth_adapter *adapter,
/* An inactive pool keeps its size but has no skbuff array. */
if (pool < IBMVETH_NUM_BUFF_POOLS &&
- index < adapter->rx_buff_pool[pool].size &&
- adapter->rx_buff_pool[pool].skbuff)
+ index < adapter->rx_buff_pool[0][pool].size &&
+ adapter->rx_buff_pool[0][pool].skbuff)
return true;
if (net_ratelimit())
@@ -504,7 +509,7 @@ static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,
if (!ibmveth_rxq_correlator_valid(adapter, correlator))
return -EINVAL;
- skb = adapter->rx_buff_pool[pool].skbuff[index];
+ skb = adapter->rx_buff_pool[0][pool].skbuff[index];
if (!skb) {
ibmveth_rxq_no_skb(adapter, correlator);
return -EFAULT;
@@ -518,24 +523,24 @@ static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,
/* remove the skb pointer to mark free. actual freeing is done
* by upper level networking after gro_receive
*/
- adapter->rx_buff_pool[pool].skbuff[index] = NULL;
+ adapter->rx_buff_pool[0][pool].skbuff[index] = NULL;
dma_unmap_single(&adapter->vdev->dev,
- adapter->rx_buff_pool[pool].dma_addr[index],
- adapter->rx_buff_pool[pool].buff_size,
+ adapter->rx_buff_pool[0][pool].dma_addr[index],
+ adapter->rx_buff_pool[0][pool].buff_size,
DMA_FROM_DEVICE);
}
- free_index = adapter->rx_buff_pool[pool].producer_index;
- adapter->rx_buff_pool[pool].producer_index++;
- if (adapter->rx_buff_pool[pool].producer_index >=
- adapter->rx_buff_pool[pool].size)
- adapter->rx_buff_pool[pool].producer_index = 0;
- adapter->rx_buff_pool[pool].free_map[free_index] = index;
+ free_index = adapter->rx_buff_pool[0][pool].producer_index;
+ adapter->rx_buff_pool[0][pool].producer_index++;
+ if (adapter->rx_buff_pool[0][pool].producer_index >=
+ adapter->rx_buff_pool[0][pool].size)
+ adapter->rx_buff_pool[0][pool].producer_index = 0;
+ adapter->rx_buff_pool[0][pool].free_map[free_index] = index;
mb();
- atomic_dec(&(adapter->rx_buff_pool[pool].available));
+ atomic_dec(&adapter->rx_buff_pool[0][pool].available);
return 0;
}
@@ -551,7 +556,7 @@ static struct sk_buff *ibmveth_rxq_get_buffer(struct ibmveth_adapter *adapter,
if (!ibmveth_rxq_correlator_valid(adapter, correlator))
return NULL;
- skb = adapter->rx_buff_pool[pool].skbuff[index];
+ skb = adapter->rx_buff_pool[0][pool].skbuff[index];
if (!skb)
ibmveth_rxq_no_skb(adapter, correlator);
return skb;
@@ -559,9 +564,11 @@ static struct sk_buff *ibmveth_rxq_get_buffer(struct ibmveth_adapter *adapter,
static void ibmveth_rxq_advance(struct ibmveth_adapter *adapter)
{
- if (++adapter->rx_queue.index == adapter->rx_queue.num_slots) {
- adapter->rx_queue.index = 0;
- adapter->rx_queue.toggle = !adapter->rx_queue.toggle;
+ struct ibmveth_rx_q *rxq = &adapter->rx_queue[0];
+
+ if (++rxq->index == rxq->num_slots) {
+ rxq->index = 0;
+ rxq->toggle = !rxq->toggle;
}
}
@@ -641,7 +648,7 @@ static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
*/
retry:
rc = h_register_logical_lan(adapter->vdev->unit_address,
- adapter->buffer_list_dma, rxq_desc.desc,
+ adapter->buffer_list_dma[0], rxq_desc.desc,
adapter->filter_list_dma, mac_address);
if (rc != H_SUCCESS && try_again) {
@@ -670,11 +677,11 @@ static int ibmveth_open(struct net_device *netdev)
netdev_dbg(netdev, "open starting\n");
for(i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- rxq_entries += adapter->rx_buff_pool[i].size;
+ rxq_entries += adapter->rx_buff_pool[0][i].size;
rc = -ENOMEM;
- adapter->buffer_list_addr = (void*) get_zeroed_page(GFP_KERNEL);
- if (!adapter->buffer_list_addr) {
+ adapter->buffer_list_addr[0] = (void *)get_zeroed_page(GFP_KERNEL);
+ if (!adapter->buffer_list_addr[0]) {
netdev_err(netdev, "unable to allocate list pages\n");
goto out;
}
@@ -687,17 +694,18 @@ static int ibmveth_open(struct net_device *netdev)
dev = &adapter->vdev->dev;
- adapter->rx_queue.queue_len = sizeof(struct ibmveth_rx_q_entry) *
+ adapter->rx_queue[0].queue_len = sizeof(struct ibmveth_rx_q_entry) *
rxq_entries;
- adapter->rx_queue.queue_addr =
- dma_alloc_coherent(dev, adapter->rx_queue.queue_len,
- &adapter->rx_queue.queue_dma, GFP_KERNEL);
- if (!adapter->rx_queue.queue_addr)
+ adapter->rx_queue[0].queue_addr =
+ dma_alloc_coherent(dev, adapter->rx_queue[0].queue_len,
+ &adapter->rx_queue[0].queue_dma, GFP_KERNEL);
+ if (!adapter->rx_queue[0].queue_addr)
goto out_free_filter_list;
- adapter->buffer_list_dma = dma_map_single(dev,
- adapter->buffer_list_addr, 4096, DMA_BIDIRECTIONAL);
- if (dma_mapping_error(dev, adapter->buffer_list_dma)) {
+ adapter->buffer_list_dma[0] =
+ dma_map_single(dev, adapter->buffer_list_addr[0],
+ 4096, DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(dev, adapter->buffer_list_dma[0])) {
netdev_err(netdev, "unable to map buffer list pages\n");
goto out_free_queue_mem;
}
@@ -714,19 +722,21 @@ static int ibmveth_open(struct net_device *netdev)
goto out_unmap_filter_list;
}
- adapter->rx_queue.index = 0;
- adapter->rx_queue.num_slots = rxq_entries;
- adapter->rx_queue.toggle = 1;
+ adapter->rx_queue[0].index = 0;
+ adapter->rx_queue[0].num_slots = rxq_entries;
+ adapter->rx_queue[0].toggle = 1;
mac_address = ether_addr_to_u64(netdev->dev_addr);
rxq_desc.fields.flags_len = IBMVETH_BUF_VALID |
- adapter->rx_queue.queue_len;
- rxq_desc.fields.address = adapter->rx_queue.queue_dma;
+ adapter->rx_queue[0].queue_len;
+ rxq_desc.fields.address = adapter->rx_queue[0].queue_dma;
- netdev_dbg(netdev, "buffer list @ 0x%p\n", adapter->buffer_list_addr);
+ netdev_dbg(netdev, "buffer list @ 0x%p\n",
+ adapter->buffer_list_addr[0]);
netdev_dbg(netdev, "filter list @ 0x%p\n", adapter->filter_list_addr);
- netdev_dbg(netdev, "receive q @ 0x%p\n", adapter->rx_queue.queue_addr);
+ netdev_dbg(netdev, "receive q @ 0x%p\n",
+ adapter->rx_queue[0].queue_addr);
h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
@@ -737,7 +747,7 @@ static int ibmveth_open(struct net_device *netdev)
lpar_rc);
netdev_err(netdev, "buffer TCE:0x%llx filter TCE:0x%llx rxq "
"desc:0x%llx MAC:0x%llx\n",
- adapter->buffer_list_dma,
+ adapter->buffer_list_dma[0],
adapter->filter_list_dma,
rxq_desc.desc,
mac_address);
@@ -746,11 +756,11 @@ static int ibmveth_open(struct net_device *netdev)
}
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
- if (!adapter->rx_buff_pool[i].active)
+ if (!adapter->rx_buff_pool[0][i].active)
continue;
- if (ibmveth_alloc_buffer_pool(&adapter->rx_buff_pool[i])) {
+ if (ibmveth_alloc_buffer_pool(&adapter->rx_buff_pool[0][i])) {
netdev_err(netdev, "unable to alloc pool\n");
- adapter->rx_buff_pool[i].active = 0;
+ adapter->rx_buff_pool[0][i].active = 0;
rc = -ENOMEM;
goto out_free_buffer_pools;
}
@@ -761,13 +771,13 @@ static int ibmveth_open(struct net_device *netdev)
* call, so enable it only once everything ibmveth_poll() touches
* exists.
*/
- napi_enable(&adapter->napi);
+ napi_enable(&adapter->napi[0]);
netdev_dbg(netdev, "registering irq 0x%x\n", netdev->irq);
rc = request_irq(netdev->irq, ibmveth_interrupt, 0, netdev->name,
netdev);
if (rc != 0) {
- napi_disable(&adapter->napi);
+ napi_disable(&adapter->napi[0]);
synchronize_net();
netdev_err(netdev, "unable to request irq 0x%x, rc %d\n",
netdev->irq, rc);
@@ -791,9 +801,9 @@ static int ibmveth_open(struct net_device *netdev)
lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
} while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY));
while (--i >= 0) {
- if (adapter->rx_buff_pool[i].active)
+ if (adapter->rx_buff_pool[0][i].active)
ibmveth_free_buffer_pool(adapter,
- &adapter->rx_buff_pool[i]);
+ &adapter->rx_buff_pool[0][i]);
}
out_unmap_filter_list:
dma_unmap_single(dev, adapter->filter_list_dma, 4096,
@@ -803,16 +813,16 @@ static int ibmveth_open(struct net_device *netdev)
ibmveth_free_tx_ltb(adapter, i);
out_unmap_buffer_list:
- dma_unmap_single(dev, adapter->buffer_list_dma, 4096,
+ dma_unmap_single(dev, adapter->buffer_list_dma[0], 4096,
DMA_BIDIRECTIONAL);
out_free_queue_mem:
- dma_free_coherent(dev, adapter->rx_queue.queue_len,
- adapter->rx_queue.queue_addr,
- adapter->rx_queue.queue_dma);
+ dma_free_coherent(dev, adapter->rx_queue[0].queue_len,
+ adapter->rx_queue[0].queue_addr,
+ adapter->rx_queue[0].queue_dma);
out_free_filter_list:
free_page((unsigned long)adapter->filter_list_addr);
out_free_buffer_list:
- free_page((unsigned long)adapter->buffer_list_addr);
+ free_page((unsigned long)adapter->buffer_list_addr[0]);
out:
return rc;
}
@@ -834,7 +844,7 @@ static int ibmveth_close(struct net_device *netdev)
netdev_dbg(netdev, "close starting\n");
- napi_disable(&adapter->napi);
+ napi_disable(&adapter->napi[0]);
/* napi_disable() returns once ibmveth_poll() has called
* napi_complete_done(), but the poll still re-enables the
* interrupt and reads the RX queue after that.
@@ -858,22 +868,22 @@ static int ibmveth_close(struct net_device *netdev)
ibmveth_update_rx_no_buffer(adapter);
- dma_unmap_single(dev, adapter->buffer_list_dma, 4096,
+ dma_unmap_single(dev, adapter->buffer_list_dma[0], 4096,
DMA_BIDIRECTIONAL);
- free_page((unsigned long)adapter->buffer_list_addr);
+ free_page((unsigned long)adapter->buffer_list_addr[0]);
dma_unmap_single(dev, adapter->filter_list_dma, 4096,
DMA_BIDIRECTIONAL);
free_page((unsigned long)adapter->filter_list_addr);
- dma_free_coherent(dev, adapter->rx_queue.queue_len,
- adapter->rx_queue.queue_addr,
- adapter->rx_queue.queue_dma);
+ dma_free_coherent(dev, adapter->rx_queue[0].queue_len,
+ adapter->rx_queue[0].queue_addr,
+ adapter->rx_queue[0].queue_dma);
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- if (adapter->rx_buff_pool[i].active)
+ if (adapter->rx_buff_pool[0][i].active)
ibmveth_free_buffer_pool(adapter,
- &adapter->rx_buff_pool[i]);
+ &adapter->rx_buff_pool[0][i]);
for (i = 0; i < netdev->real_num_tx_queues; i++)
ibmveth_free_tx_ltb(adapter, i);
@@ -1554,7 +1564,7 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,
static int ibmveth_poll(struct napi_struct *napi, int budget)
{
struct ibmveth_adapter *adapter =
- container_of(napi, struct ibmveth_adapter, napi);
+ container_of(napi, struct ibmveth_adapter, napi[0]);
struct net_device *netdev = adapter->netdev;
int frames_processed = 0;
unsigned long lpar_rc;
@@ -1597,7 +1607,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
pool = correlator >> 32;
room = min_t(unsigned int, skb_tailroom(skb),
- adapter->rx_buff_pool[pool].buff_size);
+ adapter->rx_buff_pool[0][pool].buff_size);
off = offset;
len = length;
if (unlikely(len < ETH_HLEN || off >= room ||
@@ -1730,11 +1740,11 @@ static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance)
struct ibmveth_adapter *adapter = netdev_priv(netdev);
unsigned long lpar_rc;
- if (napi_schedule_prep(&adapter->napi)) {
+ if (napi_schedule_prep(&adapter->napi[0])) {
lpar_rc = h_vio_signal(adapter->vdev->unit_address,
VIO_IRQ_DISABLE);
WARN_ON(lpar_rc != H_SUCCESS);
- __napi_schedule(&adapter->napi);
+ __napi_schedule(&adapter->napi[0]);
}
return IRQ_HANDLED;
}
@@ -1802,7 +1812,7 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
int need_restart = 0;
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size)
+ if (new_mtu_oh <= adapter->rx_buff_pool[0][i].buff_size)
break;
if (i == IBMVETH_NUM_BUFF_POOLS)
@@ -1817,9 +1827,9 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
/* Look for an active buffer pool that can hold the new MTU */
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
- adapter->rx_buff_pool[i].active = 1;
+ adapter->rx_buff_pool[0][i].active = 1;
- if (new_mtu_oh <= adapter->rx_buff_pool[i].buff_size) {
+ if (new_mtu_oh <= adapter->rx_buff_pool[0][i].buff_size) {
WRITE_ONCE(dev->mtu, new_mtu);
vio_cmo_set_dev_desired(viodev,
ibmveth_get_desired_dma
@@ -1869,12 +1879,12 @@ static unsigned long ibmveth_get_desired_dma(struct vio_dev *vdev)
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
/* add the size of the active receive buffers */
- if (adapter->rx_buff_pool[i].active)
+ if (adapter->rx_buff_pool[0][i].active)
ret +=
- adapter->rx_buff_pool[i].size *
- IOMMU_PAGE_ALIGN(adapter->rx_buff_pool[i].
+ adapter->rx_buff_pool[0][i].size *
+ IOMMU_PAGE_ALIGN(adapter->rx_buff_pool[0][i].
buff_size, tbl);
- rxqentries += adapter->rx_buff_pool[i].size;
+ rxqentries += adapter->rx_buff_pool[0][i].size;
}
/* add the size of the receive queue entries */
ret += IOMMU_PAGE_ALIGN(
@@ -1969,9 +1979,9 @@ static void ibmveth_put_pool_kobjs(struct ibmveth_adapter *adapter)
int i;
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- kobject_put(&adapter->rx_buff_pool[i].kobj);
+ kobject_put(&adapter->rx_buff_pool[0][i].kobj);
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- wait_for_completion(&adapter->rx_buff_pool[i].released);
+ wait_for_completion(&adapter->rx_buff_pool[0][i].released);
}
static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
@@ -2024,7 +2034,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
adapter->mcastFilterSize = be32_to_cpu(*mcastFilterSize_p);
ibmveth_init_link_settings(netdev);
- netif_napi_add_weight(netdev, &adapter->napi, ibmveth_poll, 16);
+ netif_napi_add_weight(netdev, &adapter->napi[0], ibmveth_poll, 16);
netdev->irq = dev->irq;
netdev->netdev_ops = &ibmveth_netdev_ops;
@@ -2056,6 +2066,8 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
netdev->features |= NETIF_F_FRAGLIST;
}
+ adapter->num_rx_queues = IBMVETH_DEFAULT_RX_QUEUES;
+
if (ret == H_SUCCESS &&
(ret_attr & IBMVETH_ILLAN_RX_MULTI_BUFF_SUPPORT)) {
adapter->rx_buffers_per_hcall = IBMVETH_MAX_RX_PER_HCALL;
@@ -2078,13 +2090,13 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
memcpy(pool_count, pool_count_cmo, sizeof(pool_count));
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
- struct kobject *kobj = &adapter->rx_buff_pool[i].kobj;
+ struct kobject *kobj = &adapter->rx_buff_pool[0][i].kobj;
int error;
- ibmveth_init_buffer_pool(&adapter->rx_buff_pool[i], i,
+ ibmveth_init_buffer_pool(&adapter->rx_buff_pool[0][i], i,
pool_count[i], pool_size[i],
pool_active[i]);
- init_completion(&adapter->rx_buff_pool[i].released);
+ init_completion(&adapter->rx_buff_pool[0][i].released);
error = kobject_init_and_add(kobj, &ktype_veth_pool,
&dev->dev.kobj, "pool%d", i);
if (!error)
@@ -2217,11 +2229,12 @@ static ssize_t veth_pool_store(struct kobject *kobj, struct attribute *attr,
/* Make sure there is a buffer pool with buffers that
can hold a packet of the size of the MTU */
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
- if (pool == &adapter->rx_buff_pool[i])
+ if (pool == &adapter->rx_buff_pool[0][i])
continue;
- if (!adapter->rx_buff_pool[i].active)
+ if (!adapter->rx_buff_pool[0][i].active)
continue;
- if (mtu <= adapter->rx_buff_pool[i].buff_size)
+ if (mtu <=
+ adapter->rx_buff_pool[0][i].buff_size)
break;
}
@@ -2395,11 +2408,11 @@ static void ibmveth_remove_buffer_from_pool_test(struct kunit *test)
/* Set sane values for buffer pools */
for (int i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- ibmveth_init_buffer_pool(&adapter->rx_buff_pool[i], i,
+ ibmveth_init_buffer_pool(&adapter->rx_buff_pool[0][i], i,
pool_count[i], pool_size[i],
pool_active[i]);
- pool = &adapter->rx_buff_pool[0];
+ pool = &adapter->rx_buff_pool[0][0];
pool->skbuff = kunit_kcalloc(test, pool->size, sizeof(void *), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pool->skbuff);
@@ -2407,7 +2420,7 @@ static void ibmveth_remove_buffer_from_pool_test(struct kunit *test)
KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, false));
KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, true));
- correlator = ((u64)0 << 32) | adapter->rx_buff_pool[0].size;
+ correlator = ((u64)0 << 32) | adapter->rx_buff_pool[0][0].size;
KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, false));
KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, true));
@@ -2447,40 +2460,43 @@ static void ibmveth_rxq_get_buffer_test(struct kunit *test)
INIT_WORK(&adapter->work, ibmveth_reset_kunit);
- adapter->rx_queue.queue_len = 1;
- adapter->rx_queue.index = 0;
- adapter->rx_queue.queue_addr = kunit_kzalloc(test, sizeof(struct ibmveth_rx_q_entry),
- GFP_KERNEL);
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter->rx_queue.queue_addr);
+ adapter->rx_queue[0].queue_len = 1;
+ adapter->rx_queue[0].index = 0;
+ adapter->rx_queue[0].queue_addr =
+ kunit_kzalloc(test, sizeof(struct ibmveth_rx_q_entry),
+ GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter->rx_queue[0].queue_addr);
/* Set sane values for buffer pools */
for (int i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- ibmveth_init_buffer_pool(&adapter->rx_buff_pool[i], i,
+ ibmveth_init_buffer_pool(&adapter->rx_buff_pool[0][i], i,
pool_count[i], pool_size[i],
pool_active[i]);
- pool = &adapter->rx_buff_pool[0];
+ pool = &adapter->rx_buff_pool[0][0];
pool->skbuff = kunit_kcalloc(test, pool->size, sizeof(void *), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pool->skbuff);
- adapter->rx_queue.queue_addr[0].correlator = (u64)IBMVETH_NUM_BUFF_POOLS << 32 | 0;
+ adapter->rx_queue[0].queue_addr[0].correlator =
+ (u64)IBMVETH_NUM_BUFF_POOLS << 32 | 0;
cor = ibmveth_rxq_correlator(adapter);
KUNIT_EXPECT_PTR_EQ(test, NULL,
ibmveth_rxq_get_buffer(adapter, cor));
- adapter->rx_queue.queue_addr[0].correlator = (u64)0 << 32 | adapter->rx_buff_pool[0].size;
+ adapter->rx_queue[0].queue_addr[0].correlator =
+ (u64)0 << 32 | adapter->rx_buff_pool[0][0].size;
cor = ibmveth_rxq_correlator(adapter);
KUNIT_EXPECT_PTR_EQ(test, NULL,
ibmveth_rxq_get_buffer(adapter, cor));
/* Pool 2 is in range but has no skbuff array, like an inactive pool. */
- adapter->rx_queue.queue_addr[0].correlator = (u64)2 << 32 | 0;
+ adapter->rx_queue[0].queue_addr[0].correlator = (u64)2 << 32 | 0;
cor = ibmveth_rxq_correlator(adapter);
KUNIT_EXPECT_PTR_EQ(test, NULL,
ibmveth_rxq_get_buffer(adapter, cor));
pool->skbuff[0] = skb;
- adapter->rx_queue.queue_addr[0].correlator = (u64)0 << 32 | 0;
+ adapter->rx_queue[0].queue_addr[0].correlator = (u64)0 << 32 | 0;
cor = ibmveth_rxq_correlator(adapter);
KUNIT_EXPECT_PTR_EQ(test, skb,
ibmveth_rxq_get_buffer(adapter, cor));
@@ -2510,41 +2526,41 @@ static void ibmveth_rxq_harvest_buffer_test(struct kunit *test)
INIT_WORK(&adapter->work, ibmveth_reset_kunit);
- adapter->rx_queue.num_slots = 2;
- adapter->rx_queue.index = 0;
- adapter->rx_queue.toggle = 1;
- adapter->rx_queue.queue_addr =
+ adapter->rx_queue[0].num_slots = 2;
+ adapter->rx_queue[0].index = 0;
+ adapter->rx_queue[0].toggle = 1;
+ adapter->rx_queue[0].queue_addr =
kunit_kcalloc(test, 2, sizeof(struct ibmveth_rx_q_entry),
GFP_KERNEL);
- KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter->rx_queue.queue_addr);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter->rx_queue[0].queue_addr);
/* Set sane values for buffer pools */
for (int i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- ibmveth_init_buffer_pool(&adapter->rx_buff_pool[i], i,
+ ibmveth_init_buffer_pool(&adapter->rx_buff_pool[0][i], i,
pool_count[i], pool_size[i],
pool_active[i]);
- pool = &adapter->rx_buff_pool[0];
+ pool = &adapter->rx_buff_pool[0][0];
pool->skbuff = kunit_kcalloc(test, pool->size, sizeof(void *),
GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pool->skbuff);
/* Slot 0: pool out of range. Slot 1: valid, but no skb. */
- adapter->rx_queue.queue_addr[0].correlator =
+ adapter->rx_queue[0].queue_addr[0].correlator =
(u64)IBMVETH_NUM_BUFF_POOLS << 32 | 0;
- adapter->rx_queue.queue_addr[1].correlator = (u64)0 << 32 | 0;
+ adapter->rx_queue[0].queue_addr[1].correlator = (u64)0 << 32 | 0;
cor = ibmveth_rxq_correlator(adapter);
ret = ibmveth_rxq_harvest_buffer(adapter, cor, true);
KUNIT_EXPECT_EQ(test, -EINVAL, ret);
- KUNIT_EXPECT_EQ(test, 1ULL, adapter->rx_queue.index);
- KUNIT_EXPECT_EQ(test, 1ULL, adapter->rx_queue.toggle);
+ KUNIT_EXPECT_EQ(test, 1ULL, adapter->rx_queue[0].index);
+ KUNIT_EXPECT_EQ(test, 1ULL, adapter->rx_queue[0].toggle);
cor = ibmveth_rxq_correlator(adapter);
ret = ibmveth_rxq_harvest_buffer(adapter, cor, true);
KUNIT_EXPECT_EQ(test, -EFAULT, ret);
- KUNIT_EXPECT_EQ(test, 0ULL, adapter->rx_queue.index);
- KUNIT_EXPECT_EQ(test, 0ULL, adapter->rx_queue.toggle);
+ KUNIT_EXPECT_EQ(test, 0ULL, adapter->rx_queue[0].index);
+ KUNIT_EXPECT_EQ(test, 0ULL, adapter->rx_queue[0].toggle);
flush_work(&adapter->work);
}
diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h
index be0939caa328..4c74bd39d4e0 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -123,6 +123,8 @@ static inline long h_illan_attributes(unsigned long unit_address,
#define IBMVETH_MAX_TX_BUF_SIZE (1024 * 64)
#define IBMVETH_MAX_QUEUES 16U
#define IBMVETH_DEFAULT_QUEUES 8U
+#define IBMVETH_MAX_RX_QUEUES 1U
+#define IBMVETH_DEFAULT_RX_QUEUES 1U
#define IBMVETH_MAX_RX_PER_HCALL 8U
static int pool_size[] = { 512, 1024 * 2, 1024 * 16, 1024 * 32, 1024 * 64 };
@@ -160,18 +162,20 @@ struct ibmveth_rx_q {
struct ibmveth_adapter {
struct vio_dev *vdev;
struct net_device *netdev;
- struct napi_struct napi;
+ struct napi_struct napi[IBMVETH_MAX_RX_QUEUES];
struct work_struct work;
unsigned int mcastFilterSize;
- void *buffer_list_addr;
+ void *buffer_list_addr[IBMVETH_MAX_RX_QUEUES];
void *filter_list_addr;
void *tx_ltb_ptr[IBMVETH_MAX_QUEUES];
unsigned int tx_ltb_size;
dma_addr_t tx_ltb_dma[IBMVETH_MAX_QUEUES];
- dma_addr_t buffer_list_dma;
+ dma_addr_t buffer_list_dma[IBMVETH_MAX_RX_QUEUES];
dma_addr_t filter_list_dma;
- struct ibmveth_buff_pool rx_buff_pool[IBMVETH_NUM_BUFF_POOLS];
- struct ibmveth_rx_q rx_queue;
+ struct ibmveth_buff_pool
+ rx_buff_pool[IBMVETH_MAX_RX_QUEUES][IBMVETH_NUM_BUFF_POOLS];
+ struct ibmveth_rx_q rx_queue[IBMVETH_MAX_RX_QUEUES];
+ unsigned int num_rx_queues;
int rx_csum;
int large_send;
bool is_active_trunk;
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH net-next 2/8] ibmveth: Refactor RX resource allocation for MQ RX bring-up
2026-11-19 0:07 [PATCH net-next 0/8] ibmveth: prepare the RX path for multi-queue Mingming Cao
2026-11-19 0:07 ` [PATCH net-next 1/8] ibmveth: Prepare MQ RX adapter data structures Mingming Cao
@ 2026-11-19 0:07 ` Mingming Cao
2026-11-23 1:06 ` netdev-bot+sashiko
2026-11-19 0:07 ` [PATCH net-next 3/8] ibmveth: Refactor buffer pool management for per-queue MQ RX Mingming Cao
` (5 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Mingming Cao @ 2026-11-19 0:07 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Move filter list and RX queue allocation out of ibmveth_open() into
helpers that loop over num_rx_queues and undo their own partial
failures, so open() does not need an unwind label per queue. close()
and the open() error path free through the same helpers.
open() now allocates the filter list first and sets up the RX ring
before the TX LTBs.
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
Reviewed-by: Dave Marquardt <davemarq@linux.ibm.com>
Tested-by: Shaik Abdulla <shaik.abdulla1@ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 264 ++++++++++++++++++++---------
1 file changed, 186 insertions(+), 78 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index fc50036d5d26..559c4d2d957b 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -159,6 +159,177 @@ static unsigned int ibmveth_real_max_tx_queues(void)
return min(n_cpu, IBMVETH_MAX_QUEUES);
}
+/**
+ * ibmveth_alloc_filter_list - Allocate and map filter list
+ * @adapter: ibmveth adapter structure
+ *
+ * Return: 0 on success, -ENOMEM on failure
+ */
+static int
+ibmveth_alloc_filter_list(struct ibmveth_adapter *adapter)
+{
+ struct device *dev = &adapter->vdev->dev;
+ struct net_device *netdev = adapter->netdev;
+
+ adapter->filter_list_addr = (void *)get_zeroed_page(GFP_KERNEL);
+ if (!adapter->filter_list_addr) {
+ netdev_err(netdev, "unable to allocate filter pages\n");
+ return -ENOMEM;
+ }
+
+ adapter->filter_list_dma = dma_map_single(dev,
+ adapter->filter_list_addr,
+ 4096, DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(dev, adapter->filter_list_dma)) {
+ netdev_err(netdev, "unable to map filter list pages\n");
+ free_page((unsigned long)adapter->filter_list_addr);
+ adapter->filter_list_addr = NULL;
+ /* Do not leave DMA_MAPPING_ERROR in the adapter. */
+ adapter->filter_list_dma = 0;
+ return -ENOMEM;
+ }
+
+ netdev_dbg(netdev, "filter list @ 0x%p (DMA: 0x%llx)\n",
+ adapter->filter_list_addr,
+ (unsigned long long)adapter->filter_list_dma);
+
+ return 0;
+}
+
+/**
+ * ibmveth_free_filter_list - Free filter list resources
+ * @adapter: ibmveth adapter structure
+ */
+static void
+ibmveth_free_filter_list(struct ibmveth_adapter *adapter)
+{
+ struct device *dev = &adapter->vdev->dev;
+
+ /* Unmap by CPU pointer: SPAPR can return DMA address 0. */
+ if (adapter->filter_list_addr) {
+ dma_unmap_single(dev, adapter->filter_list_dma, 4096,
+ DMA_BIDIRECTIONAL);
+ adapter->filter_list_dma = 0;
+ free_page((unsigned long)adapter->filter_list_addr);
+ adapter->filter_list_addr = NULL;
+ }
+}
+
+/**
+ * ibmveth_alloc_rx_queues - Allocate per-queue RX resources
+ * @adapter: ibmveth adapter structure
+ * @rxq_entries: Number of entries per RX queue
+ *
+ * Return: 0 on success, -ENOMEM on failure
+ */
+static int
+ibmveth_alloc_rx_queues(struct ibmveth_adapter *adapter, int rxq_entries)
+{
+ struct device *dev = &adapter->vdev->dev;
+ struct net_device *netdev = adapter->netdev;
+ int i;
+
+ for (i = 0; i < adapter->num_rx_queues; i++) {
+ adapter->buffer_list_addr[i] =
+ (void *)get_zeroed_page(GFP_KERNEL);
+ if (!adapter->buffer_list_addr[i]) {
+ netdev_err(netdev,
+ "unable to allocate buffer list for queue %d\n",
+ i);
+ goto err_cleanup;
+ }
+
+ adapter->rx_queue[i].queue_len =
+ sizeof(struct ibmveth_rx_q_entry) * rxq_entries;
+ adapter->rx_queue[i].queue_addr =
+ dma_alloc_coherent(dev, adapter->rx_queue[i].queue_len,
+ &adapter->rx_queue[i].queue_dma,
+ GFP_KERNEL);
+ if (!adapter->rx_queue[i].queue_addr) {
+ netdev_err(netdev,
+ "unable to allocate RX queue for queue %d\n",
+ i);
+ free_page((unsigned long)adapter->buffer_list_addr[i]);
+ adapter->buffer_list_addr[i] = NULL;
+ goto err_cleanup;
+ }
+
+ adapter->buffer_list_dma[i] =
+ dma_map_single(dev, adapter->buffer_list_addr[i],
+ 4096, DMA_BIDIRECTIONAL);
+ if (dma_mapping_error(dev, adapter->buffer_list_dma[i])) {
+ netdev_err(netdev,
+ "unable to map buffer list for queue %d\n",
+ i);
+ free_page((unsigned long)adapter->buffer_list_addr[i]);
+ adapter->buffer_list_addr[i] = NULL;
+ adapter->buffer_list_dma[i] = 0;
+ goto err_cleanup;
+ }
+
+ adapter->rx_queue[i].index = 0;
+ adapter->rx_queue[i].num_slots = rxq_entries;
+ adapter->rx_queue[i].toggle = 1;
+ }
+
+ return 0;
+
+err_cleanup:
+ /* Queue i may be partly set up: queue_addr can be live without
+ * a buffer list.
+ */
+ for (; i >= 0; i--) {
+ if (adapter->buffer_list_addr[i]) {
+ dma_unmap_single(dev, adapter->buffer_list_dma[i],
+ 4096, DMA_BIDIRECTIONAL);
+ adapter->buffer_list_dma[i] = 0;
+ }
+ if (adapter->rx_queue[i].queue_addr) {
+ dma_free_coherent(dev, adapter->rx_queue[i].queue_len,
+ adapter->rx_queue[i].queue_addr,
+ adapter->rx_queue[i].queue_dma);
+ adapter->rx_queue[i].queue_addr = NULL;
+ }
+ if (adapter->buffer_list_addr[i]) {
+ free_page((unsigned long)adapter->buffer_list_addr[i]);
+ adapter->buffer_list_addr[i] = NULL;
+ }
+ }
+
+ return -ENOMEM;
+}
+
+/**
+ * ibmveth_cleanup_rx_resources - Free all RX queue resources
+ * @adapter: ibmveth adapter structure
+ */
+static void
+ibmveth_cleanup_rx_resources(struct ibmveth_adapter *adapter)
+{
+ struct device *dev = &adapter->vdev->dev;
+ int i;
+
+ for (i = 0; i < adapter->num_rx_queues; i++) {
+ if (adapter->buffer_list_addr[i]) {
+ dma_unmap_single(dev, adapter->buffer_list_dma[i],
+ 4096, DMA_BIDIRECTIONAL);
+ adapter->buffer_list_dma[i] = 0;
+ }
+
+ if (adapter->rx_queue[i].queue_addr) {
+ dma_free_coherent(dev, adapter->rx_queue[i].queue_len,
+ adapter->rx_queue[i].queue_addr,
+ adapter->rx_queue[i].queue_dma);
+ adapter->rx_queue[i].queue_addr = NULL;
+ }
+
+ if (adapter->buffer_list_addr[i]) {
+ free_page((unsigned long)adapter->buffer_list_addr[i]);
+ adapter->buffer_list_addr[i] = NULL;
+ }
+ }
+}
+
/* setup the initial settings for a buffer pool */
static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool,
u32 pool_index, u32 pool_size,
@@ -398,8 +569,9 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter,
*/
static void ibmveth_update_rx_no_buffer(struct ibmveth_adapter *adapter)
{
- __be64 *p = adapter->buffer_list_addr[0] + 4096 - 8;
+ __be64 *p;
+ p = adapter->buffer_list_addr[0] + 4096 - 8;
adapter->rx_no_buffer = be64_to_cpup(p);
}
@@ -672,72 +844,32 @@ static int ibmveth_open(struct net_device *netdev)
int rc;
union ibmveth_buf_desc rxq_desc;
int i;
- struct device *dev;
netdev_dbg(netdev, "open starting\n");
- for(i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
+ for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
rxq_entries += adapter->rx_buff_pool[0][i].size;
- rc = -ENOMEM;
- adapter->buffer_list_addr[0] = (void *)get_zeroed_page(GFP_KERNEL);
- if (!adapter->buffer_list_addr[0]) {
- netdev_err(netdev, "unable to allocate list pages\n");
+ rc = ibmveth_alloc_filter_list(adapter);
+ if (rc)
goto out;
- }
- adapter->filter_list_addr = (void*) get_zeroed_page(GFP_KERNEL);
- if (!adapter->filter_list_addr) {
- netdev_err(netdev, "unable to allocate filter pages\n");
- goto out_free_buffer_list;
- }
-
- dev = &adapter->vdev->dev;
-
- adapter->rx_queue[0].queue_len = sizeof(struct ibmveth_rx_q_entry) *
- rxq_entries;
- adapter->rx_queue[0].queue_addr =
- dma_alloc_coherent(dev, adapter->rx_queue[0].queue_len,
- &adapter->rx_queue[0].queue_dma, GFP_KERNEL);
- if (!adapter->rx_queue[0].queue_addr)
+ rc = ibmveth_alloc_rx_queues(adapter, rxq_entries);
+ if (rc)
goto out_free_filter_list;
- adapter->buffer_list_dma[0] =
- dma_map_single(dev, adapter->buffer_list_addr[0],
- 4096, DMA_BIDIRECTIONAL);
- if (dma_mapping_error(dev, adapter->buffer_list_dma[0])) {
- netdev_err(netdev, "unable to map buffer list pages\n");
- goto out_free_queue_mem;
- }
-
- adapter->filter_list_dma = dma_map_single(dev,
- adapter->filter_list_addr, 4096, DMA_BIDIRECTIONAL);
- if (dma_mapping_error(dev, adapter->filter_list_dma)) {
- netdev_err(netdev, "unable to map filter list pages\n");
- goto out_unmap_buffer_list;
- }
-
+ rc = -ENOMEM;
for (i = 0; i < netdev->real_num_tx_queues; i++) {
if (ibmveth_allocate_tx_ltb(adapter, i))
- goto out_unmap_filter_list;
+ goto out_free_tx_ltb;
}
- adapter->rx_queue[0].index = 0;
- adapter->rx_queue[0].num_slots = rxq_entries;
- adapter->rx_queue[0].toggle = 1;
-
mac_address = ether_addr_to_u64(netdev->dev_addr);
rxq_desc.fields.flags_len = IBMVETH_BUF_VALID |
adapter->rx_queue[0].queue_len;
rxq_desc.fields.address = adapter->rx_queue[0].queue_dma;
- netdev_dbg(netdev, "buffer list @ 0x%p\n",
- adapter->buffer_list_addr[0]);
- netdev_dbg(netdev, "filter list @ 0x%p\n", adapter->filter_list_addr);
- netdev_dbg(netdev, "receive q @ 0x%p\n",
- adapter->rx_queue[0].queue_addr);
-
h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
@@ -752,7 +884,7 @@ static int ibmveth_open(struct net_device *netdev)
rxq_desc.desc,
mac_address);
rc = -ENONET;
- goto out_unmap_filter_list;
+ goto out_free_tx_ltb;
}
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
@@ -784,8 +916,6 @@ static int ibmveth_open(struct net_device *netdev)
goto out_free_buffer_pools;
}
- rc = -ENOMEM;
-
netdev_dbg(netdev, "initial replenish cycle\n");
ibmveth_interrupt(netdev->irq, netdev);
@@ -805,24 +935,12 @@ static int ibmveth_open(struct net_device *netdev)
ibmveth_free_buffer_pool(adapter,
&adapter->rx_buff_pool[0][i]);
}
-out_unmap_filter_list:
- dma_unmap_single(dev, adapter->filter_list_dma, 4096,
- DMA_BIDIRECTIONAL);
-
+out_free_tx_ltb:
for (i = netdev->real_num_tx_queues - 1; i >= 0; i--)
ibmveth_free_tx_ltb(adapter, i);
-
-out_unmap_buffer_list:
- dma_unmap_single(dev, adapter->buffer_list_dma[0], 4096,
- DMA_BIDIRECTIONAL);
-out_free_queue_mem:
- dma_free_coherent(dev, adapter->rx_queue[0].queue_len,
- adapter->rx_queue[0].queue_addr,
- adapter->rx_queue[0].queue_dma);
+ ibmveth_cleanup_rx_resources(adapter);
out_free_filter_list:
- free_page((unsigned long)adapter->filter_list_addr);
-out_free_buffer_list:
- free_page((unsigned long)adapter->buffer_list_addr[0]);
+ ibmveth_free_filter_list(adapter);
out:
return rc;
}
@@ -830,7 +948,6 @@ static int ibmveth_open(struct net_device *netdev)
static int ibmveth_close(struct net_device *netdev)
{
struct ibmveth_adapter *adapter = netdev_priv(netdev);
- struct device *dev = &adapter->vdev->dev;
long lpar_rc;
int i;
@@ -868,17 +985,8 @@ static int ibmveth_close(struct net_device *netdev)
ibmveth_update_rx_no_buffer(adapter);
- dma_unmap_single(dev, adapter->buffer_list_dma[0], 4096,
- DMA_BIDIRECTIONAL);
- free_page((unsigned long)adapter->buffer_list_addr[0]);
-
- dma_unmap_single(dev, adapter->filter_list_dma, 4096,
- DMA_BIDIRECTIONAL);
- free_page((unsigned long)adapter->filter_list_addr);
-
- dma_free_coherent(dev, adapter->rx_queue[0].queue_len,
- adapter->rx_queue[0].queue_addr,
- adapter->rx_queue[0].queue_dma);
+ ibmveth_cleanup_rx_resources(adapter);
+ ibmveth_free_filter_list(adapter);
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
if (adapter->rx_buff_pool[0][i].active)
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH net-next 2/8] ibmveth: Refactor RX resource allocation for MQ RX bring-up
2026-11-19 0:07 ` [PATCH net-next 2/8] ibmveth: Refactor RX resource allocation for MQ RX bring-up Mingming Cao
@ 2026-11-23 1:06 ` netdev-bot+sashiko
0 siblings, 0 replies; 15+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 1:06 UTC (permalink / raw)
To: mmc
Cc: netdev, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The kernel-doc for ibmveth_cleanup_rx_resources() in
drivers/net/ethernet/ibm/ibmveth.c says "Free all RX queue resources",…
--
ibmveth: Refactor RX resource allocation for MQ RX bring-up
This moves the filter list and per-queue RX ring and buffer list
allocation out of ibmveth_open() into helpers that loop over
num_rx_queues and undo their own partial failures. ibmveth_close() and
the open() error path now free through the same helpers.
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index fc50036d5d265..559c4d2d957bb 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
> @@ -159,6 +159,177 @@ static unsigned int ibmveth_real_max_tx_queues(void)
[ ... ]
> +/**
> + * ibmveth_cleanup_rx_resources - Free all RX queue resources
> + * @adapter: ibmveth adapter structure
> + */
> +static void
> +ibmveth_cleanup_rx_resources(struct ibmveth_adapter *adapter)
> +{
> + struct device *dev = &adapter->vdev->dev;
> + int i;
> +
> + for (i = 0; i < adapter->num_rx_queues; i++) {
> + if (adapter->buffer_list_addr[i]) {
> + dma_unmap_single(dev, adapter->buffer_list_dma[i],
> + 4096, DMA_BIDIRECTIONAL);
> + adapter->buffer_list_dma[i] = 0;
> + }
> +
> + if (adapter->rx_queue[i].queue_addr) {
> + dma_free_coherent(dev, adapter->rx_queue[i].queue_len,
> + adapter->rx_queue[i].queue_addr,
> + adapter->rx_queue[i].queue_dma);
> + adapter->rx_queue[i].queue_addr = NULL;
> + }
> +
> + if (adapter->buffer_list_addr[i]) {
> + free_page((unsigned long)adapter->buffer_list_addr[i]);
> + adapter->buffer_list_addr[i] = NULL;
> + }
> + }
> +}
[Severity: Low]
This isn't a bug, but is the kernel-doc for ibmveth_cleanup_rx_resources()
accurate? It says "Free all RX queue resources". The body only frees
buffer_list_addr[i] with its buffer_list_dma[i] mapping, plus the coherent
ring at rx_queue[i].queue_addr.
It doesn't free the per-queue buffer pools in adapter->rx_buff_pool[queue][*]
(the free_map, dma_addr and skbuff arrays and the DMA-mapped skbs). That is
why ibmveth_close() still frees them in a separate loop after calling this
helper:
ibmveth_cleanup_rx_resources(adapter);
ibmveth_free_filter_list(adapter);
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
if (adapter->rx_buff_pool[0][i].active)
ibmveth_free_buffer_pool(adapter,
&adapter->rx_buff_pool[0][i]);
The ibmveth_open() error path also keeps its own out_free_buffer_pools
label for the same reason.
At the end of the series this doc line hasn't changed. There, close() and
the open() error path call ibmveth_free_buffer_pools() separately before
this helper. So the helper doesn't seem meant to free the pools.
Could the comment be narrowed to describe the buffer lists and RX rings it
actually frees? The name could also be changed to match its allocator,
ibmveth_alloc_rx_queues().
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119000711.18093-1-mmc%40linux.ibm.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 3/8] ibmveth: Refactor buffer pool management for per-queue MQ RX
2026-11-19 0:07 [PATCH net-next 0/8] ibmveth: prepare the RX path for multi-queue Mingming Cao
2026-11-19 0:07 ` [PATCH net-next 1/8] ibmveth: Prepare MQ RX adapter data structures Mingming Cao
2026-11-19 0:07 ` [PATCH net-next 2/8] ibmveth: Refactor RX resource allocation for MQ RX bring-up Mingming Cao
@ 2026-11-19 0:07 ` Mingming Cao
2026-11-19 0:07 ` [PATCH net-next 4/8] ibmveth: Refactor RX interrupt control for MQ RX queues Mingming Cao
` (4 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Mingming Cao @ 2026-11-19 0:07 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
PHYP returns an RX buffer on the queue it was posted to, so each RX
queue needs its own buffer pools. Allocate and free the pools per
queue through ibmveth_alloc_buffer_pools() and
ibmveth_free_buffer_pools().
The free path now releases what was allocated rather than what is
marked active. close() frees the pools before the RX queues and the
filter list; the IRQ and NAPI are gone by then.
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
Reviewed-by: Dave Marquardt <davemarq@linux.ibm.com>
Tested-by: Shaik Abdulla <shaik.abdulla1@ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 119 ++++++++++++++++++++++++-----
1 file changed, 99 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 559c4d2d957b..20273240d8fe 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -658,6 +658,100 @@ static void ibmveth_rxq_no_skb(struct ibmveth_adapter *adapter,
schedule_work(&adapter->work);
}
+/**
+ * ibmveth_free_queue_buffer_pools - Free buffer pools for a single queue
+ * @adapter: ibmveth adapter structure
+ * @queue: queue index
+ *
+ * Frees every pool on @queue regardless of the active flag;
+ * ibmveth_free_buffer_pool() skips what was never allocated.
+ */
+static void ibmveth_free_queue_buffer_pools(struct ibmveth_adapter *adapter,
+ int queue)
+{
+ int i;
+
+ for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
+ ibmveth_free_buffer_pool(adapter,
+ &adapter->rx_buff_pool[queue][i]);
+}
+
+/**
+ * ibmveth_alloc_queue_buffer_pools - Allocate buffer pools for a single queue
+ * @adapter: ibmveth adapter structure
+ * @queue: queue index
+ *
+ * Allocates backing storage for each active pool on @queue.
+ *
+ * Return: 0 on success, -ENOMEM on failure
+ */
+static int ibmveth_alloc_queue_buffer_pools(struct ibmveth_adapter *adapter,
+ int queue)
+{
+ struct net_device *netdev = adapter->netdev;
+ int i;
+
+ for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
+ struct ibmveth_buff_pool *bpool =
+ &adapter->rx_buff_pool[queue][i];
+
+ if (!bpool->active)
+ continue;
+
+ if (ibmveth_alloc_buffer_pool(bpool)) {
+ netdev_err(netdev,
+ "queue %d pool %d alloc failed (size=%u count=%u)\n",
+ queue, i,
+ bpool->buff_size,
+ bpool->size);
+ bpool->active = 0;
+ /* Undo the pools this queue already allocated; the
+ * failed one freed its own partial allocation.
+ */
+ ibmveth_free_queue_buffer_pools(adapter, queue);
+ return -ENOMEM;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * ibmveth_alloc_buffer_pools - Allocate buffer pools for all queues
+ * @adapter: ibmveth adapter structure
+ *
+ * Return: 0 on success, -ENOMEM on failure
+ */
+static int
+ibmveth_alloc_buffer_pools(struct ibmveth_adapter *adapter)
+{
+ int q, rc;
+
+ for (q = 0; q < adapter->num_rx_queues; q++) {
+ rc = ibmveth_alloc_queue_buffer_pools(adapter, q);
+ if (rc) {
+ while (--q >= 0)
+ ibmveth_free_queue_buffer_pools(adapter, q);
+ return rc;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * ibmveth_free_buffer_pools - Free buffer pools for all queues
+ * @adapter: ibmveth adapter structure
+ */
+static void
+ibmveth_free_buffer_pools(struct ibmveth_adapter *adapter)
+{
+ int q;
+
+ for (q = 0; q < adapter->num_rx_queues; q++)
+ ibmveth_free_queue_buffer_pools(adapter, q);
+}
+
/**
* ibmveth_remove_buffer_from_pool - remove a buffer from a pool
* @adapter: adapter instance
@@ -887,16 +981,9 @@ static int ibmveth_open(struct net_device *netdev)
goto out_free_tx_ltb;
}
- for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++) {
- if (!adapter->rx_buff_pool[0][i].active)
- continue;
- if (ibmveth_alloc_buffer_pool(&adapter->rx_buff_pool[0][i])) {
- netdev_err(netdev, "unable to alloc pool\n");
- adapter->rx_buff_pool[0][i].active = 0;
- rc = -ENOMEM;
- goto out_free_buffer_pools;
- }
- }
+ rc = ibmveth_alloc_buffer_pools(adapter);
+ if (rc)
+ goto out_free_buffer_pools;
/* NAPI can run as soon as it is enabled, from netpoll during the
* direct close()/open() pairs or from a direct ibmveth_interrupt()
@@ -930,11 +1017,7 @@ static int ibmveth_open(struct net_device *netdev)
do {
lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
} while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY));
- while (--i >= 0) {
- if (adapter->rx_buff_pool[0][i].active)
- ibmveth_free_buffer_pool(adapter,
- &adapter->rx_buff_pool[0][i]);
- }
+ ibmveth_free_buffer_pools(adapter);
out_free_tx_ltb:
for (i = netdev->real_num_tx_queues - 1; i >= 0; i--)
ibmveth_free_tx_ltb(adapter, i);
@@ -985,14 +1068,10 @@ static int ibmveth_close(struct net_device *netdev)
ibmveth_update_rx_no_buffer(adapter);
+ ibmveth_free_buffer_pools(adapter);
ibmveth_cleanup_rx_resources(adapter);
ibmveth_free_filter_list(adapter);
- for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- if (adapter->rx_buff_pool[0][i].active)
- ibmveth_free_buffer_pool(adapter,
- &adapter->rx_buff_pool[0][i]);
-
for (i = 0; i < netdev->real_num_tx_queues; i++)
ibmveth_free_tx_ltb(adapter, i);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH net-next 4/8] ibmveth: Refactor RX interrupt control for MQ RX queues
2026-11-19 0:07 [PATCH net-next 0/8] ibmveth: prepare the RX path for multi-queue Mingming Cao
` (2 preceding siblings ...)
2026-11-19 0:07 ` [PATCH net-next 3/8] ibmveth: Refactor buffer pool management for per-queue MQ RX Mingming Cao
@ 2026-11-19 0:07 ` Mingming Cao
2026-11-23 1:06 ` netdev-bot+sashiko
2026-11-19 0:07 ` [PATCH net-next 5/8] ibmveth: Refactor TX resource allocation in open/close paths Mingming Cao
` (3 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Mingming Cao @ 2026-11-19 0:07 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Move IRQ and NAPI setup, teardown and PHYP masking into helpers that
take a queue index. The IRQ cookie is that queue's NAPI. The handler
and the process-context kicks (open, resume, pool sysfs) share
ibmveth_schedule_rx_queue(), which masks only when napi_schedule_prep()
succeeds, as the handler already did. The new queue_irq[] holds each
queue's Linux IRQ; queue 0 uses netdev->irq.
napi_enable() moves to after request_irq(), with PHYP still masked:
NAPI can run as soon as it is enabled, and poll is what unmasks.
Teardown waits for the poll tail and remasks before free_irq(),
because poll unmasks after napi_complete_done(). close() stops TX
before that teardown, and now frees the IRQ before H_FREE_LOGICAL_LAN
rather than after it; PHYP is masked by then. A failed h_vio_signal()
is logged, ratelimited, instead of WARN_ON().
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 217 ++++++++++++++++++++++-------
drivers/net/ethernet/ibm/ibmveth.h | 1 +
2 files changed, 169 insertions(+), 49 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 20273240d8fe..ab5df1794004 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -330,6 +330,150 @@ ibmveth_cleanup_rx_resources(struct ibmveth_adapter *adapter)
}
}
+/**
+ * ibmveth_toggle_irq - Mask or unmask one RX queue's interrupt in PHYP
+ * @adapter: ibmveth adapter structure
+ * @queue_index: RX queue index
+ * @enable: true to unmask, false to mask
+ *
+ * Return: 0 on success, -EIO on failure
+ */
+static int
+ibmveth_toggle_irq(struct ibmveth_adapter *adapter, int queue_index,
+ bool enable)
+{
+ const char *action = enable ? "enable" : "disable";
+ unsigned long h_rc;
+
+ h_rc = h_vio_signal(adapter->vdev->unit_address,
+ enable ? VIO_IRQ_ENABLE : VIO_IRQ_DISABLE);
+ if (h_rc) {
+ dev_err_ratelimited(&adapter->netdev->dev,
+ "Failed to %s IRQ for queue %d, rc=0x%lx\n",
+ action, queue_index, h_rc);
+ return -EIO;
+ }
+ return 0;
+}
+
+/**
+ * ibmveth_disable_irq - Disable interrupt for a specific queue
+ * @adapter: ibmveth adapter structure
+ * @queue_index: RX queue index
+ *
+ * Return: 0 on success, -EIO on failure
+ */
+static int
+ibmveth_disable_irq(struct ibmveth_adapter *adapter, int queue_index)
+{
+ return ibmveth_toggle_irq(adapter, queue_index, false);
+}
+
+/**
+ * ibmveth_enable_irq - Enable interrupt for a specific queue
+ * @adapter: ibmveth adapter structure
+ * @queue_index: RX queue index
+ *
+ * Return: 0 on success, -EIO on failure
+ */
+static int
+ibmveth_enable_irq(struct ibmveth_adapter *adapter, int queue_index)
+{
+ return ibmveth_toggle_irq(adapter, queue_index, true);
+}
+
+/**
+ * ibmveth_setup_rx_interrupts - Register IRQs and enable NAPI
+ * @adapter: ibmveth adapter structure
+ *
+ * Leaves the queues masked in PHYP; the caller kicks NAPI, and the first
+ * poll unmasks.
+ *
+ * Return: 0 on success, negative error code on failure
+ */
+static int
+ibmveth_setup_rx_interrupts(struct ibmveth_adapter *adapter)
+{
+ struct net_device *netdev = adapter->netdev;
+ int i, rc, num = adapter->num_rx_queues;
+
+ for (i = 0; i < num; i++) {
+ rc = request_irq(adapter->queue_irq[i], ibmveth_interrupt,
+ 0, netdev->name, &adapter->napi[i]);
+ if (rc) {
+ netdev_err(netdev,
+ "request_irq() failed for irq 0x%x queue %d: %d\n",
+ adapter->queue_irq[i], i, rc);
+ goto err_free_irqs;
+ }
+ }
+
+ for (i = 0; i < num; i++)
+ napi_enable(&adapter->napi[i]);
+
+ return 0;
+
+err_free_irqs:
+ while (--i >= 0)
+ free_irq(adapter->queue_irq[i], &adapter->napi[i]);
+ return rc;
+}
+
+/**
+ * ibmveth_cleanup_rx_interrupts - Mask PHYP IRQs, stop NAPI, and free IRQs
+ * @adapter: ibmveth adapter structure
+ *
+ * Mask, napi_disable, wait for the poll tail, remask, then free_irq.
+ * napi_disable() does not wait past napi_complete_done(), which can
+ * unmask.
+ */
+static void
+ibmveth_cleanup_rx_interrupts(struct ibmveth_adapter *adapter)
+{
+ int i;
+
+ for (i = 0; i < adapter->num_rx_queues; i++) {
+ ibmveth_disable_irq(adapter, i);
+ synchronize_irq(adapter->queue_irq[i]);
+ }
+
+ for (i = 0; i < adapter->num_rx_queues; i++)
+ napi_disable(&adapter->napi[i]);
+
+ synchronize_net();
+
+ for (i = 0; i < adapter->num_rx_queues; i++) {
+ ibmveth_disable_irq(adapter, i);
+ synchronize_irq(adapter->queue_irq[i]);
+ }
+
+ for (i = 0; i < adapter->num_rx_queues; i++)
+ free_irq(adapter->queue_irq[i], &adapter->napi[i]);
+}
+
+/**
+ * ibmveth_schedule_rx_queue - Mask PHYP IRQ and schedule NAPI for one RX queue
+ * @adapter: ibmveth adapter structure
+ * @qindex: RX queue index
+ *
+ * Shared by the IRQ handler and process-context kick sites (open, resume,
+ * pool sysfs).
+ *
+ * Does nothing if napi_schedule_prep() fails (NAPI already scheduled,
+ * or disabled because the device is closed). A failed
+ * ibmveth_disable_irq() is logged and the queue may stay unmasked.
+ */
+static void ibmveth_schedule_rx_queue(struct ibmveth_adapter *adapter,
+ int qindex)
+{
+ struct napi_struct *napi = &adapter->napi[qindex];
+
+ if (napi_schedule_prep(napi)) {
+ ibmveth_disable_irq(adapter, qindex);
+ __napi_schedule(napi);
+ }
+}
+
/* setup the initial settings for a buffer pool */
static void ibmveth_init_buffer_pool(struct ibmveth_buff_pool *pool,
u32 pool_index, u32 pool_size,
@@ -964,7 +1108,8 @@ static int ibmveth_open(struct net_device *netdev)
adapter->rx_queue[0].queue_len;
rxq_desc.fields.address = adapter->rx_queue[0].queue_dma;
- h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
+ adapter->queue_irq[0] = netdev->irq;
+ ibmveth_disable_irq(adapter, 0);
lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
@@ -985,26 +1130,16 @@ static int ibmveth_open(struct net_device *netdev)
if (rc)
goto out_free_buffer_pools;
- /* NAPI can run as soon as it is enabled, from netpoll during the
- * direct close()/open() pairs or from a direct ibmveth_interrupt()
- * call, so enable it only once everything ibmveth_poll() touches
- * exists.
+ /* Enables NAPI, so everything ibmveth_poll() touches must exist:
+ * netpoll during the direct close()/open() pairs, or a direct
+ * kick, can run it as soon as it is enabled.
*/
- napi_enable(&adapter->napi[0]);
-
- netdev_dbg(netdev, "registering irq 0x%x\n", netdev->irq);
- rc = request_irq(netdev->irq, ibmveth_interrupt, 0, netdev->name,
- netdev);
- if (rc != 0) {
- napi_disable(&adapter->napi[0]);
- synchronize_net();
- netdev_err(netdev, "unable to request irq 0x%x, rc %d\n",
- netdev->irq, rc);
+ rc = ibmveth_setup_rx_interrupts(adapter);
+ if (rc)
goto out_free_buffer_pools;
- }
netdev_dbg(netdev, "initial replenish cycle\n");
- ibmveth_interrupt(netdev->irq, netdev);
+ ibmveth_schedule_rx_queue(adapter, 0);
netif_tx_start_all_queues(netdev);
@@ -1044,30 +1179,19 @@ static int ibmveth_close(struct net_device *netdev)
netdev_dbg(netdev, "close starting\n");
- napi_disable(&adapter->napi[0]);
- /* napi_disable() returns once ibmveth_poll() has called
- * napi_complete_done(), but the poll still re-enables the
- * interrupt and reads the RX queue after that.
- */
- synchronize_net();
-
netif_tx_disable(netdev);
- h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
+ ibmveth_cleanup_rx_interrupts(adapter);
do {
lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
} while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY));
-
if (lpar_rc != H_SUCCESS) {
- netdev_err(netdev, "h_free_logical_lan failed with %lx, "
- "continuing with close\n", lpar_rc);
+ netdev_err(adapter->netdev,
+ "h_free_logical_lan failed with %lx, continuing\n",
+ lpar_rc);
}
-
- free_irq(netdev->irq, netdev);
-
ibmveth_update_rx_no_buffer(adapter);
-
ibmveth_free_buffer_pools(adapter);
ibmveth_cleanup_rx_resources(adapter);
ibmveth_free_filter_list(adapter);
@@ -1754,7 +1878,6 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
container_of(napi, struct ibmveth_adapter, napi[0]);
struct net_device *netdev = adapter->netdev;
int frames_processed = 0;
- unsigned long lpar_rc;
u64 correlator;
u16 mss = 0;
int rc;
@@ -1902,18 +2025,17 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
/* We think we are done - reenable interrupts,
* then check once more to make sure we are done.
*/
- lpar_rc = h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_ENABLE);
- if (WARN_ON(lpar_rc != H_SUCCESS)) {
+ rc = ibmveth_enable_irq(adapter, 0);
+ if (rc) {
schedule_work(&adapter->work);
goto out;
}
- /* Mask before queueing, as ibmveth_interrupt() does: a threaded
+ /* Mask before queueing, as schedule_rx_queue() does: a threaded
* NAPI can start polling, and unmask, as soon as it is queued.
*/
if (ibmveth_rxq_pending_buffer(adapter) && napi_schedule_prep(napi)) {
- lpar_rc = h_vio_signal(adapter->vdev->unit_address,
- VIO_IRQ_DISABLE);
+ ibmveth_disable_irq(adapter, 0);
__napi_schedule(napi);
}
@@ -1923,16 +2045,11 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance)
{
- struct net_device *netdev = dev_instance;
+ struct napi_struct *napi = dev_instance;
+ struct net_device *netdev = napi->dev;
struct ibmveth_adapter *adapter = netdev_priv(netdev);
- unsigned long lpar_rc;
- if (napi_schedule_prep(&adapter->napi[0])) {
- lpar_rc = h_vio_signal(adapter->vdev->unit_address,
- VIO_IRQ_DISABLE);
- WARN_ON(lpar_rc != H_SUCCESS);
- __napi_schedule(&adapter->napi[0]);
- }
+ ibmveth_schedule_rx_queue(adapter, napi - adapter->napi);
return IRQ_HANDLED;
}
@@ -2474,8 +2591,8 @@ static ssize_t veth_pool_store(struct kobject *kobj, struct attribute *attr,
}
rtnl_unlock();
- /* kick the interrupt handler to allocate/deallocate pools */
- ibmveth_interrupt(netdev->irq, netdev);
+ /* kick RX processing to allocate/deallocate pools */
+ ibmveth_schedule_rx_queue(adapter, 0);
return count;
unlock_err:
@@ -2515,7 +2632,9 @@ static struct kobj_type ktype_veth_pool = {
static int ibmveth_resume(struct device *dev)
{
struct net_device *netdev = dev_get_drvdata(dev);
- ibmveth_interrupt(netdev->irq, netdev);
+ struct ibmveth_adapter *adapter = netdev_priv(netdev);
+
+ ibmveth_schedule_rx_queue(adapter, 0);
return 0;
}
diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h
index 4c74bd39d4e0..60a94f1d23bc 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -175,6 +175,7 @@ struct ibmveth_adapter {
struct ibmveth_buff_pool
rx_buff_pool[IBMVETH_MAX_RX_QUEUES][IBMVETH_NUM_BUFF_POOLS];
struct ibmveth_rx_q rx_queue[IBMVETH_MAX_RX_QUEUES];
+ unsigned int queue_irq[IBMVETH_MAX_RX_QUEUES];
unsigned int num_rx_queues;
int rx_csum;
int large_send;
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH net-next 4/8] ibmveth: Refactor RX interrupt control for MQ RX queues
2026-11-19 0:07 ` [PATCH net-next 4/8] ibmveth: Refactor RX interrupt control for MQ RX queues Mingming Cao
@ 2026-11-23 1:06 ` netdev-bot+sashiko
0 siblings, 0 replies; 15+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 1:06 UTC (permalink / raw)
To: mmc
Cc: netdev, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The kernel-doc for the new IRQ helpers promises a per-queue mask,
but the code always masks the whole adapter.
- [Low] The kernel-doc of ibmveth_setup_rx_interrupts() says it "Leaves
the queues masked in PHYP; the caller kicks NAPI, and the first poll…
- [Low] The comment added in ibmveth_poll() says "Mask before queueing,
as schedule_rx_queue() does", but no function by that name exists.
--
ibmveth: Refactor RX interrupt control for MQ RX queues
This moves ibmveth RX IRQ and NAPI setup, teardown and PHYP masking into
helpers that take a queue index, and uses the queue's NAPI as the IRQ
cookie. It adds queue_irq[] and moves napi_enable() after request_irq().
In close(), the IRQ is now freed before H_FREE_LOGICAL_LAN.
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index 20273240d8fea..ab5df17940042 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
> @@ -330,6 +330,150 @@ ibmveth_cleanup_rx_resources(struct ibmveth_adapter *adapter)
> }
> }
>
> +/**
> + * ibmveth_toggle_irq - Mask or unmask one RX queue's interrupt in PHYP
> + * @adapter: ibmveth adapter structure
> + * @queue_index: RX queue index
> + * @enable: true to unmask, false to mask
> + *
> + * Return: 0 on success, -EIO on failure
> + */
> +static int
> +ibmveth_toggle_irq(struct ibmveth_adapter *adapter, int queue_index,
> + bool enable)
> +{
> + const char *action = enable ? "enable" : "disable";
> + unsigned long h_rc;
> +
> + h_rc = h_vio_signal(adapter->vdev->unit_address,
> + enable ? VIO_IRQ_ENABLE : VIO_IRQ_DISABLE);
[Severity: Low]
The kernel-doc says this masks "one RX queue's interrupt". The
ibmveth_disable_irq() and ibmveth_enable_irq() wrappers and
ibmveth_schedule_rx_queue() also describe a per-queue mask. Is that
accurate?
h_vio_signal() takes only the unit address and a mode:
arch/powerpc/include/asm/vio.h:
#define h_vio_signal(ua, mode) \
plpar_hcall_norets(H_VIO_SIGNAL, ua, mode)
So queue_index only reaches the dev_err_ratelimited() message, and every
call masks or unmasks the whole adapter.
With num_rx_queues > 1, the per-queue loops in
ibmveth_cleanup_rx_interrupts() would send the same adapter-wide hcall
once per queue. The unmask in ibmveth_poll() after napi_complete_done():
rc = ibmveth_enable_irq(adapter, 0);
would also re-arm the interrupt for queues whose NAPI is still scheduled.
Also, only queue_irq[0] gets set (in ibmveth_open()), but
ibmveth_setup_rx_interrupts() and ibmveth_cleanup_rx_interrupts() loop
over num_rx_queues.
IBMVETH_MAX_RX_QUEUES and IBMVETH_DEFAULT_RX_QUEUES are still 1U here and
at the end of the series, so nothing changes at runtime today.
Could the kernel-doc say the mask is adapter-wide? Or would real
multi-queue masking need a different firmware mechanism, such as the
per sub-CRQ H_VIOCTL control that ibmvnic uses?
> + if (h_rc) {
> + dev_err_ratelimited(&adapter->netdev->dev,
> + "Failed to %s IRQ for queue %d, rc=0x%lx\n",
> + action, queue_index, h_rc);
> + return -EIO;
> + }
> + return 0;
> +}
[ ... ]
> +/**
> + * ibmveth_setup_rx_interrupts - Register IRQs and enable NAPI
> + * @adapter: ibmveth adapter structure
> + *
> + * Leaves the queues masked in PHYP; the caller kicks NAPI, and the first
> + * poll unmasks.
> + *
> + * Return: 0 on success, negative error code on failure
> + */
> +static int
> +ibmveth_setup_rx_interrupts(struct ibmveth_adapter *adapter)
> +{
> + struct net_device *netdev = adapter->netdev;
> + int i, rc, num = adapter->num_rx_queues;
> +
> + for (i = 0; i < num; i++) {
> + rc = request_irq(adapter->queue_irq[i], ibmveth_interrupt,
> + 0, netdev->name, &adapter->napi[i]);
> + if (rc) {
[ ... ]
> + }
> +
> + for (i = 0; i < num; i++)
> + napi_enable(&adapter->napi[i]);
[Severity: Low]
Both this kernel-doc and the commit message ("napi_enable() moves to after
request_irq(), with PHYP still masked") say the queues are left masked.
The function itself only calls request_irq() and napi_enable(). Does it
depend on a precondition that the caller has to provide but that is not
documented?
The only mask is the earlier one in ibmveth_open(). Its return value is
ignored, and H_REGISTER_LOGICAL_LAN runs after it. On the kexec retry
path, H_FREE_LOGICAL_LAN and a second register also run:
ibmveth_open() {
...
adapter->queue_irq[0] = netdev->irq;
ibmveth_disable_irq(adapter, 0);
lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
...
}
Suppose that hcall failed, or PHYP is unmasked again by the time
request_irq() runs. An interrupt arriving before napi_enable() would go
through:
ibmveth_interrupt()
ibmveth_schedule_rx_queue()
napi_schedule_prep() fails because NAPI is still disabled
and return IRQ_HANDLED without masking. The queue would stay unmasked
until the later ibmveth_schedule_rx_queue(adapter, 0) kick in
ibmveth_open().
In the old order, napi_enable() ran before request_irq(), so the first
interrupt masked PHYP itself. I couldn't tell from the code whether PHYP
can reset the interrupt mode during register/free, so this may only be a
documentation issue.
Should the precondition be documented? Alternatively, could
ibmveth_setup_rx_interrupts() do the mask itself and check the result?
[ ... ]
> @@ -1902,18 +2025,17 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
> /* We think we are done - reenable interrupts,
> * then check once more to make sure we are done.
> */
> - lpar_rc = h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_ENABLE);
> - if (WARN_ON(lpar_rc != H_SUCCESS)) {
> + rc = ibmveth_enable_irq(adapter, 0);
> + if (rc) {
> schedule_work(&adapter->work);
> goto out;
> }
>
> - /* Mask before queueing, as ibmveth_interrupt() does: a threaded
> + /* Mask before queueing, as schedule_rx_queue() does: a threaded
> * NAPI can start polling, and unmask, as soon as it is queued.
> */
[Severity: Low]
This isn't a bug, but the comment names schedule_rx_queue(), and there is
no function with that name. Should it be ibmveth_schedule_rx_queue()?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119000711.18093-1-mmc%40linux.ibm.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 5/8] ibmveth: Refactor TX resource allocation in open/close paths
2026-11-19 0:07 [PATCH net-next 0/8] ibmveth: prepare the RX path for multi-queue Mingming Cao
` (3 preceding siblings ...)
2026-11-19 0:07 ` [PATCH net-next 4/8] ibmveth: Refactor RX interrupt control for MQ RX queues Mingming Cao
@ 2026-11-19 0:07 ` Mingming Cao
2026-11-23 1:06 ` netdev-bot+sashiko
2026-11-19 0:07 ` [PATCH net-next 6/8] ibmveth: Add RX queue register helpers for MQ Mingming Cao
` (2 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Mingming Cao @ 2026-11-19 0:07 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Move TX LTB allocation and free out of open() and close() into
ibmveth_alloc_tx_resources() and ibmveth_free_tx_resources(), like
the RX helpers.
open() now allocates the TX LTBs last, after RX is running. It stops
TX with netif_tx_disable() first: on a first open the queues are not
DRV_XOFF, so generic XDP_TX could transmit before the LTBs exist. It
starts TX under netif_tx_lock_bh() once they do. A TX allocation
failure unwinds RX the way close() does.
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 82 +++++++++++++++++++++++-------
1 file changed, 65 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index ab5df1794004..8f32f75f2d7f 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1046,6 +1046,48 @@ static int ibmveth_allocate_tx_ltb(struct ibmveth_adapter *adapter, int idx)
return 0;
}
+/**
+ * ibmveth_alloc_tx_resources - Allocate TX LTBs for real_num_tx_queues
+ * @adapter: ibmveth adapter structure
+ *
+ * Allocate a TX long-term buffer for each live TX queue. On a
+ * partial failure this helper already frees what it allocated.
+ *
+ * Return: 0 on success, -ENOMEM on failure
+ */
+static int ibmveth_alloc_tx_resources(struct ibmveth_adapter *adapter)
+{
+ struct net_device *netdev = adapter->netdev;
+ int i;
+
+ for (i = 0; i < netdev->real_num_tx_queues; i++) {
+ if (ibmveth_allocate_tx_ltb(adapter, i))
+ goto err_free_ltbs;
+ }
+
+ return 0;
+
+err_free_ltbs:
+ while (--i >= 0)
+ ibmveth_free_tx_ltb(adapter, i);
+ return -ENOMEM;
+}
+
+/**
+ * ibmveth_free_tx_resources - Free TX LTBs for real_num_tx_queues
+ * @adapter: ibmveth adapter structure
+ *
+ * Free the TX long-term buffers for each live TX queue.
+ */
+static void ibmveth_free_tx_resources(struct ibmveth_adapter *adapter)
+{
+ struct net_device *netdev = adapter->netdev;
+ int i;
+
+ for (i = 0; i < netdev->real_num_tx_queues; i++)
+ ibmveth_free_tx_ltb(adapter, i);
+}
+
static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
union ibmveth_buf_desc rxq_desc, u64 mac_address)
{
@@ -1085,6 +1127,11 @@ static int ibmveth_open(struct net_device *netdev)
netdev_dbg(netdev, "open starting\n");
+ /* Stop TX first. First-open queues are not DRV_XOFF, so generic
+ * XDP_TX could run once NAPI is up and before the LTBs exist.
+ */
+ netif_tx_disable(netdev);
+
for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
rxq_entries += adapter->rx_buff_pool[0][i].size;
@@ -1096,12 +1143,6 @@ static int ibmveth_open(struct net_device *netdev)
if (rc)
goto out_free_filter_list;
- rc = -ENOMEM;
- for (i = 0; i < netdev->real_num_tx_queues; i++) {
- if (ibmveth_allocate_tx_ltb(adapter, i))
- goto out_free_tx_ltb;
- }
-
mac_address = ether_addr_to_u64(netdev->dev_addr);
rxq_desc.fields.flags_len = IBMVETH_BUF_VALID |
@@ -1123,12 +1164,12 @@ static int ibmveth_open(struct net_device *netdev)
rxq_desc.desc,
mac_address);
rc = -ENONET;
- goto out_free_tx_ltb;
+ goto out_free_queue_mem;
}
rc = ibmveth_alloc_buffer_pools(adapter);
if (rc)
- goto out_free_buffer_pools;
+ goto out_unregister_lan;
/* Enables NAPI, so everything ibmveth_poll() touches must exist:
* netpoll during the direct close()/open() pairs, or a direct
@@ -1136,26 +1177,35 @@ static int ibmveth_open(struct net_device *netdev)
*/
rc = ibmveth_setup_rx_interrupts(adapter);
if (rc)
- goto out_free_buffer_pools;
+ goto out_unregister_lan;
netdev_dbg(netdev, "initial replenish cycle\n");
ibmveth_schedule_rx_queue(adapter, 0);
+ rc = ibmveth_alloc_tx_resources(adapter);
+ if (rc)
+ goto out_cleanup_rx_interrupts;
+
+ /* Start under the xmit lock so a sender that tests DRV_XOFF
+ * there sees the LTBs this open just published.
+ */
+ netif_tx_lock_bh(netdev);
netif_tx_start_all_queues(netdev);
+ netif_tx_unlock_bh(netdev);
adapter->opened = true;
netdev_dbg(netdev, "open complete\n");
return 0;
-out_free_buffer_pools:
+out_cleanup_rx_interrupts:
+ ibmveth_cleanup_rx_interrupts(adapter);
+out_unregister_lan:
do {
lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
} while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY));
ibmveth_free_buffer_pools(adapter);
-out_free_tx_ltb:
- for (i = netdev->real_num_tx_queues - 1; i >= 0; i--)
- ibmveth_free_tx_ltb(adapter, i);
+out_free_queue_mem:
ibmveth_cleanup_rx_resources(adapter);
out_free_filter_list:
ibmveth_free_filter_list(adapter);
@@ -1167,7 +1217,6 @@ static int ibmveth_close(struct net_device *netdev)
{
struct ibmveth_adapter *adapter = netdev_priv(netdev);
long lpar_rc;
- int i;
/* change_mtu, pool sysfs, set_csum and set_tso call close() and
* open() directly. If that open() fails, IFF_UP stays set and
@@ -1192,13 +1241,12 @@ static int ibmveth_close(struct net_device *netdev)
lpar_rc);
}
ibmveth_update_rx_no_buffer(adapter);
+ /* netif_tx_disable() above keeps xmit off the TX LTBs. */
+ ibmveth_free_tx_resources(adapter);
ibmveth_free_buffer_pools(adapter);
ibmveth_cleanup_rx_resources(adapter);
ibmveth_free_filter_list(adapter);
- for (i = 0; i < netdev->real_num_tx_queues; i++)
- ibmveth_free_tx_ltb(adapter, i);
-
netdev_dbg(netdev, "close complete\n");
return 0;
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH net-next 5/8] ibmveth: Refactor TX resource allocation in open/close paths
2026-11-19 0:07 ` [PATCH net-next 5/8] ibmveth: Refactor TX resource allocation in open/close paths Mingming Cao
@ 2026-11-23 1:06 ` netdev-bot+sashiko
0 siblings, 0 replies; 15+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 1:06 UTC (permalink / raw)
To: mmc
Cc: netdev, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In ibmveth_open() (drivers/net/ethernet/ibm/ibmveth.c), this
patch moves the TX long-term-buffer DMA mapping…
- [Low] The commit is titled and framed as a refactor ("Move TX LTB
allocation and free ... into ibmveth_alloc_tx_resources() and…
--
ibmveth: Refactor TX resource allocation in open/close paths
This moves TX long-term buffer allocation and free into the new helpers
ibmveth_alloc_tx_resources() and ibmveth_free_tx_resources(). It also
moves the TX LTB allocation in ibmveth_open() to after RX and NAPI are
running. To cover that, it adds netif_tx_disable() at the start of open()
and starts the queues under netif_tx_lock_bh().
> open() now allocates the TX LTBs last, after RX is running. It stops
> TX with netif_tx_disable() first: on a first open the queues are not
> DRV_XOFF, so generic XDP_TX could transmit before the LTBs exist. It
> starts TX under netif_tx_lock_bh() once they do. A TX allocation
> failure unwinds RX the way close() does.
[Severity: Low]
This isn't a bug, but could the commit message say why the reorder is
needed?
The subject and first paragraph present this as a refactor into helpers.
The patch also changes the bring-up order of ibmveth_open(). Before this
patch, the TX LTBs were allocated right after ibmveth_alloc_rx_queues().
That was before h_register_logical_lan() and before NAPI was enabled.
Three of the changes are only needed because of the new order:
- the new netif_tx_disable() at the top of open()
- the netif_tx_lock_bh() around netif_tx_start_all_queues()
- unwinding the whole RX bring-up when the TX allocation fails
The window that the netif_tx_disable() comment describes ("once NAPI is
up and before the LTBs exist") did not exist before this patch.
Would the ordering change fit better in its own patch with a stated
reason, separate from the helper refactor?
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index ab5df17940042..8f32f75f2d7fd 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
[ ... ]
> @@ -1096,12 +1143,6 @@ static int ibmveth_open(struct net_device *netdev)
> if (rc)
> goto out_free_filter_list;
>
> - rc = -ENOMEM;
> - for (i = 0; i < netdev->real_num_tx_queues; i++) {
> - if (ibmveth_allocate_tx_ltb(adapter, i))
> - goto out_free_tx_ltb;
> - }
> -
> mac_address = ether_addr_to_u64(netdev->dev_addr);
>
> rxq_desc.fields.flags_len = IBMVETH_BUF_VALID |
[ ... ]
> @@ -1136,26 +1177,35 @@ static int ibmveth_open(struct net_device *netdev)
> */
> rc = ibmveth_setup_rx_interrupts(adapter);
> if (rc)
> - goto out_free_buffer_pools;
> + goto out_unregister_lan;
>
> netdev_dbg(netdev, "initial replenish cycle\n");
> ibmveth_schedule_rx_queue(adapter, 0);
>
> + rc = ibmveth_alloc_tx_resources(adapter);
> + if (rc)
> + goto out_cleanup_rx_interrupts;
[Severity: Medium]
With the new order, can open() fail on CMO partitions where the old order
worked?
With FW_FEATURE_CMO, every VIO DMA mapping draws on the device's IO
entitlement through vio_dma_iommu_map_phys()->vio_cmo_alloc(). That call
returns -ENOMEM when the free reserve plus the excess pool is smaller than
the request.
By the time ibmveth_alloc_tx_resources() runs, NAPI is enabled and
ibmveth_schedule_rx_queue(adapter, 0) has scheduled the first replenish.
The replenish runs in NET_RX softirq, either in ksoftirqd or at the next
IRQ exit. It can map and post every RX pool buffer before or while the TX
LTBs are mapped:
ibmveth_open()
ibmveth_setup_rx_interrupts()
ibmveth_schedule_rx_queue()
__napi_schedule()
ibmveth_poll()
ibmveth_replenish_task()
dma_map_single() <- per RX buffer, uses entitlement
ibmveth_alloc_tx_resources()
ibmveth_allocate_tx_ltb()
dma_map_single() <- can now return DMA_MAPPING_ERROR
The two failures are handled differently. An RX mapping failure in
ibmveth_replenish_buffer_pool() bumps replenish_add_buff_failure and
breaks out of the loop.
A TX LTB mapping failure makes ibmveth_alloc_tx_resources() return
-ENOMEM. open() then tears down the IRQs, the logical LAN registration and
the RX pools, and the interface does not come up.
The direct close()/open() pairs (change_mtu, pool sysfs, set_csum and
set_tso) are affected too. There, IFF_UP stays set but the adapter is not
open.
Before this patch, the TX LTBs were mapped before any RX buffer went to
PHYP, so TX always got entitlement first.
ibmveth_get_desired_dma() seems to make this more likely:
drivers/net/ethernet/ibm/ibmveth.c:ibmveth_get_desired_dma() {
...
/* add size of mapped tx buffers */
ret += IOMMU_PAGE_ALIGN(IBMVETH_MAX_TX_BUF_SIZE, tbl);
...
}
This counts one 64K TX buffer, but open() maps one LTB per real TX queue.
The default is min(num_online_cpus(), 8) queues, so up to 512K. Once RX
has taken its share, is there any entitlement left for TX?
The order is the same at the end of the series. In "ibmveth: Split RX
poll into per-slot helpers for MQ", ibmveth_alloc_tx_resources() still
comes after ibmveth_schedule_rx_queue().
> +
> + /* Start under the xmit lock so a sender that tests DRV_XOFF
> + * there sees the LTBs this open just published.
> + */
> + netif_tx_lock_bh(netdev);
> netif_tx_start_all_queues(netdev);
> + netif_tx_unlock_bh(netdev);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119000711.18093-1-mmc%40linux.ibm.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 6/8] ibmveth: Add RX queue register helpers for MQ
2026-11-19 0:07 [PATCH net-next 0/8] ibmveth: prepare the RX path for multi-queue Mingming Cao
` (4 preceding siblings ...)
2026-11-19 0:07 ` [PATCH net-next 5/8] ibmveth: Refactor TX resource allocation in open/close paths Mingming Cao
@ 2026-11-19 0:07 ` Mingming Cao
2026-11-23 1:06 ` netdev-bot+sashiko
2026-11-19 0:07 ` [PATCH net-next 7/8] ibmveth: Pass the RX queue index through replenish and poll Mingming Cao
2026-11-19 0:07 ` [PATCH net-next 8/8] ibmveth: Split RX poll into per-slot helpers for MQ Mingming Cao
7 siblings, 1 reply; 15+ messages in thread
From: Mingming Cao @ 2026-11-19 0:07 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Move logical LAN registration and teardown out of open() and close()
into ibmveth_register_rx_queues() and ibmveth_free_all_queues(). The
three H_FREE_LOGICAL_LAN busy loops (kexec retry in register, pool
fail before register, close) share ibmveth_free_logical_lan().
open() now allocates the buffer pools before registering, so a pool
failure never has a LAN this kernel registered. A pool failure still
issues one H_FREE_LOGICAL_LAN, as before, so a kexec leftover is not
left registered.
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 154 ++++++++++++++++++++---------
1 file changed, 105 insertions(+), 49 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 8f32f75f2d7f..ab8c5f6a265b 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1088,10 +1088,34 @@ static void ibmveth_free_tx_resources(struct ibmveth_adapter *adapter)
ibmveth_free_tx_ltb(adapter, i);
}
-static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
- union ibmveth_buf_desc rxq_desc, u64 mac_address)
+/**
+ * ibmveth_free_logical_lan - Busy-retry H_FREE_LOGICAL_LAN
+ * @adapter: ibmveth adapter structure
+ *
+ * Retries while PHYP returns H_BUSY or a long-busy code.
+ *
+ * Return: the last hypervisor return code
+ */
+static long ibmveth_free_logical_lan(struct ibmveth_adapter *adapter)
{
- int rc, try_again = 1;
+ long rc;
+
+ do {
+ rc = h_free_logical_lan(adapter->vdev->unit_address);
+ } while (H_IS_LONG_BUSY(rc) || rc == H_BUSY);
+
+ return rc;
+}
+
+static long ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
+ union ibmveth_buf_desc rxq_desc,
+ u64 mac_address)
+{
+ long rc;
+ int try_again = 1;
+ unsigned long ua = adapter->vdev->unit_address;
+ unsigned long buf_dma = adapter->buffer_list_dma[0];
+ unsigned long filter_dma = adapter->filter_list_dma;
/*
* After a kexec the adapter will still be open, so our attempt to
@@ -1099,14 +1123,11 @@ static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
* try again, but only once.
*/
retry:
- rc = h_register_logical_lan(adapter->vdev->unit_address,
- adapter->buffer_list_dma[0], rxq_desc.desc,
- adapter->filter_list_dma, mac_address);
+ rc = h_register_logical_lan(ua, buf_dma, rxq_desc.desc, filter_dma,
+ mac_address);
if (rc != H_SUCCESS && try_again) {
- do {
- rc = h_free_logical_lan(adapter->vdev->unit_address);
- } while (H_IS_LONG_BUSY(rc) || (rc == H_BUSY));
+ rc = ibmveth_free_logical_lan(adapter);
try_again = 0;
goto retry;
@@ -1115,14 +1136,72 @@ static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
return rc;
}
+/**
+ * ibmveth_free_all_queues - Free all RX queues at once
+ * @adapter: ibmveth adapter structure
+ *
+ * Issues one H_FREE_LOGICAL_LAN. A failure is logged; the caller still
+ * frees the RX memory, as close() always has.
+ */
+static void ibmveth_free_all_queues(struct ibmveth_adapter *adapter)
+{
+ long lpar_rc;
+
+ lpar_rc = ibmveth_free_logical_lan(adapter);
+ if (lpar_rc != H_SUCCESS)
+ netdev_err(adapter->netdev,
+ "h_free_logical_lan failed: %ld\n", lpar_rc);
+}
+
+/**
+ * ibmveth_register_rx_queues - Register RX queues with hypervisor
+ * @adapter: ibmveth adapter structure
+ * @mac_address: MAC address for device registration
+ *
+ * Registers queue 0 with H_REGISTER_LOGICAL_LAN.
+ *
+ * Return: 0 on success, -ENONET if queue 0 registration fails
+ */
+static int
+ibmveth_register_rx_queues(struct ibmveth_adapter *adapter, u64 mac_address)
+{
+ struct net_device *netdev = adapter->netdev;
+ union ibmveth_buf_desc rxq_desc;
+ long lpar_rc;
+ int rc;
+
+ rxq_desc.fields.flags_len = IBMVETH_BUF_VALID |
+ adapter->rx_queue[0].queue_len;
+ rxq_desc.fields.address = adapter->rx_queue[0].queue_dma;
+ adapter->queue_irq[0] = netdev->irq;
+
+ rc = ibmveth_disable_irq(adapter, 0);
+ if (rc)
+ netdev_dbg(netdev,
+ "Failed to disable IRQ for queue 0 before registration, rc=%d\n",
+ rc);
+
+ lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
+ if (lpar_rc != H_SUCCESS) {
+ netdev_err(netdev,
+ "h_register_logical_lan failed: %ld\n", lpar_rc);
+ netdev_err(netdev,
+ "buffer TCE:0x%llx filter TCE:0x%llx rxq desc:0x%llx MAC:0x%llx\n",
+ adapter->buffer_list_dma[0],
+ adapter->filter_list_dma,
+ rxq_desc.desc, mac_address);
+ return -ENONET;
+ }
+
+ return 0;
+}
+
static int ibmveth_open(struct net_device *netdev)
{
struct ibmveth_adapter *adapter = netdev_priv(netdev);
- u64 mac_address;
+ u64 mac_address = ether_addr_to_u64(netdev->dev_addr);
int rxq_entries = 1;
- unsigned long lpar_rc;
int rc;
- union ibmveth_buf_desc rxq_desc;
int i;
netdev_dbg(netdev, "open starting\n");
@@ -1143,33 +1222,19 @@ static int ibmveth_open(struct net_device *netdev)
if (rc)
goto out_free_filter_list;
- mac_address = ether_addr_to_u64(netdev->dev_addr);
-
- rxq_desc.fields.flags_len = IBMVETH_BUF_VALID |
- adapter->rx_queue[0].queue_len;
- rxq_desc.fields.address = adapter->rx_queue[0].queue_dma;
-
- adapter->queue_irq[0] = netdev->irq;
- ibmveth_disable_irq(adapter, 0);
-
- lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
-
- if (lpar_rc != H_SUCCESS) {
- netdev_err(netdev, "h_register_logical_lan failed with %ld\n",
- lpar_rc);
- netdev_err(netdev, "buffer TCE:0x%llx filter TCE:0x%llx rxq "
- "desc:0x%llx MAC:0x%llx\n",
- adapter->buffer_list_dma[0],
- adapter->filter_list_dma,
- rxq_desc.desc,
- mac_address);
- rc = -ENONET;
+ rc = ibmveth_alloc_buffer_pools(adapter);
+ if (rc) {
+ /* A kexec can leave the LAN registered by the old kernel
+ * (see ibmveth_register_logical_lan()); do not leave its
+ * buffers live in PHYP.
+ */
+ ibmveth_free_logical_lan(adapter);
goto out_free_queue_mem;
}
- rc = ibmveth_alloc_buffer_pools(adapter);
+ rc = ibmveth_register_rx_queues(adapter, mac_address);
if (rc)
- goto out_unregister_lan;
+ goto out_free_buffer_pools;
/* Enables NAPI, so everything ibmveth_poll() touches must exist:
* netpoll during the direct close()/open() pairs, or a direct
@@ -1177,7 +1242,7 @@ static int ibmveth_open(struct net_device *netdev)
*/
rc = ibmveth_setup_rx_interrupts(adapter);
if (rc)
- goto out_unregister_lan;
+ goto out_free_all_queues;
netdev_dbg(netdev, "initial replenish cycle\n");
ibmveth_schedule_rx_queue(adapter, 0);
@@ -1200,10 +1265,9 @@ static int ibmveth_open(struct net_device *netdev)
out_cleanup_rx_interrupts:
ibmveth_cleanup_rx_interrupts(adapter);
-out_unregister_lan:
- do {
- lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
- } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY));
+out_free_all_queues:
+ ibmveth_free_all_queues(adapter);
+out_free_buffer_pools:
ibmveth_free_buffer_pools(adapter);
out_free_queue_mem:
ibmveth_cleanup_rx_resources(adapter);
@@ -1216,7 +1280,6 @@ static int ibmveth_open(struct net_device *netdev)
static int ibmveth_close(struct net_device *netdev)
{
struct ibmveth_adapter *adapter = netdev_priv(netdev);
- long lpar_rc;
/* change_mtu, pool sysfs, set_csum and set_tso call close() and
* open() directly. If that open() fails, IFF_UP stays set and
@@ -1232,14 +1295,7 @@ static int ibmveth_close(struct net_device *netdev)
ibmveth_cleanup_rx_interrupts(adapter);
- do {
- lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
- } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY));
- if (lpar_rc != H_SUCCESS) {
- netdev_err(adapter->netdev,
- "h_free_logical_lan failed with %lx, continuing\n",
- lpar_rc);
- }
+ ibmveth_free_all_queues(adapter);
ibmveth_update_rx_no_buffer(adapter);
/* netif_tx_disable() above keeps xmit off the TX LTBs. */
ibmveth_free_tx_resources(adapter);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH net-next 6/8] ibmveth: Add RX queue register helpers for MQ
2026-11-19 0:07 ` [PATCH net-next 6/8] ibmveth: Add RX queue register helpers for MQ Mingming Cao
@ 2026-11-23 1:06 ` netdev-bot+sashiko
0 siblings, 0 replies; 15+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 1:06 UTC (permalink / raw)
To: mmc
Cc: netdev, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message presents this patch as moving existing code
into helpers and changing the order of open().
--
ibmveth: Add RX queue register helpers for MQ
This moves logical LAN registration and teardown out of ibmveth_open() and
ibmveth_close() into the new helpers ibmveth_register_rx_queues() and
ibmveth_free_all_queues(). The H_FREE_LOGICAL_LAN busy loops now share
ibmveth_free_logical_lan(). open() also allocates the buffer pools before
registering the LAN.
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index 8f32f75f2d7fd..ab8c5f6a265b4 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
[ ... ]
> +static long ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
> + union ibmveth_buf_desc rxq_desc,
> + u64 mac_address)
> +{
> + long rc;
> + int try_again = 1;
> + unsigned long ua = adapter->vdev->unit_address;
> + unsigned long buf_dma = adapter->buffer_list_dma[0];
> + unsigned long filter_dma = adapter->filter_list_dma;
[ ... ]
> +static void ibmveth_free_all_queues(struct ibmveth_adapter *adapter)
> +{
> + long lpar_rc;
> +
> + lpar_rc = ibmveth_free_logical_lan(adapter);
> + if (lpar_rc != H_SUCCESS)
> + netdev_err(adapter->netdev,
> + "h_free_logical_lan failed: %ld\n", lpar_rc);
> +}
[ ... ]
> + rc = ibmveth_disable_irq(adapter, 0);
> + if (rc)
> + netdev_dbg(netdev,
> + "Failed to disable IRQ for queue 0 before registration, rc=%d\n",
> + rc);
[Severity: Low]
This isn't a bug, but the commit message describes the patch as moving code
into helpers and reordering open(). The patch also changes some logging that
the message doesn't mention.
In ibmveth_close(), the old message was:
"h_free_logical_lan failed with %lx, continuing\n"
ibmveth_free_all_queues() now prints it in decimal with new wording:
"h_free_logical_lan failed: %ld\n"
Anything that greps logs for the old string will no longer match.
The open() error path after a successful registration (a failure in
ibmveth_setup_rx_interrupts() or ibmveth_alloc_tx_resources()) used to free
the LAN without logging anything. It now goes through
ibmveth_free_all_queues(), so it calls netdev_err() if H_FREE_LOGICAL_LAN
fails.
The new netdev_dbg() above also seems to repeat a message that
ibmveth_toggle_irq() already prints before it returns -EIO:
dev_err_ratelimited(&adapter->netdev->dev,
"Failed to %s IRQ for queue %d, rc=0x%lx\n",
action, queue_index, h_rc);
The old code ignored the return value of ibmveth_disable_irq(). Is the extra
debug message needed?
Two other changes are unrelated to the move: ibmveth_register_logical_lan()
now returns long instead of int, and the adapter fields are copied into
local variables.
Could these changes either go in a separate patch or be mentioned in the
commit message?
> +
> + lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
[ ... ]
> @@ -1232,14 +1295,7 @@ static int ibmveth_close(struct net_device *netdev)
>
> ibmveth_cleanup_rx_interrupts(adapter);
>
> - do {
> - lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
> - } while (H_IS_LONG_BUSY(lpar_rc) || (lpar_rc == H_BUSY));
> - if (lpar_rc != H_SUCCESS) {
> - netdev_err(adapter->netdev,
> - "h_free_logical_lan failed with %lx, continuing\n",
> - lpar_rc);
> - }
> + ibmveth_free_all_queues(adapter);
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119000711.18093-1-mmc%40linux.ibm.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 7/8] ibmveth: Pass the RX queue index through replenish and poll
2026-11-19 0:07 [PATCH net-next 0/8] ibmveth: prepare the RX path for multi-queue Mingming Cao
` (5 preceding siblings ...)
2026-11-19 0:07 ` [PATCH net-next 6/8] ibmveth: Add RX queue register helpers for MQ Mingming Cao
@ 2026-11-19 0:07 ` Mingming Cao
2026-11-23 1:06 ` netdev-bot+sashiko
2026-11-19 0:07 ` [PATCH net-next 8/8] ibmveth: Split RX poll into per-slot helpers for MQ Mingming Cao
7 siblings, 1 reply; 15+ messages in thread
From: Mingming Cao @ 2026-11-19 0:07 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
The rxq_* accessors, buffer lookup, harvest and replenish still
hardcode queue 0. Give them a queue index, and have ibmveth_poll()
derive it from its NAPI instance.
Only queue 0 is used, so there is no behavior change.
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 214 +++++++++++++++++------------
1 file changed, 129 insertions(+), 85 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index ab8c5f6a265b..a40d9a6abf51 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -99,57 +99,67 @@ static struct ibmveth_stat ibmveth_stats[] = {
};
/* simple methods of getting data from the current rxq entry */
-static inline u32 ibmveth_rxq_flags(struct ibmveth_adapter *adapter)
+static u32 ibmveth_rxq_flags(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- struct ibmveth_rx_q *rxq = &adapter->rx_queue[0];
+ struct ibmveth_rx_q *rxq = &adapter->rx_queue[queue_index];
return be32_to_cpu(rxq->queue_addr[rxq->index].flags_off);
}
-static inline int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter)
+static int ibmveth_rxq_toggle(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- return (ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_TOGGLE) >>
- IBMVETH_RXQ_TOGGLE_SHIFT;
+ return (ibmveth_rxq_flags(adapter, queue_index) & IBMVETH_RXQ_TOGGLE) >>
+ IBMVETH_RXQ_TOGGLE_SHIFT;
}
-static inline int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter)
+static int ibmveth_rxq_pending_buffer(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- return ibmveth_rxq_toggle(adapter) == adapter->rx_queue[0].toggle;
+ return ibmveth_rxq_toggle(adapter, queue_index) ==
+ adapter->rx_queue[queue_index].toggle;
}
-static inline int ibmveth_rxq_buffer_valid(struct ibmveth_adapter *adapter)
+static int ibmveth_rxq_buffer_valid(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_VALID;
+ return ibmveth_rxq_flags(adapter, queue_index) & IBMVETH_RXQ_VALID;
}
-static inline int ibmveth_rxq_frame_offset(struct ibmveth_adapter *adapter)
+static int ibmveth_rxq_frame_offset(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_OFF_MASK;
+ return ibmveth_rxq_flags(adapter, queue_index) & IBMVETH_RXQ_OFF_MASK;
}
-static inline int ibmveth_rxq_large_packet(struct ibmveth_adapter *adapter)
+static int ibmveth_rxq_large_packet(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_LRG_PKT;
+ return ibmveth_rxq_flags(adapter, queue_index) & IBMVETH_RXQ_LRG_PKT;
}
-static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter)
+static int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- struct ibmveth_rx_q *rxq = &adapter->rx_queue[0];
+ struct ibmveth_rx_q *rxq = &adapter->rx_queue[queue_index];
return be32_to_cpu(rxq->queue_addr[rxq->index].length);
}
-static u64 ibmveth_rxq_correlator(struct ibmveth_adapter *adapter)
+static u64 ibmveth_rxq_correlator(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- struct ibmveth_rx_q *rxq = &adapter->rx_queue[0];
+ struct ibmveth_rx_q *rxq = &adapter->rx_queue[queue_index];
unsigned int idx = rxq->index;
return READ_ONCE(rxq->queue_addr[idx].correlator);
}
-static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter)
+static int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_CSUM_GOOD;
+ return ibmveth_rxq_flags(adapter, queue_index) & IBMVETH_RXQ_CSUM_GOOD;
}
static unsigned int ibmveth_real_max_tx_queues(void)
@@ -720,14 +730,16 @@ static void ibmveth_update_rx_no_buffer(struct ibmveth_adapter *adapter)
}
/* replenish routine */
-static void ibmveth_replenish_task(struct ibmveth_adapter *adapter)
+static void ibmveth_replenish_task(struct ibmveth_adapter *adapter,
+ int queue_index)
{
int i;
adapter->replenish_task_cycles++;
for (i = (IBMVETH_NUM_BUFF_POOLS - 1); i >= 0; i--) {
- struct ibmveth_buff_pool *pool = &adapter->rx_buff_pool[0][i];
+ struct ibmveth_buff_pool *pool =
+ &adapter->rx_buff_pool[queue_index][i];
if (pool->active &&
(atomic_read(&pool->available) < pool->threshold))
@@ -773,15 +785,15 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter,
/* The correlator comes back from PHYP; a bad one schedules a reset. */
static bool ibmveth_rxq_correlator_valid(struct ibmveth_adapter *adapter,
- u64 correlator)
+ int queue_index, u64 correlator)
{
unsigned int index = correlator & 0xffffffffUL;
unsigned int pool = correlator >> 32;
/* An inactive pool keeps its size but has no skbuff array. */
if (pool < IBMVETH_NUM_BUFF_POOLS &&
- index < adapter->rx_buff_pool[0][pool].size &&
- adapter->rx_buff_pool[0][pool].skbuff)
+ index < adapter->rx_buff_pool[queue_index][pool].size &&
+ adapter->rx_buff_pool[queue_index][pool].skbuff)
return true;
if (net_ratelimit())
@@ -900,6 +912,7 @@ ibmveth_free_buffer_pools(struct ibmveth_adapter *adapter)
* ibmveth_remove_buffer_from_pool - remove a buffer from a pool
* @adapter: adapter instance
* @correlator: identifies pool and index
+ * @queue_index: RX queue index
* @reuse: whether to reuse buffer
*
* Return:
@@ -909,17 +922,20 @@ ibmveth_free_buffer_pools(struct ibmveth_adapter *adapter)
* * %-EFAULT - pool and index map to null skb
*/
static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,
- u64 correlator, bool reuse)
+ u64 correlator, int queue_index,
+ bool reuse)
{
unsigned int pool = correlator >> 32;
unsigned int index = correlator & 0xffffffffUL;
+ struct ibmveth_buff_pool *bpool;
unsigned int free_index;
struct sk_buff *skb;
- if (!ibmveth_rxq_correlator_valid(adapter, correlator))
+ if (!ibmveth_rxq_correlator_valid(adapter, queue_index, correlator))
return -EINVAL;
- skb = adapter->rx_buff_pool[0][pool].skbuff[index];
+ bpool = &adapter->rx_buff_pool[queue_index][pool];
+ skb = bpool->skbuff[index];
if (!skb) {
ibmveth_rxq_no_skb(adapter, correlator);
return -EFAULT;
@@ -933,48 +949,48 @@ static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,
/* remove the skb pointer to mark free. actual freeing is done
* by upper level networking after gro_receive
*/
- adapter->rx_buff_pool[0][pool].skbuff[index] = NULL;
+ bpool->skbuff[index] = NULL;
dma_unmap_single(&adapter->vdev->dev,
- adapter->rx_buff_pool[0][pool].dma_addr[index],
- adapter->rx_buff_pool[0][pool].buff_size,
+ bpool->dma_addr[index],
+ bpool->buff_size,
DMA_FROM_DEVICE);
}
- free_index = adapter->rx_buff_pool[0][pool].producer_index;
- adapter->rx_buff_pool[0][pool].producer_index++;
- if (adapter->rx_buff_pool[0][pool].producer_index >=
- adapter->rx_buff_pool[0][pool].size)
- adapter->rx_buff_pool[0][pool].producer_index = 0;
- adapter->rx_buff_pool[0][pool].free_map[free_index] = index;
+ free_index = bpool->producer_index;
+ bpool->producer_index++;
+ if (bpool->producer_index >= bpool->size)
+ bpool->producer_index = 0;
+ bpool->free_map[free_index] = index;
mb();
- atomic_dec(&adapter->rx_buff_pool[0][pool].available);
+ atomic_dec(&bpool->available);
return 0;
}
/* get the buffer for @correlator, read once from the current rx queue entry */
static struct sk_buff *ibmveth_rxq_get_buffer(struct ibmveth_adapter *adapter,
- u64 correlator)
+ int queue_index, u64 correlator)
{
unsigned int pool = correlator >> 32;
unsigned int index = correlator & 0xffffffffUL;
struct sk_buff *skb;
- if (!ibmveth_rxq_correlator_valid(adapter, correlator))
+ if (!ibmveth_rxq_correlator_valid(adapter, queue_index, correlator))
return NULL;
- skb = adapter->rx_buff_pool[0][pool].skbuff[index];
+ skb = adapter->rx_buff_pool[queue_index][pool].skbuff[index];
if (!skb)
ibmveth_rxq_no_skb(adapter, correlator);
return skb;
}
-static void ibmveth_rxq_advance(struct ibmveth_adapter *adapter)
+static void ibmveth_rxq_advance(struct ibmveth_adapter *adapter,
+ int queue_index)
{
- struct ibmveth_rx_q *rxq = &adapter->rx_queue[0];
+ struct ibmveth_rx_q *rxq = &adapter->rx_queue[queue_index];
if (++rxq->index == rxq->num_slots) {
rxq->index = 0;
@@ -986,6 +1002,7 @@ static void ibmveth_rxq_advance(struct ibmveth_adapter *adapter)
* ibmveth_rxq_harvest_buffer - Harvest buffer from pool
*
* @adapter: pointer to adapter
+ * @queue_index: RX queue index
* @correlator: correlator of the current rx queue entry, as read by poll
* @reuse: whether to reuse buffer
*
@@ -999,12 +1016,14 @@ static void ibmveth_rxq_advance(struct ibmveth_adapter *adapter)
* * other - non-zero return from ibmveth_remove_buffer_from_pool
*/
static int ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter,
- u64 correlator, bool reuse)
+ int queue_index, u64 correlator,
+ bool reuse)
{
int rc;
- rc = ibmveth_remove_buffer_from_pool(adapter, correlator, reuse);
- ibmveth_rxq_advance(adapter);
+ rc = ibmveth_remove_buffer_from_pool(adapter, correlator, queue_index,
+ reuse);
+ ibmveth_rxq_advance(adapter, queue_index);
return rc;
}
@@ -1978,25 +1997,28 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,
static int ibmveth_poll(struct napi_struct *napi, int budget)
{
- struct ibmveth_adapter *adapter =
- container_of(napi, struct ibmveth_adapter, napi[0]);
- struct net_device *netdev = adapter->netdev;
+ struct net_device *netdev = napi->dev;
+ struct ibmveth_adapter *adapter = netdev_priv(netdev);
int frames_processed = 0;
+ int queue_index;
u64 correlator;
u16 mss = 0;
int rc;
+ queue_index = napi - adapter->napi;
+
while (frames_processed < budget) {
- if (!ibmveth_rxq_pending_buffer(adapter))
+ if (!ibmveth_rxq_pending_buffer(adapter, queue_index))
break;
smp_rmb();
- correlator = ibmveth_rxq_correlator(adapter);
- if (!ibmveth_rxq_buffer_valid(adapter)) {
+ correlator = ibmveth_rxq_correlator(adapter, queue_index);
+ if (!ibmveth_rxq_buffer_valid(adapter, queue_index)) {
wmb(); /* suggested by larson1 */
adapter->rx_invalid_buffer++;
netdev_dbg(netdev, "recycling invalid buffer\n");
- rc = ibmveth_rxq_harvest_buffer(adapter, correlator, true);
+ rc = ibmveth_rxq_harvest_buffer(adapter, queue_index,
+ correlator, true);
if (unlikely(rc)) {
netdev->stats.rx_dropped++;
frames_processed++;
@@ -2004,24 +2026,31 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
}
} else {
struct sk_buff *skb, *new_skb;
- int length = ibmveth_rxq_frame_length(adapter);
- int offset = ibmveth_rxq_frame_offset(adapter);
- int csum_good = ibmveth_rxq_csum_good(adapter);
- int lrg_pkt = ibmveth_rxq_large_packet(adapter);
+ int length = ibmveth_rxq_frame_length(adapter,
+ queue_index);
+ int offset = ibmveth_rxq_frame_offset(adapter,
+ queue_index);
+ int csum_good = ibmveth_rxq_csum_good(adapter,
+ queue_index);
+ int lrg_pkt = ibmveth_rxq_large_packet(adapter,
+ queue_index);
unsigned int pool, room, off, len;
+ struct ibmveth_buff_pool *bpool;
__sum16 iph_check = 0;
- skb = ibmveth_rxq_get_buffer(adapter, correlator);
+ skb = ibmveth_rxq_get_buffer(adapter, queue_index,
+ correlator);
if (unlikely(!skb)) {
- ibmveth_rxq_advance(adapter);
+ ibmveth_rxq_advance(adapter, queue_index);
netdev->stats.rx_dropped++;
frames_processed++;
continue;
}
pool = correlator >> 32;
+ bpool = &adapter->rx_buff_pool[queue_index][pool];
room = min_t(unsigned int, skb_tailroom(skb),
- adapter->rx_buff_pool[0][pool].buff_size);
+ bpool->buff_size);
off = offset;
len = length;
if (unlikely(len < ETH_HLEN || off >= room ||
@@ -2030,8 +2059,8 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
netdev_err(netdev,
"bad RX frame offset %u length %u (buffer %u), dropping\n",
off, len, room);
- ibmveth_rxq_harvest_buffer(adapter, correlator,
- true);
+ ibmveth_rxq_harvest_buffer(adapter, queue_index,
+ correlator, true);
netdev->stats.rx_dropped++;
frames_processed++;
continue;
@@ -2060,6 +2089,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
ibmveth_flush_buffer(skb->data,
length + offset);
rc = ibmveth_rxq_harvest_buffer(adapter,
+ queue_index,
correlator,
true);
if (unlikely(rc)) {
@@ -2071,6 +2101,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
skb = new_skb;
} else {
rc = ibmveth_rxq_harvest_buffer(adapter,
+ queue_index,
correlator,
false);
if (unlikely(rc)) {
@@ -2118,7 +2149,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
* with a NAPI poll that was already running when it was set up
*/
if (budget)
- ibmveth_replenish_task(adapter);
+ ibmveth_replenish_task(adapter, queue_index);
if (frames_processed == budget)
goto out;
@@ -2129,7 +2160,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
/* We think we are done - reenable interrupts,
* then check once more to make sure we are done.
*/
- rc = ibmveth_enable_irq(adapter, 0);
+ rc = ibmveth_enable_irq(adapter, queue_index);
if (rc) {
schedule_work(&adapter->work);
goto out;
@@ -2138,8 +2169,9 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
/* Mask before queueing, as schedule_rx_queue() does: a threaded
* NAPI can start polling, and unmask, as soon as it is queued.
*/
- if (ibmveth_rxq_pending_buffer(adapter) && napi_schedule_prep(napi)) {
- ibmveth_disable_irq(adapter, 0);
+ if (ibmveth_rxq_pending_buffer(adapter, queue_index) &&
+ napi_schedule_prep(napi)) {
+ ibmveth_disable_irq(adapter, queue_index);
__napi_schedule(napi);
}
@@ -2827,24 +2859,36 @@ static void ibmveth_remove_buffer_from_pool_test(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pool->skbuff);
correlator = ((u64)IBMVETH_NUM_BUFF_POOLS << 32) | 0;
- KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, false));
- KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, true));
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ ibmveth_remove_buffer_from_pool(adapter,
+ correlator, 0, false));
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ ibmveth_remove_buffer_from_pool(adapter,
+ correlator, 0, true));
correlator = ((u64)0 << 32) | adapter->rx_buff_pool[0][0].size;
- KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, false));
- KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, true));
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ ibmveth_remove_buffer_from_pool(adapter,
+ correlator, 0, false));
+ KUNIT_EXPECT_EQ(test, -EINVAL,
+ ibmveth_remove_buffer_from_pool(adapter,
+ correlator, 0, true));
/* Pool 2 is in range but has no skbuff array, like an inactive pool. */
correlator = ((u64)2 << 32) | 0;
- ret = ibmveth_remove_buffer_from_pool(adapter, correlator, false);
+ ret = ibmveth_remove_buffer_from_pool(adapter, correlator, 0, false);
KUNIT_EXPECT_EQ(test, -EINVAL, ret);
- ret = ibmveth_remove_buffer_from_pool(adapter, correlator, true);
+ ret = ibmveth_remove_buffer_from_pool(adapter, correlator, 0, true);
KUNIT_EXPECT_EQ(test, -EINVAL, ret);
correlator = (u64)0 | 0;
pool->skbuff[0] = NULL;
- KUNIT_EXPECT_EQ(test, -EFAULT, ibmveth_remove_buffer_from_pool(adapter, correlator, false));
- KUNIT_EXPECT_EQ(test, -EFAULT, ibmveth_remove_buffer_from_pool(adapter, correlator, true));
+ KUNIT_EXPECT_EQ(test, -EFAULT,
+ ibmveth_remove_buffer_from_pool(adapter,
+ correlator, 0, false));
+ KUNIT_EXPECT_EQ(test, -EFAULT,
+ ibmveth_remove_buffer_from_pool(adapter,
+ correlator, 0, true));
flush_work(&adapter->work);
}
@@ -2889,27 +2933,27 @@ static void ibmveth_rxq_get_buffer_test(struct kunit *test)
adapter->rx_queue[0].queue_addr[0].correlator =
(u64)IBMVETH_NUM_BUFF_POOLS << 32 | 0;
- cor = ibmveth_rxq_correlator(adapter);
+ cor = ibmveth_rxq_correlator(adapter, 0);
KUNIT_EXPECT_PTR_EQ(test, NULL,
- ibmveth_rxq_get_buffer(adapter, cor));
+ ibmveth_rxq_get_buffer(adapter, 0, cor));
adapter->rx_queue[0].queue_addr[0].correlator =
(u64)0 << 32 | adapter->rx_buff_pool[0][0].size;
- cor = ibmveth_rxq_correlator(adapter);
+ cor = ibmveth_rxq_correlator(adapter, 0);
KUNIT_EXPECT_PTR_EQ(test, NULL,
- ibmveth_rxq_get_buffer(adapter, cor));
+ ibmveth_rxq_get_buffer(adapter, 0, cor));
/* Pool 2 is in range but has no skbuff array, like an inactive pool. */
adapter->rx_queue[0].queue_addr[0].correlator = (u64)2 << 32 | 0;
- cor = ibmveth_rxq_correlator(adapter);
+ cor = ibmveth_rxq_correlator(adapter, 0);
KUNIT_EXPECT_PTR_EQ(test, NULL,
- ibmveth_rxq_get_buffer(adapter, cor));
+ ibmveth_rxq_get_buffer(adapter, 0, cor));
pool->skbuff[0] = skb;
adapter->rx_queue[0].queue_addr[0].correlator = (u64)0 << 32 | 0;
- cor = ibmveth_rxq_correlator(adapter);
+ cor = ibmveth_rxq_correlator(adapter, 0);
KUNIT_EXPECT_PTR_EQ(test, skb,
- ibmveth_rxq_get_buffer(adapter, cor));
+ ibmveth_rxq_get_buffer(adapter, 0, cor));
flush_work(&adapter->work);
}
@@ -2960,14 +3004,14 @@ static void ibmveth_rxq_harvest_buffer_test(struct kunit *test)
(u64)IBMVETH_NUM_BUFF_POOLS << 32 | 0;
adapter->rx_queue[0].queue_addr[1].correlator = (u64)0 << 32 | 0;
- cor = ibmveth_rxq_correlator(adapter);
- ret = ibmveth_rxq_harvest_buffer(adapter, cor, true);
+ cor = ibmveth_rxq_correlator(adapter, 0);
+ ret = ibmveth_rxq_harvest_buffer(adapter, 0, cor, true);
KUNIT_EXPECT_EQ(test, -EINVAL, ret);
KUNIT_EXPECT_EQ(test, 1ULL, adapter->rx_queue[0].index);
KUNIT_EXPECT_EQ(test, 1ULL, adapter->rx_queue[0].toggle);
- cor = ibmveth_rxq_correlator(adapter);
- ret = ibmveth_rxq_harvest_buffer(adapter, cor, true);
+ cor = ibmveth_rxq_correlator(adapter, 0);
+ ret = ibmveth_rxq_harvest_buffer(adapter, 0, cor, true);
KUNIT_EXPECT_EQ(test, -EFAULT, ret);
KUNIT_EXPECT_EQ(test, 0ULL, adapter->rx_queue[0].index);
KUNIT_EXPECT_EQ(test, 0ULL, adapter->rx_queue[0].toggle);
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH net-next 7/8] ibmveth: Pass the RX queue index through replenish and poll
2026-11-19 0:07 ` [PATCH net-next 7/8] ibmveth: Pass the RX queue index through replenish and poll Mingming Cao
@ 2026-11-23 1:06 ` netdev-bot+sashiko
0 siblings, 0 replies; 15+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 1:06 UTC (permalink / raw)
To: mmc
Cc: netdev, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This patch adds the queue_index parameter in inconsistent
positions across the RX buffer helpers in…
--
ibmveth: Pass the RX queue index through replenish and poll
This patch adds a queue_index parameter to the rxq_* accessors and to the
RX buffer lookup, harvest and replenish helpers, which used to hardcode
queue 0. ibmveth_poll() now gets the queue index from its NAPI instance.
Only queue 0 is used, so the behavior does not change.
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index ab8c5f6a265b4..a40d9a6abf51b 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
[ ... ]
> @@ -909,17 +922,20 @@ ibmveth_free_buffer_pools(struct ibmveth_adapter *adapter)
> * * %-EFAULT - pool and index map to null skb
> */
> static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,
> - u64 correlator, bool reuse)
> + u64 correlator, int queue_index,
> + bool reuse)
[Severity: Low]
This isn't a bug, but could queue_index go before correlator here, so it
matches the other RX buffer helpers in this patch?
ibmveth_rxq_correlator_valid(), ibmveth_rxq_get_buffer() and
ibmveth_rxq_harvest_buffer() all take (queue_index, correlator).
ibmveth_remove_buffer_from_pool() takes (correlator, queue_index), and its
kernel-doc also lists @correlator before @queue_index.
Because of this, ibmveth_rxq_harvest_buffer() has to swap the arguments
when it passes them on:
rc = ibmveth_remove_buffer_from_pool(adapter, correlator, queue_index,
reuse);
int and u64 convert to each other without a warning. A future caller that
follows the sibling order would compile cleanly, but it would index
adapter->rx_buff_pool[queue_index][...] with a truncated correlator.
All current callers use the correct order, including the KUnit tests. The
later patch in this series, "ibmveth: Split RX poll into per-slot helpers
for MQ", keeps the same order.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119000711.18093-1-mmc%40linux.ibm.com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next 8/8] ibmveth: Split RX poll into per-slot helpers for MQ
2026-11-19 0:07 [PATCH net-next 0/8] ibmveth: prepare the RX path for multi-queue Mingming Cao
` (6 preceding siblings ...)
2026-11-19 0:07 ` [PATCH net-next 7/8] ibmveth: Pass the RX queue index through replenish and poll Mingming Cao
@ 2026-11-19 0:07 ` Mingming Cao
2026-11-23 1:06 ` netdev-bot+sashiko
7 siblings, 1 reply; 15+ messages in thread
From: Mingming Cao @ 2026-11-19 0:07 UTC (permalink / raw)
To: netdev
Cc: Mingming Cao, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Move the invalid-slot recycle, the oversize-frame drop and frame
delivery out of ibmveth_poll() into helpers. The bad-frame message now
names the queue. Otherwise no behavior change.
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 272 ++++++++++++++++-------------
1 file changed, 147 insertions(+), 125 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index a40d9a6abf51..a36dafb8e893 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1995,6 +1995,148 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,
skb->ip_summed = CHECKSUM_NONE;
}
+/* Returns true if the slot could not be recycled; poll then counts it
+ * against the budget.
+ */
+static bool ibmveth_poll_recycle_invalid(struct net_device *netdev,
+ struct ibmveth_adapter *adapter,
+ int queue_index, u64 correlator)
+{
+ int rc;
+
+ adapter->rx_invalid_buffer++;
+ netdev_dbg(netdev, "recycling invalid buffer\n");
+ rc = ibmveth_rxq_harvest_buffer(adapter, queue_index, correlator,
+ true);
+ if (unlikely(rc))
+ netdev->stats.rx_dropped++;
+ return rc;
+}
+
+static void ibmveth_poll_drop_oversize(struct net_device *netdev,
+ struct ibmveth_adapter *adapter,
+ int queue_index, unsigned int off,
+ unsigned int len, unsigned int room,
+ u64 correlator)
+{
+ if (net_ratelimit())
+ netdev_err(netdev,
+ "bad RX frame offset %u length %u (buffer %u) on queue %d, dropping\n",
+ off, len, room, queue_index);
+ ibmveth_rxq_harvest_buffer(adapter, queue_index, correlator, true);
+ netdev->stats.rx_dropped++;
+}
+
+/**
+ * ibmveth_poll_deliver_frame - Build SKB from one valid RX slot and GRO it
+ * @napi: NAPI context for this RX queue
+ * @adapter: ibmveth adapter
+ * @netdev: net_device for @adapter
+ * @queue_index: RX queue index
+ * @correlator: correlator of the current rx queue entry, as read by poll
+ */
+static void ibmveth_poll_deliver_frame(struct napi_struct *napi,
+ struct ibmveth_adapter *adapter,
+ struct net_device *netdev,
+ int queue_index, u64 correlator)
+{
+ int length = ibmveth_rxq_frame_length(adapter, queue_index);
+ int offset = ibmveth_rxq_frame_offset(adapter, queue_index);
+ int csum_good = ibmveth_rxq_csum_good(adapter, queue_index);
+ int lrg_pkt = ibmveth_rxq_large_packet(adapter, queue_index);
+ unsigned int pool, room, off, len;
+ struct ibmveth_buff_pool *bpool;
+ struct sk_buff *skb, *new_skb;
+ __sum16 iph_check = 0;
+ u16 mss = 0;
+ int rc;
+
+ skb = ibmveth_rxq_get_buffer(adapter, queue_index, correlator);
+ if (unlikely(!skb)) {
+ ibmveth_rxq_advance(adapter, queue_index);
+ netdev->stats.rx_dropped++;
+ return;
+ }
+
+ pool = correlator >> 32;
+ bpool = &adapter->rx_buff_pool[queue_index][pool];
+ room = min_t(unsigned int, skb_tailroom(skb), bpool->buff_size);
+ off = offset;
+ len = length;
+ if (unlikely(len < ETH_HLEN || off >= room || len > room - off)) {
+ ibmveth_poll_drop_oversize(netdev, adapter, queue_index,
+ off, len, room, correlator);
+ return;
+ }
+
+ /* if the large packet bit is set in the rx queue
+ * descriptor, the mss will be written by PHYP eight
+ * bytes from the start of the rx buffer, which is
+ * skb->data at this stage
+ */
+ if (lrg_pkt) {
+ __be64 *rxmss = (__be64 *)(skb->data + 8);
+
+ mss = (u16)be64_to_cpu(*rxmss);
+ }
+
+ new_skb = NULL;
+ if (length < rx_copybreak)
+ new_skb = netdev_alloc_skb(netdev, length);
+
+ if (new_skb) {
+ skb_copy_to_linear_data(new_skb, skb->data + offset, length);
+ if (rx_flush)
+ ibmveth_flush_buffer(skb->data, length + offset);
+ rc = ibmveth_rxq_harvest_buffer(adapter, queue_index,
+ correlator, true);
+ if (unlikely(rc)) {
+ dev_kfree_skb_any(new_skb);
+ netdev->stats.rx_dropped++;
+ return;
+ }
+ skb = new_skb;
+ } else {
+ rc = ibmveth_rxq_harvest_buffer(adapter, queue_index,
+ correlator, false);
+ if (unlikely(rc)) {
+ netdev->stats.rx_dropped++;
+ return;
+ }
+ skb_reserve(skb, offset);
+ }
+
+ skb_put(skb, length);
+ skb->protocol = eth_type_trans(skb, netdev);
+
+ /* PHYP without PLSO support places a -1 in the ip
+ * checksum for large send frames.
+ */
+ if (skb->protocol == cpu_to_be16(ETH_P_IP) &&
+ skb_headlen(skb) >= sizeof(struct iphdr)) {
+ struct iphdr *iph = (struct iphdr *)skb->data;
+
+ iph_check = iph->check;
+ }
+
+ if ((length > netdev->mtu + ETH_HLEN) ||
+ lrg_pkt || iph_check == 0xffff) {
+ if (!ibmveth_rx_mss_helper(skb, mss, lrg_pkt))
+ csum_good = 0;
+ adapter->rx_large_packets++;
+ }
+
+ if (csum_good) {
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ ibmveth_rx_csum_helper(skb, adapter);
+ }
+
+ napi_gro_receive(napi, skb); /* send it up */
+
+ netdev->stats.rx_packets++;
+ netdev->stats.rx_bytes += length;
+}
+
static int ibmveth_poll(struct napi_struct *napi, int budget)
{
struct net_device *netdev = napi->dev;
@@ -2002,7 +2144,6 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
int frames_processed = 0;
int queue_index;
u64 correlator;
- u16 mss = 0;
int rc;
queue_index = napi - adapter->napi;
@@ -2015,132 +2156,13 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
correlator = ibmveth_rxq_correlator(adapter, queue_index);
if (!ibmveth_rxq_buffer_valid(adapter, queue_index)) {
wmb(); /* suggested by larson1 */
- adapter->rx_invalid_buffer++;
- netdev_dbg(netdev, "recycling invalid buffer\n");
- rc = ibmveth_rxq_harvest_buffer(adapter, queue_index,
- correlator, true);
- if (unlikely(rc)) {
- netdev->stats.rx_dropped++;
+ if (ibmveth_poll_recycle_invalid(netdev, adapter,
+ queue_index,
+ correlator))
frames_processed++;
- continue;
- }
} else {
- struct sk_buff *skb, *new_skb;
- int length = ibmveth_rxq_frame_length(adapter,
- queue_index);
- int offset = ibmveth_rxq_frame_offset(adapter,
- queue_index);
- int csum_good = ibmveth_rxq_csum_good(adapter,
- queue_index);
- int lrg_pkt = ibmveth_rxq_large_packet(adapter,
- queue_index);
- unsigned int pool, room, off, len;
- struct ibmveth_buff_pool *bpool;
- __sum16 iph_check = 0;
-
- skb = ibmveth_rxq_get_buffer(adapter, queue_index,
- correlator);
- if (unlikely(!skb)) {
- ibmveth_rxq_advance(adapter, queue_index);
- netdev->stats.rx_dropped++;
- frames_processed++;
- continue;
- }
-
- pool = correlator >> 32;
- bpool = &adapter->rx_buff_pool[queue_index][pool];
- room = min_t(unsigned int, skb_tailroom(skb),
- bpool->buff_size);
- off = offset;
- len = length;
- if (unlikely(len < ETH_HLEN || off >= room ||
- len > room - off)) {
- if (net_ratelimit())
- netdev_err(netdev,
- "bad RX frame offset %u length %u (buffer %u), dropping\n",
- off, len, room);
- ibmveth_rxq_harvest_buffer(adapter, queue_index,
- correlator, true);
- netdev->stats.rx_dropped++;
- frames_processed++;
- continue;
- }
-
- /* if the large packet bit is set in the rx queue
- * descriptor, the mss will be written by PHYP eight
- * bytes from the start of the rx buffer, which is
- * skb->data at this stage
- */
- if (lrg_pkt) {
- __be64 *rxmss = (__be64 *)(skb->data + 8);
-
- mss = (u16)be64_to_cpu(*rxmss);
- }
-
- new_skb = NULL;
- if (length < rx_copybreak)
- new_skb = netdev_alloc_skb(netdev, length);
-
- if (new_skb) {
- skb_copy_to_linear_data(new_skb,
- skb->data + offset,
- length);
- if (rx_flush)
- ibmveth_flush_buffer(skb->data,
- length + offset);
- rc = ibmveth_rxq_harvest_buffer(adapter,
- queue_index,
- correlator,
- true);
- if (unlikely(rc)) {
- dev_kfree_skb_any(new_skb);
- netdev->stats.rx_dropped++;
- frames_processed++;
- continue;
- }
- skb = new_skb;
- } else {
- rc = ibmveth_rxq_harvest_buffer(adapter,
- queue_index,
- correlator,
- false);
- if (unlikely(rc)) {
- netdev->stats.rx_dropped++;
- frames_processed++;
- continue;
- }
- skb_reserve(skb, offset);
- }
-
- skb_put(skb, length);
- skb->protocol = eth_type_trans(skb, netdev);
-
- /* PHYP without PLSO support places a -1 in the ip
- * checksum for large send frames.
- */
- if (skb->protocol == cpu_to_be16(ETH_P_IP) &&
- skb_headlen(skb) >= sizeof(struct iphdr)) {
- struct iphdr *iph = (struct iphdr *)skb->data;
-
- iph_check = iph->check;
- }
-
- if ((length > netdev->mtu + ETH_HLEN) ||
- lrg_pkt || iph_check == 0xffff) {
- if (!ibmveth_rx_mss_helper(skb, mss, lrg_pkt))
- csum_good = 0;
- adapter->rx_large_packets++;
- }
-
- if (csum_good) {
- skb->ip_summed = CHECKSUM_UNNECESSARY;
- ibmveth_rx_csum_helper(skb, adapter);
- }
-
- napi_gro_receive(napi, skb); /* send it up */
-
- netdev->stats.rx_packets++;
- netdev->stats.rx_bytes += length;
+ ibmveth_poll_deliver_frame(napi, adapter, netdev,
+ queue_index, correlator);
frames_processed++;
}
}
--
2.50.1 (Apple Git-155)
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH net-next 8/8] ibmveth: Split RX poll into per-slot helpers for MQ
2026-11-19 0:07 ` [PATCH net-next 8/8] ibmveth: Split RX poll into per-slot helpers for MQ Mingming Cao
@ 2026-11-23 1:06 ` netdev-bot+sashiko
0 siblings, 0 replies; 15+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 1:06 UTC (permalink / raw)
To: mmc
Cc: netdev, maddy, mpe, npiggin, chleroy, ritesh.list, sshegde,
nnac123, andrew+netdev, davem, edumazet, kuba, pabeni,
linuxppc-dev, horms, davemarq, haren, ricklind, bjking1,
shaik.abdulla1
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The helper ibmveth_poll_drop_oversize() in
drivers/net/ethernet/ibm/ibmveth.c has a misleading name, and the…
- [Low] Two comments still name ibmveth_poll() as the place where per-
slot RX handling happens, but this patch moved that code into new…
--
ibmveth: Split RX poll into per-slot helpers for MQ
This commit moves three pieces of per-slot RX handling out of
ibmveth_poll() and into new helpers: the invalid-slot recycle, the
bad-frame drop and frame delivery. The bad-frame error message now also
prints the queue index. Otherwise the commit intends no behavior change.
> diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
> index a40d9a6abf51b..a36dafb8e8937 100644
> --- a/drivers/net/ethernet/ibm/ibmveth.c
> +++ b/drivers/net/ethernet/ibm/ibmveth.c
> @@ -1995,6 +1995,148 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,
[ ... ]
> +static void ibmveth_poll_deliver_frame(struct napi_struct *napi,
> + struct ibmveth_adapter *adapter,
> + struct net_device *netdev,
> + int queue_index, u64 correlator)
> +{
[ ... ]
> + skb = ibmveth_rxq_get_buffer(adapter, queue_index, correlator);
> + if (unlikely(!skb)) {
> + ibmveth_rxq_advance(adapter, queue_index);
> + netdev->stats.rx_dropped++;
> + return;
> + }
[Severity: Low]
This get_buffer failure branch now lives in ibmveth_poll_deliver_frame().
Are two comments elsewhere in ibmveth.c out of date as a result?
The kernel-doc for ibmveth_rxq_harvest_buffer_test() still says:
* the toggle at the end. This covers the harvest path; the advance after
* ibmveth_rxq_get_buffer() fails in ibmveth_poll() is not tested here.
ibmveth_poll() no longer contains that ibmveth_rxq_advance() call.
The kernel-doc for ibmveth_rxq_harvest_buffer() also still says:
* Context: called from ibmveth_poll
Its direct callers are now ibmveth_poll_recycle_invalid(),
ibmveth_poll_drop_oversize() and ibmveth_poll_deliver_frame(). That one
is still roughly accurate, because these helpers are only reached from
ibmveth_poll(). The test comment, though, now names the wrong function.
> +
> + pool = correlator >> 32;
> + bpool = &adapter->rx_buff_pool[queue_index][pool];
> + room = min_t(unsigned int, skb_tailroom(skb), bpool->buff_size);
> + off = offset;
> + len = length;
> + if (unlikely(len < ETH_HLEN || off >= room || len > room - off)) {
> + ibmveth_poll_drop_oversize(netdev, adapter, queue_index,
> + off, len, room, correlator);
> + return;
> + }
[Severity: Low]
This isn't a bug, but does the name ibmveth_poll_drop_oversize() fit
what this helper handles?
It is called when any of these three checks fail:
len < ETH_HLEN || off >= room || len > room - off
Only the last check means the frame is too large. The first one catches
frames shorter than an Ethernet header. The second catches an offset
that lies outside the buffer.
The message inside the helper is already generic ("bad RX frame offset
%u length %u (buffer %u) on queue %d, dropping"). The commit message,
however, uses the same narrow wording as the helper name:
Move the invalid-slot recycle, the oversize-frame drop and frame
delivery out of ibmveth_poll() into helpers.
Would a name like ibmveth_poll_drop_bad_frame() be a better match?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119000711.18093-1-mmc%40linux.ibm.com
^ permalink raw reply [flat|nested] 15+ messages in thread