From 4c8363eaa42497fe51ce927f06a46b1a60a2169e Mon Sep 17 00:00:00 2001 From: Ido Barnea Date: Sun, 27 Nov 2016 11:43:08 +0200 Subject: make -l work with client config Signed-off-by: Ido Barnea --- src/main_dpdk.cpp | 22 ++++++++++++++++++++-- src/pre_test.cpp | 1 + src/utl_ip.cpp | 10 ++++++++-- src/utl_ip.h | 1 + 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 5680b61f..6f18b0b8 100644 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -3283,15 +3283,33 @@ void CGlobalTRex::pre_test() { fprintf(stderr, "Resolution of following IPs failed. Exiting.\n"); for (const COneIPInfo *ip=pretest_result.get_next(); ip != NULL; ip = pretest_result.get_next()) { - ip->dump(stderr); + if (ip->resolve_needed()) { + ip->dump(stderr, " "); + } } - exit(-1); + exit(1); } m_fl.set_client_config_resolved_macs(pretest_result); if ( CGlobalInfo::m_options.preview.getVMode() > 1) { m_fl.dump_client_config(stdout); } + bool port_found[TREX_MAX_PORTS]; + for (int port_id = 0; port_id < m_max_ports; port_id++) { + port_found[port_id] = false; + } + // If client config enabled, we don't resolve MACs from trex_cfg.yaml. For latency (-l) + // We need to able to send packets from RX core, so need to configure MAC/vlan for each port. + for (const COneIPInfo *ip=pretest_result.get_next(); ip != NULL; ip = pretest_result.get_next()) { + // Use first MAC/vlan we see on each port + uint8_t port_id = ip->get_port(); + uint16_t vlan = ip->get_vlan(); + if ( ! port_found[port_id]) { + port_found[port_id] = true; + ip->get_mac(CGlobalInfo::m_options.m_mac_addr[port_id].u.m_mac.dest); + CGlobalInfo::m_options.m_ip_cfg[port_id].set_vlan(vlan); + } + } } else { uint8_t mac[ETHER_ADDR_LEN]; for (int port_id = 0; port_id < m_max_ports; port_id++) { diff --git a/src/pre_test.cpp b/src/pre_test.cpp index 593d5f07..df753be5 100644 --- a/src/pre_test.cpp +++ b/src/pre_test.cpp @@ -503,6 +503,7 @@ void CPretest::get_results(CManyIPInfo &resolved_ips) { for (std::vector::iterator it = m_port_info[port].m_dst_info.begin() ; it != m_port_info[port].m_dst_info.end(); ++it) { uint8_t ip_type = (*it)->ip_ver(); + (*it)->set_port(port); switch(ip_type) { case COneIPInfo::IP4_VER: resolved_ips.insert(*(COneIPv4Info *)(*it)); diff --git a/src/utl_ip.cpp b/src/utl_ip.cpp index 5bd83f95..e7bb6fab 100644 --- a/src/utl_ip.cpp +++ b/src/utl_ip.cpp @@ -29,8 +29,14 @@ void COneIPInfo::dump(FILE *fd, const char *offset) const { get_ip_str(ip_str); std::string mac_str; utl_macaddr_to_str(mac, mac_str); - const char *mac_char = resolve_needed() ? "Not resolved" : mac_str.c_str(); - fprintf(fd, "%sip: %s vlan: %d port: %d mac: %s\n", offset, ip_str, m_vlan, m_port, mac_char); + const char *mac_char = resolve_needed() ? "Unknown" : mac_str.c_str(); + fprintf(fd, "%sip: %s ", offset, ip_str); + if (m_vlan != 0) + fprintf(fd, "vlan: %d ", m_vlan); + if (m_port != UINT8_MAX) + fprintf(fd, "port: %d ", m_port); + fprintf(fd, "mac: %s", mac_char); + fprintf(fd, "\n"); } bool COneIPInfo::resolve_needed() const { diff --git a/src/utl_ip.h b/src/utl_ip.h index 3a133a15..95db588a 100644 --- a/src/utl_ip.h +++ b/src/utl_ip.h @@ -113,6 +113,7 @@ class COneIPInfo { } uint16_t get_vlan() const {return m_vlan;} uint16_t get_port() const {return m_port;} + void set_port(uint8_t port) {m_port = port;} virtual void dump(FILE *fd) const { dump(fd, ""); } -- cgit 1.2.3-korg