From: Mingming Cao <mmc@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: Mingming Cao <mmc@linux.ibm.com>,
maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com,
chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com,
nnac123@linux.ibm.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, linuxppc-dev@lists.ozlabs.org,
horms@kernel.org, davemarq@linux.ibm.com, haren@linux.ibm.com,
ricklind@linux.ibm.com, bjking1@linux.ibm.com,
shaik.abdulla1@ibm.com, willemb@google.com
Subject: [PATCH net-next v9 07/13] ibmveth: Add the MQ RX buffer submit hypercall
Date: Tue, 1 Dec 2026 11:02:10 -0800 [thread overview]
Message-ID: <20261201190216.62407-8-mmc@linux.ibm.com> (raw)
In-Reply-To: <20261201190216.62407-1-mmc@linux.ibm.com>
This is preparation for multi-queue (MQ) RX; nothing sets multi_queue
yet, so single-queue behavior does not change.
With MQ, every RX queue, queue 0 included, posts buffers with
H_ADD_LOGICAL_LAN_BUFFERS_QUEUE against its handle. It packs two
buffer addresses per argument, so one call carries up to 12 buffers
instead of 8.
Add ibmveth_add_logical_lan_buffers(), which picks the hcall for the
adapter's mode, and pass the queue index to replenish.
IBMVETH_MAX_RX_PER_HCALL becomes 12 and sizes the descriptor array;
the legacy hcall keeps its limit of 8 as IBMVETH_MAX_RX_REGULAR, which
probe now uses.
An unexpected H_FUNCTION (hcall not supported) from the MQ hcall
schedules a reset. Unlike the legacy batch hcall, it cannot disappear
after Live Partition Migration, since PowerVM blocks migration to a
host without MQ. If H_FUNCTION comes back after the reopen, the reset
leaves the device down.
As with the single queue today, a queue whose refill posts no buffer
gets no further interrupt.
Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
drivers/net/ethernet/ibm/ibmveth.c | 131 ++++++++++++++++++++++++-----
drivers/net/ethernet/ibm/ibmveth.h | 41 ++++++++-
2 files changed, 151 insertions(+), 21 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 1a9499438930..cafbed3d1512 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -634,11 +634,81 @@ static inline void ibmveth_flush_buffer(void *addr, unsigned long length)
asm("dcbf %0,%1,1" :: "b" (addr), "r" (offset));
}
+/**
+ * ibmveth_add_logical_lan_buffers - Add receive buffers to hypervisor
+ * @adapter: ibmveth adapter structure
+ * @descs: array of buffer descriptors to add
+ * @filled: number of valid descriptors in the array
+ * @buff_size: size of each buffer (multi-queue mode only)
+ * @queue_index: RX queue index
+ *
+ * Return: hypervisor return code
+ */
+static long ibmveth_add_logical_lan_buffers(struct ibmveth_adapter *adapter,
+ union ibmveth_buf_desc *descs,
+ int filled,
+ unsigned long buff_size,
+ int queue_index)
+{
+ struct vio_dev *vdev = adapter->vdev;
+ long rc;
+
+ /*
+ * The MQ hcall takes six ioba words (12 packed addresses). The
+ * legacy hcall takes eight descriptors. The argument lists below
+ * are written out by hand; keep the defines matched to those lists.
+ */
+ static_assert(IBMVETH_MAX_RX_PER_HCALL == 12);
+ static_assert(IBMVETH_MAX_RX_REGULAR == 8);
+
+ if (adapter->multi_queue) {
+ unsigned long buffersznum = (buff_size << 32) | filled;
+ unsigned long ioba[IBMVETH_MAX_RX_PER_HCALL / 2] = {0};
+ unsigned long handle = adapter->queue_handle[queue_index];
+ int i;
+
+ /* Even descriptors go in the high 32 bits of an ioba word,
+ * odd ones in the low 32 bits.
+ */
+ for (i = 0; i < filled && i < IBMVETH_MAX_RX_PER_HCALL; i++) {
+ int pair_idx = i / 2;
+ int is_high = (i % 2 == 0);
+
+ if (is_high)
+ ioba[pair_idx] = (unsigned long)
+ descs[i].fields.address << 32;
+ else
+ ioba[pair_idx] |= descs[i].fields.address;
+ }
+
+ rc = h_add_logical_lan_buffers_queue(vdev->unit_address,
+ handle,
+ buffersznum,
+ ioba[0], ioba[1], ioba[2],
+ ioba[3], ioba[4], ioba[5]);
+ } else if (filled == 1) {
+ rc = h_add_logical_lan_buffer(vdev->unit_address,
+ descs[0].desc);
+ } else {
+ /* Legacy 8-desc hcall; rx_buffers_per_hcall never exceeds
+ * IBMVETH_MAX_RX_REGULAR outside multi-queue mode.
+ */
+ rc = h_add_logical_lan_buffers(vdev->unit_address,
+ descs[0].desc, descs[1].desc,
+ descs[2].desc, descs[3].desc,
+ descs[4].desc, descs[5].desc,
+ descs[6].desc, descs[7].desc);
+ }
+
+ return rc;
+}
+
/* replenish the buffers for a pool. note that we don't need to
* skb_reserve these since they are used for incoming...
*/
static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter,
- struct ibmveth_buff_pool *pool)
+ struct ibmveth_buff_pool *pool,
+ int queue_index)
{
union ibmveth_buf_desc descs[IBMVETH_MAX_RX_PER_HCALL] = {0};
u32 remaining = pool->size - atomic_read(&pool->available);
@@ -724,24 +794,16 @@ static void ibmveth_replenish_buffer_pool(struct ibmveth_adapter *adapter,
if (!filled)
break;
- /* single buffer case*/
- if (filled == 1)
- lpar_rc = h_add_logical_lan_buffer(vdev->unit_address,
- descs[0].desc);
- else
- /* Multi-buffer hcall */
- lpar_rc = h_add_logical_lan_buffers(vdev->unit_address,
- descs[0].desc,
- descs[1].desc,
- descs[2].desc,
- descs[3].desc,
- descs[4].desc,
- descs[5].desc,
- descs[6].desc,
- descs[7].desc);
+ lpar_rc = ibmveth_add_logical_lan_buffers(adapter, descs,
+ filled,
+ pool->buff_size,
+ queue_index);
if (lpar_rc != H_SUCCESS) {
dev_warn_ratelimited(dev,
- "RX h_add_logical_lan failed: filled=%u, rc=%lu, batch=%u\n",
+ "RX %s failed: filled=%u, rc=%lu, batch=%u\n",
+ adapter->multi_queue ?
+ "h_add_logical_lan_buffers_queue" :
+ "h_add_logical_lan",
filled, lpar_rc, batch);
goto hcall_failure;
}
@@ -782,6 +844,21 @@ hcall_failure:
}
adapter->replenish_add_buff_failure += filled;
+ /* PowerVM blocks LPM to a host without MQ support once probe
+ * has enabled multi-queue mode, so unlike the legacy batch
+ * hcall below, this hcall cannot disappear across migration.
+ * Reset on an unexpected H_FUNCTION rather than sit without
+ * buffers, link up.
+ */
+ if (lpar_rc == H_FUNCTION && adapter->multi_queue) {
+ dev_err_ratelimited(dev,
+ "MQ buffer add H_FUNCTION (q=%d, batch=%u), reset\n",
+ queue_index, batch);
+ WRITE_ONCE(adapter->mq_hfunc, true);
+ schedule_work(&adapter->work);
+ break;
+ }
+
/*
* If multi rx buffers hcall is no longer supported by FW
* e.g. in the case of Live Partition Migration
@@ -839,7 +916,8 @@ static void ibmveth_replenish_task(struct ibmveth_adapter *adapter,
if (pool->active &&
(atomic_read(&pool->available) < pool->threshold))
- ibmveth_replenish_buffer_pool(adapter, pool);
+ ibmveth_replenish_buffer_pool(adapter, pool,
+ queue_index);
}
ibmveth_update_rx_no_buffer(adapter);
@@ -1543,6 +1621,8 @@ static int ibmveth_close(struct net_device *netdev)
netif_tx_disable(netdev);
ibmveth_cleanup_rx_interrupts(adapter);
+ WRITE_ONCE(adapter->mq_hfunc, false);
+ adapter->mq_hfunc_reopened = false;
ibmveth_free_all_queues(adapter);
ibmveth_update_rx_no_buffer(adapter);
@@ -1578,8 +1658,19 @@ static void ibmveth_reset(struct work_struct *w)
rtnl_lock();
if (netif_running(netdev)) {
+ bool hfunc = READ_ONCE(adapter->mq_hfunc);
+ bool give_up = hfunc && adapter->mq_hfunc_reopened;
+
dev_close(netdev);
- dev_open(netdev, NULL);
+ /* Firmware that returns MQ H_FUNCTION again after a reopen
+ * would do so on every reopen; leave the device down rather
+ * than close and reopen forever.
+ */
+ if (give_up)
+ netdev_err(netdev,
+ "MQ buffer add H_FUNCTION again after reset, leaving device down\n");
+ else if (!dev_open(netdev, NULL))
+ adapter->mq_hfunc_reopened = hfunc;
}
rtnl_unlock();
@@ -2846,7 +2937,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
if (ret == H_SUCCESS &&
(ret_attr & IBMVETH_ILLAN_RX_MULTI_BUFF_SUPPORT)) {
- adapter->rx_buffers_per_hcall = IBMVETH_MAX_RX_PER_HCALL;
+ adapter->rx_buffers_per_hcall = IBMVETH_MAX_RX_REGULAR;
netdev_dbg(netdev,
"RX Multi-buffer hcall supported by FW, batch set to %u\n",
adapter->rx_buffers_per_hcall);
diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h
index 398d3a862503..dd89f108e726 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -100,6 +100,40 @@ h_register_logical_lan_queue(unsigned long unit_address,
return rc;
}
+/**
+ * h_add_logical_lan_buffers_queue - Add buffers to an RX queue by handle
+ * @unit_address: Device unit address
+ * @queue_handle: Queue handle from h_register_logical_lan_queue() or
+ * h_register_logical_lan_with_handle() (queue 0)
+ * @buffersznum: Buffer size (upper 32 bits) | count (lower 32 bits)
+ * @ioba12: Buffer addresses 1 and 2 packed ((addr1 << 32) | addr2)
+ * @ioba34: Buffer addresses 3 and 4 packed
+ * @ioba56: Buffer addresses 5 and 6 packed
+ * @ioba78: Buffer addresses 7 and 8 packed
+ * @ioba910: Buffer addresses 9 and 10 packed
+ * @ioba1112: Buffer addresses 11 and 12 packed
+ *
+ * Return: hypervisor return code
+ */
+static inline long h_add_logical_lan_buffers_queue(unsigned long unit_address,
+ unsigned long queue_handle,
+ unsigned long buffersznum,
+ unsigned long ioba12,
+ unsigned long ioba34,
+ unsigned long ioba56,
+ unsigned long ioba78,
+ unsigned long ioba910,
+ unsigned long ioba1112)
+{
+ unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
+
+ return plpar_hcall9(H_ADD_LOGICAL_LAN_BUFFERS_QUEUE,
+ retbuf, unit_address,
+ queue_handle, buffersznum,
+ ioba12, ioba34, ioba56,
+ ioba78, ioba910, ioba1112);
+}
+
/**
* h_register_logical_lan_with_handle - Register primary queue and get handle
* @unit_address: Device unit address
@@ -194,7 +228,8 @@ static inline long h_illan_attributes(unsigned long unit_address,
#define IBMVETH_DEFAULT_QUEUES 8U
#define IBMVETH_MAX_RX_QUEUES 1U
#define IBMVETH_DEFAULT_RX_QUEUES 1U
-#define IBMVETH_MAX_RX_PER_HCALL 8U
+#define IBMVETH_MAX_RX_REGULAR 8U
+#define IBMVETH_MAX_RX_PER_HCALL 12U
static int pool_size[] = { 512, 1024 * 2, 1024 * 16, 1024 * 32, 1024 * 64 };
static int pool_count[] = { 256, 512, 256, 256, 256 };
@@ -267,6 +302,10 @@ struct ibmveth_adapter {
bool is_active_trunk;
/* Set by a successful ibmveth_open(), cleared by ibmveth_close(). */
bool opened;
+ /* MQ buffer add returned H_FUNCTION; cleared by ibmveth_close(). */
+ bool mq_hfunc;
+ /* ibmveth_reset() reopened after mq_hfunc; cleared by ibmveth_close(). */
+ bool mq_hfunc_reopened;
unsigned int rx_buffers_per_hcall;
u64 fw_ipv6_csum_support;
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-12-01 19:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 19:02 [PATCH net-next v9 00/13] ibmveth: Add multi-queue RX support Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 01/13] ibmveth: Keep a buffer pool enabled after its allocation fails Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 02/13] ibmveth: Keep TX statistics per queue Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 03/13] powerpc/pseries: Add hcall numbers for multi-queue virtual ethernet Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 04/13] ibmveth: Add RX queue handles Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 05/13] ibmveth: Register subordinate RX queues Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 06/13] ibmveth: Add subordinate RX queue interrupt control Mingming Cao
2026-12-01 19:02 ` Mingming Cao [this message]
2026-12-01 19:02 ` [PATCH net-next v9 08/13] ibmveth: Start every RX queue on open and resume Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 09/13] ibmveth: Keep RX statistics per queue Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 10/13] ibmveth: Keep rx_no_buffer across ifdown/up Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 11/13] ibmveth: Report per-queue statistics through netdev_stat_ops Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 12/13] ibmveth: Enable multi-queue RX Mingming Cao
2026-12-01 19:02 ` [PATCH net-next v9 13/13] ibmveth: Allow changing the RX queue count Mingming Cao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201190216.62407-8-mmc@linux.ibm.com \
--to=mmc@linux.ibm.com \
--cc=andrew+netdev@lunn.ch \
--cc=bjking1@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=davem@davemloft.net \
--cc=davemarq@linux.ibm.com \
--cc=edumazet@kernel.org \
--cc=haren@linux.ibm.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=netdev@vger.kernel.org \
--cc=nnac123@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=pabeni@redhat.com \
--cc=ricklind@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=shaik.abdulla1@ibm.com \
--cc=sshegde@linux.ibm.com \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.