1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2021 HiSilicon Limited.
8 struct hns3_fd_key_cfg {
10 uint8_t inner_sipv6_word_en;
11 uint8_t inner_dipv6_word_en;
12 uint8_t outer_sipv6_word_en;
13 uint8_t outer_dipv6_word_en;
14 uint32_t tuple_active;
15 uint32_t meta_data_active;
25 HNS3_FD_ACTION_ACCEPT_PACKET,
26 HNS3_FD_ACTION_DROP_PACKET,
31 uint16_t max_key_length;
32 uint32_t rule_num[HNS3_FD_STAGE_NUM]; /* rule entry number */
33 uint16_t cnt_num[HNS3_FD_STAGE_NUM]; /* rule hit counter number */
34 struct hns3_fd_key_cfg key_cfg[HNS3_FD_STAGE_NUM];
37 /* OUTER_XXX indicates tuples in tunnel header of tunnel packet
38 * INNER_XXX indicate tuples in tunneled header of tunnel packet or
39 * tuples of non-tunnel packet
75 #define VLAN_TAG_NUM_MAX 2
76 #define VNI_OR_TNI_LEN 3
77 #define IP_ADDR_LEN 4 /* Length of IPv6 address. */
78 #define IP_ADDR_KEY_ID 3 /* The last 32bit of IP address as FDIR search key */
79 #define IPV6_ADDR_WORD_MASK 3 /* The last two word of IPv6 as FDIR search key */
81 struct hns3_fd_rule_tuples {
82 uint8_t src_mac[RTE_ETHER_ADDR_LEN];
83 uint8_t dst_mac[RTE_ETHER_ADDR_LEN];
84 uint32_t src_ip[IP_ADDR_LEN];
85 uint32_t dst_ip[IP_ADDR_LEN];
94 uint16_t outer_src_port;
96 uint16_t outer_ether_type;
98 uint8_t outer_tun_vni[VNI_OR_TNI_LEN];
99 uint8_t outer_tun_flow_id;
102 struct hns3_fd_ad_data {
106 * equal 0 when action is drop.
107 * index of queue when action is queue.
108 * index of first queue of queue region when action is queue region.
112 * equal 0 when action is drop.
113 * equal 1 when action is queue.
114 * numbers of queues of queue region when action is queue region.
119 uint8_t use_next_stage;
120 uint8_t write_rule_id_to_bd;
121 uint8_t next_input_key;
125 #define HNS3_RULE_FLAG_FDID 0x1
126 #define HNS3_RULE_FLAG_VF_ID 0x2
127 #define HNS3_RULE_FLAG_COUNTER 0x4
128 #define HNS3_RULE_FLAG_COUNTER_INDIR 0x8
130 struct hns3_fdir_key_conf {
131 struct hns3_fd_rule_tuples spec;
132 struct hns3_fd_rule_tuples mask;
134 uint8_t outer_vlan_num;
137 struct hns3_fdir_rule {
138 struct hns3_fdir_key_conf key_conf;
141 uint32_t fd_id; /* APP marked unique value for this rule. */
143 /* VF id, available when flags with HNS3_RULE_FLAG_VF_ID. */
146 * equal 0 when action is drop.
147 * index of queue when action is queue.
148 * index of first queue of queue region when action is queue region.
152 * equal 0 when action is drop.
153 * equal 1 when action is queue.
154 * numbers of queues of queue region when action is queue region.
158 struct rte_flow_action_count act_cnt;
161 /* FDIR filter list structure */
162 struct hns3_fdir_rule_ele {
163 TAILQ_ENTRY(hns3_fdir_rule_ele) entries;
164 struct hns3_fdir_rule fdir_conf;
167 TAILQ_HEAD(hns3_fdir_rule_list, hns3_fdir_rule_ele);
170 * A structure used to define fields of a FDIR related info.
172 struct hns3_fdir_info {
173 struct hns3_fdir_rule_list fdir_list;
174 struct hns3_fdir_rule_ele **hash_map;
175 struct rte_hash *hash_handle;
176 struct hns3_fd_cfg fd_cfg;
181 int hns3_init_fd_config(struct hns3_adapter *hns);
182 int hns3_fdir_filter_init(struct hns3_adapter *hns);
183 void hns3_fdir_filter_uninit(struct hns3_adapter *hns);
184 int hns3_fdir_filter_program(struct hns3_adapter *hns,
185 struct hns3_fdir_rule *rule, bool del);
186 int hns3_clear_all_fdir_filter(struct hns3_adapter *hns);
187 int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value);
188 int hns3_restore_all_fdir_filter(struct hns3_adapter *hns);
190 #endif /* _HNS3_FDIR_H_ */