diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2009-07-23 14:10:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-07-26 12:47:02 -0400 |
commit | 0cce119aa977dba00467985c0ae93fe43d28740a (patch) | |
tree | 847330167dff04e7059b949a85c93d3ca9b4a054 /drivers/net/igb/igb_ethtool.c | |
parent | 2d94d8ab76ea6c858c6e2eb0ab0403b00b031039 (diff) |
igb: cleanup flow control configuration to make requested/current more clear
This patch cleans up the flow control configuration for igb to make it a
bit more readable in regards to what the requested and current modes are.
This should help with the maintainability of the current igb driver in
regards to flow control.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/igb/igb_ethtool.c')
-rw-r--r-- | drivers/net/igb/igb_ethtool.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/net/igb/igb_ethtool.c b/drivers/net/igb/igb_ethtool.c index df2d234be229..114ccab1f2be 100644 --- a/drivers/net/igb/igb_ethtool.c +++ b/drivers/net/igb/igb_ethtool.c | |||
@@ -194,6 +194,8 @@ static int igb_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) | |||
194 | ADVERTISED_TP | | 194 | ADVERTISED_TP | |
195 | ADVERTISED_Autoneg; | 195 | ADVERTISED_Autoneg; |
196 | ecmd->advertising = hw->phy.autoneg_advertised; | 196 | ecmd->advertising = hw->phy.autoneg_advertised; |
197 | if (adapter->fc_autoneg) | ||
198 | hw->fc.requested_mode = e1000_fc_default; | ||
197 | } else { | 199 | } else { |
198 | if (igb_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { | 200 | if (igb_set_spd_dplx(adapter, ecmd->speed + ecmd->duplex)) { |
199 | clear_bit(__IGB_RESETTING, &adapter->state); | 201 | clear_bit(__IGB_RESETTING, &adapter->state); |
@@ -221,11 +223,11 @@ static void igb_get_pauseparam(struct net_device *netdev, | |||
221 | pause->autoneg = | 223 | pause->autoneg = |
222 | (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); | 224 | (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); |
223 | 225 | ||
224 | if (hw->fc.type == e1000_fc_rx_pause) | 226 | if (hw->fc.current_mode == e1000_fc_rx_pause) |
225 | pause->rx_pause = 1; | 227 | pause->rx_pause = 1; |
226 | else if (hw->fc.type == e1000_fc_tx_pause) | 228 | else if (hw->fc.current_mode == e1000_fc_tx_pause) |
227 | pause->tx_pause = 1; | 229 | pause->tx_pause = 1; |
228 | else if (hw->fc.type == e1000_fc_full) { | 230 | else if (hw->fc.current_mode == e1000_fc_full) { |
229 | pause->rx_pause = 1; | 231 | pause->rx_pause = 1; |
230 | pause->tx_pause = 1; | 232 | pause->tx_pause = 1; |
231 | } | 233 | } |
@@ -243,26 +245,28 @@ static int igb_set_pauseparam(struct net_device *netdev, | |||
243 | while (test_and_set_bit(__IGB_RESETTING, &adapter->state)) | 245 | while (test_and_set_bit(__IGB_RESETTING, &adapter->state)) |
244 | msleep(1); | 246 | msleep(1); |
245 | 247 | ||
246 | if (pause->rx_pause && pause->tx_pause) | ||
247 | hw->fc.type = e1000_fc_full; | ||
248 | else if (pause->rx_pause && !pause->tx_pause) | ||
249 | hw->fc.type = e1000_fc_rx_pause; | ||
250 | else if (!pause->rx_pause && pause->tx_pause) | ||
251 | hw->fc.type = e1000_fc_tx_pause; | ||
252 | else if (!pause->rx_pause && !pause->tx_pause) | ||
253 | hw->fc.type = e1000_fc_none; | ||
254 | |||
255 | hw->fc.original_type = hw->fc.type; | ||
256 | |||
257 | if (adapter->fc_autoneg == AUTONEG_ENABLE) { | 248 | if (adapter->fc_autoneg == AUTONEG_ENABLE) { |
249 | hw->fc.requested_mode = e1000_fc_default; | ||
258 | if (netif_running(adapter->netdev)) { | 250 | if (netif_running(adapter->netdev)) { |
259 | igb_down(adapter); | 251 | igb_down(adapter); |
260 | igb_up(adapter); | 252 | igb_up(adapter); |
261 | } else | 253 | } else |
262 | igb_reset(adapter); | 254 | igb_reset(adapter); |
263 | } else | 255 | } else { |
256 | if (pause->rx_pause && pause->tx_pause) | ||
257 | hw->fc.requested_mode = e1000_fc_full; | ||
258 | else if (pause->rx_pause && !pause->tx_pause) | ||
259 | hw->fc.requested_mode = e1000_fc_rx_pause; | ||
260 | else if (!pause->rx_pause && pause->tx_pause) | ||
261 | hw->fc.requested_mode = e1000_fc_tx_pause; | ||
262 | else if (!pause->rx_pause && !pause->tx_pause) | ||
263 | hw->fc.requested_mode = e1000_fc_none; | ||
264 | |||
265 | hw->fc.current_mode = hw->fc.requested_mode; | ||
266 | |||
264 | retval = ((hw->phy.media_type == e1000_media_type_copper) ? | 267 | retval = ((hw->phy.media_type == e1000_media_type_copper) ? |
265 | igb_force_mac_fc(hw) : igb_setup_link(hw)); | 268 | igb_force_mac_fc(hw) : igb_setup_link(hw)); |
269 | } | ||
266 | 270 | ||
267 | clear_bit(__IGB_RESETTING, &adapter->state); | 271 | clear_bit(__IGB_RESETTING, &adapter->state); |
268 | return retval; | 272 | return retval; |