vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| The following diff moves the current flow control status code out of em_media_status() and into a separate function which was modeled after the MII frameworks mii_phy_flowstatus() function. This was done so as to make em_media_status() a little nicer looking and so that when flow control status is added for fiber adapters that em_media_status() won't look so ugly. No functional change. Index: if_em.c ================================================== ================= RCS file: /cvs/src/sys/dev/pci/if_em.c,v retrieving revision 1.174 diff -u -p -r1.174 if_em.c --- if_em.c 21 Oct 2007 03:49:54 -0000 1.174 +++ if_em.c 15 Nov 2007 22:36:43 -0000 @@ -135,6 +135,7 @@ void em_init(void *); void em_stop(void *); void em_media_status(struct ifnet *, struct ifmediareq *); int em_media_change(struct ifnet *); +int em_flowstatus(struct em_softc *); void em_identify_hardware(struct em_softc *); int em_allocate_pci_resources(struct em_softc *); void em_free_pci_resources(struct em_softc *); @@ -805,7 +806,7 @@ em_media_status(struct ifnet *ifp, struc { struct em_softc *sc = ifp->if_softc; u_char fiber_type = IFM_1000_SX; - u_int16_t ar, lpar, gsr; + u_int16_t gsr; INIT_DEBUGOUT("em_media_status: begin"); @@ -841,25 +842,10 @@ em_media_status(struct ifnet *ifp, struc } if (sc->link_duplex == FULL_DUPLEX) - ifmr->ifm_active |= IFM_FDX; + ifmr->ifm_active |= em_flowstatus(sc) | IFM_FDX; else ifmr->ifm_active |= IFM_HDX; - if (ifmr->ifm_active & IFM_FDX) { - em_read_phy_reg(&sc->hw, PHY_AUTONEG_ADV, &ar); - em_read_phy_reg(&sc->hw, PHY_LP_ABILITY, &lpar); - - if ((ar & NWAY_AR_PAUSE) && (lpar & NWAY_LPAR_PAUSE)) - ifmr->ifm_active |= IFM_FLOW | IFM_ETH_TXPAUSE | - IFM_ETH_RXPAUSE; - else if (!(ar & NWAY_AR_PAUSE) && (ar & NWAY_AR_ASM_DIR) && - (lpar & NWAY_LPAR_PAUSE) && (lpar & NWAY_LPAR_ASM_DIR)) - ifmr->ifm_active |= IFM_FLOW | IFM_ETH_TXPAUSE; - else if ((ar & NWAY_AR_PAUSE) && (ar & NWAY_AR_ASM_DIR) && - !(lpar & NWAY_LPAR_PAUSE) && (lpar & NWAY_LPAR_ASM_DIR)) - ifmr->ifm_active |= IFM_FLOW | IFM_ETH_RXPAUSE; - } - if (IFM_SUBTYPE(ifmr->ifm_active) == IFM_1000_T) { em_read_phy_reg(&sc->hw, PHY_1000T_STATUS, &gsr); if (gsr & SR_1000T_MS_CONFIG_RES) @@ -925,6 +911,26 @@ em_media_change(struct ifnet *ifp) sc->hw.phy_reset_disable = FALSE; em_init(sc); + + return (0); +} + +int +em_flowstatus(struct em_softc *sc) +{ + u_int16_t ar, lpar; + + em_read_phy_reg(&sc->hw, PHY_AUTONEG_ADV, &ar); + em_read_phy_reg(&sc->hw, PHY_LP_ABILITY, &lpar); + + if ((ar & NWAY_AR_PAUSE) && (lpar & NWAY_LPAR_PAUSE)) + return (IFM_FLOW|IFM_ETH_TXPAUSE|IFM_ETH_RXPAUSE); + else if (!(ar & NWAY_AR_PAUSE) && (ar & NWAY_AR_ASM_DIR) && + (lpar & NWAY_LPAR_PAUSE) && (lpar & NWAY_LPAR_ASM_DIR)) + return (IFM_FLOW|IFM_ETH_TXPAUSE); + else if ((ar & NWAY_AR_PAUSE) && (ar & NWAY_AR_ASM_DIR) && + !(lpar & NWAY_LPAR_PAUSE) && (lpar & NWAY_LPAR_ASM_DIR)) + return (IFM_FLOW|IFM_ETH_RXPAUSE); return (0); } -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. |