1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018-2019 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
{
107 uint8_t forward_to_direct_queue
;
111 uint8_t use_next_stage
;
112 uint8_t write_rule_id_to_bd
;
113 uint8_t next_input_key
;
117 struct hns3_flow_counter
{
118 LIST_ENTRY(hns3_flow_counter
) next
; /* Pointer to the next counter. */
119 uint32_t shared
:1; /* Share counter ID with other flow rules. */
120 uint32_t ref_cnt
:31; /* Reference counter. */
121 uint16_t id
; /* Counter ID. */
122 uint64_t hits
; /* Number of packets matched by the rule. */
125 #define HNS3_RULE_FLAG_FDID 0x1
126 #define HNS3_RULE_FLAG_VF_ID 0x2
127 #define HNS3_RULE_FLAG_COUNTER 0x4
129 struct hns3_fdir_key_conf
{
130 struct hns3_fd_rule_tuples spec
;
131 struct hns3_fd_rule_tuples mask
;
133 uint8_t outer_vlan_num
;
136 struct hns3_fdir_rule
{
137 struct hns3_fdir_key_conf key_conf
;
140 uint32_t fd_id
; /* APP marked unique value for this rule. */
142 /* VF id, avaiblable when flags with HNS3_RULE_FLAG_VF_ID. */
146 struct rte_flow_action_count act_cnt
;
149 /* FDIR filter list structure */
150 struct hns3_fdir_rule_ele
{
151 TAILQ_ENTRY(hns3_fdir_rule_ele
) entries
;
152 struct hns3_fdir_rule fdir_conf
;
155 /* rss filter list structure */
156 struct hns3_rss_conf_ele
{
157 TAILQ_ENTRY(hns3_rss_conf_ele
) entries
;
158 struct hns3_rss_conf filter_info
;
161 /* hns3_flow memory list structure */
162 struct hns3_flow_mem
{
163 TAILQ_ENTRY(hns3_flow_mem
) entries
;
164 struct rte_flow
*flow
;
167 TAILQ_HEAD(hns3_fdir_rule_list
, hns3_fdir_rule_ele
);
168 TAILQ_HEAD(hns3_rss_filter_list
, hns3_rss_conf_ele
);
169 TAILQ_HEAD(hns3_flow_mem_list
, hns3_flow_mem
);
171 struct hns3_process_private
{
172 struct hns3_fdir_rule_list fdir_list
;
173 struct hns3_rss_filter_list filter_rss_list
;
174 struct hns3_flow_mem_list flow_list
;
178 * A structure used to define fields of a FDIR related info.
180 struct hns3_fdir_info
{
181 rte_spinlock_t flows_lock
;
182 struct hns3_fdir_rule_list fdir_list
;
183 struct hns3_fdir_rule_ele
**hash_map
;
184 struct rte_hash
*hash_handle
;
185 struct hns3_fd_cfg fd_cfg
;
189 enum rte_filter_type filter_type
;
195 int hns3_init_fd_config(struct hns3_adapter
*hns
);
196 int hns3_fdir_filter_init(struct hns3_adapter
*hns
);
197 void hns3_fdir_filter_uninit(struct hns3_adapter
*hns
);
198 int hns3_fdir_filter_program(struct hns3_adapter
*hns
,
199 struct hns3_fdir_rule
*rule
, bool del
);
200 int hns3_clear_all_fdir_filter(struct hns3_adapter
*hns
);
201 int hns3_get_count(struct hns3_hw
*hw
, uint32_t id
, uint64_t *value
);
202 void hns3_filterlist_init(struct rte_eth_dev
*dev
);
203 int hns3_restore_all_fdir_filter(struct hns3_adapter
*hns
);
205 #endif /* _HNS3_FDIR_H_ */