18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/* Copyright (C) 2018-2020, Intel Corporation. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#include "ice.h"
58c2ecf20Sopenharmony_ci#include "ice_fltr.h"
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci/**
88c2ecf20Sopenharmony_ci * ice_fltr_free_list - free filter lists helper
98c2ecf20Sopenharmony_ci * @dev: pointer to the device struct
108c2ecf20Sopenharmony_ci * @h: pointer to the list head to be freed
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci * Helper function to free filter lists previously created using
138c2ecf20Sopenharmony_ci * ice_fltr_add_mac_to_list
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_civoid ice_fltr_free_list(struct device *dev, struct list_head *h)
168c2ecf20Sopenharmony_ci{
178c2ecf20Sopenharmony_ci	struct ice_fltr_list_entry *e, *tmp;
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci	list_for_each_entry_safe(e, tmp, h, list_entry) {
208c2ecf20Sopenharmony_ci		list_del(&e->list_entry);
218c2ecf20Sopenharmony_ci		devm_kfree(dev, e);
228c2ecf20Sopenharmony_ci	}
238c2ecf20Sopenharmony_ci}
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/**
268c2ecf20Sopenharmony_ci * ice_fltr_add_entry_to_list - allocate and add filter entry to list
278c2ecf20Sopenharmony_ci * @dev: pointer to device needed by alloc function
288c2ecf20Sopenharmony_ci * @info: filter info struct that gets added to the passed in list
298c2ecf20Sopenharmony_ci * @list: pointer to the list which contains MAC filters entry
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_cistatic int
328c2ecf20Sopenharmony_ciice_fltr_add_entry_to_list(struct device *dev, struct ice_fltr_info *info,
338c2ecf20Sopenharmony_ci			   struct list_head *list)
348c2ecf20Sopenharmony_ci{
358c2ecf20Sopenharmony_ci	struct ice_fltr_list_entry *entry;
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	entry = devm_kzalloc(dev, sizeof(*entry), GFP_ATOMIC);
388c2ecf20Sopenharmony_ci	if (!entry)
398c2ecf20Sopenharmony_ci		return -ENOMEM;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	entry->fltr_info = *info;
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	INIT_LIST_HEAD(&entry->list_entry);
448c2ecf20Sopenharmony_ci	list_add(&entry->list_entry, list);
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	return 0;
478c2ecf20Sopenharmony_ci}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/**
508c2ecf20Sopenharmony_ci * ice_fltr_add_mac_list - add list of MAC filters
518c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
528c2ecf20Sopenharmony_ci * @list: list of filters
538c2ecf20Sopenharmony_ci */
548c2ecf20Sopenharmony_cienum ice_status
558c2ecf20Sopenharmony_ciice_fltr_add_mac_list(struct ice_vsi *vsi, struct list_head *list)
568c2ecf20Sopenharmony_ci{
578c2ecf20Sopenharmony_ci	return ice_add_mac(&vsi->back->hw, list);
588c2ecf20Sopenharmony_ci}
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/**
618c2ecf20Sopenharmony_ci * ice_fltr_remove_mac_list - remove list of MAC filters
628c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
638c2ecf20Sopenharmony_ci * @list: list of filters
648c2ecf20Sopenharmony_ci */
658c2ecf20Sopenharmony_cienum ice_status
668c2ecf20Sopenharmony_ciice_fltr_remove_mac_list(struct ice_vsi *vsi, struct list_head *list)
678c2ecf20Sopenharmony_ci{
688c2ecf20Sopenharmony_ci	return ice_remove_mac(&vsi->back->hw, list);
698c2ecf20Sopenharmony_ci}
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/**
728c2ecf20Sopenharmony_ci * ice_fltr_add_vlan_list - add list of VLAN filters
738c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
748c2ecf20Sopenharmony_ci * @list: list of filters
758c2ecf20Sopenharmony_ci */
768c2ecf20Sopenharmony_cistatic enum ice_status
778c2ecf20Sopenharmony_ciice_fltr_add_vlan_list(struct ice_vsi *vsi, struct list_head *list)
788c2ecf20Sopenharmony_ci{
798c2ecf20Sopenharmony_ci	return ice_add_vlan(&vsi->back->hw, list);
808c2ecf20Sopenharmony_ci}
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ci/**
838c2ecf20Sopenharmony_ci * ice_fltr_remove_vlan_list - remove list of VLAN filters
848c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
858c2ecf20Sopenharmony_ci * @list: list of filters
868c2ecf20Sopenharmony_ci */
878c2ecf20Sopenharmony_cistatic enum ice_status
888c2ecf20Sopenharmony_ciice_fltr_remove_vlan_list(struct ice_vsi *vsi, struct list_head *list)
898c2ecf20Sopenharmony_ci{
908c2ecf20Sopenharmony_ci	return ice_remove_vlan(&vsi->back->hw, list);
918c2ecf20Sopenharmony_ci}
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/**
948c2ecf20Sopenharmony_ci * ice_fltr_add_eth_list - add list of ethertype filters
958c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
968c2ecf20Sopenharmony_ci * @list: list of filters
978c2ecf20Sopenharmony_ci */
988c2ecf20Sopenharmony_cistatic enum ice_status
998c2ecf20Sopenharmony_ciice_fltr_add_eth_list(struct ice_vsi *vsi, struct list_head *list)
1008c2ecf20Sopenharmony_ci{
1018c2ecf20Sopenharmony_ci	return ice_add_eth_mac(&vsi->back->hw, list);
1028c2ecf20Sopenharmony_ci}
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/**
1058c2ecf20Sopenharmony_ci * ice_fltr_remove_eth_list - remove list of ethertype filters
1068c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
1078c2ecf20Sopenharmony_ci * @list: list of filters
1088c2ecf20Sopenharmony_ci */
1098c2ecf20Sopenharmony_cistatic enum ice_status
1108c2ecf20Sopenharmony_ciice_fltr_remove_eth_list(struct ice_vsi *vsi, struct list_head *list)
1118c2ecf20Sopenharmony_ci{
1128c2ecf20Sopenharmony_ci	return ice_remove_eth_mac(&vsi->back->hw, list);
1138c2ecf20Sopenharmony_ci}
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/**
1168c2ecf20Sopenharmony_ci * ice_fltr_remove_all - remove all filters associated with VSI
1178c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
1188c2ecf20Sopenharmony_ci */
1198c2ecf20Sopenharmony_civoid ice_fltr_remove_all(struct ice_vsi *vsi)
1208c2ecf20Sopenharmony_ci{
1218c2ecf20Sopenharmony_ci	ice_remove_vsi_fltr(&vsi->back->hw, vsi->idx);
1228c2ecf20Sopenharmony_ci}
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci/**
1258c2ecf20Sopenharmony_ci * ice_fltr_add_mac_to_list - add MAC filter info to exsisting list
1268c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
1278c2ecf20Sopenharmony_ci * @list: list to add filter info to
1288c2ecf20Sopenharmony_ci * @mac: MAC address to add
1298c2ecf20Sopenharmony_ci * @action: filter action
1308c2ecf20Sopenharmony_ci */
1318c2ecf20Sopenharmony_cienum ice_status
1328c2ecf20Sopenharmony_ciice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct list_head *list,
1338c2ecf20Sopenharmony_ci			 const u8 *mac, enum ice_sw_fwd_act_type action)
1348c2ecf20Sopenharmony_ci{
1358c2ecf20Sopenharmony_ci	struct ice_fltr_info info = { 0 };
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci	info.flag = ICE_FLTR_TX;
1388c2ecf20Sopenharmony_ci	info.src_id = ICE_SRC_ID_VSI;
1398c2ecf20Sopenharmony_ci	info.lkup_type = ICE_SW_LKUP_MAC;
1408c2ecf20Sopenharmony_ci	info.fltr_act = action;
1418c2ecf20Sopenharmony_ci	info.vsi_handle = vsi->idx;
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	ether_addr_copy(info.l_data.mac.mac_addr, mac);
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci	return ice_fltr_add_entry_to_list(ice_pf_to_dev(vsi->back), &info,
1468c2ecf20Sopenharmony_ci					  list);
1478c2ecf20Sopenharmony_ci}
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci/**
1508c2ecf20Sopenharmony_ci * ice_fltr_add_vlan_to_list - add VLAN filter info to exsisting list
1518c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
1528c2ecf20Sopenharmony_ci * @list: list to add filter info to
1538c2ecf20Sopenharmony_ci * @vlan_id: VLAN ID to add
1548c2ecf20Sopenharmony_ci * @action: filter action
1558c2ecf20Sopenharmony_ci */
1568c2ecf20Sopenharmony_cistatic int
1578c2ecf20Sopenharmony_ciice_fltr_add_vlan_to_list(struct ice_vsi *vsi, struct list_head *list,
1588c2ecf20Sopenharmony_ci			  u16 vlan_id, enum ice_sw_fwd_act_type action)
1598c2ecf20Sopenharmony_ci{
1608c2ecf20Sopenharmony_ci	struct ice_fltr_info info = { 0 };
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci	info.flag = ICE_FLTR_TX;
1638c2ecf20Sopenharmony_ci	info.src_id = ICE_SRC_ID_VSI;
1648c2ecf20Sopenharmony_ci	info.lkup_type = ICE_SW_LKUP_VLAN;
1658c2ecf20Sopenharmony_ci	info.fltr_act = action;
1668c2ecf20Sopenharmony_ci	info.vsi_handle = vsi->idx;
1678c2ecf20Sopenharmony_ci	info.l_data.vlan.vlan_id = vlan_id;
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci	return ice_fltr_add_entry_to_list(ice_pf_to_dev(vsi->back), &info,
1708c2ecf20Sopenharmony_ci					  list);
1718c2ecf20Sopenharmony_ci}
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci/**
1748c2ecf20Sopenharmony_ci * ice_fltr_add_eth_to_list - add ethertype filter info to exsisting list
1758c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
1768c2ecf20Sopenharmony_ci * @list: list to add filter info to
1778c2ecf20Sopenharmony_ci * @ethertype: ethertype of packet that matches filter
1788c2ecf20Sopenharmony_ci * @flag: filter direction, Tx or Rx
1798c2ecf20Sopenharmony_ci * @action: filter action
1808c2ecf20Sopenharmony_ci */
1818c2ecf20Sopenharmony_cistatic int
1828c2ecf20Sopenharmony_ciice_fltr_add_eth_to_list(struct ice_vsi *vsi, struct list_head *list,
1838c2ecf20Sopenharmony_ci			 u16 ethertype, u16 flag,
1848c2ecf20Sopenharmony_ci			 enum ice_sw_fwd_act_type action)
1858c2ecf20Sopenharmony_ci{
1868c2ecf20Sopenharmony_ci	struct ice_fltr_info info = { 0 };
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci	info.flag = flag;
1898c2ecf20Sopenharmony_ci	info.lkup_type = ICE_SW_LKUP_ETHERTYPE;
1908c2ecf20Sopenharmony_ci	info.fltr_act = action;
1918c2ecf20Sopenharmony_ci	info.vsi_handle = vsi->idx;
1928c2ecf20Sopenharmony_ci	info.l_data.ethertype_mac.ethertype = ethertype;
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	if (flag == ICE_FLTR_TX)
1958c2ecf20Sopenharmony_ci		info.src_id = ICE_SRC_ID_VSI;
1968c2ecf20Sopenharmony_ci	else
1978c2ecf20Sopenharmony_ci		info.src_id = ICE_SRC_ID_LPORT;
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	return ice_fltr_add_entry_to_list(ice_pf_to_dev(vsi->back), &info,
2008c2ecf20Sopenharmony_ci					  list);
2018c2ecf20Sopenharmony_ci}
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci/**
2048c2ecf20Sopenharmony_ci * ice_fltr_prepare_mac - add or remove MAC rule
2058c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
2068c2ecf20Sopenharmony_ci * @mac: MAC address to add
2078c2ecf20Sopenharmony_ci * @action: action to be performed on filter match
2088c2ecf20Sopenharmony_ci * @mac_action: pointer to add or remove MAC function
2098c2ecf20Sopenharmony_ci */
2108c2ecf20Sopenharmony_cistatic enum ice_status
2118c2ecf20Sopenharmony_ciice_fltr_prepare_mac(struct ice_vsi *vsi, const u8 *mac,
2128c2ecf20Sopenharmony_ci		     enum ice_sw_fwd_act_type action,
2138c2ecf20Sopenharmony_ci		     enum ice_status (*mac_action)(struct ice_vsi *,
2148c2ecf20Sopenharmony_ci						   struct list_head *))
2158c2ecf20Sopenharmony_ci{
2168c2ecf20Sopenharmony_ci	enum ice_status result;
2178c2ecf20Sopenharmony_ci	LIST_HEAD(tmp_list);
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	if (ice_fltr_add_mac_to_list(vsi, &tmp_list, mac, action)) {
2208c2ecf20Sopenharmony_ci		ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
2218c2ecf20Sopenharmony_ci		return ICE_ERR_NO_MEMORY;
2228c2ecf20Sopenharmony_ci	}
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	result = mac_action(vsi, &tmp_list);
2258c2ecf20Sopenharmony_ci	ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
2268c2ecf20Sopenharmony_ci	return result;
2278c2ecf20Sopenharmony_ci}
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci/**
2308c2ecf20Sopenharmony_ci * ice_fltr_prepare_mac_and_broadcast - add or remove MAC and broadcast filter
2318c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
2328c2ecf20Sopenharmony_ci * @mac: MAC address to add
2338c2ecf20Sopenharmony_ci * @action: action to be performed on filter match
2348c2ecf20Sopenharmony_ci * @mac_action: pointer to add or remove MAC function
2358c2ecf20Sopenharmony_ci */
2368c2ecf20Sopenharmony_cistatic enum ice_status
2378c2ecf20Sopenharmony_ciice_fltr_prepare_mac_and_broadcast(struct ice_vsi *vsi, const u8 *mac,
2388c2ecf20Sopenharmony_ci				   enum ice_sw_fwd_act_type action,
2398c2ecf20Sopenharmony_ci				   enum ice_status(*mac_action)
2408c2ecf20Sopenharmony_ci				   (struct ice_vsi *, struct list_head *))
2418c2ecf20Sopenharmony_ci{
2428c2ecf20Sopenharmony_ci	u8 broadcast[ETH_ALEN];
2438c2ecf20Sopenharmony_ci	enum ice_status result;
2448c2ecf20Sopenharmony_ci	LIST_HEAD(tmp_list);
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci	eth_broadcast_addr(broadcast);
2478c2ecf20Sopenharmony_ci	if (ice_fltr_add_mac_to_list(vsi, &tmp_list, mac, action) ||
2488c2ecf20Sopenharmony_ci	    ice_fltr_add_mac_to_list(vsi, &tmp_list, broadcast, action)) {
2498c2ecf20Sopenharmony_ci		ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
2508c2ecf20Sopenharmony_ci		return ICE_ERR_NO_MEMORY;
2518c2ecf20Sopenharmony_ci	}
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	result = mac_action(vsi, &tmp_list);
2548c2ecf20Sopenharmony_ci	ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
2558c2ecf20Sopenharmony_ci	return result;
2568c2ecf20Sopenharmony_ci}
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci/**
2598c2ecf20Sopenharmony_ci * ice_fltr_prepare_vlan - add or remove VLAN filter
2608c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
2618c2ecf20Sopenharmony_ci * @vlan_id: VLAN ID to add
2628c2ecf20Sopenharmony_ci * @action: action to be performed on filter match
2638c2ecf20Sopenharmony_ci * @vlan_action: pointer to add or remove VLAN function
2648c2ecf20Sopenharmony_ci */
2658c2ecf20Sopenharmony_cistatic enum ice_status
2668c2ecf20Sopenharmony_ciice_fltr_prepare_vlan(struct ice_vsi *vsi, u16 vlan_id,
2678c2ecf20Sopenharmony_ci		      enum ice_sw_fwd_act_type action,
2688c2ecf20Sopenharmony_ci		      enum ice_status (*vlan_action)(struct ice_vsi *,
2698c2ecf20Sopenharmony_ci						     struct list_head *))
2708c2ecf20Sopenharmony_ci{
2718c2ecf20Sopenharmony_ci	enum ice_status result;
2728c2ecf20Sopenharmony_ci	LIST_HEAD(tmp_list);
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	if (ice_fltr_add_vlan_to_list(vsi, &tmp_list, vlan_id, action))
2758c2ecf20Sopenharmony_ci		return ICE_ERR_NO_MEMORY;
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci	result = vlan_action(vsi, &tmp_list);
2788c2ecf20Sopenharmony_ci	ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
2798c2ecf20Sopenharmony_ci	return result;
2808c2ecf20Sopenharmony_ci}
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci/**
2838c2ecf20Sopenharmony_ci * ice_fltr_prepare_eth - add or remove ethertype filter
2848c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
2858c2ecf20Sopenharmony_ci * @ethertype: ethertype of packet to be filtered
2868c2ecf20Sopenharmony_ci * @flag: direction of packet, Tx or Rx
2878c2ecf20Sopenharmony_ci * @action: action to be performed on filter match
2888c2ecf20Sopenharmony_ci * @eth_action: pointer to add or remove ethertype function
2898c2ecf20Sopenharmony_ci */
2908c2ecf20Sopenharmony_cistatic enum ice_status
2918c2ecf20Sopenharmony_ciice_fltr_prepare_eth(struct ice_vsi *vsi, u16 ethertype, u16 flag,
2928c2ecf20Sopenharmony_ci		     enum ice_sw_fwd_act_type action,
2938c2ecf20Sopenharmony_ci		     enum ice_status (*eth_action)(struct ice_vsi *,
2948c2ecf20Sopenharmony_ci						   struct list_head *))
2958c2ecf20Sopenharmony_ci{
2968c2ecf20Sopenharmony_ci	enum ice_status result;
2978c2ecf20Sopenharmony_ci	LIST_HEAD(tmp_list);
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci	if (ice_fltr_add_eth_to_list(vsi, &tmp_list, ethertype, flag, action))
3008c2ecf20Sopenharmony_ci		return ICE_ERR_NO_MEMORY;
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	result = eth_action(vsi, &tmp_list);
3038c2ecf20Sopenharmony_ci	ice_fltr_free_list(ice_pf_to_dev(vsi->back), &tmp_list);
3048c2ecf20Sopenharmony_ci	return result;
3058c2ecf20Sopenharmony_ci}
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci/**
3088c2ecf20Sopenharmony_ci * ice_fltr_add_mac - add single MAC filter
3098c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
3108c2ecf20Sopenharmony_ci * @mac: MAC to add
3118c2ecf20Sopenharmony_ci * @action: action to be performed on filter match
3128c2ecf20Sopenharmony_ci */
3138c2ecf20Sopenharmony_cienum ice_status ice_fltr_add_mac(struct ice_vsi *vsi, const u8 *mac,
3148c2ecf20Sopenharmony_ci				 enum ice_sw_fwd_act_type action)
3158c2ecf20Sopenharmony_ci{
3168c2ecf20Sopenharmony_ci	return ice_fltr_prepare_mac(vsi, mac, action, ice_fltr_add_mac_list);
3178c2ecf20Sopenharmony_ci}
3188c2ecf20Sopenharmony_ci
3198c2ecf20Sopenharmony_ci/**
3208c2ecf20Sopenharmony_ci * ice_fltr_add_mac_and_broadcast - add single MAC and broadcast
3218c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
3228c2ecf20Sopenharmony_ci * @mac: MAC to add
3238c2ecf20Sopenharmony_ci * @action: action to be performed on filter match
3248c2ecf20Sopenharmony_ci */
3258c2ecf20Sopenharmony_cienum ice_status
3268c2ecf20Sopenharmony_ciice_fltr_add_mac_and_broadcast(struct ice_vsi *vsi, const u8 *mac,
3278c2ecf20Sopenharmony_ci			       enum ice_sw_fwd_act_type action)
3288c2ecf20Sopenharmony_ci{
3298c2ecf20Sopenharmony_ci	return ice_fltr_prepare_mac_and_broadcast(vsi, mac, action,
3308c2ecf20Sopenharmony_ci						  ice_fltr_add_mac_list);
3318c2ecf20Sopenharmony_ci}
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci/**
3348c2ecf20Sopenharmony_ci * ice_fltr_remove_mac - remove MAC filter
3358c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
3368c2ecf20Sopenharmony_ci * @mac: filter MAC to remove
3378c2ecf20Sopenharmony_ci * @action: action to remove
3388c2ecf20Sopenharmony_ci */
3398c2ecf20Sopenharmony_cienum ice_status ice_fltr_remove_mac(struct ice_vsi *vsi, const u8 *mac,
3408c2ecf20Sopenharmony_ci				    enum ice_sw_fwd_act_type action)
3418c2ecf20Sopenharmony_ci{
3428c2ecf20Sopenharmony_ci	return ice_fltr_prepare_mac(vsi, mac, action, ice_fltr_remove_mac_list);
3438c2ecf20Sopenharmony_ci}
3448c2ecf20Sopenharmony_ci
3458c2ecf20Sopenharmony_ci/**
3468c2ecf20Sopenharmony_ci * ice_fltr_add_vlan - add single VLAN filter
3478c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
3488c2ecf20Sopenharmony_ci * @vlan_id: VLAN ID to add
3498c2ecf20Sopenharmony_ci * @action: action to be performed on filter match
3508c2ecf20Sopenharmony_ci */
3518c2ecf20Sopenharmony_cienum ice_status ice_fltr_add_vlan(struct ice_vsi *vsi, u16 vlan_id,
3528c2ecf20Sopenharmony_ci				  enum ice_sw_fwd_act_type action)
3538c2ecf20Sopenharmony_ci{
3548c2ecf20Sopenharmony_ci	return ice_fltr_prepare_vlan(vsi, vlan_id, action,
3558c2ecf20Sopenharmony_ci				     ice_fltr_add_vlan_list);
3568c2ecf20Sopenharmony_ci}
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci/**
3598c2ecf20Sopenharmony_ci * ice_fltr_remove_vlan - remove VLAN filter
3608c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
3618c2ecf20Sopenharmony_ci * @vlan_id: filter VLAN to remove
3628c2ecf20Sopenharmony_ci * @action: action to remove
3638c2ecf20Sopenharmony_ci */
3648c2ecf20Sopenharmony_cienum ice_status ice_fltr_remove_vlan(struct ice_vsi *vsi, u16 vlan_id,
3658c2ecf20Sopenharmony_ci				     enum ice_sw_fwd_act_type action)
3668c2ecf20Sopenharmony_ci{
3678c2ecf20Sopenharmony_ci	return ice_fltr_prepare_vlan(vsi, vlan_id, action,
3688c2ecf20Sopenharmony_ci				     ice_fltr_remove_vlan_list);
3698c2ecf20Sopenharmony_ci}
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci/**
3728c2ecf20Sopenharmony_ci * ice_fltr_add_eth - add specyfic ethertype filter
3738c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
3748c2ecf20Sopenharmony_ci * @ethertype: ethertype of filter
3758c2ecf20Sopenharmony_ci * @flag: direction of packet to be filtered, Tx or Rx
3768c2ecf20Sopenharmony_ci * @action: action to be performed on filter match
3778c2ecf20Sopenharmony_ci */
3788c2ecf20Sopenharmony_cienum ice_status ice_fltr_add_eth(struct ice_vsi *vsi, u16 ethertype, u16 flag,
3798c2ecf20Sopenharmony_ci				 enum ice_sw_fwd_act_type action)
3808c2ecf20Sopenharmony_ci{
3818c2ecf20Sopenharmony_ci	return ice_fltr_prepare_eth(vsi, ethertype, flag, action,
3828c2ecf20Sopenharmony_ci				    ice_fltr_add_eth_list);
3838c2ecf20Sopenharmony_ci}
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci/**
3868c2ecf20Sopenharmony_ci * ice_fltr_remove_eth - remove ethertype filter
3878c2ecf20Sopenharmony_ci * @vsi: pointer to VSI struct
3888c2ecf20Sopenharmony_ci * @ethertype: ethertype of filter
3898c2ecf20Sopenharmony_ci * @flag: direction of filter
3908c2ecf20Sopenharmony_ci * @action: action to remove
3918c2ecf20Sopenharmony_ci */
3928c2ecf20Sopenharmony_cienum ice_status ice_fltr_remove_eth(struct ice_vsi *vsi, u16 ethertype,
3938c2ecf20Sopenharmony_ci				    u16 flag, enum ice_sw_fwd_act_type action)
3948c2ecf20Sopenharmony_ci{
3958c2ecf20Sopenharmony_ci	return ice_fltr_prepare_eth(vsi, ethertype, flag, action,
3968c2ecf20Sopenharmony_ci				    ice_fltr_remove_eth_list);
3978c2ecf20Sopenharmony_ci}
398