| 53 | } |
| 54 | |
| 55 | static inline void |
| 56 | vhost_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 | |
| 101 | static __rte_always_inline int64_t |
| 102 | vhost_async_dma_transfer_one(struct virtio_net *dev, struct vhost_virtqueue *vq, |
no test coverage detected