diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-11-14 13:38:40 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-11-14 13:56:35 +0100 |
commit | 506426c51b136b619f4710a325f47bae3d72b29f (patch) | |
tree | 37925b1798e637403a6f4416efba8c18b5c8da2a /drivers/net/fsl-fman.c | |
parent | a699b239a20140b5bc54ddb869aa2031380afa9f (diff) | |
download | barebox-506426c51b136b619f4710a325f47bae3d72b29f.tar.gz |
net: fsl-fman: simplify setting next offset
The offset of the current packet can be retrieved from the current txbd
index, so do this instead of increasing the offset with each new packet.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/net/fsl-fman.c')
-rw-r--r-- | drivers/net/fsl-fman.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c index 196be3f6bd..01f7064fd2 100644 --- a/drivers/net/fsl-fman.c +++ b/drivers/net/fsl-fman.c @@ -835,7 +835,6 @@ static int fm_eth_send(struct eth_device *edev, void *buf, int len) struct fm_eth *fm_eth = to_fm_eth(edev); struct fm_port_global_pram *pram; struct fm_port_bd *txbd; - u16 offset_in; int i; dma_addr_t dma; @@ -862,12 +861,12 @@ static int fm_eth_send(struct eth_device *edev, void *buf, int len) muram_writew(&txbd->len, len); muram_writew(&txbd->status, TxBD_READY | TxBD_LAST); + /* advance the TxBD */ + fm_eth->cur_txbd_idx = (fm_eth->cur_txbd_idx + 1) % TX_BD_RING_SIZE; + /* update TxQD, let RISC to send the packet */ - offset_in = muram_readw(&pram->txqd.offset_in); - offset_in += sizeof(struct fm_port_bd); - if (offset_in >= muram_readw(&pram->txqd.bd_ring_size)) - offset_in = 0; - muram_writew(&pram->txqd.offset_in, offset_in); + muram_writew(&pram->txqd.offset_in, + fm_eth->cur_txbd_idx * sizeof(struct fm_port_bd)); /* wait for buffer to be transmitted */ for (i = 0; muram_readw(&txbd->status) & TxBD_READY; i++) { @@ -881,9 +880,6 @@ static int fm_eth_send(struct eth_device *edev, void *buf, int len) dma_unmap_single(fm_eth->dev, dma, len, DMA_TO_DEVICE); - /* advance the TxBD */ - fm_eth->cur_txbd_idx = (fm_eth->cur_txbd_idx + 1) % TX_BD_RING_SIZE; - return 0; } |