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 | |
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>
-rw-r--r-- | drivers/net/igb/e1000_hw.h | 6 | ||||
-rw-r--r-- | drivers/net/igb/e1000_mac.c | 50 | ||||
-rw-r--r-- | drivers/net/igb/e1000_phy.c | 4 | ||||
-rw-r--r-- | drivers/net/igb/igb_ethtool.c | 34 | ||||
-rw-r--r-- | drivers/net/igb/igb_main.c | 6 |
5 files changed, 55 insertions, 45 deletions
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h index 0469e2e7e63c..119869b1124d 100644 --- a/drivers/net/igb/e1000_hw.h +++ b/drivers/net/igb/e1000_hw.h | |||
@@ -137,7 +137,7 @@ enum e1000_rev_polarity { | |||
137 | e1000_rev_polarity_undefined = 0xFF | 137 | e1000_rev_polarity_undefined = 0xFF |
138 | }; | 138 | }; |
139 | 139 | ||
140 | enum e1000_fc_type { | 140 | enum e1000_fc_mode { |
141 | e1000_fc_none = 0, | 141 | e1000_fc_none = 0, |
142 | e1000_fc_rx_pause, | 142 | e1000_fc_rx_pause, |
143 | e1000_fc_tx_pause, | 143 | e1000_fc_tx_pause, |
@@ -429,8 +429,8 @@ struct e1000_fc_info { | |||
429 | u16 pause_time; /* Flow control pause timer */ | 429 | u16 pause_time; /* Flow control pause timer */ |
430 | bool send_xon; /* Flow control send XON */ | 430 | bool send_xon; /* Flow control send XON */ |
431 | bool strict_ieee; /* Strict IEEE mode */ | 431 | bool strict_ieee; /* Strict IEEE mode */ |
432 | enum e1000_fc_type type; /* Type of flow control */ | 432 | enum e1000_fc_mode current_mode; /* Type of flow control */ |
433 | enum e1000_fc_type original_type; | 433 | enum e1000_fc_mode requested_mode; |
434 | }; | 434 | }; |
435 | 435 | ||
436 | struct e1000_mbx_operations { | 436 | struct e1000_mbx_operations { |
diff --git a/drivers/net/igb/e1000_mac.c b/drivers/net/igb/e1000_mac.c index a1e3da78dbb1..a0231cd079f1 100644 --- a/drivers/net/igb/e1000_mac.c +++ b/drivers/net/igb/e1000_mac.c | |||
@@ -536,18 +536,24 @@ s32 igb_setup_link(struct e1000_hw *hw) | |||
536 | if (igb_check_reset_block(hw)) | 536 | if (igb_check_reset_block(hw)) |
537 | goto out; | 537 | goto out; |
538 | 538 | ||
539 | ret_val = igb_set_default_fc(hw); | 539 | /* |
540 | if (ret_val) | 540 | * If requested flow control is set to default, set flow control |
541 | goto out; | 541 | * based on the EEPROM flow control settings. |
542 | */ | ||
543 | if (hw->fc.requested_mode == e1000_fc_default) { | ||
544 | ret_val = igb_set_default_fc(hw); | ||
545 | if (ret_val) | ||
546 | goto out; | ||
547 | } | ||
542 | 548 | ||
543 | /* | 549 | /* |
544 | * We want to save off the original Flow Control configuration just | 550 | * We want to save off the original Flow Control configuration just |
545 | * in case we get disconnected and then reconnected into a different | 551 | * in case we get disconnected and then reconnected into a different |
546 | * hub or switch with different Flow Control capabilities. | 552 | * hub or switch with different Flow Control capabilities. |
547 | */ | 553 | */ |
548 | hw->fc.original_type = hw->fc.type; | 554 | hw->fc.current_mode = hw->fc.requested_mode; |
549 | 555 | ||
550 | hw_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.type); | 556 | hw_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode); |
551 | 557 | ||
552 | /* Call the necessary media_type subroutine to configure the link. */ | 558 | /* Call the necessary media_type subroutine to configure the link. */ |
553 | ret_val = hw->mac.ops.setup_physical_interface(hw); | 559 | ret_val = hw->mac.ops.setup_physical_interface(hw); |
@@ -614,7 +620,7 @@ static s32 igb_set_fc_watermarks(struct e1000_hw *hw) | |||
614 | * ability to transmit pause frames is not enabled, then these | 620 | * ability to transmit pause frames is not enabled, then these |
615 | * registers will be set to 0. | 621 | * registers will be set to 0. |
616 | */ | 622 | */ |
617 | if (hw->fc.type & e1000_fc_tx_pause) { | 623 | if (hw->fc.current_mode & e1000_fc_tx_pause) { |
618 | /* | 624 | /* |
619 | * We need to set up the Receive Threshold high and low water | 625 | * We need to set up the Receive Threshold high and low water |
620 | * marks as well as (optionally) enabling the transmission of | 626 | * marks as well as (optionally) enabling the transmission of |
@@ -661,12 +667,12 @@ static s32 igb_set_default_fc(struct e1000_hw *hw) | |||
661 | } | 667 | } |
662 | 668 | ||
663 | if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0) | 669 | if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == 0) |
664 | hw->fc.type = e1000_fc_none; | 670 | hw->fc.requested_mode = e1000_fc_none; |
665 | else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == | 671 | else if ((nvm_data & NVM_WORD0F_PAUSE_MASK) == |
666 | NVM_WORD0F_ASM_DIR) | 672 | NVM_WORD0F_ASM_DIR) |
667 | hw->fc.type = e1000_fc_tx_pause; | 673 | hw->fc.requested_mode = e1000_fc_tx_pause; |
668 | else | 674 | else |
669 | hw->fc.type = e1000_fc_full; | 675 | hw->fc.requested_mode = e1000_fc_full; |
670 | 676 | ||
671 | out: | 677 | out: |
672 | return ret_val; | 678 | return ret_val; |
@@ -696,7 +702,7 @@ s32 igb_force_mac_fc(struct e1000_hw *hw) | |||
696 | * receive flow control. | 702 | * receive flow control. |
697 | * | 703 | * |
698 | * The "Case" statement below enables/disable flow control | 704 | * The "Case" statement below enables/disable flow control |
699 | * according to the "hw->fc.type" parameter. | 705 | * according to the "hw->fc.current_mode" parameter. |
700 | * | 706 | * |
701 | * The possible values of the "fc" parameter are: | 707 | * The possible values of the "fc" parameter are: |
702 | * 0: Flow control is completely disabled | 708 | * 0: Flow control is completely disabled |
@@ -707,9 +713,9 @@ s32 igb_force_mac_fc(struct e1000_hw *hw) | |||
707 | * 3: Both Rx and TX flow control (symmetric) is enabled. | 713 | * 3: Both Rx and TX flow control (symmetric) is enabled. |
708 | * other: No other values should be possible at this point. | 714 | * other: No other values should be possible at this point. |
709 | */ | 715 | */ |
710 | hw_dbg("hw->fc.type = %u\n", hw->fc.type); | 716 | hw_dbg("hw->fc.current_mode = %u\n", hw->fc.current_mode); |
711 | 717 | ||
712 | switch (hw->fc.type) { | 718 | switch (hw->fc.current_mode) { |
713 | case e1000_fc_none: | 719 | case e1000_fc_none: |
714 | ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE)); | 720 | ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE)); |
715 | break; | 721 | break; |
@@ -857,11 +863,11 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw) | |||
857 | * ONLY. Hence, we must now check to see if we need to | 863 | * ONLY. Hence, we must now check to see if we need to |
858 | * turn OFF the TRANSMISSION of PAUSE frames. | 864 | * turn OFF the TRANSMISSION of PAUSE frames. |
859 | */ | 865 | */ |
860 | if (hw->fc.original_type == e1000_fc_full) { | 866 | if (hw->fc.requested_mode == e1000_fc_full) { |
861 | hw->fc.type = e1000_fc_full; | 867 | hw->fc.current_mode = e1000_fc_full; |
862 | hw_dbg("Flow Control = FULL.\r\n"); | 868 | hw_dbg("Flow Control = FULL.\r\n"); |
863 | } else { | 869 | } else { |
864 | hw->fc.type = e1000_fc_rx_pause; | 870 | hw->fc.current_mode = e1000_fc_rx_pause; |
865 | hw_dbg("Flow Control = " | 871 | hw_dbg("Flow Control = " |
866 | "RX PAUSE frames only.\r\n"); | 872 | "RX PAUSE frames only.\r\n"); |
867 | } | 873 | } |
@@ -878,7 +884,7 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw) | |||
878 | (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && | 884 | (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && |
879 | (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && | 885 | (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && |
880 | (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { | 886 | (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { |
881 | hw->fc.type = e1000_fc_tx_pause; | 887 | hw->fc.current_mode = e1000_fc_tx_pause; |
882 | hw_dbg("Flow Control = TX PAUSE frames only.\r\n"); | 888 | hw_dbg("Flow Control = TX PAUSE frames only.\r\n"); |
883 | } | 889 | } |
884 | /* | 890 | /* |
@@ -893,7 +899,7 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw) | |||
893 | (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && | 899 | (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && |
894 | !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && | 900 | !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && |
895 | (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { | 901 | (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { |
896 | hw->fc.type = e1000_fc_rx_pause; | 902 | hw->fc.current_mode = e1000_fc_rx_pause; |
897 | hw_dbg("Flow Control = RX PAUSE frames only.\r\n"); | 903 | hw_dbg("Flow Control = RX PAUSE frames only.\r\n"); |
898 | } | 904 | } |
899 | /* | 905 | /* |
@@ -917,13 +923,13 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw) | |||
917 | * be asked to delay transmission of packets than asking | 923 | * be asked to delay transmission of packets than asking |
918 | * our link partner to pause transmission of frames. | 924 | * our link partner to pause transmission of frames. |
919 | */ | 925 | */ |
920 | else if ((hw->fc.original_type == e1000_fc_none || | 926 | else if ((hw->fc.requested_mode == e1000_fc_none || |
921 | hw->fc.original_type == e1000_fc_tx_pause) || | 927 | hw->fc.requested_mode == e1000_fc_tx_pause) || |
922 | hw->fc.strict_ieee) { | 928 | hw->fc.strict_ieee) { |
923 | hw->fc.type = e1000_fc_none; | 929 | hw->fc.current_mode = e1000_fc_none; |
924 | hw_dbg("Flow Control = NONE.\r\n"); | 930 | hw_dbg("Flow Control = NONE.\r\n"); |
925 | } else { | 931 | } else { |
926 | hw->fc.type = e1000_fc_rx_pause; | 932 | hw->fc.current_mode = e1000_fc_rx_pause; |
927 | hw_dbg("Flow Control = RX PAUSE frames only.\r\n"); | 933 | hw_dbg("Flow Control = RX PAUSE frames only.\r\n"); |
928 | } | 934 | } |
929 | 935 | ||
@@ -939,7 +945,7 @@ s32 igb_config_fc_after_link_up(struct e1000_hw *hw) | |||
939 | } | 945 | } |
940 | 946 | ||
941 | if (duplex == HALF_DUPLEX) | 947 | if (duplex == HALF_DUPLEX) |
942 | hw->fc.type = e1000_fc_none; | 948 | hw->fc.current_mode = e1000_fc_none; |
943 | 949 | ||
944 | /* | 950 | /* |
945 | * Now we call a subroutine to actually force the MAC | 951 | * Now we call a subroutine to actually force the MAC |
diff --git a/drivers/net/igb/e1000_phy.c b/drivers/net/igb/e1000_phy.c index f50fac25be40..c1f4da630420 100644 --- a/drivers/net/igb/e1000_phy.c +++ b/drivers/net/igb/e1000_phy.c | |||
@@ -735,7 +735,7 @@ static s32 igb_phy_setup_autoneg(struct e1000_hw *hw) | |||
735 | * other: No software override. The flow control configuration | 735 | * other: No software override. The flow control configuration |
736 | * in the EEPROM is used. | 736 | * in the EEPROM is used. |
737 | */ | 737 | */ |
738 | switch (hw->fc.type) { | 738 | switch (hw->fc.current_mode) { |
739 | case e1000_fc_none: | 739 | case e1000_fc_none: |
740 | /* | 740 | /* |
741 | * Flow control (RX & TX) is completely disabled by a | 741 | * Flow control (RX & TX) is completely disabled by a |
@@ -992,7 +992,7 @@ static void igb_phy_force_speed_duplex_setup(struct e1000_hw *hw, | |||
992 | u32 ctrl; | 992 | u32 ctrl; |
993 | 993 | ||
994 | /* Turn off flow control when forcing speed/duplex */ | 994 | /* Turn off flow control when forcing speed/duplex */ |
995 | hw->fc.type = e1000_fc_none; | 995 | hw->fc.current_mode = e1000_fc_none; |
996 | 996 | ||
997 | /* Force speed/duplex on the mac */ | 997 | /* Force speed/duplex on the mac */ |
998 | ctrl = rd32(E1000_CTRL); | 998 | ctrl = rd32(E1000_CTRL); |
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; |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index 12d8683c231e..fb3273517587 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -1130,7 +1130,7 @@ void igb_reset(struct igb_adapter *adapter) | |||
1130 | } | 1130 | } |
1131 | fc->pause_time = 0xFFFF; | 1131 | fc->pause_time = 0xFFFF; |
1132 | fc->send_xon = 1; | 1132 | fc->send_xon = 1; |
1133 | fc->type = fc->original_type; | 1133 | fc->current_mode = fc->requested_mode; |
1134 | 1134 | ||
1135 | /* disable receive for all VFs and wait one second */ | 1135 | /* disable receive for all VFs and wait one second */ |
1136 | if (adapter->vfs_allocated_count) { | 1136 | if (adapter->vfs_allocated_count) { |
@@ -1427,8 +1427,8 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
1427 | hw->mac.autoneg = true; | 1427 | hw->mac.autoneg = true; |
1428 | hw->phy.autoneg_advertised = 0x2f; | 1428 | hw->phy.autoneg_advertised = 0x2f; |
1429 | 1429 | ||
1430 | hw->fc.original_type = e1000_fc_default; | 1430 | hw->fc.requested_mode = e1000_fc_default; |
1431 | hw->fc.type = e1000_fc_default; | 1431 | hw->fc.current_mode = e1000_fc_default; |
1432 | 1432 | ||
1433 | adapter->itr_setting = IGB_DEFAULT_ITR; | 1433 | adapter->itr_setting = IGB_DEFAULT_ITR; |
1434 | adapter->itr = IGB_START_ITR; | 1434 | adapter->itr = IGB_START_ITR; |