All of lore.kernel.org
 help / color / mirror / Atom feed
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 04/13] ibmveth: Add RX queue handles
Date: Tue,  1 Dec 2026 11:02:07 -0800	[thread overview]
Message-ID: <20261201190216.62407-5-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, PHYP (the PowerVM hypervisor) identifies each RX queue by a
handle, and buffers are posted to a queue through it. On MQ firmware,
H_REGISTER_LOGICAL_LAN also returns queue 0's handle, which ibmveth
ignores today.

Add a multi_queue flag and a queue_handle[] array. When multi_queue
is set, register queue 0 with h_register_logical_lan_with_handle(),
which makes the same hcall and saves the handle.

Signed-off-by: Mingming Cao <mmc@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmveth.c | 20 +++++++++++++--
 drivers/net/ethernet/ibm/ibmveth.h | 40 ++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index 3a29fa601dba..236992ded33a 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1192,6 +1192,7 @@ static long ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
 	unsigned long ua = adapter->vdev->unit_address;
 	unsigned long buf_dma = adapter->buffer_list_dma[0];
 	unsigned long filter_dma = adapter->filter_list_dma;
+	unsigned long qh0;
 
 	/*
 	 * After a kexec the adapter will still be open, so our attempt to
@@ -1199,8 +1200,23 @@ static long ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
 	 * try again, but only once.
 	 */
 retry:
-	rc = h_register_logical_lan(ua, buf_dma, rxq_desc.desc, filter_dma,
-				    mac_address);
+	/* In multi-queue mode, obtain a queue handle for queue 0 so all RX
+	 * queues, even a single one, use the per-queue buffer hypercalls.
+	 * multi_queue never changes after probe; PowerVM blocks LPM to a
+	 * host without MQ support, so these hypercalls do not go away.
+	 */
+	if (adapter->multi_queue) {
+		rc = h_register_logical_lan_with_handle(ua, buf_dma,
+							rxq_desc.desc,
+							filter_dma,
+							mac_address,
+							&qh0);
+		if (rc == H_SUCCESS)
+			adapter->queue_handle[0] = qh0;
+	} else {
+		rc = h_register_logical_lan(ua, buf_dma, rxq_desc.desc,
+					    filter_dma, mac_address);
+	}
 
 	if (rc != H_SUCCESS && try_again) {
 		rc = ibmveth_free_logical_lan(adapter);
diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h
index 03b087ed5761..7ac3372afc0f 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -68,6 +68,43 @@ static inline long h_add_logical_lan_buffers(unsigned long unit_address,
 			    desc5, desc6, desc7, desc8);
 }
 
+/**
+ * h_register_logical_lan_with_handle - Register primary queue and get handle
+ * @unit_address: Device unit address
+ * @buffer_list: DMA address of buffer list
+ * @rec_queue: Buffer descriptor of receive queue
+ * @filter_list: DMA address of filter list
+ * @mac_address: MAC address
+ * @queue_handle: Output queue handle on success
+ *
+ * Like h_register_logical_lan(), but returns queue 0's handle so that
+ * multi-queue mode can post buffers to every queue by handle. R4
+ * carries a handle only on firmware that reports MQ RX support in
+ * H_ILLAN_ATTRIBUTES.
+ *
+ * Return: hypervisor return code
+ */
+static inline long
+h_register_logical_lan_with_handle(unsigned long unit_address,
+				   unsigned long buffer_list,
+				   unsigned long rec_queue,
+				   unsigned long filter_list,
+				   unsigned long mac_address,
+				   unsigned long *queue_handle)
+{
+	unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
+	long rc;
+
+	rc = plpar_hcall(H_REGISTER_LOGICAL_LAN, retbuf,
+			 unit_address, buffer_list, rec_queue,
+			 filter_list, mac_address);
+
+	if (rc == H_SUCCESS)
+		*queue_handle = retbuf[0];
+
+	return rc;
+}
+
 /* FW allows us to send 6 descriptors but we only use one so mark
  * the other 5 as unused (0)
  */
@@ -184,7 +221,10 @@ 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];
+	/* Opaque PHYP cookie, 0 can be valid. Set only in multi_queue mode. */
+	u64 queue_handle[IBMVETH_MAX_RX_QUEUES];
 	unsigned int queue_irq[IBMVETH_MAX_RX_QUEUES];
+	bool multi_queue;
 	unsigned int num_rx_queues;
 	int rx_csum;
 	int large_send;
-- 
2.50.1 (Apple Git-155)



  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 ` Mingming Cao [this message]
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 ` [PATCH net-next v9 07/13] ibmveth: Add the MQ RX buffer submit hypercall Mingming Cao
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-5-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.