1195972f6Sopenharmony_ciFrom 39f06e9ef0929da16282b23ec606c3893f394b1e Mon Sep 17 00:00:00 2001 2195972f6Sopenharmony_ciFrom: jiangheng <jiangheng14@huawei.com> 3195972f6Sopenharmony_ciDate: Mon, 25 Sep 2023 15:23:51 +0800 4195972f6Sopenharmony_ciSubject: [PATCH] lstack_lwip: external api start with do_lwip_ prefix 5195972f6Sopenharmony_ci 6195972f6Sopenharmony_ci--- 7195972f6Sopenharmony_ci src/api/api_msg.c | 8 ++++---- 8195972f6Sopenharmony_ci src/api/sockets.c | 8 ++++---- 9195972f6Sopenharmony_ci src/core/pbuf.c | 4 ++-- 10195972f6Sopenharmony_ci src/core/tcp_out.c | 4 ++-- 11195972f6Sopenharmony_ci src/core/udp.c | 4 ++-- 12195972f6Sopenharmony_ci src/include/lwip/pbuf.h | 3 ++- 13195972f6Sopenharmony_ci src/include/lwipsock.h | 19 +++++++++++-------- 14195972f6Sopenharmony_ci 7 files changed, 27 insertions(+), 23 deletions(-) 15195972f6Sopenharmony_ci 16195972f6Sopenharmony_cidiff --git a/src/api/api_msg.c b/src/api/api_msg.c 17195972f6Sopenharmony_ciindex 869d6bc..3e982ab 100644 18195972f6Sopenharmony_ci--- a/src/api/api_msg.c 19195972f6Sopenharmony_ci+++ b/src/api/api_msg.c 20195972f6Sopenharmony_ci@@ -292,7 +292,7 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p, 21195972f6Sopenharmony_ci SYS_ARCH_INC(conn->recv_avail, len); 22195972f6Sopenharmony_ci #endif /* LWIP_SO_RCVBUF */ 23195972f6Sopenharmony_ci #if GAZELLE_UDP_ENABLE 24195972f6Sopenharmony_ci- add_recv_list(conn->socket); 25195972f6Sopenharmony_ci+ do_lwip_add_recvlist(conn->socket); 26195972f6Sopenharmony_ci LWIP_UNUSED_ARG(len); 27195972f6Sopenharmony_ci #else /* GAZELLE_UDP_ENABLE */ 28195972f6Sopenharmony_ci /* Register event with callback */ 29195972f6Sopenharmony_ci@@ -356,7 +356,7 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) 30195972f6Sopenharmony_ci SYS_ARCH_INC(conn->recv_avail, len); 31195972f6Sopenharmony_ci #endif /* LWIP_SO_RCVBUF */ 32195972f6Sopenharmony_ci #if GAZELLE_ENABLE 33195972f6Sopenharmony_ci- add_recv_list(conn->socket); 34195972f6Sopenharmony_ci+ do_lwip_add_recvlist(conn->socket); 35195972f6Sopenharmony_ci LWIP_UNUSED_ARG(len); 36195972f6Sopenharmony_ci #else 37195972f6Sopenharmony_ci /* Register event with callback */ 38195972f6Sopenharmony_ci@@ -492,7 +492,7 @@ err_tcp(void *arg, err_t err) 39195972f6Sopenharmony_ci /* use trypost to prevent deadlock */ 40195972f6Sopenharmony_ci sys_mbox_trypost(&conn->recvmbox, mbox_msg); 41195972f6Sopenharmony_ci #if GAZELLE_ENABLE 42195972f6Sopenharmony_ci- add_recv_list(conn->socket); 43195972f6Sopenharmony_ci+ do_lwip_add_recvlist(conn->socket); 44195972f6Sopenharmony_ci #endif 45195972f6Sopenharmony_ci } 46195972f6Sopenharmony_ci /* pass error message to acceptmbox to wake up pending accept */ 47195972f6Sopenharmony_ci@@ -1348,7 +1348,7 @@ lwip_netconn_do_connected(void *arg, struct tcp_pcb *pcb, err_t err) 48195972f6Sopenharmony_ci } 49195972f6Sopenharmony_ci 50195972f6Sopenharmony_ci #if GAZELLE_ENABLE 51195972f6Sopenharmony_ci- gazelle_connected_callback(conn); 52195972f6Sopenharmony_ci+ do_lwip_connected_callback(conn); 53195972f6Sopenharmony_ci #endif 54195972f6Sopenharmony_ci 55195972f6Sopenharmony_ci LWIP_ASSERT("conn->state == NETCONN_CONNECT", conn->state == NETCONN_CONNECT); 56195972f6Sopenharmony_cidiff --git a/src/api/sockets.c b/src/api/sockets.c 57195972f6Sopenharmony_ciindex f9b7a8f..8d573aa 100644 58195972f6Sopenharmony_ci--- a/src/api/sockets.c 59195972f6Sopenharmony_ci+++ b/src/api/sockets.c 60195972f6Sopenharmony_ci@@ -613,7 +613,7 @@ alloc_socket(struct netconn *newconn, int accepted, int flags) 61195972f6Sopenharmony_ci return i + LWIP_SOCKET_OFFSET; 62195972f6Sopenharmony_ci } else { 63195972f6Sopenharmony_ci lwip_close(i); 64195972f6Sopenharmony_ci- gazelle_clean_sock(i); 65195972f6Sopenharmony_ci+ do_lwip_clean_sock(i); 66195972f6Sopenharmony_ci } 67195972f6Sopenharmony_ci 68195972f6Sopenharmony_ci err: 69195972f6Sopenharmony_ci@@ -785,7 +785,7 @@ lwip_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) 70195972f6Sopenharmony_ci } 71195972f6Sopenharmony_ci #if GAZELLE_ENABLE 72195972f6Sopenharmony_ci LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < sockets_num + LWIP_SOCKET_OFFSET)); 73195972f6Sopenharmony_ci- gazelle_init_sock(newsock); 74195972f6Sopenharmony_ci+ do_lwip_init_sock(newsock); 75195972f6Sopenharmony_ci #else 76195972f6Sopenharmony_ci LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < NUM_SOCKETS + LWIP_SOCKET_OFFSET)); 77195972f6Sopenharmony_ci #endif /* GAZELLE_ENABLE */ 78195972f6Sopenharmony_ci@@ -1170,7 +1170,7 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags) 79195972f6Sopenharmony_ci lwip_recv_tcp_done: 80195972f6Sopenharmony_ci #else /* GAZELLE_ENABLE */ 81195972f6Sopenharmony_ci LWIP_UNUSED_ARG(recv_left); 82195972f6Sopenharmony_ci- recvd = read_lwip_data(sock, flags, apiflags); 83195972f6Sopenharmony_ci+ recvd = do_lwip_read_from_lwip(sock, flags, apiflags); 84195972f6Sopenharmony_ci if (recvd <= 0) { 85195972f6Sopenharmony_ci return recvd; 86195972f6Sopenharmony_ci } 87195972f6Sopenharmony_ci@@ -1369,7 +1369,7 @@ lwip_recvfrom_udp_raw(struct lwip_sock *sock, int flags, struct msghdr *msg, u16 88195972f6Sopenharmony_ci LWIP_UNUSED_ARG(err); 89195972f6Sopenharmony_ci LWIP_UNUSED_ARG(copied); 90195972f6Sopenharmony_ci LWIP_UNUSED_ARG(i); 91195972f6Sopenharmony_ci- buflen = read_lwip_data(sock, flags, apiflags); 92195972f6Sopenharmony_ci+ buflen = do_lwip_read_from_lwip(sock, flags, apiflags); 93195972f6Sopenharmony_ci if (buflen <= 0) { 94195972f6Sopenharmony_ci return ERR_BUF; 95195972f6Sopenharmony_ci } 96195972f6Sopenharmony_cidiff --git a/src/core/pbuf.c b/src/core/pbuf.c 97195972f6Sopenharmony_ciindex 8a55463..975e240 100644 98195972f6Sopenharmony_ci--- a/src/core/pbuf.c 99195972f6Sopenharmony_ci+++ b/src/core/pbuf.c 100195972f6Sopenharmony_ci@@ -288,7 +288,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type) 101195972f6Sopenharmony_ci /* If pbuf is to be allocated in RAM, allocate memory for it. */ 102195972f6Sopenharmony_ci #if GAZELLE_ENABLE 103195972f6Sopenharmony_ci /* alloc mbuf avoid send copy */ 104195972f6Sopenharmony_ci- p = lwip_alloc_pbuf(layer, length, type); 105195972f6Sopenharmony_ci+ p = do_lwip_alloc_pbuf(layer, length, type); 106195972f6Sopenharmony_ci #else 107195972f6Sopenharmony_ci p = (struct pbuf *)mem_malloc(alloc_len); 108195972f6Sopenharmony_ci if (p == NULL) { 109195972f6Sopenharmony_ci@@ -780,7 +780,7 @@ pbuf_free(struct pbuf *p) 110195972f6Sopenharmony_ci /* is this a custom pbuf? */ 111195972f6Sopenharmony_ci if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0) { 112195972f6Sopenharmony_ci #if GAZELLE_ENABLE 113195972f6Sopenharmony_ci- gazelle_free_pbuf(p); 114195972f6Sopenharmony_ci+ do_lwip_free_pbuf(p); 115195972f6Sopenharmony_ci #else 116195972f6Sopenharmony_ci struct pbuf_custom *pc = (struct pbuf_custom *)p; 117195972f6Sopenharmony_ci LWIP_ASSERT("pc->custom_free_function != NULL", pc->custom_free_function != NULL); 118195972f6Sopenharmony_cidiff --git a/src/core/tcp_out.c b/src/core/tcp_out.c 119195972f6Sopenharmony_ciindex 6250e6b..547d01e 100644 120195972f6Sopenharmony_ci--- a/src/core/tcp_out.c 121195972f6Sopenharmony_ci+++ b/src/core/tcp_out.c 122195972f6Sopenharmony_ci@@ -699,7 +699,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) 123195972f6Sopenharmony_ci pbuf_cat(p/*header*/, p2/*data*/); 124195972f6Sopenharmony_ci } 125195972f6Sopenharmony_ci #else /* GAZELLE_ENABLE */ 126195972f6Sopenharmony_ci- p = write_lwip_data((struct lwip_sock *)arg, len - pos, &apiflags); 127195972f6Sopenharmony_ci+ p = do_lwip_get_from_sendring((struct lwip_sock *)arg, len - pos, &apiflags); 128195972f6Sopenharmony_ci if (p == NULL) { 129195972f6Sopenharmony_ci break; 130195972f6Sopenharmony_ci } 131195972f6Sopenharmony_ci@@ -764,7 +764,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) 132195972f6Sopenharmony_ci 133195972f6Sopenharmony_ci pos += seglen; 134195972f6Sopenharmony_ci #if GAZELLE_ENABLE 135195972f6Sopenharmony_ci- write_lwip_over((struct lwip_sock*)arg); 136195972f6Sopenharmony_ci+ do_lwip_get_from_sendring_over((struct lwip_sock*)arg); 137195972f6Sopenharmony_ci #endif 138195972f6Sopenharmony_ci } 139195972f6Sopenharmony_ci 140195972f6Sopenharmony_cidiff --git a/src/core/udp.c b/src/core/udp.c 141195972f6Sopenharmony_ciindex d9db535..5c6dadb 100644 142195972f6Sopenharmony_ci--- a/src/core/udp.c 143195972f6Sopenharmony_ci+++ b/src/core/udp.c 144195972f6Sopenharmony_ci@@ -677,8 +677,8 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, 145195972f6Sopenharmony_ci #if GAZELLE_UDP_ENABLE 146195972f6Sopenharmony_ci uint8_t apiflags = 0; 147195972f6Sopenharmony_ci 148195972f6Sopenharmony_ci- struct pbuf *udp_pbuf = write_lwip_data((struct lwip_sock *)(p->payload), p->tot_len, &apiflags); 149195972f6Sopenharmony_ci- write_lwip_over((struct lwip_sock *)(p->payload)); 150195972f6Sopenharmony_ci+ struct pbuf *udp_pbuf = do_lwip_get_from_sendring((struct lwip_sock *)(p->payload), p->tot_len, &apiflags); 151195972f6Sopenharmony_ci+ do_lwip_get_from_sendring_over((struct lwip_sock *)(p->payload)); 152195972f6Sopenharmony_ci 153195972f6Sopenharmony_ci pbuf_free(p); 154195972f6Sopenharmony_ci p = udp_pbuf; 155195972f6Sopenharmony_cidiff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h 156195972f6Sopenharmony_ciindex 2639b37..e1f2e50 100644 157195972f6Sopenharmony_ci--- a/src/include/lwip/pbuf.h 158195972f6Sopenharmony_ci+++ b/src/include/lwip/pbuf.h 159195972f6Sopenharmony_ci@@ -300,7 +300,8 @@ void pbuf_free_ooseq(void); 160195972f6Sopenharmony_ci /* Initializes the pbuf module. This call is empty for now, but may not be in future. */ 161195972f6Sopenharmony_ci #define pbuf_init() 162195972f6Sopenharmony_ci #if GAZELLE_ENABLE 163195972f6Sopenharmony_ci-struct pbuf *lwip_alloc_pbuf(pbuf_layer layer, uint16_t length, pbuf_type type); 164195972f6Sopenharmony_ci+extern struct pbuf *do_lwip_alloc_pbuf(pbuf_layer layer, uint16_t length, pbuf_type type); 165195972f6Sopenharmony_ci+extern void do_lwip_free_pbuf(struct pbuf *pbuf); 166195972f6Sopenharmony_ci #endif 167195972f6Sopenharmony_ci struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type); 168195972f6Sopenharmony_ci struct pbuf *pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type); 169195972f6Sopenharmony_cidiff --git a/src/include/lwipsock.h b/src/include/lwipsock.h 170195972f6Sopenharmony_ciindex f8480c5..ccc8c43 100644 171195972f6Sopenharmony_ci--- a/src/include/lwipsock.h 172195972f6Sopenharmony_ci+++ b/src/include/lwipsock.h 173195972f6Sopenharmony_ci@@ -164,13 +164,17 @@ static inline unsigned same_node_ring_count(struct lwip_sock *sock) 174195972f6Sopenharmony_ci #if GAZELLE_ENABLE 175195972f6Sopenharmony_ci extern uint32_t sockets_num; 176195972f6Sopenharmony_ci extern struct lwip_sock *sockets; 177195972f6Sopenharmony_ci-extern void gazelle_connected_callback(struct netconn *conn); 178195972f6Sopenharmony_ci-extern void add_recv_list(int32_t fd); 179195972f6Sopenharmony_ci-extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags); 180195972f6Sopenharmony_ci-extern struct pbuf *write_lwip_data(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags); 181195972f6Sopenharmony_ci-extern void gazelle_init_sock(int32_t fd); 182195972f6Sopenharmony_ci-extern void gazelle_clean_sock(int32_t fd); 183195972f6Sopenharmony_ci-extern void write_lwip_over(struct lwip_sock *sock); 184195972f6Sopenharmony_ci+ 185195972f6Sopenharmony_ci+extern void do_lwip_init_sock(int32_t fd); 186195972f6Sopenharmony_ci+extern void do_lwip_clean_sock(int32_t fd); 187195972f6Sopenharmony_ci+extern void do_lwip_connected_callback(struct netconn *conn); 188195972f6Sopenharmony_ci+ 189195972f6Sopenharmony_ci+extern struct pbuf *do_lwip_get_from_sendring(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags); 190195972f6Sopenharmony_ci+extern void do_lwip_get_from_sendring_over(struct lwip_sock *sock); 191195972f6Sopenharmony_ci+extern ssize_t do_lwip_read_from_lwip(struct lwip_sock *sock, int32_t flags, u8_t apiflags); 192195972f6Sopenharmony_ci+ 193195972f6Sopenharmony_ci+extern void do_lwip_add_recvlist(int32_t fd); 194195972f6Sopenharmony_ci+ 195195972f6Sopenharmony_ci extern void netif_poll(struct netif *netif); 196195972f6Sopenharmony_ci extern err_t netif_loop_output(struct netif *netif, struct pbuf *p); 197195972f6Sopenharmony_ci extern err_t find_same_node_memzone(struct tcp_pcb *pcb, struct lwip_sock *nsock); 198195972f6Sopenharmony_ci@@ -178,7 +182,6 @@ extern err_t same_node_memzone_create(const struct rte_memzone **zone, int size, 199195972f6Sopenharmony_ci extern err_t same_node_ring_create(struct rte_ring **ring, int size, int port, char *name, char *rx); 200195972f6Sopenharmony_ci extern err_t create_same_node_ring(struct tcp_pcb *pcb); 201195972f6Sopenharmony_ci extern err_t find_same_node_ring(struct tcp_pcb *pcb); 202195972f6Sopenharmony_ci-extern void gazelle_free_pbuf(struct pbuf *pbuf); 203195972f6Sopenharmony_ci extern void lstack_calculate_aggregate(int type, uint32_t len); 204195972f6Sopenharmony_ci #endif /* GAZELLE_ENABLE */ 205195972f6Sopenharmony_ci 206195972f6Sopenharmony_ci-- 207195972f6Sopenharmony_ci2.27.0 208195972f6Sopenharmony_ci 209