提交 82a71589 编写于 作者: Y Yunsheng Lin 提交者: Yang Yingliang

net: hns3: use napi_consume_skb() when cleaning tx desc

mainline inclusion
from mainline-v5.10-rc1
commit 619ae331
category: feature
bugzilla: NA
CVE: NA

----------------------------

Use napi_consume_skb() to batch consuming skb when cleaning
tx desc in NAPI polling.
Signed-off-by: NYunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NYonglong Liu <liuyonglong@huawei.com>
Reviewed-by: Nli yongxin <liyongxin1@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 0ece11e4
...@@ -2435,10 +2435,10 @@ static int hns3_alloc_buffer(struct hns3_enet_ring *ring, ...@@ -2435,10 +2435,10 @@ static int hns3_alloc_buffer(struct hns3_enet_ring *ring,
} }
static void hns3_free_buffer(struct hns3_enet_ring *ring, static void hns3_free_buffer(struct hns3_enet_ring *ring,
struct hns3_desc_cb *cb) struct hns3_desc_cb *cb, int budget)
{ {
if (cb->type == DESC_TYPE_SKB) if (cb->type == DESC_TYPE_SKB)
dev_kfree_skb_any((struct sk_buff *)cb->priv); napi_consume_skb(cb->priv, budget);
else if (!HNAE3_IS_TX_RING(ring) && cb->pagecnt_bias) else if (!HNAE3_IS_TX_RING(ring) && cb->pagecnt_bias)
__page_frag_cache_drain(cb->priv, cb->pagecnt_bias); __page_frag_cache_drain(cb->priv, cb->pagecnt_bias);
memset(cb, 0, sizeof(*cb)); memset(cb, 0, sizeof(*cb));
...@@ -2472,7 +2472,8 @@ static void hns3_buffer_detach(struct hns3_enet_ring *ring, int i) ...@@ -2472,7 +2472,8 @@ static void hns3_buffer_detach(struct hns3_enet_ring *ring, int i)
ring->desc[i].addr = 0; ring->desc[i].addr = 0;
} }
static void hns3_free_buffer_detach(struct hns3_enet_ring *ring, int i) static void hns3_free_buffer_detach(struct hns3_enet_ring *ring, int i,
int budget)
{ {
struct hns3_desc_cb *cb = &ring->desc_cb[i]; struct hns3_desc_cb *cb = &ring->desc_cb[i];
...@@ -2480,7 +2481,7 @@ static void hns3_free_buffer_detach(struct hns3_enet_ring *ring, int i) ...@@ -2480,7 +2481,7 @@ static void hns3_free_buffer_detach(struct hns3_enet_ring *ring, int i)
return; return;
hns3_buffer_detach(ring, i); hns3_buffer_detach(ring, i);
hns3_free_buffer(ring, cb); hns3_free_buffer(ring, cb, budget);
} }
static void hns3_free_buffers(struct hns3_enet_ring *ring) static void hns3_free_buffers(struct hns3_enet_ring *ring)
...@@ -2488,7 +2489,7 @@ static void hns3_free_buffers(struct hns3_enet_ring *ring) ...@@ -2488,7 +2489,7 @@ static void hns3_free_buffers(struct hns3_enet_ring *ring)
int i; int i;
for (i = 0; i < ring->desc_num; i++) for (i = 0; i < ring->desc_num; i++)
hns3_free_buffer_detach(ring, i); hns3_free_buffer_detach(ring, i, 0);
} }
/* free desc along with its attached buffer */ /* free desc along with its attached buffer */
...@@ -2533,7 +2534,7 @@ static int hns3_alloc_and_map_buffer(struct hns3_enet_ring *ring, ...@@ -2533,7 +2534,7 @@ static int hns3_alloc_and_map_buffer(struct hns3_enet_ring *ring,
return 0; return 0;
out_with_buf: out_with_buf:
hns3_free_buffer(ring, cb); hns3_free_buffer(ring, cb, 0);
out: out:
return ret; return ret;
} }
...@@ -2565,7 +2566,7 @@ static int hns3_alloc_ring_buffers(struct hns3_enet_ring *ring) ...@@ -2565,7 +2566,7 @@ static int hns3_alloc_ring_buffers(struct hns3_enet_ring *ring)
out_buffer_fail: out_buffer_fail:
for (j = i - 1; j >= 0; j--) for (j = i - 1; j >= 0; j--)
hns3_free_buffer_detach(ring, j); hns3_free_buffer_detach(ring, j, 0);
return ret; return ret;
} }
...@@ -2593,7 +2594,7 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i) ...@@ -2593,7 +2594,7 @@ static void hns3_reuse_buffer(struct hns3_enet_ring *ring, int i)
} }
static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring, static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring,
int *bytes, int *pkts) int *bytes, int *pkts, int budget)
{ {
/* pair with ring->last_to_use update in hns3_tx_doorbell(), /* pair with ring->last_to_use update in hns3_tx_doorbell(),
* smp_store_release() is not used in hns3_tx_doorbell() because * smp_store_release() is not used in hns3_tx_doorbell() because
...@@ -2616,7 +2617,7 @@ static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring, ...@@ -2616,7 +2617,7 @@ static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring,
(*pkts) += (desc_cb->type == DESC_TYPE_SKB); (*pkts) += (desc_cb->type == DESC_TYPE_SKB);
(*bytes) += desc_cb->length; (*bytes) += desc_cb->length;
/* desc_cb will be cleaned, after hnae3_free_buffer_detach */ /* desc_cb will be cleaned, after hnae3_free_buffer_detach */
hns3_free_buffer_detach(ring, ntc); hns3_free_buffer_detach(ring, ntc, budget);
if (++ntc == ring->desc_num) if (++ntc == ring->desc_num)
ntc = 0; ntc = 0;
...@@ -2636,7 +2637,7 @@ static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring, ...@@ -2636,7 +2637,7 @@ static bool hns3_nic_reclaim_desc(struct hns3_enet_ring *ring,
return true; return true;
} }
void hns3_clean_tx_ring(struct hns3_enet_ring *ring) void hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget)
{ {
struct net_device *netdev = ring_to_netdev(ring); struct net_device *netdev = ring_to_netdev(ring);
struct hns3_nic_priv *priv = netdev_priv(netdev); struct hns3_nic_priv *priv = netdev_priv(netdev);
...@@ -2646,7 +2647,7 @@ void hns3_clean_tx_ring(struct hns3_enet_ring *ring) ...@@ -2646,7 +2647,7 @@ void hns3_clean_tx_ring(struct hns3_enet_ring *ring)
bytes = 0; bytes = 0;
pkts = 0; pkts = 0;
if (unlikely(!hns3_nic_reclaim_desc(ring, &bytes, &pkts))) if (unlikely(!hns3_nic_reclaim_desc(ring, &bytes, &pkts, budget)))
return; return;
ring->tqp_vector->tx_group.total_bytes += bytes; ring->tqp_vector->tx_group.total_bytes += bytes;
...@@ -3456,7 +3457,7 @@ static int hns3_nic_common_poll(struct napi_struct *napi, int budget) ...@@ -3456,7 +3457,7 @@ static int hns3_nic_common_poll(struct napi_struct *napi, int budget)
* budget and be more aggressive about cleaning up the Tx descriptors. * budget and be more aggressive about cleaning up the Tx descriptors.
*/ */
hns3_for_each_ring(ring, tqp_vector->tx_group) hns3_for_each_ring(ring, tqp_vector->tx_group)
hns3_clean_tx_ring(ring); hns3_clean_tx_ring(ring, budget);
/* make sure rx ring budget not smaller than 1 */ /* make sure rx ring budget not smaller than 1 */
if (tqp_vector->num_tqps > 1) if (tqp_vector->num_tqps > 1)
...@@ -4303,7 +4304,7 @@ static void hns3_clear_tx_ring(struct hns3_enet_ring *ring) ...@@ -4303,7 +4304,7 @@ static void hns3_clear_tx_ring(struct hns3_enet_ring *ring)
{ {
while (ring->next_to_clean != ring->next_to_use) { while (ring->next_to_clean != ring->next_to_use) {
ring->desc[ring->next_to_clean].tx.bdtp_fe_sc_vld_ra_ri = 0; ring->desc[ring->next_to_clean].tx.bdtp_fe_sc_vld_ra_ri = 0;
hns3_free_buffer_detach(ring, ring->next_to_clean); hns3_free_buffer_detach(ring, ring->next_to_clean, 0);
ring_ptr_move_fw(ring, next_to_clean); ring_ptr_move_fw(ring, next_to_clean);
} }
......
...@@ -625,7 +625,7 @@ void hns3_ethtool_set_ops(struct net_device *netdev); ...@@ -625,7 +625,7 @@ void hns3_ethtool_set_ops(struct net_device *netdev);
int hns3_set_channels(struct net_device *netdev, int hns3_set_channels(struct net_device *netdev,
struct ethtool_channels *ch); struct ethtool_channels *ch);
void hns3_clean_tx_ring(struct hns3_enet_ring *ring); void hns3_clean_tx_ring(struct hns3_enet_ring *ring, int budget);
int hns3_init_all_ring(struct hns3_nic_priv *priv); int hns3_init_all_ring(struct hns3_nic_priv *priv);
int hns3_uninit_all_ring(struct hns3_nic_priv *priv); int hns3_uninit_all_ring(struct hns3_nic_priv *priv);
int hns3_nic_reset_all_ring(struct hnae3_handle *h); int hns3_nic_reset_all_ring(struct hnae3_handle *h);
......
...@@ -240,7 +240,7 @@ static void hns3_lb_clear_tx_ring(struct hns3_nic_priv *priv, u32 start_ringid, ...@@ -240,7 +240,7 @@ static void hns3_lb_clear_tx_ring(struct hns3_nic_priv *priv, u32 start_ringid,
for (i = start_ringid; i <= end_ringid; i++) { for (i = start_ringid; i <= end_ringid; i++) {
struct hns3_enet_ring *ring = &priv->ring[i]; struct hns3_enet_ring *ring = &priv->ring[i];
hns3_clean_tx_ring(ring); hns3_clean_tx_ring(ring, 0);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册