summaryrefslogtreecommitdiffstats
path: root/src/stateless/cp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-24 06:28:10 -0500
committerimarom <imarom@cisco.com>2016-02-24 06:29:06 -0500
commit252b8ab3f41a18af8561cece71cf07bc9872f39f (patch)
tree60ca5bedb147d54198ca806b5ce6dfe37d5f0f41 /src/stateless/cp
parent146525ddd44618bc5664cd632a86ff14be1c3ba9 (diff)
virtual NICs does not add 4 bytes of CRC
Diffstat (limited to 'src/stateless/cp')
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp2
-rw-r--r--src/stateless/cp/trex_stateless_port.h13
-rw-r--r--src/stateless/cp/trex_stream.cpp10
-rw-r--r--src/stateless/cp/trex_stream.h16
4 files changed, 31 insertions, 10 deletions
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());
}