aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJesse Brandeburg <jesse.brandeburg@intel.com>2009-07-06 06:45:01 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-06 21:07:52 -0400
commitb7cb8c2c8275ab081b97610b13a83c80904571a6 (patch)
treed65785b59b2adadc5e428392ecde3144afc0e70c /drivers
parentedbbb3ca107715067b27a71e6ea7f58750912aa2 (diff)
e1000: fix flow control thresholds
when testing the jumbo frames with pages patch, the stats would show rx_missed errors (dropped packets) even when connected to a link partner with flow control enabled. this indicates that for this MTU (9000) the flow control thresholds are not adjusting correctly. In fact, before this change, the FCRTH (xoff threshold) is 36864 when the fifo size is only 40000, with 9000 byte MTU. fix it so that we at least have room for one frame after we send the xoff. Signed-off-by: Jesse Brandeburg <jesse.brandeburg@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')
-rw-r--r--drivers/net/e1000/e1000_hw.c2
-rw-r--r--drivers/net/e1000/e1000_hw.h3
-rw-r--r--drivers/net/e1000/e1000_main.c58
3 files changed, 33 insertions, 30 deletions
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index e1a3fc1303ee..1e5ae112d57a 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -1955,7 +1955,7 @@ static s32 e1000_setup_copper_link(struct e1000_hw *hw)
1955 s32 ret_val; 1955 s32 ret_val;
1956 u16 i; 1956 u16 i;
1957 u16 phy_data; 1957 u16 phy_data;
1958 u16 reg_data; 1958 u16 reg_data = 0;
1959 1959
1960 DEBUGFUNC("e1000_setup_copper_link"); 1960 DEBUGFUNC("e1000_setup_copper_link");
1961 1961
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 99fce2c5dd26..a8866bdbb671 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -523,11 +523,8 @@ s32 e1000_check_phy_reset_block(struct e1000_hw *hw);
523 523
524/* The sizes (in bytes) of a ethernet packet */ 524/* The sizes (in bytes) of a ethernet packet */
525#define ENET_HEADER_SIZE 14 525#define ENET_HEADER_SIZE 14
526#define MAXIMUM_ETHERNET_FRAME_SIZE 1518 /* With FCS */
527#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ 526#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
528#define ETHERNET_FCS_SIZE 4 527#define ETHERNET_FCS_SIZE 4
529#define MAXIMUM_ETHERNET_PACKET_SIZE \
530 (MAXIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
531#define MINIMUM_ETHERNET_PACKET_SIZE \ 528#define MINIMUM_ETHERNET_PACKET_SIZE \
532 (MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE) 529 (MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
533#define CRC_LENGTH ETHERNET_FCS_SIZE 530#define CRC_LENGTH ETHERNET_FCS_SIZE
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index f2db9e2069e7..d7df00c2dbd6 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -641,8 +641,8 @@ void e1000_reset(struct e1000_adapter *adapter)
641{ 641{
642 struct e1000_hw *hw = &adapter->hw; 642 struct e1000_hw *hw = &adapter->hw;
643 u32 pba = 0, tx_space, min_tx_space, min_rx_space; 643 u32 pba = 0, tx_space, min_tx_space, min_rx_space;
644 u16 fc_high_water_mark = E1000_FC_HIGH_DIFF;
645 bool legacy_pba_adjust = false; 644 bool legacy_pba_adjust = false;
645 u16 hwm;
646 646
647 /* Repartition Pba for greater than 9k mtu 647 /* Repartition Pba for greater than 9k mtu
648 * To take effect CTRL.RST is required. 648 * To take effect CTRL.RST is required.
@@ -686,7 +686,7 @@ void e1000_reset(struct e1000_adapter *adapter)
686 } 686 }
687 687
688 if (legacy_pba_adjust) { 688 if (legacy_pba_adjust) {
689 if (adapter->netdev->mtu > E1000_RXBUFFER_8192) 689 if (hw->max_frame_size > E1000_RXBUFFER_8192)
690 pba -= 8; /* allocate more FIFO for Tx */ 690 pba -= 8; /* allocate more FIFO for Tx */
691 691
692 if (hw->mac_type == e1000_82547) { 692 if (hw->mac_type == e1000_82547) {
@@ -696,14 +696,14 @@ void e1000_reset(struct e1000_adapter *adapter)
696 (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT; 696 (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT;
697 atomic_set(&adapter->tx_fifo_stall, 0); 697 atomic_set(&adapter->tx_fifo_stall, 0);
698 } 698 }
699 } else if (hw->max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) { 699 } else if (hw->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) {
700 /* adjust PBA for jumbo frames */ 700 /* adjust PBA for jumbo frames */
701 ew32(PBA, pba); 701 ew32(PBA, pba);
702 702
703 /* To maintain wire speed transmits, the Tx FIFO should be 703 /* To maintain wire speed transmits, the Tx FIFO should be
704 * large enough to accomodate two full transmit packets, 704 * large enough to accommodate two full transmit packets,
705 * rounded up to the next 1KB and expressed in KB. Likewise, 705 * rounded up to the next 1KB and expressed in KB. Likewise,
706 * the Rx FIFO should be large enough to accomodate at least 706 * the Rx FIFO should be large enough to accommodate at least
707 * one full receive packet and is similarly rounded up and 707 * one full receive packet and is similarly rounded up and
708 * expressed in KB. */ 708 * expressed in KB. */
709 pba = er32(PBA); 709 pba = er32(PBA);
@@ -711,13 +711,17 @@ void e1000_reset(struct e1000_adapter *adapter)
711 tx_space = pba >> 16; 711 tx_space = pba >> 16;
712 /* lower 16 bits has Rx packet buffer allocation size in KB */ 712 /* lower 16 bits has Rx packet buffer allocation size in KB */
713 pba &= 0xffff; 713 pba &= 0xffff;
714 /* don't include ethernet FCS because hardware appends/strips */ 714 /*
715 min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE + 715 * the tx fifo also stores 16 bytes of information about the tx
716 VLAN_TAG_SIZE; 716 * but don't include ethernet FCS because hardware appends it
717 min_tx_space = min_rx_space; 717 */
718 min_tx_space *= 2; 718 min_tx_space = (hw->max_frame_size +
719 sizeof(struct e1000_tx_desc) -
720 ETH_FCS_LEN) * 2;
719 min_tx_space = ALIGN(min_tx_space, 1024); 721 min_tx_space = ALIGN(min_tx_space, 1024);
720 min_tx_space >>= 10; 722 min_tx_space >>= 10;
723 /* software strips receive CRC, so leave room for it */
724 min_rx_space = hw->max_frame_size;
721 min_rx_space = ALIGN(min_rx_space, 1024); 725 min_rx_space = ALIGN(min_rx_space, 1024);
722 min_rx_space >>= 10; 726 min_rx_space >>= 10;
723 727
@@ -754,19 +758,21 @@ void e1000_reset(struct e1000_adapter *adapter)
754 758
755 ew32(PBA, pba); 759 ew32(PBA, pba);
756 760
757 /* flow control settings */ 761 /*
758 /* Set the FC high water mark to 90% of the FIFO size. 762 * flow control settings:
759 * Required to clear last 3 LSB */ 763 * The high water mark must be low enough to fit one full frame
760 fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8; 764 * (or the size used for early receive) above it in the Rx FIFO.
761 /* We can't use 90% on small FIFOs because the remainder 765 * Set it to the lower of:
762 * would be less than 1 full frame. In this case, we size 766 * - 90% of the Rx FIFO size, and
763 * it to allow at least a full frame above the high water 767 * - the full Rx FIFO size minus the early receive size (for parts
764 * mark. */ 768 * with ERT support assuming ERT set to E1000_ERT_2048), or
765 if (pba < E1000_PBA_16K) 769 * - the full Rx FIFO size minus one full frame
766 fc_high_water_mark = (pba * 1024) - 1600; 770 */
767 771 hwm = min(((pba << 10) * 9 / 10),
768 hw->fc_high_water = fc_high_water_mark; 772 ((pba << 10) - hw->max_frame_size));
769 hw->fc_low_water = fc_high_water_mark - 8; 773
774 hw->fc_high_water = hwm & 0xFFF8; /* 8-byte granularity */
775 hw->fc_low_water = hw->fc_high_water - 8;
770 hw->fc_pause_time = E1000_FC_PAUSE_TIME; 776 hw->fc_pause_time = E1000_FC_PAUSE_TIME;
771 hw->fc_send_xon = 1; 777 hw->fc_send_xon = 1;
772 hw->fc = hw->original_fc; 778 hw->fc = hw->original_fc;
@@ -3474,7 +3480,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3474 switch (hw->mac_type) { 3480 switch (hw->mac_type) {
3475 case e1000_undefined ... e1000_82542_rev2_1: 3481 case e1000_undefined ... e1000_82542_rev2_1:
3476 case e1000_ich8lan: 3482 case e1000_ich8lan:
3477 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { 3483 if (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)) {
3478 DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n"); 3484 DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n");
3479 return -EINVAL; 3485 return -EINVAL;
3480 } 3486 }
@@ -3487,7 +3493,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3487 &eeprom_data); 3493 &eeprom_data);
3488 if ((hw->device_id != E1000_DEV_ID_82573L) || 3494 if ((hw->device_id != E1000_DEV_ID_82573L) ||
3489 (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) { 3495 (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) {
3490 if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { 3496 if (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)) {
3491 DPRINTK(PROBE, ERR, 3497 DPRINTK(PROBE, ERR,
3492 "Jumbo Frames not supported.\n"); 3498 "Jumbo Frames not supported.\n");
3493 return -EINVAL; 3499 return -EINVAL;
@@ -3535,7 +3541,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3535 3541
3536 /* adjust allocation if LPE protects us, and we aren't using SBP */ 3542 /* adjust allocation if LPE protects us, and we aren't using SBP */
3537 if (!hw->tbi_compatibility_on && 3543 if (!hw->tbi_compatibility_on &&
3538 ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) || 3544 ((max_frame == (ETH_FRAME_LEN + ETH_FCS_LEN)) ||
3539 (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE))) 3545 (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE)))
3540 adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE; 3546 adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE;
3541 3547