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

Function vhost_queue_stats_update

dpdk/lib/vhost/virtio_net.c:55–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53}
54
55static inline void
56vhost_queue_stats_update(struct virtio_net *dev, struct vhost_virtqueue *vq,
57 struct rte_mbuf **pkts, uint16_t count)
58 __rte_shared_locks_required(&vq->access_lock)
59{
60 struct virtqueue_stats *stats = &vq->stats;
61 int i;
62
63 if (!(dev->flags & VIRTIO_DEV_STATS_ENABLED))
64 return;
65
66 for (i = 0; i < count; i++) {
67 struct rte_ether_addr *ea;
68 struct rte_mbuf *pkt = pkts[i];
69 uint32_t pkt_len = rte_pktmbuf_pkt_len(pkt);
70
71 stats->packets++;
72 stats->bytes += pkt_len;
73
74 if (pkt_len == 64) {
75 stats->size_bins[1]++;
76 } else if (pkt_len > 64 && pkt_len < 1024) {
77 uint32_t bin;
78
79 /* count zeros, and offset into correct bin */
80 bin = (sizeof(pkt_len) * 8) - rte_clz32(pkt_len) - 5;
81 stats->size_bins[bin]++;
82 } else {
83 if (pkt_len < 64)
84 stats->size_bins[0]++;
85 else if (pkt_len < 1519)
86 stats->size_bins[6]++;
87 else
88 stats->size_bins[7]++;
89 }
90
91 ea = rte_pktmbuf_mtod(pkt, struct rte_ether_addr *);
92 if (rte_is_multicast_ether_addr(ea)) {
93 if (rte_is_broadcast_ether_addr(ea))
94 stats->broadcast++;
95 else
96 stats->multicast++;
97 }
98 }
99}
100
101static __rte_always_inline int64_t
102vhost_async_dma_transfer_one(struct virtio_net *dev, struct vhost_virtqueue *vq,

Callers 6

virtio_dev_rxFunction · 0.85
rte_vhost_clear_queueFunction · 0.85
rte_vhost_dequeue_burstFunction · 0.85

Calls 3

rte_clz32Function · 0.85

Tested by

no test coverage detected