Commit b64b7bb6 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: add separate buffer allocation function for napi

Introduce a separate buffer allocation function to be called
from NAPI.  We can make assumptions about the context and
buffer size.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c0f031bc
...@@ -1098,6 +1098,26 @@ nfp_net_rx_alloc_one(struct nfp_net_rx_ring *rx_ring, dma_addr_t *dma_addr, ...@@ -1098,6 +1098,26 @@ nfp_net_rx_alloc_one(struct nfp_net_rx_ring *rx_ring, dma_addr_t *dma_addr,
return frag; return frag;
} }
static void *nfp_net_napi_alloc_one(struct nfp_net *nn, dma_addr_t *dma_addr)
{
void *frag;
frag = napi_alloc_frag(nn->fl_bufsz);
if (!frag) {
nn_warn_ratelimit(nn, "Failed to alloc receive page frag\n");
return NULL;
}
*dma_addr = nfp_net_dma_map_rx(nn, frag, nn->fl_bufsz, DMA_FROM_DEVICE);
if (dma_mapping_error(&nn->pdev->dev, *dma_addr)) {
skb_free_frag(frag);
nn_warn_ratelimit(nn, "Failed to map DMA RX buffer\n");
return NULL;
}
return frag;
}
/** /**
* nfp_net_rx_give_one() - Put mapped skb on the software and hardware rings * nfp_net_rx_give_one() - Put mapped skb on the software and hardware rings
* @rx_ring: RX ring structure * @rx_ring: RX ring structure
...@@ -1413,8 +1433,7 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget) ...@@ -1413,8 +1433,7 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget)
nfp_net_rx_drop(r_vec, rx_ring, rxbuf, NULL); nfp_net_rx_drop(r_vec, rx_ring, rxbuf, NULL);
continue; continue;
} }
new_frag = nfp_net_rx_alloc_one(rx_ring, &new_dma_addr, new_frag = nfp_net_napi_alloc_one(nn, &new_dma_addr);
nn->fl_bufsz);
if (unlikely(!new_frag)) { if (unlikely(!new_frag)) {
nfp_net_rx_drop(r_vec, rx_ring, rxbuf, skb); nfp_net_rx_drop(r_vec, rx_ring, rxbuf, skb);
continue; continue;
......
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