Active-Active

In the SRIOV LAG Active-Active, the functions ice_lag_cfg_pf_fltr's
and ice_lag_config_eswitch's content are moved to earlier locations
in the source file.  Also, ice_lag_cfg_pf_fltr is renamed, and its
flow is changed.

To reduce the delta in the larger patch, move the original functions
to their new location so that only functional changes are needed in
the larger patch.

Reviewed-by: Przemek Kitszel <[email protected]>
Signed-off-by: Dave Ertman <[email protected]>
---
 drivers/net/ethernet/intel/ice/ice_lag.c | 147 ++++++++++++-----------
 1 file changed, 74 insertions(+), 73 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lag.c 
b/drivers/net/ethernet/intel/ice/ice_lag.c
index 3d5918a270a4..0c6dbf712897 100644
--- a/drivers/net/ethernet/intel/ice/ice_lag.c
+++ b/drivers/net/ethernet/intel/ice/ice_lag.c
@@ -100,6 +100,28 @@ static bool netif_is_same_ice(struct ice_pf *pf, struct 
net_device *netdev)
        return true;
 }
 
+/**
+ * ice_lag_config_eswitch - configure eswitch to work with LAG
+ * @lag: lag info struct
+ * @netdev: active network interface device struct
+ *
+ * Updates all port representors in eswitch to use @netdev for Tx.
+ *
+ * Configures the netdev to keep dst metadata (also used in representor Tx).
+ * This is required for an uplink without switchdev mode configured.
+ */
+static void ice_lag_config_eswitch(struct ice_lag *lag,
+                                  struct net_device *netdev)
+{
+       struct ice_repr *repr;
+       unsigned long id;
+
+       xa_for_each(&lag->pf->eswitch.reprs, id, repr)
+               repr->dst->u.port_info.lower_dev = netdev;
+
+       netif_keep_dst(netdev);
+}
+
 /**
  * ice_netdev_to_lag - return pointer to associated lag struct from netdev
  * @netdev: pointer to net_device struct to query
@@ -354,6 +376,58 @@ ice_lag_cfg_pf_fltrs(struct ice_lag *lag, void *ptr)
        }
 }
 
+/**
+ * ice_lag_cfg_cp_fltr - configure filter for control packets
+ * @lag: local interface's lag struct
+ * @add: add or remove rule
+ */
+static void
+ice_lag_cfg_cp_fltr(struct ice_lag *lag, bool add)
+{
+       struct ice_sw_rule_lkup_rx_tx *s_rule = NULL;
+       struct ice_vsi *vsi;
+       u16 buf_len, opc;
+
+       vsi = lag->pf->vsi[0];
+
+       buf_len = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, ICE_TRAIN_PKT_LEN);
+       s_rule = kzalloc(buf_len, GFP_KERNEL);
+       if (!s_rule) {
+               netdev_warn(lag->netdev, "-ENOMEM error configuring CP 
filter\n");
+               return;
+       }
+
+       if (add) {
+               s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);
+               s_rule->recipe_id = cpu_to_le16(ICE_LAG_SRIOV_CP_RECIPE);
+               s_rule->src = cpu_to_le16(vsi->port_info->lport);
+               s_rule->act = cpu_to_le32(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->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
+               memcpy(s_rule->hdr_data, lacp_train_pkt, ICE_TRAIN_PKT_LEN);
+               opc = ice_aqc_opc_add_sw_rules;
+       } else {
+               opc = ice_aqc_opc_remove_sw_rules;
+               s_rule->index = cpu_to_le16(lag->cp_rule_idx);
+       }
+       if (ice_aq_sw_rules(&lag->pf->hw, s_rule, buf_len, 1, opc, NULL)) {
+               netdev_warn(lag->netdev, "Error %s CP rule for fail-over\n",
+                           add ? "ADDING" : "REMOVING");
+               goto err_cp_free;
+       }
+
+       if (add)
+               lag->cp_rule_idx = le16_to_cpu(s_rule->index);
+       else
+               lag->cp_rule_idx = 0;
+
+err_cp_free:
+       kfree(s_rule);
+}
+
 /**
  * ice_display_lag_info - print LAG info
  * @lag: LAG info struct
@@ -768,57 +842,6 @@ void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 
src_prt, u8 dst_prt)
        ice_lag_destroy_netdev_list(lag, &ndlist);
 }
 
-/**
- * ice_lag_cfg_cp_fltr - configure filter for control packets
- * @lag: local interface's lag struct
- * @add: add or remove rule
- */
-static void
-ice_lag_cfg_cp_fltr(struct ice_lag *lag, bool add)
-{
-       struct ice_sw_rule_lkup_rx_tx *s_rule = NULL;
-       struct ice_vsi *vsi;
-       u16 buf_len, opc;
-
-       vsi = lag->pf->vsi[0];
-
-       buf_len = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, ICE_TRAIN_PKT_LEN);
-       s_rule = kzalloc(buf_len, GFP_KERNEL);
-       if (!s_rule) {
-               netdev_warn(lag->netdev, "-ENOMEM error configuring CP 
filter\n");
-               return;
-       }
-
-       if (add) {
-               s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);
-               s_rule->recipe_id = cpu_to_le16(ICE_LAG_SRIOV_CP_RECIPE);
-               s_rule->src = cpu_to_le16(vsi->port_info->lport);
-               s_rule->act = cpu_to_le32(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->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
-               memcpy(s_rule->hdr_data, lacp_train_pkt, ICE_TRAIN_PKT_LEN);
-               opc = ice_aqc_opc_add_sw_rules;
-       } else {
-               opc = ice_aqc_opc_remove_sw_rules;
-               s_rule->index = cpu_to_le16(lag->cp_rule_idx);
-       }
-       if (ice_aq_sw_rules(&lag->pf->hw, s_rule, buf_len, 1, opc, NULL)) {
-               netdev_warn(lag->netdev, "Error %s CP rule for fail-over\n",
-                           add ? "ADDING" : "REMOVING");
-               goto cp_free;
-       }
-
-       if (add)
-               lag->cp_rule_idx = le16_to_cpu(s_rule->index);
-       else
-               lag->cp_rule_idx = 0;
-
-cp_free:
-       kfree(s_rule);
-}
-
 /**
  * ice_lag_info_event - handle NETDEV_BONDING_INFO event
  * @lag: LAG info struct
@@ -996,28 +1019,6 @@ static void ice_lag_link(struct ice_lag *lag)
        netdev_info(lag->netdev, "Shared SR-IOV resources in bond are 
active\n");
 }
 
-/**
- * ice_lag_config_eswitch - configure eswitch to work with LAG
- * @lag: lag info struct
- * @netdev: active network interface device struct
- *
- * Updates all port representors in eswitch to use @netdev for Tx.
- *
- * Configures the netdev to keep dst metadata (also used in representor Tx).
- * This is required for an uplink without switchdev mode configured.
- */
-static void ice_lag_config_eswitch(struct ice_lag *lag,
-                                  struct net_device *netdev)
-{
-       struct ice_repr *repr;
-       unsigned long id;
-
-       xa_for_each(&lag->pf->eswitch.reprs, id, repr)
-               repr->dst->u.port_info.lower_dev = netdev;
-
-       netif_keep_dst(netdev);
-}
-
 /**
  * ice_lag_unlink - handle unlink event
  * @lag: LAG info struct
-- 
2.49.0

Reply via email to