2024-02-28 16:30:03 +08:00
|
|
|
#ifndef _PACKET_IO_H
|
|
|
|
|
#define _PACKET_IO_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-04-10 17:50:51 +08:00
|
|
|
#include "log.h"
|
|
|
|
|
#include "packet.h"
|
2024-02-28 16:30:03 +08:00
|
|
|
#include "stellar.h"
|
|
|
|
|
|
|
|
|
|
#define PACKET_IO_LOG_STATE(format, ...) LOG_STATE("packet_io", format, ##__VA_ARGS__)
|
|
|
|
|
#define PACKET_IO_LOG_ERROR(format, ...) LOG_ERROR("packet_io", format, ##__VA_ARGS__)
|
|
|
|
|
#define PACKET_IO_LOG_DEBUG(format, ...) LOG_DEBUG("packet_io", format, ##__VA_ARGS__)
|
|
|
|
|
|
2024-04-16 14:12:41 +08:00
|
|
|
struct io_stat
|
2024-02-28 16:30:03 +08:00
|
|
|
{
|
2024-04-10 17:50:51 +08:00
|
|
|
// device packet
|
|
|
|
|
uint64_t dev_rx_pkts;
|
|
|
|
|
uint64_t dev_rx_bytes;
|
2024-02-28 16:30:03 +08:00
|
|
|
|
2024-04-10 17:50:51 +08:00
|
|
|
uint64_t dev_tx_pkts;
|
|
|
|
|
uint64_t dev_tx_bytes;
|
2024-02-28 16:30:03 +08:00
|
|
|
|
2024-04-10 17:50:51 +08:00
|
|
|
// keep-alive packet
|
|
|
|
|
uint64_t keep_alive_pkts;
|
|
|
|
|
uint64_t keep_alive_bytes;
|
2024-02-28 16:30:03 +08:00
|
|
|
|
2024-04-10 17:50:51 +08:00
|
|
|
// raw packet
|
|
|
|
|
uint64_t raw_rx_pkts;
|
|
|
|
|
uint64_t raw_rx_bytes;
|
2024-02-28 16:30:03 +08:00
|
|
|
|
2024-04-10 17:50:51 +08:00
|
|
|
uint64_t raw_tx_pkts;
|
|
|
|
|
uint64_t raw_tx_bytes;
|
|
|
|
|
|
|
|
|
|
// ctrl packet
|
|
|
|
|
uint64_t ctrl_rx_pkts;
|
|
|
|
|
uint64_t ctrl_rx_bytes;
|
|
|
|
|
|
|
|
|
|
uint64_t ctrl_tx_pkts;
|
|
|
|
|
uint64_t ctrl_tx_bytes;
|
2024-02-28 16:30:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum packet_io_mode
|
|
|
|
|
{
|
|
|
|
|
PACKET_IO_DUMPFILE = 0,
|
|
|
|
|
PACKET_IO_MARSIO = 1,
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-08 14:51:21 +08:00
|
|
|
struct packet_io_options
|
2024-02-28 16:30:03 +08:00
|
|
|
{
|
|
|
|
|
enum packet_io_mode mode;
|
|
|
|
|
|
|
|
|
|
// for dumpfile
|
|
|
|
|
char dumpfile_dir[256];
|
|
|
|
|
|
|
|
|
|
// for marsio
|
|
|
|
|
char app_symbol[64];
|
|
|
|
|
char dev_symbol[64];
|
|
|
|
|
|
|
|
|
|
uint8_t nr_threads;
|
|
|
|
|
uint16_t cpu_mask[MAX_THREAD_NUM];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct packet_io;
|
2024-03-08 14:51:21 +08:00
|
|
|
struct packet_io *packet_io_new(struct packet_io_options *opts);
|
2024-04-10 17:50:51 +08:00
|
|
|
void packet_io_free(struct packet_io *packet_io);
|
2024-04-16 14:12:41 +08:00
|
|
|
struct io_stat *packet_io_get_stat(struct packet_io *packet_io);
|
2024-04-10 17:50:51 +08:00
|
|
|
|
|
|
|
|
int packet_io_init(struct packet_io *packet_io, uint16_t thr_idx);
|
|
|
|
|
int packet_io_ingress(struct packet_io *packet_io, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
|
|
|
|
void packet_io_egress(struct packet_io *packet_io, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
|
|
|
|
void packet_io_drop(struct packet_io *packet_io, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
2024-02-28 16:30:03 +08:00
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|