ice: in VEB, prevent "cross-vlan" traffic
Subsystems (3)
v4 cover ice: in VEB, prevent "cross-vlan" traffic
Currently, packets that match MAC address of a VF will be sent to loopback even if they would cross VLAN boundaries. Effectively, this drops them. In this patch series, we aim to address this behaviour by adding MAC,VLAN to complement what MAC-only filters do to select packets for loopback.
To reproduce the issue have an E810 ($pfa) connected to another adapter ($pfb), then:
# echo 2 >/sys/class/net/$pfa/device/sriov_numvfs
# ip l set $pfa vf 0 vlan 4
# ip l set $pfa vf 1 vlan 7
# ip l set $pfa_vf0 netns $pfa_vf0_netns up
# ip l set $pfa_vf1 netns $pfa_vf1_netns up
# ip netns exec $pfa_vf0_netns ip a add 10.0.0.1/24 dev $pfa_vf0
# ip netns exec $pfa_vf1_netns ip a add 10.0.0.2/24 dev $pfa_vf1And for the $pfb:
# echo 2 >/sys/class/net/$pfb/device/sriov_numvfs
# ip l set $pfb vf 0 trust on spoof off vlan 4
# ip l set $pfb vf 1 trust on spoof off vlan 7
# ip l add $br type bridge
# ip l set $pfb_vf0 master $br up
# ip l set $pfb_vf1 master $br up
# ip l set $br upWe expect $pfa_vf0 to be able to reach $pfa_vf1 through the $br on the link partner. Instead, ARP is unable to resolve 10.0.0.2/24. ARP request is fine because it's broadcastd and bounces off $br, but ARP reply is stuck in the internal switch because the destination MAC matches $pfa_vf0 and filter restricts it to the loopback.
In testing I used: ip utility, iproute2-6.1.0, libbpf 1.3.0
Changes in v4:
- Removed "ice: do not check for zero mac when creating mac filters" patch.
Changes in v3:
- Improve structure of reproduction description in cover letter.
- LB_LAN masks and values no longer rely on boolean promotion.
- ice_fill_sw_info() deals with u8 the entire time instead of building building lb_en and lan_en values at the end from booleans.
- Refer to reproduction in cover letter in current 4/7.
- Fixed some slip-ups "this patch" and "this commit" in commit messages across the series. I did not consider this change for reviewed-by drop.
Changes in v2:
- Use FIELD_GET et al. when handling fi.lb_en and fi.lan_en.
- Rename /LB_LAN/ s/_MASK/_M/ because one of uses would need to break line.
- Close open parenthesis in ice_vsi_update_bridge_mode() description.
- Explain returns in ice_vsi_update_bridge_mode().
v3: https://lore.kernel.org/intel-wired-lan/[email protected]/T/
v2: https://lore.kernel.org/intel-wired-lan/[email protected]/T/
v1: https://lore.kernel.org/intel-wired-lan/[email protected]/T/
Jakub Slepecki (6):
ice: in dvm, use outer VLAN in MAC,VLAN lookup
ice: allow creating mac,vlan filters along mac filters
ice: allow overriding lan_en, lb_en in switch
ice: update mac,vlan rules when toggling between VEB and VEPA
ice: add functions to query for vsi's pvids
ice: in VEB, prevent "cross-vlan" traffic from hitting loopback
Michal Swiatkowski (1):
ice: add mac vlan to filter API
drivers/net/ethernet/intel/ice/ice_fltr.c | 104 ++++++++++++++- drivers/net/ethernet/intel/ice/ice_fltr.h | 10 + drivers/net/ethernet/intel/ice/ice_lib.c | 56 ++++++++ drivers/net/ethernet/intel/ice/ice_lib.h | 2 drivers/net/ethernet/intel/ice/ice_main.c | 56 ++++++-- drivers/net/ethernet/intel/ice/ice_switch.c | 83 ++++++++--- drivers/net/ethernet/intel/ice/ice_switch.h | 24 ++- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 8 - drivers/net/ethernet/intel/ice/ice_vlan_mode.c | 12 + 9 files changed, 306 insertions(+), 49 deletions(-)
Signature · 1 line
2.43.0
PATCH v4 1/7 ice: in dvm, use outer VLAN in MAC,VLAN lookup
In double VLAN mode (DVM), outer VLAN is located a word earlier in the field vector compared to the single VLAN mode. We already modify ICE_SW_LKUP_VLAN to use it but ICE_SW_LKUP_MAC_VLAN was left untouched, causing the lookup to match any packet with one or no layer of Dot1q. This change enables to fix cross-vlan loopback traffic using MAC,VLAN lookups.
---
No changes in v4.
No changes in v3.
No changes in v2.
--- drivers/net/ethernet/intel/ice/ice_vlan_mode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/ethernet/intel/ice/ice_vlan_mode.c +12 -0
@@ -198,6 +198,7 @@ static bool ice_is_dvm_supported(struct ice_hw *hw)#define ICE_SW_LKUP_VLAN_LOC_LKUP_IDX 1#define ICE_SW_LKUP_VLAN_PKT_FLAGS_LKUP_IDX 2#define ICE_SW_LKUP_PROMISC_VLAN_LOC_LKUP_IDX 2 +#define ICE_SW_LKUP_MAC_VLAN_LOC_LKUP_IDX 4#define ICE_PKT_FLAGS_0_TO_15_FV_IDX 1static struct ice_update_recipe_lkup_idx_params ice_dvm_dflt_recipes[] = { {
@@ -234,6 +235,17 @@ static struct ice_update_recipe_lkup_idx_params ice_dvm_dflt_recipes[] = { .mask_valid = false, /* use pre-existing mask */ .lkup_idx = ICE_SW_LKUP_PROMISC_VLAN_LOC_LKUP_IDX, }, + { +/* Similarly to ICE_SW_LKUP_VLAN, change to outer/single VLAN in +* DVM +*/ + .rid = ICE_SW_LKUP_MAC_VLAN, + .fv_idx = ICE_EXTERNAL_VLAN_ID_FV_IDX, + .ignore_valid = true, + .mask = 0, + .mask_valid = false, + .lkup_idx = ICE_SW_LKUP_MAC_VLAN_LOC_LKUP_IDX, + }, };/**
Signature · 1 line
2.43.0
RE: [Intel-wired-lan] [PATCH iwl-next v4 1/7] ice: in dvm, use outer VLAN in MAC, VLAN lookup
Quoted 65 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jakub Slepecki
Sent: Wednesday, February 4, 2026 4:44 PM
To: [email protected]
Cc: [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Slepecki, Jakub <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4 1/7] ice: in dvm, use outer VLAN in MAC, VLAN lookupIn double VLAN mode (DVM), outer VLAN is located a word earlier in the field vector compared to the single VLAN mode. We already modify
ICE_SW_LKUP_VLANto use it butICE_SW_LKUP_MAC_VLANwas left untouched, causing the lookup to match any packet with one or no layer of Dot1q. This change enables to fix cross-vlan loopback traffic using MAC,VLAN lookups.Reviewed-by Aleksandr Loktionov <[email protected]>Reviewed-by Michal Swiatkowski <[email protected]>Signed-off-by Jakub Slepecki <[email protected]>---
No changes in v4.
No changes in v3.
No changes in v2.--- drivers/net/ethernet/intel/ice/ice_vlan_mode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/net/ethernet/intel/ice/ice_vlan_mode.c +3
-0@@ -198,6 +198,7 @@ static bool ice_is_dvm_supported(struct ice_hw *hw)#define ICE_SW_LKUP_VLAN_LOC_LKUP_IDX 1#define ICE_SW_LKUP_VLAN_PKT_FLAGS_LKUP_IDX 2#define ICE_SW_LKUP_PROMISC_VLAN_LOC_LKUP_IDX 2 +#define ICE_SW_LKUP_MAC_VLAN_LOC_LKUP_IDX 4#define ICE_PKT_FLAGS_0_TO_15_FV_IDX 1static struct ice_update_recipe_lkup_idx_params ice_dvm_dflt_recipes[] = { {@@ -234,6 +235,17 @@ static struct ice_update_recipe_lkup_idx_params ice_dvm_dflt_recipes[] = { .mask_valid = false, /* use pre-existing mask */ .lkup_idx = ICE_SW_LKUP_PROMISC_VLAN_LOC_LKUP_IDX, }, + { +/* Similarly to ICE_SW_LKUP_VLAN, change to outer/single VLAN in
drivers/net/ethernet/intel/ice/ice_vlan_mode.c +9
-1+* DVM +*/ + .rid = ICE_SW_LKUP_MAC_VLAN, + .fv_idx = ICE_EXTERNAL_VLAN_ID_FV_IDX, + .ignore_valid = true, + .mask = 0, + .mask_valid = false, + .lkup_idx = ICE_SW_LKUP_MAC_VLAN_LOC_LKUP_IDX, + }, };/** --
Quoted 1 line
2.43.0
PATCH v4 2/7 ice: allow creating mac,vlan filters along mac filters
In reply to Jakub SlepeckiAmong other uses, MAC filters are currently used to forward loopback traffic between VSIs. However, they only match destination MAC addresses making them prone to mistakes when handling traffic within multiple VLANs and especially across the boundaries.
Allows the driver to create MAC,VLAN filters in the same flow as MAC-only filters completely interchangeably. This is intended to be used to forward the loopback traffic only within the boundaries of particular VLANs.
---
No changes in v4.
No changes in v3.
No changes in v2.
--- drivers/net/ethernet/intel/ice/ice_switch.c | 48 ++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_switch.c +38 -10
@@ -3606,6 +3606,29 @@ bool ice_vlan_fltr_exist(struct ice_hw *hw, u16 vlan_id, u16 vsi_handle)return false; } +/** +* ice_fltr_mac_address - Find MAC in filter +* @dst: output MAC address +* @info: information struct for the filter in question +* +* Return: 0 for success, %-ENXIO if no address was found in the filter +* information. +*/ +static +int ice_fltr_mac_address (u8 *dst,struct ice_fltr_info *info) +{ +switch (info->lkup_type) { +case ICE_SW_LKUP_MAC : +ether_addr_copy (dst, info->l_data.mac.mac_addr); +return 0 ; +case ICE_SW_LKUP_MAC_VLAN : +ether_addr_copy (dst, info->l_data.mac_vlan.mac_addr); +return 0 ; +default : +return -ENXIO ; + } +} +/** * ice_add_mac - Add a MAC address based filter rule * @hw: pointer to the hardware structure
@@ -3614,16 +3637,19 @@ bool ice_vlan_fltr_exist(struct ice_hw *hw, u16 vlan_id, u16 vsi_handle)int ice_add_mac (struct ice_hw *hw,struct list_head *m_list) {struct ice_fltr_list_entry *m_list_itr; -int status =0 ; +int err;if (!m_list || !hw)return -EINVAL ;list_for_each_entry (m_list_itr, m_list, list_entry) { -u8 *add = &m_list_itr->fltr_info.l_data.mac.mac_addr[0 ]; +u8 addr[ETH_ALEN ];u16 vsi_handle;u16 hw_vsi_id; + err =ice_fltr_mac_address (addr, &m_list_itr->fltr_info); +if (err ||is_zero_ether_addr (addr)) +return -EINVAL ; m_list_itr->fltr_info.flag =ICE_FLTR_TX ; vsi_handle = m_list_itr->fltr_info.vsi_handle;if (!ice_is_vsi_valid (hw, vsi_handle))
@@ -3634,17 +3660,19 @@ int ice_add_mac(struct ice_hw *hw, struct list_head *m_list)if (m_list_itr->fltr_info.src_id !=ICE_SRC_ID_VSI )return -EINVAL ; m_list_itr->fltr_info.src = hw_vsi_id; -if (m_list_itr->fltr_info.lkup_type !=ICE_SW_LKUP_MAC || -is_zero_ether_addr (add)) +if (m_list_itr->fltr_info.lkup_type !=ICE_SW_LKUP_MAC && + m_list_itr->fltr_info.lkup_type !=ICE_SW_LKUP_MAC_VLAN )return -EINVAL ; - m_list_itr->status =ice_add_rule_internal (hw,ICE_SW_LKUP_MAC , - m_list_itr); + m_list_itr->status = +ice_add_rule_internal (hw, + m_list_itr->fltr_info.lkup_type, + m_list_itr);if (m_list_itr->status)return m_list_itr->status; } -return status; +return 0 ; }/**
@@ -4055,7 +4083,7 @@ int ice_remove_mac(struct ice_hw *hw, struct list_head *m_list)enum ice_sw_lkup_type l_type = list_itr->fltr_info.lkup_type;u16 vsi_handle; -if (l_type !=ICE_SW_LKUP_MAC ) +if (l_type !=ICE_SW_LKUP_MAC && l_type !=ICE_SW_LKUP_MAC_VLAN )return -EINVAL ; vsi_handle = list_itr->fltr_info.vsi_handle;
@@ -4066,7 +4094,7 @@ int ice_remove_mac(struct ice_hw *hw, struct list_head *m_list)ice_get_hw_vsi_num (hw, vsi_handle); list_itr->status =ice_remove_rule_internal (hw, -ICE_SW_LKUP_MAC , + l_type, list_itr);if (list_itr->status)return list_itr->status;
@@ -4507,6 +4535,7 @@ ice_remove_vsi_lkup_fltr(struct ice_hw *hw, u16 vsi_handle,switch (lkup) {case ICE_SW_LKUP_MAC : +case ICE_SW_LKUP_MAC_VLAN :ice_remove_mac (hw, &remove_list_head);break ;case ICE_SW_LKUP_VLAN :
@@ -4516,7 +4545,6 @@ ice_remove_vsi_lkup_fltr(struct ice_hw *hw, u16 vsi_handle,case ICE_SW_LKUP_PROMISC_VLAN :ice_remove_promisc (hw, lkup, &remove_list_head);break ; -case ICE_SW_LKUP_MAC_VLAN :case ICE_SW_LKUP_ETHERTYPE :case ICE_SW_LKUP_ETHERTYPE_MAC :case ICE_SW_LKUP_DFLT :
Signature · 1 line
2.43.0
RE: [Intel-wired-lan] [PATCH iwl-next v4 2/7] ice: allow creating mac, vlan filters along mac filters
Quoted 40 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jakub Slepecki
Sent: Wednesday, February 4, 2026 4:44 PM
To: [email protected]
Cc: [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Slepecki, Jakub <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4 2/7] ice: allow creating mac, vlan filters along mac filtersAmong other uses, MAC filters are currently used to forward loopback traffic between VSIs. However, they only match destination MAC addresses making them prone to mistakes when handling traffic within multiple VLANs and especially across the boundaries.
Allows the driver to create MAC,VLAN filters in the same flow as MAC-only filters completely interchangeably. This is intended to be used to forward the loopback traffic only within the boundaries of particular VLANs.
Reviewed-by Michal Swiatkowski <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Jakub Slepecki <[email protected]>---
No changes in v4.
No changes in v3.
No changes in v2.--- drivers/net/ethernet/intel/ice/ice_switch.c | 48 ++++++++++++++++----- 1 file changed, 38 insertions(+), 10 deletions(-)drivers/net/ethernet/intel/ice/ice_switch.c +0
-0
drivers/net/ethernet/intel/ice/ice_switch.c bool ice_vlan_fltr_exist(struct ice_hw *hw, u16 · line 3606
Quoted 1 line
drivers/net/ethernet/intel/ice/ice_switch.c +0
-0@@ -3606,6 +3606,29 @@ bool ice_vlan_fltr_exist(struct ice_hw *hw, u16 vlan_id, u16 vsi_handle)
PATCH v4 3/7 ice: allow overriding lan_en, lb_en in switch
In reply to Jakub SlepeckiCurrently, lan_en and lb_en are determined based on switching mode, destination MAC, and the lookup type, action type and flags of the rule in question. This gives little to no options for the user (such as ice_fltr.c) to enforce rules to behave in a specific way.
Such functionality is needed to work with pairs of rules, for example, when handling MAC forward to LAN together with MAC,VLAN forward to loopback rules pair. This case could not be easily deduced in a context of a single filter without adding some guessing logic or a specialized flag.
Add a slightly more generic flag to the lan_en and lb_en themselves for the ice_fltr.c to request specific destination flags later on, for example, to override both values:
struct ice_fltr_info fi;
fi.lb_en = ICE_FLTR_INFO_LB_LAN_FORCE_ENABLED;
fi.lan_en = ICE_FLTR_INFO_LB_LAN_FORCE_DISABLED;---
Added R-B from Aleksandr as we talked live and he reviewed the changes.
No changes in v4.
Changes in v3:
- LB_LAN masks and values no longer rely on boolean promotion.
- ice_fill_sw_info() deals with u8 the entire time instead of building building lb_en and lan_en values at the end from booleans.
Changes in v2:
- Use FIELD_GET et al. when handling fi.lb_en and fi.lan_en.
- Rename /LB_LAN/s/_MASK/_M/ because one of uses would need to break line
--- drivers/net/ethernet/intel/ice/ice_switch.c | 25 +++++++++++++-------- drivers/net/ethernet/intel/ice/ice_switch.h | 19 +++++++++++++--- 2 files changed, 32 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_switch.c +16 -9
@@ -2534,12 +2534,14 @@ int ice_get_initial_sw_cfg(struct ice_hw *hw)* * This helper function populates the lb_en and lan_en elements of the provided * ice_fltr_info struct using the switch's type and characteristics of the -* switch rule being configured. +* switch rule being configured. Elements are updated only if their FORCE bit +* is not set. */ static void ice_fill_sw_info (struct ice_hw *hw,struct ice_fltr_info *fi) { - fi->lb_en = false; - fi->lan_en = false; +u8 lan_en = fi->lan_en; +u8 lb_en = fi->lb_en; + if ((fi->flag & ICE_FLTR_TX) && (fi->fltr_act == ICE_FWD_TO_VSI || fi->fltr_act == ICE_FWD_TO_VSI_LIST ||
@@ -2549,7 +2551,7 @@ static void ice_fill_sw_info(struct ice_hw *hw, struct ice_fltr_info *fi)* packets to the internal switch that will be dropped. */ if (fi->lkup_type !=ICE_SW_LKUP_VLAN ) - fi->lb_en = true; +FIELD_MODIFY (ICE_FLTR_INFO_LB_LAN_VALUE_M , &lb_en,1 );/* Set lan_en to TRUE if * 1. The switch is a VEB AND
@@ -2578,14 +2580,19 @@ static void ice_fill_sw_info(struct ice_hw *hw, struct ice_fltr_info *fi) !is_unicast_ether_addr(fi->l_data.mac.mac_addr)) || (fi->lkup_type == ICE_SW_LKUP_MAC_VLAN && !is_unicast_ether_addr(fi->l_data.mac.mac_addr))) - fi->lan_en = true; +FIELD_MODIFY (ICE_FLTR_INFO_LB_LAN_VALUE_M , + &lan_en,1 ); }else { - fi->lan_en = true; +FIELD_MODIFY (ICE_FLTR_INFO_LB_LAN_VALUE_M , &lan_en,1 ); } }if (fi->flag &ICE_FLTR_TX_ONLY ) - fi->lan_en = false; +FIELD_MODIFY (ICE_FLTR_INFO_LB_LAN_VALUE_M , &lan_en,0 ); +if (!FIELD_GET (ICE_FLTR_INFO_LB_LAN_FORCE_M , lb_en)) + fi->lb_en = lb_en; +if (!FIELD_GET (ICE_FLTR_INFO_LB_LAN_FORCE_M , lan_en)) + fi->lan_en = lan_en; }/**
@@ -2669,9 +2676,9 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,return ; } -if (f_info->lb_en) +if (FIELD_GET (ICE_FLTR_INFO_LB_LAN_VALUE_M , f_info->lb_en)) act |=ICE_SINGLE_ACT_LB_ENABLE ; -if (f_info->lan_en) +if (FIELD_GET (ICE_FLTR_INFO_LB_LAN_VALUE_M , f_info->lan_en)) act |=ICE_SINGLE_ACT_LAN_ENABLE ;switch (f_info->lkup_type) {
drivers/net/ethernet/intel/ice/ice_switch.h +16 -3
@@ -72,6 +72,14 @@ enum ice_src_id { ICE_SRC_ID_LPORT, }; +#define ICE_FLTR_INFO_LB_LAN_VALUE_M BIT(0) +#define ICE_FLTR_INFO_LB_LAN_FORCE_M BIT(1) +#define ICE_FLTR_INFO_LB_LAN_FORCE_ENABLED \ + (FIELD_PREP_CONST(ICE_FLTR_INFO_LB_LAN_VALUE_M, 1) | \ + FIELD_PREP_CONST(ICE_FLTR_INFO_LB_LAN_FORCE_M, 1)) +#define ICE_FLTR_INFO_LB_LAN_FORCE_DISABLED \ + (FIELD_PREP_CONST(ICE_FLTR_INFO_LB_LAN_FORCE_M, 1)) +struct ice_fltr_info {/* Look up information: how to look up packet */ enum ice_sw_lkup_type lkup_type;
@@ -131,9 +139,14 @@ struct ice_fltr_info {*/ u8 qgrp_size; -/* Rule creations populate these indicators basing on the switch type */ -u8 lb_en;/* Indicate if packet can be looped back */ -u8 lan_en;/* Indicate if packet can be forwarded to the uplink */ +/* Following members have two bits: VALUE and FORCE. Rule creation will +* populate VALUE bit of these members based on switch type, but only if +* their FORCE bit is not set. +* +* See ICE_FLTR_INFO_LB_LAN_VALUE_M and ICE_FLTR_INFO_LB_LAN_FORCE_M. +*/ +u8 lb_en;/* VALUE bit: packet can be looped back */ +u8 lan_en;/* VALUE bit: packet can be forwarded to the uplink */ };struct ice_update_recipe_lkup_idx_params {
Signature · 1 line
2.43.0
RE: [Intel-wired-lan] [PATCH iwl-next v4 3/7] ice: allow overriding lan_en, lb_en in switch
drivers/net/ethernet/intel/ice/ice_switch.c int ice_get_initial_sw_cfg(struct ice_hw *hw)
Quoted 58 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jakub Slepecki
Sent: Wednesday, February 4, 2026 4:44 PM
To: [email protected]
Cc: [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Slepecki, Jakub <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4 3/7] ice: allow overridinglan_en,lb_enin switchCurrently,
lan_enandlb_enare determined based on switching mode, destination MAC, and the lookup type, action type and flags of the rule in question. This gives little to no options for the user (such asice_fltr.c) to enforce rules to behave in a specific way.Such functionality is needed to work with pairs of rules, for example, when handling MAC forward to LAN together with MAC,VLAN forward to loopback rules pair. This case could not be easily deduced in a context of a single filter without adding some guessing logic or a specialized flag.
Add a slightly more generic flag to the
lan_enandlb_enthemselves for theice_fltr.cto request specific destination flags later on, for example, to override both values:struct ice_fltr_info fi; fi.lb_en = ICE_FLTR_INFO_LB_LAN_FORCE_ENABLED; fi.lan_en = ICE_FLTR_INFO_LB_LAN_FORCE_DISABLED;Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Jakub Slepecki <[email protected]>---
Added R-B from Aleksandr as we talked live and he reviewed the changes.No changes in v4.
Changes in v3:
-LB_LANmasks and values no longer rely on boolean promotion.
-ice_fill_sw_info()deals with u8 the entire time instead of building buildinglb_enandlan_envalues at the end from booleans.Changes in v2:
- UseFIELD_GETet al. when handling fi.lb_en and fi.lan_en.
- Rename /LB_LAN/s/_MASK/_M/ because one of uses would need to break line--- drivers/net/ethernet/intel/ice/ice_switch.c | 25 +++++++++++++-------- drivers/net/ethernet/intel/ice/ice_switch.h | 19 +++++++++++++--- 2 files changed, 32 insertions(+), 12 deletions(-)drivers/net/ethernet/intel/ice/ice_switch.c +0
-0@@ -2534,12 +2534,14 @@ int ice_get_initial_sw_cfg(struct ice_hw *hw)
PATCH v4 4/7 ice: update mac,vlan rules when toggling between VEB and VEPA
In reply to Jakub SlepeckiWhen changing into VEPA mode MAC rules are modified to forward all traffic to the wire instead of allowing some packets to go into the loopback. MAC,VLAN rules may and will also be used to forward loopback traffic in VEB, so when we switch to VEPA, we want them to behave similarly to MAC-only rules.
ice_vsi_update_bridge_mode() will now attempt a rollback of switch filters in case an update fails. If the rollback also fails, we will now return the rollback error instead of the initial error.
---
Testing hints:
MAC,VLAN rules are created only if entire series is applied. The easiest way to test that rules were adjusted is to run traffic and observe what packets are sent to LAN. VEPA is expected to behave same as before the series. VEB is expected to (a) behave like VEPA if loopback traffic would cross VLANs, or (b) behave as before. Traffic from/to external hosts is expected to remain unchanged.
Refer to cover letter (0/7) for full network configuration. To change hwmode use:
# bridge link set dev $pf hwmode {veb,vepa}No changes in v4.
Changes in v3:
- Refer to reproduction in cover letter in current 4/7.
Changes in v2:
- Close open parenthesis in ice_vsi_update_bridge_mode() description.
- Explain returns in ice_vsi_update_bridge_mode().
--- drivers/net/ethernet/intel/ice/ice_main.c | 48 +++++++++++++++++---- drivers/net/ethernet/intel/ice/ice_switch.c | 8 ++-- drivers/net/ethernet/intel/ice/ice_switch.h | 3 +- 3 files changed, 46 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +39 -9
@@ -8208,8 +8208,16 @@ static int ice_vsi_update_bridge_mode(struct ice_vsi *vsi, u16 bmode)* * Sets the bridge mode (VEB/VEPA) of the switch to which the netdev (VSI) is * hooked up to. Iterates through the PF VSI list and sets the loopback mode (if -* not already set for all VSIs connected to this switch. And also update the +* not already set for all VSIs connected to this switch). And also update the * unicast switch filter rules for the corresponding switch of the netdev. +* +* Return: +* * %0 if mode was set, propagated to VSIs, and changes to filters were all +* successful, +* * %-EINVAL if requested netlink attributes or bridge mode were invalid, +* * otherwise an error from VSI update, filter rollback, or filter update is +* forwarded. This may include %-EINVAL. See ice_vsi_update_bridge_mode() and +* ice_update_sw_rule_bridge_mode(). */ static int ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
@@ -8219,8 +8227,8 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,struct ice_pf *pf =ice_netdev_to_pf (dev);struct nlattr *attr, *br_spec;struct ice_hw *hw = &pf->hw; +int rem, v, rb_err, err =0 ;struct ice_sw *pf_sw; -int rem, v, err =0 ; pf_sw = pf->first_sw;/* find the attribute in the netlink message */
@@ -8230,6 +8238,7 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,nla_for_each_nested_type (attr,IFLA_BRIDGE_MODE , br_spec, rem) {__u16 mode =nla_get_u16 (attr); +u8 old_evb_veb = hw->evb_veb;if (mode !=BRIDGE_MODE_VEPA && mode !=BRIDGE_MODE_VEB )return -EINVAL ;
@@ -8251,17 +8260,38 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,/* Update the unicast switch filter rules for the corresponding * switch of the netdev */ - err =ice_update_sw_rule_bridge_mode (hw); + err =ice_update_sw_rule_bridge_mode (hw,ICE_SW_LKUP_MAC ); +if (err) { +/* evb_veb is expected to be already reverted in error +* path because of the potential rollback. +*/ + hw->evb_veb = old_evb_veb; + goto err_without_rollback; + } + err =ice_update_sw_rule_bridge_mode (hw,ICE_SW_LKUP_MAC_VLAN );if (err) { -netdev_err (dev,"switch rule update failed, mode = %d err %d aq_err %s\n" , - mode, err, +/* ice_update_sw_rule_bridge_mode looks this up, so we +* must revert it before attempting a rollback. +*/ + hw->evb_veb = old_evb_veb; + goto err_rollback_mac; + } + pf_sw->bridge_mode = mode; +continue ; + +err_rollback_mac: + rb_err =ice_update_sw_rule_bridge_mode (hw,ICE_SW_LKUP_MAC ); +if (rb_err) { +netdev_err (dev,"switch rule update failed, mode = %d err %d; rollback failed, err %d aq_err %s\n" , + mode, err, rb_err,libie_aq_str (hw->adminq.sq_last_status)); -/* revert hw->evb_veb */ - hw->evb_veb = (pf_sw->bridge_mode ==BRIDGE_MODE_VEB ); -return err; +return rb_err; } - pf_sw->bridge_mode = mode; +err_without_rollback: +netdev_err (dev,"switch rule update failed, mode = %d err %d aq_err %s\n" , + mode, err,libie_aq_str (hw->adminq.sq_last_status)); +return err; }return 0 ;
drivers/net/ethernet/intel/ice/ice_switch.c +5 -3
@@ -3067,10 +3067,12 @@ ice_update_pkt_fwd_rule(struct ice_hw *hw, struct ice_fltr_info *f_info)/** * ice_update_sw_rule_bridge_mode * @hw: pointer to the HW struct +* @lkup: recipe/lookup type to update * * Updates unicast switch filter rules based on VEB/VEPA mode */ -int ice_update_sw_rule_bridge_mode (struct ice_hw *hw) +int ice_update_sw_rule_bridge_mode (struct ice_hw *hw, +enum ice_sw_lkup_type lkup) {struct ice_switch_info *sw = hw->switch_info;struct ice_fltr_mgmt_list_entry *fm_entry;
@@ -3078,8 +3080,8 @@ int ice_update_sw_rule_bridge_mode(struct ice_hw *hw)struct mutex *rule_lock;/* Lock to protect filter rule list */ int status =0 ; - rule_lock = &sw->recp_list[ICE_SW_LKUP_MAC ].filt_rule_lock; - rule_head = &sw->recp_list[ICE_SW_LKUP_MAC ].filt_rules; + rule_lock = &sw->recp_list[lkup].filt_rule_lock; + rule_head = &sw->recp_list[lkup].filt_rules;mutex_lock (rule_lock);list_for_each_entry (fm_entry, rule_head, list_entry) {
drivers/net/ethernet/intel/ice/ice_switch.h +2 -1
@@ -366,7 +366,8 @@ int ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, struct ice_adv_rule_info *rinfo, struct ice_rule_query_data *added_entry); -int ice_update_sw_rule_bridge_mode (struct ice_hw *hw); +int ice_update_sw_rule_bridge_mode (struct ice_hw *hw, +enum ice_sw_lkup_type lkup);int ice_add_vlan (struct ice_hw *hw,struct list_head *m_list);int ice_remove_vlan (struct ice_hw *hw,struct list_head *v_list);int ice_add_mac (struct ice_hw *hw,struct list_head *m_lst);
Signature · 1 line
2.43.0
RE: [Intel-wired-lan] [PATCH iwl-next v4 4/7] ice: update mac, vlan rules when toggling between VEB and VEPA
drivers/net/ethernet/intel/ice/ice_main.c static int ice_vsi_update_bridge_mode(struct ice_vsi
Quoted 59 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jakub Slepecki
Sent: Wednesday, February 4, 2026 4:44 PM
To: [email protected]
Cc: [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Slepecki, Jakub <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4 4/7] ice: update mac, vlan rules when toggling between VEB and VEPAWhen changing into VEPA mode MAC rules are modified to forward all traffic to the wire instead of allowing some packets to go into the loopback. MAC,VLAN rules may and will also be used to forward loopback traffic in VEB, so when we switch to VEPA, we want them to behave similarly to MAC-only rules.
ice_vsi_update_bridge_mode()will now attempt a rollback of switch filters in case an update fails. If the rollback also fails, we will now return the rollback error instead of the initial error.Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Jakub Slepecki <[email protected]>---
Testing hints:
MAC,VLAN rules are created only if entire series is applied. The easiest way to test that rules were adjusted is to run traffic and observe what packets are sent to LAN. VEPA is expected to behave same as before the series. VEB is expected to (a) behave like VEPA if loopback traffic would cross VLANs, or (b) behave as before. Traffic from/to external hosts is expected to remain unchanged.Refer to cover letter (0/7) for full network configuration. To change hwmode use:
# bridge link set dev $pf hwmode {veb,vepa}No changes in v4.
Changes in v3:
- Refer to reproduction in cover letter in current 4/7.Changes in v2:
- Close open parenthesis inice_vsi_update_bridge_mode()description.
- Explain returns inice_vsi_update_bridge_mode().--- drivers/net/ethernet/intel/ice/ice_main.c | 48 +++++++++++++++++---- drivers/net/ethernet/intel/ice/ice_switch.c | 8 ++-- drivers/net/ethernet/intel/ice/ice_switch.h | 3 +- 3 files changed, 46 insertions(+), 13 deletions(-)drivers/net/ethernet/intel/ice/ice_main.c +0
-0@@ -8208,8 +8208,16 @@ static int ice_vsi_update_bridge_mode(struct ice_vsi
PATCH v4 5/7 ice: add functions to query for vsi's pvids
In reply to Jakub SlepeckiPVID information is set across two structs and several members depending primarily on DVM support and VSI type. Add function that guess whether PVID is set and where and allow to access raw VLAN ID set. This is intended to be used later on to decide what MAC{,VLAN} filters to set for a VSI.
---
No changes iv v4.
No changes in v3.
No changes in v2.
--- drivers/net/ethernet/intel/ice/ice_lib.c | 56 ++++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_lib.h | 2 + 2 files changed, 58 insertions(+)
drivers/net/ethernet/intel/ice/ice_lib.c +56 -0
@@ -4136,3 +4136,59 @@ void ice_vsi_update_l2tsel(struct ice_vsi *vsi, enum ice_l2tsel l2tsel)wr32 (hw, qrx_context_offset, regval); } } + +/** +* ice_vsi_has_outer_pvid - check if VSI has outer Port VLAN ID assigned +* @info: props of VSI in question +* +* Return: true if VSI has outer PVID, false otherwise. +*/ +static bool +ice_vsi_has_outer_pvid (const struct ice_aqc_vsi_props *info) +{ +return info->outer_vlan_flags &ICE_AQ_VSI_OUTER_VLAN_PORT_BASED_INSERT ; +} + +/** +* ice_vsi_has_inner_pvid - check if VSI has inner Port VLAN ID assigned +* @info: props of VSI in question +* +* Return: true if VSI has inner PVID, false otherwise. +*/ +static bool +ice_vsi_has_inner_pvid (const struct ice_aqc_vsi_props *info) +{ +return info->inner_vlan_flags &ICE_AQ_VSI_INNER_VLAN_INSERT_PVID ; +} + +/** +* ice_vsi_has_pvid - check if VSI has Port VLAN ID assigned +* @vsi: VSI in question +* +* Return: true if VSI has either outer or inner PVID, false otherwise. +*/ +bool +ice_vsi_has_pvid (struct ice_vsi *vsi) +{ +return ice_vsi_has_outer_pvid (&vsi->info) || +ice_vsi_has_inner_pvid (&vsi->info); +} + +/** +* ice_vsi_pvid - retrieve VSI's Port VLAN ID +* @vsi: VSI in question +* +* Return: VSI's PVID; it is valid only if ice_vsi_has_pvid is true. +*/ +u16 +ice_vsi_pvid (struct ice_vsi *vsi) +{ +__le16 vlan_info =0 ; + +if (ice_vsi_has_outer_pvid (&vsi->info)) + vlan_info = vsi->info.port_based_outer_vlan; +else if (ice_vsi_has_inner_pvid (&vsi->info)) + vlan_info = vsi->info.port_based_inner_vlan; + +return le16_to_cpu (vlan_info) &VLAN_VID_MASK ; +}
drivers/net/ethernet/intel/ice/ice_lib.h +2 -0
@@ -134,6 +134,8 @@ void ice_clear_feature_support(struct ice_pf *pf, enum ice_feature f);void ice_init_feature_support (struct ice_pf *pf);bool ice_vsi_is_rx_queue_active (struct ice_vsi *vsi);void ice_vsi_update_l2tsel (struct ice_vsi *vsi,enum ice_l2tsel l2tsel); +bool ice_vsi_has_pvid (struct ice_vsi *vsi); +u16 ice_vsi_pvid (struct ice_vsi *vsi);extern const struct netdev_queue_mgmt_ops ice_queue_mgmt_ops;
Signature · 1 line
2.43.0
RE: [Intel-wired-lan] [PATCH iwl-next v4 5/7] ice: add functions to query for vsi's pvids
Quoted 37 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jakub Slepecki
Sent: Wednesday, February 4, 2026 4:44 PM
To: [email protected]
Cc: [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Slepecki, Jakub <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4 5/7] ice: add functions to query for vsi's pvidsPVID information is set across two structs and several members depending primarily on DVM support and VSI type. Add function that guess whether PVID is set and where and allow to access raw VLAN ID set. This is intended to be used later on to decide what MAC{,VLAN} filters to set for a VSI.
Reviewed-by Michal Swiatkowski <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Jakub Slepecki <[email protected]>---
No changes iv v4.
No changes in v3.
No changes in v2.--- drivers/net/ethernet/intel/ice/ice_lib.c | 56 ++++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_lib.h | 2 + 2 files changed, 58 insertions(+)drivers/net/ethernet/intel/ice/ice_lib.c +0
-0
drivers/net/ethernet/intel/ice/ice_lib.c void ice_vsi_update_l2tsel(struct ice_vsi *vsi, enum · line 4136
Quoted 1 line
drivers/net/ethernet/intel/ice/ice_lib.c +0
-0@@ -4136,3 +4136,59 @@ void ice_vsi_update_l2tsel(struct ice_vsi *vsi, enum ice_l2tsel l2tsel)
PATCH v4 6/7 ice: add mac vlan to filter API
In reply to Jakub SlepeckiFrom: Michal Swiatkowski <[email protected]>
Allow mac vlan filters to be managed by filters API in ice driver. Together with mac-only filters they will be used to forward traffic intended for loopback in VEB mode.
---
No changes in v4.
No changes in v3.
No changes in v2.
--- drivers/net/ethernet/intel/ice/ice_fltr.c | 33 +++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fltr.h | 4 +++ 2 files changed, 37 insertions(+)
drivers/net/ethernet/intel/ice/ice_fltr.c +33 -0
@@ -240,6 +240,39 @@ ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct list_head *list, list); } +/** +* ice_fltr_add_mac_vlan_to_list - add MAC VLAN filter info to +* existing list +* @vsi: pointer to VSI struct +* @list: list to add filter info to +* @mac: MAC address to add +* @vlan_id: VLAN id to add +* @action: filter action +* +* Return: +* * 0 if entry for filter was added, or +* * %-ENOMEM if entry could not be allocated. +*/ +int +ice_fltr_add_mac_vlan_to_list (struct ice_vsi *vsi,struct list_head *list, +const u8 *mac,u16 vlan_id, +enum ice_sw_fwd_act_type action) +{ +struct ice_fltr_info info = {}; + + info.flag =ICE_FLTR_TX ; + info.src_id =ICE_SRC_ID_VSI ; + info.lkup_type =ICE_SW_LKUP_MAC_VLAN ; + info.fltr_act = action; + info.vsi_handle = vsi->idx; + + info.l_data.mac_vlan.vlan_id = vlan_id; +ether_addr_copy (info.l_data.mac_vlan.mac_addr, mac); + +return ice_fltr_add_entry_to_list (ice_pf_to_dev (vsi->back), &info, + list); +} +/** * ice_fltr_add_vlan_to_list - add VLAN filter info to exsisting list * @vsi: pointer to VSI struct
drivers/net/ethernet/intel/ice/ice_fltr.h +4 -0
@@ -23,6 +23,10 @@ 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);int +ice_fltr_add_mac_vlan_to_list (struct ice_vsi *vsi,struct list_head *list, +const u8 *mac,u16 vlan_id, +enum ice_sw_fwd_act_type action); +int ice_fltr_add_mac (struct ice_vsi *vsi,const u8 *mac,enum ice_sw_fwd_act_type action);int
Signature · 1 line
2.43.0
RE: [Intel-wired-lan] [PATCH iwl-next v4 6/7] ice: add mac vlan to filter API
drivers/net/ethernet/intel/ice/ice_fltr.c ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct
Quoted 37 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jakub Slepecki
Sent: Wednesday, February 4, 2026 4:44 PM
To: [email protected]
Cc: [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Slepecki, Jakub <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4 6/7] ice: add mac vlan to filter APIFrom: Michal Swiatkowski <[email protected]>
Allow mac vlan filters to be managed by filters API in ice driver. Together with mac-only filters they will be used to forward traffic intended for loopback in VEB mode.
Signed-off-by Michal Swiatkowski <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Jakub Slepecki <[email protected]>---
No changes in v4.
No changes in v3.
No changes in v2.--- drivers/net/ethernet/intel/ice/ice_fltr.c | 33 +++++++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_fltr.h | 4 +++ 2 files changed, 37 insertions(+)drivers/net/ethernet/intel/ice/ice_fltr.c +0
-0@@ -240,6 +240,39 @@ ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct
PATCH v4 7/7 ice: in VEB, prevent "cross-vlan" traffic from hitting loopback
In reply to Jakub SlepeckiIn Virtual Ethernet Bridge (VEB) mode, we use MAC filters to forward traffic between two VFs. We also use VLAN filters to prune potential destinations, so that they don't cross VLANs. In case a VF in VLAN X sends a packet to a MAC address matching another VF but in VLAN Y, both these filters will be hit. Packet will be sent to loopback-only to VF in VLAN Y, but VLAN filter will prune its VSI from the destination list leaving the packet stranded in the internal switch and thus dropped.
Since there is no destination for the packet in the VLAN X, it should instead be sent to the wire.
To fix this, we introduce MAC,VLAN filters in place of MAC-only filters if VSI is part of any VLAN. We consider VSI part of a VLAN if it has a PVID set, or if it has a specific VLAN filter and does not have a VLAN 0 filter.
This approach does not attempt to fix interactions with upper devices. If an upper vlan device requests a separate MAC address filter resulting in a call to __dev_uc_sync, the VSI will start receiving all packets destined for this MAC and not just within the VLAN. I don't see a straight-forward way to resolve this: information about MAC and VLAN filters coming from kernel to driver is disconnected from one another and from the device that requests it. It could be worked around by, for example, tracking all upper devices with netdev notifications and adjusting the filters there. Hence, the scope is limited to VF traffic.
Following situations were considered for VLAN filters additions, removal, or changes:
1. ice changes VF's vlan
2. VF is reset and rebuilt
3. vlan device attaches above a PF or a VF
And same for MAC filters:
4. PF's MAC is changed
5. PF changes MAC of a VF
6. VF's MAC is changed
7. ndo_set_rx_mode et al
When VLAN is assigned to a VF in (1), the affected VF is reset and rebuild. This makes (1) the same as (2). We end up with two cases where VLAN filters are added: (2) and (3).
To correctly handle (1-2), we move the VLAN filters initialization before the MAC filters initialization, since MAC filters now depend on VLAN filters presence. These two handle PVID (or lack of thereof) and because they are always associated with a reset, we don't need to consider updating MAC and MAC,VLAN filters afterwards.
In (3), we will always have a lower device that is expected to receive all packets for its MAC regardless of VLAN tag. Because of the caveat described above, we will do the same for each MAC address associated with the interface regardless of VLANs. The result is we only have MAC-only filters in this case.
When we create MAC filters in (4-7) we now check for existing VLAN filters and depending on PVID and VLAN 0 presence we decide to create, respectively, a MAC and MAC,VLAN filter pair, or a MAC filter. This is done implicitly when requesting to remove old MAC and add new MAC, so no change is required to this flow.
---
Note the /a.s. dead/ branch in ice_fltr.c. I decided to make it explicit, but it can be merged into VLAN 0 branch as well (with or without a comment), because their final effect is exactly the same.
No changes in v4.
No changes in v3.
No changes in v2.
--- drivers/net/ethernet/intel/ice/ice_fltr.c | 71 +++++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_fltr.h | 6 +- drivers/net/ethernet/intel/ice/ice_main.c | 8 +-- drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- drivers/net/ethernet/intel/ice/ice_switch.h | 2 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 8 +-- 6 files changed, 83 insertions(+), 14 deletions(-)
drivers/net/ethernet/intel/ice/ice_fltr.c +67 -4
@@ -3,6 +3,7 @@#include "ice.h" #include "ice_fltr.h" +#include "ice_lib.h" /** * ice_fltr_free_list - free filter lists helper
@@ -221,10 +222,12 @@ void ice_fltr_remove_all(struct ice_vsi *vsi)* @list: list to add filter info to * @mac: MAC address to add * @action: filter action +* @external: force the filter to enable lan destination */ 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) +const u8 *mac,enum ice_sw_fwd_act_type action, +bool external) {struct ice_fltr_info info = {0 };
@@ -233,6 +236,10 @@ ice_fltr_add_mac_to_list(struct ice_vsi *vsi, struct list_head *list, info.lkup_type =ICE_SW_LKUP_MAC ; info.fltr_act = action; info.vsi_handle = vsi->idx; +if (external) { + info.lb_en =ICE_FLTR_INFO_LB_LAN_FORCE_ENABLED ; + info.lan_en =ICE_FLTR_INFO_LB_LAN_FORCE_ENABLED ; + }ether_addr_copy (info.l_data.mac.mac_addr, mac);
@@ -273,6 +280,62 @@ ice_fltr_add_mac_vlan_to_list(struct ice_vsi *vsi, struct list_head *list, list); } +/** +* ice_fltr_add_macs_to_list - add MAC and MAC,VLAN filters info to an existing +* list +* @vsi: pointer to VSI struct +* @list: list to add filter info to +* @mac: MAC address to add +* @action: filter action +* +* Return: +* * 0 on success, or +* * %-ENOMEM if entry for filter could not be allocated. +*/ +int +ice_fltr_add_macs_to_list (struct ice_vsi *vsi,struct list_head *list, +const u8 *mac,enum ice_sw_fwd_act_type action) +{ +if (is_multicast_ether_addr (mac)) { +/* There is no point in doing the same gymnastics as below +* because multicast addresses are sent to both lan and lb then +* pruned as necessary. +*/ +return ice_fltr_add_mac_to_list (vsi, list, mac, action, false); + }else if (ice_vsi_has_pvid (vsi)) { +u16 pvid =ice_vsi_pvid (vsi); +int ret; + + ret =ice_fltr_add_mac_to_list (vsi, list, mac, action, true); +if (ret) +return ret; + +return ice_fltr_add_mac_vlan_to_list (vsi, list, mac, pvid, + action); + }else if (vsi->num_vlan !=ice_vsi_num_non_zero_vlans (vsi)) { +/* If VSI has VLAN 0 filters, then the interface is prepared to +* receive untagged packets. As of now, we simply don't have +* heuristics to decide which MAC is and is not part of which +* VLAN so we put them all in the same bucket. +*/ +return ice_fltr_add_mac_to_list (vsi, list, mac, action, false); + } + +/* This branch is a.s. dead. There are three cases that may happen: +* +* - no vlans in sight; this is the VLAN 0 branch, +* - VF is assigned PVID; this is ice_vsi_has_pvid branch, +* - PF or VF is under vlan device; this is the VLAN 0 branch. +* +* This is where you would implement support for multiple VLANs but +* without the VLAN 0. This could happen if vlan upper device is +* assigned a MAC that is unique compared to lower ice device that is +* forced to accept any VLAN. This would imply MAC-only filter for one +* MAC address (PF) and MAC,VLAN+MAC filters for another (vlan). +*/ +return ice_fltr_add_mac_to_list (vsi, list, mac, action, false); +} +/** * ice_fltr_add_vlan_to_list - add VLAN filter info to exsisting list * @vsi: pointer to VSI struct
@@ -343,7 +406,7 @@ ice_fltr_prepare_mac(struct ice_vsi *vsi, const u8 *mac,LIST_HEAD (tmp_list);int result; -if (ice_fltr_add_mac_to_list (vsi, &tmp_list, mac, action)) { +if (ice_fltr_add_macs_to_list (vsi, &tmp_list, mac, action)) {ice_fltr_free_list (ice_pf_to_dev (vsi->back), &tmp_list);return -ENOMEM ; }
@@ -371,8 +434,8 @@ ice_fltr_prepare_mac_and_broadcast(struct ice_vsi *vsi, const u8 *mac,int result;eth_broadcast_addr (broadcast); -if (ice_fltr_add_mac_to_list (vsi, &tmp_list, mac, action) || -ice_fltr_add_mac_to_list (vsi, &tmp_list, broadcast, action)) { +if (ice_fltr_add_macs_to_list (vsi, &tmp_list, mac, action) || +ice_fltr_add_macs_to_list (vsi, &tmp_list, broadcast, action)) {ice_fltr_free_list (ice_pf_to_dev (vsi->back), &tmp_list);return -ENOMEM ; }
drivers/net/ethernet/intel/ice/ice_fltr.h +5 -1
@@ -21,12 +21,16 @@ ice_fltr_set_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask, u16 vid);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); +const u8 *mac,enum ice_sw_fwd_act_type action, +bool external);int ice_fltr_add_mac_vlan_to_list (struct ice_vsi *vsi,struct list_head *list,const u8 *mac,u16 vlan_id,enum ice_sw_fwd_act_type action);int +ice_fltr_add_macs_to_list (struct ice_vsi *vsi,struct list_head *list, +const u8 *mac,enum ice_sw_fwd_act_type action); +int ice_fltr_add_mac (struct ice_vsi *vsi,const u8 *mac,enum ice_sw_fwd_act_type action);int
drivers/net/ethernet/intel/ice/ice_main.c +4 -4
@@ -212,8 +212,8 @@ static int ice_add_mac_to_sync_list(struct net_device *netdev, const u8 *addr)struct ice_netdev_priv *np =netdev_priv (netdev);struct ice_vsi *vsi = np->vsi; -if (ice_fltr_add_mac_to_list (vsi, &vsi->tmp_sync_list, addr, -ICE_FWD_TO_VSI )) +if (ice_fltr_add_macs_to_list (vsi, &vsi->tmp_sync_list, addr, +ICE_FWD_TO_VSI ))return -EINVAL ;return 0 ;
@@ -242,8 +242,8 @@ static int ice_add_mac_to_unsync_list(struct net_device *netdev, const u8 *addr)if (ether_addr_equal (addr, netdev->dev_addr))return 0 ; -if (ice_fltr_add_mac_to_list (vsi, &vsi->tmp_unsync_list, addr, -ICE_FWD_TO_VSI )) +if (ice_fltr_add_macs_to_list (vsi, &vsi->tmp_unsync_list, addr, +ICE_FWD_TO_VSI ))return -EINVAL ;return 0 ;
drivers/net/ethernet/intel/ice/ice_switch.c +1 -1
@@ -4018,7 +4018,7 @@ ice_cfg_dflt_vsi(struct ice_port_info *pi, u16 vsi_handle, bool set,* @fm_entry: filter entry to inspect * @vsi_handle: VSI handle to compare with filter info */ -static bool +bool ice_vsi_uses_fltr (struct ice_fltr_mgmt_list_entry *fm_entry,u16 vsi_handle) { return ((fm_entry->fltr_info.fltr_act == ICE_FWD_TO_VSI &&
drivers/net/ethernet/intel/ice/ice_switch.h +2 -0
@@ -346,6 +346,8 @@ ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,bool ice_is_vsi_valid (struct ice_hw *hw,u16 vsi_handle);struct ice_vsi_ctx *ice_get_vsi_ctx (struct ice_hw *hw,u16 vsi_handle);void ice_clear_all_vsi_ctx (struct ice_hw *hw); +bool ice_vsi_uses_fltr (struct ice_fltr_mgmt_list_entry *fm_entry, +u16 vsi_handle);/* Switch config */ int ice_get_initial_sw_cfg (struct ice_hw *hw);
drivers/net/ethernet/intel/ice/ice_vf_lib.c +4 -4
@@ -501,14 +501,14 @@ static void ice_vf_rebuild_host_cfg(struct ice_vf *vf)ice_vf_set_host_trust_cfg (vf); -if (ice_vf_rebuild_host_mac_cfg (vf)) -dev_err (dev,"failed to rebuild default MAC configuration for VF %d\n" , - vf->vf_id); -if (ice_vf_rebuild_host_vlan_cfg (vf, vsi))dev_err (dev,"failed to rebuild VLAN configuration for VF %u\n" , vf->vf_id); +if (ice_vf_rebuild_host_mac_cfg (vf)) +dev_err (dev,"failed to rebuild default MAC configuration for VF %d\n" , + vf->vf_id); +if (ice_vf_rebuild_host_tx_rate_cfg (vf))dev_err (dev,"failed to rebuild Tx rate limiting configuration for VF %u\n" , vf->vf_id);
Signature · 1 line
2.43.0
RE: [Intel-wired-lan] [PATCH iwl-next v4 7/7] ice: in VEB, prevent "cross-vlan" traffic from hitting loopback
drivers/net/ethernet/intel/ice/ice_fltr.c
Quoted 101 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jakub Slepecki
Sent: Wednesday, February 4, 2026 4:44 PM
To: [email protected]
Cc: [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Slepecki, Jakub <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4 7/7] ice: in VEB, prevent "cross- vlan" traffic from hitting loopbackIn Virtual Ethernet Bridge (VEB) mode, we use MAC filters to forward traffic between two VFs. We also use VLAN filters to prune potential destinations, so that they don't cross VLANs. In case a VF in VLAN X sends a packet to a MAC address matching another VF but in VLAN Y, both these filters will be hit. Packet will be sent to loopback-only to VF in VLAN Y, but VLAN filter will prune its VSI from the destination list leaving the packet stranded in the internal switch and thus dropped.
Since there is no destination for the packet in the VLAN X, it should instead be sent to the wire.
To fix this, we introduce MAC,VLAN filters in place of MAC-only filters if VSI is part of any VLAN. We consider VSI part of a VLAN if it has a PVID set, or if it has a specific VLAN filter and does not have a VLAN
0 filter.This approach does not attempt to fix interactions with upper devices. If an upper vlan device requests a separate MAC address filter resulting in a call to
__dev_uc_sync, the VSI will start receiving all packets destined for this MAC and not just within the VLAN. I don't see a straight-forward way to resolve this:
information about MAC and VLAN filters coming from kernel to driver is disconnected from one another and from the device that requests it. It could be worked around by, for example, tracking all upper devices with netdev notifications and adjusting the filters there. Hence, the scope is limited to VF traffic.Following situations were considered for VLAN filters additions, removal, or changes:
1. ice changes VF's vlan
2. VF is reset and rebuilt
3. vlan device attaches above a PF or a VFAnd same for MAC filters:
4. PF's MAC is changed
5. PF changes MAC of a VF
6. VF's MAC is changed
7.ndo_set_rx_modeet alWhen VLAN is assigned to a VF in (1), the affected VF is reset and rebuild. This makes (1) the same as (2). We end up with two cases where VLAN filters are
added: (2) and (3).To correctly handle (1-2), we move the VLAN filters initialization before the MAC filters initialization, since MAC filters now depend on VLAN filters presence. These two handle PVID (or lack of thereof) and because they are always associated with a reset, we don't need to consider updating MAC and MAC,VLAN filters afterwards.
In (3), we will always have a lower device that is expected to receive all packets for its MAC regardless of VLAN tag. Because of the caveat described above, we will do the same for each MAC address associated with the interface regardless of VLANs. The result is we only have MAC-only filters in this case.
When we create MAC filters in (4-7) we now check for existing VLAN filters and depending on PVID and VLAN 0 presence we decide to create, respectively, a MAC and MAC,VLAN filter pair, or a MAC filter. This is done implicitly when requesting to remove old MAC and add new MAC, so no change is required to this flow.
Reviewed-by Michal Swiatkowski <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>Signed-off-by Jakub Slepecki <[email protected]>---
Note the /a.s. dead/ branch inice_fltr.c. I decided to make it explicit, but it can be merged into VLAN 0 branch as well (with or without a comment), because their final effect is exactly the same.No changes in v4.
No changes in v3.
No changes in v2.--- drivers/net/ethernet/intel/ice/ice_fltr.c | 71 +++++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_fltr.h | 6 +- drivers/net/ethernet/intel/ice/ice_main.c | 8 +-- drivers/net/ethernet/intel/ice/ice_switch.c | 2 +- drivers/net/ethernet/intel/ice/ice_switch.h | 2 + drivers/net/ethernet/intel/ice/ice_vf_lib.c | 8 +-- 6 files changed, 83 insertions(+), 14 deletions(-)drivers/net/ethernet/intel/ice/ice_fltr.c +0
-0@@ -3,6 +3,7 @@
Quoted 97 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jakub Slepecki
Sent: Wednesday, February 4, 2026 16:44
To: [email protected]
Cc: [email protected]; [email protected]; Kitszel, Przemyslaw <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]; Slepecki, Jakub <[email protected]>; Loktionov, Aleksandr <[email protected]>
Subject: [Intel-wired-lan] [PATCH iwl-next v4 0/7] ice: in VEB, prevent "cross- vlan" trafficCurrently, packets that match MAC address of a VF will be sent to loopback even if they would cross VLAN boundaries. Effectively, this drops them. In this patch series, we aim to address this behaviour by adding MAC,VLAN to complement what MAC-only filters do to select packets for loopback.
To reproduce the issue have an E810 ($pfa) connected to another adapter ($pfb), then:
# echo 2 >/sys/class/net/$pfa/device/sriov_numvfs # ip l set $pfa vf 0 vlan 4 # ip l set $pfa vf 1 vlan 7 # ip l set $pfa_vf0 netns $pfa_vf0_netns up # ip l set $pfa_vf1 netns $pfa_vf1_netns up # ip netns exec $pfa_vf0_netns ip a add 10.0.0.1/24 dev $pfa_vf0 # ip netns exec $pfa_vf1_netns ip a add 10.0.0.2/24 dev $pfa_vf1And for the $pfb:
# echo 2 >/sys/class/net/$pfb/device/sriov_numvfs # ip l set $pfb vf 0 trust on spoof off vlan 4 # ip l set $pfb vf 1 trust on spoof off vlan 7 # ip l add $br type bridge # ip l set $pfb_vf0 master $br up # ip l set $pfb_vf1 master $br up # ip l set $br upWe expect $pfa_vf0 to be able to reach $pfa_vf1 through the $br on the link partner. Instead, ARP is unable to resolve 10.0.0.2/24.
ARP request is fine because it's broadcastd and bounces off $br, but ARP reply is stuck in the internal switch because the destination MAC matches $pfa_vf0 and filter restricts it to the loopback.In testing I used: ip utility, iproute2-6.1.0, libbpf 1.3.0
Changes in v4:
- Removed "ice: do not check for zero mac when creating mac filters" patch.Changes in v3:
- Improve structure of reproduction description in cover letter.
-LB_LANmasks and values no longer rely on boolean promotion.
-ice_fill_sw_info()deals with u8 the entire time instead of building buildinglb_enandlan_envalues at the end from booleans.
- Refer to reproduction in cover letter in current 4/7.
- Fixed some slip-ups "this patch" and "this commit" in commit messages across the series. I did not consider this change for reviewed-by drop.Changes in v2:
- UseFIELD_GETet al. when handling fi.lb_en and fi.lan_en.
- Rename /LB_LAN/ s/_MASK/_M/ because one of uses would need to break line.
- Close open parenthesis inice_vsi_update_bridge_mode()description.
- Explain returns inice_vsi_update_bridge_mode().v3: https://lore.kernel.org/intel-wired-lan/20260120103440.892326-1-
[email protected]/T/
v2: https://lore.kernel.org/intel-wired-lan/20251125083456.28822-1-
[email protected]/T/
v1: https://lore.kernel.org/intel-wired-lan/20251120162813.37942-1-
[email protected]/T/Jakub Slepecki (6):
ice: in dvm, use outer VLAN in MAC,VLAN lookup
ice: allow creating mac,vlan filters along mac filters
ice: allow overridinglan_en,lb_enin switch
ice: update mac,vlan rules when toggling between VEB and VEPA
ice: add functions to query for vsi's pvids
ice: in VEB, prevent "cross-vlan" traffic from hitting loopbackMichal Swiatkowski (1):
ice: add mac vlan to filter APIdrivers/net/ethernet/intel/ice/ice_fltr.c | 104 ++++++++++++++- drivers/net/ethernet/intel/ice/ice_fltr.h | 10 + drivers/net/ethernet/intel/ice/ice_lib.c | 56 ++++++++ drivers/net/ethernet/intel/ice/ice_lib.h | 2 drivers/net/ethernet/intel/ice/ice_main.c | 56 ++++++-- drivers/net/ethernet/intel/ice/ice_switch.c | 83 ++++++++--- drivers/net/ethernet/intel/ice/ice_switch.h | 24 ++- drivers/net/ethernet/intel/ice/ice_vf_lib.c | 8 - drivers/net/ethernet/intel/ice/ice_vlan_mode.c | 12 + 9 files changed, 306 insertions(+), 49 deletions(-)
Quoted 2 lines
--
2.43.0