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
Subject: [PATCH net-next 8/8] ibmveth: Split RX poll into per-slot helpers for MQ
Date: Wed, 18 Nov 2026 16:07:11 -0800 [thread overview]
Message-ID: <20261119000711.18093-9-mmc@linux.ibm.com> (raw)
In-Reply-To: <20261119000711.18093-1-mmc@linux.ibm.com>
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)
prev parent reply other threads:[~2026-11-19 0:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` [PATCH net-next 3/8] ibmveth: Refactor buffer pool management for per-queue MQ RX Mingming Cao
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 ` [PATCH net-next 5/8] ibmveth: Refactor TX resource allocation in open/close paths Mingming Cao
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 ` [PATCH net-next 7/8] ibmveth: Pass the RX queue index through replenish and poll Mingming Cao
2026-11-19 0:07 ` Mingming Cao [this message]
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=20261119000711.18093-9-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 \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox