Add support for configurable number of loops through the input PCAP
file for the source port. Added an additional parameter to source
port CLI command.
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
"pipeline <pipeline_name> port in <port_id>\n"
" link <link_name> rxq <queue_id> bsz <burst_size>\n"
" ring <ring_name> bsz <burst_size>\n"
"pipeline <pipeline_name> port in <port_id>\n"
" link <link_name> rxq <queue_id> bsz <burst_size>\n"
" ring <ring_name> bsz <burst_size>\n"
-" | source <mempool_name> <file_name>\n"
+" | source <mempool_name> <file_name> loop <n_loops>\n"
" | tap <tap_name> mempool <mempool_name> mtu <mtu> bsz <burst_size>\n";
static void
" | tap <tap_name> mempool <mempool_name> mtu <mtu> bsz <burst_size>\n";
static void
struct rte_swx_port_source_params params;
struct mempool *mp;
struct rte_swx_port_source_params params;
struct mempool *mp;
- if (n_tokens < t0 + 3) {
+ if (n_tokens < t0 + 5) {
snprintf(out, out_size, MSG_ARG_MISMATCH,
"pipeline port in source");
return;
snprintf(out, out_size, MSG_ARG_MISMATCH,
"pipeline port in source");
return;
params.file_name = tokens[t0 + 2];
params.file_name = tokens[t0 + 2];
+ if (strcmp(tokens[t0 + 3], "loop") != 0) {
+ snprintf(out, out_size, MSG_ARG_NOT_FOUND, "loop");
+ return;
+ }
+
+ if (parser_read_uint64(¶ms.n_loops, tokens[t0 + 4])) {
+ snprintf(out, out_size, MSG_ARG_INVALID,
+ "n_loops");
+ return;
+ }
+
+ t0 += 5;
status = rte_swx_pipeline_port_in_config(p->p,
port_id,
status = rte_swx_pipeline_port_in_config(p->p,
port_id,
pipeline PIPELINE0 create 0
pipeline PIPELINE0 create 0
-pipeline PIPELINE0 port in 0 source MEMPOOL0 ./examples/packet.pcap
-pipeline PIPELINE0 port in 1 source MEMPOOL0 ./examples/packet.pcap
-pipeline PIPELINE0 port in 2 source MEMPOOL0 ./examples/packet.pcap
-pipeline PIPELINE0 port in 3 source MEMPOOL0 ./examples/packet.pcap
+pipeline PIPELINE0 port in 0 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
+pipeline PIPELINE0 port in 1 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
+pipeline PIPELINE0 port in 2 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
+pipeline PIPELINE0 port in 3 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
pipeline PIPELINE0 port out 0 sink none
pipeline PIPELINE0 port out 1 sink none
pipeline PIPELINE0 port out 2 sink none
pipeline PIPELINE0 port out 3 sink none
pipeline PIPELINE0 port out 0 sink none
pipeline PIPELINE0 port out 1 sink none
pipeline PIPELINE0 port out 2 sink none
pipeline PIPELINE0 port out 3 sink none
-pipeline PIPELINE0 build ./examples/l2fwd_macswp.spec
+pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd_macswp.spec
thread 1 pipeline PIPELINE0 enable
thread 1 pipeline PIPELINE0 enable
pipeline PIPELINE0 create 0
pipeline PIPELINE0 create 0
-pipeline PIPELINE0 port in 0 source MEMPOOL0 ./examples/packet.pcap
-pipeline PIPELINE0 port in 1 source MEMPOOL0 ./examples/packet.pcap
-pipeline PIPELINE0 port in 2 source MEMPOOL0 ./examples/packet.pcap
-pipeline PIPELINE0 port in 3 source MEMPOOL0 ./examples/packet.pcap
+pipeline PIPELINE0 port in 0 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
+pipeline PIPELINE0 port in 1 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
+pipeline PIPELINE0 port in 2 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
+pipeline PIPELINE0 port in 3 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
pipeline PIPELINE0 port out 0 sink none
pipeline PIPELINE0 port out 1 sink none
pipeline PIPELINE0 port out 2 sink none
pipeline PIPELINE0 port out 3 sink none
pipeline PIPELINE0 port out 0 sink none
pipeline PIPELINE0 port out 1 sink none
pipeline PIPELINE0 port out 2 sink none
pipeline PIPELINE0 port out 3 sink none
-pipeline PIPELINE0 build ./examples/l2fwd.spec
+pipeline PIPELINE0 build ./examples/pipeline/examples/l2fwd.spec
thread 1 pipeline PIPELINE0 enable
thread 1 pipeline PIPELINE0 enable
pipeline PIPELINE0 create 0
pipeline PIPELINE0 create 0
-pipeline PIPELINE0 port in 0 source MEMPOOL0 ./examples/packet.pcap
-pipeline PIPELINE0 port in 1 source MEMPOOL0 ./examples/packet.pcap
-pipeline PIPELINE0 port in 2 source MEMPOOL0 ./examples/packet.pcap
-pipeline PIPELINE0 port in 3 source MEMPOOL0 ./examples/packet.pcap
+pipeline PIPELINE0 port in 0 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
+pipeline PIPELINE0 port in 1 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
+pipeline PIPELINE0 port in 2 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
+pipeline PIPELINE0 port in 3 source MEMPOOL0 ./examples/pipeline/examples/packet.pcap loop 1
pipeline PIPELINE0 port out 0 sink none
pipeline PIPELINE0 port out 1 sink none
pipeline PIPELINE0 port out 0 sink none
pipeline PIPELINE0 port out 1 sink none
pipeline PIPELINE0 port out 3 sink none
pipeline PIPELINE0 port out 4 sink none
pipeline PIPELINE0 port out 3 sink none
pipeline PIPELINE0 port out 4 sink none
-pipeline PIPELINE0 build ./examples/vxlan.spec
-pipeline PIPELINE0 table vxlan_table add ./examples/vxlan_table.txt
+pipeline PIPELINE0 build ./examples/pipeline/examples/vxlan.spec
+pipeline PIPELINE0 table vxlan_table add ./examples/pipeline/examples/vxlan_table.txt
pipeline PIPELINE0 commit
thread 1 pipeline PIPELINE0 enable
pipeline PIPELINE0 commit
thread 1 pipeline PIPELINE0 enable
struct source {
struct {
struct rte_mempool *pool;
struct source {
struct {
struct rte_mempool *pool;
} params;
struct rte_swx_port_in_stats stats;
struct rte_mbuf **pkts;
} params;
struct rte_swx_port_in_stats stats;
struct rte_mbuf **pkts;
/* Initialization. */
p->params.pool = params->pool;
/* Initialization. */
p->params.pool = params->pool;
+ p->params.n_loops = params->n_loops ? params->n_loops : UINT64_MAX;
+
/* PCAP file. */
for (i = 0; i < n_pkts_max; i++) {
struct pcap_pkthdr pcap_pkthdr;
/* PCAP file. */
for (i = 0; i < n_pkts_max; i++) {
struct pcap_pkthdr pcap_pkthdr;
struct rte_mbuf *m_dst, *m_src;
uint8_t *m_dst_data, *m_src_data;
struct rte_mbuf *m_dst, *m_src;
uint8_t *m_dst_data, *m_src_data;
+ if (!p->params.n_loops)
+ return 0;
/* m_src identification. */
m_src = p->pkts[p->pos];
m_src_data = rte_pktmbuf_mtod(m_src, uint8_t *);
/* m_src identification. */
m_src = p->pkts[p->pos];
m_src_data = rte_pktmbuf_mtod(m_src, uint8_t *);
/* m_src next. */
p->pos++;
/* m_src next. */
p->pos++;
- if (p->pos == p->n_pkts)
+ if (p->pos == p->n_pkts) {
+ p->params.n_loops--;
+ }
/** Name of a valid PCAP file to read the input packets from. */
const char *file_name;
/** Name of a valid PCAP file to read the input packets from. */
const char *file_name;
+ /** Number of times to loop through the input PCAP file.
+ * Loop infinite times when set to 0.
+ */
+ uint64_t n_loops;
+
/** Maximum number of packets to read from the PCAP file. When 0, it is
* internally set to RTE_SWX_PORT_SOURCE_PKTS_MAX. Once read from the
* PCAP file, the same packets are looped forever.
/** Maximum number of packets to read from the PCAP file. When 0, it is
* internally set to RTE_SWX_PORT_SOURCE_PKTS_MAX. Once read from the
* PCAP file, the same packets are looped forever.