summaryrefslogtreecommitdiffstats
path: root/VNFs
diff options
context:
space:
mode:
authorXavier Simonart <simonartxavier@gmail.com>2021-11-03 16:46:47 +0000
committerXavier Simonart <simonartxavier@gmail.com>2021-12-20 12:41:52 +0000
commitd08d92ed360dab327b786fd251224f763dc0a5ac (patch)
tree287e89ee8642762657c9ae72d9c96a5fe9cc15fb /VNFs
parentb8f652cf6bd2e8b241a02cb2e455086979abbe15 (diff)
store packet id in gen and swap
Support configuration option for specifying number of packets which we will store (gen and swap). Packets are stored runtime in a buffer and written to disk at exit. Signed-off-by: Xavier Simonart <simonartxavier@gmail.com> Change-Id: Iab1c9c13048b6919f77392953675cb8c48aad8e4
Diffstat (limited to 'VNFs')
-rw-r--r--VNFs/DPPD-PROX/handle_gen.c61
-rw-r--r--VNFs/DPPD-PROX/handle_swap.c56
-rw-r--r--VNFs/DPPD-PROX/prox_args.c2
-rw-r--r--VNFs/DPPD-PROX/task_init.h1
4 files changed, 119 insertions, 1 deletions
diff --git a/VNFs/DPPD-PROX/handle_gen.c b/VNFs/DPPD-PROX/handle_gen.c
index 77e9acad..363ee17d 100644
--- a/VNFs/DPPD-PROX/handle_gen.c
+++ b/VNFs/DPPD-PROX/handle_gen.c
@@ -57,6 +57,13 @@ struct pkt_template {
uint8_t *buf;
};
+#define MAX_STORE_PKT_SIZE 2048
+
+struct packet {
+ unsigned int len;
+ unsigned char buf[MAX_STORE_PKT_SIZE];
+};
+
#define IP4(x) x & 0xff, (x >> 8) & 0xff, (x >> 16) & 0xff, x >> 24
#define DO_PANIC 1
@@ -140,6 +147,10 @@ struct task_gen {
uint32_t imix_pkt_sizes[MAX_IMIX_PKTS];
uint32_t imix_nb_pkts;
uint32_t new_imix_nb_pkts;
+ uint32_t store_pkt_id;
+ uint32_t store_msk;
+ struct packet *store_buf;
+ FILE *fp;
} __rte_cache_aligned;
static void task_gen_set_pkt_templates_len(struct task_gen *task, uint32_t *pkt_sizes);
@@ -984,6 +995,17 @@ static int handle_gen_bulk(struct task_base *tbase, struct rte_mbuf **mbufs, uin
tsc_before_tx = task_gen_write_latency(task, pkt_hdr, send_bulk);
task_gen_checksum_packets(task, new_pkts, pkt_hdr, send_bulk);
+ if (task->store_msk) {
+ for (uint32_t i = 0; i < send_bulk; i++) {
+ if (out[i] != OUT_DISCARD) {
+ uint8_t *hdr;
+ hdr = (uint8_t *)rte_pktmbuf_mtod(new_pkts[i], prox_rte_ether_hdr *);
+ memcpy(&task->store_buf[task->store_pkt_id & task->store_msk].buf, hdr, rte_pktmbuf_pkt_len(new_pkts[i]));
+ task->store_buf[task->store_pkt_id & task->store_msk].len = rte_pktmbuf_pkt_len(new_pkts[i]);
+ task->store_pkt_id++;
+ }
+ }
+ }
ret = task->base.tx_pkt(&task->base, new_pkts, send_bulk, out);
task_gen_store_accuracy(task, send_bulk, tsc_before_tx);
@@ -1529,6 +1551,31 @@ static void start(struct task_base *tbase)
*/
}
+static void stop_gen(struct task_base *tbase)
+{
+ uint32_t i, j;
+ struct task_gen *task = (struct task_gen *)tbase;
+ if (task->store_msk) {
+ for (i = task->store_pkt_id & task->store_msk; i < task->store_msk + 1; i++) {
+ if (task->store_buf[i].len) {
+ fprintf(task->fp, "%06d: ", i);
+ for (j = 0; j < task->store_buf[i].len; j++) {
+ fprintf(task->fp, "%02x ", task->store_buf[i].buf[j]);
+ }
+ fprintf(task->fp, "\n");
+ }
+ }
+ for (i = 0; i < (task->store_pkt_id & task->store_msk); i++) {
+ if (task->store_buf[i].len) {
+ fprintf(task->fp, "%06d: ", i);
+ for (j = 0; j < task->store_buf[i].len; j++) {
+ fprintf(task->fp, "%02x ", task->store_buf[i].buf[j]);
+ }
+ fprintf(task->fp, "\n");
+ }
+ }
+ }
+}
static void start_pcap(struct task_base *tbase)
{
struct task_gen_pcap *task = (struct task_gen_pcap *)tbase;
@@ -1656,6 +1703,17 @@ static void init_task_gen(struct task_base *tbase, struct task_args *targ)
for (uint32_t i = 0; i < targ->n_ranges; ++i) {
PROX_PANIC(task_gen_add_range(tbase, &targ->range[i]), "Failed to add range\n");
}
+ if (targ->store_max) {
+ char filename[256];
+ sprintf(filename, "gen_buf_%02d_%02d", targ->lconf->id, targ->task);
+
+ task->store_msk = targ->store_max - 1;
+ task->store_buf = (struct packet *)malloc(sizeof(struct packet) * targ->store_max);
+ task->fp = fopen(filename, "w+");
+ PROX_PANIC(task->fp == NULL, "Unable to open %s\n", filename);
+ } else {
+ task->store_msk = 0;
+ }
}
static struct task_init task_init_gen = {
@@ -1671,7 +1729,8 @@ static struct task_init task_init_gen = {
#else
.flag_features = TASK_FEATURE_NEVER_DISCARDS | TASK_FEATURE_NO_RX,
#endif
- .size = sizeof(struct task_gen)
+ .size = sizeof(struct task_gen),
+ .stop_last = stop_gen
};
static struct task_init task_init_gen_l3 = {
diff --git a/VNFs/DPPD-PROX/handle_swap.c b/VNFs/DPPD-PROX/handle_swap.c
index 06bbc6de..381e56de 100644
--- a/VNFs/DPPD-PROX/handle_swap.c
+++ b/VNFs/DPPD-PROX/handle_swap.c
@@ -32,6 +32,13 @@
#include "prox_cksum.h"
#include "prox_compat.h"
+#define MAX_STORE_PKT_SIZE 2048
+
+struct packet {
+ unsigned int len;
+ unsigned char buf[MAX_STORE_PKT_SIZE];
+};
+
struct task_swap {
struct task_base base;
struct rte_mempool *igmp_pool;
@@ -44,6 +51,10 @@ struct task_swap {
uint64_t last_echo_rep_rcvd_tsc;
uint32_t n_echo_req;
uint32_t n_echo_rep;
+ uint32_t store_pkt_id;
+ uint32_t store_msk;
+ struct packet *store_buf;
+ FILE *fp;
};
#define NB_IGMP_MBUF 1024
@@ -136,11 +147,34 @@ static inline void build_igmp_message(struct task_base *tbase, struct rte_mbuf *
static void stop_swap(struct task_base *tbase)
{
+ uint32_t i, j;
struct task_swap *task = (struct task_swap *)tbase;
+
if (task->igmp_pool) {
rte_mempool_free(task->igmp_pool);
task->igmp_pool = NULL;
}
+
+ if (task->store_msk) {
+ for (i = task->store_pkt_id & task->store_msk; i < task->store_msk + 1; i++) {
+ if (task->store_buf[i].len) {
+ fprintf(task->fp, "%06d: ", i);
+ for (j = 0; j < task->store_buf[i].len; j++) {
+ fprintf(task->fp, "%02x ", task->store_buf[i].buf[j]);
+ }
+ fprintf(task->fp, "\n");
+ }
+ }
+ for (i = 0; i < (task->store_pkt_id & task->store_msk); i++) {
+ if (task->store_buf[i].len) {
+ fprintf(task->fp, "%06d: ", i);
+ for (j = 0; j < task->store_buf[i].len; j++) {
+ fprintf(task->fp, "%02x ", task->store_buf[i].buf[j]);
+ }
+ fprintf(task->fp, "\n");
+ }
+ }
+ }
}
static void handle_ipv6(struct task_swap *task, struct rte_mbuf *mbufs, prox_rte_ipv6_hdr *ipv6_hdr, uint8_t *out)
@@ -417,6 +451,16 @@ static int handle_swap_bulk(struct task_base *tbase, struct rte_mbuf **mbufs, ui
continue;
}
}
+ if (task->store_msk) {
+ for (int i = 0; i < n_pkts; i++) {
+ if (out[i] != OUT_DISCARD) {
+ hdr = rte_pktmbuf_mtod(mbufs[i], prox_rte_ether_hdr *);
+ memcpy(&task->store_buf[task->store_pkt_id & task->store_msk].buf, hdr, rte_pktmbuf_pkt_len(mbufs[i]));
+ task->store_buf[task->store_pkt_id & task->store_msk].len = rte_pktmbuf_pkt_len(mbufs[i]);
+ task->store_pkt_id++;
+ }
+ }
+ }
return task->base.tx_pkt(&task->base, mbufs, n_pkts, out);
}
@@ -516,6 +560,18 @@ static void init_task_swap(struct task_base *tbase, struct task_args *targ)
if (port) {
task->offload_crc = port->requested_tx_offload & (DEV_TX_OFFLOAD_IPV4_CKSUM | DEV_TX_OFFLOAD_UDP_CKSUM);
}
+ task->store_pkt_id = 0;
+ if (targ->store_max) {
+ char filename[256];
+ sprintf(filename, "swap_buf_%02d_%02d", targ->lconf->id, targ->task);
+
+ task->store_msk = targ->store_max - 1;
+ task->store_buf = (struct packet *)malloc(sizeof(struct packet) * targ->store_max);
+ task->fp = fopen(filename, "w+");
+ PROX_PANIC(task->fp == NULL, "Unable to open %s\n", filename);
+ } else {
+ task->store_msk = 0;
+ }
}
static struct task_init task_init_swap = {
diff --git a/VNFs/DPPD-PROX/prox_args.c b/VNFs/DPPD-PROX/prox_args.c
index d7c436d6..c092e879 100644
--- a/VNFs/DPPD-PROX/prox_args.c
+++ b/VNFs/DPPD-PROX/prox_args.c
@@ -1599,6 +1599,8 @@ static int get_core_cfg(unsigned sindex, char *str, void *data)
return parse_int(&targ->arp_ndp_retransmit_timeout, pkey);
if (STR_EQ(str, "number of packets"))
return parse_int(&targ->n_pkts, pkey);
+ if (STR_EQ(str, "store size"))
+ return parse_int(&targ->store_max, pkey);
if (STR_EQ(str, "pipes")) {
uint32_t val;
int err = parse_int(&val, pkey);
diff --git a/VNFs/DPPD-PROX/task_init.h b/VNFs/DPPD-PROX/task_init.h
index 6a14aae0..ec7b8e83 100644
--- a/VNFs/DPPD-PROX/task_init.h
+++ b/VNFs/DPPD-PROX/task_init.h
@@ -258,6 +258,7 @@ struct task_args {
uint32_t imix_pkt_sizes[MAX_IMIX_PKTS];
uint32_t multiplier;
uint32_t mirror_size;
+ uint32_t store_max;
};
/* Return the first port that is reachable through the task. If the