MDIO and ethtool enhancements
Subsystems (4)
cover MDIO and ethtool enhancements
The first part of this series introduce counterparts to <linux/mii.h> and the mii module for use with MDIO clause 45 devices and controllers that support both clause 22 and clause 45, and change several 10G Ethernet drivers to use them.
The remaining patches are a bit miscellaneous:
- Extend generic flow control/pause frame support and change the sfc driver to use it
- Add fields to the ethtool_cmd structure to report the supported MDIO mode(s) and link partner advertising flags, and implement these in the mdio and mii modules
- Add support for backplane (1000BASE-KR and 10GBASE-KR/KX4) modes to ethtool and the mdio module
I have a few questions to be resolved:
- Is the naming of functions and constants in <linux/mdio.h> reasonable, or is more qualification required?
- Is it reasonable to carry on using the MII ioctl interface with flags?
- Are there more drivers that could use these generic definitions (I haven't looked at the Broadcom drivers yet)?
- Does the backplane code work at all (I don't have any suitable hardware yet)?
Ben.
Ben Hutchings (16):
ethtool: Add port type PORT_OTHER
mdio: Add register definitions for MDIO (clause 45)
mdio: Add generic MDIO (clause 45) support functions
sfc: Use generic MDIO functions and definitions
chelsio: Use generic MDIO definitions and mdio_mii_ioctl()
cxgb3: Use generic MDIO definitions and mdio_mii_ioctl()
ixgbe: Use generic MDIO definitions and functions
ixgb: Use generic MDIO definitions
s2io: Use generic MDIO definitions
mii: Simplify mii_resolve_flowctrl_fdx()
mii: Add mii_advertise_flowctrl()
mdio: Add mdio45_ethtool_spauseparam_an()
sfc: Use generic MDIO flow control auto-negotiation functions ethtool/mdio: Report MDIO mode support and link partner advertising ethtool/mdio: Support backplane mode negotiation
mii: Report mdio_support and lp_advertising from generic_mii_ioctl()
drivers/net/Kconfig | 6 + drivers/net/Makefile | 1 + drivers/net/chelsio/common.h | 2 +- drivers/net/chelsio/cphy.h | 45 +++-- drivers/net/chelsio/cxgb2.c | 36 +--- drivers/net/chelsio/mv88x201x.c | 45 +++-- drivers/net/chelsio/my3126.c | 10 +- drivers/net/chelsio/subr.c | 43 +++-- drivers/net/cxgb3/ael1002.c | 146 +++++++------- drivers/net/cxgb3/common.h | 53 +++--- drivers/net/cxgb3/cxgb3_main.c | 71 ++------ drivers/net/cxgb3/t3_hw.c | 78 ++++---- drivers/net/cxgb3/vsc8211.c | 70 ++++--- drivers/net/ixgb/ixgb_hw.c | 20 +- drivers/net/ixgb/ixgb_hw.h | 14 +-- drivers/net/ixgbe/ixgbe_82598.c | 33 ++-- drivers/net/ixgbe/ixgbe_82599.c | 17 +- drivers/net/ixgbe/ixgbe_main.c | 42 ++++ drivers/net/ixgbe/ixgbe_phy.c | 95 +++------ drivers/net/ixgbe/ixgbe_type.h | 33 +--- drivers/net/mdio.c | 414 +++++++++++++++++++++++++++++++++++++++ drivers/net/mii.c | 91 ++++++---- drivers/net/s2io-regs.h | 5 - drivers/net/s2io.c | 21 +- drivers/net/sfc/Kconfig | 2 +- drivers/net/sfc/efx.c | 10 +- drivers/net/sfc/ethtool.c | 19 +-- drivers/net/sfc/falcon.c | 137 ++++---------- drivers/net/sfc/falcon_hwdefs.h | 3 - drivers/net/sfc/falcon_xmac.c | 2 +- drivers/net/sfc/mdio_10g.c | 385 +++++++----------------------------- drivers/net/sfc/mdio_10g.h | 282 ++++----------------------- drivers/net/sfc/net_driver.h | 34 +--- drivers/net/sfc/selftest.c | 21 +- drivers/net/sfc/selftest.h | 2 +- drivers/net/sfc/tenxpress.c | 226 +++++++++------------- drivers/net/sfc/xenpack.h | 15 +- drivers/net/sfc/xfp_phy.c | 51 +++--- include/linux/ethtool.h | 15 ++- include/linux/mdio.h | 312 +++++++++++++++++++++++++++++ include/linux/mii.h | 34 ++-- 41 files changed, 1532 insertions(+), 1409 deletions(-) create mode 100644 drivers/net/mdio.c create mode 100644 include/linux/mdio.h
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 1/16 ethtool: Add port type PORT_OTHER
Add a PORT_OTHER to represent all other physical port types. Current NICs generally do not allow switching between multiple port types in software so specific types should not be needed.
--- include/linux/ethtool.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/ethtool.h +1 -0
@@ -605,6 +605,7 @@ struct ethtool_ops {#define PORT_MII 0x02#define PORT_FIBRE 0x03#define PORT_BNC 0x04 +#define PORT_OTHER 0xff/* Which transceiver to use. */ #define XCVR_INTERNAL 0x00
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 2/16 mdio: Add register definitions for MDIO (clause 45)
In reply to Ben HutchingsIEEE 802.3 clause 45 specifies the MDIO interface and registers for use in 10G and other PHYs, similar to the MII management interface.
PHYs may have up to 32 MMDs corresponding to different sub-layers and functions, each with up to 65536 registers. These are addressed by PRTAD (similar to the MII PHY address) and DEVAD. Define a mapping for specifying PRTAD and DEVAD through the existing MII ioctls.
--- include/linux/mdio.h | 237 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 237 insertions(+), 0 deletions(-) create mode 100644 include/linux/mdio.h
include/linux/mdio.h new file +237 -0
@@ -0,0 +1,237 @@ +/* +* linux/mdio.h: definitions for MDIO (clause 45) transceivers +* Copyright 2006-2009 Solarflare Communications Inc. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation, incorporated herein by reference. +*/ + +#ifndef __LINUX_MDIO_H__ +#define __LINUX_MDIO_H__ + +#include <linux/mii.h> + +/* MDIO Manageable Devices (MMDs). */ +#define MDIO_MMD_PMAPMD 1/* Physical Medium Attachment/ +* Physical Medium Dependent */ +#define MDIO_MMD_WIS 2/* WAN Interface Sublayer */ +#define MDIO_MMD_PCS 3/* Physical Coding Sublayer */ +#define MDIO_MMD_PHYXS 4/* PHY Extender Sublayer */ +#define MDIO_MMD_DTEXS 5/* DTE Extender Sublayer */ +#define MDIO_MMD_TC 6/* Transmission Convergence */ +#define MDIO_MMD_AN 7/* Auto-Negotiation */ +#define MDIO_MMD_C22EXT 29/* Clause 22 extension */ +#define MDIO_MMD_VEND1 30/* Vendor specific 1 */ +#define MDIO_MMD_VEND2 31/* Vendor specific 2 */ + +/* Generic MDIO registers. */ +#define MDIO_CTRL1 MII_BMCR +#define MDIO_STAT1 MII_BMSR +#define MDIO_DEVID1 MII_PHYSID1 +#define MDIO_DEVID2 MII_PHYSID2 +#define MDIO_SPEED 4/* Speed ability */ +#define MDIO_DEVS1 5/* Devices in package */ +#define MDIO_DEVS2 6 +#define MDIO_CTRL2 7/* 10G control 2 */ +#define MDIO_STAT2 8/* 10G status 2 */ +#define MDIO_PMA_TXDIS 9/* 10G PMA/PMD transmit disable */ +#define MDIO_PMA_RXDET 10/* 10G PMA/PMD receive signal detect */ +#define MDIO_PMA_EXTABLE 11/* 10G PMA/PMD extended ability */ +#define MDIO_PKGID1 14/* Package identifier */ +#define MDIO_PKGID2 15 +#define MDIO_AN_ADVERTISE 16/* AN advertising (base page) */ +#define MDIO_AN_LPA 19/* AN LP abilities (base page) */ +#define MDIO_PHYXS_LNSTAT 24/* PHY XGXS lane state */ + +/* Media-dependent registers. */ +#define MDIO_PMA_10GBT_TXPWR 131/* 10GBASE-T TX power control */ +#define MDIO_PCS_10GBX_STAT1 24/* 10GBASE-X PCS status 1 */ +#define MDIO_PCS_10GBRT_STAT1 32/* 10GBASE-R/-T PCS status 1 */ +#define MDIO_PCS_10GBRT_STAT2 33/* 10GBASE-R/-T PCS status 2 */ +#define MDIO_AN_10GBT_CTRL 32/* 10GBASE-T auto-negotiation control */ +#define MDIO_AN_10GBT_STAT 33/* 10GBASE-T auto-negotiation status */ + +/* Control register 1. */ +/* Enable extended speed selection */ +#define MDIO_CTRL1_SPEEDSELEXT (BMCR_SPEED1000 | BMCR_SPEED100) +/* All speed selection bits */ +#define MDIO_CTRL1_SPEEDSEL (MDIO_CTRL1_SPEEDSELEXT | 0x003c) +#define MDIO_CTRL1_FULLDPLX BMCR_FULLDPLX +#define MDIO_CTRL1_LPOWER BMCR_PDOWN +#define MDIO_CTRL1_RESET BMCR_RESET +#define MDIO_PMA_CTRL1_LOOPBACK 0x0001 +#define MDIO_PMA_CTRL1_SPEED1000 BMCR_SPEED1000 +#define MDIO_PMA_CTRL1_SPEED100 BMCR_SPEED100 +#define MDIO_PCS_CTRL1_LOOPBACK BMCR_LOOPBACK +#define MDIO_PHYXS_CTRL1_LOOPBACK BMCR_LOOPBACK +#define MDIO_AN_CTRL1_RESTART BMCR_ANRESTART +#define MDIO_AN_CTRL1_ENABLE BMCR_ANENABLE +#define MDIO_AN_CTRL1_XNP 0x2000/* Enable extended next page */ + +/* 10 Gb/s */ +#define MDIO_CTRL1_SPEED10G (MDIO_CTRL1_SPEEDSELEXT | 0x00) +/* 10PASS-TS/2BASE-TL */ +#define MDIO_CTRL1_SPEED10P2B (MDIO_CTRL1_SPEEDSELEXT | 0x04) + +/* Status register 1. */ +#define MDIO_STAT1_LPOWERABLE 0x0002/* Low-power ability */ +#define MDIO_STAT1_LSTATUS BMSR_LSTATUS +#define MDIO_STAT1_FAULT 0x0080/* Fault */ +#define MDIO_AN_STAT1_LPABLE 0x0001/* Link partner AN ability */ +#define MDIO_AN_STAT1_ABLE BMSR_ANEGCAPABLE +#define MDIO_AN_STAT1_RFAULT BMSR_RFAULT +#define MDIO_AN_STAT1_COMPLETE BMSR_ANEGCOMPLETE +#define MDIO_AN_STAT1_PAGE 0x0040/* Page received */ +#define MDIO_AN_STAT1_XNP 0x0080/* Extended next page status */ + +/* Speed register. */ +#define MDIO_SPEED_10G 0x0001/* 10G capable */ +#define MDIO_PMA_SPEED_2B 0x0002/* 2BASE-TL capable */ +#define MDIO_PMA_SPEED_10P 0x0004/* 10PASS-TS capable */ +#define MDIO_PMA_SPEED_1000 0x0010/* 1000M capable */ +#define MDIO_PMA_SPEED_100 0x0020/* 100M capable */ +#define MDIO_PMA_SPEED_10 0x0040/* 10M capable */ +#define MDIO_PCS_SPEED_10P2B 0x0002/* 10PASS-TS/2BASE-TL capable */ + +/* Device present registers. */ +#define MDIO_DEVS_PRESENT (devad) (1 << (devad)) +#define MDIO_DEVS_PMAPMD MDIO_DEVS_PRESENT(MDIO_MMD_PMAPMD) +#define MDIO_DEVS_WIS MDIO_DEVS_PRESENT(MDIO_MMD_WIS) +#define MDIO_DEVS_PCS MDIO_DEVS_PRESENT(MDIO_MMD_PCS) +#define MDIO_DEVS_PHYXS MDIO_DEVS_PRESENT(MDIO_MMD_PHYXS) +#define MDIO_DEVS_DTEXS MDIO_DEVS_PRESENT(MDIO_MMD_DTEXS) +#define MDIO_DEVS_TC MDIO_DEVS_PRESENT(MDIO_MMD_TC) +#define MDIO_DEVS_AN MDIO_DEVS_PRESENT(MDIO_MMD_AN) +#define MDIO_DEVS_C22EXT MDIO_DEVS_PRESENT(MDIO_MMD_C22EXT) + +/* Control register 2. */ +#define MDIO_PMA_CTRL2_TYPE 0x000f/* PMA/PMD type selection */ +#define MDIO_PMA_CTRL2_10GBCX4 0x0000/* 10GBASE-CX4 type */ +#define MDIO_PMA_CTRL2_10GBEW 0x0001/* 10GBASE-EW type */ +#define MDIO_PMA_CTRL2_10GBLW 0x0002/* 10GBASE-LW type */ +#define MDIO_PMA_CTRL2_10GBSW 0x0003/* 10GBASE-SW type */ +#define MDIO_PMA_CTRL2_10GBLX4 0x0004/* 10GBASE-LX4 type */ +#define MDIO_PMA_CTRL2_10GBER 0x0005/* 10GBASE-ER type */ +#define MDIO_PMA_CTRL2_10GBLR 0x0006/* 10GBASE-LR type */ +#define MDIO_PMA_CTRL2_10GBSR 0x0007/* 10GBASE-SR type */ +#define MDIO_PMA_CTRL2_10GBLRM 0x0008/* 10GBASE-LRM type */ +#define MDIO_PMA_CTRL2_10GBT 0x0009/* 10GBASE-T type */ +#define MDIO_PMA_CTRL2_10GBKX4 0x000a/* 10GBASE-KX4 type */ +#define MDIO_PMA_CTRL2_10GBKR 0x000b/* 10GBASE-KR type */ +#define MDIO_PMA_CTRL2_1000BT 0x000c/* 1000BASE-T type */ +#define MDIO_PMA_CTRL2_1000BKX 0x000d/* 1000BASE-KX type */ +#define MDIO_PMA_CTRL2_100BTX 0x000e/* 100BASE-TX type */ +#define MDIO_PMA_CTRL2_10BT 0x000f/* 10BASE-T type */ +#define MDIO_PCS_CTRL2_TYPE 0x0003/* PCS type selection */ +#define MDIO_PCS_CTRL2_10GBR 0x0000/* 10GBASE-R type */ +#define MDIO_PCS_CTRL2_10GBX 0x0001/* 10GBASE-X type */ +#define MDIO_PCS_CTRL2_10GBW 0x0002/* 10GBASE-W type */ +#define MDIO_PCS_CTRL2_10GBT 0x0003/* 10GBASE-T type */ + +/* Status register 2. */ +#define MDIO_STAT2_RXFAULT 0x0400/* Receive fault */ +#define MDIO_STAT2_TXFAULT 0x0800/* Transmit fault */ +#define MDIO_STAT2_DEVPRST 0xc000/* Device present */ +#define MDIO_STAT2_DEVPRST_VAL 0x8000/* Device present value */ +#define MDIO_PMA_STAT2_LBABLE 0x0001/* PMA loopback ability */ +#define MDIO_PMA_STAT2_10GBEW 0x0002/* 10GBASE-EW ability */ +#define MDIO_PMA_STAT2_10GBLW 0x0004/* 10GBASE-LW ability */ +#define MDIO_PMA_STAT2_10GBSW 0x0008/* 10GBASE-SW ability */ +#define MDIO_PMA_STAT2_10GBLX4 0x0010/* 10GBASE-LX4 ability */ +#define MDIO_PMA_STAT2_10GBER 0x0020/* 10GBASE-ER ability */ +#define MDIO_PMA_STAT2_10GBLR 0x0040/* 10GBASE-LR ability */ +#define MDIO_PMA_STAT2_10GBSR 0x0080/* 10GBASE-SR ability */ +#define MDIO_PMD_STAT2_TXDISAB 0x0100/* PMD TX disable ability */ +#define MDIO_PMA_STAT2_EXTABLE 0x0200/* Extended abilities */ +#define MDIO_PMA_STAT2_RXFLTABLE 0x1000/* Receive fault ability */ +#define MDIO_PMA_STAT2_TXFLTABLE 0x2000/* Transmit fault ability */ +#define MDIO_PCS_STAT2_10GBR 0x0001/* 10GBASE-R capable */ +#define MDIO_PCS_STAT2_10GBX 0x0002/* 10GBASE-X capable */ +#define MDIO_PCS_STAT2_10GBW 0x0004/* 10GBASE-W capable */ +#define MDIO_PCS_STAT2_RXFLTABLE 0x1000/* Receive fault ability */ +#define MDIO_PCS_STAT2_TXFLTABLE 0x2000/* Transmit fault ability */ + +/* Transmit disable register. */ +#define MDIO_PMD_TXDIS_GLOBAL 0x0001/* Global PMD TX disable */ +#define MDIO_PMD_TXDIS_0 0x0002/* PMD TX disable 0 */ +#define MDIO_PMD_TXDIS_1 0x0004/* PMD TX disable 1 */ +#define MDIO_PMD_TXDIS_2 0x0008/* PMD TX disable 2 */ +#define MDIO_PMD_TXDIS_3 0x0010/* PMD TX disable 3 */ + +/* Receive signal detect register. */ +#define MDIO_PMD_RXDET_GLOBAL 0x0001/* Global PMD RX signal detect */ +#define MDIO_PMD_RXDET_0 0x0002/* PMD RX signal detect 0 */ +#define MDIO_PMD_RXDET_1 0x0004/* PMD RX signal detect 1 */ +#define MDIO_PMD_RXDET_2 0x0008/* PMD RX signal detect 2 */ +#define MDIO_PMD_RXDET_3 0x0010/* PMD RX signal detect 3 */ + +/* Extended abilities register. */ +#define MDIO_PMA_EXTABLE_10GCX4 0x0001/* 10GBASE-CX4 ability */ +#define MDIO_PMA_EXTABLE_10GBLRM 0x0002/* 10GBASE-LRM ability */ +#define MDIO_PMA_EXTABLE_10GBT 0x0004/* 10GBASE-T ability */ +#define MDIO_PMA_EXTABLE_10GBKX4 0x0008/* 10GBASE-KX4 ability */ +#define MDIO_PMA_EXTABLE_10GBKR 0x0010/* 10GBASE-KR ability */ +#define MDIO_PMA_EXTABLE_1000BT 0x0020/* 1000BASE-T ability */ +#define MDIO_PMA_EXTABLE_1000BKX 0x0040/* 1000BASE-KX ability */ +#define MDIO_PMA_EXTABLE_100BTX 0x0080/* 100BASE-TX ability */ +#define MDIO_PMA_EXTABLE_10BT 0x0100/* 10BASE-T ability */ + +/* PHY XGXS lane state register. */ +#define MDIO_PHYXS_LNSTAT_SYNC0 0x0001 +#define MDIO_PHYXS_LNSTAT_SYNC1 0x0002 +#define MDIO_PHYXS_LNSTAT_SYNC2 0x0004 +#define MDIO_PHYXS_LNSTAT_SYNC3 0x0008 +#define MDIO_PHYXS_LNSTAT_ALIGN 0x1000 + +/* PMA 10GBASE-T TX power register. */ +#define MDIO_PMA_10GBT_TXPWR_SHORT 0x0001/* Short-reach mode */ + +/* PCS 10GBASE-R/-T status register 1. */ +#define MDIO_PCS_10GBRT_STAT1_BLKLK 0x0001/* Block lock attained */ + +/* PCS 10GBASE-R/-T status register 2. */ +#define MDIO_PCS_10GBRT_STAT2_ERR 0x00ff +#define MDIO_PCS_10GBRT_STAT2_BER 0x3f00 + +/* AN 10GBASE-T control register. */ +#define MDIO_AN_10GBT_CTRL_ADV10G 0x1000/* Advertise 10GBASE-T */ + +/* AN 10GBASE-T status register. */ +#define MDIO_AN_10GBT_STAT_LPTRR 0x0200/* LP training reset req. */ +#define MDIO_AN_10GBT_STAT_LPLTABLE 0x0400/* LP loop timing ability */ +#define MDIO_AN_10GBT_STAT_LP10G 0x0800/* LP is 10GBT capable */ +#define MDIO_AN_10GBT_STAT_REMOK 0x1000/* Remote OK */ +#define MDIO_AN_10GBT_STAT_LOCOK 0x2000/* Local OK */ +#define MDIO_AN_10GBT_STAT_MS 0x4000/* Master/slave config */ +#define MDIO_AN_10GBT_STAT_MSFLT 0x8000/* Master/slave config fault */ + +/* Mapping between MDIO PRTAD/DEVAD and mii_ioctl_data::phy_id */ + +#define MDIO_PHY_ID_C45 0x8000 +#define MDIO_PHY_ID_PRTAD 0x03e0 +#define MDIO_PHY_ID_DEVAD 0x001f +#define MDIO_PHY_ID_C45_MASK \ + (MDIO_PHY_ID_C45 | MDIO_PHY_ID_PRTAD | MDIO_PHY_ID_DEVAD) + +static inline __u16 mdio_phy_id_c45 (int prtad,int devad) +{ +return MDIO_PHY_ID_C45 | (prtad <<5 ) | devad; +} + +static inline bool mdio_phy_id_is_c45 (int phy_id) +{ +return (phy_id &MDIO_PHY_ID_C45 ) && !(phy_id & ~MDIO_PHY_ID_C45_MASK ); +} + +static inline __u16 mdio_phy_id_prtad (int phy_id) +{ +return (phy_id &MDIO_PHY_ID_PRTAD ) >>5 ; +} + +static inline __u16 mdio_phy_id_devad (int phy_id) +{ +return phy_id &MDIO_PHY_ID_DEVAD ; +} + +#endif /* __LINUX_MDIO_H__ */
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 3/16 mdio: Add generic MDIO (clause 45) support functions
In reply to Ben HutchingsThese roughly mirror many of the MII library functions and are based on code from the sfc driver.
--- drivers/net/Kconfig | 3 + drivers/net/Makefile | 1 + drivers/net/mdio.c | 359 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mdio.h | 66 +++++++++ 4 files changed, 429 insertions(+), 0 deletions(-) create mode 100644 drivers/net/mdio.c
drivers/net/Kconfig +3 -0
@@ -2443,6 +2443,9 @@ menuconfig NETDEV_10000 if NETDEV_10000 +config MDIO + tristate + config CHELSIO_T1 tristate "Chelsio 10Gb Ethernet support" depends on PCI
drivers/net/Makefile +1 -0
@@ -95,6 +95,7 @@ obj-$(CONFIG_SH_ETH) += sh_eth.o # obj-$(CONFIG_MII) += mii.o +obj-$(CONFIG_MDIO) += mdio.o obj-$(CONFIG_PHYLIB) += phy/ obj-$(CONFIG_SUNDANCE) += sundance.o
drivers/net/mdio.c new file +359 -0
359 lines not on this page · raw message
include/linux/mdio.h +66 -0
70 lines not on this page · raw message
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 4/16 sfc: Use generic MDIO functions and definitions
In reply to Ben HutchingsMake use of the newly-added generic MDIO clause 45 support and remove redundant definitions.
Add an 'efx_' prefix to the remaining driver-specific MDIO functions and remove arguments which are redundant with efx->mdio.prtad.
--- drivers/net/sfc/Kconfig | 2 +- drivers/net/sfc/efx.c | 10 +- drivers/net/sfc/ethtool.c | 18 +-- drivers/net/sfc/falcon.c | 137 ++++---------- drivers/net/sfc/falcon_hwdefs.h | 3 - drivers/net/sfc/falcon_xmac.c | 2 +- drivers/net/sfc/mdio_10g.c | 379 +++++++++------------------------------ drivers/net/sfc/mdio_10g.h | 281 ++++------------------------- drivers/net/sfc/net_driver.h | 8 +- drivers/net/sfc/selftest.c | 21 +-- drivers/net/sfc/selftest.h | 2 +- drivers/net/sfc/tenxpress.c | 227 +++++++++-------------- drivers/net/sfc/xenpack.h | 15 +- drivers/net/sfc/xfp_phy.c | 51 +++--- 14 files changed, 311 insertions(+), 845 deletions(-)
drivers/net/sfc/Kconfig +1 -1
@@ -1,7 +1,7 @@ config SFC tristate "Solarflare Solarstorm SFC4000 support" depends on PCI && INET - select MII + select MDIO select CRC32 select I2C select I2C_ALGOBIT
drivers/net/sfc/efx.c +8 -2
@@ -1300,10 +1300,16 @@ out_requeue:static int efx_ioctl (struct net_device *net_dev,struct ifreq *ifr,int cmd) {struct efx_nic *efx =netdev_priv (net_dev); +struct mii_ioctl_data *data =if_mii (ifr);EFX_ASSERT_RESET_SERIALISED (efx); -return generic_mii_ioctl (&efx->mii,if_mii (ifr), cmd,NULL ); +/* Convert phy_id from older PRTAD/DEVAD format */ +if ((cmd ==SIOCGMIIREG || cmd ==SIOCSMIIREG ) && + (data->phy_id &0xfc00 ) ==0x0400 ) + data->phy_id ^=MDIO_PHY_ID_C45 |0x0400 ; + +return mdio_mii_ioctl (&efx->mdio, data, cmd); }/**************************************************************************
@@ -1945,7 +1951,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,mutex_init (&efx->mac_lock); efx->mac_op = &efx_dummy_mac_operations; efx->phy_op = &efx_dummy_phy_operations; - efx->mii.dev = net_dev; + efx->mdio.dev = net_dev;INIT_WORK (&efx->phy_work, efx_phy_work);INIT_WORK (&efx->mac_work, efx_mac_work);atomic_set (&efx->netif_stop_count,1 );
drivers/net/sfc/ethtool.c +6 -12
@@ -10,6 +10,7 @@#include <linux/netdevice.h> #include <linux/ethtool.h> +#include <linux/mdio.h> #include <linux/rtnetlink.h> #include "net_driver.h" #include "workarounds.h"
@@ -345,8 +346,8 @@ static int efx_ethtool_fill_self_tests(struct efx_nic *efx,unsigned int n =0 , i;enum efx_loopback_mode mode; -efx_fill_test (n++, strings, data, &tests->mii, -"core" ,0 ,"mii" ,NULL ); +efx_fill_test (n++, strings, data, &tests->mdio, +"core" ,0 ,"mdio" ,NULL );efx_fill_test (n++, strings, data, &tests->nvram,"core" ,0 ,"nvram" ,NULL ); efx_fill_test(n++, strings, data, &tests->interrupt,
@@ -529,14 +530,7 @@ static int efx_ethtool_nway_reset(struct net_device *net_dev) {struct efx_nic *efx =netdev_priv (net_dev); -if (efx->phy_op->mmds &DEV_PRESENT_BIT (MDIO_MMD_AN )) { -mdio_clause45_set_flag (efx, efx->mii.phy_id,MDIO_MMD_AN , -MDIO_MMDREG_CTRL1 , -__ffs (BMCR_ANRESTART ), true); -return 0 ; - } - -return -EOPNOTSUPP ; +return mdio45_nway_restart (&efx->mdio); }static u32 efx_ethtool_get_link (struct net_device *net_dev)
@@ -689,7 +683,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,return -EINVAL ; } -if (!(efx->phy_op->mmds &DEV_PRESENT_BIT (MDIO_MMD_AN )) && +if (!(efx->phy_op->mmds &MDIO_DEVS_AN ) && (wanted_fc &EFX_FC_AUTO )) {EFX_LOG (efx,"PHY does not support flow control " "autonegotiation\n" );
@@ -717,7 +711,7 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,mutex_lock (&efx->mac_lock); efx->wanted_fc = wanted_fc; -mdio_clause45_set_pause (efx); +efx_mdio_set_pause (efx);__efx_reconfigure_port (efx);mutex_unlock (&efx->mac_lock);
drivers/net/sfc/falcon.c +37 -100
228 lines not on this page · raw message
drivers/net/sfc/falcon_hwdefs.h +0 -3
@@ -456,9 +456,6 @@#define MD_PRT_ADR_WIDTH 5#define MD_DEV_ADR_LBN 6#define MD_DEV_ADR_WIDTH 5 -/* Used for writing both at once */ -#define MD_PRT_DEV_ADR_LBN 6 -#define MD_PRT_DEV_ADR_WIDTH 10/* PHY management status & mask register (DWORD read only) */ #define MD_STAT_REG_KER 0xc50
drivers/net/sfc/falcon_xmac.c +1 -1
@@ -133,7 +133,7 @@ bool falcon_xaui_link_ok(struct efx_nic *efx)/* If the link is up, then check the phy side of the xaui link */ if (efx->link_up && link_ok)if (efx->phy_op->mmds & (1 <<MDIO_MMD_PHYXS )) - link_ok =mdio_clause45_phyxgxs_lane_sync (efx); + link_ok =efx_mdio_phyxgxs_lane_sync (efx);return link_ok; }
drivers/net/sfc/mdio_10g.c +84 -295
550 lines not on this page · raw message
drivers/net/sfc/mdio_10g.h +40 -241
341 lines not on this page · raw message
drivers/net/sfc/net_driver.h +3 -5
@@ -19,7 +19,7 @@#include <linux/ethtool.h> #include <linux/if_vlan.h> #include <linux/timer.h> -#include <linux/mii.h> +#include <linux/mdio.h> #include <linux/list.h> #include <linux/pci.h> #include <linux/device.h>
@@ -458,8 +458,6 @@ enum phy_type {PHY_TYPE_MAX /* Insert any new items before this */ }; -#define PHY_ADDR_INVALID 0xff -#define EFX_IS10G (efx) ((efx)->link_speed == 10000)enum nic_state {
@@ -758,7 +756,7 @@ union efx_multicast_hash {* @phy_lock: PHY access lock * @phy_op: PHY interface * @phy_data: PHY private data (including PHY-specific stats) -* @mii: PHY interface +* @mdio: PHY MDIO interface * @phy_mode: PHY operating mode. Serialised by @mac_lock. * @mac_up: MAC link state * @link_up: Link status
@@ -845,7 +843,7 @@ struct efx_nic {struct work_struct phy_work;struct efx_phy_operations *phy_op;void *phy_data; -struct mii_if_info mii; +struct mdio_if_info mdio;enum efx_phy_mode phy_mode;bool mac_up;
drivers/net/sfc/selftest.c +10 -11
@@ -80,39 +80,38 @@ struct efx_loopback_state {* **************************************************************************/ -static int efx_test_mii (struct efx_nic *efx,struct efx_self_tests *tests) +static int efx_test_mdio (struct efx_nic *efx,struct efx_self_tests *tests) {int rc =0 ; +int devad =__ffs (efx->mdio.mmds);u16 physid1, physid2; -struct mii_if_info *mii = &efx->mii; -struct net_device *net_dev = efx->net_dev;if (efx->phy_type ==PHY_TYPE_NONE )return 0 ;mutex_lock (&efx->mac_lock); - tests->mii =-1 ; + tests->mdio =-1 ; - physid1 = mii->mdio_read (net_dev, mii->phy_id,MII_PHYSID1 ); - physid2 = mii->mdio_read (net_dev, mii->phy_id,MII_PHYSID2 ); + physid1 =efx_mdio_read (efx, devad,MDIO_DEVID1 ); + physid2 =efx_mdio_read (efx, devad,MDIO_DEVID2 );if ((physid1 ==0x0000 ) || (physid1 ==0xffff ) || (physid2 ==0x0000 ) || (physid2 ==0xffff )) { -EFX_ERR (efx,"no MII PHY present with ID %d\n" , - mii->phy_id); +EFX_ERR (efx,"no MDIO PHY present with ID %d\n" , + efx->mdio.prtad); rc = -EINVAL ; goto out; }if (EFX_IS10G (efx)) { - rc =mdio_clause45_check_mmds (efx, efx->phy_op->mmds,0 ); + rc =efx_mdio_check_mmds (efx, efx->phy_op->mmds,0 );if (rc) goto out; } out:mutex_unlock (&efx->mac_lock); - tests->mii = rc ?-1 :1 ; + tests->mdio = rc ?-1 :1 ;return rc; }
@@ -673,7 +672,7 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,/* Online (i.e. non-disruptive) testing * This checks interrupt generation, event delivery and PHY presence. */ - rc =efx_test_mii (efx, tests); + rc =efx_test_mdio (efx, tests);if (rc && !rc_test) rc_test = rc;
drivers/net/sfc/selftest.h +1 -1
@@ -32,7 +32,7 @@ struct efx_loopback_self_tests {*/ struct efx_self_tests {/* online tests */ -int mii; +int mdio;int nvram;int interrupt;int eventq_dma[EFX_MAX_CHANNELS ];
drivers/net/sfc/tenxpress.c +90 -137
463 lines not on this page · raw message
drivers/net/sfc/xenpack.h +5 -10
@@ -34,29 +34,24 @@/* Enable LASI interrupts for PHY */ static inline void xenpack_enable_lasi_irqs (struct efx_nic *efx) { -int reg; -int phy_id = efx->mii.phy_id;/* Read to clear LASI status register */ - reg =mdio_clause45_read (efx, phy_id,MDIO_MMD_PMAPMD , -MDIO_XP_LASI_STAT ); +efx_mdio_read (efx,MDIO_MMD_PMAPMD ,MDIO_XP_LASI_STAT ); -mdio_clause45_write (efx, phy_id,MDIO_MMD_PMAPMD , -MDIO_XP_LASI_CTRL ,XP_LASI_LS_ALARM ); +efx_mdio_write (efx,MDIO_MMD_PMAPMD ,MDIO_XP_LASI_CTRL , +XP_LASI_LS_ALARM ); }/* Read the LASI interrupt status to clear the interrupt. */ static inline int xenpack_clear_lasi_irqs (struct efx_nic *efx) {/* Read to clear link status alarm */ -return mdio_clause45_read (efx, efx->mii.phy_id, -MDIO_MMD_PMAPMD ,MDIO_XP_LASI_STAT ); +return efx_mdio_read (efx,MDIO_MMD_PMAPMD ,MDIO_XP_LASI_STAT ); }/* Turn off LASI interrupts */ static inline void xenpack_disable_lasi_irqs (struct efx_nic *efx) { -mdio_clause45_write (efx, efx->mii.phy_id,MDIO_MMD_PMAPMD , -MDIO_XP_LASI_CTRL ,0 ); +efx_mdio_write (efx,MDIO_MMD_PMAPMD ,MDIO_XP_LASI_CTRL ,0 ); }#endif /* EFX_XENPACK_H */
drivers/net/sfc/xfp_phy.c +25 -26
136 lines not on this page · raw message
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 5/16 chelsio: Use generic MDIO definitions and mdio_mii_ioctl()
In reply to Ben HutchingsCompile-tested only.
--- drivers/net/Kconfig | 1 + drivers/net/chelsio/common.h | 2 +- drivers/net/chelsio/cphy.h | 45 +++++++++++++++++++++----------------- drivers/net/chelsio/cxgb2.c | 36 ++---------------------------- drivers/net/chelsio/mv88x201x.c | 45 ++++++++++++++++++++------------------- drivers/net/chelsio/my3126.c | 10 +++++--- drivers/net/chelsio/subr.c | 43 ++++++++++++++++++++----------------- 7 files changed, 82 insertions(+), 100 deletions(-)
drivers/net/Kconfig +1 -0
@@ -2450,6 +2450,7 @@ config CHELSIO_T1 tristate "Chelsio 10Gb Ethernet support" depends on PCI select CRC32 + select MDIO help This driver supports Chelsio gigabit and 10-gigabit Ethernet cards. More information about adapter features and
drivers/net/chelsio/common.h +1 -1
@@ -46,7 +46,7 @@#include <linux/pci.h> #include <linux/ethtool.h> #include <linux/if_vlan.h> -#include <linux/mii.h> +#include <linux/mdio.h> #include <linux/crc32.h> #include <linux/init.h> #include <asm/io.h>
drivers/net/chelsio/cphy.h +25 -20
93 lines not on this page · raw message
drivers/net/chelsio/cxgb2.c +3 -33
@@ -589,7 +589,7 @@ static int get_settings(struct net_device *dev, struct ethtool_cmd *cmd) } cmd->port = (cmd->supported &SUPPORTED_TP ) ?PORT_TP :PORT_FIBRE ; - cmd->phy_address = p->phy->addr; + cmd->phy_address = p->phy->mdio.prtad; cmd->transceiver =XCVR_EXTERNAL ; cmd->autoneg = p->link_config.autoneg; cmd->maxtxpkt =0 ;
@@ -849,39 +849,9 @@ static const struct ethtool_ops t1_ethtool_ops = {static int t1_ioctl (struct net_device *dev,struct ifreq *req,int cmd) {struct adapter *adapter = dev->ml_priv; -struct mii_ioctl_data *data =if_mii (req); - -switch (cmd) { -case SIOCGMIIPHY : - data->phy_id = adapter->port[dev->if_port].phy->addr; -/* FALLTHRU */ -case SIOCGMIIREG : { -struct cphy *phy = adapter->port[dev->if_port].phy; -u32 val; - -if (!phy->mdio_read) -return -EOPNOTSUPP ; - phy->mdio_read (adapter, data->phy_id,0 , data->reg_num &0x1f , - &val); - data->val_out = val; -break ; - } -case SIOCSMIIREG : { -struct cphy *phy = adapter->port[dev->if_port].phy; - -if (!capable (CAP_NET_ADMIN )) -return -EPERM ; -if (!phy->mdio_write) -return -EOPNOTSUPP ; - phy->mdio_write (adapter, data->phy_id,0 , data->reg_num &0x1f , - data->val_in); -break ; - } +struct mdio_if_info *mdio = &adapter->port[dev->if_port].phy->mdio; -default : -return -EOPNOTSUPP ; - } -return 0 ; +return mdio_mii_ioctl (mdio,if_mii (req), cmd); }static int t1_change_mtu (struct net_device *dev,int new_mtu)
drivers/net/chelsio/mv88x201x.c +23 -22
114 lines not on this page · raw message
drivers/net/chelsio/my3126.c +6 -4
@@ -43,11 +43,11 @@ static int my3126_interrupt_handler(struct cphy *cphy) adapter = cphy->adapter;if (cphy->count ==50 ) { -mdio_read (cphy,0x1 ,0x1 , &val); +cphy_mdio_read (cphy,MDIO_MMD_PMAPMD ,MDIO_STAT1 , &val); val16 = (u16 ) val; status = cphy->bmsr ^ val16; -if (status &BMSR_LSTATUS ) +if (status &MDIO_STAT1_LSTATUS )t1_link_changed (adapter,0 ); cphy->bmsr = val16;
@@ -114,14 +114,14 @@ static int my3126_get_link_status(struct cphy *cphy,adapter_t *adapter; adapter = cphy->adapter; -mdio_read (cphy,0x1 ,0x1 , &val); +cphy_mdio_read (cphy,MDIO_MMD_PMAPMD ,MDIO_STAT1 , &val); val16 = (u16 ) val;/* Populate elmer_gpo with the register value */ t1_tpi_read (adapter,A_ELMER0_GPO , &val); cphy->elmer_gpo = val; - *link_ok = (val16 &BMSR_LSTATUS ); + *link_ok = (val16 &MDIO_STAT1_LSTATUS );if (*link_ok) {/* Turn on the LED. */
@@ -163,6 +163,8 @@ static struct cphy_ops my3126_ops = { .interrupt_handler = my3126_interrupt_handler, .get_link_status = my3126_get_link_status, .set_loopback = my3126_set_loopback, + .mmds = (MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | + MDIO_DEVS_PHYXS), }; static struct cphy *my3126_phy_create(adapter_t *adapter,
drivers/net/chelsio/subr.c +23 -20
98 lines not on this page · raw message
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 6/16 cxgb3: Use generic MDIO definitions and mdio_mii_ioctl()
In reply to Ben HutchingsCompile-tested only.
--- drivers/net/Kconfig | 1 + drivers/net/cxgb3/ael1002.c | 146 +++++++++++++++++++++------------------- drivers/net/cxgb3/common.h | 53 ++++++-------- drivers/net/cxgb3/cxgb3_main.c | 71 ++++---------------- drivers/net/cxgb3/t3_hw.c | 78 ++++++++++++---------- drivers/net/cxgb3/vsc8211.c | 70 +++++++++++-------- 6 files changed, 195 insertions(+), 224 deletions(-)
drivers/net/Kconfig +1 -0
@@ -2483,6 +2483,7 @@ config CHELSIO_T3 tristate "Chelsio Communications T3 10Gb Ethernet support" depends on CHELSIO_T3_DEPENDS select FW_LOADER + select MDIO help This driver supports Chelsio T3-based gigabit and 10Gb Ethernet adapters.
drivers/net/cxgb3/ael1002.c +76 -70
356 lines not on this page · raw message
drivers/net/cxgb3/common.h +23 -30
105 lines not on this page · raw message
drivers/net/cxgb3/cxgb3_main.c +13 -58
97 lines not on this page · raw message
drivers/net/cxgb3/t3_hw.c +42 -36
220 lines not on this page · raw message
drivers/net/cxgb3/vsc8211.c +40 -30
194 lines not on this page · raw message
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 7/16 ixgbe: Use generic MDIO definitions and functions
In reply to Ben HutchingsCompile-tested only.
--- drivers/net/Kconfig | 1 + drivers/net/ixgbe/ixgbe_82598.c | 33 +++++++------- drivers/net/ixgbe/ixgbe_82599.c | 17 +++---- drivers/net/ixgbe/ixgbe_main.c | 42 +++++++++++++++++ drivers/net/ixgbe/ixgbe_phy.c | 95 +++++++++++++-------------------------- drivers/net/ixgbe/ixgbe_type.h | 33 +------------ 6 files changed, 102 insertions(+), 119 deletions(-)
drivers/net/Kconfig +1 -0
@@ -2519,6 +2519,7 @@ config ENIC config IXGBE tristate "Intel(R) 10GbE PCI Express adapters support" depends on PCI && INET + select MDIO ---help--- This driver supports Intel(R) 10GbE PCI Express family of adapters. For more information on how to identify your adapter, go
drivers/net/ixgbe/ixgbe_82598.c +16 -17
@@ -229,14 +229,13 @@ static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw, *speed =0 ; *autoneg = true; - status = hw->phy.ops.read_reg (hw,IXGBE_MDIO_PHY_SPEED_ABILITY , -IXGBE_MDIO_PMA_PMD_DEV_TYPE , + status = hw->phy.ops.read_reg (hw,MDIO_SPEED ,MDIO_MMD_PMAPMD , &speed_ability);if (status ==0 ) { -if (speed_ability &IXGBE_MDIO_PHY_SPEED_10G ) +if (speed_ability &MDIO_SPEED_10G ) *speed |=IXGBE_LINK_SPEED_10GB_FULL ; -if (speed_ability &IXGBE_MDIO_PHY_SPEED_1G ) +if (speed_ability &MDIO_PMA_SPEED_1000 ) *speed |=IXGBE_LINK_SPEED_1GB_FULL ; }
@@ -526,9 +525,9 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,* clear indicates active; set indicates inactive. */ if (hw->phy.type == ixgbe_phy_nl) { - hw->phy.ops.read_reg (hw,0xC79F ,IXGBE_TWINAX_DEV , &link_reg); - hw->phy.ops.read_reg (hw,0xC79F ,IXGBE_TWINAX_DEV , &link_reg); - hw->phy.ops.read_reg (hw,0xC00C ,IXGBE_TWINAX_DEV , + hw->phy.ops.read_reg (hw,0xC79F ,MDIO_MMD_PMAPMD , &link_reg); + hw->phy.ops.read_reg (hw,0xC79F ,MDIO_MMD_PMAPMD , &link_reg); + hw->phy.ops.read_reg (hw,0xC00C ,MDIO_MMD_PMAPMD , &adapt_comp_reg);if (link_up_wait_to_complete) {for (i =0 ; i <IXGBE_LINK_UP_TIME ; i++) {
@@ -541,10 +540,10 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw, }msleep (100 ); hw->phy.ops.read_reg (hw,0xC79F , -IXGBE_TWINAX_DEV , +MDIO_MMD_PMAPMD , &link_reg); hw->phy.ops.read_reg (hw,0xC00C , -IXGBE_TWINAX_DEV , +MDIO_MMD_PMAPMD , &adapt_comp_reg); } }else {
@@ -990,14 +989,14 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset, sfp_addr = (sfp_addr |IXGBE_I2C_EEPROM_READ_MASK ); hw->phy.ops.write_reg (hw,IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR , -IXGBE_MDIO_PMA_PMD_DEV_TYPE , +MDIO_MMD_PMAPMD , sfp_addr);/* Poll status */ for (i =0 ; i <100 ; i++) { hw->phy.ops.read_reg (hw,IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT , -IXGBE_MDIO_PMA_PMD_DEV_TYPE , +MDIO_MMD_PMAPMD , &sfp_stat); sfp_stat = sfp_stat &IXGBE_I2C_EEPROM_STATUS_MASK ;if (sfp_stat !=IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS )
@@ -1013,7 +1012,7 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,/* Read data */ hw->phy.ops.read_reg (hw,IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA , -IXGBE_MDIO_PMA_PMD_DEV_TYPE , &sfp_data); +MDIO_MMD_PMAPMD , &sfp_data); *eeprom_data = (u8)(sfp_data >>8 ); }else {
@@ -1045,13 +1044,13 @@ static u32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)* physical layer because 10GBase-T PHYs use LMS = KX4/KX */ if (hw->phy.type == ixgbe_phy_tn || hw->phy.type == ixgbe_phy_cu_unknown) { - hw->phy.ops.read_reg (hw,IXGBE_MDIO_PHY_EXT_ABILITY , -IXGBE_MDIO_PMA_PMD_DEV_TYPE , &ext_ability); -if (ext_ability &IXGBE_MDIO_PHY_10GBASET_ABILITY ) + hw->phy.ops.read_reg (hw,MDIO_PMA_EXTABLE ,MDIO_MMD_PMAPMD , + &ext_ability); +if (ext_ability &MDIO_PMA_EXTABLE_10GBT ) physical_layer |=IXGBE_PHYSICAL_LAYER_10GBASE_T ; -if (ext_ability &IXGBE_MDIO_PHY_1000BASET_ABILITY ) +if (ext_ability &MDIO_PMA_EXTABLE_1000BT ) physical_layer |=IXGBE_PHYSICAL_LAYER_1000BASE_T ; -if (ext_ability &IXGBE_MDIO_PHY_100BASETX_ABILITY ) +if (ext_ability &MDIO_PMA_EXTABLE_100BTX ) physical_layer |=IXGBE_PHYSICAL_LAYER_100BASE_TX ; goto out; }
drivers/net/ixgbe/ixgbe_82599.c +8 -9
@@ -314,14 +314,13 @@ static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw, *speed =0 ; *autoneg = true; - status = hw->phy.ops.read_reg (hw,IXGBE_MDIO_PHY_SPEED_ABILITY , -IXGBE_MDIO_PMA_PMD_DEV_TYPE , + status = hw->phy.ops.read_reg (hw,MDIO_SPEED ,MDIO_MMD_PMAPMD , &speed_ability);if (status ==0 ) { -if (speed_ability &IXGBE_MDIO_PHY_SPEED_10G ) +if (speed_ability &MDIO_SPEED_10G ) *speed |=IXGBE_LINK_SPEED_10GB_FULL ; -if (speed_ability &IXGBE_MDIO_PHY_SPEED_1G ) +if (speed_ability &MDIO_PMA_SPEED_1000 ) *speed |=IXGBE_LINK_SPEED_1GB_FULL ; }
@@ -1153,13 +1152,13 @@ u32 ixgbe_get_supported_physical_layer_82599(struct ixgbe_hw *hw)if (hw->phy.type == ixgbe_phy_tn || hw->phy.type == ixgbe_phy_cu_unknown) { - hw->phy.ops.read_reg (hw,IXGBE_MDIO_PHY_EXT_ABILITY , -IXGBE_MDIO_PMA_PMD_DEV_TYPE , &ext_ability); -if (ext_ability &IXGBE_MDIO_PHY_10GBASET_ABILITY ) + hw->phy.ops.read_reg (hw,MDIO_PMA_EXTABLE ,MDIO_MMD_PMAPMD , + &ext_ability); +if (ext_ability &MDIO_PMA_EXTABLE_10GBT ) physical_layer |=IXGBE_PHYSICAL_LAYER_10GBASE_T ; -if (ext_ability &IXGBE_MDIO_PHY_1000BASET_ABILITY ) +if (ext_ability &MDIO_PMA_EXTABLE_1000BT ) physical_layer |=IXGBE_PHYSICAL_LAYER_1000BASE_T ; -if (ext_ability &IXGBE_MDIO_PHY_100BASETX_ABILITY ) +if (ext_ability &MDIO_PMA_EXTABLE_100BTX ) physical_layer |=IXGBE_PHYSICAL_LAYER_100BASE_TX ; goto out; }
drivers/net/ixgbe/ixgbe_main.c +42 -0
60 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_phy.c +32 -63
212 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_type.h +3 -30
@@ -29,6 +29,7 @@#define _IXGBE_TYPE_H_#include <linux/types.h> +#include <linux/mdio.h> /* Vendor ID */ #define IXGBE_INTEL_VENDOR_ID 0x8086
@@ -848,13 +849,7 @@/* Omer bit masks */ #define IXGBE_CORECTL_WRITE_CMD 0x00010000 -/* Device Type definitions for new protocol MDIO commands */ -#define IXGBE_MDIO_PMA_PMD_DEV_TYPE 0x1 -#define IXGBE_MDIO_PCS_DEV_TYPE 0x3 -#define IXGBE_MDIO_PHY_XS_DEV_TYPE 0x4 -#define IXGBE_MDIO_AUTO_NEG_DEV_TYPE 0x7 -#define IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE 0x1E/* Device 30 */ -#define IXGBE_TWINAX_DEV 1 +/* MDIO definitions */ #define IXGBE_MDIO_COMMAND_TIMEOUT 100/* PHY Timeout for 1 GB mode */
@@ -865,32 +860,10 @@#define IXGBE_MDIO_VENDOR_SPECIFIC_1_10G_SPEED 0x0018#define IXGBE_MDIO_VENDOR_SPECIFIC_1_1G_SPEED 0x0010 -#define IXGBE_MDIO_AUTO_NEG_CONTROL 0x0/* AUTO_NEG Control Reg */ -#define IXGBE_MDIO_AUTO_NEG_STATUS 0x1/* AUTO_NEG Status Reg */ -#define IXGBE_MDIO_PHY_XS_CONTROL 0x0/* PHY_XS Control Reg */ -#define IXGBE_MDIO_PHY_XS_RESET 0x8000/* PHY_XS Reset */ -#define IXGBE_MDIO_PHY_ID_HIGH 0x2/* PHY ID High Reg*/ -#define IXGBE_MDIO_PHY_ID_LOW 0x3/* PHY ID Low Reg*/ -#define IXGBE_MDIO_PHY_SPEED_ABILITY 0x4/* Speed Ability Reg */ -#define IXGBE_MDIO_PHY_SPEED_10G 0x0001/* 10G capable */ -#define IXGBE_MDIO_PHY_SPEED_1G 0x0010/* 1G capable */ -#define IXGBE_MDIO_PHY_EXT_ABILITY 0xB/* Ext Ability Reg */ -#define IXGBE_MDIO_PHY_10GBASET_ABILITY 0x0004/* 10GBaseT capable */ -#define IXGBE_MDIO_PHY_1000BASET_ABILITY 0x0020/* 1000BaseT capable */ -#define IXGBE_MDIO_PHY_100BASETX_ABILITY 0x0080/* 100BaseTX capable */ -#define IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR 0xC30A/* PHY_XS SDA/SCL Addr Reg */ #define IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA 0xC30B/* PHY_XS SDA/SCL Data Reg */ #define IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT 0xC30C/* PHY_XS SDA/SCL Status Reg */ -/* MII clause 22/28 definitions */ -#define IXGBE_MDIO_PHY_LOW_POWER_MODE 0x0800 - -#define IXGBE_MII_SPEED_SELECTION_REG 0x10 -#define IXGBE_MII_RESTART 0x200 -#define IXGBE_MII_AUTONEG_COMPLETE 0x20 -#define IXGBE_MII_AUTONEG_REG 0x0 -#define IXGBE_PHY_REVISION_MASK 0xFFFFFFF0#define IXGBE_MAX_PHY_ADDR 32
@@ -2214,8 +2187,8 @@ struct ixgbe_mac_info {struct ixgbe_phy_info {struct ixgbe_phy_operations ops; +struct mdio_if_info mdio;enum ixgbe_phy_type type; -u32 addr;u32 id;enum ixgbe_sfp_type sfp_type;bool sfp_setup_needed;
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 8/16 ixgb: Use generic MDIO definitions
In reply to Ben HutchingsCompile-tested only.
--- drivers/net/ixgb/ixgb_hw.c | 20 ++++++++++---------- drivers/net/ixgb/ixgb_hw.h | 14 ++------------ 2 files changed, 12 insertions(+), 22 deletions(-)
drivers/net/ixgb/ixgb_hw.c +10 -10
@@ -192,7 +192,7 @@ ixgb_identify_xpak_vendor(struct ixgb_hw *hw) vendor_name[i] =ixgb_read_phy_reg (hw,MDIO_PMA_PMD_XPAK_VENDOR_NAME + i,IXGB_PHY_ADDRESS , -MDIO_PMA_PMD_DID ); +MDIO_MMD_PMAPMD ); }/* Determine the actual vendor */
@@ -1225,15 +1225,15 @@ ixgb_optics_reset(struct ixgb_hw *hw)u16 mdio_reg;ixgb_write_phy_reg (hw, -MDIO_PMA_PMD_CR1 , -IXGB_PHY_ADDRESS , -MDIO_PMA_PMD_DID , -MDIO_PMA_PMD_CR1_RESET ); - - mdio_reg =ixgb_read_phy_reg ( hw, -MDIO_PMA_PMD_CR1 , -IXGB_PHY_ADDRESS , -MDIO_PMA_PMD_DID ); +MDIO_CTRL1 , +IXGB_PHY_ADDRESS , +MDIO_MMD_PMAPMD , +MDIO_CTRL1_RESET ); + + mdio_reg =ixgb_read_phy_reg (hw, +MDIO_CTRL1 , +IXGB_PHY_ADDRESS , +MDIO_MMD_PMAPMD ); }return ;
drivers/net/ixgb/ixgb_hw.h +2 -12
@@ -29,6 +29,8 @@#ifndef _IXGB_HW_H_#define _IXGB_HW_H_ +#include <linux/mdio.h> +#include "ixgb_osdep.h" /* Enums */
@@ -507,18 +509,6 @@ typedef enum {/* Definitions for the optics devices on the MDIO bus. */ #define IXGB_PHY_ADDRESS 0x0/* Single PHY, multiple "Devices" */ -/* Standard five-bit Device IDs. See IEEE 802.3ae, clause 45 */ -#define MDIO_PMA_PMD_DID 0x01 -#define MDIO_WIS_DID 0x02 -#define MDIO_PCS_DID 0x03 -#define MDIO_XGXS_DID 0x04 - -/* Standard PMA/PMD registers and bit definitions. */ -/* Note: This is a very limited set of definitions, */ -/* only implemented features are defined. */ -#define MDIO_PMA_PMD_CR1 0x0000 -#define MDIO_PMA_PMD_CR1_RESET 0x8000 -#define MDIO_PMA_PMD_XPAK_VENDOR_NAME 0x803A/* XPAK/XENPAK devices only */ /* Vendor-specific MDIO registers */
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 9/16 s2io: Use generic MDIO definitions
In reply to Ben HutchingsCompile-tested only.
--- drivers/net/s2io-regs.h | 5 ----- drivers/net/s2io.c | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-)
drivers/net/s2io-regs.h +0 -5
@@ -271,11 +271,6 @@ struct XENA_dev_config {u64 mdio_control;#define MDIO_MMD_INDX_ADDR (val) vBIT(val, 0, 16)#define MDIO_MMD_DEV_ADDR (val) vBIT(val, 19, 5) -#define MDIO_MMD_PMA_DEV_ADDR 0x1 -#define MDIO_MMD_PMD_DEV_ADDR 0x1 -#define MDIO_MMD_WIS_DEV_ADDR 0x2 -#define MDIO_MMD_PCS_DEV_ADDR 0x3 -#define MDIO_MMD_PHYXS_DEV_ADDR 0x4#define MDIO_MMS_PRT_ADDR (val) vBIT(val, 27, 5)#define MDIO_CTRL_START_TRANS (val) vBIT(val, 56, 4)#define MDIO_OP (val) vBIT(val, 60, 2)
drivers/net/s2io.c +11 -10
@@ -63,6 +63,7 @@#include <linux/kernel.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> +#include <linux/mdio.h> #include <linux/skbuff.h> #include <linux/init.h> #include <linux/delay.h>
@@ -3328,9 +3329,9 @@ static void s2io_updt_xpak_counter(struct net_device *dev)struct stat_block *stat_info = sp->mac_control.stats_info;/* Check the communication with the MDIO slave */ - addr =0x0000 ; + addr =MDIO_CTRL1 ; val64 =0x0 ; - val64 =s2io_mdio_read (MDIO_MMD_PMA_DEV_ADDR , addr, dev); + val64 =s2io_mdio_read (MDIO_MMD_PMAPMD , addr, dev);if ((val64 ==0xFFFF ) || (val64 ==0x0000 )) { DBG_PRINT(ERR_DBG, "ERR: MDIO slave access failed - "
@@ -3338,24 +3339,24 @@ static void s2io_updt_xpak_counter(struct net_device *dev)return ; } -/* Check for the expecte value of 2040 at PMA address 0x0000 */ -if (val64 !=0x2040 ) +/* Check for the expected value of control reg 1 */ +if (val64 !=MDIO_CTRL1_SPEED10G ) {DBG_PRINT (ERR_DBG ,"Incorrect value at PMA address 0x0000 - " ); -DBG_PRINT (ERR_DBG ,"Returned: %llx- Expected: 0x2040\n" , - (unsigned long long )val64); +DBG_PRINT (ERR_DBG ,"Returned: %llx- Expected: 0x%x\n" , + (unsigned long long )val64,MDIO_CTRL1_SPEED10G );return ; }/* Loading the DOM register to MDIO register */ addr =0xA100 ; -s2io_mdio_write (MDIO_MMD_PMA_DEV_ADDR , addr, val16, dev); - val64 =s2io_mdio_read (MDIO_MMD_PMA_DEV_ADDR , addr, dev); +s2io_mdio_write (MDIO_MMD_PMAPMD , addr, val16, dev); + val64 =s2io_mdio_read (MDIO_MMD_PMAPMD , addr, dev);/* Reading the Alarm flags */ addr =0xA070 ; val64 =0x0 ; - val64 =s2io_mdio_read (MDIO_MMD_PMA_DEV_ADDR , addr, dev); + val64 =s2io_mdio_read (MDIO_MMD_PMAPMD , addr, dev); flag =CHECKBIT (val64,0x7 ); type =1 ;
@@ -3387,7 +3388,7 @@ static void s2io_updt_xpak_counter(struct net_device *dev)/* Reading the Warning flags */ addr =0xA074 ; val64 =0x0 ; - val64 =s2io_mdio_read (MDIO_MMD_PMA_DEV_ADDR , addr, dev); + val64 =s2io_mdio_read (MDIO_MMD_PMAPMD , addr, dev);if (CHECKBIT (val64,0x7 )) stat_info->xpak_stat.warn_transceiver_temp_high++;
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 10/16 mii: Simplify mii_resolve_flowctrl_fdx()
In reply to Ben HutchingsThis is a shorter and more comprehensible formulation of the conditions for each flow control mode.
--- include/linux/mii.h | 18 ++++++------------ 1 files changed, 6 insertions(+), 12 deletions(-)
include/linux/mii.h +6 -12
@@ -250,18 +250,12 @@ static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv) {u8 cap =0 ; -if (lcladv &ADVERTISE_PAUSE_CAP ) { -if (lcladv &ADVERTISE_PAUSE_ASYM ) { -if (rmtadv &LPA_PAUSE_CAP ) - cap =FLOW_CTRL_TX |FLOW_CTRL_RX ; -else if (rmtadv &LPA_PAUSE_ASYM ) - cap =FLOW_CTRL_RX ; - }else { -if (rmtadv &LPA_PAUSE_CAP ) - cap =FLOW_CTRL_TX |FLOW_CTRL_RX ; - } - }else if (lcladv &ADVERTISE_PAUSE_ASYM ) { -if ((rmtadv &LPA_PAUSE_CAP ) && (rmtadv &LPA_PAUSE_ASYM )) +if (lcladv & rmtadv &ADVERTISE_PAUSE_CAP ) { + cap =FLOW_CTRL_TX |FLOW_CTRL_RX ; + }else if (lcladv & rmtadv &ADVERTISE_PAUSE_ASYM ) { +if (lcladv &ADVERTISE_PAUSE_CAP ) + cap =FLOW_CTRL_RX ; +else if (rmtadv &ADVERTISE_PAUSE_CAP ) cap =FLOW_CTRL_TX ; }
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 11/16 mii: Add mii_advertise_flowctrl()
In reply to Ben HutchingsThis converts flow control capabilites to an advertising mask and can be useful in combination with mii_resolve_flowctrl_fdx().
---
This is intended to be used to implement ETHTOOL_SPAUSEPARAM when autoneg is set, but I'm not sure how that command is supposed to interact with pause autonegotiation flags set through ETHTOOL_SSET.
Ben.
include/linux/mii.h | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
include/linux/mii.h +16 -0
@@ -240,6 +240,22 @@ static inline unsigned int mii_duplex (unsigned int duplex_lock, }/** +* mii_advertise_flowctrl - get flow control advertisement flags +* @cap: Flow control capabilities (FLOW_CTRL_RX, FLOW_CTRL_TX or both) +*/ +static inline u16 mii_advertise_flowctrl (int cap) +{ +u16 adv =0 ; + +if (cap &FLOW_CTRL_RX ) + adv =ADVERTISE_PAUSE_CAP |ADVERTISE_PAUSE_ASYM ; +if (cap &FLOW_CTRL_TX ) + adv ^=ADVERTISE_PAUSE_ASYM ; + +return adv; +} + +/** * mii_resolve_flowctrl_fdx * @lcladv: value of MII ADVERTISE register * @rmtadv: value of MII LPA register
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 12/16 mdio: Add mdio45_ethtool_spauseparam_an()
In reply to Ben HutchingsThis implements the ETHTOOL_SPAUSEPARAM operation for MDIO (clause 45) PHYs with auto-negotiation MMDs.
--- drivers/net/mdio.c | 30 ++++++++++++++++++++++++++++++ include/linux/mdio.h | 3 +++ 2 files changed, 33 insertions(+), 0 deletions(-)
drivers/net/mdio.c +30 -0
@@ -275,6 +275,36 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,EXPORT_SYMBOL (mdio45_ethtool_gset_npage);/** +* mdio45_ethtool_spauseparam_an - set auto-negotiated pause parameters +* @mdio: MDIO interface +* @ecmd: Ethtool request structure +* +* This function assumes that the PHY has an auto-negotiation MMD. It +* will enable and disable advertising of flow control as appropriate. +*/ +void mdio45_ethtool_spauseparam_an (const struct mdio_if_info *mdio, +const struct ethtool_pauseparam *ecmd) +{ +int adv, old_adv; + +WARN_ON (!(mdio->mmds &MDIO_DEVS_AN )); + + old_adv = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_AN , +MDIO_AN_ADVERTISE ); + adv = old_adv & ~(ADVERTISE_PAUSE_CAP |ADVERTISE_PAUSE_ASYM ); +if (ecmd->autoneg) + adv |=mii_advertise_flowctrl ( + (ecmd->rx_pause ?FLOW_CTRL_RX :0 ) | + (ecmd->tx_pause ?FLOW_CTRL_TX :0 )); +if (adv != old_adv) { + mdio->mdio_write (mdio->dev, mdio->prtad,MDIO_MMD_AN , +MDIO_AN_ADVERTISE , adv); +mdio45_nway_restart (mdio); + } +} +EXPORT_SYMBOL (mdio45_ethtool_spauseparam_an); + +/** * mdio_mii_ioctl - MII ioctl interface for MDIO (clause 22 or 45) PHYs * @mdio: MDIO interface * @mii_data: MII ioctl data structure
include/linux/mdio.h +3 -0
@@ -279,6 +279,9 @@ extern int mdio45_nway_restart(const struct mdio_if_info *mdio);extern void mdio45_ethtool_gset_npage (const struct mdio_if_info *mdio,struct ethtool_cmd *ecmd,u32 npage_adv,u32 npage_lpa); +extern void +mdio45_ethtool_spauseparam_an (const struct mdio_if_info *mdio, +const struct ethtool_pauseparam *ecmd);/** * mdio45_ethtool_gset - get settings for ETHTOOL_GSET
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 13/16 sfc: Use generic MDIO flow control auto-negotiation functions
In reply to Ben Hutchings--- drivers/net/sfc/ethtool.c | 3 ++- drivers/net/sfc/mdio_10g.c | 22 +--------------------- drivers/net/sfc/mdio_10g.h | 3 --- drivers/net/sfc/net_driver.h | 26 ++++---------------------- drivers/net/sfc/tenxpress.c | 1 - 5 files changed, 7 insertions(+), 48 deletions(-)
drivers/net/sfc/ethtool.c +2 -1
@@ -711,7 +711,8 @@ static int efx_ethtool_set_pauseparam(struct net_device *net_dev,mutex_lock (&efx->mac_lock); efx->wanted_fc = wanted_fc; -efx_mdio_set_pause (efx); +if (efx->phy_op->mmds &MDIO_DEVS_AN ) +mdio45_ethtool_spauseparam_an (&efx->mdio, pause);__efx_reconfigure_port (efx);mutex_unlock (&efx->mac_lock);
drivers/net/sfc/mdio_10g.c +1 -21
@@ -304,7 +304,7 @@ int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)else if (ecmd->advertising & (ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full)) reg |=ADVERTISE_NPAGE ; - reg |=efx_fc_advertise (efx->wanted_fc); + reg |=mii_advertise_flowctrl (efx->wanted_fc);efx_mdio_write (efx,MDIO_MMD_AN ,MDIO_AN_ADVERTISE , reg);/* Set up the (extended) next page if necessary */
@@ -340,26 +340,6 @@ int efx_mdio_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)return 0 ; } -void efx_mdio_set_pause (struct efx_nic *efx) -{ -int reg; - -if (efx->phy_op->mmds &MDIO_DEVS_AN ) { -/* Set pause capability advertising */ - reg =efx_mdio_read (efx,MDIO_MMD_AN ,MDIO_AN_ADVERTISE ); - reg &= ~(ADVERTISE_PAUSE_CAP |ADVERTISE_PAUSE_ASYM ); - reg |=efx_fc_advertise (efx->wanted_fc); -efx_mdio_write (efx,MDIO_MMD_AN ,MDIO_AN_ADVERTISE , reg); - -/* Restart auto-negotiation */ - reg =efx_mdio_read (efx,MDIO_MMD_AN ,MDIO_CTRL1 ); -if (reg &MDIO_AN_CTRL1_ENABLE ) { - reg |=MDIO_AN_CTRL1_RESTART ; -efx_mdio_write (efx,MDIO_MMD_AN ,MDIO_CTRL1 , reg); - } - } -} -enum efx_fc_type efx_mdio_get_pause (struct efx_nic *efx) {int lpa;
drivers/net/sfc/mdio_10g.h +0 -3
@@ -87,9 +87,6 @@ extern void efx_mdio_set_mmds_lpower(struct efx_nic *efx,/* Set (some of) the PHY settings over MDIO */ extern int efx_mdio_set_settings (struct efx_nic *efx,struct ethtool_cmd *ecmd); -/* Set pause parameters to be advertised through AN (if available) */ -extern void efx_mdio_set_pause (struct efx_nic *efx); -/* Get pause parameters from AN if available (otherwise return * requested pause parameters) */
drivers/net/sfc/net_driver.h +4 -22
@@ -495,8 +495,8 @@ struct efx_nic;/* Pseudo bit-mask flow control field */ enum efx_fc_type { -EFX_FC_RX =1 , -EFX_FC_TX =2 , +EFX_FC_RX =FLOW_CTRL_RX , +EFX_FC_TX =FLOW_CTRL_TX ,EFX_FC_AUTO =4 , };
@@ -506,33 +506,15 @@ enum efx_mac_type { EFX_XMAC = 2, }; -static inline unsigned int efx_fc_advertise (enum efx_fc_type wanted_fc) -{ -unsigned int adv =0 ; -if (wanted_fc &EFX_FC_RX ) - adv =ADVERTISE_PAUSE_CAP |ADVERTISE_PAUSE_ASYM ; -if (wanted_fc &EFX_FC_TX ) - adv ^=ADVERTISE_PAUSE_ASYM ; -return adv; -} -static inline enum efx_fc_type efx_fc_resolve (enum efx_fc_type wanted_fc,unsigned int lpa) { -unsigned int adv =efx_fc_advertise (wanted_fc); +BUILD_BUG_ON (EFX_FC_AUTO & (EFX_FC_RX |EFX_FC_TX ));if (!(wanted_fc &EFX_FC_AUTO ))return wanted_fc; -if (adv & lpa &ADVERTISE_PAUSE_CAP ) -return EFX_FC_RX |EFX_FC_TX ; -if (adv & lpa &ADVERTISE_PAUSE_ASYM ) { -if (adv &ADVERTISE_PAUSE_CAP ) -return EFX_FC_RX ; -if (lpa &ADVERTISE_PAUSE_CAP ) -return EFX_FC_TX ; - } -return 0 ; +return mii_resolve_flowctrl_fdx (mii_advertise_flowctrl (wanted_fc), lpa); }/**
drivers/net/sfc/tenxpress.c +0 -1
@@ -343,7 +343,6 @@ static int tenxpress_phy_init(struct efx_nic *efx) rc =tenxpress_init (efx);if (rc <0 ) goto fail; -efx_mdio_set_pause (efx);if (efx->phy_type ==PHY_TYPE_SFT9001B ) { rc = device_create_file(&efx->pci_dev->dev,
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 14/16 ethtool/mdio: Report MDIO mode support and link partner advertising
In reply to Ben HutchingsAdd mdio_support and lp_advertising fields to ethtool_cmd. Set these in mdio45_ethtool_gset{,_npage}().
--- drivers/net/mdio.c | 19 ++++++++++++------- include/linux/ethtool.h | 4 +++- include/linux/mdio.h | 5 +++-- 3 files changed, 18 insertions(+), 10 deletions(-)
drivers/net/mdio.c +12 -7
@@ -173,6 +173,8 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio, ecmd->transceiver =XCVR_INTERNAL ; ecmd->phy_address = mdio->prtad; + ecmd->mdio_support = + mdio->mode_support & (MDIO_SUPPORTS_C45 |MDIO_SUPPORTS_C22 ); reg = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_PMAPMD ,MDIO_CTRL2 );
@@ -235,16 +237,19 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,if (ecmd->autoneg) {u32 modes =0 ; +int an_stat = mdio->mdio_read (mdio->dev, mdio->prtad, +MDIO_MMD_AN ,MDIO_STAT1 );/* If AN is complete and successful, report best common * mode, otherwise report best advertised mode. */ -if (mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_AN , -MDIO_STAT1 ) & -MDIO_AN_STAT1_COMPLETE ) - modes = (ecmd->advertising & - (mdio45_get_an (mdio,MDIO_AN_LPA ) | - npage_lpa)); -if (modes ==0 ) +if (an_stat &MDIO_AN_STAT1_COMPLETE ) { + ecmd->lp_advertising = +mdio45_get_an (mdio,MDIO_AN_LPA ) | npage_lpa; +if (an_stat &MDIO_AN_STAT1_LPABLE ) + ecmd->lp_advertising |= ADVERTISED_Autoneg; + modes = ecmd->advertising & ecmd->lp_advertising; + } +if ((modes & ~ADVERTISED_Autoneg) ==0 ) modes = ecmd->advertising;if (modes & ADVERTISED_10000baseT_Full) {
include/linux/ethtool.h +3 -1
@@ -26,11 +26,13 @@ struct ethtool_cmd {__u8 phy_address;__u8 transceiver;/* Which transceiver to use */ __u8 autoneg;/* Enable or disable autonegotiation */ +__u8 mdio_support;__u32 maxtxpkt;/* Tx pkts before generating tx int */ __u32 maxrxpkt;/* Rx pkts before generating rx int */ __u16 speed_hi;__u16 reserved2; -__u32 reserved[3 ]; +__u32 lp_advertising;/* Features the link partner advertises */ +__u32 reserved[2 ]; }; static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
include/linux/mdio.h +3 -2
@@ -234,6 +234,9 @@ static inline __u16 mdio_phy_id_devad(int phy_id)return phy_id &MDIO_PHY_ID_DEVAD ; } +#define MDIO_SUPPORTS_C22 1 +#define MDIO_SUPPORTS_C45 2 +#ifdef __KERNEL__/**
@@ -264,8 +267,6 @@ struct mdio_if_info {#define MDIO_PRTAD_NONE (-1)#define MDIO_DEVAD_NONE (-1) -#define MDIO_SUPPORTS_C22 1 -#define MDIO_SUPPORTS_C45 2#define MDIO_EMULATE_C22 4struct ethtool_cmd ;
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 15/16 ethtool/mdio: Support backplane mode negotiation
In reply to Ben HutchingsCompile-tested only.
---
This should be tested with some actual backplane-Ethernet hardware. If no-one does that I can resubmit just the header changes for now.
Ben.
drivers/net/mdio.c | 30 +++++++++++++++++++++++++----- include/linux/ethtool.h | 10 ++++++++++ include/linux/mdio.h | 5 +++++ 3 files changed, 40 insertions(+), 5 deletions(-)
drivers/net/mdio.c +25 -5
@@ -202,12 +202,29 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,break ;case MDIO_PMA_CTRL2_10GBCX4 : + ecmd->port =PORT_OTHER ; + ecmd->supported =0 ; + ecmd->advertising =0 ; +break ; +case MDIO_PMA_CTRL2_10GBKX4 :case MDIO_PMA_CTRL2_10GBKR :case MDIO_PMA_CTRL2_1000BKX : ecmd->port =PORT_OTHER ; - ecmd->supported =0 ; - ecmd->advertising =0 ; + ecmd->supported = SUPPORTED_Backplane; + reg = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_PMAPMD , +MDIO_PMA_EXTABLE ); +if (reg &MDIO_PMA_EXTABLE_10GBKX4 ) + ecmd->supported |= SUPPORTED_10000baseKX4_Full; +if (reg &MDIO_PMA_EXTABLE_10GBKR ) + ecmd->supported |= SUPPORTED_10000baseKR_Full; +if (reg &MDIO_PMA_EXTABLE_1000BKX ) + ecmd->supported |= SUPPORTED_1000baseKX_Full; + reg = mdio->mdio_read (mdio->dev, mdio->prtad,MDIO_MMD_PMAPMD , +MDIO_PMA_10GBR_FECABLE ); +if (reg &MDIO_PMA_10GBR_FECABLE_ABLE ) + ecmd->supported |= SUPPORTED_10000baseR_FEC; + ecmd->advertising = ADVERTISED_Backplane;break ;/* All the other defined modes are flavours of optical */
@@ -252,13 +269,16 @@ void mdio45_ethtool_gset_npage(const struct mdio_if_info *mdio,if ((modes & ~ADVERTISED_Autoneg) ==0 ) modes = ecmd->advertising; -if (modes & ADVERTISED_10000baseT_Full) { +if (modes & (ADVERTISED_10000baseT_Full | + ADVERTISED_10000baseKX4_Full | + ADVERTISED_10000baseKR_Full)) { ecmd->speed =SPEED_10000 ; ecmd->duplex =DUPLEX_FULL ; }else if (modes & (ADVERTISED_1000baseT_Full | - ADVERTISED_1000baseT_Half)) { + ADVERTISED_1000baseT_Half | + ADVERTISED_1000baseKX_Full)) { ecmd->speed =SPEED_1000 ; - ecmd->duplex = !!(modes & ADVERTISED_1000baseT_Full); + ecmd->duplex = !(modes & ADVERTISED_1000baseT_Half); }else if (modes & (ADVERTISED_100baseT_Full | ADVERTISED_100baseT_Half)) { ecmd->speed =SPEED_100 ;
include/linux/ethtool.h +10 -0
@@ -565,6 +565,11 @@ struct ethtool_ops {#define SUPPORTED_Pause (1 << 13)#define SUPPORTED_Asym_Pause (1 << 14)#define SUPPORTED_2500baseX_Full (1 << 15) +#define SUPPORTED_Backplane (1 << 16) +#define SUPPORTED_1000baseKX_Full (1 << 17) +#define SUPPORTED_10000baseKX4_Full (1 << 18) +#define SUPPORTED_10000baseKR_Full (1 << 19) +#define SUPPORTED_10000baseR_FEC (1 << 20)/* Indicates what features are advertised by the interface. */ #define ADVERTISED_10baseT_Half (1 << 0)
@@ -583,6 +588,11 @@ struct ethtool_ops {#define ADVERTISED_Pause (1 << 13)#define ADVERTISED_Asym_Pause (1 << 14)#define ADVERTISED_2500baseX_Full (1 << 15) +#define ADVERTISED_Backplane (1 << 16) +#define ADVERTISED_1000baseKX_Full (1 << 17) +#define ADVERTISED_10000baseKX4_Full (1 << 18) +#define ADVERTISED_10000baseKR_Full (1 << 19) +#define ADVERTISED_10000baseR_FEC (1 << 20)/* The following are all involved in forcing a particular link * mode for the device for setting things. When getting the
include/linux/mdio.h +5 -0
@@ -46,6 +46,7 @@/* Media-dependent registers. */ #define MDIO_PMA_10GBT_TXPWR 131/* 10GBASE-T TX power control */ +#define MDIO_PMA_10GBR_FECABLE 170/* 10GBASE-R FEC ability */ #define MDIO_PCS_10GBX_STAT1 24/* 10GBASE-X PCS status 1 */ #define MDIO_PCS_10GBRT_STAT1 32/* 10GBASE-R/-T PCS status 1 */ #define MDIO_PCS_10GBRT_STAT2 33/* 10GBASE-R/-T PCS status 2 */
@@ -187,6 +188,10 @@/* PMA 10GBASE-T TX power register. */ #define MDIO_PMA_10GBT_TXPWR_SHORT 0x0001/* Short-reach mode */ +/* PMA 10GBASE-R FEC ability register. */ +#define MDIO_PMA_10GBR_FECABLE_ABLE 0x0001/* FEC ability */ +#define MDIO_PMA_10GBR_FECABLE_ERRABLE 0x0002/* FEC error indic. ability */ +/* PCS 10GBASE-R/-T status register 1. */ #define MDIO_PCS_10GBRT_STAT1_BLKLK 0x0001/* Block lock attained */
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 16/16 mii: Rewrite mii_ethtool_gset() to report mdio_support and lp_advertising
In reply to Ben HutchingsIgnore link partner advertising flags while AN is not complete.
Compile-tested only.
---
I can't seem to find any hardware whose driver uses the mii module now, so this is unfortunately untested.
This might well be better split into 2 or more patches.
Ben.
drivers/net/mii.c | 91 +++++++++++++++++++++++++++++++++-------------------- 1 files changed, 57 insertions(+), 34 deletions(-)
drivers/net/mii.c +57 -34
@@ -31,7 +31,27 @@#include <linux/module.h> #include <linux/netdevice.h> #include <linux/ethtool.h> -#include <linux/mii.h> +#include <linux/mdio.h> + +static u32 mii_get_an (struct mii_if_info *mii,u16 addr) +{ +u32 result =0 ; +int advert; + + advert = mii->mdio_read (mii->dev, mii->phy_id, addr); +if (advert &LPA_LPACK ) + result |= ADVERTISED_Autoneg; +if (advert &ADVERTISE_10HALF ) + result |= ADVERTISED_10baseT_Half; +if (advert &ADVERTISE_10FULL ) + result |= ADVERTISED_10baseT_Full; +if (advert &ADVERTISE_100HALF ) + result |= ADVERTISED_100baseT_Half; +if (advert &ADVERTISE_100FULL ) + result |= ADVERTISED_100baseT_Full; + +return result; +}/** * mii_ethtool_gset - get settings that are specified in @ecmd
@@ -43,8 +63,8 @@int mii_ethtool_gset (struct mii_if_info *mii,struct ethtool_cmd *ecmd) {struct net_device *dev = mii->dev; -u32 advert, bmcr, lpa, nego; -u32 advert2 =0 , bmcr2 =0 , lpa2 =0 ; +u16 bmcr, bmsr, ctrl1000 =0 , stat1000 =0 ; +u32 nego; ecmd->supported = (SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
@@ -62,50 +82,51 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd)/* this isn't fully supported at higher layers */ ecmd->phy_address = mii->phy_id; + ecmd->mdio_support =MDIO_SUPPORTS_C22 ; ecmd->advertising =ADVERTISED_TP |ADVERTISED_MII ; - advert = mii->mdio_read (dev, mii->phy_id,MII_ADVERTISE ); -if (mii->supports_gmii) - advert2 = mii->mdio_read (dev, mii->phy_id,MII_CTRL1000 ); - -if (advert &ADVERTISE_10HALF ) - ecmd->advertising |= ADVERTISED_10baseT_Half; -if (advert &ADVERTISE_10FULL ) - ecmd->advertising |= ADVERTISED_10baseT_Full; -if (advert &ADVERTISE_100HALF ) - ecmd->advertising |= ADVERTISED_100baseT_Half; -if (advert &ADVERTISE_100FULL ) - ecmd->advertising |= ADVERTISED_100baseT_Full; -if (advert2 &ADVERTISE_1000HALF ) - ecmd->advertising |= ADVERTISED_1000baseT_Half; -if (advert2 &ADVERTISE_1000FULL ) - ecmd->advertising |= ADVERTISED_1000baseT_Full; bmcr = mii->mdio_read (dev, mii->phy_id,MII_BMCR ); - lpa = mii->mdio_read (dev, mii->phy_id,MII_LPA ); + bmsr = mii->mdio_read (dev, mii->phy_id,MII_BMSR );if (mii->supports_gmii) { - bmcr2 = mii->mdio_read (dev, mii->phy_id,MII_CTRL1000 ); - lpa2 = mii->mdio_read (dev, mii->phy_id,MII_STAT1000 ); + ctrl1000 = mii->mdio_read (dev, mii->phy_id,MII_CTRL1000 ); + stat1000 = mii->mdio_read (dev, mii->phy_id,MII_STAT1000 ); }if (bmcr &BMCR_ANENABLE ) { ecmd->advertising |= ADVERTISED_Autoneg; ecmd->autoneg =AUTONEG_ENABLE ; - nego =mii_nway_result (advert & lpa); -if ((bmcr2 & (ADVERTISE_1000HALF |ADVERTISE_1000FULL )) & - (lpa2 >>2 )) + ecmd->advertising |=mii_get_an (mii,MII_ADVERTISE ); +if (ctrl1000 &ADVERTISE_1000HALF ) + ecmd->advertising |= ADVERTISED_1000baseT_Half; +if (ctrl1000 &ADVERTISE_1000FULL ) + ecmd->advertising |= ADVERTISED_1000baseT_Full; + +if (bmsr &BMSR_ANEGCOMPLETE ) { + ecmd->lp_advertising =mii_get_an (mii,MII_LPA ); +if (stat1000 &LPA_1000HALF ) + ecmd->lp_advertising |= + ADVERTISED_1000baseT_Half; +if (stat1000 &LPA_1000FULL ) + ecmd->lp_advertising |= + ADVERTISED_1000baseT_Full; + }else { + ecmd->lp_advertising =0 ; + } + + nego = ecmd->advertising & ecmd->lp_advertising; + +if (nego & (ADVERTISED_1000baseT_Full | + ADVERTISED_1000baseT_Half)) { ecmd->speed =SPEED_1000 ; -else if (nego ==LPA_100FULL || nego ==LPA_100HALF ) + ecmd->duplex = !!(nego & ADVERTISED_1000baseT_Full); + }else if (nego & (ADVERTISED_100baseT_Full | + ADVERTISED_100baseT_Half)) { ecmd->speed =SPEED_100 ; -else - ecmd->speed =SPEED_10 ; -if ((lpa2 &LPA_1000FULL ) || nego ==LPA_100FULL || - nego ==LPA_10FULL ) { - ecmd->duplex =DUPLEX_FULL ; - mii->full_duplex =1 ; + ecmd->duplex = !!(nego & ADVERTISED_100baseT_Full); }else { - ecmd->duplex =DUPLEX_HALF ; - mii->full_duplex =0 ; + ecmd->speed =SPEED_10 ; + ecmd->duplex = !!(nego & ADVERTISED_10baseT_Full); } }else { ecmd->autoneg =AUTONEG_DISABLE ;
@@ -116,6 +137,8 @@ int mii_ethtool_gset(struct mii_if_info *mii, struct ethtool_cmd *ecmd) ecmd->duplex = (bmcr &BMCR_FULLDPLX ) ?DUPLEX_FULL :DUPLEX_HALF ; } + mii->full_duplex = ecmd->duplex; +/* ignore maxtxpkt, maxrxpkt for now */ return 0 ;
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
David Miller
maintainerFrom: Ben Hutchings <[email protected]>
Date: Wed, 29 Apr 2009 19:01:26 +0100
Quoted 5 lines
The first part of this series introduce counterparts to <
linux/mii.h> and the mii module for use with MDIO clause 45 devices and controllers that support both clause 22 and clause 45, and change several 10G Ethernet drivers to use them.
Quoted 8 lines
The remaining patches are a bit miscellaneous:
- Extend generic flow control/pause frame support and change the sfc driver to use it
- Add fields to theethtool_cmdstructure to report the supported MDIO mode(s) and link partner advertising flags, and implement these in the mdio and mii modules
- Add support for backplane (1000BASE-KR and 10GBASE-KR/KX4) modes to ethtool and the mdio module
I like these changes, I'll add them to net-next-2.6 and we can further refine them as-needed.
Quoted 3 lines
I have a few questions to be resolved:
- Is the naming of functions and constants in <linux/mdio.h> reasonable, or is more qualification required?
I think those are fine.
Quoted 1 line
- Is it reasonable to carry on using the MII ioctl interface with flags?
I don't know, I'm a little disappointed it's still around but I suppose someone finds it useful.
Quoted 2 lines
- Are there more drivers that could use these generic definitions (I haven't looked at the Broadcom drivers yet)?
No idea.
Quoted 2 lines
- Does the backplane code work at all (I don't have any suitable hardware yet)?
The code will be there so someone can play around and test it.
On Wed, 2009-04-29 at 17:31 -0700, David Miller wrote:
[...]
Quoted 4 lines
Quoted 1 line
- Is it reasonable to carry on using the MII ioctl interface with flags?
I don't know, I'm a little disappointed it's still around but I suppose someone finds it useful.
[...]
It's definitely a useful debugging feature, though probably less important where the PHY driver is implemented in firmware. We also use it for field upgrades of PHY firmware.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
Re: [PATCH 10/16] mii: Simplify mii_resolve_flowctrl_fdx()
In reply to Ben HutchingsBen Hutchings <[email protected]> wrote on 29/04/2009 19:15:05:
Quoted 4 lines
This is a shorter and more comprehensible formulation of the conditions for each flow control mode.
Signed-off-by Ben Hutchings <[email protected]>
Thanks Ben, much simpler than my version!