Commit fb05ba12 authored by Brett Creeley's avatar Brett Creeley Committed by Tony Nguyen
Browse files

ice: Introduce ice_vlan struct



Add a new struct for VLAN related information. Currently this holds
VLAN ID and priority values, but will be expanded to hold TPID value.
This reduces the changes necessary if any other values are added in
future. Remove the action argument from these calls as it's always
ICE_FWD_VSI.

Signed-off-by: default avatarBrett Creeley <brett.creeley@intel.com>
Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent bc42afa9
Loading
Loading
Loading
Loading
+13 −22
Original line number Diff line number Diff line
@@ -203,21 +203,20 @@ ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct list_head *list,
 * ice_fltr_add_vlan_to_list - add VLAN filter info to exsisting list
 * @vsi: pointer to VSI struct
 * @list: list to add filter info to
 * @vlan_id: VLAN ID to add
 * @action: filter action
 * @vlan: VLAN filter details
 */
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)
			  struct ice_vlan *vlan)
{
	struct ice_fltr_info info = { 0 };

	info.flag = ICE_FLTR_TX;
	info.src_id = ICE_SRC_ID_VSI;
	info.lkup_type = ICE_SW_LKUP_VLAN;
	info.fltr_act = action;
	info.fltr_act = ICE_FWD_TO_VSI;
	info.vsi_handle = vsi->idx;
	info.l_data.vlan.vlan_id = vlan_id;
	info.l_data.vlan.vlan_id = vlan->vid;

	return ice_fltr_add_entry_to_list(ice_pf_to_dev(vsi->back), &info,
					  list);
@@ -310,19 +309,17 @@ ice_fltr_prepare_mac_and_broadcast(struct ice_vsi *vsi, const u8 *mac,
/**
 * ice_fltr_prepare_vlan - add or remove VLAN filter
 * @vsi: pointer to VSI struct
 * @vlan_id: VLAN ID to add
 * @action: action to be performed on filter match
 * @vlan: VLAN filter details
 * @vlan_action: pointer to add or remove VLAN function
 */
static int
ice_fltr_prepare_vlan(struct ice_vsi *vsi, u16 vlan_id,
		      enum ice_sw_fwd_act_type action,
ice_fltr_prepare_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan,
		      int (*vlan_action)(struct ice_vsi *, struct list_head *))
{
	LIST_HEAD(tmp_list);
	int result;

	if (ice_fltr_add_vlan_to_list(vsi, &tmp_list, vlan_id, action))
	if (ice_fltr_add_vlan_to_list(vsi, &tmp_list, vlan))
		return -ENOMEM;

	result = vlan_action(vsi, &tmp_list);
@@ -395,27 +392,21 @@ int ice_fltr_remove_mac(struct ice_vsi *vsi, const u8 *mac,
/**
 * ice_fltr_add_vlan - add single VLAN filter
 * @vsi: pointer to VSI struct
 * @vlan_id: VLAN ID to add
 * @action: action to be performed on filter match
 * @vlan: VLAN filter details
 */
int ice_fltr_add_vlan(struct ice_vsi *vsi, u16 vlan_id,
		      enum ice_sw_fwd_act_type action)
int ice_fltr_add_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan)
{
	return ice_fltr_prepare_vlan(vsi, vlan_id, action,
				     ice_fltr_add_vlan_list);
	return ice_fltr_prepare_vlan(vsi, vlan, ice_fltr_add_vlan_list);
}

/**
 * ice_fltr_remove_vlan - remove VLAN filter
 * @vsi: pointer to VSI struct
 * @vlan_id: filter VLAN to remove
 * @action: action to remove
 * @vlan: VLAN filter details
 */
int ice_fltr_remove_vlan(struct ice_vsi *vsi, u16 vlan_id,
			 enum ice_sw_fwd_act_type action)
int ice_fltr_remove_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan)
{
	return ice_fltr_prepare_vlan(vsi, vlan_id, action,
				     ice_fltr_remove_vlan_list);
	return ice_fltr_prepare_vlan(vsi, vlan, ice_fltr_remove_vlan_list);
}

/**
+4 −6
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@
#ifndef _ICE_FLTR_H_
#define _ICE_FLTR_H_

#include "ice_vlan.h"

void ice_fltr_free_list(struct device *dev, struct list_head *h);
int
ice_fltr_set_vlan_vsi_promisc(struct ice_hw *hw, struct ice_vsi *vsi,
@@ -32,12 +34,8 @@ ice_fltr_remove_mac(struct ice_vsi *vsi, const u8 *mac,
		    enum ice_sw_fwd_act_type action);
int ice_fltr_remove_mac_list(struct ice_vsi *vsi, struct list_head *list);

int
ice_fltr_add_vlan(struct ice_vsi *vsi, u16 vid,
		  enum ice_sw_fwd_act_type action);
int
ice_fltr_remove_vlan(struct ice_vsi *vsi, u16 vid,
		     enum ice_sw_fwd_act_type action);
int ice_fltr_add_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan);
int ice_fltr_remove_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan);

int
ice_fltr_add_eth(struct ice_vsi *vsi, u16 ethertype, u16 flag,
+4 −1
Original line number Diff line number Diff line
@@ -3921,7 +3921,10 @@ int ice_set_link(struct ice_vsi *vsi, bool ena)
 */
int ice_vsi_add_vlan_zero(struct ice_vsi *vsi)
{
	return vsi->vlan_ops.add_vlan(vsi, 0, ICE_FWD_TO_VSI);
	struct ice_vlan vlan;

	vlan = ICE_VLAN(0, 0);
	return vsi->vlan_ops.add_vlan(vsi, &vlan);
}

/**
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#define _ICE_LIB_H_

#include "ice.h"
#include "ice_vlan.h"

const char *ice_vsi_type_str(enum ice_vsi_type vsi_type);

+6 −2
Original line number Diff line number Diff line
@@ -3413,6 +3413,7 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto,
{
	struct ice_netdev_priv *np = netdev_priv(netdev);
	struct ice_vsi *vsi = np->vsi;
	struct ice_vlan vlan;
	int ret;

	/* VLAN 0 is added by default during load/reset */
@@ -3429,7 +3430,8 @@ ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto,
	/* Add a switch rule for this VLAN ID so its corresponding VLAN tagged
	 * packets aren't pruned by the device's internal switch on Rx
	 */
	ret = vsi->vlan_ops.add_vlan(vsi, vid, ICE_FWD_TO_VSI);
	vlan = ICE_VLAN(vid, 0);
	ret = vsi->vlan_ops.add_vlan(vsi, &vlan);
	if (!ret)
		set_bit(ICE_VSI_VLAN_FLTR_CHANGED, vsi->state);

@@ -3450,6 +3452,7 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,
{
	struct ice_netdev_priv *np = netdev_priv(netdev);
	struct ice_vsi *vsi = np->vsi;
	struct ice_vlan vlan;
	int ret;

	/* don't allow removal of VLAN 0 */
@@ -3459,7 +3462,8 @@ ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto,
	/* Make sure VLAN delete is successful before updating VLAN
	 * information
	 */
	ret = vsi->vlan_ops.del_vlan(vsi, vid);
	vlan = ICE_VLAN(vid, 0);
	ret = vsi->vlan_ops.del_vlan(vsi, &vlan);
	if (ret)
		return ret;

Loading