Skip to contentSkip to conversation

bnx2: Add better support for auto-mdix

PATCH In review Michael Chan 3 participants 7 messages Jan 1, 2014 – Jan 2, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover bnx2: Add better support for auto-mdix

Michael Chan (4):
bnx2: Advertise nothing when speed is forced
bnx2: Enable auto-mdix when autoneg is disabled.
bnx2: Report MDI/MDIX status to ethtool.
bnx2: Update version to 2.2.5.

 drivers/net/ethernet/broadcom/bnx2.c |   56 ++++++++++++++++++++++++----------
 drivers/net/ethernet/broadcom/bnx2.h |   10 ++++++
 2 files changed, 50 insertions(+), 16 deletions(-)
#1 lore raw

PATCH 1/4 bnx2: Advertise nothing when speed is forced

The current code does not reset the advertisement register when the speed is forced, leaving the default advertisement value of 10 Mbps. This does not work with some link partners when the next patch enables auto-mdix.

Set advertisement register to 0 if the speed is forced.

---
 drivers/net/ethernet/broadcom/bnx2.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +13 -11
index 0ced358..1ae3348 100644
@@ -2048,29 +2048,27 @@ bnx2_setup_copper_phy(struct bnx2 *bp)
 __releases(&bp->phy_lock)
 __acquires(&bp->phy_lock)
 {
-	u32 bmcr;
+	u32 bmcr, adv_reg, new_adv = 0;
 	u32 new_bmcr;
 
 	bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
 
+	bnx2_read_phy(bp, bp->mii_adv, &adv_reg);
+	adv_reg &= (PHY_ALL_10_100_SPEED | ADVERTISE_PAUSE_CAP |
+		    ADVERTISE_PAUSE_ASYM);
+
+	new_adv = ADVERTISE_CSMA | ethtool_adv_to_mii_adv_t(bp->advertising);
+
 	if (bp->autoneg & AUTONEG_SPEED) {
-		u32 adv_reg, adv1000_reg;
-		u32 new_adv = 0;
+		u32 adv1000_reg;
 		u32 new_adv1000 = 0;
 
-		bnx2_read_phy(bp, bp->mii_adv, &adv_reg);
-		adv_reg &= (PHY_ALL_10_100_SPEED | ADVERTISE_PAUSE_CAP |
-			ADVERTISE_PAUSE_ASYM);
+		new_adv |= bnx2_phy_get_pause_adv(bp);
 
 		bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg);
 		adv1000_reg &= PHY_ALL_1000_SPEED;
 
-		new_adv = ethtool_adv_to_mii_adv_t(bp->advertising);
-		new_adv |= ADVERTISE_CSMA;
-		new_adv |= bnx2_phy_get_pause_adv(bp);
-
 		new_adv1000 |= ethtool_adv_to_mii_ctrl1000_t(bp->advertising);
-
 		if ((adv1000_reg != new_adv1000) ||
 			(adv_reg != new_adv) ||
 			((bmcr & BMCR_ANENABLE) == 0)) {
@@ -2090,6 +2088,10 @@ __acquires(&bp->phy_lock)
 		return 0;
 	}
 
+	/* advertise nothing when forcing speed */
+	if (adv_reg != new_adv)
+		bnx2_write_phy(bp, bp->mii_adv, new_adv);
+
 	new_bmcr = 0;
 	if (bp->req_line_speed == SPEED_100) {
 		new_bmcr |= BMCR_SPEED100;
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/4 bnx2: Enable auto-mdix when autoneg is disabled.

Auto-mdix currently only works if autoneg is enabled. This patch enables auto-mdix all the time by setting a bit in a PHY register. Define meaningful constants for this PHY registers.

---
 drivers/net/ethernet/broadcom/bnx2.c |   12 +++++++++---
 drivers/net/ethernet/broadcom/bnx2.h |    6 ++++++
 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +9 -3
index 1ae3348..b380c69 100644
@@ -2343,9 +2343,15 @@ bnx2_init_copper_phy(struct bnx2 *bp, int reset_phy)
 	}
 
 	/* ethernet@wirespeed */
-	bnx2_write_phy(bp, 0x18, 0x7007);
-	bnx2_read_phy(bp, 0x18, &val);
-	bnx2_write_phy(bp, 0x18, val | (1 << 15) | (1 << 4));
+	bnx2_write_phy(bp, MII_BNX2_AUX_CTL, AUX_CTL_MISC_CTL);
+	bnx2_read_phy(bp, MII_BNX2_AUX_CTL, &val);
+	val |=  AUX_CTL_MISC_CTL_WR | AUX_CTL_MISC_CTL_WIRESPEED;
+
+	/* auto-mdix */
+	if (BNX2_CHIP(bp) == BNX2_CHIP_5709)
+		val |=  AUX_CTL_MISC_CTL_AUTOMDIX;
+
+	bnx2_write_phy(bp, MII_BNX2_AUX_CTL, val);
 	return 0;
 }
 
drivers/net/ethernet/broadcom/bnx2.h +6 -0
index 18cb2d2..39f40d1 100644
@@ -6471,6 +6471,12 @@ struct l2_fhdr {
 
 #define BCM5708S_TX_ACTL3			0x17
 
+#define MII_BNX2_AUX_CTL			0x18
+#define AUX_CTL_MISC_CTL			 0x7007
+#define AUX_CTL_MISC_CTL_WIRESPEED		  (1 << 4)
+#define AUX_CTL_MISC_CTL_AUTOMDIX		  (1 << 9)
+#define AUX_CTL_MISC_CTL_WR			  (1 << 15)
+
 #define MII_BNX2_DSP_RW_PORT			0x15
 #define MII_BNX2_DSP_ADDRESS			0x17
 #define MII_BNX2_DSP_EXPAND_REG			 0x0f00
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/4 bnx2: Report MDI/MDIX status to ethtool.

---
 drivers/net/ethernet/broadcom/bnx2.c |   16 ++++++++++++++++
 drivers/net/ethernet/broadcom/bnx2.h |    4 ++++
 2 files changed, 20 insertions(+), 0 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +16 -0
index b380c69..3fcabd9 100644
@@ -1197,6 +1197,8 @@ bnx2_copper_linkup(struct bnx2 *bp)
 {
 	u32 bmcr;
 
+	bp->phy_flags &= ~BNX2_PHY_FLAG_MDIX;
+
 	bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
 	if (bmcr & BMCR_ANENABLE) {
 		u32 local_adv, remote_adv, common;
@@ -1255,6 +1257,14 @@ bnx2_copper_linkup(struct bnx2 *bp)
 		}
 	}
 
+	if (bp->link_up) {
+		u32 ext_status;
+
+		bnx2_read_phy(bp, MII_BNX2_EXT_STATUS, &ext_status);
+		if (ext_status & EXT_STATUS_MDIX)
+			bp->phy_flags |= BNX2_PHY_FLAG_MDIX;
+	}
+
 	return 0;
 }
 
@@ -6874,6 +6884,12 @@ bnx2_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 	if (netif_carrier_ok(dev)) {
 		ethtool_cmd_speed_set(cmd, bp->line_speed);
 		cmd->duplex = bp->duplex;
+		if (!(bp->phy_flags & BNX2_PHY_FLAG_SERDES)) {
+			if (bp->phy_flags & BNX2_PHY_FLAG_MDIX)
+				cmd->eth_tp_mdix = ETH_TP_MDI_X;
+			else
+				cmd->eth_tp_mdix = ETH_TP_MDI;
+		}
 	}
 	else {
 		ethtool_cmd_speed_set(cmd, -1);
drivers/net/ethernet/broadcom/bnx2.h +4 -0
index 39f40d1..f1cf2c4 100644
@@ -6471,6 +6471,9 @@ struct l2_fhdr {
 
 #define BCM5708S_TX_ACTL3			0x17
 
+#define MII_BNX2_EXT_STATUS			0x11
+#define EXT_STATUS_MDIX				 (1 << 13)
+
 #define MII_BNX2_AUX_CTL			0x18
 #define AUX_CTL_MISC_CTL			 0x7007
 #define AUX_CTL_MISC_CTL_WIRESPEED		  (1 << 4)
@@ -6850,6 +6853,7 @@ struct bnx2 {
 #define BNX2_PHY_FLAG_REMOTE_PHY_CAP		0x00000800
 #define BNX2_PHY_FLAG_FORCED_DOWN		0x00001000
 #define BNX2_PHY_FLAG_NO_PARALLEL		0x00002000
+#define BNX2_PHY_FLAG_MDIX			0x00004000
 
 	u32			mii_bmcr;
 	u32			mii_bmsr;
Signature · 1 line
1.7.1
#4 lore raw

PATCH 4/4 bnx2: Update version to 2.2.5.

---
 drivers/net/ethernet/broadcom/bnx2.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +2 -2
index 3fcabd9..3f3cae2 100644
@@ -58,8 +58,8 @@
 #include "bnx2_fw.h"
 
 #define DRV_MODULE_NAME		"bnx2"
-#define DRV_MODULE_VERSION	"2.2.4"
-#define DRV_MODULE_RELDATE	"Aug 05, 2013"
+#define DRV_MODULE_VERSION	"2.2.5"
+#define DRV_MODULE_RELDATE	"December 20, 2013"
 #define FW_MIPS_FILE_06		"bnx2/bnx2-mips-06-6.2.3.fw"
 #define FW_RV2P_FILE_06		"bnx2/bnx2-rv2p-06-6.0.15.fw"
 #define FW_MIPS_FILE_09		"bnx2/bnx2-mips-09-6.2.1b.fw"
Signature · 1 line
1.7.1
#5 lore raw

Re: [PATCH net-next 3/4] bnx2: Report MDI/MDIX status to ethtool.

In reply to Michael Chan
Quoted 10 lines · Michael Chan
---
 drivers/net/ethernet/broadcom/bnx2.c |   16 ++++++++++++++++
 drivers/net/ethernet/broadcom/bnx2.h |    4 ++++
 2 files changed, 20 insertions(+), 0 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +0 -0
index b380c69..3fcabd9 100644

[...]

drivers/net/ethernet/broadcom/bnx2.c bnx2_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) · line 6892

Quoted 10 lines
drivers/net/ethernet/broadcom/bnx2.c +6 -0
@@ -6874,6 +6884,12 @@ bnx2_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 	if (netif_carrier_ok(dev)) {
 		ethtool_cmd_speed_set(cmd, bp->line_speed);
 		cmd->duplex = bp->duplex;
+		if (!(bp->phy_flags & BNX2_PHY_FLAG_SERDES)) {
+			if (bp->phy_flags & BNX2_PHY_FLAG_MDIX)
+				cmd->eth_tp_mdix = ETH_TP_MDI_X;
+			else
+				cmd->eth_tp_mdix = ETH_TP_MDI;
+		}

[...]

You could also set cmd->eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO to show that auto-MDI-X is supported.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
maintainer
#6 lore raw
In reply to Michael Chan

From: Michael Chan <[email protected]>
Date: Tue, 31 Dec 2013 23:22:31 -0800

Quoted 5 lines

Michael Chan (4):
bnx2: Advertise nothing when speed is forced
bnx2: Enable auto-mdix when autoneg is disabled.
bnx2: Report MDI/MDIX status to ethtool.
bnx2: Update version to 2.2.5.

Series applied, please consider the enhancement for advertising this feature via ethtool that Ben mentioned.