summaryrefslogtreecommitdiffstats
path: root/src/bp_sim.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/bp_sim.h')
-rwxr-xr-xsrc/bp_sim.h113
1 files changed, 70 insertions, 43 deletions
diff --git a/src/bp_sim.h b/src/bp_sim.h
index 9cdfd30a..282e7fe4 100755
--- a/src/bp_sim.h
+++ b/src/bp_sim.h
@@ -370,6 +370,13 @@ public:
#define CONST_9k_MBUF_SIZE (MAX_PKT_ALIGN_BUF_9K + MBUF_PKT_PREFIX)
+#define TW_BUCKETS (CGlobalInfo::m_options.get_tw_buckets())
+#define TW_BUCKETS_LEVEL1_DIV (16)
+#define TW_LEVELS (CGlobalInfo::m_options.get_tw_levels())
+#define BUCKET_TIME_SEC (CGlobalInfo::m_options.get_tw_bucket_time_in_sec())
+#define BUCKET_TIME_SEC_LEVEL1 (CGlobalInfo::m_options.get_tw_bucket_level1_time_in_sec())
+
+
class CPreviewMode {
public:
CPreviewMode(){
@@ -642,9 +649,12 @@ typedef struct mac_align_t_ {
struct CMacAddrCfg {
public:
- CMacAddrCfg (){
- memset(u.m_data,0,sizeof(u.m_data));
- u.m_mac.dest[3]=1;
+ CMacAddrCfg () {
+ reset();
+ }
+ void reset () {
+ memset(u.m_data, 0, sizeof(u.m_data));
+ u.m_mac.dest[3] = 1;
u.m_mac.is_set = 0;
}
union {
@@ -701,36 +711,49 @@ public:
};
public:
- CParserOption(){
- m_factor=1.0;
- m_mbuf_factor=1.0;
- m_duration=0.0;
- m_latency_rate =0;
- m_latency_mask =0xffffffff;
- m_latency_prev=0;
- m_wait_before_traffic=1;
- m_zmq_port=4500;
- m_telnet_port =4501;
- m_platform_factor=1.0;
- m_expected_portd = 4; /* should be at least the number of ports found in the system but could be less */
- m_vlan_port[0]=100;
- m_vlan_port[1]=100;
- m_rx_check_sample=0;
+
+ void reset() {
+ preview.clean();
+ m_tw_buckets = 1024;
+ m_tw_levels = 3;
+ m_active_flows = 0;
+ m_factor = 1.0;
+ m_mbuf_factor = 1.0;
+ m_duration = 0.0;
+ m_platform_factor = 1.0;
+ m_vlan_port[0] = 100;
+ m_vlan_port[1] = 100;
+ memset(m_src_ipv6, 0, sizeof(m_src_ipv6));
+ memset(m_dst_ipv6, 0, sizeof(m_dst_ipv6));
+ memset(m_ip_cfg, 0, sizeof(m_ip_cfg));
+ m_latency_rate = 0;
+ m_latency_mask = 0xffffffff;
+ m_latency_prev = 0;
+ m_rx_check_sample = 0;
m_rx_check_hops = 0;
- m_io_mode=1;
- m_run_flags=0;
- prefix="";
- m_run_mode = RUN_MODE_INVALID;
+ m_wait_before_traffic = 1;
+ m_zmq_port = 4500;
+ m_telnet_port = 4501;
+ m_expected_portd = 4; /* should be at least the number of ports found in the system but could be less */
+ m_io_mode = 1;
+ m_run_flags = 0;
m_l_pkt_mode = 0;
- m_rx_thread_enabled = false;
+ m_learn_mode = 0;
+ m_debug_pkt_proto = 0;
m_arp_ref_per = 120; // in seconds
- m_tw_buckets = 1024;
- m_tw_levels = 3;
- m_tw_bucket_time_sec = (20.0/1000000.0);
- m_active_flows=0;
-
+ m_rx_thread_enabled = false;
+ m_run_mode = RUN_MODE_INVALID;
+ cfg_file = "";
+ client_cfg_file = "";
+ platform_cfg_file = "";
+ out_file = "";
+ prefix = "";
+ set_tw_bucket_time_in_usec(20.0);
}
+ CParserOption(){
+ reset();
+ }
CPreviewMode preview;
uint16_t m_tw_buckets;
@@ -761,22 +784,17 @@ public:
uint16_t m_arp_ref_per;
bool m_rx_thread_enabled;
trex_run_mode_e m_run_mode;
-
-
-
std::string cfg_file;
std::string client_cfg_file;
std::string platform_cfg_file;
-
std::string out_file;
std::string prefix;
std::vector<std::string> dump_interfaces;
-
-
CMacAddrCfg m_mac_addr[TREX_MAX_PORTS];
double m_tw_bucket_time_sec;
-
+ double m_tw_bucket_time_sec_level1;
+public:
uint8_t * get_src_mac_addr(int if_index){
return (m_mac_addr[if_index].u.m_mac.src);
}
@@ -784,7 +802,6 @@ public:
return (m_mac_addr[if_index].u.m_mac.dest);
}
-public:
uint32_t get_expected_ports(){
return (m_expected_portd);
}
@@ -819,8 +836,13 @@ public:
return (m_tw_bucket_time_sec);
}
+ inline double get_tw_bucket_level1_time_in_sec(void){
+ return (m_tw_bucket_time_sec_level1);
+ }
+
void set_tw_bucket_time_in_usec(double usec){
- m_tw_bucket_time_sec=(usec/1000000.0);
+ m_tw_bucket_time_sec= (usec/1000000.0);
+ m_tw_bucket_time_sec_level1 = (m_tw_bucket_time_sec*(double)m_tw_buckets)/((double)TW_BUCKETS_LEVEL1_DIV);
}
void set_tw_buckets(uint16_t buckets){
@@ -1469,7 +1491,9 @@ public:
EXIT_PORT_SCHED =8,
PCAP_PKT =9,
GRAT_ARP =10,
- TW_SYNC =11
+ TW_SYNC =11,
+ TW_SYNC1 =12,
+
};
/* flags MASKS*/
@@ -2215,6 +2239,8 @@ private:
void handle_flow_sync(CGenNode *node, CFlowGenListPerThread *thread, bool &exit_scheduler);
void handle_pcap_pkt(CGenNode *node, CFlowGenListPerThread *thread);
void handle_maintenance(CFlowGenListPerThread *thread);
+ void handle_batch_tw_level1(CGenNode *node, CFlowGenListPerThread *thread,bool &exit_scheduler,bool on_terminate);
+
public:
pqueue_t m_p_queue;
@@ -2226,8 +2252,10 @@ public:
uint64_t m_non_active;
uint64_t m_limit;
CTimeHistogram m_realtime_his;
+ dsec_t m_scheduler_offset;
dsec_t m_last_sync_time_sec;
+ dsec_t m_tw_level1_next_sec;
};
@@ -3798,9 +3826,6 @@ private:
bool server_seq_init; /* TCP seq been init for server? */
};
-#define TW_BUCKETS (CGlobalInfo::m_options.get_tw_buckets())
-#define TW_LEVELS (CGlobalInfo::m_options.get_tw_levels())
-#define BUCKET_TIME_SEC (CGlobalInfo::m_options.get_tw_bucket_time_in_sec())
@@ -3957,6 +3982,8 @@ public:
private:
+ FORCE_NO_INLINE void no_memory_error();
+
bool check_msgs_from_rx();
void handle_nat_msg(CGenNodeNatInfo * msg);
@@ -4016,7 +4043,7 @@ public:
public:
CNodeGenerator m_node_gen;
- CHTimerWheel m_tw;
+ CNATimerWheel m_tw;
public:
uint32_t m_cur_template;
@@ -4051,7 +4078,7 @@ private:
inline CGenNode * CFlowGenListPerThread::create_node(void){
CGenNode * res;
if ( unlikely (rte_mempool_sc_get(m_node_pool, (void **)&res) <0) ){
- rte_exit(EXIT_FAILURE, "cant allocate object , need more \n");
+ no_memory_error();
return (0);
}
return (res);