2024-06-19 15:06:14 +08:00
|
|
|
#pragma once
|
2024-02-28 16:30:03 +08:00
|
|
|
|
2024-04-21 11:30:41 +08:00
|
|
|
#ifdef __cplusplus
|
2024-02-28 16:30:03 +08:00
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-06-24 17:07:05 +08:00
|
|
|
#include <stdint.h>
|
2024-02-28 16:30:03 +08:00
|
|
|
|
2024-10-23 10:01:20 +08:00
|
|
|
#include "stellar/packet.h"
|
2024-02-28 16:30:03 +08:00
|
|
|
|
2024-09-18 18:32:20 +08:00
|
|
|
struct packet_io_stat
|
2024-02-28 16:30:03 +08:00
|
|
|
{
|
2024-04-10 17:50:51 +08:00
|
|
|
// device packet
|
2024-08-16 17:44:23 +08:00
|
|
|
uint64_t pkts_rx;
|
|
|
|
|
uint64_t bytes_rx;
|
2024-02-28 16:30:03 +08:00
|
|
|
|
2024-08-16 17:44:23 +08:00
|
|
|
uint64_t pkts_tx;
|
|
|
|
|
uint64_t bytes_tx;
|
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-30 15:25:34 +08:00
|
|
|
// drop packet
|
2024-08-16 17:44:23 +08:00
|
|
|
uint64_t pkts_dropped;
|
|
|
|
|
uint64_t bytes_dropped;
|
2024-04-30 15:25:34 +08:00
|
|
|
|
2024-04-25 15:34:46 +08:00
|
|
|
// inject packet
|
2024-08-16 17:44:23 +08:00
|
|
|
uint64_t pkts_injected;
|
|
|
|
|
uint64_t bytes_injected;
|
2024-04-25 15:34:46 +08:00
|
|
|
|
2024-10-23 10:01:20 +08:00
|
|
|
// user freed
|
|
|
|
|
uint64_t pkts_user_freed;
|
|
|
|
|
uint64_t bytes_user_freed;
|
2024-09-18 18:32:20 +08:00
|
|
|
} __attribute__((aligned(64)));
|
2024-02-28 16:30:03 +08:00
|
|
|
|
|
|
|
|
struct packet_io;
|
2024-09-20 18:41:07 +08:00
|
|
|
struct packet_io *packet_io_new(const char *toml_file);
|
2024-08-30 10:21:44 +08:00
|
|
|
void packet_io_free(struct packet_io *pkt_io);
|
|
|
|
|
int packet_io_isbreak(struct packet_io *pkt_io);
|
|
|
|
|
|
|
|
|
|
int packet_io_init(struct packet_io *pkt_io, uint16_t thr_idx);
|
2024-10-23 10:01:20 +08:00
|
|
|
int packet_io_recv(struct packet_io *pkt_io, uint16_t thr_idx, struct packet *pkts[], int nr_pkts);
|
|
|
|
|
void packet_io_send(struct packet_io *pkt_io, uint16_t thr_idx, struct packet *pkts[], int nr_pkts);
|
|
|
|
|
void packet_io_drop(struct packet_io *pkt_io, uint16_t thr_idx, struct packet *pkts[], int nr_pkts);
|
2024-08-30 10:21:44 +08:00
|
|
|
void packet_io_yield(struct packet_io *pkt_io, uint16_t thr_idx);
|
2024-10-23 10:01:20 +08:00
|
|
|
void packet_io_polling(struct packet_io *pkt_io, uint16_t thr_idx);
|
2024-08-30 10:21:44 +08:00
|
|
|
struct packet_io_stat *packet_io_stat(struct packet_io *pkt_io, uint16_t thr_idx);
|
2024-02-28 16:30:03 +08:00
|
|
|
|
2024-04-21 11:30:41 +08:00
|
|
|
#ifdef __cplusplus
|
2024-02-28 16:30:03 +08:00
|
|
|
}
|
|
|
|
|
#endif
|