aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwangyalei <wylandrea@gmail.com>2018-07-24 02:37:52 +0800
committerYalei Wang <william.wangyalei@huawei.com>2018-08-14 16:48:34 +0800
commit1c5d7496f4c7f5d0358d8b57781fd471882b1ece (patch)
tree695a843e8d885746be1416955a4f4e82b90cc91a
parentc080b73a936e0fcdb2d90b32a38135edde2d8fa7 (diff)
Feat: Add a new type 4 for simple stack integration
When simple stack integration(type=4), only alloc necessary memory(32M), and add prefix to differentiate the apps in primary mode. Change-Id: Ide8b3a276e999827b7ad3321cbd62cff127c2d44 Signed-off-by: Yalei Wang <william.wangyalei@huawei.com>
-rwxr-xr-x[-rw-r--r--]scripts/checkstyle.sh0
-rw-r--r--src/adapt/nstack_dmm_adpt.c3
-rw-r--r--src/adapt/nstack_dmm_adpt.h2
-rw-r--r--src/framework/common/base/include/common/common_mem_buf.h3
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c5
-rw-r--r--src/framework/lib_common_mem/common_buf.c21
-rw-r--r--src/nSocket/nstack/nstack.c14
7 files changed, 39 insertions, 9 deletions
diff --git a/scripts/checkstyle.sh b/scripts/checkstyle.sh
index 4f3c0a0..4f3c0a0 100644..100755
--- a/scripts/checkstyle.sh
+++ b/scripts/checkstyle.sh
diff --git a/src/adapt/nstack_dmm_adpt.c b/src/adapt/nstack_dmm_adpt.c
index c5fd660..637301b 100644
--- a/src/adapt/nstack_dmm_adpt.c
+++ b/src/adapt/nstack_dmm_adpt.c
@@ -121,7 +121,8 @@ nstack_adpt_init (nstack_dmm_para * para)
stinfo.iargsnum = para->argc;
stinfo.pargs = para->argv;
stinfo.enflag = para->proc_type;
- if (para->deploy_type >= NSTACK_MODEL_TYPE1)
+ if (para->deploy_type != NSTACK_MODEL_TYPE1
+ && para->deploy_type != NSTACK_MODEL_TYPE_SIMPLE_STACK)
{
g_same_process = 0;
}
diff --git a/src/adapt/nstack_dmm_adpt.h b/src/adapt/nstack_dmm_adpt.h
index 25ac61f..1621475 100644
--- a/src/adapt/nstack_dmm_adpt.h
+++ b/src/adapt/nstack_dmm_adpt.h
@@ -30,6 +30,8 @@ typedef enum
*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;
diff --git a/src/framework/common/base/include/common/common_mem_buf.h b/src/framework/common/base/include/common/common_mem_buf.h
index 441da6a..f9f1593 100644
--- a/src/framework/common/base/include/common/common_mem_buf.h
+++ b/src/framework/common/base/include/common/common_mem_buf.h
@@ -21,6 +21,7 @@
#else
#include "common_mem_base_type.h"
+#include "types.h"
typedef enum __DMM_PROC_TYPE
{
@@ -63,7 +64,7 @@ typedef struct __common_pal_module_info
* @param name
* The name of the buf pool.
*/
-int nscomm_pal_module_init (common_mem_pal_module_info * pinfo);
+int nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode);
void *nscomm_memzone_data_reserve_name (const char *name, size_t len,
int socket_id);
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c
index 2622809..abd6ce0 100644
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c
+++ b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c
@@ -37,6 +37,7 @@
#define NSFW_SHMEM_PID (get_sys_pid())
#define NSFW_SHMEM_FLAG (g_shmem_localdata->enflag)
+extern u8 app_mode;
nsfw_mem_localdata *g_shmem_localdata = NULL;
/*check g_mem_localdata*/
@@ -75,13 +76,13 @@ nsfw_shmem_init (nsfw_mem_para * para)
}
else if (NSFW_PROC_MAIN == para->enflag)
{
- iret = common_pal_module_init (NULL);
+ iret = common_pal_module_init (NULL, app_mode);
}
else
{
LCORE_MASK_SET (rteinfo.ilcoremask, 1);
rteinfo.ucproctype = DMM_PROC_T_SECONDARY;
- iret = common_pal_module_init (&rteinfo);
+ iret = common_pal_module_init (&rteinfo, app_mode);
}
if (NSFW_MEM_OK != iret)
diff --git a/src/framework/lib_common_mem/common_buf.c b/src/framework/lib_common_mem/common_buf.c
index 877becf..897445a 100644
--- a/src/framework/lib_common_mem/common_buf.c
+++ b/src/framework/lib_common_mem/common_buf.c
@@ -88,7 +88,7 @@
int log_level = LOG_INFO;
int
-nscomm_pal_module_init (common_mem_pal_module_info * pinfo)
+nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode)
{
char tempargv[PATA_NUM_MAX][PATA_STRLENT];
char *argv[PATA_NUM_MAX];
@@ -98,6 +98,8 @@ nscomm_pal_module_init (common_mem_pal_module_info * pinfo)
int agindex = 0;
int intmask = 0;
int retVal;
+ char name[10] = { '\0' };
+
retVal = MEMSET_S (tempargv, sizeof (tempargv), '\0', sizeof (tempargv));
if (EOK != retVal)
{
@@ -115,9 +117,24 @@ nscomm_pal_module_init (common_mem_pal_module_info * pinfo)
PARA1_SET (argv, tempargv, agindex, "nStackMain");
PARA2_SET (argv, tempargv, agindex, "-c", "0x1");
PARA2_SET (argv, tempargv, agindex, "-n", "4");
- PARA2_SET (argv, tempargv, agindex, "-m", "2048");
PARA1_SET (argv, tempargv, agindex, "--huge-dir=/mnt/nstackhuge");
PARA1_SET (argv, tempargv, agindex, "--proc-type=primary");
+
+ if (app_mode == 1)
+ {
+ sprintf (name, "dmm_app_%ld", (long) getpid ());
+ PARA2_SET (argv, tempargv, agindex, "--file-prefix", name);
+ // TODO: the size of the memory should not be fixed
+ PARA2_SET (argv, tempargv, agindex, "-m", "32");
+ }
+ else
+ {
+ // TODO: replay the name 'nStackMain'
+ /* snprintf(name, 10, "dmm_main_%ld", (long) getpid()); */
+ PARA2_SET (argv, tempargv, agindex, "--file-prefix", "nStackMain");
+ PARA2_SET (argv, tempargv, agindex, "-m", "2048");
+ }
+
}
else
{
diff --git a/src/nSocket/nstack/nstack.c b/src/nSocket/nstack/nstack.c
index 66281af..8718091 100644
--- a/src/nSocket/nstack/nstack.c
+++ b/src/nSocket/nstack/nstack.c
@@ -57,6 +57,10 @@ nStack_info_t g_nStackInfo = {
/*if this flag was set, maybe all socket interface called during initializing*/
__thread int g_tloadflag = 0;
+/* app_mode 1: simple stack with APP*/
+u8 app_mode=0;
+
+
/*check init stack*/
#define NSTACK_INIT_STATE_CHECK_RET(state) do {\
if ((state) == NSTACK_MODULE_SUCCESS) \
@@ -411,7 +415,7 @@ nstack_init_shmem ()
int deploytype = nstack_get_deploy_type ();
- if (deploytype > NSTACK_MODEL_TYPE1)
+ if (deploytype != NSTACK_MODEL_TYPE1 && deploytype != NSTACK_MODEL_TYPE_SIMPLE_STACK )
{
if (-1 == nsep_attach_memory ())
{
@@ -449,7 +453,7 @@ nstack_init_mem (void)
int deploytype = nstack_get_deploy_type ();
/* record unmatched app version*/
/* check lib version match - Begin */
- if (deploytype > NSTACK_MODEL_TYPE1)
+ if (deploytype != NSTACK_MODEL_TYPE1 && deploytype != NSTACK_MODEL_TYPE_SIMPLE_STACK )
{
check_main_version ();
initflag = 1;
@@ -772,7 +776,7 @@ nstack_fw_init ()
if (0 != nstack_stack_module_load())
{
- NSSOC_LOGERR("nstack stack module load fail");
+ NSSOC_LOGERR("nstack stack module load fail");
g_nStackInfo.fwInited = NSTACK_MODULE_FAIL;
return -1;
}
@@ -787,6 +791,10 @@ nstack_fw_init ()
if (deploytype == NSTACK_MODEL_TYPE1)
{
proc_type = NSFW_PROC_MAIN;
+ }else if (deploytype == NSTACK_MODEL_TYPE_SIMPLE_STACK)
+ {
+ proc_type = NSFW_PROC_MAIN;
+ app_mode=1;
}
stinfo.iargsnum = 0;