Thread (21 messages) 21 messages, 3 authors, 2026-06-03

RE: [PATCH net-next v4 5/5] net: wangxun: implement pci_error_handlers ops

From: Jiawen Wu <jiawenwu@trustnetic.com>
Date: 2026-06-03 02:52:19

On Tue, Jun 2, 2026 7:30 PM, Larysa Zaremba wrote:
On Mon, Jun 01, 2026 at 03:22:21PM +0800, Jiawen Wu wrote:
quoted
Support AER driver to handle the PCIe errors.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ethernet/wangxun/libwx/wx_err.c   | 111 ++++++++++++++++++
 drivers/net/ethernet/wangxun/libwx/wx_err.h   |   2 +
 drivers/net/ethernet/wangxun/libwx/wx_type.h  |   1 +
 drivers/net/ethernet/wangxun/ngbe/ngbe_main.c |   9 +-
 .../net/ethernet/wangxun/txgbe/txgbe_main.c   |   8 +-
 5 files changed, 127 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/wangxun/libwx/wx_err.c b/drivers/net/ethernet/wangxun/libwx/wx_err.c
index e249cea874be..ae5d14071f3d 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_err.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_err.c
@@ -4,11 +4,122 @@

 #include <linux/netdevice.h>
 #include <linux/pci.h>
+#include <linux/aer.h>

 #include "wx_type.h"
 #include "wx_lib.h"
 #include "wx_err.h"

+/**
+ * wx_io_error_detected - called when PCI error is detected
+ * @pdev: Pointer to PCI device
+ * @state: The current pci connection state
+ *
+ * Return: pci_ers_result_t.
+ *
+ * This function is called after a PCI bus error affecting
+ * this device has been detected.
+ */
+static pci_ers_result_t wx_io_error_detected(struct pci_dev *pdev,
+					     pci_channel_state_t state)
+{
+	struct wx *wx = pci_get_drvdata(pdev);
+	struct net_device *netdev;
+
+	if (!wx)
+		return PCI_ERS_RESULT_DISCONNECT;
+
+	netdev = wx->netdev;
+	if (!netif_device_present(netdev))
+		return PCI_ERS_RESULT_DISCONNECT;
+
+	if (state == pci_channel_io_perm_failure)
+		return PCI_ERS_RESULT_DISCONNECT;
+
+	rtnl_lock();
+	netif_device_detach(netdev);
Sashiko says:

 "Calling netif_device_detach() stops new packets from entering the TX queue but
  doesn't wait for currently executing ndo_start_xmit operations to complete,
  which netif_tx_disable() would do."

Device detaching does not grab __netif_tx_lock(), so it does seem like
netif_device_detach() leaves some race possibilities.
netif_tx_disable() is missed in soft_quiesce(). I'll add it.
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help