• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From 05bfdb54fc744d835c8b3b50b54d220fe7e87277 Mon Sep 17 00:00:00 2001
2From: wuchangsheng <wuchangsheng2@huawei.com>
3Date: Mon, 7 Mar 2022 21:10:06 +0800
4Subject: [PATCH] reduce copy in send
5
6---
7 src/core/pbuf.c         | 5 +++++
8 src/include/lwip/pbuf.h | 3 +++
9 2 files changed, 8 insertions(+)
10
11diff --git a/src/core/pbuf.c b/src/core/pbuf.c
12index 27afc28..cd6b558 100644
13--- a/src/core/pbuf.c
14+++ b/src/core/pbuf.c
15@@ -281,6 +281,10 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
16       }
17
18       /* If pbuf is to be allocated in RAM, allocate memory for it. */
19+#if USE_LIBOS
20+      /* alloc mbuf to reduce copy in sending */
21+      p = lwip_alloc_pbuf(layer, length, type);
22+#else
23       p = (struct pbuf *)mem_malloc(alloc_len);
24       if (p == NULL) {
25         return NULL;
26@@ -289,6 +293,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
27                              length, length, type, 0);
28       LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned",
29                   ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0);
30+#endif
31       break;
32     }
33     default:
34diff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h
35index e5daf96..3894574 100644
36--- a/src/include/lwip/pbuf.h
37+++ b/src/include/lwip/pbuf.h
38@@ -272,6 +272,9 @@ void pbuf_free_ooseq(void);
39 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
40 #define pbuf_init()
41
42+#if USE_LIBOS
43+struct pbuf *lwip_alloc_pbuf(pbuf_layer l, u16_t length, pbuf_type type);
44+#endif
45 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
46 struct pbuf *pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type);
47 #if LWIP_SUPPORT_CUSTOM_PBUF
48--
492.30.0
50
51