From d4828d6829137971c58a0e56b67a58154a8d6415 Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Sun, 25 Oct 2015 13:55:42 +0200 Subject: first version --- src/bp_sim.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index b7cfb20b..0b1f91ae 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -721,6 +721,7 @@ public: m_run_mode = RUN_MODE_INVALID; } + CPreviewMode preview; float m_factor; float m_duration; @@ -741,9 +742,10 @@ public: uint16_t m_run_flags; uint8_t m_mac_splitter; uint8_t m_pad; - trex_run_mode_e m_run_mode; + + std::string cfg_file; std::string mac_file; std::string platform_cfg_file; @@ -778,6 +780,10 @@ public: return ( m_latency_rate == 0 ?true:false); } + bool is_stateless(){ + return (m_run_mode == RUN_MODE_INTERACTIVE ?true:false); + } + bool is_latency_enabled(){ return ( !is_latency_disabled() ); } @@ -1187,6 +1193,9 @@ public: static CPlatformSocketInfo m_socket; }; +static inline int get_is_stateless(){ + return (CGlobalInfo::m_options.is_stateless() ); +} static inline int get_is_rx_check_mode(){ return (CGlobalInfo::m_options.preview.get_is_rx_check_enable() ?1:0); @@ -3331,7 +3340,9 @@ public : public: void Clean(); - void generate_erf(std::string erf_file_name,CPreviewMode &preview); + void start_generate_stateful(std::string erf_file_name,CPreviewMode &preview); + void start_stateless_daemon(); + void Dump(FILE *fd); void DumpCsv(FILE *fd); void DumpStats(FILE *fd); @@ -3421,7 +3432,11 @@ private: CNodeRing * m_ring_to_rx; /* ring dp -> latency thread */ flow_id_node_t m_flow_id_to_node_lookup; -}; + + +private: + uint8_t m_cacheline_pad[RTE_CACHE_LINE_SIZE][19]; // improve prefech +} __rte_cache_aligned ; inline CGenNode * CFlowGenListPerThread::create_node(void){ CGenNode * res; -- cgit From 44d266232d124bb277f6dec965a04dd93e47fb55 Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Sun, 25 Oct 2015 20:26:25 +0200 Subject: add stateless io object --- src/bp_sim.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index 0b1f91ae..328b6ba1 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -1652,6 +1652,8 @@ public: } __rte_cache_aligned ; + + /* run time verification of objects size and offsets need to clean this up and derive this objects from base object but require too much refactoring right now hhaim -- cgit From 587f97686900f757b173469a2b231ede6705c568 Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Mon, 26 Oct 2015 16:49:19 +0200 Subject: stateless dp works with static packet --- src/bp_sim.h | 188 ++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 148 insertions(+), 40 deletions(-) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index 328b6ba1..4dae7837 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -360,6 +360,16 @@ public: */ virtual int flush_tx_queue(void)=0; + + /** + * update the source and destination mac-addr of a given mbuf by global database + * + * @param dir + * @param m + * + * @return + */ + virtual int update_mac_addr_from_global_cfg(pkt_dir_t dir, rte_mbuf_t *m)=0; public: @@ -1342,15 +1352,17 @@ class CCapFileFlowInfo ; /* this is a simple struct, do not add constructor and destractor here! we are optimizing the allocation dealocation !!! */ -struct CGenNode { + +struct CGenNodeBase { public: enum { - FLOW_PKT=0, - FLOW_FIF=1, - FLOW_DEFER_PORT_RELEASE=2, - FLOW_PKT_NAT=3, - FLOW_SYNC=4 /* called evey 1 msec */ + FLOW_PKT =0, + FLOW_FIF =1, + FLOW_DEFER_PORT_RELEASE =2, + FLOW_PKT_NAT =3, + FLOW_SYNC =4, /* called evey 1 msec */ + STATELESS_PKT =5 }; @@ -1358,7 +1370,7 @@ public: enum { NODE_FLAGS_DIR =1, NODE_FLAGS_MBUF_CACHE =2, - NODE_FLAGS_SAMPLE_RX_CHECK =4, + NODE_FLAGS_SAMPLE_RX_CHECK =4, NODE_FLAGS_LEARN_MODE =8, /* bits 3,4 MASK 0x18 wait for second direction packet */ NODE_FLAGS_LEARN_MSG_PROCESSED =0x10, /* got NAT msg */ @@ -1369,19 +1381,49 @@ public: NODE_FLAGS_INIT_START_FROM_SERVER_SIDE_SERVER_ADDR = 0x100 /* init packet start from server side with server addr */ }; + public: - /* C1 */ + /*********************************************/ + /* C1 must */ uint8_t m_type; uint8_t m_thread_id; /* zero base */ uint8_t m_socket_id; - uint8_t m_pad2; + uint8_t m_pad2; uint16_t m_src_port; uint16_t m_flags; /* BIT 0 - DIR , BIT 1 - mbug_cache BIT 2 - SAMPLE DUPLICATE */ - double m_time; + double m_time; /* can't change this header - size 16 bytes*/ + +public: + bool operator <(const CGenNodeBase * rsh ) const { + return (m_timem_time); + } + bool operator ==(const CGenNodeBase * rsh ) const { + return (m_time==rsh->m_time); + } + bool operator >(const CGenNodeBase * rsh ) const { + return (m_time>rsh->m_time); + } + +public: + void set_socket_id(socket_id_t socket){ + m_socket_id=socket; + } + + socket_id_t get_socket_id(){ + return ( m_socket_id ); + } + + +}; + + +struct CGenNode : public CGenNodeBase { + +public: uint32_t m_src_ip; /* client ip */ uint32_t m_dest_ip; /* server ip */ @@ -1410,26 +1452,9 @@ public: uint32_t m_dest_idx; uint32_t m_end_of_cache_line[6]; -public: - bool operator <(const CGenNode * rsh ) const { - return (m_timem_time); - } - bool operator ==(const CGenNode * rsh ) const { - return (m_time==rsh->m_time); - } - bool operator >(const CGenNode * rsh ) const { - return (m_time>rsh->m_time); - } public: void Dump(FILE *fd); - void set_socket_id(socket_id_t socket){ - m_socket_id=socket; - } - - socket_id_t get_socket_id(){ - return ( m_socket_id ); - } static void DumpHeader(FILE *fd); @@ -1612,6 +1637,60 @@ public: } __rte_cache_aligned; +/* this is a event for stateless */ +struct CGenNodeStateless : public CGenNodeBase { +public: + + +private: + void * m_cache_mbuf; + + + uint64_t m_pad_end[13]; + + +public: + + void set_socket_id(socket_id_t socket){ + m_socket_id=socket; + } + + socket_id_t get_socket_id(){ + return ( m_socket_id ); + } + + inline void set_mbuf_cache_dir(pkt_dir_t dir){ + if (dir) { + m_flags |=NODE_FLAGS_DIR; + }else{ + m_flags &=~NODE_FLAGS_DIR; + } + } + + inline pkt_dir_t get_mbuf_cache_dir(){ + return ((pkt_dir_t)( m_flags &1)); + } + + + + inline void set_cache_mbuf(rte_mbuf_t * m){ + m_cache_mbuf=(void *)m; + m_flags |= NODE_FLAGS_MBUF_CACHE; + } + + inline rte_mbuf_t * get_cache_mbuf(){ + if ( m_flags &NODE_FLAGS_MBUF_CACHE ) { + return ((rte_mbuf_t *)m_cache_mbuf); + }else{ + return ((rte_mbuf_t *)0); + } + } + + +} __rte_cache_aligned; ; + + + #if __x86_64__ /* size of 64 bytes */ #define DEFER_CLIENTS_NUM (16) @@ -1658,19 +1737,30 @@ public: need to clean this up and derive this objects from base object but require too much refactoring right now hhaim */ + +#define COMPARE_NODE_OBJECT(NODE_NAME) if ( sizeof(NODE_NAME) != sizeof(CGenNode) ) { \ + printf("ERROR sizeof(%s) %lu != sizeof(CGenNode) %lu must be the same size \n",#NODE_NAME,sizeof(NODE_NAME),sizeof(CGenNode)); \ + assert(0); \ + }\ + if ( (int)offsetof(struct NODE_NAME,m_type)!=offsetof(struct CGenNodeBase,m_type) ){\ + printf("ERROR offsetof(struct %s,m_type)!=offsetof(struct CGenNodeBase,m_type) \n",#NODE_NAME);\ + assert(0);\ + }\ + if ( (int)offsetof(struct CGenNodeDeferPort,m_time)!=offsetof(struct CGenNodeBase,m_time) ){\ + printf("ERROR offsetof(struct %s,m_time)!=offsetof(struct CGenNodeBase,m_time) \n",#NODE_NAME);\ + assert(0);\ + } + +#define COMPARE_NODE_OBJECT_SIZE(NODE_NAME) if ( sizeof(NODE_NAME) != sizeof(CGenNode) ) { \ + printf("ERROR sizeof(%s) %lu != sizeof(CGenNode) %lu must be the same size \n",#NODE_NAME,sizeof(NODE_NAME),sizeof(CGenNode)); \ + assert(0); \ + } + + + inline int check_objects_sizes(void){ - if ( sizeof(CGenNodeDeferPort) != sizeof(CGenNode) ) { - printf("ERROR sizeof(CGenNodeDeferPort) %lu != sizeof(CGenNode) %lu must be the same size \n",sizeof(CGenNodeDeferPort),sizeof(CGenNode)); - assert(0); - } - if ( (int)offsetof(struct CGenNodeDeferPort,m_type)!=offsetof(struct CGenNode,m_type) ){ - printf("ERROR offsetof(struct CGenNodeDeferPort,m_type)!=offsetof(struct CGenNode,m_type) \n"); - assert(0); - } - if ( (int)offsetof(struct CGenNodeDeferPort,m_time)!=offsetof(struct CGenNode,m_time) ){ - printf("ERROR offsetof(struct CGenNodeDeferPort,m_time)!=offsetof(struct CGenNode,m_time) \n"); - assert(0); - } + COMPARE_NODE_OBJECT(CGenNodeDeferPort); + COMPARE_NODE_OBJECT_SIZE(CGenNodeStateless); return (0); } @@ -1729,6 +1819,11 @@ public: virtual int write_pkt(CCapPktRaw *pkt_raw); virtual int close_file(void); + virtual int update_mac_addr_from_global_cfg(pkt_dir_t dir, rte_mbuf_t *m){ + return (0); + } + + /** * send one packet @@ -1790,6 +1885,10 @@ public: return (0); } + virtual int update_mac_addr_from_global_cfg(pkt_dir_t dir, rte_mbuf_t *m){ + return (0); + } + virtual int send_node(CGenNode * node); @@ -1841,7 +1940,9 @@ public: private: - int flush_one_node_to_file(CGenNode * node); + inline int flush_one_node_to_file(CGenNode * node){ + return (m_v_if->send_node(node)); + } int update_stats(CGenNode * node); FORCE_NO_INLINE void handle_slow_messages(uint8_t type, CGenNode * node, @@ -3336,6 +3437,11 @@ public : inline CGenNode * create_node(void); + inline CGenNodeStateless * create_node_sl(void){ + return ((CGenNodeStateless*)create_node() ); + } + + inline void free_node(CGenNode *p); inline void free_last_flow_node(CGenNode *p); @@ -3344,6 +3450,8 @@ public: void Clean(); void start_generate_stateful(std::string erf_file_name,CPreviewMode &preview); void start_stateless_daemon(); + void start_stateless_const_rate_demo(); + void Dump(FILE *fd); void DumpCsv(FILE *fd); -- cgit From b77fef12a08d6d964e522eea6b2d846dfcc98b08 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 26 Oct 2015 18:13:18 +0200 Subject: RPC control plane now integarted with DPDK --- src/bp_sim.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index 0b1f91ae..8f5fe02f 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -1187,10 +1187,10 @@ public: public: static CRteMemPool m_mem_pool[MAX_SOCKETS_SUPPORTED]; - static uint32_t m_nodes_pool_size; - static CParserOption m_options; - static CGlobalMemory m_memory_cfg; - static CPlatformSocketInfo m_socket; + static uint32_t m_nodes_pool_size; + static CParserOption m_options; + static CGlobalMemory m_memory_cfg; + static CPlatformSocketInfo m_socket; }; static inline int get_is_stateless(){ -- cgit From ea0b6efc3a41f425e46d81f4b6b8bbbf3238add1 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 27 Oct 2015 19:25:03 +0200 Subject: working cont. stream on 1 core --- src/bp_sim.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index 2cdfccb2..5747c2da 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -57,6 +57,8 @@ limitations under the License. #include #include "platform_cfg.h" +#include + #undef NAT_TRACE_ @@ -1641,6 +1643,9 @@ public: struct CGenNodeStateless : public CGenNodeBase { public: + inline uint8_t *get_opaque_storage() { + return (uint8_t *)&m_pad_end; + } private: void * m_cache_mbuf; @@ -3450,7 +3455,6 @@ public: void Clean(); void start_generate_stateful(std::string erf_file_name,CPreviewMode &preview); void start_stateless_daemon(); - void start_stateless_const_rate_demo(); void Dump(FILE *fd); @@ -3465,6 +3469,7 @@ public: private: void check_msgs(void); + void handel_nat_msg(CGenNodeNatInfo * msg); void handel_latecy_pkt_msg(CGenNodeLatencyPktInfo * msg); @@ -3543,6 +3548,7 @@ private: flow_id_node_t m_flow_id_to_node_lookup; + TrexStatelessDpCore *m_stateless_dp_info; private: uint8_t m_cacheline_pad[RTE_CACHE_LINE_SIZE][19]; // improve prefech -- cgit From 9a820782c35c6de79d2e724a48087e8ee62fc72d Mon Sep 17 00:00:00 2001 From: imarom Date: Thu, 29 Oct 2015 18:15:17 +0200 Subject: Hanoch's review comments #1 : fixed performancei issue with the stateless node --- src/bp_sim.h | 57 --------------------------------------------------------- 1 file changed, 57 deletions(-) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index 5747c2da..a11011ce 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -1639,62 +1639,6 @@ public: } __rte_cache_aligned; -/* this is a event for stateless */ -struct CGenNodeStateless : public CGenNodeBase { -public: - - inline uint8_t *get_opaque_storage() { - return (uint8_t *)&m_pad_end; - } - -private: - void * m_cache_mbuf; - - - uint64_t m_pad_end[13]; - - -public: - - void set_socket_id(socket_id_t socket){ - m_socket_id=socket; - } - - socket_id_t get_socket_id(){ - return ( m_socket_id ); - } - - inline void set_mbuf_cache_dir(pkt_dir_t dir){ - if (dir) { - m_flags |=NODE_FLAGS_DIR; - }else{ - m_flags &=~NODE_FLAGS_DIR; - } - } - - inline pkt_dir_t get_mbuf_cache_dir(){ - return ((pkt_dir_t)( m_flags &1)); - } - - - - inline void set_cache_mbuf(rte_mbuf_t * m){ - m_cache_mbuf=(void *)m; - m_flags |= NODE_FLAGS_MBUF_CACHE; - } - - inline rte_mbuf_t * get_cache_mbuf(){ - if ( m_flags &NODE_FLAGS_MBUF_CACHE ) { - return ((rte_mbuf_t *)m_cache_mbuf); - }else{ - return ((rte_mbuf_t *)0); - } - } - - -} __rte_cache_aligned; ; - - #if __x86_64__ /* size of 64 bytes */ @@ -1765,7 +1709,6 @@ public: inline int check_objects_sizes(void){ COMPARE_NODE_OBJECT(CGenNodeDeferPort); - COMPARE_NODE_OBJECT_SIZE(CGenNodeStateless); return (0); } -- cgit From ee2c7f45e0bf973443b70eb8329811bcad44f83a Mon Sep 17 00:00:00 2001 From: imarom Date: Sun, 1 Nov 2015 14:28:28 +0200 Subject: stateless cores starts on IDLE - and starts the scheduler only when traffic is being transmitted if the traffic stops completely on the core - back to IDLE state --- src/bp_sim.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index a11011ce..af084757 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -1364,7 +1364,8 @@ public: FLOW_DEFER_PORT_RELEASE =2, FLOW_PKT_NAT =3, FLOW_SYNC =4, /* called evey 1 msec */ - STATELESS_PKT =5 + STATELESS_PKT =5, + EXIT_SCHED =6 }; @@ -1680,8 +1681,6 @@ public: } __rte_cache_aligned ; - - /* run time verification of objects size and offsets need to clean this up and derive this objects from base object but require too much refactoring right now hhaim @@ -1857,6 +1856,7 @@ public: CFlowGenListPerThread * Parent(){ return (m_parent); } + public: void add_node(CGenNode * mynode); void remove_all(CFlowGenListPerThread * thread); -- cgit From c0a49eef86df00d9497fa5701d5b9d4cbf4bacc2 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 3 Nov 2015 16:29:07 +0200 Subject: now support multiple interfaces / ports --- src/bp_sim.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index af084757..75958776 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -372,6 +372,15 @@ public: * @return */ virtual int update_mac_addr_from_global_cfg(pkt_dir_t dir, rte_mbuf_t *m)=0; + + /** + * translate a port_id to the correct dir on the core + * + */ + virtual pkt_dir_t port_id_to_dir(uint8_t port_id) { + return (CS_INVALID); + } + public: -- cgit From bc7d9ee81604fd33607569ac4f03ca8b91777b29 Mon Sep 17 00:00:00 2001 From: imarom Date: Sun, 8 Nov 2015 11:39:09 +0200 Subject: code review notes: 1. performance improvement for stateless DP core object (direct object) 2. exit scheduler loop is now using a scheduled message and not IF 3. duration for inifinite is negative number 4. fixed stop_traffic scheduled node time --- src/bp_sim.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index 75958776..c201cd20 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -1901,9 +1901,10 @@ private: return (m_v_if->send_node(node)); } int update_stats(CGenNode * node); - FORCE_NO_INLINE void handle_slow_messages(uint8_t type, - CGenNode * node, - CFlowGenListPerThread * thread, + + FORCE_NO_INLINE bool handle_slow_messages(uint8_t type, + CGenNode * node, + CFlowGenListPerThread * thread, bool always); @@ -3500,7 +3501,7 @@ private: flow_id_node_t m_flow_id_to_node_lookup; - TrexStatelessDpCore *m_stateless_dp_info; + TrexStatelessDpCore m_stateless_dp_info; private: uint8_t m_cacheline_pad[RTE_CACHE_LINE_SIZE][19]; // improve prefech -- cgit From 38dc2db83370ee9d2483a09f4451a5c0f1167cee Mon Sep 17 00:00:00 2001 From: imarom Date: Sun, 8 Nov 2015 15:08:07 +0200 Subject: fixed all warnings now compiles with -Wall -Werror --- src/bp_sim.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/bp_sim.h') diff --git a/src/bp_sim.h b/src/bp_sim.h index c201cd20..36595581 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -894,6 +894,8 @@ public: /* number of main active sockets. socket #0 is always used */ virtual socket_id_t max_num_active_sockets()=0; + virtual ~CPlatformSocketInfoBase() {} + public: /* which socket to allocate memory to each port */ virtual socket_id_t port_to_socket(port_id_t port)=0; @@ -1337,8 +1339,8 @@ public: -#define DP(f) if (f) printf(" %-40s: %llu \n",#f,f) -#define DP_name(n,f) if (f) printf(" %-40s: %llu \n",n,f) +#define DP(f) if (f) printf(" %-40s: %llu \n",#f,(unsigned long long)f) +#define DP_name(n,f) if (f) printf(" %-40s: %llu \n",n,(unsigned long long)f) #define DP_S(f,f_s) if (f) printf(" %-40s: %s \n",#f,f_s.c_str()) @@ -2380,6 +2382,7 @@ public: return (uint32_t)((uintptr_t)( ((char *)l3.m_ipv4)-getBasePtr()) ); }else{ BP_ASSERT(0); + return (0); } } -- cgit