Callback is added to the TX port. 8< */
| 69 | |
| 70 | /* Callback is added to the TX port. 8< */ |
| 71 | static uint16_t |
| 72 | calc_latency(uint16_t port, uint16_t qidx __rte_unused, |
| 73 | struct rte_mbuf **pkts, uint16_t nb_pkts, void *_ __rte_unused) |
| 74 | { |
| 75 | uint64_t cycles = 0; |
| 76 | uint64_t queue_ticks = 0; |
| 77 | uint64_t now = rte_rdtsc(); |
| 78 | uint64_t ticks; |
| 79 | unsigned i; |
| 80 | |
| 81 | if (hw_timestamping) |
| 82 | rte_eth_read_clock(port, &ticks); |
| 83 | |
| 84 | for (i = 0; i < nb_pkts; i++) { |
| 85 | cycles += now - *tsc_field(pkts[i]); |
| 86 | if (hw_timestamping) |
| 87 | queue_ticks += ticks - *hwts_field(pkts[i]); |
| 88 | } |
| 89 | |
| 90 | latency_numbers.total_cycles += cycles; |
| 91 | if (hw_timestamping) |
| 92 | latency_numbers.total_queue_cycles += (queue_ticks |
| 93 | * ticks_per_cycle_mult) >> TICKS_PER_CYCLE_SHIFT; |
| 94 | |
| 95 | latency_numbers.total_pkts += nb_pkts; |
| 96 | |
| 97 | if (latency_numbers.total_pkts > (100 * 1000 * 1000ULL)) { |
| 98 | printf("Latency = %"PRIu64" cycles\n", |
| 99 | latency_numbers.total_cycles / latency_numbers.total_pkts); |
| 100 | if (hw_timestamping) { |
| 101 | printf("Latency from HW = %"PRIu64" cycles\n", |
| 102 | latency_numbers.total_queue_cycles |
| 103 | / latency_numbers.total_pkts); |
| 104 | } |
| 105 | latency_numbers.total_cycles = 0; |
| 106 | latency_numbers.total_queue_cycles = 0; |
| 107 | latency_numbers.total_pkts = 0; |
| 108 | } |
| 109 | return nb_pkts; |
| 110 | } |
| 111 | /* >8 End of callback addition. */ |
| 112 | |
| 113 | /* |
nothing calls this directly
no test coverage detected