#ifndef _PACKET_IO_H #define _PACKET_IO_H #ifdef __cpluscplus extern "C" { #endif #include "log.h" #include "packet.h" #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__) struct io_stat { // device packet uint64_t dev_rx_pkts; uint64_t dev_rx_bytes; uint64_t dev_tx_pkts; uint64_t dev_tx_bytes; // keep-alive packet uint64_t keep_alive_pkts; uint64_t keep_alive_bytes; // raw packet uint64_t raw_rx_pkts; uint64_t raw_rx_bytes; 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; }; enum packet_io_mode { PACKET_IO_DUMPFILE = 0, PACKET_IO_MARSIO = 1, }; struct packet_io_options { 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; struct packet_io *packet_io_new(struct packet_io_options *opts); void packet_io_free(struct packet_io *packet_io); struct io_stat *packet_io_get_stat(struct packet_io *packet_io); 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); #ifdef __cpluscplus } #endif #endif