1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2021 HiSilicon Limited.
10 struct hns3_fd_key_cfg {
12 uint8_t inner_sipv6_word_en;
13 uint8_t inner_dipv6_word_en;
14 uint8_t outer_sipv6_word_en;
15 uint8_t outer_dipv6_word_en;
16 uint32_t tuple_active;
17 uint32_t meta_data_active;
27 HNS3_FD_ACTION_ACCEPT_PACKET,
28 HNS3_FD_ACTION_DROP_PACKET,
33 uint16_t max_key_length;
34 uint32_t rule_num[HNS3_FD_STAGE_NUM]; /* rule entry number */
35 uint16_t cnt_num[HNS3_FD_STAGE_NUM]; /* rule hit counter number */
36 struct hns3_fd_key_cfg key_cfg[HNS3_FD_STAGE_NUM];
39 /* OUTER_XXX indicates tuples in tunnel header of tunnel packet
40 * INNER_XXX indicate tuples in tunneled header of tunnel packet or
41 * tuples of non-tunnel packet
77 #define VLAN_TAG_NUM_MAX 2
78 #define VNI_OR_TNI_LEN 3
79 #define IP_ADDR_LEN 4 /* Length of IPv6 address. */
80 #define IP_ADDR_KEY_ID 3 /* The last 32bit of IP address as FDIR search key */
81 #define IPV6_ADDR_WORD_MASK 3 /* The last two word of IPv6 as FDIR search key */
83 struct hns3_fd_rule_tuples {
84 uint8_t src_mac[RTE_ETHER_ADDR_LEN];
85 uint8_t dst_mac[RTE_ETHER_ADDR_LEN];
86 uint32_t src_ip[IP_ADDR_LEN];
87 uint32_t dst_ip[IP_ADDR_LEN];
96 uint16_t outer_src_port;
98 uint16_t outer_ether_type;
100 uint8_t outer_tun_vni[VNI_OR_TNI_LEN];
101 uint8_t outer_tun_flow_id;
104 struct hns3_fd_ad_data {
108 * equal 0 when action is drop.
109 * index of queue when action is queue.
110 * index of first queue of queue region when action is queue region.
114 * equal 0 when action is drop.
115 * equal 1 when action is queue.
116 * numbers of queues of queue region when action is queue region.
121 uint8_t use_next_stage;
122 uint8_t write_rule_id_to_bd;
123 uint8_t next_input_key;
127 struct hns3_flow_counter {
128 LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */
129 uint32_t shared:1; /* Share counter ID with other flow rules. */
130 uint32_t ref_cnt:31; /* Reference counter. */
131 uint16_t id; /* Counter ID. */
132 uint64_t hits; /* Number of packets matched by the rule. */
135 #define HNS3_RULE_FLAG_FDID 0x1
136 #define HNS3_RULE_FLAG_VF_ID 0x2
137 #define HNS3_RULE_FLAG_COUNTER 0x4
139 struct hns3_fdir_key_conf {
140 struct hns3_fd_rule_tuples spec;
141 struct hns3_fd_rule_tuples mask;
143 uint8_t outer_vlan_num;
146 struct hns3_fdir_rule {
147 struct hns3_fdir_key_conf key_conf;
150 uint32_t fd_id; /* APP marked unique value for this rule. */
152 /* VF id, avaiblable when flags with HNS3_RULE_FLAG_VF_ID. */
155 * equal 0 when action is drop.
156 * index of queue when action is queue.
157 * index of first queue of queue region when action is queue region.
161 * equal 0 when action is drop.
162 * equal 1 when action is queue.
163 * numbers of queues of queue region when action is queue region.
167 struct rte_flow_action_count act_cnt;
170 /* FDIR filter list structure */
171 struct hns3_fdir_rule_ele {
172 TAILQ_ENTRY(hns3_fdir_rule_ele) entries;
173 struct hns3_fdir_rule fdir_conf;
176 /* rss filter list structure */
177 struct hns3_rss_conf_ele {
178 TAILQ_ENTRY(hns3_rss_conf_ele) entries;
179 struct hns3_rss_conf filter_info;
182 /* hns3_flow memory list structure */
183 struct hns3_flow_mem {
184 TAILQ_ENTRY(hns3_flow_mem) entries;
185 struct rte_flow *flow;
188 TAILQ_HEAD(hns3_fdir_rule_list, hns3_fdir_rule_ele);
189 TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele);
190 TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem);
192 struct hns3_process_private {
193 struct hns3_fdir_rule_list fdir_list;
194 struct hns3_rss_filter_list filter_rss_list;
195 struct hns3_flow_mem_list flow_list;
199 * A structure used to define fields of a FDIR related info.
201 struct hns3_fdir_info {
202 struct hns3_fdir_rule_list fdir_list;
203 struct hns3_fdir_rule_ele **hash_map;
204 struct rte_hash *hash_handle;
205 struct hns3_fd_cfg fd_cfg;
209 enum rte_filter_type filter_type;
215 int hns3_init_fd_config(struct hns3_adapter *hns);
216 int hns3_fdir_filter_init(struct hns3_adapter *hns);
217 void hns3_fdir_filter_uninit(struct hns3_adapter *hns);
218 int hns3_fdir_filter_program(struct hns3_adapter *hns,
219 struct hns3_fdir_rule *rule, bool del);
220 int hns3_clear_all_fdir_filter(struct hns3_adapter *hns);
221 int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value);
222 void hns3_flow_init(struct rte_eth_dev *dev);
223 int hns3_restore_all_fdir_filter(struct hns3_adapter *hns);
225 #endif /* _HNS3_FDIR_H_ */