summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-28 04:30:11 -0500
committerimarom <imarom@cisco.com>2016-02-28 04:30:58 -0500
commit5f17c48a1f6f7006cbb6e1b17eca2ebd6b682b78 (patch)
treed1af472bbc92962e6cf4757cf7da09bcd73edf82
parent2f42eda77b027f5c9d39cba48373d75c0e1e2155 (diff)
support for mac addr query
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py6
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py11
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py3
-rw-r--r--src/internal_api/trex_platform_api.h7
-rw-r--r--src/main_dpdk.cpp11
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp1
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp21
-rw-r--r--src/stateless/cp/trex_stateless_port.h1
8 files changed, 54 insertions, 7 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 6dd7a6d2..a241fe1b 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,12 +663,14 @@ 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']
+ speed = self.system_info['ports'][port_id]['speed']
+ driver = self.system_info['ports'][port_id]['driver']
+ macaddr = self.system_info['ports'][port_id]['macaddr']
self.ports[port_id] = Port(port_id,
speed,
driver,
+ macaddr,
self.username,
self.comm_link,
self.session_id)
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 ef454b8c..f2d4cd95 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, user, comm_link, session_id):
+ def __init__ (self, port_id, speed, driver, macaddr, user, comm_link, session_id):
self.port_id = port_id
self.state = self.STATE_IDLE
self.handler = None
@@ -51,6 +51,7 @@ class Port(object):
self.user = user
self.driver = driver
self.speed = speed
+ self.macaddr = macaddr
self.streams = {}
self.profile = None
self.session_id = session_id
@@ -520,9 +521,10 @@ 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['speed'] = self.speed
+ info['driver'] = self.driver
+ info['status'] = self.get_port_state_name()
+ info['macaddr'] = self.macaddr
if self.attr.get('promiscuous'):
info['prom'] = "on" if self.attr['promiscuous']['enabled'] else "off"
@@ -544,6 +546,7 @@ class Port(object):
info = self.get_info()
return {"type": info['driver'],
+ "macaddr": info['macaddr'],
"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 353d2ef2..ec5435a3 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,7 +180,8 @@ class CTRexInfoGenerator(object):
relevant_ports = self.__get_relevant_ports(port_id_list)
return_stats_data = {}
- per_field_status = OrderedDict([("type", []),
+ per_field_status = OrderedDict([("macaddr", []),
+ ("type", []),
("maximum", []),
("status", []),
("promiscuous", []),
diff --git a/src/internal_api/trex_platform_api.h b/src/internal_api/trex_platform_api.h
index 249adb2f..5d5f4389 100644
--- a/src/internal_api/trex_platform_api.h
+++ b/src/internal_api/trex_platform_api.h
@@ -25,6 +25,7 @@ limitations under the License.
#include <stdint.h>
#include <vector>
#include <string>
+#include <string.h>
/**
* Global stats
@@ -129,6 +130,7 @@ 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() {}
};
@@ -159,6 +161,7 @@ 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;
};
@@ -215,6 +218,10 @@ 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 c23e27d4..cdf4f6f3 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -5180,3 +5180,14 @@ 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 05565179..47569bde 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -177,6 +177,7 @@ TrexRpcCmdGetSysInfo::_run(const Json::Value &params, Json::Value &result) {
section["ports"][i]["index"] = i;
section["ports"][i]["driver"] = driver;
+ section["ports"][i]["macaddr"] = port->get_macaddr();
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 43f32d22..01733117 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -679,7 +679,28 @@ 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]);
+ }
+
+ output += formatted;
+ }
+
+ return output;
+
+}
void
TrexStatelessPort::add_stream(TrexStream *stream) {
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index 1d3eebc3..0d626375 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -331,6 +331,7 @@ public:
*/
void set_promiscuous(bool enabled);
bool get_promiscuous();
+ std::string get_macaddr();
private: