| 557 | #endif |
| 558 | |
| 559 | void |
| 560 | setup_lpm(const int socketid) |
| 561 | { |
| 562 | struct rte_eth_dev_info dev_info; |
| 563 | struct rte_lpm6_config config; |
| 564 | struct rte_lpm_config config_ipv4; |
| 565 | int i; |
| 566 | int ret; |
| 567 | char s[64]; |
| 568 | char abuf[INET6_ADDRSTRLEN]; |
| 569 | |
| 570 | /* create the LPM table */ |
| 571 | config_ipv4.max_rules = IPV4_L3FWD_LPM_MAX_RULES; |
| 572 | config_ipv4.number_tbl8s = IPV4_L3FWD_LPM_NUMBER_TBL8S; |
| 573 | config_ipv4.flags = 0; |
| 574 | snprintf(s, sizeof(s), "IPV4_L3FWD_LPM_%d", socketid); |
| 575 | ipv4_l3fwd_lpm_lookup_struct[socketid] = |
| 576 | rte_lpm_create(s, socketid, &config_ipv4); |
| 577 | if (ipv4_l3fwd_lpm_lookup_struct[socketid] == NULL) |
| 578 | rte_exit(EXIT_FAILURE, |
| 579 | "Unable to create the l3fwd LPM table on socket %d\n", |
| 580 | socketid); |
| 581 | |
| 582 | /* populate the LPM table */ |
| 583 | for (i = 0; i < route_num_v4; i++) { |
| 584 | struct in_addr in; |
| 585 | |
| 586 | /* skip unused ports */ |
| 587 | if ((1 << route_base_v4[i].if_out & |
| 588 | enabled_port_mask) == 0) |
| 589 | continue; |
| 590 | |
| 591 | rte_eth_dev_info_get(route_base_v4[i].if_out, |
| 592 | &dev_info); |
| 593 | ret = rte_lpm_add(ipv4_l3fwd_lpm_lookup_struct[socketid], |
| 594 | route_base_v4[i].ip, |
| 595 | route_base_v4[i].depth, |
| 596 | route_base_v4[i].if_out); |
| 597 | |
| 598 | if (ret < 0) { |
| 599 | lpm_free_routes(); |
| 600 | rte_exit(EXIT_FAILURE, |
| 601 | "Unable to add entry %u to the l3fwd LPM table on socket %d\n", |
| 602 | i, socketid); |
| 603 | } |
| 604 | |
| 605 | in.s_addr = htonl(route_base_v4[i].ip); |
| 606 | printf("LPM: Adding route %s / %d (%d) [%s]\n", |
| 607 | inet_ntop(AF_INET, &in, abuf, sizeof(abuf)), |
| 608 | route_base_v4[i].depth, |
| 609 | route_base_v4[i].if_out, rte_dev_name(dev_info.device)); |
| 610 | } |
| 611 | |
| 612 | /* create the LPM6 table */ |
| 613 | snprintf(s, sizeof(s), "IPV6_L3FWD_LPM_%d", socketid); |
| 614 | |
| 615 | config.max_rules = IPV6_L3FWD_LPM_MAX_RULES; |
| 616 | config.number_tbl8s = IPV6_L3FWD_LPM_NUMBER_TBL8S; |
nothing calls this directly
no test coverage detected