summaryrefslogtreecommitdiffstats
path: root/src/stateless
diff options
context:
space:
mode:
Diffstat (limited to 'src/stateless')
-rw-r--r--src/stateless/cp/trex_stream.cpp32
-rw-r--r--src/stateless/cp/trex_stream.h6
-rw-r--r--src/stateless/cp/trex_stream_vm.cpp7
-rw-r--r--src/stateless/cp/trex_stream_vm.h10
-rw-r--r--src/stateless/cp/trex_streams_compiler.cpp37
-rw-r--r--src/stateless/cp/trex_streams_compiler.h9
6 files changed, 69 insertions, 32 deletions
diff --git a/src/stateless/cp/trex_stream.cpp b/src/stateless/cp/trex_stream.cpp
index ef718529..72e72c7c 100644
--- a/src/stateless/cp/trex_stream.cpp
+++ b/src/stateless/cp/trex_stream.cpp
@@ -53,19 +53,30 @@ std::string TrexStream::get_stream_type_str(stream_type_t stream_type){
}
-void TrexStream::post_vm_compile(){
- /* if VM is enabled */
- if (is_vm()) {
- m_vm_dp = m_vm.cloneAsVmDp();
+void
+TrexStream::compile() {
+ /* in case there are no instructions - nothing to do */
+ if (m_vm.is_vm_empty()) {
+ m_has_vm = false;
+ return;
+ }
- /* calc m_vm_prefix_size which is the size of the writable packet */
- uint16_t max_pkt_offset = m_vm_dp->get_max_packet_update_offset();
- uint16_t pkt_size = m_pkt.len;
+ m_has_vm = true;
- /* calculate the mbuf size that we should allocate */
- m_vm_prefix_size =calc_writable_mbuf_size(max_pkt_offset,pkt_size);
- }
+ m_vm.set_packet_size(m_pkt.len);
+
+ m_vm.compile();
+
+ m_vm_dp = m_vm.cloneAsVmDp();
+
+
+ /* calc m_vm_prefix_size which is the size of the writable packet */
+ uint16_t max_pkt_offset = m_vm_dp->get_max_packet_update_offset();
+ uint16_t pkt_size = m_pkt.len;
+
+ /* calculate the mbuf size that we should allocate */
+ m_vm_prefix_size = calc_writable_mbuf_size(max_pkt_offset, pkt_size);
}
@@ -222,3 +233,4 @@ int TrexStreamTable::size() {
return m_stream_table.size();
}
+
diff --git a/src/stateless/cp/trex_stream.h b/src/stateless/cp/trex_stream.h
index 53b658fc..720246f6 100644
--- a/src/stateless/cp/trex_stream.h
+++ b/src/stateless/cp/trex_stream.h
@@ -229,6 +229,12 @@ public:
void post_vm_compile();
+ /**
+ * internal compilation of stream (for DP)
+ *
+ */
+ void compile();
+
public:
/* basic */
uint8_t m_type;
diff --git a/src/stateless/cp/trex_stream_vm.cpp b/src/stateless/cp/trex_stream_vm.cpp
index 310a4369..e10e1a81 100644
--- a/src/stateless/cp/trex_stream_vm.cpp
+++ b/src/stateless/cp/trex_stream_vm.cpp
@@ -595,7 +595,7 @@ void StreamVm::build_bss() {
-void StreamVm::compile_next() {
+void StreamVm::compile() {
/* build flow var offset table */
build_flow_var_table() ;
@@ -613,11 +613,6 @@ void StreamVm::compile_next() {
}
-bool StreamVm::compile() {
-
- return (false);
-}
-
StreamVm::~StreamVm() {
for (auto inst : m_inst_list) {
delete inst;
diff --git a/src/stateless/cp/trex_stream_vm.h b/src/stateless/cp/trex_stream_vm.h
index 0484693f..e65a87e3 100644
--- a/src/stateless/cp/trex_stream_vm.h
+++ b/src/stateless/cp/trex_stream_vm.h
@@ -927,6 +927,10 @@ public:
}
+ bool is_vm_empty() {
+ return (m_inst_list.size() == 0);
+ }
+
/**
* add new instruction to the VM
*
@@ -961,11 +965,7 @@ public:
* return true of success, o.w false
*
*/
- bool compile();
-
-
- void compile_next();
-
+ void compile();
~StreamVm();
diff --git a/src/stateless/cp/trex_streams_compiler.cpp b/src/stateless/cp/trex_streams_compiler.cpp
index 478e09f8..c4900e66 100644
--- a/src/stateless/cp/trex_streams_compiler.cpp
+++ b/src/stateless/cp/trex_streams_compiler.cpp
@@ -376,6 +376,26 @@ TrexStreamsCompiler::compile(uint8_t port_id,
double factor,
std::string *fail_msg) {
+ try {
+ return compile_internal(port_id,streams,objs,dp_core_count,factor,fail_msg);
+ } catch (const TrexException &ex) {
+ if (fail_msg) {
+ *fail_msg = ex.what();
+ } else {
+ std::cout << ex.what();
+ }
+ return false;
+ }
+
+}
+bool
+TrexStreamsCompiler::compile_internal(uint8_t port_id,
+ const std::vector<TrexStream *> &streams,
+ std::vector<TrexStreamsCompiledObj *> &objs,
+ uint8_t dp_core_count,
+ double factor,
+ std::string *fail_msg) {
+
#if 0
for (auto stream : streams) {
stream->Dump(stdout);
@@ -387,16 +407,7 @@ TrexStreamsCompiler::compile(uint8_t port_id,
/* compile checks */
- try {
- pre_compile_check(streams, nodes);
- } catch (const TrexException &ex) {
- if (fail_msg) {
- *fail_msg = ex.what();
- } else {
- std::cout << ex.what();
- }
- return false;
- }
+ pre_compile_check(streams, nodes);
/* check if all are cont. streams */
bool all_continues = true;
@@ -424,7 +435,6 @@ TrexStreamsCompiler::compile(uint8_t port_id,
/* compile a single stream to all cores */
compile_stream(stream, factor, dp_core_count, objs, nodes);
-
}
return true;
@@ -457,6 +467,10 @@ TrexStreamsCompiler::compile_stream(const TrexStream *stream,
double per_core_rate = (stream->m_pps * (factor / dp_core_count));
int per_core_burst_total_pkts = (stream->m_burst_total_pkts / dp_core_count);
+ /* compile VM */
+ /* fix this const away problem */
+ ((TrexStream *)stream)->compile();
+
std::vector<TrexStream *> per_core_streams(dp_core_count);
/* for each core - creates its own version of the stream */
@@ -486,6 +500,7 @@ TrexStreamsCompiler::compile_stream(const TrexStream *stream,
}
+
/**************************************
* streams graph
*************************************/
diff --git a/src/stateless/cp/trex_streams_compiler.h b/src/stateless/cp/trex_streams_compiler.h
index 7fe2dbf2..d2b0cd1d 100644
--- a/src/stateless/cp/trex_streams_compiler.h
+++ b/src/stateless/cp/trex_streams_compiler.h
@@ -103,6 +103,13 @@ public:
private:
+ bool compile_internal(uint8_t port_id,
+ const std::vector<TrexStream *> &streams,
+ std::vector<TrexStreamsCompiledObj *> &objs,
+ uint8_t dp_core_count,
+ double factor,
+ std::string *fail_msg);
+
void pre_compile_check(const std::vector<TrexStream *> &streams,
GraphNodeMap & nodes);
void allocate_pass(const std::vector<TrexStream *> &streams, GraphNodeMap *nodes);
@@ -118,6 +125,8 @@ private:
std::vector<TrexStreamsCompiledObj *> &objs,
GraphNodeMap &nodes);
+ void compile_stream_vm(TrexStream *stream);
+
std::vector<std::string> m_warnings;
};