1195972f6Sopenharmony_ciFrom 05bfdb54fc744d835c8b3b50b54d220fe7e87277 Mon Sep 17 00:00:00 2001
2195972f6Sopenharmony_ciFrom: wuchangsheng <wuchangsheng2@huawei.com>
3195972f6Sopenharmony_ciDate: Mon, 7 Mar 2022 21:10:06 +0800
4195972f6Sopenharmony_ciSubject: [PATCH] reduce copy in send
5195972f6Sopenharmony_ci
6195972f6Sopenharmony_ci---
7195972f6Sopenharmony_ci src/core/pbuf.c         | 5 +++++
8195972f6Sopenharmony_ci src/include/lwip/pbuf.h | 3 +++
9195972f6Sopenharmony_ci 2 files changed, 8 insertions(+)
10195972f6Sopenharmony_ci
11195972f6Sopenharmony_cidiff --git a/src/core/pbuf.c b/src/core/pbuf.c
12195972f6Sopenharmony_ciindex 27afc28..cd6b558 100644
13195972f6Sopenharmony_ci--- a/src/core/pbuf.c
14195972f6Sopenharmony_ci+++ b/src/core/pbuf.c
15195972f6Sopenharmony_ci@@ -281,6 +281,10 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
16195972f6Sopenharmony_ci       }
17195972f6Sopenharmony_ci 
18195972f6Sopenharmony_ci       /* If pbuf is to be allocated in RAM, allocate memory for it. */
19195972f6Sopenharmony_ci+#if USE_LIBOS
20195972f6Sopenharmony_ci+      /* alloc mbuf to reduce copy in sending */
21195972f6Sopenharmony_ci+      p = lwip_alloc_pbuf(layer, length, type);
22195972f6Sopenharmony_ci+#else
23195972f6Sopenharmony_ci       p = (struct pbuf *)mem_malloc(alloc_len);
24195972f6Sopenharmony_ci       if (p == NULL) {
25195972f6Sopenharmony_ci         return NULL;
26195972f6Sopenharmony_ci@@ -289,6 +293,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
27195972f6Sopenharmony_ci                              length, length, type, 0);
28195972f6Sopenharmony_ci       LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned",
29195972f6Sopenharmony_ci                   ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0);
30195972f6Sopenharmony_ci+#endif
31195972f6Sopenharmony_ci       break;
32195972f6Sopenharmony_ci     }
33195972f6Sopenharmony_ci     default:
34195972f6Sopenharmony_cidiff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h
35195972f6Sopenharmony_ciindex e5daf96..3894574 100644
36195972f6Sopenharmony_ci--- a/src/include/lwip/pbuf.h
37195972f6Sopenharmony_ci+++ b/src/include/lwip/pbuf.h
38195972f6Sopenharmony_ci@@ -272,6 +272,9 @@ void pbuf_free_ooseq(void);
39195972f6Sopenharmony_ci /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
40195972f6Sopenharmony_ci #define pbuf_init()
41195972f6Sopenharmony_ci 
42195972f6Sopenharmony_ci+#if USE_LIBOS
43195972f6Sopenharmony_ci+struct pbuf *lwip_alloc_pbuf(pbuf_layer l, u16_t length, pbuf_type type);
44195972f6Sopenharmony_ci+#endif
45195972f6Sopenharmony_ci struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
46195972f6Sopenharmony_ci struct pbuf *pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type);
47195972f6Sopenharmony_ci #if LWIP_SUPPORT_CUSTOM_PBUF
48195972f6Sopenharmony_ci-- 
49195972f6Sopenharmony_ci2.30.0
50195972f6Sopenharmony_ci
51