[PACKET_IO] finish marsio mode
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include "../../sdk/include/utils.h"
|
||||
#include "../../sdk/include/util_errors.h"
|
||||
|
||||
#define MARSIO_BURST_PKT_MAX (256)
|
||||
|
||||
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)
|
||||
@@ -257,32 +259,50 @@ static int pio_get_marsio_dll_function_entries(void)
|
||||
|
||||
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 = \
|
||||
struct mr_instance *mr_inst_handle = pdev->ppio_inst->entity.marsio_inst->mr_inst_handle;
|
||||
pdev->entity.marsio_dev->mr_dev_handle = \
|
||||
shared_marsio_dll_func_entries.ptr_marsio_open_device(mr_inst_handle, dev_name, nr_rxq, nr_txq);
|
||||
if (nullptr == pdev->entity.marsio_dev->mr_dev_handle) {
|
||||
fprintf(stderr,"marsio_open_device:%s error\n", dev_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_marsio_device_close(const void *init_data)
|
||||
int pio_marsio_device_close(const struct packet_io_device *pdev)
|
||||
{
|
||||
if (nullptr == pdev) {
|
||||
log_error(ST_ERR_PIO_DEVICE, "invalid pdev pointer so close marsio device failed!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_close_device(pdev->entity.marsio_dev->mr_dev_handle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p)
|
||||
{
|
||||
|
||||
return 0;
|
||||
return shared_marsio_dll_func_entries.ptr_marsio_recv_burst(pdev->entity.marsio_dev->mr_dev_handle,
|
||||
rxq_id, (marsio_buff_t **)p, nr_p);
|
||||
}
|
||||
|
||||
int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p)
|
||||
{
|
||||
struct mr_sendpath *sendpath = \
|
||||
shared_marsio_dll_func_entries.ptr_marsio_sendpath_create_by_vdev(pdev->entity.marsio_dev->mr_dev_handle);
|
||||
if (nullptr == sendpath) {
|
||||
log_error(ST_ERR_PIO_DEVICE, "device:%s marsio_sendpath_create_by_vdev failed!", pdev->dev_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
shared_marsio_dll_func_entries.ptr_marsio_send_burst(sendpath, txq_id, (marsio_buff_t **)p, nr_p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int marsio_instance_init(struct packet_io_instance *pinst, int worker_thread_num)
|
||||
static int marsio_instance_init(struct packet_io_instance *pinst, int wrk_thread_num)
|
||||
{
|
||||
int ret = -1;
|
||||
ret = pio_get_marsio_dll_function_entries();
|
||||
@@ -291,21 +311,25 @@ static int marsio_instance_init(struct packet_io_instance *pinst, int worker_thr
|
||||
return -1;
|
||||
}
|
||||
|
||||
pinst->entity.marsio_inst->mr_inst = shared_marsio_dll_func_entries.ptr_marsio_create();
|
||||
if (nullptr == pinst->entity.marsio_inst->mr_inst) {
|
||||
pinst->entity.marsio_inst->mr_inst_handle = shared_marsio_dll_func_entries.ptr_marsio_create();
|
||||
if (nullptr == pinst->entity.marsio_inst->mr_inst_handle) {
|
||||
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.marsio_inst->mr_inst,
|
||||
MARSIO_OPT_THREAD_NUM,
|
||||
&worker_thread_num, sizeof(int));
|
||||
ret = shared_marsio_dll_func_entries.ptr_marsio_option_set(pinst->entity.marsio_inst->mr_inst_handle,
|
||||
MARSIO_OPT_THREAD_NUM,
|
||||
&wrk_thread_num, sizeof(int));
|
||||
if (ret < 0) {
|
||||
fprintf(stderr,"%s\n","marsio_option_set MARSIO_OPT_THREAD_NUM error!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* TODO: MARSIO_OPT_THREAD_MASK_IN_CPUSET */
|
||||
|
||||
/* marsio_init */
|
||||
ret = shared_marsio_dll_func_entries.ptr_marsio_init(pinst->entity.marsio_inst->mr_inst, pinst->inst_name);
|
||||
ret = shared_marsio_dll_func_entries.ptr_marsio_init(pinst->entity.marsio_inst->mr_inst_handle, pinst->inst_name);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr,"%s\n","marsio_init error!\n");
|
||||
return -1;
|
||||
@@ -319,10 +343,10 @@ static int marsio_instance_init(struct packet_io_instance *pinst, int worker_thr
|
||||
*
|
||||
* @param: pinst(in/out)
|
||||
*/
|
||||
int pio_marsio_instance_create(struct packet_io_instance *pinst, int worker_thread_num)
|
||||
int pio_marsio_instance_create(struct packet_io_instance *pinst, int wrk_thread_num)
|
||||
{
|
||||
/* instance init */
|
||||
int ret = marsio_instance_init(pinst, worker_thread_num);
|
||||
int ret = marsio_instance_init(pinst, wrk_thread_num);
|
||||
if (ret < 0) {
|
||||
log_error(ST_ERR_PIO_INSTANCE, "marsio instance init failed.");
|
||||
return -1;
|
||||
@@ -334,4 +358,4 @@ int pio_marsio_instance_create(struct packet_io_instance *pinst, int worker_thre
|
||||
void pio_marsio_instance_destroy(void)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user