summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/flow_stat.cpp38
-rw-r--r--src/gtest/rpc_test.cpp2
-rw-r--r--src/main_dpdk.cpp20
-rw-r--r--src/main_dpdk.h1
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_stream.cpp6
-rw-r--r--src/stateless/cp/trex_stream.h2
6 files changed, 41 insertions, 28 deletions
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index 5c3c7462..700c584b 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -391,7 +391,7 @@ std::ostream& operator<<(std::ostream& os, const CFlowStatRuleMgr& cf) {
int CFlowStatRuleMgr::compile_stream(const TrexStream * stream, Cxl710Parser &parser) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << " en:";
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << " en:";
std::cout << stream->m_rx_check.m_enabled << std::endl;
#endif
@@ -428,7 +428,7 @@ int CFlowStatRuleMgr::compile_stream(const TrexStream * stream, Cxl710Parser &pa
int CFlowStatRuleMgr::add_stream(const TrexStream * stream) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << std::endl;
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << std::endl;
#endif
if (! m_api ) {
@@ -468,12 +468,12 @@ int CFlowStatRuleMgr::add_stream(const TrexStream * stream) {
return -1;
}
- return m_user_id_map.add_stream(stream->m_rx_check.m_user_id, l4_proto);
+ return m_user_id_map.add_stream(stream->m_rx_check.m_pg_id, l4_proto);
}
int CFlowStatRuleMgr::del_stream(const TrexStream * stream) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << std::endl;
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << std::endl;
#endif
if (no_stat_supported)
@@ -483,7 +483,7 @@ int CFlowStatRuleMgr::del_stream(const TrexStream * stream) {
return 0;
}
- return m_user_id_map.del_stream(stream->m_rx_check.m_user_id);
+ return m_user_id_map.del_stream(stream->m_rx_check.m_pg_id);
}
// called on all streams, when stream start to transmit
@@ -494,7 +494,7 @@ int CFlowStatRuleMgr::del_stream(const TrexStream * stream) {
// Might change the IP ID of the stream packet
int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << std::endl;
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << std::endl;
#endif
Cxl710Parser parser;
@@ -523,8 +523,8 @@ int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
}
// from here, we know the stream need rx stat
- if (m_user_id_map.is_started(stream->m_rx_check.m_user_id)) {
- m_user_id_map.start_stream(stream->m_rx_check.m_user_id); // just increase ref count;
+ if (m_user_id_map.is_started(stream->m_rx_check.m_pg_id)) {
+ m_user_id_map.start_stream(stream->m_rx_check.m_pg_id); // just increase ref count;
} else {
uint16_t hw_id = m_hw_id_map.find_free_hw_id();
if (hw_id > m_max_hw_id) {
@@ -534,14 +534,14 @@ int CFlowStatRuleMgr::start_stream(TrexStream * stream, uint16_t &ret_hw_id) {
printf("Error: %s failed finding free hw_id\n", __func__);
return -1;
} else {
- uint32_t user_id = stream->m_rx_check.m_user_id;
+ uint32_t user_id = stream->m_rx_check.m_pg_id;
m_user_id_map.start_stream(user_id, hw_id);
m_hw_id_map.map(hw_id, user_id);
add_hw_rule(hw_id, m_user_id_map.l4_proto(user_id));
}
}
- uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_user_id); // can't fail if we got here
+ uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_pg_id); // can't fail if we got here
parser.set_ip_id(IP_ID_RESERVE_BASE + hw_id);
ret_hw_id = hw_id;
@@ -563,7 +563,7 @@ int CFlowStatRuleMgr::add_hw_rule(uint16_t hw_id, uint8_t proto) {
int CFlowStatRuleMgr::stop_stream(const TrexStream * stream) {
#ifdef __DEBUG_FUNC_ENTRY__
- std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_user_id << std::endl;
+ std::cout << __METHOD_NAME__ << " user id:" << stream->m_rx_check.m_pg_id << std::endl;
#endif
if (no_stat_supported)
return -ENOTSUP;
@@ -572,11 +572,11 @@ int CFlowStatRuleMgr::stop_stream(const TrexStream * stream) {
return 0;
}
- if (m_user_id_map.stop_stream(stream->m_rx_check.m_user_id) == 0) {
+ if (m_user_id_map.stop_stream(stream->m_rx_check.m_pg_id) == 0) {
// last stream associated with the entry stopped transmittig.
// remove user_id <--> hw_id mapping
- uint8_t proto = m_user_id_map.l4_proto(stream->m_rx_check.m_user_id);
- uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_user_id);
+ uint8_t proto = m_user_id_map.l4_proto(stream->m_rx_check.m_pg_id);
+ uint16_t hw_id = m_user_id_map.get_hw_id(stream->m_rx_check.m_pg_id);
if (hw_id >= MAX_FLOW_STATS) {
fprintf(stderr, "Error: %s got wrong hw_id %d from unmap\n", __func__, hw_id);
return -1;
@@ -592,7 +592,7 @@ int CFlowStatRuleMgr::stop_stream(const TrexStream * stream) {
p_user_id->set_rx_counter(port, rx_counter);
p_user_id->set_tx_counter(port, tx_counter);
}
- m_user_id_map.unmap(stream->m_rx_check.m_user_id);
+ m_user_id_map.unmap(stream->m_rx_check.m_pg_id);
m_hw_id_map.unmap(hw_id);
}
}
@@ -610,7 +610,7 @@ bool CFlowStatRuleMgr::dump_json(std::string & json) {
if (m_user_id_map.is_empty()) {
return false;
}
- root["name"] = "rx-stats";
+ root["name"] = "flow_stats";
root["type"] = 0;
Json::Value &data_section = root["data"];
@@ -650,12 +650,12 @@ bool CFlowStatRuleMgr::dump_json(std::string & json) {
std::string str_port = static_cast<std::ostringstream*>( &(std::ostringstream() << int(port) ) )->str();
if (user_id_info->get_rx_counter(port) != 0) {
- data_section[str_user_id]["rx-pkts"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port));
+ data_section[str_user_id]["rx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port));
ret = true;
}
if (user_id_info->get_tx_counter(port).get_pkts() != 0) {
- data_section[str_user_id]["tx-pkts"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_pkts());
- data_section[str_user_id]["tx-bytes"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_bytes());
+ data_section[str_user_id]["tx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_pkts());
+ data_section[str_user_id]["tx_bytes"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_bytes());
ret = true;
}
}
diff --git a/src/gtest/rpc_test.cpp b/src/gtest/rpc_test.cpp
index 34bb02a8..49a52071 100644
--- a/src/gtest/rpc_test.cpp
+++ b/src/gtest/rpc_test.cpp
@@ -462,7 +462,7 @@ create_simple_stream(Json::Value &obj) {
}
obj["vm"] = Json::arrayValue;
- obj["rx_stats"]["enabled"] = false;
+ obj["flow_stats"]["enabled"] = false;
}
static bool
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 57b3719b..92bfda09 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -1472,6 +1472,10 @@ void CPhyEthIF::update_link_status(){
rte_eth_link_get(m_port_id, &m_link);
}
+void CPhyEthIF::update_link_status_nowait(){
+ rte_eth_link_get_nowait(m_port_id, &m_link);
+}
+
void CPhyEthIF::add_mac(char * mac){
struct ether_addr mac_addr;
int i=0;
@@ -2645,6 +2649,7 @@ public:
void get_stats(CGlobalStats & stats);
void dump_post_test_stats(FILE *fd);
void dump_config(FILE *fd);
+ void dump_links_status(FILE *fd);
public:
port_cfg_t m_port_cfg;
@@ -2942,10 +2947,6 @@ int CGlobalTRex::ixgbe_start(void){
_if->disable_flow_control();
}
- _if->update_link_status();
-
- _if->dump_link(stdout);
-
_if->add_mac((char *)CGlobalInfo::m_options.get_src_mac_addr(i));
fflush(stdout);
@@ -2956,6 +2957,7 @@ int CGlobalTRex::ixgbe_start(void){
get_ex_drv()->wait_for_stable_link();
if ( !is_all_links_are_up(true) ){
+ dump_links_status(stdout);
rte_exit(EXIT_FAILURE, " "
" one of the link is down \n");
}
@@ -2963,6 +2965,8 @@ int CGlobalTRex::ixgbe_start(void){
get_ex_drv()->wait_after_link_up();
}
+ dump_links_status(stdout);
+
ixgbe_rx_queue_flush();
@@ -3209,6 +3213,14 @@ void CGlobalTRex::dump_config(FILE *fd){
}
+void CGlobalTRex::dump_links_status(FILE *fd){
+ for (int i=0; i<m_max_ports; i++) {
+ CPhyEthIF * _if=&m_ports[i];
+ _if->update_link_status_nowait();
+ _if->dump_link(fd);
+ }
+}
+
void CGlobalTRex::dump_post_test_stats(FILE *fd){
uint64_t pkt_out=0;
diff --git a/src/main_dpdk.h b/src/main_dpdk.h
index 33615636..a475d321 100644
--- a/src/main_dpdk.h
+++ b/src/main_dpdk.h
@@ -89,6 +89,7 @@ class CPhyEthIF {
void start();
void stop();
void update_link_status();
+ void update_link_status_nowait();
bool is_link_up(){
return (m_link.link_status?true:false);
}
diff --git a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
index cf11f8c6..68bebeb6 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_stream.cpp
@@ -81,7 +81,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
stream->m_pkt.len = std::max(pkt_binary.size(), 60UL);
/* allocate and init to zero ( with () ) */
- stream->m_pkt.binary = new uint8_t[pkt_binary.size()]();
+ stream->m_pkt.binary = new uint8_t[stream->m_pkt.len]();
if (!stream->m_pkt.binary) {
generate_internal_err(result, "unable to allocate memory");
}
@@ -101,7 +101,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
parse_vm(vm, stream, result);
/* parse RX info */
- const Json::Value &rx = parse_object(section, "rx_stats", result);
+ const Json::Value &rx = parse_object(section, "flow_stats", result);
stream->m_rx_check.m_enabled = parse_bool(rx, "enabled", result);
@@ -114,7 +114,7 @@ TrexRpcCmdAddStream::_run(const Json::Value &params, Json::Value &result) {
generate_parse_err(result, "RX stats is not supported on this interface");
}
- stream->m_rx_check.m_user_id = parse_int(rx, "stream_id", result);
+ stream->m_rx_check.m_pg_id = parse_int(rx, "stream_id", result);
stream->m_rx_check.m_seq_enabled = parse_bool(rx, "seq_enabled", result);
stream->m_rx_check.m_latency = parse_bool(rx, "latency_enabled", result);
}
diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h
index 1abf0c04..ded6363e 100644
--- a/src/stateless/cp/trex_stream.h
+++ b/src/stateless/cp/trex_stream.h
@@ -513,7 +513,7 @@ public:
bool m_enabled;
bool m_seq_enabled;
bool m_latency;
- uint32_t m_user_id;
+ uint32_t m_pg_id;
uint16_t m_hw_id;
} m_rx_check;