summaryrefslogtreecommitdiff
path: root/include/external
diff options
context:
space:
mode:
authorQiuwen Lu <[email protected]>2017-03-20 15:45:32 +0800
committerQiuwen Lu <[email protected]>2017-03-20 15:45:32 +0800
commit12b59f3f18db45ff85e27d90fba44156dceec059 (patch)
tree0e4070687dfcde68d611bd9eacf08de7e7fdcfa2 /include/external
parentd92ba3bf81a931a77ca175a50f8990f8b91233d2 (diff)
调整MARSIOv4的接口,接口加入了instance参数。
Diffstat (limited to 'include/external')
-rw-r--r--include/external/marsio.h121
-rw-r--r--include/external/marsio_buffer_user_api.h69
-rw-r--r--include/external/marsio_rawio_user_api.h22
-rw-r--r--include/external/marsio_udp_user_api.h32
4 files changed, 70 insertions, 174 deletions
diff --git a/include/external/marsio.h b/include/external/marsio.h
index 8606e0f..7fd9ecc 100644
--- a/include/external/marsio.h
+++ b/include/external/marsio.h
@@ -19,50 +19,10 @@ typedef enum
* 设置该掩码后,数据面线程数选项将被忽略。
*/
MARSIO_OPT_THREAD_MASK,
- /* 日志句柄(FILE *),类型:FILE *,缺省值:stderr
- * 不设置该选项将使日志向stderr输出
- */
- MARSIO_OPT_FILE_LOG,
- /* 配置文件路径,类型:char *, 缺省值:NULL
- * 设置该路径后,将到这一路径读取配置参数,SET_OPT的其他属性无效。
- */
- MARSIO_OPT_FILE_CONF_PATH,
/* 处理SIG信号,缺省值:类型:uint32_t,关闭(0)
* 启用该选项后,将自动处理SIGINT、SIGTERM信号
*/
- MARSIO_OPT_AUTOEXIT,
- /* 原始报文收发:收报文环数,类型:uint32_t,
- * 缺省值:与数据面线程数一致
- */
- MARSIO_OPT_RAW_RX_STREAM_NUM,
- /* 原始报文收发:发报文环数,
- * 类型:uint32_t,缺省值:与数据面线程数一致
- */
- MARSIO_OPT_RAW_TX_STREAM_NUM,
- /* 协议栈报文收发:收报文环数,
- * 类型:uint32_t,缺省值:与数据面线程数一致
- */
- MARSIO_OPT_STACK_RX_STREAM_NUM,
- /* 协议栈报文收发:发报文环数,
- * 类型:uint32_t,缺省值:与数据面线程数一致
- */
- MARSIO_OPT_STACK_TX_STREAM_NUM,
- /* 原始报文收发:注册启用设备,类型:const char *,返回值:device_id_t
- * 不设置启用设备将启用所有可能启用的设备
- */
- MARSIO_OPT_RAW_DEVICE,
- /* 协议栈设备收发:注册启用设备,类型:const char *,返回值:device_id_t
- * 不设置启用设备将启用所有可能启用的设备
- */
- MARSIO_OPT_STACK_DEVICE,
- /* 原始报文收发:查询设备数量
- * 查询选项,返回值:启用的原始报文收发设备数量。
- */
- MARSIO_OPT_RAW_DEVICE_NUM,
- /* 协议栈报文收发:查询设备数量
- * 查询选项,返回值:启用的协议栈设备收发设备数量
- */
- MARSIO_OPT_STACK_DEVICE_NUM,
+ MARSIO_OPT_EXIT_WHEN_ERR,
} marsio_opt_type_t;
@@ -70,30 +30,89 @@ typedef enum
extern "C" {
#endif
-#include <marsio_buffer_user_api.h>
+#include <stdint.h>
+#include <stddef.h>
typedef uint32_t device_id_t;
typedef uint32_t port_id_t;
typedef uint32_t queue_id_t;
typedef uint32_t thread_id_t;
+typedef void marsio_buff_t;
struct mr_sendpath;
+struct mr_instance;
+
+struct mr_instance * marsio_create();
+int marsio_option_get(struct mr_instance * instance, int opt_type, void * out_opt, size_t out_opt_buffer);
+int marsio_option_set(struct mr_instance * instance, marsio_opt_type_t opt_type, void * opt, size_t sz_opt);
+int marsio_init(struct mr_instance * instance, const char * appsym);
+int marsio_thread_init(struct mr_instance * instance);
+int marsio_destory(struct mr_instance * instance);
-int marsio_init(const char * appsym);
-int marsio_thread_init();
-int marsio_destory();
-int marsio_open_device(const char * devsym, unsigned int nr_rxstream, unsigned int nr_txstream);
+struct mr_vdev * marsio_open_device(struct mr_instance * instance,
+ const char * devsym, unsigned int nr_rxstream, unsigned int nr_txstream);
-int marsio_raw_recv_burst(device_id_t dev_id, queue_id_t qid, marsio_buff_t * mbufs[], int nr_mbufs);
-int marsio_raw_send_burst(device_id_t dev_id, queue_id_t qid, marsio_buff_t * mbufs[], int nr_mbufs);
-int marsio_fast_send_burst(device_id_t dev_id, queue_id_t qid, marsio_buff_t * mbufs[], int nr_mbufs);
+void marsio_close_device(struct mr_vdev * vdev);
-int marsio_recv_burst(device_id_t dev_id, queue_id_t sid, marsio_buff_t * mbufs[], int nr_mbufs);
-int marsio_send_burst(struct mr_sendpath * sendpath, queue_id_t sid, marsio_buff_t * mbufs[], int nr_mbufs);
+struct mr_vdev * marsio_device_lookup(struct mr_instance * instance, const char * devsym);
+
+int marsio_recv_burst(struct mr_vdev * vdev, queue_id_t qid, marsio_buff_t * mbufs[], int nr_mbufs);
+int marsio_send_burst(struct mr_sendpath * sendpath, queue_id_t qid, marsio_buff_t * mbufs[], int nr_mbufs);
int marsio_udp_header_construct(marsio_buff_t * buff, uint16_t s_port, uint16_t d_port);
int marsio_ipv4_header_construct(marsio_buff_t * buff, uint32_t s_ip, uint32_t d_ip, uint8_t proto);
+//simply get control zone data ptr.
+void *marsio_buff_ctrlzone(marsio_buff_t *m, uint8_t id);
+
+//a safe way to read control zone data.
+void *marsio_buff_ctrlzone_data(marsio_buff_t *m, uint8_t id, uint8_t *size);
+
+//a safe way to set control zone data.
+void marsio_buff_ctrlzone_set(marsio_buff_t *m, uint8_t id, void* ptr_data, uint8_t size);
+
+void marsio_buff_reset(marsio_buff_t *m);
+
+marsio_buff_t *marsio_buff_getnext_seg(marsio_buff_t *m);
+marsio_buff_t *marsio_buff_getnext_pkt(marsio_buff_t *m);
+
+void marsio_buff_append_pkt(marsio_buff_t *head, marsio_buff_t *next);
+void marsio_buff_append_seg(marsio_buff_t *head, marsio_buff_t *next);
+
+uint16_t marsio_buff_headroom(const marsio_buff_t *m);
+uint16_t marsio_buff_tailroom(const marsio_buff_t *m);
+
+marsio_buff_t *marsio_buff_getnext_seg(marsio_buff_t *m);
+marsio_buff_t *marsio_buff_getnext_pkt(marsio_buff_t *m);
+
+char *marsio_buff_mtod(marsio_buff_t *m);
+
+uint32_t marsio_buff_buflen(marsio_buff_t *m);
+
+uint32_t marsio_buff_datalen(marsio_buff_t *m);
+
+char *marsio_buff_prepend(marsio_buff_t *m, uint16_t len);
+
+char *marsio_buff_append(marsio_buff_t *m, uint16_t len);
+
+char *marsio_buff_adj(marsio_buff_t *m, uint16_t len);
+
+int marsio_buff_trim(marsio_buff_t *m, uint16_t len);
+
+uint16_t marsio_buff_headroom(const marsio_buff_t *m);
+
+uint16_t marsio_buff_tailroom(const marsio_buff_t *m);
+
+uint32_t marsio_get_pkt_type(marsio_buff_t *m);
+
+marsio_buff_t *marsio_buff_dup(struct mr_vdev * vdev, marsio_buff_t *m);
+
+int marsio_buff_malloc(struct mr_vdev * vdev, marsio_buff_t *marsio_buff[],
+ unsigned int nb_buff, unsigned int flags, int thread_seq);
+
+void marsio_buff_free(struct mr_vdev * vdev, marsio_buff_t *marsio_buff[],
+ unsigned int nb_buff);
+
#ifdef __cplusplus
}
#endif \ No newline at end of file
diff --git a/include/external/marsio_buffer_user_api.h b/include/external/marsio_buffer_user_api.h
deleted file mode 100644
index 1aabae1..0000000
--- a/include/external/marsio_buffer_user_api.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef _MARSIO_BUFF_USER_API_H_
-#define _MARSIO_BUFF_USER_API_H_
-
-/*
- marsio mbuf definition.
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-
-typedef void marsio_buff_t;
-
-int marsio_buff_malloc(marsio_buff_t *m[], unsigned int nb_buff,unsigned int flags,int thread_seq);
-void marsio_buff_free(marsio_buff_t *m[], unsigned int nb_buff);
-
-//simply get control zone data ptr.
-void *marsio_buff_ctrlzone(marsio_buff_t *m,uint8_t id);
-
-//a safe way to read control zone data.
-void *marsio_buff_ctrlzone_data(marsio_buff_t *m,uint8_t id,uint8_t *size);
-
-//a safe way to set control zone data.
-void marsio_buff_ctrlzone_set(marsio_buff_t *m,uint8_t id,void* ptr_data,uint8_t size);
-
-void marsio_buff_reset(marsio_buff_t *m);
-
-marsio_buff_t *marsio_buff_getnext_seg(marsio_buff_t *m);
-marsio_buff_t *marsio_buff_getnext_pkt(marsio_buff_t *m);
-
-void marsio_buff_append_pkt(marsio_buff_t *head, marsio_buff_t *next);
-void marsio_buff_append_seg(marsio_buff_t *head, marsio_buff_t *next);
-
-uint16_t marsio_buff_headroom(const marsio_buff_t *m);
-uint16_t marsio_buff_tailroom(const marsio_buff_t *m);
-
-marsio_buff_t *marsio_buff_getnext_seg(marsio_buff_t *m);
-marsio_buff_t *marsio_buff_getnext_pkt(marsio_buff_t *m);
-
-char *marsio_buff_mtod(marsio_buff_t *m);
-
-uint32_t marsio_buff_buflen(marsio_buff_t *m);
-
-uint32_t marsio_buff_datalen(marsio_buff_t *m);
-
-char *marsio_buff_prepend(marsio_buff_t *m, uint16_t len);
-
-char *marsio_buff_append(marsio_buff_t *m, uint16_t len);
-
-char *marsio_buff_adj(marsio_buff_t *m, uint16_t len);
-
-int marsio_buff_trim(marsio_buff_t *m, uint16_t len);
-
-uint16_t marsio_buff_headroom(const marsio_buff_t *m);
-
-uint16_t marsio_buff_tailroom(const marsio_buff_t *m);
-
-uint32_t marsio_get_pkt_type(marsio_buff_t *m);
-
-marsio_buff_t *marsio_buff_dup(marsio_buff_t *m);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/include/external/marsio_rawio_user_api.h b/include/external/marsio_rawio_user_api.h
deleted file mode 100644
index 6d48286..0000000
--- a/include/external/marsio_rawio_user_api.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#pragma once
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "marsio_buffer_user_api.h"
-
-typedef void * raw_socket_t;
-typedef uint32_t thread_id_t;
-typedef uint32_t device_id_t;
-
-int marsio_raw_recv_burst(device_id_t dev_id, thread_id_t sid,
- marsio_buff_t * mbufs[], int nr_max_mbufs);
-
-int marsio_raw_send_burst(device_id_t dev_id, thread_id_t sid,
- marsio_buff_t * mbufs[], int nr_mbufs);
-
-
-#ifdef __cplusplus
-}
-#endif \ No newline at end of file
diff --git a/include/external/marsio_udp_user_api.h b/include/external/marsio_udp_user_api.h
deleted file mode 100644
index a2332ec..0000000
--- a/include/external/marsio_udp_user_api.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-
-#include <sys/socket.h>
-#include <unistd.h>
-
-int marsio_socket(int family, int type, int protocol);
-
-int marsio_connect(int fd, const struct sockaddr * addr, socklen_t addrlen);
-
-int marsio_bind(int fd, const struct sockaddr * addr, socklen_t addrlen);
-
-/* UDP���Ļ�������ͬһ�����ϵĻ�������ʾͬһ��UDP���� */
-/* ����MARSIO-3�汾���¹��ܲ�Ҫʹ�� */
-struct marsio_udp_buff
-{
- /* ��������ʼ��ַ */
- void * start;
- /* ���������� */
- unsigned int len;
- /* ��һ�黺������ַ */
- struct marsio_udp_buff * next;
- /* ��һ������ʼ��ַ */
- struct marsio_udp_buff * next_pkt;
-};
-
-struct marsio_udp_buff * marsio_udp_alloc() __attribute__((__deprecated__));
-
-void marsio_udp_free(struct marsio_udp_buff * udp_buff) __attribute__((__deprecated__));
-
-ssize_t marsio_udp_sendto_chain(int marsio_fd, struct marsio_udp_buff * chain_head,
- int nb_buff, int flags, struct sockaddr * to[], socklen_t addrlen[], int nb_sockaddrs)
- __attribute__((__deprecated__)); \ No newline at end of file