pcap_t * orig;
uint16_t portid; // portid of DPDK
int must_clear_promisc;
- uint64_t rx_pkts;
uint64_t bpf_drop;
int nonblock;
+ struct timeval required_select_timeout;
struct timeval prev_ts;
struct rte_eth_stats prev_stats;
struct timeval curr_ts;
if (p->break_loop){
break;
}
- // sleep for a very short while, but do not block CPU.
+ // sleep for a very short while.
+ // block sleep is the only choice, since usleep() will impact performance dramatically.
rte_delay_us_block(DPDK_DEF_MIN_SLEEP_MS*1000);
sleep_ms += DPDK_DEF_MIN_SLEEP_MS;
}
u_char *large_buffer=NULL;
int timeout_ms = p->opt.timeout;
- pd->rx_pkts = 0;
if ( !PACKET_COUNT_IS_UNLIMITED(max_cnt) && max_cnt < MAX_PKT_BURST){
burst_cnt = max_cnt;
}else{
while( PACKET_COUNT_IS_UNLIMITED(max_cnt) || pkt_cnt < max_cnt){
if (p->break_loop){
- p->break_loop = 1;
+ p->break_loop = 0;
return PCAP_ERROR_BREAK;
}
// read once in non-blocking mode, or try many times waiting for timeout_ms.
}else{
if (p->break_loop){
RTE_LOG(DEBUG, USER1, "dpdk: no packets available and break_loop is setted in blocking mode.\n");
- p->break_loop = 1;
+ p->break_loop = 0;
return PCAP_ERROR_BREAK;
}
}
}
}
- pd->rx_pkts = pkt_cnt;
- return pd->rx_pkts;
+ return pkt_cnt;
}
static int pcap_dpdk_inject(pcap_t *p, const void *buf _U_, int size _U_)
p->stats_op = pcap_dpdk_stats;
p->cleanup_op = pcap_dpdk_close;
p->breakloop_op = pcap_breakloop_common;
+ // set default timeout
+ pd->required_select_timeout.tv_sec = 0;
+ pd->required_select_timeout.tv_usec = DPDK_DEF_MIN_SLEEP_MS*1000;
+ p->required_select_timeout = &pd->required_select_timeout;
ret = 0; // OK
}while(0);