Skip to content

Commit b2e9715

Browse files
dmertmananguy11
authored andcommitted
ice: move LAG function in code to prepare for 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]> Tested-by: Sujai Buvaneswaran <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent a66b3b5 commit b2e9715

File tree

1 file changed

+74
-73
lines changed

1 file changed

+74
-73
lines changed

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

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,28 @@ static bool netif_is_same_ice(struct ice_pf *pf, struct net_device *netdev)
100100
return true;
101101
}
102102

103+
/**
104+
* ice_lag_config_eswitch - configure eswitch to work with LAG
105+
* @lag: lag info struct
106+
* @netdev: active network interface device struct
107+
*
108+
* Updates all port representors in eswitch to use @netdev for Tx.
109+
*
110+
* Configures the netdev to keep dst metadata (also used in representor Tx).
111+
* This is required for an uplink without switchdev mode configured.
112+
*/
113+
static void ice_lag_config_eswitch(struct ice_lag *lag,
114+
struct net_device *netdev)
115+
{
116+
struct ice_repr *repr;
117+
unsigned long id;
118+
119+
xa_for_each(&lag->pf->eswitch.reprs, id, repr)
120+
repr->dst->u.port_info.lower_dev = netdev;
121+
122+
netif_keep_dst(netdev);
123+
}
124+
103125
/**
104126
* ice_netdev_to_lag - return pointer to associated lag struct from netdev
105127
* @netdev: pointer to net_device struct to query
@@ -354,6 +376,58 @@ ice_lag_cfg_pf_fltrs(struct ice_lag *lag, void *ptr)
354376
}
355377
}
356378

379+
/**
380+
* ice_lag_cfg_cp_fltr - configure filter for control packets
381+
* @lag: local interface's lag struct
382+
* @add: add or remove rule
383+
*/
384+
static void
385+
ice_lag_cfg_cp_fltr(struct ice_lag *lag, bool add)
386+
{
387+
struct ice_sw_rule_lkup_rx_tx *s_rule = NULL;
388+
struct ice_vsi *vsi;
389+
u16 buf_len, opc;
390+
391+
vsi = lag->pf->vsi[0];
392+
393+
buf_len = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, ICE_TRAIN_PKT_LEN);
394+
s_rule = kzalloc(buf_len, GFP_KERNEL);
395+
if (!s_rule) {
396+
netdev_warn(lag->netdev, "-ENOMEM error configuring CP filter\n");
397+
return;
398+
}
399+
400+
if (add) {
401+
s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);
402+
s_rule->recipe_id = cpu_to_le16(ICE_LAG_SRIOV_CP_RECIPE);
403+
s_rule->src = cpu_to_le16(vsi->port_info->lport);
404+
s_rule->act = cpu_to_le32(ICE_FWD_TO_VSI |
405+
ICE_SINGLE_ACT_LAN_ENABLE |
406+
ICE_SINGLE_ACT_VALID_BIT |
407+
FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M,
408+
vsi->vsi_num));
409+
s_rule->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
410+
memcpy(s_rule->hdr_data, lacp_train_pkt, ICE_TRAIN_PKT_LEN);
411+
opc = ice_aqc_opc_add_sw_rules;
412+
} else {
413+
opc = ice_aqc_opc_remove_sw_rules;
414+
s_rule->index = cpu_to_le16(lag->cp_rule_idx);
415+
}
416+
if (ice_aq_sw_rules(&lag->pf->hw, s_rule, buf_len, 1, opc, NULL)) {
417+
netdev_warn(lag->netdev, "Error %s CP rule for fail-over\n",
418+
add ? "ADDING" : "REMOVING");
419+
goto err_cp_free;
420+
}
421+
422+
if (add)
423+
lag->cp_rule_idx = le16_to_cpu(s_rule->index);
424+
else
425+
lag->cp_rule_idx = 0;
426+
427+
err_cp_free:
428+
kfree(s_rule);
429+
}
430+
357431
/**
358432
* ice_display_lag_info - print LAG info
359433
* @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)
768842
ice_lag_destroy_netdev_list(lag, &ndlist);
769843
}
770844

771-
/**
772-
* ice_lag_cfg_cp_fltr - configure filter for control packets
773-
* @lag: local interface's lag struct
774-
* @add: add or remove rule
775-
*/
776-
static void
777-
ice_lag_cfg_cp_fltr(struct ice_lag *lag, bool add)
778-
{
779-
struct ice_sw_rule_lkup_rx_tx *s_rule = NULL;
780-
struct ice_vsi *vsi;
781-
u16 buf_len, opc;
782-
783-
vsi = lag->pf->vsi[0];
784-
785-
buf_len = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, ICE_TRAIN_PKT_LEN);
786-
s_rule = kzalloc(buf_len, GFP_KERNEL);
787-
if (!s_rule) {
788-
netdev_warn(lag->netdev, "-ENOMEM error configuring CP filter\n");
789-
return;
790-
}
791-
792-
if (add) {
793-
s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX);
794-
s_rule->recipe_id = cpu_to_le16(ICE_LAG_SRIOV_CP_RECIPE);
795-
s_rule->src = cpu_to_le16(vsi->port_info->lport);
796-
s_rule->act = cpu_to_le32(ICE_FWD_TO_VSI |
797-
ICE_SINGLE_ACT_LAN_ENABLE |
798-
ICE_SINGLE_ACT_VALID_BIT |
799-
FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi->vsi_num));
800-
s_rule->hdr_len = cpu_to_le16(ICE_TRAIN_PKT_LEN);
801-
memcpy(s_rule->hdr_data, lacp_train_pkt, ICE_TRAIN_PKT_LEN);
802-
opc = ice_aqc_opc_add_sw_rules;
803-
} else {
804-
opc = ice_aqc_opc_remove_sw_rules;
805-
s_rule->index = cpu_to_le16(lag->cp_rule_idx);
806-
}
807-
if (ice_aq_sw_rules(&lag->pf->hw, s_rule, buf_len, 1, opc, NULL)) {
808-
netdev_warn(lag->netdev, "Error %s CP rule for fail-over\n",
809-
add ? "ADDING" : "REMOVING");
810-
goto cp_free;
811-
}
812-
813-
if (add)
814-
lag->cp_rule_idx = le16_to_cpu(s_rule->index);
815-
else
816-
lag->cp_rule_idx = 0;
817-
818-
cp_free:
819-
kfree(s_rule);
820-
}
821-
822845
/**
823846
* ice_lag_prepare_vf_reset - helper to adjust vf lag for reset
824847
* @lag: lag struct for interface that owns VF
@@ -1038,28 +1061,6 @@ static void ice_lag_link(struct ice_lag *lag)
10381061
netdev_info(lag->netdev, "Shared SR-IOV resources in bond are active\n");
10391062
}
10401063

1041-
/**
1042-
* ice_lag_config_eswitch - configure eswitch to work with LAG
1043-
* @lag: lag info struct
1044-
* @netdev: active network interface device struct
1045-
*
1046-
* Updates all port representors in eswitch to use @netdev for Tx.
1047-
*
1048-
* Configures the netdev to keep dst metadata (also used in representor Tx).
1049-
* This is required for an uplink without switchdev mode configured.
1050-
*/
1051-
static void ice_lag_config_eswitch(struct ice_lag *lag,
1052-
struct net_device *netdev)
1053-
{
1054-
struct ice_repr *repr;
1055-
unsigned long id;
1056-
1057-
xa_for_each(&lag->pf->eswitch.reprs, id, repr)
1058-
repr->dst->u.port_info.lower_dev = netdev;
1059-
1060-
netif_keep_dst(netdev);
1061-
}
1062-
10631064
/**
10641065
* ice_lag_unlink - handle unlink event
10651066
* @lag: LAG info struct

0 commit comments

Comments
 (0)