aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDon Skidmore <donald.c.skidmore@intel.com>2013-10-30 03:45:39 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2013-12-10 04:27:33 -0500
commit5cdab2f620de9cb14de297326e30e3dd7ea769de (patch)
tree037f1cd2be26337e243e1d6d6f463d8e5f1bad6b
parentc0832b2c105d3b666bab325e2790267157df6290 (diff)
ixgbe: Focus config of head, tail ntc, and ntu all into a single function
This patch makes it so that head, tail, next to clean, and next to use are all reset in a single function for the Tx or Rx path. Previously the code for this was spread out over several areas which could make it difficult to track what the values for these were. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Don Skidmore <donald.c.skidmore@intel.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf.h4
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c55
2 files changed, 19 insertions, 40 deletions
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
index 8971e2d0a984..eaaa3ecacfd7 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf.h
@@ -86,9 +86,7 @@ struct ixgbevf_ring {
86 u64 bp_misses; 86 u64 bp_misses;
87 u64 bp_cleaned; 87 u64 bp_cleaned;
88#endif 88#endif
89 89 u8 __iomem *tail;
90 u16 head;
91 u16 tail;
92 90
93 u16 reg_idx; /* holds the special value that gets the hardware register 91 u16 reg_idx; /* holds the special value that gets the hardware register
94 * offset associated with this ring, which is different 92 * offset associated with this ring, which is different
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 92ef4cb5a8e8..84b55fe71546 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -98,10 +98,11 @@ MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
98static void ixgbevf_set_itr(struct ixgbevf_q_vector *q_vector); 98static void ixgbevf_set_itr(struct ixgbevf_q_vector *q_vector);
99static void ixgbevf_free_all_rx_resources(struct ixgbevf_adapter *adapter); 99static void ixgbevf_free_all_rx_resources(struct ixgbevf_adapter *adapter);
100 100
101static inline void ixgbevf_release_rx_desc(struct ixgbe_hw *hw, 101static inline void ixgbevf_release_rx_desc(struct ixgbevf_ring *rx_ring,
102 struct ixgbevf_ring *rx_ring,
103 u32 val) 102 u32 val)
104{ 103{
104 rx_ring->next_to_use = val;
105
105 /* 106 /*
106 * Force memory writes to complete before letting h/w 107 * Force memory writes to complete before letting h/w
107 * know there are new descriptors to fetch. (Only 108 * know there are new descriptors to fetch. (Only
@@ -109,7 +110,7 @@ static inline void ixgbevf_release_rx_desc(struct ixgbe_hw *hw,
109 * such as IA-64). 110 * such as IA-64).
110 */ 111 */
111 wmb(); 112 wmb();
112 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(rx_ring->reg_idx), val); 113 writel(val, rx_ring->tail);
113} 114}
114 115
115/** 116/**
@@ -406,10 +407,8 @@ static void ixgbevf_alloc_rx_buffers(struct ixgbevf_adapter *adapter,
406 } 407 }
407 408
408no_buffers: 409no_buffers:
409 if (rx_ring->next_to_use != i) { 410 if (rx_ring->next_to_use != i)
410 rx_ring->next_to_use = i; 411 ixgbevf_release_rx_desc(rx_ring, i);
411 ixgbevf_release_rx_desc(&adapter->hw, rx_ring, i);
412 }
413} 412}
414 413
415static inline void ixgbevf_irq_enable_queues(struct ixgbevf_adapter *adapter, 414static inline void ixgbevf_irq_enable_queues(struct ixgbevf_adapter *adapter,
@@ -1110,8 +1109,9 @@ static void ixgbevf_configure_tx(struct ixgbevf_adapter *adapter)
1110 IXGBE_WRITE_REG(hw, IXGBE_VFTDLEN(j), tdlen); 1109 IXGBE_WRITE_REG(hw, IXGBE_VFTDLEN(j), tdlen);
1111 IXGBE_WRITE_REG(hw, IXGBE_VFTDH(j), 0); 1110 IXGBE_WRITE_REG(hw, IXGBE_VFTDH(j), 0);
1112 IXGBE_WRITE_REG(hw, IXGBE_VFTDT(j), 0); 1111 IXGBE_WRITE_REG(hw, IXGBE_VFTDT(j), 0);
1113 adapter->tx_ring[i].head = IXGBE_VFTDH(j); 1112 ring->tail = hw->hw_addr + IXGBE_VFTDT(j);
1114 adapter->tx_ring[i].tail = IXGBE_VFTDT(j); 1113 ring->next_to_clean = 0;
1114 ring->next_to_use = 0;
1115 /* Disable Tx Head Writeback RO bit, since this hoses 1115 /* Disable Tx Head Writeback RO bit, since this hoses
1116 * bookkeeping if things aren't delivered in order. 1116 * bookkeeping if things aren't delivered in order.
1117 */ 1117 */
@@ -1208,20 +1208,22 @@ static void ixgbevf_configure_rx(struct ixgbevf_adapter *adapter)
1208 /* set_rx_buffer_len must be called before ring initialization */ 1208 /* set_rx_buffer_len must be called before ring initialization */
1209 ixgbevf_set_rx_buffer_len(adapter); 1209 ixgbevf_set_rx_buffer_len(adapter);
1210 1210
1211 rdlen = adapter->rx_ring[0].count * sizeof(union ixgbe_adv_rx_desc);
1212 /* Setup the HW Rx Head and Tail Descriptor Pointers and 1211 /* Setup the HW Rx Head and Tail Descriptor Pointers and
1213 * the Base and Length of the Rx Descriptor Ring */ 1212 * the Base and Length of the Rx Descriptor Ring */
1214 for (i = 0; i < adapter->num_rx_queues; i++) { 1213 for (i = 0; i < adapter->num_rx_queues; i++) {
1215 rdba = adapter->rx_ring[i].dma; 1214 struct ixgbevf_ring *ring = &adapter->rx_ring[i];
1216 j = adapter->rx_ring[i].reg_idx; 1215 rdba = ring->dma;
1216 j = ring->reg_idx;
1217 rdlen = ring->count * sizeof(union ixgbe_adv_rx_desc);
1217 IXGBE_WRITE_REG(hw, IXGBE_VFRDBAL(j), 1218 IXGBE_WRITE_REG(hw, IXGBE_VFRDBAL(j),
1218 (rdba & DMA_BIT_MASK(32))); 1219 (rdba & DMA_BIT_MASK(32)));
1219 IXGBE_WRITE_REG(hw, IXGBE_VFRDBAH(j), (rdba >> 32)); 1220 IXGBE_WRITE_REG(hw, IXGBE_VFRDBAH(j), (rdba >> 32));
1220 IXGBE_WRITE_REG(hw, IXGBE_VFRDLEN(j), rdlen); 1221 IXGBE_WRITE_REG(hw, IXGBE_VFRDLEN(j), rdlen);
1221 IXGBE_WRITE_REG(hw, IXGBE_VFRDH(j), 0); 1222 IXGBE_WRITE_REG(hw, IXGBE_VFRDH(j), 0);
1222 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(j), 0); 1223 IXGBE_WRITE_REG(hw, IXGBE_VFRDT(j), 0);
1223 adapter->rx_ring[i].head = IXGBE_VFRDH(j); 1224 ring->tail = hw->hw_addr + IXGBE_VFRDT(j);
1224 adapter->rx_ring[i].tail = IXGBE_VFRDT(j); 1225 ring->next_to_clean = 0;
1226 ring->next_to_use = 0;
1225 1227
1226 ixgbevf_configure_srrctl(adapter, j); 1228 ixgbevf_configure_srrctl(adapter, j);
1227 } 1229 }
@@ -1402,7 +1404,7 @@ static void ixgbevf_rx_desc_queue_enable(struct ixgbevf_adapter *adapter,
1402 hw_dbg(hw, "RXDCTL.ENABLE queue %d not set while polling\n", 1404 hw_dbg(hw, "RXDCTL.ENABLE queue %d not set while polling\n",
1403 rxr); 1405 rxr);
1404 1406
1405 ixgbevf_release_rx_desc(&adapter->hw, &adapter->rx_ring[rxr], 1407 ixgbevf_release_rx_desc(&adapter->rx_ring[rxr],
1406 (adapter->rx_ring[rxr].count - 1)); 1408 (adapter->rx_ring[rxr].count - 1));
1407} 1409}
1408 1410
@@ -1680,14 +1682,6 @@ static void ixgbevf_clean_rx_ring(struct ixgbevf_adapter *adapter,
1680 1682
1681 /* Zero out the descriptor ring */ 1683 /* Zero out the descriptor ring */
1682 memset(rx_ring->desc, 0, rx_ring->size); 1684 memset(rx_ring->desc, 0, rx_ring->size);
1683
1684 rx_ring->next_to_clean = 0;
1685 rx_ring->next_to_use = 0;
1686
1687 if (rx_ring->head)
1688 writel(0, adapter->hw.hw_addr + rx_ring->head);
1689 if (rx_ring->tail)
1690 writel(0, adapter->hw.hw_addr + rx_ring->tail);
1691} 1685}
1692 1686
1693/** 1687/**
@@ -1715,14 +1709,6 @@ static void ixgbevf_clean_tx_ring(struct ixgbevf_adapter *adapter,
1715 memset(tx_ring->tx_buffer_info, 0, size); 1709 memset(tx_ring->tx_buffer_info, 0, size);
1716 1710
1717 memset(tx_ring->desc, 0, tx_ring->size); 1711 memset(tx_ring->desc, 0, tx_ring->size);
1718
1719 tx_ring->next_to_use = 0;
1720 tx_ring->next_to_clean = 0;
1721
1722 if (tx_ring->head)
1723 writel(0, adapter->hw.hw_addr + tx_ring->head);
1724 if (tx_ring->tail)
1725 writel(0, adapter->hw.hw_addr + tx_ring->tail);
1726} 1712}
1727 1713
1728/** 1714/**
@@ -2473,8 +2459,6 @@ int ixgbevf_setup_tx_resources(struct ixgbevf_adapter *adapter,
2473 if (!tx_ring->desc) 2459 if (!tx_ring->desc)
2474 goto err; 2460 goto err;
2475 2461
2476 tx_ring->next_to_use = 0;
2477 tx_ring->next_to_clean = 0;
2478 return 0; 2462 return 0;
2479 2463
2480err: 2464err:
@@ -2542,9 +2526,6 @@ int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter,
2542 goto alloc_failed; 2526 goto alloc_failed;
2543 } 2527 }
2544 2528
2545 rx_ring->next_to_clean = 0;
2546 rx_ring->next_to_use = 0;
2547
2548 return 0; 2529 return 0;
2549alloc_failed: 2530alloc_failed:
2550 return -ENOMEM; 2531 return -ENOMEM;
@@ -3181,7 +3162,7 @@ static int ixgbevf_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
3181 ixgbevf_tx_map(tx_ring, skb, tx_flags), 3162 ixgbevf_tx_map(tx_ring, skb, tx_flags),
3182 first, skb->len, hdr_len); 3163 first, skb->len, hdr_len);
3183 3164
3184 writel(tx_ring->next_to_use, adapter->hw.hw_addr + tx_ring->tail); 3165 writel(tx_ring->next_to_use, tx_ring->tail);
3185 3166
3186 ixgbevf_maybe_stop_tx(tx_ring, DESC_NEEDED); 3167 ixgbevf_maybe_stop_tx(tx_ring, DESC_NEEDED);
3187 3168