Patchwork [net-next,6/6] be2net: fix to set ecmd->autoneg correctly

login
register
mail settings
Submitter Ajit Khaparde
Date Aug. 5, 2011, 8:01 p.m.
Message ID <20110805200107.GA13631@akhaparde-VBox>
Download mbox | patch
Permalink /patch/108728/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Ajit Khaparde - Aug. 5, 2011, 8:01 p.m.
Set the autonegotation settings correctly based on the port speed.

Signed-off-by: Suresh Reddy <suresh.reddy@emulex.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@emulex.com>
---
 drivers/net/benet/be_ethtool.c |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
Ben Hutchings - Aug. 5, 2011, 9:51 p.m.
On Fri, 2011-08-05 at 15:01 -0500, Ajit Khaparde wrote:
> Set the autonegotation settings correctly based on the port speed.
[...]

Autonegotiation and multi-speed are two entirely different things.

Selecting a single speed doesn't mean turning autoneg off.  If you
enable only 1000BASE-T or only 10GBASE-T, the PHY must still go through
autoneg to determine whether it is the clock master for the link.

Enabling multiple speeds doesn't mean turning autoneg on.  An SFP+ slot
can take 1G and 10G modules but the modules generally won't support
autoneg.

Ben.

Patch

diff --git a/drivers/net/benet/be_ethtool.c b/drivers/net/benet/be_ethtool.c
index 5dd3ed6..2177c8c 100644
--- a/drivers/net/benet/be_ethtool.c
+++ b/drivers/net/benet/be_ethtool.c
@@ -353,6 +353,8 @@  static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 	u8 mac_speed = 0;
 	u16 link_speed = 0;
 	int status;
+	u16 port_speed = 0;
+	u16 dac_cable_len = 0;
 
 	if ((adapter->link_speed < 0) || (!(netdev->flags & IFF_UP))) {
 		status = be_cmd_link_status_query(adapter, &mac_speed,
@@ -397,11 +399,9 @@  static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 			switch (phy_info.interface_type) {
 			case PHY_TYPE_KR_10GB:
 			case PHY_TYPE_KX4_10GB:
-				ecmd->autoneg = AUTONEG_ENABLE;
 			ecmd->transceiver = XCVR_INTERNAL;
 				break;
 			default:
-				ecmd->autoneg = AUTONEG_DISABLE;
 				ecmd->transceiver = XCVR_EXTERNAL;
 				break;
 			}
@@ -411,12 +411,25 @@  static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
 		adapter->link_speed = ethtool_cmd_speed(ecmd);
 		adapter->port_type = ecmd->port;
 		adapter->transceiver = ecmd->transceiver;
-		adapter->autoneg = ecmd->autoneg;
 	} else {
 		ethtool_cmd_speed_set(ecmd, adapter->link_speed);
 		ecmd->port = adapter->port_type;
 		ecmd->transceiver = adapter->transceiver;
-		ecmd->autoneg = adapter->autoneg;
+	}
+
+	be_cmd_get_port_speed(adapter, adapter->port_num,
+			&dac_cable_len, &port_speed);
+	switch (port_speed) {
+	case SPEED_FORCED_10GB:
+	case SPEED_FORCED_1GB:
+	case SPEED_FORCED_100MB:
+	case SPEED_FORCED_10MB:
+	case SPEED_DEFAULT:
+		ecmd->autoneg = AUTONEG_DISABLE;
+		break;
+	default:
+		ecmd->autoneg = AUTONEG_ENABLE;
+		break;
 	}
 
 	ecmd->duplex = DUPLEX_FULL;