public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: jiawenwu@trustnetic.com
Cc: kees@kernel.org, michal.swiatkowski@linux.intel.com,
	kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch,
	richardcochran@gmail.com, mengyuanlou@net-swift.com,
	jacob.e.keller@intel.com, joe@dama.to, linux@armlinux.org.uk,
	abdun.nihaal@gmail.com, edumazet@google.com, horms@kernel.org,
	davem@davemloft.net, larysa.zaremba@intel.com,
	netdev@vger.kernel.org, leitao@debian.org
Subject: Re: [net-next,v4,09/10] net: wangxun: add Tx timeout process
Date: Tue, 10 Mar 2026 11:51:27 +0100	[thread overview]
Message-ID: <20260310105127.167195-1-pabeni@redhat.com> (raw)
In-Reply-To: <20260306063211.20536-10-jiawenwu@trustnetic.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net: wangxun: add Tx timeout process

This commit implements .ndo_tx_timeout to handle Tx side timeout events.
When a Tx timeout occurs, it triggers a driver reset process.

> diff --git a/drivers/net/ethernet/wangxun/libwx/Makefile b/drivers/net/ethernet/wangxun/libwx/Makefile
> index a71b0ad77de3..c8724bb129aa 100644
> --- a/drivers/net/ethernet/wangxun/libwx/Makefile
> +++ b/drivers/net/ethernet/wangxun/libwx/Makefile
> @@ -4,5 +4,5 @@
>
>  obj-$(CONFIG_LIBWX) += libwx.o
>
> -libwx-objs := wx_hw.o wx_lib.o wx_ethtool.o wx_ptp.o wx_mbx.o wx_sriov.o
> +libwx-objs := wx_hw.o wx_lib.o wx_ethtool.o wx_ptp.o wx_mbx.o wx_sriov.o wx_err.o
>  libwx-objs += wx_vf.o wx_vf_lib.o wx_vf_common.o
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_err.c b/drivers/net/ethernet/wangxun/libwx/wx_err.c
> new file mode 100644
> index 000000000000..bb77bdce69d2
> --- /dev/null
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_err.c

[ ... ]

> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index c65240ca3c28..5a21478a592b 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c

[ ... ]

> @@ -742,6 +743,48 @@ static struct netdev_queue *wx_txring_txq(const struct wx_ring *ring)
>  	return netdev_get_tx_queue(ring->netdev, ring->queue_index);
>  }
>
> +static u64 wx_get_tx_pending(struct wx_ring *ring)
> +{
> +	unsigned int head, tail;
> +
> +	head = ring->next_to_clean;
> +	tail = ring->next_to_use;
> +
> +	return ((head <= tail) ? tail : tail + ring->count) - head;
> +}
> +
> +bool wx_check_tx_hang(struct wx_ring *ring)
> +{
> +	u64 tx_done_old = ring->tx_stats.tx_done_old;
> +	u64 tx_pending = wx_get_tx_pending(ring);
> +	u64 tx_done = ring->stats.packets;
> +
> +	clear_bit(WX_TX_DETECT_HANG, ring->state);
> +
> +	/*
> +	 * Check for a hung queue, but be thorough. This verifies
> +	 * that a transmit has been completed since the previous
> +	 * check AND there is at least one packet pending. The
> +	 * ARMED bit is set to indicate a potential hang. The
> +	 * bit is cleared if a pause frame is received to remove
> +	 * false hang detection due to PFC or 802.3x frames. By
> +	 * requiring this to fail twice we avoid races with
> +	 * pfc clearing the ARMED bit and conditions where we
> +	 * run the check_tx_hang logic with a transmit completion
> +	 * pending but without time to complete it yet.
> +	 */

The comment here mentions that "the bit is cleared if a pause frame is
received to remove false hang detection due to PFC or 802.3x frames."
However, I don't see any code in the wangxun driver that clears
WX_HANG_CHECK_ARMED when pause frames are received.

Looking at where WX_HANG_CHECK_ARMED is used in the driver:

drivers/net/ethernet/wangxun/libwx/wx_lib.c:wx_check_tx_hang() {
    ...
    clear_bit(WX_TX_DETECT_HANG, ring->state);
    ...
    if (tx_done_old == tx_done && tx_pending)
        return test_and_set_bit(WX_HANG_CHECK_ARMED, ring->state);
    ...
    clear_bit(WX_HANG_CHECK_ARMED, ring->state);
    return false;
}

The bit is only cleared within wx_check_tx_hang() itself when packets
have completed or when there are no pending packets. The driver does
support flow control (both ngbe and txgbe implement get_pauseparam and
set_pauseparam and advertise MAC_SYM_PAUSE/MAC_ASYM_PAUSE capabilities).

Won't legitimate TX stalls caused by pause frames be misidentified as
hangs after two service timer intervals, triggering unnecessary adapter
resets? The ixgbe driver this appears to be based on has
ixgbe_update_xoff_received() which clears __IXGBE_HANG_CHECK_ARMED when
flow control pause frames are received.

Should the wangxun driver implement similar pause frame handling to
prevent false hang detections, or should the comment be updated to
reflect the current behavior?

> +	if (tx_done_old == tx_done && tx_pending)
> +		/* make sure it is true for two checks in a row */
> +		return test_and_set_bit(WX_HANG_CHECK_ARMED, ring->state);
> +
> +	/* update completed stats and continue */
> +	ring->tx_stats.tx_done_old = tx_done;
> +	/* reset the countdown */
> +	clear_bit(WX_HANG_CHECK_ARMED, ring->state);
> +
> +	return false;
> +}

[ ... ]


  reply	other threads:[~2026-03-10 10:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06  6:32 [PATCH net-next v4 00/10] Wangxun improvement and new support Jiawen Wu
2026-03-06  6:32 ` [PATCH net-next v4 01/10] net: ngbe: remove netdev->ethtool->wol_enabled setting Jiawen Wu
2026-03-06  6:32 ` [PATCH net-next v4 02/10] net: ngbe: move the WOL functions to libwx Jiawen Wu
2026-03-06  6:32 ` [PATCH net-next v4 03/10] net: ngbe: remove redundant macros Jiawen Wu
2026-03-06  6:32 ` [PATCH net-next v4 04/10] net: ngbe: improve the reset flow Jiawen Wu
2026-03-06  6:32 ` [PATCH net-next v4 05/10] net: wangxun: move reusable PCI driver ops functions into libwx Jiawen Wu
2026-03-06  6:32 ` [PATCH net-next v4 06/10] net: txgbe: add power management support Jiawen Wu
2026-03-06  6:32 ` [PATCH net-next v4 07/10] net: wangxun: move ethtool_ops.set_channels into libwx Jiawen Wu
2026-03-06  6:32 ` [PATCH net-next v4 08/10] net: wangxun: delete service_timer before cancel service_work Jiawen Wu
2026-03-06  6:32 ` [PATCH net-next v4 09/10] net: wangxun: add Tx timeout process Jiawen Wu
2026-03-10 10:51   ` Paolo Abeni [this message]
2026-03-06  6:32 ` [PATCH net-next v4 10/10] net: wangxun: implement pci_error_handlers ops Jiawen Wu
2026-03-10 10:51   ` [net-next,v4,10/10] " Paolo Abeni

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=20260310105127.167195-1-pabeni@redhat.com \
    --to=pabeni@redhat.com \
    --cc=abdun.nihaal@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jiawenwu@trustnetic.com \
    --cc=joe@dama.to \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=larysa.zaremba@intel.com \
    --cc=leitao@debian.org \
    --cc=linux@armlinux.org.uk \
    --cc=mengyuanlou@net-swift.com \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.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