95 lines
3.9 KiB
Diff
95 lines
3.9 KiB
Diff
From aacafde3598f8e9ec4e9fd13a17ce9d0a23c3fe5 Mon Sep 17 00:00:00 2001
|
|
From: jiangheng <jiangheng14@huawei.com>
|
|
Date: Sat, 17 Dec 2022 20:33:16 +0800
|
|
Subject: [PATCH] remove mbuf reserve in mbuf alloc
|
|
|
|
---
|
|
src/lstack/core/lstack_dpdk.c | 9 ---------
|
|
src/lstack/core/lstack_lwip.c | 10 +++++-----
|
|
src/lstack/include/lstack_dpdk.h | 1 -
|
|
3 files changed, 5 insertions(+), 15 deletions(-)
|
|
|
|
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
|
|
index 4be31c3..76ebe96 100644
|
|
--- a/src/lstack/core/lstack_dpdk.c
|
|
+++ b/src/lstack/core/lstack_dpdk.c
|
|
@@ -194,15 +194,6 @@ int32_t pktmbuf_pool_init(struct protocol_stack *stack, uint16_t stack_num)
|
|
return 0;
|
|
}
|
|
|
|
-int32_t gazelle_alloc_mbuf_with_reserve(struct rte_mempool *pool, struct rte_mbuf **mbufs, unsigned count)
|
|
-{
|
|
- if (rte_mempool_avail_count(pool) < RESERVE_NIC_RECV) {
|
|
- return -1;
|
|
- }
|
|
-
|
|
- return rte_pktmbuf_alloc_bulk(pool, mbufs, count);
|
|
-}
|
|
-
|
|
struct rte_ring *create_ring(const char *name, uint32_t count, uint32_t flags, int32_t queue_id)
|
|
{
|
|
char ring_name[RTE_RING_NAMESIZE] = {0};
|
|
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
|
|
index d4e2d9c..c04ed27 100644
|
|
--- a/src/lstack/core/lstack_lwip.c
|
|
+++ b/src/lstack/core/lstack_lwip.c
|
|
@@ -134,7 +134,7 @@ static bool replenish_send_idlembuf(struct protocol_stack *stack, struct rte_rin
|
|
return false;
|
|
}
|
|
|
|
- if (gazelle_alloc_mbuf_with_reserve(stack->rxtx_pktmbuf_pool, (struct rte_mbuf **)pbuf, replenish_cnt) != 0) {
|
|
+ if (rte_pktmbuf_alloc_bulk(stack->rxtx_pktmbuf_pool, (struct rte_mbuf **)pbuf, replenish_cnt) != 0) {
|
|
stack->stats.tx_allocmbuf_fail++;
|
|
return true;
|
|
}
|
|
@@ -225,7 +225,7 @@ int32_t gazelle_alloc_pktmbuf(struct rte_mempool *pool, struct rte_mbuf **mbufs,
|
|
{
|
|
struct pbuf_custom *pbuf_custom = NULL;
|
|
|
|
- int32_t ret = gazelle_alloc_mbuf_with_reserve(pool, mbufs, num);
|
|
+ int32_t ret = rte_pktmbuf_alloc_bulk(pool, mbufs, num);
|
|
if (ret != 0) {
|
|
return ret;
|
|
}
|
|
@@ -243,7 +243,7 @@ struct pbuf *lwip_alloc_pbuf(pbuf_layer layer, uint16_t length, pbuf_type type)
|
|
struct rte_mbuf *mbuf;
|
|
struct protocol_stack *stack = get_protocol_stack();
|
|
|
|
- if (gazelle_alloc_mbuf_with_reserve(stack->rxtx_pktmbuf_pool, &mbuf, 1) != 0) {
|
|
+ if (rte_pktmbuf_alloc_bulk(stack->rxtx_pktmbuf_pool, &mbuf, 1) != 0) {
|
|
stack->stats.tx_allocmbuf_fail++;
|
|
return NULL;
|
|
}
|
|
@@ -353,7 +353,7 @@ static inline ssize_t app_direct_write(struct protocol_stack *stack, struct lwip
|
|
}
|
|
|
|
/* first pbuf get from send_ring. and malloc pbufs attach to first pbuf */
|
|
- if (gazelle_alloc_mbuf_with_reserve(stack->rxtx_pktmbuf_pool, (struct rte_mbuf **)&pbufs[1], write_num - 1) != 0) {
|
|
+ if (rte_pktmbuf_alloc_bulk(stack->rxtx_pktmbuf_pool, (struct rte_mbuf **)&pbufs[1], write_num - 1) != 0) {
|
|
stack->stats.tx_allocmbuf_fail++;
|
|
free(pbufs);
|
|
return 0;
|
|
@@ -389,7 +389,7 @@ static inline ssize_t app_direct_attach(struct protocol_stack *stack, struct pbu
|
|
}
|
|
|
|
/* first pbuf get from send_ring. and malloc pbufs attach to first pbuf */
|
|
- if (gazelle_alloc_mbuf_with_reserve(stack->rxtx_pktmbuf_pool, (struct rte_mbuf **)pbufs, write_num) != 0) {
|
|
+ if (rte_pktmbuf_alloc_bulk(stack->rxtx_pktmbuf_pool, (struct rte_mbuf **)pbufs, write_num) != 0) {
|
|
stack->stats.tx_allocmbuf_fail++;
|
|
free(pbufs);
|
|
return 0;
|
|
diff --git a/src/lstack/include/lstack_dpdk.h b/src/lstack/include/lstack_dpdk.h
|
|
index a0f09af..c3bc527 100644
|
|
--- a/src/lstack/include/lstack_dpdk.h
|
|
+++ b/src/lstack/include/lstack_dpdk.h
|
|
@@ -51,6 +51,5 @@ void dpdk_skip_nic_init(void);
|
|
int32_t dpdk_init_lstack_kni(void);
|
|
void dpdk_restore_pci(void);
|
|
bool port_in_stack_queue(uint32_t src_ip, uint32_t dst_ip, uint16_t src_port, uint16_t dst_port);
|
|
-int32_t gazelle_alloc_mbuf_with_reserve(struct rte_mempool *pool, struct rte_mbuf **mbufs, unsigned count);
|
|
|
|
#endif /* GAZELLE_DPDK_H */
|
|
--
|
|
2.23.0
|
|
|