[patch] Bring link down when interface goes down

Eugene Grosbein egrosbein at rdtc.ru
Mon Dec 6 11:48:43 UTC 2010


On 04.12.2010 15:08, Jack Vogel wrote:
> This isn't some simple 'go change this line or parameter',
> there were some problematic issues that my Linux coworkers
> faced, I have to go look into it before I even decide...
> 
> so...patience friend.

For igb(4) the change seems pretty short. At least, it works
for my 82576-based dual-port copper card.

--- if_igb.h.orig	2010-12-06 12:27:54.000000000 +0600
+++ if_igb.h	2010-12-06 12:29:47.000000000 +0600
@@ -450,6 +450,8 @@
 #endif
 
 	void 			*stats;
+	/* Bring link down when interface goes down */
+	int		down_disables_link;
 };
 
 /* ******************************************************************************
--- if_igb.c.orig	2010-11-30 11:14:42.000000000 +0600
+++ if_igb.c	2010-12-06 12:37:10.000000000 +0600
@@ -432,6 +432,13 @@
 	    OID_AUTO, "enable_aim", CTLTYPE_INT|CTLFLAG_RW,
 	    &igb_enable_aim, 1, "Interrupt Moderation");
 
+	adapter->down_disables_link = 0;
+	SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
+	    SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
+	    OID_AUTO, "down_disables_link", CTLTYPE_INT|CTLFLAG_RW,
+	    &adapter->down_disables_link, adapter->down_disables_link,
+	    "Bring link down when interface goes down");
+
 	callout_init_mtx(&adapter->timer, &adapter->core_mtx, 0);
 
 	/* Determine hardware and mac info */
@@ -2070,6 +2077,13 @@
 
 	e1000_led_off(&adapter->hw);
 	e1000_cleanup_led(&adapter->hw);
+
+	if(adapter->down_disables_link) {
+		e1000_power_down_phy(&adapter->hw);
+		igb_handle_link(adapter, 0);
+		/* Reset the phy next time init gets called */
+		adapter->hw.phy.reset_disable = FALSE;
+	}
 }
 
 

However, similar patch applied to em(4) does not work
for my on-board 82574L-based cards: e1000_power_down_phy()
thanslates to e1000_power_down_phy_copper_82571() that does nothing
because mac->ops.check_mng_mode(hw) returns true value
and, therefore, e1000_power_down_phy_copper(hw) is not even called.

Still trying to find a way...

Eugene Grosbein


More information about the freebsd-net mailing list