packet IO support inject packet and add inject packet stat
This commit is contained in:
@@ -274,6 +274,32 @@ void dumpfile_io_drop(struct dumpfile_io *handle, uint16_t thr_idx, struct packe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dumpfile_io_inject(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
struct packet *pkt = NULL;
|
||||||
|
struct io_stat *stat = &handle->stat[thr_idx];
|
||||||
|
|
||||||
|
for (int i = 0; i < nr_pkts; i++)
|
||||||
|
{
|
||||||
|
pkt = &pkts[i];
|
||||||
|
len = packet_get_len(pkt);
|
||||||
|
|
||||||
|
stat->inject_pkts++;
|
||||||
|
stat->inject_bytes += len;
|
||||||
|
|
||||||
|
stat->raw_tx_pkts++;
|
||||||
|
stat->raw_tx_bytes += len;
|
||||||
|
|
||||||
|
stat->dev_tx_pkts++;
|
||||||
|
stat->dev_tx_bytes += len;
|
||||||
|
|
||||||
|
packet_free(pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nr_pkts;
|
||||||
|
}
|
||||||
|
|
||||||
void dumpfile_io_yield(struct dumpfile_io *handle, uint16_t thr_idx, uint64_t timeout_ms)
|
void dumpfile_io_yield(struct dumpfile_io *handle, uint16_t thr_idx, uint64_t timeout_ms)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ int dumpfile_io_init(struct dumpfile_io *handle, uint16_t thr_idx);
|
|||||||
int dumpfile_io_ingress(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
int dumpfile_io_ingress(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
||||||
void dumpfile_io_egress(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
void dumpfile_io_egress(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
||||||
void dumpfile_io_drop(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
void dumpfile_io_drop(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
||||||
|
int dumpfile_io_inject(struct dumpfile_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
||||||
void dumpfile_io_yield(struct dumpfile_io *handle, uint16_t thr_idx, uint64_t timeout_ms);
|
void dumpfile_io_yield(struct dumpfile_io *handle, uint16_t thr_idx, uint64_t timeout_ms);
|
||||||
struct io_stat *dumpfile_io_stat(struct dumpfile_io *handle, uint16_t thr_idx);
|
struct io_stat *dumpfile_io_stat(struct dumpfile_io *handle, uint16_t thr_idx);
|
||||||
|
|
||||||
|
|||||||
@@ -241,6 +241,46 @@ 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)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
int nr_inject = 0;
|
||||||
|
char *ptr;
|
||||||
|
struct packet *pkt;
|
||||||
|
marsio_buff_t *mbuff;
|
||||||
|
struct io_stat *stat = &handle->stat[thr_idx];
|
||||||
|
|
||||||
|
for (int i = 0; i < nr_pkts; i++)
|
||||||
|
{
|
||||||
|
pkt = &pkts[i];
|
||||||
|
len = packet_get_len(pkt);
|
||||||
|
|
||||||
|
if (marsio_buff_malloc_global(handle->mr_ins, &mbuff, 1, MARSIO_SOCKET_ID_ANY, MARSIO_LCORE_ID_ANY) < 0)
|
||||||
|
{
|
||||||
|
PACKET_IO_LOG_ERROR("unable to allocate marsio buffer for inject packet");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
stat->inject_pkts++;
|
||||||
|
stat->inject_bytes += len;
|
||||||
|
|
||||||
|
stat->raw_tx_pkts++;
|
||||||
|
stat->raw_tx_bytes += len;
|
||||||
|
|
||||||
|
stat->dev_tx_pkts++;
|
||||||
|
stat->dev_tx_bytes += len;
|
||||||
|
|
||||||
|
nr_inject++;
|
||||||
|
|
||||||
|
ptr = marsio_buff_append(mbuff, len);
|
||||||
|
memcpy(ptr, packet_get_data(pkt), len);
|
||||||
|
marsio_send_burst(handle->mr_path, thr_idx, &mbuff, 1);
|
||||||
|
packet_free(pkt);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nr_inject;
|
||||||
|
}
|
||||||
|
|
||||||
void marsio_io_yield(struct marsio_io *handle, uint16_t thr_idx, uint64_t timeout_ms)
|
void marsio_io_yield(struct marsio_io *handle, uint16_t thr_idx, uint64_t timeout_ms)
|
||||||
{
|
{
|
||||||
struct mr_vdev *vdevs[1] = {
|
struct mr_vdev *vdevs[1] = {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ int marsio_io_init(struct marsio_io *handle, uint16_t thr_idx);
|
|||||||
int marsio_io_ingress(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
int marsio_io_ingress(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, int nr_pkts);
|
void marsio_io_egress(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, int nr_pkts);
|
void marsio_io_drop(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
||||||
|
int marsio_io_inject(struct marsio_io *handle, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
||||||
void marsio_io_yield(struct marsio_io *handle, uint16_t thr_idx, uint64_t timeout_ms);
|
void marsio_io_yield(struct marsio_io *handle, uint16_t thr_idx, uint64_t timeout_ms);
|
||||||
struct io_stat *marsio_io_stat(struct marsio_io *handle, uint16_t thr_idx);
|
struct io_stat *marsio_io_stat(struct marsio_io *handle, uint16_t thr_idx);
|
||||||
|
|
||||||
|
|||||||
@@ -106,6 +106,18 @@ void packet_io_drop(struct packet_io *packet_io, uint16_t thr_idx, struct packet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int packet_io_inject(struct packet_io *packet_io, uint16_t thr_idx, struct packet *pkts, int nr_pkts)
|
||||||
|
{
|
||||||
|
if (likely(packet_io->mode == PACKET_IO_MARSIO))
|
||||||
|
{
|
||||||
|
return marsio_io_inject(packet_io->marsio, thr_idx, pkts, nr_pkts);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return dumpfile_io_inject(packet_io->dumpfile, thr_idx, pkts, nr_pkts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void packet_io_yield(struct packet_io *packet_io, uint16_t thr_idx, uint64_t timeout_ms)
|
void packet_io_yield(struct packet_io *packet_io, uint16_t thr_idx, uint64_t timeout_ms)
|
||||||
{
|
{
|
||||||
if (likely(packet_io->mode == PACKET_IO_MARSIO))
|
if (likely(packet_io->mode == PACKET_IO_MARSIO))
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ struct io_stat
|
|||||||
uint64_t raw_tx_pkts;
|
uint64_t raw_tx_pkts;
|
||||||
uint64_t raw_tx_bytes;
|
uint64_t raw_tx_bytes;
|
||||||
|
|
||||||
|
// inject packet
|
||||||
|
uint64_t inject_pkts;
|
||||||
|
uint64_t inject_bytes;
|
||||||
|
|
||||||
// ctrl packet
|
// ctrl packet
|
||||||
uint64_t ctrl_rx_pkts;
|
uint64_t ctrl_rx_pkts;
|
||||||
uint64_t ctrl_rx_bytes;
|
uint64_t ctrl_rx_bytes;
|
||||||
@@ -71,6 +75,7 @@ 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);
|
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_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);
|
void packet_io_drop(struct packet_io *packet_io, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
||||||
|
int packet_io_inject(struct packet_io *packet_io, uint16_t thr_idx, struct packet *pkts, int nr_pkts);
|
||||||
void packet_io_yield(struct packet_io *packet_io, uint16_t thr_idx, uint64_t timeout_ms);
|
void packet_io_yield(struct packet_io *packet_io, uint16_t thr_idx, uint64_t timeout_ms);
|
||||||
struct io_stat *packet_io_stat(struct packet_io *packet_io, uint16_t thr_idx);
|
struct io_stat *packet_io_stat(struct packet_io *packet_io, uint16_t thr_idx);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user