[PAKCET_IO] framework intermediate state <the second time>

This commit is contained in:
liuwentan
2022-07-28 20:30:48 +08:00
parent 7ae4ca2e2a
commit 536bf31be1
12 changed files with 168 additions and 82 deletions

View File

@@ -15,6 +15,7 @@
#include "../../common/global_var.h"
#include "../../common/common.h"
#include "../../sdk/include/logger.h"
#include "../../sdk/include/utils.h"
#include "../../sdk/include/util_errors.h"
static struct marsio_dll_function_entries shared_marsio_dll_func_entries;
@@ -36,154 +37,176 @@ static int pio_get_marsio_dll_function_entries(void)
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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;
}
@@ -191,37 +214,53 @@ static int pio_get_marsio_dll_function_entries(void)
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);
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 */
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 */
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 */
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)
int pio_marsio_device_open(struct packet_io_device *pdev, const char *dev_name, uint32_t nr_rxq, uint32_t nr_txq)
{
struct mr_instance *mr_inst_handle = pdev->ppio_inst->entity.marsio_inst->mr_inst;
struct mr_vdev *mr_dev_handle = \
shared_marsio_dll_func_entries.ptr_marsio_open_device(mr_inst_handle, dev_name, nr_rxq, nr_txq);
return 0;
}
@@ -252,21 +291,21 @@ static int marsio_instance_init(struct packet_io_instance *pinst, int worker_thr
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) {
pinst->entity.marsio_inst->mr_inst = shared_marsio_dll_func_entries.ptr_marsio_create();
if (nullptr == pinst->entity.marsio_inst->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,
shared_marsio_dll_func_entries.ptr_marsio_option_set(pinst->entity.marsio_inst->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);
ret = shared_marsio_dll_func_entries.ptr_marsio_init(pinst->entity.marsio_inst->mr_inst, pinst->inst_name);
if (ret < 0) {
fprintf(stderr,"%s\n","marsio_init error!\n");
return -1;