From 39f06e9ef0929da16282b23ec606c3893f394b1e Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Mon, 25 Sep 2023 15:23:51 +0800
Subject: [PATCH] lstack_lwip: external api start with do_lwip_ prefix

---
 src/api/api_msg.c       |  8 ++++----
 src/api/sockets.c       |  8 ++++----
 src/core/pbuf.c         |  4 ++--
 src/core/tcp_out.c      |  4 ++--
 src/core/udp.c          |  4 ++--
 src/include/lwip/pbuf.h |  3 ++-
 src/include/lwipsock.h  | 19 +++++++++++--------
 7 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/src/api/api_msg.c b/src/api/api_msg.c
index 869d6bc..3e982ab 100644
--- a/src/api/api_msg.c
+++ b/src/api/api_msg.c
@@ -292,7 +292,7 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
     SYS_ARCH_INC(conn->recv_avail, len);
 #endif /* LWIP_SO_RCVBUF */
 #if GAZELLE_UDP_ENABLE
-    add_recv_list(conn->socket);
+    do_lwip_add_recvlist(conn->socket);
     LWIP_UNUSED_ARG(len);
 #else /* GAZELLE_UDP_ENABLE */
     /* Register event with callback */
@@ -356,7 +356,7 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
     SYS_ARCH_INC(conn->recv_avail, len);
 #endif /* LWIP_SO_RCVBUF */
 #if GAZELLE_ENABLE
-    add_recv_list(conn->socket);
+    do_lwip_add_recvlist(conn->socket);
     LWIP_UNUSED_ARG(len);
 #else
     /* Register event with callback */
@@ -492,7 +492,7 @@ err_tcp(void *arg, err_t err)
     /* use trypost to prevent deadlock */
     sys_mbox_trypost(&conn->recvmbox, mbox_msg);
 #if GAZELLE_ENABLE
-    add_recv_list(conn->socket);
+    do_lwip_add_recvlist(conn->socket);
 #endif
   }
   /* pass error message to acceptmbox to wake up pending accept */
@@ -1348,7 +1348,7 @@ lwip_netconn_do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
   }
 
 #if GAZELLE_ENABLE
-  gazelle_connected_callback(conn);
+  do_lwip_connected_callback(conn);
 #endif
 
   LWIP_ASSERT("conn->state == NETCONN_CONNECT", conn->state == NETCONN_CONNECT);
diff --git a/src/api/sockets.c b/src/api/sockets.c
index f9b7a8f..8d573aa 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -613,7 +613,7 @@ alloc_socket(struct netconn *newconn, int accepted, int flags)
     return i + LWIP_SOCKET_OFFSET;
   } else {
     lwip_close(i);
-    gazelle_clean_sock(i);
+    do_lwip_clean_sock(i);
   }
 
 err:
@@ -785,7 +785,7 @@ lwip_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
   }
 #if GAZELLE_ENABLE
   LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < sockets_num + LWIP_SOCKET_OFFSET));
-  gazelle_init_sock(newsock);
+  do_lwip_init_sock(newsock);
 #else
   LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < NUM_SOCKETS + LWIP_SOCKET_OFFSET));
 #endif /* GAZELLE_ENABLE */
@@ -1170,7 +1170,7 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
 lwip_recv_tcp_done:
 #else /* GAZELLE_ENABLE */
   LWIP_UNUSED_ARG(recv_left);
-  recvd = read_lwip_data(sock, flags, apiflags);
+  recvd = do_lwip_read_from_lwip(sock, flags, apiflags);
   if (recvd <= 0) {
     return recvd;
   }
@@ -1369,7 +1369,7 @@ lwip_recvfrom_udp_raw(struct lwip_sock *sock, int flags, struct msghdr *msg, u16
   LWIP_UNUSED_ARG(err);
   LWIP_UNUSED_ARG(copied);
   LWIP_UNUSED_ARG(i);
-  buflen = read_lwip_data(sock, flags, apiflags);
+  buflen = do_lwip_read_from_lwip(sock, flags, apiflags);
   if (buflen <= 0) {
     return ERR_BUF;
   }
diff --git a/src/core/pbuf.c b/src/core/pbuf.c
index 8a55463..975e240 100644
--- a/src/core/pbuf.c
+++ b/src/core/pbuf.c
@@ -288,7 +288,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
       /* If pbuf is to be allocated in RAM, allocate memory for it. */
 #if GAZELLE_ENABLE
       /* alloc mbuf avoid send copy */
-      p = lwip_alloc_pbuf(layer, length, type);
+      p = do_lwip_alloc_pbuf(layer, length, type);
 #else
       p = (struct pbuf *)mem_malloc(alloc_len);
       if (p == NULL) {
@@ -780,7 +780,7 @@ pbuf_free(struct pbuf *p)
       /* is this a custom pbuf? */
       if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0) {
 #if GAZELLE_ENABLE
-        gazelle_free_pbuf(p);
+        do_lwip_free_pbuf(p);
 #else
         struct pbuf_custom *pc = (struct pbuf_custom *)p;
         LWIP_ASSERT("pc->custom_free_function != NULL", pc->custom_free_function != NULL);
diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
index 6250e6b..547d01e 100644
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -699,7 +699,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
       pbuf_cat(p/*header*/, p2/*data*/);
     }
 #else  /* GAZELLE_ENABLE */
-    p = write_lwip_data((struct lwip_sock *)arg, len - pos, &apiflags);
+    p = do_lwip_get_from_sendring((struct lwip_sock *)arg, len - pos, &apiflags);
     if (p == NULL) {
       break;
     }
@@ -764,7 +764,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
 
     pos += seglen;
 #if GAZELLE_ENABLE
-    write_lwip_over((struct lwip_sock*)arg);
+    do_lwip_get_from_sendring_over((struct lwip_sock*)arg);
 #endif
   }
 
diff --git a/src/core/udp.c b/src/core/udp.c
index d9db535..5c6dadb 100644
--- a/src/core/udp.c
+++ b/src/core/udp.c
@@ -677,8 +677,8 @@ udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
 #if GAZELLE_UDP_ENABLE
   uint8_t apiflags = 0;
 
-  struct pbuf *udp_pbuf = write_lwip_data((struct lwip_sock *)(p->payload), p->tot_len, &apiflags);
-  write_lwip_over((struct lwip_sock *)(p->payload));
+  struct pbuf *udp_pbuf = do_lwip_get_from_sendring((struct lwip_sock *)(p->payload), p->tot_len, &apiflags);
+  do_lwip_get_from_sendring_over((struct lwip_sock *)(p->payload));
 
   pbuf_free(p);
   p = udp_pbuf;
diff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h
index 2639b37..e1f2e50 100644
--- a/src/include/lwip/pbuf.h
+++ b/src/include/lwip/pbuf.h
@@ -300,7 +300,8 @@ void pbuf_free_ooseq(void);
 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
 #define pbuf_init()
 #if GAZELLE_ENABLE
-struct pbuf *lwip_alloc_pbuf(pbuf_layer layer, uint16_t length, pbuf_type type);
+extern struct pbuf *do_lwip_alloc_pbuf(pbuf_layer layer, uint16_t length, pbuf_type type);
+extern void do_lwip_free_pbuf(struct pbuf *pbuf);
 #endif
 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
 struct pbuf *pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type);
diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
index f8480c5..ccc8c43 100644
--- a/src/include/lwipsock.h
+++ b/src/include/lwipsock.h
@@ -164,13 +164,17 @@ static inline unsigned same_node_ring_count(struct lwip_sock *sock)
 #if GAZELLE_ENABLE
 extern uint32_t sockets_num;
 extern struct lwip_sock *sockets;
-extern void gazelle_connected_callback(struct netconn *conn);
-extern void add_recv_list(int32_t fd);
-extern ssize_t read_lwip_data(struct lwip_sock *sock, int32_t flags, u8_t apiflags);
-extern struct pbuf *write_lwip_data(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags);
-extern void gazelle_init_sock(int32_t fd);
-extern void gazelle_clean_sock(int32_t fd);
-extern void write_lwip_over(struct lwip_sock *sock);
+
+extern void do_lwip_init_sock(int32_t fd);
+extern void do_lwip_clean_sock(int32_t fd);
+extern void do_lwip_connected_callback(struct netconn *conn);
+
+extern struct pbuf *do_lwip_get_from_sendring(struct lwip_sock *sock, uint16_t remain_size, uint8_t *apiflags);
+extern void do_lwip_get_from_sendring_over(struct lwip_sock *sock);
+extern ssize_t do_lwip_read_from_lwip(struct lwip_sock *sock, int32_t flags, u8_t apiflags);
+
+extern void do_lwip_add_recvlist(int32_t fd);
+
 extern void netif_poll(struct netif *netif);
 extern err_t netif_loop_output(struct netif *netif, struct pbuf *p);
 extern err_t find_same_node_memzone(struct tcp_pcb *pcb, struct lwip_sock *nsock);
@@ -178,7 +182,6 @@ extern err_t same_node_memzone_create(const struct rte_memzone **zone, int size,
 extern err_t same_node_ring_create(struct rte_ring **ring, int size, int port, char *name, char *rx);
 extern err_t create_same_node_ring(struct tcp_pcb *pcb);
 extern err_t find_same_node_ring(struct tcp_pcb *pcb);
-extern void gazelle_free_pbuf(struct pbuf *pbuf);
 extern void lstack_calculate_aggregate(int type, uint32_t len);
 #endif /* GAZELLE_ENABLE */
 
-- 
2.27.0

