On Thu, Jun 8, 2023 at 6:25 AM Ferruh Yigit <ferruh.yi...@amd.com> wrote: > > On 6/8/2023 10:59 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 to supporting mac, macswap, and > > 5tswap modes. To facilitate adding this support, some new header files > > were added. > > > > Signed-off-by: Mike Pattrick <m...@redhat.com> > > --- > > v2: Reverted changes to random memory lookup > > v3: Refactored entire patch > > v4: Implemented recommended formatting changes > > v5: Corrected copyright statement and formatting changes > > v6: Reordered some variables, preserved noisy subtype for display > > --- > > app/test-pmd/5tswap.c | 118 +---------------------- > > app/test-pmd/5tswap.h | 130 ++++++++++++++++++++++++++ > > app/test-pmd/config.c | 18 +++- > > app/test-pmd/macfwd.c | 33 +------ > > app/test-pmd/macfwd.h | 45 +++++++++ > > app/test-pmd/noisy_vnf.c | 106 +++++++++++++++++---- > > app/test-pmd/parameters.c | 15 +++ > > app/test-pmd/testpmd.c | 14 +++ > > app/test-pmd/testpmd.h | 10 ++ > > doc/guides/testpmd_app_ug/run_app.rst | 9 ++ > > 10 files changed, 334 insertions(+), 164 deletions(-) > > create mode 100644 app/test-pmd/5tswap.h > > create mode 100644 app/test-pmd/macfwd.h > > > > <...> > > > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > > index 096c218c12..a3e2c2ac15 100644 > > --- a/app/test-pmd/config.c > > +++ b/app/test-pmd/config.c > > @@ -4052,9 +4052,16 @@ rxtx_config_display(void) > > { > > portid_t pid; > > queueid_t qid; > > + char buf[32]; > > + > > + if (cur_fwd_eng == &noisy_vnf_engine) > > + snprintf(buf, sizeof(buf), " (%s)", > > noisy_fwd_mode_desc[noisy_fwd_mode]); > > + else > > + buf[0] = '\0'; > > > > - printf(" %s packet forwarding%s packets/burst=%d\n", > > + printf(" %s%s packet forwarding%s packets/burst=%d\n", > > cur_fwd_eng->fwd_mode_name, > > + buf, > > retry_enabled == 0 ? "" : " with retry", > > nb_pkt_per_burst); > > > > @@ -4816,10 +4823,17 @@ pkt_fwd_config_display(struct fwd_config *cfg) > > struct fwd_stream *fs; > > lcoreid_t lc_id; > > streamid_t sm_id; > > + char buf[32]; > > + > > + if (cfg->fwd_eng == &noisy_vnf_engine) > > + snprintf(buf, sizeof(buf), " (%s)", > > noisy_fwd_mode_desc[noisy_fwd_mode]); > > + else > > + buf[0] = '\0'; > > > > - printf("%s packet forwarding%s - ports=%d - cores=%d - streams=%d - " > > + printf("%s%s packet forwarding%s - ports=%d - cores=%d - streams=%d - > > " > > "NUMA support %s, MP allocation mode: %s\n", > > cfg->fwd_eng->fwd_mode_name, > > + buf, > > retry_enabled == 0 ? "" : " with retry", > > cfg->nb_fwd_ports, cfg->nb_fwd_lcores, cfg->nb_fwd_streams, > > numa_support == 1 ? "enabled" : "disabled", > > > This works but I wonder if we can keep the display functions generic (as > much as possible), without forwarding enginee specific checks. > > What about the idea to update '.fwd_mode_name' in 'noisy_fwd_begin()'? > That way generic display code can stay as it is.
I worried that this would interfere with set_pkt_forwarding_mode() among other functions. The .fwd_mode_name seems to play double duty as view and model. I was also thinking about adding another member to struct fwd_engine to display subtype / internal status. But I couldn't think of a compelling use case in the other modules. So I leaned towards this implementation. Which do you prefer? > > <...> > > > +static bool > > +pkt_burst_mac(struct fwd_stream *fs) > > +{ > > + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; > > + uint16_t nb_rx; > > + uint16_t nb_tx; > > + > > + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); > > + if (likely(nb_rx != 0)) > > + do_macfwd(pkts_burst, nb_rx, fs); > > + nb_tx = noisy_eth_tx_burst(fs, nb_rx, pkts_burst); > > + > > + return nb_rx > 0 || nb_tx > 0; > > +} > > +static bool > > +pkt_burst_macswap(struct fwd_stream *fs) > > +{ > > + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; > > + uint16_t nb_rx; > > + uint16_t nb_tx; > > + > > + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); > > + if (likely(nb_rx != 0)) > > + do_macswap(pkts_burst, nb_rx, &ports[fs->tx_port]); > > + nb_tx = noisy_eth_tx_burst(fs, nb_rx, pkts_burst); > > + > > + return nb_rx > 0 || nb_tx > 0; > > +} > > +static bool > > +pkt_burst_5tswap(struct fwd_stream *fs) > > +{ > > + struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; > > + uint16_t nb_rx; > > + uint16_t nb_tx; > > + > > + nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); > > + if (likely(nb_rx != 0)) > > + do_5tswap(pkts_burst, nb_rx, fs); > > + nb_tx = noisy_eth_tx_burst(fs, nb_rx, pkts_burst); > > + > > + return nb_rx > 0 || nb_tx > 0; > > +} > > > > Empty lines are missing between functions. > >