Skip to contentSkip to conversation

Add ethtool to mii advertisment conversion helpers

PATCH Superseded Matt Carlson 4 participants 11 messages Nov 15, 2011 – Nov 17, 2011

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add ethtool to mii advertisment conversion helpers

Translating between ethtool advertisement settings and MII advertisements are common operations for ethernet drivers. This patch adds a set of helper functions that implements the conversion. The patch then modifies a couple of the drivers to use the new functions.

---
 drivers/net/ethernet/broadcom/bnx2.c |   15 +---
 drivers/net/ethernet/broadcom/tg3.c  |   53 +++--------
 drivers/net/ethernet/sun/niu.c       |   15 +---
 drivers/net/mii.c                    |   48 ++--------
 drivers/net/phy/phy_device.c         |   20 +----
 include/linux/mii.h                  |  165 ++++++++++++++++++++++++++++++++++
 6 files changed, 196 insertions(+), 120 deletions(-)
drivers/net/ethernet/broadcom/bnx2.c +3 -12
index 32d1f92..e82b981 100644
@@ -2064,21 +2064,12 @@ __acquires(&bp->phy_lock)
 		bnx2_read_phy(bp, MII_CTRL1000, &adv1000_reg);
 		adv1000_reg &= PHY_ALL_1000_SPEED;
 
-		if (bp->advertising & ADVERTISED_10baseT_Half)
-			new_adv_reg |= ADVERTISE_10HALF;
-		if (bp->advertising & ADVERTISED_10baseT_Full)
-			new_adv_reg |= ADVERTISE_10FULL;
-		if (bp->advertising & ADVERTISED_100baseT_Half)
-			new_adv_reg |= ADVERTISE_100HALF;
-		if (bp->advertising & ADVERTISED_100baseT_Full)
-			new_adv_reg |= ADVERTISE_100FULL;
-		if (bp->advertising & ADVERTISED_1000baseT_Full)
-			new_adv1000_reg |= ADVERTISE_1000FULL;
-
+		new_adv_reg = ethtool_adv_to_mii_100bt(bp->advertising);
 		new_adv_reg |= ADVERTISE_CSMA;
-
 		new_adv_reg |= bnx2_phy_get_pause_adv(bp);
 
+		new_adv1000_reg |= ethtool_adv_to_mii_1000T(bp->advertising);
+
 		if ((adv1000_reg != new_adv1000_reg) ||
 			(adv_reg != new_adv_reg) ||
 			((bmcr & BMCR_ANENABLE) == 0)) {
drivers/net/ethernet/broadcom/tg3.c +13 -40

87 lines not on this page · raw message

drivers/net/ethernet/sun/niu.c +2 -13
index 3ebeb9d..9997be5 100644
@@ -1151,19 +1151,8 @@ static int link_status_mii(struct niu *np, int *link_up_p)
 		supported |= SUPPORTED_1000baseT_Full;
 	lp->supported = supported;
 
-	advertising = 0;
-	if (advert & ADVERTISE_10HALF)
-		advertising |= ADVERTISED_10baseT_Half;
-	if (advert & ADVERTISE_10FULL)
-		advertising |= ADVERTISED_10baseT_Full;
-	if (advert & ADVERTISE_100HALF)
-		advertising |= ADVERTISED_100baseT_Half;
-	if (advert & ADVERTISE_100FULL)
-		advertising |= ADVERTISED_100baseT_Full;
-	if (ctrl1000 & ADVERTISE_1000HALF)
-		advertising |= ADVERTISED_1000baseT_Half;
-	if (ctrl1000 & ADVERTISE_1000FULL)
-		advertising |= ADVERTISED_1000baseT_Full;
+	advertising = mii_adv_to_ethtool_100bt(advert);
+	advertising |= mii_adv_to_ethtool_1000T(ctrl1000);
 
 	if (bmcr & BMCR_ANENABLE) {
 		int neg, neg1000;
drivers/net/mii.c +10 -38

69 lines not on this page · raw message

drivers/net/phy/phy_device.c +3 -17
index 83a5a5a..edb905f 100644
@@ -563,20 +563,9 @@ static int genphy_config_advert(struct phy_device *phydev)
 	if (adv < 0)
 		return adv;
 
-	adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP | 
+	adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4 | ADVERTISE_PAUSE_CAP |
 		 ADVERTISE_PAUSE_ASYM);
-	if (advertise & ADVERTISED_10baseT_Half)
-		adv |= ADVERTISE_10HALF;
-	if (advertise & ADVERTISED_10baseT_Full)
-		adv |= ADVERTISE_10FULL;
-	if (advertise & ADVERTISED_100baseT_Half)
-		adv |= ADVERTISE_100HALF;
-	if (advertise & ADVERTISED_100baseT_Full)
-		adv |= ADVERTISE_100FULL;
-	if (advertise & ADVERTISED_Pause)
-		adv |= ADVERTISE_PAUSE_CAP;
-	if (advertise & ADVERTISED_Asym_Pause)
-		adv |= ADVERTISE_PAUSE_ASYM;
+	adv |= ethtool_adv_to_mii_100bt(advertise);
 
 	if (adv != oldadv) {
 		err = phy_write(phydev, MII_ADVERTISE, adv);
@@ -595,10 +584,7 @@ static int genphy_config_advert(struct phy_device *phydev)
 			return adv;
 
 		adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
-		if (advertise & SUPPORTED_1000baseT_Half)
-			adv |= ADVERTISE_1000HALF;
-		if (advertise & SUPPORTED_1000baseT_Full)
-			adv |= ADVERTISE_1000FULL;
+		adv |= ethtool_adv_to_mii_1000T(advertise);
 
 		if (adv != oldadv) {
 			err = phy_write(phydev, MII_CTRL1000, adv);
include/linux/mii.h +165 -0

171 lines not on this page · raw message

Signature · 1 line
1.7.3.4
maintainer
#1 lore raw

From: "Matt Carlson" <[email protected]>
Date: Tue, 15 Nov 2011 14:00:53 -0800

Quoted 7 lines

Translating between ethtool advertisement settings and MII advertisements are common operations for ethernet drivers. This patch adds a set of helper functions that implements the conversion. The patch then modifies a couple of the drivers to use the new functions.

Doesn't build:

In file included from drivers/net/ethernet/3com/3c59x.c:82:0:
include/linux/mii.h: In function ‘ethtool_adv_to_mii_100bt’:
include/linux/mii.h:254:15: error: ‘ADVERTISED_10baseT_Half’ undeclared (first use in this function) include/linux/mii.h:254:15: note: each undeclared identifier is reported only once for each function it appears in include/linux/mii.h:256:15: error: ‘ADVERTISED_10baseT_Full’ undeclared (first use in this function) include/linux/mii.h:258:15: error: ‘ADVERTISED_100baseT_Half’ undeclared (first use in this function) include/linux/mii.h:260:15: error: ‘ADVERTISED_100baseT_Full’ undeclared (first use in this function) include/linux/mii.h:262:15: error: ‘ADVERTISED_Pause’ undeclared (first use in this function) include/linux/mii.h:264:15: error: ‘ADVERTISED_Asym_Pause’ undeclared (first use in this function)

#2 lore raw
Quoted 13 lines · David Miller

From: "Matt Carlson" <[email protected]>
Date: Tue, 15 Nov 2011 14:00:53 -0800

Quoted 7 lines

Translating between ethtool advertisement settings and MII advertisements are common operations for ethernet drivers. This patch adds a set of helper functions that implements the conversion. The patch then modifies a couple of the drivers to use the new functions.

Doesn't build:

Quoted 9 lines

In file included from drivers/net/ethernet/3com/3c59x.c:82:0:
include/linux/mii.h: In function ?ethtool_adv_to_mii_100bt?:
include/linux/mii.h:254:15: error: ?ADVERTISED_10baseT_Half? undeclared (first use in this function) include/linux/mii.h:254:15: note: each undeclared identifier is reported only once for each function it appears in include/linux/mii.h:256:15: error: ?ADVERTISED_10baseT_Full? undeclared (first use in this function) include/linux/mii.h:258:15: error: ?ADVERTISED_100baseT_Half? undeclared (first use in this function) include/linux/mii.h:260:15: error: ?ADVERTISED_100baseT_Full? undeclared (first use in this function) include/linux/mii.h:262:15: error: ?ADVERTISED_Pause? undeclared (first use in this function) include/linux/mii.h:264:15: error: ?ADVERTISED_Asym_Pause? undeclared (first use in this function)

I forgot to add '#include <linux\ethtool.h>' to mii.h. I guess for the drivers I enabled, ethtool.h was already included. New patch on its way.

#3 lore raw
In reply to Matt Carlson
Quoted 4 lines · Matt Carlson

Translating between ethtool advertisement settings and MII advertisements are common operations for ethernet drivers. This patch adds a set of helper functions that implements the conversion. The patch then modifies a couple of the drivers to use the new functions.

I like this, but:

[....]

Quoted 2 lines
drivers/net/ethernet/broadcom/tg3.c +0 -0

[...]

Quoted 8 lines
drivers/net/ethernet/broadcom/tg3.c +1 -1
@@ -4903,23 +4880,19 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
 	    (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT)) {
 		/* do nothing, just check for link up at the end */
 	} else if (tp->link_config.autoneg == AUTONEG_ENABLE) {
-		u32 adv, new_adv;
+		u32 adv, newadv;
 
 		err |= tg3_readphy(tp, MII_ADVERTISE, &adv);

drivers/net/ethernet/broadcom/tg3.c static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) · line 4889

Quoted 10 lines
drivers/net/ethernet/broadcom/tg3.c +4 -6
-		new_adv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF |
-				  ADVERTISE_1000XPAUSE |
-				  ADVERTISE_1000XPSE_ASYM |
-				  ADVERTISE_SLCT);
-
-		new_adv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
+		newadv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF |
+				 ADVERTISE_1000XPAUSE |
+				 ADVERTISE_1000XPSE_ASYM |
+				 ADVERTISE_SLCT);

Not sure why you're renaming the variable here.

drivers/net/ethernet/broadcom/tg3.c static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) · line 4892

Quoted 6 lines
drivers/net/ethernet/broadcom/tg3.c +2 -4
-		if (tp->link_config.advertising & ADVERTISED_1000baseT_Half)
-			new_adv |= ADVERTISE_1000XHALF;
-		if (tp->link_config.advertising & ADVERTISED_1000baseT_Full)
-			new_adv |= ADVERTISE_1000XFULL;
+		newadv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
+		newadv |= ethtool_adv_to_mii_1000X(tp->link_config.advertising);

Doesn't this generate flow control advertising flags twice? Can the link_config.flowctrl and link_config.advertising fields get out of synch?

[...]

Quoted 14 lines
include/linux/mii.h +8 -0
@@ -240,6 +240,171 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock,
 }
 
 /**
+ * ethtool_adv_to_mii_100bt
+ * @ethadv: the ethtool advertisement settings
+ *
+ * A small helper function that translates ethtool advertisement
+ * settings to phy autonegotiation advertisements for the
+ * MII_ADVERTISE register.
+ */
+static inline u32 ethtool_adv_to_mii_100bt(u32 ethadv)

[...]

Quoted 1 line

+static inline u32 mii_adv_to_ethtool_100bt(u32 adv)

[...]

Quoted 1 line

+static inline u32 ethtool_adv_to_mii_1000T(u32 ethadv)

[...]

Quoted 1 line

+static inline u32 mii_adv_to_ethtool_1000T(u32 adv)

[...]

Quoted 1 line

+#define mii_lpa_to_ethtool_100bt(lpa) mii_adv_to_ethtool_100bt(lpa)

Shouldn't this additionally translate LPA_LPACK into ADVERTISED_Autoneg?

[...]

Quoted 1 line

+static inline u32 mii_lpa_to_ethtool_1000T(u32 lpa)

[...]

Quoted 1 line

+static inline u32 ethtool_adv_to_mii_1000X(u32 ethadv)

[...]

Quoted 1 line

+static inline u32 mii_adv_to_ethtool_1000X(u32 adv)

[...]

I'm not convinced about the naming convention for these. Would it not make more sense to name them consistently by register name and signal type:

ethtool_adv_to_mii_adv_t
mii_adv_to_ethtool_adv_t
ethtool_adv_to_mii_ctrl1000_t
mii_ctrl1000_to_ethtool_adv_t
mii_lpa_to_ethtool_lpa_t
mii_stat1000_to_ethtool_lpa_t
ethtool_adv_to_mii_adv_x
mii_adv_to_ethtool_adv_x

Shouldn't there be mii_lpa_to_ethtool_1000X (or
mii_lpa_to_ethtool_lpa_x)?

Finally, do these need to be inline?

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.
#4 lore raw
Quoted 19 lines · Ben Hutchings
Quoted 4 lines · Matt Carlson

Translating between ethtool advertisement settings and MII advertisements are common operations for ethernet drivers. This patch adds a set of helper functions that implements the conversion. The patch then modifies a couple of the drivers to use the new functions.

I like this, but:

[....]

Quoted 2 lines
drivers/net/ethernet/broadcom/tg3.c +0 -0

[...]

Quoted 7 lines
drivers/net/ethernet/broadcom/tg3.c +1 -1
@@ -4903,23 +4880,19 @@ static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset)
 	    (tp->phy_flags & TG3_PHYFLG_PARALLEL_DETECT)) {
 		/* do nothing, just check for link up at the end */
 	} else if (tp->link_config.autoneg == AUTONEG_ENABLE) {
-		u32 adv, new_adv;
+		u32 adv, newadv;
 
Quoted 13 lines

drivers/net/ethernet/broadcom/tg3.c static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) · line 4889

Quoted 11 lines
drivers/net/ethernet/broadcom/tg3.c +4 -6
 		err |= tg3_readphy(tp, MII_ADVERTISE, &adv);
-		new_adv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF |
-				  ADVERTISE_1000XPAUSE |
-				  ADVERTISE_1000XPSE_ASYM |
-				  ADVERTISE_SLCT);
-
-		new_adv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
+		newadv = adv & ~(ADVERTISE_1000XFULL | ADVERTISE_1000XHALF |
+				 ADVERTISE_1000XPAUSE |
+				 ADVERTISE_1000XPSE_ASYM |
+				 ADVERTISE_SLCT);

Not sure why you're renaming the variable here.

80 column character violations. By eliminating the underscore, I can *just* make it fit.

Quoted 10 lines

drivers/net/ethernet/broadcom/tg3.c static int tg3_setup_fiber_mii_phy(struct tg3 *tp, int force_reset) · line 4892

Quoted 6 lines
drivers/net/ethernet/broadcom/tg3.c +2 -4
-		if (tp->link_config.advertising & ADVERTISED_1000baseT_Half)
-			new_adv |= ADVERTISE_1000XHALF;
-		if (tp->link_config.advertising & ADVERTISED_1000baseT_Full)
-			new_adv |= ADVERTISE_1000XFULL;
+		newadv |= tg3_advert_flowctrl_1000X(tp->link_config.flowctrl);
+		newadv |= ethtool_adv_to_mii_1000X(tp->link_config.advertising);

Doesn't this generate flow control advertising flags twice? Can the link_config.flowctrl and link_config.advertising fields get out of synch?

The tg3 driver doesn't store flow control settings through the advertising field. I thought about changing the driver in that direction and eliminating the tp->link_config.flowctrl field. That would be a separate patch though.

Quoted 17 lines

[...]

Quoted 14 lines
include/linux/mii.h +8 -0
@@ -240,6 +240,171 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock,
 }
 
 /**
+ * ethtool_adv_to_mii_100bt
+ * @ethadv: the ethtool advertisement settings
+ *
+ * A small helper function that translates ethtool advertisement
+ * settings to phy autonegotiation advertisements for the
+ * MII_ADVERTISE register.
+ */
+static inline u32 ethtool_adv_to_mii_100bt(u32 ethadv)

[...]

Quoted 1 line

+static inline u32 mii_adv_to_ethtool_100bt(u32 adv)

Quoted 8 lines

[...]

Quoted 1 line

+static inline u32 ethtool_adv_to_mii_1000T(u32 ethadv)

[...]

Quoted 1 line

+static inline u32 mii_adv_to_ethtool_1000T(u32 adv)

[...]

Quoted 1 line

+#define mii_lpa_to_ethtool_100bt(lpa) mii_adv_to_ethtool_100bt(lpa)

Shouldn't this additionally translate LPA_LPACK into ADVERTISED_Autoneg?

You mean, like this?

static inline u32 mii_lpa_to_ethtool_100bt(u32 lpa)

{
	u32 result = 0;

	if (lpa & LPA_LPACK)
		result |= ADVERTISED_Autoneg;

	return result | mii_adv_to_ethtool_100bt(lpa);
}

Yes, that looks like a better implementation.

Quoted 12 lines

[...]

Quoted 1 line

+static inline u32 mii_lpa_to_ethtool_1000T(u32 lpa)

[...]

Quoted 1 line

+static inline u32 ethtool_adv_to_mii_1000X(u32 ethadv)

[...]

Quoted 1 line

+static inline u32 mii_adv_to_ethtool_1000X(u32 adv)

[...]

I'm not convinced about the naming convention for these. Would it not make more sense to name them consistently by register name and signal type:

Quoted 8 lines

ethtool_adv_to_mii_adv_t
mii_adv_to_ethtool_adv_t
ethtool_adv_to_mii_ctrl1000_t
mii_ctrl1000_to_ethtool_adv_t
mii_lpa_to_ethtool_lpa_t
mii_stat1000_to_ethtool_lpa_t
ethtool_adv_to_mii_adv_x
mii_adv_to_ethtool_adv_x

I don't have a strong preference either way. I'll post the change along with the above modification.

Quoted 2 lines

Shouldn't there be mii_lpa_to_ethtool_1000X (or
mii_lpa_to_ethtool_lpa_x)?

Yes. You're right. Should it just be a preprocessor definition that points to mii_adv_to_ethtool_1000X()?

Quoted 1 line

Finally, do these need to be inline?

I don't have a strong preference here either. Phy code tends to be slower, so there isn't really a strong performance argument. The implementations don't seem to be so large to argue against it though. Would you prefer they not be inlined?

#5 lore raw
Quoted 1 line · Matt Carlson

On Wed, Nov 16, 2011 at 04:34:37PM -0800, Ben Hutchings wrote:

[...]

Quoted 16 lines
Quoted 3 lines
Quoted 1 line

+#define mii_lpa_to_ethtool_100bt(lpa) mii_adv_to_ethtool_100bt(lpa)

Shouldn't this additionally translate LPA_LPACK into ADVERTISED_Autoneg?

You mean, like this?

static inline u32 mii_lpa_to_ethtool_100bt(u32 lpa)

{
	u32 result = 0;

	if (lpa & LPA_LPACK)
		result |= ADVERTISED_Autoneg;

	return result | mii_adv_to_ethtool_100bt(lpa);
}
Quoted 1 line

Yes, that looks like a better implementation.

Think so.

And I think the mii_adv_to_ethtool_* functions should add ADVERTISED_Autoneg unconditionally. But I'm not entirely sure that's right.

Quoted 21 lines
Quoted 12 lines

[...]

Quoted 1 line

+static inline u32 mii_lpa_to_ethtool_1000T(u32 lpa)

[...]

Quoted 1 line

+static inline u32 ethtool_adv_to_mii_1000X(u32 ethadv)

[...]

Quoted 1 line

+static inline u32 mii_adv_to_ethtool_1000X(u32 adv)

[...]

I'm not convinced about the naming convention for these. Would it not make more sense to name them consistently by register name and signal type:

Quoted 8 lines

ethtool_adv_to_mii_adv_t
mii_adv_to_ethtool_adv_t
ethtool_adv_to_mii_ctrl1000_t
mii_ctrl1000_to_ethtool_adv_t
mii_lpa_to_ethtool_lpa_t
mii_stat1000_to_ethtool_lpa_t
ethtool_adv_to_mii_adv_x
mii_adv_to_ethtool_adv_x

Quoted 8 lines

I don't have a strong preference either way. I'll post the change along with the above modification.

Quoted 2 lines

Shouldn't there be mii_lpa_to_ethtool_1000X (or
mii_lpa_to_ethtool_lpa_x)?

Yes. You're right. Should it just be a preprocessor definition that points to mii_adv_to_ethtool_1000X()?

I think that would need to handle LPA_LPACK as well.

Quoted 6 lines
Quoted 1 line

Finally, do these need to be inline?

I don't have a strong preference here either. Phy code tends to be slower, so there isn't really a strong performance argument. The implementations don't seem to be so large to argue against it though. Would you prefer they not be inlined?

I suppose one of us should measure what difference it makes to code size.

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.
#6 lore raw
Quoted 19 lines · Ben Hutchings
Quoted 1 line · Matt Carlson

On Wed, Nov 16, 2011 at 04:34:37PM -0800, Ben Hutchings wrote:

[...]

Quoted 16 lines
Quoted 3 lines
Quoted 1 line

+#define mii_lpa_to_ethtool_100bt(lpa) mii_adv_to_ethtool_100bt(lpa)

Shouldn't this additionally translate LPA_LPACK into ADVERTISED_Autoneg?

You mean, like this?

static inline u32 mii_lpa_to_ethtool_100bt(u32 lpa)

{
	u32 result = 0;

	if (lpa & LPA_LPACK)
		result |= ADVERTISED_Autoneg;

	return result | mii_adv_to_ethtool_100bt(lpa);
}
Quoted 7 lines
Quoted 1 line

Yes, that looks like a better implementation.

Think so.

And I think the mii_adv_to_ethtool_* functions should add ADVERTISED_Autoneg unconditionally. But I'm not entirely sure that's right.

The primary purpose of these functions is to translate the information between two representations. It seems wise to be careful not to add from it or take anything away from it. It is certainly possible to have a valid AN advertisement register configuration, but not have autoneg enabled. Keeping the ADVERTISED_Autoneg out could prevent misuse. Do you agree?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Shouldn't there be mii_lpa_to_ethtool_1000X (or
mii_lpa_to_ethtool_lpa_x)?

Yes. You're right. Should it just be a preprocessor definition that points to mii_adv_to_ethtool_1000X()?

I think that would need to handle LPA_LPACK as well.

I was wondering if that was present in 1000Base-X mode. I didn't see it in my passing glance at a spec.

#7 lore raw
Quoted 28 lines · Matt Carlson
Quoted 19 lines · Ben Hutchings
Quoted 1 line · Matt Carlson

On Wed, Nov 16, 2011 at 04:34:37PM -0800, Ben Hutchings wrote:

[...]

Quoted 16 lines
Quoted 3 lines
Quoted 1 line

+#define mii_lpa_to_ethtool_100bt(lpa) mii_adv_to_ethtool_100bt(lpa)

Shouldn't this additionally translate LPA_LPACK into ADVERTISED_Autoneg?

You mean, like this?

static inline u32 mii_lpa_to_ethtool_100bt(u32 lpa)

{
	u32 result = 0;

	if (lpa & LPA_LPACK)
		result |= ADVERTISED_Autoneg;

	return result | mii_adv_to_ethtool_100bt(lpa);
}
Quoted 7 lines
Quoted 1 line

Yes, that looks like a better implementation.

Think so.

And I think the mii_adv_to_ethtool_* functions should add ADVERTISED_Autoneg unconditionally. But I'm not entirely sure that's right.

Quoted 6 lines

The primary purpose of these functions is to translate the information between two representations. It seems wise to be careful not to add from it or take anything away from it. It is certainly possible to have a valid AN advertisement register configuration, but not have autoneg enabled. Keeping the ADVERTISED_Autoneg out could prevent misuse. Do you agree?

I'm not sure what you mean about misuse. If autoneg is not enabled then the register contents are not used and I don't think the mii_adv_to_ethtool functions should be called at all. But I'm not that bothered either way.

Quoted 10 lines
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Shouldn't there be mii_lpa_to_ethtool_1000X (or
mii_lpa_to_ethtool_lpa_x)?

Yes. You're right. Should it just be a preprocessor definition that points to mii_adv_to_ethtool_1000X()?

I think that would need to handle LPA_LPACK as well.

I was wondering if that was present in 1000Base-X mode. I didn't see it in my passing glance at a spec.

IEEE 802.3-2005 §37.2.1.6 seems to define it similarly to the TP case.

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.
#8 lore raw
In reply to Matt Carlson
Quoted 7 lines · Matt Carlson
Quoted 1 line

Finally, do these need to be inline?

I don't have a strong preference here either. Phy code tends to be slower, so there isn't really a strong performance argument. The implementations don't seem to be so large to argue against it though. Would you prefer they not be inlined?

Since we are defining these in .h file, they need to be inline, right? Otherwise multiple source files including the same .h file will have conflict.

maintainer
#9 lore raw

From: "Michael Chan" <[email protected]>
Date: Wed, 16 Nov 2011 17:21:32 -0800

Quoted 10 lines · Matt Carlson
Quoted 7 lines
Quoted 1 line

Finally, do these need to be inline?

I don't have a strong preference here either. Phy code tends to be slower, so there isn't really a strong performance argument. The implementations don't seem to be so large to argue against it though. Would you prefer they not be inlined?

Quoted 3 lines

Since we are defining these in .h file, they need to be inline, right? Otherwise multiple source files including the same .h file will have conflict.

Yes, if you keep them in the header you have to keep them inline.

Ben, by suggesting to not inline them, is implicitly saying to put them out in a seperate *.c file somewhere, perhaps net/core/ethtool.c or similar. With appropriate EXPORT_SYMBOL() added.

#10 lore raw
Quoted 17 lines · David Miller

From: "Michael Chan" <[email protected]>
Date: Wed, 16 Nov 2011 17:21:32 -0800

Quoted 10 lines · Matt Carlson
Quoted 7 lines
Quoted 1 line

Finally, do these need to be inline?

I don't have a strong preference here either. Phy code tends to be slower, so there isn't really a strong performance argument. The implementations don't seem to be so large to argue against it though. Would you prefer they not be inlined?

Quoted 3 lines

Since we are defining these in .h file, they need to be inline, right? Otherwise multiple source files including the same .h file will have conflict.

Quoted 5 lines

Yes, if you keep them in the header you have to keep them inline.

Ben, by suggesting to not inline them, is implicitly saying to put them out in a seperate *.c file somewhere, perhaps net/core/ethtool.c or similar. With appropriate EXPORT_SYMBOL() added.

I was thinking of putting them in drivers/net/mii.c, like the other functions declared extern in include/linux/mii.h. That would require 'select MII' in Kconfig for the drivers using them.

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.