1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
**********************************************************************************************
* File: packet_io.h
* Description: packet io module entry
* Authors: Liu WenTan <[email protected]>
* 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_ */
|