* Application main function - loops through * receiving and processing packets. Never returns */
| 200 | * receiving and processing packets. Never returns |
| 201 | */ |
| 202 | int |
| 203 | main(int argc, char *argv[]) |
| 204 | { |
| 205 | const struct rte_memzone *mz; |
| 206 | struct rte_ring *rx_ring; |
| 207 | struct rte_mempool *mp; |
| 208 | struct port_info *ports; |
| 209 | int need_flush = 0; /* indicates whether we have unsent packets */ |
| 210 | int retval; |
| 211 | void *pkts[PKT_READ_SIZE]; |
| 212 | uint16_t sent; |
| 213 | |
| 214 | if ((retval = rte_eal_init(argc, argv)) < 0) |
| 215 | return -1; |
| 216 | argc -= retval; |
| 217 | argv += retval; |
| 218 | |
| 219 | if (parse_app_args(argc, argv) < 0) |
| 220 | rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n"); |
| 221 | |
| 222 | if (rte_eth_dev_count_avail() == 0) |
| 223 | rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); |
| 224 | |
| 225 | rx_ring = rte_ring_lookup(get_rx_queue_name(client_id)); |
| 226 | if (rx_ring == NULL) |
| 227 | rte_exit(EXIT_FAILURE, "Cannot get RX ring - is server process running?\n"); |
| 228 | |
| 229 | mp = rte_mempool_lookup(PKTMBUF_POOL_NAME); |
| 230 | if (mp == NULL) |
| 231 | rte_exit(EXIT_FAILURE, "Cannot get mempool for mbufs\n"); |
| 232 | |
| 233 | mz = rte_memzone_lookup(MZ_PORT_INFO); |
| 234 | if (mz == NULL) |
| 235 | rte_exit(EXIT_FAILURE, "Cannot get port info structure\n"); |
| 236 | ports = mz->addr; |
| 237 | tx_stats = &(ports->tx_stats[client_id]); |
| 238 | |
| 239 | configure_output_ports(ports); |
| 240 | |
| 241 | RTE_LOG(INFO, APP, "Finished Process Init.\n"); |
| 242 | |
| 243 | printf("\nClient process %d handling packets\n", client_id); |
| 244 | printf("[Press Ctrl-C to quit ...]\n"); |
| 245 | |
| 246 | for (;;) { |
| 247 | uint16_t i, rx_pkts; |
| 248 | |
| 249 | rx_pkts = rte_ring_dequeue_burst(rx_ring, pkts, |
| 250 | PKT_READ_SIZE, NULL); |
| 251 | |
| 252 | if (rx_pkts == 0 && need_flush) { |
| 253 | for (i = 0; i < ports->num_ports; i++) { |
| 254 | uint16_t port = ports->id[i]; |
| 255 | |
| 256 | sent = rte_eth_tx_buffer_flush(port, |
| 257 | client_id, |
| 258 | tx_buffer[port]); |
| 259 | tx_stats->tx[port] += sent; |
nothing calls this directly
no test coverage detected