Setup ACL context. 8< */
| 684 | |
| 685 | /* Setup ACL context. 8< */ |
| 686 | static struct rte_acl_ctx* |
| 687 | app_acl_init(struct rte_acl_rule *route_base, |
| 688 | struct rte_acl_rule *acl_base, unsigned int route_num, |
| 689 | unsigned int acl_num, int ipv6, int socketid) |
| 690 | { |
| 691 | char name[PATH_MAX]; |
| 692 | struct rte_acl_param acl_param; |
| 693 | struct rte_acl_config acl_build_param; |
| 694 | struct rte_acl_ctx *context; |
| 695 | int dim = ipv6 ? RTE_DIM(ipv6_defs) : RTE_DIM(ipv4_defs); |
| 696 | |
| 697 | /* Create ACL contexts */ |
| 698 | snprintf(name, sizeof(name), "%s%d", |
| 699 | ipv6 ? L3FWD_ACL_IPV6_NAME : L3FWD_ACL_IPV4_NAME, |
| 700 | socketid); |
| 701 | |
| 702 | acl_param.name = name; |
| 703 | acl_param.socket_id = socketid; |
| 704 | acl_param.rule_size = RTE_ACL_RULE_SZ(dim); |
| 705 | acl_param.max_rule_num = MAX_ACL_RULE_NUM; |
| 706 | |
| 707 | context = rte_acl_create(&acl_param); |
| 708 | if (context == NULL) |
| 709 | rte_exit(EXIT_FAILURE, "Failed to create ACL context\n"); |
| 710 | |
| 711 | if (parm_config.alg != RTE_ACL_CLASSIFY_DEFAULT && |
| 712 | rte_acl_set_ctx_classify(context, parm_config.alg) != 0) |
| 713 | rte_exit(EXIT_FAILURE, |
| 714 | "Failed to setup classify method for ACL context\n"); |
| 715 | |
| 716 | if (rte_acl_add_rules(context, route_base, route_num) < 0) |
| 717 | rte_exit(EXIT_FAILURE, "add rules failed\n"); |
| 718 | |
| 719 | if (rte_acl_add_rules(context, acl_base, acl_num) < 0) |
| 720 | rte_exit(EXIT_FAILURE, "add rules failed\n"); |
| 721 | |
| 722 | /* Perform builds */ |
| 723 | memset(&acl_build_param, 0, sizeof(acl_build_param)); |
| 724 | |
| 725 | acl_build_param.num_categories = DEFAULT_MAX_CATEGORIES; |
| 726 | acl_build_param.num_fields = dim; |
| 727 | memcpy(&acl_build_param.defs, ipv6 ? ipv6_defs : ipv4_defs, |
| 728 | ipv6 ? sizeof(ipv6_defs) : sizeof(ipv4_defs)); |
| 729 | |
| 730 | if (rte_acl_build(context, &acl_build_param) != 0) |
| 731 | rte_exit(EXIT_FAILURE, "Failed to build ACL trie\n"); |
| 732 | |
| 733 | rte_acl_dump(context); |
| 734 | |
| 735 | return context; |
| 736 | } |
| 737 | /* >8 End of ACL context setup. */ |
| 738 | |
| 739 | void |
no test coverage detected