diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/internal_api/trex_platform_api.h | 18 | ||||
-rwxr-xr-x | src/main_dpdk.cpp | 33 | ||||
-rw-r--r-- | src/rpc-server/commands/trex_rpc_cmd_general.cpp | 26 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.cpp | 11 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.h | 7 |
5 files changed, 86 insertions, 9 deletions
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 ¶ms, 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; |