aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2015-03-13 15:11:06 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-13 15:52:31 -0400
commitae67bf0188cbb9d1786bdfcca9e1976cb36ee327 (patch)
tree07347e19a36c09ce7b95a45984388b75dd4a27c7
parentd6707bec598649450ee0887bf11896e525777874 (diff)
net: bcmgenet: update ring producer index and buffer count in xmit
There is no need to have both bcmgenet_xmit_single() and bcmgenet_xmit_frag() perform a free_bds decrement and a prod_index increment by one. In case one of these functions fails to map a SKB or fragment for transmit, we will return and exit bcmgenet_xmit() with an error. We can therefore safely use our local copy of nr_frags to know by how much we should decrement the number of free buffers available, and by how much the producer count must be incremented and do this in the tail of bcmgenet_xmit(). Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Petri Gynther <pgynther@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 875967e8d719..53c916ea06a2 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -1130,11 +1130,6 @@ static int bcmgenet_xmit_single(struct net_device *dev,
1130 1130
1131 dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, length_status); 1131 dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, length_status);
1132 1132
1133 /* Decrement total BD count and advance our write pointer */
1134 ring->free_bds -= 1;
1135 ring->prod_index += 1;
1136 ring->prod_index &= DMA_P_INDEX_MASK;
1137
1138 return 0; 1133 return 0;
1139} 1134}
1140 1135
@@ -1173,11 +1168,6 @@ static int bcmgenet_xmit_frag(struct net_device *dev,
1173 (frag->size << DMA_BUFLENGTH_SHIFT) | dma_desc_flags | 1168 (frag->size << DMA_BUFLENGTH_SHIFT) | dma_desc_flags |
1174 (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT)); 1169 (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT));
1175 1170
1176
1177 ring->free_bds -= 1;
1178 ring->prod_index += 1;
1179 ring->prod_index &= DMA_P_INDEX_MASK;
1180
1181 return 0; 1171 return 0;
1182} 1172}
1183 1173
@@ -1321,9 +1311,11 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
1321 1311
1322 skb_tx_timestamp(skb); 1312 skb_tx_timestamp(skb);
1323 1313
1324 /* we kept a software copy of how much we should advance the TDMA 1314 /* Decrement total BD count and advance our write pointer */
1325 * producer index, now write it down to the hardware 1315 ring->free_bds -= nr_frags + 1;
1326 */ 1316 ring->prod_index += nr_frags + 1;
1317 ring->prod_index &= DMA_P_INDEX_MASK;
1318
1327 bcmgenet_tdma_ring_writel(priv, ring->index, 1319 bcmgenet_tdma_ring_writel(priv, ring->index,
1328 ring->prod_index, TDMA_PROD_INDEX); 1320 ring->prod_index, TDMA_PROD_INDEX);
1329 1321