Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ethtool, mdio, mii: Specify MDIO information fields in struct ethtool_cmd

Add comments for ethtool_cmd::phy_address and
ethtool_cmd::mdio_support, and definitions of the flags currently
used in mdio_support.

In the mdio library, assert that its own flags continue to match those
in the ethtool interface.

In the mii library, use the ethtool flag definition and stop
including <linux/mdio.h>.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ben Hutchings and committed by
David S. Miller
9c4df53b 9c717758

+26 -4
+3
drivers/net/mdio.c
··· 190 190 int reg; 191 191 u32 speed; 192 192 193 + BUILD_BUG_ON(MDIO_SUPPORTS_C22 != ETH_MDIO_SUPPORTS_C22); 194 + BUILD_BUG_ON(MDIO_SUPPORTS_C45 != ETH_MDIO_SUPPORTS_C45); 195 + 193 196 ecmd->transceiver = XCVR_INTERNAL; 194 197 ecmd->phy_address = mdio->prtad; 195 198 ecmd->mdio_support =
+2 -2
drivers/net/mii.c
··· 31 31 #include <linux/module.h> 32 32 #include <linux/netdevice.h> 33 33 #include <linux/ethtool.h> 34 - #include <linux/mdio.h> 34 + #include <linux/mii.h> 35 35 36 36 static u32 mii_get_an(struct mii_if_info *mii, u16 addr) 37 37 { ··· 74 74 75 75 /* this isn't fully supported at higher layers */ 76 76 ecmd->phy_address = mii->phy_id; 77 - ecmd->mdio_support = MDIO_SUPPORTS_C22; 77 + ecmd->mdio_support = ETH_MDIO_SUPPORTS_C22; 78 78 79 79 ecmd->advertising = ADVERTISED_TP | ADVERTISED_MII; 80 80
+21 -2
include/linux/ethtool.h
··· 30 30 * access it */ 31 31 __u8 duplex; /* Duplex, half or full */ 32 32 __u8 port; /* Which connector port */ 33 - __u8 phy_address; 33 + __u8 phy_address; /* MDIO PHY address (PRTAD for clause 45). 34 + * May be read-only or read-write 35 + * depending on the driver. 36 + */ 34 37 __u8 transceiver; /* Which transceiver to use */ 35 38 __u8 autoneg; /* Enable or disable autonegotiation */ 36 - __u8 mdio_support; 39 + __u8 mdio_support; /* MDIO protocols supported. Read-only. 40 + * Not set by all drivers. 41 + */ 37 42 __u32 maxtxpkt; /* Tx pkts before generating tx int */ 38 43 __u32 maxrxpkt; /* Rx pkts before generating rx int */ 39 44 __u16 speed_hi; /* The forced speed (upper ··· 63 58 { 64 59 return (ep->speed_hi << 16) | ep->speed; 65 60 } 61 + 62 + /* Device supports clause 22 register access to PHY or peripherals 63 + * using the interface defined in <linux/mii.h>. This should not be 64 + * set if there are known to be no such peripherals present or if 65 + * the driver only emulates clause 22 registers for compatibility. 66 + */ 67 + #define ETH_MDIO_SUPPORTS_C22 1 68 + 69 + /* Device supports clause 45 register access to PHY or peripherals 70 + * using the interface defined in <linux/mii.h> and <linux/mdio.h>. 71 + * This should not be set if there are known to be no such peripherals 72 + * present. 73 + */ 74 + #define ETH_MDIO_SUPPORTS_C45 2 66 75 67 76 #define ETHTOOL_FWVERS_LEN 32 68 77 #define ETHTOOL_BUSINFO_LEN 32