summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-11-06 18:50:16 +0200
committerimarom <imarom@cisco.com>2016-11-06 18:50:16 +0200
commite85ea75669ea39e4f99519138a3a84e4df6eed2d (patch)
tree27e1563def12afc2ef03c369324aa2b03807cc76
parenta1ade6fd8e044b9866a8644db3519305539cfc61 (diff)
RX features
Signed-off-by: imarom <imarom@cisco.com>
-rwxr-xr-xscripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py37
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_port.py20
-rw-r--r--src/rpc-server/commands/trex_rpc_cmd_general.cpp4
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp5
-rw-r--r--src/stateless/rx/trex_stateless_rx_defs.h16
5 files changed, 73 insertions, 9 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 b9143896..2d5a6379 100755
--- 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
@@ -658,7 +658,7 @@ class STLClient(object):
return rc
-
+
def __add_streams(self, stream_list, port_id_list = None):
port_id_list = self.__ports(port_id_list)
@@ -830,6 +830,16 @@ class STLClient(object):
return rc
+ def __remove_rx_sniffer (self, port_id_list):
+ port_id_list = self.__ports(port_id_list)
+ rc = RC()
+
+ for port_id in port_id_list:
+ rc.add(self.ports[port_id].remove_rx_sniffer())
+
+ return rc
+
+
# connect to server
def __connect(self):
@@ -1875,7 +1885,13 @@ class STLClient(object):
self.stop(ports, rx_delay_ms = 0)
self.remove_all_streams(ports)
self.clear_stats(ports)
+ self.set_port_attr(ports,
+ promiscuous = False,
+ link_up = True,
+ rx_filter_mode = 'hw')
+ self.remove_rx_sniffer(ports)
+
@__api_check(True)
def remove_all_streams (self, ports = None):
@@ -2733,6 +2749,25 @@ class STLClient(object):
+ @__api_check(True)
+ def remove_rx_sniffer (self, ports = None, base_filename = 'rx_capture', limit = 1000):
+ """
+ Removes RX sniffer from port(s)
+
+ :raises:
+ + :exe:'STLError'
+
+ """
+ ports = ports if ports is not None else self.get_acquired_ports()
+ ports = self._validate_port_list(ports)
+
+ self.logger.pre_cmd("Removing RX sniffers on port(s) {0}:".format(ports))
+ rc = self.__remove_rx_sniffer(ports)
+ self.logger.post_cmd(rc)
+
+ if not rc:
+ raise STLError(rc)
+
def clear_events (self):
"""
Clear all events
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 571a6e16..4e5778a6 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
@@ -75,13 +75,13 @@ class Port(object):
# decorator to verify port is up
def up(func):
- def func_wrapper(*args):
+ def func_wrapper(*args, **kwargs):
port = args[0]
if not port.is_up():
return port.err("{0} - port is down".format(func.__name__))
- return func(*args)
+ return func(*args, **kwargs)
return func_wrapper
@@ -489,7 +489,7 @@ class Port(object):
return self.ok()
- @writeable
+ @owned
def set_rx_sniffer (self, pcap_filename, limit):
params = {"handler": self.handler,
@@ -506,6 +506,20 @@ class Port(object):
return self.ok()
@owned
+ def remove_rx_sniffer (self):
+ params = {"handler": self.handler,
+ "port_id": self.port_id,
+ "type": "capture",
+ "enabled": False}
+
+ rc = self.transmit("set_rx_feature", params)
+ if rc.bad():
+ return self.err(rc.err())
+
+ return self.ok()
+
+
+ @owned
def pause (self):
if (self.state == self.STATE_PCAP_TX) :
diff --git a/src/rpc-server/commands/trex_rpc_cmd_general.cpp b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
index a441fc33..b5747d21 100644
--- a/src/rpc-server/commands/trex_rpc_cmd_general.cpp
+++ b/src/rpc-server/commands/trex_rpc_cmd_general.cpp
@@ -708,12 +708,14 @@ TrexRpcCmdSetRxFeature::_run(const Json::Value &params, Json::Value &result) {
void
TrexRpcCmdSetRxFeature::parse_capture_msg(const Json::Value &msg, TrexStatelessPort *port, Json::Value &result) {
- std::string pcap_filename = parse_string(msg, "pcap_filename", result);
+
bool enabled = parse_bool(msg, "enabled", result);
if (enabled) {
+ std::string pcap_filename = parse_string(msg, "pcap_filename", result);
uint64_t limit = parse_uint32(msg, "limit", result);
+
if (limit == 0) {
generate_parse_err(result, "limit cannot be zero");
}
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index f93d7abd..2318061d 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -947,9 +947,7 @@ TrexStatelessPort::remove_and_delete_all_streams() {
void
TrexStatelessPort::start_rx_capture(const std::string &pcap_filename, uint64_t limit) {
- m_rx_capture_info.m_is_active = true;
- m_rx_capture_info.m_limit = limit;
- m_rx_capture_info.m_pcap_filename = pcap_filename;
+ m_rx_capture_info.enable(pcap_filename, limit);
TrexStatelessCpToRxMsgBase *msg = new TrexStatelessRxStartCapture(m_port_id,
pcap_filename,
@@ -962,6 +960,7 @@ void
TrexStatelessPort::stop_rx_capture() {
TrexStatelessCpToRxMsgBase *msg = new TrexStatelessRxStopCapture(m_port_id);
send_message_to_rx(msg);
+ m_rx_capture_info.disable();
}
const RXCaptureInfo &
diff --git a/src/stateless/rx/trex_stateless_rx_defs.h b/src/stateless/rx/trex_stateless_rx_defs.h
index 0b7d1aa3..ee124270 100644
--- a/src/stateless/rx/trex_stateless_rx_defs.h
+++ b/src/stateless/rx/trex_stateless_rx_defs.h
@@ -59,13 +59,26 @@ typedef enum rx_filter_mode_ {
* holds RX capture info
*
*/
-struct RXCaptureInfo {
+class RXCaptureInfo {
+public:
RXCaptureInfo() {
m_is_active = false;
m_limit = 0;
m_shared_counter = 0;
}
+ void enable(const std::string &pcap_filename, uint64_t limit) {
+ m_pcap_filename = pcap_filename;
+ m_limit = limit;
+ m_is_active = true;
+ }
+
+ void disable() {
+ m_is_active = false;
+ m_pcap_filename = "";
+ m_limit = 0;
+ }
+
void to_json(Json::Value &output) const {
output["is_active"] = m_is_active;
if (m_is_active) {
@@ -75,6 +88,7 @@ struct RXCaptureInfo {
}
}
+public:
bool m_is_active;
std::string m_pcap_filename;
uint64_t m_limit;