Skip to content

Commit ae67bf0

Browse files
ffainellidavem330
authored andcommitted
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 <[email protected]> Acked-by: Petri Gynther <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d6707be commit ae67bf0

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,11 +1130,6 @@ static int bcmgenet_xmit_single(struct net_device *dev,
11301130

11311131
dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, length_status);
11321132

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-
11381133
return 0;
11391134
}
11401135

@@ -1173,11 +1168,6 @@ static int bcmgenet_xmit_frag(struct net_device *dev,
11731168
(frag->size << DMA_BUFLENGTH_SHIFT) | dma_desc_flags |
11741169
(priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT));
11751170

1176-
1177-
ring->free_bds -= 1;
1178-
ring->prod_index += 1;
1179-
ring->prod_index &= DMA_P_INDEX_MASK;
1180-
11811171
return 0;
11821172
}
11831173

@@ -1321,9 +1311,11 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)
13211311

13221312
skb_tx_timestamp(skb);
13231313

1324-
/* we kept a software copy of how much we should advance the TDMA
1325-
* producer index, now write it down to the hardware
1326-
*/
1314+
/* Decrement total BD count and advance our write pointer */
1315+
ring->free_bds -= nr_frags + 1;
1316+
ring->prod_index += nr_frags + 1;
1317+
ring->prod_index &= DMA_P_INDEX_MASK;
1318+
13271319
bcmgenet_tdma_ring_writel(priv, ring->index,
13281320
ring->prod_index, TDMA_PROD_INDEX);
13291321

0 commit comments

Comments
 (0)