aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/igb/e1000_mac.c
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2009-07-23 14:10:24 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-26 12:47:02 -0400
commit0cce119aa977dba00467985c0ae93fe43d28740a (patch)
tree847330167dff04e7059b949a85c93d3ca9b4a054 /drivers/net/igb/e1000_mac.c
parent2d94d8ab76ea6c858c6e2eb0ab0403b00b031039 (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/e1000_mac.c')
-rw-r--r--drivers/net/igb/e1000_mac.c50
1 files changed, 28 insertions, 22 deletions
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
671out: 677out:
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