summaryrefslogtreecommitdiffstats
path: root/src/stateless/rx
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-11-06 17:20:17 +0200
committerimarom <imarom@cisco.com>2016-11-06 17:20:17 +0200
commita1ade6fd8e044b9866a8644db3519305539cfc61 (patch)
tree08b4d0e2db80c4d1e5cb759512c5e3631c19fd95 /src/stateless/rx
parent234779fd32e747f4ac918f3c39e59618dde0f2d7 (diff)
RX features - RX sniffer
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src/stateless/rx')
-rw-r--r--src/stateless/rx/trex_stateless_rx_core.cpp4
-rw-r--r--src/stateless/rx/trex_stateless_rx_core.h2
-rw-r--r--src/stateless/rx/trex_stateless_rx_defs.h27
-rw-r--r--src/stateless/rx/trex_stateless_rx_port_mngr.cpp7
-rw-r--r--src/stateless/rx/trex_stateless_rx_port_mngr.h9
5 files changed, 41 insertions, 8 deletions
diff --git a/src/stateless/rx/trex_stateless_rx_core.cpp b/src/stateless/rx/trex_stateless_rx_core.cpp
index ee9c64c4..3fe72f54 100644
--- a/src/stateless/rx/trex_stateless_rx_core.cpp
+++ b/src/stateless/rx/trex_stateless_rx_core.cpp
@@ -356,8 +356,8 @@ double CRxCoreStateless::get_cpu_util() {
void
-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);
+CRxCoreStateless::start_capture(uint8_t port_id, const std::string &pcap_filename, uint64_t limit, uint64_t *shared_counter) {
+ m_rx_port_mngr[port_id].start_capture(pcap_filename, limit, shared_counter);
}
void
diff --git a/src/stateless/rx/trex_stateless_rx_core.h b/src/stateless/rx/trex_stateless_rx_core.h
index 425c15ae..689b28ec 100644
--- a/src/stateless/rx/trex_stateless_rx_core.h
+++ b/src/stateless/rx/trex_stateless_rx_core.h
@@ -124,7 +124,7 @@ class CRxCoreStateless {
* @param pcap_filename
* @param limit
*/
- void start_capture(uint8_t port_id, const std::string &pcap_filename, uint64_t limit);
+ void start_capture(uint8_t port_id, const std::string &pcap_filename, uint64_t limit, uint64_t *shared_counter);
void stop_capture(uint8_t port_id);
/**
diff --git a/src/stateless/rx/trex_stateless_rx_defs.h b/src/stateless/rx/trex_stateless_rx_defs.h
index 9df6af67..0b7d1aa3 100644
--- a/src/stateless/rx/trex_stateless_rx_defs.h
+++ b/src/stateless/rx/trex_stateless_rx_defs.h
@@ -23,6 +23,7 @@
#define __TREX_STATELESS_RX_DEFS_H__
#include "trex_defs.h"
+#include <json/json.h>
class CPortLatencyHWBase;
@@ -54,4 +55,30 @@ typedef enum rx_filter_mode_ {
RX_FILTER_MODE_ALL
} rx_filter_mode_e;
+/**
+ * holds RX capture info
+ *
+ */
+struct RXCaptureInfo {
+ RXCaptureInfo() {
+ m_is_active = false;
+ m_limit = 0;
+ m_shared_counter = 0;
+ }
+
+ void to_json(Json::Value &output) const {
+ output["is_active"] = m_is_active;
+ if (m_is_active) {
+ output["pcap_filename"] = m_pcap_filename;
+ output["limit"] = Json::UInt64(m_limit);
+ output["count"] = Json::UInt64(m_shared_counter);
+ }
+ }
+
+ bool m_is_active;
+ std::string m_pcap_filename;
+ uint64_t m_limit;
+ uint64_t m_shared_counter;
+};
+
#endif /* __TREX_STATELESS_RX_DEFS_H__ */
diff --git a/src/stateless/rx/trex_stateless_rx_port_mngr.cpp b/src/stateless/rx/trex_stateless_rx_port_mngr.cpp
index 35d331cf..7283f703 100644
--- a/src/stateless/rx/trex_stateless_rx_port_mngr.cpp
+++ b/src/stateless/rx/trex_stateless_rx_port_mngr.cpp
@@ -139,6 +139,7 @@ RXLatency::reset_stats() {
RXPacketRecorder::RXPacketRecorder() {
m_writer = NULL;
+ m_shared_counter = NULL;
m_limit = 0;
m_epoch = -1;
}
@@ -148,7 +149,7 @@ RXPacketRecorder::~RXPacketRecorder() {
}
void
-RXPacketRecorder::start(const std::string &pcap, uint64_t limit) {
+RXPacketRecorder::start(const std::string &pcap, uint64_t limit, uint64_t *shared_counter) {
m_writer = CCapWriterFactory::CreateWriter(LIBPCAP, (char *)pcap.c_str());
if (m_writer == NULL) {
std::stringstream ss;
@@ -158,6 +159,8 @@ RXPacketRecorder::start(const std::string &pcap, uint64_t limit) {
assert(limit > 0);
m_limit = limit;
+ m_shared_counter = shared_counter;
+ (*m_shared_counter) = 0;
}
void
@@ -192,6 +195,8 @@ RXPacketRecorder::handle_pkt(const rte_mbuf_t *m) {
m_writer->write_packet(&m_pkt);
m_limit--;
+ (*m_shared_counter)++;
+
if (m_limit == 0) {
stop();
}
diff --git a/src/stateless/rx/trex_stateless_rx_port_mngr.h b/src/stateless/rx/trex_stateless_rx_port_mngr.h
index 7cc527d8..90527f0c 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, uint64_t limit);
+ void start(const std::string &pcap, uint64_t limit, uint64_t *shared_counter);
void stop();
void handle_pkt(const rte_mbuf_t *m);
@@ -220,7 +220,8 @@ private:
CFileWriterBase *m_writer;
CCapPktRaw m_pkt;
dsec_t m_epoch;
- uint32_t m_limit;
+ uint64_t m_limit;
+ uint64_t *m_shared_counter;
};
@@ -279,8 +280,8 @@ public:
* @param pcap
* @param limit_pkts
*/
- void start_capture(const std::string &pcap, uint64_t limit_pkts) {
- m_recorder.start(pcap, limit_pkts);
+ void start_capture(const std::string &pcap, uint64_t limit_pkts, uint64_t *shared_counter) {
+ m_recorder.start(pcap, limit_pkts, shared_counter);
set_feature(CAPTURE);
}