virtual NICs does not add 4 bytes of CRC
authorimarom <[email protected]>
Wed, 24 Feb 2016 11:28:10 +0000 (06:28 -0500)
committerimarom <[email protected]>
Wed, 24 Feb 2016 11:29:06 +0000 (06:29 -0500)
src/internal_api/trex_platform_api.h
src/main_dpdk.cpp
src/sim/trex_sim.h
src/stateless/cp/trex_stateless_port.cpp
src/stateless/cp/trex_stateless_port.h
src/stateless/cp/trex_stream.cpp
src/stateless/cp/trex_stream.h

index f8bc10d..67288b1 100644 (file)
@@ -109,7 +109,11 @@ public:
     virtual void port_id_to_cores(uint8_t port_id, std::vector<std::pair<uint8_t, uint8_t>> &cores_id_list) const = 0;
     virtual void get_global_stats(TrexPlatformGlobalStats &stats) const = 0;
     virtual void get_interface_stats(uint8_t interface_id, TrexPlatformInterfaceStats &stats) const = 0;
-    virtual void get_interface_info(uint8_t interface_id, std::string &driver_name, driver_speed_e &speed) const = 0;
+
+    virtual void get_interface_info(uint8_t interface_id, std::string &driver_name,
+                                    driver_speed_e &speed,
+                                    bool &has_crc) const = 0;
+
     virtual void publish_async_data_now(uint32_t key) const = 0;
     virtual uint8_t get_dp_core_count() const = 0;
     
@@ -127,7 +131,12 @@ public:
     void port_id_to_cores(uint8_t port_id, std::vector<std::pair<uint8_t, uint8_t>> &cores_id_list) const;
     void get_global_stats(TrexPlatformGlobalStats &stats) const;
     void get_interface_stats(uint8_t interface_id, TrexPlatformInterfaceStats &stats) const;
-    void get_interface_info(uint8_t interface_id, std::string &driver_name, driver_speed_e &speed) const;
+
+    void get_interface_info(uint8_t interface_id,
+                            std::string &driver_name,
+                            driver_speed_e &speed,
+                            bool &has_crc) const;
+
     void publish_async_data_now(uint32_t key) const;
     uint8_t get_dp_core_count() const;
     
@@ -143,9 +152,14 @@ public:
     void port_id_to_cores(uint8_t port_id, std::vector<std::pair<uint8_t, uint8_t>> &cores_id_list) const;
     void get_global_stats(TrexPlatformGlobalStats &stats) const;
     void get_interface_stats(uint8_t interface_id, TrexPlatformInterfaceStats &stats) const;
-    void get_interface_info(uint8_t interface_id, std::string &driver_name, driver_speed_e &speed) const {
+
+    void get_interface_info(uint8_t interface_id,
+                            std::string &driver_name,
+                            driver_speed_e &speed,
+                            bool &has_crc) const {
         driver_name = "MOCK";
         speed = SPEED_INVALID;
+        has_crc = false;
     }
 
     void publish_async_data_now(uint32_t key) const {}
index 701ae13..608a05b 100755 (executable)
@@ -127,6 +127,11 @@ public:
 
     virtual TrexPlatformApi::driver_speed_e get_driver_speed(uint8_t port_id) = 0;
 
+    /* by default NIC driver adds CRC */
+    virtual bool has_crc_added() {
+        return true;
+    }
+
     virtual int get_min_sample_rate(void)=0;
     virtual void update_configuration(port_cfg_t * cfg)=0;
     virtual void update_global_config_fdir(port_cfg_t * cfg)=0;
@@ -201,6 +206,10 @@ public:
         return TrexPlatformApi::SPEED_1G;
     }
 
+    virtual bool has_crc_added() {
+        return false;
+    }
+
     static CTRexExtendedDriverBase * create(){
         return ( new CTRexExtendedDriverBase1GVm() );
     }
@@ -4927,10 +4936,12 @@ TrexDpdkPlatformApi::port_id_to_cores(uint8_t port_id, std::vector<std::pair<uin
 void
 TrexDpdkPlatformApi::get_interface_info(uint8_t port_id,
                                         std::string &driver_name,
-                                        driver_speed_e &speed) const {
+                                        driver_speed_e &speed,
+                                        bool &has_crc) const {
 
     driver_name = CTRexExtendedDriverDb::Ins()->get_driver_name();
-    speed = CTRexExtendedDriverDb::Ins()->get_drv()->get_driver_speed(port_id);
+    speed       = CTRexExtendedDriverDb::Ins()->get_drv()->get_driver_speed(port_id);
+    has_crc     = CTRexExtendedDriverDb::Ins()->get_drv()->has_crc_added();
 }
 
 void
index 2149897..48e038d 100644 (file)
@@ -54,9 +54,13 @@ public:
     virtual void get_global_stats(TrexPlatformGlobalStats &stats) const {
     }
 
-    virtual void get_interface_info(uint8_t interface_id, std::string &driver_name, driver_speed_e &speed) const {
+    virtual void get_interface_info(uint8_t interface_id,
+                                    std::string &driver_name,
+                                    driver_speed_e &speed,
+                                    bool &has_crc) const {
         driver_name = "TEST";
         speed = TrexPlatformApi::SPEED_10G;
+        has_crc = true;
     }
 
     virtual void get_interface_stats(uint8_t interface_id, TrexPlatformInterfaceStats &stats) const {
index 99b6565..6ac9357 100644 (file)
@@ -59,7 +59,7 @@ TrexStatelessPort::TrexStatelessPort(uint8_t port_id, const TrexPlatformApi *api
     m_port_state = PORT_STATE_IDLE;
 
     /* get the platform specific data */
-    api->get_interface_info(port_id, m_driver_name, m_speed);
+    api->get_interface_info(port_id, m_driver_name, m_speed, m_has_crc);
 
     /* get the DP cores belonging to this port */
     api->port_id_to_cores(m_port_id, core_pair_list);
index 49e6975..df52e75 100644 (file)
@@ -308,6 +308,18 @@ public:
      */
     uint64_t get_port_speed_bps() const;
 
+    /**
+     * return true if port adds CRC to a packet (not occurs for 
+     * VNICs) 
+     * 
+     * @author imarom (24-Feb-16)
+     * 
+     * @return bool 
+     */
+    bool has_crc_added() const {
+        return m_has_crc;
+    }
+
     TrexPortOwner & get_owner() {
         return m_owner;
     }
@@ -382,6 +394,7 @@ private:
     uint8_t            m_port_id;
     port_state_e       m_port_state;
     std::string        m_driver_name;
+    bool               m_has_crc;
 
     TrexPlatformApi::driver_speed_e m_speed;
 
index f1c93a1..7ea9089 100644 (file)
@@ -254,5 +254,13 @@ TrexStreamRate::get_line_speed_bps() {
 
 double
 TrexStreamRate::get_pkt_size() {
-    return m_stream.get_pkt_size();
+    TrexStatelessPort *port = get_stateless_obj()->get_port_by_id(m_stream.m_port_id);
+
+    double pkt_size = m_stream.get_pkt_size();
+
+    if (port->has_crc_added()) {
+        pkt_size += 4;
+    }
+
+    return pkt_size;
 }
index cc05c19..088478b 100644 (file)
@@ -244,29 +244,29 @@ private:
     double get_pkt_size();
 
     void calculate_from_pps() {
-        m_bps_L1     = m_pps * (get_pkt_size() + 24) * 8;
-        m_bps_L2     = m_pps * (get_pkt_size() + 4) * 8;
+        m_bps_L1     = m_pps * (get_pkt_size() + 20) * 8;
+        m_bps_L2     = m_pps * get_pkt_size() * 8;
         m_percentage = (m_bps_L1 / get_line_speed_bps()) * 100.0;
     }
 
 
     void calculate_from_bps_L1() {
-        m_bps_L2     = m_bps_L1 * ( (get_pkt_size() + 4.0) / (get_pkt_size() + 24.0) );
-        m_pps        = m_bps_L2 / (8 * (get_pkt_size() + 4));
+        m_bps_L2     = m_bps_L1 * ( get_pkt_size() / (get_pkt_size() + 20.0) );
+        m_pps        = m_bps_L2 / (8 * get_pkt_size());
         m_percentage = (m_bps_L1 / get_line_speed_bps()) * 100.0;
     }
 
 
     void calculate_from_bps_L2() {
-        m_bps_L1     = m_bps_L2 * ( (get_pkt_size() + 24.0) / (get_pkt_size() + 4.0));
-        m_pps        = m_bps_L2 / (8 * (get_pkt_size() + 4));
+        m_bps_L1     = m_bps_L2 * ( (get_pkt_size() + 20.0) / get_pkt_size());
+        m_pps        = m_bps_L2 / (8 * get_pkt_size());
         m_percentage = (m_bps_L1 / get_line_speed_bps()) * 100.0;
     }
 
     void calculate_from_percentage() {
         m_bps_L1     = (m_percentage / 100.0) * get_line_speed_bps();
-        m_bps_L2     = m_bps_L1 * ( (get_pkt_size() + 4.0) / (get_pkt_size() + 24.0) );
-        m_pps        = m_bps_L2 / (8 * (get_pkt_size() + 4));
+        m_bps_L2     = m_bps_L1 * ( get_pkt_size() / (get_pkt_size() + 20.0) );
+        m_pps        = m_bps_L2 / (8 * get_pkt_size());
 
     }