提交 1a1d74d3 编写于 作者: J Jakub Kicinski 提交者: David S. Miller

nfp: use AND instead of modulo to get ring indexes

We already force ring sizes to be power of 2 so replace
modulo operations with AND (size - 1) in index calculations.
Signed-off-by: NJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b64b7bb6
...@@ -778,7 +778,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev) ...@@ -778,7 +778,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
if (dma_mapping_error(&nn->pdev->dev, dma_addr)) if (dma_mapping_error(&nn->pdev->dev, dma_addr))
goto err_free; goto err_free;
wr_idx = tx_ring->wr_p % tx_ring->cnt; wr_idx = tx_ring->wr_p & (tx_ring->cnt - 1);
/* Stash the soft descriptor of the head then initialize it */ /* Stash the soft descriptor of the head then initialize it */
txbuf = &tx_ring->txbufs[wr_idx]; txbuf = &tx_ring->txbufs[wr_idx];
...@@ -822,7 +822,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev) ...@@ -822,7 +822,7 @@ static int nfp_net_tx(struct sk_buff *skb, struct net_device *netdev)
if (dma_mapping_error(&nn->pdev->dev, dma_addr)) if (dma_mapping_error(&nn->pdev->dev, dma_addr))
goto err_unmap; goto err_unmap;
wr_idx = (wr_idx + 1) % tx_ring->cnt; wr_idx = (wr_idx + 1) & (tx_ring->cnt - 1);
tx_ring->txbufs[wr_idx].skb = skb; tx_ring->txbufs[wr_idx].skb = skb;
tx_ring->txbufs[wr_idx].dma_addr = dma_addr; tx_ring->txbufs[wr_idx].dma_addr = dma_addr;
tx_ring->txbufs[wr_idx].fidx = f; tx_ring->txbufs[wr_idx].fidx = f;
...@@ -917,7 +917,7 @@ static void nfp_net_tx_complete(struct nfp_net_tx_ring *tx_ring) ...@@ -917,7 +917,7 @@ static void nfp_net_tx_complete(struct nfp_net_tx_ring *tx_ring)
todo = qcp_rd_p + tx_ring->cnt - tx_ring->qcp_rd_p; todo = qcp_rd_p + tx_ring->cnt - tx_ring->qcp_rd_p;
while (todo--) { while (todo--) {
idx = tx_ring->rd_p % tx_ring->cnt; idx = tx_ring->rd_p & (tx_ring->cnt - 1);
tx_ring->rd_p++; tx_ring->rd_p++;
skb = tx_ring->txbufs[idx].skb; skb = tx_ring->txbufs[idx].skb;
...@@ -992,7 +992,7 @@ nfp_net_tx_ring_reset(struct nfp_net *nn, struct nfp_net_tx_ring *tx_ring) ...@@ -992,7 +992,7 @@ nfp_net_tx_ring_reset(struct nfp_net *nn, struct nfp_net_tx_ring *tx_ring)
int nr_frags, fidx, idx; int nr_frags, fidx, idx;
struct sk_buff *skb; struct sk_buff *skb;
idx = tx_ring->rd_p % tx_ring->cnt; idx = tx_ring->rd_p & (tx_ring->cnt - 1);
skb = tx_ring->txbufs[idx].skb; skb = tx_ring->txbufs[idx].skb;
nr_frags = skb_shinfo(skb)->nr_frags; nr_frags = skb_shinfo(skb)->nr_frags;
fidx = tx_ring->txbufs[idx].fidx; fidx = tx_ring->txbufs[idx].fidx;
...@@ -1129,7 +1129,7 @@ static void nfp_net_rx_give_one(struct nfp_net_rx_ring *rx_ring, ...@@ -1129,7 +1129,7 @@ static void nfp_net_rx_give_one(struct nfp_net_rx_ring *rx_ring,
{ {
unsigned int wr_idx; unsigned int wr_idx;
wr_idx = rx_ring->wr_p % rx_ring->cnt; wr_idx = rx_ring->wr_p & (rx_ring->cnt - 1);
/* Stash SKB and DMA address away */ /* Stash SKB and DMA address away */
rx_ring->rxbufs[wr_idx].frag = frag; rx_ring->rxbufs[wr_idx].frag = frag;
...@@ -1164,7 +1164,7 @@ static void nfp_net_rx_ring_reset(struct nfp_net_rx_ring *rx_ring) ...@@ -1164,7 +1164,7 @@ static void nfp_net_rx_ring_reset(struct nfp_net_rx_ring *rx_ring)
unsigned int wr_idx, last_idx; unsigned int wr_idx, last_idx;
/* Move the empty entry to the end of the list */ /* Move the empty entry to the end of the list */
wr_idx = rx_ring->wr_p % rx_ring->cnt; wr_idx = rx_ring->wr_p & (rx_ring->cnt - 1);
last_idx = rx_ring->cnt - 1; last_idx = rx_ring->cnt - 1;
rx_ring->rxbufs[wr_idx].dma_addr = rx_ring->rxbufs[last_idx].dma_addr; rx_ring->rxbufs[wr_idx].dma_addr = rx_ring->rxbufs[last_idx].dma_addr;
rx_ring->rxbufs[wr_idx].frag = rx_ring->rxbufs[last_idx].frag; rx_ring->rxbufs[wr_idx].frag = rx_ring->rxbufs[last_idx].frag;
...@@ -1413,7 +1413,7 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget) ...@@ -1413,7 +1413,7 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)
int idx; int idx;
while (pkts_polled < budget) { while (pkts_polled < budget) {
idx = rx_ring->rd_p % rx_ring->cnt; idx = rx_ring->rd_p & (rx_ring->cnt - 1);
rxd = &rx_ring->rxds[idx]; rxd = &rx_ring->rxds[idx];
if (!(rxd->rxd.meta_len_dd & PCIE_DESC_RX_DD)) if (!(rxd->rxd.meta_len_dd & PCIE_DESC_RX_DD))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册