From aee39c9dd61944b3be3c20b4e3f9ec4d57602d01 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 23 Jan 2017 14:06:52 +0200 Subject: enable TRex to run with --rt : real time priority for DP and RX cores Signed-off-by: imarom --- src/main_dpdk.cpp | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'src/main_dpdk.cpp') diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index aa31cf0b..f58e403f 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -713,7 +713,8 @@ enum { OPT_HELP, OPT_ARP_REF_PER, OPT_NO_OFED_CHECK, OPT_NO_SCAPY_SERVER, - OPT_ACTIVE_FLOW + OPT_ACTIVE_FLOW, + OPT_RT }; /* these are the argument types: @@ -774,6 +775,7 @@ static CSimpleOpt::SOption parser_options[] = { OPT_ARP_REF_PER, "--arp-refresh-period", SO_REQ_SEP }, { OPT_NO_OFED_CHECK, "--no-ofed-check", SO_NONE }, { OPT_NO_SCAPY_SERVER, "--no-scapy-server", SO_NONE }, + { OPT_RT, "--rt", SO_NONE }, SO_END_OF_OPTIONS }; @@ -828,6 +830,7 @@ static int usage(){ printf(" --no-ofed-check : Disable the check of OFED version \n"); printf(" --no-scapy-server : Disable Scapy server implicit start at stateless \n"); printf(" --no-watchdog : Disable watchdog \n"); + printf(" --rt : Run TRex DP/RX cores in realtime priority \n"); printf(" -p : Send all flow packets from the same interface (choosed randomly between client ad server ports) without changing their src/dst IP \n"); printf(" -pm : Platform factor. If you have splitter in the setup, you can multiply the total results by this factor \n"); printf(" e.g --pm 2.0 will multiply all the results bps in this factor \n"); @@ -956,6 +959,9 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t po->preview.set_ipv6_mode_enable(true); break; + case OPT_RT: + po->preview.set_rt_prio_mode(true); + break; case OPT_LEARN : po->m_learn_mode = CParserOption::LEARN_MODE_IP_OPTION; @@ -4845,8 +4851,20 @@ int CGlobalTRex::run_in_master() { int CGlobalTRex::run_in_rx_core(void){ + CPreviewMode *lp = &CGlobalInfo::m_options.preview; + rte_thread_setname(pthread_self(), "TRex RX"); - + + /* set RT mode if set */ + if (lp->get_rt_prio_mode()) { + struct sched_param param; + param.sched_priority = sched_get_priority_max(SCHED_FIFO); + if (pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) != 0) { + perror("setting RT priroity mode on RX core failed with error"); + exit(EXIT_FAILURE); + } + } + if (get_is_stateless()) { m_sl_rx_running = true; m_rx_sl.start(); @@ -4863,11 +4881,22 @@ int CGlobalTRex::run_in_rx_core(void){ int CGlobalTRex::run_in_core(virtual_thread_id_t virt_core_id){ std::stringstream ss; - + CPreviewMode *lp = &CGlobalInfo::m_options.preview; + ss << "Trex DP core " << int(virt_core_id); rte_thread_setname(pthread_self(), ss.str().c_str()); + + /* set RT mode if set */ + if (lp->get_rt_prio_mode()) { + struct sched_param param; + param.sched_priority = sched_get_priority_max(SCHED_FIFO); + if (pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m) != 0) { + perror("setting RT priroity mode on DP core failed with error"); + exit(EXIT_FAILURE); + } + } - CPreviewMode *lp=&CGlobalInfo::m_options.preview; + if ( lp->getSingleCore() && (virt_core_id==2 ) && (lp-> getCores() ==1) ){ -- cgit 1.2.3-korg From 030c124495335da372a5bb4f537365cce3def3af Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Mon, 23 Jan 2017 14:57:29 +0200 Subject: fix trex-333 Signed-off-by: Hanoh Haim --- .../regression/stateful_tests/trex_imix_test.py | 7 -- .../regression/stateless_tests/stl_rx_test.py | 34 +++++-- src/main_dpdk.cpp | 111 ++++++++++++++++++++- 3 files changed, 135 insertions(+), 17 deletions(-) (limited to 'src/main_dpdk.cpp') diff --git a/scripts/automation/regression/stateful_tests/trex_imix_test.py b/scripts/automation/regression/stateful_tests/trex_imix_test.py index dc7eea0b..4cb01db3 100755 --- a/scripts/automation/regression/stateful_tests/trex_imix_test.py +++ b/scripts/automation/regression/stateful_tests/trex_imix_test.py @@ -121,11 +121,6 @@ class CTRexIMIX_Test(CTRexGeneral_Test): mult = self.get_benchmark_param('multiplier') core = self.get_benchmark_param('cores') - - # in case of VMXNET3 the number of bytes reported is 60 bytes for 64B - if self.is_VM: - self.trex.result_obj.set_warmup (0.89) - # trex_res = self.trex.run(multiplier = mult, cores = core, duration = 30, l = 1000, p = True) ret = self.trex.start_trex( c = core, @@ -146,8 +141,6 @@ class CTRexIMIX_Test(CTRexGeneral_Test): self.check_general_scenario_results(trex_res) self.check_CPU_benchmark(trex_res) - if self.is_VM: - self.trex.result_obj.set_warmup_default() # the name intentionally not matches nose default pattern, including the test should be specified explicitly diff --git a/scripts/automation/regression/stateless_tests/stl_rx_test.py b/scripts/automation/regression/stateless_tests/stl_rx_test.py index 8812ac48..a3efa01d 100644 --- a/scripts/automation/regression/stateless_tests/stl_rx_test.py +++ b/scripts/automation/regression/stateless_tests/stl_rx_test.py @@ -526,19 +526,37 @@ class STLRX_Test(CStlGeneral_Test): except STLError as e: assert False , '{0}'.format(e) + def _run_fcs_stream (self,is_vm): + """ this test send 1 64 byte packet with latency and check that all counters are reported as 64 bytes""" + res=True + try: + all_ports=list(CTRexScenario.stl_ports_map['map'].keys()); + for port in all_ports: + for l in [True,False]: + print(" test port {0} latency : {1} ".format(port,l)) + self.send_1_burst(port,l,100) + except Exception as e: + if is_vm : + res=False + else: + raise e + return(res); + + def test_fcs_stream(self): """ this test send 1 64 byte packet with latency and check that all counters are reported as 64 bytes""" - if self.is_virt_nics: - self.skip('Skip this for virtual NICs') - - all_ports=list(CTRexScenario.stl_ports_map['map'].keys()); - for port in all_ports: - for l in [True,False]: - print(" test port {0} latency : {1} ".format(port,l)) - self.send_1_burst(port,l,100) + is_vm=self.is_virt_nics # in case of VM and vSwitch there are drop of packets in some cases, let retry number of times + # in this case we just want to check functionality that packet of 64 is reported as 64 in all levels + retry=1 + if is_vm: + retry=4 + for i in range(0,retry): + if self._run_fcs_stream (is_vm): + break; + print("==> retry %d .." %(i)); # this test adds more and more latency streams and re-test with incremental diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index f58e403f..452baef2 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -288,6 +288,27 @@ public: virtual int set_rcv_all(CPhyEthIF * _if, bool set_on) {return 0;} }; + +class CTRexExtendedDriverBaseVmxnet3 : public CTRexExtendedDriverBase1GVm { +public: + static CTRexExtendedDriverBase * create(){ + return ( new CTRexExtendedDriverBaseVmxnet3() ); + } + + virtual void get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats); +}; + +class CTRexExtendedDriverBaseVirtio : public CTRexExtendedDriverBase1GVm { +public: + static CTRexExtendedDriverBase * create(){ + return ( new CTRexExtendedDriverBaseVmxnet3() ); + } + + virtual void get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats); +}; + + + class CTRexExtendedDriverVf : public CTRexExtendedDriverBase1GVm { public: @@ -320,6 +341,9 @@ public: } // e1000 driver handing us packets with ethernet CRC, so we need to chop them virtual uint8_t get_num_crc_fix_bytes() {return 4;} + + virtual void get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats); + }; class CTRexExtendedDriverBase10G : public CTRexExtendedDriverBase { @@ -594,8 +618,8 @@ private: /* virtual devices */ register_driver(std::string("rte_em_pmd"),CTRexExtendedDriverBaseE1000::create); - register_driver(std::string("rte_vmxnet3_pmd"),CTRexExtendedDriverBase1GVm::create); - register_driver(std::string("rte_virtio_pmd"),CTRexExtendedDriverBase1GVm::create); + register_driver(std::string("rte_vmxnet3_pmd"),CTRexExtendedDriverBaseVmxnet3::create); + register_driver(std::string("rte_virtio_pmd"),CTRexExtendedDriverBaseVirtio::create); register_driver(std::string("rte_ixgbevf_pmd"),CTRexExtendedDriverVf::create); register_driver(std::string("rte_i40evf_pmd"),CTRexExtendedDriverVf::create); @@ -7193,6 +7217,89 @@ int CTRexExtendedDriverBase1GVm::stop_queue(CPhyEthIF * _if, uint16_t q_num) { return (0); } +void CTRexExtendedDriverBaseE1000::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats){ + struct rte_eth_stats stats1; + struct rte_eth_stats *prev_stats = &stats->m_prev_stats; + rte_eth_stats_get(_if->get_port_id(), &stats1); + + stats->ipackets += stats1.ipackets - prev_stats->ipackets; + stats->ibytes += stats1.ibytes - prev_stats->ibytes ; + stats->opackets += stats1.opackets - prev_stats->opackets; + stats->obytes += stats1.obytes - prev_stats->obytes + (stats1.opackets - prev_stats->opackets) * 4; + stats->f_ipackets += 0; + stats->f_ibytes += 0; + stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf + - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; + stats->oerrors += stats1.oerrors - prev_stats->oerrors; + stats->imcasts += 0; + stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; + + prev_stats->ipackets = stats1.ipackets; + prev_stats->ibytes = stats1.ibytes; + prev_stats->opackets = stats1.opackets; + prev_stats->obytes = stats1.obytes; + prev_stats->imissed = stats1.imissed; + prev_stats->oerrors = stats1.oerrors; + prev_stats->ierrors = stats1.ierrors; + prev_stats->rx_nombuf = stats1.rx_nombuf; +} + + +void CTRexExtendedDriverBaseVirtio::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats){ + struct rte_eth_stats stats1; + struct rte_eth_stats *prev_stats = &stats->m_prev_stats; + rte_eth_stats_get(_if->get_port_id(), &stats1); + + stats->ipackets += stats1.ipackets - prev_stats->ipackets; + stats->ibytes += stats1.ibytes - prev_stats->ibytes +(stats1.ipackets - prev_stats->ipackets) * 4; + stats->opackets += stats1.opackets - prev_stats->opackets; + stats->obytes += stats1.obytes - prev_stats->obytes + (stats1.opackets - prev_stats->opackets) * 4; + stats->f_ipackets += 0; + stats->f_ibytes += 0; + stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf + - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; + stats->oerrors += stats1.oerrors - prev_stats->oerrors; + stats->imcasts += 0; + stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; + + prev_stats->ipackets = stats1.ipackets; + prev_stats->ibytes = stats1.ibytes; + prev_stats->opackets = stats1.opackets; + prev_stats->obytes = stats1.obytes; + prev_stats->imissed = stats1.imissed; + prev_stats->oerrors = stats1.oerrors; + prev_stats->ierrors = stats1.ierrors; + prev_stats->rx_nombuf = stats1.rx_nombuf; +} + +void CTRexExtendedDriverBaseVmxnet3::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats){ + struct rte_eth_stats stats1; + struct rte_eth_stats *prev_stats = &stats->m_prev_stats; + rte_eth_stats_get(_if->get_port_id(), &stats1); + + stats->ipackets += stats1.ipackets - prev_stats->ipackets; + stats->ibytes += stats1.ibytes - prev_stats->ibytes +(stats1.ipackets - prev_stats->ipackets) * 4; + stats->opackets += stats1.opackets - prev_stats->opackets; + stats->obytes += stats1.obytes - prev_stats->obytes + (stats1.opackets - prev_stats->opackets) * 4; + stats->f_ipackets += 0; + stats->f_ibytes += 0; + stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf + - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; + stats->oerrors += stats1.oerrors - prev_stats->oerrors; + stats->imcasts += 0; + stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; + + prev_stats->ipackets = stats1.ipackets; + prev_stats->ibytes = stats1.ibytes; + prev_stats->opackets = stats1.opackets; + prev_stats->obytes = stats1.obytes; + prev_stats->imissed = stats1.imissed; + prev_stats->oerrors = stats1.oerrors; + prev_stats->ierrors = stats1.ierrors; + prev_stats->rx_nombuf = stats1.rx_nombuf; +} + + void CTRexExtendedDriverBase1GVm::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats){ struct rte_eth_stats stats1; struct rte_eth_stats *prev_stats = &stats->m_prev_stats; -- cgit 1.2.3-korg From f844ce6167867335d85277ed74bb0aa5490a5815 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 23 Jan 2017 18:39:22 +0200 Subject: DEBUG ONLY - MOVING TO RT MODE FOR REGRESSION WILL REVERT IN THE FOLLOWING DAY Signed-off-by: imarom --- src/main_dpdk.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/main_dpdk.cpp') diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 452baef2..6cd1c516 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -1253,6 +1253,10 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t po->set_tw_levels(lp->m_levels); } } + + /* DEBUG MODE FOR REGRESSION - REMOVE THIS */ + po->preview.set_rt_prio_mode(true); + return 0; } -- cgit 1.2.3-korg From 415852536c1aaedd6df672af20a30cea0908ce15 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 24 Jan 2017 10:24:08 +0200 Subject: revert the default RT test flag Signed-off-by: imarom --- src/main_dpdk.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/main_dpdk.cpp') diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 6cd1c516..1be84147 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -1254,9 +1254,6 @@ static int parse_options(int argc, char *argv[], CParserOption* po, bool first_t } } - /* DEBUG MODE FOR REGRESSION - REMOVE THIS */ - po->preview.set_rt_prio_mode(true); - return 0; } -- cgit 1.2.3-korg From 2155c64b103391cc5693ee849ad73d9b35f79903 Mon Sep 17 00:00:00 2001 From: Ido Barnea Date: Thu, 19 Jan 2017 18:09:38 +0200 Subject: Fixed support for i40evf + Refactor of VM drivers Signed-off-by: Ido Barnea --- .../regression/stateless_tests/stl_rx_test.py | 6 + src/main_dpdk.cpp | 332 ++++++--------------- 2 files changed, 104 insertions(+), 234 deletions(-) (limited to 'src/main_dpdk.cpp') diff --git a/scripts/automation/regression/stateless_tests/stl_rx_test.py b/scripts/automation/regression/stateless_tests/stl_rx_test.py index a3efa01d..3d4ed977 100644 --- a/scripts/automation/regression/stateless_tests/stl_rx_test.py +++ b/scripts/automation/regression/stateless_tests/stl_rx_test.py @@ -32,6 +32,12 @@ class STLRX_Test(CStlGeneral_Test): 'latency_9k_max_average': 100, 'latency_9k_max_latency': 250, }, + 'rte_i40evf_pmd': { + 'rate_percent': 80, + 'total_pkts': 1000, + 'rate_latency': 1, + 'latency_9k_enable': False, + }, 'rte_igb_pmd': { 'rate_percent': 80, 'total_pkts': 500, diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 1be84147..51c3197e 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -133,7 +133,6 @@ static char global_master_id_str[10]; class CTRexExtendedDriverBase { public: - /* by default NIC driver adds CRC */ virtual bool has_crc_added() { return true; @@ -154,6 +153,7 @@ public: } virtual int stop_queue(CPhyEthIF * _if, uint16_t q_num); + void get_extended_stats_fixed(CPhyEthIF * _if, CPhyEthIFStats *stats, int fix_i, int fix_o); virtual void get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats)=0; virtual void clear_extended_stats(CPhyEthIF * _if)=0; virtual int wait_for_stable_link(); @@ -237,10 +237,10 @@ public: virtual int set_rcv_all(CPhyEthIF * _if, bool set_on); }; -class CTRexExtendedDriverBase1GVm : public CTRexExtendedDriverBase { +class CTRexExtendedDriverVirtio : public CTRexExtendedDriverBase { public: - CTRexExtendedDriverBase1GVm(){ + CTRexExtendedDriverVirtio() { /* we are working in mode that we have 1 queue for rx and one queue for tx*/ CGlobalInfo::m_options.preview.set_vm_one_queue_enable(true); } @@ -254,12 +254,10 @@ public: } static CTRexExtendedDriverBase * create(){ - return ( new CTRexExtendedDriverBase1GVm() ); + return ( new CTRexExtendedDriverVirtio() ); } - virtual void update_global_config_fdir(port_cfg_t * cfg){ - - } + virtual void update_global_config_fdir(port_cfg_t * cfg) {} virtual int get_min_sample_rate(void){ return ( RX_CHECK_MIX_SAMPLE_RATE_1G); @@ -288,49 +286,53 @@ public: virtual int set_rcv_all(CPhyEthIF * _if, bool set_on) {return 0;} }; - -class CTRexExtendedDriverBaseVmxnet3 : public CTRexExtendedDriverBase1GVm { +class CTRexExtendedDriverVmxnet3 : public CTRexExtendedDriverVirtio { public: - static CTRexExtendedDriverBase * create(){ - return ( new CTRexExtendedDriverBaseVmxnet3() ); + CTRexExtendedDriverVmxnet3(){ + /* we are working in mode in which we have 1 queue for rx and one queue for tx*/ + CGlobalInfo::m_options.preview.set_vm_one_queue_enable(true); } - virtual void get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats); + static CTRexExtendedDriverBase * create() { + return ( new CTRexExtendedDriverVmxnet3() ); + } + + virtual void update_configuration(port_cfg_t * cfg); }; -class CTRexExtendedDriverBaseVirtio : public CTRexExtendedDriverBase1GVm { +class CTRexExtendedDriverI40evf : public CTRexExtendedDriverVirtio { public: - static CTRexExtendedDriverBase * create(){ - return ( new CTRexExtendedDriverBaseVmxnet3() ); + CTRexExtendedDriverI40evf(){ + /* we are working in mode in which we have 1 queue for rx and one queue for tx*/ + CGlobalInfo::m_options.preview.set_vm_one_queue_enable(true); + } + virtual void get_extended_stats(CPhyEthIF * _if, CPhyEthIFStats *stats) { + get_extended_stats_fixed(_if, stats, 0, 4); } - virtual void get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats); + virtual void update_configuration(port_cfg_t * cfg); + static CTRexExtendedDriverBase * create() { + return ( new CTRexExtendedDriverI40evf() ); + } }; - - -class CTRexExtendedDriverVf : public CTRexExtendedDriverBase1GVm { +class CTRexExtendedDriverIxgbevf : public CTRexExtendedDriverI40evf { public: - CTRexExtendedDriverVf(){ - /* we are working in mode in which we have we have 1 queue for rx and one queue for tx*/ + CTRexExtendedDriverIxgbevf(){ + /* we are working in mode in which we have 1 queue for rx and one queue for tx*/ CGlobalInfo::m_options.preview.set_vm_one_queue_enable(true); } virtual void get_extended_stats(CPhyEthIF * _if, CPhyEthIFStats *stats) { - uint64_t prev_ipackets = stats->ipackets; - uint64_t prev_opackets = stats->opackets; - - CTRexExtendedDriverBase1GVm::get_extended_stats(_if, stats); - // Since this driver report byte counts without Ethernet FCS (4 bytes), we need to fix the reported numbers - stats->ibytes += (stats->ipackets - prev_ipackets) * 4; - stats->obytes += (stats->opackets - prev_opackets) * 4; + get_extended_stats_fixed(_if, stats, 4, 4); } - static CTRexExtendedDriverBase * create(){ - return ( new CTRexExtendedDriverVf() ); + + static CTRexExtendedDriverBase * create() { + return ( new CTRexExtendedDriverIxgbevf() ); } }; -class CTRexExtendedDriverBaseE1000 : public CTRexExtendedDriverBase1GVm { +class CTRexExtendedDriverBaseE1000 : public CTRexExtendedDriverVirtio { CTRexExtendedDriverBaseE1000() { // E1000 driver is only relevant in VM in our case CGlobalInfo::m_options.preview.set_vm_one_queue_enable(true); @@ -617,11 +619,11 @@ private: register_driver(std::string("net_mlx5"),CTRexExtendedDriverBaseMlnx5G::create); /* virtual devices */ - register_driver(std::string("rte_em_pmd"),CTRexExtendedDriverBaseE1000::create); - register_driver(std::string("rte_vmxnet3_pmd"),CTRexExtendedDriverBaseVmxnet3::create); - register_driver(std::string("rte_virtio_pmd"),CTRexExtendedDriverBaseVirtio::create); - register_driver(std::string("rte_ixgbevf_pmd"),CTRexExtendedDriverVf::create); - register_driver(std::string("rte_i40evf_pmd"),CTRexExtendedDriverVf::create); + register_driver(std::string("rte_em_pmd"), CTRexExtendedDriverBaseE1000::create); + register_driver(std::string("rte_vmxnet3_pmd"), CTRexExtendedDriverVmxnet3::create); + register_driver(std::string("rte_virtio_pmd"), CTRexExtendedDriverVirtio::create); + register_driver(std::string("rte_i40evf_pmd"), CTRexExtendedDriverI40evf::create); + register_driver(std::string("rte_ixgbevf_pmd"), CTRexExtendedDriverIxgbevf::create); m_driver_was_set=false; m_drv=0; @@ -3715,6 +3717,7 @@ void CGlobalTRex::rx_sl_configure(void) { int CGlobalTRex::ixgbe_start(void){ int i; + for (i=0; ienable_rss_drop_workaround(); if ( get_vm_one_queue_enable() ) { - /* VMXNET3 does claim to support 16K but somehow does not work */ - /* reduce to 2000 */ m_port_cfg.m_port_conf.rxmode.max_rx_pkt_len = 2000; /* In VM case, there is one tx q and one rx q */ _if->configure(1, 1, &m_port_cfg.m_port_conf); // Only 1 rx queue, so use it for everything m_rx_core_tx_q_id = 0; _if->set_rx_queue(0); + // We usually have less memory in VM, so don't use the 9k pool. This means that large packets will + // be received in chain of few mbufs _if->rx_queue_setup(0, RTE_TEST_RX_DESC_VM_DEFAULT, socket_id, &m_port_cfg.m_rx_conf, CGlobalInfo::m_mem_pool[socket_id].m_mbuf_pool_2048); // 1 TX queue in VM case @@ -5921,6 +5924,35 @@ CFlowStatParser *CTRexExtendedDriverBase::get_flow_stat_parser() { return parser; } +void CTRexExtendedDriverBase::get_extended_stats_fixed(CPhyEthIF * _if, CPhyEthIFStats *stats, int fix_i, int fix_o) { + struct rte_eth_stats stats1; + struct rte_eth_stats *prev_stats = &stats->m_prev_stats; + rte_eth_stats_get(_if->get_port_id(), &stats1); + + stats->ipackets += stats1.ipackets - prev_stats->ipackets; + // Some drivers report input byte counts without Ethernet FCS (4 bytes), we need to fix the reported numbers + stats->ibytes += stats1.ibytes - prev_stats->ibytes + (stats1.ipackets - prev_stats->ipackets) * fix_i; + stats->opackets += stats1.opackets - prev_stats->opackets; + // Some drivers report output byte counts without Ethernet FCS (4 bytes), we need to fix the reported numbers + stats->obytes += stats1.obytes - prev_stats->obytes + (stats1.opackets - prev_stats->opackets) * fix_o; + stats->f_ipackets += 0; + stats->f_ibytes += 0; + stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf + - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; + stats->oerrors += stats1.oerrors - prev_stats->oerrors; + stats->imcasts += 0; + stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; + + prev_stats->ipackets = stats1.ipackets; + prev_stats->ibytes = stats1.ibytes; + prev_stats->opackets = stats1.opackets; + prev_stats->obytes = stats1.obytes; + prev_stats->imissed = stats1.imissed; + prev_stats->oerrors = stats1.oerrors; + prev_stats->ierrors = stats1.ierrors; + prev_stats->rx_nombuf = stats1.rx_nombuf; +} + // in 1G we need to wait if links became ready to soon void CTRexExtendedDriverBase1G::wait_after_link_up(){ wait_x_sec(6 + CGlobalInfo::m_options.m_wait_before_traffic); @@ -6701,31 +6733,7 @@ int CTRexExtendedDriverBase40G::dump_fdir_global_stats(CPhyEthIF * _if, FILE *fd } void CTRexExtendedDriverBase40G::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats) { - struct rte_eth_stats stats1; - struct rte_eth_stats *prev_stats = &stats->m_prev_stats; - rte_eth_stats_get(_if->get_port_id(), &stats1); - - stats->ipackets += stats1.ipackets - prev_stats->ipackets; - stats->ibytes += stats1.ibytes - prev_stats->ibytes; - stats->opackets += stats1.opackets - prev_stats->opackets; - // Since this driver report obytes count without Ethernet FCS (4 bytes), we need to fix the reported numbers - stats->obytes += stats1.obytes - prev_stats->obytes + (stats1.opackets - prev_stats->opackets) * 4; - stats->f_ipackets += 0; - stats->f_ibytes += 0; - stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf - - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; - stats->oerrors += stats1.oerrors - prev_stats->oerrors; - stats->imcasts += 0; - stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; - - prev_stats->ipackets = stats1.ipackets; - prev_stats->ibytes = stats1.ibytes; - prev_stats->opackets = stats1.opackets; - prev_stats->obytes = stats1.obytes; - prev_stats->imissed = stats1.imissed; - prev_stats->oerrors = stats1.oerrors; - prev_stats->ierrors = stats1.ierrors; - prev_stats->rx_nombuf = stats1.rx_nombuf; + get_extended_stats_fixed(_if, stats, 0, 4); } int CTRexExtendedDriverBase40G::wait_for_stable_link(){ @@ -6945,33 +6953,7 @@ int CTRexExtendedDriverBaseMlnx5G::dump_fdir_global_stats(CPhyEthIF * _if, FILE } void CTRexExtendedDriverBaseMlnx5G::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats){ - - struct rte_eth_stats stats1; - struct rte_eth_stats *prev_stats = &stats->m_prev_stats; - rte_eth_stats_get(_if->get_port_id(), &stats1); - - stats->ipackets += stats1.ipackets - prev_stats->ipackets; - stats->ibytes += stats1.ibytes - prev_stats->ibytes + - + (stats1.ipackets << 2) - (prev_stats->ipackets << 2); - stats->opackets += stats1.opackets - prev_stats->opackets; - stats->obytes += stats1.obytes - prev_stats->obytes - + (stats1.opackets << 2) - (prev_stats->opackets << 2); - stats->f_ipackets += 0; - stats->f_ibytes += 0; - stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf - - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; - stats->oerrors += stats1.oerrors - prev_stats->oerrors; - stats->imcasts += 0; - stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; - - prev_stats->ipackets = stats1.ipackets; - prev_stats->ibytes = stats1.ibytes; - prev_stats->opackets = stats1.opackets; - prev_stats->obytes = stats1.obytes; - prev_stats->imissed = stats1.imissed; - prev_stats->oerrors = stats1.oerrors; - prev_stats->ierrors = stats1.ierrors; - prev_stats->rx_nombuf = stats1.rx_nombuf; + get_extended_stats_fixed(_if, stats, 4, 4); } int CTRexExtendedDriverBaseMlnx5G::wait_for_stable_link(){ @@ -7108,31 +7090,8 @@ void CTRexExtendedDriverBaseVIC::clear_extended_stats(CPhyEthIF * _if){ } void CTRexExtendedDriverBaseVIC::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats) { - struct rte_eth_stats stats1; - struct rte_eth_stats *prev_stats = &stats->m_prev_stats; - rte_eth_stats_get(_if->get_port_id(), &stats1); - - stats->ipackets += stats1.ipackets - prev_stats->ipackets; - stats->ibytes += stats1.ibytes - prev_stats->ibytes - - ((stats1.ipackets << 2) - (prev_stats->ipackets << 2)); - stats->opackets += stats1.opackets - prev_stats->opackets; - stats->obytes += stats1.obytes - prev_stats->obytes; - stats->f_ipackets += 0; - stats->f_ibytes += 0; - stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf - - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; - stats->oerrors += stats1.oerrors - prev_stats->oerrors; - stats->imcasts += 0; - stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; - - prev_stats->ipackets = stats1.ipackets; - prev_stats->ibytes = stats1.ibytes; - prev_stats->opackets = stats1.opackets; - prev_stats->obytes = stats1.obytes; - prev_stats->imissed = stats1.imissed; - prev_stats->oerrors = stats1.oerrors; - prev_stats->ierrors = stats1.ierrors; - prev_stats->rx_nombuf = stats1.rx_nombuf; + // In VIC, we need to reduce 4 bytes from the amount reported for each incoming packet + get_extended_stats_fixed(_if, stats, -4, 0); } int CTRexExtendedDriverBaseVIC::verify_fw_ver(int port_id) { @@ -7190,151 +7149,56 @@ CFlowStatParser *CTRexExtendedDriverBaseVIC::get_flow_stat_parser() { ///////////////////////////////////////////////////////////////////////////////////// - - -void CTRexExtendedDriverBase1GVm::update_configuration(port_cfg_t * cfg){ - struct rte_eth_dev_info dev_info; - rte_eth_dev_info_get((uint8_t) 0,&dev_info); - +void CTRexExtendedDriverVirtio::update_configuration(port_cfg_t * cfg){ cfg->m_tx_conf.tx_thresh.pthresh = TX_PTHRESH_1G; cfg->m_tx_conf.tx_thresh.hthresh = TX_HTHRESH; cfg->m_tx_conf.tx_thresh.wthresh = 0; - cfg->m_tx_conf.txq_flags=dev_info.default_txconf.txq_flags; - + // must have this, otherwise the driver fail at init + cfg->m_tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOXSUMS; } - -int CTRexExtendedDriverBase1GVm::configure_rx_filter_rules(CPhyEthIF * _if){ +int CTRexExtendedDriverVirtio::configure_rx_filter_rules(CPhyEthIF * _if){ return (0); } -void CTRexExtendedDriverBase1GVm::clear_extended_stats(CPhyEthIF * _if){ - +void CTRexExtendedDriverVirtio::clear_extended_stats(CPhyEthIF * _if){ rte_eth_stats_reset(_if->get_port_id()); - } -int CTRexExtendedDriverBase1GVm::stop_queue(CPhyEthIF * _if, uint16_t q_num) { +int CTRexExtendedDriverVirtio::stop_queue(CPhyEthIF * _if, uint16_t q_num) { return (0); } void CTRexExtendedDriverBaseE1000::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats){ - struct rte_eth_stats stats1; - struct rte_eth_stats *prev_stats = &stats->m_prev_stats; - rte_eth_stats_get(_if->get_port_id(), &stats1); - - stats->ipackets += stats1.ipackets - prev_stats->ipackets; - stats->ibytes += stats1.ibytes - prev_stats->ibytes ; - stats->opackets += stats1.opackets - prev_stats->opackets; - stats->obytes += stats1.obytes - prev_stats->obytes + (stats1.opackets - prev_stats->opackets) * 4; - stats->f_ipackets += 0; - stats->f_ibytes += 0; - stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf - - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; - stats->oerrors += stats1.oerrors - prev_stats->oerrors; - stats->imcasts += 0; - stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; - - prev_stats->ipackets = stats1.ipackets; - prev_stats->ibytes = stats1.ibytes; - prev_stats->opackets = stats1.opackets; - prev_stats->obytes = stats1.obytes; - prev_stats->imissed = stats1.imissed; - prev_stats->oerrors = stats1.oerrors; - prev_stats->ierrors = stats1.ierrors; - prev_stats->rx_nombuf = stats1.rx_nombuf; + get_extended_stats_fixed(_if, stats, 0, 4); } - -void CTRexExtendedDriverBaseVirtio::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats){ - struct rte_eth_stats stats1; - struct rte_eth_stats *prev_stats = &stats->m_prev_stats; - rte_eth_stats_get(_if->get_port_id(), &stats1); - - stats->ipackets += stats1.ipackets - prev_stats->ipackets; - stats->ibytes += stats1.ibytes - prev_stats->ibytes +(stats1.ipackets - prev_stats->ipackets) * 4; - stats->opackets += stats1.opackets - prev_stats->opackets; - stats->obytes += stats1.obytes - prev_stats->obytes + (stats1.opackets - prev_stats->opackets) * 4; - stats->f_ipackets += 0; - stats->f_ibytes += 0; - stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf - - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; - stats->oerrors += stats1.oerrors - prev_stats->oerrors; - stats->imcasts += 0; - stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; - - prev_stats->ipackets = stats1.ipackets; - prev_stats->ibytes = stats1.ibytes; - prev_stats->opackets = stats1.opackets; - prev_stats->obytes = stats1.obytes; - prev_stats->imissed = stats1.imissed; - prev_stats->oerrors = stats1.oerrors; - prev_stats->ierrors = stats1.ierrors; - prev_stats->rx_nombuf = stats1.rx_nombuf; +void CTRexExtendedDriverVirtio::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats) { + get_extended_stats_fixed(_if, stats, 4, 4); } -void CTRexExtendedDriverBaseVmxnet3::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats){ - struct rte_eth_stats stats1; - struct rte_eth_stats *prev_stats = &stats->m_prev_stats; - rte_eth_stats_get(_if->get_port_id(), &stats1); - - stats->ipackets += stats1.ipackets - prev_stats->ipackets; - stats->ibytes += stats1.ibytes - prev_stats->ibytes +(stats1.ipackets - prev_stats->ipackets) * 4; - stats->opackets += stats1.opackets - prev_stats->opackets; - stats->obytes += stats1.obytes - prev_stats->obytes + (stats1.opackets - prev_stats->opackets) * 4; - stats->f_ipackets += 0; - stats->f_ibytes += 0; - stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf - - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; - stats->oerrors += stats1.oerrors - prev_stats->oerrors; - stats->imcasts += 0; - stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; - - prev_stats->ipackets = stats1.ipackets; - prev_stats->ibytes = stats1.ibytes; - prev_stats->opackets = stats1.opackets; - prev_stats->obytes = stats1.obytes; - prev_stats->imissed = stats1.imissed; - prev_stats->oerrors = stats1.oerrors; - prev_stats->ierrors = stats1.ierrors; - prev_stats->rx_nombuf = stats1.rx_nombuf; +int CTRexExtendedDriverVirtio::wait_for_stable_link(){ + wait_x_sec(CGlobalInfo::m_options.m_wait_before_traffic); + return (0); } - -void CTRexExtendedDriverBase1GVm::get_extended_stats(CPhyEthIF * _if,CPhyEthIFStats *stats){ - struct rte_eth_stats stats1; - struct rte_eth_stats *prev_stats = &stats->m_prev_stats; - rte_eth_stats_get(_if->get_port_id(), &stats1); - - stats->ipackets += stats1.ipackets - prev_stats->ipackets; - stats->ibytes += stats1.ibytes - prev_stats->ibytes; - stats->opackets += stats1.opackets - prev_stats->opackets; - stats->obytes += stats1.obytes - prev_stats->obytes; - stats->f_ipackets += 0; - stats->f_ibytes += 0; - stats->ierrors += stats1.imissed + stats1.ierrors + stats1.rx_nombuf - - prev_stats->imissed - prev_stats->ierrors - prev_stats->rx_nombuf; - stats->oerrors += stats1.oerrors - prev_stats->oerrors; - stats->imcasts += 0; - stats->rx_nombuf += stats1.rx_nombuf - prev_stats->rx_nombuf; - - prev_stats->ipackets = stats1.ipackets; - prev_stats->ibytes = stats1.ibytes; - prev_stats->opackets = stats1.opackets; - prev_stats->obytes = stats1.obytes; - prev_stats->imissed = stats1.imissed; - prev_stats->oerrors = stats1.oerrors; - prev_stats->ierrors = stats1.ierrors; - prev_stats->rx_nombuf = stats1.rx_nombuf; +/////////////////////////////////////////////////////////// VMxnet3 +void CTRexExtendedDriverVmxnet3::update_configuration(port_cfg_t * cfg){ + cfg->m_tx_conf.tx_thresh.pthresh = TX_PTHRESH_1G; + cfg->m_tx_conf.tx_thresh.hthresh = TX_HTHRESH; + cfg->m_tx_conf.tx_thresh.wthresh = 0; + // must have this, otherwise the driver fail at init + cfg->m_tx_conf.txq_flags |= ETH_TXQ_FLAGS_NOXSUMSCTP; } -int CTRexExtendedDriverBase1GVm::wait_for_stable_link(){ - wait_x_sec(CGlobalInfo::m_options.m_wait_before_traffic); - return (0); +///////////////////////////////////////////////////////// VF +void CTRexExtendedDriverI40evf::update_configuration(port_cfg_t * cfg) { + cfg->m_tx_conf.tx_thresh.pthresh = TX_PTHRESH; + cfg->m_tx_conf.tx_thresh.hthresh = TX_HTHRESH; + cfg->m_tx_conf.tx_thresh.wthresh = TX_WTHRESH; } - /** * convert chain of mbuf to one big mbuf * -- cgit 1.2.3-korg