Commit 4265114d authored by Netanel Belgazal's avatar Netanel Belgazal Committed by David S. Miller

net: ena: separate skb allocation to dedicated function

Signed-off-by: default avatarNetanel Belgazal <netanel@amazon.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e745dafa
...@@ -825,6 +825,28 @@ static int ena_clean_tx_irq(struct ena_ring *tx_ring, u32 budget) ...@@ -825,6 +825,28 @@ static int ena_clean_tx_irq(struct ena_ring *tx_ring, u32 budget)
return tx_pkts; return tx_pkts;
} }
static struct sk_buff *ena_alloc_skb(struct ena_ring *rx_ring, bool frags)
{
struct sk_buff *skb;
if (frags)
skb = napi_get_frags(rx_ring->napi);
else
skb = netdev_alloc_skb_ip_align(rx_ring->netdev,
rx_ring->rx_copybreak);
if (unlikely(!skb)) {
u64_stats_update_begin(&rx_ring->syncp);
rx_ring->rx_stats.skb_alloc_fail++;
u64_stats_update_end(&rx_ring->syncp);
netif_dbg(rx_ring->adapter, rx_err, rx_ring->netdev,
"Failed to allocate skb. frags: %d\n", frags);
return NULL;
}
return skb;
}
static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring, static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
struct ena_com_rx_buf_info *ena_bufs, struct ena_com_rx_buf_info *ena_bufs,
u32 descs, u32 descs,
...@@ -854,16 +876,9 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring, ...@@ -854,16 +876,9 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
prefetch(va + NET_IP_ALIGN); prefetch(va + NET_IP_ALIGN);
if (len <= rx_ring->rx_copybreak) { if (len <= rx_ring->rx_copybreak) {
skb = netdev_alloc_skb_ip_align(rx_ring->netdev, skb = ena_alloc_skb(rx_ring, false);
rx_ring->rx_copybreak); if (unlikely(!skb))
if (unlikely(!skb)) {
u64_stats_update_begin(&rx_ring->syncp);
rx_ring->rx_stats.skb_alloc_fail++;
u64_stats_update_end(&rx_ring->syncp);
netif_err(rx_ring->adapter, rx_err, rx_ring->netdev,
"Failed to allocate skb\n");
return NULL; return NULL;
}
netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev, netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev,
"rx allocated small packet. len %d. data_len %d\n", "rx allocated small packet. len %d. data_len %d\n",
...@@ -882,20 +897,15 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring, ...@@ -882,20 +897,15 @@ static struct sk_buff *ena_rx_skb(struct ena_ring *rx_ring,
skb_put(skb, len); skb_put(skb, len);
skb->protocol = eth_type_trans(skb, rx_ring->netdev); skb->protocol = eth_type_trans(skb, rx_ring->netdev);
rx_ring->free_rx_ids[*next_to_clean] = req_id;
*next_to_clean = ENA_RX_RING_IDX_ADD(*next_to_clean, descs, *next_to_clean = ENA_RX_RING_IDX_ADD(*next_to_clean, descs,
rx_ring->ring_size); rx_ring->ring_size);
return skb; return skb;
} }
skb = napi_get_frags(rx_ring->napi); skb = ena_alloc_skb(rx_ring, true);
if (unlikely(!skb)) { if (unlikely(!skb))
netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev,
"Failed allocating skb\n");
u64_stats_update_begin(&rx_ring->syncp);
rx_ring->rx_stats.skb_alloc_fail++;
u64_stats_update_end(&rx_ring->syncp);
return NULL; return NULL;
}
do { do {
dma_unmap_page(rx_ring->dev, dma_unmap_page(rx_ring->dev,
......
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