ig: Factor out e1000_force_flowctrl
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 25 Nov 2015 06:33:14 +0000 (14:33 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 25 Nov 2015 06:33:14 +0000 (14:33 +0800)
sys/dev/netif/em/if_em.c
sys/dev/netif/emx/if_emx.c
sys/dev/netif/ig_hal/e1000_dragonfly.h
sys/dev/netif/ig_hal/e1000_osdep.c
sys/dev/netif/igb/if_igb.c

index 77ecca9..dbb63f0 100644 (file)
@@ -2149,16 +2149,8 @@ em_update_link_status(struct adapter *adapter)
                            "Full Duplex" : "Half Duplex",
                            flowctrl);
                }
-               if (adapter->ifm_flowctrl & IFM_ETH_FORCEPAUSE) {
-                       enum e1000_fc_mode fc;
-
-                       fc = e1000_ifmedia2fc(adapter->ifm_flowctrl);
-                       if (hw->fc.current_mode != fc) {
-                               hw->fc.requested_mode = fc;
-                               hw->fc.current_mode = fc;
-                               e1000_force_mac_fc(hw);
-                       }
-               }
+               if (adapter->ifm_flowctrl & IFM_ETH_FORCEPAUSE)
+                       e1000_force_flowctrl(hw, adapter->ifm_flowctrl);
                adapter->link_active = 1;
                adapter->smartspeed = 0;
                ifp->if_baudrate = adapter->link_speed * 1000000;
index e912615..60ce2b2 100644 (file)
@@ -1883,16 +1883,8 @@ emx_update_link_status(struct emx_softc *sc)
                            "Full Duplex" : "Half Duplex",
                            flowctrl);
                }
-               if (sc->ifm_flowctrl & IFM_ETH_FORCEPAUSE) {
-                       enum e1000_fc_mode fc;
-
-                       fc = e1000_ifmedia2fc(sc->ifm_flowctrl);
-                       if (hw->fc.current_mode != fc) {
-                               hw->fc.requested_mode = fc;
-                               hw->fc.current_mode = fc;
-                               e1000_force_mac_fc(hw);
-                       }
-               }
+               if (sc->ifm_flowctrl & IFM_ETH_FORCEPAUSE)
+                       e1000_force_flowctrl(hw, sc->ifm_flowctrl);
                sc->link_active = 1;
                sc->smartspeed = 0;
                ifp->if_baudrate = sc->link_speed * 1000000;
index 5454b31..76d0f10 100644 (file)
 #ifndef _E1000_DRAGONFLY_H_
 #define _E1000_DRAGONFLY_H_
 
-struct ifnet;
-struct sysctl_oid;
-struct sysctl_req;
-
 void   e1000_fc2str(enum e1000_fc_mode fc, char *str, int len);
 enum e1000_fc_mode e1000_ifmedia2fc(int ifm);
 int    e1000_fc2ifmedia(enum e1000_fc_mode fc);
+void   e1000_force_flowctrl(struct e1000_hw *hw, int ifm);
 
 #endif /* !_E1000_DRAGONFLY_H_ */
index a7a54aa..1ca935c 100644 (file)
@@ -164,6 +164,19 @@ e1000_fc2ifmedia(enum e1000_fc_mode fc)
        }
 }
 
+void
+e1000_force_flowctrl(struct e1000_hw *hw, int ifm)
+{
+       enum e1000_fc_mode fc;
+
+       fc = e1000_ifmedia2fc(ifm);
+       if (hw->fc.current_mode != fc) {
+               hw->fc.requested_mode = fc;
+               hw->fc.current_mode = fc;
+               e1000_force_mac_fc(hw);
+       }
+}
+
 /* Module glue */
 static moduledata_t ig_hal_mod = { "ig_hal" };
 DECLARE_MODULE(ig_hal, ig_hal_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
index dc94f95..9924b7b 100644 (file)
@@ -1332,16 +1332,8 @@ igb_update_link_status(struct igb_softc *sc)
                            "Full Duplex" : "Half Duplex",
                            flowctrl);
                }
-               if (sc->ifm_flowctrl & IFM_ETH_FORCEPAUSE) {
-                       enum e1000_fc_mode fc;
-
-                       fc = e1000_ifmedia2fc(sc->ifm_flowctrl);
-                       if (hw->fc.current_mode != fc) {
-                               hw->fc.requested_mode = fc;
-                               hw->fc.current_mode = fc;
-                               e1000_force_mac_fc(hw);
-                       }
-               }
+               if (sc->ifm_flowctrl & IFM_ETH_FORCEPAUSE)
+                       e1000_force_flowctrl(hw, sc->ifm_flowctrl);
                sc->link_active = 1;
 
                ifp->if_baudrate = sc->link_speed * 1000000;