summaryrefslogtreecommitdiffstats
path: root/src/stateless/cp
diff options
context:
space:
mode:
Diffstat (limited to 'src/stateless/cp')
-rw-r--r--src/stateless/cp/trex_stateless.cpp56
-rw-r--r--src/stateless/cp/trex_stateless.h28
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp57
-rw-r--r--src/stateless/cp/trex_stateless_port.h51
4 files changed, 84 insertions, 108 deletions
diff --git a/src/stateless/cp/trex_stateless.cpp b/src/stateless/cp/trex_stateless.cpp
index c31ba0a5..6ab9b417 100644
--- a/src/stateless/cp/trex_stateless.cpp
+++ b/src/stateless/cp/trex_stateless.cpp
@@ -18,13 +18,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
-#include <trex_stateless.h>
-#include <trex_stateless_port.h>
-#include <sched.h>
#include <iostream>
#include <unistd.h>
+#include "trex_stateless.h"
+#include "trex_stateless_port.h"
+#include "trex_stateless_messaging.h"
+
using namespace std;
/***********************************************************
@@ -141,53 +142,10 @@ TrexStateless::get_dp_core_count() {
}
void
-TrexStateless::encode_stats(Json::Value &global) {
-
- TrexPlatformGlobalStats stats;
- m_platform_api->get_global_stats(stats);
-
- global["cpu_util"] = stats.m_stats.m_cpu_util;
- global["rx_cpu_util"] = stats.m_stats.m_rx_cpu_util;
-
- global["tx_bps"] = stats.m_stats.m_tx_bps;
- global["rx_bps"] = stats.m_stats.m_rx_bps;
-
- global["tx_pps"] = stats.m_stats.m_tx_pps;
- global["rx_pps"] = stats.m_stats.m_rx_pps;
-
- global["total_tx_pkts"] = Json::Value::UInt64(stats.m_stats.m_total_tx_pkts);
- global["total_rx_pkts"] = Json::Value::UInt64(stats.m_stats.m_total_rx_pkts);
-
- global["total_tx_bytes"] = Json::Value::UInt64(stats.m_stats.m_total_tx_bytes);
- global["total_rx_bytes"] = Json::Value::UInt64(stats.m_stats.m_total_rx_bytes);
-
- global["tx_rx_errors"] = Json::Value::UInt64(stats.m_stats.m_tx_rx_errors);
-
- for (uint8_t i = 0; i < m_port_count; i++) {
- std::stringstream ss;
-
- ss << "port " << i;
- Json::Value &port_section = global[ss.str()];
+TrexStateless::send_msg_to_rx(TrexStatelessCpToRxMsgBase *msg) const {
- m_ports[i]->encode_stats(port_section);
- }
+ CNodeRing *ring = CMsgIns::Ins()->getCpRx()->getRingCpToDp(0);
+ ring->Enqueue((CGenNode *)msg);
}
-/**
- * generate a snapshot for publish (async publish)
- *
- */
-void
-TrexStateless::generate_publish_snapshot(std::string &snapshot) {
- Json::FastWriter writer;
- Json::Value root;
-
- root["name"] = "trex-stateless-info";
- root["type"] = 0;
-
- /* stateless specific info goes here */
- root["data"] = Json::nullValue;
-
- snapshot = writer.write(root);
-}
diff --git a/src/stateless/cp/trex_stateless.h b/src/stateless/cp/trex_stateless.h
index 3a1a2c24..87d227f6 100644
--- a/src/stateless/cp/trex_stateless.h
+++ b/src/stateless/cp/trex_stateless.h
@@ -132,32 +132,14 @@ public:
/**
- * shutdown the server
+ * send a message to the RX core
*/
- void shutdown();
-
+ void send_msg_to_rx(TrexStatelessCpToRxMsgBase *msg) const;
+
/**
- * fetch xstats names (keys of dict)
- *
- */
- void encode_xstats_names(Json::Value &global);
-
- /**
- * fetch xstats values
- *
- */
- void encode_xstats_values(Json::Value &global);
-
- /**
- * fetch all the stats
- *
- */
- void encode_stats(Json::Value &global);
-
- /**
- * generate a snapshot for publish
+ * shutdown the server
*/
- void generate_publish_snapshot(std::string &snapshot);
+ void shutdown();
const TrexPlatformApi * get_platform_api() {
return (m_platform_api);
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp
index 443f0df7..b88ac715 100644
--- a/src/stateless/cp/trex_stateless_port.cpp
+++ b/src/stateless/cp/trex_stateless_port.cpp
@@ -165,10 +165,11 @@ 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;
+ m_is_service_mode_on = false;
+
/* get the platform specific data */
api->get_interface_info(port_id, m_api_info);
@@ -958,24 +959,44 @@ TrexStatelessPort::remove_and_delete_all_streams() {
}
}
+/**
+ * enable/disable service mode
+ * sends a query to the RX core
+ *
+ */
void
-TrexStatelessPort::start_rx_capture(const std::string &pcap_filename, uint64_t limit) {
- static MsgReply<bool> reply;
-
+TrexStatelessPort::set_service_mode(bool enabled) {
+ static MsgReply<TrexStatelessRxQuery::query_rc_e> reply;
reply.reset();
- TrexStatelessRxStartCapture *msg = new TrexStatelessRxStartCapture(m_port_id, pcap_filename, limit, reply);
- send_message_to_rx((TrexStatelessCpToRxMsgBase *)msg);
+ TrexStatelessRxQuery::query_type_e query_type = (enabled ? TrexStatelessRxQuery::SERVICE_MODE_ON : TrexStatelessRxQuery::SERVICE_MODE_OFF);
- /* as below, must wait for ACK from RX core before returning ACK */
- reply.wait_for_reply();
+ TrexStatelessRxQuery *msg = new TrexStatelessRxQuery(m_port_id, query_type, reply);
+ send_message_to_rx( (TrexStatelessCpToRxMsgBase *)msg );
+
+ TrexStatelessRxQuery::query_rc_e rc = reply.wait_for_reply();
+
+ switch (rc) {
+ case TrexStatelessRxQuery::RC_OK:
+ if (enabled) {
+ getPortAttrObj()->set_rx_filter_mode(RX_FILTER_MODE_ALL);
+ } else {
+ getPortAttrObj()->set_rx_filter_mode(RX_FILTER_MODE_HW);
+ }
+ m_is_service_mode_on = enabled;
+ return;
+
+ case TrexStatelessRxQuery::RC_FAIL_RX_QUEUE_ACTIVE:
+ throw TrexException("unable to disable service mode - please remove RX queue");
+
+ case TrexStatelessRxQuery::RC_FAIL_CAPTURE_ACTIVE:
+ throw TrexException("unable to disable service mode - an active capture on port " + std::to_string(m_port_id) + " exists");
+
+ default:
+ assert(0);
+ }
}
-void
-TrexStatelessPort::stop_rx_capture() {
- TrexStatelessCpToRxMsgBase *msg = new TrexStatelessRxStopCapture(m_port_id);
- send_message_to_rx(msg);
-}
void
TrexStatelessPort::start_rx_queue(uint64_t size) {
@@ -999,9 +1020,9 @@ TrexStatelessPort::stop_rx_queue() {
}
-const RXPacketBuffer *
+const TrexPktBuffer *
TrexStatelessPort::get_rx_queue_pkts() {
- static MsgReply<const RXPacketBuffer *> reply;
+ static MsgReply<const TrexPktBuffer *> reply;
reply.reset();
diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h
index d4ac4018..4b8ea3d9 100644
--- a/src/stateless/cp/trex_stateless_port.h
+++ b/src/stateless/cp/trex_stateless_port.h
@@ -26,12 +26,14 @@ limitations under the License.
#include "trex_dp_port_events.h"
#include "trex_stateless_rx_defs.h"
#include "trex_stream.h"
+#include "trex_exception.h"
+#include "trex_stateless_capture.h"
class TrexStatelessCpToDpMsgBase;
class TrexStatelessCpToRxMsgBase;
class TrexStreamsGraphObj;
class TrexPortMultiplier;
-class RXPacketBuffer;
+class TrexPktBuffer;
/**
@@ -113,7 +115,6 @@ private:
static const std::string g_unowned_handler;
};
-
class AsyncStopEvent;
/**
@@ -150,7 +151,15 @@ public:
RC_ERR_FAILED_TO_COMPILE_STREAMS
};
-
+ /**
+ * port capture mode
+ */
+ enum capture_mode_e {
+ PORT_CAPTURE_NONE = 0,
+ PORT_CAPTURE_RX,
+ PORT_CAPTURE_ALL
+ };
+
TrexStatelessPort(uint8_t port_id, const TrexPlatformApi *api);
~TrexStatelessPort();
@@ -227,6 +236,20 @@ public:
double duration,
bool is_dual);
+
+ /**
+ * sets service mode
+ *
+ * @author imarom (1/22/2017)
+ *
+ * @param enabled
+ */
+ void set_service_mode(bool enabled);
+
+ bool is_service_mode_on() const {
+ return m_is_service_mode_on;
+ }
+
/**
* get the port state
*
@@ -365,19 +388,6 @@ 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);
-
- /**
- * disable RX capture if on
- *
- */
- void stop_rx_capture();
-
/**
* start RX queueing of packets
*
@@ -398,7 +408,7 @@ public:
* fetch the RX queue packets from the queue
*
*/
- const RXPacketBuffer *get_rx_queue_pkts();
+ const TrexPktBuffer *get_rx_queue_pkts();
/**
* configures port for L2 mode
@@ -429,7 +439,9 @@ public:
}
private:
-
+ void set_service_mode_on();
+ void set_service_mode_off();
+
bool is_core_active(int core_id);
const std::vector<uint8_t> get_core_id_list () {
@@ -514,6 +526,9 @@ private:
TrexPortOwner m_owner;
int m_pending_async_stop_event;
+
+ bool m_is_service_mode_on;
+
static const uint32_t MAX_STREAMS = 20000;
};