| 221 | }; |
| 222 | |
| 223 | static int |
| 224 | lcore_rx(struct lcore_params *p) |
| 225 | { |
| 226 | const uint16_t nb_ports = rte_eth_dev_count_avail(); |
| 227 | const int socket_id = rte_socket_id(); |
| 228 | uint16_t port; |
| 229 | struct rte_mbuf *bufs[BURST_SIZE*2]; |
| 230 | |
| 231 | RTE_ETH_FOREACH_DEV(port) { |
| 232 | /* skip ports that are not enabled */ |
| 233 | if ((enabled_port_mask & (1 << port)) == 0) |
| 234 | continue; |
| 235 | |
| 236 | if (rte_eth_dev_socket_id(port) >= 0 && |
| 237 | rte_eth_dev_socket_id(port) != socket_id) |
| 238 | printf("WARNING, port %u is on remote NUMA node to " |
| 239 | "RX thread.\n\tPerformance will not " |
| 240 | "be optimal.\n", port); |
| 241 | } |
| 242 | |
| 243 | printf("\nCore %u doing packet RX.\n", rte_lcore_id()); |
| 244 | port = 0; |
| 245 | while (!quit_signal_rx) { |
| 246 | |
| 247 | /* skip ports that are not enabled */ |
| 248 | if ((enabled_port_mask & (1 << port)) == 0) { |
| 249 | if (++port == nb_ports) |
| 250 | port = 0; |
| 251 | continue; |
| 252 | } |
| 253 | const uint16_t nb_rx = rte_eth_rx_burst(port, 0, bufs, |
| 254 | BURST_SIZE); |
| 255 | if (unlikely(nb_rx == 0)) { |
| 256 | if (++port == nb_ports) |
| 257 | port = 0; |
| 258 | continue; |
| 259 | } |
| 260 | app_stats.rx.rx_pkts += nb_rx; |
| 261 | |
| 262 | /* |
| 263 | * Swap the following two lines if you want the rx traffic |
| 264 | * to go directly to tx, no distribution. |
| 265 | */ |
| 266 | struct rte_ring *out_ring = p->rx_dist_ring; |
| 267 | /* struct rte_ring *out_ring = p->dist_tx_ring; */ |
| 268 | |
| 269 | uint16_t sent = rte_ring_enqueue_burst(out_ring, |
| 270 | (void *)bufs, nb_rx, NULL); |
| 271 | |
| 272 | app_stats.rx.enqueued_pkts += sent; |
| 273 | if (unlikely(sent < nb_rx)) { |
| 274 | app_stats.rx.enqdrop_pkts += nb_rx - sent; |
| 275 | RTE_LOG_DP(DEBUG, DISTRAPP, |
| 276 | "%s:Packet loss due to full ring\n", __func__); |
| 277 | while (sent < nb_rx) |
| 278 | rte_pktmbuf_free(bufs[sent++]); |
| 279 | } |
| 280 | if (++port == nb_ports) |
nothing calls this directly
no test coverage detected