| 600 | } |
| 601 | |
| 602 | static struct rte_acl_ctx * |
| 603 | acl6_init(const char *name, int32_t socketid, const struct acl6_rules *rules, |
| 604 | uint32_t rules_nb) |
| 605 | { |
| 606 | char s[PATH_MAX]; |
| 607 | struct rte_acl_param acl_param; |
| 608 | struct rte_acl_config acl_build_param; |
| 609 | struct rte_acl_ctx *ctx; |
| 610 | |
| 611 | printf("Creating SP context with %u rules\n", rules_nb); |
| 612 | |
| 613 | memset(&acl_param, 0, sizeof(acl_param)); |
| 614 | |
| 615 | /* Create ACL contexts */ |
| 616 | snprintf(s, sizeof(s), "%s_%d", name, socketid); |
| 617 | |
| 618 | printf("IPv4 %s entries [%u]:\n", s, rules_nb); |
| 619 | dump_ip6_rules(rules, rules_nb, 1); |
| 620 | |
| 621 | acl_param.name = s; |
| 622 | acl_param.socket_id = socketid; |
| 623 | acl_param.rule_size = RTE_ACL_RULE_SZ(RTE_DIM(ip6_defs)); |
| 624 | acl_param.max_rule_num = rules_nb; |
| 625 | |
| 626 | ctx = rte_acl_create(&acl_param); |
| 627 | if (ctx == NULL) |
| 628 | rte_exit(EXIT_FAILURE, "Failed to create ACL context\n"); |
| 629 | |
| 630 | if (rte_acl_add_rules(ctx, (const struct rte_acl_rule *)rules, |
| 631 | rules_nb) < 0) |
| 632 | rte_exit(EXIT_FAILURE, "add rules failed\n"); |
| 633 | |
| 634 | /* Perform builds */ |
| 635 | memset(&acl_build_param, 0, sizeof(acl_build_param)); |
| 636 | |
| 637 | acl_build_param.num_categories = DEFAULT_MAX_CATEGORIES; |
| 638 | acl_build_param.num_fields = RTE_DIM(ip6_defs); |
| 639 | memcpy(&acl_build_param.defs, ip6_defs, sizeof(ip6_defs)); |
| 640 | |
| 641 | if (rte_acl_build(ctx, &acl_build_param) != 0) |
| 642 | rte_exit(EXIT_FAILURE, "Failed to build ACL trie\n"); |
| 643 | |
| 644 | rte_acl_dump(ctx); |
| 645 | |
| 646 | return ctx; |
| 647 | } |
| 648 | |
| 649 | /* |
| 650 | * check that for each rule it's SPI has a correspondent entry in SAD |
no test coverage detected