Skip to content

Commit

Permalink
ig: Factor out e1000_force_flowctrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Sepherosa Ziehau committed Nov 25, 2015
1 parent 81ac62f commit 9b8968b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 34 deletions.
12 changes: 2 additions & 10 deletions sys/dev/netif/em/if_em.c
Expand Up @@ -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;
Expand Down
12 changes: 2 additions & 10 deletions sys/dev/netif/emx/if_emx.c
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions sys/dev/netif/ig_hal/e1000_dragonfly.h
Expand Up @@ -35,12 +35,9 @@
#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_ */
13 changes: 13 additions & 0 deletions sys/dev/netif/ig_hal/e1000_osdep.c
Expand Up @@ -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);
Expand Down
12 changes: 2 additions & 10 deletions sys/dev/netif/igb/if_igb.c
Expand Up @@ -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;
Expand Down

0 comments on commit 9b8968b

Please sign in to comment.