summaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'stacks/lwip_stack/src/include')
-rw-r--r--stacks/lwip_stack/src/include/common_func.h140
-rw-r--r--stacks/lwip_stack/src/include/common_mem_api.h134
-rw-r--r--stacks/lwip_stack/src/include/common_mem_base_type.h85
-rw-r--r--stacks/lwip_stack/src/include/common_mem_buf.h78
-rw-r--r--stacks/lwip_stack/src/include/common_mem_common.h25
-rw-r--r--stacks/lwip_stack/src/include/common_mem_mbuf.h40
-rw-r--r--stacks/lwip_stack/src/include/common_mem_mempool.h25
-rw-r--r--stacks/lwip_stack/src/include/common_mem_pal_memconfig.h26
-rw-r--r--stacks/lwip_stack/src/include/common_mem_rwlock.h25
-rw-r--r--stacks/lwip_stack/src/include/common_mem_spinlock.h38
-rw-r--r--stacks/lwip_stack/src/include/nsfw_msg.h201
-rw-r--r--stacks/lwip_stack/src/include/nsfw_msg_api.h305
-rw-r--r--stacks/lwip_stack/src/include/nsfw_mt_config.h63
-rw-r--r--stacks/lwip_stack/src/include/nsfw_rti.h49
-rw-r--r--stacks/lwip_stack/src/include/nstack_dmm_adpt.h64
15 files changed, 1298 insertions, 0 deletions
diff --git a/stacks/lwip_stack/src/include/common_func.h b/stacks/lwip_stack/src/include/common_func.h
new file mode 100644
index 0000000..db1aee7
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_func.h
@@ -0,0 +1,140 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _RTE_COMM_FUNC_H_
+#define _RTE_COMM_FUNC_H_
+
+#ifdef HAL_LIB
+
+#else
+#include "common_mem_rwlock.h"
+
+#define common_mem_rwlock_t rte_rwlock_t
+#define common_mem_spinlock_t rte_spinlock_t
+ //typedef rte_rwlock_t common_mem_rwlock_t;
+
+#define nsfw_write_lock(plock) rte_rwlock_write_lock(plock)
+#define nsfw_write_unlock(plock) rte_rwlock_write_unlock(plock)
+#define nsfw_read_lock(plock) rte_rwlock_read_lock(plock)
+#define nsfw_read_unlock(plock) rte_rwlock_read_unlock(plock)
+
+#define common_mem_align32pow2 rte_align32pow2
+
+#define common_mem_atomic32_cmpset rte_atomic32_cmpset
+#define common_mem_pause rte_pause
+
+#define COMMON_MEM_MAX_MEMZONE RTE_MAX_MEMZONE
+
+#define common_mem_atomic32_t rte_atomic32_t
+
+#define common_mem_memseg rte_memseg
+#define common_mem_mem_config rte_mem_config
+
+#define common_mem_pal_get_configuration rte_eal_get_configuration
+
+ //#define commem_mem_pal_module_info rte_eal_module_info
+ //
+#define common_mem_pal_init rte_eal_init
+
+#define COMMON_MEM_MEMPOOL_NAMESIZE RTE_MEMPOOL_NAMESIZE
+
+#define common_mem_memzone_lookup rte_memzone_lookup
+#define common_mem_memzone rte_memzone
+#define common_mem_atomic32_add_return rte_atomic32_add_return
+
+#define common_mem_spinlock_init rte_spinlock_init
+#define common_mem_spinlock_lock rte_spinlock_lock
+#define common_mem_spinlock_unlock rte_spinlock_unlock
+
+#define common_mem_memzone_free rte_memzone_free
+#define common_mem_pktmbuf_pool_create rte_pktmbuf_pool_create
+
+#define common_mem_pktmbuf_alloc rte_pktmbuf_alloc
+
+#define common_mem_mempool rte_mempool
+
+#define common_mem_pktmbuf_free rte_pktmbuf_free
+#define common_mem_mbuf rte_mbuf
+
+#define common_mem_mempool_lookup rte_mempool_lookup
+
+#define common_mem_ring_get_memsize rte_ring_get_memsize
+#define common_mem_ring rte_ring
+
+#define COMMON_MEM_MAX_MEMSEG RTE_MAX_MEMSEG
+
+#define common_mem_memzone_reserve rte_memzone_reserve
+#define common_mem_rwlock_read_lock rte_rwlock_read_lock
+#define common_mem_rwlock_read_unlock rte_rwlock_read_unlock
+
+#define common_mem_rwlock_write_lock rte_rwlock_write_lock
+#define common_mem_rwlock_write_unlock rte_rwlock_write_unlock
+#define common_mem_spinlock_trylock rte_spinlock_trylock
+
+#define common_mem_socket_id rte_socket_id
+#define common_mem_malloc_socket_stats rte_malloc_socket_stats
+
+#define COMMON_MEM_MIN RTE_MIN
+
+#define common_pal_module_init nscomm_pal_module_init
+#define common_memzone_data_reserve_name nscomm_memzone_data_reserve_name
+#define common_memzone_data_lookup_name nscomm_memzone_data_lookup_name
+
+#define common_dump_stack rte_dump_stack
+#define COMMON_PKTMBUF_HEADROOM RTE_PKTMBUF_HEADROOM
+
+#define common_pktmbuf_mtod rte_pktmbuf_mtod
+#define common_memcpy rte_memcpy
+#define common_spinlock_try_lock_with_pid dmm_spinlock_try_lock_with_pid
+#define common_spinlock_unlock rte_spinlock_unlock
+#define common_atomic64_t rte_atomic64_t
+#define common_atomic64_inc rte_atomic64_inc
+#define common_atomic64_read rte_atomic64_read
+#define common_atomic64_dec rte_atomic64_dec
+#define common_mbuf_refcnt_set rte_mbuf_refcnt_set
+#define common_mbuf_refcnt_read rte_mbuf_refcnt_read
+#define common_exit rte_exit
+#define COMMON_CACHE_LINE_SIZE RTE_CACHE_LINE_SIZE
+#define common_eal_process_type rte_eal_process_type
+#define COMMON_PROC_PRIMARY RTE_PROC_PRIMARY
+
+void dmm_addr_print(void);
+
+#define NSFW_NAME_LENCHECK_RET(name, desc) \
+ { \
+ i32 inamelen = strlen(name); \
+ if (inamelen >= NSFW_MEM_APPNAME_LENTH) \
+ { \
+ NSRTP_LOGERR("name length check fail]desc=%s,name len=%d,expected max=%d", \
+ #desc, inamelen, NSFW_MEM_APPNAME_LENTH); \
+ return NSFW_MEM_ERR; \
+ } \
+ }
+
+#define NSFW_NAME_LENCHECK_RET_NULL(name, desc) \
+ { \
+ i32 inamelen = strlen(name); \
+ if (inamelen >= NSFW_MEM_APPNAME_LENTH) \
+ { \
+ NSRTP_LOGERR("name length check fail]desc=%s,name len=%d,expected max=%d", \
+ #desc, inamelen, NSFW_MEM_APPNAME_LENTH); \
+ return NULL; \
+ } \
+ }
+
+#endif
+
+#endif // _RTE_COMM_FUNC_H_
diff --git a/stacks/lwip_stack/src/include/common_mem_api.h b/stacks/lwip_stack/src/include/common_mem_api.h
new file mode 100644
index 0000000..a799677
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_mem_api.h
@@ -0,0 +1,134 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __COMMON_MEM_API_H__
+#define __COMMON_MEM_API_H__
+
+#ifdef HAL_LIB
+#else
+
+#include "rte_atomic.h"
+#include "common_mem_spinlock.h"
+#include <sys/types.h>
+#include <unistd.h>
+#include <semaphore.h>
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#ifndef NSTACK_LINT_CODE_DISABLE
+#define NSTACK_LINT_CODE_DISABLE(code) /*lint -e#code */
+#endif
+
+#ifndef NSTACK_LINT_CODE_ENABLE
+#define NSTACK_LINT_CODE_ENABLE(code) /*lint +e#code */
+#endif
+
+#define SYS_MBOX_NULL (sys_mbox_t)0
+
+typedef sem_t *sys_sem_t_v1;
+typedef sem_t sys_sem_st_v1;
+typedef struct queue *sys_mbox_t;
+
+typedef rte_spinlock_t *sys_sem_t_v2;
+typedef rte_spinlock_t sys_sem_st_v2;
+
+#ifndef u32_t
+typedef uint32_t u32_t;
+#endif
+
+#ifndef u8_t
+typedef uint8_t u8_t;
+#endif
+
+#ifndef s8_t
+typedef int8_t s8_t;
+#endif
+
+#ifndef err_t
+typedef s8_t err_t;
+#endif
+
+/** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */
+#define SYS_ARCH_TIMEOUT 0xffffffffUL
+
+/** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate.
+ * For now we use the same magic value, but we allow this to change in future.
+ */
+#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT
+
+void sys_sem_signal_s_v2(sys_sem_t_v2 sem);
+void sys_sem_init_v2(sys_sem_t_v2 sem);
+u32_t sys_arch_sem_trywait_v2(sys_sem_t_v2 * sem);
+
+u32_t sys_arch_sem_wait_s_v2(sys_sem_t_v2 sem);
+
+#define SYS_HOST_INITIAL_PID 1
+extern volatile pid_t g_sys_host_pid;
+pid_t sys_get_hostpid_from_file(pid_t pid);
+
+u32_t sys_now(void);
+
+#define sys_sem_t sys_sem_t_v2
+#define sys_sem_st sys_sem_st_v2
+#define sys_sem_new(sem, count) sys_sem_new_v2(sem, count)
+#define sys_sem_free(sem) sys_sem_free_v2(sem)
+#define sys_sem_signal(sem) sys_sem_signal_v2(sem)
+#define sys_arch_sem_wait(sem, timeout) sys_arch_sem_wait_v2(sem)
+#define sys_arch_sem_trywait(sem) sys_arch_sem_trywait_v2(sem)
+
+#define sys_sem_init(sem) sys_sem_init_v2(sem)
+#define sys_sem_s_signal(sem) sys_sem_signal_s_v2(sem)
+#define sys_arch_sem_s_wait(sem, timeout) sys_arch_sem_wait_s_v2(sem)
+#define sys_arch_lock_with_pid(sem) (void)sys_arch_lock_with_pid_v2(sem)
+
+#define BUF_SIZE_FILEPATH 256
+#define STR_PID "pid:"
+#define READ_FILE_BUFLEN 512
+
+extern pid_t sys_get_hostpid_from_file(pid_t pid);
+extern pid_t get_hostpid_from_file(u32_t pid);
+extern void get_exec_name_by_pid(pid_t pid, char *task_name,
+ int task_name_len);
+
+static inline u32_t sys_arch_lock_with_pid_v2(sys_sem_t_v2 sem)
+{
+ if (SYS_HOST_INITIAL_PID == g_sys_host_pid)
+ (void) sys_get_hostpid_from_file(getpid());
+ dmm_spinlock_lock_with_pid(sem, g_sys_host_pid);
+ return 0;
+}
+
+#define NSTACK_SEM_MALLOC(sys_sem,count) \
+{ \
+ rte_spinlock_init(&(sys_sem)); \
+ if (!(count)) \
+ { \
+ rte_spinlock_lock(&(sys_sem)); \
+ } \
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+#endif
+
+#endif /* __COMMON_MEM_API_H__ */
diff --git a/stacks/lwip_stack/src/include/common_mem_base_type.h b/stacks/lwip_stack/src/include/common_mem_base_type.h
new file mode 100644
index 0000000..01707d9
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_mem_base_type.h
@@ -0,0 +1,85 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _COMMON_MEM_BASE_TYPE_H_
+#define _COMMON_MEM_BASE_TYPE_H_
+
+#ifdef HAL_LIB
+
+#else
+
+#define ALIGN_TYPE uint64_t
+#define PTR_ALIGN_TYPE uint64_t
+
+/*alignment define*/
+#define ALIGNMENT_DEF(name, type, aligntype) \
+ union { \
+ type name; \
+ aligntype name##_align; \
+ }
+
+#define PTR_ALIGNMENT_DEF(name, type) ALIGNMENT_DEF(name, type, PTR_ALIGN_TYPE)
+
+#define OTHER_ALIGNMENT_DEF(name, type) ALIGNMENT_DEF(name, type, ALIGN_TYPE)
+
+/*
+ * * List definitions.
+ * */
+#define DMM_LIST_HEAD(name, type) \
+struct name { \
+ PTR_ALIGNMENT_DEF(lh_first, struct type *); /* first element */ \
+}
+
+#define DMM_LIST_ENTRY(type) \
+struct { \
+ PTR_ALIGNMENT_DEF(le_next, struct type *); /* next element */\
+ PTR_ALIGNMENT_DEF(le_prev, struct type **); /* address of previous next element */ \
+}
+
+/*
+ * * Tail queue definitions.
+ * */
+#define _DMM_TAILQ_HEAD(name, type, qual) \
+struct name { \
+ PTR_ALIGNMENT_DEF(tqh_first, qual type *); /* first element */ \
+ PTR_ALIGNMENT_DEF(tqh_last, qual type * qual *); /* addr of last next element */ \
+}
+
+#define DMM_TAILQ_HEAD(name, type) _DMM_TAILQ_HEAD(name, struct type,)
+
+#define _DMM_TAILQ_ENTRY(type, qual) \
+struct { \
+ PTR_ALIGNMENT_DEF(tqe_next, qual type *); /* next element */\
+ PTR_ALIGNMENT_DEF(tqe_prev, qual type * qual*); /* address of previous next element */\
+}
+#define DMM_TAILQ_ENTRY(type) _DMM_TAILQ_ENTRY(struct type,)
+
+/*
+ * * Singly-linked Tail queue declarations.
+ * */
+#define DMM_STAILQ_HEAD(name, type) \
+ struct name { \
+ PTR_ALIGNMENT_DEF(stqh_first, struct type *); /* first element */ \
+ PTR_ALIGNMENT_DEF(stqh_last, struct type **); /* addr of last next element */ \
+ }
+
+#define DMM_STAILQ_ENTRY(type) \
+ struct { \
+ PTR_ALIGNMENT_DEF(stqe_next, struct type *); /* next element */ \
+ }
+#endif
+
+#endif
diff --git a/stacks/lwip_stack/src/include/common_mem_buf.h b/stacks/lwip_stack/src/include/common_mem_buf.h
new file mode 100644
index 0000000..9ba0008
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_mem_buf.h
@@ -0,0 +1,78 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _COMMON_MEM_BUF_H_
+#define _COMMON_MEM_BUF_H_
+
+#ifdef HAL_LIB
+#else
+
+#include "nsfw_mem_api.h"
+#include "common_mem_base_type.h"
+#include "types.h"
+
+typedef enum __DMM_PROC_TYPE
+{
+ DMM_PROC_T_AUTO = 0, /*auto detect */
+ DMM_PROC_T_PRIMARY = 1, /* set to primary */
+ DMM_PROC_T_SECONDARY = 2, /* set to secondary */
+ DMM_PROC_T_INVALID
+} DMM_PROC_TYPE;
+
+#define DMM_MBUF_RET_OK 0
+#define DMM_MBUF_RET_ERR 1
+
+#define LCORE_MAX 128
+#define LCORE_MASK_PER (sizeof(int) * 8)
+#define LCORE_MASK_MAX (LCORE_MAX/LCORE_MASK_PER)
+
+#define LCORE_MASK_SET(ilcoremask, value) \
+ if (value < LCORE_MAX) \
+ { \
+ ilcoremask[(value/LCORE_MASK_PER)] = (int) ( (ilcoremask[(value/LCORE_MASK_PER)]) | (1< (value%LCORE_MASK_PER))); \
+ } \
+
+#define DMM_HUGTBL_ENABLE 0
+#define DMM_HUGTBL_DISABLE 1
+
+typedef struct __common_pal_module_info
+{
+ int ishare_mem_size; /*shared memory size */
+ int ilcoremask[LCORE_MASK_MAX];
+ /**/ unsigned char uchugeflag;
+ unsigned char ucproctype;
+ unsigned char ucinstance;
+ unsigned char ucresrv2;
+} common_mem_pal_module_info;
+
+/**
+ * rte pal module init.
+ *
+ *
+ * @param name
+ * The name of the buf pool.
+ */
+int nscomm_pal_module_init(nsfw_mem_para * para,
+ common_mem_pal_module_info * pinfo, u8 app_mode);
+
+void *nscomm_memzone_data_reserve_name(const char *name, size_t len,
+ int socket_id);
+
+void *nscomm_memzone_data_lookup_name(const char *name);
+
+#endif
+
+#endif /* _COMMON_MEM_BUF_H_ */
diff --git a/stacks/lwip_stack/src/include/common_mem_common.h b/stacks/lwip_stack/src/include/common_mem_common.h
new file mode 100644
index 0000000..1e4cf56
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_mem_common.h
@@ -0,0 +1,25 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _COMMON_MEM_COMMON_H_
+#define _COMMON_MEM_COMMON_H_
+
+#ifdef HAL_LIB
+#else
+#include "rte_common.h"
+#endif
+
+#endif
diff --git a/stacks/lwip_stack/src/include/common_mem_mbuf.h b/stacks/lwip_stack/src/include/common_mem_mbuf.h
new file mode 100644
index 0000000..ee8cfa2
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_mem_mbuf.h
@@ -0,0 +1,40 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/*******************************************************************
+ Copyright 2017 - 2047, Huawei Tech. Co., Ltd.
+ ALL RIGHTS RESERVED
+
+Filename : common_mem_mbuf.h
+Description :
+Version : 1.1
+********************************************************************/
+
+#ifndef _COMMON_MEM_MBUF_H_
+#define _COMMON_MEM_MBUF_H_
+
+#ifdef HAL_LIB
+#else
+#include "rte_mbuf.h"
+#include "common_func.h"
+
+typedef uint32_t(*dmm_mbuf_item_fun) (void *data, void *argv);
+int32_t dmm_pktmbuf_pool_iterator(struct common_mem_mempool *mp,
+ uint32_t start, uint32_t end,
+ dmm_mbuf_item_fun fun, void *argv);
+#endif
+
+#endif /* _COMMON_MEM_MBUF_H_ */
diff --git a/stacks/lwip_stack/src/include/common_mem_mempool.h b/stacks/lwip_stack/src/include/common_mem_mempool.h
new file mode 100644
index 0000000..58a8e82
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_mem_mempool.h
@@ -0,0 +1,25 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _COMMON_MEM_MEMPOOL_H_
+#define _COMMON_MEM_MEMPOOL_H_
+
+#ifdef HAL_LIB
+#else
+#include "rte_mempool.h"
+#endif
+
+#endif /* _COMMON_MEM_MEMPOOL_H_ */
diff --git a/stacks/lwip_stack/src/include/common_mem_pal_memconfig.h b/stacks/lwip_stack/src/include/common_mem_pal_memconfig.h
new file mode 100644
index 0000000..65b6e04
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_mem_pal_memconfig.h
@@ -0,0 +1,26 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _COMMON_MEM_PAL_MEMCONFIG_H_
+#define _COMMON_MEM_PAL_MEMCONFIG_H_
+
+#ifdef HAL_LIB
+#else
+#include "rte_eal_memconfig.h"
+
+#endif
+
+#endif
diff --git a/stacks/lwip_stack/src/include/common_mem_rwlock.h b/stacks/lwip_stack/src/include/common_mem_rwlock.h
new file mode 100644
index 0000000..2eed259
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_mem_rwlock.h
@@ -0,0 +1,25 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _COMMON_MEM_RWLOCK_H_
+#define _COMMON_MEM_RWLOCK_H_
+
+#ifdef HAL_LIB
+#else
+#include "rte_rwlock.h"
+#endif
+
+#endif /* _COMMON_MEM_RWLOCK_H_ */
diff --git a/stacks/lwip_stack/src/include/common_mem_spinlock.h b/stacks/lwip_stack/src/include/common_mem_spinlock.h
new file mode 100644
index 0000000..482e87b
--- /dev/null
+++ b/stacks/lwip_stack/src/include/common_mem_spinlock.h
@@ -0,0 +1,38 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _COMMON_MEM_SPINLOCK_X86_64_H_
+#define _COMMON_MEM_SPINLOCK_X86_64_H_
+
+#ifdef HAL_LIB
+#else
+#include "rte_spinlock.h"
+
+static inline void dmm_spinlock_lock_with_pid(rte_spinlock_t * sl, int pid)
+{
+ while (!__sync_bool_compare_and_swap(&sl->locked, 0, pid))
+ while (sl->locked)
+ rte_pause();
+}
+
+static inline int dmm_spinlock_try_lock_with_pid(rte_spinlock_t * sl, int pid)
+{
+ return __sync_bool_compare_and_swap(&sl->locked, 0, pid);
+}
+
+#endif
+
+#endif /* _COMMON_MEM_SPINLOCK_X86_64_H_ */
diff --git a/stacks/lwip_stack/src/include/nsfw_msg.h b/stacks/lwip_stack/src/include/nsfw_msg.h
new file mode 100644
index 0000000..9efa694
--- /dev/null
+++ b/stacks/lwip_stack/src/include/nsfw_msg.h
@@ -0,0 +1,201 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef MSG_H
+#define MSG_H
+#include "types.h"
+#include "common_mem_api.h"
+#include "nsfw_rti.h"
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define MAX_MSG_SIZE 512
+COMPAT_PROTECT_RETURN(MAX_MSG_SIZE, 512);
+#define MAX_MSG_PARAM_SIZE 128
+COMPAT_PROTECT_RETURN(MAX_MSG_PARAM_SIZE, 128);
+
+#define MSG_ASYN_POST 0
+#define MSG_SYN_POST 1
+
+typedef struct
+{
+ u16 module_type;
+ u16 major_type;
+ u16 minor_type;
+ u16 op_type; /* MSG_SYN_POST or MSG_ASYN_POST */
+ sys_sem_st op_completed;
+ i32 err;
+ PRIMARY_ADDR void *msg_from; /* use it to free msg */
+ i64 receiver;
+ i64 comm_receiver;
+ nsfw_res res_chk;
+ u32 src_pid;
+ u32 recycle_pid; /* use it in recycle */
+ u64 span_pid;
+ i64 extend_member_bit;
+} msg_param;
+
+typedef struct msg_t
+{
+ msg_param param;
+ i8 msg_param_pad[MAX_MSG_PARAM_SIZE - sizeof(msg_param)]; /* sizeof(msg_param) + sizeof(msg_param_pad) = MAX_MSG_PARAM_SIZE */
+ i64 buffer[(MAX_MSG_SIZE - MAX_MSG_PARAM_SIZE) / 8];
+}
+data_com_msg;
+
+#define MAX_MODULE_TYPE 64
+#define MAX_MAJOR_TYPE 256
+#define MAX_MINOR_TYPE 256
+
+struct rti_queue
+{
+ /* corresponding to enum spl_tcpip_msg_type */
+ volatile u64 tcpip_msg_enq[MAX_MAJOR_TYPE];
+ volatile u64 tcpip_msg_enq_fail[MAX_MAJOR_TYPE];
+ u64 tcpip_msg_deq[MAX_MAJOR_TYPE];
+
+ /* corresponding to enum api_msg_type, this is sub-type of SPL_TCPIP_NEW_MSG_API */
+ volatile u64 api_msg_enq[MAX_MINOR_TYPE];
+ volatile u64 api_msg_enq_fail[MAX_MINOR_TYPE];
+ u64 api_msg_deq[MAX_MINOR_TYPE];
+
+ u64 extend_member_bit;
+};
+
+enum MSG_MODULE_TYPE
+{
+ MSG_MODULE_IP,
+ MSG_MODULE_SBR,
+ MSG_MODULE_HAL,
+ MSG_MODULE_SPL,
+ MSG_MODULE_TIMER,
+ MSG_MODULE_MT,
+ MSG_MODULE_DFX,
+ MSG_MODULE_MAX = MAX_MODULE_TYPE
+};
+
+typedef int (*msg_fun) (data_com_msg * m);
+
+/* *INDENT-OFF* */
+extern msg_fun g_msg_module_fun_array[MAX_MODULE_TYPE];
+extern msg_fun g_msg_module_major_fun_array[MAX_MODULE_TYPE][MAX_MAJOR_TYPE];
+extern msg_fun g_msg_module_major_minor_fun_array[MAX_MODULE_TYPE][MAX_MAJOR_TYPE][MAX_MINOR_TYPE];
+extern msg_fun g_msg_unsupport_fun;
+/* *INDENT-ON* */
+
+#define REGIST_MSG_MODULE_FUN(module, fun) \
+ static void regist_ ## module ## _function (void) \
+ __attribute__((__constructor__)); \
+ static void regist_ ## module ## _function (void) \
+ { \
+ g_msg_module_fun_array[module] = fun; \
+ } \
+
+#define REGIST_MSG_MODULE_MAJOR_FUN(module, major, fun) \
+ static void regist_ ## module ## major ## _function (void) \
+ __attribute__((__constructor__)); \
+ static void regist_ ## module ## major ## _function (void) \
+ { \
+ g_msg_module_major_fun_array[module][major] = fun; \
+ } \
+
+#define REGIST_MSG_MODULE_MAJOR_MINOR_FUN(module, major, minor, fun) \
+ static void regist_ ## module ## major ## minor ## _function (void) \
+ __attribute__((__constructor__)); \
+ static void regist_ ## module ## major ## minor ## _function (void) \
+ { \
+ g_msg_module_major_minor_fun_array[module][major][minor] = fun; \
+ } \
+
+#define REGIST_MSG_UNSUPPORT_FUN(fun) \
+ static void regist_msg_unsupport_function (void) \
+ __attribute__((__constructor__)); \
+ static void regist_msg_unsupport_function (void) \
+ { \
+ g_msg_unsupport_fun = fun; \
+ }
+
+static inline int unsupport_msg(data_com_msg * m)
+{
+ if (g_msg_unsupport_fun)
+ {
+ return g_msg_unsupport_fun(m);
+ }
+
+ return -1;
+}
+
+/*****************************************************************************
+* Prototype : call_msg_fun
+* Description : call msg fun
+* Input : data_com_msg* m
+* Output : None
+* Return Value : static inline int
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+static inline int call_msg_fun(data_com_msg * m)
+{
+ u16 module = m->param.module_type;
+ u16 major = m->param.major_type;
+ u16 minor = m->param.minor_type;
+
+ if ((module >= MAX_MODULE_TYPE) || (major >= MAX_MAJOR_TYPE)
+ || (minor >= MAX_MINOR_TYPE))
+ {
+ return unsupport_msg(m);
+ }
+
+ nsfw_rti_stat_macro(NSFW_STAT_PRIMARY_DEQ, m);
+
+ if (g_msg_module_fun_array[module]
+ && (g_msg_module_fun_array[module] (m) != 0))
+ {
+ return -1;
+ }
+
+ if (g_msg_module_major_fun_array[module][major]
+ && (g_msg_module_major_fun_array[module][major] (m) != 0))
+ {
+ return -1;
+ }
+
+ if (g_msg_module_major_minor_fun_array[module][major][minor])
+ {
+ return g_msg_module_major_minor_fun_array[module][major][minor] (m);
+ }
+
+ if (!g_msg_module_fun_array[module]
+ && !g_msg_module_major_fun_array[module][major]
+ && !g_msg_module_major_minor_fun_array[module][major][minor])
+ {
+ return unsupport_msg(m);
+ }
+
+ return 0;
+}
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/stacks/lwip_stack/src/include/nsfw_msg_api.h b/stacks/lwip_stack/src/include/nsfw_msg_api.h
new file mode 100644
index 0000000..b7e0d1c
--- /dev/null
+++ b/stacks/lwip_stack/src/include/nsfw_msg_api.h
@@ -0,0 +1,305 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef MSG_API_H
+#define MSG_API_H
+#include "nsfw_msg.h"
+#include "nsfw_mem_api.h"
+#include "nstack_log.h"
+#include "nsfw_rti.h"
+#include "common_mem_api.h"
+#include "nsfw_recycle_api.h"
+#include "common_pal_bitwide_adjust.h"
+#include "pid_common.h"
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define SET_MSG_ERR(m, error) ((m)->param.err = (error))
+#define GET_MSG_ERR(m) ((m)->param.err)
+
+/* for sync message from sbr we should signal sem */
+#define SYNC_MSG_ACK(m) sys_sem_s_signal(&((m)->param.op_completed))
+
+/* for async message from sbr we should free the message */
+#define ASYNC_MSG_FREE(m) msg_free(m)
+
+#define MSG_ENTRY(_ptr, _type, _member) container_of((void *)_ptr, _type, _member)
+
+#ifndef NSTACK_STATIC_CHECK
+/*****************************************************************************
+* Prototype : msg_malloc
+* Description : malloc msg
+* Input : mring_handle mhandle
+* Output : None
+* Return Value : static inline data_com_msg*
+* Calls :
+* Called By :
+*****************************************************************************/
+static inline data_com_msg *msg_malloc(mring_handle mhandle)
+{
+ if (!mhandle)
+ {
+ NSFW_LOGERR("mhandle is null");
+ return NULL;
+ }
+
+ data_com_msg *m = NULL;
+ if (nsfw_mem_ring_dequeue(mhandle, (void **) &m) != 1)
+ {
+ return NULL;
+ }
+
+ m->param.recycle_pid = get_sys_pid();
+ res_alloc(&m->param.res_chk);
+ return m;
+}
+
+/*****************************************************************************
+* Prototype : msg_free
+* Description : free msg
+* Input : data_com_msg* m
+* mring_handle mhandle
+* Output : None
+* Return Value : static inline void
+* Calls :
+* Called By :
+*****************************************************************************/
+static inline void msg_free(data_com_msg * m)
+{
+ if (!m)
+ {
+ NSFW_LOGERR("m is NULL");
+ return;
+ }
+
+ mring_handle mhandle = ADDR_SHTOL(m->param.msg_from);
+ if (!mhandle)
+ {
+ return;
+ }
+
+ if (res_free(&m->param.res_chk))
+ {
+ NSFW_LOGERR("m refree!]m=%p", m);
+ return;
+ }
+
+ m->param.recycle_pid = 0;
+
+ if (nsfw_mem_ring_enqueue(mhandle, (void *) m) != 1)
+ {
+ NSFW_LOGERR("nsfw_mem_ring_enqueue failed,this can not happen");
+ }
+}
+
+/*****************************************************************************
+* Prototype : msg_post
+* Description : post msg
+* Input : data_com_msg* m
+* mring_handle mhandle
+* Output : None
+* Return Value : static inline int
+* Calls :
+* Called By :
+*****************************************************************************/
+static inline int msg_post(data_com_msg * m, mring_handle mhandle)
+{
+ int ret;
+ if (!m || !mhandle)
+ {
+ NSFW_LOGERR("param is not ok]m=%p,mhandle=%p", m, mhandle);
+ return -1;
+ }
+
+ while (1)
+ {
+ ret = nsfw_mem_ring_enqueue(mhandle, (void *) m);
+ switch (ret)
+ {
+ case 1:
+ if (MSG_SYN_POST == m->param.op_type)
+ {
+ sys_arch_sem_s_wait(&m->param.op_completed, 0);
+ }
+
+ return 0;
+ case 0:
+ continue;
+ default:
+ nsfw_rti_stat_macro(NSFW_STAT_PRIMARY_ENQ_FAIL, m);
+ return -1;
+ }
+ }
+}
+
+#define MSG_POST_FAILED 50
+/*****************************************************************************
+* Prototype : msg_post_with_lock_rel
+* Description : post msg to tcpip thread in mgrcom thread
+* Input : data_com_msg* m
+* mring_handle mhandle
+* Output : None
+* Return Value : static inline int
+* Calls :
+* Called By :
+*****************************************************************************/
+static inline int
+msg_post_with_lock_rel(data_com_msg * m, mring_handle mhandle)
+{
+ int ret;
+ int try_count = 0;
+ if (!m || !mhandle)
+ {
+ NSFW_LOGERR("param is not ok]m=%p,mhandle=%p", m, mhandle);
+ return -1;
+ }
+
+ while (1)
+ {
+ ret = nsfw_mem_ring_enqueue(mhandle, (void *) m);
+ switch (ret)
+ {
+ case 1:
+ if (MSG_SYN_POST == m->param.op_type)
+ {
+ sys_arch_sem_s_wait(&m->param.op_completed, 0);
+ }
+
+ return 0;
+ case 0:
+ try_count++;
+ if (try_count > MSG_POST_FAILED)
+ {
+ try_count = 0;
+ nsfw_recycle_rechk_lock();
+ }
+ sys_sleep_ns(0, 1000000);
+ continue;
+ default:
+ nsfw_rti_stat_macro(NSFW_STAT_PRIMARY_ENQ_FAIL, m);
+ return -1;
+ }
+ }
+}
+
+/*****************************************************************************
+* Prototype : msg_try_post
+* Description : try post msg
+* Input : data_com_msg* m
+* mring_handle mhandle
+* Output : None
+* Return Value : static inline int
+* Calls :
+* Called By :
+*****************************************************************************/
+static inline int msg_try_post(data_com_msg * m, mring_handle mhandle)
+{
+ if (!m || !mhandle)
+ {
+ NSFW_LOGERR("param is not ok]m=%p,mhandle=%p", m, mhandle);
+ return -1;
+ }
+
+ int ret = nsfw_mem_ring_enqueue(mhandle, (void *) m);
+ if (1 == ret)
+ {
+ if (MSG_SYN_POST == m->param.op_type)
+ {
+ sys_arch_sem_s_wait(&m->param.op_completed, 0);
+ }
+
+ return 0;
+ }
+
+ return -1;
+}
+
+/*****************************************************************************
+* Prototype : msg_fetch
+* Description : fetch msg
+* Input : mring_handle mhandle
+* data_com_msg** m
+* u32 num
+* Output : None
+* Return Value : static inline int
+* Calls :
+* Called By :
+*****************************************************************************/
+static inline int msg_fetch(mring_handle mhandle, data_com_msg ** m, u32 num)
+{
+ if (!m || !mhandle)
+ {
+ NSFW_LOGERR("param is not ok]m=%p,mhandle=%p", m, mhandle);
+ return -1;
+ }
+
+ int ret;
+ while (1)
+ {
+ ret = nsfw_mem_ring_dequeuev(mhandle, (void *) m, num);
+ if (ret > 0)
+ {
+ break;
+ }
+ }
+
+ return ret;
+}
+
+/*****************************************************************************
+* Prototype : msg_try_fetch
+* Description : try fetch msg
+* Input : mring_handle mhandle
+* data_com_msg** m
+* u32 num
+* Output : None
+* Return Value : static inline int
+* Calls :
+* Called By :
+*****************************************************************************/
+static inline int
+msg_try_fetch(mring_handle mhandle, data_com_msg ** m, u32 num)
+{
+ if (!m || !mhandle)
+ {
+ NSFW_LOGERR("param is not ok]m=%p,mhandle=%p", m, mhandle);
+ return -1;
+ }
+
+ return nsfw_mem_ring_dequeuev(mhandle, (void *) m, num);
+}
+
+#else
+data_com_msg *msg_malloc(mring_handle mhandle);
+void msg_free(data_com_msg * m);
+int msg_post(data_com_msg * m, mring_handle mhandle);
+int msg_try_post(data_com_msg * m, mring_handle mhandle);
+int msg_fetch(mring_handle mhandle, data_com_msg ** m, u32 num);
+int msg_try_fetch(mring_handle mhandle, data_com_msg ** m, u32 num);
+int msg_post_with_lock_rel(data_com_msg * m, mring_handle mhandle);
+#endif
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/stacks/lwip_stack/src/include/nsfw_mt_config.h b/stacks/lwip_stack/src/include/nsfw_mt_config.h
new file mode 100644
index 0000000..3735be4
--- /dev/null
+++ b/stacks/lwip_stack/src/include/nsfw_mt_config.h
@@ -0,0 +1,63 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _FW_MT_CONFIG_H
+#define _FW_MT_CONFIG_H
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#include "nsfw_maintain_api.h"
+
+/* socket num config */
+#define SOCKET_NUM_PER_THREAD 1024 /* socket number per thread */
+
+#define APP_POOL_NUM 32
+
+#define DEF_HAL_RX_RING_SIZE 2048
+
+/* stackx recv ring size config */
+#define DEF_SPL_MAX_RING_SIZE 1024
+
+/* pcb number config */
+#define DEF_TCP_PCB_NUM 4096 /* tcp pcb number, per thread */
+#define DEF_UDP_PCB_NUM 512 /* udp pcb number, per thread */
+#define DEF_RAW_PCB_NUM 600 /* raw pcb number, per thread */
+
+#define DEF_ARP_QUEUE_NUM 300
+
+/* tx mbuf pool size config */
+#define DEF_TX_MBUF_POOL_SIZE (4*POOL_RING_BASE_SIZE)
+
+/* rx mbuf pool size config */
+#define DEF_RX_MBUF_POOL_SIZE (8*POOL_RING_BASE_SIZE) /* rx mbuf pool size */
+
+/* stackx internal msg number config */
+#define DEF_TX_MSG_POOL_SIZE (DEF_TX_MBUF_POOL_SIZE*APP_POOL_NUM + MAX_VF_NUM*DEF_RX_MBUF_POOL_SIZE + DEF_RING_BASE_SIZE)
+
+/* mbox ring size config */
+#define DEF_MBOX_RING_SIZE (DEF_RING_BASE_SIZE/4)
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/stacks/lwip_stack/src/include/nsfw_rti.h b/stacks/lwip_stack/src/include/nsfw_rti.h
new file mode 100644
index 0000000..f6eb1b8
--- /dev/null
+++ b/stacks/lwip_stack/src/include/nsfw_rti.h
@@ -0,0 +1,49 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef RTI_H
+#define RTI_H
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+#define nsfw_rti_stat_macro(type, m) if (1 == g_dfx_switch) { nsfw_rti_stat(type, m); }
+
+typedef enum nsfw_rti_stat_type
+{
+ NSFW_STAT_PRIMARY_ENQ,
+ NSFW_STAT_PRIMARY_ENQ_FAIL,
+ NSFW_STAT_PRIMARY_DEQ,
+} nsfw_rti_stat_type_t;
+
+struct rti_queue;
+struct msg_t;
+
+extern char g_dfx_switch;
+extern struct rti_queue *g_nsfw_rti_primary_stat;
+
+void nsfw_rti_stat(nsfw_rti_stat_type_t statType, const struct msg_t *m);
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+#endif
diff --git a/stacks/lwip_stack/src/include/nstack_dmm_adpt.h b/stacks/lwip_stack/src/include/nstack_dmm_adpt.h
new file mode 100644
index 0000000..7e6e9cb
--- /dev/null
+++ b/stacks/lwip_stack/src/include/nstack_dmm_adpt.h
@@ -0,0 +1,64 @@
+/*
+*
+* Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at:
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif /* __cplusplus */
+
+#ifndef __NSTACK_DMM_ADPT_H__
+#define __NSTACK_DMM_ADPT_H__
+
+typedef enum
+{
+ NSTACK_MODEL_TYPE1 = 1, /*nSocket and stack belong to the same process */
+ NSTACK_MODEL_TYPE2 = 2, /*nSocket and stack belong to different processes,
+ *and nStack don't take care the communication between stack and stack adpt
+ */
+ NSTACK_MODEL_TYPE3 = 3, /*nSocket and stack belong to different processes, and sbr was supplied to communicate whit stack */
+ NSTACK_MODEL_TYPE_SIMPLE_STACK = 4, /* like TYPE1, DMM will NOT provide SBR or pipeline mode, just allocate 32M, and use dpdk file
+ * prefix to support multiple running app under DMM */
+ NSTACK_MODEL_INVALID,
+} nstack_model_deploy_type;
+
+#define NSTACK_DMM_MODULE "nstack_dmm_module"
+
+typedef struct nsfw_com_attr
+{
+ int policy;
+ int pri;
+} nsfw_com_attr;
+
+typedef struct __nstack_dmm_para
+{
+ nstack_model_deploy_type deploy_type;
+ int proc_type;
+ nsfw_com_attr attr;
+ int argc;
+ char **argv;
+} nstack_dmm_para;
+
+extern int nstack_adpt_init(nstack_dmm_para * para);
+extern int nstack_event_callback(void *pdata, int events);
+
+#endif
+
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif /* __cplusplus */