Skip to content

Commit

Permalink
net: bcmgenet: update ring producer index and buffer count in xmit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Florian Fainelli authored and David S. Miller committed Mar 13, 2015
1 parent d6707be commit ae67bf0
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions drivers/net/ethernet/broadcom/genet/bcmgenet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,11 +1130,6 @@ static int bcmgenet_xmit_single(struct net_device *dev,

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

/* Decrement total BD count and advance our write pointer */
ring->free_bds -= 1;
ring->prod_index += 1;
ring->prod_index &= DMA_P_INDEX_MASK;

return 0;
}

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


ring->free_bds -= 1;
ring->prod_index += 1;
ring->prod_index &= DMA_P_INDEX_MASK;

return 0;
}

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

skb_tx_timestamp(skb);

/* we kept a software copy of how much we should advance the TDMA
* producer index, now write it down to the hardware
*/
/* Decrement total BD count and advance our write pointer */
ring->free_bds -= nr_frags + 1;
ring->prod_index += nr_frags + 1;
ring->prod_index &= DMA_P_INDEX_MASK;

bcmgenet_tdma_ring_writel(priv, ring->index,
ring->prod_index, TDMA_PROD_INDEX);

Expand Down

0 comments on commit ae67bf0

Please sign in to comment.