summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-05-03 16:09:00 +0300
committerHanoh Haim <hhaim@cisco.com>2016-05-03 16:09:00 +0300
commitf27bfbab72f9221b221a7f36f4063e9ff8e9d307 (patch)
treea8775aa1c5063b5ed02fd13fbb94d541b696e91b /src
parentdbe44f64ec7cff8d55400327e5f6994ac1fc87bb (diff)
parent737d92948a1bfd9f94fd31a4e207d0f9e6f028c0 (diff)
Merge trex-204
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bp_sim.cpp4
-rw-r--r--src/main_dpdk.cpp18
-rw-r--r--src/publisher/trex_publisher.h3
-rw-r--r--src/stateless/cp/trex_stateless.cpp2
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp39
-rw-r--r--src/stateless/cp/trex_stateless_port.h10
6 files changed, 52 insertions, 24 deletions
diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp
index 2c122e72..94f8a2ba 100755
--- a/src/bp_sim.cpp
+++ b/src/bp_sim.cpp
@@ -2258,11 +2258,11 @@ enum CCapFileFlowInfo::load_cap_file_err CCapFileFlowInfo::load_cap_file(std::st
}
}else{
- fprintf(stderr, "ERROR packet %d is not supported, should be IP(0x0800)/TCP/UDP format try to convert it using Wireshark !\n",cnt);
+ fprintf(stderr, "ERROR packet %d is not supported, should be Ethernet/IP(0x0800)/(TCP|UDP) format try to convert it using Wireshark !\n",cnt);
return kPktNotSupp;
}
}else{
- fprintf(stderr, "ERROR packet %d is not supported, should be IP(0x0800)/TCP/UDP format try to convert it using Wireshark !\n",cnt);
+ fprintf(stderr, "ERROR packet %d is not supported, should be Ethernet/IP(0x0800)/(TCP|UDP) format try to convert it using Wireshark !\n",cnt);
return kPktProcessFail;
}
}
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 440cf820..6dec3dec 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -2317,6 +2317,7 @@ public:
float m_open_flows;
float m_cpu_util;
float m_rx_cpu_util;
+ float m_bw_per_core;
uint8_t m_threads;
uint32_t m_num_of_ports;
@@ -2335,7 +2336,10 @@ private:
std::string CGlobalStats::get_field(std::string name,float &f){
char buff[200];
- snprintf(buff, sizeof(buff), "\"%s\":%.1f,",name.c_str(),f);
+ if(f <= -10.0 or f >= 10.0)
+ snprintf(buff, sizeof(buff), "\"%s\":%.1f,",name.c_str(),f);
+ else
+ snprintf(buff, sizeof(buff), "\"%s\":%.3e,",name.c_str(),f);
return (std::string(buff));
}
@@ -2347,7 +2351,10 @@ std::string CGlobalStats::get_field(std::string name,uint64_t &f){
std::string CGlobalStats::get_field_port(int port,std::string name,float &f){
char buff[200];
- snprintf(buff, sizeof(buff), "\"%s-%d\":%.1f,",name.c_str(),port,f);
+ if(f <= -10.0 or f >= 10.0)
+ snprintf(buff, sizeof(buff), "\"%s-%d\":%.1f,",name.c_str(),port,f);
+ else
+ snprintf(buff, sizeof(buff), "\"%s-%d\":%.3e,",name.c_str(),port,f);
return (std::string(buff));
}
@@ -2376,6 +2383,7 @@ void CGlobalStats::dump_json(std::string & json, bool baseline,uint32_t stats_ti
#define GET_FIELD_PORT(p,f) get_field_port(p,std::string(#f),lp->f)
json+=GET_FIELD(m_cpu_util);
+ json+=GET_FIELD(m_bw_per_core);
json+=GET_FIELD(m_rx_cpu_util);
json+=GET_FIELD(m_platform_factor);
json+=GET_FIELD(m_tx_bps);
@@ -2441,7 +2449,7 @@ void CGlobalStats::DumpAllPorts(FILE *fd){
- fprintf (fd," Cpu Utilization : %2.1f %% %2.1f Gb/core \n",m_cpu_util,(2*(m_tx_bps/1e9)*100.0/(m_cpu_util*m_threads)));
+ fprintf (fd," Cpu Utilization : %2.1f %% %2.1f Gb/core \n",m_cpu_util,m_bw_per_core);
fprintf (fd," Platform_factor : %2.1f \n",m_platform_factor);
fprintf (fd," Total-Tx : %s ",double_to_human_str(m_tx_bps,"bps",KBYE_1000).c_str());
if ( CGlobalInfo::is_learn_mode() ) {
@@ -3554,6 +3562,10 @@ void CGlobalTRex::get_stats(CGlobalStats & stats){
stats.m_tx_pps = total_tx_pps*pf;
stats.m_rx_pps = total_rx_pps*pf;
stats.m_tx_cps = m_last_total_cps*pf;
+ if(stats.m_cpu_util < 0.0001)
+ stats.m_bw_per_core = 0;
+ else
+ stats.m_bw_per_core = 2*(stats.m_tx_bps/1e9)*100.0/(stats.m_cpu_util*stats.m_threads);
stats.m_tx_expected_cps = m_expected_cps*pf;
stats.m_tx_expected_pps = m_expected_pps*pf;
diff --git a/src/publisher/trex_publisher.h b/src/publisher/trex_publisher.h
index f086babb..f8843758 100644
--- a/src/publisher/trex_publisher.h
+++ b/src/publisher/trex_publisher.h
@@ -46,7 +46,8 @@ public:
EVENT_PORT_PAUSED = 2,
EVENT_PORT_RESUMED = 3,
EVENT_PORT_FINISHED_TX = 4,
- EVENT_PORT_FORCE_ACQUIRED = 5,
+ EVENT_PORT_ACQUIRED = 5,
+ EVENT_PORT_RELEASED = 6,
EVENT_SERVER_STOPPED = 100,
diff --git a/src/stateless/cp/trex_stateless.cpp b/src/stateless/cp/trex_stateless.cpp
index c86c5f65..5bbe9faf 100644
--- a/src/stateless/cp/trex_stateless.cpp
+++ b/src/stateless/cp/trex_stateless.cpp
@@ -54,7 +54,7 @@ TrexStateless::TrexStateless(const TrexStatelessCfg &cfg) {
m_publisher = cfg.m_publisher;
/* API core version */
- m_api_classes[APIClass::API_CLASS_TYPE_CORE].init(APIClass::API_CLASS_TYPE_CORE, 1, 1);
+ m_api_classes[APIClass::API_CLASS_TYPE_CORE].init(APIClass::API_CLASS_TYPE_CORE, 1, 2);
}
/**
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index 605995ae..90142d9b 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -119,23 +119,10 @@ TrexStatelessPort::~TrexStatelessPort() {
void
TrexStatelessPort::acquire(const std::string &user, uint32_t session_id, bool force) {
- /* if port is free - just take it */
- if (get_owner().is_free()) {
- get_owner().own(user);
- return;
- }
-
- if (force) {
- get_owner().own(user);
-
- /* inform the other client of the steal... */
- Json::Value data;
+ bool used_force = !get_owner().is_free() && force;
- data["port_id"] = m_port_id;
- data["who"] = user;
- data["session_id"] = session_id;
-
- get_stateless_obj()->get_publisher()->publish_event(TrexPublisher::EVENT_PORT_FORCE_ACQUIRED, data);
+ if (get_owner().is_free() || force) {
+ get_owner().own(user, session_id);
} else {
/* not same user or session id and not force - report error */
@@ -146,11 +133,30 @@ TrexStatelessPort::acquire(const std::string &user, uint32_t session_id, bool fo
}
}
+ Json::Value data;
+
+ data["port_id"] = m_port_id;
+ data["who"] = user;
+ data["session_id"] = session_id;
+ data["force"] = used_force;
+
+ get_stateless_obj()->get_publisher()->publish_event(TrexPublisher::EVENT_PORT_ACQUIRED, data);
+
}
void
TrexStatelessPort::release(void) {
+
+
+ Json::Value data;
+
+ data["port_id"] = m_port_id;
+ data["who"] = get_owner().get_name();
+ data["session_id"] = get_owner().get_session_id();
+
get_owner().release();
+
+ get_stateless_obj()->get_publisher()->publish_event(TrexPublisher::EVENT_PORT_RELEASED, data);
}
/**
@@ -776,6 +782,7 @@ TrexStatelessPort::remove_and_delete_all_streams() {
TrexPortOwner::TrexPortOwner() {
m_is_free = true;
+ m_session_id = 0;
/* for handlers random generation */
m_seed = time(NULL);
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index 2167e735..520940d8 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -54,16 +54,18 @@ public:
m_is_free = true;
m_owner_name = "";
m_handler = "";
+ m_session_id = 0;
}
bool is_owned_by(const std::string &user) {
return ( !m_is_free && (m_owner_name == user) );
}
- void own(const std::string &owner_name) {
+ void own(const std::string &owner_name, uint32_t session_id) {
/* save user data */
m_owner_name = owner_name;
+ m_session_id = session_id;
/* internal data */
m_handler = utl_generate_random_str(m_seed, 8);
@@ -82,6 +84,9 @@ public:
return (!m_is_free ? m_handler : g_unowned_handler);
}
+ const uint32_t get_session_id() {
+ return m_session_id;
+ }
private:
@@ -91,6 +96,9 @@ private:
/* user provided info */
std::string m_owner_name;
+ /* which session of the user holds this port*/
+ uint32_t m_session_id;
+
/* handler genereated internally */
std::string m_handler;