[PAKCET_IO] framework intermediate state
This commit is contained in:
@@ -18,17 +18,4 @@ typedef enum {
|
||||
ST_ERR_PIO_INSTANCE,
|
||||
ST_ERR_PIO_DEVICE,
|
||||
ST_ERR_MAX
|
||||
} error_code_t;
|
||||
|
||||
const char *st_error_to_string(error_code_t err)
|
||||
{
|
||||
switch (err) {
|
||||
CASE_CODE (ST_OK);
|
||||
CASE_CODE (ST_ERR_MEM_ALLOC);
|
||||
CASE_CODE (ST_ERR_RUN_MODE);
|
||||
CASE_CODE (ST_ERR_PIO_INSTANCE);
|
||||
CASE_CODE (ST_ERR_PIO_DEVICE);
|
||||
}
|
||||
|
||||
return "UNKNOWN_ERROR";
|
||||
}
|
||||
} error_code_t;
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/sdk/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/deps/)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/common/)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/packet_io/)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/session_manager/)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/plugin_manager/)
|
||||
@@ -16,4 +17,4 @@ add_executable(stellar
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(stellar packet_io plugin_manager session_manager http)
|
||||
target_link_libraries(stellar packet_io plugin_manager session_manager http dl)
|
||||
0
src/common/common.h
Normal file
0
src/common/common.h
Normal file
13
src/common/global_var.cpp
Normal file
13
src/common/global_var.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: global_var.cpp
|
||||
* Description:
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#include "global_var.h"
|
||||
|
||||
struct stellar_engine g_engine_instance;
|
||||
63
src/common/global_var.h
Normal file
63
src/common/global_var.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: global_var.h
|
||||
* Description: global variable and data structure
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define DEV_MAX_CNT 16
|
||||
|
||||
enum packet_io_run_mode {
|
||||
PACKET_IO_RUN_MODE_PCAP_FILE,
|
||||
PACKET_IO_RUN_MODE_PCAP_LIVE,
|
||||
PACKET_IO_RUN_MODE_MARSIO,
|
||||
PACKET_IO_RUN_MODE_MAX,
|
||||
};
|
||||
|
||||
struct cpu_config {};
|
||||
struct mem_config {};
|
||||
|
||||
struct system_config {
|
||||
char instance_name[NAME_MAX];
|
||||
};
|
||||
|
||||
/* store packet_io config */
|
||||
struct packet_io_config {
|
||||
/* packet_io run mode */
|
||||
enum packet_io_run_mode mode;
|
||||
|
||||
/* worker thread num */
|
||||
uint32_t thread_num;
|
||||
|
||||
/* device name list */
|
||||
char dev_name[DEV_MAX_CNT][NAME_MAX];
|
||||
|
||||
/* device counts */
|
||||
uint32_t dev_cnt;
|
||||
};
|
||||
|
||||
struct lib_config {
|
||||
const char *libmarsio_path;
|
||||
};
|
||||
|
||||
struct stellar_config {
|
||||
struct cpu_config cpu;
|
||||
struct mem_config mem;
|
||||
struct system_config system;
|
||||
struct packet_io_config packet_io;
|
||||
struct lib_config lib;
|
||||
};
|
||||
|
||||
struct stellar_engine {
|
||||
struct stellar_config config;
|
||||
};
|
||||
|
||||
extern struct stellar_engine g_engine_instance;
|
||||
38
src/main.cpp
38
src/main.cpp
@@ -1,15 +1,20 @@
|
||||
#include "packet_io.h"
|
||||
#include "session_manager.h"
|
||||
#include "plugin_manager.h"
|
||||
#include "http.h"
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: main.cpp
|
||||
* Description: stellar main entry
|
||||
*
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#include "./common/common.h"
|
||||
#include "./common/global_var.h"
|
||||
#include "./packet_io/packet_io.h"
|
||||
#include "./session_manager/session_manager.h"
|
||||
#include "./plugin_manager/plugin_manager.h"
|
||||
#include "../sdk/include/http.h"
|
||||
#include "../sdk/include/logger.h"
|
||||
|
||||
struct engine_instance {
|
||||
struct packet_io_config pio_config;
|
||||
};
|
||||
|
||||
struct engine_instance g_engine_instance;
|
||||
|
||||
struct packet_io_loop_arg
|
||||
{
|
||||
struct packet_io_device *dev;
|
||||
@@ -46,9 +51,9 @@ void packet_io_loop(struct packet_io_loop_arg *arg)
|
||||
}
|
||||
|
||||
|
||||
struct packet_io_device *packet_io_init(int worker_thread_num, const char *device_name)
|
||||
struct packet_io_device *packet_io_init(const char *instance_name, enum packet_io_run_mode mode, int worker_thread_num)
|
||||
{
|
||||
struct packet_io_instance *ppio_instance = packet_io_instance_init(&g_engine_instance.pio_config);
|
||||
struct packet_io_instance *ppio_instance = packet_io_instance_create(instance_name, mode, worker_thread_num);
|
||||
if (nullptr == ppio_instance) {
|
||||
log_error(ST_ERR_PIO_INSTANCE, "packet_io instance init failed.");
|
||||
return nullptr;
|
||||
@@ -67,12 +72,13 @@ int main(int argc, char ** argv)
|
||||
/* global engine instance init */
|
||||
memset(&g_engine_instance, 0, sizeof(g_engine_instance));
|
||||
|
||||
g_engine_instance.pio_config.mode = PACKET_IO_RUN_MODE_PCAP_FILE;
|
||||
strncpy(g_engine_instance.pio_config.dev_name[0], "./test.pcap", sizeof(NAME_MAX_LEN));
|
||||
g_engine_instance.pio_config.dev_cnt = 1;
|
||||
g_engine_instance.config.packet_io.mode = PACKET_IO_RUN_MODE_PCAP_FILE;
|
||||
strncpy(g_engine_instance.config.packet_io.dev_name[0], "./test.pcap", sizeof(NAME_MAX));
|
||||
g_engine_instance.config.packet_io.dev_cnt = 1;
|
||||
|
||||
/* packet io init */
|
||||
packet_io_instance_init(&g_engine_instance.pio_config);
|
||||
packet_io_init("stellar", g_engine_instance.config.packet_io.mode, 2);
|
||||
|
||||
session_manager_session_event_register(http_decoder, SESSION_TYPE_HTTP);
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
|
||||
add_library(packet_io
|
||||
../common/global_var.cpp
|
||||
packet_io.cpp
|
||||
pcap_live_mode/pcap_live.cpp
|
||||
pcap_file_mode/pcap_file.cpp
|
||||
marsio_mode/marsio.cpp
|
||||
pcap_live_mode/pio_pcap_live.cpp
|
||||
pcap_file_mode/pio_pcap_file.cpp
|
||||
marsio_mode/pio_marsio.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(test)
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: marsio.cpp
|
||||
* Description:
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#include "marsio.h"
|
||||
|
||||
int marsio_device_init(const void *init_data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_device_fini(const void *init_data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_device_receive(void *data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_device_send(void *data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int marsio_instance_create(struct packet_io_instance *pinst) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void marsio_instance_destroy(void) {
|
||||
|
||||
}
|
||||
@@ -1,31 +1,268 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: marsio.h
|
||||
* Description: marsio runmode api
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
* \brief MARSIO Userspace ZeroCopy Driver Version 4
|
||||
*
|
||||
* This is the user api header file of MARSIOv4 ZeroCopy Driver
|
||||
*
|
||||
* \author Qiuwen Lu<luqiuwen@iie.ac.cn>
|
||||
* Institute of Information Engineering, Chinese Academy of Sciences
|
||||
*
|
||||
* \date 2016-12-01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
typedef enum
|
||||
{
|
||||
/* 数据面线程数,没有缺省值 */
|
||||
MARSIO_OPT_THREAD_NUM,
|
||||
/* 数据面线程绑定掩码,没有缺省值,设置该掩码后,数据面线程数选项将被忽略。*/
|
||||
MARSIO_OPT_THREAD_MASK,
|
||||
/* 线程绑定模式,类型:uint32_t */
|
||||
MARSIO_OPT_THREAD_AFFINITY_MODE,
|
||||
|
||||
struct mr_instance;
|
||||
/* 处理SIG信号,缺省值:类型:uint32_t,关闭(0)
|
||||
* 启用该选项后,将自动处理SIGINT、SIGTERM信号
|
||||
*/
|
||||
MARSIO_OPT_EXIT_WHEN_ERR,
|
||||
|
||||
struct pio_marsio_device_context {
|
||||
/* 拓展数据面线程绑定掩码,适应大于64个核处理器的硬件平台
|
||||
* 设置该掩码后,数据面线程数选项将被忽略
|
||||
*/
|
||||
MARSIO_OPT_THREAD_MASK_IN_CPUSET,
|
||||
|
||||
} marsio_opt_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/* 发送后不释放数据包,由应用自行释放数据包 */
|
||||
MARSIO_SEND_OPT_NO_FREE = 1 << 0,
|
||||
/* 发送时计算发包哈希值,用于分流 */
|
||||
MARSIO_SEND_OPT_REHASH = 1 << 1,
|
||||
/* 快速报文路径 */
|
||||
MARSIO_SEND_OPT_FAST = 1 << 2,
|
||||
/* 报文追踪标记 */
|
||||
MARSIO_SEND_OPT_TRACE = 1 << 3,
|
||||
/* 控制报文标记 */
|
||||
MARSIO_SEND_OPT_CTRL = 1 << 4
|
||||
|
||||
} marsio_opt_send_t;
|
||||
|
||||
enum mr_sendpath_type
|
||||
{
|
||||
/* 去往特定虚设备的发包路径 */
|
||||
MR_SENDPATH_VDEV,
|
||||
/* 路由查表确定发包路径 */
|
||||
MR_SENDPATH_ROUTE_NORMAL,
|
||||
/* 特定设备路由查表确定发包路径 */
|
||||
MR_SENDPATH_ROUTE_SPEC_DEV,
|
||||
/* MAX标记 */
|
||||
MR_SENDPATH_MAX
|
||||
};
|
||||
|
||||
int marsio_device_init(const void *init_data);
|
||||
enum mr_sendpath_option
|
||||
{
|
||||
/* 构建四层报文头 */
|
||||
MR_SENDPATH_OPT_BUILD_L4 = 0,
|
||||
/* 构建三层报文头 */
|
||||
MR_SENDPATH_OPT_BUILD_L3 = 1,
|
||||
/* 构建二层报文头 */
|
||||
MR_SENDPATH_OPT_BUILD_L2 = 2,
|
||||
/* 构建前Hook点回调 */
|
||||
MR_SENDPATH_OPT_HOOK_PREBUILD = 50,
|
||||
/* 构建后Hook点回调 */
|
||||
MR_SENDPATH_OPT_HOOK_POSTBUILD = 51,
|
||||
};
|
||||
|
||||
int marsio_device_fini(const void *init_data);
|
||||
enum mr_clone_options
|
||||
{
|
||||
/* 拷贝区域 */
|
||||
MR_BUFF_CLONE_DATA = 1 << 0,
|
||||
MR_BUFF_CLONE_BUFF = 1 << 1,
|
||||
MR_BUFF_CLONE_CTRLZONE = 1 << 2,
|
||||
};
|
||||
|
||||
int marsio_device_receive(void *data);
|
||||
enum mr_thread_affinity_mode
|
||||
{
|
||||
/* 禁用线程亲和性设置 */
|
||||
MR_THREAD_AFFINITY_DISABLE = 0,
|
||||
/* 自动线程亲和性设置 */
|
||||
MR_THREAD_AFFINITY_AUTO = 1,
|
||||
/* 自定义线程亲和性设置 */
|
||||
MR_THREAD_AFFINITY_USER = 255
|
||||
};
|
||||
|
||||
int marsio_device_send(void *data);
|
||||
enum mr_timestamp_type
|
||||
{
|
||||
/* 从网卡收取时或报文缓冲区申请时的时间戳 */
|
||||
MR_TIMESTAMP_RX_OR_ALLOC = 0,
|
||||
};
|
||||
|
||||
int marsio_instance_create(struct packet_io_instance *pinst);
|
||||
enum mr_buff_metadata_type
|
||||
{
|
||||
/* 分流哈希值,会根据该值计算分流队列 */
|
||||
MR_BUFF_REHASH_INDEX = 0,
|
||||
/* 网卡剥离的VLAN标签 */
|
||||
MR_BUFF_METADATA_VLAN_TCI = 1,
|
||||
};
|
||||
|
||||
void marsio_instance_destroy(void);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef MARSIO_SOCKET_ID_ANY
|
||||
#define MARSIO_SOCKET_ID_ANY -1
|
||||
#endif
|
||||
|
||||
#ifndef MARSIO_LCORE_ID_ANY
|
||||
#define MARSIO_LCORE_ID_ANY -1
|
||||
#endif
|
||||
|
||||
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_vdev;
|
||||
|
||||
struct mr_instance * marsio_create();
|
||||
struct mr_instance * marsio_current();
|
||||
|
||||
typedef int (*fn_sendpath_hook_t)(struct mr_sendpath * sendpath, marsio_buff_t * mbuf[], unsigned int nr_mbuf,
|
||||
void * arg);
|
||||
|
||||
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);
|
||||
|
||||
struct mr_vdev * marsio_open_device(struct mr_instance * instance, const char * devsym, unsigned int nr_rxstream,
|
||||
unsigned int nr_txstream);
|
||||
|
||||
void marsio_close_device(struct mr_vdev * vdev);
|
||||
|
||||
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_recv_all_burst(struct mr_instance * instance, 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_send_burst_with_options(struct mr_sendpath * sendpath, queue_id_t sid, marsio_buff_t * mbufs[], int nr_mbufs,
|
||||
uint16_t options);
|
||||
void marsio_send_burst_flush(struct mr_sendpath * sendpath, queue_id_t sid);
|
||||
|
||||
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);
|
||||
|
||||
struct mr_sendpath * marsio_sendpath_create_by_droute(struct mr_vdev * dest_device, struct in_addr addr);
|
||||
struct mr_sendpath * marsio_sendpath_create_by_route(struct mr_instance * instance, struct in_addr addr);
|
||||
struct mr_sendpath * marsio_sendpath_create_by_vdev(struct mr_vdev * dest_device);
|
||||
|
||||
struct mr_sendpath * marsio_sendpath_create(struct mr_instance * instance, int type, ...);
|
||||
int marsio_sendpath_option_set(struct mr_instance * instance, struct mr_sendpath * sendpath, int opt, ...);
|
||||
int marsio_sendpath_option_get(struct mr_instance * instance, struct mr_sendpath * sendpath, int opt, ...);
|
||||
void marsio_sendpath_destory(struct mr_sendpath * sendpath);
|
||||
|
||||
// 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);
|
||||
void marsio_buff_chain_pkt(marsio_buff_t * pkt, 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);
|
||||
|
||||
char * marsio_buff_offset_set(marsio_buff_t * m, off_t offset, int is_relative);
|
||||
|
||||
off_t marsio_buff_offset_get(marsio_buff_t * m);
|
||||
|
||||
/* 支持写时复制的报文修改裁剪函数 */
|
||||
marsio_buff_t * marsio_buff_prepend_cw(struct mr_instance * instance, marsio_buff_t * m, uint16_t len, void ** ptr_out);
|
||||
|
||||
marsio_buff_t * marsio_buff_append_cw(struct mr_instance * instance, marsio_buff_t * m, uint16_t len, void ** ptr_out);
|
||||
|
||||
marsio_buff_t * marsio_buff_adj_cw(struct mr_instance * instance, marsio_buff_t * m, uint16_t len, void ** ptr_out);
|
||||
|
||||
marsio_buff_t * marsio_buff_trim_cw(struct mr_instance * instance, marsio_buff_t * m, uint16_t len, void ** ptr_out);
|
||||
|
||||
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);
|
||||
|
||||
void marsio_pktmbuf_dump(FILE * f, const marsio_buff_t * m, unsigned dump_len);
|
||||
|
||||
marsio_buff_t * marsio_buff_clone_deep(struct mr_instance * instance, marsio_buff_t * md, int socket_id, int thread_id);
|
||||
|
||||
marsio_buff_t * marsio_buff_clone_with_options(struct mr_instance * instance, marsio_buff_t * md, int socket_id,
|
||||
int thread_id, uint16_t options);
|
||||
|
||||
int marsio_buff_malloc_device(struct mr_vdev * vdev, marsio_buff_t * marsio_buff[], unsigned int nr_mbufs,
|
||||
int socket_id, int thread_id);
|
||||
|
||||
int marsio_buff_malloc_global(struct mr_instance * instance, marsio_buff_t * marsio_buff[], unsigned int nr_mbufs,
|
||||
int socket_id, int thread_id);
|
||||
|
||||
void marsio_buff_free(struct mr_instance * instance, marsio_buff_t * marsio_buff[], unsigned int nr_mbufs,
|
||||
int socket_id, int thread_id);
|
||||
|
||||
int marsio_buff_is_ctrlbuf(marsio_buff_t * m);
|
||||
|
||||
void marsio_buff_set_ctrlbuf(marsio_buff_t * m);
|
||||
|
||||
marsio_buff_t * marsio_buff_malloc_smartoffload(struct mr_vdev * vdev, const char * pkt, unsigned int pkt_len);
|
||||
|
||||
uint64_t marsio_buff_get_timestamp(marsio_buff_t * m);
|
||||
void marsio_buff_set_timestamp(marsio_buff_t * m, uint64_t timestamp);
|
||||
int marsio_buff_get_timestamp_ex(marsio_buff_t * m, enum mr_timestamp_type ts_type, struct timespec * ts);
|
||||
|
||||
void marsio_buff_set_rehash_index(marsio_buff_t * m, uint32_t hash);
|
||||
uint32_t marsio_buff_get_rehash_index(marsio_buff_t * m);
|
||||
|
||||
int marsio_buff_get_metadata(marsio_buff_t * m, enum mr_buff_metadata_type type, void * data, unsigned int sz_data);
|
||||
int marsio_buff_set_metadata(marsio_buff_t * m, enum mr_buff_metadata_type type, void * data, unsigned int sz_data);
|
||||
int marsio_buff_unset_metadata(marsio_buff_t * m, enum mr_buff_metadata_type type);
|
||||
|
||||
void * marsio_shared_mem_alloc(struct mr_instance * instance, size_t len);
|
||||
void marsio_shared_mem_free(struct mr_instance * instance, void * mem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
298
src/packet_io/marsio_mode/pio_marsio.cpp
Normal file
298
src/packet_io/marsio_mode/pio_marsio.cpp
Normal file
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: marsio.h
|
||||
* Description: marsio runmode api
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "pio_marsio.h"
|
||||
#include "../packet_io.h"
|
||||
#include "../../common/global_var.h"
|
||||
#include "../../common/common.h"
|
||||
#include "../../sdk/include/logger.h"
|
||||
#include "../../sdk/include/util_errors.h"
|
||||
|
||||
static struct marsio_dll_function_entries shared_marsio_dll_func_entries;
|
||||
|
||||
static void fake_marsio_buff_set_rehash_index(marsio_buff_t *m, uint32_t hash)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int pio_get_marsio_dll_function_entries(void)
|
||||
{
|
||||
|
||||
void *marsio_so_handle = dlopen(g_engine_instance.config.lib.libmarsio_path, RTLD_NOW | RTLD_LOCAL | RTLD_NODELETE);
|
||||
if (nullptr == marsio_so_handle) {
|
||||
printf("\033[1;31;40m[Error]dlopen '%s' failed, %s\033[0m\n", g_engine_instance.config.lib.libmarsio_path, dlerror());
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_create =
|
||||
(struct mr_instance *(*)(void))dlsym(marsio_so_handle, "marsio_create");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_create) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_create", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_init =
|
||||
(int (*)(struct mr_instance *, const char *))dlsym(marsio_so_handle, "marsio_init");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_init) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_init", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_destroy =
|
||||
(int (*)(struct mr_instance *))dlsym(marsio_so_handle, "marsio_destory");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_destroy) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_destory", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_open_device =
|
||||
(struct mr_vdev *(*)(struct mr_instance *, const char *, unsigned int, unsigned int))dlsym(marsio_so_handle, "marsio_open_device");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_open_device) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_open_device", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_close_device =
|
||||
(void (*)(struct mr_vdev *))dlsym(marsio_so_handle, "marsio_close_device");
|
||||
if (nullptr ==shared_marsio_dll_func_entries.ptr_marsio_close_device) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_close_device", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_option_set =
|
||||
(int (*)(struct mr_instance *, marsio_opt_type_t, void *, size_t))dlsym(marsio_so_handle, "marsio_option_set");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_option_set) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_option_set", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_sendpath_create_by_vdev =
|
||||
(struct mr_sendpath *(*)(struct mr_vdev *))dlsym(marsio_so_handle, "marsio_sendpath_create_by_vdev");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_sendpath_create_by_vdev) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_sendpath_create_by_vdev", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_sendpath_destroy =
|
||||
(void (*)(struct mr_sendpath *))dlsym(marsio_so_handle, "marsio_sendpath_destory");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_sendpath_destroy) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_sendpath_destory", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_thread_init =
|
||||
(int (*)(struct mr_instance *))dlsym(marsio_so_handle, "marsio_thread_init");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_thread_init) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_thread_init", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_recv_burst =
|
||||
(int (*)(struct mr_vdev *, queue_id_t, marsio_buff_t **, int))dlsym(marsio_so_handle, "marsio_recv_burst");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_recv_burst) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_recv_burst", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_send_burst =
|
||||
(int (*)(struct mr_sendpath *, queue_id_t, marsio_buff_t **, int))dlsym(marsio_so_handle, "marsio_send_burst");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_send_burst) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_send_burst", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_send_burst_with_options =
|
||||
(int (*)(struct mr_sendpath *, queue_id_t, marsio_buff_t **, int, uint16_t))dlsym(marsio_so_handle, "marsio_send_burst_with_options");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_send_burst_with_options) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_send_burst_with_options", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_malloc_global =
|
||||
(int (*)(struct mr_instance *, marsio_buff_t **, unsigned int, int, int))dlsym(marsio_so_handle, "marsio_buff_malloc_global");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_malloc_global) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_malloc_global", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_free =
|
||||
(void (*)(struct mr_instance *, marsio_buff_t **,unsigned int, int, int))dlsym(marsio_so_handle, "marsio_buff_free");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_free) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_free", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_append =
|
||||
(char * (*)(marsio_buff_t *, uint16_t))dlsym(marsio_so_handle, "marsio_buff_append");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_append) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_append", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_ctrlzone =
|
||||
(void * (*)(marsio_buff_t *, uint8_t))dlsym(marsio_so_handle, "marsio_buff_ctrlzone");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_ctrlzone) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_ctrlzone", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_ctrlzone_set =
|
||||
(void (*)(marsio_buff_t *, uint8_t, void *, uint8_t))dlsym(marsio_so_handle, "marsio_buff_ctrlzone_set");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_ctrlzone_set) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_ctrlzone_set", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_set_rehash_index =
|
||||
(void (*)(marsio_buff_t *, uint32_t))dlsym(marsio_so_handle, "marsio_buff_set_rehash_index");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_set_rehash_index) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_set_rehash_index", g_engine_instance.config.lib.libmarsio_path);
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_set_rehash_index = fake_marsio_buff_set_rehash_index;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_mtod =
|
||||
(char * (*)(marsio_buff_t *))dlsym(marsio_so_handle, "marsio_buff_mtod");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_mtod) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_mtod", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_datalen =
|
||||
(uint32_t (*)(marsio_buff_t *))dlsym(marsio_so_handle, "marsio_buff_datalen");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_datalen) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_datalen", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_buflen =
|
||||
(uint32_t (*)(marsio_buff_t *))dlsym(marsio_so_handle, "marsio_buff_buflen");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_buflen) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_buflen", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_clone_with_options =
|
||||
(marsio_buff_t * (*)(struct mr_instance *, marsio_buff_t *, int, int, uint16_t))dlsym(marsio_so_handle, "marsio_buff_clone_with_options");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_clone_with_options) {
|
||||
printf("\033[1;31;40m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_clone_with_options", g_engine_instance.config.lib.libmarsio_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* note: if not include marsio_send_burst_flush(), no errors. include just for backward compatibility */
|
||||
shared_marsio_dll_func_entries.ptr_marsio_send_burst_flush =
|
||||
(void (*)(struct mr_sendpath *, queue_id_t))dlsym(marsio_so_handle, "marsio_send_burst_flush");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_send_burst_flush) {
|
||||
printf("\033[33m[Warning]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_send_burst_flush", g_engine_instance.config.lib.libmarsio_path);
|
||||
}
|
||||
|
||||
/* for vlan flipping */
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_get_metadata =
|
||||
(int (*)(marsio_buff_t *, enum mr_buff_metadata_type, void *, unsigned int))dlsym(marsio_so_handle, "marsio_buff_get_metadata");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_get_metadata) {
|
||||
printf("\033[33m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_get_metadata", g_engine_instance.config.lib.libmarsio_path);
|
||||
/* in order to be forward compatible with the previous version of mrzcpd, no error is returned here. vlan_flipping will become invalid */
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_set_metadata =
|
||||
(int (*)(marsio_buff_t *, enum mr_buff_metadata_type, void *, unsigned int))dlsym(marsio_so_handle, "marsio_buff_set_metadata");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_get_metadata) {
|
||||
printf("\033[33m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_set_metadata", g_engine_instance.config.lib.libmarsio_path);
|
||||
/* in order to be forward compatible with the previous version of mrzcpd, no error is returned here. vlan_flipping will become invalid */
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_buff_unset_metadata =
|
||||
(int (*)(marsio_buff_t *, enum mr_buff_metadata_type))dlsym(marsio_so_handle, "marsio_buff_unset_metadata");
|
||||
if (nullptr == shared_marsio_dll_func_entries.ptr_marsio_buff_unset_metadata) {
|
||||
printf("\033[33m[Error]dlsym function '%s' from '%s' failed!\033[0m\n", "marsio_buff_unset_metadata", g_engine_instance.config.lib.libmarsio_path);
|
||||
/* in order to be forward compatible with the previous version of mrzcpd, no error is returned here. vlan_flipping will become invalid */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_marsio_device_open(const void *init_data)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_marsio_device_close(const void *init_data)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int marsio_instance_init(struct packet_io_instance *pinst, int worker_thread_num)
|
||||
{
|
||||
int ret = -1;
|
||||
ret = pio_get_marsio_dll_function_entries();
|
||||
if (ret < 0) {
|
||||
printf("\033[1;31;40m[Error]dlopen marsio.so symbol failed!\033[0m\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pinst->entity.ppio_marsio_inst->ptr_mr_inst = shared_marsio_dll_func_entries.ptr_marsio_create();
|
||||
if (nullptr == pinst->entity.ppio_marsio_inst->ptr_mr_inst) {
|
||||
fprintf(stderr,"%s\n","marsio_create error!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* TODO: MARSIO_OPT_THREAD_NUM */
|
||||
shared_marsio_dll_func_entries.ptr_marsio_option_set(pinst->entity.ppio_marsio_inst->ptr_mr_inst,
|
||||
MARSIO_OPT_THREAD_NUM,
|
||||
&worker_thread_num, sizeof(int));
|
||||
|
||||
/* TODO: MARSIO_OPT_THREAD_MASK_IN_CPUSET */
|
||||
|
||||
/* marsio_init */
|
||||
ret = shared_marsio_dll_func_entries.ptr_marsio_init(pinst->entity.ppio_marsio_inst->ptr_mr_inst, pinst->inst_name);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr,"%s\n","marsio_init error!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief create packet_io marsio instance
|
||||
*
|
||||
* @param: pinst(in/out)
|
||||
*/
|
||||
int pio_marsio_instance_create(struct packet_io_instance *pinst, int worker_thread_num)
|
||||
{
|
||||
/* instance init */
|
||||
int ret = marsio_instance_init(pinst, worker_thread_num);
|
||||
if (ret < 0) {
|
||||
log_error(ST_ERR_PIO_INSTANCE, "marsio instance init failed.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pio_marsio_instance_destroy(void)
|
||||
{
|
||||
|
||||
}
|
||||
127
src/packet_io/marsio_mode/pio_marsio.h
Normal file
127
src/packet_io/marsio_mode/pio_marsio.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: marsio.h
|
||||
* Description: marsio runmode api
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "marsio.h"
|
||||
|
||||
/*
|
||||
dll is short for dynamic link lib
|
||||
the following entries is supported by marsio system
|
||||
*/
|
||||
struct marsio_dll_function_entries {
|
||||
/* marsio_create() */
|
||||
struct mr_instance *(*ptr_marsio_create)(void);
|
||||
|
||||
/* marsio_init() */
|
||||
int (*ptr_marsio_init)(struct mr_instance *instance, const char *appsym);
|
||||
|
||||
/* marsio_destroy() */
|
||||
int (*ptr_marsio_destroy)(struct mr_instance *instance);
|
||||
|
||||
/* marsio_open_device() */
|
||||
struct mr_vdev *(*ptr_marsio_open_device)(struct mr_instance *instance, const char *devsym,
|
||||
unsigned int nr_rxstream, unsigned int nr_txstream);
|
||||
|
||||
/* marsio_close_device() */
|
||||
void (*ptr_marsio_close_device)(struct mr_vdev *pdev);
|
||||
|
||||
/* marsio_option_set() */
|
||||
int (*ptr_marsio_option_set)(struct mr_instance *instance, marsio_opt_type_t opt_type, void *opt, size_t sz_opt);
|
||||
|
||||
/* marsio_sendpath_create_by_vdev() */
|
||||
struct mr_sendpath *(*ptr_marsio_sendpath_create_by_vdev)(struct mr_vdev *pdev);
|
||||
|
||||
/* marsio_sendpath_destroy() */
|
||||
void (*ptr_marsio_sendpath_destroy)(struct mr_sendpath *sendpath);
|
||||
|
||||
/* marsio_thread_init() */
|
||||
int (*ptr_marsio_thread_init)(struct mr_instance *instance);
|
||||
|
||||
/* marsio_recv_burst() */
|
||||
int (*ptr_marsio_recv_burst)(struct mr_vdev *pdev, queue_id_t qid, marsio_buff_t *mbufs[], int nr_mbufs);
|
||||
|
||||
/* marsio_send_burst() */
|
||||
int (*ptr_marsio_send_burst)(struct mr_sendpath *sendpath, queue_id_t qid, marsio_buff_t *mbufs[], int nr_mbufs);
|
||||
|
||||
/* marsio_send_burst_with_options() */
|
||||
int (*ptr_marsio_send_burst_with_options)(struct mr_sendpath *sendpath, queue_id_t sid,
|
||||
marsio_buff_t *mbufs[], int nr_mbufs, uint16_t options);
|
||||
|
||||
/* marsio_buff_malloc_global() */
|
||||
int (*ptr_marsio_buff_malloc_global)(struct mr_instance *instance, marsio_buff_t *marsio_buff[], unsigned int nr_mbufs,
|
||||
int socket_id, int thread_id);
|
||||
|
||||
/* marsio_buff_free() */
|
||||
void (*ptr_marsio_buff_free)(struct mr_instance *, marsio_buff_t **,unsigned int, int socket_id, int thread_id);
|
||||
|
||||
/* marsio_buff_append() */
|
||||
char *(*ptr_marsio_buff_append)(marsio_buff_t *m, uint16_t len);
|
||||
|
||||
/* marsio_buff_ctrlzone() */
|
||||
void *(*ptr_marsio_buff_ctrlzone)(marsio_buff_t *m, uint8_t id);
|
||||
|
||||
/* marsio_buff_ctrlzone_set() */
|
||||
void (*ptr_marsio_buff_ctrlzone_set)(marsio_buff_t *m, uint8_t id, void* ptr_data, uint8_t size);
|
||||
|
||||
/* marsio_buff_set_rehash_index() */
|
||||
void (*ptr_marsio_buff_set_rehash_index)(marsio_buff_t *m, uint32_t hash);
|
||||
|
||||
/* marsio_buff_mtod() */
|
||||
char *(*ptr_marsio_buff_mtod)(marsio_buff_t *m);
|
||||
|
||||
/* marsio_buff_datalen() */
|
||||
uint32_t (*ptr_marsio_buff_datalen)(marsio_buff_t *m);
|
||||
|
||||
/* marsio_buff_buflen() */
|
||||
uint32_t (*ptr_marsio_buff_buflen)(marsio_buff_t *m);
|
||||
|
||||
/* marsio_buff_clone_with_options() */
|
||||
marsio_buff_t *(*ptr_marsio_buff_clone_with_options)(struct mr_instance *instance, marsio_buff_t *md, int socket_id,
|
||||
int thread_id, uint16_t options);
|
||||
|
||||
/* marsio_send_burst_flush() */
|
||||
void (*ptr_marsio_send_burst_flush)(struct mr_sendpath *sendpath, queue_id_t sid);
|
||||
|
||||
/* marsio_buff_get_metadata() */
|
||||
int (*ptr_marsio_buff_get_metadata)(marsio_buff_t *m, enum mr_buff_metadata_type type, void *data, unsigned int sz_data);
|
||||
|
||||
/* marsio_buff_set_metadata() */
|
||||
int (*ptr_marsio_buff_set_metadata)(marsio_buff_t *m, enum mr_buff_metadata_type type, void *data, unsigned int sz_data);
|
||||
|
||||
/* marsio_bufrf_unset_metadata() */
|
||||
int (*ptr_marsio_buff_unset_metadata)(marsio_buff_t *m, enum mr_buff_metadata_type type);
|
||||
};
|
||||
|
||||
struct pio_marsio_instance {
|
||||
struct mr_instance *ptr_mr_inst;
|
||||
};
|
||||
|
||||
struct pio_marsio_device {
|
||||
struct mr_vdev *vdev;
|
||||
};
|
||||
|
||||
struct pio_marsio_device_context {
|
||||
|
||||
};
|
||||
|
||||
int pio_marsio_device_open(const void *init_data);
|
||||
|
||||
int pio_marsio_device_close(const void *init_data);
|
||||
|
||||
int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p);
|
||||
|
||||
int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p);
|
||||
|
||||
int pio_marsio_instance_create(struct packet_io_instance *pinst, int worker_thread_num);
|
||||
|
||||
void pio_marsio_instance_destroy(void);
|
||||
@@ -14,63 +14,67 @@
|
||||
#include "../../sdk/include/logger.h"
|
||||
#include "../../sdk/include/utils.h"
|
||||
#include "../../sdk/include/util_errors.h"
|
||||
#include "./pcap_live_mode/pcap_live.h"
|
||||
#include "./pcap_file_mode/pcap_file.h"
|
||||
#include "./marsio_mode/marsio.h"
|
||||
|
||||
struct pio_device_operations device_ops_array[PACKET_IO_RUN_MODE_MAX] =
|
||||
struct pio_device_operations pio_device_ops_array[PACKET_IO_RUN_MODE_MAX] =
|
||||
{
|
||||
{
|
||||
.init = pcap_file_device_init,
|
||||
.fini = pcap_file_device_fini,
|
||||
.recv = pcap_file_device_receive,
|
||||
.send = pcap_file_device_send,
|
||||
.open = pio_pcap_file_device_open,
|
||||
.close = pio_pcap_file_device_close,
|
||||
.recv = pio_pcap_file_device_receive,
|
||||
.send = pio_pcap_file_device_send,
|
||||
},
|
||||
|
||||
{
|
||||
.init = pcap_live_device_init,
|
||||
.fini = pcap_live_device_fini,
|
||||
.recv = pcap_live_device_receive,
|
||||
.send = pcap_live_device_send,
|
||||
.open = pio_pcap_live_device_open,
|
||||
.close = pio_pcap_live_device_close,
|
||||
.recv = pio_pcap_live_device_receive,
|
||||
.send = pio_pcap_live_device_send,
|
||||
},
|
||||
|
||||
{
|
||||
.init = marsio_device_init,
|
||||
.fini = marsio_device_fini,
|
||||
.recv = marsio_device_receive,
|
||||
.send = marsio_device_send,
|
||||
.open = pio_marsio_device_open,
|
||||
.close = pio_marsio_device_close,
|
||||
.recv = pio_marsio_device_receive,
|
||||
.send = pio_marsio_device_send,
|
||||
}
|
||||
};
|
||||
|
||||
struct pio_instance_operations instance_ops_array[PACKET_IO_RUN_MODE_MAX] =
|
||||
struct pio_instance_operations pio_instance_ops_array[PACKET_IO_RUN_MODE_MAX] =
|
||||
{
|
||||
|
||||
{
|
||||
.create = pcap_file_instance_create,
|
||||
.destroy = pcap_file_instance_destroy,
|
||||
.create = pio_pcap_file_instance_create,
|
||||
.destroy = pio_pcap_file_instance_destroy,
|
||||
},
|
||||
|
||||
{
|
||||
.create = pcap_live_instance_create,
|
||||
.destroy = pcap_live_instance_destroy,
|
||||
.create = pio_pcap_live_instance_create,
|
||||
.destroy = pio_pcap_live_instance_destroy,
|
||||
},
|
||||
|
||||
{
|
||||
.create = marsio_instance_create,
|
||||
.destroy = marsio_instance_destroy,
|
||||
.create = pio_marsio_instance_create,
|
||||
.destroy = pio_marsio_instance_destroy,
|
||||
}
|
||||
};
|
||||
|
||||
struct packet_io_instance *packet_io_instance_init(struct packet_io_config *ppio_config) {
|
||||
struct packet_io_instance *packet_io_instance_create(const char *instance_name, enum packet_io_run_mode mode, int worker_thread_num) {
|
||||
struct packet_io_instance *pio_instance = CALLOC(struct packet_io_instance, 1);
|
||||
if (nullptr == pio_instance) {
|
||||
log_error(ST_ERR_MEM_ALLOC, "packet_io_instance alloc failed.");
|
||||
log_error(ST_ERR_MEM_ALLOC, "packet_io instance alloc failed.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
memset(pio_instance, 0, sizeof(*pio_instance));
|
||||
pio_instance->mode = ppio_config->mode;
|
||||
pio_instance->inst_ops = &instance_ops_array[ppio_config->mode];
|
||||
strncpy(pio_instance->inst_name, instance_name, strlen(instance_name));
|
||||
pio_instance->mode = mode;
|
||||
pio_instance->inst_ops = &pio_instance_ops_array[mode];
|
||||
|
||||
int ret = pio_instance->inst_ops->create(pio_instance, worker_thread_num);
|
||||
if (ret < 0) {
|
||||
log_error(ST_ERR_PIO_INSTANCE, "packet_io instance create failed.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return pio_instance;
|
||||
}
|
||||
@@ -83,11 +87,11 @@ void packet_io_instance_destroy(struct packet_io_instance *ppio_inst) {
|
||||
}
|
||||
}
|
||||
|
||||
struct packet_io_device *packet_io_device_init(struct packet_io_instance *ppio_inst, void *dev_ctx, uint32_t nr_rxqueue, uint32_t nr_txqueue)
|
||||
struct packet_io_device *packet_io_open_device(struct packet_io_instance *ppio_inst, void *dev_ctx, uint32_t nr_rxqueue, uint32_t nr_txqueue)
|
||||
{
|
||||
struct packet_io_device *ppio_dev = CALLOC(struct packet_io_device, 1);
|
||||
if (nullptr == ppio_dev) {
|
||||
log_error(ST_ERR_MEM_ALLOC, "packet_io_device alloc failed.");
|
||||
log_error(ST_ERR_MEM_ALLOC, "packet_io device alloc failed.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -95,11 +99,11 @@ struct packet_io_device *packet_io_device_init(struct packet_io_instance *ppio_i
|
||||
|
||||
ppio_dev->dev_ctx = dev_ctx;
|
||||
ppio_dev->ppio_inst = ppio_inst;
|
||||
ppio_dev->dev_ops = &device_ops_array[ppio_inst->mode];
|
||||
ppio_dev->dev_ops = &pio_device_ops_array[ppio_inst->mode];
|
||||
|
||||
int ret = ppio_dev->dev_ops->init(dev_ctx);
|
||||
int ret = ppio_dev->dev_ops->open(dev_ctx);
|
||||
if (ret < 0) {
|
||||
log_error(ST_ERR_PIO_DEVICE, "packet_io_device init failed.");
|
||||
log_error(ST_ERR_PIO_DEVICE, "packet_io device open failed.");
|
||||
FREE(ppio_dev);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -107,22 +111,24 @@ struct packet_io_device *packet_io_device_init(struct packet_io_instance *ppio_i
|
||||
return ppio_dev;
|
||||
}
|
||||
|
||||
struct packet_io_device *packet_io_open_device(struct packet_io_instance *instance,
|
||||
void *dev_ctx, uint32_t nr_rxqueue, uint32_t nr_txqueue) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void packet_io_close_device(struct packet_io_device *ppio_dev)
|
||||
{
|
||||
ppio_dev->dev_ops->fini(nullptr);
|
||||
if (nullptr == ppio_dev || nullptr == ppio_dev->dev_ops) {
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = ppio_dev->dev_ops->close(nullptr);
|
||||
if (ret < 0) {
|
||||
log_error(ST_ERR_PIO_DEVICE, "packet_io device close failed.");
|
||||
}
|
||||
}
|
||||
|
||||
int packet_io_rx(struct packet_io_device *ppio_dev, uint32_t rx_queue_id, struct packet *p[], int nr_p)
|
||||
int packet_io_rx(struct packet_io_device *ppio_dev, uint32_t rxq_id, struct packet *p[], int nr_p)
|
||||
{
|
||||
return ppio_dev->dev_ops->recv(nullptr);
|
||||
return ppio_dev->dev_ops->recv(ppio_dev, rxq_id, p, nr_p);
|
||||
}
|
||||
|
||||
int packet_io_tx(struct packet_io_device *ppio_dev, uint32_t rx_queue_id, struct packet *p[], int nr_p)
|
||||
int packet_io_tx(struct packet_io_device *ppio_dev, uint32_t txq_id, struct packet *p[], int nr_p)
|
||||
{
|
||||
return ppio_dev->dev_ops->send(nullptr);
|
||||
return ppio_dev->dev_ops->send(ppio_dev, txq_id, p, nr_p);
|
||||
}
|
||||
@@ -11,40 +11,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include "./marsio_mode/marsio.h"
|
||||
#include "./pcap_file_mode/pcap_file.h"
|
||||
#include "./pcap_live_mode/pcap_live.h"
|
||||
#include "../common/global_var.h"
|
||||
#include "./pcap_live_mode/pio_pcap_live.h"
|
||||
#include "./pcap_file_mode/pio_pcap_file.h"
|
||||
#include "./marsio_mode/pio_marsio.h"
|
||||
|
||||
#define DEV_MAX_CNT 16
|
||||
#define NAME_MAX_LEN 64
|
||||
|
||||
enum packet_io_run_mode {
|
||||
PACKET_IO_RUN_MODE_PCAP_FILE,
|
||||
PACKET_IO_RUN_MODE_PCAP_LIVE,
|
||||
PACKET_IO_RUN_MODE_MARSIO,
|
||||
PACKET_IO_RUN_MODE_MAX,
|
||||
};
|
||||
|
||||
struct packet_io_config {
|
||||
enum packet_io_run_mode mode;
|
||||
char dev_name[DEV_MAX_CNT][NAME_MAX_LEN];
|
||||
uint32_t dev_cnt;
|
||||
};
|
||||
|
||||
struct pio_instance_operations {
|
||||
int (*create)(struct packet_io_instance *);
|
||||
int (*create)(struct packet_io_instance *instance, int worker_thread_num);
|
||||
|
||||
void (*destroy)(void);
|
||||
};
|
||||
|
||||
struct packet_io_instance {
|
||||
/* packet io run mode of the instance */
|
||||
/* packet_io instance name */
|
||||
char inst_name[NAME_MAX];
|
||||
|
||||
/* packet_io run mode of the instance */
|
||||
enum packet_io_run_mode mode;
|
||||
|
||||
/* device handle set in this instance */
|
||||
struct packet_io_device **device_handle;
|
||||
|
||||
/* device count */
|
||||
uint32_t dev_cnt;
|
||||
|
||||
/* instance operations */
|
||||
@@ -52,30 +45,35 @@ struct packet_io_instance {
|
||||
|
||||
union
|
||||
{
|
||||
struct pcap_file_instance *ptr_pcap_file_inst;
|
||||
struct pcap_live_instance *ptr_pcap_live_inst;
|
||||
struct mr_instance *ptr_marsio_inst;
|
||||
struct pio_pcap_file_instance *ppio_pcap_file_inst;
|
||||
struct pio_pcap_live_instance *ppio_pcap_live_inst;
|
||||
struct pio_marsio_instance *ppio_marsio_inst;
|
||||
} entity;
|
||||
|
||||
};
|
||||
|
||||
struct pio_device_operations {
|
||||
int (*init)(const void *init_data);
|
||||
int (*open)(const void *init_data);
|
||||
|
||||
int (*fini)(const void *init_data);
|
||||
int (*close)(const void *init_data);
|
||||
|
||||
int (*recv)(void *data);
|
||||
int (*recv)(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int pkt_cnt);
|
||||
|
||||
int (*send)(void *data);
|
||||
int (*send)(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int pkt_cnt);
|
||||
};
|
||||
|
||||
struct packet_io_device {
|
||||
/* device name */
|
||||
const char *dev_name;
|
||||
char dev_name[NAME_MAX];
|
||||
|
||||
/* device operations */
|
||||
struct pio_device_operations *dev_ops;
|
||||
|
||||
union {
|
||||
struct pio_pcap_file_device *ppio_pcap_file_dev;
|
||||
struct pio_pcap_live_device *ppio_pcap_live_dev;
|
||||
struct pio_marsio_device *ppio_marsio_dev;
|
||||
} entity;
|
||||
|
||||
/* packet io device context */
|
||||
void *dev_ctx;
|
||||
|
||||
@@ -83,7 +81,8 @@ struct packet_io_device {
|
||||
struct packet_io_instance *ppio_inst;
|
||||
};
|
||||
|
||||
struct packet_io_instance *packet_io_instance_init(struct packet_io_config *ppio_config);
|
||||
struct packet_io_instance *packet_io_instance_create(const char *instance_name, enum packet_io_run_mode mode, int worker_thread_num);
|
||||
void packet_io_instance_destroy(struct packet_io_instance *ppio_inst);
|
||||
|
||||
struct packet_io_device *packet_io_open_device(struct packet_io_instance *instance, void *dev_ctx, uint32_t nr_rxqueue, uint32_t nr_txqueue);
|
||||
void packet_io_close_device(struct packet_io_device *dev);
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: pcap_file.h
|
||||
* Description: pcap file runmode api
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct pcap_file_instance;
|
||||
|
||||
struct pio_pcap_file_device_context {
|
||||
|
||||
};
|
||||
|
||||
int pcap_file_device_init(const void *init_data);
|
||||
|
||||
int pcap_file_device_fini(const void *init_data);
|
||||
|
||||
int pcap_file_device_receive(void *data);
|
||||
|
||||
int pcap_file_device_send(void *data);
|
||||
|
||||
int pcap_file_instance_create(struct packet_io_instance *pinst);
|
||||
|
||||
void pcap_file_instance_destroy(void);
|
||||
@@ -10,34 +10,34 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "pcap_file.h"
|
||||
#include "pio_pcap_file.h"
|
||||
|
||||
int pcap_file_device_init(const void *init_data) {
|
||||
int pio_pcap_file_device_open(const void *init_data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_file_device_fini(const void *init_data) {
|
||||
int pio_pcap_file_device_close(const void *init_data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_file_device_receive(void *data) {
|
||||
int pio_pcap_file_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_file_device_send(void *data) {
|
||||
int pio_pcap_file_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pcap_file_instance_create(struct packet_io_instance *pinst) {
|
||||
int pio_pcap_file_instance_create(struct packet_io_instance *pinst, int worker_thread_num) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pcap_file_instance_destroy(void) {
|
||||
void pio_pcap_file_instance_destroy(void) {
|
||||
|
||||
}
|
||||
39
src/packet_io/pcap_file_mode/pio_pcap_file.h
Normal file
39
src/packet_io/pcap_file_mode/pio_pcap_file.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: pcap_file.h
|
||||
* Description: pcap file runmode api
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <pcap/pcap.h>
|
||||
|
||||
struct pio_pcap_file_instance {
|
||||
|
||||
};
|
||||
|
||||
struct pio_pcap_file_device {
|
||||
pcap_t *pcap_up_handle;
|
||||
pcap_t *pcap_down_handle;
|
||||
};
|
||||
|
||||
struct pio_pcap_file_device_context {
|
||||
|
||||
};
|
||||
|
||||
int pio_pcap_file_device_open(const void *init_data);
|
||||
|
||||
int pio_pcap_file_device_close(const void *init_data);
|
||||
|
||||
int pio_pcap_file_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p);
|
||||
|
||||
int pio_pcap_file_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p);
|
||||
|
||||
int pio_pcap_file_instance_create(struct packet_io_instance *pinst, int worker_thread_num);
|
||||
|
||||
void pio_pcap_file_instance_destroy(void);
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: pcap_live.cpp
|
||||
* Description:
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#include "pcap_live.h"
|
||||
|
||||
int pcap_live_device_init(const void *init_data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_live_device_fini(const void *init_data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_live_device_receive(void *data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_live_device_send(void *data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcap_live_instance_create(struct packet_io_instance *pinst) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pcap_live_instance_destroy(void) {
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: pcap_live.h
|
||||
* Description: pcap live runmode api
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct pcap_live_instance;
|
||||
|
||||
struct pio_pcap_live_device_context {
|
||||
|
||||
};
|
||||
|
||||
int pcap_live_device_init(const void *init_data);
|
||||
|
||||
int pcap_live_device_fini(const void *init_data);
|
||||
|
||||
int pcap_live_device_receive(void *data);
|
||||
|
||||
int pcap_live_device_send(void *data);
|
||||
|
||||
int pcap_live_instance_create(struct packet_io_instance *pinst);
|
||||
|
||||
void pcap_live_instance_destroy(void);
|
||||
40
src/packet_io/pcap_live_mode/pio_pcap_live.cpp
Normal file
40
src/packet_io/pcap_live_mode/pio_pcap_live.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: pcap_live.cpp
|
||||
* Description:
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#include "pio_pcap_live.h"
|
||||
|
||||
int pio_pcap_live_device_open(const void *init_data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_pcap_live_device_close(const void *init_data) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_pcap_live_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_pcap_live_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_pcap_live_instance_create(struct packet_io_instance *pinst, int worker_thread_num) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pio_pcap_live_instance_destroy(void) {
|
||||
|
||||
}
|
||||
37
src/packet_io/pcap_live_mode/pio_pcap_live.h
Normal file
37
src/packet_io/pcap_live_mode/pio_pcap_live.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
**********************************************************************************************
|
||||
* File: pcap_live.h
|
||||
* Description: pcap live runmode api
|
||||
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
||||
* Date: 2022-07-15
|
||||
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
||||
***********************************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct pio_pcap_live_instance {
|
||||
|
||||
};
|
||||
|
||||
struct pio_pcap_live_device {
|
||||
|
||||
};
|
||||
|
||||
struct pio_pcap_live_device_context {
|
||||
|
||||
};
|
||||
|
||||
int pio_pcap_live_device_open(const void *init_data);
|
||||
|
||||
int pio_pcap_live_device_close(const void *init_data);
|
||||
|
||||
int pio_pcap_live_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p);
|
||||
|
||||
int pio_pcap_live_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p);
|
||||
|
||||
int pio_pcap_live_instance_create(struct packet_io_instance *pinst, int worker_thread_num);
|
||||
|
||||
void pio_pcap_live_instance_destroy(void);
|
||||
@@ -6,6 +6,7 @@ target_link_libraries(
|
||||
gtest_packet_io
|
||||
gtest_main
|
||||
packet_io
|
||||
dl
|
||||
)
|
||||
|
||||
include(GoogleTest)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "packet_io.h"
|
||||
#include "../packet_io.h"
|
||||
|
||||
TEST(PACKET_IO_Test, packet_io_open_device) {
|
||||
struct packet_io_config ppio_config;
|
||||
struct packet_io_instance *ppio_inst = packet_io_instance_init(&ppio_config);
|
||||
struct packet_io_instance *ppio_inst = packet_io_instance_create("stellar",PACKET_IO_RUN_MODE_PCAP_FILE, 2);
|
||||
EXPECT_EQ(packet_io_open_device(ppio_inst, nullptr, 1, 1), nullptr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user