Commit c3bc2adb authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Jakub Kicinski

net: netsec: add xdp tx return bulking support

Convert netsec driver to xdp_return_frame_bulk APIs.
Rely on xdp_return_frame_rx_napi for XDP_TX in order to try to recycle
the page in the "in-irq" page_pool cache.
Co-developed-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/01487b8f5167d62649339469cdd0c6d8df885902.1605605531.git.lorenzo@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e2ef5203
...@@ -631,6 +631,7 @@ static void netsec_set_rx_de(struct netsec_priv *priv, ...@@ -631,6 +631,7 @@ static void netsec_set_rx_de(struct netsec_priv *priv,
static bool netsec_clean_tx_dring(struct netsec_priv *priv) static bool netsec_clean_tx_dring(struct netsec_priv *priv)
{ {
struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_TX]; struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_TX];
struct xdp_frame_bulk bq;
struct netsec_de *entry; struct netsec_de *entry;
int tail = dring->tail; int tail = dring->tail;
unsigned int bytes; unsigned int bytes;
...@@ -639,8 +640,11 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv) ...@@ -639,8 +640,11 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
spin_lock(&dring->lock); spin_lock(&dring->lock);
bytes = 0; bytes = 0;
xdp_frame_bulk_init(&bq);
entry = dring->vaddr + DESC_SZ * tail; entry = dring->vaddr + DESC_SZ * tail;
rcu_read_lock(); /* need for xdp_return_frame_bulk */
while (!(entry->attr & (1U << NETSEC_TX_SHIFT_OWN_FIELD)) && while (!(entry->attr & (1U << NETSEC_TX_SHIFT_OWN_FIELD)) &&
cnt < DESC_NUM) { cnt < DESC_NUM) {
struct netsec_desc *desc; struct netsec_desc *desc;
...@@ -665,7 +669,10 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv) ...@@ -665,7 +669,10 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
dev_kfree_skb(desc->skb); dev_kfree_skb(desc->skb);
} else { } else {
bytes += desc->xdpf->len; bytes += desc->xdpf->len;
xdp_return_frame(desc->xdpf); if (desc->buf_type == TYPE_NETSEC_XDP_TX)
xdp_return_frame_rx_napi(desc->xdpf);
else
xdp_return_frame_bulk(desc->xdpf, &bq);
} }
next: next:
/* clean up so netsec_uninit_pkt_dring() won't free the skb /* clean up so netsec_uninit_pkt_dring() won't free the skb
...@@ -684,6 +691,9 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv) ...@@ -684,6 +691,9 @@ static bool netsec_clean_tx_dring(struct netsec_priv *priv)
entry = dring->vaddr + DESC_SZ * tail; entry = dring->vaddr + DESC_SZ * tail;
cnt++; cnt++;
} }
xdp_flush_frame_bulk(&bq);
rcu_read_unlock();
spin_unlock(&dring->lock); spin_unlock(&dring->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment