* [PATCH net-next v04 1/4] hinic3: Fix the RX stalls in hinic3_rx_poll()
2026-11-17 12:08 [PATCH net-next v04 0/4] net: hinic3: Bugfix for later patch-set Fan Gong
@ 2026-11-17 12:08 ` Fan Gong
2026-11-17 12:08 ` [PATCH net-next v04 2/4] hinic3: Read the queue counters once per u64_stats retry loop Fan Gong
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Fan Gong @ 2026-11-17 12:08 UTC (permalink / raw)
To: Fan Gong, Wu Di, Teng Peisen, netdev, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Andrew Lunn, Ioana Ciornei, Maxime Chevallier, Mohsin Bashir,
Dimitri Daskalakis, Harshitha Ramamurthy, Larysa Zaremba,
Vadim Fedorenko
Cc: linux-kernel, linux-doc, Zhou Shuai, Wu Like
hinic3_rx_poll() can leave the loop with a completed CQE still sitting at
the head of the ring, or with no WQE left to receive into, and still
return nr_pkts, which is below budget. hinic3_poll() then calls
napi_complete_done() and re-enables the MSI-X interrupt, which is edge
triggered, so nothing re-arms the queue if no further packet arrives.
Three exits behave this way:
- a large LRO packet consumed enough WQEs to cross lro_replenish_thld;
- napi_alloc_skb() failed in recv_one_pkt();
- hinic3_rx_fill_buffers() posted fewer WQEs than rxq->delta - 1 because
page_pool_dev_alloc_frag() failed.
The first two leave a completed CQE unprocessed. The third leaves the
device without a WQE to receive into: it then drops every packet and,
because no CQE is written, raises no interrupt either, so the queue stays
dead until the interface is reset.
Return budget from all three paths so that hinic3_poll() skips
napi_complete_done() and NAPI runs again immediately.
When recv_one_pkt() fails no CQE is consumed and no state is advanced, so
the same CQE is simply retried on the next poll; this is the only way to
make progress, as the completed CQE cannot be dropped. Likewise
hinic3_rx_fill_buffers() keeps the WQEs it could not post accounted for in
rxq->delta, so the next poll retries the refill and the ring is complete
again as soon as a full refill succeeds. All three failures are transient
(memory pressure), which bounds the immediate repoll, and i40e, ice and
iavf return budget on a ring refill failure in the same way. A deferred
refill would need to be serialized against hinic3_rx_poll(), which
retries the same WQEs from rxq->delta, so the poll based retry is used
instead.
Fixes: 17fcb3dc12bb ("hinic3: module initialization and tx/rx logic")
Co-developed-by: Wu Di <wudi234@huawei.com>
Signed-off-by: Wu Di <wudi234@huawei.com>
Co-developed-by: Teng Peisen <tengpeisen@huawei.com>
Signed-off-by: Teng Peisen <tengpeisen@huawei.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
.../net/ethernet/huawei/hinic3/hinic3_rx.c | 22 ++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
index 309ab5901379..9a02a7bf6c50 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
@@ -555,6 +555,7 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget)
struct hinic3_nic_dev *nic_dev = netdev_priv(rxq->netdev);
u32 sw_ci, status, pkt_len, vlan_len;
struct hinic3_rq_cqe *rx_cqe;
+ bool poll_again = false;
u32 num_wqe = 0;
int nr_pkts = 0;
u16 num_lro;
@@ -571,8 +572,10 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget)
vlan_len = le32_to_cpu(rx_cqe->vlan_len);
pkt_len = RQ_CQE_SGE_GET(vlan_len, LEN);
- if (recv_one_pkt(rxq, rx_cqe, pkt_len, vlan_len, status))
+ if (recv_one_pkt(rxq, rx_cqe, pkt_len, vlan_len, status)) {
+ poll_again = true;
break;
+ }
nr_pkts++;
num_lro = RQ_CQE_STATUS_GET(status, NUM_LRO);
@@ -581,12 +584,21 @@ int hinic3_rx_poll(struct hinic3_rxq *rxq, int budget)
rx_cqe->status = 0;
- if (num_wqe >= nic_dev->lro_replenish_thld)
+ if (num_wqe >= nic_dev->lro_replenish_thld) {
+ poll_again = true;
break;
+ }
}
- if (rxq->delta >= HINIC3_RX_BUFFER_WRITE)
- hinic3_rx_fill_buffers(rxq);
+ if (rxq->delta >= HINIC3_RX_BUFFER_WRITE) {
+ u32 free_wqebbs = rxq->delta - 1;
+
+ /* Refill stops at the first failed allocation, so a short
+ * refill may leave the ring without any WQE posted.
+ */
+ if (hinic3_rx_fill_buffers(rxq) != free_wqebbs)
+ poll_again = true;
+ }
- return nr_pkts;
+ return poll_again ? budget : nr_pkts;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-next v04 2/4] hinic3: Read the queue counters once per u64_stats retry loop
2026-11-17 12:08 [PATCH net-next v04 0/4] net: hinic3: Bugfix for later patch-set Fan Gong
2026-11-17 12:08 ` [PATCH net-next v04 1/4] hinic3: Fix the RX stalls in hinic3_rx_poll() Fan Gong
@ 2026-11-17 12:08 ` Fan Gong
2026-11-17 12:08 ` [PATCH net-next v04 3/4] hinic3: Wrap long lines and rename q_params Fan Gong
2026-11-17 12:08 ` [PATCH net-next v04 4/4] hinic3: Keep max_qps at the hardware maximum when RSS setup fails Fan Gong
3 siblings, 0 replies; 5+ messages in thread
From: Fan Gong @ 2026-11-17 12:08 UTC (permalink / raw)
To: Fan Gong, Wu Di, Teng Peisen, netdev, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Andrew Lunn, Ioana Ciornei, Maxime Chevallier, Mohsin Bashir,
Dimitri Daskalakis, Harshitha Ramamurthy, Larysa Zaremba,
Vadim Fedorenko
Cc: linux-kernel, linux-doc, Zhou Shuai, Wu Like
hinic3_get_stats64() accumulates the per-queue counters with += inside the
u64_stats_fetch_begin()/u64_stats_fetch_retry() sequence. A retry repeats
the body, so the values read by an aborted pass would be counted twice.
Read the snapshot of one queue into the locals instead, and add it to the
rtnl_link_stats64 fields after the loop.
This cannot trigger today: the driver depends on 64BIT, where
u64_stats_fetch_retry() always returns false, and the only writers of
these counters are the clean_stats() helpers, which run before the queues
are used. The change is a prerequisite for the per-queue statistics that
will populate them, so it carries no Fixes: tag and reports the same
values as before.
While at it, drop the dead stores into the locals before the loops: every
iteration overwrites them before they are read.
Also drop the nic_dev->txqs and nic_dev->rxqs NULL checks. Both arrays
are allocated by hinic3_sw_init() before register_netdev() and freed by
hinic3_sw_uninit() after unregister_netdev(), and the loops are bounded by
nic_dev->max_qps, the number of entries they were allocated with.
rx_errors keeps reporting csum_errors + other_errors. Neither counter is
populated yet, and the checksum error accounting together with its
"csum_bad" queue statistic belongs to the queue-stats work that adds the
writer.
Co-developed-by: Wu Di <wudi234@huawei.com>
Signed-off-by: Wu Di <wudi234@huawei.com>
Co-developed-by: Teng Peisen <tengpeisen@huawei.com>
Signed-off-by: Teng Peisen <tengpeisen@huawei.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
.../huawei/hinic3/hinic3_netdev_ops.c | 43 +++++++------------
1 file changed, 15 insertions(+), 28 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c b/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c
index da73811641a9..6007e0e58478 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c
@@ -791,49 +791,36 @@ static void hinic3_get_stats64(struct net_device *netdev,
unsigned int start;
int i;
- bytes = 0;
- packets = 0;
- dropped = 0;
for (i = 0; i < nic_dev->max_qps; i++) {
- if (!nic_dev->txqs)
- break;
-
txq = &nic_dev->txqs[i];
txq_stats = &txq->txq_stats;
do {
start = u64_stats_fetch_begin(&txq_stats->syncp);
- bytes += txq_stats->bytes;
- packets += txq_stats->packets;
- dropped += txq_stats->dropped;
+ bytes = txq_stats->bytes;
+ packets = txq_stats->packets;
+ dropped = txq_stats->dropped;
} while (u64_stats_fetch_retry(&txq_stats->syncp, start));
+ stats->tx_packets += packets;
+ stats->tx_bytes += bytes;
+ stats->tx_dropped += dropped;
}
- stats->tx_packets = packets;
- stats->tx_bytes = bytes;
- stats->tx_dropped = dropped;
- bytes = 0;
- packets = 0;
- errors = 0;
- dropped = 0;
for (i = 0; i < nic_dev->max_qps; i++) {
- if (!nic_dev->rxqs)
- break;
-
rxq = &nic_dev->rxqs[i];
rxq_stats = &rxq->rxq_stats;
do {
start = u64_stats_fetch_begin(&rxq_stats->syncp);
- bytes += rxq_stats->bytes;
- packets += rxq_stats->packets;
- errors += rxq_stats->csum_errors +
- rxq_stats->other_errors;
- dropped += rxq_stats->dropped;
+ bytes = rxq_stats->bytes;
+ packets = rxq_stats->packets;
+ errors = rxq_stats->csum_errors +
+ rxq_stats->other_errors;
+ dropped = rxq_stats->dropped;
} while (u64_stats_fetch_retry(&rxq_stats->syncp, start));
+ stats->rx_packets += packets;
+ stats->rx_bytes += bytes;
+ stats->rx_errors += errors;
+ stats->rx_dropped += dropped;
}
- stats->rx_packets = packets;
- stats->rx_bytes = bytes;
- stats->rx_errors = errors;
- stats->rx_dropped = dropped;
}
static void hinic3_nic_set_rx_mode(struct net_device *netdev)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-next v04 3/4] hinic3: Wrap long lines and rename q_params
2026-11-17 12:08 [PATCH net-next v04 0/4] net: hinic3: Bugfix for later patch-set Fan Gong
2026-11-17 12:08 ` [PATCH net-next v04 1/4] hinic3: Fix the RX stalls in hinic3_rx_poll() Fan Gong
2026-11-17 12:08 ` [PATCH net-next v04 2/4] hinic3: Read the queue counters once per u64_stats retry loop Fan Gong
@ 2026-11-17 12:08 ` Fan Gong
2026-11-17 12:08 ` [PATCH net-next v04 4/4] hinic3: Keep max_qps at the hardware maximum when RSS setup fails Fan Gong
3 siblings, 0 replies; 5+ messages in thread
From: Fan Gong @ 2026-11-17 12:08 UTC (permalink / raw)
To: Fan Gong, Wu Di, Teng Peisen, netdev, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Andrew Lunn, Ioana Ciornei, Maxime Chevallier, Mohsin Bashir,
Dimitri Daskalakis, Harshitha Ramamurthy, Larysa Zaremba,
Vadim Fedorenko
Cc: linux-kernel, linux-doc, Zhou Shuai, Wu Like
Wrap the long function signatures of hinic3_alloc_txrxq_resources(),
hinic3_free_txrxq_resources(), hinic3_alloc_channel_resources() and
hinic3_free_channel_resources() so that they fit in 80 columns.
While at it, rename the trxq_params argument of
hinic3_alloc_channel_resources() and hinic3_free_channel_resources()
to q_params, matching the name used by the other queue parameter
helpers. No expression, call or error path changes.
Co-developed-by: Wu Di <wudi234@huawei.com>
Signed-off-by: Wu Di <wudi234@huawei.com>
Co-developed-by: Teng Peisen <tengpeisen@huawei.com>
Signed-off-by: Teng Peisen <tengpeisen@huawei.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
.../huawei/hinic3/hinic3_netdev_ops.c | 34 +++++++++++--------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c b/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c
index 6007e0e58478..943310274a69 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c
@@ -121,8 +121,9 @@ static void hinic3_destroy_num_qps(struct net_device *netdev)
kfree(nic_dev->qps_msix_entries);
}
-static int hinic3_alloc_txrxq_resources(struct net_device *netdev,
- struct hinic3_dyna_txrxq_params *q_params)
+static int
+hinic3_alloc_txrxq_resources(struct net_device *netdev,
+ struct hinic3_dyna_txrxq_params *q_params)
{
int err;
@@ -176,8 +177,9 @@ static int hinic3_alloc_txrxq_resources(struct net_device *netdev,
return err;
}
-static void hinic3_free_txrxq_resources(struct net_device *netdev,
- struct hinic3_dyna_txrxq_params *q_params)
+static void
+hinic3_free_txrxq_resources(struct net_device *netdev,
+ struct hinic3_dyna_txrxq_params *q_params)
{
hinic3_free_rxqs_res(netdev, q_params->num_qps, q_params->rq_depth,
q_params->rxqs_res);
@@ -251,16 +253,17 @@ static void hinic3_remove_configure(struct net_device *netdev)
hinic3_rss_uninit(netdev);
}
-static int hinic3_alloc_channel_resources(struct net_device *netdev,
- struct hinic3_dyna_qp_params *qp_params,
- struct hinic3_dyna_txrxq_params *trxq_params)
+static int
+hinic3_alloc_channel_resources(struct net_device *netdev,
+ struct hinic3_dyna_qp_params *qp_params,
+ struct hinic3_dyna_txrxq_params *q_params)
{
struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
int err;
- qp_params->num_qps = trxq_params->num_qps;
- qp_params->sq_depth = trxq_params->sq_depth;
- qp_params->rq_depth = trxq_params->rq_depth;
+ qp_params->num_qps = q_params->num_qps;
+ qp_params->sq_depth = q_params->sq_depth;
+ qp_params->rq_depth = q_params->rq_depth;
err = hinic3_alloc_qps(nic_dev, qp_params);
if (err) {
@@ -268,7 +271,7 @@ static int hinic3_alloc_channel_resources(struct net_device *netdev,
return err;
}
- err = hinic3_alloc_txrxq_resources(netdev, trxq_params);
+ err = hinic3_alloc_txrxq_resources(netdev, q_params);
if (err) {
netdev_err(netdev, "Failed to alloc txrxq resources\n");
hinic3_free_qps(nic_dev, qp_params);
@@ -278,13 +281,14 @@ static int hinic3_alloc_channel_resources(struct net_device *netdev,
return 0;
}
-static void hinic3_free_channel_resources(struct net_device *netdev,
- struct hinic3_dyna_qp_params *qp_params,
- struct hinic3_dyna_txrxq_params *trxq_params)
+static void
+hinic3_free_channel_resources(struct net_device *netdev,
+ struct hinic3_dyna_qp_params *qp_params,
+ struct hinic3_dyna_txrxq_params *q_params)
{
struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
- hinic3_free_txrxq_resources(netdev, trxq_params);
+ hinic3_free_txrxq_resources(netdev, q_params);
hinic3_free_qps(nic_dev, qp_params);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH net-next v04 4/4] hinic3: Keep max_qps at the hardware maximum when RSS setup fails
2026-11-17 12:08 [PATCH net-next v04 0/4] net: hinic3: Bugfix for later patch-set Fan Gong
` (2 preceding siblings ...)
2026-11-17 12:08 ` [PATCH net-next v04 3/4] hinic3: Wrap long lines and rename q_params Fan Gong
@ 2026-11-17 12:08 ` Fan Gong
3 siblings, 0 replies; 5+ messages in thread
From: Fan Gong @ 2026-11-17 12:08 UTC (permalink / raw)
To: Fan Gong, Wu Di, Teng Peisen, netdev, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
Andrew Lunn, Ioana Ciornei, Maxime Chevallier, Mohsin Bashir,
Dimitri Daskalakis, Harshitha Ramamurthy, Larysa Zaremba,
Vadim Fedorenko
Cc: linux-kernel, linux-doc, Zhou Shuai, Wu Like
nic_dev->max_qps sizes the per-queue software arrays: txqs, rxqs,
intr_coalesce and qps_msix_entries are allocated with one entry per
max_qps by hinic3_sw_init() and hinic3_open(). The number of queues the
driver uses is nic_dev->q_params.num_qps: decide_num_qps() clamps it to
max_qps and hinic3_config_num_qps() forces it to 1 on every open while
HINIC3_RSS_ENABLE is clear.
hinic3_try_to_enable_rss() also shrank max_qps to 1 on its error paths.
The netdev is created with alloc_etherdev_mq(..., max_qps) queues, while
netif_set_real_num_queues() only lowers real_num_{tx,rx}_queues on a
successful open, so between probe and the first open the queue count the
netdev advertises and the size of these arrays disagreed.
This is a design change, not a bug fix, so it carries no Fixes: tag: the
old fallback was self consistent (one txq, one rxq, one coalesce entry,
one MSI-X entry and num_qps = 1), and nothing can reach the mismatch
today. hinic3_xmit_frame() is bounded by q_params.num_qps and
hinic3_get_stats64() by max_qps, and the queue count cannot grow later
either, as the driver has no ethtool set_channels or set_rxfh callback.
Keeping the arrays at the hardware maximum is what the per-queue
statistics that will walk real_num_*_queues need, since they must not be
able to index past the end of a one-element array.
After this change nothing sets max_qps to 1 any more. Keep it at
hinic3_func_max_qnum() in every branch, which is also the value
hinic3_init_nic_io() uses for the hardware queue capacity, and reduce
only q_params.num_qps. err_reset_q_params() now sets it to 1 explicitly
instead of copying max_qps, since one queue is what the device uses while
RSS is disabled.
Co-developed-by: Wu Di <wudi234@huawei.com>
Signed-off-by: Wu Di <wudi234@huawei.com>
Co-developed-by: Teng Peisen <tengpeisen@huawei.com>
Signed-off-by: Teng Peisen <tengpeisen@huawei.com>
Signed-off-by: Fan Gong <gongfan1@huawei.com>
---
| 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
--git a/drivers/net/ethernet/huawei/hinic3/hinic3_rss.c b/drivers/net/ethernet/huawei/hinic3/hinic3_rss.c
index 25db74d8c7dd..a5717e728545 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_rss.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_rss.c
@@ -312,10 +312,8 @@ void hinic3_try_to_enable_rss(struct net_device *netdev)
goto err_reset_q_params;
err = alloc_rss_resource(netdev);
- if (err) {
- nic_dev->max_qps = 1;
+ if (err)
goto err_reset_q_params;
- }
set_bit(HINIC3_RSS_ENABLE, &nic_dev->flags);
decide_num_qps(netdev);
@@ -324,7 +322,6 @@ void hinic3_try_to_enable_rss(struct net_device *netdev)
if (err) {
dev_err(hwdev->dev, "Failed to set hardware rss parameters\n");
hinic3_clear_rss_config(netdev);
- nic_dev->max_qps = 1;
goto err_reset_q_params;
}
@@ -332,5 +329,5 @@ void hinic3_try_to_enable_rss(struct net_device *netdev)
err_reset_q_params:
clear_bit(HINIC3_RSS_ENABLE, &nic_dev->flags);
- nic_dev->q_params.num_qps = nic_dev->max_qps;
+ nic_dev->q_params.num_qps = 1;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread