em/emx/igb: Properly set status for manually configured media/mediaopt
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 27 Nov 2015 03:00:41 +0000 (11:00 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 27 Nov 2015 03:00:41 +0000 (11:00 +0800)
sys/dev/netif/em/if_em.c
sys/dev/netif/emx/if_emx.c
sys/dev/netif/igb/if_igb.c

index dbb63f0..e107f47 100644 (file)
@@ -1530,7 +1530,6 @@ static void
 em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
 {
        struct adapter *adapter = ifp->if_softc;
-       u_char fiber_type = IFM_1000_SX;
 
        ASSERT_SERIALIZED(ifp->if_serializer);
 
@@ -1540,16 +1539,21 @@ em_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
        ifmr->ifm_active = IFM_ETHER;
 
        if (!adapter->link_active) {
-               ifmr->ifm_active |= IFM_NONE;
+               if (adapter->hw.mac.autoneg)
+                       ifmr->ifm_active |= IFM_NONE;
+               else
+                       ifmr->ifm_active = adapter->media.ifm_media;
                return;
        }
 
        ifmr->ifm_status |= IFM_ACTIVE;
        if (adapter->ifm_flowctrl & IFM_ETH_FORCEPAUSE)
-               ifmr->ifm_active |= IFM_ETH_FORCEPAUSE;
+               ifmr->ifm_active |= adapter->ifm_flowctrl;
 
        if (adapter->hw.phy.media_type == e1000_media_type_fiber ||
            adapter->hw.phy.media_type == e1000_media_type_internal_serdes) {
+               u_char fiber_type = IFM_1000_SX;
+
                if (adapter->hw.mac.type == e1000_82545)
                        fiber_type = IFM_1000_LX;
                ifmr->ifm_active |= fiber_type | IFM_FDX;
index 60ce2b2..63f25cb 100644 (file)
@@ -1484,13 +1484,16 @@ emx_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
        ifmr->ifm_active = IFM_ETHER;
 
        if (!sc->link_active) {
-               ifmr->ifm_active |= IFM_NONE;
+               if (sc->hw.mac.autoneg)
+                       ifmr->ifm_active |= IFM_NONE;
+               else
+                       ifmr->ifm_active |= sc->media.ifm_media;
                return;
        }
 
        ifmr->ifm_status |= IFM_ACTIVE;
        if (sc->ifm_flowctrl & IFM_ETH_FORCEPAUSE)
-               ifmr->ifm_active |= IFM_ETH_FORCEPAUSE;
+               ifmr->ifm_active |= sc->ifm_flowctrl;
 
        if (sc->hw.phy.media_type == e1000_media_type_fiber ||
            sc->hw.phy.media_type == e1000_media_type_internal_serdes) {
index 450fc2a..40d0906 100644 (file)
@@ -1048,13 +1048,16 @@ igb_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
        ifmr->ifm_active = IFM_ETHER;
 
        if (!sc->link_active) {
-               ifmr->ifm_active |= IFM_NONE;
+               if (sc->hw.mac.autoneg)
+                       ifmr->ifm_active |= IFM_NONE;
+               else
+                       ifmr->ifm_active |= sc->media.ifm_media;
                return;
        }
 
        ifmr->ifm_status |= IFM_ACTIVE;
        if (sc->ifm_flowctrl & IFM_ETH_FORCEPAUSE)
-               ifmr->ifm_active |= IFM_ETH_FORCEPAUSE;
+               ifmr->ifm_active |= sc->ifm_flowctrl;
 
        switch (sc->link_speed) {
        case 10: