diff options
author | 2018-03-12 10:07:58 +0800 | |
---|---|---|
committer | 2018-03-12 10:07:58 +0800 | |
commit | c398e6ec613c1f90ffe33608c511208100e7372f (patch) | |
tree | 554b2bc400e14e9ae8e838582e7433ea71eb499f /src/nSocket/nstack_rd/nstack_rd_priv.h | |
parent | 71a4e2f34afa8018426f0e830050e50a1de6d375 (diff) |
Add the nSocket module for dmm
Change-Id: I8b97fbe50c9c1c479072510b8d799fe711360da7
Signed-off-by: Yalei Wang <william.wangyalei@huawei.com>
Diffstat (limited to 'src/nSocket/nstack_rd/nstack_rd_priv.h')
-rw-r--r-- | src/nSocket/nstack_rd/nstack_rd_priv.h | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/src/nSocket/nstack_rd/nstack_rd_priv.h b/src/nSocket/nstack_rd/nstack_rd_priv.h new file mode 100644 index 0000000..217f1d3 --- /dev/null +++ b/src/nSocket/nstack_rd/nstack_rd_priv.h @@ -0,0 +1,112 @@ +/* +* +* 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_RD_PRIV_H +#define __NSTACK_RD_PRIV_H +#include "list.h" + +#define NSTACK_RD_SUCCESS (0) +#define NSTACK_RD_FAIL (-1) +#define NSTACK_RD_ITEM_MAX (1024) + +#define NSTACK_RD_AGETIME_MAX (1) +#define NSTACK_SYS_FUN_MAX (16) + +#define RD_STACKX_NAME "stackx" +#define RD_LINUX_NAME "kernel" + +#define RD_STACKX_PLANENAME "nstack-dpdk" +#define RD_LINUX_PLANENAME "nstack-kernel" +#define RD_LINUX_PLANENULL "null" + +#define NSTACK_RD_INDEX_BYIP(ip) (((ip) & 0xff) \ + + (((ip) >> 8)&0xff) \ + + (((ip) >> 16)&0xff) \ + + (((ip) >> 24)&0xff)) + +typedef struct __rd_stack_plane_map +{ + char stackname[STACK_NAME_MAX]; + char planename[RD_PLANE_NAMELEN]; + int stackid; +} rd_stack_plane_map; + +/*route data*/ +typedef struct __rd_data_item +{ + /*route info type , for example base on ip */ + rd_data_type type; + int stack_id; + int agetime; + union + { + rd_ip_data ipdata; + unsigned int proto_type; + }; +} rd_data_item; + +/*stack rd node*/ +typedef struct __nstack_rd_node +{ + struct hlist_node rdnode; + rd_data_item item; +} nstack_rd_node; + +typedef struct __nstack_rd_list +{ + struct hlist_head headlist; +} nstack_rd_list; + +typedef struct __nstack_rd_stack_info +{ + /*stack name */ + rd_stack_plane_map stack; + /*stack id */ + int stack_id; + /*when route info not found, high priority stack was chose, same priority chose fist input one */ + int priority; /*0: highest: route info not found choose first */ +} nstack_rd_stack_info; + +/*rd local data*/ +typedef struct __rd_local_data +{ + nstack_rd_stack_info *pstack_info; + int stack_num; + nstack_rd_list route_list[RD_DATA_TYPE_MAX]; /*route table */ + nstack_get_route_data sys_fun[NSTACK_SYS_FUN_MAX]; /*rd data sys proc function list */ + int fun_num; +} rd_local_data; + +typedef struct __rd_data_proc +{ + int (*rd_item_cpy) (void *destdata, void *srcdata); + int (*rd_item_inset) (nstack_rd_list * hlist, void *rditem); + int (*rd_item_age) (nstack_rd_list * hlist); + int (*rd_item_find) (nstack_rd_list * hlist, void *rdkey, void *outitem); + int (*rd_item_spec) (void *rdkey); + int (*rd_item_defualt) (void *rdkey); +} rd_data_proc; + +extern rd_local_data *g_rd_local_data; +extern rd_data_proc g_rd_cpy[RD_DATA_TYPE_MAX]; + +#define NSTACK_NUM (g_rd_local_data->stack_num) +#define NSTACK_RD_LIST(type) (&(g_rd_local_data->route_list[(type)])) +#define NSTACK_GET_STACK(idx) ((g_rd_local_data->pstack_info)[idx].stack_id) + +int nstack_get_stackid_byname (char *name); + +#endif |