Skip to content

Commit fcf6cfc

Browse files
jacob-kellerJeff Kirsher
authored andcommitted
i40e: move check for avoiding VID=0 filters into i40e_vsi_add_vlan
In i40e_vsi_add_vlan we treat attempting to add VID=0 as an error, because it does not do what the caller might expect. We already special case VID=0 in i40e_vlan_rx_add_vid so that we avoid this error when adding the VLAN. This special casing is necessary so that we do not add the VLAN=0 filter since we don't want to stop receiving untagged traffic. Unfortunately, not all callers of i40e_vsi_add_vlan are aware of this, including when we add VLANs from a VF device. Rather than special casing every single caller of i40e_vsi_add_vlan, lets just move this check internally. This makes the code simpler because the caller does not need to be aware of how VLAN=0 is special, and we don't forget to add this check in new places. This fixes a harmless error message displaying when adding a VLAN from within a VF. The message was meaningless but there is no reason to confuse end users and system administrators, and this is now avoided. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent 841c950 commit fcf6cfc

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

‎drivers/net/ethernet/intel/i40e/i40e_main.c‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,9 +2595,20 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, u16 vid)
25952595
{
25962596
int err;
25972597

2598-
if (!vid || vsi->info.pvid)
2598+
if (vsi->info.pvid)
25992599
return -EINVAL;
26002600

2601+
/* The network stack will attempt to add VID=0, with the intention to
2602+
* receive priority tagged packets with a VLAN of 0. Our HW receives
2603+
* these packets by default when configured to receive untagged
2604+
* packets, so we don't need to add a filter for this case.
2605+
* Additionally, HW interprets adding a VID=0 filter as meaning to
2606+
* receive *only* tagged traffic and stops receiving untagged traffic.
2607+
* Thus, we do not want to actually add a filter for VID=0
2608+
*/
2609+
if (!vid)
2610+
return 0;
2611+
26012612
/* Locked once because all functions invoked below iterates list*/
26022613
spin_lock_bh(&vsi->mac_filter_hash_lock);
26032614
err = i40e_add_vlan_all_mac(vsi, vid);
@@ -2674,15 +2685,7 @@ static int i40e_vlan_rx_add_vid(struct net_device *netdev,
26742685
if (vid >= VLAN_N_VID)
26752686
return -EINVAL;
26762687

2677-
/* If the network stack called us with vid = 0 then
2678-
* it is asking to receive priority tagged packets with
2679-
* vlan id 0. Our HW receives them by default when configured
2680-
* to receive untagged packets so there is no need to add an
2681-
* extra filter for vlan 0 tagged packets.
2682-
*/
2683-
if (vid)
2684-
ret = i40e_vsi_add_vlan(vsi, vid);
2685-
2688+
ret = i40e_vsi_add_vlan(vsi, vid);
26862689
if (!ret)
26872690
set_bit(vid, vsi->active_vlans);
26882691

0 commit comments

Comments
 (0)