Skip to contentSkip to conversation

app/testpmd: add l3fwd mode to testpmd

RFC In review Kathleen Capella 4 participants 5 messages Apr 30, 2021 – Aug 24, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover app/testpmd: add l3fwd mode to testpmd

Performance of the LPM mode in L3fwd example application is used as an industry standard to compare between various platforms.

Unfortunately, L3fwd example application lacks debugging capabilities to understand the performance bottlenecks and fix them.

While debugging performance issues we need all the flexibility possible. Some of the capabilities we have used are:
1) ability to print hardware and software statistics - xstats, stats at port/queue level, burst stats to identify any headroom available, CPU cycles/packet etc
2) ability to modify all possible configurable parameters for the PMD as well as the application at run time without recompiling the code. Some of the parameters we have used are RX/TX queue depths, burst size, number of receive queues, PMD specific parameters etc. This configurability at runtime helps to understand and debug L3fwd performance issues quickly and effectively.

It is possible to add all these capabilities to L3fwd example application. However, doing that we will result in L3fwd example application losing its purpose (of being a sample application). At the same time, testpmd application has all these capabilities to debug an application. In my opinion it makes sense to add L3fwd mode to testpmd.

This patch adds l3fwd mode into testpmd to take advantage of the existing infrastructure in testpmd.

I'd like to hear from the community if the structure of this change makes sense, namely, adding l3fwd as a separate fwd_engine into testpmd.

This feature is not yet implemeted for SSE or AltiVec.

Kathleen Capella (1):
app/testpmd: add l3fwd mode to testpmd

 app/test-pmd/config.c         |  66 +++++++
 app/test-pmd/l3fwd.c          | 356 ++++++++++++++++++++++++++++++++++
 app/test-pmd/l3fwd.h          | 143 ++++++++++++++
 app/test-pmd/l3fwd_common.h   | 268 +++++++++++++++++++++++++
 app/test-pmd/l3fwd_lpm.h      | 107 ++++++++++
 app/test-pmd/l3fwd_lpm_neon.h | 169 ++++++++++++++++
 app/test-pmd/l3fwd_neon.h     | 234 ++++++++++++++++++++++
 app/test-pmd/meson.build      |   3 +-
 app/test-pmd/testpmd.c        |   4 +-
 app/test-pmd/testpmd.h        |  20 ++
 10 files changed, 1368 insertions(+), 2 deletions(-)
 create mode 100644 app/test-pmd/l3fwd.c
 create mode 100644 app/test-pmd/l3fwd.h
 create mode 100644 app/test-pmd/l3fwd_common.h
 create mode 100644 app/test-pmd/l3fwd_lpm.h
 create mode 100644 app/test-pmd/l3fwd_lpm_neon.h
 create mode 100644 app/test-pmd/l3fwd_neon.h
Signature · 1 line
2.25.1
#1 lore raw

RFC 1/1 app/testpmd: add l3fwd mode to testpmd

Add l3fwd mode to testpmd to speed up debugging and performance analysis. Implement LPM lookup for single NUMA socket only.

---
 app/test-pmd/config.c         |  66 +++++++
 app/test-pmd/l3fwd.c          | 356 ++++++++++++++++++++++++++++++++++
 app/test-pmd/l3fwd.h          | 143 ++++++++++++++
 app/test-pmd/l3fwd_common.h   | 268 +++++++++++++++++++++++++
 app/test-pmd/l3fwd_lpm.h      | 107 ++++++++++
 app/test-pmd/l3fwd_lpm_neon.h | 169 ++++++++++++++++
 app/test-pmd/l3fwd_neon.h     | 234 ++++++++++++++++++++++
 app/test-pmd/meson.build      |   3 +-
 app/test-pmd/testpmd.c        |   4 +-
 app/test-pmd/testpmd.h        |  20 ++
 10 files changed, 1368 insertions(+), 2 deletions(-)
 create mode 100644 app/test-pmd/l3fwd.c
 create mode 100644 app/test-pmd/l3fwd.h
 create mode 100644 app/test-pmd/l3fwd_common.h
 create mode 100644 app/test-pmd/l3fwd_lpm.h
 create mode 100644 app/test-pmd/l3fwd_lpm_neon.h
 create mode 100644 app/test-pmd/l3fwd_neon.h
app/test-pmd/config.c +66 -0
index e189062ef..6ea742fda 100644
@@ -65,6 +65,9 @@
 
 #define NS_PER_SEC 1E9
 
+/* Used in l3 fwd mode to ensure only one lookup table is created per socket */
+static uint8_t lkp_per_socket[NB_SOCKETS];
+
 static char *flowtype_to_str(uint16_t flow_type);
 
 static const struct {
@@ -2947,6 +2950,9 @@ simple_fwd_config_setup(void)
 			(lcoreid_t) cur_fwd_config.nb_fwd_ports;
 	setup_fwd_config_of_each_lcore(&cur_fwd_config);
 
+	printf("nb_fwd_ports: %d\n", cur_fwd_config.nb_fwd_ports);
+	printf("nb_fwd_streams: %d\n", cur_fwd_config.nb_fwd_streams);
+
 	for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) {
 		fwd_streams[i]->rx_port   = fwd_ports_ids[i];
 		fwd_streams[i]->rx_queue  = 0;
@@ -3151,6 +3157,61 @@ icmp_echo_config_setup(void)
 	}
 }
 
+static void
+l3_fwd_config_setup(void)
+{
+	portid_t rxp;
+	queueid_t rxq;
+	queueid_t nb_q;
+	streamid_t sm_id;
+	int socketid = 0;
+
+	nb_q = nb_rxq;
+	if (nb_q > nb_txq)
+		nb_q = nb_txq;
+
+	cur_fwd_config.nb_fwd_lcores = (lcoreid_t) nb_fwd_lcores;
+	cur_fwd_config.nb_fwd_ports = (portid_t) nb_fwd_ports;
+	cur_fwd_config.nb_fwd_streams =
+		(streamid_t) (nb_q * cur_fwd_config.nb_fwd_ports);
+
+	/*TODO check if want this behavior */
+	if (cur_fwd_config.nb_fwd_streams < cur_fwd_config.nb_fwd_lcores)
+		cur_fwd_config.nb_fwd_lcores =
+			(lcoreid_t)cur_fwd_config.nb_fwd_streams;
+
+	/* reinitialize forwarding streams */
+	init_fwd_streams();
+
+	setup_fwd_config_of_each_lcore(&cur_fwd_config);
+	rxp = 0; rxq = 0;
+	for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) {
+		struct fwd_stream *fs;
+
+		fs = fwd_streams[sm_id];
+		fs->rx_port   = fwd_ports_ids[rxp];
+		fs->rx_queue  = rxq;
+		fs->tx_queue  = rxq;
+		fs->retry_enabled = retry_enabled;
+		fs->drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /
+			US_PER_S * BURST_TX_DRAIN_US;
+		fs->cur_tsc = rte_rdtsc();
+		fs->prev_tsc = fs->cur_tsc;
+		rxp++;
+		if (rxp < nb_fwd_ports)
+			continue;
+		rxp = 0;
+		rxq++;
+	}
+
+	/*Set up lpm table */
+	/*TODO  Making the assumption that there is one socket*/
+	if (!lkp_per_socket[socketid]) {
+		setup_lpm(socketid);
+		lkp_per_socket[socketid] = 1;
+	}
+}
+
 void
 fwd_config_setup(void)
 {
@@ -3160,6 +3221,11 @@ fwd_config_setup(void)
 		return;
 	}
 
+	if (strcmp(cur_fwd_eng->fwd_mode_name, "l3") == 0) {
+		l3_fwd_config_setup();
+		return;
+	}
+
 	if ((nb_rxq > 1) && (nb_txq > 1)){
 		if (dcb_config)
 			dcb_fwd_config_setup();
app/test-pmd/l3fwd.c new file +356 -0

356 lines not on this page · raw message

app/test-pmd/l3fwd.h new file +143 -0

143 lines not on this page · raw message

app/test-pmd/l3fwd_common.h new file +268 -0

268 lines not on this page · raw message

app/test-pmd/l3fwd_lpm.h new file +107 -0

107 lines not on this page · raw message

app/test-pmd/l3fwd_lpm_neon.h new file +169 -0

169 lines not on this page · raw message

app/test-pmd/l3fwd_neon.h new file +234 -0

234 lines not on this page · raw message

app/test-pmd/meson.build +2 -1
index 98f3289bd..933738e62 100644
@@ -16,6 +16,7 @@ sources = files(
         'icmpecho.c',
         'ieee1588fwd.c',
         'iofwd.c',
+	'l3fwd.c',
         'macfwd.c',
         'macswap.c',
         'noisy_vnf.c',
@@ -26,7 +27,7 @@ sources = files(
         'util.c',
 )
 
-deps += ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci']
+deps += ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci', 'lpm']
 if dpdk_conf.has('RTE_LIB_BITRATESTATS')
     deps += 'bitratestats'
 endif
app/test-pmd/testpmd.c +3 -1
index d4be23f8f..d9c614dd6 100644
@@ -172,6 +172,7 @@ streamid_t nb_fwd_streams;       /**< Is equal to (nb_ports * nb_rxq). */
 struct fwd_engine * fwd_engines[] = {
 	&io_fwd_engine,
 	&mac_fwd_engine,
+	&l3_fwd_engine,
 	&mac_swap_engine,
 	&flow_gen_engine,
 	&rx_only_engine,
@@ -2116,6 +2117,7 @@ launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore)
 	int diag;
 
 	port_fwd_begin = cur_fwd_config.fwd_eng->port_fwd_begin;
+
 	if (port_fwd_begin != NULL) {
 		for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++)
 			(*port_fwd_begin)(fwd_ports_ids[i]);
@@ -2132,7 +2134,6 @@ launch_packet_forwarding(lcore_function_t *pkt_fwd_on_lcore)
 		}
 	}
 }
-
 /*
  * Launch packet forwarding configuration.
  */
@@ -2212,6 +2213,7 @@ start_packet_forwarding(int with_tx_first)
 				(*port_fwd_end)(fwd_ports_ids[i]);
 		}
 	}
+
 	launch_packet_forwarding(start_pkt_forward_on_core);
 }
 
app/test-pmd/testpmd.h +20 -0
index 6ca872db8..80c014276 100644
@@ -24,6 +24,9 @@
 #define RTE_PORT_CLOSED         (uint16_t)2
 #define RTE_PORT_HANDLING       (uint16_t)3
 
+#define NB_SOCKETS	8
+#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us in l3 mode*/
+
 /*
  * It is used to allocate the memory for hash key.
  * The hash key size is NIC dependent.
@@ -115,6 +118,12 @@ extern const struct rss_type_info rss_type_table[];
  */
 extern char dynf_names[64][RTE_MBUF_DYN_NAMESIZE];
 
+/*Used for buffering tx packets to send in a burst in l3 fwd mode */
+struct mbuf_table {
+	uint16_t len;
+	struct rte_mbuf *m_table[MAX_PKT_BURST];
+};
+
 /**
  * The data structure associated with a forwarding stream between a receive
  * port/queue and a transmit port/queue.
@@ -143,6 +152,13 @@ struct fwd_stream {
 	uint64_t     core_cycles; /**< used for RX and TX processing */
 	struct pkt_burst_stats rx_burst_stats;
 	struct pkt_burst_stats tx_burst_stats;
+
+	/* l3 fwd mode data */
+	struct mbuf_table tx_mbufs[RTE_MAX_ETHPORTS];
+	/**< Table for buffering packets before sending in a burst in l3 mode */
+	uint64_t prev_tsc; /**< timestamp of previous iteration of fwding loop */
+	uint64_t cur_tsc; /**< timestamp of current iteration of fwding loop */
+	uint64_t drain_tsc; /**< timeout for draining tx queue */
 };
 
 /**
@@ -286,6 +302,7 @@ extern uint32_t burst_tx_retry_num;
 
 extern struct fwd_engine io_fwd_engine;
 extern struct fwd_engine mac_fwd_engine;
+extern struct fwd_engine l3_fwd_engine;
 extern struct fwd_engine mac_swap_engine;
 extern struct fwd_engine flow_gen_engine;
 extern struct fwd_engine rx_only_engine;
@@ -1014,6 +1031,9 @@ void add_tx_dynf_callback(portid_t portid);
 void remove_tx_dynf_callback(portid_t portid);
 int update_jumbo_frame_offload(portid_t portid);
 
+/*Functions for l3 forwarding*/
+void setup_lpm(const int socketid);
+
 /*
  * Work-around of a compilation error with ICC on invocations of the
  * rte_be_to_cpu_16() function.
Signature · 1 line
2.25.1
#2 lore raw
In reply to Kathleen Capella

@Xiaoyun could you share your thoughts on it?

As far as I remember there is no agreement on the topic. Adding more people in Cc.

Quoted 53 lines · Kathleen Capella

Performance of the LPM mode in L3fwd example application is used as an industry standard to compare between various platforms.

Unfortunately, L3fwd example application lacks debugging capabilities to understand the performance bottlenecks and fix them.

While debugging performance issues we need all the flexibility possible. Some of the capabilities we have used are:
1) ability to print hardware and software statistics - xstats, stats at port/queue level, burst stats to identify any headroom available, CPU cycles/packet etc
2) ability to modify all possible configurable parameters for the PMD as well as the application at run time without recompiling the code. Some of the parameters we have used are RX/TX queue depths, burst size, number of receive queues, PMD specific parameters etc. This configurability at runtime helps to understand and debug L3fwd performance issues quickly and effectively.

It is possible to add all these capabilities to L3fwd example application. However, doing that we will result in L3fwd example application losing its purpose (of being a sample application). At the same time, testpmd application has all these capabilities to debug an application. In my opinion it makes sense to add L3fwd mode to testpmd.

This patch adds l3fwd mode into testpmd to take advantage of the existing infrastructure in testpmd.

I'd like to hear from the community if the structure of this change makes sense, namely, adding l3fwd as a separate fwd_engine into testpmd.

This feature is not yet implemeted for SSE or AltiVec.

Kathleen Capella (1):
app/testpmd: add l3fwd mode to testpmd

 app/test-pmd/config.c         |  66 +++++++
 app/test-pmd/l3fwd.c          | 356 ++++++++++++++++++++++++++++++++++
 app/test-pmd/l3fwd.h          | 143 ++++++++++++++
 app/test-pmd/l3fwd_common.h   | 268 +++++++++++++++++++++++++
 app/test-pmd/l3fwd_lpm.h      | 107 ++++++++++
 app/test-pmd/l3fwd_lpm_neon.h | 169 ++++++++++++++++
 app/test-pmd/l3fwd_neon.h     | 234 ++++++++++++++++++++++
 app/test-pmd/meson.build      |   3 +-
 app/test-pmd/testpmd.c        |   4 +-
 app/test-pmd/testpmd.h        |  20 ++
 10 files changed, 1368 insertions(+), 2 deletions(-)
 create mode 100644 app/test-pmd/l3fwd.c
 create mode 100644 app/test-pmd/l3fwd.h
 create mode 100644 app/test-pmd/l3fwd_common.h
 create mode 100644 app/test-pmd/l3fwd_lpm.h
 create mode 100644 app/test-pmd/l3fwd_lpm_neon.h
 create mode 100644 app/test-pmd/l3fwd_neon.h
#3 lore raw
Quoted 5 lines · Andrew Rybchenko

@Xiaoyun could you share your thoughts on it?

As far as I remember there is no agreement on the topic. Adding more people in Cc.

I was OK for adding simple l3fwd forwarding engine to testpmd, to benefit from configuration/debugging/measurement benefits testpmd brings as patch mentions.

But adding neon will likely bring other architecture specific implementations, and there will be more code duplicates, which is not good.
Also it is possible that people may want to add more lookup methods (em, fib..) making things worse.

If we get the feature, what about limiting it to scalar implementation and LPM? Still it is questionable to have the feature in the testpmd, but at least we limit the scope.
For performance measurements can use the l3fwd sample application.

Another point is testing, this feature should come with dts updates to test testpmd l3fwd, otherwise it may not be tested and turn into dead code easily.

Quoted 55 lines · Kathleen Capella
Quoted 53 lines

Performance of the LPM mode in L3fwd example application is used as an industry standard to compare between various platforms.

Unfortunately, L3fwd example application lacks debugging capabilities to understand the performance bottlenecks and fix them.

While debugging performance issues we need all the flexibility possible. Some of the capabilities we have used are:
1) ability to print hardware and software statistics - xstats, stats at port/queue level, burst stats to identify any headroom available, CPU cycles/packet etc
2) ability to modify all possible configurable parameters for the PMD as well as the application at run time without recompiling the code. Some of the parameters we have used are RX/TX queue depths, burst size, number of receive queues, PMD specific parameters etc. This configurability at runtime helps to understand and debug L3fwd performance issues quickly and effectively.

It is possible to add all these capabilities to L3fwd example application. However, doing that we will result in L3fwd example application losing its purpose (of being a sample application). At the same time, testpmd application has all these capabilities to debug an application. In my opinion it makes sense to add L3fwd mode to testpmd.

This patch adds l3fwd mode into testpmd to take advantage of the existing infrastructure in testpmd.

I'd like to hear from the community if the structure of this change makes sense, namely, adding l3fwd as a separate fwd_engine into testpmd.

This feature is not yet implemeted for SSE or AltiVec.

Kathleen Capella (1):
app/testpmd: add l3fwd mode to testpmd

 app/test-pmd/config.c         |  66 +++++++
 app/test-pmd/l3fwd.c          | 356 ++++++++++++++++++++++++++++++++++
 app/test-pmd/l3fwd.h          | 143 ++++++++++++++
 app/test-pmd/l3fwd_common.h   | 268 +++++++++++++++++++++++++
 app/test-pmd/l3fwd_lpm.h      | 107 ++++++++++
 app/test-pmd/l3fwd_lpm_neon.h | 169 ++++++++++++++++
 app/test-pmd/l3fwd_neon.h     | 234 ++++++++++++++++++++++
 app/test-pmd/meson.build      |   3 +-
 app/test-pmd/testpmd.c        |   4 +-
 app/test-pmd/testpmd.h        |  20 ++
 10 files changed, 1368 insertions(+), 2 deletions(-)
 create mode 100644 app/test-pmd/l3fwd.c
 create mode 100644 app/test-pmd/l3fwd.h
 create mode 100644 app/test-pmd/l3fwd_common.h
 create mode 100644 app/test-pmd/l3fwd_lpm.h
 create mode 100644 app/test-pmd/l3fwd_lpm_neon.h
 create mode 100644 app/test-pmd/l3fwd_neon.h
#4 lore raw

<snip>

Quoted 8 lines · Andrew Rybchenko
Quoted 5 lines

@Xiaoyun could you share your thoughts on it?

As far as I remember there is no agreement on the topic. Adding more people in Cc.

Quoted 8 lines

I was OK for adding simple l3fwd forwarding engine to testpmd, to benefit from configuration/debugging/measurement benefits testpmd brings as patch mentions.

But adding neon will likely bring other architecture specific implementations, and there will be more code duplicates, which is not good.
Also it is possible that people may want to add more lookup methods (em, fib..) making things worse.

The main goal we are trying to address is the ability to debugging the performance issues of the L3fwd application. As far as I know, the marketing folks care about LPM (may be replace LPM with fib). We could definitely avoid adding exact match. Since the L3fwd application is about showcasing the best possible performance, it is better to keep vector implementation and skip scalar code. This will help debug the correct code path.

Quoted 2 lines

If we get the feature, what about limiting it to scalar implementation and LPM?

I agree with LPM, scalar only might not be very useful.

Quoted 6 lines

Still it is questionable to have the feature in the testpmd, but at least we limit the scope.
For performance measurements can use the l3fwd sample application.

Another point is testing, this feature should come with dts updates to test testpmd l3fwd, otherwise it may not be tested and turn into dead code easily.

Agree

Quoted 56 lines
Quoted 56 lines · Kathleen Capella
Quoted 52 lines

Performance of the LPM mode in L3fwd example application is used as an industry standard to compare between various platforms.

Unfortunately, L3fwd example application lacks debugging capabilities to understand the performance bottlenecks and fix them.

While debugging performance issues we need all the flexibility possible. Some of the capabilities we have used are:
1) ability to print hardware and software statistics - xstats, stats at port/queue level, burst stats to identify any headroom available, CPU cycles/packet etc
2) ability to modify all possible configurable parameters for the PMD as well as the application at run time without recompiling the code. Some of the parameters we have used are RX/TX queue depths, burst size, number of receive queues, PMD specific parameters etc. This configurability at runtime helps to understand and debug L3fwd performance issues quickly and effectively.

It is possible to add all these capabilities to L3fwd example application. However, doing that we will result in L3fwd example application losing its purpose (of being a sample application). At the same time, testpmd application has all these capabilities to debug an application. In my opinion it makes sense to add L3fwd mode to testpmd.

This patch adds l3fwd mode into testpmd to take advantage of the existing infrastructure in testpmd.

I'd like to hear from the community if the structure of this change makes sense, namely, adding l3fwd as a separate fwd_engine into testpmd.

This feature is not yet implemeted for SSE or AltiVec.

Kathleen Capella (1):
app/testpmd: add l3fwd mode to testpmd

 app/test-pmd/config.c         |  66 +++++++
 app/test-pmd/l3fwd.c          | 356 ++++++++++++++++++++++++++++++++++
 app/test-pmd/l3fwd.h          | 143 ++++++++++++++
 app/test-pmd/l3fwd_common.h   | 268 +++++++++++++++++++++++++
 app/test-pmd/l3fwd_lpm.h      | 107 ++++++++++
 app/test-pmd/l3fwd_lpm_neon.h | 169 ++++++++++++++++
 app/test-pmd/l3fwd_neon.h     | 234 ++++++++++++++++++++++
 app/test-pmd/meson.build      |   3 +-
 app/test-pmd/testpmd.c        |   4 +-
 app/test-pmd/testpmd.h        |  20 ++
 10 files changed, 1368 insertions(+), 2 deletions(-)  create mode

100644 app/test-pmd/l3fwd.c create mode 100644 app/test-pmd/l3fwd.h create mode 100644 app/test-pmd/l3fwd_common.h create mode 100644 app/test-pmd/l3fwd_lpm.h create mode 100644 app/test-pmd/l3fwd_lpm_neon.h create mode 100644 app/test-pmd/l3fwd_neon.h