diff options
author | 2016-02-24 06:28:10 -0500 | |
---|---|---|
committer | 2016-02-24 06:29:06 -0500 | |
commit | 252b8ab3f41a18af8561cece71cf07bc9872f39f (patch) | |
tree | 60ca5bedb147d54198ca806b5ce6dfe37d5f0f41 /src | |
parent | 146525ddd44618bc5664cd632a86ff14be1c3ba9 (diff) |
virtual NICs does not add 4 bytes of CRC
Diffstat (limited to 'src')
-rw-r--r-- | src/internal_api/trex_platform_api.h | 20 | ||||
-rwxr-xr-x | src/main_dpdk.cpp | 15 | ||||
-rw-r--r-- | src/sim/trex_sim.h | 6 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.cpp | 2 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.h | 13 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream.cpp | 10 | ||||
-rw-r--r-- | src/stateless/cp/trex_stream.h | 16 |
7 files changed, 66 insertions, 16 deletions
diff --git a/src/internal_api/trex_platform_api.h b/src/internal_api/trex_platform_api.h index f8bc10d5..67288b19 100644 --- a/src/internal_api/trex_platform_api.h +++ b/src/internal_api/trex_platform_api.h @@ -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 {} diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp index 701ae13e..608a05b3 100755 --- a/src/main_dpdk.cpp +++ b/src/main_dpdk.cpp @@ -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 diff --git a/src/sim/trex_sim.h b/src/sim/trex_sim.h index 21498978..48e038db 100644 --- a/src/sim/trex_sim.h +++ b/src/sim/trex_sim.h @@ -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 { diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index 99b6565c..6ac93577 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -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); diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h index 49e69757..df52e751 100644 --- a/src/stateless/cp/trex_stateless_port.h +++ b/src/stateless/cp/trex_stateless_port.h @@ -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; diff --git a/src/stateless/cp/trex_stream.cpp b/src/stateless/cp/trex_stream.cpp index f1c93a11..7ea90895 100644 --- a/src/stateless/cp/trex_stream.cpp +++ b/src/stateless/cp/trex_stream.cpp @@ -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; } diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h index cc05c198..088478bb 100644 --- a/src/stateless/cp/trex_stream.h +++ b/src/stateless/cp/trex_stream.h @@ -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()); } |