diff options
author | Dimitris Michailidis <d.michailidis@fungible.com> | 2022-07-29 00:32:54 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-08-01 12:38:57 +0100 |
commit | 16ead40812a08248c89268736b973c53cfe6e16e (patch) | |
tree | 7c691686a1d0ef96a0f0a7c3b09c16f66894388e /drivers/net/ethernet/fungible | |
parent | d4d11f8ff14b28a956d01700d4559620ffe4c2a2 (diff) |
net/funeth: Unify skb/XDP Tx packet unmapping.
Current XDP unmapping is a subset of its skb analog, dealing with
only one buffer. In preparation for multi-frag XDP rename the skb
function and use it also for XDP. The XDP version is removed.
Signed-off-by: Dimitris Michailidis <dmichail@fungible.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/fungible')
-rw-r--r-- | drivers/net/ethernet/fungible/funeth/funeth_tx.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/net/ethernet/fungible/funeth/funeth_tx.c b/drivers/net/ethernet/fungible/funeth/funeth_tx.c index 54bdeb65a2bd..83fe825ce11d 100644 --- a/drivers/net/ethernet/fungible/funeth/funeth_tx.c +++ b/drivers/net/ethernet/fungible/funeth/funeth_tx.c @@ -371,7 +371,7 @@ static u16 txq_hw_head(const struct funeth_txq *q) /* Unmap the Tx packet starting at the given descriptor index and * return the number of Tx descriptors it occupied. */ -static unsigned int unmap_skb(const struct funeth_txq *q, unsigned int idx) +static unsigned int fun_unmap_pkt(const struct funeth_txq *q, unsigned int idx) { const struct fun_eth_tx_req *req = fun_tx_desc_addr(q, idx); unsigned int ngle = req->dataop.ngather; @@ -419,7 +419,7 @@ static bool fun_txq_reclaim(struct funeth_txq *q, int budget) rmb(); do { - unsigned int pkt_desc = unmap_skb(q, reclaim_idx); + unsigned int pkt_desc = fun_unmap_pkt(q, reclaim_idx); struct sk_buff *skb = q->info[reclaim_idx].skb; trace_funeth_tx_free(q, reclaim_idx, pkt_desc, head); @@ -461,20 +461,10 @@ int fun_txq_napi_poll(struct napi_struct *napi, int budget) return 0; } -static void fun_xdp_unmap(const struct funeth_txq *q, unsigned int idx) -{ - const struct fun_eth_tx_req *req = fun_tx_desc_addr(q, idx); - const struct fun_dataop_gl *gle; - - gle = (const struct fun_dataop_gl *)req->dataop.imm; - dma_unmap_single(q->dma_dev, be64_to_cpu(gle->sgl_data), - be32_to_cpu(gle->sgl_len), DMA_TO_DEVICE); -} - -/* Reclaim up to @budget completed Tx descriptors from a TX XDP queue. */ +/* Reclaim up to @budget completed Tx packets from a TX XDP queue. */ static unsigned int fun_xdpq_clean(struct funeth_txq *q, unsigned int budget) { - unsigned int npkts = 0, head, reclaim_idx; + unsigned int npkts = 0, ndesc = 0, head, reclaim_idx; for (head = txq_hw_head(q), reclaim_idx = q->cons_cnt & q->mask; head != reclaim_idx && npkts < budget; head = txq_hw_head(q)) { @@ -486,17 +476,19 @@ static unsigned int fun_xdpq_clean(struct funeth_txq *q, unsigned int budget) rmb(); do { - fun_xdp_unmap(q, reclaim_idx); + unsigned int pkt_desc = fun_unmap_pkt(q, reclaim_idx); + xdp_return_frame(q->info[reclaim_idx].xdpf); - trace_funeth_tx_free(q, reclaim_idx, 1, head); + trace_funeth_tx_free(q, reclaim_idx, pkt_desc, head); - reclaim_idx = (reclaim_idx + 1) & q->mask; + reclaim_idx = (reclaim_idx + pkt_desc) & q->mask; + ndesc += pkt_desc; npkts++; } while (reclaim_idx != head && npkts < budget); } - q->cons_cnt += npkts; + q->cons_cnt += ndesc; return npkts; } @@ -584,7 +576,7 @@ static void fun_txq_purge(struct funeth_txq *q) while (q->cons_cnt != q->prod_cnt) { unsigned int idx = q->cons_cnt & q->mask; - q->cons_cnt += unmap_skb(q, idx); + q->cons_cnt += fun_unmap_pkt(q, idx); dev_kfree_skb_any(q->info[idx].skb); } netdev_tx_reset_queue(q->ndq); @@ -595,9 +587,8 @@ static void fun_xdpq_purge(struct funeth_txq *q) while (q->cons_cnt != q->prod_cnt) { unsigned int idx = q->cons_cnt & q->mask; - fun_xdp_unmap(q, idx); + q->cons_cnt += fun_unmap_pkt(q, idx); xdp_return_frame(q->info[idx].xdpf); - q->cons_cnt++; } } |