refactor: move packet queue to dumpfile_io.cpp

This commit is contained in:
luwenpeng
2024-08-21 14:33:03 +08:00
parent f2f5441b4c
commit 415c21440f
10 changed files with 139 additions and 168 deletions

View File

@@ -256,21 +256,20 @@ int marsio_io_init(struct marsio_io *handle, uint16_t thr_idx __attribute__((unu
return 0;
}
int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts)
uint16_t marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, uint16_t nr_pkts)
{
struct packet *pkt;
marsio_buff_t *mbuff;
marsio_buff_t *rx_buffs[RX_BURST_MAX];
struct packet_io_stat *stat = &handle->stat[thr_idx];
int nr_recv;
int nr_parsed = 0;
uint16_t nr_parsed = 0;
int len;
char *data;
nr_recv = marsio_recv_burst(handle->mr_dev, thr_idx, rx_buffs, MIN(RX_BURST_MAX, nr_pkts));
int nr_recv = marsio_recv_burst(handle->mr_dev, thr_idx, rx_buffs, MIN(RX_BURST_MAX, nr_pkts));
if (nr_recv <= 0)
{
return 0;
return nr_parsed;
}
for (int i = 0; i < nr_recv; i++)
@@ -294,10 +293,9 @@ int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet
continue;
}
pkt = &pkts[nr_parsed];
pkt = &pkts[nr_parsed++];
packet_parse(pkt, data, len);
metadata_from_mbuff_to_packet(mbuff, pkt);
nr_parsed++;
if (marsio_buff_is_ctrlbuf(mbuff))
{
@@ -314,14 +312,14 @@ int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet
return nr_parsed;
}
void marsio_io_egress(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts)
void marsio_io_egress(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, uint16_t nr_pkts)
{
struct packet *pkt;
marsio_buff_t *mbuff;
struct packet_io_stat *stat = &handle->stat[thr_idx];
int len;
for (int i = 0; i < nr_pkts; i++)
for (uint16_t i = 0; i < nr_pkts; i++)
{
pkt = &pkts[i];
len = packet_get_raw_len(pkt);
@@ -349,13 +347,13 @@ void marsio_io_egress(struct marsio_io *handle, uint16_t thr_idx, struct packet
}
}
void marsio_io_drop(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts)
void marsio_io_drop(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, uint16_t nr_pkts)
{
struct packet *pkt;
marsio_buff_t *mbuff;
struct packet_io_stat *stat = &handle->stat[thr_idx];
for (int i = 0; i < nr_pkts; i++)
for (uint16_t i = 0; i < nr_pkts; i++)
{
pkt = &pkts[i];
mbuff = (marsio_buff_t *)packet_get_origin_ctx(pkt);
@@ -369,16 +367,16 @@ void marsio_io_drop(struct marsio_io *handle, uint16_t thr_idx, struct packet *p
}
}
int marsio_io_inject(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts)
uint16_t marsio_io_inject(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, uint16_t nr_pkts)
{
int len;
int nr_inject = 0;
char *ptr;
uint16_t nr_inject = 0;
struct packet *pkt;
marsio_buff_t *mbuff;
struct packet_io_stat *stat = &handle->stat[thr_idx];
for (int i = 0; i < nr_pkts; i++)
for (uint16_t i = 0; i < nr_pkts; i++)
{
pkt = &pkts[i];
len = packet_get_raw_len(pkt);