• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From b42299206a917ed5876c27617de59fb71f8437a7 Mon Sep 17 00:00:00 2001
2From: Lemmy Huang <huangliming5@huawei.com>
3Date: Thu, 9 Mar 2023 10:57:16 +0800
4Subject: [PATCH] cleancode: improve lwipopts.h readability
5
6Signed-off-by: Lemmy Huang <huangliming5@huawei.com>
7---
8 src/api/api_msg.c                |  12 +-
9 src/api/sockets.c                |  66 ++++-----
10 src/api/tcpip.c                  |  18 +--
11 src/core/ipv4/etharp.c           |   4 +-
12 src/core/ipv4/icmp.c             |   2 +-
13 src/core/ipv4/ip4.c              |   6 +-
14 src/core/ipv4/ip4_frag.c         |   4 +-
15 src/core/memp.c                  |   4 +-
16 src/core/pbuf.c                  |   8 +-
17 src/core/tcp.c                   |  66 ++++-----
18 src/core/tcp_in.c                |  46 +++---
19 src/core/tcp_out.c               |  36 ++---
20 src/core/timeouts.c              |   4 +-
21 src/include/arch/sys_arch.h      |   2 +-
22 src/include/dpdk_cksum.h         |   4 +-
23 src/include/hlist.h              |   4 +-
24 src/include/lwip/api.h           |  10 +-
25 src/include/lwip/ip.h            |   4 +-
26 src/include/lwip/memp.h          |  10 +-
27 src/include/lwip/opt.h           |   8 +-
28 src/include/lwip/pbuf.h          |   6 +-
29 src/include/lwip/priv/memp_std.h |   4 +-
30 src/include/lwip/priv/tcp_priv.h |  24 ++--
31 src/include/lwip/sockets.h       |  30 ++--
32 src/include/lwip/tcp.h           |  16 +--
33 src/include/lwip/timeouts.h      |   4 +-
34 src/include/lwiplog.h            |   4 +-
35 src/include/lwipopts.h           | 240 +++++++++++++++++--------------
36 src/include/lwipsock.h           |   8 +-
37 src/netif/ethernet.c             |   2 +-
38 30 files changed, 339 insertions(+), 317 deletions(-)
39
40diff --git a/src/api/api_msg.c b/src/api/api_msg.c
41index 3a4a473..1840c9d 100644
42--- a/src/api/api_msg.c
43+++ b/src/api/api_msg.c
44@@ -54,7 +54,7 @@
45 #include "lwip/mld6.h"
46 #include "lwip/priv/tcpip_priv.h"
47
48-#if USE_LIBOS
49+#if GAZELLE_ENABLE
50 #include "lwip/sockets.h"
51 #include "lwipsock.h"
52 #include "posix_api.h"
53@@ -341,7 +341,7 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
54 #if LWIP_SO_RCVBUF
55     SYS_ARCH_INC(conn->recv_avail, len);
56 #endif /* LWIP_SO_RCVBUF */
57-#if USE_LIBOS
58+#if GAZELLE_ENABLE
59     add_recv_list(conn->socket);
60     LWIP_UNUSED_ARG(len);
61 #else
62@@ -477,7 +477,7 @@ err_tcp(void *arg, err_t err)
63   if (NETCONN_MBOX_VALID(conn, &conn->recvmbox)) {
64     /* use trypost to prevent deadlock */
65     sys_mbox_trypost(&conn->recvmbox, mbox_msg);
66-#if USE_LIBOS
67+#if GAZELLE_ENABLE
68     add_recv_list(conn->socket);
69 #endif
70   }
71@@ -609,7 +609,7 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
72     API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0);
73   }
74
75-#if USE_LIBOS
76+#if GAZELLE_ENABLE
77   LWIP_DEBUGF(API_MSG_DEBUG, ("libos incoming connection established\n"));
78   SET_CONN_TYPE_LIBOS(newconn);
79 #endif
80@@ -1333,7 +1333,7 @@ lwip_netconn_do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
81     return ERR_VAL;
82   }
83
84-#if USE_LIBOS
85+#if GAZELLE_ENABLE
86   gazelle_connected_callback(conn);
87 #endif
88
89@@ -1738,7 +1738,7 @@ lwip_netconn_do_writemore(struct netconn *conn  WRITE_DELAYED_PARAM)
90       } else {
91         write_more = 0;
92       }
93-#if USE_LIBOS
94+#if GAZELLE_ENABLE
95       /* vector->ptr is private arg sock */
96       LWIP_UNUSED_ARG(dataptr);
97       write_more = 0;
98diff --git a/src/api/sockets.c b/src/api/sockets.c
99index 2cb6f22..356e345 100644
100--- a/src/api/sockets.c
101+++ b/src/api/sockets.c
102@@ -62,7 +62,7 @@
103 #include <stdarg.h>
104 #endif
105
106-#if USE_LIBOS
107+#if GAZELLE_ENABLE
108 #include <stdarg.h>
109 #include "lwipsock.h"
110 #include "posix_api.h"
111@@ -92,7 +92,7 @@
112 #define API_SELECT_CB_VAR_FREE(name)              API_VAR_FREE(MEMP_SELECT_CB, name)
113
114 #if LWIP_IPV4
115-#if USE_LIBOS
116+#if GAZELLE_ENABLE
117 #define IP4ADDR_PORT_TO_SOCKADDR(sin, ipaddr, port) do { \
118       (sin)->sin_family = AF_INET; \
119       (sin)->sin_port = lwip_htons((port)); \
120@@ -105,7 +105,7 @@
121       (sin)->sin_port = lwip_htons((port)); \
122       inet_addr_from_ip4addr(&(sin)->sin_addr, ipaddr); \
123       memset((sin)->sin_zero, 0, SIN_ZERO_LEN); }while(0)
124-#endif /* USE_LIBOS */
125+#endif /* GAZELLE_ENABLE */
126 #define SOCKADDR4_TO_IP4ADDR_PORT(sin, ipaddr, port) do { \
127     inet_addr_to_ip4addr(ip_2_ip4(ipaddr), &((sin)->sin_addr)); \
128     (port) = lwip_ntohs((sin)->sin_port); }while(0)
129@@ -271,12 +271,12 @@ static void lwip_socket_drop_registered_mld6_memberships(int s);
130 #endif /* LWIP_IPV6_MLD */
131
132 /** The global array of available sockets */
133-#if USE_LIBOS
134+#if GAZELLE_ENABLE
135 uint32_t sockets_num;
136 struct lwip_sock *sockets;
137 #else
138 static struct lwip_sock sockets[NUM_SOCKETS];
139-#endif /* USE_LIBOS */
140+#endif /* GAZELLE_ENABLE */
141
142 #if LWIP_SOCKET_SELECT || LWIP_SOCKET_POLL
143 #if LWIP_TCPIP_CORE_LOCKING
144@@ -431,11 +431,11 @@ tryget_socket_unconn_nouse(int fd)
145 {
146   int s = fd - LWIP_SOCKET_OFFSET;
147
148-#if USE_LIBOS
149+#if GAZELLE_ENABLE
150   if ((s < 0) || (s >= sockets_num))
151 #else
152   if ((s < 0) || (s >= NUM_SOCKETS))
153-#endif /* USE_LIBOS */
154+#endif /* GAZELLE_ENABLE */
155   {
156     LWIP_DEBUGF(SOCKETS_DEBUG, ("tryget_socket_unconn(%d): invalid\n", fd));
157     return NULL;
158@@ -500,13 +500,13 @@ tryget_socket(int fd)
159  * @param fd externally used socket index
160  * @return struct lwip_sock for the socket or NULL if not found
161  */
162-#if USE_LIBOS
163+#if GAZELLE_ENABLE
164 struct lwip_sock *
165 get_socket(int fd)
166 #else
167 static struct lwip_sock *
168 get_socket(int fd)
169-#endif /* USE_LIBOS */
170+#endif /* GAZELLE_ENABLE */
171 {
172   struct lwip_sock *sock = tryget_socket(fd);
173   if (!sock) {
174@@ -519,7 +519,7 @@ get_socket(int fd)
175   return sock;
176 }
177
178-#if USE_LIBOS
179+#if GAZELLE_ENABLE
180 /**
181  * Map a externally used socket index to the internal socket representation.
182  *
183@@ -535,7 +535,7 @@ get_socket_by_fd(int fd)
184   }
185   return &sockets[fd - LWIP_SOCKET_OFFSET];
186 }
187-#endif /* USE_LIBOS */
188+#endif /* GAZELLE_ENABLE */
189
190 /**
191  * Allocate a new socket for a given netconn.
192@@ -553,7 +553,7 @@ alloc_socket(struct netconn *newconn, int accepted, int flags)
193   SYS_ARCH_DECL_PROTECT(lev);
194   LWIP_UNUSED_ARG(accepted);
195
196-#if USE_LIBOS
197+#if GAZELLE_ENABLE
198   int type, protocol = 0, domain = AF_INET;
199   switch (NETCONNTYPE_GROUP(newconn->type)) {
200     case NETCONN_RAW:
201@@ -615,7 +615,7 @@ err:
202   posix_api->close_fn(i);
203   SYS_ARCH_UNPROTECT(lev);
204   return -1;
205-#else /* USE_LIBOS */
206+#else /* GAZELLE_ENABLE */
207
208   /* allocate a new socket identifier */
209   for (i = 0; i < NUM_SOCKETS; ++i) {
210@@ -649,7 +649,7 @@ err:
211   }
212   return -1;
213
214-#endif /* USE_LIBOS */
215+#endif /* GAZELLE_ENABLE */
216 }
217
218 /** Free a socket (under lock)
219@@ -773,12 +773,12 @@ lwip_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
220     done_socket(sock);
221     return -1;
222   }
223-#if USE_LIBOS
224+#if GAZELLE_ENABLE
225   LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < sockets_num + LWIP_SOCKET_OFFSET));
226   gazelle_init_sock(newsock);
227 #else
228   LWIP_ASSERT("invalid socket index", (newsock >= LWIP_SOCKET_OFFSET) && (newsock < NUM_SOCKETS + LWIP_SOCKET_OFFSET));
229-#endif /* USE_LIBOS */
230+#endif /* GAZELLE_ENABLE */
231   nsock = &sockets[newsock - LWIP_SOCKET_OFFSET];
232
233   /* See event_callback: If data comes in right away after an accept, even
234@@ -816,13 +816,13 @@ lwip_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
235     }
236
237     IPADDR_PORT_TO_SOCKADDR(&tempaddr, &naddr, port);
238-#if !USE_LIBOS
239+#if !GAZELLE_ENABLE
240     if (*addrlen > tempaddr.sa.sa_len) {
241       *addrlen = tempaddr.sa.sa_len;
242     }
243 #else
244         *addrlen = LWIP_MIN(*addrlen, sizeof(tempaddr));
245-#endif /* USE_LIBOS */
246+#endif /* GAZELLE_ENABLE */
247     MEMCPY(addr, &tempaddr, *addrlen);
248
249     LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock));
250@@ -993,10 +993,10 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t namelen)
251     return -1;
252   }
253
254-#if USE_LIBOS
255+#if GAZELLE_ENABLE
256   LWIP_DEBUGF(SOCKETS_DEBUG, ("libos connect succeed fd=%d\n",s));
257   SET_CONN_TYPE_LIBOS(sock->conn);
258-#endif /* USE_LIBOS */
259+#endif /* GAZELLE_ENABLE */
260
261   LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) succeeded\n", s));
262   sock_set_errno(sock, 0);
263@@ -1065,7 +1065,7 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
264     apiflags |= NETCONN_DONTBLOCK;
265   }
266
267-#if !USE_LIBOS
268+#if !GAZELLE_ENABLE
269   do {
270     struct pbuf *p;
271     err_t err;
272@@ -1146,13 +1146,13 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t len, int flags)
273   } while ((recv_left > 0) && !(flags & MSG_PEEK));
274
275 lwip_recv_tcp_done:
276-#else /* USE_LIBOS */
277+#else /* GAZELLE_ENABLE */
278   LWIP_UNUSED_ARG(recv_left);
279   recvd = read_lwip_data(sock, flags, apiflags);
280   if (recvd <= 0) {
281     return recvd;
282   }
283-#endif /* USE_LIBOS */
284+#endif /* GAZELLE_ENABLE */
285   if (apiflags & NETCONN_NOAUTORCVD) {
286     if ((recvd > 0) && !(flags & MSG_PEEK)) {
287       /* ensure window update after copying all data */
288@@ -1188,7 +1188,7 @@ lwip_sock_make_addr(struct netconn *conn, ip_addr_t *fromaddr, u16_t port,
289 #endif /* LWIP_IPV4 && LWIP_IPV6 */
290
291   IPADDR_PORT_TO_SOCKADDR(&saddr, fromaddr, port);
292-#if !USE_LIBOS
293+#if !GAZELLE_ENABLE
294   if (*fromlen < saddr.sa.sa_len) {
295     truncated = 1;
296   } else if (*fromlen > saddr.sa.sa_len) {
297@@ -2692,7 +2692,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
298       if (sock->rcvevent > 1) {
299         check_waiters = 0;
300       }
301-#if USE_LIBOS
302+#if GAZELLE_ENABLE
303       if (conn->acceptmbox != NULL && !sys_mbox_empty(conn->acceptmbox)) {
304         add_sock_event(sock, POLLIN);
305       }
306@@ -2714,7 +2714,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
307       break;
308     case NETCONN_EVT_ERROR:
309       sock->errevent = 1;
310-#if USE_LIBOS
311+#if GAZELLE_ENABLE
312       add_sock_event(sock, EPOLLERR);
313 #endif
314       break;
315@@ -2911,7 +2911,7 @@ lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
316   ip_addr_debug_print_val(SOCKETS_DEBUG, naddr);
317   LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", port));
318
319-#if !USE_LIBOS
320+#if !GAZELLE_ENABLE
321   if (*namelen > saddr.sa.sa_len) {
322     *namelen = saddr.sa.sa_len;
323   }
324@@ -3052,7 +3052,7 @@ lwip_sockopt_to_ipopt(int optname)
325     return SOF_KEEPALIVE;
326   case SO_REUSEADDR:
327     return SOF_REUSEADDR;
328-#if USE_LIBOS
329+#if GAZELLE_ENABLE
330   case SO_REUSEPORT:
331     return SO_REUSEPORT;
332 #endif
333@@ -3928,7 +3928,7 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
334   return err;
335 }
336
337-#if USE_LIBOS
338+#if GAZELLE_ENABLE
339 int
340 lwip_ioctl(int s, long cmd, ...)
341 {
342@@ -3963,7 +3963,7 @@ lwip_ioctl(int s, long cmd, void *argp)
343   if (!sock) {
344     return -1;
345   }
346-#endif /* USE_LIBOS */
347+#endif /* GAZELLE_ENABLE */
348
349   switch (cmd) {
350 #if LWIP_SO_RCVBUF || LWIP_FIONREAD_LINUXMODE
351@@ -4107,7 +4107,7 @@ lwip_fcntl(int s, int cmd, int val)
352       break;
353     default:
354       LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_fcntl(%d, UNIMPL: %d, %d)\n", s, cmd, val));
355-#if USE_LIBOS
356+#if GAZELLE_ENABLE
357       sock_set_errno(sock, 0); /* not yet implemented, but we return 0 for compatilbe with app */
358       ret = 0;
359 #else
360@@ -4375,7 +4375,7 @@ lwip_socket_drop_registered_mld6_memberships(int s)
361 }
362 #endif /* LWIP_IPV6_MLD */
363
364-#if USE_LIBOS
365+#if GAZELLE_ENABLE
366 void lwip_sock_init(void)
367 {
368   if (sockets_num == 0) {
369@@ -4400,6 +4400,6 @@ void lwip_exit(void)
370   return;
371 }
372
373-#endif /* USE_LIBOS */
374+#endif /* GAZELLE_ENABLE */
375
376 #endif /* LWIP_SOCKET */
377diff --git a/src/api/tcpip.c b/src/api/tcpip.c
378index d3d0b55..fe7a7bd 100644
379--- a/src/api/tcpip.c
380+++ b/src/api/tcpip.c
381@@ -123,13 +123,13 @@ again:
382  *
383  * @param arg unused argument
384  */
385-#if USE_LIBOS
386+#if GAZELLE_ENABLE
387 __attribute__((unused)) static void
388 tcpip_thread(void *arg)
389 #else
390 static void
391 tcpip_thread(void *arg)
392-#endif /* USE_LIBOS */
393+#endif /* GAZELLE_ENABLE */
394 {
395   struct tcpip_msg *msg;
396   LWIP_UNUSED_ARG(arg);
397@@ -247,7 +247,7 @@ tcpip_inpkt(struct pbuf *p, struct netif *inp, netif_input_fn input_fn)
398 #if LWIP_TCPIP_CORE_LOCKING_INPUT
399   err_t ret;
400   LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_inpkt: PACKET %p/%p\n", (void *)p, (void *)inp));
401-#if USE_LIBOS && LWIP_TIMERS
402+#if GAZELLE_ENABLE && LWIP_TIMERS
403   sys_timer_run();
404 #endif
405   LOCK_TCPIP_CORE();
406@@ -329,7 +329,7 @@ tcpip_callback(tcpip_callback_fn function, void *ctx)
407   msg->msg.cb.function = function;
408   msg->msg.cb.ctx = ctx;
409
410-#if USE_LIBOS && LWIP_TIMER
411+#if GAZELLE_ENABLE && LWIP_TIMER
412   sys_timer_run();
413 #endif
414   sys_mbox_post(&tcpip_mbox, msg);
415@@ -368,7 +368,7 @@ tcpip_try_callback(tcpip_callback_fn function, void *ctx)
416   msg->msg.cb.function = function;
417   msg->msg.cb.ctx = ctx;
418
419-#if USE_LIBOS && LWIP_TIMER
420+#if GAZELLE_ENABLE && LWIP_TIMER
421   sys_timer_run();
422 #endif
423   if (sys_mbox_trypost(&tcpip_mbox, msg) != ERR_OK) {
424@@ -452,7 +452,7 @@ tcpip_send_msg_wait_sem(tcpip_callback_fn fn, void *apimsg, sys_sem_t *sem)
425 {
426 #if LWIP_TCPIP_CORE_LOCKING
427   LWIP_UNUSED_ARG(sem);
428-#if USE_LIBOS && LWIP_TIMERS
429+#if GAZELLE_ENABLE && LWIP_TIMERS
430   sys_timer_run();
431 #endif
432   LOCK_TCPIP_CORE();
433@@ -492,7 +492,7 @@ tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call_data *call)
434 #if LWIP_TCPIP_CORE_LOCKING
435   err_t err;
436   LOCK_TCPIP_CORE();
437-#if USE_LIBOS && LWIP_TIMERS
438+#if GAZELLE_ENABLE && LWIP_TIMERS
439   sys_timer_run();
440 #endif
441   err = fn(call);
442@@ -558,7 +558,7 @@ tcpip_callbackmsg_new(tcpip_callback_fn function, void *ctx)
443   msg->msg.cb.function = function;
444   msg->msg.cb.ctx = ctx;
445
446-#if USE_LIBOS && LWIP_TIMER
447+#if GAZELLE_ENABLE && LWIP_TIMER
448   sys_timer_run();
449 #endif
450   return (struct tcpip_callback_msg *)msg;
451@@ -638,7 +638,7 @@ tcpip_init(tcpip_init_done_fn initfunc, void *arg)
452   }
453 #endif /* LWIP_TCPIP_CORE_LOCKING */
454
455-#if !USE_LIBOS
456+#if !GAZELLE_ENABLE
457   sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
458 #endif
459 }
460diff --git a/src/core/ipv4/etharp.c b/src/core/ipv4/etharp.c
461index f1903e4..5a1a834 100644
462--- a/src/core/ipv4/etharp.c
463+++ b/src/core/ipv4/etharp.c
464@@ -482,7 +482,7 @@ etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, struct et
465     struct pbuf *p = arp_table[i].q;
466     arp_table[i].q = NULL;
467 #endif /* ARP_QUEUEING */
468-#if USE_LIBOS
469+#if GAZELLE_ENABLE
470     struct pbuf *tmp = p->next;
471     while (tmp != NULL) {
472        tmp->ref--;
473@@ -1034,7 +1034,7 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
474     } else {
475       /* referencing the old pbuf is enough */
476       p = q;
477-#if USE_LIBOS
478+#if GAZELLE_ENABLE
479       struct pbuf *tmp = p;
480       while (tmp != NULL) {
481         pbuf_ref(tmp);
482diff --git a/src/core/ipv4/icmp.c b/src/core/ipv4/icmp.c
483index c58ae25..402ba69 100644
484--- a/src/core/ipv4/icmp.c
485+++ b/src/core/ipv4/icmp.c
486@@ -51,7 +51,7 @@
487
488 #include <string.h>
489
490-#if USE_LIBOS && CHECKSUM_GEN_IP_HW
491+#if GAZELLE_ENABLE && CHECKSUM_GEN_IP_HW
492 #include "dpdk_cksum.h"
493 #endif
494
495diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c
496index d823491..1b70bb5 100644
497--- a/src/core/ipv4/ip4.c
498+++ b/src/core/ipv4/ip4.c
499@@ -59,7 +59,7 @@
500
501 #include <string.h>
502
503-#if USE_LIBOS && (CHECKSUM_CHECK_IP_HW || CHECKSUM_GEN_IP_HW)
504+#if GAZELLE_ENABLE && (CHECKSUM_CHECK_IP_HW || CHECKSUM_GEN_IP_HW)
505 #include "dpdk_cksum.h"
506 #endif
507
508@@ -1034,13 +1034,13 @@ ip4_output_if_opt_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *d
509 #endif /* ENABLE_LOOPBACK */
510 #if IP_FRAG
511   /* don't fragment if interface has mtu set to 0 [loopif] */
512-#if USE_LIBOS
513+#if GAZELLE_ENABLE
514   if (!(get_eth_params_tx_ol() & DEV_TX_OFFLOAD_TCP_TSO)) {
515 #endif
516     if (netif->mtu && (p->tot_len > netif->mtu)) {
517       return ip4_frag(p, netif, dest);
518     }
519-#if USE_LIBOS
520+#if GAZELLE_ENABLE
521   }
522 #endif
523 #endif /* IP_FRAG */
524diff --git a/src/core/ipv4/ip4_frag.c b/src/core/ipv4/ip4_frag.c
525index c60523d..f15b798 100644
526--- a/src/core/ipv4/ip4_frag.c
527+++ b/src/core/ipv4/ip4_frag.c
528@@ -51,7 +51,7 @@
529
530 #include <string.h>
531
532-#if USE_LIBOS && CHECKSUM_GEN_IP_HW
533+#if GAZELLE_ENABLE && CHECKSUM_GEN_IP_HW
534 #include "dpdk_cksum.h"
535 #endif
536
537@@ -115,7 +115,7 @@ PACK_STRUCT_END
538    IPH_ID(iphdrA) == IPH_ID(iphdrB)) ? 1 : 0
539
540 /* global variables */
541-#if USE_LIBOS
542+#if GAZELLE_ENABLE
543 static PER_THREAD struct ip_reassdata *reassdatagrams;
544 static PER_THREAD u16_t ip_reass_pbufcount;
545 #else
546diff --git a/src/core/memp.c b/src/core/memp.c
547index 454ba32..fca1b0c 100644
548--- a/src/core/memp.c
549+++ b/src/core/memp.c
550@@ -78,14 +78,14 @@
551 #define LWIP_MEMPOOL(name,num,size,desc) LWIP_MEMPOOL_DECLARE(name,num,size,desc)
552 #include "lwip/priv/memp_std.h"
553
554-#if USE_LIBOS
555+#if GAZELLE_ENABLE
556 PER_THREAD struct memp_desc* memp_pools[MEMP_MAX] = {NULL};
557 #else
558 const struct memp_desc *const memp_pools[MEMP_MAX] = {
559 #define LWIP_MEMPOOL(name,num,size,desc) &memp_ ## name,
560 #include "lwip/priv/memp_std.h"
561 };
562-#endif /* USE_LIBOS */
563+#endif /* GAZELLE_ENABLE */
564
565 #ifdef LWIP_HOOK_FILENAME
566 #include LWIP_HOOK_FILENAME
567diff --git a/src/core/pbuf.c b/src/core/pbuf.c
568index ad75aa6..dd71519 100644
569--- a/src/core/pbuf.c
570+++ b/src/core/pbuf.c
571@@ -83,7 +83,7 @@
572 #if LWIP_CHECKSUM_ON_COPY
573 #include "lwip/inet_chksum.h"
574 #endif
575-#if USE_LIBOS
576+#if GAZELLE_ENABLE
577 #include <rte_prefetch.h>
578 #endif
579
580@@ -284,7 +284,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
581       }
582
583       /* If pbuf is to be allocated in RAM, allocate memory for it. */
584-#if USE_LIBOS
585+#if GAZELLE_ENABLE
586       /* alloc mbuf avoid send copy */
587       p = lwip_alloc_pbuf(layer, length, type);
588 #else
589@@ -753,7 +753,7 @@ pbuf_free(struct pbuf *p)
590   /* de-allocate all consecutive pbufs from the head of the chain that
591    * obtain a zero reference count after decrementing*/
592   while (p != NULL) {
593-#if USE_LIBOS
594+#if GAZELLE_ENABLE
595     if (p->next)
596       rte_prefetch0(p->next);
597 #endif
598@@ -1027,7 +1027,7 @@ pbuf_copy_partial_pbuf(struct pbuf *p_to, const struct pbuf *p_from, u16_t copy_
599       len_calc = p_to->len - offset_to;
600     }
601
602-#if USE_LIBOS && (CHECKSUM_GEN_IP_HW || CHECKSUM_GEN_TCP_HW)
603+#if GAZELLE_ENABLE && (CHECKSUM_GEN_IP_HW || CHECKSUM_GEN_TCP_HW)
604     p_to->l2_len = p_from->l2_len;
605     p_to->l3_len = p_from->l3_len;
606     p_to->ol_flags = p_from->ol_flags;
607diff --git a/src/core/tcp.c b/src/core/tcp.c
608index 3171c5e..69a39f6 100644
609--- a/src/core/tcp.c
610+++ b/src/core/tcp.c
611@@ -183,7 +183,7 @@ PER_THREAD struct tcp_pcb *tcp_tw_pcbs;
612 /** An array with all (non-temporary) PCB lists, mainly used for smaller code size */
613 PER_THREAD struct tcp_pcb ** tcp_pcb_lists[NUM_TCP_PCB_LISTS] = {NULL, NULL, NULL, NULL};
614
615-#if TCP_PCB_HASH
616+#if GAZELLE_TCP_PCB_HASH
617 #define INIT_TCP_HTABLE(ht_ptr) \
618   do { \
619     int _i; \
620@@ -203,7 +203,7 @@ PER_THREAD u8_t tcp_active_pcbs_changed;
621 /** Timer counter to handle calling slow-timer from tcp_tmr() */
622 static PER_THREAD u8_t tcp_timer;
623 static PER_THREAD u8_t tcp_timer_ctr;
624-#if USE_LIBOS
625+#if GAZELLE_ENABLE
626 static u16_t tcp_new_port(struct tcp_pcb *pcb);
627 #else
628 static u16_t tcp_new_port(void);
629@@ -214,7 +214,7 @@ static err_t tcp_close_shutdown_fin(struct tcp_pcb *pcb);
630 static void tcp_ext_arg_invoke_callbacks_destroyed(struct tcp_pcb_ext_args *ext_args);
631 #endif
632
633-#if USE_LIBOS
634+#if GAZELLE_ENABLE
635 static u8_t port_state[TCP_LOCAL_PORT_RANGE_END - TCP_LOCAL_PORT_RANGE_START + 1] = {0};
636 void release_port(u16_t port)
637 {
638@@ -238,7 +238,7 @@ tcp_init(void)
639   tcp_port = TCP_ENSURE_LOCAL_PORT_RANGE(LWIP_RAND());
640 #endif /* LWIP_RAND */
641
642-#if TCP_PCB_HASH
643+#if GAZELLE_TCP_PCB_HASH
644   tcp_active_htable = (struct tcp_hash_table*)mem_malloc(sizeof(struct tcp_hash_table));
645   LWIP_ASSERT("malloc tcp_active_htable mem failed.", tcp_active_htable != NULL);
646   INIT_TCP_HTABLE(tcp_active_htable);
647@@ -249,7 +249,7 @@ tcp_init(void)
648 void
649 tcp_free(struct tcp_pcb *pcb)
650 {
651-#if USE_LIBOS
652+#if GAZELLE_ENABLE
653   vdev_unreg_done(pcb);
654   release_port(pcb->local_port);
655 #endif
656@@ -405,7 +405,7 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
657               pcb->local_port, pcb->remote_port);
658
659       tcp_pcb_purge(pcb);
660-#if TCP_PCB_HASH
661+#if GAZELLE_TCP_PCB_HASH
662       TCP_RMV_ACTIVE_HASH(pcb);
663 #endif
664       TCP_RMV_ACTIVE(pcb);
665@@ -442,7 +442,7 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data)
666       tcp_free_listen(pcb);
667       break;
668     case SYN_SENT:
669-#if TCP_PCB_HASH
670+#if GAZELLE_TCP_PCB_HASH
671       TCP_PCB_REMOVE_ACTIVE_HASH(pcb);
672 #endif
673       TCP_PCB_REMOVE_ACTIVE(pcb);
674@@ -650,7 +650,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset)
675     } else {
676       send_rst = reset;
677       local_port = pcb->local_port;
678-#if TCP_PCB_HASH
679+#if GAZELLE_TCP_PCB_HASH
680       TCP_PCB_REMOVE_ACTIVE_HASH(pcb);
681 #endif
682       TCP_PCB_REMOVE_ACTIVE(pcb);
683@@ -761,7 +761,7 @@ tcp_bind(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
684 #endif /* LWIP_IPV6 && LWIP_IPV6_SCOPES */
685
686   if (port == 0) {
687-#if USE_LIBOS
688+#if GAZELLE_ENABLE
689     port = tcp_new_port(pcb);
690 #else
691     port = tcp_new_port();
692@@ -773,7 +773,7 @@ tcp_bind(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
693     /* Check if the address already is in use (on all lists) */
694     for (i = 0; i < max_pcb_list; i++) {
695       for (cpcb = *tcp_pcb_lists[i]; cpcb != NULL; cpcb = cpcb->next) {
696-#if REUSE_IPPORT
697+#if GAZELLE_TCP_REUSE_IPPORT
698               continue;
699 #else
700         if (cpcb->local_port == port) {
701@@ -927,7 +927,7 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
702     goto done;
703   }
704
705-#if REUSE_IPPORT
706+#if GAZELLE_TCP_REUSE_IPPORT
707   struct tcp_pcb_listen *first_same_port_pcb = NULL;
708   for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
709     if ((lpcb->local_port == pcb->local_port) &&
710@@ -952,9 +952,9 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
711       }
712     }
713   }
714-#endif /* REUSE_IPPORT */
715+#endif /* GAZELLE_TCP_REUSE_IPPORT */
716
717-#if USE_LIBOS
718+#if GAZELLE_ENABLE
719   vdev_reg_done(REG_RING_TCP_LISTEN, pcb);
720 #endif
721
722@@ -972,7 +972,7 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
723   lpcb->ttl = pcb->ttl;
724   lpcb->tos = pcb->tos;
725
726-#if REUSE_IPPORT
727+#if GAZELLE_TCP_REUSE_IPPORT
728   lpcb->connect_num = 0;
729   lpcb->next_same_port_pcb = NULL;
730
731@@ -992,7 +992,7 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
732   /* copy over ext_args to listening pcb  */
733   memcpy(&lpcb->ext_args, &pcb->ext_args, sizeof(pcb->ext_args));
734 #endif
735-#if USE_LIBOS
736+#if GAZELLE_ENABLE
737   /* pcb transfer to lpcb and reg into tcp_listen_pcbs. freeing pcb shouldn't release sock table in here.
738    * local_port=0 avoid to release sock table in tcp_free */
739   pcb->local_port = 0;
740@@ -1006,7 +1006,7 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
741   tcp_backlog_set(lpcb, backlog);
742 #endif /* TCP_LISTEN_BACKLOG */
743
744-#if REUSE_IPPORT
745+#if GAZELLE_TCP_REUSE_IPPORT
746   if (first_same_port_pcb != NULL) {
747     TCP_REG_SAMEPORT((struct tcp_pcb_listen *)first_same_port_pcb, (struct tcp_pcb_listen *)lpcb);
748   } else
749@@ -1109,7 +1109,7 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len)
750  *
751  * @return a new (free) local TCP port number
752  */
753-#if USE_LIBOS
754+#if GAZELLE_ENABLE
755 static u16_t
756 tcp_new_port(struct tcp_pcb *pcb)
757 #else
758@@ -1128,7 +1128,7 @@ tcp_new_port(void)
759       }
760
761       if (__atomic_load_n(&port_state[tcp_port - TCP_LOCAL_PORT_RANGE_START], __ATOMIC_ACQUIRE) == 0) {
762-#if USE_LIBOS
763+#if GAZELLE_ENABLE
764         if (port_in_stack_queue(pcb->remote_ip.addr, pcb->local_ip.addr, pcb->remote_port, tcp_port)) {
765             tmp_port = tcp_port;
766             __atomic_store_n(&port_state[tcp_port - TCP_LOCAL_PORT_RANGE_START], 1, __ATOMIC_RELEASE);
767@@ -1231,7 +1231,7 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
768
769   old_local_port = pcb->local_port;
770   if (pcb->local_port == 0) {
771-#if USE_LIBOS
772+#if GAZELLE_ENABLE
773     pcb->local_port = tcp_new_port(pcb);
774 #else
775     pcb->local_port = tcp_new_port();
776@@ -1289,7 +1289,7 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
777   /* Send a SYN together with the MSS option. */
778   ret = tcp_enqueue_flags(pcb, TCP_SYN);
779   if (ret == ERR_OK) {
780-#if USE_LIBOS
781+#if GAZELLE_ENABLE
782     vdev_reg_done(REG_RING_TCP_CONNECT, pcb);
783 #endif
784
785@@ -1298,7 +1298,7 @@ tcp_connect(struct tcp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port,
786     if (old_local_port != 0) {
787       TCP_RMV(&tcp_bound_pcbs, pcb);
788     }
789-#if TCP_PCB_HASH
790+#if GAZELLE_TCP_PCB_HASH
791     TCP_REG_ACTIVE_HASH(pcb);
792 #endif
793     TCP_REG_ACTIVE(pcb);
794@@ -1516,7 +1516,7 @@ tcp_slowtmr_start:
795       if (prev != NULL) {
796         LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs);
797         prev->next = pcb->next;
798-#if USE_LIBOS
799+#if GAZELLE_ENABLE
800         if (pcb->next)
801           pcb->next->prev = prev;
802         //dont set next NULL, it will be used below
803@@ -1526,14 +1526,14 @@ tcp_slowtmr_start:
804         /* This PCB was the first. */
805         LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_active_pcbs", tcp_active_pcbs == pcb);
806         tcp_active_pcbs = pcb->next;
807-#if USE_LIBOS
808+#if GAZELLE_ENABLE
809         if (pcb->next)
810           pcb->next->prev = NULL;
811         //dont set next NULL, it will be used below
812         pcb->prev = NULL;
813 #endif
814       }
815-#if TCP_PCB_HASH
816+#if GAZELLE_TCP_PCB_HASH
817       TCP_RMV_ACTIVE_HASH(pcb);
818 #endif
819
820@@ -1546,7 +1546,7 @@ tcp_slowtmr_start:
821       last_state = pcb->state;
822       pcb2 = pcb;
823       pcb = pcb->next;
824-#if USE_LIBOS
825+#if GAZELLE_ENABLE
826       pcb2->next = NULL;
827 #endif
828       tcp_free(pcb2);
829@@ -1600,7 +1600,7 @@ tcp_slowtmr_start:
830       if (prev != NULL) {
831         LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs);
832         prev->next = pcb->next;
833-#if USE_LIBOS
834+#if GAZELLE_ENABLE
835         if (pcb->next)
836           pcb->next->prev = prev;
837         //dont set next NULL, it will be used below
838@@ -1610,7 +1610,7 @@ tcp_slowtmr_start:
839         /* This PCB was the first. */
840         LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_tw_pcbs", tcp_tw_pcbs == pcb);
841         tcp_tw_pcbs = pcb->next;
842-#if USE_LIBOS
843+#if GAZELLE_ENABLE
844         if (pcb->next)
845           pcb->next->prev = NULL;
846         //dont set next NULL, it will be used below
847@@ -1619,7 +1619,7 @@ tcp_slowtmr_start:
848       }
849       pcb2 = pcb;
850       pcb = pcb->next;
851-#if USE_LIBOS
852+#if GAZELLE_ENABLE
853       pcb2->next = NULL;
854 #endif
855       tcp_free(pcb2);
856@@ -1790,7 +1790,7 @@ tcp_seg_free(struct tcp_seg *seg)
857       seg->p = NULL;
858 #endif /* TCP_DEBUG */
859     }
860-#if !USE_LIBOS
861+#if !GAZELLE_ENABLE
862     memp_free(MEMP_TCP_SEG, seg);
863 #endif
864   }
865@@ -1828,7 +1828,7 @@ tcp_seg_copy(struct tcp_seg *seg)
866
867   LWIP_ASSERT("tcp_seg_copy: invalid seg", seg != NULL);
868
869-#if USE_LIBOS
870+#if GAZELLE_ENABLE
871   cseg = (struct tcp_seg *)((uint8_t *)seg->p + sizeof(struct pbuf_custom));
872 #else
873   cseg = (struct tcp_seg *)memp_malloc(MEMP_TCP_SEG);
874@@ -2371,7 +2371,7 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
875 #endif /* TCP_QUEUE_OOSEQ */
876   }
877
878-#if USE_LIBOS
879+#if GAZELLE_ENABLE
880   vdev_unreg_done(pcb);
881   release_port(pcb->local_port);
882 #endif
883@@ -2383,13 +2383,13 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
884   LWIP_ASSERT("tcp_pcb_remove: tcp_pcbs_sane()", tcp_pcbs_sane());
885 }
886
887-#if TCP_PCB_HASH
888+#if GAZELLE_TCP_PCB_HASH
889 void
890 tcp_pcb_remove_hash(struct tcp_hash_table *htb, struct tcp_pcb *pcb)
891 {
892   TCP_RMV_HASH(htb, pcb);
893 }
894-#endif /* TCP_PCB_HASH */
895+#endif /* GAZELLE_TCP_PCB_HASH */
896
897 /**
898  * Calculates a new initial sequence number for new connections.
899diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
900index 9f5c34a..dd83260 100644
901--- a/src/core/tcp_in.c
902+++ b/src/core/tcp_in.c
903@@ -58,13 +58,13 @@
904 #if LWIP_ND6_TCP_REACHABILITY_HINTS
905 #include "lwip/nd6.h"
906 #endif /* LWIP_ND6_TCP_REACHABILITY_HINTS */
907-#if USE_LIBOS
908+#if GAZELLE_ENABLE
909 #include "lwip/api.h"
910 #endif
911
912 #include <string.h>
913
914-#if USE_LIBOS && CHECKSUM_CHECK_TCP_HW
915+#if GAZELLE_ENABLE && CHECKSUM_CHECK_TCP_HW
916 #include <dpdk_cksum.h>
917 #endif /* CHECKSUM_CHECK_TCP_HW */
918
919@@ -134,7 +134,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
920   u8_t hdrlen_bytes;
921   err_t err;
922
923-#if TCP_PCB_HASH
924+#if GAZELLE_TCP_PCB_HASH
925   u32_t idx;
926   struct hlist_head *head;
927   struct hlist_node *node;
928@@ -277,7 +277,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
929      for an active connection. */
930   prev = NULL;
931
932-#if TCP_PCB_HASH
933+#if GAZELLE_TCP_PCB_HASH
934   idx = TUPLE4_HASH_FN( ip_current_dest_addr()->addr, tcphdr->dest,
935                       ip_current_src_addr()->addr, tcphdr->src) &
936          (tcp_active_htable->size - 1);
937@@ -301,7 +301,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
938         pcb->local_port == tcphdr->dest &&
939         ip_addr_cmp(&pcb->remote_ip, ip_current_src_addr()) &&
940         ip_addr_cmp(&pcb->local_ip, ip_current_dest_addr())) {
941-#if !TCP_PCB_HASH
942+#if !GAZELLE_TCP_PCB_HASH
943       /* Move this PCB to the front of the list so that subsequent
944          lookups will be faster (we exploit locality in TCP segment
945          arrivals). */
946@@ -317,7 +317,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
947 #endif
948       break;
949     }
950-#if TCP_PCB_HASH
951+#if GAZELLE_TCP_PCB_HASH
952     pcb = NULL;
953 #else
954     prev = pcb;
955@@ -356,7 +356,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
956       }
957     }
958
959-#if REUSE_IPPORT
960+#if GAZELLE_TCP_REUSE_IPPORT
961     struct tcp_pcb_listen *min_cnts_lpcb = NULL;
962 #endif
963     /* Finally, if we still did not get a match, we check all PCBs that
964@@ -382,7 +382,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
965         } else if (IP_ADDR_PCB_VERSION_MATCH_EXACT(lpcb, ip_current_dest_addr())) {
966           if (ip_addr_cmp(&lpcb->local_ip, ip_current_dest_addr())) {
967             /* found an exact match */
968-#if REUSE_IPPORT
969+#if GAZELLE_TCP_REUSE_IPPORT
970             // check master fd
971             struct tcp_pcb_listen *tmp_lpcb = lpcb;
972             u8_t have_master_fd = 0;
973@@ -395,7 +395,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
974
975             tmp_lpcb = lpcb;
976             min_cnts_lpcb = lpcb;
977-            u16_t min_conn_num = MAX_CONN_NUM_PER_THREAD;
978+            u16_t min_conn_num = GAZELLE_TCP_MAX_CONN_PER_THREAD;
979             while (tmp_lpcb != NULL) {
980               if (!have_master_fd || tmp_lpcb->master_lpcb) {
981                 if (tmp_lpcb->connect_num < min_conn_num) {
982@@ -434,13 +434,13 @@ tcp_input(struct pbuf *p, struct netif *inp)
983          arrivals). */
984       if (prev != NULL) {
985         ((struct tcp_pcb_listen *)prev)->next = lpcb->next;
986-#if USE_LIBOS
987+#if GAZELLE_ENABLE
988         if (lpcb->next)
989           lpcb->next->prev = (struct tcp_pcb_listen *)prev;
990 #endif
991         /* our successor is the remainder of the listening list */
992         lpcb->next = tcp_listen_pcbs.listen_pcbs;
993-#if USE_LIBOS
994+#if GAZELLE_ENABLE
995         lpcb->prev = NULL;
996 #endif
997         /* put this listening pcb at the head of the listening list */
998@@ -455,7 +455,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
999                                      tcphdr_opt1len, tcphdr_opt2, p) == ERR_OK)
1000 #endif
1001       {
1002-#if REUSE_IPPORT
1003+#if GAZELLE_TCP_REUSE_IPPORT
1004         tcp_listen_input(min_cnts_lpcb);
1005 	min_cnts_lpcb->connect_num++;
1006 #else
1007@@ -528,7 +528,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
1008            application that the connection is dead before we
1009            deallocate the PCB. */
1010         TCP_EVENT_ERR(pcb->state, pcb->errf, pcb->callback_arg, ERR_RST);
1011-#if TCP_PCB_HASH
1012+#if GAZELLE_TCP_PCB_HASH
1013         tcp_pcb_remove_hash(tcp_active_htable, pcb);
1014 #endif
1015         tcp_pcb_remove(&tcp_active_pcbs, pcb);
1016@@ -710,7 +710,7 @@ tcp_input_delayed_close(struct tcp_pcb *pcb)
1017           ensure the application doesn't continue using the PCB. */
1018       TCP_EVENT_ERR(pcb->state, pcb->errf, pcb->callback_arg, ERR_CLSD);
1019     }
1020-#if TCP_PCB_HASH
1021+#if GAZELLE_TCP_PCB_HASH
1022     tcp_pcb_remove_hash(tcp_active_htable, pcb);
1023 #endif
1024     tcp_pcb_remove(&tcp_active_pcbs, pcb);
1025@@ -799,12 +799,12 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
1026     npcb->netif_idx = pcb->netif_idx;
1027     /* Register the new PCB so that we can begin receiving segments
1028        for it. */
1029-#if TCP_PCB_HASH
1030+#if GAZELLE_TCP_PCB_HASH
1031     TCP_REG_ACTIVE_HASH(npcb);
1032 #endif
1033     TCP_REG_ACTIVE(npcb);
1034
1035-#if USE_LIBOS
1036+#if GAZELLE_ENABLE
1037     vdev_reg_done(REG_RING_TCP_CONNECT, npcb);
1038 #endif
1039
1040@@ -1102,7 +1102,7 @@ tcp_process(struct tcp_pcb *pcb)
1041           if (recv_flags & TF_GOT_FIN) {
1042             tcp_ack_now(pcb);
1043             pcb->state = CLOSE_WAIT;
1044-#if USE_LIBOS
1045+#if GAZELLE_ENABLE
1046             API_EVENT(((struct netconn *)pcb->callback_arg), NETCONN_EVT_ERROR, 0);
1047 #endif
1048           }
1049@@ -1120,7 +1120,7 @@ tcp_process(struct tcp_pcb *pcb)
1050       if (recv_flags & TF_GOT_FIN) { /* passive close */
1051         tcp_ack_now(pcb);
1052         pcb->state = CLOSE_WAIT;
1053-#if USE_LIBOS
1054+#if GAZELLE_ENABLE
1055         API_EVENT(((struct netconn *)pcb->callback_arg), NETCONN_EVT_ERROR, 0);
1056 #endif
1057       }
1058@@ -1134,7 +1134,7 @@ tcp_process(struct tcp_pcb *pcb)
1059                       ("TCP connection closed: FIN_WAIT_1 %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest));
1060           tcp_ack_now(pcb);
1061           tcp_pcb_purge(pcb);
1062-#if TCP_PCB_HASH
1063+#if GAZELLE_TCP_PCB_HASH
1064           TCP_RMV_ACTIVE_HASH(pcb);
1065 #endif
1066           TCP_RMV_ACTIVE(pcb);
1067@@ -1155,7 +1155,7 @@ tcp_process(struct tcp_pcb *pcb)
1068         LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: FIN_WAIT_2 %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest));
1069         tcp_ack_now(pcb);
1070         tcp_pcb_purge(pcb);
1071-#if TCP_PCB_HASH
1072+#if GAZELLE_TCP_PCB_HASH
1073         TCP_RMV_ACTIVE_HASH(pcb);
1074 #endif
1075         TCP_RMV_ACTIVE(pcb);
1076@@ -1168,7 +1168,7 @@ tcp_process(struct tcp_pcb *pcb)
1077       if ((flags & TCP_ACK) && ackno == pcb->snd_nxt && pcb->unsent == NULL) {
1078         LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed: CLOSING %"U16_F" -> %"U16_F".\n", inseg.tcphdr->src, inseg.tcphdr->dest));
1079         tcp_pcb_purge(pcb);
1080-#if TCP_PCB_HASH
1081+#if GAZELLE_TCP_PCB_HASH
1082         TCP_RMV_ACTIVE_HASH(pcb);
1083 #endif
1084         TCP_RMV_ACTIVE(pcb);
1085@@ -1377,7 +1377,7 @@ tcp_receive(struct tcp_pcb *pcb)
1086             if (pcb->lastack == ackno) {
1087               found_dataack = 1;
1088               ++pcb->dataacks;
1089-              if (pcb->dataacks > MAX_DATA_ACK_NUM) {
1090+              if (pcb->dataacks > GAZELLE_TCP_MAX_DATA_ACK_NUM) {
1091                 if (tcp_rexmit(pcb) == ERR_OK) {
1092                   pcb->rtime = 0;
1093                   pcb->dataacks = 0;
1094@@ -1775,7 +1775,7 @@ tcp_receive(struct tcp_pcb *pcb)
1095             recv_flags |= TF_GOT_FIN;
1096             if (pcb->state == ESTABLISHED) { /* force passive close or we can move to active close */
1097               pcb->state = CLOSE_WAIT;
1098-#if USE_LIBOS
1099+#if GAZELLE_ENABLE
1100               API_EVENT(((struct netconn *)pcb->callback_arg), NETCONN_EVT_ERROR, 0);
1101 #endif
1102             }
1103diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
1104index bf23381..1b3c5af 100644
1105--- a/src/core/tcp_out.c
1106+++ b/src/core/tcp_out.c
1107@@ -80,7 +80,7 @@
1108
1109 #include <string.h>
1110
1111-#if USE_LIBOS
1112+#if GAZELLE_ENABLE
1113 #include "lwipsock.h"
1114 #include <rte_prefetch.h>
1115 #if CHECKSUM_GEN_TCP_HW
1116@@ -162,7 +162,7 @@ tcp_route(const struct tcp_pcb *pcb, const ip_addr_t *src, const ip_addr_t *dst)
1117  * The TCP header is filled in except ackno and wnd.
1118  * p is freed on failure.
1119  */
1120-#if USE_LIBOS
1121+#if GAZELLE_ENABLE
1122 void tcp_init_segment(struct tcp_seg *seg, const struct tcp_pcb *pcb, struct pbuf *p, u8_t hdrflags,
1123   u32_t seqno, u8_t optflags)
1124 {
1125@@ -515,7 +515,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
1126    * pos records progress as data is segmented.
1127    */
1128
1129-#if !USE_LIBOS
1130+#if !GAZELLE_ENABLE
1131   /* Find the tail of the unsent queue. */
1132   if (pcb->unsent != NULL) {
1133     u16_t space;
1134@@ -631,9 +631,9 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
1135                 pcb->unsent_oversize == 0);
1136 #endif /* TCP_OVERSIZE */
1137   }
1138-#else /* USE_LIBOS */
1139+#else /* GAZELLE_ENABLE */
1140   last_unsent = pcb->last_unsent;
1141-#endif /* USE_LIBOS */
1142+#endif /* GAZELLE_ENABLE */
1143
1144   /*
1145    * Phase 3: Create new segments.
1146@@ -651,7 +651,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
1147     u8_t chksum_swapped = 0;
1148 #endif /* TCP_CHECKSUM_ON_COPY */
1149
1150-#if !USE_LIBOS
1151+#if !GAZELLE_ENABLE
1152     if (apiflags & TCP_WRITE_FLAG_COPY) {
1153       /* If copy is set, memory should be allocated and data copied
1154        * into pbuf */
1155@@ -698,13 +698,13 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
1156       /* Concatenate the headers and data pbufs together. */
1157       pbuf_cat(p/*header*/, p2/*data*/);
1158     }
1159-#else  /* USE_LIBOS */
1160+#else  /* GAZELLE_ENABLE */
1161     p = write_lwip_data((struct lwip_sock *)arg, len - pos, &apiflags);
1162     if (p == NULL) {
1163       break;
1164     }
1165     seglen = p->tot_len;
1166-#endif  /* USE_LIBOS */
1167+#endif  /* GAZELLE_ENABLE */
1168
1169     queuelen += pbuf_clen(p);
1170
1171@@ -714,7 +714,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
1172     if (queuelen > LWIP_MIN(TCP_SND_QUEUELEN, TCP_SNDQUEUELEN_OVERFLOW)) {
1173       LWIP_DEBUGF(TCP_OUTPUT_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("tcp_write: queue too long %"U16_F" (%d)\n",
1174                   queuelen, (int)TCP_SND_QUEUELEN));
1175-#if USE_LIBOS
1176+#if GAZELLE_ENABLE
1177       if (pos > 0) {
1178         queuelen -= pbuf_clen(p);
1179         break;
1180@@ -726,7 +726,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
1181     }
1182
1183     if ((seg = tcp_create_segment(pcb, p, 0, pcb->snd_lbb + pos, optflags)) == NULL) {
1184-#if USE_LIBOS
1185+#if GAZELLE_ENABLE
1186       if (pos > 0) {
1187         queuelen -= pbuf_clen(p);
1188         break;
1189@@ -759,7 +759,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
1190                 lwip_ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg)));
1191
1192     pos += seglen;
1193-#if USE_LIBOS
1194+#if GAZELLE_ENABLE
1195     write_lwip_over((struct lwip_sock*)arg);
1196 #endif
1197   }
1198@@ -847,7 +847,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
1199   /*
1200    * Finally update the pcb state.
1201    */
1202-#if USE_LIBOS
1203+#if GAZELLE_ENABLE
1204   if (queue) {
1205     pcb->last_unsent = prev_seg;
1206   }
1207@@ -876,7 +876,7 @@ memerr:
1208   tcp_set_flags(pcb, TF_NAGLEMEMERR);
1209   TCP_STATS_INC(tcp.memerr);
1210
1211-#if !USE_LIBOS
1212+#if !GAZELLE_ENABLE
1213   if (concat_p != NULL) {
1214     pbuf_free(concat_p);
1215   }
1216@@ -1307,7 +1307,7 @@ tcp_build_wnd_scale_option(u32_t *opts)
1217 }
1218 #endif
1219
1220-#if USE_LIBOS
1221+#if GAZELLE_ENABLE
1222 static struct tcp_seg *tcp_output_over(struct tcp_pcb *pcb, struct tcp_seg *seg, struct tcp_seg *useg)
1223 {
1224   if (TCP_TCPLEN(seg) > 0) {
1225@@ -1472,7 +1472,7 @@ tcp_output(struct tcp_pcb *pcb)
1226   /* data available and window allows it to be sent? */
1227
1228   u32_t send_len = 0;
1229-#if USE_LIBOS
1230+#if GAZELLE_ENABLE
1231   if ((get_eth_params_tx_ol() & DEV_TX_OFFLOAD_TCP_TSO) && pcb->need_tso_send) {
1232     while(seg && send_len < 0xffff) {
1233       /**
1234@@ -1485,7 +1485,7 @@ tcp_output(struct tcp_pcb *pcb)
1235       struct pbuf *pre_pbuf = NULL;
1236       u8_t pbuf_chain_len = 0;
1237       u32_t next_seqno = lwip_ntohl(seg->tcphdr->seqno);
1238-      while (seg != NULL && pbuf_chain_len < MAX_PBUF_CHAIN_LEN) {
1239+      while (seg != NULL && pbuf_chain_len < GAZELLE_TCP_MAX_PBUF_CHAIN_LEN) {
1240         u32_t seg_seqno = lwip_ntohl(seg->tcphdr->seqno);
1241         if (seg_seqno - pcb->lastack + seg->len > wnd) {
1242           if (first_pbuf)
1243@@ -1501,7 +1501,7 @@ tcp_output(struct tcp_pcb *pcb)
1244             goto output_done;
1245         }
1246
1247-        if (seg->len < TCP_MSS || next_seqno != seg_seqno || pbuf_chain_len >= MAX_PBUF_CHAIN_LEN) {
1248+        if (seg->len < TCP_MSS || next_seqno != seg_seqno || pbuf_chain_len >= GAZELLE_TCP_MAX_PBUF_CHAIN_LEN) {
1249           break;
1250         }
1251         if (first_pbuf == NULL && (seg->next == NULL || seg->next->len < TCP_MSS)) {
1252@@ -1771,7 +1771,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb, struct netif *netif
1253   }
1254 #endif
1255
1256-#if USE_LIBOS
1257+#if GAZELLE_ENABLE
1258   /* pbuf into mbuf. ref dpdk_common.h */
1259   rte_prefetch0((uint8_t *)(seg->p) - sizeof(struct rte_mbuf) - sizeof(uint64_t) * 2);
1260 #endif
1261diff --git a/src/core/timeouts.c b/src/core/timeouts.c
1262index 0542a32..2b80b0a 100644
1263--- a/src/core/timeouts.c
1264+++ b/src/core/timeouts.c
1265@@ -442,7 +442,7 @@ sys_timeouts_sleeptime(void)
1266   }
1267 }
1268
1269-#if USE_LIBOS
1270+#if GAZELLE_ENABLE
1271 void sys_timer_run(void)
1272 {
1273   u32_t sleeptime;
1274@@ -452,7 +452,7 @@ void sys_timer_run(void)
1275     sys_check_timeouts();
1276   }
1277 }
1278-#endif /* USE_LIBOS */
1279+#endif /* GAZELLE_ENABLE */
1280
1281 #else /* LWIP_TIMERS && !LWIP_TIMERS_CUSTOM */
1282 /* Satisfy the TCP code which calls this function */
1283diff --git a/src/include/arch/sys_arch.h b/src/include/arch/sys_arch.h
1284index fc4a9fd..04e3192 100644
1285--- a/src/include/arch/sys_arch.h
1286+++ b/src/include/arch/sys_arch.h
1287@@ -76,7 +76,7 @@ int sys_mbox_empty(struct sys_mbox *);
1288 struct sys_thread;
1289 typedef struct sys_thread *sys_thread_t;
1290
1291-#if USE_LIBOS
1292+#if GAZELLE_ENABLE
1293 extern int eth_dev_poll(void);
1294 #include <rte_ring.h>
1295
1296diff --git a/src/include/dpdk_cksum.h b/src/include/dpdk_cksum.h
1297index 83c9c38..df2e2a5 100644
1298--- a/src/include/dpdk_cksum.h
1299+++ b/src/include/dpdk_cksum.h
1300@@ -34,7 +34,7 @@
1301 #define __DPDK_CKSUM_H__
1302
1303 #include "lwipopts.h"
1304-#if USE_LIBOS
1305+#if GAZELLE_ENABLE
1306 #include <rte_ethdev.h>
1307
1308 #if CHECKSUM_OFFLOAD_ALL
1309@@ -103,5 +103,5 @@ static inline u16_t ip_chksum_pseudo_offload(u8_t proto, u16_t proto_len,
1310 }
1311 #endif /* CHECKSUM_GEN_TCP_HW */
1312
1313-#endif /* USE_LIBOS */
1314+#endif /* GAZELLE_ENABLE */
1315 #endif /* __DPDK_CKSUM_H__ */
1316diff --git a/src/include/hlist.h b/src/include/hlist.h
1317index 7059488..988b017 100644
1318--- a/src/include/hlist.h
1319+++ b/src/include/hlist.h
1320@@ -35,7 +35,7 @@
1321
1322 #include "list.h"
1323
1324-//#if TCP_PCB_HASH
1325+//#if GAZELLE_TCP_PCB_HASH
1326 struct hlist_node {
1327     /**
1328      * @pprev: point the previous node's next pointer
1329@@ -228,6 +228,6 @@ static inline void hlist_ctl_add_after(struct hlist_node *n, struct hlist_node *
1330         ctl->tail.end = next;
1331     }
1332 }
1333-//#endif /* TCP_PCB_HASH */
1334+//#endif /* GAZELLE_TCP_PCB_HASH */
1335
1336 #endif /* __HLIST_H__ */
1337diff --git a/src/include/lwip/api.h b/src/include/lwip/api.h
1338index 430a7a0..197faef 100644
1339--- a/src/include/lwip/api.h
1340+++ b/src/include/lwip/api.h
1341@@ -141,16 +141,16 @@ enum netconn_type {
1342   , NETCONN_RAW_IPV6    = NETCONN_RAW | NETCONN_TYPE_IPV6 /* 0x48 */
1343 #endif /* LWIP_IPV6 */
1344
1345-#if USE_LIBOS
1346+#if GAZELLE_ENABLE
1347   /*here must bigger than 0xff, because (type & 0xff) is for lwip inner use*/
1348   , NETCONN_LIBOS = 0x100
1349   , NETCONN_HOST = 0x200
1350   , NETCONN_INPRG = 0x400
1351   , NETCONN_STACK = NETCONN_LIBOS | NETCONN_HOST | NETCONN_INPRG
1352-#endif /* USE_LIBOS */
1353+#endif /* GAZELLE_ENABLE */
1354 };
1355
1356-#ifdef USE_LIBOS
1357+#ifdef GAZELLE_ENABLE
1358 #define SET_CONN_TYPE_LIBOS_OR_HOST(conn) do { \
1359   conn->type &= ~(NETCONN_STACK); \
1360   conn->type |= (NETCONN_LIBOS | NETCONN_HOST); } while (0)
1361@@ -175,7 +175,7 @@ enum netconn_type {
1362 #define CONN_TYPE_HAS_LIBOS_AND_HOST(conn) (0)
1363 #define CONN_TYPE_HAS_LIBOS(conn) (0)
1364 #define CONN_TYPE_HAS_HOST(conn) (0)
1365-#endif /* USE_LIBOS */
1366+#endif /* GAZELLE_ENABLE */
1367
1368 /** Current state of the netconn. Non-TCP netconns are always
1369  * in state NETCONN_NONE! */
1370@@ -319,7 +319,7 @@ struct netconn {
1371   /** A callback function that is informed about events for this netconn */
1372   netconn_callback callback;
1373
1374-#if REUSE_IPPORT
1375+#if GAZELLE_TCP_REUSE_IPPORT
1376   u8_t is_master_fd;
1377 #endif
1378 };
1379diff --git a/src/include/lwip/ip.h b/src/include/lwip/ip.h
1380index 7f55fb3..1c6988b 100644
1381--- a/src/include/lwip/ip.h
1382+++ b/src/include/lwip/ip.h
1383@@ -97,7 +97,7 @@ struct ip_pcb {
1384 /*
1385  * Option flags per-socket. These are the same like SO_XXX in sockets.h
1386  */
1387-#if USE_LIBOS
1388+#if GAZELLE_ENABLE
1389 #define SOF_REUSEADDR     0x02U /* allow local address reuse */
1390 #define SOF_KEEPALIVE     0x09U /* keep connections alive */
1391 #define SOF_BROADCAST     0x06U /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
1392@@ -105,7 +105,7 @@ struct ip_pcb {
1393 #define SOF_REUSEADDR     0x04U  /* allow local address reuse */
1394 #define SOF_KEEPALIVE     0x08U  /* keep connections alive */
1395 #define SOF_BROADCAST     0x20U  /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */
1396-#endif /* USE_LIBOS */
1397+#endif /* GAZELLE_ENABLE */
1398
1399 /* These flags are inherited (e.g. from a listen-pcb to a connection-pcb): */
1400 #define SOF_INHERITED   (SOF_REUSEADDR|SOF_KEEPALIVE)
1401diff --git a/src/include/lwip/memp.h b/src/include/lwip/memp.h
1402index 64d8f31..1763836 100644
1403--- a/src/include/lwip/memp.h
1404+++ b/src/include/lwip/memp.h
1405@@ -58,11 +58,11 @@ typedef enum {
1406 #include "lwip/priv/memp_priv.h"
1407 #include "lwip/stats.h"
1408
1409-#if USE_LIBOS
1410+#if GAZELLE_ENABLE
1411 extern PER_THREAD struct memp_desc* memp_pools[MEMP_MAX];
1412 #else
1413 extern const struct memp_desc* const memp_pools[MEMP_MAX];
1414-#endif /* USE_LIBOS */
1415+#endif /* GAZELLE_ENABLE */
1416
1417 /**
1418  * @ingroup mempool
1419@@ -96,7 +96,7 @@ extern const struct memp_desc* const memp_pools[MEMP_MAX];
1420  * To relocate a pool, declare it as extern in cc.h. Example for GCC:
1421  *   extern u8_t \_\_attribute\_\_((section(".onchip_mem"))) memp_memory_my_private_pool_base[];
1422  */
1423-#if USE_LIBOS
1424+#if GAZELLE_ENABLE
1425 #define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \
1426     PER_THREAD struct memp_desc memp_ ## name = {0}; \
1427     PER_THREAD char memp_desc_ ## name[] = desc; \
1428@@ -106,7 +106,7 @@ extern const struct memp_desc* const memp_pools[MEMP_MAX];
1429     PER_THREAD struct memp *memp_tab_ ## name = NULL; \
1430     LWIP_DECLARE_MEMP_BASE_ALIGNED(name, ((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size))));
1431
1432-#else /* USE_LIBOS */
1433+#else /* GAZELLE_ENABLE */
1434
1435 #define LWIP_MEMPOOL_DECLARE(name,num,size,desc) \
1436   LWIP_DECLARE_MEMORY_ALIGNED(memp_memory_ ## name ## _base, ((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))); \
1437@@ -124,7 +124,7 @@ extern const struct memp_desc* const memp_pools[MEMP_MAX];
1438     &memp_tab_ ## name \
1439   };
1440
1441-#endif /* USE_LIBOS */
1442+#endif /* GAZELLE_ENABLE */
1443 #endif /* MEMP_MEM_MALLOC */
1444
1445 /**
1446diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h
1447index 718816b..0376f60 100644
1448--- a/src/include/lwip/opt.h
1449+++ b/src/include/lwip/opt.h
1450@@ -3525,7 +3525,7 @@
1451 /**
1452  * EPOLL_DEBUG: Enable debugging in epoll.c.
1453  */
1454-#if !defined EPOLL_DEBUG || defined __DOXYGEN__ && USE_LIBOS
1455+#if !defined EPOLL_DEBUG || defined __DOXYGEN__ && GAZELLE_ENABLE
1456 #define EPOLL_DEBUG                    LWIP_DBG_OFF
1457 #endif
1458 /**
1459@@ -3535,7 +3535,7 @@
1460 /**
1461  * ETHDEV_DEBUG: Enable debugging in ethdev.c.
1462  */
1463-#if !defined ETHDEV_DEBUG || defined __DOXYGEN__ && USE_LIBOS
1464+#if !defined ETHDEV_DEBUG || defined __DOXYGEN__ && GAZELLE_ENABLE
1465 #define ETHDEV_DEBUG                    LWIP_DBG_OFF
1466 #endif
1467 /**
1468@@ -3545,7 +3545,7 @@
1469 /**
1470  * ETHDEV_DEBUG: Enable debugging in ethdev.c.
1471  */
1472-#if !defined SYSCALL_DEBUG || defined __DOXYGEN__ && USE_LIBOS
1473+#if !defined SYSCALL_DEBUG || defined __DOXYGEN__ && GAZELLE_ENABLE
1474 #define SYSCALL_DEBUG                    LWIP_DBG_OFF
1475 #endif
1476 /**
1477@@ -3555,7 +3555,7 @@
1478 /**
1479  * CONTROL_DEBUG: Enable debugging in control_plane.c.
1480  */
1481-#if !defined CONTROL_DEBUG || defined __DOXYGEN__ && USE_LIBOS
1482+#if !defined CONTROL_DEBUG || defined __DOXYGEN__ && GAZELLE_ENABLE
1483 #define CONTROL_DEBUG                    LWIP_DBG_ON
1484 #endif
1485 /**
1486diff --git a/src/include/lwip/pbuf.h b/src/include/lwip/pbuf.h
1487index 1124408..a2e8e01 100644
1488--- a/src/include/lwip/pbuf.h
1489+++ b/src/include/lwip/pbuf.h
1490@@ -220,7 +220,7 @@ struct pbuf {
1491   /** For incoming packets, this contains the input netif's index */
1492   u8_t if_idx;
1493
1494-#if USE_LIBOS && CHECKSUM_OFFLOAD_ALL
1495+#if GAZELLE_ENABLE && CHECKSUM_OFFLOAD_ALL
1496   /** checksum offload ol_flags */
1497   u64_t ol_flags;
1498   /* < L2 (MAC) Header Length for non-tunneling pkt. */
1499@@ -234,7 +234,7 @@ struct pbuf {
1500   u8_t in_write;
1501   u8_t head;
1502   struct pbuf *last;
1503-#endif /* USE_LIBOS CHECKSUM_OFFLOAD_SWITCH */
1504+#endif /* GAZELLE_ENABLE CHECKSUM_OFFLOAD_SWITCH */
1505
1506   /** In case the user needs to store data custom data on a pbuf */
1507   LWIP_PBUF_CUSTOM_DATA
1508@@ -287,7 +287,7 @@ void pbuf_free_ooseq(void);
1509
1510 /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
1511 #define pbuf_init()
1512-#if USE_LIBOS
1513+#if GAZELLE_ENABLE
1514 struct pbuf *lwip_alloc_pbuf(pbuf_layer layer, uint16_t length, pbuf_type type);
1515 #endif
1516 struct pbuf *pbuf_alloc(pbuf_layer l, u16_t length, pbuf_type type);
1517diff --git a/src/include/lwip/priv/memp_std.h b/src/include/lwip/priv/memp_std.h
1518index 395ac0c..66d7e4e 100644
1519--- a/src/include/lwip/priv/memp_std.h
1520+++ b/src/include/lwip/priv/memp_std.h
1521@@ -122,13 +122,13 @@ LWIP_MEMPOOL(MLD6_GROUP,     MEMP_NUM_MLD6_GROUP,      sizeof(struct mld_group),
1522 #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
1523
1524
1525-#if USE_LIBOS
1526+#if GAZELLE_ENABLE
1527 #if !LWIP_NETCONN_SEM_PER_THREAD
1528 LWIP_MEMPOOL(SYS_SEM,     MEMP_NUM_SYS_SEM,      sizeof(struct sys_sem),     "SYS_SEM")
1529 #endif
1530
1531 LWIP_MEMPOOL(SYS_MBOX,     MEMP_NUM_SYS_MBOX,      sizeof(struct sys_mbox),     "SYS_MBOX")
1532-#endif /* USE_LIBOS */
1533+#endif /* GAZELLE_ENABLE */
1534 /*
1535  * A list of pools of pbuf's used by LWIP.
1536  *
1537diff --git a/src/include/lwip/priv/tcp_priv.h b/src/include/lwip/priv/tcp_priv.h
1538index 97f799e..ddae3fd 100644
1539--- a/src/include/lwip/priv/tcp_priv.h
1540+++ b/src/include/lwip/priv/tcp_priv.h
1541@@ -340,7 +340,7 @@ extern PER_THREAD struct tcp_pcb *tcp_tw_pcbs;      /* List of all TCP PCBs in T
1542 #define NUM_TCP_PCB_LISTS               4
1543 extern PER_THREAD struct tcp_pcb ** tcp_pcb_lists[NUM_TCP_PCB_LISTS];
1544
1545-#if USE_LIBOS
1546+#if GAZELLE_ENABLE
1547 #include "reg_sock.h"
1548 static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pcb *pcb)
1549 {
1550@@ -353,7 +353,7 @@ static inline int vdev_reg_done(enum reg_ring_type reg_type, const struct tcp_pc
1551   qtuple.dst_ip     = pcb->remote_ip.addr;
1552   qtuple.dst_port   = lwip_htons(pcb->remote_port);
1553
1554-#if REUSE_IPPORT
1555+#if GAZELLE_TCP_REUSE_IPPORT
1556   if (reg_type == REG_RING_TCP_CONNECT_CLOSE) {
1557     struct tcp_pcb_listen* lpcb = pcb->listener;
1558     if (lpcb != NULL) {
1559@@ -389,7 +389,7 @@ static inline void vdev_unreg_done(const struct tcp_pcb *pcb)
1560 #define TCP_DEBUG_PCB_LISTS 0
1561 #endif
1562 #if TCP_DEBUG_PCB_LISTS
1563-#if USE_LIBOS
1564+#if GAZELLE_ENABLE
1565 #define TCP_REG(pcbs, npcb) do {\
1566                             struct tcp_pcb *tcp_tmp_pcb; \
1567                             LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", (npcb), (npcb)->local_port)); \
1568@@ -432,7 +432,7 @@ static inline void vdev_unreg_done(const struct tcp_pcb *pcb)
1569                             LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (npcb), *(pcbs))); \
1570                             } while(0)
1571
1572-#else /* USE_LIBOS */
1573+#else /* GAZELLE_ENABLE */
1574 #define TCP_REG(pcbs, npcb) do {\
1575                             struct tcp_pcb *tcp_tmp_pcb; \
1576                             LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %"U16_F"\n", (void *)(npcb), (npcb)->local_port)); \
1577@@ -465,10 +465,10 @@ static inline void vdev_unreg_done(const struct tcp_pcb *pcb)
1578                             LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", (void *)(npcb), (void *)(*(pcbs)))); \
1579                             } while(0)
1580
1581-#endif /* USE_LIBOS */
1582+#endif /* GAZELLE_ENABLE */
1583 #else /* LWIP_DEBUG */
1584
1585-#if TCP_PCB_HASH
1586+#if GAZELLE_TCP_PCB_HASH
1587 #define TCP_REG_HASH(pcbs, npcb)                   \
1588   do {                                             \
1589     u32_t idx;                                     \
1590@@ -496,9 +496,9 @@ static inline void vdev_unreg_done(const struct tcp_pcb *pcb)
1591   do {                                             \
1592     hlist_del_init(&(npcb)->tcp_node);             \
1593   } while (0)
1594-#endif /* TCP_PCB_HASH */
1595+#endif /* GAZELLE_TCP_PCB_HASH */
1596
1597-#if USE_LIBOS
1598+#if GAZELLE_ENABLE
1599 #define TCP_REG(pcbs, npcb)                        \
1600   do {                                             \
1601     if (*pcbs)                                     \
1602@@ -529,7 +529,7 @@ static inline void vdev_unreg_done(const struct tcp_pcb *pcb)
1603     (npcb)->next = NULL;                           \
1604   } while(0)
1605
1606-#else /* USE_LIBOS */
1607+#else /* GAZELLE_ENABLE */
1608 #define TCP_REG(pcbs, npcb)                        \
1609   do {                                             \
1610     (npcb)->next = *pcbs;                          \
1611@@ -556,11 +556,11 @@ static inline void vdev_unreg_done(const struct tcp_pcb *pcb)
1612     (npcb)->next = NULL;                           \
1613   } while(0)
1614
1615-#endif /* USE_LIBOS */
1616+#endif /* GAZELLE_ENABLE */
1617 #endif /* LWIP_DEBUG */
1618
1619
1620-#if TCP_PCB_HASH
1621+#if GAZELLE_TCP_PCB_HASH
1622 #define TCP_REG_ACTIVE_HASH(npcb)                  \
1623   do {                                             \
1624     TCP_REG_HASH(tcp_active_htable, npcb);         \
1625@@ -580,7 +580,7 @@ static inline void vdev_unreg_done(const struct tcp_pcb *pcb)
1626   } while (0)
1627
1628 void tcp_pcb_remove_hash(struct tcp_hash_table *htb, struct tcp_pcb *pcb);
1629-#endif /* TCP_PCB_HASH */
1630+#endif /* GAZELLE_TCP_PCB_HASH */
1631
1632 #define TCP_REG_ACTIVE(npcb)                       \
1633   do {                                             \
1634diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h
1635index 3c5b87b..58acf0f 100644
1636--- a/src/include/lwip/sockets.h
1637+++ b/src/include/lwip/sockets.h
1638@@ -57,7 +57,7 @@ extern "C" {
1639
1640 /* If your port already typedef's sa_family_t, define SA_FAMILY_T_DEFINED
1641    to prevent this code from redefining it. */
1642-#if USE_LIBOS
1643+#if GAZELLE_ENABLE
1644 #define SA_FAMILY_T_DEFINED
1645   typedef u16_t sa_family_t;
1646 #endif
1647@@ -74,7 +74,7 @@ typedef u16_t in_port_t;
1648 #if LWIP_IPV4
1649 /* members are in network byte order */
1650 struct sockaddr_in {
1651-#if !USE_LIBOS
1652+#if !GAZELLE_ENABLE
1653   u8_t            sin_len;
1654 #endif
1655   sa_family_t     sin_family;
1656@@ -97,7 +97,7 @@ struct sockaddr_in6 {
1657 #endif /* LWIP_IPV6 */
1658
1659 struct sockaddr {
1660-#if !USE_LIBOS
1661+#if !GAZELLE_ENABLE
1662   u8_t        sa_len;
1663 #endif
1664   sa_family_t sa_family;
1665@@ -198,7 +198,7 @@ struct ifreq {
1666 #define SOCK_DGRAM      2
1667 #define SOCK_RAW        3
1668
1669-#if USE_LIBOS
1670+#if GAZELLE_ENABLE
1671 #include <asm/socket.h>
1672 #else
1673 /*
1674@@ -236,7 +236,7 @@ struct ifreq {
1675  * Level number for (get/set)sockopt() to apply to socket itself.
1676  */
1677 #define  SOL_SOCKET  0xfff    /* options for socket level */
1678-#endif /* USE_LIBOS */
1679+#endif /* GAZELLE_ENABLE */
1680
1681 /*
1682  * Structure used for manipulating linger option.
1683@@ -289,20 +289,20 @@ struct linger {
1684 /*
1685  * Options for level IPPROTO_TCP
1686  */
1687-#if USE_LIBOS
1688+#if GAZELLE_ENABLE
1689 /* come from netinet/tcp.h */
1690 #define TCP_NODELAY    0x01    /* don't delay send to coalesce packets */
1691 #define TCP_KEEPALIVE  0x24    /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
1692 #define TCP_KEEPIDLE   0x04    /* set pcb->keep_idle  - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
1693 #define TCP_KEEPINTVL  0x05    /* set pcb->keep_intvl - Use seconds for get/setsockopt */
1694 #define TCP_KEEPCNT    0x06    /* set pcb->keep_cnt   - Use number of probes sent for get/setsockopt */
1695-#else /* USE_LIBOS */
1696+#else /* GAZELLE_ENABLE */
1697 #define TCP_NODELAY    0x01    /* don't delay send to coalesce packets */
1698 #define TCP_KEEPALIVE  0x02    /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */
1699 #define TCP_KEEPIDLE   0x03    /* set pcb->keep_idle  - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */
1700 #define TCP_KEEPINTVL  0x04    /* set pcb->keep_intvl - Use seconds for get/setsockopt */
1701 #define TCP_KEEPCNT    0x05    /* set pcb->keep_cnt   - Use number of probes sent for get/setsockopt */
1702-#endif /* USE_LIBOS */
1703+#endif /* GAZELLE_ENABLE */
1704 #endif /* LWIP_TCP */
1705
1706 #if LWIP_IPV6
1707@@ -505,13 +505,13 @@ typedef struct fd_set
1708   unsigned char fd_bits [(FD_SETSIZE+7)/8];
1709 } fd_set;
1710
1711-#elif FD_SETSIZE < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN) && !USE_LIBOS
1712+#elif FD_SETSIZE < (LWIP_SOCKET_OFFSET + MEMP_NUM_NETCONN) && !GAZELLE_ENABLE
1713 #error "external FD_SETSIZE too small for number of sockets"
1714 #else
1715 #define LWIP_SELECT_MAXNFDS FD_SETSIZE
1716 #endif /* FD_SET */
1717
1718-#if USE_LIBOS
1719+#if GAZELLE_ENABLE
1720 #if !defined(POLLIN) && !defined(POLLOUT)
1721 /* come from bits/poll.h */
1722 #define POLLIN     0x001
1723@@ -526,7 +526,7 @@ typedef struct fd_set
1724 #define POLLWRBAND 0x200
1725 #define POLLHUP    0x010
1726 #endif
1727-#endif /* USE_LIBOS */
1728+#endif /* GAZELLE_ENABLE */
1729
1730 #if LWIP_SOCKET_POLL
1731 /* poll-related defines and types */
1732@@ -664,13 +664,13 @@ int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptse
1733 int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout);
1734 #endif
1735
1736-#if USE_LIBOS
1737+#if GAZELLE_ENABLE
1738 int lwip_ioctl(int s, long cmd, ...);
1739 int lwip_fcntl(int s, int cmd, int val);
1740 #else
1741 int lwip_ioctl(int s, long cmd, void *argp);
1742 int lwip_fcntl(int s, int cmd, int val);
1743-#endif /* USE_LIBOS */
1744+#endif /* GAZELLE_ENABLE */
1745
1746 const char *lwip_inet_ntop(int af, const void *src, char *dst, socklen_t size);
1747 int lwip_inet_pton(int af, const char *src, void *dst);
1748@@ -740,7 +740,7 @@ int lwip_inet_pton(int af, const char *src, void *dst);
1749 /** @ingroup socket */
1750 #define close(s)                                  lwip_close(s)
1751
1752-#if USE_LIBOS
1753+#if GAZELLE_ENABLE
1754 #define fcntl(s,cmd...)                           lwip_fcntl(s,cmd)
1755 #define ioctl(s,cmd...)                           lwip_ioctl(s,cmd)
1756 #else
1757@@ -748,7 +748,7 @@ int lwip_inet_pton(int af, const char *src, void *dst);
1758 #define fcntl(s,cmd,val)                          lwip_fcntl(s,cmd,val)
1759 /** @ingroup socket */
1760 #define ioctl(s,cmd,argp)                         lwip_ioctl(s,cmd,argp)
1761-#endif /* USE_LIBOS */
1762+#endif /* GAZELLE_ENABLE */
1763
1764 #endif /* LWIP_POSIX_SOCKETS_IO_NAMES */
1765 #endif /* LWIP_COMPAT_SOCKETS != 2 */
1766diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h
1767index c2018cb..b822f40 100644
1768--- a/src/include/lwip/tcp.h
1769+++ b/src/include/lwip/tcp.h
1770@@ -51,7 +51,7 @@
1771 #include "lwip/ip6.h"
1772 #include "lwip/ip6_addr.h"
1773
1774-#if TCP_PCB_HASH
1775+#if GAZELLE_TCP_PCB_HASH
1776 #include "lwip/sys.h"
1777 #include "hlist.h"
1778 #endif
1779@@ -214,7 +214,7 @@ typedef u16_t tcpflags_t;
1780 /**
1781  * members common to struct tcp_pcb and struct tcp_listen_pcb
1782  */
1783-#if USE_LIBOS
1784+#if GAZELLE_ENABLE
1785 #define TCP_PCB_COMMON(type) \
1786   type *next; /* for the linked list */ \
1787   type *prev; /* for the linked list */ \
1788@@ -225,7 +225,7 @@ typedef u16_t tcpflags_t;
1789   /* ports are in host byte order */ \
1790   u16_t local_port
1791
1792-#else /* USE_LIBOS */
1793+#else /* GAZELLE_ENABLE */
1794 #define TCP_PCB_COMMON(type) \
1795   type *next; /* for the linked list */ \
1796   void *callback_arg; \
1797@@ -234,7 +234,7 @@ typedef u16_t tcpflags_t;
1798   u8_t prio; \
1799   /* ports are in host byte order */ \
1800   u16_t local_port
1801-#endif /* USE_LIBOS */
1802+#endif /* GAZELLE_ENABLE */
1803
1804 /** the TCP protocol control block for listening pcbs */
1805 struct tcp_pcb_listen {
1806@@ -253,7 +253,7 @@ struct tcp_pcb_listen {
1807   u8_t accepts_pending;
1808 #endif /* TCP_LISTEN_BACKLOG */
1809
1810-#if REUSE_IPPORT
1811+#if GAZELLE_TCP_REUSE_IPPORT
1812   struct tcp_pcb_listen* next_same_port_pcb;
1813   u16_t connect_num;
1814   int socket_fd;
1815@@ -269,7 +269,7 @@ struct tcp_pcb {
1816   IP_PCB;
1817 /** protocol specific PCB members */
1818   TCP_PCB_COMMON(struct tcp_pcb);
1819-#if TCP_PCB_HASH
1820+#if GAZELLE_TCP_PCB_HASH
1821   struct hlist_node tcp_node;
1822 #endif
1823
1824@@ -421,7 +421,7 @@ struct tcp_pcb {
1825   u8_t need_tso_send;
1826 };
1827
1828-#if TCP_PCB_HASH
1829+#if GAZELLE_TCP_PCB_HASH
1830 #define TCP_HTABLE_SIZE MEMP_NUM_NETCONN*12
1831
1832 struct tcp_hashbucket
1833@@ -471,7 +471,7 @@ static inline unsigned int jhash_3words(unsigned int a, unsigned int b, unsigned
1834 #define tcppcb_hlist_for_each(tcppcb, node, list) \
1835   hlist_for_each_entry(tcppcb, node, list, tcp_node)
1836
1837-#endif /* TCP_PCB_HASH */
1838+#endif /* GAZELLE_TCP_PCB_HASH */
1839
1840 #if LWIP_EVENT_API
1841
1842diff --git a/src/include/lwip/timeouts.h b/src/include/lwip/timeouts.h
1843index b451554..f7ffc5e 100644
1844--- a/src/include/lwip/timeouts.h
1845+++ b/src/include/lwip/timeouts.h
1846@@ -119,9 +119,9 @@ struct sys_timeo** sys_timeouts_get_next_timeout(void);
1847 void lwip_cyclic_timer(void *arg);
1848 #endif
1849
1850-#if USE_LIBOS
1851+#if GAZELLE_ENABLE
1852 void sys_timer_run(void);
1853-#endif /* USE_LIBOS */
1854+#endif /* GAZELLE_ENABLE */
1855
1856 #endif /* LWIP_TIMERS */
1857
1858diff --git a/src/include/lwiplog.h b/src/include/lwiplog.h
1859index 011ed21..f278ff4 100644
1860--- a/src/include/lwiplog.h
1861+++ b/src/include/lwiplog.h
1862@@ -41,7 +41,7 @@
1863
1864 #include "lwipopts.h"
1865
1866-#if USE_DPDK_LOG
1867+#if GAZELLE_USE_DPDK_LOG
1868
1869 #define LWIP_LOG_WARN   LWIP_DBG_LEVEL_WARNING
1870 #define LWIP_LOG_ERROR  LWIP_DBG_LEVEL_SERIOUS
1871@@ -75,6 +75,6 @@ do { LWIP_PLATFORM_LOG(LWIP_LOG_FATAL, "Assertion \"%s\" failed at line %d in %s
1872
1873 #define LWIP_PLATFORM_LOG(debug, message)
1874
1875-#endif /* USE_DPDK_LOG */
1876+#endif /* GAZELLE_USE_DPDK_LOG */
1877
1878 #endif /* __LWIPLOG_H__ */
1879diff --git a/src/include/lwipopts.h b/src/include/lwipopts.h
1880index be58ec3..9cc93bc 100644
1881--- a/src/include/lwipopts.h
1882+++ b/src/include/lwipopts.h
1883@@ -33,182 +33,204 @@
1884 #ifndef __LWIPOPTS_H__
1885 #define __LWIPOPTS_H__
1886
1887-#define LWIP_TCPIP_CORE_LOCKING 1
1888-
1889-#define LWIP_NETCONN_SEM_PER_THREAD 0
1890-
1891-#define LWIP_TCP 1
1892-
1893-#define LWIP_SO_SENTIMEO 0
1894-
1895-#define LIP_SO_LINGER 0
1896-
1897-#define MEMP_USE_CUSTOM_POOLS 0
1898-#define MEM_USE_POOLS 0
1899-
1900-#define PER_TCP_PCB_BUFFER (16 * 128)
1901-
1902-#define MAX_CLIENTS (20000)
1903-
1904-#define RESERVED_CLIENTS (2000)
1905-
1906-#define MEMP_NUM_TCP_PCB (MAX_CLIENTS + RESERVED_CLIENTS)
1907-
1908-/* we use PBUF_POOL instead of PBUF_RAM in tcp_write, so reduce PBUF_RAM size,
1909- * and do NOT let PBUF_POOL_BUFSIZE less then TCP_MSS
1910+/*
1911+   -------------------------------------
1912+   ---------- gazelle options ----------
1913+   -------------------------------------
1914 */
1915-#define MEM_SIZE (((PER_TCP_PCB_BUFFER + 128) * MEMP_NUM_TCP_SEG) >> 2)
1916+#define LWIP_PERF 1
1917+#define LWIP_RECORD_PERF 0
1918
1919-#define MEMP_NUM_TCP_PCB_LISTEN 3000
1920+//#define LWIP_DEBUG 1
1921+#define GAZELLE_USE_DPDK_LOG 1
1922
1923-#define MEMP_NUM_TCP_SEG (128 * 128 * 2)
1924+#define GAZELLE_ENABLE 1
1925+#define PER_THREAD __thread
1926
1927-#define MEMP_NUM_NETCONN (MAX_CLIENTS + RESERVED_CLIENTS)
1928+#define FRAME_MTU 1500
1929
1930-#define MEMP_NUM_SYS_SEM (MAX_CLIENTS + RESERVED_CLIENTS)
1931+#define GAZELLE_TCP_PCB_HASH 1
1932
1933-#define MEMP_NUM_SYS_MBOX (MAX_CLIENTS + RESERVED_CLIENTS)
1934+#define GAZELLE_TCP_MAX_DATA_ACK_NUM 256
1935
1936-#define PBUF_POOL_SIZE (MAX_CLIENTS * 2)
1937+#define GAZELLE_TCP_MAX_PBUF_CHAIN_LEN 40
1938
1939-#define MEMP_MEM_MALLOC 0
1940+/*
1941+   ----------------------------------
1942+   ---------- NIC offloads ----------
1943+   ----------------------------------
1944+*/
1945+#define LWIP_CHECKSUM_CTRL_PER_NETIF 1 /* checksum ability check before checksum*/
1946
1947-#define LWIP_ARP 1
1948+// rx cksum
1949+#define CHECKSUM_CHECK_IP     1 /*  master switch */
1950+#define CHECKSUM_CHECK_TCP    1 /*  master switch */
1951+// tx cksum
1952+#define CHECKSUM_GEN_IP       1 /*  master switch */
1953+#define CHECKSUM_GEN_TCP      1 /* master switch */
1954
1955-#define ETHARP_SUPPORT_STATIC_ENTRIES 1
1956+// rx offload cksum
1957+#define CHECKSUM_CHECK_IP_HW  (1 && CHECKSUM_CHECK_IP) /*  hardware switch */
1958+#define CHECKSUM_CHECK_TCP_HW (1 && CHECKSUM_CHECK_TCP) /*  hardware switch */
1959+// tx offload cksum
1960+#define CHECKSUM_GEN_IP_HW    (1 && CHECKSUM_GEN_IP) /* hardware switch */
1961+#define CHECKSUM_GEN_TCP_HW   (1 && CHECKSUM_GEN_TCP) /*  hardware switch */
1962
1963-#define LWIP_IPV4 1
1964+#define CHECKSUM_OFFLOAD_ALL (CHECKSUM_GEN_IP_HW || CHECKSUM_GEN_TCP_HW || CHECKSUM_CHECK_IP_HW || CHECKSUM_CHECK_TCP_HW)
1965
1966-#define IP_FORWARD 0
1967
1968-#define IP_REASSEMBLY 1
1969+/*
1970+   ---------------------------------------
1971+   ---------- lwIP APIs options ----------
1972+   ---------------------------------------
1973+*/
1974+#define LWIP_TCPIP_CORE_LOCKING 1
1975
1976-#define LWIP_UDP 0
1977+#define LWIP_TCPIP_TIMEOUT 0
1978
1979-#define LWIP_TCP 1
1980+#define TCPIP_MBOX_SIZE (MEMP_NUM_TCPIP_MSG_API)
1981
1982-#define IP_HLEN 20
1983+#define LWIP_NETCONN 1
1984
1985-#define TCP_HLEN 20
1986+#define LWIP_NETCONN_SEM_PER_THREAD 0
1987
1988-#define FRAME_MTU 1500
1989+#define LWIP_STATS 1
1990
1991-#define TCP_MSS (FRAME_MTU - IP_HLEN - TCP_HLEN)
1992+#define LWIP_STATS_DISPLAY 1
1993
1994-#define TCP_WND (2500 * TCP_MSS)
1995+#define LWIP_TIMERS 1
1996
1997-#define TCP_SND_BUF (2500 * TCP_MSS)
1998+#define LWIP_TIMEVAL_PRIVATE 0
1999
2000-#define TCP_SND_QUEUELEN (8191)
2001
2002-#define TCP_SNDLOWAT (TCP_SND_BUF / 5)
2003+/*
2004+   ------------------------------------------------
2005+   ---------- Internal Memory Pool Sizes ----------
2006+   ------------------------------------------------
2007+*/
2008+#define GAZELLE_MAX_CLIENTS (20000)
2009+#define GAZELLE_RESERVED_CLIENTS (2000)
2010
2011-#define TCP_SNDQUEUELOWAT (TCP_SND_QUEUELEN / 5)
2012+#define LWIP_SUPPORT_CUSTOM_PBUF 1
2013
2014-#define TCP_LISTEN_BACKLOG 1
2015+#define MEMP_MEM_MALLOC 0
2016+#define MEM_LIBC_MALLOC 0
2017+#define MEM_USE_POOLS 0
2018+#define MEMP_USE_CUSTOM_POOLS 0
2019
2020-#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
2021+#define MEMP_NUM_TCP_PCB_LISTEN 3000
2022
2023-#define TCP_OVERSIZE 0
2024+#define MEMP_NUM_TCP_PCB (GAZELLE_MAX_CLIENTS + GAZELLE_RESERVED_CLIENTS)
2025
2026-#define LWIP_NETIF_API 1
2027+#define MEMP_NUM_NETCONN (GAZELLE_MAX_CLIENTS + GAZELLE_RESERVED_CLIENTS)
2028
2029-#define DEFAULT_TCP_RECVMBOX_SIZE 4096
2030+#define MEMP_NUM_SYS_SEM (GAZELLE_MAX_CLIENTS + GAZELLE_RESERVED_CLIENTS)
2031
2032-#define DEFAULT_ACCEPTMBOX_SIZE 1024
2033+#define MEMP_NUM_SYS_MBOX (GAZELLE_MAX_CLIENTS + GAZELLE_RESERVED_CLIENTS)
2034
2035-#define LWIP_NETCONN 1
2036+#define PBUF_POOL_SIZE (GAZELLE_MAX_CLIENTS * 2)
2037
2038-#define LWIP_TCPIP_TIMEOUT 0
2039+/* we use PBUF_POOL instead of PBUF_RAM in tcp_write, so reduce PBUF_RAM size,
2040+ * and do NOT let PBUF_POOL_BUFSIZE less then TCP_MSS
2041+*/
2042+#define MEMP_NUM_TCP_SEG (128 * 128 * 2)
2043+#define PER_TCP_PCB_BUFFER (16 * 128)
2044+#define MEM_SIZE (((PER_TCP_PCB_BUFFER + 128) * MEMP_NUM_TCP_SEG) >> 2)
2045
2046-#define LWIP_SOCKET 1
2047
2048-#define LWIP_TCP_KEEPALIVE 1
2049+/*
2050+   ---------------------------------
2051+   ---------- ARP options ----------
2052+   ---------------------------------
2053+*/
2054+#define LWIP_ARP 1
2055
2056-#define LWIP_STATS 1
2057+#define ARP_TABLE_SIZE 512
2058
2059-#define LWIP_STATS_DISPLAY 1
2060+#define ARP_QUEUEING 1
2061
2062-#define LWIP_TIMEVAL_PRIVATE 0
2063+#define ARP_QUEUE_LEN 32
2064
2065-#define USE_LIBOS 1
2066+#define ETHARP_SUPPORT_STATIC_ENTRIES 1
2067
2068-//#define LWIP_DEBUG 1
2069
2070-#define LWIP_PERF 1
2071+/*
2072+   ---------------------------------
2073+   ---------- IP options ----------
2074+   ---------------------------------
2075+*/
2076+#define LWIP_IPV4 1
2077
2078-#define LWIP_RECORD_PERF 0
2079+#define IP_FORWARD 0
2080
2081-#define LWIP_SOCKET_POLL   0
2082+#define IP_REASSEMBLY 1
2083
2084-#define USE_LIBOS_ZC_RING 0
2085+#define IP_HLEN 20
2086
2087-#define REUSE_IPPORT 1
2088
2089-#define MAX_CONN_NUM_PER_THREAD 65535
2090+/*
2091+   ---------------------------------
2092+   ---------- UDP options ----------
2093+   ---------------------------------
2094+*/
2095+#define LWIP_UDP 0
2096
2097-#define SO_REUSE 1
2098
2099-#define SIOCSHIWAT 1
2100+/*
2101+   ---------------------------------
2102+   ---------- TCP options ----------
2103+   ---------------------------------
2104+*/
2105+#define LWIP_TCP 1
2106
2107-#define O_NONBLOCK 04000 /* same as define in bits/fcntl-linux.h */
2108+#define TCP_HLEN 20
2109
2110-#define O_NDELAY O_NONBLOCK
2111+#define DEFAULT_ACCEPTMBOX_SIZE 1024
2112+#define DEFAULT_TCP_RECVMBOX_SIZE 4096
2113
2114-#define FIONBIO 0x5421 /* same as define in asm-generic/ioctls.h */
2115+#define TCP_LISTEN_BACKLOG 1
2116+#define TCP_DEFAULT_LISTEN_BACKLOG 0xff
2117
2118-#define LWIP_SUPPORT_CUSTOM_PBUF 1
2119+#define TCP_OVERSIZE 0
2120+#define LWIP_NETIF_TX_SINGLE_PBUF 0
2121
2122-#define MEM_LIBC_MALLOC 0
2123+#define TCP_MSS (FRAME_MTU - IP_HLEN - TCP_HLEN)
2124
2125-#define LWIP_TIMERS 1
2126+#define TCP_WND (2500 * TCP_MSS)
2127
2128-#define TCPIP_MBOX_SIZE (MEMP_NUM_TCPIP_MSG_API)
2129+#define TCP_SND_BUF (2500 * TCP_MSS)
2130
2131-#define TCP_PCB_HASH 1
2132+#define TCP_SND_QUEUELEN (8191)
2133
2134-#define USE_DPDK_LOG 1
2135+#define TCP_SNDLOWAT (TCP_SND_BUF / 5)
2136
2137-#define LWIP_EPOOL_WAIT_MAX_EVENTS 30
2138+#define TCP_SNDQUEUELOWAT (TCP_SND_QUEUELEN / 5)
2139
2140-#define ARP_TABLE_SIZE 512
2141+#define LWIP_TCP_KEEPALIVE 1
2142
2143-#define ARP_QUEUEING 1
2144+#define GAZELLE_TCP_MAX_CONN_PER_THREAD 65535
2145+#define GAZELLE_TCP_REUSE_IPPORT 1
2146
2147-#define ARP_QUEUE_LEN 32
2148
2149-#define MAX_PBUF_CHAIN_LEN 40
2150+/*
2151+   ------------------------------------
2152+   ---------- Socket options ----------
2153+   ------------------------------------
2154+*/
2155+#define LWIP_SOCKET 1
2156
2157-#define MIN_TSO_SEG_LEN 256
2158+#define LWIP_SOCKET_POLL   0
2159
2160-#define MAX_DATA_ACK_NUM 256
2161+#define LWIP_SO_SNDTIMEO 0
2162
2163-/*  ---------------------------------------
2164- *  -------      NIC offloads      --------
2165- *  ---------------------------------------
2166- */
2167-#define LWIP_CHECKSUM_CTRL_PER_NETIF 1 /* checksum ability check before checksum*/
2168+#define LWIP_SO_LINGER 0
2169
2170-// rx cksum
2171-#define CHECKSUM_CHECK_IP     1 /*  master switch */
2172-#define CHECKSUM_CHECK_TCP    1 /*  master switch */
2173-// tx cksum
2174-#define CHECKSUM_GEN_IP       1 /*  master switch */
2175-#define CHECKSUM_GEN_TCP      1 /* master switch */
2176+#define SO_REUSE 1
2177
2178-// rx offload cksum
2179-#define CHECKSUM_CHECK_IP_HW  (1 && CHECKSUM_CHECK_IP) /*  hardware switch */
2180-#define CHECKSUM_CHECK_TCP_HW (1 && CHECKSUM_CHECK_TCP) /*  hardware switch */
2181-// tx offload cksum
2182-#define CHECKSUM_GEN_IP_HW    (1 && CHECKSUM_GEN_IP) /* hardware switch */
2183-#define CHECKSUM_GEN_TCP_HW   (1 && CHECKSUM_GEN_TCP) /*  hardware switch */
2184+#define FIONBIO 0x5421 /* same as define in asm-generic/ioctls.h */
2185
2186-#define CHECKSUM_OFFLOAD_ALL (CHECKSUM_GEN_IP_HW || CHECKSUM_GEN_TCP_HW || CHECKSUM_CHECK_IP_HW || CHECKSUM_CHECK_TCP_HW)
2187+#define O_NONBLOCK 04000 /* same as define in bits/fcntl-linux.h */
2188
2189-#if USE_LIBOS
2190-#define PER_THREAD __thread
2191-#else
2192-#define PER_THREAD
2193-#endif
2194+#define SIOCSHIWAT 1
2195
2196 #endif /* __LWIPOPTS_H__ */
2197diff --git a/src/include/lwipsock.h b/src/include/lwipsock.h
2198index a807e3e..f78c9cf 100644
2199--- a/src/include/lwipsock.h
2200+++ b/src/include/lwipsock.h
2201@@ -59,7 +59,7 @@ union lwip_sock_lastdata {
2202   struct pbuf *pbuf;
2203 };
2204
2205-#if USE_LIBOS
2206+#if GAZELLE_ENABLE
2207 struct protocol_stack;
2208 struct wakeup_poll;
2209 struct rte_ring;
2210@@ -92,7 +92,7 @@ struct lwip_sock {
2211 #define LWIP_SOCK_FD_FREE_FREE 2
2212 #endif
2213
2214-#if USE_LIBOS
2215+#if GAZELLE_ENABLE
2216   char pad0 __rte_cache_aligned;
2217   /* app thread use */
2218   struct pbuf *recv_lastdata; /* unread data in one pbuf */
2219@@ -131,7 +131,7 @@ struct lwip_sock {
2220  * --------------- LIBNET references ----------------
2221  * --------------------------------------------------
2222  */
2223-#if USE_LIBOS
2224+#if GAZELLE_ENABLE
2225 extern uint32_t sockets_num;
2226 extern struct lwip_sock *sockets;
2227 extern void gazelle_connected_callback(struct netconn *conn);
2228@@ -141,7 +141,7 @@ extern struct pbuf *write_lwip_data(struct lwip_sock *sock, uint16_t remain_size
2229 extern void gazelle_init_sock(int32_t fd);
2230 extern void gazelle_clean_sock(int32_t fd);
2231 extern void write_lwip_over(struct lwip_sock *sock);
2232-#endif /* USE_LIBOS */
2233+#endif /* GAZELLE_ENABLE */
2234
2235 struct lwip_sock *get_socket(int s);
2236 struct lwip_sock *get_socket_by_fd(int s);
2237diff --git a/src/netif/ethernet.c b/src/netif/ethernet.c
2238index ab976a8..fd13f00 100644
2239--- a/src/netif/ethernet.c
2240+++ b/src/netif/ethernet.c
2241@@ -56,7 +56,7 @@
2242 #include "netif/ppp/pppoe.h"
2243 #endif /* PPPOE_SUPPORT */
2244
2245-#if USE_LIBOS && (CHECKSUM_GEN_TCP_HW || CHECKSUM_GEN_IP_HW)
2246+#if GAZELLE_ENABLE && (CHECKSUM_GEN_TCP_HW || CHECKSUM_GEN_IP_HW)
2247 #include "dpdk_cksum.h"
2248 #endif
2249
2250--
22512.33.0
2252
2253