summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/automation/trex_control_plane/client/trex_stateless_client.py17
-rwxr-xr-xscripts/automation/trex_control_plane/console/parsing_opts.py18
-rw-r--r--src/internal_api/trex_platform_api.h18
-rwxr-xr-xsrc/main_dpdk.cpp33
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp26
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp11
-rw-r--r--src/stateless/cp/trex_stateless_port.h7
7 files changed, 111 insertions, 19 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_stateless_client.py b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
index 7bcbf2c7..af166b7f 100755
--- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py
+++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py
@@ -146,13 +146,14 @@ class Port(object):
STATE_TX = 3
STATE_PAUSE = 4
- def __init__ (self, port_id, user, transmit):
+ def __init__ (self, port_id, speed, driver, user, transmit):
self.port_id = port_id
self.state = self.STATE_IDLE
self.handler = None
self.transmit = transmit
self.user = user
-
+ self.driver = driver
+ self.speed = speed
self.streams = {}
def err(self, msg):
@@ -161,6 +162,9 @@ class Port(object):
def ok(self):
return RC_OK()
+ def get_speed_bps (self):
+ return (self.speed * 1000 * 1000)
+
# take the port
def acquire(self, force = False):
params = {"port_id": self.port_id,
@@ -299,6 +303,11 @@ class Port(object):
if self.state == self.STATE_TX:
return self.err("Unable to start traffic - port is already transmitting")
+ # if percentage - translate
+ if mul['type'] == 'percentage':
+ mul['type'] = 'max_bps'
+ mul['max'] = self.get_speed_bps() * (mul['max'] / 100)
+
params = {"handler": self.handler,
"port_id": self.port_id,
"mul": mul,
@@ -461,7 +470,9 @@ class CTRexStatelessClient(object):
# create ports
for port_id in xrange(self.get_port_count()):
- self.ports.append(Port(port_id, self.user, self.transmit))
+ speed = self.system_info['ports'][port_id]['speed']
+ driver = self.system_info['ports'][port_id]['driver']
+ self.ports.append(Port(port_id, speed, driver, self.user, self.transmit))
# acquire all ports
rc = self.acquire()
diff --git a/scripts/automation/trex_control_plane/console/parsing_opts.py b/scripts/automation/trex_control_plane/console/parsing_opts.py
index 732ba764..ab678586 100755
--- a/scripts/automation/trex_control_plane/console/parsing_opts.py
+++ b/scripts/automation/trex_control_plane/console/parsing_opts.py
@@ -42,6 +42,12 @@ def match_time_unit(val):
"-d 10m : in min \n"
"-d 1h : in hours")
+match_multiplier_help = """Multiplier should be passed in the following format:
+ [number][<empty> | bps | kbps | mbps | gbps | pps | kpps | mpps | %% ].
+ no suffix will provide an absoulute factor and percentage
+ will provide a percentage of the line rate. examples
+ : '-m 10', '-m 10kbps', '-m 10mpps', '-m 23%%' """
+
def match_multiplier(val):
'''match some val against multiplier shortcut inputs '''
@@ -88,16 +94,14 @@ def match_multiplier(val):
result['max'] = value * 1000 * 1000
elif unit == "%":
- raise argparse.ArgumentTypeError("percetange is currently unsupported...")
+ # will be translated by the port object
+ result['type'] = 'percentage'
+ result['max'] = value
return result
else:
- raise argparse.ArgumentTypeError("\n\nMultiplier should be passed in the following format: \n\n"
- "-m 100 : multiply by factor \n"
- "-m 1bps / 1kbps / 1mbps / 1gbps : normalize to bps \n"
- "-m 1pps / 1kpps / 1mbps : normalize to pps \n"
- "-m 40% : normalize to % from port line rate\n")
+ raise argparse.ArgumentTypeError(match_multiplier_help)
@@ -109,7 +113,7 @@ def is_valid_file(filename):
OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'],
- {'help': "Set multiplier for stream",
+ {'help': match_multiplier_help,
'dest': "mult",
'default': 1.0,
'type': match_multiplier}),
diff --git a/src/internal_api/trex_platform_api.h b/src/internal_api/trex_platform_api.h
index 5890a965..343b8004 100644
--- a/src/internal_api/trex_platform_api.h
+++ b/src/internal_api/trex_platform_api.h
@@ -24,6 +24,7 @@ limitations under the License.
#include <stdint.h>
#include <vector>
+#include <string>
/**
* Global stats
@@ -97,10 +98,20 @@ public:
class TrexPlatformApi {
public:
+
+ enum driver_speed_e {
+ SPEED_INVALID,
+ SPEED_1G,
+ SPEED_10G,
+ SPEED_40G,
+ };
+
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 uint8_t get_dp_core_count() const = 0;
+
virtual ~TrexPlatformApi() {}
};
@@ -115,7 +126,9 @@ 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;
uint8_t get_dp_core_count() const;
+
};
/**
@@ -128,6 +141,11 @@ 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 {
+ driver_name = "MOCK";
+ speed = SPEED_INVALID;
+ }
+
uint8_t get_dp_core_count() const;
};
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index b1c9ed12..57a87b71 100755
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -127,6 +127,9 @@ class CPhyEthIFStats ;
class CTRexExtendedDriverBase {
public:
+
+ virtual TrexPlatformApi::driver_speed_e get_driver_speed() = 0;
+
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;
@@ -153,6 +156,10 @@ public:
CTRexExtendedDriverBase1G(){
}
+ TrexPlatformApi::driver_speed_e get_driver_speed() {
+ return TrexPlatformApi::SPEED_1G;
+ }
+
static CTRexExtendedDriverBase * create(){
return ( new CTRexExtendedDriverBase1G() );
}
@@ -191,6 +198,10 @@ public:
CGlobalInfo::m_options.preview.set_vm_one_queue_enable(true);
}
+ TrexPlatformApi::driver_speed_e get_driver_speed() {
+ return TrexPlatformApi::SPEED_1G;
+ }
+
static CTRexExtendedDriverBase * create(){
return ( new CTRexExtendedDriverBase1GVm() );
}
@@ -229,6 +240,11 @@ class CTRexExtendedDriverBase10G : public CTRexExtendedDriverBase {
public:
CTRexExtendedDriverBase10G(){
}
+
+ TrexPlatformApi::driver_speed_e get_driver_speed() {
+ return TrexPlatformApi::SPEED_10G;
+ }
+
static CTRexExtendedDriverBase * create(){
return ( new CTRexExtendedDriverBase10G() );
}
@@ -261,6 +277,10 @@ public:
CTRexExtendedDriverBase40G(){
}
+ TrexPlatformApi::driver_speed_e get_driver_speed() {
+ return TrexPlatformApi::SPEED_40G;
+ }
+
static CTRexExtendedDriverBase * create(){
return ( new CTRexExtendedDriverBase40G() );
}
@@ -303,6 +323,11 @@ public:
class CTRexExtendedDriverDb {
public:
+
+ const std::string & get_driver_name() {
+ return m_driver_name;
+ }
+
bool is_driver_exists(std::string name);
@@ -5275,3 +5300,11 @@ TrexDpdkPlatformApi::port_id_to_cores(uint8_t port_id, std::vector<std::pair<uin
}
}
+void
+TrexDpdkPlatformApi::get_interface_info(uint8_t interface_id,
+ std::string &driver_name,
+ driver_speed_e &speed) const {
+
+ driver_name = CTRexExtendedDriverDb::Ins()->get_driver_name();
+ speed = CTRexExtendedDriverDb::Ins()->get_drv()->get_driver_speed();
+}
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index 1a7132ff..9570aae7 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -25,6 +25,8 @@ limitations under the License.
#include <trex_stateless_port.h>
#include <trex_rpc_cmds_table.h>
+#include <internal_api/trex_platform_api.h>
+
#include <fstream>
#include <iostream>
#include <unistd.h>
@@ -167,14 +169,34 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
for (int i = 0; i < main->get_port_count(); i++) {
string driver;
- string speed;
+ TrexPlatformApi::driver_speed_e speed;
TrexStatelessPort *port = main->get_port_by_id(i);
port->get_properties(driver, speed);
section["ports"][i]["index"] = i;
+
section["ports"][i]["driver"] = driver;
- section["ports"][i]["speed"] = speed;
+
+ switch (speed) {
+ case TrexPlatformApi::SPEED_1G:
+ section["ports"][i]["speed"] = 1;
+ break;
+
+ case TrexPlatformApi::SPEED_10G:
+ section["ports"][i]["speed"] = 10;
+ break;
+
+ case TrexPlatformApi::SPEED_40G:
+ section["ports"][i]["speed"] = 40;
+ break;
+
+ default:
+ /* unknown value */
+ section["ports"][i]["speed"] = 0;
+ break;
+ }
+
section["ports"][i]["owner"] = port->get_owner();
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index be1bea12..5f1a3bca 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -56,10 +56,12 @@ TrexStatelessPort::TrexStatelessPort(uint8_t port_id, const TrexPlatformApi *api
std::vector<std::pair<uint8_t, uint8_t>> core_pair_list;
m_port_id = port_id;
-
m_port_state = PORT_STATE_IDLE;
clear_owner();
+ /* get the platform specific data */
+ api->get_interface_info(port_id, m_driver_name, m_speed);
+
/* get the DP cores belonging to this port */
api->port_id_to_cores(m_port_id, core_pair_list);
@@ -266,11 +268,10 @@ TrexStatelessPort::get_state_as_string() const {
}
void
-TrexStatelessPort::get_properties(string &driver, string &speed) {
+TrexStatelessPort::get_properties(std::string &driver, TrexPlatformApi::driver_speed_e &speed) {
- /* take this from DPDK */
- driver = "e1000";
- speed = "1 Gbps";
+ driver = m_driver_name;
+ speed = m_speed;
}
bool
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index 6adb5fef..20acd927 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -23,8 +23,8 @@ limitations under the License.
#include <trex_stream.h>
#include <trex_dp_port_events.h>
+#include <internal_api/trex_platform_api.h>
-class TrexPlatformApi;
class TrexStatelessCpToDpMsgBase;
/**
@@ -126,7 +126,7 @@ public:
* @param driver
* @param speed
*/
- void get_properties(std::string &driver, std::string &speed);
+ void get_properties(std::string &driver, TrexPlatformApi::driver_speed_e &speed);
/**
@@ -260,6 +260,9 @@ private:
port_state_e m_port_state;
std::string m_owner;
std::string m_owner_handler;
+ std::string m_driver_name;
+
+ TrexPlatformApi::driver_speed_e m_speed;
/* holds the DP cores associated with this port */
std::vector<int> m_cores_id_list;