[PACKET_IO]unallocated memory related bugfix for marsio mode

This commit is contained in:
liuwentan
2022-08-01 15:19:57 +08:00
parent 523748e05a
commit 2cccb3ec04
11 changed files with 298 additions and 75 deletions

View File

@@ -16,6 +16,13 @@ typedef enum {
ST_ERR_MEM_ALLOC,
ST_ERR_RUN_MODE,
ST_ERR_PIO_INSTANCE,
ST_ERR_PIO_MARSIO_INSTANCE,
ST_ERR_PIO_PCAP_FILE_INSTANCE,
ST_ERR_PIO_PCAP_LIVE_INSTANCE,
ST_ERR_PIO_DEVICE,
ST_ERR_PIO_MARSIO_DEVICE,
ST_ERR_PIO_PCAP_FILE_DEVICE,
ST_ERR_PIO_PCAP_LIVE_DEVICE,
ST_ERR_FOPEN,
ST_ERR_MAX
} error_code_t;

View File

@@ -25,4 +25,8 @@
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#endif
#ifndef __unused
#define __unused __attribute__((__unused__))
#endif

View File

View File

@@ -9,6 +9,7 @@
*/
#include <dlfcn.h>
#include <string.h>
#include "pio_marsio.h"
#include "../packet_io.h"
@@ -266,43 +267,60 @@ 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_handle;
if (nullptr == pdev) {
log_error(ST_ERR_PIO_MARSIO_DEVICE, "invalid packet_io_device pointer.");
return -1;
}
if (nullptr == pdev->ppio_inst->entity.marsio_inst_ctx) {
log_error(ST_ERR_PIO_MARSIO_DEVICE, "invalid marsio_inst_ctx pointer.");
return -1;
}
pdev->entity.marsio_dev_ctx = CALLOC(struct pio_marsio_device_context, 1);
if (nullptr == pdev->entity.marsio_dev_ctx) {
log_error(ST_ERR_PIO_MARSIO_DEVICE, "alloc marsio_dev_ctx failed.");
return -1;
}
struct mr_instance *mr_inst_handle = pdev->ppio_inst->entity.marsio_inst_ctx->mr_inst_handle;
/* marsio_open_device() return marsio device handle*/
pdev->entity.marsio_dev->mr_dev_handle = \
pdev->entity.marsio_dev_ctx->mr_dev_handle = \
g_marsio_dll_func.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);
if (nullptr == pdev->entity.marsio_dev_ctx->mr_dev_handle) {
log_error(ST_ERR_PIO_MARSIO_DEVICE, "marsio_open_device:%s error\n", dev_name);
return -1;
}
/* ptr_marsio_sendpath_create_by_vdev() return marsio sendpath handle */
pdev->entity.marsio_dev->mr_sendpath_handle = \
g_marsio_dll_func.marsio_sendpath_create_by_vdev(pdev->entity.marsio_dev->mr_dev_handle);
if (nullptr == pdev->entity.marsio_dev->mr_sendpath_handle) {
log_error(ST_ERR_PIO_DEVICE, "device:%s marsio_sendpath_create_by_vdev failed!", pdev->dev_name);
pdev->entity.marsio_dev_ctx->mr_sendpath_handle = \
g_marsio_dll_func.marsio_sendpath_create_by_vdev(pdev->entity.marsio_dev_ctx->mr_dev_handle);
if (nullptr == pdev->entity.marsio_dev_ctx->mr_sendpath_handle) {
log_error(ST_ERR_PIO_MARSIO_DEVICE, "device:%s marsio_sendpath_create_by_vdev failed!", pdev->dev_name);
return -1;
}
return 0;
}
int pio_marsio_device_close(const struct packet_io_device *pdev)
int pio_marsio_device_close(struct packet_io_device *pdev)
{
if (nullptr == pdev) {
log_error(ST_ERR_PIO_DEVICE, "invalid pdev pointer so close marsio device failed!");
log_error(ST_ERR_PIO_MARSIO_DEVICE, "invalid pdev pointer so close marsio device failed!");
return -1;
}
g_marsio_dll_func.marsio_close_device(pdev->entity.marsio_dev->mr_dev_handle);
g_marsio_dll_func.marsio_sendpath_destroy(pdev->entity.marsio_dev->mr_sendpath_handle);
g_marsio_dll_func.marsio_close_device(pdev->entity.marsio_dev_ctx->mr_dev_handle);
g_marsio_dll_func.marsio_sendpath_destroy(pdev->entity.marsio_dev_ctx->mr_sendpath_handle);
FREE(pdev->entity.marsio_dev_ctx);
return 0;
}
int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts)
{
struct mr_vdev *mr_dev_handle = pdev->entity.marsio_dev->mr_dev_handle;
struct mr_vdev *mr_dev_handle = pdev->entity.marsio_dev_ctx->mr_dev_handle;
marsio_buff_t *rx_buff[MARSIO_BURST_PKT_MAX];
int recv_res = g_marsio_dll_func.marsio_recv_burst(mr_dev_handle, rxq_id, rx_buff, nr_pkts);
@@ -318,13 +336,19 @@ int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, st
int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts)
{
struct mr_sendpath *sendpath_handle = pdev->entity.marsio_dev->mr_sendpath_handle;
return g_marsio_dll_func.marsio_send_burst(sendpath_handle, txq_id, (marsio_buff_t **)pkts, nr_pkts);
struct mr_sendpath *sendpath_handle = pdev->entity.marsio_dev_ctx->mr_sendpath_handle;
int ret = g_marsio_dll_func.marsio_send_burst(sendpath_handle, txq_id, (marsio_buff_t **)pkts, nr_pkts);
if (ret < 0) {
g_marsio_dll_func.marsio_buff_free(pdev->ppio_inst->entity.marsio_inst_ctx->mr_inst_handle,
(marsio_buff_t **)pkts, nr_pkts, MARSIO_SOCKET_ID_ANY, txq_id);
}
return ret;
}
void pio_marsio_device_pkt_free(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts)
{
struct mr_instance *mr_inst = pdev->ppio_inst->entity.marsio_inst->mr_inst_handle;
struct mr_instance *mr_inst = pdev->ppio_inst->entity.marsio_inst_ctx->mr_inst_handle;
g_marsio_dll_func.marsio_buff_free(mr_inst, (marsio_buff_t **)pkts, nr_pkts, MARSIO_SOCKET_ID_ANY, qid);
}
@@ -337,14 +361,14 @@ static int marsio_instance_init(struct packet_io_instance *pinst, int wrk_thread
return -1;
}
pinst->entity.marsio_inst->mr_inst_handle = g_marsio_dll_func.marsio_create();
if (nullptr == pinst->entity.marsio_inst->mr_inst_handle) {
pinst->entity.marsio_inst_ctx->mr_inst_handle = g_marsio_dll_func.marsio_create();
if (nullptr == pinst->entity.marsio_inst_ctx->mr_inst_handle) {
fprintf(stderr,"%s\n","marsio_create error!\n");
return -1;
}
/* TODO: MARSIO_OPT_THREAD_NUM */
ret = g_marsio_dll_func.marsio_option_set(pinst->entity.marsio_inst->mr_inst_handle,
ret = g_marsio_dll_func.marsio_option_set(pinst->entity.marsio_inst_ctx->mr_inst_handle,
MARSIO_OPT_THREAD_NUM,
&wrk_thread_num, sizeof(int));
if (ret < 0) {
@@ -355,7 +379,7 @@ static int marsio_instance_init(struct packet_io_instance *pinst, int wrk_thread
/* TODO: MARSIO_OPT_THREAD_MASK_IN_CPUSET */
/* marsio_init */
ret = g_marsio_dll_func.marsio_init(pinst->entity.marsio_inst->mr_inst_handle, pinst->inst_name);
ret = g_marsio_dll_func.marsio_init(pinst->entity.marsio_inst_ctx->mr_inst_handle, pinst->inst_name);
if (ret < 0) {
fprintf(stderr,"%s\n","marsio_init error!\n");
return -1;
@@ -371,10 +395,16 @@ static int marsio_instance_init(struct packet_io_instance *pinst, int wrk_thread
*/
int pio_marsio_instance_create(struct packet_io_instance *pinst, int wrk_thread_num)
{
pinst->entity.marsio_inst_ctx = CALLOC(struct pio_marsio_instance_context, 1);
if (nullptr == pinst->entity.marsio_inst_ctx) {
log_error(ST_ERR_PIO_MARSIO_INSTANCE, "alloc marsio instance context failed.");
return -1;
}
/* instance init */
int ret = marsio_instance_init(pinst, wrk_thread_num);
if (ret < 0) {
log_error(ST_ERR_PIO_INSTANCE, "marsio instance init failed.");
log_error(ST_ERR_PIO_MARSIO_INSTANCE, "marsio instance init failed.");
return -1;
}
@@ -383,7 +413,8 @@ int pio_marsio_instance_create(struct packet_io_instance *pinst, int wrk_thread_
void pio_marsio_instance_destroy(struct packet_io_instance *pinst)
{
g_marsio_dll_func.marsio_destroy(pinst->entity.marsio_inst->mr_inst_handle);
g_marsio_dll_func.marsio_destroy(pinst->entity.marsio_inst_ctx->mr_inst_handle);
FREE(pinst->entity.marsio_inst_ctx);
for (uint32_t i = 0; i < pinst->dev_cnt; i++) {
pio_marsio_device_close(pinst->devices[i]);

View File

@@ -27,7 +27,7 @@ struct marsio_dll_function_entries {
int (*marsio_destroy)(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);
unsigned int nr_rxstream, unsigned int nr_txstream);
void (*marsio_close_device)(struct mr_vdev *pdev);
@@ -44,12 +44,13 @@ struct marsio_dll_function_entries {
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);
marsio_buff_t *mbufs[], int nr_mbufs, uint16_t options);
int (*marsio_buff_malloc_global)(struct mr_instance *instance, marsio_buff_t *marsio_buff[], unsigned int nr_mbufs,
int socket_id, int thread_id);
int socket_id, int thread_id);
void (*marsio_buff_free)(struct mr_instance *, marsio_buff_t **,unsigned int, 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);
char *(*marsio_buff_append)(marsio_buff_t *m, uint16_t len);
@@ -66,7 +67,7 @@ struct marsio_dll_function_entries {
uint32_t (*marsio_buff_buflen)(marsio_buff_t *m);
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 thread_id, uint16_t options);
void (*marsio_send_burst_flush)(struct mr_sendpath *sendpath, queue_id_t sid);
@@ -77,7 +78,7 @@ struct marsio_dll_function_entries {
int (*marsio_buff_unset_metadata)(marsio_buff_t *m, enum mr_buff_metadata_type type);
};
struct pio_marsio_instance {
struct pio_marsio_instance_context {
struct mr_instance *mr_inst_handle;
};
@@ -88,34 +89,58 @@ struct pio_marsio_instance {
* @mr_sendpath_handle: marsio sendpath handle
* if marsio device send packets, both mr_dev_handle and sendpath are required
**/
struct pio_marsio_device {
struct pio_marsio_device_context {
struct mr_vdev *mr_dev_handle;
struct mr_sendpath * mr_sendpath_handle;
};
struct pio_marsio_device_context {
};
/*
* @brief open marsio device
*
* @param pdev: the marsio device's pointer
* @param dev_name: device name, such as eth1, eth2 ...
* @param nr_rxq: number of the packet receiving queues for the device
* @param nr_txq: number of the packet sending queues for the device
* @param pdev: the marsio device's pointer
* @param dev_name: device name, such as eth1, eth2 ...
* @param nr_rxq: number of the packet receiving queues for the device
* @param nr_txq: number of the packet sending queues for the device
**/
int pio_marsio_device_open(struct packet_io_device *pdev, const char *dev_name, uint32_t nr_rxq, uint32_t nr_txq);
/*
* @brief close pcap_live device
**/
int pio_marsio_device_close(const struct packet_io_device *pdev);
int pio_marsio_device_close(struct packet_io_device *pdev);
/*
* @brief receive packets from device's single rx queue which specified by rxq_id
*
* @param pdev: the marsio device's pointer
* @param rxq_id: the marsio device's rx queue id
* @param pkts: store received packets' pointer array
* @param nr_pkts: number of packets expected to receive
*
* @retval number of packets actually received
*/
int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts);
/*
* @brief send packets by device's single tx queue which specified by txq_id
*
* @param pdev: the marsio device's pointer
* @param txq_id: the marsio device's tx queue id
* @param pkts: store prepare to send packets' pointer array
* @param nr_pkts: number of packets expected to send
*
* @retval if ret<0, means the sending fails; if ret==0 means the sending succeeds
*/
int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts);
/*
* @brief manually free packet's memory
*
* @param pdev: the marsio device's pointer
* @param qid:
* @param pkts:
* @param nr_pkts:
*/
void pio_marsio_device_pkt_free(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts);
int pio_marsio_instance_create(struct packet_io_instance *pinst, int wrk_thread_num);

View File

@@ -61,7 +61,7 @@ struct pio_instance_operations pio_instance_ops_array[PACKET_IO_RUN_MODE_MAX] =
};
struct packet_io_instance *
packet_io_instance_create(const char *instance_name, const enum packet_io_run_mode mode, const int wrk_thread_num)
packet_io_instance_create(const char *inst_name, const enum packet_io_run_mode mode, const int wrk_thread_num)
{
struct packet_io_instance *pio_instance = CALLOC(struct packet_io_instance, 1);
if (nullptr == pio_instance) {
@@ -69,8 +69,7 @@ packet_io_instance_create(const char *instance_name, const enum packet_io_run_mo
return nullptr;
}
memset(pio_instance, 0, sizeof(*pio_instance));
strncpy(pio_instance->inst_name, instance_name, strlen(instance_name));
strncpy(pio_instance->inst_name, inst_name, strlen(inst_name));
pio_instance->mode = mode;
pio_instance->inst_ops = &pio_instance_ops_array[mode];
@@ -101,10 +100,7 @@ packet_io_device_open(struct packet_io_instance *pinst, const char *dev_name, ui
return nullptr;
}
memset(ppio_dev, 0, sizeof(*ppio_dev));
strncpy(ppio_dev->dev_name, dev_name, strlen(dev_name));
// TODO: ppio_dev->dev_ctx = dev_ctx;
ppio_dev->ppio_inst = pinst;
ppio_dev->dev_ops = &pio_device_ops_array[pinst->mode];

View File

@@ -49,16 +49,16 @@ struct packet_io_instance {
union
{
struct pio_pcap_file_instance *pcap_file_inst;
struct pio_pcap_live_instance *pcap_live_inst;
struct pio_marsio_instance *marsio_inst;
struct pio_pcap_file_instance_context *pcap_file_inst_ctx;
struct pio_pcap_live_instance_context *pcap_live_inst_ctx;
struct pio_marsio_instance_context *marsio_inst_ctx;
} entity;
};
struct pio_device_operations {
int (*open)(struct packet_io_device *pinst, const char *dev_name, uint32_t nr_rxq, uint32_t nr_txq);
int (*close)(const struct packet_io_device *pdev);
int (*close)(struct packet_io_device *pdev);
int (*recv)(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts);
@@ -74,14 +74,12 @@ struct packet_io_device {
/* device operations */
struct pio_device_operations *dev_ops;
union {
struct pio_pcap_file_device *pcap_file_dev;
struct pio_pcap_live_device *pcap_live_dev;
struct pio_marsio_device *marsio_dev;
} entity;
/* packet io device context */
void *dev_ctx;
union {
struct pio_pcap_file_device_context *pcap_file_dev_ctx;
struct pio_pcap_live_device_context *pcap_live_dev_ctx;
struct pio_marsio_device_context *marsio_dev_ctx;
} entity;
/* packet_io instance which the device belongs to */
struct packet_io_instance *ppio_inst;
@@ -92,7 +90,8 @@ struct packet_io_device {
*
* @param instance_name: packet_io instance name
* @param mode: packet_io run mode
* @param wrk_thread_num: expected number of packet receiving threads, which will be created by packet_io
* @param wrk_thread_num: expected number of packet receiving threads, which will be created by packet_io,
* this param is useful only in marsio mode
**/
struct packet_io_instance *
packet_io_instance_create(const char *instance_name, const enum packet_io_run_mode mode, const int wrk_thread_num);

View File

@@ -9,17 +9,114 @@
*/
#include <stdio.h>
#include <errno.h>
#include "pio_pcap_file.h"
#include "../packet_io.h"
#include "../../sdk/include/utils.h"
#include "../../sdk/include/util_errors.h"
#include "../../sdk/include/logger.h"
int pio_pcap_file_device_open(struct packet_io_device *pdev, const char *path, uint32_t nr_rxq, uint32_t nr_txq)
{
/*
* @brief validate path is a valid plain file or directory
*
* @retval failed (-1) successful (0),
* if success, dir == nullptr <---> means path is plain file
* dir != nullptr <---> means path is directory
**/
static int validate_directory_or_file(const char *path, DIR **dir) {
DIR *temp_dir = nullptr;
int ret = -1;
temp_dir = opendir(path);
if (nullptr == temp_dir) {
switch (errno) {
case EACCES:
log_error(ST_ERR_FOPEN, "%s: Permission denied", path);
break;
case EBADF:
log_error(ST_ERR_FOPEN, "%s: invalid file descriptor", path);
break;
case ENOTDIR:
log_info("%s: is a plain file, not directory", path);
ret = 0;
break;
default:
log_error(ST_ERR_FOPEN, "%s: errno:%d", path, errno);
}
} else {
*dir = temp_dir;
ret = 0;
}
return ret;
}
static int pcap_plain_file_init(struct pio_pcap_file_device_context *pfile_dev_ctx) {
struct pcap_plain_file_info *pfile_info = CALLOC(struct pcap_plain_file_info, 1);
if (nullptr == pfile_info) {
log_error(ST_ERR_PIO_PCAP_FILE_DEVICE);
return -1;
}
return 0;
}
int pio_pcap_file_device_close(const struct packet_io_device *pdev)
static int pcap_directory_file_init(struct pio_pcap_file_device_context *pfile_dev_ctx) {
return 0;
}
static int pcap_file_shared_init(struct pio_pcap_file_device_context *pfile_dev_ctx) {
return 0;
}
int pio_pcap_file_device_open(struct packet_io_device *pdev, const char *path, uint32_t nr_rxq, uint32_t nr_txq)
{
int status = -1;
DIR *directory = nullptr;
status = pcap_file_shared_init(pdev->entity.pcap_file_dev_ctx);
if (status < 0) {
log_error(ST_ERR_PIO_PCAP_FILE_DEVICE, "pcap file shared init failed.");
return -1;
}
if (validate_directory_or_file(path, &directory) != 0) {
log_error(ST_ERR_PIO_PCAP_FILE_DEVICE, "invalid path:%s (not plain file or directory)", path);
return -1;
}
if (nullptr == directory) {
/* plain file */
status = pcap_plain_file_init(pdev->entity.pcap_file_dev_ctx);
if (status < 0) {
log_error(ST_ERR_PIO_PCAP_FILE_DEVICE, "pcap plain file init failed.");
return -1;
}
} else {
/* directory */
status = pcap_directory_file_init(pdev->entity.pcap_file_dev_ctx);
if (status < 0) {
log_error(ST_ERR_PIO_PCAP_FILE_DEVICE, "pcap directory file init failed.");
return -1;
}
}
return 0;
}
int pio_pcap_file_device_close(struct packet_io_device *pdev)
{
if (nullptr == pdev) {
log_error(ST_ERR_PIO_PCAP_FILE_DEVICE, "invalid pdev pointer so close pcap file device failed!");
return -1;
}
/* TODO: */
//pcap_close(pdev->entity.pcap_file_dev->pcap_handle);
return 0;
}
@@ -41,7 +138,7 @@ void pio_pcap_file_device_pkt_free(struct packet_io_device *pdev, uint32_t qid,
}
int pio_pcap_file_instance_create(struct packet_io_instance *pinst, int wrk_thread_num)
int pio_pcap_file_instance_create(struct packet_io_instance *pinst, __unused int wrk_thread_num)
{
return 0;
@@ -49,5 +146,8 @@ int pio_pcap_file_instance_create(struct packet_io_instance *pinst, int wrk_thre
void pio_pcap_file_instance_destroy(struct packet_io_instance *pinst)
{
for (uint32_t i = 0; i < pinst->dev_cnt; i++) {
pio_pcap_file_device_close(pinst->devices[i]);
FREE(pinst->devices[i]);
}
}

View File

@@ -11,19 +11,81 @@
#pragma once
#include <stdint.h>
#include <dirent.h>
#include <sys/queue.h>
#include <pcap/pcap.h>
struct pio_pcap_file_instance {
struct pio_pcap_file_instance_context {
};
struct pio_pcap_file_device {
pcap_t *pcap_up_handle;
pcap_t *pcap_down_handle;
struct pending_file {
char file_name[NAME_MAX];
struct timespec modified_time;
TAILQ_ENTRY(pending_file) entry;
};
struct pcap_file_shared_info {
/* reserved for bpf filter rules */
char *bpf_string;
/* if true which means pcap file will be deleted after processed */
bool should_delete;
/* the timestamp of the last process */
struct timespec last_processed_ts;
/* counters */
uint64_t pkts;
uint64_t bytes;
uint64_t files;
/* processing completed flags */
uint8_t done;
};
struct pcap_plain_file_info {
char file_name[NAME_MAX];
pcap_t *pcap_handle;
int data_link;
struct bpf_program filter;
/* get the first packet timestamp */
const u_char *first_pkt_data;
struct pcap_pkthdr *first_pkt_hdr;
struct timeval first_pkt_ts;
struct pcap_file_shared_info *shared;
};
struct pcap_file_directory_info {
char dir_name[NAME_MAX];
DIR *directory;
struct pcap_plain_file_info *current_file;
/* whether to loop through the pcap files in the directory */
bool should_loop;
time_t delay;
/* poll pcap file interval */
time_t poll_interval;
/* the pending files queue for the specific directory */
TAILQ_HEAD(pending_file_queue, pending_file) file_queue_head;
struct pcap_file_shared_info *shared;
};
struct pio_pcap_file_device_context {
union {
struct pcap_file_directory_info *dir;
struct pcap_plain_file_info *file;
} entity;
bool is_dir;
struct pcap_file_shared_info shared;
};
/*
@@ -39,7 +101,7 @@ int pio_pcap_file_device_open(struct packet_io_device *pdev, const char *path, u
/*
* @brief close pcap_live device
**/
int pio_pcap_file_device_close(const struct packet_io_device *pdev);
int pio_pcap_file_device_close(struct packet_io_device *pdev);
int pio_pcap_file_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts);

View File

@@ -9,13 +9,15 @@
*/
#include "pio_pcap_live.h"
#include "../packet_io.h"
#include "../../sdk/include/utils.h"
int pio_pcap_live_device_open(struct packet_io_device *pdev, const char *dev_name, uint32_t nr_rxq, uint32_t nr_txq) {
return 0;
}
int pio_pcap_live_device_close(const struct packet_io_device *pdev) {
int pio_pcap_live_device_close(struct packet_io_device *pdev) {
return 0;
}
@@ -35,7 +37,7 @@ void pio_pcap_live_device_pkt_free(struct packet_io_device *pdev, uint32_t qid,
}
int pio_pcap_live_instance_create(struct packet_io_instance *pinst, int wrk_thread_num) {
int pio_pcap_live_instance_create(struct packet_io_instance *pinst, __unused int wrk_thread_num) {
return 0;
}

View File

@@ -11,17 +11,14 @@
#pragma once
#include <stdint.h>
#include <pcap/pcap.h>
struct pio_pcap_live_instance {
};
struct pio_pcap_live_device {
struct pio_pcap_live_instance_context {
};
struct pio_pcap_live_device_context {
pcap_t *pcap_handle;
};
/*
@@ -37,7 +34,7 @@ int pio_pcap_live_device_open(struct packet_io_device *pdev, const char *dev_nam
/*
* @brief close pcap_live device
**/
int pio_pcap_live_device_close(const struct packet_io_device *pdev);
int pio_pcap_live_device_close(struct packet_io_device *pdev);
int pio_pcap_live_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts);