diff options
author | nanger <zhenyinan@huawei.com> | 2018-09-29 16:41:15 +0800 |
---|---|---|
committer | nanger <zhenyinan@huawei.com> | 2018-09-29 16:45:14 +0800 |
commit | 74c9aed15303d388d7d0429128bc3af96f7eb45c (patch) | |
tree | b4659364e410ef5b0f36b61bbf98c48e5763d8e5 /stacks/lwip_stack/lwip_src | |
parent | 31ea86798426cf236d70c9de1944c723a6cb1d95 (diff) |
Refactor: change to dmm share memory
Change-Id: Iff87eb5c6610c1db9247a898dd4c8ffbe6eeabdf
Signed-off-by: nanger <zhenyinan@huawei.com>
Diffstat (limited to 'stacks/lwip_stack/lwip_src')
-rw-r--r-- | stacks/lwip_stack/lwip_src/CMakeLists.txt | 14 | ||||
-rw-r--r-- | stacks/lwip_stack/lwip_src/api/spl_api.c | 2 | ||||
-rw-r--r-- | stacks/lwip_stack/lwip_src/common/stackxopts.h | 2 | ||||
-rw-r--r-- | stacks/lwip_stack/lwip_src/core/global_tick.c | 31 | ||||
-rw-r--r-- | stacks/lwip_stack/lwip_src/core/global_tick.h | 29 | ||||
-rw-r--r-- | stacks/lwip_stack/lwip_src/core/spl_timers.c | 2 | ||||
-rw-r--r-- | stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h | 1 | ||||
-rw-r--r-- | stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c | 3 | ||||
-rw-r--r-- | stacks/lwip_stack/lwip_src/socket/CMakeLists.txt | 15 | ||||
-rw-r--r-- | stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.c | 2 |
10 files changed, 75 insertions, 26 deletions
diff --git a/stacks/lwip_stack/lwip_src/CMakeLists.txt b/stacks/lwip_stack/lwip_src/CMakeLists.txt index 4425905..7c91c2c 100644 --- a/stacks/lwip_stack/lwip_src/CMakeLists.txt +++ b/stacks/lwip_stack/lwip_src/CMakeLists.txt @@ -23,24 +23,23 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack -mcmodel=medium") ADD_DEFINITIONS(-D_GNU_SOURCE) ADD_DEFINITIONS(-DDPDK_MODULE=0) if(WITH_HAL_LIB) -SET(RTP_CONFIG ${CMAKE_CURRENT_LIST_DIR}/../src/include/rtp_config.h) else() SET(PAL_H_DIRECTORIES "/usr/include/dpdk/") - SET(RTP_CONFIG ${PROJECT_SOURCE_DIR}/../../src/framework/common/base/include/common/common_sys_config.h) INCLUDE_DIRECTORIES( ${PAL_H_DIRECTORIES} ) endif() -SET(COMPLE_CONFIG ${CMAKE_CURRENT_LIST_DIR}/../src/include/compile_config.h) -SET(MGR_COM ${CMAKE_CURRENT_LIST_DIR}/../src/include/mgr_com.h) + ADD_DEFINITIONS(-include ${RTP_CONFIG}) ADD_DEFINITIONS(-include ${COMPLE_CONFIG}) -ADD_DEFINITIONS(-include ${MGR_COM}) +ADD_DEFINITIONS(-include common_mem_api.h) + if(WITH_SECUREC_LIB) -LINK_LIBRARIES(pthread rt securec) + LINK_LIBRARIES(pthread rt securec) else() -LINK_LIBRARIES(pthread rt) + LINK_LIBRARIES(pthread rt) endif() + LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC}) INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_LIST_DIR}/../../../SecureC/include @@ -60,6 +59,7 @@ FILE(GLOB RECYCLE recycle/*.c) FILE(GLOB_RECURSE MAINTAIN maintain/*.c) FILE(GLOB COMMON common/*.c) FILE(GLOB_RECURSE LWIPSRC lwip/arch/*.c lwip/core/*.c lwip/netif/*.c) + FOREACH(item ${LWIPSRC}) IF(${item} MATCHES "slipif.c") LIST(REMOVE_ITEM LWIPSRC ${item}) diff --git a/stacks/lwip_stack/lwip_src/api/spl_api.c b/stacks/lwip_stack/lwip_src/api/spl_api.c index 5c8af7d..a8c9af6 100644 --- a/stacks/lwip_stack/lwip_src/api/spl_api.c +++ b/stacks/lwip_stack/lwip_src/api/spl_api.c @@ -44,7 +44,7 @@ spl_main_init (void *args) /* *INDENT-OFF* */ NSFW_MODULE_NAME ("STACKX_MAIN") -NSFW_MODULE_PRIORITY (10) +NSFW_MODULE_PRIORITY (90) NSFW_MODULE_DEPENDS (NSFW_ALARM_MODULE) NSFW_MODULE_DEPENDS (NSTACK_DMM_MODULE) NSFW_MODULE_INIT (spl_main_init) diff --git a/stacks/lwip_stack/lwip_src/common/stackxopts.h b/stacks/lwip_stack/lwip_src/common/stackxopts.h index 15fc6b8..3daba0d 100644 --- a/stacks/lwip_stack/lwip_src/common/stackxopts.h +++ b/stacks/lwip_stack/lwip_src/common/stackxopts.h @@ -17,6 +17,8 @@ #ifndef STACKX_OPTS_H #define STACKX_OPTS_H +#include "types.h" + struct memory_statics { char name[120]; diff --git a/stacks/lwip_stack/lwip_src/core/global_tick.c b/stacks/lwip_stack/lwip_src/core/global_tick.c index ee180c9..7a0feb2 100644 --- a/stacks/lwip_stack/lwip_src/core/global_tick.c +++ b/stacks/lwip_stack/lwip_src/core/global_tick.c @@ -15,10 +15,12 @@ */ #include "nsfw_mem_api.h" -#include "nstack_share_res.h" +#include "global_tick.h" #include "nstack_securec.h" +#include "nstack_share_res.h" -extern nstack_tick_info_t g_nstack_timer_tick; +/** global timer tick */ +nstack_tick_info_t g_nstack_timer_tick; int init_stackx_global_tick (void) @@ -46,3 +48,28 @@ init_stackx_global_tick (void) return 0; } + +int +nstack_lookup_share_global_tick () +{ + int ret; + nsfw_mem_name name = {.entype = NSFW_SHMEM,.enowner = NSFW_PROC_MAIN }; + + ret = STRCPY_S (name.aname, NSFW_MEM_NAME_LENGTH, NSTACK_GLOBAL_TICK_SHM); + if (EOK != ret) + { + NSSOC_LOGERR ("STRCPY_S failed]name=%s,ret=%d", NSTACK_GLOBAL_TICK_SHM, + ret); + return -1; + } + + g_nstack_timer_tick.tick_ptr = (uint64_t *) nsfw_mem_zone_lookup (&name); + if (NULL == g_nstack_timer_tick.tick_ptr) + { + NSPOL_LOGERR ("Failed to lookup global timer tick memory"); + return -1; + } + + NSSOC_LOGDBG ("ok"); + return 0; +} diff --git a/stacks/lwip_stack/lwip_src/core/global_tick.h b/stacks/lwip_stack/lwip_src/core/global_tick.h new file mode 100644 index 0000000..8e2070b --- /dev/null +++ b/stacks/lwip_stack/lwip_src/core/global_tick.h @@ -0,0 +1,29 @@ +/* +* +* 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 _GLOBAL_TICK_H_ +#define _GLOBAL_TICK_H_ + +#define DFX_TMR_INTERVAL 60000 /*60 seconds */ +typedef struct nstack_tick_info +{ + uint64_t *tick_ptr; // tick from shared memory + uint64_t interval; // tick interval, only used in stack process + /* tick reference, updated periodically and read in tcpip_thread only */ + struct timeval ref_time; // ref tick time + uint64_t ref_tick; // ref tick +} nstack_tick_info_t; + +#endif diff --git a/stacks/lwip_stack/lwip_src/core/spl_timers.c b/stacks/lwip_stack/lwip_src/core/spl_timers.c index cfa130b..8559f6f 100644 --- a/stacks/lwip_stack/lwip_src/core/spl_timers.c +++ b/stacks/lwip_stack/lwip_src/core/spl_timers.c @@ -20,7 +20,7 @@ #include "sc_dpdk.h" #include "nstack_log.h" #include "nstack_securec.h" -#include "nstack_share_res.h" +#include "global_tick.h" #include <time.h> #include <signal.h> diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h index 01fe242..febf162 100644 --- a/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h +++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h @@ -22,6 +22,7 @@ #include "common_mem_base_type.h" #include "stackx_pbuf_comm.h" #include "common_mem_mbuf.h" +#include "common_mem_api.h" #ifdef HAL_LIB #else diff --git a/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c b/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c index 03b5998..b9ca085 100644 --- a/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c +++ b/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c @@ -361,6 +361,7 @@ get_network_json_data () tmp_config_path = realpath ("./network_data_tonStack.json", NULL); if (!tmp_config_path) { + NSTCP_LOGERR ("realpath ./network_data_tonStack.json failed.\n"); exit (1); } @@ -368,7 +369,7 @@ get_network_json_data () if (-1 == fp) { free (tmp_config_path); - NSTCP_LOGINF ("network file open failed.\n"); + NSTCP_LOGERR ("network file open failed.\n"); exit (1); } free (tmp_config_path); diff --git a/stacks/lwip_stack/lwip_src/socket/CMakeLists.txt b/stacks/lwip_stack/lwip_src/socket/CMakeLists.txt index e7915d2..d4027aa 100644 --- a/stacks/lwip_stack/lwip_src/socket/CMakeLists.txt +++ b/stacks/lwip_stack/lwip_src/socket/CMakeLists.txt @@ -26,22 +26,15 @@ SET(ADAPT_DIRECTORIES "${PROJECT_SOURCE_DIR}/src/adapt/") ADD_DEFINITIONS(-D_GNU_SOURCE -D_FORTIFY_SOURCE=2) ADD_DEFINITIONS(-DDPDK_MODULE=0) if(WITH_HAL_LIB) -SET(RTP_CONFIG ${CMAKE_CURRENT_LIST_DIR}/../../../src/include/rtp_config.h) else() - SET(PAL_H_DIRECTORIES "/usr/include/dpdk/") - SET(RTP_CONFIG ${PROJECT_SOURCE_DIR}/../../src/framework/common/base/include/common/common_sys_config.h) + INCLUDE_DIRECTORIES("/usr/include/dpdk/") INCLUDE_DIRECTORIES( - ${PAL_H_DIRECTORIES} ${ADAPT_DIRECTORIES} # ${DMM_API} ) endif() -SET(COMPLE_CONFIG ${CMAKE_CURRENT_LIST_DIR}/../../src/include/compile_config.h) -#SET(MGR_COM ${PROJECT_SOURCE_DIR}/src/framework/ipc/mgr_com/mgr_com.h) -SET(MGR_COM ${CMAKE_CURRENT_LIST_DIR}/../../src/include/mgr_com.h) ADD_DEFINITIONS(-include ${RTP_CONFIG}) ADD_DEFINITIONS(-include ${COMPLE_CONFIG}) -ADD_DEFINITIONS(-include ${MGR_COM}) if(WITH_SECUREC_LIB) LINK_LIBRARIES(pthread rt securec) else() @@ -52,8 +45,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_LIST_DIR}/../../../../thirdparty/json/json-c-0.12.1/ ${CMAKE_CURRENT_LIST_DIR}/../../../../thirdparty/glog/glog-0.3.4/src/ ${CMAKE_CURRENT_LIST_DIR}/../../src/include/ -# ${PROJECT_SOURCE_DIR}/src/framework/include/ -# ${PROJECT_SOURCE_DIR}/src/framework/common/include/ # ${ADAPT_DIRECTORIES} # ${DMM_API} ) @@ -69,8 +60,6 @@ TARGET_INCLUDE_DIRECTORIES( ./ ${CMAKE_CURRENT_LIST_DIR}/../../src/sbr/ ${CMAKE_CURRENT_LIST_DIR}/../../src/include/ -# ${PROJECT_SOURCE_DIR}/src/framework/include/ -# ${PROJECT_SOURCE_DIR}/src/framework/common/include/ # ${ADAPT_DIRECTORIES} -# ${DMM_API} +# ${DMM_API} ) diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.c b/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.c index 0223ac9..97368a3 100644 --- a/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.c +++ b/stacks/lwip_stack/lwip_src/socket/stackx_epoll_api.c @@ -30,7 +30,7 @@ void epoll_triggle_event_from_api (sbr_socket_t * sock, int op) { struct spl_netconn *conn = sbr_get_conn (sock); - void *epInfo = ADDR_SHTOL (conn->epInfo); + void *epInfo = conn->epInfo; //NSPOL_LOGDBG(SOCKETS_DEBUG, "enter]fd=%d,op=%d", sock, op); switch (op) { |