| 166 | |
| 167 | |
| 168 | static __rte_noreturn int |
| 169 | main_loop(__rte_unused void *dummy) |
| 170 | { |
| 171 | uint64_t current_time, last_time = rte_rdtsc(); |
| 172 | uint32_t lcore_id = rte_lcore_id(); |
| 173 | |
| 174 | printf("Core %u: port RX = %d, port TX = %d\n", lcore_id, port_rx, port_tx); |
| 175 | |
| 176 | while (1) { |
| 177 | uint64_t time_diff; |
| 178 | int i, nb_rx; |
| 179 | |
| 180 | /* Mechanism to avoid stale packets in the output buffer */ |
| 181 | current_time = rte_rdtsc(); |
| 182 | time_diff = current_time - last_time; |
| 183 | if (unlikely(time_diff > TIME_TX_DRAIN)) { |
| 184 | /* Flush tx buffer */ |
| 185 | rte_eth_tx_buffer_flush(port_tx, NIC_TX_QUEUE, tx_buffer); |
| 186 | last_time = current_time; |
| 187 | } |
| 188 | |
| 189 | /* Read packet burst from NIC RX */ |
| 190 | nb_rx = rte_eth_rx_burst(port_rx, NIC_RX_QUEUE, pkts_rx, RTE_MBUF_F_RX_BURST_MAX); |
| 191 | |
| 192 | /* Handle packets */ |
| 193 | for (i = 0; i < nb_rx; i ++) { |
| 194 | struct rte_mbuf *pkt = pkts_rx[i]; |
| 195 | |
| 196 | /* Handle current packet */ |
| 197 | if (app_pkt_handle(pkt, current_time) == DROP) |
| 198 | rte_pktmbuf_free(pkt); |
| 199 | else |
| 200 | rte_eth_tx_buffer(port_tx, NIC_TX_QUEUE, tx_buffer, pkt); |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | static void |
| 206 | print_usage(const char *prgname) |
nothing calls this directly
no test coverage detected