Lines Matching refs:lag

30  * @lag: LAG info struct
32 static void ice_lag_set_primary(struct ice_lag *lag)
34 struct ice_pf *pf = lag->pf;
39 if (lag->role != ICE_LAG_UNSET && lag->role != ICE_LAG_BACKUP) {
41 netdev_name(lag->netdev));
45 lag->role = ICE_LAG_PRIMARY;
50 * @lag: LAG info struct
52 static void ice_lag_set_backup(struct ice_lag *lag)
54 struct ice_pf *pf = lag->pf;
59 if (lag->role != ICE_LAG_UNSET && lag->role != ICE_LAG_PRIMARY) {
61 netdev_name(lag->netdev));
65 lag->role = ICE_LAG_BACKUP;
102 * ice_netdev_to_lag - return pointer to associated lag struct from netdev
121 return vsi->back->lag;
126 * @lag: lag struct
130 ice_lag_find_hw_by_lport(struct ice_lag *lag, u8 lport)
137 list_for_each_entry(entry, lag->netdev_head, node) {
176 * ice_lag_find_primary - returns pointer to primary interfaces lag struct
177 * @lag: local interfaces lag struct
179 static struct ice_lag *ice_lag_find_primary(struct ice_lag *lag)
184 list_for_each(tmp, lag->netdev_head) {
201 * @lag: lag struct for local interface
208 ice_lag_cfg_fltr(struct ice_lag *lag, u32 act, u16 recipe_id, u16 *rule_idx,
218 hw = &lag->pf->hw;
224 dev_err(ice_pf_to_dev(lag->pf), "error allocating rule for LAG\n");
245 err = ice_aq_sw_rules(&lag->pf->hw, s_rule, s_rule_sz, 1, opc, NULL);
261 * @lag: lag struct for local interface
265 ice_lag_cfg_dflt_fltr(struct ice_lag *lag, bool add)
270 return ice_lag_cfg_fltr(lag, act, lag->pf_recipe,
271 &lag->pf_rule_id, add);
276 * @lag: lag struct for local interface
280 ice_lag_cfg_drop_fltr(struct ice_lag *lag, bool add)
286 return ice_lag_cfg_fltr(lag, act, lag->lport_recipe,
287 &lag->lport_rule_idx, add);
292 * @lag: local interfaces lag struct
296 ice_lag_cfg_pf_fltrs(struct ice_lag *lag, void *ptr)
305 if (event_netdev != lag->netdev)
310 dev = ice_pf_to_dev(lag->pf);
313 if (bonding_info->slave.state && lag->pf_rule_id) {
314 if (ice_lag_cfg_dflt_fltr(lag, false))
316 if (ice_lag_cfg_drop_fltr(lag, true))
322 if (!bonding_info->slave.state && !lag->pf_rule_id) {
323 if (ice_lag_cfg_dflt_fltr(lag, true))
325 if (lag->lport_rule_idx && ice_lag_cfg_drop_fltr(lag, false))
332 * @lag: LAG info struct
334 static void ice_display_lag_info(struct ice_lag *lag)
337 struct device *dev = &lag->pf->pdev->dev;
339 name = lag->netdev ? netdev_name(lag->netdev) : "unset";
340 upper = lag->upper_netdev ? netdev_name(lag->upper_netdev) : "unset";
341 primary = lag->primary ? "TRUE" : "FALSE";
342 bonded = lag->bonded ? "BONDED" : "UNBONDED";
344 switch (lag->role) {
484 * @lag: lag info struct
491 ice_lag_move_vf_node_tc(struct ice_lag *lag, u8 oldport, u8 newport,
495 struct device *dev = ice_pf_to_dev(lag->pf);
505 ctx = ice_get_vsi_ctx(&lag->pf->hw, vsi_num);
516 new_hw = ice_lag_find_hw_by_lport(lag, newport);
533 if (ice_sched_suspend_resume_elems(&lag->pf->hw, 1, &tmp_teid, true))
547 valq = ice_lag_qbuf_recfg(&lag->pf->hw, qbuf, vsi_num, numq, tc);
553 if (ice_aq_cfg_lan_txq(&lag->pf->hw, qbuf, qbuf_size, valq, oldport,
576 if (ice_aq_move_sched_elems(&lag->pf->hw, buf, buf_size, &num_moved))
588 if (ice_sched_suspend_resume_elems(&lag->pf->hw, 1, &tmp_teid, false))
593 * ice_lag_build_netdev_list - populate the lag struct's netdev list
594 * @lag: local lag struct
597 static void ice_lag_build_netdev_list(struct ice_lag *lag,
605 for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) {
614 lag->netdev_head = &ndlist->node;
618 * ice_lag_destroy_netdev_list - free lag struct's netdev list
619 * @lag: pointer to local lag struct
620 * @ndlist: pointer to lag struct netdev list
622 static void ice_lag_destroy_netdev_list(struct ice_lag *lag,
633 lag->netdev_head = NULL;
638 * @lag: primary interface LAG struct
644 ice_lag_move_single_vf_nodes(struct ice_lag *lag, u8 oldport, u8 newport,
650 ice_lag_move_vf_node_tc(lag, oldport, newport, vsi_num, tc);
665 struct ice_lag *lag;
678 lag = pf->lag;
681 if (!lag->bonded)
685 act_port = lag->active_port;
687 if (lag->upper_netdev)
688 ice_lag_build_netdev_list(lag, &ndlist);
691 lag->bonded && lag->primary && pri_port != act_port &&
692 !list_empty(lag->netdev_head))
693 ice_lag_move_single_vf_nodes(lag, pri_port, act_port, vsi->idx);
695 ice_lag_destroy_netdev_list(lag, &ndlist);
703 * @lag: lag info struct
707 static void ice_lag_move_vf_nodes(struct ice_lag *lag, u8 oldport, u8 newport)
712 if (!lag->primary)
715 pf = lag->pf;
719 ice_lag_move_single_vf_nodes(lag, oldport, newport, i);
724 * @lag: local lag struct
731 * Must be called while holding the lag_mutex to avoid lag events from
736 void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 src_prt, u8 dst_prt)
740 ice_lag_build_netdev_list(lag, &ndlist);
741 ice_lag_move_vf_nodes(lag, src_prt, dst_prt);
742 ice_lag_destroy_netdev_list(lag, &ndlist);
750 * @lag: local interface's lag struct
754 ice_lag_cfg_cp_fltr(struct ice_lag *lag, bool add)
760 vsi = lag->pf->vsi[0];
766 netdev_warn(lag->netdev, "-ENOMEM error configuring CP filter\n");
783 s_rule->index = cpu_to_le16(lag->cp_rule_idx);
785 if (ice_aq_sw_rules(&lag->pf->hw, s_rule, buf_len, 1, opc, NULL)) {
786 netdev_warn(lag->netdev, "Error %s CP rule for fail-over\n",
792 lag->cp_rule_idx = le16_to_cpu(s_rule->index);
794 lag->cp_rule_idx = 0;
802 * @lag: LAG info struct
807 static void ice_lag_info_event(struct ice_lag *lag, void *ptr)
816 lag_netdev_name = netdev_name(lag->netdev);
819 if (event_netdev != lag->netdev || !lag->bonded || !lag->upper_netdev)
823 netdev_dbg(lag->netdev, "Bonding event recv, but mode not active/backup\n");
828 netdev_dbg(lag->netdev, "Bonding event recv, but secondary info not for us\n");
833 ice_lag_set_backup(lag);
835 ice_lag_set_primary(lag);
838 ice_display_lag_info(lag);
843 * @lag: primary interface lag struct
849 ice_lag_reclaim_vf_tc(struct ice_lag *lag, struct ice_hw *src_hw, u16 vsi_num,
853 struct device *dev = ice_pf_to_dev(lag->pf);
863 hw = &lag->pf->hw;
924 if (ice_aq_move_sched_elems(&lag->pf->hw, buf, buf_size, &num_moved))
942 * @lag: primary interface lag struct
946 ice_lag_reclaim_vf_nodes(struct ice_lag *lag, struct ice_hw *src_hw)
951 if (!lag->primary || !src_hw)
954 pf = lag->pf;
959 ice_lag_reclaim_vf_tc(lag, src_hw, i, tc);
964 * @lag: LAG info struct
966 static void ice_lag_link(struct ice_lag *lag)
968 struct ice_pf *pf = lag->pf;
970 if (lag->bonded)
972 netdev_name(lag->netdev));
974 lag->bonded = true;
975 lag->role = ICE_LAG_UNSET;
976 netdev_info(lag->netdev, "Shared SR-IOV resources in bond are active\n");
981 * @lag: LAG info struct
983 static void ice_lag_unlink(struct ice_lag *lag)
986 struct ice_pf *pf = lag->pf;
988 if (!lag->bonded) {
989 netdev_dbg(lag->netdev, "bonding unlink event on non-LAG netdev\n");
993 if (lag->primary) {
994 act_port = lag->active_port;
995 pri_port = lag->pf->hw.port_info->lport;
997 ice_lag_move_vf_nodes(lag, act_port, pri_port);
998 lag->primary = false;
999 lag->active_port = ICE_LAG_INVALID_PORT;
1003 primary_lag = ice_lag_find_primary(lag);
1011 &lag->pf->hw);
1017 lag->bonded = false;
1018 lag->role = ICE_LAG_NONE;
1019 lag->upper_netdev = NULL;
1024 * @lag: lag info struct
1027 static void ice_lag_link_unlink(struct ice_lag *lag, void *ptr)
1032 if (netdev != lag->netdev)
1036 ice_lag_link(lag);
1038 ice_lag_unlink(lag);
1129 * @lag: primary interface's lag struct
1134 static void ice_lag_primary_swid(struct ice_lag *lag, bool link)
1139 hw = &lag->pf->hw;
1143 dev_warn(ice_pf_to_dev(lag->pf), "Failure to set primary interface shared status\n");
1148 * @lag: lag info struct
1151 static void ice_lag_add_prune_list(struct ice_lag *lag, struct ice_pf *event_pf)
1159 dev = ice_pf_to_dev(lag->pf);
1161 prim_vsi_idx = lag->pf->vsi[0]->idx;
1163 if (!ice_find_vsi_list_entry(&lag->pf->hw, ICE_SW_LKUP_VLAN,
1189 * @lag: primary interface's ice_lag struct
1192 static void ice_lag_del_prune_list(struct ice_lag *lag, struct ice_pf *event_pf)
1200 dev = ice_pf_to_dev(lag->pf);
1202 vsi_idx = lag->pf->vsi[0]->idx;
1204 if (!ice_find_vsi_list_entry(&lag->pf->hw, ICE_SW_LKUP_VLAN,
1251 * @lag: LAG info struct
1254 static void ice_lag_changeupper_event(struct ice_lag *lag, void *ptr)
1264 if (netdev != lag->netdev)
1267 primary_lag = ice_lag_find_primary(lag);
1269 lag->upper_netdev = info->upper_dev;
1274 lag->primary = true;
1276 ice_lag_primary_swid(lag, true);
1277 primary_lag = lag;
1282 ice_lag_set_swid(swid, lag, true);
1283 ice_lag_add_prune_list(primary_lag, lag->pf);
1284 ice_lag_cfg_drop_fltr(lag, true);
1287 ice_lag_cfg_cp_fltr(lag, true);
1289 if (!primary_lag && lag->primary)
1290 primary_lag = lag;
1292 if (!lag->primary) {
1293 ice_lag_set_swid(0, lag, false);
1295 if (primary_lag && lag->primary) {
1296 ice_lag_primary_swid(lag, false);
1297 ice_lag_del_prune_list(primary_lag, lag->pf);
1301 ice_lag_cfg_cp_fltr(lag, false);
1307 * @lag: lag info struct
1312 static void ice_lag_monitor_link(struct ice_lag *lag, void *ptr)
1320 if (!lag->primary)
1324 if (!netif_is_same_ice(lag->pf, event_netdev))
1327 pf = lag->pf;
1332 if (info->upper_dev != lag->upper_netdev)
1340 if (prim_port != lag->active_port &&
1341 lag->active_port != ICE_LAG_INVALID_PORT) {
1342 active_hw = ice_lag_find_hw_by_lport(lag,
1343 lag->active_port);
1344 ice_lag_reclaim_vf_nodes(lag, active_hw);
1345 lag->active_port = ICE_LAG_INVALID_PORT;
1352 * @lag: lag info struct
1358 static void ice_lag_monitor_active(struct ice_lag *lag, void *ptr)
1367 if (!lag->primary)
1370 pf = lag->pf;
1378 if (!netif_is_ice(event_netdev) || event_upper != lag->upper_netdev)
1393 if (lag->active_port == ICE_LAG_INVALID_PORT) {
1395 ice_lag_move_vf_nodes(lag, prim_port,
1397 lag->active_port = event_port;
1402 if (lag->active_port == event_port)
1405 ice_lag_move_vf_nodes(lag, lag->active_port, event_port);
1406 lag->active_port = event_port;
1411 if (lag->active_port != event_port)
1418 ice_lag_move_vf_nodes(lag, event_port, prim_port);
1419 lag->active_port = ICE_LAG_INVALID_PORT;
1425 * @lag: lag info struct
1429 ice_lag_chk_comp(struct ice_lag *lag, void *ptr)
1438 if (!lag->primary)
1445 if (event_upper != lag->upper_netdev)
1448 dev = ice_pf_to_dev(lag->pf);
1453 if (!ice_is_switchdev_running(lag->pf)) {
1460 lag->bond_mode = bonding_info->master.bond_mode;
1461 if (lag->bond_mode != BOND_MODE_ACTIVEBACKUP) {
1466 list_for_each(tmp, lag->netdev_head) {
1489 vsi = ice_get_main_vsi(lag->pf);
1491 if (lag->pf->pdev->bus != peer_vsi->back->pdev->bus ||
1492 lag->pf->pdev->slot != peer_vsi->back->pdev->slot) {
1520 * @lag: LAG info struct
1524 ice_lag_unregister(struct ice_lag *lag, struct net_device *event_netdev)
1530 p_lag = ice_lag_find_primary(lag);
1539 active_hw = ice_lag_find_hw_by_lport(lag,
1543 lag->active_port = ICE_LAG_INVALID_PORT;
1548 if (lag->primary && lag->netdev == event_netdev)
1549 ice_lag_primary_swid(lag, false);
1552 if (lag->primary && lag->netdev != event_netdev)
1553 ice_lag_del_prune_list(lag, event_pf);
1556 if (!lag->primary && lag->netdev == event_netdev)
1557 ice_lag_set_swid(0, lag, false);
1562 * @lag: pointer to lag struct
1566 ice_lag_monitor_rdma(struct ice_lag *lag, void *ptr)
1574 if (netdev != lag->netdev)
1578 ice_clear_rdma_cap(lag->pf);
1580 ice_set_rdma_cap(lag->pf);
1585 * @lag: lag info struct
1592 static void ice_lag_chk_disabled_bond(struct ice_lag *lag, void *ptr)
1598 if (netdev != lag->netdev)
1602 prim_lag = ice_lag_find_primary(lag);
1605 ice_clear_feature_support(lag->pf, ICE_F_SRIOV_LAG);
1609 ice_lag_init_feature_support_flag(lag->pf);
1615 * @lag: primary interfaces lag struct
1617 static void ice_lag_disable_sriov_bond(struct ice_lag *lag)
1622 np = netdev_priv(lag->netdev);
1640 pf = lag_work->lag->pf;
1643 lag_work->lag->netdev_head = &lag_work->netdev_list.node;
1648 ice_lag_chk_disabled_bond(lag_work->lag, info);
1650 ice_lag_monitor_link(lag_work->lag, info);
1651 ice_lag_changeupper_event(lag_work->lag, info);
1652 ice_lag_link_unlink(lag_work->lag, info);
1654 ice_lag_monitor_rdma(lag_work->lag, info);
1658 if (!ice_lag_chk_comp(lag_work->lag,
1661 ice_lag_disable_sriov_bond(lag_work->lag);
1662 ice_lag_unregister(lag_work->lag, netdev);
1665 ice_lag_monitor_active(lag_work->lag,
1667 ice_lag_cfg_pf_fltrs(lag_work->lag,
1670 ice_lag_info_event(lag_work->lag, &lag_work->info.bonding_info);
1675 if ((netdev == lag_work->lag->netdev ||
1676 lag_work->lag->primary) && lag_work->lag->bonded)
1677 ice_lag_unregister(lag_work->lag, netdev);
1693 lag_work->lag->netdev_head = NULL;
1713 struct ice_lag *lag;
1725 lag = container_of(notif_blk, struct ice_lag, notif_block);
1726 if (!lag->netdev)
1738 lag_work->lag = lag;
1789 * @lag: LAG struct
1791 static int ice_register_lag_handler(struct ice_lag *lag)
1793 struct device *dev = ice_pf_to_dev(lag->pf);
1796 notif_blk = &lag->notif_block;
1812 * @lag: LAG struct
1814 static void ice_unregister_lag_handler(struct ice_lag *lag)
1816 struct device *dev = ice_pf_to_dev(lag->pf);
1819 notif_blk = &lag->notif_block;
1867 * @lag: primary interfaces lag struct
1873 ice_lag_move_vf_nodes_tc_sync(struct ice_lag *lag, struct ice_hw *dest_hw,
1877 struct device *dev = ice_pf_to_dev(lag->pf);
1887 hw = &lag->pf->hw;
1944 if (ice_aq_move_sched_elems(&lag->pf->hw, buf, buf_size, &num_moved))
1961 * @lag: primary interfaces lag struct
1969 ice_lag_move_vf_nodes_sync(struct ice_lag *lag, struct ice_hw *dest_hw)
1974 if (!lag->primary || !dest_hw)
1977 pf = lag->pf;
1982 ice_lag_move_vf_nodes_tc_sync(lag, dest_hw, i,
1996 struct ice_lag *lag;
2005 pf->lag = kzalloc(sizeof(*lag), GFP_KERNEL);
2006 if (!pf->lag)
2008 lag = pf->lag;
2017 lag->pf = pf;
2018 lag->netdev = vsi->netdev;
2019 lag->role = ICE_LAG_NONE;
2020 lag->active_port = ICE_LAG_INVALID_PORT;
2021 lag->bonded = false;
2022 lag->upper_netdev = NULL;
2023 lag->notif_block.notifier_call = NULL;
2025 err = ice_register_lag_handler(lag);
2031 err = ice_create_lag_recipe(&pf->hw, &lag->pf_recipe,
2036 err = ice_create_lag_recipe(&pf->hw, &lag->lport_recipe,
2049 recipe_bits |= BIT(lag->pf_recipe) |
2050 BIT(lag->lport_recipe);
2056 ice_display_lag_info(lag);
2063 &pf->lag->pf_recipe);
2065 kfree(lag);
2066 pf->lag = NULL;
2079 struct ice_lag *lag;
2081 lag = pf->lag;
2083 if (!lag)
2086 if (lag->pf)
2087 ice_unregister_lag_handler(lag);
2092 &pf->lag->pf_recipe);
2094 &pf->lag->lport_recipe);
2096 kfree(lag);
2098 pf->lag = NULL;
2102 * ice_lag_rebuild - rebuild lag resources after reset
2107 * this will happen outside the normal event processing, need to acquire the lag
2116 struct ice_lag *lag, *prim_lag;
2119 if (!pf->lag || !pf->lag->bonded)
2124 lag = pf->lag;
2125 if (lag->primary) {
2126 prim_lag = lag;
2128 ice_lag_build_netdev_list(lag, &ndlist);
2129 prim_lag = ice_lag_find_primary(lag);
2138 loc_port = lag->pf->hw.port_info->lport;
2141 if (lag->primary) {
2142 ice_lag_primary_swid(lag, true);
2144 ice_lag_set_swid(prim_lag->pf->hw.port_info->sw_id, lag, true);
2150 ice_lag_cfg_cp_fltr(lag, true);
2152 if (lag->pf_rule_id)
2153 if (ice_lag_cfg_dflt_fltr(lag, true))
2158 ice_lag_destroy_netdev_list(lag, &ndlist);
2166 * Check if switchdev is running on any of the interfaces connected to lag.
2170 struct ice_lag *lag = pf->lag;
2173 if (!ice_is_feature_supported(pf, ICE_F_SRIOV_LAG) || !lag)
2177 for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) {