diff options
author | charan makkina <charan795m@gmail.com> | 2019-04-30 17:40:53 +0530 |
---|---|---|
committer | charan makkina <charan795m@gmail.com> | 2019-05-20 18:14:40 +0530 |
commit | a826fe833d3f2a8fe2673fa05811fe1a22baf045 (patch) | |
tree | da11a17c46ca9b8a002a52a290628574fa3f5eda /src/nSocket/nstack/nstack_module.h | |
parent | 3e6bf7b64eea418c59959c18750261b815b2892c (diff) |
Feature: 19.04 part 1
Change-Id: Ibba924b8deca1f246b9dcb12d89d085b6fd33046
Signed-off-by: charan makkina <charan795m@gmail.com>
Diffstat (limited to 'src/nSocket/nstack/nstack_module.h')
-rw-r--r-- | src/nSocket/nstack/nstack_module.h | 127 |
1 files changed, 58 insertions, 69 deletions
diff --git a/src/nSocket/nstack/nstack_module.h b/src/nSocket/nstack/nstack_module.h index 40a2ef8..1520cf1 100644 --- a/src/nSocket/nstack/nstack_module.h +++ b/src/nSocket/nstack/nstack_module.h @@ -17,12 +17,14 @@ #ifndef __NSTACK_MODULE_H__ #define __NSTACK_MODULE_H__ +#ifndef SPL_INSTANCE_H #include <poll.h> +#endif #include <sys/socket.h> #include <sys/epoll.h> -#include "nstack_types.h" -#include "nstack_dmm_api.h" #include "types.h" +#include "nstack_callback_ops.h" +#include "nsfw_common_defs.h" #ifdef __cplusplus /* *INDENT-OFF* */ @@ -30,60 +32,56 @@ extern "C"{ /* *INDENT-ON* */ #endif -#define NSTACK_LIB_LOAD_DYN 0 -#define NSTACK_LIB_LOAD_STATIC 1 - -#define NSTACK_PLUGIN_NAME_LEN 64 - -#define NSTACK_MAX_MODULE_NUM 8 -#define NSTACK_PRO_MODULE 1 - -#define NSTACK_EP_FREE_NEED_REF 1 /*when epoll information free, need to wait that stack would not notify event */ -#define NSTACK_EP_FREE_NONEED_REF 0 - -#define MODULE_NAME_MAX 128 +#define MOD_INDEX_FOR_STACKPOOL 1 typedef struct __NSTACK_MODULE_KEYS { - ns_char modName[MODULE_NAME_MAX]; /*stack name */ - ns_char register_fn_name[MODULE_NAME_MAX]; /*stack register fun name */ - ns_char libPath[MODULE_NAME_MAX]; /*if libtype is dynamic, it is the path of lib */ - ns_char deploytype; /*delpoly model type: model type1, model type2, model type3 */ - ns_char libtype; /*dynamic lib or static lib */ - ns_char ep_free_ref; /*when epoll information free, - *need to wait that stack would not notify event - */ - ns_char default_stack; /*whether is default stack:when don't know how to choose stack, - *just use default stack - */ - ns_int32 priority; - ns_int32 maxfdid; //the max fd id - ns_int32 minfdid; //the min fd id - ns_int32 modInx; // This is alloced by nStack , not from configuration + ns_char modName[NSTACK_MODULE_NAME_MAX]; // stack name + ns_char register_fn_name[NSTACK_MODULE_NAME_MAX]; // stack register function symbol + ns_char libPath[NSTACK_MODULE_NAME_MAX]; // if libtype is dynamic, it is the path of lib + ns_char deploytype; // deploy type: type1, type2, type3, and etc + ns_char libtype; // dynamic or static + ns_char default_stack; // whether it is the default one + ns_int32 priority; + ns_int32 maxfdid; //the max fd id + ns_int32 minfdid; //the min fd id + ns_int32 modInx; // This is alloced by nStack , not from configuration } nstack_module_keys; typedef struct __NSTACK_MODULE { - char modulename[NSTACK_PLUGIN_NAME_LEN]; - ns_int32 priority; - void *handle; - nstack_proc_cb mops; - ns_int32 ep_free_ref; //ep information need free with ref - ns_int32 modInx; // The index of module - ns_int32 maxfdid; //the max fd id - ns_int32 minfdid; //the min fd id + char modulename[NSTACK_MODULE_NAME_MAX]; + ns_int32 priority; + void *handle; + nstack_socket_ops ops; + ns_int32 modInx; // The index of module + ns_int32 maxfdid; //the max fd id + ns_int32 minfdid; //the min fd id } nstack_module; typedef struct { - ns_int32 modNum; // Number of modules registered - ns_int32 fix_mid; - nstack_module *defMod; // The default module - nstack_module modules[NSTACK_MAX_MODULE_NUM]; + ns_int32 modNum; // Number of modules registed + ns_int32 fix_mid; + ns_int32 linuxmid; + nstack_module *defMod; // The default module + nstack_module modules[NSTACK_MAX_MODULE_NUM]; } nstack_module_info; +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; + /*register module according the modulecfg file*/ -extern ns_int nstack_register_module (); +extern ns_int nstack_register_module(); /***************************************************************** Parameters : ops never be null; nstack api calls it; @@ -91,48 +89,39 @@ Return : 0,not match; 1, match Description : *****************************************************************/ extern nstack_module_info g_nstack_modules; +extern nstack_proc_ops nstack_fd_deal[NSTACK_MAX_MODULE_NUM]; extern nstack_module_keys g_nstack_module_desc[]; +extern ns_uint32 g_module_num; #define nstack_defmod_name() (g_nstack_modules.defMod->modulename) #define nstack_default_module() (g_nstack_modules.defMod) -#define nstack_defMod_inx() (g_nstack_modules.defMod->modInx) +#define nstack_defmod_inx() (g_nstack_modules.fix_mid) #define nstack_get_module(inx) (&g_nstack_modules.modules[(inx)]) -#define nstack_get_modNum() (g_nstack_modules.modNum) +#define nstack_get_module_num() (g_nstack_modules.modNum) #define nstack_get_module_name_by_idx(inx) (g_nstack_modules.modules[inx].modulename) -#define nstack_def_ops() (&g_nstack_modules.defMod->mops.socket_ops) -#define nstack_module_ops(modInx) (&g_nstack_modules.modules[(modInx)].mops.socket_ops) +#define nstack_def_ops() (&g_nstack_modules.defMod->ops) +#define nstack_get_linux_mid() (g_nstack_modules.linuxmid) +#define nstack_module_ops(modInx) (&g_nstack_modules.modules[(modInx)].ops) #define nstack_get_maxfd_id(modInx) (g_nstack_modules.modules[modInx].maxfdid) #define nstack_get_minfd_id(modInx) (g_nstack_modules.modules[modInx].minfdid) -#define nstack_get_descmaxfd_id(modInx) (g_nstack_module_desc[modInx].maxfdid) -#define nstack_epinfo_free_flag(modInx) (g_nstack_modules.modules[(modInx)].ep_free_ref == NSTACK_EP_FREE_NEED_REF) - -#define nstack_extern_deal(modInx) (g_nstack_modules.modules[(modInx)].mops.extern_ops) +#define nstack_set_maxfd_id(modInx, maxfd) (g_nstack_module_desc[modInx].maxfdid = maxfd) -#define nstack_defMod_profd(fdInf) ((fdInf)->protoFD[g_nstack_modules.defMod->modInx].fd) -#define nstack_inf_modProfd(fdInf, pMod) ((fdInf)->protoFD[(pMod)->modInx].fd) +#define nstack_def_mod_profd(fdInf) ((fdInf)->protoFD[g_nstack_modules.defMod->modInx].fd) +#define nstack_inf_mod_profd(fdInf, pMod) ((fdInf)->protoFD[(pMod)->modInx].fd) -#define nstack_get_fix_mid() (g_nstack_modules.fix_mid) -#define nstack_fix_mid_ops() (&(g_nstack_modules.modules[g_nstack_modules.fix_mid].mops.socket_ops)) -#define nstack_fix_stack_name() (g_nstack_modules.modules[g_nstack_modules.fix_mid].modulename) +#define nstack_each_mod_ops(modInx, ops) \ + for ((modInx) = 0; ((modInx) < nstack_get_module_num() && ((ops) = nstack_module_ops(modInx))); (modInx)++) -#define nstack_fix_fd_check() ((g_nstack_modules.fix_mid >= 0) && (g_nstack_modules.fix_mid < NSTACK_MAX_MODULE_NUM) \ - ? g_nstack_modules.modules[g_nstack_modules.fix_mid].mops.extern_ops.stack_fd_check \ - : NULL) - -#define nstack_each_modOps(modInx, ops) \ - for ((modInx) = 0; ((modInx) < nstack_get_modNum() && ((ops) = nstack_module_ops(modInx))); (modInx)++) - -#define nstack_each_modInx(modInx) \ - for ((modInx) = 0; ((modInx) < nstack_get_modNum()); (modInx)++) +#define nstack_each_mod_inx(modInx) \ + for ((modInx) = 0; ((modInx) < nstack_get_module_num()); (modInx)++) #define nstack_each_module(modInx, pMod) \ - for ((modInx) = 0; ((modInx) < nstack_get_modNum() && (pMod = nstack_get_module((modInx)))); (modInx)++) - -int nstack_stack_module_init (); -int nstack_stack_module_init_child (); + for ((modInx) = 0; ((modInx) < nstack_get_module_num() && (pMod = nstack_get_module((modInx)))); (modInx)++) -int nstack_get_deploy_type (); +void nstack_register_module_forchild(void); +int nstack_get_deploy_type(); +int nstack_stack_module_init(); #ifdef __cplusplus /* *INDENT-OFF* */ |