xref: /OK3568_Linux_fs/kernel/drivers/net/ethernet/intel/ice/ice_fltr.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /* Copyright (C) 2018-2020, Intel Corporation. */
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun #include "ice.h"
5*4882a593Smuzhiyun #include "ice_fltr.h"
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun /**
8*4882a593Smuzhiyun  * ice_fltr_free_list - free filter lists helper
9*4882a593Smuzhiyun  * @dev: pointer to the device struct
10*4882a593Smuzhiyun  * @h: pointer to the list head to be freed
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * Helper function to free filter lists previously created using
13*4882a593Smuzhiyun  * ice_fltr_add_mac_to_list
14*4882a593Smuzhiyun  */
ice_fltr_free_list(struct device * dev,struct list_head * h)15*4882a593Smuzhiyun void ice_fltr_free_list(struct device *dev, struct list_head *h)
16*4882a593Smuzhiyun {
17*4882a593Smuzhiyun 	struct ice_fltr_list_entry *e, *tmp;
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun 	list_for_each_entry_safe(e, tmp, h, list_entry) {
20*4882a593Smuzhiyun 		list_del(&e->list_entry);
21*4882a593Smuzhiyun 		devm_kfree(dev, e);
22*4882a593Smuzhiyun 	}
23*4882a593Smuzhiyun }
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun /**
26*4882a593Smuzhiyun  * ice_fltr_add_entry_to_list - allocate and add filter entry to list
27*4882a593Smuzhiyun  * @dev: pointer to device needed by alloc function
28*4882a593Smuzhiyun  * @info: filter info struct that gets added to the passed in list
29*4882a593Smuzhiyun  * @list: pointer to the list which contains MAC filters entry
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun static int
ice_fltr_add_entry_to_list(struct device * dev,struct ice_fltr_info * info,struct list_head * list)32*4882a593Smuzhiyun ice_fltr_add_entry_to_list(struct device *dev, struct ice_fltr_info *info,
33*4882a593Smuzhiyun 			   struct list_head *list)
34*4882a593Smuzhiyun {
35*4882a593Smuzhiyun 	struct ice_fltr_list_entry *entry;
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun 	entry = devm_kzalloc(dev, sizeof(*entry), GFP_ATOMIC);
38*4882a593Smuzhiyun 	if (!entry)
39*4882a593Smuzhiyun 		return -ENOMEM;
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun 	entry->fltr_info = *info;
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun 	INIT_LIST_HEAD(&entry->list_entry);
44*4882a593Smuzhiyun 	list_add(&entry->list_entry, list);
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun 	return 0;
47*4882a593Smuzhiyun }
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun /**
50*4882a593Smuzhiyun  * ice_fltr_add_mac_list - add list of MAC filters
51*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
52*4882a593Smuzhiyun  * @list: list of filters
53*4882a593Smuzhiyun  */
54*4882a593Smuzhiyun enum ice_status
ice_fltr_add_mac_list(struct ice_vsi * vsi,struct list_head * list)55*4882a593Smuzhiyun ice_fltr_add_mac_list(struct ice_vsi *vsi, struct list_head *list)
56*4882a593Smuzhiyun {
57*4882a593Smuzhiyun 	return ice_add_mac(&vsi->back->hw, list);
58*4882a593Smuzhiyun }
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun /**
61*4882a593Smuzhiyun  * ice_fltr_remove_mac_list - remove list of MAC filters
62*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
63*4882a593Smuzhiyun  * @list: list of filters
64*4882a593Smuzhiyun  */
65*4882a593Smuzhiyun enum ice_status
ice_fltr_remove_mac_list(struct ice_vsi * vsi,struct list_head * list)66*4882a593Smuzhiyun ice_fltr_remove_mac_list(struct ice_vsi *vsi, struct list_head *list)
67*4882a593Smuzhiyun {
68*4882a593Smuzhiyun 	return ice_remove_mac(&vsi->back->hw, list);
69*4882a593Smuzhiyun }
70*4882a593Smuzhiyun 
71*4882a593Smuzhiyun /**
72*4882a593Smuzhiyun  * ice_fltr_add_vlan_list - add list of VLAN filters
73*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
74*4882a593Smuzhiyun  * @list: list of filters
75*4882a593Smuzhiyun  */
76*4882a593Smuzhiyun static enum ice_status
ice_fltr_add_vlan_list(struct ice_vsi * vsi,struct list_head * list)77*4882a593Smuzhiyun ice_fltr_add_vlan_list(struct ice_vsi *vsi, struct list_head *list)
78*4882a593Smuzhiyun {
79*4882a593Smuzhiyun 	return ice_add_vlan(&vsi->back->hw, list);
80*4882a593Smuzhiyun }
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun /**
83*4882a593Smuzhiyun  * ice_fltr_remove_vlan_list - remove list of VLAN filters
84*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
85*4882a593Smuzhiyun  * @list: list of filters
86*4882a593Smuzhiyun  */
87*4882a593Smuzhiyun static enum ice_status
ice_fltr_remove_vlan_list(struct ice_vsi * vsi,struct list_head * list)88*4882a593Smuzhiyun ice_fltr_remove_vlan_list(struct ice_vsi *vsi, struct list_head *list)
89*4882a593Smuzhiyun {
90*4882a593Smuzhiyun 	return ice_remove_vlan(&vsi->back->hw, list);
91*4882a593Smuzhiyun }
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun /**
94*4882a593Smuzhiyun  * ice_fltr_add_eth_list - add list of ethertype filters
95*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
96*4882a593Smuzhiyun  * @list: list of filters
97*4882a593Smuzhiyun  */
98*4882a593Smuzhiyun static enum ice_status
ice_fltr_add_eth_list(struct ice_vsi * vsi,struct list_head * list)99*4882a593Smuzhiyun ice_fltr_add_eth_list(struct ice_vsi *vsi, struct list_head *list)
100*4882a593Smuzhiyun {
101*4882a593Smuzhiyun 	return ice_add_eth_mac(&vsi->back->hw, list);
102*4882a593Smuzhiyun }
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun /**
105*4882a593Smuzhiyun  * ice_fltr_remove_eth_list - remove list of ethertype filters
106*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
107*4882a593Smuzhiyun  * @list: list of filters
108*4882a593Smuzhiyun  */
109*4882a593Smuzhiyun static enum ice_status
ice_fltr_remove_eth_list(struct ice_vsi * vsi,struct list_head * list)110*4882a593Smuzhiyun ice_fltr_remove_eth_list(struct ice_vsi *vsi, struct list_head *list)
111*4882a593Smuzhiyun {
112*4882a593Smuzhiyun 	return ice_remove_eth_mac(&vsi->back->hw, list);
113*4882a593Smuzhiyun }
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun /**
116*4882a593Smuzhiyun  * ice_fltr_remove_all - remove all filters associated with VSI
117*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
118*4882a593Smuzhiyun  */
ice_fltr_remove_all(struct ice_vsi * vsi)119*4882a593Smuzhiyun void ice_fltr_remove_all(struct ice_vsi *vsi)
120*4882a593Smuzhiyun {
121*4882a593Smuzhiyun 	ice_remove_vsi_fltr(&vsi->back->hw, vsi->idx);
122*4882a593Smuzhiyun }
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun /**
125*4882a593Smuzhiyun  * ice_fltr_add_mac_to_list - add MAC filter info to exsisting list
126*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
127*4882a593Smuzhiyun  * @list: list to add filter info to
128*4882a593Smuzhiyun  * @mac: MAC address to add
129*4882a593Smuzhiyun  * @action: filter action
130*4882a593Smuzhiyun  */
131*4882a593Smuzhiyun int
ice_fltr_add_mac_to_list(struct ice_vsi * vsi,struct list_head * list,const u8 * mac,enum ice_sw_fwd_act_type action)132*4882a593Smuzhiyun ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct list_head *list,
133*4882a593Smuzhiyun 			 const u8 *mac, enum ice_sw_fwd_act_type action)
134*4882a593Smuzhiyun {
135*4882a593Smuzhiyun 	struct ice_fltr_info info = { 0 };
136*4882a593Smuzhiyun 
137*4882a593Smuzhiyun 	info.flag = ICE_FLTR_TX;
138*4882a593Smuzhiyun 	info.src_id = ICE_SRC_ID_VSI;
139*4882a593Smuzhiyun 	info.lkup_type = ICE_SW_LKUP_MAC;
140*4882a593Smuzhiyun 	info.fltr_act = action;
141*4882a593Smuzhiyun 	info.vsi_handle = vsi->idx;
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun 	ether_addr_copy(info.l_data.mac.mac_addr, mac);
144*4882a593Smuzhiyun 
145*4882a593Smuzhiyun 	return ice_fltr_add_entry_to_list(ice_pf_to_dev(vsi->back), &info,
146*4882a593Smuzhiyun 					  list);
147*4882a593Smuzhiyun }
148*4882a593Smuzhiyun 
149*4882a593Smuzhiyun /**
150*4882a593Smuzhiyun  * ice_fltr_add_vlan_to_list - add VLAN filter info to exsisting list
151*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
152*4882a593Smuzhiyun  * @list: list to add filter info to
153*4882a593Smuzhiyun  * @vlan_id: VLAN ID to add
154*4882a593Smuzhiyun  * @action: filter action
155*4882a593Smuzhiyun  */
156*4882a593Smuzhiyun static int
ice_fltr_add_vlan_to_list(struct ice_vsi * vsi,struct list_head * list,u16 vlan_id,enum ice_sw_fwd_act_type action)157*4882a593Smuzhiyun ice_fltr_add_vlan_to_list(struct ice_vsi *vsi, struct list_head *list,
158*4882a593Smuzhiyun 			  u16 vlan_id, enum ice_sw_fwd_act_type action)
159*4882a593Smuzhiyun {
160*4882a593Smuzhiyun 	struct ice_fltr_info info = { 0 };
161*4882a593Smuzhiyun 
162*4882a593Smuzhiyun 	info.flag = ICE_FLTR_TX;
163*4882a593Smuzhiyun 	info.src_id = ICE_SRC_ID_VSI;
164*4882a593Smuzhiyun 	info.lkup_type = ICE_SW_LKUP_VLAN;
165*4882a593Smuzhiyun 	info.fltr_act = action;
166*4882a593Smuzhiyun 	info.vsi_handle = vsi->idx;
167*4882a593Smuzhiyun 	info.l_data.vlan.vlan_id = vlan_id;
168*4882a593Smuzhiyun 
169*4882a593Smuzhiyun 	return ice_fltr_add_entry_to_list(ice_pf_to_dev(vsi->back), &info,
170*4882a593Smuzhiyun 					  list);
171*4882a593Smuzhiyun }
172*4882a593Smuzhiyun 
173*4882a593Smuzhiyun /**
174*4882a593Smuzhiyun  * ice_fltr_add_eth_to_list - add ethertype filter info to exsisting list
175*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
176*4882a593Smuzhiyun  * @list: list to add filter info to
177*4882a593Smuzhiyun  * @ethertype: ethertype of packet that matches filter
178*4882a593Smuzhiyun  * @flag: filter direction, Tx or Rx
179*4882a593Smuzhiyun  * @action: filter action
180*4882a593Smuzhiyun  */
181*4882a593Smuzhiyun static int
ice_fltr_add_eth_to_list(struct ice_vsi * vsi,struct list_head * list,u16 ethertype,u16 flag,enum ice_sw_fwd_act_type action)182*4882a593Smuzhiyun ice_fltr_add_eth_to_list(struct ice_vsi *vsi, struct list_head *list,
183*4882a593Smuzhiyun 			 u16 ethertype, u16 flag,
184*4882a593Smuzhiyun 			 enum ice_sw_fwd_act_type action)
185*4882a593Smuzhiyun {
186*4882a593Smuzhiyun 	struct ice_fltr_info info = { 0 };
187*4882a593Smuzhiyun 
188*4882a593Smuzhiyun 	info.flag = flag;
189*4882a593Smuzhiyun 	info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
190*4882a593Smuzhiyun 	info.fltr_act = action;
191*4882a593Smuzhiyun 	info.vsi_handle = vsi->idx;
192*4882a593Smuzhiyun 	info.l_data.ethertype_mac.ethertype = ethertype;
193*4882a593Smuzhiyun 
194*4882a593Smuzhiyun 	if (flag == ICE_FLTR_TX)
195*4882a593Smuzhiyun 		info.src_id = ICE_SRC_ID_VSI;
196*4882a593Smuzhiyun 	else
197*4882a593Smuzhiyun 		info.src_id = ICE_SRC_ID_LPORT;
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun 	return ice_fltr_add_entry_to_list(ice_pf_to_dev(vsi->back), &info,
200*4882a593Smuzhiyun 					  list);
201*4882a593Smuzhiyun }
202*4882a593Smuzhiyun 
203*4882a593Smuzhiyun /**
204*4882a593Smuzhiyun  * ice_fltr_prepare_mac - add or remove MAC rule
205*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
206*4882a593Smuzhiyun  * @mac: MAC address to add
207*4882a593Smuzhiyun  * @action: action to be performed on filter match
208*4882a593Smuzhiyun  * @mac_action: pointer to add or remove MAC function
209*4882a593Smuzhiyun  */
210*4882a593Smuzhiyun static enum ice_status
ice_fltr_prepare_mac(struct ice_vsi * vsi,const u8 * mac,enum ice_sw_fwd_act_type action,enum ice_status (* mac_action)(struct ice_vsi *,struct list_head *))211*4882a593Smuzhiyun ice_fltr_prepare_mac(struct ice_vsi *vsi, const u8 *mac,
212*4882a593Smuzhiyun 		     enum ice_sw_fwd_act_type action,
213*4882a593Smuzhiyun 		     enum ice_status (*mac_action)(struct ice_vsi *,
214*4882a593Smuzhiyun 						   struct list_head *))
215*4882a593Smuzhiyun {
216*4882a593Smuzhiyun 	enum ice_status result;
217*4882a593Smuzhiyun 	LIST_HEAD(tmp_list);
218*4882a593Smuzhiyun 
219*4882a593Smuzhiyun 	if (ice_fltr_add_mac_to_list(vsi, &tmp_list, mac, action)) {
220*4882a593Smuzhiyun 		ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
221*4882a593Smuzhiyun 		return ICE_ERR_NO_MEMORY;
222*4882a593Smuzhiyun 	}
223*4882a593Smuzhiyun 
224*4882a593Smuzhiyun 	result = mac_action(vsi, &tmp_list);
225*4882a593Smuzhiyun 	ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
226*4882a593Smuzhiyun 	return result;
227*4882a593Smuzhiyun }
228*4882a593Smuzhiyun 
229*4882a593Smuzhiyun /**
230*4882a593Smuzhiyun  * ice_fltr_prepare_mac_and_broadcast - add or remove MAC and broadcast filter
231*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
232*4882a593Smuzhiyun  * @mac: MAC address to add
233*4882a593Smuzhiyun  * @action: action to be performed on filter match
234*4882a593Smuzhiyun  * @mac_action: pointer to add or remove MAC function
235*4882a593Smuzhiyun  */
236*4882a593Smuzhiyun static enum ice_status
ice_fltr_prepare_mac_and_broadcast(struct ice_vsi * vsi,const u8 * mac,enum ice_sw_fwd_act_type action,enum ice_status (* mac_action)(struct ice_vsi *,struct list_head *))237*4882a593Smuzhiyun ice_fltr_prepare_mac_and_broadcast(struct ice_vsi *vsi, const u8 *mac,
238*4882a593Smuzhiyun 				   enum ice_sw_fwd_act_type action,
239*4882a593Smuzhiyun 				   enum ice_status(*mac_action)
240*4882a593Smuzhiyun 				   (struct ice_vsi *, struct list_head *))
241*4882a593Smuzhiyun {
242*4882a593Smuzhiyun 	u8 broadcast[ETH_ALEN];
243*4882a593Smuzhiyun 	enum ice_status result;
244*4882a593Smuzhiyun 	LIST_HEAD(tmp_list);
245*4882a593Smuzhiyun 
246*4882a593Smuzhiyun 	eth_broadcast_addr(broadcast);
247*4882a593Smuzhiyun 	if (ice_fltr_add_mac_to_list(vsi, &tmp_list, mac, action) ||
248*4882a593Smuzhiyun 	    ice_fltr_add_mac_to_list(vsi, &tmp_list, broadcast, action)) {
249*4882a593Smuzhiyun 		ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
250*4882a593Smuzhiyun 		return ICE_ERR_NO_MEMORY;
251*4882a593Smuzhiyun 	}
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun 	result = mac_action(vsi, &tmp_list);
254*4882a593Smuzhiyun 	ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
255*4882a593Smuzhiyun 	return result;
256*4882a593Smuzhiyun }
257*4882a593Smuzhiyun 
258*4882a593Smuzhiyun /**
259*4882a593Smuzhiyun  * ice_fltr_prepare_vlan - add or remove VLAN filter
260*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
261*4882a593Smuzhiyun  * @vlan_id: VLAN ID to add
262*4882a593Smuzhiyun  * @action: action to be performed on filter match
263*4882a593Smuzhiyun  * @vlan_action: pointer to add or remove VLAN function
264*4882a593Smuzhiyun  */
265*4882a593Smuzhiyun static enum ice_status
ice_fltr_prepare_vlan(struct ice_vsi * vsi,u16 vlan_id,enum ice_sw_fwd_act_type action,enum ice_status (* vlan_action)(struct ice_vsi *,struct list_head *))266*4882a593Smuzhiyun ice_fltr_prepare_vlan(struct ice_vsi *vsi, u16 vlan_id,
267*4882a593Smuzhiyun 		      enum ice_sw_fwd_act_type action,
268*4882a593Smuzhiyun 		      enum ice_status (*vlan_action)(struct ice_vsi *,
269*4882a593Smuzhiyun 						     struct list_head *))
270*4882a593Smuzhiyun {
271*4882a593Smuzhiyun 	enum ice_status result;
272*4882a593Smuzhiyun 	LIST_HEAD(tmp_list);
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun 	if (ice_fltr_add_vlan_to_list(vsi, &tmp_list, vlan_id, action))
275*4882a593Smuzhiyun 		return ICE_ERR_NO_MEMORY;
276*4882a593Smuzhiyun 
277*4882a593Smuzhiyun 	result = vlan_action(vsi, &tmp_list);
278*4882a593Smuzhiyun 	ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
279*4882a593Smuzhiyun 	return result;
280*4882a593Smuzhiyun }
281*4882a593Smuzhiyun 
282*4882a593Smuzhiyun /**
283*4882a593Smuzhiyun  * ice_fltr_prepare_eth - add or remove ethertype filter
284*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
285*4882a593Smuzhiyun  * @ethertype: ethertype of packet to be filtered
286*4882a593Smuzhiyun  * @flag: direction of packet, Tx or Rx
287*4882a593Smuzhiyun  * @action: action to be performed on filter match
288*4882a593Smuzhiyun  * @eth_action: pointer to add or remove ethertype function
289*4882a593Smuzhiyun  */
290*4882a593Smuzhiyun static enum ice_status
ice_fltr_prepare_eth(struct ice_vsi * vsi,u16 ethertype,u16 flag,enum ice_sw_fwd_act_type action,enum ice_status (* eth_action)(struct ice_vsi *,struct list_head *))291*4882a593Smuzhiyun ice_fltr_prepare_eth(struct ice_vsi *vsi, u16 ethertype, u16 flag,
292*4882a593Smuzhiyun 		     enum ice_sw_fwd_act_type action,
293*4882a593Smuzhiyun 		     enum ice_status (*eth_action)(struct ice_vsi *,
294*4882a593Smuzhiyun 						   struct list_head *))
295*4882a593Smuzhiyun {
296*4882a593Smuzhiyun 	enum ice_status result;
297*4882a593Smuzhiyun 	LIST_HEAD(tmp_list);
298*4882a593Smuzhiyun 
299*4882a593Smuzhiyun 	if (ice_fltr_add_eth_to_list(vsi, &tmp_list, ethertype, flag, action))
300*4882a593Smuzhiyun 		return ICE_ERR_NO_MEMORY;
301*4882a593Smuzhiyun 
302*4882a593Smuzhiyun 	result = eth_action(vsi, &tmp_list);
303*4882a593Smuzhiyun 	ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
304*4882a593Smuzhiyun 	return result;
305*4882a593Smuzhiyun }
306*4882a593Smuzhiyun 
307*4882a593Smuzhiyun /**
308*4882a593Smuzhiyun  * ice_fltr_add_mac - add single MAC filter
309*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
310*4882a593Smuzhiyun  * @mac: MAC to add
311*4882a593Smuzhiyun  * @action: action to be performed on filter match
312*4882a593Smuzhiyun  */
ice_fltr_add_mac(struct ice_vsi * vsi,const u8 * mac,enum ice_sw_fwd_act_type action)313*4882a593Smuzhiyun enum ice_status ice_fltr_add_mac(struct ice_vsi *vsi, const u8 *mac,
314*4882a593Smuzhiyun 				 enum ice_sw_fwd_act_type action)
315*4882a593Smuzhiyun {
316*4882a593Smuzhiyun 	return ice_fltr_prepare_mac(vsi, mac, action, ice_fltr_add_mac_list);
317*4882a593Smuzhiyun }
318*4882a593Smuzhiyun 
319*4882a593Smuzhiyun /**
320*4882a593Smuzhiyun  * ice_fltr_add_mac_and_broadcast - add single MAC and broadcast
321*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
322*4882a593Smuzhiyun  * @mac: MAC to add
323*4882a593Smuzhiyun  * @action: action to be performed on filter match
324*4882a593Smuzhiyun  */
325*4882a593Smuzhiyun enum ice_status
ice_fltr_add_mac_and_broadcast(struct ice_vsi * vsi,const u8 * mac,enum ice_sw_fwd_act_type action)326*4882a593Smuzhiyun ice_fltr_add_mac_and_broadcast(struct ice_vsi *vsi, const u8 *mac,
327*4882a593Smuzhiyun 			       enum ice_sw_fwd_act_type action)
328*4882a593Smuzhiyun {
329*4882a593Smuzhiyun 	return ice_fltr_prepare_mac_and_broadcast(vsi, mac, action,
330*4882a593Smuzhiyun 						  ice_fltr_add_mac_list);
331*4882a593Smuzhiyun }
332*4882a593Smuzhiyun 
333*4882a593Smuzhiyun /**
334*4882a593Smuzhiyun  * ice_fltr_remove_mac - remove MAC filter
335*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
336*4882a593Smuzhiyun  * @mac: filter MAC to remove
337*4882a593Smuzhiyun  * @action: action to remove
338*4882a593Smuzhiyun  */
ice_fltr_remove_mac(struct ice_vsi * vsi,const u8 * mac,enum ice_sw_fwd_act_type action)339*4882a593Smuzhiyun enum ice_status ice_fltr_remove_mac(struct ice_vsi *vsi, const u8 *mac,
340*4882a593Smuzhiyun 				    enum ice_sw_fwd_act_type action)
341*4882a593Smuzhiyun {
342*4882a593Smuzhiyun 	return ice_fltr_prepare_mac(vsi, mac, action, ice_fltr_remove_mac_list);
343*4882a593Smuzhiyun }
344*4882a593Smuzhiyun 
345*4882a593Smuzhiyun /**
346*4882a593Smuzhiyun  * ice_fltr_add_vlan - add single VLAN filter
347*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
348*4882a593Smuzhiyun  * @vlan_id: VLAN ID to add
349*4882a593Smuzhiyun  * @action: action to be performed on filter match
350*4882a593Smuzhiyun  */
ice_fltr_add_vlan(struct ice_vsi * vsi,u16 vlan_id,enum ice_sw_fwd_act_type action)351*4882a593Smuzhiyun enum ice_status ice_fltr_add_vlan(struct ice_vsi *vsi, u16 vlan_id,
352*4882a593Smuzhiyun 				  enum ice_sw_fwd_act_type action)
353*4882a593Smuzhiyun {
354*4882a593Smuzhiyun 	return ice_fltr_prepare_vlan(vsi, vlan_id, action,
355*4882a593Smuzhiyun 				     ice_fltr_add_vlan_list);
356*4882a593Smuzhiyun }
357*4882a593Smuzhiyun 
358*4882a593Smuzhiyun /**
359*4882a593Smuzhiyun  * ice_fltr_remove_vlan - remove VLAN filter
360*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
361*4882a593Smuzhiyun  * @vlan_id: filter VLAN to remove
362*4882a593Smuzhiyun  * @action: action to remove
363*4882a593Smuzhiyun  */
ice_fltr_remove_vlan(struct ice_vsi * vsi,u16 vlan_id,enum ice_sw_fwd_act_type action)364*4882a593Smuzhiyun enum ice_status ice_fltr_remove_vlan(struct ice_vsi *vsi, u16 vlan_id,
365*4882a593Smuzhiyun 				     enum ice_sw_fwd_act_type action)
366*4882a593Smuzhiyun {
367*4882a593Smuzhiyun 	return ice_fltr_prepare_vlan(vsi, vlan_id, action,
368*4882a593Smuzhiyun 				     ice_fltr_remove_vlan_list);
369*4882a593Smuzhiyun }
370*4882a593Smuzhiyun 
371*4882a593Smuzhiyun /**
372*4882a593Smuzhiyun  * ice_fltr_add_eth - add specyfic ethertype filter
373*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
374*4882a593Smuzhiyun  * @ethertype: ethertype of filter
375*4882a593Smuzhiyun  * @flag: direction of packet to be filtered, Tx or Rx
376*4882a593Smuzhiyun  * @action: action to be performed on filter match
377*4882a593Smuzhiyun  */
ice_fltr_add_eth(struct ice_vsi * vsi,u16 ethertype,u16 flag,enum ice_sw_fwd_act_type action)378*4882a593Smuzhiyun enum ice_status ice_fltr_add_eth(struct ice_vsi *vsi, u16 ethertype, u16 flag,
379*4882a593Smuzhiyun 				 enum ice_sw_fwd_act_type action)
380*4882a593Smuzhiyun {
381*4882a593Smuzhiyun 	return ice_fltr_prepare_eth(vsi, ethertype, flag, action,
382*4882a593Smuzhiyun 				    ice_fltr_add_eth_list);
383*4882a593Smuzhiyun }
384*4882a593Smuzhiyun 
385*4882a593Smuzhiyun /**
386*4882a593Smuzhiyun  * ice_fltr_remove_eth - remove ethertype filter
387*4882a593Smuzhiyun  * @vsi: pointer to VSI struct
388*4882a593Smuzhiyun  * @ethertype: ethertype of filter
389*4882a593Smuzhiyun  * @flag: direction of filter
390*4882a593Smuzhiyun  * @action: action to remove
391*4882a593Smuzhiyun  */
ice_fltr_remove_eth(struct ice_vsi * vsi,u16 ethertype,u16 flag,enum ice_sw_fwd_act_type action)392*4882a593Smuzhiyun enum ice_status ice_fltr_remove_eth(struct ice_vsi *vsi, u16 ethertype,
393*4882a593Smuzhiyun 				    u16 flag, enum ice_sw_fwd_act_type action)
394*4882a593Smuzhiyun {
395*4882a593Smuzhiyun 	return ice_fltr_prepare_eth(vsi, ethertype, flag, action,
396*4882a593Smuzhiyun 				    ice_fltr_remove_eth_list);
397*4882a593Smuzhiyun }
398