| 374 | } |
| 375 | |
| 376 | void |
| 377 | ff_kni_init(uint16_t nb_ports, const char *tcp_ports, const char *udp_ports) |
| 378 | { |
| 379 | if (rte_eal_process_type() == RTE_PROC_PRIMARY) { |
| 380 | kni_stat = rte_zmalloc("kni:stat", |
| 381 | sizeof(struct kni_interface_stats *) * nb_ports, |
| 382 | RTE_CACHE_LINE_SIZE); |
| 383 | if (kni_stat == NULL) |
| 384 | rte_exit(EXIT_FAILURE, "rte_zmalloc(1 (struct netio_kni_stat *)) " |
| 385 | "failed\n"); |
| 386 | } |
| 387 | |
| 388 | uint16_t lcoreid = rte_lcore_id(); |
| 389 | char name_buf[RTE_RING_NAMESIZE]; |
| 390 | snprintf(name_buf, RTE_RING_NAMESIZE, "kni::ring_%d", lcoreid); |
| 391 | kni_rp = rte_zmalloc(name_buf, |
| 392 | sizeof(struct rte_ring *) * nb_ports, |
| 393 | RTE_CACHE_LINE_SIZE); |
| 394 | if (kni_rp == NULL) { |
| 395 | rte_exit(EXIT_FAILURE, "rte_zmalloc(%s (struct rte_ring*)) " |
| 396 | "failed\n", name_buf); |
| 397 | } |
| 398 | |
| 399 | snprintf(name_buf, RTE_RING_NAMESIZE, "kni:tcp_port_bitmap_%d", lcoreid); |
| 400 | tcp_port_bitmap = rte_zmalloc("kni:tcp_port_bitmap", 8192, |
| 401 | RTE_CACHE_LINE_SIZE); |
| 402 | if (tcp_port_bitmap == NULL) { |
| 403 | rte_exit(EXIT_FAILURE, "rte_zmalloc(%s (tcp_port_bitmap)) " |
| 404 | "failed\n", name_buf); |
| 405 | } |
| 406 | |
| 407 | snprintf(name_buf, RTE_RING_NAMESIZE, "kni:udp_port_bitmap_%d", lcoreid); |
| 408 | udp_port_bitmap = rte_zmalloc("kni:udp_port_bitmap", 8192, |
| 409 | RTE_CACHE_LINE_SIZE); |
| 410 | if (udp_port_bitmap == NULL) { |
| 411 | rte_exit(EXIT_FAILURE, "rte_zmalloc(%s (udp_port_bitmap)) " |
| 412 | "failed\n",name_buf); |
| 413 | } |
| 414 | |
| 415 | memset(tcp_port_bitmap, 0, 8192); |
| 416 | memset(udp_port_bitmap, 0, 8192); |
| 417 | |
| 418 | kni_set_bitmap(tcp_ports, tcp_port_bitmap); |
| 419 | kni_set_bitmap(udp_ports, udp_port_bitmap); |
| 420 | } |
| 421 | |
| 422 | void |
| 423 | ff_kni_alloc(uint16_t port_id, unsigned socket_id, int port_idx, |
no test coverage detected