diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2010-08-19 09:38:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-08-19 19:44:23 -0400 |
commit | 477de6ed027dbbeb0424a4d1a978429037287d22 (patch) | |
tree | 36ec8b8a0431ef22335a53fee5cebb6b56dcc353 /drivers | |
parent | 826437d3de43174a8199776b5c1178bafa0b6634 (diff) |
ixgbe: Move max frame size and Rx buffer length configuration into a function
This change consolidates all of the Rx max frame size and Rx buffer length
configuration into a single function.
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')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_main.c | 108 |
1 files changed, 60 insertions, 48 deletions
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index 520b95fc4d41..841ef9827ec6 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -2695,25 +2695,15 @@ static void ixgbe_setup_psrtype(struct ixgbe_adapter *adapter) | |||
2695 | psrtype); | 2695 | psrtype); |
2696 | } | 2696 | } |
2697 | 2697 | ||
2698 | /** | 2698 | static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) |
2699 | * ixgbe_configure_rx - Configure 8259x Receive Unit after Reset | ||
2700 | * @adapter: board private structure | ||
2701 | * | ||
2702 | * Configure the Rx unit of the MAC after a reset. | ||
2703 | **/ | ||
2704 | static void ixgbe_configure_rx(struct ixgbe_adapter *adapter) | ||
2705 | { | 2699 | { |
2706 | struct ixgbe_hw *hw = &adapter->hw; | 2700 | struct ixgbe_hw *hw = &adapter->hw; |
2707 | struct ixgbe_ring *rx_ring; | ||
2708 | struct net_device *netdev = adapter->netdev; | 2701 | struct net_device *netdev = adapter->netdev; |
2709 | int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; | 2702 | int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; |
2710 | int i; | ||
2711 | u32 rxctrl; | ||
2712 | u32 hlreg0, gcr_ext; | ||
2713 | u32 rdrxctl; | ||
2714 | int rx_buf_len; | 2703 | int rx_buf_len; |
2715 | 2704 | struct ixgbe_ring *rx_ring; | |
2716 | ixgbe_setup_psrtype(adapter); | 2705 | int i; |
2706 | u32 mhadd, hlreg0; | ||
2717 | 2707 | ||
2718 | /* Decide whether to use packet split mode or not */ | 2708 | /* Decide whether to use packet split mode or not */ |
2719 | /* Do not use packet split if we're in SR-IOV Mode */ | 2709 | /* Do not use packet split if we're in SR-IOV Mode */ |
@@ -2728,23 +2718,28 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter) | |||
2728 | (netdev->mtu <= ETH_DATA_LEN)) | 2718 | (netdev->mtu <= ETH_DATA_LEN)) |
2729 | rx_buf_len = MAXIMUM_ETHERNET_VLAN_SIZE; | 2719 | rx_buf_len = MAXIMUM_ETHERNET_VLAN_SIZE; |
2730 | else | 2720 | else |
2731 | rx_buf_len = ALIGN(max_frame, 1024); | 2721 | rx_buf_len = ALIGN(max_frame + VLAN_HLEN, 1024); |
2732 | } | 2722 | } |
2733 | 2723 | ||
2734 | hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0); | ||
2735 | if (adapter->netdev->mtu <= ETH_DATA_LEN) | ||
2736 | hlreg0 &= ~IXGBE_HLREG0_JUMBOEN; | ||
2737 | else | ||
2738 | hlreg0 |= IXGBE_HLREG0_JUMBOEN; | ||
2739 | #ifdef IXGBE_FCOE | 2724 | #ifdef IXGBE_FCOE |
2740 | if (netdev->features & NETIF_F_FCOE_MTU) | 2725 | /* adjust max frame to be able to do baby jumbo for FCoE */ |
2741 | hlreg0 |= IXGBE_HLREG0_JUMBOEN; | 2726 | if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) && |
2742 | #endif | 2727 | (max_frame < IXGBE_FCOE_JUMBO_FRAME_SIZE)) |
2743 | IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); | 2728 | max_frame = IXGBE_FCOE_JUMBO_FRAME_SIZE; |
2744 | 2729 | ||
2745 | /* disable receives while setting up the descriptors */ | 2730 | #endif /* IXGBE_FCOE */ |
2746 | rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL); | 2731 | mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD); |
2747 | IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl & ~IXGBE_RXCTRL_RXEN); | 2732 | if (max_frame != (mhadd >> IXGBE_MHADD_MFS_SHIFT)) { |
2733 | mhadd &= ~IXGBE_MHADD_MFS_MASK; | ||
2734 | mhadd |= max_frame << IXGBE_MHADD_MFS_SHIFT; | ||
2735 | |||
2736 | IXGBE_WRITE_REG(hw, IXGBE_MHADD, mhadd); | ||
2737 | } | ||
2738 | |||
2739 | hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0); | ||
2740 | /* set jumbo enable since MHADD.MFS is keeping size locked at max_frame */ | ||
2741 | hlreg0 |= IXGBE_HLREG0_JUMBOEN; | ||
2742 | IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); | ||
2748 | 2743 | ||
2749 | /* | 2744 | /* |
2750 | * Setup the HW Rx Head and Tail Descriptor Pointers and | 2745 | * Setup the HW Rx Head and Tail Descriptor Pointers and |
@@ -2760,7 +2755,8 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter) | |||
2760 | rx_ring->flags &= ~IXGBE_RING_RX_PS_ENABLED; | 2755 | rx_ring->flags &= ~IXGBE_RING_RX_PS_ENABLED; |
2761 | 2756 | ||
2762 | #ifdef IXGBE_FCOE | 2757 | #ifdef IXGBE_FCOE |
2763 | if (netdev->features & NETIF_F_FCOE_MTU) { | 2758 | if (netdev->features & NETIF_F_FCOE_MTU) |
2759 | { | ||
2764 | struct ixgbe_ring_feature *f; | 2760 | struct ixgbe_ring_feature *f; |
2765 | f = &adapter->ring_feature[RING_F_FCOE]; | 2761 | f = &adapter->ring_feature[RING_F_FCOE]; |
2766 | if ((i >= f->mask) && (i < f->mask + f->indices)) { | 2762 | if ((i >= f->mask) && (i < f->mask + f->indices)) { |
@@ -2770,8 +2766,41 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter) | |||
2770 | IXGBE_FCOE_JUMBO_FRAME_SIZE; | 2766 | IXGBE_FCOE_JUMBO_FRAME_SIZE; |
2771 | } | 2767 | } |
2772 | } | 2768 | } |
2773 | |||
2774 | #endif /* IXGBE_FCOE */ | 2769 | #endif /* IXGBE_FCOE */ |
2770 | } | ||
2771 | |||
2772 | } | ||
2773 | |||
2774 | /** | ||
2775 | * ixgbe_configure_rx - Configure 8259x Receive Unit after Reset | ||
2776 | * @adapter: board private structure | ||
2777 | * | ||
2778 | * Configure the Rx unit of the MAC after a reset. | ||
2779 | **/ | ||
2780 | static void ixgbe_configure_rx(struct ixgbe_adapter *adapter) | ||
2781 | { | ||
2782 | struct ixgbe_hw *hw = &adapter->hw; | ||
2783 | struct ixgbe_ring *rx_ring; | ||
2784 | int i; | ||
2785 | u32 rxctrl; | ||
2786 | u32 gcr_ext; | ||
2787 | u32 rdrxctl; | ||
2788 | |||
2789 | /* disable receives while setting up the descriptors */ | ||
2790 | rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL); | ||
2791 | IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl & ~IXGBE_RXCTRL_RXEN); | ||
2792 | |||
2793 | ixgbe_setup_psrtype(adapter); | ||
2794 | |||
2795 | /* set_rx_buffer_len must be called before ring initialization */ | ||
2796 | ixgbe_set_rx_buffer_len(adapter); | ||
2797 | |||
2798 | /* | ||
2799 | * Setup the HW Rx Head and Tail Descriptor Pointers and | ||
2800 | * the Base and Length of the Rx Descriptor Ring | ||
2801 | */ | ||
2802 | for (i = 0; i < adapter->num_rx_queues; i++) { | ||
2803 | rx_ring = adapter->rx_ring[i]; | ||
2775 | ixgbe_configure_rx_ring(adapter, rx_ring); | 2804 | ixgbe_configure_rx_ring(adapter, rx_ring); |
2776 | ixgbe_configure_srrctl(adapter, rx_ring); | 2805 | ixgbe_configure_srrctl(adapter, rx_ring); |
2777 | } | 2806 | } |
@@ -3322,13 +3351,11 @@ static inline void ixgbe_rx_desc_queue_enable(struct ixgbe_adapter *adapter, | |||
3322 | 3351 | ||
3323 | static int ixgbe_up_complete(struct ixgbe_adapter *adapter) | 3352 | static int ixgbe_up_complete(struct ixgbe_adapter *adapter) |
3324 | { | 3353 | { |
3325 | struct net_device *netdev = adapter->netdev; | ||
3326 | struct ixgbe_hw *hw = &adapter->hw; | 3354 | struct ixgbe_hw *hw = &adapter->hw; |
3327 | int i, j = 0; | 3355 | int i, j = 0; |
3328 | int num_rx_rings = adapter->num_rx_queues; | 3356 | int num_rx_rings = adapter->num_rx_queues; |
3329 | int err; | 3357 | int err; |
3330 | int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; | 3358 | u32 txdctl, rxdctl; |
3331 | u32 txdctl, rxdctl, mhadd; | ||
3332 | u32 dmatxctl; | 3359 | u32 dmatxctl; |
3333 | u32 gpie; | 3360 | u32 gpie; |
3334 | u32 ctrl_ext; | 3361 | u32 ctrl_ext; |
@@ -3395,21 +3422,6 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter) | |||
3395 | IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie); | 3422 | IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie); |
3396 | } | 3423 | } |
3397 | 3424 | ||
3398 | #ifdef IXGBE_FCOE | ||
3399 | /* adjust max frame to be able to do baby jumbo for FCoE */ | ||
3400 | if ((netdev->features & NETIF_F_FCOE_MTU) && | ||
3401 | (max_frame < IXGBE_FCOE_JUMBO_FRAME_SIZE)) | ||
3402 | max_frame = IXGBE_FCOE_JUMBO_FRAME_SIZE; | ||
3403 | |||
3404 | #endif /* IXGBE_FCOE */ | ||
3405 | mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD); | ||
3406 | if (max_frame != (mhadd >> IXGBE_MHADD_MFS_SHIFT)) { | ||
3407 | mhadd &= ~IXGBE_MHADD_MFS_MASK; | ||
3408 | mhadd |= max_frame << IXGBE_MHADD_MFS_SHIFT; | ||
3409 | |||
3410 | IXGBE_WRITE_REG(hw, IXGBE_MHADD, mhadd); | ||
3411 | } | ||
3412 | |||
3413 | if (hw->mac.type == ixgbe_mac_82599EB) { | 3425 | if (hw->mac.type == ixgbe_mac_82599EB) { |
3414 | /* DMATXCTL.EN must be set after all Tx queue config is done */ | 3426 | /* DMATXCTL.EN must be set after all Tx queue config is done */ |
3415 | dmatxctl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL); | 3427 | dmatxctl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL); |
@@ -3522,7 +3534,7 @@ static int ixgbe_up_complete(struct ixgbe_adapter *adapter) | |||
3522 | &(adapter->tx_ring[i]->reinit_state)); | 3534 | &(adapter->tx_ring[i]->reinit_state)); |
3523 | 3535 | ||
3524 | /* enable transmits */ | 3536 | /* enable transmits */ |
3525 | netif_tx_start_all_queues(netdev); | 3537 | netif_tx_start_all_queues(adapter->netdev); |
3526 | 3538 | ||
3527 | /* bring the link up in the watchdog, this could race with our first | 3539 | /* bring the link up in the watchdog, this could race with our first |
3528 | * link up interrupt but shouldn't be a problem */ | 3540 | * link up interrupt but shouldn't be a problem */ |