#include <mii.h>Go to the source code of this file.
Functions | |
| 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 | |
| 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 }
1.5.7.1