diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2009-10-27 11:50:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-28 04:20:20 -0400 |
commit | 85b430b47736d1f59e8f9efb0e47bc46aeb2b01d (patch) | |
tree | 24d97f367a97c9b863950bb1d929e28a4d597d97 /drivers/net/igb/igb_main.c | |
parent | 7d95b7170eca3f95bad939fc9eb365b823c05e39 (diff) |
igb: move the tx and rx ring specific config into seperate functions
This change makes the tx and rx config a bit cleaner by breaking out the ring
specific configuration from the generic rx and tx configuration.
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_main.c')
-rw-r--r-- | drivers/net/igb/igb_main.c | 179 |
1 files changed, 112 insertions, 67 deletions
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index 6146f5db9871..61ef4c2c4fca 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -90,6 +90,7 @@ static int igb_open(struct net_device *); | |||
90 | static int igb_close(struct net_device *); | 90 | static int igb_close(struct net_device *); |
91 | static void igb_configure_tx(struct igb_adapter *); | 91 | static void igb_configure_tx(struct igb_adapter *); |
92 | static void igb_configure_rx(struct igb_adapter *); | 92 | static void igb_configure_rx(struct igb_adapter *); |
93 | static void igb_setup_tctl(struct igb_adapter *); | ||
93 | static void igb_setup_rctl(struct igb_adapter *); | 94 | static void igb_setup_rctl(struct igb_adapter *); |
94 | static void igb_clean_all_tx_rings(struct igb_adapter *); | 95 | static void igb_clean_all_tx_rings(struct igb_adapter *); |
95 | static void igb_clean_all_rx_rings(struct igb_adapter *); | 96 | static void igb_clean_all_rx_rings(struct igb_adapter *); |
@@ -1101,8 +1102,10 @@ static void igb_configure(struct igb_adapter *adapter) | |||
1101 | 1102 | ||
1102 | igb_restore_vlan(adapter); | 1103 | igb_restore_vlan(adapter); |
1103 | 1104 | ||
1104 | igb_configure_tx(adapter); | 1105 | igb_setup_tctl(adapter); |
1105 | igb_setup_rctl(adapter); | 1106 | igb_setup_rctl(adapter); |
1107 | |||
1108 | igb_configure_tx(adapter); | ||
1106 | igb_configure_rx(adapter); | 1109 | igb_configure_rx(adapter); |
1107 | 1110 | ||
1108 | igb_rx_fifo_flush_82575(&adapter->hw); | 1111 | igb_rx_fifo_flush_82575(&adapter->hw); |
@@ -2069,49 +2072,16 @@ static int igb_setup_all_tx_resources(struct igb_adapter *adapter) | |||
2069 | } | 2072 | } |
2070 | 2073 | ||
2071 | /** | 2074 | /** |
2072 | * igb_configure_tx - Configure transmit Unit after Reset | 2075 | * igb_setup_tctl - configure the transmit control registers |
2073 | * @adapter: board private structure | 2076 | * @adapter: Board private structure |
2074 | * | ||
2075 | * Configure the Tx unit of the MAC after a reset. | ||
2076 | **/ | 2077 | **/ |
2077 | static void igb_configure_tx(struct igb_adapter *adapter) | 2078 | static void igb_setup_tctl(struct igb_adapter *adapter) |
2078 | { | 2079 | { |
2079 | u64 tdba; | ||
2080 | struct e1000_hw *hw = &adapter->hw; | 2080 | struct e1000_hw *hw = &adapter->hw; |
2081 | u32 tctl; | 2081 | u32 tctl; |
2082 | u32 txdctl, txctrl; | ||
2083 | int i, j; | ||
2084 | |||
2085 | for (i = 0; i < adapter->num_tx_queues; i++) { | ||
2086 | struct igb_ring *ring = &adapter->tx_ring[i]; | ||
2087 | j = ring->reg_idx; | ||
2088 | wr32(E1000_TDLEN(j), | ||
2089 | ring->count * sizeof(union e1000_adv_tx_desc)); | ||
2090 | tdba = ring->dma; | ||
2091 | wr32(E1000_TDBAL(j), | ||
2092 | tdba & 0x00000000ffffffffULL); | ||
2093 | wr32(E1000_TDBAH(j), tdba >> 32); | ||
2094 | |||
2095 | ring->head = E1000_TDH(j); | ||
2096 | ring->tail = E1000_TDT(j); | ||
2097 | writel(0, hw->hw_addr + ring->tail); | ||
2098 | writel(0, hw->hw_addr + ring->head); | ||
2099 | txdctl = rd32(E1000_TXDCTL(j)); | ||
2100 | txdctl |= E1000_TXDCTL_QUEUE_ENABLE; | ||
2101 | wr32(E1000_TXDCTL(j), txdctl); | ||
2102 | |||
2103 | /* Turn off Relaxed Ordering on head write-backs. The | ||
2104 | * writebacks MUST be delivered in order or it will | ||
2105 | * completely screw up our bookeeping. | ||
2106 | */ | ||
2107 | txctrl = rd32(E1000_DCA_TXCTRL(j)); | ||
2108 | txctrl &= ~E1000_DCA_TXCTRL_TX_WB_RO_EN; | ||
2109 | wr32(E1000_DCA_TXCTRL(j), txctrl); | ||
2110 | } | ||
2111 | 2082 | ||
2112 | /* disable queue 0 to prevent tail bump w/o re-configuration */ | 2083 | /* disable queue 0 which is enabled by default on 82575 and 82576 */ |
2113 | if (adapter->vfs_allocated_count) | 2084 | wr32(E1000_TXDCTL(0), 0); |
2114 | wr32(E1000_TXDCTL(0), 0); | ||
2115 | 2085 | ||
2116 | /* Program the Transmit Control Register */ | 2086 | /* Program the Transmit Control Register */ |
2117 | tctl = rd32(E1000_TCTL); | 2087 | tctl = rd32(E1000_TCTL); |
@@ -2121,9 +2091,6 @@ static void igb_configure_tx(struct igb_adapter *adapter) | |||
2121 | 2091 | ||
2122 | igb_config_collision_dist(hw); | 2092 | igb_config_collision_dist(hw); |
2123 | 2093 | ||
2124 | /* Setup Transmit Descriptor Settings for eop descriptor */ | ||
2125 | adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_RS; | ||
2126 | |||
2127 | /* Enable transmits */ | 2094 | /* Enable transmits */ |
2128 | tctl |= E1000_TCTL_EN; | 2095 | tctl |= E1000_TCTL_EN; |
2129 | 2096 | ||
@@ -2131,6 +2098,64 @@ static void igb_configure_tx(struct igb_adapter *adapter) | |||
2131 | } | 2098 | } |
2132 | 2099 | ||
2133 | /** | 2100 | /** |
2101 | * igb_configure_tx_ring - Configure transmit ring after Reset | ||
2102 | * @adapter: board private structure | ||
2103 | * @ring: tx ring to configure | ||
2104 | * | ||
2105 | * Configure a transmit ring after a reset. | ||
2106 | **/ | ||
2107 | static void igb_configure_tx_ring(struct igb_adapter *adapter, | ||
2108 | struct igb_ring *ring) | ||
2109 | { | ||
2110 | struct e1000_hw *hw = &adapter->hw; | ||
2111 | u32 txdctl; | ||
2112 | u64 tdba = ring->dma; | ||
2113 | int reg_idx = ring->reg_idx; | ||
2114 | |||
2115 | /* disable the queue */ | ||
2116 | txdctl = rd32(E1000_TXDCTL(reg_idx)); | ||
2117 | wr32(E1000_TXDCTL(reg_idx), | ||
2118 | txdctl & ~E1000_TXDCTL_QUEUE_ENABLE); | ||
2119 | wrfl(); | ||
2120 | mdelay(10); | ||
2121 | |||
2122 | wr32(E1000_TDLEN(reg_idx), | ||
2123 | ring->count * sizeof(union e1000_adv_tx_desc)); | ||
2124 | wr32(E1000_TDBAL(reg_idx), | ||
2125 | tdba & 0x00000000ffffffffULL); | ||
2126 | wr32(E1000_TDBAH(reg_idx), tdba >> 32); | ||
2127 | |||
2128 | ring->head = E1000_TDH(reg_idx); | ||
2129 | ring->tail = E1000_TDT(reg_idx); | ||
2130 | writel(0, hw->hw_addr + ring->tail); | ||
2131 | writel(0, hw->hw_addr + ring->head); | ||
2132 | |||
2133 | txdctl |= IGB_TX_PTHRESH; | ||
2134 | txdctl |= IGB_TX_HTHRESH << 8; | ||
2135 | txdctl |= IGB_TX_WTHRESH << 16; | ||
2136 | |||
2137 | txdctl |= E1000_TXDCTL_QUEUE_ENABLE; | ||
2138 | wr32(E1000_TXDCTL(reg_idx), txdctl); | ||
2139 | } | ||
2140 | |||
2141 | /** | ||
2142 | * igb_configure_tx - Configure transmit Unit after Reset | ||
2143 | * @adapter: board private structure | ||
2144 | * | ||
2145 | * Configure the Tx unit of the MAC after a reset. | ||
2146 | **/ | ||
2147 | static void igb_configure_tx(struct igb_adapter *adapter) | ||
2148 | { | ||
2149 | int i; | ||
2150 | |||
2151 | for (i = 0; i < adapter->num_tx_queues; i++) | ||
2152 | igb_configure_tx_ring(adapter, &adapter->tx_ring[i]); | ||
2153 | |||
2154 | /* Setup Transmit Descriptor Settings for eop descriptor */ | ||
2155 | adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_RS; | ||
2156 | } | ||
2157 | |||
2158 | /** | ||
2134 | * igb_setup_rx_resources - allocate Rx resources (Descriptors) | 2159 | * igb_setup_rx_resources - allocate Rx resources (Descriptors) |
2135 | * @adapter: board private structure | 2160 | * @adapter: board private structure |
2136 | * @rx_ring: rx descriptor ring (for a specific queue) to setup | 2161 | * @rx_ring: rx descriptor ring (for a specific queue) to setup |
@@ -2334,6 +2359,49 @@ static void igb_configure_vt_default_pool(struct igb_adapter *adapter) | |||
2334 | } | 2359 | } |
2335 | 2360 | ||
2336 | /** | 2361 | /** |
2362 | * igb_configure_rx_ring - Configure a receive ring after Reset | ||
2363 | * @adapter: board private structure | ||
2364 | * @ring: receive ring to be configured | ||
2365 | * | ||
2366 | * Configure the Rx unit of the MAC after a reset. | ||
2367 | **/ | ||
2368 | static void igb_configure_rx_ring(struct igb_adapter *adapter, | ||
2369 | struct igb_ring *ring) | ||
2370 | { | ||
2371 | struct e1000_hw *hw = &adapter->hw; | ||
2372 | u64 rdba = ring->dma; | ||
2373 | int reg_idx = ring->reg_idx; | ||
2374 | u32 rxdctl; | ||
2375 | |||
2376 | /* disable the queue */ | ||
2377 | rxdctl = rd32(E1000_RXDCTL(reg_idx)); | ||
2378 | wr32(E1000_RXDCTL(reg_idx), | ||
2379 | rxdctl & ~E1000_RXDCTL_QUEUE_ENABLE); | ||
2380 | |||
2381 | /* Set DMA base address registers */ | ||
2382 | wr32(E1000_RDBAL(reg_idx), | ||
2383 | rdba & 0x00000000ffffffffULL); | ||
2384 | wr32(E1000_RDBAH(reg_idx), rdba >> 32); | ||
2385 | wr32(E1000_RDLEN(reg_idx), | ||
2386 | ring->count * sizeof(union e1000_adv_rx_desc)); | ||
2387 | |||
2388 | /* initialize head and tail */ | ||
2389 | ring->head = E1000_RDH(reg_idx); | ||
2390 | ring->tail = E1000_RDT(reg_idx); | ||
2391 | writel(0, hw->hw_addr + ring->head); | ||
2392 | writel(0, hw->hw_addr + ring->tail); | ||
2393 | |||
2394 | /* enable receive descriptor fetching */ | ||
2395 | rxdctl = rd32(E1000_RXDCTL(reg_idx)); | ||
2396 | rxdctl |= E1000_RXDCTL_QUEUE_ENABLE; | ||
2397 | rxdctl &= 0xFFF00000; | ||
2398 | rxdctl |= IGB_RX_PTHRESH; | ||
2399 | rxdctl |= IGB_RX_HTHRESH << 8; | ||
2400 | rxdctl |= IGB_RX_WTHRESH << 16; | ||
2401 | wr32(E1000_RXDCTL(reg_idx), rxdctl); | ||
2402 | } | ||
2403 | |||
2404 | /** | ||
2337 | * igb_configure_rx - Configure receive Unit after Reset | 2405 | * igb_configure_rx - Configure receive Unit after Reset |
2338 | * @adapter: board private structure | 2406 | * @adapter: board private structure |
2339 | * | 2407 | * |
@@ -2341,10 +2409,8 @@ static void igb_configure_vt_default_pool(struct igb_adapter *adapter) | |||
2341 | **/ | 2409 | **/ |
2342 | static void igb_configure_rx(struct igb_adapter *adapter) | 2410 | static void igb_configure_rx(struct igb_adapter *adapter) |
2343 | { | 2411 | { |
2344 | u64 rdba; | ||
2345 | struct e1000_hw *hw = &adapter->hw; | 2412 | struct e1000_hw *hw = &adapter->hw; |
2346 | u32 rctl, rxcsum; | 2413 | u32 rctl, rxcsum; |
2347 | u32 rxdctl; | ||
2348 | int i; | 2414 | int i; |
2349 | 2415 | ||
2350 | /* disable receives while setting up the descriptors */ | 2416 | /* disable receives while setting up the descriptors */ |
@@ -2358,29 +2424,8 @@ static void igb_configure_rx(struct igb_adapter *adapter) | |||
2358 | 2424 | ||
2359 | /* Setup the HW Rx Head and Tail Descriptor Pointers and | 2425 | /* Setup the HW Rx Head and Tail Descriptor Pointers and |
2360 | * the Base and Length of the Rx Descriptor Ring */ | 2426 | * the Base and Length of the Rx Descriptor Ring */ |
2361 | for (i = 0; i < adapter->num_rx_queues; i++) { | 2427 | for (i = 0; i < adapter->num_rx_queues; i++) |
2362 | struct igb_ring *ring = &adapter->rx_ring[i]; | 2428 | igb_configure_rx_ring(adapter, &adapter->rx_ring[i]); |
2363 | int j = ring->reg_idx; | ||
2364 | rdba = ring->dma; | ||
2365 | wr32(E1000_RDBAL(j), | ||
2366 | rdba & 0x00000000ffffffffULL); | ||
2367 | wr32(E1000_RDBAH(j), rdba >> 32); | ||
2368 | wr32(E1000_RDLEN(j), | ||
2369 | ring->count * sizeof(union e1000_adv_rx_desc)); | ||
2370 | |||
2371 | ring->head = E1000_RDH(j); | ||
2372 | ring->tail = E1000_RDT(j); | ||
2373 | writel(0, hw->hw_addr + ring->tail); | ||
2374 | writel(0, hw->hw_addr + ring->head); | ||
2375 | |||
2376 | rxdctl = rd32(E1000_RXDCTL(j)); | ||
2377 | rxdctl |= E1000_RXDCTL_QUEUE_ENABLE; | ||
2378 | rxdctl &= 0xFFF00000; | ||
2379 | rxdctl |= IGB_RX_PTHRESH; | ||
2380 | rxdctl |= IGB_RX_HTHRESH << 8; | ||
2381 | rxdctl |= IGB_RX_WTHRESH << 16; | ||
2382 | wr32(E1000_RXDCTL(j), rxdctl); | ||
2383 | } | ||
2384 | 2429 | ||
2385 | if (adapter->num_rx_queues > 1) { | 2430 | if (adapter->num_rx_queues > 1) { |
2386 | u32 random[10]; | 2431 | u32 random[10]; |