diff options
author | Jakub Kicinski <jakub.kicinski@netronome.com> | 2016-10-31 20:43:14 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-11-01 11:04:59 -0400 |
commit | e9949aebe04a1d917a15f4dc71e77deaefe9de94 (patch) | |
tree | 1a6a1a141d06e52e0d4f08b345f0925068f3b28a /drivers | |
parent | bf187ea01b07739167420088adb385f9385a7c7f (diff) | |
download | linux-stable-e9949aebe04a1d917a15f4dc71e77deaefe9de94.tar.gz linux-stable-e9949aebe04a1d917a15f4dc71e77deaefe9de94.tar.bz2 linux-stable-e9949aebe04a1d917a15f4dc71e77deaefe9de94.zip |
nfp: add buffer drop/recycle helper for RX
nfp_net_rx() is quite long already and about to get longer.
Move buffer drop/recycle to a helper.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/netronome/nfp/nfp_net_common.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 77c645abb827..abd4f17e89c7 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -1330,6 +1330,20 @@ nfp_net_parse_meta(struct net_device *netdev, struct sk_buff *skb, return data; } +static void +nfp_net_rx_drop(struct nfp_net_r_vector *r_vec, struct nfp_net_rx_ring *rx_ring, + struct nfp_net_rx_buf *rxbuf, struct sk_buff *skb) +{ + u64_stats_update_begin(&r_vec->rx_sync); + r_vec->rx_drops++; + u64_stats_update_end(&r_vec->rx_sync); + + if (rxbuf) + nfp_net_rx_give_one(rx_ring, rxbuf->skb, rxbuf->dma_addr); + if (skb) + dev_kfree_skb_any(skb); +} + /** * nfp_net_rx() - receive up to @budget packets on @rx_ring * @rx_ring: RX ring to receive from @@ -1372,11 +1386,8 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget) new_skb = nfp_net_rx_alloc_one(rx_ring, &new_dma_addr, nn->fl_bufsz); if (!new_skb) { - nfp_net_rx_give_one(rx_ring, rx_ring->rxbufs[idx].skb, - rx_ring->rxbufs[idx].dma_addr); - u64_stats_update_begin(&r_vec->rx_sync); - r_vec->rx_drops++; - u64_stats_update_end(&r_vec->rx_sync); + nfp_net_rx_drop(r_vec, rx_ring, &rx_ring->rxbufs[idx], + NULL); continue; } @@ -1420,12 +1431,8 @@ static int nfp_net_rx(struct nfp_net_rx_ring *rx_ring, int budget) end = nfp_net_parse_meta(nn->netdev, skb, meta_len); if (unlikely(end != skb->data)) { - u64_stats_update_begin(&r_vec->rx_sync); - r_vec->rx_drops++; - u64_stats_update_end(&r_vec->rx_sync); - - dev_kfree_skb_any(skb); nn_warn_ratelimit(nn, "invalid RX packet metadata\n"); + nfp_net_rx_drop(r_vec, rx_ring, NULL, skb); continue; } } |