1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2022 Intel Corporation 3 */ 4 5 #ifndef L3FWD_ACL_H 6 #define L3FWD_ACL_H 7 8 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG 9 #define L3FWDACL_DEBUG 10 #endif 11 12 #define MAX_ACL_RULE_NUM 100000 13 #define DEFAULT_MAX_CATEGORIES 1 14 #define L3FWD_ACL_IPV4_NAME "l3fwd-acl-ipv4" 15 #define L3FWD_ACL_IPV6_NAME "l3fwd-acl-ipv6" 16 17 #define ACL_DENY_SIGNATURE 0xf0000000 18 #define RTE_LOGTYPE_L3FWDACL RTE_LOGTYPE_USER3 19 #define acl_log(format, ...) RTE_LOG(ERR, L3FWDACL, format, ##__VA_ARGS__) 20 #define uint32_t_to_char(ip, a, b, c, d) do {\ 21 *a = (unsigned char)(ip >> 24 & 0xff);\ 22 *b = (unsigned char)(ip >> 16 & 0xff);\ 23 *c = (unsigned char)(ip >> 8 & 0xff);\ 24 *d = (unsigned char)(ip & 0xff);\ 25 } while (0) 26 #define OFF_ETHHEAD (sizeof(struct rte_ether_hdr)) 27 #define OFF_IPV42PROTO (offsetof(struct rte_ipv4_hdr, next_proto_id)) 28 #define OFF_IPV62PROTO (offsetof(struct rte_ipv6_hdr, proto)) 29 #define MBUF_IPV4_2PROTO(m) \ 30 rte_pktmbuf_mtod_offset((m), uint8_t *, OFF_ETHHEAD + OFF_IPV42PROTO) 31 #define MBUF_IPV6_2PROTO(m) \ 32 rte_pktmbuf_mtod_offset((m), uint8_t *, OFF_ETHHEAD + OFF_IPV62PROTO) 33 34 /* 35 * ACL rules should have higher priorities than route ones to ensure ACL rule 36 * always be found when input packets have multi-matches in the database. 37 * A exception case is performance measure, which can define route rules with 38 * higher priority and route rules will always be returned in each lookup. 39 * Reserve range from ACL_RULE_PRIORITY_MAX + 1 to 40 * RTE_ACL_MAX_PRIORITY for route entries in performance measure 41 */ 42 #define ACL_RULE_PRIORITY_MAX 0x10000000 43 44 /* 45 * Forward port info save in ACL lib starts from 1 46 * since ACL assume 0 is invalid. 47 * So, need add 1 when saving and minus 1 when forwarding packets. 48 */ 49 #define FWD_PORT_SHIFT 1 50 51 void 52 print_one_ipv4_rule(struct acl4_rule *rule, int extra); 53 54 void 55 print_one_ipv6_rule(struct acl6_rule *rule, int extra); 56 57 #endif /* L3FWD_ACL_H */ 58