make -l work with client config 19/4019/1
authorIdo Barnea <[email protected]>
Sun, 27 Nov 2016 09:43:08 +0000 (11:43 +0200)
committerIdo Barnea <[email protected]>
Sun, 27 Nov 2016 09:43:08 +0000 (11:43 +0200)
Signed-off-by: Ido Barnea <[email protected]>
src/main_dpdk.cpp
src/pre_test.cpp
src/utl_ip.cpp
src/utl_ip.h

index 5680b61..6f18b0b 100644 (file)
@@ -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++) {
index 593d5f0..df753be 100644 (file)
@@ -503,6 +503,7 @@ void CPretest::get_results(CManyIPInfo &resolved_ips) {
         for (std::vector<COneIPInfo *>::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));
index 5bd83f9..e7bb6fa 100644 (file)
@@ -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 {
index 3a133a1..95db588 100644 (file)
@@ -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, "");
     }