94 lines
2.7 KiB
C
94 lines
2.7 KiB
C
/*
|
|
**********************************************************************************************
|
|
* File: packet_io.h
|
|
* Description: packet io module entry
|
|
* Authors: Liu WenTan <liuwentan@geedgenetworks.com>
|
|
* Date: 2022-07-15
|
|
* Copyright: (c) 2018-2022 Geedge Networks, Inc. All rights reserved.
|
|
***********************************************************************************************
|
|
*/
|
|
|
|
#ifndef _PACKET_IO_H_
|
|
#define _PACKET_IO_H_
|
|
|
|
#ifdef __cpluscplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
#include <sys/types.h>
|
|
|
|
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_instance;
|
|
struct packet_io_device;
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
* @param instance_name: packet_io instance's name
|
|
* @param filename: packet_io config file's name
|
|
* @param devices(in/out): return packet_io_device pointer array, each pointer stands for an opened packet_io device
|
|
* @param dev_num: the num of opened packet_io_device's pointer
|
|
* @return struct packet_io_instance*
|
|
*/
|
|
struct packet_io_instance *
|
|
packet_io_init(const char *instance_name, const char *filename, struct packet_io_device *devices[], size_t *dev_num);
|
|
|
|
/* destroy packet_io instance */
|
|
void packet_io_fini(struct packet_io_instance *pinst);
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
* @param inst_name
|
|
* @param mode
|
|
* @return struct packet_io_instance*
|
|
*/
|
|
struct packet_io_instance *
|
|
packet_io_instance_create(const char *inst_name, const enum packet_io_run_mode mode);
|
|
|
|
void packet_io_instance_destroy(struct packet_io_instance *pinst);
|
|
|
|
struct packet_io_device *
|
|
packet_io_device_open(struct packet_io_instance *pinst, const char *dev_name, size_t nr_rxq, size_t nr_txq);
|
|
|
|
void packet_io_device_close(struct packet_io_device *pdev);
|
|
|
|
/**
|
|
* @brief packet_io device receive function
|
|
*
|
|
* @param pdev: packet_io device pointer
|
|
* @param rxq_id: which queue will receive from
|
|
* @param p: received packet's pointer array
|
|
* @param nr_p: number of received packets
|
|
*/
|
|
ssize_t packet_io_device_rx(struct packet_io_device *pdev, uint32_t rxq_id, struct stellar_packet **pkts, size_t nr_pkts);
|
|
|
|
/**
|
|
* @brief packet_io device send function
|
|
*
|
|
* @param pdev: packet_io device pointer
|
|
* @param rxq_id: which queue will send to
|
|
* @param p: prepare to send packet's pointer array
|
|
* @param nr_p: number of packets which prepare to send
|
|
*/
|
|
ssize_t packet_io_device_tx(struct packet_io_device *pdev, uint32_t txq_id, struct stellar_packet **pkts, size_t nr_pkts);
|
|
|
|
/*
|
|
* @brief packet_io free packet buff
|
|
*/
|
|
void packet_io_pkts_free(struct packet_io_device *pdev, uint32_t qid, struct stellar_packet **pkts, size_t nr_pkts);
|
|
|
|
#ifdef __cpluscplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _PIO_PCAP_LIVE_H_ */ |