diff options
author | imarom <imarom@cisco.com> | 2016-11-06 17:20:17 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-11-06 17:20:17 +0200 |
commit | a1ade6fd8e044b9866a8644db3519305539cfc61 (patch) | |
tree | 08b4d0e2db80c4d1e5cb759512c5e3631c19fd95 /src/stateless | |
parent | 234779fd32e747f4ac918f3c39e59618dde0f2d7 (diff) |
RX features - RX sniffer
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src/stateless')
-rw-r--r-- | src/stateless/cp/trex_stateless_port.cpp | 16 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.h | 9 | ||||
-rw-r--r-- | src/stateless/messaging/trex_stateless_messaging.cpp | 2 | ||||
-rw-r--r-- | src/stateless/messaging/trex_stateless_messaging.h | 7 | ||||
-rw-r--r-- | src/stateless/rx/trex_stateless_rx_core.cpp | 4 | ||||
-rw-r--r-- | src/stateless/rx/trex_stateless_rx_core.h | 2 | ||||
-rw-r--r-- | src/stateless/rx/trex_stateless_rx_defs.h | 27 | ||||
-rw-r--r-- | src/stateless/rx/trex_stateless_rx_port_mngr.cpp | 7 | ||||
-rw-r--r-- | src/stateless/rx/trex_stateless_rx_port_mngr.h | 9 |
9 files changed, 72 insertions, 11 deletions
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index c0156c12..f93d7abd 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -946,7 +946,15 @@ TrexStatelessPort::remove_and_delete_all_streams() { void TrexStatelessPort::start_rx_capture(const std::string &pcap_filename, uint64_t limit) { - TrexStatelessCpToRxMsgBase *msg = new TrexStatelessRxStartCapture(m_port_id, pcap_filename, 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; + + TrexStatelessCpToRxMsgBase *msg = new TrexStatelessRxStartCapture(m_port_id, + pcap_filename, + limit, + &m_rx_capture_info.m_shared_counter); send_message_to_rx(msg); } @@ -956,6 +964,12 @@ TrexStatelessPort::stop_rx_capture() { send_message_to_rx(msg); } +const RXCaptureInfo & +TrexStatelessPort::get_rx_capture_info() { + return m_rx_capture_info; +} + + RxPacketBuffer * TrexStatelessPort::get_rx_sw_pkts() { diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h index 5a1935a1..973a95c6 100644 --- a/src/stateless/cp/trex_stateless_port.h +++ b/src/stateless/cp/trex_stateless_port.h @@ -33,6 +33,7 @@ class TrexStreamsGraphObj; class TrexPortMultiplier; class RxPacketBuffer; + /** * TRex port owner can perform * write commands @@ -382,6 +383,12 @@ public: void stop_rx_capture(); /** + * status of the RX capture + * + */ + const RXCaptureInfo &get_rx_capture_info(); + + /** * fetch the RX software packets from the queue * */ @@ -473,6 +480,8 @@ private: TrexPortOwner m_owner; int m_pending_async_stop_event; + + RXCaptureInfo m_rx_capture_info; }; diff --git a/src/stateless/messaging/trex_stateless_messaging.cpp b/src/stateless/messaging/trex_stateless_messaging.cpp index 6e7bfee5..bd444dff 100644 --- a/src/stateless/messaging/trex_stateless_messaging.cpp +++ b/src/stateless/messaging/trex_stateless_messaging.cpp @@ -264,7 +264,7 @@ TrexStatelessRxSwGetPkts::TrexStatelessRxSwGetPkts(uint8_t port_id, TrexStateles bool TrexStatelessRxStartCapture::handle(CRxCoreStateless *rx_core) { - rx_core->start_capture(m_port_id, m_pcap_filename, m_limit); + rx_core->start_capture(m_port_id, m_pcap_filename, m_limit, m_shared_counter); return true; } diff --git a/src/stateless/messaging/trex_stateless_messaging.h b/src/stateless/messaging/trex_stateless_messaging.h index e96e83d6..f35d9da6 100644 --- a/src/stateless/messaging/trex_stateless_messaging.h +++ b/src/stateless/messaging/trex_stateless_messaging.h @@ -423,9 +423,13 @@ class TrexStatelessRxQuit : public TrexStatelessCpToRxMsgBase { class TrexStatelessRxStartCapture : public TrexStatelessCpToRxMsgBase { public: - TrexStatelessRxStartCapture(uint8_t port_id, const std::string &pcap_filename, uint64_t limit) : m_pcap_filename(pcap_filename) { + TrexStatelessRxStartCapture(uint8_t port_id, + const std::string &pcap_filename, + uint64_t limit, + uint64_t *shared_counter) : m_pcap_filename(pcap_filename) { m_port_id = port_id; m_limit = limit; + m_shared_counter = shared_counter; } virtual bool handle(CRxCoreStateless *rx_core); @@ -434,6 +438,7 @@ private: uint8_t m_port_id; std::string m_pcap_filename; uint64_t m_limit; + uint64_t *m_shared_counter; }; 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); } |