app/testpmd: expand noisy neighbour forward mode support
PATCH 1/1 app/testpmd: expand noisy neighbour forward mode support
Previously the noisy neighbour vnf simulation would only operate in io mode, forwarding packets as is. However, this limited the usefulness of noisy neighbour simulation.
This feature has now been expanded into all forwarding modes except for ieee1588, where it isn't relevant; and iofwd, which would otherwise be duplicative of noisy mode.
Additionally, the calls to rte_rand in noisy's memory simulation were replaced with a simple function as the calls to rte_rand incured a level of overhead and variance that significantly overshadowed the memory activity that this feature was designed to exercise.
--- app/test-pmd/5tswap.c | 29 ++---- app/test-pmd/csumonly.c | 36 ++----- app/test-pmd/flowgen.c | 24 +---- app/test-pmd/icmpecho.c | 28 +----- app/test-pmd/macfwd.c | 27 +----- app/test-pmd/macswap.c | 28 +----- app/test-pmd/noisy_vnf.c | 134 ++++++++++++++++---------- app/test-pmd/testpmd.c | 6 ++ app/test-pmd/txonly.c | 38 ++------ doc/guides/testpmd_app_ug/run_app.rst | 19 ++-- 10 files changed, 134 insertions(+), 235 deletions(-)
app/test-pmd/5tswap.c +6 -23
@@ -19,6 +19,7 @@#include "macswap_common.h" #include "testpmd.h" +#include "noisy_vnf.h" static inline void
@@ -91,8 +92,6 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)uint64_t ol_flags;uint16_t proto;uint16_t nb_rx; -uint16_t nb_tx; -uint32_t retry;int i;union {
@@ -116,7 +115,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) nb_pkt_per_burst);inc_rx_burst_stats (fs, nb_rx);if (unlikely (nb_rx ==0 )) -return ; + goto flush; fs->rx_packets += nb_rx; txp = &ports[fs->tx_port];
@@ -162,26 +161,10 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) }mbuf_field_set (mb, ol_flags); } - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_rx) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_rx); - } + +flush: +noisy_eth_tx_burst (fs, nb_rx, pkts_burst); +get_end_cycles (fs, start_tsc); }
app/test-pmd/csumonly.c +10 -26
@@ -48,6 +48,7 @@#include <rte_geneve.h> #include "testpmd.h" +#include "noisy_vnf.h" #define IP_DEFTTL 64/* from RFC 1340. */
@@ -847,12 +848,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)uint8_t gro_enable;#endif uint16_t nb_rx; -uint16_t nb_tx;uint16_t nb_prep;uint16_t i;uint64_t rx_ol_flags, tx_ol_flags;uint64_t tx_offloads; -uint32_t retry;uint32_t rx_bad_ip_csum;uint32_t rx_bad_l4_csum;uint32_t rx_bad_outer_l4_csum;
@@ -867,8 +866,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) nb_rx =rte_eth_rx_burst (fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst);inc_rx_burst_stats (fs, nb_rx); -if (unlikely (nb_rx ==0 )) -return ; +if (unlikely (nb_rx ==0 )) { +// May still need to flush some packets + nb_prep =0 ; + tx_pkts_burst = pkts_burst; + goto flush; + } + fs->rx_packets += nb_rx; rx_bad_ip_csum =0 ;
@@ -1173,33 +1177,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)"Preparing packet burst to transmit failed: %s\n" , rte_strerror(rte_errno)); - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, tx_pkts_burst, - nb_prep); - -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_rx) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &tx_pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; fs->rx_bad_ip_csum += rx_bad_ip_csum; fs->rx_bad_l4_csum += rx_bad_l4_csum; fs->rx_bad_outer_l4_csum += rx_bad_outer_l4_csum; fs->rx_bad_outer_ip_csum += rx_bad_outer_ip_csum; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); -do { -rte_pktmbuf_free (tx_pkts_burst[nb_tx]); - }while (++nb_tx < nb_rx); - } +flush: +noisy_eth_tx_burst (fs, nb_prep, tx_pkts_burst);get_end_cycles (fs, start_tsc); }
app/test-pmd/flowgen.c +2 -22
@@ -37,6 +37,7 @@#include <rte_flow.h> #include "testpmd.h" +#include "noisy_vnf.h" static uint32_t cfg_ip_src =RTE_IPV4 (10 ,254 ,0 ,0 );static uint32_t cfg_ip_dst =RTE_IPV4 (10 ,253 ,0 ,0 );
@@ -71,12 +72,10 @@ pkt_burst_flow_gen(struct fwd_stream *fs)uint16_t vlan_tci, vlan_tci_outer;uint64_t ol_flags =0 ;uint16_t nb_rx; -uint16_t nb_tx;uint16_t nb_dropped;uint16_t nb_pkt;uint16_t nb_clones = nb_pkt_flowgen_clones;uint16_t i; -uint32_t retry;uint64_t tx_offloads;uint64_t start_tsc =0 ;int next_flow =RTE_PER_LCORE (_next_flow);
@@ -166,32 +165,13 @@ pkt_burst_flow_gen(struct fwd_stream *fs) next_flow =0 ; } - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_pkt) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_pkt && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_pkt - nb_tx); - } - } - fs->tx_packets += nb_tx; + nb_dropped =noisy_eth_tx_burst (fs, nb_rx, pkts_burst); -inc_tx_burst_stats (fs, nb_tx); - nb_dropped = nb_pkt - nb_tx;if (unlikely (nb_dropped >0 )) {/* Back out the flow counter. */ next_flow -= nb_dropped;while (next_flow <0 ) next_flow += nb_flows_flowgen; - - fs->fwd_dropped += nb_dropped; -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_pkt); }RTE_PER_LCORE (_next_flow) = next_flow;
app/test-pmd/icmpecho.c +2 -26
@@ -33,6 +33,7 @@#include <rte_flow.h> #include "testpmd.h" +#include "noisy_vnf.h" static const char *arp_op_name (uint16_t arp_op)
@@ -280,10 +281,8 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)struct rte_ipv4_hdr *ip_h;struct rte_icmp_hdr *icmp_h;struct rte_ether_addr eth_addr; -uint32_t retry;uint32_t ip_addr;uint16_t nb_rx; -uint16_t nb_tx;uint16_t nb_replies;uint16_t eth_type;uint16_t vlan_id;
@@ -483,30 +482,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)/* Send back ICMP echo replies, if any. */ if (nb_replies >0 ) { - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, - nb_replies); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_replies) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_replies && - retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, - fs->tx_queue, - &pkts_burst[nb_tx], - nb_replies - nb_tx); - } - } - fs->tx_packets += nb_tx; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_replies)) { - fs->fwd_dropped += (nb_replies - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_replies); - } +noisy_eth_tx_burst (fs, nb_replies, pkts_burst); }get_end_cycles (fs, start_tsc);
app/test-pmd/macfwd.c +4 -23
@@ -35,6 +35,7 @@#include <rte_flow.h> #include "testpmd.h" +#include "noisy_vnf.h" /* * Forwarding of packets in MAC mode.
@@ -48,9 +49,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs)struct rte_port *txp;struct rte_mbuf *mb;struct rte_ether_hdr *eth_hdr; -uint32_t retry;uint16_t nb_rx; -uint16_t nb_tx;uint16_t i;uint64_t ol_flags =0 ;uint64_t tx_offloads;
@@ -65,7 +64,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) nb_pkt_per_burst);inc_rx_burst_stats (fs, nb_rx);if (unlikely (nb_rx ==0 )) -return ; + goto flush; fs->rx_packets += nb_rx; txp = &ports[fs->tx_port];
@@ -93,27 +92,9 @@ pkt_burst_mac_forward(struct fwd_stream *fs) mb->vlan_tci = txp->tx_vlan_id; mb->vlan_tci_outer = txp->tx_vlan_id_outer; } - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_rx) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_rx); - } +flush: +noisy_eth_tx_burst (fs, nb_rx, pkts_burst);get_end_cycles (fs, start_tsc); }
app/test-pmd/macswap.c +5 -23
@@ -42,6 +42,7 @@#else #include "macswap.h" #endif +#include "noisy_vnf.h" /* * MAC swap forwarding mode: Swap the source and the destination Ethernet
@@ -53,8 +54,6 @@ pkt_burst_mac_swap(struct fwd_stream *fs)struct rte_mbuf *pkts_burst[MAX_PKT_BURST ];struct rte_port *txp;uint16_t nb_rx; -uint16_t nb_tx; -uint32_t retry;uint64_t start_tsc =0 ;get_start_cycles (&start_tsc);
@@ -66,33 +65,16 @@ pkt_burst_mac_swap(struct fwd_stream *fs) nb_pkt_per_burst);inc_rx_burst_stats (fs, nb_rx);if (unlikely (nb_rx ==0 )) -return ; + goto flush; fs->rx_packets += nb_rx; txp = &ports[fs->tx_port];do_macswap (pkts_burst, nb_rx, txp); - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_rx) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_rx); - } +flush: +noisy_eth_tx_burst (fs, nb_rx, pkts_burst); +get_end_cycles (fs, start_tsc); }
app/test-pmd/noisy_vnf.c +81 -53
235 lines not on this page · raw message
app/test-pmd/testpmd.c +6 -0
@@ -74,6 +74,7 @@#endif #include "testpmd.h" +#include "noisy_vnf.h" #ifndef MAP_HUGETLB /* FreeBSD may not have MAP_HUGETLB (in fact, it probably doesn't) */
@@ -2382,6 +2383,9 @@ start_packet_forwarding(int with_tx_first)for (i =0 ; i < cur_fwd_config.nb_fwd_streams; i++)stream_init (fwd_streams[i]); +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) +noisy_fwd_begin (fwd_ports_ids[i]); + 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++) {
@@ -2446,6 +2450,8 @@ stop_packet_forwarding(void) fwd_lcores[lc_id]->stopped =1 ;printf ("\nWaiting for lcores to finish...\n" );rte_eal_mp_wait_lcore (); +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) +noisy_fwd_end (fwd_ports_ids[i]); port_fwd_end = cur_fwd_config.fwd_eng->port_fwd_end;if (port_fwd_end !=NULL ) {for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) {
app/test-pmd/txonly.c +6 -32
@@ -37,6 +37,7 @@#include <rte_flow.h> #include "testpmd.h" +#include "noisy_vnf.h" struct tx_timestamp {rte_be32_t signature;
@@ -331,10 +332,9 @@ pkt_burst_transmit(struct fwd_stream *fs)struct rte_mbuf *pkt;struct rte_mempool *mbp;struct rte_ether_hdr eth_hdr; -uint16_t nb_tx;uint16_t nb_pkt; +uint16_t dropped;uint16_t vlan_tci, vlan_tci_outer; -uint32_t retry;uint64_t ol_flags =0 ;uint64_t tx_offloads;uint64_t start_tsc =0 ;
@@ -391,40 +391,14 @@ pkt_burst_transmit(struct fwd_stream *fs) } } -if (nb_pkt ==0 ) -return ; - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); + dropped =noisy_eth_tx_burst (fs, nb_pkt, pkts_burst); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_pkt) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_pkt && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_pkt - nb_tx); - } - } - fs->tx_packets += nb_tx; +if (nb_pkt ==0 ) +return ;if (txonly_multi_flow) -RTE_PER_LCORE (_ip_var) -= nb_pkt - nb_tx; - -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_pkt)) { -if (verbose_level >0 && fs->fwd_dropped ==0 ) -printf ("port %d tx_queue %d - drop " -"(nb_pkt:%u - nb_tx:%u)=%u packets\n" , - fs->tx_port, fs->tx_queue, - (unsigned ) nb_pkt, (unsigned ) nb_tx, - (unsigned ) (nb_pkt - nb_tx)); - fs->fwd_dropped += (nb_pkt - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_pkt); - } +RTE_PER_LCORE (_ip_var) -= dropped;get_end_cycles (fs, start_tsc); }
doc/guides/testpmd_app_ug/run_app.rst +12 -7
@@ -484,34 +484,39 @@ The command line options are: * ``--noisy-tx-sw-buffer-size`` Set the number of maximum elements of the FIFO queue to be created - for buffering packets. Only available with the noisy forwarding mode. - The default value is 0. + for buffering packets. Available with all forwarding modes except for + io and ieee1588. The default value is 0. * ``--noisy-tx-sw-buffer-flushtime=N`` Set the time before packets in the FIFO queue is flushed. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--noisy-lkup-memory=N`` Set the size of the noisy neighbor simulation memory buffer in MB to N. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--noisy-lkup-num-reads=N`` Set the number of reads to be done in noisy neighbor simulation memory buffer to N. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--noisy-lkup-num-writes=N`` Set the number of writes to be done in noisy neighbor simulation memory buffer to N. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--noisy-lkup-num-reads-writes=N`` Set the number of r/w accesses to be done in noisy neighbor simulation memory buffer to N. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--no-iova-contig``
Signature · 1 line
2.31.1
Review
Quoted 2 lines · On Wed, 25 Jan 2023 17:45:31 -0500 Mike Pattrick <[email protected]> wrote:
(quoted diff) +2
-0+ if (unlikely(nb_rx == 0)) { + // May still need to flush some packet
DPDK style is to only use C style comments
app/test-pmd/noisy_vnf.c struct noisy_config { · line 64
Quoted 8 lines · On Wed, 25 Jan 2023 17:45:31 -0500 Mike Pattrick <[email protected]> wrote:
app/test-pmd/noisy_vnf.c +8
-0+ +static uint64_t rnd (void ) +{ +RTE_PER_LCORE (seed) =1103515245U *RTE_PER_LCORE (seed) +12345U ; + +return RTE_PER_LCORE (seed); +} +
Strong NAK
don't add another random generator.
PATCH v2 1/1 app/testpmd: expand noisy neighbour forward mode support
In reply to Mike PattrickPreviously the noisy neighbour vnf simulation would only operate in io mode, forwarding packets as is. However, this limited the usefulness of noisy neighbour simulation.
This feature has now been expanded into all forwarding modes except for ieee1588, where it isn't relevant; and iofwd, which would otherwise be duplicative of noisy mode.
---
v2:
- Included header that was incorrectly excluded from v1
- Restored calls to rte_rand()
--- app/test-pmd/5tswap.c | 29 ++----- app/test-pmd/csumonly.c | 36 +++----- app/test-pmd/flowgen.c | 24 +----- app/test-pmd/icmpecho.c | 28 +----- app/test-pmd/macfwd.c | 27 +----- app/test-pmd/macswap.c | 28 ++---- app/test-pmd/noisy_vnf.c | 118 ++++++++++++++++---------- app/test-pmd/noisy_vnf.h | 48 +++++++++++ app/test-pmd/testpmd.c | 6 ++ app/test-pmd/txonly.c | 38 ++------- doc/guides/testpmd_app_ug/run_app.rst | 19 +++-- 11 files changed, 172 insertions(+), 229 deletions(-) create mode 100644 app/test-pmd/noisy_vnf.h
app/test-pmd/5tswap.c +6 -23
@@ -19,6 +19,7 @@#include "macswap_common.h" #include "testpmd.h" +#include "noisy_vnf.h" static inline void
@@ -91,8 +92,6 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)uint64_t ol_flags;uint16_t proto;uint16_t nb_rx; -uint16_t nb_tx; -uint32_t retry;int i;union {
@@ -116,7 +115,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) nb_pkt_per_burst);inc_rx_burst_stats (fs, nb_rx);if (unlikely (nb_rx ==0 )) -return ; + goto flush; fs->rx_packets += nb_rx; txp = &ports[fs->tx_port];
@@ -162,26 +161,10 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs) }mbuf_field_set (mb, ol_flags); } - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_rx) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_rx); - } + +flush: +noisy_eth_tx_burst (fs, nb_rx, pkts_burst); +get_end_cycles (fs, start_tsc); }
app/test-pmd/csumonly.c +10 -26
@@ -48,6 +48,7 @@#include <rte_geneve.h> #include "testpmd.h" +#include "noisy_vnf.h" #define IP_DEFTTL 64/* from RFC 1340. */
@@ -847,12 +848,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)uint8_t gro_enable;#endif uint16_t nb_rx; -uint16_t nb_tx;uint16_t nb_prep;uint16_t i;uint64_t rx_ol_flags, tx_ol_flags;uint64_t tx_offloads; -uint32_t retry;uint32_t rx_bad_ip_csum;uint32_t rx_bad_l4_csum;uint32_t rx_bad_outer_l4_csum;
@@ -867,8 +866,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) nb_rx =rte_eth_rx_burst (fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst);inc_rx_burst_stats (fs, nb_rx); -if (unlikely (nb_rx ==0 )) -return ; +if (unlikely (nb_rx ==0 )) { +/* May still need to flush some packets */ + nb_prep =0 ; + tx_pkts_burst = pkts_burst; + goto flush; + } + fs->rx_packets += nb_rx; rx_bad_ip_csum =0 ;
@@ -1173,33 +1177,13 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)"Preparing packet burst to transmit failed: %s\n" , rte_strerror(rte_errno)); - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, tx_pkts_burst, - nb_prep); - -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_rx) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &tx_pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; fs->rx_bad_ip_csum += rx_bad_ip_csum; fs->rx_bad_l4_csum += rx_bad_l4_csum; fs->rx_bad_outer_l4_csum += rx_bad_outer_l4_csum; fs->rx_bad_outer_ip_csum += rx_bad_outer_ip_csum; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); -do { -rte_pktmbuf_free (tx_pkts_burst[nb_tx]); - }while (++nb_tx < nb_rx); - } +flush: +noisy_eth_tx_burst (fs, nb_prep, tx_pkts_burst);get_end_cycles (fs, start_tsc); }
app/test-pmd/flowgen.c +2 -22
@@ -37,6 +37,7 @@#include <rte_flow.h> #include "testpmd.h" +#include "noisy_vnf.h" static uint32_t cfg_ip_src =RTE_IPV4 (10 ,254 ,0 ,0 );static uint32_t cfg_ip_dst =RTE_IPV4 (10 ,253 ,0 ,0 );
@@ -71,12 +72,10 @@ pkt_burst_flow_gen(struct fwd_stream *fs)uint16_t vlan_tci, vlan_tci_outer;uint64_t ol_flags =0 ;uint16_t nb_rx; -uint16_t nb_tx;uint16_t nb_dropped;uint16_t nb_pkt;uint16_t nb_clones = nb_pkt_flowgen_clones;uint16_t i; -uint32_t retry;uint64_t tx_offloads;uint64_t start_tsc =0 ;int next_flow =RTE_PER_LCORE (_next_flow);
@@ -166,32 +165,13 @@ pkt_burst_flow_gen(struct fwd_stream *fs) next_flow =0 ; } - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_pkt) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_pkt && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_pkt - nb_tx); - } - } - fs->tx_packets += nb_tx; + nb_dropped =noisy_eth_tx_burst (fs, nb_rx, pkts_burst); -inc_tx_burst_stats (fs, nb_tx); - nb_dropped = nb_pkt - nb_tx;if (unlikely (nb_dropped >0 )) {/* Back out the flow counter. */ next_flow -= nb_dropped;while (next_flow <0 ) next_flow += nb_flows_flowgen; - - fs->fwd_dropped += nb_dropped; -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_pkt); }RTE_PER_LCORE (_next_flow) = next_flow;
app/test-pmd/icmpecho.c +2 -26
@@ -33,6 +33,7 @@#include <rte_flow.h> #include "testpmd.h" +#include "noisy_vnf.h" static const char *arp_op_name (uint16_t arp_op)
@@ -280,10 +281,8 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)struct rte_ipv4_hdr *ip_h;struct rte_icmp_hdr *icmp_h;struct rte_ether_addr eth_addr; -uint32_t retry;uint32_t ip_addr;uint16_t nb_rx; -uint16_t nb_tx;uint16_t nb_replies;uint16_t eth_type;uint16_t vlan_id;
@@ -483,30 +482,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)/* Send back ICMP echo replies, if any. */ if (nb_replies >0 ) { - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, - nb_replies); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_replies) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_replies && - retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, - fs->tx_queue, - &pkts_burst[nb_tx], - nb_replies - nb_tx); - } - } - fs->tx_packets += nb_tx; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_replies)) { - fs->fwd_dropped += (nb_replies - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_replies); - } +noisy_eth_tx_burst (fs, nb_replies, pkts_burst); }get_end_cycles (fs, start_tsc);
app/test-pmd/macfwd.c +4 -23
@@ -35,6 +35,7 @@#include <rte_flow.h> #include "testpmd.h" +#include "noisy_vnf.h" /* * Forwarding of packets in MAC mode.
@@ -48,9 +49,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs)struct rte_port *txp;struct rte_mbuf *mb;struct rte_ether_hdr *eth_hdr; -uint32_t retry;uint16_t nb_rx; -uint16_t nb_tx;uint16_t i;uint64_t ol_flags =0 ;uint64_t tx_offloads;
@@ -65,7 +64,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) nb_pkt_per_burst);inc_rx_burst_stats (fs, nb_rx);if (unlikely (nb_rx ==0 )) -return ; + goto flush; fs->rx_packets += nb_rx; txp = &ports[fs->tx_port];
@@ -93,27 +92,9 @@ pkt_burst_mac_forward(struct fwd_stream *fs) mb->vlan_tci = txp->tx_vlan_id; mb->vlan_tci_outer = txp->tx_vlan_id_outer; } - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_rx) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_rx); - } +flush: +noisy_eth_tx_burst (fs, nb_rx, pkts_burst);get_end_cycles (fs, start_tsc); }
app/test-pmd/macswap.c +5 -23
@@ -42,6 +42,7 @@#else #include "macswap.h" #endif +#include "noisy_vnf.h" /* * MAC swap forwarding mode: Swap the source and the destination Ethernet
@@ -53,8 +54,6 @@ pkt_burst_mac_swap(struct fwd_stream *fs)struct rte_mbuf *pkts_burst[MAX_PKT_BURST ];struct rte_port *txp;uint16_t nb_rx; -uint16_t nb_tx; -uint32_t retry;uint64_t start_tsc =0 ;get_start_cycles (&start_tsc);
@@ -66,33 +65,16 @@ pkt_burst_mac_swap(struct fwd_stream *fs) nb_pkt_per_burst);inc_rx_burst_stats (fs, nb_rx);if (unlikely (nb_rx ==0 )) -return ; + goto flush; fs->rx_packets += nb_rx; txp = &ports[fs->tx_port];do_macswap (pkts_burst, nb_rx, txp); - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_rx) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_rx && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_rx - nb_tx); - } - } - fs->tx_packets += nb_tx; -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_rx)) { - fs->fwd_dropped += (nb_rx - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_rx); - } +flush: +noisy_eth_tx_burst (fs, nb_rx, pkts_burst); +get_end_cycles (fs, start_tsc); }
app/test-pmd/noisy_vnf.c +71 -47
207 lines not on this page · raw message
app/test-pmd/noisy_vnf.h new file +48 -0
48 lines not on this page · raw message
app/test-pmd/testpmd.c +6 -0
@@ -74,6 +74,7 @@#endif #include "testpmd.h" +#include "noisy_vnf.h" #ifndef MAP_HUGETLB /* FreeBSD may not have MAP_HUGETLB (in fact, it probably doesn't) */
@@ -2382,6 +2383,9 @@ start_packet_forwarding(int with_tx_first)for (i =0 ; i < cur_fwd_config.nb_fwd_streams; i++)stream_init (fwd_streams[i]); +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) +noisy_fwd_begin (fwd_ports_ids[i]); + 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++) {
@@ -2446,6 +2450,8 @@ stop_packet_forwarding(void) fwd_lcores[lc_id]->stopped =1 ;printf ("\nWaiting for lcores to finish...\n" );rte_eal_mp_wait_lcore (); +for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) +noisy_fwd_end (fwd_ports_ids[i]); port_fwd_end = cur_fwd_config.fwd_eng->port_fwd_end;if (port_fwd_end !=NULL ) {for (i =0 ; i < cur_fwd_config.nb_fwd_ports; i++) {
app/test-pmd/txonly.c +6 -32
@@ -37,6 +37,7 @@#include <rte_flow.h> #include "testpmd.h" +#include "noisy_vnf.h" struct tx_timestamp {rte_be32_t signature;
@@ -331,10 +332,9 @@ pkt_burst_transmit(struct fwd_stream *fs)struct rte_mbuf *pkt;struct rte_mempool *mbp;struct rte_ether_hdr eth_hdr; -uint16_t nb_tx;uint16_t nb_pkt; +uint16_t dropped;uint16_t vlan_tci, vlan_tci_outer; -uint32_t retry;uint64_t ol_flags =0 ;uint64_t tx_offloads;uint64_t start_tsc =0 ;
@@ -391,40 +391,14 @@ pkt_burst_transmit(struct fwd_stream *fs) } } -if (nb_pkt ==0 ) -return ; - nb_tx =rte_eth_tx_burst (fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); + dropped =noisy_eth_tx_burst (fs, nb_pkt, pkts_burst); -/* -* Retry if necessary -*/ -if (unlikely (nb_tx < nb_pkt) && fs->retry_enabled) { - retry =0 ; -while (nb_tx < nb_pkt && retry++ < burst_tx_retry_num) { -rte_delay_us (burst_tx_delay_time); - nb_tx +=rte_eth_tx_burst (fs->tx_port, fs->tx_queue, - &pkts_burst[nb_tx], nb_pkt - nb_tx); - } - } - fs->tx_packets += nb_tx; +if (nb_pkt ==0 ) +return ;if (txonly_multi_flow) -RTE_PER_LCORE (_ip_var) -= nb_pkt - nb_tx; - -inc_tx_burst_stats (fs, nb_tx); -if (unlikely (nb_tx < nb_pkt)) { -if (verbose_level >0 && fs->fwd_dropped ==0 ) -printf ("port %d tx_queue %d - drop " -"(nb_pkt:%u - nb_tx:%u)=%u packets\n" , - fs->tx_port, fs->tx_queue, - (unsigned ) nb_pkt, (unsigned ) nb_tx, - (unsigned ) (nb_pkt - nb_tx)); - fs->fwd_dropped += (nb_pkt - nb_tx); -do { -rte_pktmbuf_free (pkts_burst[nb_tx]); - }while (++nb_tx < nb_pkt); - } +RTE_PER_LCORE (_ip_var) -= dropped;get_end_cycles (fs, start_tsc); }
doc/guides/testpmd_app_ug/run_app.rst +12 -7
@@ -484,34 +484,39 @@ The command line options are: * ``--noisy-tx-sw-buffer-size`` Set the number of maximum elements of the FIFO queue to be created - for buffering packets. Only available with the noisy forwarding mode. - The default value is 0. + for buffering packets. Available with all forwarding modes except for + io and ieee1588. The default value is 0. * ``--noisy-tx-sw-buffer-flushtime=N`` Set the time before packets in the FIFO queue is flushed. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--noisy-lkup-memory=N`` Set the size of the noisy neighbor simulation memory buffer in MB to N. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--noisy-lkup-num-reads=N`` Set the number of reads to be done in noisy neighbor simulation memory buffer to N. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--noisy-lkup-num-writes=N`` Set the number of writes to be done in noisy neighbor simulation memory buffer to N. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--noisy-lkup-num-reads-writes=N`` Set the number of r/w accesses to be done in noisy neighbor simulation memory buffer to N. - Only available with the noisy forwarding mode. The default value is 0. + Available with all forwarding modes except for io and ieee1588. + The default value is 0. * ``--no-iova-contig``
Signature · 1 line
2.31.1
Hi Mike,
Thanks a lot for the patch.
Quoted 7 lines · Mike Pattrick
Previously the noisy neighbour vnf simulation would only operate in io mode, forwarding packets as is. However, this limited the usefulness of noisy neighbour simulation.
This feature has now been expanded into all forwarding modes except for ieee1588, where it isn't relevant; and iofwd, which would otherwise be duplicative of noisy mode.
Well I would first like to know, why we need noisy neighbor for all modes IMHO, do we need to add code to each mode, if most users don't use it.
Secondly, can't we achieve same behavior by running testpmd instances in parallel on same NUMA node. Where one testpmd is in noisy mode.
Quoted 4 lines
Signed-off-by Mike Pattrick<[email protected]>---
<snip>
Quoted 15 lines · Aman Deep
Hi Mike,
Thanks a lot for the patch.
On 1/26/2023 10:25 AM, Mike Pattrick wrote:
Previously the noisy neighbour vnf simulation would only operate in io mode, forwarding packets as is. However, this limited the usefulness of noisy neighbour simulation.
This feature has now been expanded into all forwarding modes except for ieee1588, where it isn't relevant; and iofwd, which would otherwise be duplicative of noisy mode.
Quoted 5 lines
Well I would first like to know, why we need noisy neighbor for all modes IMHO, do we need to add code to each mode, if most users don't use it.
Secondly, can't we achieve same behavior by running testpmd instances in parallel on same NUMA node. Where one testpmd is in noisy mode.
I don't think the dual testpmd solution is identical, one of the motivations for this change is to actually run the other modes with the characteristics of the noisy mode. If we ran noisy with another mode, that other mode would experience cache and memory contention, but wouldn't experience queuing; and the contention wouldn't be directly correlated with the exact packets that it forwarded, but instead with the packets that noisy was forwarding.
Would it be preferable if I changed how this worked to not impact the other forward modes when noisy options are disabled? I could change this to switch the value of packet_fwd when noisy options are set. I could also just move the full implementation back into noisy_vnf.c and add a new option to affect how it forwards.
Thank you,
Mike
Quoted 6 lines
Signed-off-by Mike Pattrick <[email protected]>---
<snip>
Quoted 29 lines · Mike Pattrick
Quoted 14 lines · Aman Deep
Hi Mike,
Thanks a lot for the patch.
On 1/26/2023 10:25 AM, Mike Pattrick wrote:
Previously the noisy neighbour vnf simulation would only operate in io mode, forwarding packets as is. However, this limited the usefulness of noisy neighbour simulation.
This feature has now been expanded into all forwarding modes except for ieee1588, where it isn't relevant; and iofwd, which would otherwise be duplicative of noisy mode.
Quoted 5 lines
Well I would first like to know, why we need noisy neighbor for all modes IMHO, do we need to add code to each mode, if most users don't use it.
Secondly, can't we achieve same behavior by running testpmd instances in parallel on same NUMA node. Where one testpmd is in noisy mode.
I don't think the dual testpmd solution is identical, one of the motivations for this change is to actually run the other modes with the characteristics of the noisy mode. If we ran noisy with another mode, that other mode would experience cache and memory contention, but wouldn't experience queuing; and the contention wouldn't be directly correlated with the exact packets that it forwarded, but instead with the packets that noisy was forwarding.
Quoted 5 lines
Would it be preferable if I changed how this worked to not impact the other forward modes when noisy options are disabled? I could change this to switch the value of
packet_fwdwhen noisy options are set. I could also just move the full implementation back intonoisy_vnf.cand add a new option to affect how it forwards.
Yes that will be good, to have full implementation in noisy_vnf.c only.
Quoted 10 lines
Thank you,
MikeQuoted 5 lines
Signed-off-by Mike Pattrick <[email protected]>---
<snip>