summaryrefslogtreecommitdiffstats
path: root/src/stateless
diff options
context:
space:
mode:
Diffstat (limited to 'src/stateless')
-rw-r--r--src/stateless/cp/trex_stateless.cpp4
-rw-r--r--src/stateless/cp/trex_stateless.h12
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp42
-rw-r--r--src/stateless/cp/trex_stateless_port.h9
-rw-r--r--src/stateless/cp/trex_streams_compiler.h6
5 files changed, 41 insertions, 32 deletions
diff --git a/src/stateless/cp/trex_stateless.cpp b/src/stateless/cp/trex_stateless.cpp
index 22389d6a..6029cbd5 100644
--- a/src/stateless/cp/trex_stateless.cpp
+++ b/src/stateless/cp/trex_stateless.cpp
@@ -152,10 +152,8 @@ TrexStateless::get_dp_core_count() {
void
TrexStateless::encode_stats(Json::Value &global) {
- const TrexPlatformApi *api = get_stateless_obj()->get_platform_api();
-
TrexPlatformGlobalStats stats;
- api->get_global_stats(stats);
+ m_platform_api->get_global_stats(stats);
global["cpu_util"] = stats.m_stats.m_cpu_util;
global["rx_cpu_util"] = stats.m_stats.m_rx_cpu_util;
diff --git a/src/stateless/cp/trex_stateless.h b/src/stateless/cp/trex_stateless.h
index 7ea669df..3a1a2c24 100644
--- a/src/stateless/cp/trex_stateless.h
+++ b/src/stateless/cp/trex_stateless.h
@@ -137,6 +137,18 @@ public:
void shutdown();
/**
+ * fetch xstats names (keys of dict)
+ *
+ */
+ void encode_xstats_names(Json::Value &global);
+
+ /**
+ * fetch xstats values
+ *
+ */
+ void encode_xstats_values(Json::Value &global);
+
+ /**
* fetch all the stats
*
*/
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index 58410fea..9bb20990 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -158,6 +158,7 @@ TrexStatelessPort::TrexStatelessPort(uint8_t port_id, const TrexPlatformApi *api
m_port_id = port_id;
m_port_state = PORT_STATE_IDLE;
+ m_platform_api = api;
/* get the platform specific data */
api->get_interface_info(port_id, m_api_info);
@@ -252,6 +253,11 @@ TrexStatelessPort::start_traffic(const TrexPortMultiplier &mul, double duration,
/* on start - we can only provide absolute values */
assert(mul.m_op == TrexPortMultiplier::OP_ABS);
+ /* check link state */
+ if ( !m_platform_api->getPortAttrObj(m_port_id)->is_link_up() && !force ) {
+ throw TrexException("Link state is DOWN.");
+ }
+
/* caclulate the effective factor for DP */
double factor = calculate_effective_factor(mul, force);
@@ -278,7 +284,7 @@ TrexStatelessPort::start_traffic(const TrexPortMultiplier &mul, double duration,
feeder.set_status(true);
- /* generate a message to all the relevant DP cores to start transmitting */
+ /* generate a message to all the relevant DP cores to stop transmitting */
assert(m_pending_async_stop_event == TrexDpPortEvents::INVALID_ID);
m_pending_async_stop_event = m_dp_events.create_event(new AsyncStopEvent());
@@ -581,7 +587,7 @@ void
TrexStatelessPort::get_properties(std::string &driver, uint32_t &speed) {
driver = m_api_info.driver_name;
- speed = m_api_info.speed;
+ speed = m_platform_api->getPortAttrObj(m_port_id)->get_link_speed();
}
bool
@@ -609,10 +615,8 @@ TrexStatelessPort::change_state(port_state_e new_state) {
void
TrexStatelessPort::encode_stats(Json::Value &port) {
- const TrexPlatformApi *api = get_stateless_obj()->get_platform_api();
-
TrexPlatformInterfaceStats stats;
- api->get_interface_stats(m_port_id, stats);
+ m_platform_api->get_interface_stats(m_port_id, stats);
port["tx_bps"] = stats.m_stats.m_tx_bps;
port["rx_bps"] = stats.m_stats.m_rx_bps;
@@ -664,7 +668,7 @@ TrexStatelessPort::send_message_to_rx(TrexStatelessCpToRxMsgBase *msg) {
uint64_t
TrexStatelessPort::get_port_speed_bps() const {
- return (uint64_t) m_api_info.speed * 1000 * 1000;
+ return (uint64_t) m_platform_api->getPortAttrObj(m_port_id)->get_link_speed() * 1000 * 1000;
}
static inline double
@@ -687,6 +691,20 @@ TrexStatelessPort::calculate_effective_factor(const TrexPortMultiplier &mul, boo
throw TrexException(ss.str());
}
+ /* L1 BW must be positive */
+ if (expected_l1_rate <= 0){
+ stringstream ss;
+ ss << "Effective bandwidth must be positive, got: " << expected_l1_rate;
+ throw TrexException(ss.str());
+ }
+
+ /* factor must be positive */
+ if (factor <= 0) {
+ stringstream ss;
+ ss << "Factor must be positive, got: " << factor;
+ throw TrexException(ss.str());
+ }
+
return factor;
}
@@ -869,18 +887,6 @@ TrexStatelessPort::get_port_effective_rate(double &pps,
}
-
-void
-TrexStatelessPort::set_promiscuous(bool enabled) {
- get_stateless_obj()->get_platform_api()->set_promiscuous(m_port_id, enabled);
-}
-
-bool
-TrexStatelessPort::get_promiscuous() {
- return get_stateless_obj()->get_platform_api()->get_promiscuous(m_port_id);
-}
-
-
void
TrexStatelessPort::get_macaddr(std::string &hw_macaddr,
std::string &src_macaddr,
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index 147efc70..e2a2aeba 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -363,14 +363,6 @@ public:
double &percentage);
- /**
- * set port promiscuous on/off
- *
- * @param enabled
- */
- void set_promiscuous(bool enabled);
- bool get_promiscuous();
-
void get_macaddr(std::string &hw_macaddr,
std::string &src_macaddr,
std::string &dst_macaddr);
@@ -443,6 +435,7 @@ private:
port_state_e m_port_state;
TrexPlatformApi::intf_info_st m_api_info;
+ const TrexPlatformApi *m_platform_api;
uint16_t m_rx_count_num;
uint16_t m_rx_caps;
diff --git a/src/stateless/cp/trex_streams_compiler.h b/src/stateless/cp/trex_streams_compiler.h
index c944df4a..43fee09b 100644
--- a/src/stateless/cp/trex_streams_compiler.h
+++ b/src/stateless/cp/trex_streams_compiler.h
@@ -309,7 +309,7 @@ public:
}
double get_factor_pps(double req_pps) const {
- if ( (req_pps - m_fixed.m_pps) <= 0 ) {
+ if ( (req_pps - m_fixed.m_pps) < 0 ) {
std::stringstream ss;
ss << "current stream configuration enforces a minimum rate of '" << m_fixed.m_pps << "' pps";
throw TrexException(ss.str());
@@ -319,7 +319,7 @@ public:
}
double get_factor_bps_l1(double req_bps_l1) const {
- if ( (req_bps_l1 - m_fixed.m_bps_l1) <= 0 ) {
+ if ( (req_bps_l1 - m_fixed.m_bps_l1) < 0 ) {
std::stringstream ss;
ss << "current stream configuration enforces a minimum rate of '" << m_fixed.m_bps_l1 << "' BPS L1";
throw TrexException(ss.str());
@@ -329,7 +329,7 @@ public:
}
double get_factor_bps_l2(double req_bps_l2) const {
- if ( (req_bps_l2 - m_fixed.m_bps_l2) <= 0 ) {
+ if ( (req_bps_l2 - m_fixed.m_bps_l2) < 0 ) {
std::stringstream ss;
ss << "current stream configuration enforces a minimum rate of '" << m_fixed.m_bps_l2 << "' BPS L2";
throw TrexException(ss.str());