diff options
Diffstat (limited to 'src/stateless/dp/trex_stream_node.h')
-rw-r--r-- | src/stateless/dp/trex_stream_node.h | 83 |
1 files changed, 72 insertions, 11 deletions
diff --git a/src/stateless/dp/trex_stream_node.h b/src/stateless/dp/trex_stream_node.h index 70054bbc..b5395e78 100644 --- a/src/stateless/dp/trex_stream_node.h +++ b/src/stateless/dp/trex_stream_node.h @@ -51,6 +51,15 @@ public: static_assert(sizeof(CGenNodeCommand) == sizeof(CGenNode), "sizeof(CGenNodeCommand) != sizeof(CGenNode)" ); +struct CGenNodeCacheMbuf { + rte_mbuf_t * m_mbuf_const; + rte_mbuf_t * m_array[0]; +public: + static uint32_t get_object_size(uint32_t size){ + return ( sizeof(CGenNodeCacheMbuf) + sizeof(rte_mbuf_t *) * size ); + } +}; + /* this is a event for stateless */ struct CGenNodeStateless : public CGenNodeBase { friend class TrexStatelessDpCore; @@ -63,10 +72,10 @@ public: SL_NODE_FLAGS_MBUF_CACHE =2, //USED by master SL_NODE_CONST_MBUF =4, - - SL_NODE_VAR_PKT_SIZE =8, - SL_NODE_STATS_NEEDED = 0x10 - + + SL_NODE_VAR_PKT_SIZE = 8, + SL_NODE_STATS_NEEDED = 0x10, + SL_NODE_CONST_MBUF_CACHE_ARRAY = 0x20 /* array of mbuf - cache */ }; enum { @@ -79,15 +88,18 @@ public: static std::string get_stream_state_str(stream_state_t stream_state); private: - /* cache line 0 */ - /* important stuff here */ - void * m_cache_mbuf; + /******************************/ + /* cache line 0 */ + /* important stuff here R/W */ + /******************************/ + void * m_cache_mbuf; /* could be an array or a one mbuf */ double m_next_time_offset; /* in sec */ uint16_t m_action_counter; uint8_t m_stat_hw_id; // hw id used to count rx and tx stats uint8_t m_null_stream; - uint32_t m_pad12; + uint16_t m_cache_array_cnt; + uint16_t m_pad12; stream_state_t m_state; uint8_t m_port_id; @@ -99,7 +111,10 @@ private: uint32_t m_multi_bursts; /* in case of multi_burst how many bursts */ - /* cache line 1 */ + /******************************/ + /* cache line 1 + this cache line should be READONLY ! you can write only at init time */ + /******************************/ TrexStream * m_ref_stream_info; /* the stream info */ CGenNodeStateless * m_next_stream; @@ -109,8 +124,11 @@ private: uint8_t * m_vm_flow_var; /* pointer to the vm flow var */ uint8_t * m_vm_program; /* pointer to the program */ uint16_t m_vm_program_size; /* up to 64K op codes */ - uint16_t m_pad2; - uint32_t m_pad3; + uint16_t m_cache_size; /*RO*/ /* the size of the mbuf array */ + uint8_t m_batch_size; /*RO*/ /* the batch size */ + + uint8_t m_pad4; + uint16_t m_pad5; /* End Fast Field VM Section */ @@ -120,6 +138,8 @@ private: public: + + void set_random_seed(uint32_t seed){ uint32_t *p=get_random_bss_seed_memory(); *p=seed; @@ -343,6 +363,10 @@ public: } } + void clear_const_mbuf(){ + m_flags= ( m_flags & ~SL_NODE_CONST_MBUF ); + } + /* prefix header exits only in non cache mode size is 64/128/512 other are not possible right now */ inline void alloc_prefix_header(uint16_t size){ set_prefix_header_size(size); @@ -353,6 +377,7 @@ public: inline void free_prefix_header(){ if (m_original_packet_data_prefix) { free(m_original_packet_data_prefix); + m_original_packet_data_prefix=0; } } @@ -370,6 +395,42 @@ public: void free_stl_node(); +protected: + + void free_stl_vm_buf(); + +public: + void cache_mbuf_array_init(); + + inline bool is_cache_mbuf_array(){ + return ( m_flags & SL_NODE_CONST_MBUF_CACHE_ARRAY ? true:false ); + } + + void cache_mbuf_array_copy(CGenNodeCacheMbuf *obj,uint16_t size); + + rte_mbuf_t ** cache_mbuf_array_alloc(uint16_t size); + + void cache_mbuf_array_free(); + + void cache_mbuf_array_set(uint16_t index,rte_mbuf_t * m); + + void cache_mbuf_array_set_const_mbuf(rte_mbuf_t * m); + + rte_mbuf_t * cache_mbuf_array_get_const_mbuf(); + + rte_mbuf_t * cache_mbuf_array_get(uint16_t index); + + rte_mbuf_t * cache_mbuf_array_get_cur(void){ + CGenNodeCacheMbuf *p =(CGenNodeCacheMbuf *) m_cache_mbuf; + rte_mbuf_t * m=p->m_array[m_cache_array_cnt]; + assert(m); + m_cache_array_cnt++; + if (m_cache_array_cnt == m_cache_size) { + m_cache_array_cnt=0; + } + return m; + } + public: /* debug functions */ |