From 3a5bf13c0e7b427b805a372dc1ed1bd5d7759082 Mon Sep 17 00:00:00 2001 From: Yalei Wang Date: Tue, 13 Mar 2018 16:36:34 +0800 Subject: Clean up the src and update the doc Change-Id: If9c9cdb3ae5167198f0a2ae085871ff7134b32b0 Signed-off-by: Yalei Wang --- src/framework/CMakeLists.txt | 1 - .../base/include/common_pal_bitwide_adjust.h | 20 ---- src/framework/include/nsfw_mgr_com_api.h | 2 - src/framework/include/nstack_log.h | 110 +-------------------- src/framework/include/nstack_trace.h | 76 -------------- src/framework/ipc/mgr_com/mgr_com.c | 6 +- src/framework/log/nstack_log.c | 4 - src/framework/tracing/nstack_trace.c | 52 ---------- 8 files changed, 2 insertions(+), 269 deletions(-) delete mode 100644 src/framework/include/nstack_trace.h delete mode 100644 src/framework/tracing/nstack_trace.c (limited to 'src/framework') diff --git a/src/framework/CMakeLists.txt b/src/framework/CMakeLists.txt index 78c5a45..78072c6 100644 --- a/src/framework/CMakeLists.txt +++ b/src/framework/CMakeLists.txt @@ -27,7 +27,6 @@ FILE(GLOB LOG log/*.c) FILE(GLOB SNAPSHOT snapshot/*.c) FILE(GLOB STARTUP startup/*.c) FILE(GLOB MAINTAIN maintain/*.c) -FILE(GLOB TRACEING tracing/*.c) FILE(GLOB HAL hal/*.c) FILE(GLOB DMM_ADPT ../adapt/*.c) diff --git a/src/framework/common/base/include/common_pal_bitwide_adjust.h b/src/framework/common/base/include/common_pal_bitwide_adjust.h index 850742b..96ae54e 100644 --- a/src/framework/common/base/include/common_pal_bitwide_adjust.h +++ b/src/framework/common/base/include/common_pal_bitwide_adjust.h @@ -26,26 +26,6 @@ #include "common_func.h" -#ifndef _UT_FUN_DISABLE_ -/*define struct for UT restore global variant*/ -struct ut_adjust_global -{ - void **ut_PrimAddr2LocalMap; - uint64_t *ut_LocalAddr2PrimMap; - void *ut_LocalBaseAddr; - void *ut_LocalMaxAddr; - void *ut_LocalCfgAddrBase; - uint64_t ut_PrimBaseAddr; - uint64_t ut_PrimMaxAddr; - uint64_t ut_PrimCfgAddrBase; - int ut_PrimSameFlg; - uint64_t ut_LBitMask; - int ut_LBitMaskLen; - struct common_mem_memseg *ut_PMemSegArry; - void **ut_LMegAddrArry; -}; -#endif - #define ALIGN_SIZET(size) ((uint64_t)(size)) #define ALIGN_PTR(PTR) ((uint64_t)(PTR)) diff --git a/src/framework/include/nsfw_mgr_com_api.h b/src/framework/include/nsfw_mgr_com_api.h index 2499fee..099cdbc 100644 --- a/src/framework/include/nsfw_mgr_com_api.h +++ b/src/framework/include/nsfw_mgr_com_api.h @@ -150,8 +150,6 @@ typedef struct _nsfw_mgr_msg u32 src_pid; u32 dst_pid; - u64 traceid; - u8 msg_body[NSFW_MGR_MSG_BODY_LEN]; } nsfw_mgr_msg; diff --git a/src/framework/include/nstack_log.h b/src/framework/include/nstack_log.h index bb90ec8..1f0749a 100644 --- a/src/framework/include/nstack_log.h +++ b/src/framework/include/nstack_log.h @@ -34,7 +34,6 @@ #include #include #include "types.h" -#include "nstack_trace.h" #include "glog/nstack_glog.ph" #include "glog/nstack_glog_in.h" @@ -275,65 +274,24 @@ extern __thread unsigned int nstack_log_nonreentry; /* hanging up version check log need restrain */ extern int ctrl_log_switch; -#if defined MPTCP_UT -#define NS_LOGPID(_module,_prestr,_level,fmt, ...) -#elif !defined FOR_NSTACK_UT + #define NS_LOGPID(_module,_prestr,_level,fmt, ...) \ {\ if (log_shooting(_module, _level) && (0 == nstack_log_nonreentry) && (0 == ctrl_log_switch))\ {\ nstack_log_nonreentry = 1;\ - NSTACK_TRACING(_level, _prestr, fmt,##__VA_ARGS__);\ if(nstack_log_info_check(_module, _level))\ glog_print(LOG_TYPE(_module,_level),_prestr,level_stoa(_level),-1,GET_FILE_NAME(__FILE__),\ __LINE__,__func__,fmt, ##__VA_ARGS__);\ nstack_log_nonreentry = 0;\ }\ } -#else -static inline void -ut_log_info (const char *file_name, int line_no, const char *func_name, - int _module, const char *_prestr, unsigned int _level, char *fmt, - ...) -{ - va_list ap; - - if (log_shooting (_module, _level) && (0 == nstack_log_nonreentry) - && (0 == ctrl_log_switch)) - { - - nstack_log_nonreentry = 1; - if (nstack_log_info_check (_module, _level)) - { - char pMsgBuf[MAX_LOG_TRANSITIONAL_LEN] = "\0"; - va_start (ap, fmt); - VSNPRINTF_S (pMsgBuf, - MAX_LOG_TRANSITIONAL_LEN, - MAX_LOG_TRANSITIONAL_LEN - 1, fmt, ap); - glog_print (LOG_TYPE (_module, _level), _prestr, - level_stoa (_level), -1, GET_FILE_NAME (file_name), - line_no, func_name, "%s", pMsgBuf); - va_end (ap); - } - nstack_log_nonreentry = 0; - - } -} -#define NS_LOGPID(_module,_prestr,_level,fmt, ...) \ -{\ - ut_log_info(__FILE__,__LINE__, __func__, _module,_prestr,_level,fmt, ##__VA_ARGS__); \ -} - -#endif - -#ifndef FOR_NSTACK_UT #define NS_LOG_CTRL(_id, _module, _prestr, _level, fmt, ...) \ {\ if (log_shooting(_module, _level) && (0 == nstack_log_nonreentry) && check_log_prt_time(_id))\ {\ nstack_log_nonreentry = 1;\ - NSTACK_TRACING(_level, _prestr, fmt,##__VA_ARGS__);\ if(nstack_log_info_check(_module, _level))\ glog_print(LOG_TYPE(_module,_level),_prestr,level_stoa(_level),get_unprt_log_count(_id),\ GET_FILE_NAME(__FILE__),__LINE__,__func__,fmt, ##__VA_ARGS__);\ @@ -342,42 +300,6 @@ ut_log_info (const char *file_name, int line_no, const char *func_name, }\ } -#else -static inline void -ut_ctrl_log_info (char *file_name, int line_no, char *func_name, int _id, - int _module, char *_prestr, unsigned int _level, char *fmt, - ...) -{ - va_list ap; - if (log_shooting (_module, _level) && (0 == nstack_log_nonreentry) - && check_log_prt_time (_id)) - { - nstack_log_nonreentry = 1; - if (nstack_log_info_check (_module, _level)) - { - char pMsgBuf[MAX_LOG_TRANSITIONAL_LEN] = "\0"; - va_start (ap, fmt); - VSNPRINTF_S (pMsgBuf, - MAX_LOG_TRANSITIONAL_LEN, - MAX_LOG_TRANSITIONAL_LEN - 1, fmt, ap); - glog_print (LOG_TYPE (_module, _level), _prestr, - level_stoa (_level), get_unprt_log_count (_id), - GET_FILE_NAME (file_name), line_no, func_name, "%s", - pMsgBuf); - va_end (ap); - } - clr_unprt_log_count (_id); - nstack_log_nonreentry = 0; - - } -} - -#define NS_LOG_CTRL(_id, _module, _prestr, _level, fmt, ...) \ -{\ - ut_ctrl_log_info(__FILE__,__LINE__, __func__, _id, _module,_prestr,_level,fmt, ##__VA_ARGS__); \ -} - -#endif #define NS_LOG_CTRL_STACKX(_id, dbug,_module,_prestr,_level,fmt, ...) \ {\ @@ -547,34 +469,4 @@ void clr_unprt_log_count (int id); void get_current_time (char *buf, const int len); -#ifdef CPU_CYCLES -static __inline__ unsigned long long -nstack_rdtsc (void) -{ - unsigned hi, lo; - __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi)); - return ((unsigned long long) lo) | (((unsigned long long) hi) << 32); -} - -#define CPUB(name) \ -unsigned long long start##name = 0;\ -unsigned long long stop##name = 0;\ -static unsigned long long total##name = 0;\ -static unsigned long long total_cout##name = 0;\ -start##name = nstack_rdtsc(); - -#define CPUE(name) \ -stop##name = nstack_rdtsc();\ -total##name += (stop##name - start##name);\ -if(++total_cout##name == 1000000)\ -{\ - NSSOC_LOGINF(#name" cpu %llu-------\n", total##name / total_cout##name);\ - total##name = 0;\ - total_cout##name = 0;\ -} -#else -#define CPUB(name) -#define CPUE(name) -#endif - #endif diff --git a/src/framework/include/nstack_trace.h b/src/framework/include/nstack_trace.h deleted file mode 100644 index 0f4f640..0000000 --- a/src/framework/include/nstack_trace.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -* -* 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 __NSTACK_TRACE_H__ -#define __NSTACK_TRACE_H__ - -#ifdef __cplusplus -/* *INDENT-OFF* */ -extern "C"{ -/* *INDENT-ON* */ -#endif - -/*==============================================* - * include header files * - *----------------------------------------------*/ -#include "types.h" -#include "nstack_log.h" -#include -#define SPAN_NAME_MAX 64 -#define TRACE_NULL 0 -#define NSTACK_TRACE_ON 0 -#define NSTACK_TRACE_OFF 1 - -typedef struct nst_trace_header -{ - u64 trace_id; - u64 span_pid; - u64 span_id; /*now us */ - int fd; - int thread_id; -} trace_hread_t; - -typedef struct nst_trace_fun -{ - u64 (*current_traceid) (); - void (*span_raw) (char *msg); - void (*tracing_enable) (int enable); - void (*tracing_simpling) (int frequency); - void (*tracing_cleanup) (); - void (*tracing_setup) (u32 process); - u64 (*tracing_string_to_traceid) (const char *input, size_t length); -} trace_fun_t; - -extern __thread struct nst_trace_header strace_header; - -#define get_trace_header() (&strace_header) - -//For Tracing define own tracing feature. -#define nstack_trace_init( a ) -#define nstack_set_tracing_contex( a,b,c) -#define nstack_get_tracing_contex(traceid,spanid,spanpid,fd) -#define nstack_clear_tracing_contex( ) -#define NSTACK_TRACING(level, module_name,famt,...) -#define nstack_tracing_enalbe() -#define nstack_get_traceid() (NULL) - -#ifdef __cplusplus -/* *INDENT-OFF* */ -} -/* *INDENT-ON* */ -#endif - -#endif diff --git a/src/framework/ipc/mgr_com/mgr_com.c b/src/framework/ipc/mgr_com/mgr_com.c index 4a57d6a..5cdb044 100644 --- a/src/framework/ipc/mgr_com/mgr_com.c +++ b/src/framework/ipc/mgr_com/mgr_com.c @@ -109,7 +109,6 @@ nsfw_mgr_reg_msg_fun (u16 msg_type, nsfw_mgr_msg_fun fun) { if (NULL == g_mgr_fun[msg_type][i]) { - /*TODO should use cas */ g_mgr_fun[msg_type][i] = fun; NSFW_LOGINF ("reg mgr_msg fun suc]msg_type=%u,fun=%p", msg_type, fun); @@ -740,7 +739,6 @@ nsfw_mgr_send_msg_socket (u32 fd, nsfw_mgr_msg * msg) off_set = NSFW_MGR_MSG_HDR_LEN; } - /*TODO if closed by peer, may send failed, should close this fd */ do { off_set += send_len; @@ -1026,7 +1024,7 @@ nsfw_mgr_msg_in (i32 fd) nsfw_mgr_msg_free (msg); return FALSE; } - nstack_get_tracing_contex (msg->traceid, 0, 0, -1); + if (msg->fw_flag != TRUE) { (void) nsfw_mgr_new_socket (fd, msg->src_proc_type, msg->src_pid); @@ -1049,7 +1047,6 @@ nsfw_mgr_msg_in (i32 fd) if (FALSE != msg_match) { nsfw_mgr_msg_free (msg); - nstack_clear_tracing_contex (); return TRUE; } @@ -1072,7 +1069,6 @@ nsfw_mgr_msg_in (i32 fd) g_mgr_stat.recv_drop[msg->msg_type]++; } nsfw_mgr_msg_free (msg); - nstack_clear_tracing_contex (); return FALSE; } diff --git a/src/framework/log/nstack_log.c b/src/framework/log/nstack_log.c index 5e8ffd4..50279ba 100644 --- a/src/framework/log/nstack_log.c +++ b/src/framework/log/nstack_log.c @@ -675,11 +675,7 @@ nstack_log_init_app () } init_log_ctrl_info (); g_my_pro_type = LOG_PRO_APP; -#ifdef FOR_NSTACK_UT - -#else SetGlogCtrlOpt (TRUE); -#endif NSPOL_LOGERR ("app_nStack_version=%s", NSTACK_VERSION); return; } diff --git a/src/framework/tracing/nstack_trace.c b/src/framework/tracing/nstack_trace.c deleted file mode 100644 index 88c8ffb..0000000 --- a/src/framework/tracing/nstack_trace.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -* -* 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. -*/ - -/*==============================================* - * include header files * - *----------------------------------------------*/ -#include "nstack_trace.h" -#include "nstack_securec.h" -#include -#include - -#ifdef __cplusplus -/* *INDENT-OFF* */ -extern "C"{ -/* *INDENT-ON* */ -#endif - -/*==============================================* - * constants or macros define * - *----------------------------------------------*/ -#define EVENT_MAX 5 -#define NSTACK_TRACE_SWICH "NSTACK_TRACE_ON" -/*==============================================* - * project-wide global variables * - *----------------------------------------------*/ -trace_fun_t nstack_trace_fun; -__thread trace_hread_t strace_header = { - .thread_id = -1, - .trace_id = TRACE_NULL, -}; - -int tracing_inited = 0; -__thread char *cad_traceID_string = NULL; - -#ifdef __cplusplus -/* *INDENT-OFF* */ -} -/* *INDENT-ON* */ -#endif -- cgit 1.2.3-korg