packet IO stat metric rename

This commit is contained in:
luwenpeng
2024-08-16 17:44:23 +08:00
parent 169607cd1e
commit 2b9e867071
5 changed files with 95 additions and 129 deletions

View File

@@ -6,48 +6,8 @@
# "name": "stellar",
# "tags": {},
# "fields": {
# "dev_rx_pkts": 90099,
# "dev_rx_bytes": 63205423,
# "dev_tx_pkts": 90082,
# "dev_tx_bytes": 63194807,
# "keep_alive_pkts": 0,
# "keep_alive_bytes": 0,
# "raw_rx_pkts": 90099,
# "raw_rx_bytes": 63205423,
# "raw_tx_pkts": 90082,
# "raw_tx_bytes": 63194807,
# "ctrl_rx_pkts": 0,
# "ctrl_rx_bytes": 0,
# "ctrl_tx_pkts": 0,
# "ctrl_tx_bytes": 0,
# "tcp_sess_used": 480,
# "tcp_sess_opening": 0,
# "tcp_sess_active": 141,
# "tcp_sess_closing": 339,
# "tcp_sess_discard": 0,
# "tcp_sess_closed": 0,
# "udp_sess_used": 0,
# "udp_sess_opening": 0,
# "udp_sess_active": 0,
# "udp_sess_closing": 0,
# "udp_sess_discard": 0,
# "udp_sess_closed": 0,
# "tcp_sess_evicted": 0,
# "udp_sess_evicted": 0,
# "udp_pkts_nospace_bypass": 0,
# "tcp_pkts_nospace_bypass": 0,
# "tcp_pkts_nosess_bypass": 4769,
# "tcp_pkts_duped_bypass": 1796,
# "udp_pkts_duped_bypass": 382,
# "udp_pkts_evctd_bypass": 0,
# "tcp_seg_received": 49833,
# "tcp_seg_expired": 0,
# "tcp_seg_overlap": 3012,
# "tcp_seg_no_space": 36452,
# "tcp_seg_inorder": 6189,
# "tcp_seg_reorded": 218,
# "tcp_seg_buffered": 5967,
# "tcp_seg_released": 218
# "aaaa": 1111111,
# "bbbb": 2222222,
# },
# "timestamp_ms": 1713053113549
# }

View File

@@ -15,24 +15,24 @@
#define IS_BUSY 0xf
typedef uint64_t get_val_func(struct thread_stat *thr_stat);
static inline uint64_t get_dev_rx_pkts(struct thread_stat *thr_stat) { return thr_stat->packet_io->dev_rx_pkts; }
static inline uint64_t get_dev_rx_bytes(struct thread_stat *thr_stat) { return thr_stat->packet_io->dev_rx_bytes; }
static inline uint64_t get_dev_tx_pkts(struct thread_stat *thr_stat) { return thr_stat->packet_io->dev_tx_pkts; }
static inline uint64_t get_dev_tx_bytes(struct thread_stat *thr_stat) { return thr_stat->packet_io->dev_tx_bytes; }
static inline uint64_t get_pkts_rx(struct thread_stat *thr_stat) { return thr_stat->packet_io->pkts_rx; }
static inline uint64_t get_bytes_rx(struct thread_stat *thr_stat) { return thr_stat->packet_io->bytes_rx; }
static inline uint64_t get_pkts_tx(struct thread_stat *thr_stat) { return thr_stat->packet_io->pkts_tx; }
static inline uint64_t get_bytes_tx(struct thread_stat *thr_stat) { return thr_stat->packet_io->bytes_tx; }
static inline uint64_t get_keep_alive_pkts(struct thread_stat *thr_stat) { return thr_stat->packet_io->keep_alive_pkts; }
static inline uint64_t get_keep_alive_bytes(struct thread_stat *thr_stat) { return thr_stat->packet_io->keep_alive_bytes; }
static inline uint64_t get_raw_rx_pkts(struct thread_stat *thr_stat) { return thr_stat->packet_io->raw_rx_pkts; }
static inline uint64_t get_raw_rx_bytes(struct thread_stat *thr_stat) { return thr_stat->packet_io->raw_rx_bytes; }
static inline uint64_t get_raw_tx_pkts(struct thread_stat *thr_stat) { return thr_stat->packet_io->raw_tx_pkts; }
static inline uint64_t get_raw_tx_bytes(struct thread_stat *thr_stat) { return thr_stat->packet_io->raw_tx_bytes; }
static inline uint64_t get_drop_pkts(struct thread_stat *thr_stat) { return thr_stat->packet_io->drop_pkts; }
static inline uint64_t get_drop_bytes(struct thread_stat *thr_stat) { return thr_stat->packet_io->drop_bytes; }
static inline uint64_t get_inject_pkts(struct thread_stat *thr_stat) { return thr_stat->packet_io->inject_pkts; }
static inline uint64_t get_inject_bytes(struct thread_stat *thr_stat) { return thr_stat->packet_io->inject_bytes; }
static inline uint64_t get_ctrl_rx_pkts(struct thread_stat *thr_stat) { return thr_stat->packet_io->ctrl_rx_pkts; }
static inline uint64_t get_ctrl_rx_bytes(struct thread_stat *thr_stat) { return thr_stat->packet_io->ctrl_rx_bytes; }
static inline uint64_t get_ctrl_tx_pkts(struct thread_stat *thr_stat) { return thr_stat->packet_io->ctrl_tx_pkts; }
static inline uint64_t get_ctrl_tx_bytes(struct thread_stat *thr_stat) { return thr_stat->packet_io->ctrl_tx_bytes; }
static inline uint64_t get_raw_pkts_rx(struct thread_stat *thr_stat) { return thr_stat->packet_io->raw_pkts_rx; }
static inline uint64_t get_raw_bytes_rx(struct thread_stat *thr_stat) { return thr_stat->packet_io->raw_bytes_rx; }
static inline uint64_t get_raw_pkts_tx(struct thread_stat *thr_stat) { return thr_stat->packet_io->raw_pkts_tx; }
static inline uint64_t get_raw_bytes_tx(struct thread_stat *thr_stat) { return thr_stat->packet_io->raw_bytes_tx; }
static inline uint64_t get_pkts_dropped(struct thread_stat *thr_stat) { return thr_stat->packet_io->pkts_dropped; }
static inline uint64_t get_bytes_dropped(struct thread_stat *thr_stat) { return thr_stat->packet_io->bytes_dropped; }
static inline uint64_t get_pkts_injected(struct thread_stat *thr_stat) { return thr_stat->packet_io->pkts_injected; }
static inline uint64_t get_bytes_injected(struct thread_stat *thr_stat) { return thr_stat->packet_io->bytes_injected; }
static inline uint64_t get_ctrl_pkts_rx(struct thread_stat *thr_stat) { return thr_stat->packet_io->ctrl_pkts_rx; }
static inline uint64_t get_ctrl_bytes_rx(struct thread_stat *thr_stat) { return thr_stat->packet_io->ctrl_bytes_rx; }
static inline uint64_t get_ctrl_pkts_tx(struct thread_stat *thr_stat) { return thr_stat->packet_io->ctrl_pkts_tx; }
static inline uint64_t get_ctrl_bytes_tx(struct thread_stat *thr_stat) { return thr_stat->packet_io->ctrl_bytes_tx; }
static inline uint64_t get_ip4_flow_find(struct thread_stat *thr_stat) { return thr_stat->ip_reassembly->ip4_flow_find; }
static inline uint64_t get_ip4_flow_add(struct thread_stat *thr_stat) { return thr_stat->ip_reassembly->ip4_flow_add; }
static inline uint64_t get_ip4_flow_del(struct thread_stat *thr_stat) { return thr_stat->ip_reassembly->ip4_flow_del; }
@@ -85,6 +85,12 @@ static inline uint64_t get_tcp_seg_reorded(struct thread_stat *thr_stat) { retur
static inline uint64_t get_tcp_seg_buffered(struct thread_stat *thr_stat) { return thr_stat->session_mgr->tcp_seg_buffered; }
static inline uint64_t get_tcp_seg_released(struct thread_stat *thr_stat) { return thr_stat->session_mgr->tcp_seg_released; }
/*
* This naming convention maintains consistency by using a clear, structured pattern:
* • tcp_sessions_ or ipv6_frags_ as the prefix to indicate the type of data.
* • Action or status (e.g., bypassed, active, dropped) as the middle part.
* • Cause or condition (e.g., full_table, buffer_limit) as the suffix for additional clarity.
*/
struct metric_schema
{
const char *name;
@@ -92,29 +98,29 @@ struct metric_schema
} schemas[] =
{
// device packet
{"dev_rx_pkts", get_dev_rx_pkts},
{"dev_rx_bytes", get_dev_rx_bytes},
{"dev_tx_pkts", get_dev_tx_pkts},
{"dev_tx_bytes", get_dev_tx_bytes},
{"pkts_rx", get_pkts_rx},
{"bytes_rx", get_bytes_rx},
{"pkts_tx", get_pkts_tx},
{"bytes_tx", get_bytes_tx},
// keep-alive packet
{"keep_alive_pkts", get_keep_alive_pkts},
{"keep_alive_bytes", get_keep_alive_bytes},
// raw packet
{"raw_rx_pkts", get_raw_rx_pkts},
{"raw_rx_bytes", get_raw_rx_bytes},
{"raw_tx_pkts", get_raw_tx_pkts},
{"raw_tx_bytes", get_raw_tx_bytes},
{"raw_pkts_rx", get_raw_pkts_rx},
{"raw_bytes_rx", get_raw_bytes_rx},
{"raw_pkts_tx", get_raw_pkts_tx},
{"raw_bytes_tx", get_raw_bytes_tx},
// drop packet
{"drop_pkts", get_drop_pkts},
{"drop_bytes", get_drop_bytes},
{"pkts_dropped", get_pkts_dropped},
{"bytes_dropped", get_bytes_dropped},
// inject packet
{"inject_pkts", get_inject_pkts},
{"inject_bytes", get_inject_bytes},
{"pkts_injected", get_pkts_injected},
{"bytes_injected", get_bytes_injected},
// ctrl packet
{"ctrl_rx_pkts", get_ctrl_rx_pkts},
{"ctrl_rx_bytes", get_ctrl_rx_bytes},
{"ctrl_tx_pkts", get_ctrl_tx_pkts},
{"ctrl_tx_bytes", get_ctrl_tx_bytes},
{"ctrl_pkts_rx", get_ctrl_pkts_rx},
{"ctrl_bytes_rx", get_ctrl_bytes_rx},
{"ctrl_pkts_tx", get_ctrl_pkts_tx},
{"ctrl_bytes_tx", get_ctrl_bytes_tx},
// ipv4 reassembly
{"ip4_flow_find", get_ip4_flow_find},
{"ip4_flow_add", get_ip4_flow_add},

View File

@@ -318,11 +318,11 @@ int dumpfile_io_ingress(struct dumpfile_io *handle, uint16_t thr_idx, struct pac
}
else
{
stat->dev_rx_pkts++;
stat->dev_rx_bytes += pcap_pkt->len;
stat->pkts_rx++;
stat->bytes_rx += pcap_pkt->len;
stat->raw_rx_pkts++;
stat->raw_rx_bytes += pcap_pkt->len;
stat->raw_pkts_rx++;
stat->raw_bytes_rx += pcap_pkt->len;
pkt = &pkts[nr_parsed];
packet_parse(pkt, pcap_pkt->data, pcap_pkt->len);
@@ -347,11 +347,11 @@ void dumpfile_io_egress(struct dumpfile_io *handle, uint16_t thr_idx, struct pac
pkt = &pkts[i];
len = packet_get_raw_len(pkt);
stat->dev_tx_pkts++;
stat->dev_tx_bytes += len;
stat->pkts_tx++;
stat->bytes_tx += len;
stat->raw_tx_pkts++;
stat->raw_tx_bytes += len;
stat->raw_pkts_tx++;
stat->raw_bytes_tx += len;
struct pcap_pkt *pcap_pkt = (struct pcap_pkt *)packet_get_origin_ctx(pkt);
if (pcap_pkt)
@@ -373,8 +373,8 @@ void dumpfile_io_drop(struct dumpfile_io *handle, uint16_t thr_idx, struct packe
struct pcap_pkt *pcap_pkt = (struct pcap_pkt *)packet_get_origin_ctx(pkt);
if (pcap_pkt)
{
stat->drop_pkts++;
stat->drop_bytes += packet_get_raw_len(pkt);
stat->pkts_dropped++;
stat->bytes_dropped += packet_get_raw_len(pkt);
free(pcap_pkt);
}
packet_free(pkt);
@@ -397,14 +397,14 @@ int dumpfile_io_inject(struct dumpfile_io *handle, uint16_t thr_idx, struct pack
pkt = &pkts[i];
len = packet_get_raw_len(pkt);
stat->inject_pkts++;
stat->inject_bytes += len;
stat->pkts_injected++;
stat->bytes_injected += len;
stat->raw_tx_pkts++;
stat->raw_tx_bytes += len;
stat->raw_pkts_tx++;
stat->raw_bytes_tx += len;
stat->dev_tx_pkts++;
stat->dev_tx_bytes += len;
stat->pkts_tx++;
stat->bytes_tx += len;
memset(&tuple, 0, sizeof(struct tuple6));
packet_get_innermost_tuple6(pkt, &tuple);
@@ -419,7 +419,7 @@ int dumpfile_io_inject(struct dumpfile_io *handle, uint16_t thr_idx, struct pack
inet_ntop(AF_INET6, &tuple.src_addr.v6, src_addr, INET6_ADDRSTRLEN);
inet_ntop(AF_INET6, &tuple.dst_addr.v6, dst_addr, INET6_ADDRSTRLEN);
}
snprintf(file, sizeof(file), "%s/inject-%s:%u-%s:%u-%lu.pcap", handle->work_dir, src_addr, ntohs(tuple.src_port), dst_addr, ntohs(tuple.dst_port), stat->inject_pkts);
snprintf(file, sizeof(file), "%s/inject-%s:%u-%s:%u-%lu.pcap", handle->work_dir, src_addr, ntohs(tuple.src_port), dst_addr, ntohs(tuple.dst_port), stat->pkts_injected);
if (packet_dump_pcap(pkt, file) == -1)
{

View File

@@ -279,16 +279,16 @@ int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet
data = marsio_buff_mtod(mbuff);
len = marsio_buff_datalen(mbuff);
stat->dev_rx_pkts++;
stat->dev_rx_bytes += len;
stat->pkts_rx++;
stat->bytes_rx += len;
if (is_keepalive_packet(data, len))
{
stat->keep_alive_pkts++;
stat->keep_alive_bytes += len;
stat->dev_tx_pkts++;
stat->dev_tx_bytes += len;
stat->pkts_tx++;
stat->bytes_tx += len;
marsio_send_burst(handle->mr_path, thr_idx, &mbuff, 1);
continue;
@@ -301,13 +301,13 @@ int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet
if (marsio_buff_is_ctrlbuf(mbuff))
{
stat->ctrl_rx_pkts++;
stat->ctrl_rx_bytes += len;
stat->ctrl_pkts_rx++;
stat->ctrl_bytes_rx += len;
}
else
{
stat->raw_rx_pkts++;
stat->raw_rx_bytes += len;
stat->raw_pkts_rx++;
stat->raw_bytes_rx += len;
}
}
@@ -326,8 +326,8 @@ void marsio_io_egress(struct marsio_io *handle, uint16_t thr_idx, struct packet
pkt = &pkts[i];
len = packet_get_raw_len(pkt);
stat->dev_tx_pkts++;
stat->dev_tx_bytes += len;
stat->pkts_tx++;
stat->bytes_tx += len;
mbuff = (marsio_buff_t *)packet_get_origin_ctx(pkt);
assert(mbuff != NULL);
@@ -335,13 +335,13 @@ void marsio_io_egress(struct marsio_io *handle, uint16_t thr_idx, struct packet
if (marsio_buff_is_ctrlbuf(mbuff))
{
stat->ctrl_tx_pkts++;
stat->ctrl_tx_bytes += len;
stat->ctrl_pkts_tx++;
stat->ctrl_bytes_tx += len;
}
else
{
stat->raw_tx_pkts++;
stat->raw_tx_bytes += len;
stat->raw_pkts_tx++;
stat->raw_bytes_tx += len;
}
marsio_send_burst(handle->mr_path, thr_idx, &mbuff, 1);
@@ -361,8 +361,8 @@ void marsio_io_drop(struct marsio_io *handle, uint16_t thr_idx, struct packet *p
mbuff = (marsio_buff_t *)packet_get_origin_ctx(pkt);
if (mbuff)
{
stat->drop_pkts++;
stat->drop_bytes += packet_get_raw_len(pkt);
stat->pkts_dropped++;
stat->bytes_dropped += packet_get_raw_len(pkt);
marsio_buff_free(handle->mr_ins, &mbuff, 1, 0, thr_idx);
}
packet_free(pkt);
@@ -389,14 +389,14 @@ int marsio_io_inject(struct marsio_io *handle, uint16_t thr_idx, struct packet *
continue;
}
stat->inject_pkts++;
stat->inject_bytes += len;
stat->pkts_injected++;
stat->bytes_injected += len;
stat->raw_tx_pkts++;
stat->raw_tx_bytes += len;
stat->raw_pkts_tx++;
stat->raw_bytes_tx += len;
stat->dev_tx_pkts++;
stat->dev_tx_bytes += len;
stat->pkts_tx++;
stat->bytes_tx += len;
nr_inject++;

View File

@@ -12,37 +12,37 @@ extern "C"
struct __attribute__((aligned(64))) packet_io_stat
{
// device packet
uint64_t dev_rx_pkts;
uint64_t dev_rx_bytes;
uint64_t pkts_rx;
uint64_t bytes_rx;
uint64_t dev_tx_pkts;
uint64_t dev_tx_bytes;
uint64_t pkts_tx;
uint64_t bytes_tx;
// 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_pkts_rx;
uint64_t raw_bytes_rx;
uint64_t raw_tx_pkts;
uint64_t raw_tx_bytes;
uint64_t raw_pkts_tx;
uint64_t raw_bytes_tx;
// drop packet
uint64_t drop_pkts;
uint64_t drop_bytes;
uint64_t pkts_dropped;
uint64_t bytes_dropped;
// inject packet
uint64_t inject_pkts;
uint64_t inject_bytes;
uint64_t pkts_injected;
uint64_t bytes_injected;
// ctrl packet
uint64_t ctrl_rx_pkts;
uint64_t ctrl_rx_bytes;
uint64_t ctrl_pkts_rx;
uint64_t ctrl_bytes_rx;
uint64_t ctrl_tx_pkts;
uint64_t ctrl_tx_bytes;
uint64_t ctrl_pkts_tx;
uint64_t ctrl_bytes_tx;
};
enum packet_io_mode