aboutsummaryrefslogtreecommitdiffstats
path: root/release
diff options
context:
space:
mode:
authorqchang <qing.chang1@huawei.com>2018-03-08 17:39:22 -0800
committerqchang <qing.chang1@huawei.com>2018-03-08 17:39:22 -0800
commit697ade6190b23c80e7f60963983786e679759393 (patch)
treedd9782d1e936b8342163b26795e23571d4b1b415 /release
parent71a4e2f34afa8018426f0e830050e50a1de6d375 (diff)
dmm initial commit
Change-Id: I049ee277cf4efdb83f9c2ac439365fcd421c159b Signed-off-by: qchang <qing.chang1@huawei.com>
Diffstat (limited to 'release')
-rw-r--r--release/configure/module_config.json27
-rw-r--r--release/configure/rd_config.json26
-rw-r--r--release/include/declare_syscalls.h51
-rw-r--r--release/include/nsocket_dmm_api.h128
4 files changed, 232 insertions, 0 deletions
diff --git a/release/configure/module_config.json b/release/configure/module_config.json
new file mode 100644
index 0000000..c9bae26
--- /dev/null
+++ b/release/configure/module_config.json
@@ -0,0 +1,27 @@
+{
+ "default_stack_name": "kernel",
+ "module_list": [
+ {
+ "stack_name": "kernel",
+ "function_name": "kernel_stack_register",
+ "libname": "./",
+ "loadtype": "static",
+ "deploytype": "1",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "0",
+ },
+ {
+ "stack_name": "stackpool",
+ "function_name": "nstack_stack_register",
+ "libname": "libnstack.so",
+ "loadtype": "dynmic",
+ "deploytype": "3",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "1",
+ },
+ ]
+}
diff --git a/release/configure/rd_config.json b/release/configure/rd_config.json
new file mode 100644
index 0000000..d005569
--- /dev/null
+++ b/release/configure/rd_config.json
@@ -0,0 +1,26 @@
+{
+ "ip_route": [
+ {
+ "subnet": "192.168.1.1/24",
+ "type": "nstack-kernel",
+ },
+ {
+ "subnet": "192.167.1.1/24",
+ "type": "nstack-kernel",
+ },
+ {
+ "subnet": "192.166.1.1/24",
+ "type": "nstack-kernel",
+ }
+ ],
+ "prot_route": [
+ {
+ "proto_type": "1",
+ "type": "nstack-kernel",
+ },
+ {
+ "proto_type": "2",
+ "type": "nstack-kernel",
+ }
+ ],
+}
diff --git a/release/include/declare_syscalls.h b/release/include/declare_syscalls.h
new file mode 100644
index 0000000..c4810f5
--- /dev/null
+++ b/release/include/declare_syscalls.h
@@ -0,0 +1,51 @@
+/*
+*
+* 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.
+*/
+
+NSTACK_MK_DECL (int, socket, (int, int, int));
+NSTACK_MK_DECL (int, bind, (int, const struct sockaddr *, socklen_t));
+NSTACK_MK_DECL (int, listen, (int, int));
+NSTACK_MK_DECL (int, shutdown, (int, int));
+NSTACK_MK_DECL (int, getsockname, (int, struct sockaddr *, socklen_t *));
+NSTACK_MK_DECL (int, getpeername, (int, struct sockaddr *, socklen_t *));
+NSTACK_MK_DECL (int, getsockopt, (int, int, int, void *, socklen_t *));
+NSTACK_MK_DECL (int, setsockopt, (int, int, int, const void *, socklen_t));
+NSTACK_MK_DECL (int, accept, (int, struct sockaddr *, socklen_t *));
+NSTACK_MK_DECL (int, accept4,
+ (int, struct sockaddr *, socklen_t *, int flags));
+NSTACK_MK_DECL (int, connect, (int, const struct sockaddr *, socklen_t));
+NSTACK_MK_DECL (ssize_t, recv, (int, void *, size_t, int));
+NSTACK_MK_DECL (ssize_t, send, (int, const void *, size_t, int));
+NSTACK_MK_DECL (ssize_t, read, (int, void *, size_t));
+NSTACK_MK_DECL (ssize_t, write, (int, const void *, size_t));
+NSTACK_MK_DECL (ssize_t, writev, (int, const struct iovec *, int));
+NSTACK_MK_DECL (ssize_t, readv, (int, const struct iovec *, int));
+NSTACK_MK_DECL (ssize_t, sendto,
+ (int, const void *, size_t, int, const struct sockaddr *,
+ socklen_t));
+NSTACK_MK_DECL (ssize_t, recvfrom,
+ (int, void *, size_t, int, struct sockaddr *, socklen_t *));
+NSTACK_MK_DECL (ssize_t, sendmsg, (int, const struct msghdr *, int flags));
+NSTACK_MK_DECL (ssize_t, recvmsg, (int, struct msghdr *, int flags));
+NSTACK_MK_DECL (int, close, (int));
+NSTACK_MK_DECL (int, select,
+ (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+NSTACK_MK_DECL (int, ioctl, (int, unsigned long, unsigned long));
+NSTACK_MK_DECL (int, fcntl, (int, int, unsigned long));
+NSTACK_MK_DECL (int, epoll_create, (int));
+NSTACK_MK_DECL (int, epoll_ctl, (int, int, int, struct epoll_event *));
+NSTACK_MK_DECL (int, epoll_wait, (int, struct epoll_event *, int, int));
+NSTACK_MK_DECL (pid_t, fork, (void));
+#undef NSTACK_MK_DECL
diff --git a/release/include/nsocket_dmm_api.h b/release/include/nsocket_dmm_api.h
new file mode 100644
index 0000000..ffdb709
--- /dev/null
+++ b/release/include/nsocket_dmm_api.h
@@ -0,0 +1,128 @@
+/*
+*
+* 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 __NSOCKET_DMM_API_H__
+#define __NSOCKET_DMM_API_H__
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/epoll.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+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 spplied to communicate whit stack */
+ NSTACK_MODEL_INVALID,
+} nstack_model_deploy_type;
+
+typedef enum
+{
+ MBUF_TRANSPORT,
+ MBUF_UDP,
+ MBUF_IP,
+ MBUF_LINK,
+ MBUF_RAW,
+ MBUF_MAX_LAYER,
+} mbuf_layer;
+
+/*
+ *Standard api interface definition.
+ *these interface is provided by Protocol stack to nStack
+ */
+typedef struct __nstack_socket_ops
+{
+#undef NSTACK_MK_DECL
+#define NSTACK_MK_DECL(ret, fn, args) ret (*pf##fn) args
+#include "declare_syscalls.h"
+} nstack_socket_ops;
+
+/*
+ *Interactive interface for Protocol stack and nStack defined here
+ *these interface is provided by Protocol stack to nStack
+ */
+typedef struct __nstack_extern_ops
+{
+ int (*module_init) (void); /*stack module init */
+ int (*fork_init_child) (pid_t p, pid_t c); /*after fork, stack child process init again if needed. */
+ void (*fork_parent_fd) (int s, pid_t p); /*after fork, stack parent process proc again if needed. */
+ void (*fork_child_fd) (int s, pid_t p, pid_t c); /*after fork, child record pid for recycle if needed. */
+ void (*fork_free_fd) (int s, pid_t p, pid_t c); /*for SOCK_CLOEXEC when fork if needed. */
+ unsigned int (*ep_ctl) (int epFD, int proFD, int ctl_ops, struct epoll_event * event, void *pdata); /*when fd add to epoll fd, triggle stack to proc if need */
+ unsigned int (*ep_getevt) (int epFD, int profd, unsigned int events); /*check whether some events exist really */
+ int (*peak) (int s); /*used for stack-x , isource maybe no need */
+} nstack_extern_ops;
+
+/*
+ *The event notify interface provided to the protocol stack by nStack
+ *these interface is provided by nStack to Protocol stack
+ */
+typedef struct __nstack_event_cb
+{
+ void *handle; /*current so file handler */
+ int type; /*nstack is assigned to the protocol stack and needs to be passed to nstack when the event is reported */
+ int (*event_cb) (void *pdata, int events);
+} nstack_event_cb;
+
+typedef struct __nstack_proc_cb
+{
+ nstack_socket_ops socket_ops; /*posix socket api */
+ nstack_extern_ops extern_ops; /*other proc callback */
+} nstack_proc_cb;
+
+/*
+ *Module registration interface.
+ *ouput param:posix_ps,proc_ops
+ *input param:event_ops
+ */
+typedef int (*nstack_stack_registe_fn) (nstack_proc_cb * proc_fun,
+ nstack_event_cb * event_ops);
+typedef void (*io_send_fn) (void *pbuf, void *pargs);
+typedef void (*io_recv_cb) (void **pbuf, void *pargs);
+typedef int (*recycle_fun) (unsigned int exit_pid, void *pdata,
+ unsigned short rec_type);
+
+/*structure type of mbuf*/
+typedef enum
+{
+ MBUF_TYPE_DPDK, /*mbuf structure type of DPDK */
+ MBUF_TYPE_STACKPOOL, /*mbuf structure type of stack-x */
+ MBUF_TYPE_INVALID,
+} mbuf_type;
+
+typedef struct
+{
+ int (*event_notify) (void *pdata, int events); /*event notify */
+ int (*ep_pdata_free) (void *pdata); /*pdata free */
+ void (*obj_recycle_reg) (unsigned char priority, unsigned short rec_type, void *data, recycle_fun cb_fun); /*source recycle */
+ void *(*mbuf_alloc) (mbuf_layer layer, unsigned short length, mbuf_type Type, unsigned short thread_index); /*zero copy memory alloc */
+ void (*mbuf_free) (void *p, mbuf_type Type); /*zero copy memory free */
+ void (*pkt_send_cb) (void *pbuf, mbuf_type inType, mbuf_type outType,
+ void *pargs, io_send_fn io_send);
+ void (*pkt_recv_cb) (void **pbuf, mbuf_type inType, mbuf_type outType,
+ void *pargs, io_recv_cb io_recv);
+} nStack_adpt_fun;
+
+extern int nstack_adpt_init (nstack_model_deploy_type deploy_type,
+ nStack_adpt_fun * out_ops, int flag);
+
+#endif