Lines Matching +full:interface +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2018-2021, Intel Corporation. */
29 * ice_lag_set_primary - set PF LAG state as Primary
34 struct ice_pf *pf = lag->pf; in ice_lag_set_primary()
39 if (lag->role != ICE_LAG_UNSET && lag->role != ICE_LAG_BACKUP) { in ice_lag_set_primary()
41 netdev_name(lag->netdev)); in ice_lag_set_primary()
45 lag->role = ICE_LAG_PRIMARY; in ice_lag_set_primary()
49 * ice_lag_set_backup - set PF LAG state to Backup
54 struct ice_pf *pf = lag->pf; in ice_lag_set_backup()
59 if (lag->role != ICE_LAG_UNSET && lag->role != ICE_LAG_PRIMARY) { in ice_lag_set_backup()
61 netdev_name(lag->netdev)); in ice_lag_set_backup()
65 lag->role = ICE_LAG_BACKUP; in ice_lag_set_backup()
69 * netif_is_same_ice - determine if netdev is on the same ice NIC as local PF
86 vsi = np->vsi; in netif_is_same_ice()
90 test_pf = vsi->back; in netif_is_same_ice()
94 if (pf->pdev->bus != test_pf->pdev->bus || in netif_is_same_ice()
95 pf->pdev->slot != test_pf->pdev->slot) in netif_is_same_ice()
102 * ice_netdev_to_lag - return pointer to associated lag struct from netdev
117 vsi = np->vsi; in ice_netdev_to_lag()
121 return vsi->back->lag; in ice_netdev_to_lag()
125 * ice_lag_find_hw_by_lport - return an hw struct from bond members lport
137 list_for_each_entry(entry, lag->netdev_head, node) { in ice_lag_find_hw_by_lport()
138 tmp_netdev = entry->netdev; in ice_lag_find_hw_by_lport()
143 if (!np || !np->vsi) in ice_lag_find_hw_by_lport()
146 hw = &np->vsi->back->hw; in ice_lag_find_hw_by_lport()
147 if (hw->port_info->lport == lport) in ice_lag_find_hw_by_lport()
155 * ice_pkg_has_lport_extract - check if lport extraction supported
162 for (i = 0; i < hw->blk[ICE_BLK_SW].es.count; i++) { in ice_pkg_has_lport_extract()
176 * ice_lag_find_primary - returns pointer to primary interfaces lag struct
184 list_for_each(tmp, lag->netdev_head) { in ice_lag_find_primary()
188 entry = list_entry(tmp, struct ice_lag_netdev_list, node); in ice_lag_find_primary()
189 tmp_lag = ice_netdev_to_lag(entry->netdev); in ice_lag_find_primary()
190 if (tmp_lag && tmp_lag->primary) { in ice_lag_find_primary()
200 * ice_lag_cfg_fltr - Add/Remove rule for LAG
201 * @lag: lag struct for local interface
219 hw = &lag->pf->hw; in ice_lag_cfg_fltr()
225 dev_err(ice_pf_to_dev(lag->pf), "error allocating rule for LAG\n"); in ice_lag_cfg_fltr()
226 return -ENOMEM; in ice_lag_cfg_fltr()
230 eth_hdr = s_rule->hdr_data; in ice_lag_cfg_fltr()
235 s_rule->recipe_id = cpu_to_le16(recipe_id); in ice_lag_cfg_fltr()
237 s_rule->hdr.type = in ice_lag_cfg_fltr()
239 s_rule->src = cpu_to_le16(hw->port_info->lport); in ice_lag_cfg_fltr()
241 s_rule->hdr.type = in ice_lag_cfg_fltr()
243 s_rule->src = cpu_to_le16(vsi_num); in ice_lag_cfg_fltr()
245 s_rule->act = cpu_to_le32(act); in ice_lag_cfg_fltr()
246 s_rule->hdr_len = cpu_to_le16(DUMMY_ETH_HDR_LEN); in ice_lag_cfg_fltr()
249 s_rule->index = cpu_to_le16(*rule_idx); in ice_lag_cfg_fltr()
253 err = ice_aq_sw_rules(&lag->pf->hw, s_rule, s_rule_sz, 1, opc, NULL); in ice_lag_cfg_fltr()
258 *rule_idx = le16_to_cpu(s_rule->index); in ice_lag_cfg_fltr()
268 * ice_lag_cfg_dflt_fltr - Add/Remove default VSI rule for LAG
269 * @lag: lag struct for local interface
279 err = ice_lag_cfg_fltr(lag, act, lag->pf_recipe, &lag->pf_rx_rule_id, in ice_lag_cfg_dflt_fltr()
286 err = ice_lag_cfg_fltr(lag, act, lag->pf_recipe, &lag->pf_tx_rule_id, in ice_lag_cfg_dflt_fltr()
294 ice_lag_cfg_fltr(lag, act, lag->pf_recipe, &lag->pf_rx_rule_id, in ice_lag_cfg_dflt_fltr()
301 * ice_lag_cfg_drop_fltr - Add/Remove lport drop rule
302 * @lag: lag struct for local interface
312 return ice_lag_cfg_fltr(lag, act, lag->lport_recipe, in ice_lag_cfg_drop_fltr()
313 &lag->lport_rule_idx, ICE_FLTR_RX, add); in ice_lag_cfg_drop_fltr()
317 * ice_lag_cfg_pf_fltrs - set filters up for new active port
331 if (event_netdev != lag->netdev) in ice_lag_cfg_pf_fltrs()
335 bonding_info = &info->bonding_info; in ice_lag_cfg_pf_fltrs()
336 dev = ice_pf_to_dev(lag->pf); in ice_lag_cfg_pf_fltrs()
338 /* interface not active - remove old default VSI rule */ in ice_lag_cfg_pf_fltrs()
339 if (bonding_info->slave.state && lag->pf_rx_rule_id) { in ice_lag_cfg_pf_fltrs()
347 /* interface becoming active - add new default VSI rule */ in ice_lag_cfg_pf_fltrs()
348 if (!bonding_info->slave.state && !lag->pf_rx_rule_id) { in ice_lag_cfg_pf_fltrs()
351 if (lag->lport_rule_idx && ice_lag_cfg_drop_fltr(lag, false)) in ice_lag_cfg_pf_fltrs()
357 * ice_display_lag_info - print LAG info
363 struct device *dev = &lag->pf->pdev->dev; in ice_display_lag_info()
365 name = lag->netdev ? netdev_name(lag->netdev) : "unset"; in ice_display_lag_info()
366 upper = lag->upper_netdev ? netdev_name(lag->upper_netdev) : "unset"; in ice_display_lag_info()
367 primary = lag->primary ? "TRUE" : "FALSE"; in ice_display_lag_info()
368 bonded = lag->bonded ? "BONDED" : "UNBONDED"; in ice_display_lag_info()
370 switch (lag->role) { in ice_display_lag_info()
392 * ice_lag_qbuf_recfg - generate a buffer of queues for a reconfigure command
410 pf = hw->back; in ice_lag_qbuf_recfg()
418 if (q_ctx->q_teid == ICE_INVAL_TEID) { in ice_lag_qbuf_recfg()
423 if (q_ctx->q_handle == ICE_INVAL_Q_HANDLE) { in ice_lag_qbuf_recfg()
429 qid = pf->vsi[vsi_num]->txq_map[q_ctx->q_handle]; in ice_lag_qbuf_recfg()
430 qbuf->queue_info[count].q_handle = cpu_to_le16(qid); in ice_lag_qbuf_recfg()
431 qbuf->queue_info[count].tc = tc; in ice_lag_qbuf_recfg()
432 qbuf->queue_info[count].q_teid = cpu_to_le32(q_ctx->q_teid); in ice_lag_qbuf_recfg()
440 * ice_lag_get_sched_parent - locate or create a sched node parent
442 * @tc: traffic class on parent/node
449 struct ice_port_info *pi = hw->port_info; in ice_lag_get_sched_parent()
458 dev_warn(dev, "Failure to find TC node for LAG move\n"); in ice_lag_get_sched_parent()
464 dev_warn(dev, "Failure to find aggregate node for LAG move\n"); in ice_lag_get_sched_parent()
474 for (n = 0; n < aggnode->num_children; n++) { in ice_lag_get_sched_parent()
475 parent = ice_sched_get_free_vsi_parent(hw, aggnode->children[n], in ice_lag_get_sched_parent()
481 /* if free parent not found - add one */ in ice_lag_get_sched_parent()
498 parent = parent->children[0]; in ice_lag_get_sched_parent()
509 * ice_lag_move_vf_node_tc - move scheduling nodes for one VF on one TC
521 struct device *dev = ice_pf_to_dev(lag->pf); in ice_lag_move_vf_node_tc()
531 ctx = ice_get_vsi_ctx(&lag->pf->hw, vsi_num); in ice_lag_move_vf_node_tc()
538 if (!ctx->sched.vsi_node[tc]) in ice_lag_move_vf_node_tc()
544 dev_warn(dev, "Unable to locate HW struct for LAG node destination\n"); in ice_lag_move_vf_node_tc()
548 numq = ctx->num_lan_q_entries[tc]; in ice_lag_move_vf_node_tc()
549 teid = ctx->sched.vsi_node[tc]->info.node_teid; in ice_lag_move_vf_node_tc()
551 parent_teid = ctx->sched.vsi_node[tc]->info.parent_teid; in ice_lag_move_vf_node_tc()
559 if (ice_sched_suspend_resume_elems(&lag->pf->hw, 1, &tmp_teid, true)) in ice_lag_move_vf_node_tc()
560 dev_dbg(dev, "Problem suspending traffic for LAG node move\n"); in ice_lag_move_vf_node_tc()
573 valq = ice_lag_qbuf_recfg(&lag->pf->hw, qbuf, vsi_num, numq, tc); in ice_lag_move_vf_node_tc()
579 if (ice_aq_cfg_lan_txq(&lag->pf->hw, qbuf, qbuf_size, valq, oldport, in ice_lag_move_vf_node_tc()
588 /* find new parent in destination port's tree for VF VSI node on this in ice_lag_move_vf_node_tc()
595 /* Move Vf's VSI node for this TC to newport's scheduler tree */ in ice_lag_move_vf_node_tc()
596 buf->hdr.src_parent_teid = parent_teid; in ice_lag_move_vf_node_tc()
597 buf->hdr.dest_parent_teid = n_prt->info.node_teid; in ice_lag_move_vf_node_tc()
598 buf->hdr.num_elems = cpu_to_le16(1); in ice_lag_move_vf_node_tc()
599 buf->hdr.mode = ICE_AQC_MOVE_ELEM_MODE_KEEP_OWN; in ice_lag_move_vf_node_tc()
600 buf->teid[0] = teid; in ice_lag_move_vf_node_tc()
602 if (ice_aq_move_sched_elems(&lag->pf->hw, buf, buf_size, &num_moved)) in ice_lag_move_vf_node_tc()
605 ice_sched_update_parent(n_prt, ctx->sched.vsi_node[tc]); in ice_lag_move_vf_node_tc()
613 /* restart traffic for VSI node */ in ice_lag_move_vf_node_tc()
614 if (ice_sched_suspend_resume_elems(&lag->pf->hw, 1, &tmp_teid, false)) in ice_lag_move_vf_node_tc()
615 dev_dbg(dev, "Problem restarting traffic for LAG node move\n"); in ice_lag_move_vf_node_tc()
619 * ice_lag_build_netdev_list - populate the lag struct's netdev list
629 INIT_LIST_HEAD(&ndlist->node); in ice_lag_build_netdev_list()
631 for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) { in ice_lag_build_netdev_list()
636 nl->netdev = tmp_nd; in ice_lag_build_netdev_list()
637 list_add(&nl->node, &ndlist->node); in ice_lag_build_netdev_list()
640 lag->netdev_head = &ndlist->node; in ice_lag_build_netdev_list()
644 * ice_lag_destroy_netdev_list - free lag struct's netdev list
654 list_for_each_entry_safe(entry, n, &ndlist->node, node) { in ice_lag_destroy_netdev_list()
655 list_del(&entry->node); in ice_lag_destroy_netdev_list()
659 lag->netdev_head = NULL; in ice_lag_destroy_netdev_list()
663 * ice_lag_move_single_vf_nodes - Move Tx scheduling nodes for single VF
664 * @lag: primary interface LAG struct
665 * @oldport: lport of previous interface
666 * @newport: lport of destination interface
680 * ice_lag_move_new_vf_nodes - Move Tx scheduling nodes for a VF if required
700 if (WARN_ON(vsi->type != ICE_VSI_VF)) in ice_lag_move_new_vf_nodes()
703 pf = vf->pf; in ice_lag_move_new_vf_nodes()
704 lag = pf->lag; in ice_lag_move_new_vf_nodes()
706 mutex_lock(&pf->lag_mutex); in ice_lag_move_new_vf_nodes()
707 if (!lag->bonded) in ice_lag_move_new_vf_nodes()
710 pri_port = pf->hw.port_info->lport; in ice_lag_move_new_vf_nodes()
711 act_port = lag->active_port; in ice_lag_move_new_vf_nodes()
713 if (lag->upper_netdev) in ice_lag_move_new_vf_nodes()
717 lag->bonded && lag->primary && pri_port != act_port && in ice_lag_move_new_vf_nodes()
718 !list_empty(lag->netdev_head)) in ice_lag_move_new_vf_nodes()
719 ice_lag_move_single_vf_nodes(lag, pri_port, act_port, vsi->idx); in ice_lag_move_new_vf_nodes()
724 mutex_unlock(&pf->lag_mutex); in ice_lag_move_new_vf_nodes()
728 * ice_lag_move_vf_nodes - move Tx scheduling nodes for all VFs to new port
730 * @oldport: lport of previous interface
731 * @newport: lport of destination interface
738 if (!lag->primary) in ice_lag_move_vf_nodes()
741 pf = lag->pf; in ice_lag_move_vf_nodes()
743 if (pf->vsi[i] && pf->vsi[i]->type == ICE_VSI_VF) in ice_lag_move_vf_nodes()
748 * ice_lag_move_vf_nodes_cfg - move vf nodes outside LAG netdev event context
753 * This function is used to move nodes during an out-of-netdev-event situation,
757 * processing while out-of-sync moves are happening. Also, paired moves,
774 * ice_lag_cfg_cp_fltr - configure filter for control packets
775 * @lag: local interface's lag struct
785 vsi = lag->pf->vsi[0]; in ice_lag_cfg_cp_fltr()
791 netdev_warn(lag->netdev, "-ENOMEM error configuring CP filter\n"); in ice_lag_cfg_cp_fltr()
796 s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_LKUP_RX); in ice_lag_cfg_cp_fltr()
797 s_rule->recipe_id = cpu_to_le16(ICE_LAG_SRIOV_CP_RECIPE); in ice_lag_cfg_cp_fltr()
798 s_rule->src = cpu_to_le16(vsi->port_info->lport); in ice_lag_cfg_cp_fltr()
799 s_rule->act = cpu_to_le32(ICE_FWD_TO_VSI | in ice_lag_cfg_cp_fltr()
802 FIELD_PREP(ICE_SINGLE_ACT_VSI_ID_M, vsi->vsi_num)); in ice_lag_cfg_cp_fltr()
803 s_rule->hdr_len = cpu_to_le16(ICE_LAG_SRIOV_TRAIN_PKT_LEN); in ice_lag_cfg_cp_fltr()
804 memcpy(s_rule->hdr_data, lacp_train_pkt, LACP_TRAIN_PKT_LEN); in ice_lag_cfg_cp_fltr()
808 s_rule->index = cpu_to_le16(lag->cp_rule_idx); in ice_lag_cfg_cp_fltr()
810 if (ice_aq_sw_rules(&lag->pf->hw, s_rule, buf_len, 1, opc, NULL)) { in ice_lag_cfg_cp_fltr()
811 netdev_warn(lag->netdev, "Error %s CP rule for fail-over\n", in ice_lag_cfg_cp_fltr()
817 lag->cp_rule_idx = le16_to_cpu(s_rule->index); in ice_lag_cfg_cp_fltr()
819 lag->cp_rule_idx = 0; in ice_lag_cfg_cp_fltr()
826 * ice_lag_info_event - handle NETDEV_BONDING_INFO event
841 lag_netdev_name = netdev_name(lag->netdev); in ice_lag_info_event()
842 bonding_info = &info->bonding_info; in ice_lag_info_event()
844 if (event_netdev != lag->netdev || !lag->bonded || !lag->upper_netdev) in ice_lag_info_event()
847 if (bonding_info->master.bond_mode != BOND_MODE_ACTIVEBACKUP) { in ice_lag_info_event()
848 netdev_dbg(lag->netdev, "Bonding event recv, but mode not active/backup\n"); in ice_lag_info_event()
852 if (strcmp(bonding_info->slave.slave_name, lag_netdev_name)) { in ice_lag_info_event()
853 netdev_dbg(lag->netdev, "Bonding event recv, but secondary info not for us\n"); in ice_lag_info_event()
857 if (bonding_info->slave.state) in ice_lag_info_event()
867 * ice_lag_reclaim_vf_tc - move scheduling nodes back to primary interface
868 * @lag: primary interface lag struct
869 * @src_hw: HW struct current node location
878 struct device *dev = ice_pf_to_dev(lag->pf); in ice_lag_reclaim_vf_tc()
888 hw = &lag->pf->hw; in ice_lag_reclaim_vf_tc()
896 if (!ctx->sched.vsi_node[tc]) in ice_lag_reclaim_vf_tc()
899 numq = ctx->num_lan_q_entries[tc]; in ice_lag_reclaim_vf_tc()
900 teid = ctx->sched.vsi_node[tc]->info.node_teid; in ice_lag_reclaim_vf_tc()
902 parent_teid = ctx->sched.vsi_node[tc]->info.parent_teid; in ice_lag_reclaim_vf_tc()
910 dev_dbg(dev, "Problem suspending traffic for LAG node move\n"); in ice_lag_reclaim_vf_tc()
928 src_hw->port_info->lport, hw->port_info->lport, in ice_lag_reclaim_vf_tc()
942 /* Move node to new parent */ in ice_lag_reclaim_vf_tc()
943 buf->hdr.src_parent_teid = parent_teid; in ice_lag_reclaim_vf_tc()
944 buf->hdr.dest_parent_teid = n_prt->info.node_teid; in ice_lag_reclaim_vf_tc()
945 buf->hdr.num_elems = cpu_to_le16(1); in ice_lag_reclaim_vf_tc()
946 buf->hdr.mode = ICE_AQC_MOVE_ELEM_MODE_KEEP_OWN; in ice_lag_reclaim_vf_tc()
947 buf->teid[0] = teid; in ice_lag_reclaim_vf_tc()
949 if (ice_aq_move_sched_elems(&lag->pf->hw, buf, buf_size, &num_moved)) in ice_lag_reclaim_vf_tc()
952 ice_sched_update_parent(n_prt, ctx->sched.vsi_node[tc]); in ice_lag_reclaim_vf_tc()
962 dev_warn(dev, "Problem restarting traffic for LAG node reclaim\n"); in ice_lag_reclaim_vf_tc()
966 * ice_lag_reclaim_vf_nodes - When interface leaving bond primary reclaims nodes
967 * @lag: primary interface lag struct
968 * @src_hw: HW struct for current node location
976 if (!lag->primary || !src_hw) in ice_lag_reclaim_vf_nodes()
979 pf = lag->pf; in ice_lag_reclaim_vf_nodes()
981 if (pf->vsi[i] && pf->vsi[i]->type == ICE_VSI_VF) in ice_lag_reclaim_vf_nodes()
987 * ice_lag_link - handle LAG link event
992 struct ice_pf *pf = lag->pf; in ice_lag_link()
994 if (lag->bonded) in ice_lag_link()
996 netdev_name(lag->netdev)); in ice_lag_link()
998 lag->bonded = true; in ice_lag_link()
999 lag->role = ICE_LAG_UNSET; in ice_lag_link()
1000 netdev_info(lag->netdev, "Shared SR-IOV resources in bond are active\n"); in ice_lag_link()
1004 * ice_lag_unlink - handle unlink event
1010 struct ice_pf *pf = lag->pf; in ice_lag_unlink()
1012 if (!lag->bonded) { in ice_lag_unlink()
1013 netdev_dbg(lag->netdev, "bonding unlink event on non-LAG netdev\n"); in ice_lag_unlink()
1017 if (lag->primary) { in ice_lag_unlink()
1018 act_port = lag->active_port; in ice_lag_unlink()
1019 pri_port = lag->pf->hw.port_info->lport; in ice_lag_unlink()
1022 lag->primary = false; in ice_lag_unlink()
1023 lag->active_port = ICE_LAG_INVALID_PORT; in ice_lag_unlink()
1029 act_port = primary_lag->active_port; in ice_lag_unlink()
1030 pri_port = primary_lag->pf->hw.port_info->lport; in ice_lag_unlink()
1031 loc_port = pf->hw.port_info->lport; in ice_lag_unlink()
1035 &lag->pf->hw); in ice_lag_unlink()
1036 primary_lag->active_port = ICE_LAG_INVALID_PORT; in ice_lag_unlink()
1041 lag->bonded = false; in ice_lag_unlink()
1042 lag->role = ICE_LAG_NONE; in ice_lag_unlink()
1043 lag->upper_netdev = NULL; in ice_lag_unlink()
1047 * ice_lag_link_unlink - helper function to call lag_link/unlink
1056 if (netdev != lag->netdev) in ice_lag_link_unlink()
1059 if (info->linking) in ice_lag_link_unlink()
1066 * ice_lag_set_swid - set the SWID on secondary interface
1067 * @primary_swid: primary interface's SWID
1087 dev_err(ice_pf_to_dev(local_lag->pf), "-ENOMEM error setting SWID\n"); in ice_lag_set_swid()
1091 buf->num_elems = cpu_to_le16(1); in ice_lag_set_swid()
1092 buf->res_type = cpu_to_le16(ICE_AQC_RES_TYPE_SWID); in ice_lag_set_swid()
1094 if (!link && local_lag->bond_swid) { in ice_lag_set_swid()
1095 buf->elem[0].e.sw_resp = cpu_to_le16(local_lag->bond_swid); in ice_lag_set_swid()
1096 status = ice_aq_alloc_free_res(&local_lag->pf->hw, buf, in ice_lag_set_swid()
1099 dev_err(ice_pf_to_dev(local_lag->pf), "Error freeing SWID during LAG unlink\n"); in ice_lag_set_swid()
1100 local_lag->bond_swid = 0; in ice_lag_set_swid()
1104 buf->res_type |= cpu_to_le16(ICE_LAG_RES_SHARED | in ice_lag_set_swid()
1107 local_lag->bond_swid = primary_swid; in ice_lag_set_swid()
1108 buf->elem[0].e.sw_resp = cpu_to_le16(local_lag->bond_swid); in ice_lag_set_swid()
1110 buf->elem[0].e.sw_resp = in ice_lag_set_swid()
1111 cpu_to_le16(local_lag->pf->hw.port_info->sw_id); in ice_lag_set_swid()
1114 status = ice_aq_alloc_free_res(&local_lag->pf->hw, buf, buf_len, in ice_lag_set_swid()
1117 dev_err(ice_pf_to_dev(local_lag->pf), "Error subscribing to SWID 0x%04X\n", in ice_lag_set_swid()
1118 local_lag->bond_swid); in ice_lag_set_swid()
1126 swid = local_lag->pf->hw.port_info->sw_id; in ice_lag_set_swid()
1131 cmd->swid = cpu_to_le16(ICE_AQC_PORT_SWID_VALID | swid); in ice_lag_set_swid()
1133 * primary interface has not finished setting its SWID to SHARED in ice_lag_set_swid()
1138 status = ice_aq_send_cmd(&local_lag->pf->hw, &desc, NULL, 0, in ice_lag_set_swid()
1147 dev_err(ice_pf_to_dev(local_lag->pf), "Error setting SWID in port params %d\n", in ice_lag_set_swid()
1152 * ice_lag_primary_swid - set/clear the SHARED attrib of primary's SWID
1153 * @lag: primary interface's lag struct
1163 hw = &lag->pf->hw; in ice_lag_primary_swid()
1164 swid = hw->port_info->sw_id; in ice_lag_primary_swid()
1167 dev_warn(ice_pf_to_dev(lag->pf), "Failure to set primary interface shared status\n"); in ice_lag_primary_swid()
1171 * ice_lag_add_prune_list - Adds event_pf's VSI to primary's prune list
1183 dev = ice_pf_to_dev(lag->pf); in ice_lag_add_prune_list()
1184 event_vsi_num = event_pf->vsi[0]->vsi_num; in ice_lag_add_prune_list()
1185 prim_vsi_idx = lag->pf->vsi[0]->idx; in ice_lag_add_prune_list()
1187 if (!ice_find_vsi_list_entry(&lag->pf->hw, ICE_SW_LKUP_VLAN, in ice_lag_add_prune_list()
1200 s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_PRUNE_LIST_SET); in ice_lag_add_prune_list()
1201 s_rule->index = cpu_to_le16(vsi_list_id); in ice_lag_add_prune_list()
1202 s_rule->number_vsi = cpu_to_le16(num_vsi); in ice_lag_add_prune_list()
1203 s_rule->vsi[0] = cpu_to_le16(event_vsi_num); in ice_lag_add_prune_list()
1205 if (ice_aq_sw_rules(&event_pf->hw, s_rule, rule_buf_sz, 1, in ice_lag_add_prune_list()
1212 * ice_lag_del_prune_list - Remove secondary's vsi from primary's prune list
1213 * @lag: primary interface's ice_lag struct
1214 * @event_pf: PF struct for unlinking interface
1224 dev = ice_pf_to_dev(lag->pf); in ice_lag_del_prune_list()
1225 vsi_num = event_pf->vsi[0]->vsi_num; in ice_lag_del_prune_list()
1226 vsi_idx = lag->pf->vsi[0]->idx; in ice_lag_del_prune_list()
1228 if (!ice_find_vsi_list_entry(&lag->pf->hw, ICE_SW_LKUP_VLAN, in ice_lag_del_prune_list()
1241 s_rule->hdr.type = cpu_to_le16(ICE_AQC_SW_RULES_T_PRUNE_LIST_CLEAR); in ice_lag_del_prune_list()
1242 s_rule->index = cpu_to_le16(vsi_list_id); in ice_lag_del_prune_list()
1243 s_rule->number_vsi = cpu_to_le16(num_vsi); in ice_lag_del_prune_list()
1244 s_rule->vsi[0] = cpu_to_le16(vsi_num); in ice_lag_del_prune_list()
1246 if (ice_aq_sw_rules(&event_pf->hw, (struct ice_aqc_sw_rules *)s_rule, in ice_lag_del_prune_list()
1254 * ice_lag_init_feature_support_flag - Check for package and NVM support for LAG
1261 caps = &pf->hw.dev_caps.common_cap; in ice_lag_init_feature_support_flag()
1262 if (caps->roce_lag) in ice_lag_init_feature_support_flag()
1267 if (caps->sriov_lag && ice_pkg_has_lport_extract(&pf->hw)) in ice_lag_init_feature_support_flag()
1274 * ice_lag_changeupper_event - handle LAG changeupper event
1288 if (netdev != lag->netdev) in ice_lag_changeupper_event()
1292 if (info->linking) { in ice_lag_changeupper_event()
1293 lag->upper_netdev = info->upper_dev; in ice_lag_changeupper_event()
1294 /* If there is not already a primary interface in the LAG, in ice_lag_changeupper_event()
1298 lag->primary = true; in ice_lag_changeupper_event()
1305 swid = primary_lag->pf->hw.port_info->sw_id; in ice_lag_changeupper_event()
1307 ice_lag_add_prune_list(primary_lag, lag->pf); in ice_lag_changeupper_event()
1313 if (!primary_lag && lag->primary) in ice_lag_changeupper_event()
1316 if (!lag->primary) { in ice_lag_changeupper_event()
1319 if (primary_lag && lag->primary) { in ice_lag_changeupper_event()
1321 ice_lag_del_prune_list(primary_lag, lag->pf); in ice_lag_changeupper_event()
1330 * ice_lag_monitor_link - monitor interfaces entering/leaving the aggregate
1344 if (!lag->primary) in ice_lag_monitor_link()
1348 if (!netif_is_same_ice(lag->pf, event_netdev)) in ice_lag_monitor_link()
1351 pf = lag->pf; in ice_lag_monitor_link()
1352 prim_hw = &pf->hw; in ice_lag_monitor_link()
1353 prim_port = prim_hw->port_info->lport; in ice_lag_monitor_link()
1356 if (info->upper_dev != lag->upper_netdev) in ice_lag_monitor_link()
1359 if (!info->linking) { in ice_lag_monitor_link()
1362 * interface. in ice_lag_monitor_link()
1364 if (prim_port != lag->active_port && in ice_lag_monitor_link()
1365 lag->active_port != ICE_LAG_INVALID_PORT) { in ice_lag_monitor_link()
1367 lag->active_port); in ice_lag_monitor_link()
1369 lag->active_port = ICE_LAG_INVALID_PORT; in ice_lag_monitor_link()
1375 * ice_lag_monitor_active - main PF keep track of which port is active
1391 if (!lag->primary) in ice_lag_monitor_active()
1394 pf = lag->pf; in ice_lag_monitor_active()
1402 if (!netif_is_ice(event_netdev) || event_upper != lag->upper_netdev) in ice_lag_monitor_active()
1406 event_pf = event_np->vsi->back; in ice_lag_monitor_active()
1407 event_port = event_pf->hw.port_info->lport; in ice_lag_monitor_active()
1408 prim_port = pf->hw.port_info->lport; in ice_lag_monitor_active()
1411 bonding_info = &info->bonding_info; in ice_lag_monitor_active()
1413 if (!bonding_info->slave.state) { in ice_lag_monitor_active()
1417 if (lag->active_port == ICE_LAG_INVALID_PORT) { in ice_lag_monitor_active()
1421 lag->active_port = event_port; in ice_lag_monitor_active()
1426 if (lag->active_port == event_port) in ice_lag_monitor_active()
1429 ice_lag_move_vf_nodes(lag, lag->active_port, event_port); in ice_lag_monitor_active()
1430 lag->active_port = event_port; in ice_lag_monitor_active()
1435 if (lag->active_port != event_port) in ice_lag_monitor_active()
1438 * Link down on the bond - set active port to invalid and move in ice_lag_monitor_active()
1443 lag->active_port = ICE_LAG_INVALID_PORT; in ice_lag_monitor_active()
1448 * ice_lag_chk_comp - evaluate bonded interface for feature support
1462 if (!lag->primary) in ice_lag_chk_comp()
1469 if (event_upper != lag->upper_netdev) in ice_lag_chk_comp()
1472 dev = ice_pf_to_dev(lag->pf); in ice_lag_chk_comp()
1475 * primary interface has to be in switchdev mode in ice_lag_chk_comp()
1477 if (!ice_is_switchdev_running(lag->pf)) { in ice_lag_chk_comp()
1478 dev_info(dev, "Primary interface not in switchdev mode - VF LAG disabled\n"); in ice_lag_chk_comp()
1483 bonding_info = &info->bonding_info; in ice_lag_chk_comp()
1484 lag->bond_mode = bonding_info->master.bond_mode; in ice_lag_chk_comp()
1485 if (lag->bond_mode != BOND_MODE_ACTIVEBACKUP) { in ice_lag_chk_comp()
1486 dev_info(dev, "Bond Mode not ACTIVE-BACKUP - VF LAG disabled\n"); in ice_lag_chk_comp()
1490 list_for_each(tmp, lag->netdev_head) { in ice_lag_chk_comp()
1498 entry = list_entry(tmp, struct ice_lag_netdev_list, node); in ice_lag_chk_comp()
1499 peer_netdev = entry->netdev; in ice_lag_chk_comp()
1501 dev_info(dev, "Found %s non-ice netdev in LAG - VF LAG disabled\n", in ice_lag_chk_comp()
1508 dev_info(dev, "Found more than two netdevs in LAG - VF LAG disabled\n"); in ice_lag_chk_comp()
1513 vsi = ice_get_main_vsi(lag->pf); in ice_lag_chk_comp()
1514 peer_vsi = peer_np->vsi; in ice_lag_chk_comp()
1515 if (lag->pf->pdev->bus != peer_vsi->back->pdev->bus || in ice_lag_chk_comp()
1516 lag->pf->pdev->slot != peer_vsi->back->pdev->slot) { in ice_lag_chk_comp()
1517 dev_info(dev, "Found %s on different device in LAG - VF LAG disabled\n", in ice_lag_chk_comp()
1522 dcb_cfg = &vsi->port_info->qos_cfg.local_dcbx_cfg; in ice_lag_chk_comp()
1523 peer_dcb_cfg = &peer_vsi->port_info->qos_cfg.local_dcbx_cfg; in ice_lag_chk_comp()
1526 dev_info(dev, "Found %s with different DCB in LAG - VF LAG disabled\n", in ice_lag_chk_comp()
1531 peer_pf = peer_vsi->back; in ice_lag_chk_comp()
1532 if (test_bit(ICE_FLAG_FW_LLDP_AGENT, peer_pf->flags)) { in ice_lag_chk_comp()
1533 dev_warn(dev, "Found %s with FW LLDP agent active - VF LAG disabled\n", in ice_lag_chk_comp()
1543 * ice_lag_unregister - handle netdev unregister events
1556 event_pf = np->vsi->back; in ice_lag_unregister()
1559 if (p_lag->active_port != p_lag->pf->hw.port_info->lport && in ice_lag_unregister()
1560 p_lag->active_port != ICE_LAG_INVALID_PORT) { in ice_lag_unregister()
1564 p_lag->active_port); in ice_lag_unregister()
1567 lag->active_port = ICE_LAG_INVALID_PORT; in ice_lag_unregister()
1572 if (lag->primary && lag->netdev == event_netdev) in ice_lag_unregister()
1576 if (lag->primary && lag->netdev != event_netdev) in ice_lag_unregister()
1580 if (!lag->primary && lag->netdev == event_netdev) in ice_lag_unregister()
1585 * ice_lag_monitor_rdma - set and clear rdma functionality
1598 if (netdev != lag->netdev) in ice_lag_monitor_rdma()
1601 if (info->linking) in ice_lag_monitor_rdma()
1602 ice_clear_rdma_cap(lag->pf); in ice_lag_monitor_rdma()
1604 ice_set_rdma_cap(lag->pf); in ice_lag_monitor_rdma()
1608 * ice_lag_chk_disabled_bond - monitor interfaces entering/leaving disabled bond
1612 * as interfaces enter a bond - determine if the bond is currently
1622 if (netdev != lag->netdev) in ice_lag_chk_disabled_bond()
1625 if (info->linking) { in ice_lag_chk_disabled_bond()
1628 !ice_is_feature_supported(prim_lag->pf, ICE_F_SRIOV_LAG)) { in ice_lag_chk_disabled_bond()
1629 ice_clear_feature_support(lag->pf, ICE_F_SRIOV_LAG); in ice_lag_chk_disabled_bond()
1630 netdev_info(netdev, "Interface added to non-compliant SRIOV LAG aggregate\n"); in ice_lag_chk_disabled_bond()
1633 ice_lag_init_feature_support_flag(lag->pf); in ice_lag_chk_disabled_bond()
1638 * ice_lag_disable_sriov_bond - set members of bond as not supporting SRIOV LAG
1646 np = netdev_priv(lag->netdev); in ice_lag_disable_sriov_bond()
1647 pf = np->vsi->back; in ice_lag_disable_sriov_bond()
1652 * ice_lag_process_event - process a task assigned to the lag_wq
1664 pf = lag_work->lag->pf; in ice_lag_process_event()
1666 mutex_lock(&pf->lag_mutex); in ice_lag_process_event()
1667 lag_work->lag->netdev_head = &lag_work->netdev_list.node; in ice_lag_process_event()
1669 switch (lag_work->event) { in ice_lag_process_event()
1671 info = &lag_work->info.changeupper_info; in ice_lag_process_event()
1672 ice_lag_chk_disabled_bond(lag_work->lag, info); in ice_lag_process_event()
1674 ice_lag_monitor_link(lag_work->lag, info); in ice_lag_process_event()
1675 ice_lag_changeupper_event(lag_work->lag, info); in ice_lag_process_event()
1676 ice_lag_link_unlink(lag_work->lag, info); in ice_lag_process_event()
1678 ice_lag_monitor_rdma(lag_work->lag, info); in ice_lag_process_event()
1682 if (!ice_lag_chk_comp(lag_work->lag, in ice_lag_process_event()
1683 &lag_work->info.bonding_info)) { in ice_lag_process_event()
1684 netdev = lag_work->info.bonding_info.info.dev; in ice_lag_process_event()
1685 ice_lag_disable_sriov_bond(lag_work->lag); in ice_lag_process_event()
1686 ice_lag_unregister(lag_work->lag, netdev); in ice_lag_process_event()
1689 ice_lag_monitor_active(lag_work->lag, in ice_lag_process_event()
1690 &lag_work->info.bonding_info); in ice_lag_process_event()
1691 ice_lag_cfg_pf_fltrs(lag_work->lag, in ice_lag_process_event()
1692 &lag_work->info.bonding_info); in ice_lag_process_event()
1694 ice_lag_info_event(lag_work->lag, &lag_work->info.bonding_info); in ice_lag_process_event()
1698 netdev = lag_work->info.bonding_info.info.dev; in ice_lag_process_event()
1699 if ((netdev == lag_work->lag->netdev || in ice_lag_process_event()
1700 lag_work->lag->primary) && lag_work->lag->bonded) in ice_lag_process_event()
1701 ice_lag_unregister(lag_work->lag, netdev); in ice_lag_process_event()
1710 list_for_each_safe(tmp, n, &lag_work->netdev_list.node) { in ice_lag_process_event()
1713 entry = list_entry(tmp, struct ice_lag_netdev_list, node); in ice_lag_process_event()
1714 list_del(&entry->node); in ice_lag_process_event()
1717 lag_work->lag->netdev_head = NULL; in ice_lag_process_event()
1719 mutex_unlock(&pf->lag_mutex); in ice_lag_process_event()
1725 * ice_lag_event_handler - handle LAG events from netdev
1746 if (!(netdev->priv_flags & IFF_BONDING)) in ice_lag_event_handler()
1750 if (!lag->netdev) in ice_lag_event_handler()
1759 return -ENOMEM; in ice_lag_event_handler()
1761 lag_work->event_netdev = netdev; in ice_lag_event_handler()
1762 lag_work->lag = lag; in ice_lag_event_handler()
1763 lag_work->event = event; in ice_lag_event_handler()
1768 upper_netdev = info->upper_dev; in ice_lag_event_handler()
1773 INIT_LIST_HEAD(&lag_work->netdev_list.node); in ice_lag_event_handler()
1784 nd_list->netdev = tmp_nd; in ice_lag_event_handler()
1785 list_add(&nd_list->node, &lag_work->netdev_list.node); in ice_lag_event_handler()
1792 lag_work->info.changeupper_info = in ice_lag_event_handler()
1796 lag_work->info.bonding_info = in ice_lag_event_handler()
1800 lag_work->info.notifier_info = in ice_lag_event_handler()
1805 INIT_WORK(&lag_work->lag_task, ice_lag_process_event); in ice_lag_event_handler()
1806 queue_work(ice_lag_wq, &lag_work->lag_task); in ice_lag_event_handler()
1812 * ice_register_lag_handler - register LAG handler on netdev
1817 struct device *dev = ice_pf_to_dev(lag->pf); in ice_register_lag_handler()
1820 notif_blk = &lag->notif_block; in ice_register_lag_handler()
1822 if (!notif_blk->notifier_call) { in ice_register_lag_handler()
1823 notif_blk->notifier_call = ice_lag_event_handler; in ice_register_lag_handler()
1825 notif_blk->notifier_call = NULL; in ice_register_lag_handler()
1827 return -EINVAL; in ice_register_lag_handler()
1835 * ice_unregister_lag_handler - unregister LAG handler on netdev
1840 struct device *dev = ice_pf_to_dev(lag->pf); in ice_unregister_lag_handler()
1843 notif_blk = &lag->notif_block; in ice_unregister_lag_handler()
1844 if (notif_blk->notifier_call) { in ice_unregister_lag_handler()
1871 return -ENOMEM; in ice_create_lag_recipe()
1874 new_rcp->content.act_ctrl_fwd_priority = prio; in ice_create_lag_recipe()
1875 new_rcp->content.rid = *rid | ICE_AQ_RECIPE_ID_IS_ROOT; in ice_create_lag_recipe()
1876 new_rcp->recipe_indx = *rid; in ice_create_lag_recipe()
1877 bitmap_zero((unsigned long *)new_rcp->recipe_bitmap, in ice_create_lag_recipe()
1879 set_bit(*rid, (unsigned long *)new_rcp->recipe_bitmap); in ice_create_lag_recipe()
1890 * ice_lag_move_vf_nodes_tc_sync - move a VF's nodes for a tc during reset
1892 * @dest_hw: HW struct for destination's interface
1901 struct device *dev = ice_pf_to_dev(lag->pf); in ice_lag_move_vf_nodes_tc_sync()
1911 hw = &lag->pf->hw; in ice_lag_move_vf_nodes_tc_sync()
1918 if (!ctx->sched.vsi_node[tc]) in ice_lag_move_vf_nodes_tc_sync()
1921 numq = ctx->num_lan_q_entries[tc]; in ice_lag_move_vf_nodes_tc_sync()
1922 teid = ctx->sched.vsi_node[tc]->info.node_teid; in ice_lag_move_vf_nodes_tc_sync()
1924 parent_teid = ctx->sched.vsi_node[tc]->info.parent_teid; in ice_lag_move_vf_nodes_tc_sync()
1947 if (ice_aq_cfg_lan_txq(hw, qbuf, qbuf_size, numq, hw->port_info->lport, in ice_lag_move_vf_nodes_tc_sync()
1948 dest_hw->port_info->lport, NULL)) { in ice_lag_move_vf_nodes_tc_sync()
1961 /* Move node to new parent */ in ice_lag_move_vf_nodes_tc_sync()
1962 buf->hdr.src_parent_teid = parent_teid; in ice_lag_move_vf_nodes_tc_sync()
1963 buf->hdr.dest_parent_teid = n_prt->info.node_teid; in ice_lag_move_vf_nodes_tc_sync()
1964 buf->hdr.num_elems = cpu_to_le16(1); in ice_lag_move_vf_nodes_tc_sync()
1965 buf->hdr.mode = ICE_AQC_MOVE_ELEM_MODE_KEEP_OWN; in ice_lag_move_vf_nodes_tc_sync()
1966 buf->teid[0] = teid; in ice_lag_move_vf_nodes_tc_sync()
1968 if (ice_aq_move_sched_elems(&lag->pf->hw, buf, buf_size, &num_moved)) in ice_lag_move_vf_nodes_tc_sync()
1971 ice_sched_update_parent(n_prt, ctx->sched.vsi_node[tc]); in ice_lag_move_vf_nodes_tc_sync()
1980 dev_warn(dev, "Problem restarting traffic for LAG node reset rebuild\n"); in ice_lag_move_vf_nodes_tc_sync()
1984 * ice_lag_move_vf_nodes_sync - move vf nodes to active interface
1989 * to move the VF nodes to the secondary interface when that interface
1990 * is the active interface during a reset rebuild
1998 if (!lag->primary || !dest_hw) in ice_lag_move_vf_nodes_sync()
2001 pf = lag->pf; in ice_lag_move_vf_nodes_sync()
2003 if (pf->vsi[i] && pf->vsi[i]->type == ICE_VSI_VF) in ice_lag_move_vf_nodes_sync()
2010 * ice_init_lag - initialize support for LAG
2028 pf->lag = kzalloc(sizeof(*lag), GFP_KERNEL); in ice_init_lag()
2029 if (!pf->lag) in ice_init_lag()
2030 return -ENOMEM; in ice_init_lag()
2031 lag = pf->lag; in ice_init_lag()
2036 err = -EIO; in ice_init_lag()
2040 lag->pf = pf; in ice_init_lag()
2041 lag->netdev = vsi->netdev; in ice_init_lag()
2042 lag->role = ICE_LAG_NONE; in ice_init_lag()
2043 lag->active_port = ICE_LAG_INVALID_PORT; in ice_init_lag()
2044 lag->bonded = false; in ice_init_lag()
2045 lag->upper_netdev = NULL; in ice_init_lag()
2046 lag->notif_block.notifier_call = NULL; in ice_init_lag()
2054 err = ice_create_lag_recipe(&pf->hw, &lag->pf_recipe, in ice_init_lag()
2059 err = ice_create_lag_recipe(&pf->hw, &lag->lport_recipe, in ice_init_lag()
2066 err = ice_aq_get_recipe_to_profile(&pf->hw, n, in ice_init_lag()
2072 recipe_bits |= BIT(lag->pf_recipe) | in ice_init_lag()
2073 BIT(lag->lport_recipe); in ice_init_lag()
2074 ice_aq_map_recipe_to_profile(&pf->hw, n, in ice_init_lag()
2085 ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1, in ice_init_lag()
2086 &pf->lag->pf_recipe); in ice_init_lag()
2089 pf->lag = NULL; in ice_init_lag()
2094 * ice_deinit_lag - Clean up LAG
2104 lag = pf->lag; in ice_deinit_lag()
2109 if (lag->pf) in ice_deinit_lag()
2114 ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1, in ice_deinit_lag()
2115 &pf->lag->pf_recipe); in ice_deinit_lag()
2116 ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1, in ice_deinit_lag()
2117 &pf->lag->lport_recipe); in ice_deinit_lag()
2121 pf->lag = NULL; in ice_deinit_lag()
2125 * ice_lag_rebuild - rebuild lag resources after reset
2128 * PF resets are promoted to CORER resets when interface in an aggregate. This
2129 * means that we need to rebuild the PF resources for the interface. Since
2134 * interface.
2142 if (!pf->lag || !pf->lag->bonded) in ice_lag_rebuild()
2145 mutex_lock(&pf->lag_mutex); in ice_lag_rebuild()
2147 lag = pf->lag; in ice_lag_rebuild()
2148 if (lag->primary) { in ice_lag_rebuild()
2156 dev_dbg(ice_pf_to_dev(pf), "No primary interface in aggregate, can't rebuild\n"); in ice_lag_rebuild()
2160 act_port = prim_lag->active_port; in ice_lag_rebuild()
2161 loc_port = lag->pf->hw.port_info->lport; in ice_lag_rebuild()
2164 if (lag->primary) { in ice_lag_rebuild()
2167 ice_lag_set_swid(prim_lag->pf->hw.port_info->sw_id, lag, true); in ice_lag_rebuild()
2170 ice_lag_move_vf_nodes_sync(prim_lag, &pf->hw); in ice_lag_rebuild()
2175 if (lag->pf_rx_rule_id) in ice_lag_rebuild()
2182 mutex_unlock(&pf->lag_mutex); in ice_lag_rebuild()
2193 struct ice_lag *lag = pf->lag; in ice_lag_is_switchdev_running()
2200 for_each_netdev_in_bond_rcu(lag->upper_netdev, tmp_nd) { in ice_lag_is_switchdev_running()
2203 if (!netif_is_ice(tmp_nd) || !priv || !priv->vsi || in ice_lag_is_switchdev_running()
2204 !priv->vsi->back) in ice_lag_is_switchdev_running()
2207 if (ice_is_switchdev_running(priv->vsi->back)) { in ice_lag_is_switchdev_running()