Skip to contentSkip to conversation

ice: Add lport/MAC rules for PF traffic in bonds

PATCH In review Dave Ertman 3 participants 7 messages Oct 3, 2025 – Oct 8, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: Add lport/MAC rules for PF traffic in bonds

When two E8XX interfaces are placed into a bond, and are correctly configured for supporting SRIOV traffic over the bonded interfaces, there is a problem with traffic aimed directly at the bond netdev. By conjoining both interfaces onto a single switch black in the NIC, all unicast and broadcast traffic is being directed to the primary interface's set of resources no matter which interface is the active/targeting one.

To fix this, add a set of rules into the switch block that combines both target MAC address and source logical port to direct packets to the active/targeted VSI. This change will not touch traffic directed to SRIOV VF targets.

Fixes ec5a6c5f79ed ("ice: process events created by lag netdev event handler")
---
 drivers/net/ethernet/intel/ice/ice_lag.c | 101 +++++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_lag.h |   5 ++
 2 files changed, 106 insertions(+)
drivers/net/ethernet/intel/ice/ice_lag.c +101 -0
index d2576d606e10..7773d5b9bae9 100644
@@ -17,6 +17,7 @@ static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
 static const u8 act_act_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
 							 0, 0, 0, 0, 0, 0,
 							 0, 0, 0, 0 };
+static u8 mac_train_pkt[ICE_TRAIN_PKT_LEN] = { 0 };
 
 #define ICE_RECIPE_LEN			64
 #define ICE_LAG_SRIOV_CP_RECIPE		10
@@ -29,6 +30,10 @@ static const u8 ice_lport_rcp[ICE_RECIPE_LEN] = {
 	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0x85, 0, 0x16, 0, 0, 0, 0xff, 0xff, 0x07, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0x30 };
+static const u8 ice_pfmac_rcp[ICE_RECIPE_LEN] = {
+	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x85, 0, 0x16,
+	0x05, 0x06, 0x07, 0xff, 0xff, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0, 0, 0, 0, 0, 0, 0x30 };
 
 /**
  * ice_lag_set_primary - set PF LAG state as Primary
@@ -1336,6 +1341,89 @@ ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)
 				ice_lag_reclaim_vf_tc(lag, src_hw, i, tc);
 }
 
+/**
+ * ice_lag_cfg_pfmac_fltrs
+ * @lag: local lag info struct
+ * @link: is this a linking action
+ *
+ * Configure lport/MAC filters for this interfaces PF traffic in the
+ * current interfaces SWID
+ */
+static void ice_lag_cfg_pfmac_fltrs(struct ice_lag *lag, bool link)
+{
+	u8 lport = lag->pf->hw.port_info->lport;
+	struct ice_sw_rule_lkup_rx_tx *s_rule;
+	struct ice_vsi *vsi = lag->pf->vsi[0];
+	struct ice_hw *hw = &lag->pf->hw;
+	u16 s_rule_sz;
+	u32 act;
+
+	act = ICE_FWD_TO_VSI | ICE_SINGLE_ACT_LAN_ENABLE | ICE_SINGLE_ACT_VALID_BIT |
+		FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi->vsi_num);
+
+	s_rule_sz = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, ICE_TRAIN_PKT_LEN);
+	s_rule = kzalloc(s_rule_sz, GFP_KERNEL);
+	if (!s_rule) {
+		netdev_warn(lag->netdev, "-ENOMEM error configuring PFMAC filters\n");
+		return;
+	}
+
+	if (link) {
+		u8 broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+		/* unicast */
+		ether_addr_copy(mac_train_pkt, lag->upper_netdev->dev_addr);
+		memcpy(s_rule->hdr_data, mac_train_pkt, ICE_TRAIN_PKT_LEN);
+		s_rule->recipe_id = cpu_to_le16(lag->pfmac_recipe);
+		s_rule->src = cpu_to_le16(lport);
+		s_rule->act = cpu_to_le32(act);
+		s_rule->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
+		s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);
+
+		if (ice_aq_sw_rules(hw, s_rule, s_rule_sz, 1,
+				    ice_aqc_opc_add_sw_rules, NULL)) {
+			netdev_warn(lag->netdev, "Error ADDING Unicast PFMAC rule for aggregate\n");
+			goto err_pfmac_free;
+		}
+
+		lag->pfmac_unicst_idx = le16_to_cpu(s_rule->index);
+
+		/* broadast */
+		ether_addr_copy(mac_train_pkt, broadcast);
+		memcpy(s_rule->hdr_data, mac_train_pkt, ICE_TRAIN_PKT_LEN);
+		if (ice_aq_sw_rules(hw, s_rule, s_rule_sz, 1,
+				    ice_aqc_opc_add_sw_rules, NULL)) {
+			netdev_warn(lag->netdev, "Error ADDING Broadcast PFMAC rule for aggregate\n");
+			goto err_pfmac_free;
+		}
+
+		lag->pfmac_bdcst_idx = le16_to_cpu(s_rule->index);
+	} else {
+		/* unicast */
+		s_rule->index = cpu_to_le16(lag->pfmac_unicst_idx);
+		if (s_rule->index && ice_aq_sw_rules(&lag->pf->hw, s_rule,
+						     s_rule_sz, 1,
+						     ice_aqc_opc_remove_sw_rules,
+						     NULL))
+			netdev_warn(lag->netdev, "Error REMOVING Unicast PFMAC rule for aggregate\n");
+
+		lag->pfmac_unicst_idx = 0;
+
+		/* broadcast */
+		s_rule->index = cpu_to_le16(lag->pfmac_bdcst_idx);
+		if (s_rule->index && ice_aq_sw_rules(&lag->pf->hw, s_rule,
+						     s_rule_sz, 1,
+						     ice_aqc_opc_remove_sw_rules,
+						     NULL))
+			netdev_warn(lag->netdev, "Error REMOVING Broadcast PFMAC rule for aggregate\n");
+
+		lag->pfmac_bdcst_idx = 0;
+	}
+
+err_pfmac_free:
+	kfree(s_rule);
+}
+
 /**
  * ice_lag_link - handle LAG link event
  * @lag: LAG info struct
@@ -1437,7 +1525,9 @@ static void ice_lag_link_unlink(struct ice_lag *lag, void *ptr)
 
 	if (info->linking) {
 		ice_lag_link(lag);
+		ice_lag_cfg_pfmac_fltrs(lag, true);
 	} else {
+		ice_lag_cfg_pfmac_fltrs(lag, false);
 		if (lag->bond_aa)
 			ice_lag_aa_unlink(lag);
 		else
@@ -2622,6 +2712,11 @@ int ice_init_lag(struct ice_pf *pf)
 	if (err)
 		goto  free_lport_res;
 
+	err = ice_create_lag_recipe(&pf->hw, &lag->pfmac_recipe,
+				    ice_pfmac_rcp, 3);
+	if (err)
+		goto free_act_act_res;
+
 	/* associate recipes to profiles */
 	for (n = 0; n < ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER; n++) {
 		err = ice_aq_get_recipe_to_profile(&pf->hw, n,
@@ -2643,6 +2738,10 @@ int ice_init_lag(struct ice_pf *pf)
 	dev_dbg(dev, "INIT LAG complete\n");
 	return 0;
 
+free_act_act_res:
+	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
+			&pf->lag->act_act_recipe);
+
 free_lport_res:
 	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
 			&lag->lport_recipe);
@@ -2679,6 +2778,8 @@ void ice_deinit_lag(struct ice_pf *pf)
 			&pf->lag->pf_recipe);
 	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
 			&pf->lag->lport_recipe);
+	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
+			&pf->lag->pfmac_recipe);
 
 	kfree(lag);
 
drivers/net/ethernet/intel/ice/ice_lag.h +5 -0
index f77ebcd61042..f1bff43228ee 100644
@@ -60,11 +60,16 @@ struct ice_lag {
 	u16 pf_recipe;
 	u16 lport_recipe;
 	u16 act_act_recipe;
+	u16 pfmac_recipe;
+
 	u16 pf_rx_rule_id;
 	u16 pf_tx_rule_id;
 	u16 cp_rule_idx;
 	u16 lport_rule_idx;
 	u16 act_act_rule_idx;
+	u16 pfmac_unicst_idx;
+	u16 pfmac_bdcst_idx;
+
 	u8 role;
 };
 
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw

Dear Dave,

Thank you for the patch.

Am 03.10.25 um 18:27 schrieb Dave Ertman:

Quoted 4 lines

When two E8XX interfaces are placed into a bond, and are correctly configured for supporting SRIOV traffic over the bonded interfaces, there is a problem with traffic aimed directly at the bond netdev. By conjoining both interfaces onto a single switch black in the NIC, all

Sorry, what is a “single switch black“? bl*o*ck?

Quoted 7 lines

unicast and broadcast traffic is being directed to the primary interface's set of resources no matter which interface is the active/targeting one.

To fix this, add a set of rules into the switch block that combines both target MAC address and source logical port to direct packets to the active/targeted VSI. This change will not touch traffic directed to SRIOV VF targets.

Please document a reproducer, if you have one.

Quoted 20 lines
Fixes ec5a6c5f79ed ("ice: process events created by lag netdev event handler")
---
  drivers/net/ethernet/intel/ice/ice_lag.c | 101 +++++++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_lag.h |   5 ++
  2 files changed, 106 insertions(+)
drivers/net/ethernet/intel/ice/ice_lag.c +1 -0
index d2576d606e10..7773d5b9bae9 100644
@@ -17,6 +17,7 @@ static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
  static const u8 act_act_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
  							 0, 0, 0, 0, 0, 0,
  							 0, 0, 0, 0 };
+static u8 mac_train_pkt[ICE_TRAIN_PKT_LEN] = { 0 };
 
  #define ICE_RECIPE_LEN			64
  #define ICE_LAG_SRIOV_CP_RECIPE		10

drivers/net/ethernet/intel/ice/ice_lag.c static const u8 ice_lport_rcp[ICE_RECIPE_LEN] = { · line 36

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_lag.c +4 -0
@@ -29,6 +30,10 @@ static const u8 ice_lport_rcp[ICE_RECIPE_LEN] = {
  	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  	0x85, 0, 0x16, 0, 0, 0, 0xff, 0xff, 0x07, 0, 0, 0, 0, 0, 0, 0,
  	0, 0, 0, 0, 0, 0, 0x30 };
+static const u8 ice_pfmac_rcp[ICE_RECIPE_LEN] = {
+	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x85, 0, 0x16,
+	0x05, 0x06, 0x07, 0xff, 0xff, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0, 0, 0, 0, 0, 0, 0x30 };

Excuse my ignorance, how can these numbers be reviewed?

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1349

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_lag.c +6 -0
  /**
   * ice_lag_set_primary - set PF LAG state as Primary
@@ -1336,6 +1341,89 @@ ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)
  				ice_lag_reclaim_vf_tc(lag, src_hw, i, tc);
  }
 
+/**
+ * ice_lag_cfg_pfmac_fltrs
+ * @lag: local lag info struct
+ * @link: is this a linking action
+ *
+ * Configure lport/MAC filters for this interfaces PF traffic in the

interface’s

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1358

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_lag.c +9 -0
+ * current interfaces SWID
+ */
+static void ice_lag_cfg_pfmac_fltrs(struct ice_lag *lag, bool link)
+{
+	u8 lport = lag->pf->hw.port_info->lport;
+	struct ice_sw_rule_lkup_rx_tx *s_rule;
+	struct ice_vsi *vsi = lag->pf->vsi[0];
+	struct ice_hw *hw = &lag->pf->hw;
+	u16 s_rule_sz;

size_t?

Quoted 17 lines
drivers/net/ethernet/intel/ice/ice_lag.c +17 -0
+	u32 act;
+
+	act = ICE_FWD_TO_VSI | ICE_SINGLE_ACT_LAN_ENABLE | ICE_SINGLE_ACT_VALID_BIT |
+		FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi->vsi_num);
+
+	s_rule_sz = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, ICE_TRAIN_PKT_LEN);
+	s_rule = kzalloc(s_rule_sz, GFP_KERNEL);
+	if (!s_rule) {
+		netdev_warn(lag->netdev, "-ENOMEM error configuring PFMAC filters\n");
+		return;
+	}
+
+	if (link) {
+		u8 broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+		/* unicast */
+		ether_addr_copy(mac_train_pkt, lag->upper_netdev->dev_addr);

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1385

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +10 -0
+		memcpy(s_rule->hdr_data, mac_train_pkt, ICE_TRAIN_PKT_LEN);
+		s_rule->recipe_id = cpu_to_le16(lag->pfmac_recipe);
+		s_rule->src = cpu_to_le16(lport);
+		s_rule->act = cpu_to_le32(act);
+		s_rule->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
+		s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);
+
+		if (ice_aq_sw_rules(hw, s_rule, s_rule_sz, 1,
+				    ice_aqc_opc_add_sw_rules, NULL)) {
+			netdev_warn(lag->netdev, "Error ADDING Unicast PFMAC rule for aggregate\n");

Log the return value?

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1396

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_lag.c +11 -0
+			goto err_pfmac_free;
+		}
+
+		lag->pfmac_unicst_idx = le16_to_cpu(s_rule->index);
+
+		/* broadast */
+		ether_addr_copy(mac_train_pkt, broadcast);
+		memcpy(s_rule->hdr_data, mac_train_pkt, ICE_TRAIN_PKT_LEN);
+		if (ice_aq_sw_rules(hw, s_rule, s_rule_sz, 1,
+				    ice_aqc_opc_add_sw_rules, NULL)) {
+			netdev_warn(lag->netdev, "Error ADDING Broadcast PFMAC rule for aggregate\n");

Log the return value?

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1408

Quoted 12 lines
drivers/net/ethernet/intel/ice/ice_lag.c +12 -0
+			goto err_pfmac_free;
+		}
+
+		lag->pfmac_bdcst_idx = le16_to_cpu(s_rule->index);
+	} else {
+		/* unicast */
+		s_rule->index = cpu_to_le16(lag->pfmac_unicst_idx);
+		if (s_rule->index && ice_aq_sw_rules(&lag->pf->hw, s_rule,
+						     s_rule_sz, 1,
+						     ice_aqc_opc_remove_sw_rules,
+						     NULL))
+			netdev_warn(lag->netdev, "Error REMOVING Unicast PFMAC rule for aggregate\n");

Log the return value?

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1418

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +10 -0
+
+		lag->pfmac_unicst_idx = 0;
+
+		/* broadcast */
+		s_rule->index = cpu_to_le16(lag->pfmac_bdcst_idx);
+		if (s_rule->index && ice_aq_sw_rules(&lag->pf->hw, s_rule,
+						     s_rule_sz, 1,
+						     ice_aqc_opc_remove_sw_rules,
+						     NULL))
+			netdev_warn(lag->netdev, "Error REMOVING Broadcast PFMAC rule for aggregate\n");

Log the return value?

Quoted 63 lines
drivers/net/ethernet/intel/ice/ice_lag.c +21 -0
+
+		lag->pfmac_bdcst_idx = 0;
+	}
+
+err_pfmac_free:
+	kfree(s_rule);
+}
+
  /**
   * ice_lag_link - handle LAG link event
   * @lag: LAG info struct
@@ -1437,7 +1525,9 @@ static void ice_lag_link_unlink(struct ice_lag *lag, void *ptr)
 
  	if (info->linking) {
  		ice_lag_link(lag);
+		ice_lag_cfg_pfmac_fltrs(lag, true);
  	} else {
+		ice_lag_cfg_pfmac_fltrs(lag, false);
  		if (lag->bond_aa)
  			ice_lag_aa_unlink(lag);
  		else
@@ -2622,6 +2712,11 @@ int ice_init_lag(struct ice_pf *pf)
  	if (err)
  		goto  free_lport_res;
 
+	err = ice_create_lag_recipe(&pf->hw, &lag->pfmac_recipe,
+				    ice_pfmac_rcp, 3);
+	if (err)
+		goto free_act_act_res;
+
  	/* associate recipes to profiles */
  	for (n = 0; n < ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER; n++) {
  		err = ice_aq_get_recipe_to_profile(&pf->hw, n,
@@ -2643,6 +2738,10 @@ int ice_init_lag(struct ice_pf *pf)
  	dev_dbg(dev, "INIT LAG complete\n");
  	return 0;
 
+free_act_act_res:
+	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
+			&pf->lag->act_act_recipe);
+
  free_lport_res:
  	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
  			&lag->lport_recipe);
@@ -2679,6 +2778,8 @@ void ice_deinit_lag(struct ice_pf *pf)
  			&pf->lag->pf_recipe);
  	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
  			&pf->lag->lport_recipe);
+	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
+			&pf->lag->pfmac_recipe);
 
  	kfree(lag);
 
drivers/net/ethernet/intel/ice/ice_lag.h +2 -0
index f77ebcd61042..f1bff43228ee 100644
@@ -60,11 +60,16 @@ struct ice_lag {
  	u16 pf_recipe;
  	u16 lport_recipe;
  	u16 act_act_recipe;
+	u16 pfmac_recipe;
+

drivers/net/ethernet/intel/ice/ice_lag.h struct ice_lag { · line 74

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.h +3 -0
  	u16 pf_rx_rule_id;
  	u16 pf_tx_rule_id;
  	u16 cp_rule_idx;
  	u16 lport_rule_idx;
  	u16 act_act_rule_idx;
+	u16 pfmac_unicst_idx;
+	u16 pfmac_bdcst_idx;
+
  	u8 role;
  };

With the above addressed:

Kind regards,

Paul

#2 lore raw
Quoted 13 lines

-----Original Message-----
From: Paul Menzel <[email protected]>
Sent: Saturday, October 4, 2025 5:01 AM
To: Ertman, David M <[email protected]>
Cc: [email protected]
Subject: Re: [Intel-wired-lan] [PATCH iwl-net] ice: Add lport/MAC rules for PF traffic in bonds

Dear Dave,

Thank you for the patch.

Quoted 7 lines

Am 03.10.25 um 18:27 schrieb Dave Ertman:

Quoted 4 lines

When two E8XX interfaces are placed into a bond, and are correctly configured for supporting SRIOV traffic over the bonded interfaces, there is a problem with traffic aimed directly at the bond netdev. By conjoining both interfaces onto a single switch black in the NIC, all

Sorry, what is a “single switch black“? bl*o*ck?

Yes, was meant to be "block" 😊

Quoted 10 lines
Quoted 8 lines

unicast and broadcast traffic is being directed to the primary interface's set of resources no matter which interface is the active/targeting one.

To fix this, add a set of rules into the switch block that combines both target MAC address and source logical port to direct packets to the active/targeted VSI. This change will not touch traffic directed to SRIOV VF targets.

Please document a reproducer, if you have one.

This is hard to showcase, as it is an internal packet resource issue. It fixes the resources so that they are correctly utilized, but the external aberrant behavior is something that won't display until future features are built on top of this.

Quoted 21 lines
Quoted 2 lines
Fixes ec5a6c5f79ed ("ice: process events created by lag netdev event

handler")

Review

Quoted 7 lines
---
  drivers/net/ethernet/intel/ice/ice_lag.c | 101 +++++++++++++++++++++++
  drivers/net/ethernet/intel/ice/ice_lag.h |   5 ++
  2 files changed, 106 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_lag.c

drivers/net/ethernet/intel/ice/ice_lag.c static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = {

Quoted 4 lines

index d2576d606e10..7773d5b9bae9 100644

drivers/net/ethernet/intel/ice/ice_lag.c +0 -0
@@ -17,6 +17,7 @@ static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = {

0, 0, 0, 0, 0, 0,

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_lag.c +1 -0
  static const u8 act_act_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
  							 0, 0, 0, 0, 0, 0,
  							 0, 0, 0, 0 };
+static u8 mac_train_pkt[ICE_TRAIN_PKT_LEN] = { 0 };
 
Quoted 13 lines

drivers/net/ethernet/intel/ice/ice_lag.c static const u8 ice_lport_rcp[ICE_RECIPE_LEN] = { · line 36

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +4 -0
  #define ICE_RECIPE_LEN			64
  #define ICE_LAG_SRIOV_CP_RECIPE		10
@@ -29,6 +30,10 @@ static const u8 ice_lport_rcp[ICE_RECIPE_LEN] = {
  	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  	0x85, 0, 0x16, 0, 0, 0, 0xff, 0xff, 0x07, 0, 0, 0, 0, 0, 0, 0,
  	0, 0, 0, 0, 0, 0, 0x30 };
+static const u8 ice_pfmac_rcp[ICE_RECIPE_LEN] = {
+	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x85, 0, 0x16,
+	0x05, 0x06, 0x07, 0xff, 0xff, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0, 0, 0, 0, 0, 0, 0x30 };

Excuse my ignorance, how can these numbers be reviewed?

I understand your concern here, but this is a "formula" that Is used by the HW/FW to create a switch routing entry. I am not sure how to make this easier to review ☹

Quoted 8 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag,

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_lag.c +0 -0
  /**
   * ice_lag_set_primary - set PF LAG state as Primary
@@ -1336,6 +1341,89 @@ ice_lag_reclaim_vf_nodes(struct ice_lag *lag,

struct ice_hw *src_hw)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_lag.c +0 -0
  				ice_lag_reclaim_vf_tc(lag, src_hw, i, tc);
  }
 
Quoted 9 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1349

Quoted 6 lines
drivers/net/ethernet/intel/ice/ice_lag.c +6 -0
+/**
+ * ice_lag_cfg_pfmac_fltrs
+ * @lag: local lag info struct
+ * @link: is this a linking action
+ *
+ * Configure lport/MAC filters for this interfaces PF traffic in the

interface’s

Fized

Quoted 11 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1358

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_lag.c +9 -0
+ * current interfaces SWID
+ */
+static void ice_lag_cfg_pfmac_fltrs(struct ice_lag *lag, bool link)
+{
+	u8 lport = lag->pf->hw.port_info->lport;
+	struct ice_sw_rule_lkup_rx_tx *s_rule;
+	struct ice_vsi *vsi = lag->pf->vsi[0];
+	struct ice_hw *hw = &lag->pf->hw;
+	u16 s_rule_sz;

size_t?

Changed

Quoted 30 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
+	u32 act;
+
+	act = ICE_FWD_TO_VSI | ICE_SINGLE_ACT_LAN_ENABLE |

ICE_SINGLE_ACT_VALID_BIT |

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
+		FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi->vsi_num);
+
+	s_rule_sz = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule,

ICE_TRAIN_PKT_LEN);

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
+	s_rule = kzalloc(s_rule_sz, GFP_KERNEL);
+	if (!s_rule) {
+		netdev_warn(lag->netdev, "-ENOMEM error configuring

PFMAC filters\n");

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +9 -0
+		return;
+	}
+
+	if (link) {
+		u8 broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+		/* unicast */
+		ether_addr_copy(mac_train_pkt, lag->upper_netdev-
 dev_addr);
+		memcpy(s_rule->hdr_data, mac_train_pkt,

ICE_TRAIN_PKT_LEN);

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_lag.c +5 -0
+		s_rule->recipe_id = cpu_to_le16(lag->pfmac_recipe);
+		s_rule->src = cpu_to_le16(lport);
+		s_rule->act = cpu_to_le32(act);
+		s_rule->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
+		s_rule->hdr.type =

cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);

Quoted 7 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_lag.c +4 -0
+
+		if (ice_aq_sw_rules(hw, s_rule, s_rule_sz, 1,
+				    ice_aqc_opc_add_sw_rules, NULL)) {
+			netdev_warn(lag->netdev, "Error ADDING Unicast

PFMAC rule for aggregate\n");

Log the return value?

Flow changed to include return value in err messages

Quoted 10 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_lag.c +8 -0
+			goto err_pfmac_free;
+		}
+
+		lag->pfmac_unicst_idx = le16_to_cpu(s_rule->index);
+
+		/* broadast */
+		ether_addr_copy(mac_train_pkt, broadcast);
+		memcpy(s_rule->hdr_data, mac_train_pkt,

ICE_TRAIN_PKT_LEN);

Quoted 6 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
+		if (ice_aq_sw_rules(hw, s_rule, s_rule_sz, 1,
+				    ice_aqc_opc_add_sw_rules, NULL)) {
+			netdev_warn(lag->netdev, "Error ADDING Broadcast

PFMAC rule for aggregate\n");

Log the return value?

Fixed

Quoted 12 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1409

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_lag.c +10 -0
+			goto err_pfmac_free;
+		}
+
+		lag->pfmac_bdcst_idx = le16_to_cpu(s_rule->index);
+	} else {
+		/* unicast */
+		s_rule->index = cpu_to_le16(lag->pfmac_unicst_idx);
+		if (s_rule->index && ice_aq_sw_rules(&lag->pf->hw, s_rule,
+						     s_rule_sz, 1,
+

ice_aqc_opc_remove_sw_rules,

Quoted 5 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, · line 1409

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_lag.c +2 -0
+						     NULL))
+			netdev_warn(lag->netdev, "Error REMOVING Unicast

PFMAC rule for aggregate\n");

Log the return value?

Fixed

Quoted 10 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1419

Quoted 9 lines
drivers/net/ethernet/intel/ice/ice_lag.c +8 -0
+
+		lag->pfmac_unicst_idx = 0;
+
+		/* broadcast */
+		s_rule->index = cpu_to_le16(lag->pfmac_bdcst_idx);
+		if (s_rule->index && ice_aq_sw_rules(&lag->pf->hw, s_rule,
+						     s_rule_sz, 1,
+

ice_aqc_opc_remove_sw_rules,

Quoted 5 lines

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, · line 1419

Quoted 2 lines
drivers/net/ethernet/intel/ice/ice_lag.c +2 -0
+						     NULL))
+			netdev_warn(lag->netdev, "Error REMOVING

Broadcast PFMAC rule for aggregate\n");

Log the return value?

Fixed

Quoted 85 lines

drivers/net/ethernet/intel/ice/ice_lag.c static void ice_lag_link_unlink(struct ice_lag *lag,

Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_lag.c +8 -0
+
+		lag->pfmac_bdcst_idx = 0;
+	}
+
+err_pfmac_free:
+	kfree(s_rule);
+}
+
  /**
   * ice_lag_link - handle LAG link event

* @lag: LAG info struct

drivers/net/ethernet/intel/ice/ice_lag.c +0 -0
@@ -1437,7 +1525,9 @@ static void ice_lag_link_unlink(struct ice_lag *lag,

void *ptr)

Review

Quoted 42 lines
drivers/net/ethernet/intel/ice/ice_lag.c +13 -0
  	if (info->linking) {
  		ice_lag_link(lag);
+		ice_lag_cfg_pfmac_fltrs(lag, true);
  	} else {
+		ice_lag_cfg_pfmac_fltrs(lag, false);
  		if (lag->bond_aa)
  			ice_lag_aa_unlink(lag);
  		else
@@ -2622,6 +2712,11 @@ int ice_init_lag(struct ice_pf *pf)
  	if (err)
  		goto  free_lport_res;
 
+	err = ice_create_lag_recipe(&pf->hw, &lag->pfmac_recipe,
+				    ice_pfmac_rcp, 3);
+	if (err)
+		goto free_act_act_res;
+
  	/* associate recipes to profiles */
  	for (n = 0; n < ICE_PROFID_IPV6_GTPU_IPV6_TCP_INNER; n++) {
  		err = ice_aq_get_recipe_to_profile(&pf->hw, n,
@@ -2643,6 +2738,10 @@ int ice_init_lag(struct ice_pf *pf)
  	dev_dbg(dev, "INIT LAG complete\n");
  	return 0;
 
+free_act_act_res:
+	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
+			&pf->lag->act_act_recipe);
+
  free_lport_res:
  	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
  			&lag->lport_recipe);
@@ -2679,6 +2778,8 @@ void ice_deinit_lag(struct ice_pf *pf)
  			&pf->lag->pf_recipe);
  	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
  			&pf->lag->lport_recipe);
+	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
+			&pf->lag->pfmac_recipe);
 
  	kfree(lag);
 
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_lag.h

Quoted 9 lines

index f77ebcd61042..f1bff43228ee 100644

drivers/net/ethernet/intel/ice/ice_lag.h +2 -0
@@ -60,11 +60,16 @@ struct ice_lag {
  	u16 pf_recipe;
  	u16 lport_recipe;
  	u16 act_act_recipe;
+	u16 pfmac_recipe;
+

drivers/net/ethernet/intel/ice/ice_lag.h struct ice_lag { · line 74

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.h +3 -0
  	u16 pf_rx_rule_id;
  	u16 pf_tx_rule_id;
  	u16 cp_rule_idx;
  	u16 lport_rule_idx;
  	u16 act_act_rule_idx;
+	u16 pfmac_unicst_idx;
+	u16 pfmac_bdcst_idx;
+
  	u8 role;
  };

With the above addressed:

Kind regards,

Paul

#3 lore raw
In reply to Dave Ertman
Quoted 24 lines · Dave Ertman

When two E8XX interfaces are placed into a bond, and are correctly configured for supporting SRIOV traffic over the bonded interfaces, there is a problem with traffic aimed directly at the bond netdev. By conjoining both interfaces onto a single switch black in the NIC, all unicast and broadcast traffic is being directed to the primary interface's set of resources no matter which interface is the active/targeting one.

To fix this, add a set of rules into the switch block that combines both target MAC address and source logical port to direct packets to the active/targeted VSI. This change will not touch traffic directed to SRIOV VF targets.

Fixes ec5a6c5f79ed ("ice: process events created by lag netdev event handler")
---
 drivers/net/ethernet/intel/ice/ice_lag.c | 101 +++++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_lag.h |   5 ++
 2 files changed, 106 insertions(+)
drivers/net/ethernet/intel/ice/ice_lag.c +0 -0
index d2576d606e10..7773d5b9bae9 100644

drivers/net/ethernet/intel/ice/ice_lag.c static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0, · line 21

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_lag.c +1 -0
@@ -17,6 +17,7 @@ static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
 static const u8 act_act_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
 							 0, 0, 0, 0, 0, 0,
 							 0, 0, 0, 0 };
+static u8 mac_train_pkt[ICE_TRAIN_PKT_LEN] = { 0 };
 

Is there any way this static global variable could be either allocated or made part of the LAG structure or something?

You're using it as some sort of storage from what I can tell, but I really don't like that its a driver global and open to a lot of potential race conditions.

For that matter, its only accessed a couple of times, and each time its used to copy a value into it and then copy that into something else.. Can you explain whats going on with that and why it even needs a global variable like this??

Quoted 40 lines
drivers/net/ethernet/intel/ice/ice_lag.c +27 -0
 #define ICE_RECIPE_LEN			64
 #define ICE_LAG_SRIOV_CP_RECIPE		10
@@ -29,6 +30,10 @@ static const u8 ice_lport_rcp[ICE_RECIPE_LEN] = {
 	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0x85, 0, 0x16, 0, 0, 0, 0xff, 0xff, 0x07, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0x30 };
+static const u8 ice_pfmac_rcp[ICE_RECIPE_LEN] = {
+	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x85, 0, 0x16,
+	0x05, 0x06, 0x07, 0xff, 0xff, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0, 0, 0, 0, 0, 0, 0x30 };
 
 /**
  * ice_lag_set_primary - set PF LAG state as Primary
@@ -1336,6 +1341,89 @@ ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)
 				ice_lag_reclaim_vf_tc(lag, src_hw, i, tc);
 }
 
+/**
+ * ice_lag_cfg_pfmac_fltrs
+ * @lag: local lag info struct
+ * @link: is this a linking action
+ *
+ * Configure lport/MAC filters for this interfaces PF traffic in the
+ * current interfaces SWID
+ */
+static void ice_lag_cfg_pfmac_fltrs(struct ice_lag *lag, bool link)
+{
+	u8 lport = lag->pf->hw.port_info->lport;
+	struct ice_sw_rule_lkup_rx_tx *s_rule;
+	struct ice_vsi *vsi = lag->pf->vsi[0];
+	struct ice_hw *hw = &lag->pf->hw;
+	u16 s_rule_sz;
+	u32 act;
+
+	act = ICE_FWD_TO_VSI | ICE_SINGLE_ACT_LAN_ENABLE | ICE_SINGLE_ACT_VALID_BIT |
+		FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi->vsi_num);
+
+	s_rule_sz = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, ICE_TRAIN_PKT_LEN);
+	s_rule = kzalloc(s_rule_sz, GFP_KERNEL);
+	if (!s_rule) {

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1376

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +10 -0
+		netdev_warn(lag->netdev, "-ENOMEM error configuring PFMAC filters\n");
+		return;
+	}
+
+	if (link) {
+		u8 broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+		/* unicast */
+		ether_addr_copy(mac_train_pkt, lag->upper_netdev->dev_addr);
+		memcpy(s_rule->hdr_data, mac_train_pkt, ICE_TRAIN_PKT_LEN);

Here, you copy dev_addr into it, then you copy that back into s_rule->hdr_data...

Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_lag.c +7 -0
+		s_rule->recipe_id = cpu_to_le16(lag->pfmac_recipe);
+		s_rule->src = cpu_to_le16(lport);
+		s_rule->act = cpu_to_le32(act);
+		s_rule->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
+		s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);
+
+		if (ice_aq_sw_rules(hw, s_rule, s_rule_sz, 1,

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw) · line 1393

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +10 -0
+				    ice_aqc_opc_add_sw_rules, NULL)) {
+			netdev_warn(lag->netdev, "Error ADDING Unicast PFMAC rule for aggregate\n");
+			goto err_pfmac_free;
+		}
+
+		lag->pfmac_unicst_idx = le16_to_cpu(s_rule->index);
+
+		/* broadast */
+		ether_addr_copy(mac_train_pkt, broadcast);
+		memcpy(s_rule->hdr_data, mac_train_pkt, ICE_TRAIN_PKT_LEN);

And here, you copy the broadcast into it, and then copy that into the s_rule_hdr_data...

But why not just copy directly into the s_rule->hdr_data instead of copying twice? Literally nothing else interacts with mac_train_pkt introduced in this patch, so we needlessly copy, and result in using a value that could be modified by another thread possibly even on another PF since its a global variable...

Please fix this.

#4 lore raw
Quoted 140 lines

-----Original Message-----
From: Keller, Jacob E <[email protected]>
Sent: Monday, October 6, 2025 3:59 PM
To: Ertman, David M <[email protected]>; intel-wired- [email protected]
Subject: Re: [Intel-wired-lan] [PATCH iwl-net] ice: Add lport/MAC rules for PF traffic in bonds

Quoted 7 lines · Dave Ertman

When two E8XX interfaces are placed into a bond, and are correctly configured for supporting SRIOV traffic over the bonded interfaces, there is a problem with traffic aimed directly at the bond netdev. By conjoining both interfaces onto a single switch black in the NIC, all unicast and broadcast traffic is being directed to the primary interface's set of resources no matter which interface is the active/targeting one.

Quoted 6 lines

To fix this, add a set of rules into the switch block that combines both target MAC address and source logical port to direct packets to the active/targeted VSI. This change will not touch traffic directed to SRIOV VF targets.

Fixes ec5a6c5f79ed ("ice: process events created by lag netdev event

handler")

Review

Quoted 7 lines
---
 drivers/net/ethernet/intel/ice/ice_lag.c | 101 +++++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_lag.h |   5 ++
 2 files changed, 106 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_lag.c

drivers/net/ethernet/intel/ice/ice_lag.c static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = {

Quoted 4 lines

index d2576d606e10..7773d5b9bae9 100644

drivers/net/ethernet/intel/ice/ice_lag.c +0 -0
@@ -17,6 +17,7 @@ static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = {

0, 0, 0, 0, 0, 0,

drivers/net/ethernet/intel/ice/ice_lag.c static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0, · line 21

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_lag.c +1 -0
 static const u8 act_act_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
 							 0, 0, 0, 0, 0, 0,
 							 0, 0, 0, 0 };
+static u8 mac_train_pkt[ICE_TRAIN_PKT_LEN] = { 0 };
 

Is there any way this static global variable could be either allocated or made part of the LAG structure or something?

You're using it as some sort of storage from what I can tell, but I really don't like that its a driver global and open to a lot of potential race conditions.

For that matter, its only accessed a couple of times, and each time its used to copy a value into it and then copy that into something else.. Can you explain whats going on with that and why it even needs a global variable like this??

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag,

Quoted 14 lines
drivers/net/ethernet/intel/ice/ice_lag.c +4 -0
 #define ICE_RECIPE_LEN			64
 #define ICE_LAG_SRIOV_CP_RECIPE		10
@@ -29,6 +30,10 @@ static const u8 ice_lport_rcp[ICE_RECIPE_LEN] = {
 	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0x85, 0, 0x16, 0, 0, 0, 0xff, 0xff, 0x07, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0x30 };
+static const u8 ice_pfmac_rcp[ICE_RECIPE_LEN] = {
+	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x85, 0, 0x16,
+	0x05, 0x06, 0x07, 0xff, 0xff, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0, 0, 0, 0, 0, 0, 0x30 };
 
 /**
  * ice_lag_set_primary - set PF LAG state as Primary
@@ -1336,6 +1341,89 @@ ice_lag_reclaim_vf_nodes(struct ice_lag *lag,

struct ice_hw *src_hw)

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_lag.c +8 -0
 				ice_lag_reclaim_vf_tc(lag, src_hw, i, tc);
 }
 
+/**
+ * ice_lag_cfg_pfmac_fltrs
+ * @lag: local lag info struct
+ * @link: is this a linking action
+ *
+ * Configure lport/MAC filters for this interfaces PF traffic in the
+ * current interfaces SWID
+ */

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +10 -0
+static void ice_lag_cfg_pfmac_fltrs(struct ice_lag *lag, bool link)
+{
+	u8 lport = lag->pf->hw.port_info->lport;
+	struct ice_sw_rule_lkup_rx_tx *s_rule;
+	struct ice_vsi *vsi = lag->pf->vsi[0];
+	struct ice_hw *hw = &lag->pf->hw;
+	u16 s_rule_sz;
+	u32 act;
+
+	act = ICE_FWD_TO_VSI | ICE_SINGLE_ACT_LAN_ENABLE |

ICE_SINGLE_ACT_VALID_BIT |

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
+		FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi->vsi_num);
+
+	s_rule_sz = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule,

ICE_TRAIN_PKT_LEN);

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
+	s_rule = kzalloc(s_rule_sz, GFP_KERNEL);
+	if (!s_rule) {
+		netdev_warn(lag->netdev, "-ENOMEM error configuring

PFMAC filters\n");

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +9 -0
+		return;
+	}
+
+	if (link) {
+		u8 broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+		/* unicast */
+		ether_addr_copy(mac_train_pkt, lag->upper_netdev-
 dev_addr);
+		memcpy(s_rule->hdr_data, mac_train_pkt,

ICE_TRAIN_PKT_LEN);

Here, you copy dev_addr into it, then you copy that back into s_rule->hdr_data...

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_lag.c +5 -0
+		s_rule->recipe_id = cpu_to_le16(lag->pfmac_recipe);
+		s_rule->src = cpu_to_le16(lport);
+		s_rule->act = cpu_to_le32(act);
+		s_rule->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
+		s_rule->hdr.type =

cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_lag.c +4 -0
+
+		if (ice_aq_sw_rules(hw, s_rule, s_rule_sz, 1,
+				    ice_aqc_opc_add_sw_rules, NULL)) {
+			netdev_warn(lag->netdev, "Error ADDING Unicast

PFMAC rule for aggregate\n");

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_lag.c +8 -0
+			goto err_pfmac_free;
+		}
+
+		lag->pfmac_unicst_idx = le16_to_cpu(s_rule->index);
+
+		/* broadast */
+		ether_addr_copy(mac_train_pkt, broadcast);
+		memcpy(s_rule->hdr_data, mac_train_pkt,

ICE_TRAIN_PKT_LEN);

And here, you copy the broadcast into it, and then copy that into the s_rule_hdr_data...

Quoted 7 lines

But why not just copy directly into the s_rule->hdr_data instead of copying twice? Literally nothing else interacts with mac_train_pkt introduced in this patch, so we needlessly copy, and result in using a value that could be modified by another thread possibly even on another PF since its a global variable...

Please fix this.

Yeah - I think you are right. I originally wrote this following the pattern already Present in the code, but with this packet starting with all zeros there is no need for It to be a const.

Will rewrite this using a local variable.

DaveE

#5 lore raw
Quoted 149 lines · David M
Quoted 140 lines

-----Original Message-----
From: Keller, Jacob E <[email protected]>
Sent: Monday, October 6, 2025 3:59 PM
To: Ertman, David M <[email protected]>; intel-wired- [email protected]
Subject: Re: [Intel-wired-lan] [PATCH iwl-net] ice: Add lport/MAC rules for PF traffic in bonds

Quoted 7 lines · Dave Ertman

When two E8XX interfaces are placed into a bond, and are correctly configured for supporting SRIOV traffic over the bonded interfaces, there is a problem with traffic aimed directly at the bond netdev. By conjoining both interfaces onto a single switch black in the NIC, all unicast and broadcast traffic is being directed to the primary interface's set of resources no matter which interface is the active/targeting one.

Quoted 6 lines

To fix this, add a set of rules into the switch block that combines both target MAC address and source logical port to direct packets to the active/targeted VSI. This change will not touch traffic directed to SRIOV VF targets.

Fixes ec5a6c5f79ed ("ice: process events created by lag netdev event

handler")

Review

Quoted 7 lines
---
 drivers/net/ethernet/intel/ice/ice_lag.c | 101 +++++++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_lag.h |   5 ++
 2 files changed, 106 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/intel/ice/ice_lag.c

drivers/net/ethernet/intel/ice/ice_lag.c static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = {

Quoted 4 lines

index d2576d606e10..7773d5b9bae9 100644

drivers/net/ethernet/intel/ice/ice_lag.c +0 -0
@@ -17,6 +17,7 @@ static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = {

0, 0, 0, 0, 0, 0,

drivers/net/ethernet/intel/ice/ice_lag.c static const u8 lacp_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0, · line 21

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_lag.c +1 -0
 static const u8 act_act_train_pkt[ICE_TRAIN_PKT_LEN] = { 0, 0, 0, 0, 0, 0,
 							 0, 0, 0, 0, 0, 0,
 							 0, 0, 0, 0 };
+static u8 mac_train_pkt[ICE_TRAIN_PKT_LEN] = { 0 };
 

Is there any way this static global variable could be either allocated or made part of the LAG structure or something?

You're using it as some sort of storage from what I can tell, but I really don't like that its a driver global and open to a lot of potential race conditions.

For that matter, its only accessed a couple of times, and each time its used to copy a value into it and then copy that into something else.. Can you explain whats going on with that and why it even needs a global variable like this??

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag,

Quoted 14 lines
drivers/net/ethernet/intel/ice/ice_lag.c +4 -0
 #define ICE_RECIPE_LEN			64
 #define ICE_LAG_SRIOV_CP_RECIPE		10
@@ -29,6 +30,10 @@ static const u8 ice_lport_rcp[ICE_RECIPE_LEN] = {
 	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0x85, 0, 0x16, 0, 0, 0, 0xff, 0xff, 0x07, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0x30 };
+static const u8 ice_pfmac_rcp[ICE_RECIPE_LEN] = {
+	0x05, 0, 0, 0, 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x85, 0, 0x16,
+	0x05, 0x06, 0x07, 0xff, 0xff, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff,
+	0xff, 0xff, 0, 0, 0, 0, 0, 0, 0x30 };
 
 /**
  * ice_lag_set_primary - set PF LAG state as Primary
@@ -1336,6 +1341,89 @@ ice_lag_reclaim_vf_nodes(struct ice_lag *lag,

struct ice_hw *src_hw)

Quoted 11 lines
drivers/net/ethernet/intel/ice/ice_lag.c +8 -0
 				ice_lag_reclaim_vf_tc(lag, src_hw, i, tc);
 }
 
+/**
+ * ice_lag_cfg_pfmac_fltrs
+ * @lag: local lag info struct
+ * @link: is this a linking action
+ *
+ * Configure lport/MAC filters for this interfaces PF traffic in the
+ * current interfaces SWID
+ */

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +10 -0
+static void ice_lag_cfg_pfmac_fltrs(struct ice_lag *lag, bool link)
+{
+	u8 lport = lag->pf->hw.port_info->lport;
+	struct ice_sw_rule_lkup_rx_tx *s_rule;
+	struct ice_vsi *vsi = lag->pf->vsi[0];
+	struct ice_hw *hw = &lag->pf->hw;
+	u16 s_rule_sz;
+	u32 act;
+
+	act = ICE_FWD_TO_VSI | ICE_SINGLE_ACT_LAN_ENABLE |

ICE_SINGLE_ACT_VALID_BIT |

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
+		FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi->vsi_num);
+
+	s_rule_sz = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule,

ICE_TRAIN_PKT_LEN);

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 3 lines
drivers/net/ethernet/intel/ice/ice_lag.c +3 -0
+	s_rule = kzalloc(s_rule_sz, GFP_KERNEL);
+	if (!s_rule) {
+		netdev_warn(lag->netdev, "-ENOMEM error configuring

PFMAC filters\n");

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 10 lines
drivers/net/ethernet/intel/ice/ice_lag.c +9 -0
+		return;
+	}
+
+	if (link) {
+		u8 broadcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+		/* unicast */
+		ether_addr_copy(mac_train_pkt, lag->upper_netdev-
 dev_addr);
+		memcpy(s_rule->hdr_data, mac_train_pkt,

ICE_TRAIN_PKT_LEN);

Here, you copy dev_addr into it, then you copy that back into s_rule->hdr_data...

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 5 lines
drivers/net/ethernet/intel/ice/ice_lag.c +5 -0
+		s_rule->recipe_id = cpu_to_le16(lag->pfmac_recipe);
+		s_rule->src = cpu_to_le16(lport);
+		s_rule->act = cpu_to_le32(act);
+		s_rule->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
+		s_rule->hdr.type =

cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_lag.c +4 -0
+
+		if (ice_aq_sw_rules(hw, s_rule, s_rule_sz, 1,
+				    ice_aqc_opc_add_sw_rules, NULL)) {
+			netdev_warn(lag->netdev, "Error ADDING Unicast

PFMAC rule for aggregate\n");

drivers/net/ethernet/intel/ice/ice_lag.c ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)

Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_lag.c +8 -0
+			goto err_pfmac_free;
+		}
+
+		lag->pfmac_unicst_idx = le16_to_cpu(s_rule->index);
+
+		/* broadast */
+		ether_addr_copy(mac_train_pkt, broadcast);
+		memcpy(s_rule->hdr_data, mac_train_pkt,

ICE_TRAIN_PKT_LEN);

And here, you copy the broadcast into it, and then copy that into the s_rule_hdr_data...

Quoted 7 lines

But why not just copy directly into the s_rule->hdr_data instead of copying twice? Literally nothing else interacts with mac_train_pkt introduced in this patch, so we needlessly copy, and result in using a value that could be modified by another thread possibly even on another PF since its a global variable...

Please fix this.

Quoted 7 lines

Yeah - I think you are right. I originally wrote this following the pattern already Present in the code, but with this packet starting with all zeros there is no need for It to be a const.

Will rewrite this using a local variable.

DaveE

I still don't understand why you can't just do this:

ether_addr_copy(s_rule->hdr_data, broadcast)

and

ether_addr_copy(s_rule->hdr_data, lag->upper_netdev->dev_addr)

without the extra temporary buffer?

The memcpy is using ICE_TRAIN_PKT_LEN.. is that not the same size as the dev_addr? Is it because ICE_TRAIN_PKT_LEN is 16 bytes, and you're copying a bunch of zeros over as well?

But why not just memset and then copy the address in?

memset(s_rule->hdr_data, 0, sizeof(s_rule->hdr_data)); ether_addr_copy(s_rule->hdr_data, lag->upper_netdev->dev_addr);

Thanks,
Jake

#6 lore raw
Quoted 36 lines
Quoted 9 lines
Quoted 9 lines

And here, you copy the broadcast into it, and then copy that into the s_rule_hdr_data...

But why not just copy directly into the s_rule->hdr_data instead of copying twice? Literally nothing else interacts with mac_train_pkt introduced in this patch, so we needlessly copy, and result in using a value that could be modified by another thread possibly even on another PF since its a global variable...

Quoted 4 lines
Quoted 1 line

Please fix this.

Yeah - I think you are right. I originally wrote this following the pattern

already

Quoted 1 line

Present in the code, but with this packet starting with all zeros there is no

need for

Quoted 5 lines

It to be a const.

Will rewrite this using a local variable.

DaveE

I still don't understand why you can't just do this:

ether_addr_copy(s_rule->hdr_data, broadcast)

and

ether_addr_copy(s_rule->hdr_data, lag->upper_netdev->dev_addr)

without the extra temporary buffer?

The memcpy is using ICE_TRAIN_PKT_LEN.. is that not the same size as the dev_addr? Is it because ICE_TRAIN_PKT_LEN is 16 bytes, and you're copying a bunch of zeros over as well?

Quoted 7 lines

But why not just memset and then copy the address in?

memset(s_rule->hdr_data, 0, sizeof(s_rule->hdr_data)); ether_addr_copy(s_rule->hdr_data, lag->upper_netdev->dev_addr);

Thanks,
Jake

memset and ether_addr_copy (or eth_broadcast_addr) is actually what I ended up doing 😊

DaveE