Loading...
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2018, Intel Corporation. */
3
4#ifndef _ICE_SWITCH_H_
5#define _ICE_SWITCH_H_
6
7#include "ice_common.h"
8
9#define ICE_SW_CFG_MAX_BUF_LEN 2048
10#define ICE_DFLT_VSI_INVAL 0xff
11#define ICE_FLTR_RX BIT(0)
12#define ICE_FLTR_TX BIT(1)
13#define ICE_FLTR_TX_ONLY BIT(2)
14#define ICE_VSI_INVAL_ID 0xffff
15#define ICE_INVAL_Q_HANDLE 0xFFFF
16
17/* Switch Profile IDs for Profile related switch rules */
18#define ICE_PROFID_IPV4_GTPC_TEID 41
19#define ICE_PROFID_IPV4_GTPC_NO_TEID 42
20#define ICE_PROFID_IPV4_GTPU_TEID 43
21#define ICE_PROFID_IPV6_GTPC_TEID 44
22#define ICE_PROFID_IPV6_GTPC_NO_TEID 45
23#define ICE_PROFID_IPV6_GTPU_TEID 46
24#define ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER 70
25#define ICE_PROFID_IPV4_PFCP_NODE 79
26#define ICE_PROFID_IPV6_PFCP_SESSION 82
27
28#define ICE_SW_RULE_VSI_LIST_SIZE(s, n) struct_size((s), vsi, (n))
29#define ICE_SW_RULE_RX_TX_HDR_SIZE(s, l) struct_size((s), hdr_data, (l))
30#define ICE_SW_RULE_RX_TX_ETH_HDR_SIZE(s) \
31 ICE_SW_RULE_RX_TX_HDR_SIZE((s), DUMMY_ETH_HDR_LEN)
32#define ICE_SW_RULE_RX_TX_NO_HDR_SIZE(s) \
33 ICE_SW_RULE_RX_TX_HDR_SIZE((s), 0)
34#define ICE_SW_RULE_LG_ACT_SIZE(s, n) struct_size((s), act, (n))
35
36#define DUMMY_ETH_HDR_LEN 16
37
38/* VSI context structure for add/get/update/free operations */
39struct ice_vsi_ctx {
40 u16 vsi_num;
41 u16 vsis_allocd;
42 u16 vsis_unallocated;
43 u16 flags;
44 struct ice_aqc_vsi_props info;
45 struct ice_sched_vsi_info sched;
46 u8 alloc_from_pool;
47 u8 vf_num;
48 u16 num_lan_q_entries[ICE_MAX_TRAFFIC_CLASS];
49 struct ice_q_ctx *lan_q_ctx[ICE_MAX_TRAFFIC_CLASS];
50 u16 num_rdma_q_entries[ICE_MAX_TRAFFIC_CLASS];
51 struct ice_q_ctx *rdma_q_ctx[ICE_MAX_TRAFFIC_CLASS];
52};
53
54/* Switch recipe ID enum values are specific to hardware */
55enum ice_sw_lkup_type {
56 ICE_SW_LKUP_ETHERTYPE = 0,
57 ICE_SW_LKUP_MAC = 1,
58 ICE_SW_LKUP_MAC_VLAN = 2,
59 ICE_SW_LKUP_PROMISC = 3,
60 ICE_SW_LKUP_VLAN = 4,
61 ICE_SW_LKUP_DFLT = 5,
62 ICE_SW_LKUP_ETHERTYPE_MAC = 8,
63 ICE_SW_LKUP_PROMISC_VLAN = 9,
64 ICE_SW_LKUP_LAST
65};
66
67/* type of filter src ID */
68enum ice_src_id {
69 ICE_SRC_ID_UNKNOWN = 0,
70 ICE_SRC_ID_VSI,
71 ICE_SRC_ID_QUEUE,
72 ICE_SRC_ID_LPORT,
73};
74
75struct ice_fltr_info {
76 /* Look up information: how to look up packet */
77 enum ice_sw_lkup_type lkup_type;
78 /* Forward action: filter action to do after lookup */
79 enum ice_sw_fwd_act_type fltr_act;
80 /* rule ID returned by firmware once filter rule is created */
81 u16 fltr_rule_id;
82 u16 flag;
83
84 /* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
85 u16 src;
86 enum ice_src_id src_id;
87
88 union {
89 struct {
90 u8 mac_addr[ETH_ALEN];
91 } mac;
92 struct {
93 u8 mac_addr[ETH_ALEN];
94 u16 vlan_id;
95 } mac_vlan;
96 struct {
97 u16 vlan_id;
98 u16 tpid;
99 u8 tpid_valid;
100 } vlan;
101 /* Set lkup_type as ICE_SW_LKUP_ETHERTYPE
102 * if just using ethertype as filter. Set lkup_type as
103 * ICE_SW_LKUP_ETHERTYPE_MAC if MAC also needs to be
104 * passed in as filter.
105 */
106 struct {
107 u16 ethertype;
108 u8 mac_addr[ETH_ALEN]; /* optional */
109 } ethertype_mac;
110 } l_data; /* Make sure to zero out the memory of l_data before using
111 * it or only set the data associated with lookup match
112 * rest everything should be zero
113 */
114
115 /* Depending on filter action */
116 union {
117 /* queue ID in case of ICE_FWD_TO_Q and starting
118 * queue ID in case of ICE_FWD_TO_QGRP.
119 */
120 u16 q_id:11;
121 u16 hw_vsi_id:10;
122 u16 vsi_list_id:10;
123 } fwd_id;
124
125 /* Sw VSI handle */
126 u16 vsi_handle;
127
128 /* Set to num_queues if action is ICE_FWD_TO_QGRP. This field
129 * determines the range of queues the packet needs to be forwarded to.
130 * Note that qgrp_size must be set to a power of 2.
131 */
132 u8 qgrp_size;
133
134 /* Rule creations populate these indicators basing on the switch type */
135 u8 lb_en; /* Indicate if packet can be looped back */
136 u8 lan_en; /* Indicate if packet can be forwarded to the uplink */
137};
138
139struct ice_update_recipe_lkup_idx_params {
140 u16 rid;
141 u16 fv_idx;
142 bool ignore_valid;
143 u16 mask;
144 bool mask_valid;
145 u8 lkup_idx;
146};
147
148struct ice_adv_lkup_elem {
149 enum ice_protocol_type type;
150 union {
151 union ice_prot_hdr h_u; /* Header values */
152 /* Used to iterate over the headers */
153 u16 h_raw[sizeof(union ice_prot_hdr) / sizeof(u16)];
154 };
155 union {
156 union ice_prot_hdr m_u; /* Mask of header values to match */
157 /* Used to iterate over header mask */
158 u16 m_raw[sizeof(union ice_prot_hdr) / sizeof(u16)];
159 };
160};
161
162struct ice_sw_act_ctrl {
163 /* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
164 u16 src;
165 u16 flag;
166 enum ice_sw_fwd_act_type fltr_act;
167 /* Depending on filter action */
168 union {
169 /* This is a queue ID in case of ICE_FWD_TO_Q and starting
170 * queue ID in case of ICE_FWD_TO_QGRP.
171 */
172 u16 q_id:11;
173 u16 vsi_id:10;
174 u16 hw_vsi_id:10;
175 u16 vsi_list_id:10;
176 } fwd_id;
177 /* software VSI handle */
178 u16 vsi_handle;
179 u8 qgrp_size;
180};
181
182struct ice_rule_query_data {
183 /* Recipe ID for which the requested rule was added */
184 u16 rid;
185 /* Rule ID that was added or is supposed to be removed */
186 u16 rule_id;
187 /* vsi_handle for which Rule was added or is supposed to be removed */
188 u16 vsi_handle;
189};
190
191/* This structure allows to pass info about lb_en and lan_en
192 * flags to ice_add_adv_rule. Values in act would be used
193 * only if act_valid was set to true, otherwise default
194 * values would be used.
195 */
196struct ice_adv_rule_flags_info {
197 u32 act;
198 u8 act_valid; /* indicate if flags in act are valid */
199};
200
201struct ice_adv_rule_info {
202 /* Store metadata values in rule info */
203 enum ice_sw_tunnel_type tun_type;
204 u16 vlan_type;
205 u16 fltr_rule_id;
206 u32 priority;
207 u16 need_pass_l2:1;
208 u16 allow_pass_l2:1;
209 u16 src_vsi;
210 struct ice_sw_act_ctrl sw_act;
211 struct ice_adv_rule_flags_info flags_info;
212};
213
214/* A collection of one or more four word recipe */
215struct ice_sw_recipe {
216 /* For a chained recipe the root recipe is what should be used for
217 * programming rules
218 */
219 u8 root_rid;
220 u8 recp_created;
221
222 /* Number of extraction words */
223 u8 n_ext_words;
224 /* Protocol ID and Offset pair (extraction word) to describe the
225 * recipe
226 */
227 struct ice_fv_word ext_words[ICE_MAX_CHAIN_WORDS];
228 u16 word_masks[ICE_MAX_CHAIN_WORDS];
229 u8 fv_idx[ICE_MAX_CHAIN_WORDS];
230 u16 fv_mask[ICE_MAX_CHAIN_WORDS];
231
232 /* Bit map specifying the IDs associated with this group of recipe */
233 DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
234
235 enum ice_sw_tunnel_type tun_type;
236
237 /* List of type ice_fltr_mgmt_list_entry or adv_rule */
238 u8 adv_rule;
239 struct list_head filt_rules;
240 struct list_head filt_replay_rules;
241
242 struct mutex filt_rule_lock; /* protect filter rule structure */
243
244 /* Profiles this recipe should be associated with */
245 struct list_head fv_list;
246
247 /* Profiles this recipe is associated with */
248 u8 num_profs, *prof_ids;
249
250 /* Bit map for possible result indexes */
251 DECLARE_BITMAP(res_idxs, ICE_MAX_FV_WORDS);
252
253 /* This allows user to specify the recipe priority.
254 * For now, this becomes 'fwd_priority' when recipe
255 * is created, usually recipes can have 'fwd' and 'join'
256 * priority.
257 */
258 u8 priority;
259
260 u8 need_pass_l2:1;
261 u8 allow_pass_l2:1;
262
263 /* This struct saves the fv_words for a given lookup */
264 struct ice_prot_lkup_ext lkup_exts;
265};
266
267/* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list ID */
268struct ice_vsi_list_map_info {
269 struct list_head list_entry;
270 DECLARE_BITMAP(vsi_map, ICE_MAX_VSI);
271 u16 vsi_list_id;
272 /* counter to track how many rules are reusing this VSI list */
273 u16 ref_cnt;
274};
275
276struct ice_fltr_list_entry {
277 struct list_head list_entry;
278 int status;
279 struct ice_fltr_info fltr_info;
280};
281
282/* This defines an entry in the list that maintains MAC or VLAN membership
283 * to HW list mapping, since multiple VSIs can subscribe to the same MAC or
284 * VLAN. As an optimization the VSI list should be created only when a
285 * second VSI becomes a subscriber to the same MAC address. VSI lists are always
286 * used for VLAN membership.
287 */
288struct ice_fltr_mgmt_list_entry {
289 /* back pointer to VSI list ID to VSI list mapping */
290 struct ice_vsi_list_map_info *vsi_list_info;
291 u16 vsi_count;
292#define ICE_INVAL_LG_ACT_INDEX 0xffff
293 u16 lg_act_idx;
294#define ICE_INVAL_SW_MARKER_ID 0xffff
295 u16 sw_marker_id;
296 struct list_head list_entry;
297 struct ice_fltr_info fltr_info;
298#define ICE_INVAL_COUNTER_ID 0xff
299 u8 counter_index;
300};
301
302struct ice_adv_fltr_mgmt_list_entry {
303 struct list_head list_entry;
304
305 struct ice_adv_lkup_elem *lkups;
306 struct ice_adv_rule_info rule_info;
307 u16 lkups_cnt;
308 struct ice_vsi_list_map_info *vsi_list_info;
309 u16 vsi_count;
310};
311
312enum ice_promisc_flags {
313 ICE_PROMISC_UCAST_RX = 0x1,
314 ICE_PROMISC_UCAST_TX = 0x2,
315 ICE_PROMISC_MCAST_RX = 0x4,
316 ICE_PROMISC_MCAST_TX = 0x8,
317 ICE_PROMISC_BCAST_RX = 0x10,
318 ICE_PROMISC_BCAST_TX = 0x20,
319 ICE_PROMISC_VLAN_RX = 0x40,
320 ICE_PROMISC_VLAN_TX = 0x80,
321};
322
323/* VSI related commands */
324int
325ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
326 struct ice_sq_cd *cd);
327int
328ice_free_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
329 bool keep_vsi_alloc, struct ice_sq_cd *cd);
330int
331ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
332 struct ice_sq_cd *cd);
333bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle);
334struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
335void ice_clear_all_vsi_ctx(struct ice_hw *hw);
336/* Switch config */
337int ice_get_initial_sw_cfg(struct ice_hw *hw);
338
339int
340ice_alloc_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
341 u16 *counter_id);
342int
343ice_free_res_cntr(struct ice_hw *hw, u8 type, u8 alloc_shared, u16 num_items,
344 u16 counter_id);
345int ice_share_res(struct ice_hw *hw, u16 type, u8 shared, u16 res_id);
346
347/* Switch/bridge related commands */
348void ice_rule_add_tunnel_metadata(struct ice_adv_lkup_elem *lkup);
349void ice_rule_add_direction_metadata(struct ice_adv_lkup_elem *lkup);
350void ice_rule_add_vlan_metadata(struct ice_adv_lkup_elem *lkup);
351void ice_rule_add_src_vsi_metadata(struct ice_adv_lkup_elem *lkup);
352int
353ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
354 u16 lkups_cnt, struct ice_adv_rule_info *rinfo,
355 struct ice_rule_query_data *added_entry);
356int ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
357int ice_add_vlan(struct ice_hw *hw, struct list_head *m_list);
358int ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list);
359int ice_add_mac(struct ice_hw *hw, struct list_head *m_lst);
360int ice_remove_mac(struct ice_hw *hw, struct list_head *m_lst);
361bool ice_vlan_fltr_exist(struct ice_hw *hw, u16 vlan_id, u16 vsi_handle);
362int ice_add_eth_mac(struct ice_hw *hw, struct list_head *em_list);
363int ice_remove_eth_mac(struct ice_hw *hw, struct list_head *em_list);
364int ice_cfg_rdma_fltr(struct ice_hw *hw, u16 vsi_handle, bool enable);
365void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);
366
367/* Promisc/defport setup for VSIs */
368int
369ice_cfg_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle, bool set,
370 u8 direction);
371bool
372ice_check_if_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle,
373 bool *rule_exists);
374
375int
376ice_set_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
377 u16 vid);
378int
379ice_clear_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
380 u16 vid);
381int
382ice_set_vlan_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
383 bool rm_vlan_promisc);
384
385int
386ice_rem_adv_rule_by_id(struct ice_hw *hw,
387 struct ice_rule_query_data *remove_entry);
388
389int ice_init_def_sw_recp(struct ice_hw *hw);
390u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
391
392int ice_replay_vsi_all_fltr(struct ice_hw *hw, u16 vsi_handle);
393void ice_rm_all_sw_replay_rule_info(struct ice_hw *hw);
394void ice_fill_eth_hdr(u8 *eth_hdr);
395
396int
397ice_aq_sw_rules(struct ice_hw *hw, void *rule_list, u16 rule_list_sz,
398 u8 num_rules, enum ice_adminq_opc opc, struct ice_sq_cd *cd);
399int
400ice_update_recipe_lkup_idx(struct ice_hw *hw,
401 struct ice_update_recipe_lkup_idx_params *params);
402void ice_change_proto_id_to_dvm(void);
403struct ice_vsi_list_map_info *
404ice_find_vsi_list_entry(struct ice_hw *hw, u8 recp_id, u16 vsi_handle,
405 u16 *vsi_list_id);
406int ice_alloc_recipe(struct ice_hw *hw, u16 *rid);
407int ice_aq_get_recipe(struct ice_hw *hw,
408 struct ice_aqc_recipe_data_elem *s_recipe_list,
409 u16 *num_recipes, u16 recipe_root, struct ice_sq_cd *cd);
410int ice_aq_add_recipe(struct ice_hw *hw,
411 struct ice_aqc_recipe_data_elem *s_recipe_list,
412 u16 num_recipes, struct ice_sq_cd *cd);
413int
414ice_aq_get_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 *r_assoc,
415 struct ice_sq_cd *cd);
416int
417ice_aq_map_recipe_to_profile(struct ice_hw *hw, u32 profile_id, u64 r_assoc,
418 struct ice_sq_cd *cd);
419void ice_init_chk_recipe_reuse_support(struct ice_hw *hw);
420
421#endif /* _ICE_SWITCH_H_ */
1/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2018, Intel Corporation. */
3
4#ifndef _ICE_SWITCH_H_
5#define _ICE_SWITCH_H_
6
7#include "ice_common.h"
8
9#define ICE_SW_CFG_MAX_BUF_LEN 2048
10#define ICE_DFLT_VSI_INVAL 0xff
11#define ICE_FLTR_RX BIT(0)
12#define ICE_FLTR_TX BIT(1)
13#define ICE_FLTR_TX_RX (ICE_FLTR_RX | ICE_FLTR_TX)
14#define ICE_VSI_INVAL_ID 0xffff
15#define ICE_INVAL_Q_HANDLE 0xFFFF
16
17/* VSI queue context structure */
18struct ice_q_ctx {
19 u16 q_handle;
20};
21
22/* VSI context structure for add/get/update/free operations */
23struct ice_vsi_ctx {
24 u16 vsi_num;
25 u16 vsis_allocd;
26 u16 vsis_unallocated;
27 u16 flags;
28 struct ice_aqc_vsi_props info;
29 struct ice_sched_vsi_info sched;
30 u8 alloc_from_pool;
31 u8 vf_num;
32 u16 num_lan_q_entries[ICE_MAX_TRAFFIC_CLASS];
33 struct ice_q_ctx *lan_q_ctx[ICE_MAX_TRAFFIC_CLASS];
34};
35
36enum ice_sw_fwd_act_type {
37 ICE_FWD_TO_VSI = 0,
38 ICE_FWD_TO_VSI_LIST, /* Do not use this when adding filter */
39 ICE_FWD_TO_Q,
40 ICE_FWD_TO_QGRP,
41 ICE_DROP_PACKET,
42 ICE_INVAL_ACT
43};
44
45/* Switch recipe ID enum values are specific to hardware */
46enum ice_sw_lkup_type {
47 ICE_SW_LKUP_ETHERTYPE = 0,
48 ICE_SW_LKUP_MAC = 1,
49 ICE_SW_LKUP_MAC_VLAN = 2,
50 ICE_SW_LKUP_PROMISC = 3,
51 ICE_SW_LKUP_VLAN = 4,
52 ICE_SW_LKUP_DFLT = 5,
53 ICE_SW_LKUP_ETHERTYPE_MAC = 8,
54 ICE_SW_LKUP_PROMISC_VLAN = 9,
55 ICE_SW_LKUP_LAST
56};
57
58/* type of filter src ID */
59enum ice_src_id {
60 ICE_SRC_ID_UNKNOWN = 0,
61 ICE_SRC_ID_VSI,
62 ICE_SRC_ID_QUEUE,
63 ICE_SRC_ID_LPORT,
64};
65
66struct ice_fltr_info {
67 /* Look up information: how to look up packet */
68 enum ice_sw_lkup_type lkup_type;
69 /* Forward action: filter action to do after lookup */
70 enum ice_sw_fwd_act_type fltr_act;
71 /* rule ID returned by firmware once filter rule is created */
72 u16 fltr_rule_id;
73 u16 flag;
74
75 /* Source VSI for LOOKUP_TX or source port for LOOKUP_RX */
76 u16 src;
77 enum ice_src_id src_id;
78
79 union {
80 struct {
81 u8 mac_addr[ETH_ALEN];
82 } mac;
83 struct {
84 u8 mac_addr[ETH_ALEN];
85 u16 vlan_id;
86 } mac_vlan;
87 struct {
88 u16 vlan_id;
89 } vlan;
90 /* Set lkup_type as ICE_SW_LKUP_ETHERTYPE
91 * if just using ethertype as filter. Set lkup_type as
92 * ICE_SW_LKUP_ETHERTYPE_MAC if MAC also needs to be
93 * passed in as filter.
94 */
95 struct {
96 u16 ethertype;
97 u8 mac_addr[ETH_ALEN]; /* optional */
98 } ethertype_mac;
99 } l_data; /* Make sure to zero out the memory of l_data before using
100 * it or only set the data associated with lookup match
101 * rest everything should be zero
102 */
103
104 /* Depending on filter action */
105 union {
106 /* queue ID in case of ICE_FWD_TO_Q and starting
107 * queue ID in case of ICE_FWD_TO_QGRP.
108 */
109 u16 q_id:11;
110 u16 hw_vsi_id:10;
111 u16 vsi_list_id:10;
112 } fwd_id;
113
114 /* Sw VSI handle */
115 u16 vsi_handle;
116
117 /* Set to num_queues if action is ICE_FWD_TO_QGRP. This field
118 * determines the range of queues the packet needs to be forwarded to.
119 * Note that qgrp_size must be set to a power of 2.
120 */
121 u8 qgrp_size;
122
123 /* Rule creations populate these indicators basing on the switch type */
124 u8 lb_en; /* Indicate if packet can be looped back */
125 u8 lan_en; /* Indicate if packet can be forwarded to the uplink */
126};
127
128struct ice_sw_recipe {
129 struct list_head l_entry;
130
131 /* To protect modification of filt_rule list
132 * defined below
133 */
134 struct mutex filt_rule_lock;
135
136 /* List of type ice_fltr_mgmt_list_entry */
137 struct list_head filt_rules;
138 struct list_head filt_replay_rules;
139
140 /* linked list of type recipe_list_entry */
141 struct list_head rg_list;
142 /* linked list of type ice_sw_fv_list_entry*/
143 struct list_head fv_list;
144 struct ice_aqc_recipe_data_elem *r_buf;
145 u8 recp_count;
146 u8 root_rid;
147 u8 num_profs;
148 u8 *prof_ids;
149
150 /* recipe bitmap: what all recipes makes this recipe */
151 DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES);
152};
153
154/* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list ID */
155struct ice_vsi_list_map_info {
156 struct list_head list_entry;
157 DECLARE_BITMAP(vsi_map, ICE_MAX_VSI);
158 u16 vsi_list_id;
159 /* counter to track how many rules are reusing this VSI list */
160 u16 ref_cnt;
161};
162
163struct ice_fltr_list_entry {
164 struct list_head list_entry;
165 enum ice_status status;
166 struct ice_fltr_info fltr_info;
167};
168
169/* This defines an entry in the list that maintains MAC or VLAN membership
170 * to HW list mapping, since multiple VSIs can subscribe to the same MAC or
171 * VLAN. As an optimization the VSI list should be created only when a
172 * second VSI becomes a subscriber to the same MAC address. VSI lists are always
173 * used for VLAN membership.
174 */
175struct ice_fltr_mgmt_list_entry {
176 /* back pointer to VSI list ID to VSI list mapping */
177 struct ice_vsi_list_map_info *vsi_list_info;
178 u16 vsi_count;
179#define ICE_INVAL_LG_ACT_INDEX 0xffff
180 u16 lg_act_idx;
181#define ICE_INVAL_SW_MARKER_ID 0xffff
182 u16 sw_marker_id;
183 struct list_head list_entry;
184 struct ice_fltr_info fltr_info;
185#define ICE_INVAL_COUNTER_ID 0xff
186 u8 counter_index;
187};
188
189enum ice_promisc_flags {
190 ICE_PROMISC_UCAST_RX = 0x1,
191 ICE_PROMISC_UCAST_TX = 0x2,
192 ICE_PROMISC_MCAST_RX = 0x4,
193 ICE_PROMISC_MCAST_TX = 0x8,
194 ICE_PROMISC_BCAST_RX = 0x10,
195 ICE_PROMISC_BCAST_TX = 0x20,
196 ICE_PROMISC_VLAN_RX = 0x40,
197 ICE_PROMISC_VLAN_TX = 0x80,
198};
199
200/* VSI related commands */
201enum ice_status
202ice_add_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
203 struct ice_sq_cd *cd);
204enum ice_status
205ice_free_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
206 bool keep_vsi_alloc, struct ice_sq_cd *cd);
207enum ice_status
208ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
209 struct ice_sq_cd *cd);
210bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle);
211struct ice_vsi_ctx *ice_get_vsi_ctx(struct ice_hw *hw, u16 vsi_handle);
212void ice_clear_all_vsi_ctx(struct ice_hw *hw);
213/* Switch config */
214enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw);
215
216/* Switch/bridge related commands */
217enum ice_status ice_update_sw_rule_bridge_mode(struct ice_hw *hw);
218enum ice_status ice_add_mac(struct ice_hw *hw, struct list_head *m_lst);
219enum ice_status ice_remove_mac(struct ice_hw *hw, struct list_head *m_lst);
220enum ice_status
221ice_add_eth_mac(struct ice_hw *hw, struct list_head *em_list);
222enum ice_status
223ice_remove_eth_mac(struct ice_hw *hw, struct list_head *em_list);
224void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);
225enum ice_status
226ice_add_vlan(struct ice_hw *hw, struct list_head *m_list);
227enum ice_status ice_remove_vlan(struct ice_hw *hw, struct list_head *v_list);
228
229/* Promisc/defport setup for VSIs */
230enum ice_status
231ice_cfg_dflt_vsi(struct ice_hw *hw, u16 vsi_handle, bool set, u8 direction);
232enum ice_status
233ice_set_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
234 u16 vid);
235enum ice_status
236ice_clear_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
237 u16 vid);
238enum ice_status
239ice_set_vlan_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
240 bool rm_vlan_promisc);
241
242enum ice_status ice_init_def_sw_recp(struct ice_hw *hw);
243u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
244bool ice_is_vsi_valid(struct ice_hw *hw, u16 vsi_handle);
245
246enum ice_status ice_replay_vsi_all_fltr(struct ice_hw *hw, u16 vsi_handle);
247void ice_rm_all_sw_replay_rule_info(struct ice_hw *hw);
248
249#endif /* _ICE_SWITCH_H_ */