net: mana: Extend RX CQE coalescing up to 8 packets
Subsystems (5)
PATCH 1/1 net: mana: Extend RX CQE coalescing up to 8 packets
From: Haiyang Zhang <[email protected]>
To support up to 8 packets per CQE, put two packet lengths and hash values into one PPI entry by using the reserved fields. Update ethtool handlers to set this feature.
Update per queue stat to show the coalesced CQE counters. This feature is supported on NIC hardware showing the relevant PF flag.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 137 ++++++++++++------ .../ethernet/microsoft/mana/mana_ethtool.c | 30 +++- include/net/mana/gdma.h | 4 + include/net/mana/mana.h | 43 ++++-- 4 files changed, 150 insertions(+), 64 deletions(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +91 -46
@@ -1241,6 +1241,9 @@ int mana_gd_query_device_cfg(struct gdma_context *gc, u32 proto_major_ver,return err; } +if (resp.pf_cap_flags1 &MANA_PF_FLAG_1_CQE_8_COALESCING_SUPPORTED ) + gc->cqe8_coalescing_sup = true; + *max_num_vports = resp.max_num_vports;if (resp.hdr.response.msg_version >=GDMA_MESSAGE_V2 ) {
@@ -1426,7 +1429,11 @@ static int mana_cfg_vport_steering(struct mana_port_context *apc,mana_gd_init_req_hdr (&req->hdr,MANA_CONFIG_VPORT_RX , req_buf_size,sizeof (resp)); - req->hdr.req.msg_version =GDMA_MESSAGE_V2 ; +/* Request & response versions can be different. +* HW can handle newer msg versions, by skipping +* new fields. +*/ + req->hdr.req.msg_version =GDMA_MESSAGE_V5 ; req->hdr.resp.msg_version =GDMA_MESSAGE_V2 ; req->vport = apc->port_handle;
@@ -1440,8 +1447,13 @@ static int mana_cfg_vport_steering(struct mana_port_context *apc, req->update_indir_tab = update_tab; req->default_rxobj = apc->default_rxobj; -if (rx !=TRI_STATE_FALSE ) +/* Request-msg v5 requires this field */ + req->rss_hash_types =MANA_HASH_ENABLE_SUPPORTED ; + +if (rx !=TRI_STATE_FALSE ) { req->cqe_coalescing_enable = apc->cqe_coalescing_enable; + req->cqe8_coalescing_enable = apc->cqe8_coalescing_enable; + }if (update_key)memcpy (&req->hashkey, apc->hashkey,MANA_HASH_KEY_SIZE );
@@ -2046,16 +2058,14 @@ static struct sk_buff *mana_build_skb(struct mana_rxq *rxq, void *buf_va,static void mana_rx_skb (void *buf_va,bool from_pool,struct mana_rxcomp_oob *cqe,struct mana_rxq *rxq, -int i) +u32 pkt_len,u32 pkt_hash) {struct mana_stats_rx *rx_stats = &rxq->stats;struct net_device *ndev = rxq->ndev; -uint pkt_len = cqe->ppi[i].pkt_len;u16 rxq_idx = rxq->rxq_idx;struct napi_struct *napi;struct xdp_buff xdp = {};struct sk_buff *skb; -u32 hash_value;u32 act; rxq->rx_cq.work_done++;
@@ -2094,12 +2104,10 @@ static void mana_rx_skb(void *buf_va, bool from_pool, }if (cqe->rx_hashtype !=0 && (ndev->features &NETIF_F_RXHASH )) { - hash_value = cqe->ppi[i].pkt_hash; -if (cqe->rx_hashtype &MANA_HASH_L4 ) -skb_set_hash (skb, hash_value,PKT_HASH_TYPE_L4 ); +skb_set_hash (skb, pkt_hash,PKT_HASH_TYPE_L4 );else -skb_set_hash (skb, hash_value,PKT_HASH_TYPE_L3 ); +skb_set_hash (skb, pkt_hash,PKT_HASH_TYPE_L3 ); }if (cqe->rx_vlantag_present) {
@@ -2240,6 +2248,43 @@ static void mana_refill_rx_oob(struct device *dev, struct mana_rxq *rxq, rxoob->dma_sync_offset = dma_sync_offset; } +static void mana_process_one_rx_pkt (struct device *dev,struct mana_rxq *rxq, +struct mana_rxcomp_oob *oob, +u32 pktlen,u32 pkt_hash) +{ +struct mana_recv_buf_oob *rxbuf_oob; +struct net_device *ndev = rxq->ndev; +void *old_buf =NULL ; +bool old_fp; + + rxbuf_oob = &rxq->rx_oobs[rxq->buf_index]; +WARN_ON_ONCE (rxbuf_oob->wqe_inf.wqe_size_in_bu !=1 ); + +if (unlikely (pktlen > rxq->datasize)) { +/* Increase it even if mana_rx_skb() isn't called. */ + rxq->rx_cq.work_done++; + + ++ndev->stats.rx_dropped; +netdev_warn_once (ndev, +"Dropped oversized RX packet: len=%u, datasize=%u\n" , + pktlen, rxq->datasize); + +/* Reuse the RX buffer since rxbuf_oob is unchanged. */ + }else { +mana_refill_rx_oob (dev, rxq, rxbuf_oob, pktlen, + &old_buf, &old_fp); + +/* Unsuccessful refill will have old_buf == NULL. +* In this case, mana_rx_skb() will drop the packet. +*/ +mana_rx_skb (old_buf, old_fp, oob, rxq, pktlen, pkt_hash); + } + +mana_move_wq_tail (rxq->gdma_rq, rxbuf_oob->wqe_inf.wqe_size_in_bu); + +mana_post_pkt_rxq (rxq); +} +static void mana_process_rx_cqe (struct mana_rxq *rxq,struct mana_cq *cq,struct gdma_comp *cqe) {
@@ -2249,10 +2294,10 @@ static void mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq,struct mana_recv_buf_oob *rxbuf_oob;struct mana_port_context *apc;struct device *dev = gc->dev; +bool coalesced_8 = false;bool coalesced = false; -void *old_buf =NULL ; -u32 curr, pktlen; -bool old_fp; +u32 pktlen; +int pkt_i;int i; apc =netdev_priv (ndev);
@@ -2275,6 +2320,11 @@ static void mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq, coalesced = true;break ; +case CQE_RX_COALESCED_8 : + coalesced = true; + coalesced_8 = true; +break ; +case CQE_RX_OBJECT_FENCE :complete (&rxq->fence_event);return ;
@@ -2286,54 +2336,48 @@ static void mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq,return ; } + pkt_i =0 ;for (i =0 ; i <MANA_RXCOMP_OOB_NUM_PPI ; i++) { - old_buf =NULL ; - pktlen = oob->ppi[i].pkt_len; -if (pktlen ==0 ) -break ; - - curr = rxq->buf_index; - rxbuf_oob = &rxq->rx_oobs[curr]; -WARN_ON_ONCE (rxbuf_oob->wqe_inf.wqe_size_in_bu !=1 ); - -if (unlikely (pktlen > rxq->datasize)) { -/* Increase it even if mana_rx_skb() isn't called. */ - rxq->rx_cq.work_done++; +u32 pkt_hash; - ++ndev->stats.rx_dropped; -netdev_warn_once (ndev, -"Dropped oversized RX packet: len=%u, datasize=%u\n" , - pktlen, rxq->datasize); - -/* Reuse the RX buffer since rxbuf_oob is unchanged. */ +if (coalesced_8) { +/* 8-pkt mode: 2 packets per PPI entry */ + pktlen = oob->ppi[i].pkt_len0; + pkt_hash = oob->ppi[i].pkt_hash0; }else { - -mana_refill_rx_oob (dev, rxq, rxbuf_oob, pktlen, - &old_buf, &old_fp); - -/* Unsuccessful refill will have old_buf == NULL. -* In this case, mana_rx_skb() will drop the packet. -*/ -mana_rx_skb (old_buf, old_fp, oob, rxq, i); + pktlen = oob->ppi[i].pkt_len; + pkt_hash = oob->ppi[i].pkt_hash; } +if (pktlen ==0 ) +break ; -mana_move_wq_tail (rxq->gdma_rq, - rxbuf_oob->wqe_inf.wqe_size_in_bu); - -mana_post_pkt_rxq (rxq); +mana_process_one_rx_pkt (dev, rxq, oob, pktlen, pkt_hash); + pkt_i++;if (!coalesced)break ; + +/* Process 2nd packet from the same PPI in 8-pkt mode */ +if (coalesced_8) { + pktlen = oob->ppi[i].pkt_len1; + pkt_hash = oob->ppi[i].pkt_hash1; +if (pktlen ==0 ) +break ; + +mana_process_one_rx_pkt (dev, rxq, oob, pktlen, + pkt_hash); + pkt_i++; + } }/* Collect coalesced CQE count based on packets processed. -* Coalesced CQEs have at least 2 packets, so index is i - 2. +* Coalesced CQEs have at least 2 packets, so index is pkt_i - 2. */ -if (i >1 ) { +if (pkt_i >1 ) {u64_stats_update_begin (&rxq->stats.syncp); - rxq->stats.coalesced_cqe[i -2 ]++; + rxq->stats.coalesced_cqe[pkt_i -2 ]++;u64_stats_update_end (&rxq->stats.syncp); - }else if (!i && !pktlen) { + }else if (!pkt_i && !pktlen) {u64_stats_update_begin (&rxq->stats.syncp); rxq->stats.pkt_len0_err++;u64_stats_update_end (&rxq->stats.syncp);
@@ -3763,6 +3807,7 @@ static int mana_probe_port(struct mana_context *ac, int port_idx, apc->port_idx = port_idx; apc->link_cfg_error =1 ; apc->cqe_coalescing_enable =0 ; + apc->cqe8_coalescing_enable =0 ;/* Initialize interrupt moderation settings if supported by HW */ if (gc->pf_cap_flags1 &GDMA_PF_CAP_FLAG_1_DYN_INTERRUPT_MODERATION ) {
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +22 -8
@@ -169,7 +169,7 @@ static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data)ethtool_sprintf (&data,"rx_%d_xdp_tx" , i);ethtool_sprintf (&data,"rx_%d_xdp_redirect" , i);ethtool_sprintf (&data,"rx_%d_pkt_len0_err" , i); -for (j =0 ; j <MANA_RXCOMP_OOB_NUM_PPI -1 ; j++) +for (j =0 ; j <MANA_CQE_COAL_PKTS_8 -1 ; j++)ethtool_sprintf (&data,"rx_%d_coalesced_cqe_%d" , i, j +2 ); }
@@ -205,7 +205,7 @@ static void mana_get_ethtool_stats(struct net_device *ndev,u64 xdp_drop;u64 xdp_tx;u64 pkt_len0_err; -u64 coalesced_cqe[MANA_RXCOMP_OOB_NUM_PPI -1 ]; +u64 coalesced_cqe[MANA_CQE_COAL_PKTS_8 -1 ];u64 tso_packets;u64 tso_bytes;u64 tso_inner_packets;
@@ -245,7 +245,7 @@ static void mana_get_ethtool_stats(struct net_device *ndev, xdp_tx = rx_stats->xdp_tx; xdp_redirect = rx_stats->xdp_redirect; pkt_len0_err = rx_stats->pkt_len0_err; -for (j =0 ; j <MANA_RXCOMP_OOB_NUM_PPI -1 ; j++) +for (j =0 ; j <MANA_CQE_COAL_PKTS_8 -1 ; j++) coalesced_cqe[j] = rx_stats->coalesced_cqe[j]; }while (u64_stats_fetch_retry (&rx_stats->syncp, start));
@@ -255,7 +255,7 @@ static void mana_get_ethtool_stats(struct net_device *ndev, data[i++] = xdp_tx; data[i++] = xdp_redirect; data[i++] = pkt_len0_err; -for (j =0 ; j <MANA_RXCOMP_OOB_NUM_PPI -1 ; j++) +for (j =0 ; j <MANA_CQE_COAL_PKTS_8 -1 ; j++) data[i++] = coalesced_cqe[j]; }
@@ -408,6 +408,7 @@ static int mana_get_coalesce(struct net_device *ndev,struct mana_port_context *apc =netdev_priv (ndev); kernel_coal->rx_cqe_frames = + apc->cqe8_coalescing_enable ?MANA_CQE_COAL_PKTS_8 : apc->cqe_coalescing_enable ?MANA_RXCOMP_OOB_NUM_PPI :1 ; kernel_coal->rx_cqe_nsecs = apc->cqe_coalescing_timeout_ns;
@@ -443,6 +444,7 @@ static int mana_set_coalesce(struct net_device *ndev,u16 intr_modr_tx_usec;u16 intr_modr_tx_comp;u8 cqe_coalescing_enable; +u8 cqe8_coalescing_enable;bool rx_dim_enabled;bool tx_dim_enabled; } saved;
@@ -466,10 +468,12 @@ static int mana_set_coalesce(struct net_device *ndev, }if (kernel_coal->rx_cqe_frames !=1 && - kernel_coal->rx_cqe_frames !=MANA_RXCOMP_OOB_NUM_PPI ) { + kernel_coal->rx_cqe_frames !=MANA_RXCOMP_OOB_NUM_PPI && + kernel_coal->rx_cqe_frames !=MANA_CQE_COAL_PKTS_8 ) {NL_SET_ERR_MSG_FMT (extack, -"rx-frames must be 1 or %u, got %u" , +"rx-frames must be 1, %u, or %u, got %u" ,MANA_RXCOMP_OOB_NUM_PPI , +MANA_CQE_COAL_PKTS_8 , kernel_coal->rx_cqe_frames);return -EINVAL ; }
@@ -514,8 +518,15 @@ static int mana_set_coalesce(struct net_device *ndev, saved.tx_dim_enabled = apc->tx_dim_enabled; saved.cqe_coalescing_enable = apc->cqe_coalescing_enable; + saved.cqe8_coalescing_enable = apc->cqe8_coalescing_enable; apc->cqe_coalescing_enable = - kernel_coal->rx_cqe_frames ==MANA_RXCOMP_OOB_NUM_PPI ; + kernel_coal->rx_cqe_frames >=MANA_RXCOMP_OOB_NUM_PPI ; + +if (gc->cqe8_coalescing_sup) + apc->cqe8_coalescing_enable = + kernel_coal->rx_cqe_frames ==MANA_CQE_COAL_PKTS_8 ; +else if (kernel_coal->rx_cqe_frames ==MANA_CQE_COAL_PKTS_8 ) +netdev_info (ndev,"Fall back to RX-CQE x4 coalescing\n" );if (!apc->port_is_up) {WRITE_ONCE (apc->rx_dim_enabled, !!ec->use_adaptive_rx_coalesce);
@@ -523,7 +534,8 @@ static int mana_set_coalesce(struct net_device *ndev,return 0 ; } -if (apc->cqe_coalescing_enable != saved.cqe_coalescing_enable) { +if (apc->cqe_coalescing_enable != saved.cqe_coalescing_enable || + apc->cqe8_coalescing_enable != saved.cqe8_coalescing_enable) {/* CQE coalescing setting is applied via RSS configuration. */ err =mana_config_rss (apc,TRI_STATE_TRUE , false, false);if (err) {
@@ -531,6 +543,8 @@ static int mana_set_coalesce(struct net_device *ndev, err); apc->cqe_coalescing_enable = saved.cqe_coalescing_enable; + apc->cqe8_coalescing_enable = + saved.cqe8_coalescing_enable; apc->intr_modr_rx_usec = saved.intr_modr_rx_usec; apc->intr_modr_rx_comp = saved.intr_modr_rx_comp; apc->intr_modr_tx_usec = saved.intr_modr_tx_usec;
include/net/mana/gdma.h +4 -0
@@ -182,6 +182,7 @@ struct gdma_general_req {#define GDMA_MESSAGE_V2 2#define GDMA_MESSAGE_V3 3#define GDMA_MESSAGE_V4 4 +#define GDMA_MESSAGE_V5 5struct gdma_general_resp {struct gdma_resp_hdr hdr;
@@ -428,6 +429,9 @@ struct gdma_context {/* L2 MTU */ u16 adapter_mtu; +/* NIC supports CQE x8 coalescing */ +bool cqe8_coalescing_sup; +/* This maps a CQ index to the queue structure. */ unsigned int max_num_cqs;struct gdma_queue **cq_table;
include/net/mana/mana.h +33 -10
100 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 22 lines · Haiyang Zhang
From: Haiyang Zhang <[email protected]>
To support up to 8 packets per CQE, put two packet lengths and hash values into one PPI entry by using the reserved fields. Update ethtool handlers to set this feature.
Update per queue stat to show the coalesced CQE counters. This feature is supported on NIC hardware showing the relevant PF flag.Signed-off-by Haiyang Zhang <[email protected]>--- drivers/net/ethernet/microsoft/mana/mana_en.c | 137 ++++++++++++------ .../ethernet/microsoft/mana/mana_ethtool.c | 30 +++- include/net/mana/gdma.h | 4 + include/net/mana/mana.h | 43 ++++-- 4 files changed, 150 insertions(+), 64 deletions(-)drivers/net/ethernet/microsoft/mana/mana_en.c +0
-0@@ -1241,6 +1241,9 @@ int mana_gd_query_device_cfg(struct gdma_context *gc, u32 proto_major_ver,
[...]
Quoted 8 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +7
-0+static void mana_process_one_rx_pkt (struct device *dev,struct mana_rxq *rxq, +struct mana_rxcomp_oob *oob, +u32 pktlen,u32 pkt_hash) +{ +struct mana_recv_buf_oob *rxbuf_oob; +struct net_device *ndev = rxq->ndev; +void *old_buf =NULL ;
drivers/net/ethernet/microsoft/mana/mana_en.c static void mana_refill_rx_oob(struct device *dev, struct mana_rxq *rxq, · line 2267
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +10
-0+bool old_fp; + + rxbuf_oob = &rxq->rx_oobs[rxq->buf_index]; +WARN_ON_ONCE (rxbuf_oob->wqe_inf.wqe_size_in_bu !=1 ); + +if (unlikely (pktlen > rxq->datasize)) { +/* Increase it even if mana_rx_skb() isn't called. */ + rxq->rx_cq.work_done++; + + ++ndev->stats.rx_dropped;
It looks like this code was moved from mana_process_rx_cqe, so this is prob out of scope, but I saw this and was wondering if maybe rx_length_errors is more appropriate?
from if_link.h:
* @rx_length_errors: Number of packets dropped due to invalid length.
* Part of aggregate "frame" errors in /proc/net/dev.
Haiyang Zhang
maintainerQuoted 78 lines
-----Original Message-----
From: Joe Damato <[email protected]>
Sent: Thursday, July 30, 2026 11:55 AM
To: Haiyang Zhang <[email protected]>
Cc: [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Wei Liu <[email protected]>; Dexuan Cui <[email protected]>; Long Li <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Konstantin Taranov <[email protected]>; Simon Horman <[email protected]>; Erni Sri Satya Vennela <[email protected]>; Dipayaan Roy <[email protected]>; Aditya Garg <[email protected]>; Breno Leitao <[email protected]>; linux- [email protected]; [email protected]; Paul Rosswurm <[email protected]>
Subject: [EXTERNAL] Re: [PATCH net-next] net: mana: Extend RX CQE coalescing up to 8 packets[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Quoted 10 lines · Haiyang Zhang
From: Haiyang Zhang <[email protected]>
To support up to 8 packets per CQE, put two packet lengths and hash values into one PPI entry by using the reserved fields. Update ethtool handlers to set this feature.
Update per queue stat to show the coalesced CQE counters. This feature is supported on NIC hardware showing the relevant PF flag.Signed-off-by Haiyang Zhang <[email protected]>Review
Quoted 8 lines
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 137 ++++++++++++------ .../ethernet/microsoft/mana/mana_ethtool.c | 30 +++- include/net/mana/gdma.h | 4 + include/net/mana/mana.h | 43 ++++-- 4 files changed, 150 insertions(+), 64 deletions(-)(quoted diff) +0
-0
b/drivers/net/ethernet/microsoft/mana/mana_en.cdrivers/net/ethernet/microsoft/mana/mana_en.c int mana_gd_query_device_cfg(struct gdma_context
Quoted 4 lines
index
a8c329bdbacf..720d22e6aea9100644drivers/net/ethernet/microsoft/mana/mana_en.c +0
-0@@ -1241,6 +1241,9 @@ int mana_gd_query_device_cfg(struct gdma_context*gc, u32
proto_major_ver,[...]
drivers/net/ethernet/microsoft/mana/mana_en.c int mana_gd_query_device_cfg(struct gdma_context · line 1241
Quoted 2 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +1
-0+static void mana_process_one_rx_pkt(struct device *dev, struct mana_rxq*rxq,
Quoted 6 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +6
-0+struct mana_rxcomp_oob *oob, + u32 pktlen, u32 pkt_hash) +{ + struct mana_recv_buf_oob *rxbuf_oob; +struct net_device *ndev = rxq->ndev; +void *old_buf =NULL ;drivers/net/ethernet/microsoft/mana/mana_en.c static void mana_refill_rx_oob(struct device *dev, struct mana_rxq *rxq, · line 2267
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_en.c +10
-0+bool old_fp; + + rxbuf_oob = &rxq->rx_oobs[rxq->buf_index]; +WARN_ON_ONCE (rxbuf_oob->wqe_inf.wqe_size_in_bu !=1 ); + +if (unlikely (pktlen > rxq->datasize)) { +/* Increase it even if mana_rx_skb() isn't called. */ + rxq->rx_cq.work_done++; + + ++ndev->stats.rx_dropped;It looks like this code was moved from
mana_process_rx_cqe, so this is prob
out of scope, but I saw this and was wondering if mayberx_length_errorsis more
appropriate?
Quoted 4 lines
from
if_link.h:* @rx_length_errors: Number of packets dropped due to invalid length.
* Part of aggregate "frame" errors in/proc/net/dev.
Yes, it's moved from mana_process_rx_cqe(). We can consider a separate patch if any changes are needed here.
I found: "Linux rx_length_errors is a network interface counter that tracks incoming packets dropped because their actual size does not match the packet length stated in the header."
But (pktlen > rxq->datasize) is different, it means the len in OOB is bigger than the data buflen, which is a HW error, and unexpected. So it probably should not be put into "rx_length_errors"?
Thanks,
- Haiyang
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The `mana_rxcomp_perpkt_info` union defines the 8-packet mode layout in a way that incorrectly…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The mana_rxcomp_perpkt_info union defines the 8-packet mode layout in a way that incorrectly rearranges fields, contradicting the commit message and potentially causing the driver to read bogus packet lengths and hashes.
- [Medium] The driver accepts rx-frames=8 via ethtool even when the hardware does not support it (!gc->cqe8_coalescing_sup), silently falling back to 4 packets instead of returning an error. --
--- Patch [1]: [PATCH net-next] net: mana: Extend RX CQE coalescing up to 8 packets --- commit 2083fcc78b90120f37ea18fdedab5ea909bd1068
Author: Haiyang Zhang <[email protected]>
net: mana: Extend RX CQE coalescing up to 8 packets
To support up to 8 packets per CQE, put two packet lengths and hash values into one PPI entry by using the reserved fields. Update ethtool handlers to set this feature and per queue stat to show the coalesced CQE counters. This feature is supported on NIC hardware showing the relevant PF flag.
Quoted 4 lines
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +0
-0
[ ... ]
Quoted 4 lines
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +0
-0@@ -514,8 +518,15 @@ static int mana_set_coalesce(struct net_device *ndev, saved.tx_dim_enabled = apc->tx_dim_enabled; saved.cqe_coalescing_enable = apc->cqe_coalescing_enable;
drivers/net/ethernet/microsoft/mana/mana_ethtool.c static int mana_set_coalesce(struct net_device *ndev, · line 529
Quoted 10 lines
drivers/net/ethernet/microsoft/mana/mana_ethtool.c +8
-1+ saved.cqe8_coalescing_enable = apc->cqe8_coalescing_enable; apc->cqe_coalescing_enable = - kernel_coal->rx_cqe_frames ==MANA_RXCOMP_OOB_NUM_PPI ; + kernel_coal->rx_cqe_frames >=MANA_RXCOMP_OOB_NUM_PPI ; + +if (gc->cqe8_coalescing_sup) + apc->cqe8_coalescing_enable = + kernel_coal->rx_cqe_frames ==MANA_CQE_COAL_PKTS_8 ; +else if (kernel_coal->rx_cqe_frames ==MANA_CQE_COAL_PKTS_8 ) +netdev_info (ndev,"Fall back to RX-CQE x4 coalescing\n" );
[Severity: Medium]
When the hardware does not support 8-packet coalescing, this code logs an info message and falls back to 4 packets while still returning success (0).
Should this instead return an error code like -EINVAL or -EOPNOTSUPP? Silently changing the requested parameter might break userspace configuration scripts that expect ethtool to reject unsupported values.
Quoted 4 lines
include/net/mana/mana.h +0
-0
[ ... ]
Quoted 19 lines
include/net/mana/mana.h +11
-3@@ -238,12 +242,25 @@ struct mana_cqe_header {#define MANA_HASH_L4 \ (NDIS_HASH_TCP_IPV4 | NDIS_HASH_UDP_IPV4 | NDIS_HASH_TCP_IPV6 | \ NDIS_HASH_UDP_IPV6 | NDIS_HASH_TCP_IPV6_EX | NDIS_HASH_UDP_IPV6_EX) +#define MANA_HASH_ENABLE_SUPPORTED \ + (NDIS_HASH_IPV4 | NDIS_HASH_TCP_IPV4 | NDIS_HASH_UDP_IPV4 | \ + NDIS_HASH_IPV6 | NDIS_HASH_TCP_IPV6 | NDIS_HASH_UDP_IPV6) + +union mana_rxcomp_perpkt_info { +struct { +u32 pkt_len :16 ; +u32 reserved1 :16 ; +u32 reserved2; +u32 pkt_hash; + }; -struct mana_rxcomp_perpkt_info { -u32 pkt_len :16 ; -u32 reserved1 :16 ;
include/net/mana/mana.h struct mana_cqe_header { · line 264
Quoted 10 lines
include/net/mana/mana.h +7
-2-u32 reserved2; -u32 pkt_hash; +/* Up to two pkts per PPI entry */ +struct { +u32 pkt_hash0; +u16 pkt_len0; +u16 pkt_len1; +u32 pkt_hash1; + }; };/* HW DATA */
[Severity: High]
The commit message mentions using the reserved fields for the second packet, but does this new structure layout match the original offsets?
In the original structure, pkt_len is at offset 0. However, the new 8-packet struct places pkt_hash0 at offset 0.
On little-endian systems, this will overwrite the original pkt_len position and move pkt_len0 and pkt_len1 to offsets 4 and 6. If the hardware still populates the first packet's length at offset 0, could the driver misinterpret the first 4 bytes as a hash and parse bogus packet lengths, potentially causing 8-packet coalesced packets to be dropped as oversized?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Haiyang Zhang
maintainerQuoted 29 lines
-----Original Message-----
From: Haiyang Zhang <[email protected]>
Sent: Wednesday, July 29, 2026 6:52 PM
To: [email protected]; [email protected]; KY Srinivasan <[email protected]>; Haiyang Zhang <[email protected]>; Wei Liu <[email protected]>; Dexuan Cui <[email protected]>; Long Li <[email protected]>; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Konstantin Taranov <[email protected]>; Simon Horman <[email protected]>; Erni Sri Satya Vennela <[email protected]>; Dipayaan Roy <[email protected]>; Aditya Garg <[email protected]>; Breno Leitao <[email protected]>; linux- [email protected]; [email protected]
Cc: Paul Rosswurm <[email protected]>
Subject: [PATCH net-next] net: mana: Extend RX CQE coalescing up to 8 packetsFrom: Haiyang Zhang <[email protected]>
To support up to 8 packets per CQE, put two packet lengths and hash values into one PPI entry by using the reserved fields. Update ethtool handlers to set this feature.
Update per queue stat to show the coalesced CQE counters. This feature is supported on NIC hardware showing the relevant PF flag.
Quoted 7 lines
Signed-off-by Haiyang Zhang <[email protected]>--- drivers/net/ethernet/microsoft/mana/mana_en.c | 137 ++++++++++++------ .../ethernet/microsoft/mana/mana_ethtool.c | 30 +++- include/net/mana/gdma.h | 4 + include/net/mana/mana.h | 43 ++++-- 4 files changed, 150 insertions(+), 64 deletions(-)
I submitted v2 based on the AI review.