MCPcopy Create free account
hub / github.com/F-Stack/f-stack / process_ring

Function process_ring

dpdk/app/dumpcap/main.c:904–940  ·  view source on GitHub ↗

Process all packets in ring and dump to capture file */

Source from the content-addressed store, hash-verified

902
903/* Process all packets in ring and dump to capture file */
904static int process_ring(dumpcap_out_t out, struct rte_ring *r)
905{
906 struct rte_mbuf *pkts[BURST_SIZE];
907 unsigned int avail, n;
908 static unsigned int empty_count;
909 ssize_t written;
910
911 n = rte_ring_sc_dequeue_burst(r, (void **) pkts, BURST_SIZE,
912 &avail);
913 if (n == 0) {
914 /* don't consume endless amounts of cpu if idle */
915 if (empty_count < SLEEP_THRESHOLD)
916 ++empty_count;
917 else
918 usleep(10);
919 return 0;
920 }
921
922 empty_count = (avail == 0);
923
924 if (use_pcapng)
925 written = rte_pcapng_write_packets(out.pcapng, pkts, n);
926 else
927 written = pcap_write_packets(out.dumper, pkts, n);
928
929 rte_pktmbuf_free_bulk(pkts, n);
930
931 if (written < 0)
932 return -1;
933
934 file_size += written;
935 packets_received += n;
936 if (!quiet)
937 show_count(packets_received);
938
939 return 0;
940}
941
942int main(int argc, char **argv)
943{

Callers 1

mainFunction · 0.85

Calls 5

rte_pcapng_write_packetsFunction · 0.85
pcap_write_packetsFunction · 0.85
rte_pktmbuf_free_bulkFunction · 0.85
show_countFunction · 0.85

Tested by

no test coverage detected