diff options
author | 2016-11-16 17:40:01 +0200 | |
---|---|---|
committer | 2016-11-16 17:40:01 +0200 | |
commit | 11c216470c30e4c200e46e1b51d721a549f440d6 (patch) | |
tree | 03ad20c67decf7da4d52e5679c2fd22dd8f5eaa6 /src/bp_sim.h | |
parent | e46e3f598e52112b9db21d6faabde7a5c87341cb (diff) | |
parent | efba1bd2c32391c443a9dbaf0fffa6468bb681c6 (diff) |
Merge branch 'master' to rx_features phase 0.5
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src/bp_sim.h')
-rwxr-xr-x | src/bp_sim.h | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/bp_sim.h b/src/bp_sim.h index cd0f6a13..0cf77437 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -80,6 +80,7 @@ typedef struct { /* reserve both 0xFF and 0xFE , router will -1 FF */ #define TTL_RESERVE_DUPLICATE 0xff +#define TOS_TTL_RESERVE_DUPLICATE 0x1 /* * Length of string needed to hold the largest port (16-bit) address @@ -824,6 +825,11 @@ public: return ( (m_expected_portd>>1) * preview.getCores()); } bool is_stateless(){ + if (m_run_mode == RUN_MODE_INVALID) { + fprintf(stderr, "Internal bug: Calling is stateless before initializing run mode\n"); + fprintf(stderr, "Try to put -i or -f <file> option as first in the option list\n"); + exit(-1); + } return (m_run_mode == RUN_MODE_INTERACTIVE ?true:false); } bool is_latency_enabled() { @@ -1199,12 +1205,13 @@ public: /* for simulation */ static void free_pools(); - static inline rte_mbuf_t * pktmbuf_alloc_small(socket_id_t socket){ return ( m_mem_pool[socket].pktmbuf_alloc_small() ); } - + static inline rte_mbuf_t * pktmbuf_alloc_small_by_port(uint8_t port_id) { + return ( m_mem_pool[m_socket.port_to_socket(port_id)].pktmbuf_alloc_small() ); + } /** * try to allocate small buffers too @@ -1222,6 +1229,13 @@ public: return (m_mem_pool[socket].pktmbuf_alloc(size)); } + static inline rte_mbuf_t * pktmbuf_alloc_by_port(uint8_t port_id, uint16_t size){ + socket_id_t socket = m_socket.port_to_socket(port_id); + if (size<FIRST_PKT_SIZE) { + return ( pktmbuf_alloc_small(socket)); + } + return (m_mem_pool[socket].pktmbuf_alloc(size)); + } static inline bool is_learn_verify_mode(){ return ( (m_options.m_learn_mode != CParserOption::LEARN_MODE_DISABLED) && m_options.preview.get_learn_and_verify_mode_enable()); @@ -2682,6 +2696,26 @@ public: return (0); } } + + + void setTOSReserve(){ + BP_ASSERT(l3.m_ipv4); + if (is_ipv6()) { + l3.m_ipv6->setTrafficClass(l3.m_ipv6->getTrafficClass() | TOS_TTL_RESERVE_DUPLICATE ); + }else{ + l3.m_ipv4->setTOS(l3.m_ipv4->getTOS()| TOS_TTL_RESERVE_DUPLICATE ); + } + } + + void clearTOSReserve(){ + BP_ASSERT(l3.m_ipv4); + if (is_ipv6()) { + l3.m_ipv6->setTrafficClass(l3.m_ipv6->getTrafficClass()& (~TOS_TTL_RESERVE_DUPLICATE) ); + }else{ + l3.m_ipv4->setTOS(l3.m_ipv4->getTOS() & (~TOS_TTL_RESERVE_DUPLICATE) ); + } + } + uint8_t getTTL(){ BP_ASSERT(l3.m_ipv4); if (is_ipv6()) { @@ -3054,6 +3088,8 @@ inline void CFlowPktInfo::update_pkt_info(char *p, printf(" %.3f : DP : learn packet !\n",now_sec()); #endif ipv4->setTimeToLive(TTL_RESERVE_DUPLICATE); + ipv4->setTOS(ipv4->getTOS()|TOS_TTL_RESERVE_DUPLICATE); + /* first ipv4 option add the info in case of learn packet, usualy only the first packet */ if (CGlobalInfo::is_learn_mode(CParserOption::LEARN_MODE_IP_OPTION)) { |