Thread (9 messages) flat view 9 messages, 2 authors, 1d ago
WARM1d

[PATCH iwl-net v2 2/4] ixgbe: Fix FCoE refcount taking for unsupported adapters

From: Sergey Temerkhanov <hidden>
Date: 2026-09-22 11:36:07
Also in: intel-wired-lan
Subsystem: intel ethernet drivers, networking drivers, the rest · Maintainers: Tony Nguyen, Przemek Kitszel, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

ixgbe_fcoe_enable() increments the FCoE reference count before
checking whether the device supports FCoE. The unsupported adapters
shall not take a reference while the ones which have FCoE already
enabled only need to skip hardware initialization.

Fixes: 27ab76065c0c ("ixgbe: add a refcnt when turning on/off FCoE offload capability")
Signed-off-by: Sergey Temerkhanov <redacted>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
index 54d8b079ada4..6585af527743 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
@@ -838,15 +838,21 @@ int ixgbe_fcoe_enable(struct net_device *netdev)
 	struct ixgbe_fcoe *fcoe = &adapter->fcoe;
 	bool running;
 
+	/* Unsupported adapters do not take a reference */
+	if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE))
+		return -EINVAL;
+
 	/* libfcoe calls ndo_fcoe_disable() even when this callback fails. */
 	atomic_inc(&fcoe->refcnt);
 
 	if (!netif_device_present(netdev))
 		return -ENETDOWN;
 
-	if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE))
-		return -EINVAL;
-
+	/* If offload is enabled, only skip HW init, but keep the reference.
+	 * ixgbe_fcoe_disable() decreases the refcount for this case and only
+	 * disables the offload when the refcount reaches 0. This handles the case
+	 * where multiple offload interfaces are enabled on the same PF (e.g. VLANs)
+	 */
 	if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
 		return -EINVAL;
 
@@ -892,6 +898,9 @@ int ixgbe_fcoe_disable(struct net_device *netdev)
 	struct ixgbe_adapter *adapter = ixgbe_from_netdev(netdev);
 	bool running;
 
+	if (!(adapter->flags & IXGBE_FLAG_FCOE_CAPABLE))
+		return -EINVAL;
+
 	if (!atomic_dec_and_test(&adapter->fcoe.refcnt))
 		return -EINVAL;
 
-- 
2.53.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help