aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-04-29 04:21:53 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-29 20:32:37 -0400
commit0c09c1a49cc7b819b33566a49d9901f7cfdd6889 (patch)
treee10fc988a21ca0b3e1550ae905b96cc444f90a76
parent3f926da82f128c68c479247b1771729b9487502a (diff)
ethtool/mdio: Report MDIO mode support and link partner advertising
Add mdio_support and lp_advertising fields to ethtool_cmd. Set these in mdio45_ethtool_gset{,_npage}(). Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/mdio.c19
-rw-r--r--include/linux/ethtool.h4
-rw-r--r--include/linux/mdio.h5
3 files changed, 18 insertions, 10 deletions
diff --git a/drivers/net/mdio.c b/drivers/net/mdio.c
index 2fb0d16b61f7..ee383c256931 100644
--- a/drivers/net/mdio.c
+++ b/drivers/net/mdio.c
@@ -173,6 +173,8 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
173 173
174 ecmd->transceiver = XCVR_INTERNAL; 174 ecmd->transceiver = XCVR_INTERNAL;
175 ecmd->phy_address = mdio->prtad; 175 ecmd->phy_address = mdio->prtad;
176 ecmd->mdio_support =
177 mdio->mode_support & (MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22);
176 178
177 reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD, 179 reg = mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_PMAPMD,
178 MDIO_CTRL2); 180 MDIO_CTRL2);
@@ -235,16 +237,19 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,
235 237
236 if (ecmd->autoneg) { 238 if (ecmd->autoneg) {
237 u32 modes = 0; 239 u32 modes = 0;
240 int an_stat = mdio->mdio_read(mdio->dev, mdio->prtad,
241 MDIO_MMD_AN, MDIO_STAT1);
238 242
239 /* If AN is complete and successful, report best common 243 /* If AN is complete and successful, report best common
240 * mode, otherwise report best advertised mode. */ 244 * mode, otherwise report best advertised mode. */
241 if (mdio->mdio_read(mdio->dev, mdio->prtad, MDIO_MMD_AN, 245 if (an_stat & MDIO_AN_STAT1_COMPLETE) {
242 MDIO_STAT1) & 246 ecmd->lp_advertising =
243 MDIO_AN_STAT1_COMPLETE) 247 mdio45_get_an(mdio, MDIO_AN_LPA) | npage_lpa;
244 modes = (ecmd->advertising & 248 if (an_stat & MDIO_AN_STAT1_LPABLE)
245 (mdio45_get_an(mdio, MDIO_AN_LPA) | 249 ecmd->lp_advertising |= ADVERTISED_Autoneg;
246 npage_lpa)); 250 modes = ecmd->advertising & ecmd->lp_advertising;
247 if (modes == 0) 251 }
252 if ((modes & ~ADVERTISED_Autoneg) == 0)
248 modes = ecmd->advertising; 253 modes = ecmd->advertising;
249 254
250 if (modes & ADVERTISED_10000baseT_Full) { 255 if (modes & ADVERTISED_10000baseT_Full) {
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 5ccb6bd660c7..14e6bc860112 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -26,11 +26,13 @@ struct ethtool_cmd {
26 __u8 phy_address; 26 __u8 phy_address;
27 __u8 transceiver; /* Which transceiver to use */ 27 __u8 transceiver; /* Which transceiver to use */
28 __u8 autoneg; /* Enable or disable autonegotiation */ 28 __u8 autoneg; /* Enable or disable autonegotiation */
29 __u8 mdio_support;
29 __u32 maxtxpkt; /* Tx pkts before generating tx int */ 30 __u32 maxtxpkt; /* Tx pkts before generating tx int */
30 __u32 maxrxpkt; /* Rx pkts before generating rx int */ 31 __u32 maxrxpkt; /* Rx pkts before generating rx int */
31 __u16 speed_hi; 32 __u16 speed_hi;
32 __u16 reserved2; 33 __u16 reserved2;
33 __u32 reserved[3]; 34 __u32 lp_advertising; /* Features the link partner advertises */
35 __u32 reserved[2];
34}; 36};
35 37
36static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, 38static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 5645c0f863dc..1bff2f2d0e19 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -234,6 +234,9 @@ static inline __u16 mdio_phy_id_devad(int phy_id)
234 return phy_id & MDIO_PHY_ID_DEVAD; 234 return phy_id & MDIO_PHY_ID_DEVAD;
235} 235}
236 236
237#define MDIO_SUPPORTS_C22 1
238#define MDIO_SUPPORTS_C45 2
239
237#ifdef __KERNEL__ 240#ifdef __KERNEL__
238 241
239/** 242/**
@@ -264,8 +267,6 @@ struct mdio_if_info {
264 267
265#define MDIO_PRTAD_NONE (-1) 268#define MDIO_PRTAD_NONE (-1)
266#define MDIO_DEVAD_NONE (-1) 269#define MDIO_DEVAD_NONE (-1)
267#define MDIO_SUPPORTS_C22 1
268#define MDIO_SUPPORTS_C45 2
269#define MDIO_EMULATE_C22 4 270#define MDIO_EMULATE_C22 4
270 271
271struct ethtool_cmd; 272struct ethtool_cmd;