summaryrefslogtreecommitdiffstats
path: root/src/stateless
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-11-03 16:33:52 +0200
committerimarom <imarom@cisco.com>2016-11-03 16:33:52 +0200
commit234779fd32e747f4ac918f3c39e59618dde0f2d7 (patch)
tree2ba641354b6d6c751f94de44f9453dcbec0e19aa /src/stateless
parent0ed685e077e8533ffe6d96f5d1fefcdd42626763 (diff)
moved RX filter feature to port attr
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src/stateless')
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp26
-rw-r--r--src/stateless/cp/trex_stateless_port.h24
-rw-r--r--src/stateless/messaging/trex_stateless_messaging.cpp19
-rw-r--r--src/stateless/messaging/trex_stateless_messaging.h27
-rw-r--r--src/stateless/rx/trex_stateless_rx_core.cpp61
-rw-r--r--src/stateless/rx/trex_stateless_rx_core.h45
-rw-r--r--src/stateless/rx/trex_stateless_rx_port_mngr.cpp4
-rw-r--r--src/stateless/rx/trex_stateless_rx_port_mngr.h55
8 files changed, 175 insertions, 86 deletions
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index 5d31abbf..c0156c12 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -157,9 +157,9 @@ private:
TrexStatelessPort::TrexStatelessPort(uint8_t port_id, const TrexPlatformApi *api) : m_dp_events(this) {
std::vector<std::pair<uint8_t, uint8_t>> core_pair_list;
- m_port_id = port_id;
- m_port_state = PORT_STATE_IDLE;
- m_platform_api = api;
+ m_port_id = port_id;
+ m_port_state = PORT_STATE_IDLE;
+ m_platform_api = api;
/* get the platform specific data */
api->get_interface_info(port_id, m_api_info);
@@ -585,10 +585,9 @@ TrexStatelessPort::get_max_stream_id() const {
}
void
-TrexStatelessPort::get_properties(std::string &driver, uint32_t &speed) {
+TrexStatelessPort::get_properties(std::string &driver) {
driver = m_api_info.driver_name;
- speed = m_platform_api->getPortAttrObj(m_port_id)->get_link_speed();
}
bool
@@ -945,16 +944,15 @@ TrexStatelessPort::remove_and_delete_all_streams() {
}
}
-/**
- * set the filter type for a port
- *
- * @author imarom (10/31/2016)
- *
- * @param rx_sw_cfg
- */
+void
+TrexStatelessPort::start_rx_capture(const std::string &pcap_filename, uint64_t limit) {
+ TrexStatelessCpToRxMsgBase *msg = new TrexStatelessRxStartCapture(m_port_id, pcap_filename, limit);
+ send_message_to_rx(msg);
+}
+
void
-TrexStatelessPort::set_rx_filter_mode(rx_filter_mode_e filter_mode) {
- TrexStatelessCpToRxMsgBase *msg = new TrexStatelessRxSetFilterMode(m_port_id, filter_mode);
+TrexStatelessPort::stop_rx_capture() {
+ TrexStatelessCpToRxMsgBase *msg = new TrexStatelessRxStopCapture(m_port_id);
send_message_to_rx(msg);
}
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index 41453caa..5a1935a1 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -257,11 +257,8 @@ public:
* @author imarom (16-Sep-15)
*
* @param driver
- * @param speed
*/
- void get_properties(std::string &driver, uint32_t &speed);
-
-
+ void get_properties(std::string &driver);
/**
* encode stats as JSON
@@ -371,11 +368,18 @@ public:
void get_pci_info(std::string &pci_addr, int &numa_node);
+
+ /**
+ * enable RX capture on port
+ *
+ */
+ void start_rx_capture(const std::string &pcap_filename, uint64_t limit);
+
/**
- * set RX filter mode
- * can be hardware or software
+ * disable RX capture if on
+ *
*/
- void set_rx_filter_mode(rx_filter_mode_e);
+ void stop_rx_capture();
/**
* fetch the RX software packets from the queue
@@ -515,9 +519,9 @@ public:
static const std::initializer_list<std::string> g_types;
static const std::initializer_list<std::string> g_ops;
- mul_type_e m_type;
- mul_op_e m_op;
- double m_value;
+ mul_type_e m_type;
+ mul_op_e m_op;
+ double m_value;
};
#endif /* __TREX_STATELESS_PORT_H__ */
diff --git a/src/stateless/messaging/trex_stateless_messaging.cpp b/src/stateless/messaging/trex_stateless_messaging.cpp
index 10b4355b..6e7bfee5 100644
--- a/src/stateless/messaging/trex_stateless_messaging.cpp
+++ b/src/stateless/messaging/trex_stateless_messaging.cpp
@@ -241,13 +241,13 @@ TrexDpPortEventMsg::handle() {
}
/************************* messages from CP to RX **********************/
-bool TrexStatelessRxStartMsg::handle (CRxCoreStateless *rx_core) {
- rx_core->work();
+bool TrexStatelessRxEnableLatency::handle (CRxCoreStateless *rx_core) {
+ rx_core->enable_latency();
return true;
}
-bool TrexStatelessRxStopMsg::handle (CRxCoreStateless *rx_core) {
- rx_core->idle();
+bool TrexStatelessRxDisableLatency::handle (CRxCoreStateless *rx_core) {
+ rx_core->disable_latency();
return true;
}
@@ -263,8 +263,15 @@ TrexStatelessRxSwGetPkts::TrexStatelessRxSwGetPkts(uint8_t port_id, TrexStateles
bool
-TrexStatelessRxSetFilterMode::handle(CRxCoreStateless *rx_core) {
- rx_core->set_rx_filter_mode(m_port_id, m_filter_mode);
+TrexStatelessRxStartCapture::handle(CRxCoreStateless *rx_core) {
+ rx_core->start_capture(m_port_id, m_pcap_filename, m_limit);
+
+ return true;
+}
+
+bool
+TrexStatelessRxStopCapture::handle(CRxCoreStateless *rx_core) {
+ rx_core->stop_capture(m_port_id);
return true;
}
diff --git a/src/stateless/messaging/trex_stateless_messaging.h b/src/stateless/messaging/trex_stateless_messaging.h
index 42a422b0..e96e83d6 100644
--- a/src/stateless/messaging/trex_stateless_messaging.h
+++ b/src/stateless/messaging/trex_stateless_messaging.h
@@ -408,11 +408,11 @@ public:
};
-class TrexStatelessRxStartMsg : public TrexStatelessCpToRxMsgBase {
+class TrexStatelessRxEnableLatency : public TrexStatelessCpToRxMsgBase {
bool handle (CRxCoreStateless *rx_core);
};
-class TrexStatelessRxStopMsg : public TrexStatelessCpToRxMsgBase {
+class TrexStatelessRxDisableLatency : public TrexStatelessCpToRxMsgBase {
bool handle (CRxCoreStateless *rx_core);
};
@@ -421,17 +421,32 @@ class TrexStatelessRxQuit : public TrexStatelessCpToRxMsgBase {
};
-class TrexStatelessRxSetFilterMode : public TrexStatelessCpToRxMsgBase {
+class TrexStatelessRxStartCapture : public TrexStatelessCpToRxMsgBase {
public:
- TrexStatelessRxSetFilterMode(uint8_t port_id, rx_filter_mode_e filter_mode) {
+ TrexStatelessRxStartCapture(uint8_t port_id, const std::string &pcap_filename, uint64_t limit) : m_pcap_filename(pcap_filename) {
m_port_id = port_id;
- m_filter_mode = filter_mode;
+ m_limit = limit;
}
+
+ virtual bool handle(CRxCoreStateless *rx_core);
+
+private:
+ uint8_t m_port_id;
+ std::string m_pcap_filename;
+ uint64_t m_limit;
+};
+
+
+class TrexStatelessRxStopCapture : public TrexStatelessCpToRxMsgBase {
+public:
+ TrexStatelessRxStopCapture(uint8_t port_id) {
+ m_port_id = port_id;
+ }
+
virtual bool handle(CRxCoreStateless *rx_core);
private:
uint8_t m_port_id;
- rx_filter_mode_e m_filter_mode;
};
diff --git a/src/stateless/rx/trex_stateless_rx_core.cpp b/src/stateless/rx/trex_stateless_rx_core.cpp
index ca39b8a0..ee9c64c4 100644
--- a/src/stateless/rx/trex_stateless_rx_core.cpp
+++ b/src/stateless/rx/trex_stateless_rx_core.cpp
@@ -121,10 +121,29 @@ bool CRxCoreStateless::periodic_check_for_cp_messages() {
handle_cp_msg(msg);
}
+ recalculate_next_state();
return true;
}
+void CRxCoreStateless::recalculate_next_state() {
+ if (m_state == STATE_QUIT) {
+ return;
+ }
+
+ /* next state is determine by the question are there any ports with active features ? */
+ m_state = (are_any_features_active() ? STATE_WORKING : STATE_IDLE);
+}
+
+bool CRxCoreStateless::are_any_features_active() {
+ for (int i = 0; i < m_max_ports; i++) {
+ if (m_rx_port_mngr[i].has_features_set()) {
+ return true;
+ }
+ }
+
+ return false;
+}
void CRxCoreStateless::idle_state_loop() {
const int SHORT_DELAY_MS = 2;
@@ -260,12 +279,12 @@ void CRxCoreStateless::try_rx_queues() {
int CRxCoreStateless::process_all_pending_pkts(bool flush_rx) {
- int total_pkts = 0;
- for (int i = 0; i < m_max_ports; i++) {
- total_pkts += m_rx_port_mngr[i].process_all_pending_pkts(flush_rx);
- }
+ int total_pkts = 0;
+ for (int i = 0; i < m_max_ports; i++) {
+ total_pkts += m_rx_port_mngr[i].process_all_pending_pkts(flush_rx);
+ }
- return total_pkts;
+ return total_pkts;
}
@@ -336,17 +355,27 @@ double CRxCoreStateless::get_cpu_util() {
}
-/**
- * configure RX filtering mode (HW or software)
- *
- * @author imarom (11/1/2016)
- *
- * @param port_id
- * @param filter_mode
- */
void
-CRxCoreStateless::set_rx_filter_mode(uint8_t port_id, rx_filter_mode_e filter_mode) {
- const TrexPlatformApi *api = get_stateless_obj()->get_platform_api();
- api->set_rx_filter_mode(port_id, filter_mode);
+CRxCoreStateless::start_capture(uint8_t port_id, const std::string &pcap_filename, uint64_t limit) {
+ m_rx_port_mngr[port_id].start_capture(pcap_filename, limit);
+}
+
+void
+CRxCoreStateless::stop_capture(uint8_t port_id) {
+ m_rx_port_mngr[port_id].stop_capture();
+}
+
+void
+CRxCoreStateless::enable_latency() {
+ for (int i = 0; i < m_max_ports; i++) {
+ m_rx_port_mngr[i].enable_latency();
+ }
+}
+
+void
+CRxCoreStateless::disable_latency() {
+ for (int i = 0; i < m_max_ports; i++) {
+ m_rx_port_mngr[i].disable_latency();
+ }
}
diff --git a/src/stateless/rx/trex_stateless_rx_core.h b/src/stateless/rx/trex_stateless_rx_core.h
index 2a59862b..425c15ae 100644
--- a/src/stateless/rx/trex_stateless_rx_core.h
+++ b/src/stateless/rx/trex_stateless_rx_core.h
@@ -103,11 +103,8 @@ class CRxCoreStateless {
, TrexPlatformApi::driver_stat_cap_e type);
int get_rfc2544_info(rfc2544_info_t *rfc2544_info, int min, int max, bool reset);
int get_rx_err_cntrs(CRxCoreErrCntrs *rx_err);
- void work() {
- m_state = STATE_WORKING;
- m_err_cntrs.reset(); // When starting to work, reset global counters
- }
- void idle() {m_state = STATE_IDLE;}
+
+
void quit() {m_state = STATE_QUIT;}
bool is_working() const {return (m_ack_start_work_msg == true);}
void set_working_msg_ack(bool val);
@@ -119,19 +116,33 @@ class CRxCoreStateless {
}
/**
- * sets the port filter mode
+ * start capturing of RX packets on a specific port
*
- * @author imarom (10/31/2016)
+ * @author imarom (11/2/2016)
*
- * @param filter_mode
+ * @param port_id
+ * @param pcap_filename
+ * @param limit
+ */
+ void start_capture(uint8_t port_id, const std::string &pcap_filename, uint64_t limit);
+ void stop_capture(uint8_t port_id);
+
+ /**
+ * enable latency feature for RX packets
+ * will be apply to all ports
*/
- void set_rx_filter_mode(uint8_t port_id, rx_filter_mode_e filter_mode);
+ void enable_latency();
+ void disable_latency();
private:
void handle_cp_msg(TrexStatelessCpToRxMsgBase *msg);
bool periodic_check_for_cp_messages();
void tickle();
void idle_state_loop();
+
+ void recalculate_next_state();
+ bool are_any_features_active();
+
void capture_pkt(rte_mbuf_t *m);
void handle_rx_queue_msgs(uint8_t thread_id, CNodeRing * r);
void handle_work_stage(bool do_try_rx_queue);
@@ -145,14 +156,14 @@ class CRxCoreStateless {
void try_rx_queues();
private:
- TrexMonitor m_monitor;
- uint32_t m_max_ports;
- bool m_capture;
- state_e m_state;
- CNodeRing *m_ring_from_cp;
- CNodeRing *m_ring_to_cp;
- CCpuUtlDp m_cpu_dp_u;
- CCpuUtlCp m_cpu_cp_u;
+ TrexMonitor m_monitor;
+ uint32_t m_max_ports;
+ bool m_capture;
+ state_e m_state;
+ CNodeRing *m_ring_from_cp;
+ CNodeRing *m_ring_to_cp;
+ CCpuUtlDp m_cpu_dp_u;
+ CCpuUtlCp m_cpu_cp_u;
// Used for acking "work" (go out of idle) messages from cp
volatile bool m_ack_start_work_msg __rte_cache_aligned;
diff --git a/src/stateless/rx/trex_stateless_rx_port_mngr.cpp b/src/stateless/rx/trex_stateless_rx_port_mngr.cpp
index 5b10eebf..35d331cf 100644
--- a/src/stateless/rx/trex_stateless_rx_port_mngr.cpp
+++ b/src/stateless/rx/trex_stateless_rx_port_mngr.cpp
@@ -148,7 +148,7 @@ RXPacketRecorder::~RXPacketRecorder() {
}
void
-RXPacketRecorder::start(const std::string &pcap, uint32_t limit) {
+RXPacketRecorder::start(const std::string &pcap, uint64_t limit) {
m_writer = CCapWriterFactory::CreateWriter(LIBPCAP, (char *)pcap.c_str());
if (m_writer == NULL) {
std::stringstream ss;
@@ -206,7 +206,7 @@ void RXPortManager::handle_pkt(const rte_mbuf_t *m) {
m_latency.handle_pkt(m);
}
- if (is_feature_set(RECORD)) {
+ if (is_feature_set(CAPTURE)) {
m_recorder.handle_pkt(m);
}
diff --git a/src/stateless/rx/trex_stateless_rx_port_mngr.h b/src/stateless/rx/trex_stateless_rx_port_mngr.h
index d197c423..7cc527d8 100644
--- a/src/stateless/rx/trex_stateless_rx_port_mngr.h
+++ b/src/stateless/rx/trex_stateless_rx_port_mngr.h
@@ -212,7 +212,7 @@ class RXPacketRecorder {
public:
RXPacketRecorder();
~RXPacketRecorder();
- void start(const std::string &pcap, uint32_t limit);
+ void start(const std::string &pcap, uint64_t limit);
void stop();
void handle_pkt(const rte_mbuf_t *m);
@@ -235,16 +235,15 @@ class RXPortManager {
public:
enum features_t {
LATENCY = 0x1,
- RECORD = 0x2,
+ CAPTURE = 0x2,
QUEUE = 0x4
};
RXPortManager() {
- m_features = 0;
- m_pkt_buffer = NULL;
- m_io = NULL;
- m_cpu_dp_u = NULL;
- set_feature(LATENCY);
+ m_features = 0;
+ m_pkt_buffer = NULL;
+ m_io = NULL;
+ m_cpu_dp_u = NULL;
}
void create(CPortLatencyHWBase *io,
@@ -264,16 +263,36 @@ public:
return m_latency;
}
- void start_recorder(const std::string &pcap, uint32_t limit_pkts) {
+ void enable_latency() {
+ set_feature(LATENCY);
+ }
+
+ void disable_latency() {
+ unset_feature(LATENCY);
+ }
+
+ /**
+ * capturing of RX packets
+ *
+ * @author imarom (11/2/2016)
+ *
+ * @param pcap
+ * @param limit_pkts
+ */
+ void start_capture(const std::string &pcap, uint64_t limit_pkts) {
m_recorder.start(pcap, limit_pkts);
- set_feature(RECORD);
+ set_feature(CAPTURE);
}
- void stop_recorder() {
+ void stop_capture() {
m_recorder.stop();
- unset_feature(RECORD);
+ unset_feature(CAPTURE);
}
+ /**
+ * queueing packets
+ *
+ */
void start_queue(uint32_t limit) {
if (m_pkt_buffer) {
delete m_pkt_buffer;
@@ -329,6 +348,16 @@ public:
*/
void handle_pkt(const rte_mbuf_t *m);
+
+ bool has_features_set() {
+ return (m_features != 0);
+ }
+
+
+ bool no_features_set() {
+ return (!has_features_set());
+ }
+
private:
@@ -344,10 +373,6 @@ private:
return ( (m_features & feature) == feature );
}
- bool no_features_set() {
- return (m_features == 0);
- }
-
uint32_t m_features;
RXPacketRecorder m_recorder;
RXLatency m_latency;