[PACKET_IO]format comment
This commit is contained in:
@@ -3,6 +3,5 @@
|
||||
#include "marsio.h"
|
||||
|
||||
struct packet {
|
||||
marsio_buff_t *rx_buf;
|
||||
};
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "../../sdk/include/utils.h"
|
||||
#include "../../sdk/include/util_errors.h"
|
||||
|
||||
#define MARSIO_BURST_PKT_MAX (256)
|
||||
|
||||
/* marsio dynamic link lib function entries */
|
||||
static struct marsio_dll_function_entries g_marsio_dll_func;
|
||||
|
||||
@@ -298,16 +300,26 @@ int pio_marsio_device_close(const struct packet_io_device *pdev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p)
|
||||
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;
|
||||
return g_marsio_dll_func.marsio_recv_burst(mr_dev_handle, rxq_id, (marsio_buff_t **)p, nr_p);
|
||||
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);
|
||||
/* receive some pkts, copy mbuf pointer to packet structure */
|
||||
if (recv_res > 0) {
|
||||
for (int i = 0; i < recv_res; i++) {
|
||||
pkts[i]= (struct packet *)rx_buff[i];
|
||||
}
|
||||
}
|
||||
|
||||
return recv_res;
|
||||
}
|
||||
|
||||
int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p)
|
||||
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 **)p, nr_p);
|
||||
return g_marsio_dll_func.marsio_send_burst(sendpath_handle, txq_id, (marsio_buff_t **)pkts, nr_pkts);
|
||||
}
|
||||
|
||||
static int marsio_instance_init(struct packet_io_instance *pinst, int wrk_thread_num)
|
||||
|
||||
@@ -15,90 +15,65 @@
|
||||
#include "marsio.h"
|
||||
|
||||
/*
|
||||
dll is short for dynamic link lib
|
||||
the following entries is supported by marsio system
|
||||
*/
|
||||
* 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 *(*marsio_create)(void);
|
||||
|
||||
/* marsio_init() */
|
||||
int (*marsio_init)(struct mr_instance *instance, const char *appsym);
|
||||
|
||||
/* marsio_destroy() */
|
||||
int (*marsio_destroy)(struct mr_instance *instance);
|
||||
|
||||
/* marsio_open_device() */
|
||||
struct mr_vdev *(*marsio_open_device)(struct mr_instance *instance, const char *devsym,
|
||||
unsigned int nr_rxstream, unsigned int nr_txstream);
|
||||
|
||||
/* marsio_close_device() */
|
||||
void (*marsio_close_device)(struct mr_vdev *pdev);
|
||||
|
||||
/* marsio_option_set() */
|
||||
int (*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 *(*marsio_sendpath_create_by_vdev)(struct mr_vdev *pdev);
|
||||
|
||||
/* marsio_sendpath_destroy() */
|
||||
void (*marsio_sendpath_destroy)(struct mr_sendpath *sendpath);
|
||||
|
||||
/* marsio_thread_init() */
|
||||
int (*marsio_thread_init)(struct mr_instance *instance);
|
||||
|
||||
/* marsio_recv_burst() */
|
||||
int (*marsio_recv_burst)(struct mr_vdev *pdev, queue_id_t qid, marsio_buff_t *mbufs[], int nr_mbufs);
|
||||
|
||||
/* marsio_send_burst() */
|
||||
int (*marsio_send_burst)(struct mr_sendpath *sendpath, queue_id_t qid, marsio_buff_t *mbufs[], int nr_mbufs);
|
||||
|
||||
/* marsio_send_burst_with_options() */
|
||||
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_malloc_global() */
|
||||
int (*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 (*marsio_buff_free)(struct mr_instance *, marsio_buff_t **,unsigned int, int socket_id, int thread_id);
|
||||
|
||||
/* marsio_buff_append() */
|
||||
char *(*marsio_buff_append)(marsio_buff_t *m, uint16_t len);
|
||||
|
||||
/* marsio_buff_ctrlzone() */
|
||||
void *(*marsio_buff_ctrlzone)(marsio_buff_t *m, uint8_t id);
|
||||
|
||||
/* marsio_buff_ctrlzone_set() */
|
||||
void (*marsio_buff_ctrlzone_set)(marsio_buff_t *m, uint8_t id, void* ptr_data, uint8_t size);
|
||||
|
||||
/* marsio_buff_set_rehash_index() */
|
||||
void (*marsio_buff_set_rehash_index)(marsio_buff_t *m, uint32_t hash);
|
||||
|
||||
/* marsio_buff_mtod() */
|
||||
char *(*marsio_buff_mtod)(marsio_buff_t *m);
|
||||
|
||||
/* marsio_buff_datalen() */
|
||||
uint32_t (*marsio_buff_datalen)(marsio_buff_t *m);
|
||||
|
||||
/* marsio_buff_buflen() */
|
||||
uint32_t (*marsio_buff_buflen)(marsio_buff_t *m);
|
||||
|
||||
/* marsio_buff_clone_with_options() */
|
||||
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);
|
||||
|
||||
/* marsio_send_burst_flush() */
|
||||
void (*marsio_send_burst_flush)(struct mr_sendpath *sendpath, queue_id_t sid);
|
||||
|
||||
/* marsio_buff_get_metadata() */
|
||||
int (*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 (*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 (*marsio_buff_unset_metadata)(marsio_buff_t *m, enum mr_buff_metadata_type type);
|
||||
};
|
||||
|
||||
@@ -123,23 +98,23 @@ 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
|
||||
*/
|
||||
* @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
|
||||
**/
|
||||
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
|
||||
*/
|
||||
* @brief close pcap_live device
|
||||
**/
|
||||
int pio_marsio_device_close(const struct packet_io_device *pdev);
|
||||
|
||||
int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p);
|
||||
int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts);
|
||||
|
||||
int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p);
|
||||
int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts);
|
||||
|
||||
int pio_marsio_instance_create(struct packet_io_instance *pinst, int wrk_thread_num);
|
||||
|
||||
|
||||
@@ -106,9 +106,9 @@ packet_io_device_open(struct packet_io_instance *pinst, const char *dev_name, ui
|
||||
ppio_dev->dev_ops = &pio_device_ops_array[pinst->mode];
|
||||
|
||||
/*
|
||||
ppio_inst->devices --> | struct packet_io_device * | struct packet_io_device * | struct packet_io_device * |
|
||||
* ppio_inst->devices --> | struct packet_io_device * | struct packet_io_device * | struct packet_io_device * |
|
||||
array[0] array[1] array[2]
|
||||
*/
|
||||
**/
|
||||
pinst->devices[pinst->dev_cnt++] = ppio_dev;
|
||||
|
||||
int ret = ppio_dev->dev_ops->open(ppio_dev, dev_name, nr_rxq, nr_txq);
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
/*
|
||||
* note:
|
||||
1. packet_io_XXX function is supported by packet_io.h
|
||||
2. pio_XXX function is supported by pio_pcap_live.h/pio_pcap_file.h/pio_marsio.h
|
||||
* 1. packet_io_XXX function is supported by packet_io.h
|
||||
* 2. pio_XXX function is supported by pio_pcap_live.h/pio_pcap_file.h/pio_marsio.h
|
||||
**/
|
||||
|
||||
struct pio_instance_operations {
|
||||
|
||||
@@ -22,12 +22,12 @@ int pio_pcap_file_device_close(const struct packet_io_device *pdev) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -27,23 +27,23 @@ struct pio_pcap_file_device_context {
|
||||
};
|
||||
|
||||
/*
|
||||
@brief open pcap_file device
|
||||
|
||||
@param pdev: pcap_file device's pointer
|
||||
@param dev_name: the path of pcap file
|
||||
@param nr_rxq: number of the packet receiving queues for the device
|
||||
@param nr_txq: number of the packet sending queues for the device
|
||||
*/
|
||||
* @brief open pcap_file device
|
||||
*
|
||||
* @param pdev: pcap_file device's pointer
|
||||
* @param dev_name: the path of pcap file
|
||||
* @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_pcap_file_device_open(struct packet_io_device *pdev, const char *path, uint32_t nr_rxq, uint32_t nr_txq);
|
||||
|
||||
/*
|
||||
@brief close pcap_live device
|
||||
*/
|
||||
* @brief close pcap_live device
|
||||
**/
|
||||
int pio_pcap_file_device_close(const struct packet_io_device *pdev);
|
||||
|
||||
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_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts);
|
||||
|
||||
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_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts);
|
||||
|
||||
int pio_pcap_file_instance_create(struct packet_io_instance *pinst, int wrk_thread_num);
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ int pio_pcap_live_device_close(const struct packet_io_device *pdev) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -25,23 +25,23 @@ struct pio_pcap_live_device_context {
|
||||
};
|
||||
|
||||
/*
|
||||
@brief open pcap_live device
|
||||
|
||||
@param pdev: pcap_live 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
|
||||
*/
|
||||
* @brief open pcap_live device
|
||||
*
|
||||
* @param pdev: pcap_live 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_pcap_live_device_open(struct packet_io_device *pdev, const char *dev_name, uint32_t nr_rxq, uint32_t nr_txq);
|
||||
|
||||
/*
|
||||
@brief close pcap_live device
|
||||
*/
|
||||
* @brief close pcap_live device
|
||||
**/
|
||||
int pio_pcap_live_device_close(const struct packet_io_device *pdev);
|
||||
|
||||
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_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts);
|
||||
|
||||
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_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts);
|
||||
|
||||
int pio_pcap_live_instance_create(struct packet_io_instance *pinst, int wrk_thread_num);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user