Lines Matching +full:reset +full:- +full:bps

31 1. Pcap-dpdk provides libpcap the ability to use DPDK with the device name as dpdk:{portid}, such as dpdk:0.
33 3. The testprogs/capturetest provides 6.4Gbps/800,000 pps on Intel 10-Gigabit X540-AT2 with DPDK 18.11.
36 1. DPDK support will be on if DPDK is available. Please set DIR for --with-dpdk[=DIR] with ./configure or -DDPDK_DIR[=DIR] with cmake if DPDK is installed manually.
46 sed -i 's/CONFIG_RTE_BUILD_SHARED_LIB=n/CONFIG_RTE_BUILD_SHARED_LIB=y/' $RTE_SDK/$RTE_TARGET/.config
50 You shall learn how to bind nic with DPDK-compatible driver by $RTE_SDK/usertools/dpdk-devbind.py, such as igb_uio.
51 And enable hugepages by dpdk-setup.sh
54 $RTE_SDK/examples/l2fwd/$RTE_TARGET/l2fwd -dlibrte_pmd_e1000.so -dlibrte_pmd_ixgbe.so -dlibrte_mempool_ring.so -- -p 0x1
58 If DPDK has not been found automatically, you shall export DPDK environment variable which are used for compiling DPDK. And then pass $RTE_SDK/$RTE_TARGET to --with-dpdk or -DDPDK_DIR
65 ./configure --with-dpdk=$RTE_SDK/$RTE_TARGET && make -s all && make -s testprogs && make install
69 mkdir -p build && cd build && cmake -DDPDK_DIR=$RTE_SDK/$RTE_TARGET ../ && make -s all && make -s testprogs && make install
75 env DPDK_CFG="--log-level=debug -l0 -dlibrte_pmd_e1000.so -dlibrte_pmd_ixgbe.so -dlibrte_mempool_ring.so" ./capturetest -i dpdk:0
114 #include "pcap-int.h"
115 #include "pcap-dpdk.h"
148 #define DPDK_DEF_CFG "--log-level=error -l0 -dlibrte_pmd_e1000.so -dlibrte_pmd_ixgbe.so -dlibrte_mempool_ring.so"
189 uint64_t bps;
232 /* No - just give them what we've produced. */
236 errbuflen_remaining = errbuflen - msglen;
241 errbuflen_remaining -= 2;
245 * rte_strerror() is thread-safe, at least as of dpdk 18.11,
246 * unlike strerror() - it uses strerror_r() rather than strerror()
247 * for UN*X errno values, and prints to what I assume is a per-thread
255 gettimeofday(&(pd->ts_helper.start_time),NULL);
256 pd->ts_helper.start_cycles = rte_get_timer_cycles();
257 pd->ts_helper.hz = rte_get_timer_hz();
258 if (pd->ts_helper.hz == 0){
259 return -1;
268 cycles = rte_get_timer_cycles() - helper->start_cycles;
269 cur_time.tv_sec = (time_t)(cycles/helper->hz);
270 cur_time.tv_usec = (suseconds_t)((cycles%helper->hz)*1e6/helper->hz);
271 timeradd(&(helper->start_time), &cur_time, ts);
277 while (mbuf && (total_len+mbuf->data_len) < len ){
278 rte_memcpy(data+total_len, rte_pktmbuf_mtod(mbuf,void *),mbuf->data_len);
279 total_len+=mbuf->data_len;
280 mbuf=mbuf->next;
287 struct pcap_dpdk *pd = (struct pcap_dpdk*)(p->priv);
289 int timeout_ms = p->opt.timeout;
291 if (pd->nonblock){
292 // In non-blocking mode, just read once, no matter how many packets are captured.
293 nb_rx = (int)rte_eth_rx_burst(pd->portid, 0, pkts_burst, burst_cnt);
298 nb_rx = (int)rte_eth_rx_burst(pd->portid, 0, pkts_burst, burst_cnt);
302 if (p->break_loop){
317 struct pcap_dpdk *pd = (struct pcap_dpdk*)(p->priv);
331 int timeout_ms = p->opt.timeout;
339 * return a too-low count.
355 if (p->break_loop){
356 p->break_loop = 0;
359 // read once in non-blocking mode, or try many times waiting for timeout_ms.
363 if (pd->nonblock){
364 RTE_LOG(DEBUG, USER1, "dpdk: no packets available in non-blocking mode.\n");
366 if (p->break_loop){
368 p->break_loop = 0;
374 // break if dpdk reads 0 packet, no matter in blocking(timeout) or non-blocking mode.
380 calculate_timestamp(&(pd->ts_helper),&(pcap_header.ts));
382 // caplen = min(pkt_len, p->snapshot);
384 caplen = pkt_len < (uint32_t)p->snapshot ? pkt_len: (uint32_t)p->snapshot;
390 if (m->nb_segs == 1)
397 gather_len = dpdk_gather_data(pd->pcap_tmp_buf, RTE_ETH_PCAP_SNAPLEN, m);
398 bp = pd->pcap_tmp_buf;
408 if (p->fcode.bf_insns==NULL || pcapint_filter(p->fcode.bf_insns, bp, pcap_header.len, pcap_header.caplen)){
411 pd->bpf_drop++;
428 pcapint_strlcpy(p->errbuf,
436 struct pcap_dpdk *pd = p->priv;
441 if (pd->must_clear_promisc)
443 rte_eth_promiscuous_disable(pd->portid);
445 rte_eth_dev_stop(pd->portid);
446 rte_eth_dev_close(pd->portid);
452 uint16_t portid = pd->portid;
455 RTE_LOG(INFO,USER1, "portid:%d, RX-packets: %-10"PRIu64" RX-errors: %-10"PRIu64
456 " RX-bytes: %-10"PRIu64" RX-Imissed: %-10"PRIu64"\n", portid, stats.ipackets, stats.ierrors,
458 RTE_LOG(INFO,USER1, "portid:%d, RX-PPS: %-10"PRIu64" RX-Mbps: %.2lf\n", portid, pd->pps, pd->bps/1e6f );
463 struct pcap_dpdk *pd = p->priv;
464 calculate_timestamp(&(pd->ts_helper), &(pd->curr_ts));
465 rte_eth_stats_get(pd->portid,&(pd->curr_stats));
467 ps->ps_recv = pd->curr_stats.ipackets;
468 ps->ps_drop = pd->curr_stats.ierrors;
469 ps->ps_drop += pd->bpf_drop;
470 ps->ps_ifdrop = pd->curr_stats.imissed;
472 uint64_t delta_pkt = pd->curr_stats.ipackets - pd->prev_stats.ipackets;
474 timersub(&(pd->curr_ts),&(pd->prev_ts), &delta_tm);
476 uint64_t delta_bit = (pd->curr_stats.ibytes-pd->prev_stats.ibytes)*8;
477 RTE_LOG(DEBUG, USER1, "delta_usec: %-10"PRIu64" delta_pkt: %-10"PRIu64" delta_bit: %-10"PRIu64"\n", delta_usec, delta_pkt, delta_bit);
478 pd->pps = (uint64_t)(delta_pkt*1e6f/delta_usec);
479 pd->bps = (uint64_t)(delta_bit*1e6f/delta_usec);
481 pd->prev_stats = pd->curr_stats;
482 pd->prev_ts = pd->curr_ts;
487 struct pcap_dpdk *pd = (struct pcap_dpdk*)(p->priv);
488 pd->nonblock = nonblock;
493 struct pcap_dpdk *pd = (struct pcap_dpdk*)(p->priv);
494 return pd->nonblock;
500 return plink->link_status == ETH_LINK_UP;
506 snprintf(mac_str, len-1, DPDK_DEF_MAC_ADDR);
517 snprintf(mac_str+offset, len-1-offset, "%02X",addrp->addr_bytes[i]);
520 snprintf(mac_str+offset, len-1-offset, ":%02X", addrp->addr_bytes[i]);
526 // return portid by device name, otherwise return -1
566 for (i=0;dpdk_cfg[i] && cnt<DPDK_ARGC_MAX-1;i++){
590 // If eaccess_not_fatal is non-zero, treat "a permissions issue" the way
626 snprintf(dpdk_cfg_buf,DPDK_CFG_MAX_LEN-1,"%s %s",DPDK_LIB_NAME,ptr_dpdk_cfg);
629 if (ret == -1)
634 is_dpdk_pre_inited = -rte_errno;
642 switch (-is_dpdk_pre_inited)
693 // an out-of-memory condition."
744 PCAP_ERRBUF_SIZE, -is_dpdk_pre_inited,
754 struct pcap_dpdk *pd = p->priv;
755 pd->orig = p;
773 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
775 p->opt.device, dpdk_pre_init_errbuf);
782 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
784 p->opt.device);
791 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
793 p->opt.device);
801 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
807 portid = portid_by_device(p->opt.device);
809 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
811 p->opt.device);
816 pd->portid = portid;
818 if (p->snapshot <= 0 || p->snapshot > MAXIMUM_SNAPLEN)
820 p->snapshot = MAXIMUM_SNAPLEN;
823 pd->pktmbuf_pool = rte_pktmbuf_pool_create(MBUF_POOL_NAME, nb_mbufs,
826 if (pd->pktmbuf_pool == NULL)
828 dpdk_fmt_errmsg_for_rte_errno(p->errbuf,
844 dpdk_fmt_errmsg_for_rte_errno(p->errbuf,
845 PCAP_ERRBUF_SIZE, -ret,
855 dpdk_fmt_errmsg_for_rte_errno(p->errbuf,
856 PCAP_ERRBUF_SIZE, -ret,
863 rte_eth_macaddr_get(portid, &(pd->eth_addr));
864 eth_addr_str(&(pd->eth_addr), pd->mac_addr, DPDK_MAC_ADDR_SIZE-1);
872 pd->pktmbuf_pool);
875 dpdk_fmt_errmsg_for_rte_errno(p->errbuf,
876 PCAP_ERRBUF_SIZE, -ret,
891 dpdk_fmt_errmsg_for_rte_errno(p->errbuf,
892 PCAP_ERRBUF_SIZE, -ret,
904 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
914 dpdk_fmt_errmsg_for_rte_errno(p->errbuf,
915 PCAP_ERRBUF_SIZE, -ret,
922 if (p->opt.promisc){
923 pd->must_clear_promisc=1;
929 snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
934 // reset statistics
935 rte_eth_stats_reset(pd->portid);
936 calculate_timestamp(&(pd->ts_helper), &(pd->prev_ts));
937 rte_eth_stats_get(pd->portid,&(pd->prev_stats));
939 pd->portid = portid;
940 p->fd = pd->portid;
941 if (p->snapshot <=0 || p->snapshot> MAXIMUM_SNAPLEN)
943 p->snapshot = MAXIMUM_SNAPLEN;
945 p->linktype = DLT_EN10MB; // Ethernet, the 10MB is historical.
946 p->selectable_fd = p->fd;
947 p->read_op = pcap_dpdk_dispatch;
948 p->inject_op = pcap_dpdk_inject;
950 p->setfilter_op = pcapint_install_bpf_program;
951 p->setdirection_op = NULL;
952 p->set_datalink_op = NULL;
953 p->getnonblock_op = pcap_dpdk_getnonblock;
954 p->setnonblock_op = pcap_dpdk_setnonblock;
955 p->stats_op = pcap_dpdk_stats;
956 p->cleanup_op = pcap_dpdk_close;
957 p->breakloop_op = pcapint_breakloop_common;
959 pd->required_select_timeout.tv_sec = 0;
960 pd->required_select_timeout.tv_usec = DPDK_DEF_MIN_SLEEP_MS*1000;
961 p->required_select_timeout = &pd->required_select_timeout;
969 rte_eth_dev_get_name_by_port(portid,pd->pci_addr);
970 RTE_LOG(INFO, USER1,"Port %d device: %s, MAC:%s, PCI:%s\n", portid, p->opt.device, pd->mac_addr, pd->pci_addr);
971 RTE_LOG(INFO, USER1,"Port %d Link Up. Speed %u Mbps - %s\n",
974 ("full-duplex") : ("half-duplex\n"));
993 p->activate_op = pcap_dpdk_activate;
1034 snprintf(dpdk_name, DPDK_DEV_NAME_MAX-1,
1041 snprintf(dpdk_desc,DPDK_DEV_DESC_MAX-1,"%s %s, MAC:%s, PCI:%s", DPDK_DESC, dpdk_name, mac_addr, pci_addr);
1082 return (PCAP_VERSION_STRING " (DPDK-only)");