diff options
Diffstat (limited to 'src/main_dpdk.cpp')
-rw-r--r-- | src/main_dpdk.cpp | 94 |
1 files changed, 58 insertions, 36 deletions
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 3466572c..f8f365c8 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -3117,6 +3117,8 @@ public: void dump_config(FILE *fd); void dump_links_status(FILE *fd); + bool lookup_port_by_mac(const uint8_t *mac, uint8_t &port_id); + public: port_cfg_t m_port_cfg; uint32_t m_max_ports; /* active number of ports supported options are 2,4,8,10,12 */ @@ -3178,11 +3180,6 @@ void CGlobalTRex::pre_test() { // If we got src MAC for port in global config, take it, otherwise use src MAC from DPDK uint8_t port_macs[m_max_ports][ETHER_ADDR_LEN]; for (int port_id = 0; port_id < m_max_ports; port_id++) { - uint8_t empty_mac[ETHER_ADDR_LEN] = {0,0,0,0,0,0}; - if (! memcmp( CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.src, empty_mac, ETHER_ADDR_LEN)) { - rte_eth_macaddr_get(port_id, - (struct ether_addr *)&CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.src); - } memcpy(port_macs[port_id], CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.src, ETHER_ADDR_LEN); } @@ -3225,16 +3222,9 @@ void CGlobalTRex::pre_test() { } else { resolve_needed = false; } - if (! memcmp( CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.src, empty_mac, ETHER_ADDR_LEN)) { - rte_eth_macaddr_get(port_id, - (struct ether_addr *)&CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.src); - need_grat_arp[port_id] = true; - } else { - // If we got src MAC from config file, do not send gratuitous ARP for it - // (for compatibility with old behaviour) - need_grat_arp[port_id] = false; - } - + + need_grat_arp[port_id] = CGlobalInfo::m_options.m_ip_cfg[port_id].get_ip() != 0; + pretest.add_ip(port_id, CGlobalInfo::m_options.m_ip_cfg[port_id].get_ip() , CGlobalInfo::m_options.m_ip_cfg[port_id].get_vlan() , CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.src); @@ -3344,17 +3334,32 @@ void CGlobalTRex::pre_test() { // Configure port back to normal mode. Only relevant packets handled by software. CTRexExtendedDriverDb::Ins()->get_drv()->set_rcv_all(pif, false); - /* set resolved IPv4 */ - uint32_t dg = CGlobalInfo::m_options.m_ip_cfg[port_id].get_def_gw(); - const uint8_t *dst_mac = CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.dest; - if (dg) { - m_ports[port_id].get_port_attr()->get_dest().set_dest(dg, dst_mac); - } else { - m_ports[port_id].get_port_attr()->get_dest().set_dest(dst_mac); } + } + + /* for stateless only - set port mode */ + if (get_is_stateless()) { + for (int port_id = 0; port_id < m_max_ports; port_id++) { + uint32_t src_ipv4 = CGlobalInfo::m_options.m_ip_cfg[port_id].get_ip(); + uint32_t dg = CGlobalInfo::m_options.m_ip_cfg[port_id].get_def_gw(); + const uint8_t *dst_mac = CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.dest; + + /* L3 mode */ + if (src_ipv4 && dg) { + if (memcmp(dst_mac, empty_mac, 6) == 0) { + m_trex_stateless->get_port_by_id(port_id)->set_l3_mode(src_ipv4, dg); + } else { + m_trex_stateless->get_port_by_id(port_id)->set_l3_mode(src_ipv4, dg, dst_mac); + } + /* L2 mode */ + } else { + m_trex_stateless->get_port_by_id(port_id)->set_l2_mode(dst_mac); + } } } + + } /** @@ -3675,9 +3680,7 @@ int CGlobalTRex::ixgbe_start(void){ if (! get_is_stateless()) { ixgbe_configure_mg(); - } else { - rx_sl_configure(); - } + } /* core 0 - control @@ -3816,6 +3819,8 @@ bool CGlobalTRex::Create(){ cfg.m_publisher = &m_zmq_publisher; m_trex_stateless = new TrexStateless(cfg); + + rx_sl_configure(); } return (true); @@ -3979,6 +3984,16 @@ void CGlobalTRex::dump_links_status(FILE *fd){ } } +bool CGlobalTRex::lookup_port_by_mac(const uint8_t *mac, uint8_t &port_id) { + for (int i = 0; i < m_max_ports; i++) { + if (memcmp(m_ports[i].get_port_attr()->get_src_mac(), mac, 6) == 0) { + port_id = i; + return true; + } + } + + return false; +} void CGlobalTRex::dump_post_test_stats(FILE *fd){ uint64_t pkt_out=0; @@ -4977,7 +4992,13 @@ void CPhyEthIF::configure_rss_redirect_table(uint16_t numer_of_queues, void CPhyEthIF::update_counters() { get_ex_drv()->get_extended_stats(this, &m_stats); CRXCoreIgnoreStat ign_stats; - g_trex.m_mg.get_ignore_stats(m_port_id, ign_stats, true); + + if (get_is_stateless()) { + g_trex.m_rx_sl.get_ignore_stats(m_port_id, ign_stats, true); + } else { + g_trex.m_mg.get_ignore_stats(m_port_id, ign_stats, true); + } + m_stats.obytes -= ign_stats.get_tx_bytes(); m_stats.opackets -= ign_stats.get_tx_pkts(); m_ignore_stats.opackets += ign_stats.get_tx_pkts(); @@ -4997,16 +5018,11 @@ bool CPhyEthIF::Create(uint8_t portid) { m_last_tx_pps = 0.0; m_port_attr = g_trex.m_drv->create_port_attr(portid); - - uint32_t src_ipv4 = CGlobalInfo::m_options.m_ip_cfg[m_port_id].get_ip(); - if (src_ipv4) { - m_port_attr->set_src_ipv4(src_ipv4); - } - - /* for now set as unresolved IPv4 destination */ - uint32_t dest_ipv4 = CGlobalInfo::m_options.m_ip_cfg[m_port_id].get_def_gw(); - if (dest_ipv4) { - m_port_attr->get_dest().set_dest(dest_ipv4); + /* set src MAC addr */ + uint8_t empty_mac[ETHER_ADDR_LEN] = {0,0,0,0,0,0}; + if (! memcmp( CGlobalInfo::m_options.m_mac_addr[m_port_id].u.m_mac.src, empty_mac, ETHER_ADDR_LEN)) { + rte_eth_macaddr_get(m_port_id, + (struct ether_addr *)&CGlobalInfo::m_options.m_mac_addr[m_port_id].u.m_mac.src); } return true; @@ -7365,6 +7381,11 @@ int DpdkTRexPortAttr::set_rx_filter_mode(rx_filter_mode_e rx_filter_mode) { return (0); } +bool DpdkTRexPortAttr::is_loopback() const { + uint8_t port_id; + return g_trex.lookup_port_by_mac(m_dest.get_dest_mac(), port_id); +} + /** * marks the control plane for a total server shutdown * @@ -7373,3 +7394,4 @@ int DpdkTRexPortAttr::set_rx_filter_mode(rx_filter_mode_e rx_filter_mode) { void TrexDpdkPlatformApi::mark_for_shutdown() const { g_trex.mark_for_shutdown(CGlobalTRex::SHUTDOWN_RPC_REQ); } + |