summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py10
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py28
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py10
-rwxr-xr-xsrc/common/basic_utils.cpp14
-rwxr-xr-xsrc/common/basic_utils.h1
-rw-r--r--src/internal_api/trex_platform_api.h49
-rw-r--r--src/main_dpdk.cpp50
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp21
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp40
-rw-r--r--src/stateless/cp/trex_stateless_port.h16
10 files changed, 148 insertions, 91 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index a241fe1b..3cfef087 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -663,17 +663,13 @@ class STLClient(object):
# create ports
for port_id in xrange(self.system_info["port_count"]):
- speed = self.system_info['ports'][port_id]['speed']
- driver = self.system_info['ports'][port_id]['driver']
- macaddr = self.system_info['ports'][port_id]['macaddr']
+ info = self.system_info['ports'][port_id]
self.ports[port_id] = Port(port_id,
- speed,
- driver,
- macaddr,
self.username,
self.comm_link,
- self.session_id)
+ self.session_id,
+ info)
# sync the ports
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
index f2d4cd95..6aa18847 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py
@@ -41,7 +41,7 @@ class Port(object):
STATE_PAUSE: "PAUSE"}
- def __init__ (self, port_id, speed, driver, macaddr, user, comm_link, session_id):
+ def __init__ (self, port_id, user, comm_link, session_id, info):
self.port_id = port_id
self.state = self.STATE_IDLE
self.handler = None
@@ -49,9 +49,9 @@ class Port(object):
self.transmit = comm_link.transmit
self.transmit_batch = comm_link.transmit_batch
self.user = user
- self.driver = driver
- self.speed = speed
- self.macaddr = macaddr
+
+ self.info = dict(info)
+
self.streams = {}
self.profile = None
self.session_id = session_id
@@ -69,7 +69,7 @@ class Port(object):
return RC_OK(data)
def get_speed_bps (self):
- return (self.speed * 1000 * 1000 * 1000)
+ return (self.info['speed'] * 1000 * 1000 * 1000)
# take the port
def acquire(self, force = False):
@@ -520,11 +520,9 @@ class Port(object):
# generate port info
def get_info (self):
- info = {}
- info['speed'] = self.speed
- info['driver'] = self.driver
- info['status'] = self.get_port_state_name()
- info['macaddr'] = self.macaddr
+ info = dict(self.info)
+
+ info['status'] = self.get_port_state_name()
if self.attr.get('promiscuous'):
info['prom'] = "on" if self.attr['promiscuous']['enabled'] else "off"
@@ -545,8 +543,14 @@ class Port(object):
info = self.get_info()
- return {"type": info['driver'],
- "macaddr": info['macaddr'],
+ return {"driver": info['driver'],
+ "HW src mac": info['hw_macaddr'],
+ "SW src mac": info['src_macaddr'],
+ "SW dst mac": info['dst_macaddr'],
+ "PCI Address": info['pci_addr'],
+ "NUMA Node": info['numa'],
+ "--": "",
+ "---": "",
"maximum": "{speed} Gb/s".format(speed=info['speed']),
"status": info['status'],
"promiscuous" : info['prom']
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
index ec5435a3..620ccacd 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
@@ -180,11 +180,17 @@ class CTRexInfoGenerator(object):
relevant_ports = self.__get_relevant_ports(port_id_list)
return_stats_data = {}
- per_field_status = OrderedDict([("macaddr", []),
- ("type", []),
+ per_field_status = OrderedDict([("driver", []),
("maximum", []),
("status", []),
("promiscuous", []),
+ ("--", []),
+ ("HW src mac", []),
+ ("SW src mac", []),
+ ("SW dst mac", []),
+ ("---", []),
+ ("PCI Address", []),
+ ("NUMA Node", []),
]
)
diff --git a/src/common/basic_utils.cpp b/src/common/basic_utils.cpp
index 1cd5ce8f..34c37755 100755
--- a/src/common/basic_utils.cpp
+++ b/src/common/basic_utils.cpp
@@ -160,4 +160,18 @@ void TestDump(void){
utl_DumpBuffer2(stdout,buffer,31,1,4,SHOW_BUFFER_ADDR_EN |SHOW_BUFFER_CHAR);
}
+void utl_macaddr_to_str(const uint8_t *macaddr, std::string &output) {
+
+ for (int i = 0; i < 6; i++) {
+ char formatted[4];
+
+ if (i == 0) {
+ snprintf(formatted, sizeof(formatted), "%02x", macaddr[i]);
+ } else {
+ snprintf(formatted, sizeof(formatted), ":%02x", macaddr[i]);
+ }
+ output += formatted;
+ }
+
+}
diff --git a/src/common/basic_utils.h b/src/common/basic_utils.h
index 4bd208d3..77282eea 100755
--- a/src/common/basic_utils.h
+++ b/src/common/basic_utils.h
@@ -85,6 +85,7 @@ inline void utl_swap(T& a, T& b) {
bool utl_is_file_exists (const std::string& name) ;
+void utl_macaddr_to_str(const uint8_t *macaddr, std::string &output);
#endif
diff --git a/src/internal_api/trex_platform_api.h b/src/internal_api/trex_platform_api.h
index 5d5f4389..847611e4 100644
--- a/src/internal_api/trex_platform_api.h
+++ b/src/internal_api/trex_platform_api.h
@@ -113,13 +113,30 @@ public:
SPEED_40G,
};
+ struct mac_cfg_st {
+ uint8_t hw_macaddr[6];
+ uint8_t src_macaddr[6];
+ uint8_t dst_macaddr[6];
+ };
+
+ /**
+ * interface static info
+ *
+ */
+ struct intf_info_st {
+ std::string driver_name;
+ driver_speed_e speed;
+ mac_cfg_st mac_info;
+ std::string pci_addr;
+ int numa_node;
+ bool has_crc;
+ };
+
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,
- bool &has_crc) const = 0;
+ virtual void get_interface_info(uint8_t interface_id, intf_info_st &info) const = 0;
virtual void publish_async_data_now(uint32_t key) const = 0;
virtual uint8_t get_dp_core_count() const = 0;
@@ -130,7 +147,6 @@ public:
virtual int del_rx_flow_stat_rule(uint8_t port_id, uint8_t type, uint16_t proto, uint16_t id) const = 0;
virtual void set_promiscuous(uint8_t port_id, bool enabled) const = 0;
virtual bool get_promiscuous(uint8_t port_id) const = 0;
- virtual void get_macaddr(uint8_t port_id, uint8_t *macaddr) const = 0;
virtual ~TrexPlatformApi() {}
};
@@ -147,10 +163,7 @@ public:
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,
- bool &has_crc) const;
+ void get_interface_info(uint8_t interface_id, intf_info_st &info) const;
void publish_async_data_now(uint32_t key) const;
uint8_t get_dp_core_count() const;
@@ -161,7 +174,6 @@ public:
int del_rx_flow_stat_rule(uint8_t port_id, uint8_t type, uint16_t proto, uint16_t id) const;
void set_promiscuous(uint8_t port_id, bool enabled) const;
bool get_promiscuous(uint8_t port_id) const;
- void get_macaddr(uint8_t port_id, uint8_t *macaddr) const;
};
@@ -184,13 +196,14 @@ public:
virtual void get_global_stats(TrexPlatformGlobalStats &stats) const {
}
- virtual void get_interface_info(uint8_t interface_id,
- std::string &driver_name,
- driver_speed_e &speed,
- bool &has_crc) const {
- driver_name = "TEST";
- speed = TrexPlatformApi::SPEED_10G;
- has_crc = true;
+ virtual void get_interface_info(uint8_t interface_id, intf_info_st &info) const {
+
+ info.driver_name = "TEST";
+ info.speed = TrexPlatformApi::SPEED_10G;
+ info.has_crc = true;
+ info.numa_node = 0;
+
+ memset(&info.mac_info, 0, sizeof(info.mac_info));
}
virtual void get_interface_stats(uint8_t interface_id, TrexPlatformInterfaceStats &stats) const {
@@ -218,10 +231,6 @@ public:
return false;
}
- void get_macaddr(uint8_t port_id, uint8_t *macaddr) const {
- memset(macaddr, 0, 6);
- }
-
private:
int m_dp_core_count;
};
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 79f3d628..1b5b82f9 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -1517,6 +1517,7 @@ void CPhyEthIF::macaddr_get(struct ether_addr *mac_addr){
rte_eth_macaddr_get(m_port_id , mac_addr);
}
+
void CPhyEthIF::get_stats_1g(CPhyEthIFStats *stats){
stats->ipackets += pci_reg_read(E1000_GPRC) ;
@@ -5121,14 +5122,39 @@ TrexDpdkPlatformApi::port_id_to_cores(uint8_t port_id, std::vector<std::pair<uin
}
void
-TrexDpdkPlatformApi::get_interface_info(uint8_t port_id,
- std::string &driver_name,
- driver_speed_e &speed,
- bool &has_crc) const {
+TrexDpdkPlatformApi::get_interface_info(uint8_t interface_id, intf_info_st &info) const {
+ struct ether_addr rte_mac_addr;
+
+ info.driver_name = CTRexExtendedDriverDb::Ins()->get_driver_name();
+ info.speed = CTRexExtendedDriverDb::Ins()->get_drv()->get_driver_speed(interface_id);
+ info.has_crc = CTRexExtendedDriverDb::Ins()->get_drv()->has_crc_added();
+
+ /* mac INFO */
+
+ /* hardware */
+ g_trex.m_ports[interface_id].macaddr_get(&rte_mac_addr);
+ assert(ETHER_ADDR_LEN == 6);
+ for (int i = 0; i < 6; i++) {
+ info.mac_info.hw_macaddr[i] = rte_mac_addr.addr_bytes[i];
+ }
+
+ /* software */
+ uint8_t sw_macaddr[12];
+ memcpy(sw_macaddr, CGlobalInfo::m_options.get_dst_src_mac_addr(interface_id), 12);
+
+ for (int i = 0; i < 6; i++) {
+ info.mac_info.dst_macaddr[i] = sw_macaddr[i];
+ info.mac_info.src_macaddr[i] = sw_macaddr[6 + i];
+
+ }
+
+ info.numa_node = g_trex.m_ports[interface_id].m_dev_info.pci_dev->numa_node;
+ struct rte_pci_addr *loc = &g_trex.m_ports[interface_id].m_dev_info.pci_dev->addr;
+
+ char pci_addr[50];
+ snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT, loc->domain, loc->bus, loc->devid, loc->function);
+ info.pci_addr = pci_addr;
- driver_name = CTRexExtendedDriverDb::Ins()->get_driver_name();
- speed = CTRexExtendedDriverDb::Ins()->get_drv()->get_driver_speed(port_id);
- has_crc = CTRexExtendedDriverDb::Ins()->get_drv()->has_crc_added();
}
void
@@ -5165,14 +5191,4 @@ bool TrexDpdkPlatformApi::get_promiscuous(uint8_t port_id) const {
return g_trex.m_ports[port_id].get_promiscuous();
}
-void TrexDpdkPlatformApi::get_macaddr(uint8_t port_id, uint8_t *macaddr) const {
- struct ether_addr rte_mac_addr;
-
- g_trex.m_ports[port_id].macaddr_get(&rte_mac_addr);
- assert(ETHER_ADDR_LEN == 6);
- for (int i = 0; i < 6; i++) {
- macaddr[i] = rte_mac_addr.addr_bytes[i];
- }
-
-}
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index 47569bde..88ead3c2 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -168,16 +168,29 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
section["ports"] = Json::arrayValue;
for (int i = 0; i < main->get_port_count(); i++) {
- string driver;
TrexPlatformApi::driver_speed_e speed;
-
+ string driver;
+ string hw_macaddr;
+ string src_macaddr;
+ string dst_macaddr;
+ string pci_addr;
+ int numa;
+
TrexStatelessPort *port = main->get_port_by_id(i);
port->get_properties(driver, speed);
+ port->get_macaddr(hw_macaddr, src_macaddr, dst_macaddr);
+
+ port->get_pci_info(pci_addr, numa);
section["ports"][i]["index"] = i;
- section["ports"][i]["driver"] = driver;
- section["ports"][i]["macaddr"] = port->get_macaddr();
+ section["ports"][i]["driver"] = driver;
+ section["ports"][i]["hw_macaddr"] = hw_macaddr;
+ section["ports"][i]["src_macaddr"] = src_macaddr;
+ section["ports"][i]["dst_macaddr"] = dst_macaddr;
+
+ section["ports"][i]["pci_addr"] = pci_addr;
+ section["ports"][i]["numa"] = numa;
section["ports"][i]["rx"]["caps"] = port->get_rx_caps();
section["ports"][i]["rx"]["counters"] = port->get_rx_count_num();
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index 01733117..c60b0e85 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -23,6 +23,7 @@ limitations under the License.
#include <trex_stateless_port.h>
#include <trex_stateless_messaging.h>
#include <trex_streams_compiler.h>
+#include <common/basic_utils.h>
#include <string>
@@ -58,7 +59,7 @@ TrexStatelessPort::TrexStatelessPort(uint8_t port_id, const TrexPlatformApi *api
m_port_state = PORT_STATE_IDLE;
/* get the platform specific data */
- api->get_interface_info(port_id, m_driver_name, m_speed, m_has_crc);
+ api->get_interface_info(port_id, m_api_info);
/* get RX caps */
api->get_interface_stat_info(port_id, m_rx_count_num, m_rx_caps);
@@ -372,8 +373,8 @@ TrexStatelessPort::get_max_stream_id() const {
void
TrexStatelessPort::get_properties(std::string &driver, TrexPlatformApi::driver_speed_e &speed) {
- driver = m_driver_name;
- speed = m_speed;
+ driver = m_api_info.driver_name;
+ speed = m_api_info.speed;
}
bool
@@ -460,7 +461,7 @@ TrexStatelessPort::on_dp_event_occured(TrexDpPortEvent::event_e event_type) {
uint64_t
TrexStatelessPort::get_port_speed_bps() const {
- switch (m_speed) {
+ switch (m_api_info.speed) {
case TrexPlatformApi::SPEED_1G:
return (1LLU * 1000 * 1000 * 1000);
@@ -679,27 +680,20 @@ TrexStatelessPort::get_promiscuous() {
}
-std::string
-TrexStatelessPort::get_macaddr() {
- uint8_t macaddr[6];
- std::string output;
-
- get_stateless_obj()->get_platform_api()->get_macaddr(m_port_id, macaddr);
-
- for (int i = 0; i < 6; i++) {
- char formatted[4];
-
- if (i == 0) {
- snprintf(formatted, sizeof(formatted), "%02x", macaddr[i]);
- } else {
- snprintf(formatted, sizeof(formatted), ":%02x", macaddr[i]);
- }
+void
+TrexStatelessPort::get_macaddr(std::string &hw_macaddr,
+ std::string &src_macaddr,
+ std::string &dst_macaddr) {
- output += formatted;
- }
-
- return output;
+ utl_macaddr_to_str(m_api_info.mac_info.hw_macaddr, hw_macaddr);
+ utl_macaddr_to_str(m_api_info.mac_info.src_macaddr, src_macaddr);
+ utl_macaddr_to_str(m_api_info.mac_info.dst_macaddr, dst_macaddr);
+}
+void
+TrexStatelessPort::get_pci_info(std::string &pci_addr, int &numa_node) {
+ pci_addr = m_api_info.pci_addr;
+ numa_node = m_api_info.numa_node;
}
void
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index 0d626375..192d0d19 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -304,7 +304,7 @@ public:
* @return bool
*/
bool has_crc_added() const {
- return m_has_crc;
+ return m_api_info.has_crc;
}
TrexPortOwner & get_owner() {
@@ -331,7 +331,12 @@ public:
*/
void set_promiscuous(bool enabled);
bool get_promiscuous();
- std::string get_macaddr();
+
+ void get_macaddr(std::string &hw_macaddr,
+ std::string &src_macaddr,
+ std::string &dst_macaddr);
+
+ void get_pci_info(std::string &pci_addr, int &numa_node);
private:
@@ -396,13 +401,12 @@ private:
TrexStreamTable m_stream_table;
uint8_t m_port_id;
port_state_e m_port_state;
- std::string m_driver_name;
- bool m_has_crc;
+
+ TrexPlatformApi::intf_info_st m_api_info;
+
uint16_t m_rx_count_num;
uint16_t m_rx_caps;
- TrexPlatformApi::driver_speed_e m_speed;
-
/* holds the DP cores associated with this port */
std::vector<int> m_cores_id_list;