summaryrefslogtreecommitdiffstats
path: root/src/stateless/cp
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-09-25 18:45:04 +0300
committerimarom <imarom@cisco.com>2016-09-25 18:45:04 +0300
commitf6d11f9e01e39fe2688558c7598f22ce9feb35da (patch)
tree672f5e4c5010484569edbbe8b29c4c03b2cd7ef4 /src/stateless/cp
parentd94e6a00edc22a1dd4946b3603aebb29319ce5ce (diff)
merge issues with rand limit
Diffstat (limited to 'src/stateless/cp')
-rw-r--r--src/stateless/cp/trex_stream_vm.cpp60
-rw-r--r--src/stateless/cp/trex_stream_vm.h60
2 files changed, 51 insertions, 69 deletions
diff --git a/src/stateless/cp/trex_stream_vm.cpp b/src/stateless/cp/trex_stream_vm.cpp
index 106b5ea3..c157ab06 100644
--- a/src/stateless/cp/trex_stream_vm.cpp
+++ b/src/stateless/cp/trex_stream_vm.cpp
@@ -133,30 +133,27 @@ void StreamVmInstructionFlowMan::sanity_check_valid_range(uint32_t ins_id,Stream
-uint8_t StreamVmInstructionFlowMan::bss_init_value(uint8_t *p){
- uint8_t res;
+uint8_t StreamVmInstructionFlowMan::set_bss_init_value(uint8_t *p) {
+
+ uint64_t prev = peek_prev();
switch (m_size_bytes) {
case 1:
- *p=(uint8_t)get_bss_init_value();
- res=1;
- break;
+ *p=(uint8_t)prev;
+ return 1;
case 2:
- *((uint16_t*)p)=(uint16_t)get_bss_init_value();
- res=2;
- break;
+ *((uint16_t*)p)=(uint16_t)prev;
+ return 2;
case 4:
- *((uint32_t*)p)=(uint32_t)get_bss_init_value();
- res=4;
- break;
+ *((uint32_t*)p)=(uint32_t)prev;
+ return 4;
case 8:
- *((uint64_t*)p)=(uint64_t)get_bss_init_value();
- res=8;
- break;
+ *((uint64_t*)p)=(uint64_t)prev;
+ return 8;
default:
assert(0);
+ return(0);
}
- return(res);
}
@@ -179,7 +176,7 @@ void StreamVmInstructionFlowRandLimit::sanity_check(uint32_t ins_id,StreamVm *lp
}
-uint8_t StreamVmInstructionFlowRandLimit::bss_init_value(uint8_t *p){
+uint8_t StreamVmInstructionFlowRandLimit::set_bss_init_value(uint8_t *p){
uint8_t res;
typedef union ua_ {
@@ -305,26 +302,25 @@ void StreamVmInstructionFlowClient::Dump(FILE *fd){
}
-uint8_t StreamVmInstructionFlowClient::bss_init_value(uint8_t *p){
+uint8_t StreamVmInstructionFlowClient::set_bss_init_value(uint8_t *p) {
- if (m_client_min>0) {
- *((uint32_t*)p)=(uint32_t)(m_client_min-1);
- }else{
- *((uint32_t*)p)=(uint32_t)m_client_min;
- }
+ uint32_t bss_ip;
+ uint16_t bss_port;
- p+=4;
+ /* fetch the previous values by 1 */
+ peek_prev(bss_ip, bss_port, 1);
- if (is_unlimited_flows() ) {
- *((uint16_t*)p)=StreamDPOpClientsUnLimit::CLIENT_UNLIMITED_MIN_PORT;
- }else{
- *((uint16_t*)p)=(uint16_t)m_port_min;
- }
+ /* ip */
+ *((uint32_t*)p) = bss_ip;
+ p += 4;
- p+=2;
+ /* port */
+ *((uint16_t*)p) = bss_port;
+ p += 2;
- *((uint32_t*)p)=0;
- p+=4;
+ /* reserve */
+ *((uint32_t*)p) = 0;
+ p += 4;
return (get_flow_var_size());
}
@@ -1057,7 +1053,7 @@ void StreamVm::build_bss() {
}
for (auto inst : m_inst_list) {
- p+=inst->bss_init_value(p);
+ p+=inst->set_bss_init_value(p);
}
}
diff --git a/src/stateless/cp/trex_stream_vm.h b/src/stateless/cp/trex_stream_vm.h
index 92fefbb3..be0c03ba 100644
--- a/src/stateless/cp/trex_stream_vm.h
+++ b/src/stateless/cp/trex_stream_vm.h
@@ -912,11 +912,11 @@ public:
bool is_var_instruction() const {
instruction_type_t type = get_instruction_type();
- return ( (type == itFLOW_MAN) || (type == itFLOW_CLIENT) );
+ return ( (type == itFLOW_MAN) || (type == itFLOW_CLIENT) || (type == itFLOW_RAND_LIMIT) );
}
/* nothing to init */
- virtual uint8_t bss_init_value(uint8_t *p){
+ virtual uint8_t set_bss_init_value(uint8_t *p) {
return (0);
}
@@ -941,11 +941,6 @@ public:
return m_var_name;
}
- /**
- * what is the split range for this var
- *
- */
- //virtual uint64_t get_range() const = 0;
/**
* allows a var instruction to be updated
@@ -1010,7 +1005,7 @@ public:
}
- virtual uint8_t bss_init_value(uint8_t *p);
+ virtual uint8_t set_bss_init_value(uint8_t *p);
/**
@@ -1022,17 +1017,6 @@ public:
FLOW_VAR_OP_RANDOM
};
-
- /**
- * for BSS we take one previous value
- * because the VM will be executed before writing to pkt
- * so the init value is one step's advanced
- *
- */
- uint64_t get_bss_init_value() const {
- return peek_prev();
- }
-
StreamVmInstructionFlowMan(const std::string &var_name,
uint8_t size,
flow_var_op_e op,
@@ -1121,7 +1105,7 @@ private:
public:
/* flow var size */
- uint8_t m_size_bytes;
+ uint8_t m_size_bytes;
/* type of op */
flow_var_op_e m_op;
@@ -1148,22 +1132,16 @@ public:
return ( StreamVmInstruction::itFLOW_RAND_LIMIT);
}
- virtual bool is_valid_for_split() const {
- return (false);
- }
-
-
- virtual uint64_t get_splitable_range() const {
- return (1);
+ virtual bool need_split() const {
+ return true;
}
-
StreamVmInstructionFlowRandLimit(const std::string &var_name,
uint8_t size,
uint64_t limit,
uint64_t min_value,
uint64_t max_value,
- int seed
+ uint64_t seed
) : StreamVmInstructionVar(var_name) {
m_size_bytes = size;
@@ -1177,7 +1155,7 @@ public:
void sanity_check(uint32_t ins_id,StreamVm *lp);
- virtual uint8_t bss_init_value(uint8_t *p);
+ virtual uint8_t set_bss_init_value(uint8_t *p);
virtual StreamVmInstruction * clone() {
return new StreamVmInstructionFlowRandLimit(m_var_name,
@@ -1188,6 +1166,19 @@ public:
m_seed);
}
+ virtual void update(uint64_t phase, uint64_t step_mul) {
+
+ /* phase */
+ m_seed = m_seed * ( ( (phase + 1) * 514229 ) & 0xFFFFFFFF );
+
+ /* limit */
+ uint64_t per_core_limit = (m_limit / step_mul);
+ if (phase == 0) {
+ per_core_limit += (m_limit % step_mul);
+ }
+ m_limit = per_core_limit;
+ }
+
private:
void sanity_check_valid_size(uint32_t ins_id,StreamVm *lp);
@@ -1197,7 +1188,7 @@ public:
uint64_t m_min_value;
uint64_t m_max_value;
- int m_seed;
+ uint64_t m_seed;
uint8_t m_size_bytes;
};
@@ -1332,7 +1323,7 @@ public:
}
- virtual uint8_t bss_init_value(uint8_t *p);
+ virtual uint8_t set_bss_init_value(uint8_t *p);
bool is_unlimited_flows(){
@@ -1340,11 +1331,6 @@ public:
StreamVmInstructionFlowClient::CLIENT_F_UNLIMITED_FLOWS );
}
- void get_bss_init_value(uint32_t &ip, uint16_t &port) {
- /* fetch the previous values by 1 */
- peek_prev(ip, port, 1);
- }
-
virtual StreamVmInstruction * clone() {
return new StreamVmInstructionFlowClient(*this);
}