#include <gpxe/netdevice.h>Go to the source code of this file.
Data Structures | |
| struct | mii_if_info |
Defines | |
| #define | MII_BMCR 0x00 |
| #define | MII_BMSR 0x01 |
| #define | MII_PHYSID1 0x02 |
| #define | MII_PHYSID2 0x03 |
| #define | MII_ADVERTISE 0x04 |
| #define | MII_LPA 0x05 |
| #define | MII_EXPANSION 0x06 |
| #define | MII_CTRL1000 0x09 |
| #define | MII_STAT1000 0x0a |
| #define | MII_ESTATUS 0x0f |
| #define | MII_DCOUNTER 0x12 |
| #define | MII_FCSCOUNTER 0x13 |
| #define | MII_NWAYTEST 0x14 |
| #define | MII_RERRCOUNTER 0x15 |
| #define | MII_SREVISION 0x16 |
| #define | MII_RESV1 0x17 |
| #define | MII_LBRERROR 0x18 |
| #define | MII_PHYADDR 0x19 |
| #define | MII_RESV2 0x1a |
| #define | MII_TPISTATUS 0x1b |
| #define | MII_NCONFIG 0x1c |
| #define | BMCR_RESV 0x003f |
| #define | BMCR_SPEED1000 0x0040 |
| #define | BMCR_CTST 0x0080 |
| #define | BMCR_FULLDPLX 0x0100 |
| #define | BMCR_ANRESTART 0x0200 |
| #define | BMCR_ISOLATE 0x0400 |
| #define | BMCR_PDOWN 0x0800 |
| #define | BMCR_ANENABLE 0x1000 |
| #define | BMCR_SPEED100 0x2000 |
| #define | BMCR_LOOPBACK 0x4000 |
| #define | BMCR_RESET 0x8000 |
| #define | BMSR_ERCAP 0x0001 |
| #define | BMSR_JCD 0x0002 |
| #define | BMSR_LSTATUS 0x0004 |
| #define | BMSR_ANEGCAPABLE 0x0008 |
| #define | BMSR_RFAULT 0x0010 |
| #define | BMSR_ANEGCOMPLETE 0x0020 |
| #define | BMSR_RESV 0x00c0 |
| #define | BMSR_ESTATEN 0x0100 |
| #define | BMSR_100HALF2 0x0200 |
| #define | BMSR_100FULL2 0x0400 |
| #define | BMSR_10HALF 0x0800 |
| #define | BMSR_10FULL 0x1000 |
| #define | BMSR_100HALF 0x2000 |
| #define | BMSR_100FULL 0x4000 |
| #define | BMSR_100BASE4 0x8000 |
| #define | ADVERTISE_SLCT 0x001f |
| #define | ADVERTISE_CSMA 0x0001 |
| #define | ADVERTISE_10HALF 0x0020 |
| #define | ADVERTISE_1000XFULL 0x0020 |
| #define | ADVERTISE_10FULL 0x0040 |
| #define | ADVERTISE_1000XHALF 0x0040 |
| #define | ADVERTISE_100HALF 0x0080 |
| #define | ADVERTISE_1000XPAUSE 0x0080 |
| #define | ADVERTISE_100FULL 0x0100 |
| #define | ADVERTISE_1000XPSE_ASYM 0x0100 |
| #define | ADVERTISE_100BASE4 0x0200 |
| #define | ADVERTISE_PAUSE_CAP 0x0400 |
| #define | ADVERTISE_PAUSE_ASYM 0x0800 |
| #define | ADVERTISE_RESV 0x1000 |
| #define | ADVERTISE_RFAULT 0x2000 |
| #define | ADVERTISE_LPACK 0x4000 |
| #define | ADVERTISE_NPAGE 0x8000 |
| #define | ADVERTISE_FULL |
| #define | ADVERTISE_ALL |
| #define | LPA_SLCT 0x001f |
| #define | LPA_10HALF 0x0020 |
| #define | LPA_1000XFULL 0x0020 |
| #define | LPA_10FULL 0x0040 |
| #define | LPA_1000XHALF 0x0040 |
| #define | LPA_100HALF 0x0080 |
| #define | LPA_1000XPAUSE 0x0080 |
| #define | LPA_100FULL 0x0100 |
| #define | LPA_1000XPAUSE_ASYM 0x0100 |
| #define | LPA_100BASE4 0x0200 |
| #define | LPA_PAUSE_CAP 0x0400 |
| #define | LPA_PAUSE_ASYM 0x0800 |
| #define | LPA_RESV 0x1000 |
| #define | LPA_RFAULT 0x2000 |
| #define | LPA_LPACK 0x4000 |
| #define | LPA_NPAGE 0x8000 |
| #define | LPA_DUPLEX (LPA_10FULL | LPA_100FULL) |
| #define | LPA_100 (LPA_100FULL | LPA_100HALF | LPA_100BASE4) |
| #define | EXPANSION_NWAY 0x0001 |
| #define | EXPANSION_LCWP 0x0002 |
| #define | EXPANSION_ENABLENPAGE 0x0004 |
| #define | EXPANSION_NPCAPABLE 0x0008 |
| #define | EXPANSION_MFAULTS 0x0010 |
| #define | EXPANSION_RESV 0xffe0 |
| #define | ESTATUS_1000_TFULL 0x2000 |
| #define | ESTATUS_1000_THALF 0x1000 |
| #define | NWAYTEST_RESV1 0x00ff |
| #define | NWAYTEST_LOOPBACK 0x0100 |
| #define | NWAYTEST_RESV2 0xfe00 |
| #define | ADVERTISE_1000FULL 0x0200 |
| #define | ADVERTISE_1000HALF 0x0100 |
| #define | LPA_1000LOCALRXOK 0x2000 |
| #define | LPA_1000REMRXOK 0x1000 |
| #define | LPA_1000FULL 0x0800 |
| #define | LPA_1000HALF 0x0400 |
Functions | |
| FILE_LICENCE (GPL2_ONLY) | |
| int | mii_link_ok (struct mii_if_info *mii) |
| mii_link_ok - is link status up/ok : the MII interface | |
| void | mii_check_link (struct mii_if_info *mii) |
| mii_check_link - check MII link status : MII interface | |
| unsigned int | mii_check_media (struct mii_if_info *mii, unsigned int ok_to_print, unsigned int init_media) |
| mii_check_media - check the MII interface for a duplex change : the MII interface : OK to print link up/down messages : OK to save duplex mode in | |
| static unsigned int | mii_nway_result (unsigned int negotiated) |
| mii_nway_result : value of MII ANAR and'd with ANLPAR | |
| static unsigned int | mii_duplex (unsigned int duplex_lock, unsigned int negotiated) |
| mii_duplex : Non-zero if duplex is locked at full : value of MII ANAR and'd with ANLPAR | |
| #define MII_CTRL1000 0x09 |
Definition at line 27 of file mii.h.
Referenced by bnx2_copper_linkup(), bnx2_setup_copper_phy(), gmii_autoneg_advertised(), phy_init(), rtl8169_set_speed_xmii(), sis190_phy_task(), sis190_set_speed_auto(), and update_linkspeed().
| #define MII_STAT1000 0x0a |
Definition at line 28 of file mii.h.
Referenced by bnx2_copper_linkup(), gmii_autoneg_lpa(), mii_check_media(), sis190_phy_task(), and update_linkspeed().
| #define BMCR_SPEED1000 0x0040 |
| #define BMCR_FULLDPLX 0x0100 |
Definition at line 46 of file mii.h.
Referenced by bnx2_5706s_linkup(), bnx2_copper_linkup(), bnx2_setup_copper_phy(), bnx2_setup_serdes_phy(), sundance_probe(), tg3_phy_reset_5703_4_5(), TLan_PhyFinishAutoNeg(), and TLan_PhyStartLink().
| #define BMCR_ANRESTART 0x0200 |
Definition at line 47 of file mii.h.
Referenced by bnx2_setup_copper_phy(), bnx2_setup_serdes_phy(), phy_init(), rtl8169_set_speed_xmii(), sis190_set_speed_auto(), tg3_phy_copper_begin(), and tg3_phy_probe().
| #define BMCR_ISOLATE 0x0400 |
| #define BMCR_PDOWN 0x0800 |
| #define BMCR_ANENABLE 0x1000 |
Definition at line 50 of file mii.h.
Referenced by bnx2_5706s_linkup(), bnx2_copper_linkup(), bnx2_set_link(), bnx2_setup_copper_phy(), bnx2_setup_serdes_phy(), phy_init(), rtl8169_set_speed_xmii(), sis190_default_phy(), sis190_set_speed_auto(), tg3_phy_copper_begin(), tg3_phy_probe(), tg3_setup_copper_phy(), and TLan_PhyFinishAutoNeg().
| #define BMCR_LOOPBACK 0x4000 |
Definition at line 52 of file mii.h.
Referenced by bnx2_setup_copper_phy(), bnx2_setup_serdes_phy(), TLan_PhyPowerDown(), TLan_PhyPowerUp(), and TLan_PhyReset().
| #define BMSR_LSTATUS 0x0004 |
Definition at line 58 of file mii.h.
Referenced by atl1e_check_link(), bnx2_set_link(), bnx2_setup_copper_phy(), getlinkstatus(), gmii_link_ok(), mii_link_ok(), sis190_default_phy(), tg3_setup_copper_phy(), TLan_FinishReset(), and update_linkspeed().
| #define BMSR_ANEGCAPABLE 0x0008 |
| #define BMSR_ANEGCOMPLETE 0x0020 |
Definition at line 61 of file mii.h.
Referenced by bnx2_report_fw_link(), sis190_phy_task(), TLan_PhyFinishAutoNeg(), and update_linkspeed().
| #define BMSR_100HALF 0x2000 |
| #define BMSR_100FULL 0x4000 |
| #define ADVERTISE_SLCT 0x001f |
| #define ADVERTISE_CSMA 0x0001 |
Definition at line 74 of file mii.h.
Referenced by bnx2_setup_copper_phy(), rtl8169_set_speed_xmii(), tg3_phy_copper_begin(), and tg3_phy_probe().
| #define ADVERTISE_10HALF 0x0020 |
Definition at line 75 of file mii.h.
Referenced by bnx2_copper_linkup(), bnx2_setup_copper_phy(), pcnet32_probe(), phy_init(), rtl8169_set_speed_xmii(), sis190_set_speed_auto(), sundance_probe(), tg3_phy_copper_begin(), and tg3_phy_probe().
| #define ADVERTISE_1000XFULL 0x0020 |
Definition at line 76 of file mii.h.
Referenced by bnx2_5706s_linkup(), and bnx2_setup_serdes_phy().
| #define ADVERTISE_10FULL 0x0040 |
Definition at line 77 of file mii.h.
Referenced by bnx2_copper_linkup(), bnx2_setup_copper_phy(), pcnet32_probe(), phy_init(), rtl8169_set_speed_xmii(), sis190_set_speed_auto(), sundance_probe(), tg3_phy_copper_begin(), and tg3_phy_probe().
| #define ADVERTISE_1000XHALF 0x0040 |
Definition at line 78 of file mii.h.
Referenced by bnx2_5706s_linkup(), and bnx2_setup_serdes_phy().
| #define ADVERTISE_100HALF 0x0080 |
Definition at line 79 of file mii.h.
Referenced by bnx2_copper_linkup(), bnx2_setup_copper_phy(), mii_check_media(), pcnet32_probe(), phy_init(), rtl8169_set_speed_xmii(), sis190_set_speed_auto(), sundance_probe(), tg3_phy_copper_begin(), and tg3_phy_probe().
| #define ADVERTISE_1000XPAUSE 0x0080 |
Definition at line 80 of file mii.h.
Referenced by bnx2_phy_get_pause_adv(), and bnx2_resolve_flow_ctrl().
| #define ADVERTISE_100FULL 0x0100 |
Definition at line 81 of file mii.h.
Referenced by bnx2_copper_linkup(), bnx2_setup_copper_phy(), mii_check_media(), pcnet32_probe(), phy_init(), rtl8169_set_speed_xmii(), sis190_set_speed_auto(), sundance_probe(), tg3_phy_copper_begin(), and tg3_phy_probe().
| #define ADVERTISE_1000XPSE_ASYM 0x0100 |
Definition at line 82 of file mii.h.
Referenced by bnx2_phy_get_pause_adv(), and bnx2_resolve_flow_ctrl().
| #define ADVERTISE_PAUSE_CAP 0x0400 |
Definition at line 84 of file mii.h.
Referenced by bnx2_phy_get_pause_adv(), bnx2_resolve_flow_ctrl(), bnx2_setup_copper_phy(), rtl8169_set_speed_xmii(), sky2_autoneg_done(), tg3_phy_copper_begin(), tg3_phy_probe(), tg3_setup_copper_phy(), tg3_setup_fiber_phy(), and tg3_setup_flow_control().
| #define ADVERTISE_PAUSE_ASYM 0x0800 |
Definition at line 85 of file mii.h.
Referenced by bnx2_phy_get_pause_adv(), bnx2_resolve_flow_ctrl(), bnx2_setup_copper_phy(), rtl8169_set_speed_xmii(), sky2_autoneg_done(), tg3_setup_copper_phy(), and tg3_setup_flow_control().
| #define ADVERTISE_FULL |
| #define ADVERTISE_ALL |
Value:
| #define LPA_10HALF 0x0020 |
Definition at line 98 of file mii.h.
Referenced by gmii_nway_result(), mii_nway_result(), sis190_phy_task(), and update_linkspeed().
| #define LPA_10FULL 0x0040 |
Definition at line 100 of file mii.h.
Referenced by gmii_nway_result(), mii_nway_result(), sis190_phy_task(), and update_linkspeed().
| #define LPA_100HALF 0x0080 |
Definition at line 102 of file mii.h.
Referenced by gmii_nway_result(), mii_nway_result(), sis190_phy_task(), and update_linkspeed().
| #define LPA_100FULL 0x0100 |
Definition at line 104 of file mii.h.
Referenced by gmii_nway_result(), mii_nway_result(), sis190_phy_task(), and update_linkspeed().
| #define LPA_100BASE4 0x0200 |
| #define LPA_PAUSE_CAP 0x0400 |
Definition at line 107 of file mii.h.
Referenced by mentormac_init(), sky2_autoneg_done(), tg3_setup_copper_phy(), tg3_setup_fiber_phy(), and tg3_setup_flow_control().
| #define LPA_PAUSE_ASYM 0x0800 |
Definition at line 108 of file mii.h.
Referenced by sky2_autoneg_done(), tg3_setup_copper_phy(), tg3_setup_fiber_phy(), and tg3_setup_flow_control().
| #define LPA_NPAGE 0x8000 |
| #define LPA_DUPLEX (LPA_10FULL | LPA_100FULL) |
| #define EXPANSION_NWAY 0x0001 |
| #define ADVERTISE_1000FULL 0x0200 |
Definition at line 134 of file mii.h.
Referenced by bnx2_copper_linkup(), bnx2_setup_copper_phy(), phy_init(), rtl8169_probe(), rtl8169_set_speed_xmii(), sis190_phy_task(), sis190_set_speed_auto(), and update_linkspeed().
| #define ADVERTISE_1000HALF 0x0100 |
Definition at line 135 of file mii.h.
Referenced by bnx2_copper_linkup(), phy_init(), rtl8169_set_speed_xmii(), and sis190_phy_task().
| #define LPA_1000FULL 0x0800 |
Definition at line 140 of file mii.h.
Referenced by mii_check_media(), sis190_phy_task(), and update_linkspeed().
| #define LPA_1000HALF 0x0400 |
| FILE_LICENCE | ( | GPL2_ONLY | ) |
| int mii_link_ok | ( | struct mii_if_info * | mii | ) |
mii_link_ok - is link status up/ok : the MII interface
Returns 1 if the MII reports link status up/ok, 0 otherwise.
Definition at line 41 of file mii.c.
References BMSR_LSTATUS, mii_if_info::dev, mii_if_info::mdio_read, MII_BMSR, and mii_if_info::phy_id.
Referenced by mii_check_link(), and mii_check_media().
00042 { 00043 /* first, a dummy read, needed to latch some MII phys */ 00044 mii->mdio_read ( mii->dev, mii->phy_id, MII_BMSR ); 00045 if ( mii->mdio_read ( mii->dev, mii->phy_id, MII_BMSR ) & BMSR_LSTATUS ) 00046 return 1; 00047 return 0; 00048 }
| void mii_check_link | ( | struct mii_if_info * | mii | ) |
mii_check_link - check MII link status : MII interface
If the link status changed (previous != current), call netif_carrier_on() if current link status is Up or call netif_carrier_off() if current link status is Down.
Definition at line 59 of file mii.c.
References mii_if_info::dev, mii_link_ok(), netdev_link_down(), netdev_link_ok(), and netdev_link_up().
00060 { 00061 int cur_link = mii_link_ok ( mii ); 00062 int prev_link = netdev_link_ok ( mii->dev ); 00063 00064 if ( cur_link && !prev_link ) 00065 netdev_link_up ( mii->dev ); 00066 else if (prev_link && !cur_link) 00067 netdev_link_down ( mii->dev ); 00068 }
| unsigned int mii_check_media | ( | struct mii_if_info * | mii, | |
| unsigned int | ok_to_print, | |||
| unsigned int | init_media | |||
| ) |
mii_check_media - check the MII interface for a duplex change : the MII interface : OK to print link up/down messages : OK to save duplex mode in
Returns 1 if the duplex mode changed, 0 if not. If the media type is forced, always returns 0.
Definition at line 81 of file mii.c.
References ADVERTISE_100FULL, ADVERTISE_100HALF, ADVERTISE_FULL, mii_if_info::advertising, DBG, mii_if_info::dev, mii_if_info::force_media, mii_if_info::full_duplex, LPA_1000FULL, LPA_1000HALF, mii_if_info::mdio_read, media, MII_ADVERTISE, mii_link_ok(), MII_LPA, mii_nway_result(), MII_STAT1000, net_device::name, netdev_link_down(), netdev_link_ok(), netdev_link_up(), mii_if_info::phy_id, and mii_if_info::supports_gmii.
00084 { 00085 unsigned int old_carrier, new_carrier; 00086 int advertise, lpa, media, duplex; 00087 int lpa2 = 0; 00088 00089 /* if forced media, go no further */ 00090 if (mii->force_media) 00091 return 0; /* duplex did not change */ 00092 00093 /* check current and old link status */ 00094 old_carrier = netdev_link_ok ( mii->dev ) ? 1 : 0; 00095 new_carrier = (unsigned int) mii_link_ok ( mii ); 00096 00097 /* if carrier state did not change, this is a "bounce", 00098 * just exit as everything is already set correctly 00099 */ 00100 if ( ( ! init_media ) && ( old_carrier == new_carrier ) ) 00101 return 0; /* duplex did not change */ 00102 00103 /* no carrier, nothing much to do */ 00104 if ( ! new_carrier ) { 00105 netdev_link_down ( mii->dev ); 00106 if ( ok_to_print ) 00107 DBG ( "%s: link down\n", mii->dev->name); 00108 return 0; /* duplex did not change */ 00109 } 00110 00111 /* 00112 * we have carrier, see who's on the other end 00113 */ 00114 netdev_link_up ( mii->dev ); 00115 00116 /* get MII advertise and LPA values */ 00117 if ( ( ! init_media ) && ( mii->advertising ) ) { 00118 advertise = mii->advertising; 00119 } else { 00120 advertise = mii->mdio_read ( mii->dev, mii->phy_id, MII_ADVERTISE ); 00121 mii->advertising = advertise; 00122 } 00123 lpa = mii->mdio_read ( mii->dev, mii->phy_id, MII_LPA ); 00124 if ( mii->supports_gmii ) 00125 lpa2 = mii->mdio_read ( mii->dev, mii->phy_id, MII_STAT1000 ); 00126 00127 /* figure out media and duplex from advertise and LPA values */ 00128 media = mii_nway_result ( lpa & advertise ); 00129 duplex = ( media & ADVERTISE_FULL ) ? 1 : 0; 00130 if ( lpa2 & LPA_1000FULL ) 00131 duplex = 1; 00132 00133 if ( ok_to_print ) 00134 DBG ( "%s: link up, %sMbps, %s-duplex, lpa 0x%04X\n", 00135 mii->dev->name, 00136 lpa2 & ( LPA_1000FULL | LPA_1000HALF ) ? "1000" : 00137 media & ( ADVERTISE_100FULL | ADVERTISE_100HALF ) ? "100" : "10", 00138 duplex ? "full" : "half", 00139 lpa); 00140 00141 if ( ( init_media ) || ( mii->full_duplex != duplex ) ) { 00142 mii->full_duplex = duplex; 00143 return 1; /* duplex changed */ 00144 } 00145 00146 return 0; /* duplex did not change */ 00147 }
| static unsigned int mii_nway_result | ( | unsigned int | negotiated | ) | [inline, static] |
mii_nway_result : value of MII ANAR and'd with ANLPAR
Given a set of MII abilities, check each bit and returns the currently supported media, in the priority order defined by IEEE 802.3u. We use LPA_xxx constants but note this is not the value of LPA solely, as described above.
The one exception to IEEE 802.3u is that 100baseT4 is placed between 100T-full and 100T-half. If your phy does not support 100T4 this is fine. If your phy places 100T4 elsewhere in the priority order, you will need to roll your own function.
Definition at line 182 of file mii.h.
References LPA_100BASE4, LPA_100FULL, LPA_100HALF, LPA_10FULL, and LPA_10HALF.
Referenced by mii_check_media(), and mii_duplex().
00183 { 00184 unsigned int ret; 00185 00186 if (negotiated & LPA_100FULL) 00187 ret = LPA_100FULL; 00188 else if (negotiated & LPA_100BASE4) 00189 ret = LPA_100BASE4; 00190 else if (negotiated & LPA_100HALF) 00191 ret = LPA_100HALF; 00192 else if (negotiated & LPA_10FULL) 00193 ret = LPA_10FULL; 00194 else 00195 ret = LPA_10HALF; 00196 00197 return ret; 00198 }
| static unsigned int mii_duplex | ( | unsigned int | duplex_lock, | |
| unsigned int | negotiated | |||
| ) | [inline, static] |
mii_duplex : Non-zero if duplex is locked at full : value of MII ANAR and'd with ANLPAR
A small helper function for a common case. Returns one if the media is operating or locked at full duplex, and returns zero otherwise.
Definition at line 209 of file mii.h.
References LPA_DUPLEX, and mii_nway_result().
00211 { 00212 if (duplex_lock) 00213 return 1; 00214 if (mii_nway_result(negotiated) & LPA_DUPLEX) 00215 return 1; 00216 return 0; 00217 }
1.5.7.1