Lines Matching +full:tlv +full:- +full:layout

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018-2023, Intel Corporation. */
41 static int debug = -1;
53 * ice_hw_to_dev - Get device pointer from the hardware structure
64 return &pf->pdev->dev; in ice_hw_to_dev()
87 return dev && (dev->netdev_ops == &ice_netdev_ops || in netif_is_ice()
88 dev->netdev_ops == &ice_netdev_safe_mode_ops); in netif_is_ice()
92 * ice_get_tx_pending - returns number of Tx descriptors not processed
99 head = ring->next_to_clean; in ice_get_tx_pending()
100 tail = ring->next_to_use; in ice_get_tx_pending()
104 tail - head : (tail + ring->count - head); in ice_get_tx_pending()
109 * ice_check_for_hang_subtask - check for and recover hung queues
121 if (pf->vsi[v] && pf->vsi[v]->type == ICE_VSI_PF) { in ice_check_for_hang_subtask()
122 vsi = pf->vsi[v]; in ice_check_for_hang_subtask()
126 if (!vsi || test_bit(ICE_VSI_DOWN, vsi->state)) in ice_check_for_hang_subtask()
129 if (!(vsi->netdev && netif_carrier_ok(vsi->netdev))) in ice_check_for_hang_subtask()
132 hw = &vsi->back->hw; in ice_check_for_hang_subtask()
135 struct ice_tx_ring *tx_ring = vsi->tx_rings[i]; in ice_check_for_hang_subtask()
143 ring_stats = tx_ring->ring_stats; in ice_check_for_hang_subtask()
147 if (tx_ring->desc) { in ice_check_for_hang_subtask()
155 packets = ring_stats->stats.pkts & INT_MAX; in ice_check_for_hang_subtask()
156 if (ring_stats->tx_stats.prev_pkt == packets) { in ice_check_for_hang_subtask()
158 ice_trigger_sw_intr(hw, tx_ring->q_vector); in ice_check_for_hang_subtask()
166 ring_stats->tx_stats.prev_pkt = in ice_check_for_hang_subtask()
167 ice_get_tx_pending(tx_ring) ? packets : -1; in ice_check_for_hang_subtask()
173 * ice_init_mac_fltr - Set initial MAC filters
187 return -EINVAL; in ice_init_mac_fltr()
189 perm_addr = vsi->port_info->mac.perm_addr; in ice_init_mac_fltr()
194 * ice_add_mac_to_sync_list - creates list of MAC addresses to be synced
206 struct ice_vsi *vsi = np->vsi; in ice_add_mac_to_sync_list()
208 if (ice_fltr_add_mac_to_list(vsi, &vsi->tmp_sync_list, addr, in ice_add_mac_to_sync_list()
210 return -EINVAL; in ice_add_mac_to_sync_list()
216 * ice_add_mac_to_unsync_list - creates list of MAC addresses to be unsynced
228 struct ice_vsi *vsi = np->vsi; in ice_add_mac_to_unsync_list()
235 if (ether_addr_equal(addr, netdev->dev_addr)) in ice_add_mac_to_unsync_list()
238 if (ice_fltr_add_mac_to_list(vsi, &vsi->tmp_unsync_list, addr, in ice_add_mac_to_unsync_list()
240 return -EINVAL; in ice_add_mac_to_unsync_list()
246 * ice_vsi_fltr_changed - check if filter state changed
253 return test_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state) || in ice_vsi_fltr_changed()
254 test_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state); in ice_vsi_fltr_changed()
258 * ice_set_promisc - Enable promiscuous mode for a given PF
267 if (vsi->type != ICE_VSI_PF) in ice_set_promisc()
272 status = ice_fltr_set_vlan_vsi_promisc(&vsi->back->hw, vsi, in ice_set_promisc()
275 status = ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_set_promisc()
278 if (status && status != -EEXIST) in ice_set_promisc()
281 netdev_dbg(vsi->netdev, "set promisc filter bits for VSI %i: 0x%x\n", in ice_set_promisc()
282 vsi->vsi_num, promisc_m); in ice_set_promisc()
287 * ice_clear_promisc - Disable promiscuous mode for a given PF
296 if (vsi->type != ICE_VSI_PF) in ice_clear_promisc()
301 status = ice_fltr_clear_vlan_vsi_promisc(&vsi->back->hw, vsi, in ice_clear_promisc()
304 status = ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_clear_promisc()
308 netdev_dbg(vsi->netdev, "clear promisc filter bits for VSI %i: 0x%x\n", in ice_clear_promisc()
309 vsi->vsi_num, promisc_m); in ice_clear_promisc()
314 * ice_vsi_sync_fltr - Update the VSI filter list to the HW
322 struct device *dev = ice_pf_to_dev(vsi->back); in ice_vsi_sync_fltr()
323 struct net_device *netdev = vsi->netdev; in ice_vsi_sync_fltr()
325 struct ice_pf *pf = vsi->back; in ice_vsi_sync_fltr()
326 struct ice_hw *hw = &pf->hw; in ice_vsi_sync_fltr()
330 if (!vsi->netdev) in ice_vsi_sync_fltr()
331 return -EINVAL; in ice_vsi_sync_fltr()
333 while (test_and_set_bit(ICE_CFG_BUSY, vsi->state)) in ice_vsi_sync_fltr()
336 changed_flags = vsi->current_netdev_flags ^ vsi->netdev->flags; in ice_vsi_sync_fltr()
337 vsi->current_netdev_flags = vsi->netdev->flags; in ice_vsi_sync_fltr()
339 INIT_LIST_HEAD(&vsi->tmp_sync_list); in ice_vsi_sync_fltr()
340 INIT_LIST_HEAD(&vsi->tmp_unsync_list); in ice_vsi_sync_fltr()
343 clear_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state); in ice_vsi_sync_fltr()
344 clear_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state); in ice_vsi_sync_fltr()
357 err = ice_fltr_remove_mac_list(vsi, &vsi->tmp_unsync_list); in ice_vsi_sync_fltr()
358 ice_fltr_free_list(dev, &vsi->tmp_unsync_list); in ice_vsi_sync_fltr()
362 if (err == -ENOMEM) in ice_vsi_sync_fltr()
367 err = ice_fltr_add_mac_list(vsi, &vsi->tmp_sync_list); in ice_vsi_sync_fltr()
368 ice_fltr_free_list(dev, &vsi->tmp_sync_list); in ice_vsi_sync_fltr()
373 if (err && err != -EEXIST) { in ice_vsi_sync_fltr()
379 if (hw->adminq.sq_last_status == ICE_AQ_RC_ENOSPC && in ice_vsi_sync_fltr()
381 vsi->state)) { in ice_vsi_sync_fltr()
384 vsi->vsi_num); in ice_vsi_sync_fltr()
392 if (vsi->current_netdev_flags & IFF_ALLMULTI) { in ice_vsi_sync_fltr()
395 vsi->current_netdev_flags &= ~IFF_ALLMULTI; in ice_vsi_sync_fltr()
399 /* !(vsi->current_netdev_flags & IFF_ALLMULTI) */ in ice_vsi_sync_fltr()
402 vsi->current_netdev_flags |= IFF_ALLMULTI; in ice_vsi_sync_fltr()
409 test_bit(ICE_VSI_PROMISC_CHANGED, vsi->state)) { in ice_vsi_sync_fltr()
410 clear_bit(ICE_VSI_PROMISC_CHANGED, vsi->state); in ice_vsi_sync_fltr()
411 if (vsi->current_netdev_flags & IFF_PROMISC) { in ice_vsi_sync_fltr()
413 if (!ice_is_dflt_vsi_in_use(vsi->port_info)) { in ice_vsi_sync_fltr()
415 if (err && err != -EEXIST) { in ice_vsi_sync_fltr()
417 err, vsi->vsi_num); in ice_vsi_sync_fltr()
418 vsi->current_netdev_flags &= in ice_vsi_sync_fltr()
423 vlan_ops->dis_rx_filtering(vsi); in ice_vsi_sync_fltr()
441 err, vsi->vsi_num); in ice_vsi_sync_fltr()
442 vsi->current_netdev_flags |= in ice_vsi_sync_fltr()
446 if (vsi->netdev->features & in ice_vsi_sync_fltr()
448 vlan_ops->ena_rx_filtering(vsi); in ice_vsi_sync_fltr()
454 if (!(vsi->current_netdev_flags & IFF_ALLMULTI)) { in ice_vsi_sync_fltr()
459 err, vsi->vsi_num); in ice_vsi_sync_fltr()
467 set_bit(ICE_VSI_PROMISC_CHANGED, vsi->state); in ice_vsi_sync_fltr()
471 set_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state); in ice_vsi_sync_fltr()
472 set_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state); in ice_vsi_sync_fltr()
474 clear_bit(ICE_CFG_BUSY, vsi->state); in ice_vsi_sync_fltr()
479 * ice_sync_fltr_subtask - Sync the VSI filter list with HW
486 if (!pf || !(test_bit(ICE_FLAG_FLTR_SYNC, pf->flags))) in ice_sync_fltr_subtask()
489 clear_bit(ICE_FLAG_FLTR_SYNC, pf->flags); in ice_sync_fltr_subtask()
492 if (pf->vsi[v] && ice_vsi_fltr_changed(pf->vsi[v]) && in ice_sync_fltr_subtask()
493 ice_vsi_sync_fltr(pf->vsi[v])) { in ice_sync_fltr_subtask()
495 set_bit(ICE_FLAG_FLTR_SYNC, pf->flags); in ice_sync_fltr_subtask()
501 * ice_pf_dis_all_vsi - Pause all VSIs on a PF
511 if (pf->vsi[v]) in ice_pf_dis_all_vsi()
512 ice_dis_vsi(pf->vsi[v], locked); in ice_pf_dis_all_vsi()
515 pf->pf_agg_node[node].num_vsis = 0; in ice_pf_dis_all_vsi()
518 pf->vf_agg_node[node].num_vsis = 0; in ice_pf_dis_all_vsi()
522 * ice_prepare_for_reset - prep for reset
531 struct ice_hw *hw = &pf->hw; in ice_prepare_for_reset()
539 if (test_bit(ICE_PREPARED_FOR_RESET, pf->state)) in ice_prepare_for_reset()
542 synchronize_irq(pf->oicr_irq.virq); in ice_prepare_for_reset()
547 if (ice_check_sq_alive(hw, &hw->mailboxq)) in ice_prepare_for_reset()
551 mutex_lock(&pf->vfs.table_lock); in ice_prepare_for_reset()
554 mutex_unlock(&pf->vfs.table_lock); in ice_prepare_for_reset()
558 ice_eswitch_br_fdb_flush(pf->eswitch.br_offloads->bridge); in ice_prepare_for_reset()
570 vsi->orig_rss_size = 0; in ice_prepare_for_reset()
572 if (test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) { in ice_prepare_for_reset()
574 vsi->old_ena_tc = vsi->all_enatc; in ice_prepare_for_reset()
575 vsi->old_numtc = vsi->all_numtc; in ice_prepare_for_reset()
582 vsi->old_ena_tc = 0; in ice_prepare_for_reset()
583 vsi->all_enatc = 0; in ice_prepare_for_reset()
584 vsi->old_numtc = 0; in ice_prepare_for_reset()
585 vsi->all_numtc = 0; in ice_prepare_for_reset()
586 vsi->req_txq = 0; in ice_prepare_for_reset()
587 vsi->req_rxq = 0; in ice_prepare_for_reset()
588 clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags); in ice_prepare_for_reset()
589 memset(&vsi->mqprio_qopt, 0, sizeof(vsi->mqprio_qopt)); in ice_prepare_for_reset()
593 if (vsi->netdev) in ice_prepare_for_reset()
594 netif_device_detach(vsi->netdev); in ice_prepare_for_reset()
600 set_bit(ICE_VSI_REBUILD_PENDING, ice_get_main_vsi(pf)->state); in ice_prepare_for_reset()
603 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_prepare_for_reset()
609 if (hw->port_info) in ice_prepare_for_reset()
610 ice_sched_clear_port(hw->port_info); in ice_prepare_for_reset()
614 set_bit(ICE_PREPARED_FOR_RESET, pf->state); in ice_prepare_for_reset()
618 * ice_do_reset - Initiate one of many types of resets
625 struct ice_hw *hw = &pf->hw; in ice_do_reset()
629 if (pf->lag && pf->lag->bonded && reset_type == ICE_RESET_PFR) { in ice_do_reset()
639 set_bit(ICE_RESET_FAILED, pf->state); in ice_do_reset()
640 clear_bit(ICE_RESET_OICR_RECV, pf->state); in ice_do_reset()
641 clear_bit(ICE_PREPARED_FOR_RESET, pf->state); in ice_do_reset()
642 clear_bit(ICE_PFR_REQ, pf->state); in ice_do_reset()
643 clear_bit(ICE_CORER_REQ, pf->state); in ice_do_reset()
644 clear_bit(ICE_GLOBR_REQ, pf->state); in ice_do_reset()
645 wake_up(&pf->reset_wait_queue); in ice_do_reset()
650 * interrupt. So for PFR, rebuild after the reset and clear the reset- in ice_do_reset()
654 pf->pfr_count++; in ice_do_reset()
656 clear_bit(ICE_PREPARED_FOR_RESET, pf->state); in ice_do_reset()
657 clear_bit(ICE_PFR_REQ, pf->state); in ice_do_reset()
658 wake_up(&pf->reset_wait_queue); in ice_do_reset()
664 * ice_reset_subtask - Set up for resetting the device and driver
673 * of reset is pending and sets bits in pf->state indicating the reset in ice_reset_subtask()
675 * prepare for pending reset if not already (for PF software-initiated in ice_reset_subtask()
681 if (test_bit(ICE_RESET_OICR_RECV, pf->state)) { in ice_reset_subtask()
683 if (test_and_clear_bit(ICE_CORER_RECV, pf->state)) in ice_reset_subtask()
685 if (test_and_clear_bit(ICE_GLOBR_RECV, pf->state)) in ice_reset_subtask()
687 if (test_and_clear_bit(ICE_EMPR_RECV, pf->state)) in ice_reset_subtask()
695 if (ice_check_reset(&pf->hw)) { in ice_reset_subtask()
696 set_bit(ICE_RESET_FAILED, pf->state); in ice_reset_subtask()
699 pf->hw.reset_ongoing = false; in ice_reset_subtask()
704 clear_bit(ICE_RESET_OICR_RECV, pf->state); in ice_reset_subtask()
705 clear_bit(ICE_PREPARED_FOR_RESET, pf->state); in ice_reset_subtask()
706 clear_bit(ICE_PFR_REQ, pf->state); in ice_reset_subtask()
707 clear_bit(ICE_CORER_REQ, pf->state); in ice_reset_subtask()
708 clear_bit(ICE_GLOBR_REQ, pf->state); in ice_reset_subtask()
709 wake_up(&pf->reset_wait_queue); in ice_reset_subtask()
717 if (test_bit(ICE_PFR_REQ, pf->state)) { in ice_reset_subtask()
719 if (pf->lag && pf->lag->bonded) { in ice_reset_subtask()
724 if (test_bit(ICE_CORER_REQ, pf->state)) in ice_reset_subtask()
726 if (test_bit(ICE_GLOBR_REQ, pf->state)) in ice_reset_subtask()
733 if (!test_bit(ICE_DOWN, pf->state) && in ice_reset_subtask()
734 !test_bit(ICE_CFG_BUSY, pf->state)) { in ice_reset_subtask()
740 * ice_print_topo_conflict - print topology conflict message
745 switch (vsi->port_info->phy.link_info.topo_media_conflict) { in ice_print_topo_conflict()
751 …netdev_info(vsi->netdev, "Potential misconfiguration of the Ethernet port detected. If it was not … in ice_print_topo_conflict()
754 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, vsi->back->flags)) in ice_print_topo_conflict()
755 …netdev_warn(vsi->netdev, "An unsupported module type was detected. Refer to the Intel(R) Ethernet … in ice_print_topo_conflict()
757 …netdev_err(vsi->netdev, "Rx/Tx is disabled on this device because an unsupported module type was d… in ice_print_topo_conflict()
765 * ice_print_link_msg - print link up or down message
783 if (vsi->current_isup == isup) in ice_print_link_msg()
786 vsi->current_isup = isup; in ice_print_link_msg()
789 netdev_info(vsi->netdev, "NIC Link is Down\n"); in ice_print_link_msg()
793 switch (vsi->port_info->phy.link_info.link_speed) { in ice_print_link_msg()
829 switch (vsi->port_info->fc.current_mode) { in ice_print_link_msg()
848 switch (vsi->port_info->phy.link_info.fec_info) { in ice_print_link_msg()
851 fec = "RS-FEC"; in ice_print_link_msg()
854 fec = "FC-FEC/BASE-R"; in ice_print_link_msg()
862 if (vsi->port_info->phy.link_info.an_info & ICE_AQ_AN_COMPLETED) in ice_print_link_msg()
875 status = ice_aq_get_phy_caps(vsi->port_info, false, in ice_print_link_msg()
878 netdev_info(vsi->netdev, "Get phy capability failed.\n"); in ice_print_link_msg()
882 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ || in ice_print_link_msg()
883 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ) in ice_print_link_msg()
884 fec_req = "RS-FEC"; in ice_print_link_msg()
885 else if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ || in ice_print_link_msg()
886 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ) in ice_print_link_msg()
887 fec_req = "FC-FEC/BASE-R"; in ice_print_link_msg()
894 …netdev_info(vsi->netdev, "NIC Link is up %sbps Full Duplex, Requested FEC: %s, Negotiated FEC: %s,… in ice_print_link_msg()
900 * ice_vsi_link_event - update the VSI's netdev
909 if (test_bit(ICE_VSI_DOWN, vsi->state) || !vsi->netdev) in ice_vsi_link_event()
912 if (vsi->type == ICE_VSI_PF) { in ice_vsi_link_event()
913 if (link_up == netif_carrier_ok(vsi->netdev)) in ice_vsi_link_event()
917 netif_carrier_on(vsi->netdev); in ice_vsi_link_event()
918 netif_tx_wake_all_queues(vsi->netdev); in ice_vsi_link_event()
920 netif_carrier_off(vsi->netdev); in ice_vsi_link_event()
921 netif_tx_stop_all_queues(vsi->netdev); in ice_vsi_link_event()
927 * ice_set_dflt_mib - send a default config MIB to the FW
942 struct ice_lldp_org_tlv *tlv; in ice_set_dflt_mib() local
943 struct ice_hw *hw = &pf->hw; in ice_set_dflt_mib()
954 /* Add ETS CFG TLV */ in ice_set_dflt_mib()
955 tlv = (struct ice_lldp_org_tlv *)lldpmib; in ice_set_dflt_mib()
958 tlv->typelen = htons(typelen); in ice_set_dflt_mib()
961 tlv->ouisubtype = htonl(ouisubtype); in ice_set_dflt_mib()
963 buf = tlv->tlvinfo; in ice_set_dflt_mib()
966 /* ETS CFG all UPs map to TC 0. Next 4 (1 - 4) Octets = 0. in ice_set_dflt_mib()
967 * Octets 5 - 12 are BW values, set octet 5 to 100% BW. in ice_set_dflt_mib()
968 * Octets 13 - 20 are TSA values - leave as zeros in ice_set_dflt_mib()
973 tlv = (struct ice_lldp_org_tlv *) in ice_set_dflt_mib()
974 ((char *)tlv + sizeof(tlv->typelen) + len); in ice_set_dflt_mib()
976 /* Add ETS REC TLV */ in ice_set_dflt_mib()
977 buf = tlv->tlvinfo; in ice_set_dflt_mib()
978 tlv->typelen = htons(typelen); in ice_set_dflt_mib()
982 tlv->ouisubtype = htonl(ouisubtype); in ice_set_dflt_mib()
985 * Octets 1 - 4 map UP to TC - all UPs map to zero in ice_set_dflt_mib()
986 * Octets 5 - 12 are BW values - set TC 0 to 100%. in ice_set_dflt_mib()
987 * Octets 13 - 20 are TSA value - leave as zeros in ice_set_dflt_mib()
991 tlv = (struct ice_lldp_org_tlv *) in ice_set_dflt_mib()
992 ((char *)tlv + sizeof(tlv->typelen) + len); in ice_set_dflt_mib()
994 /* Add PFC CFG TLV */ in ice_set_dflt_mib()
997 tlv->typelen = htons(typelen); in ice_set_dflt_mib()
1001 tlv->ouisubtype = htonl(ouisubtype); in ice_set_dflt_mib()
1003 /* Octet 1 left as all zeros - PFC disabled */ in ice_set_dflt_mib()
1015 * ice_check_phy_fw_load - check if PHY FW load failed
1024 clear_bit(ICE_FLAG_PHY_FW_LOAD_FAILED, pf->flags); in ice_check_phy_fw_load()
1028 if (test_bit(ICE_FLAG_PHY_FW_LOAD_FAILED, pf->flags)) in ice_check_phy_fw_load()
1033 set_bit(ICE_FLAG_PHY_FW_LOAD_FAILED, pf->flags); in ice_check_phy_fw_load()
1050 clear_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags); in ice_check_module_power()
1057 if (test_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags)) in ice_check_module_power()
1062 set_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags); in ice_check_module_power()
1065 set_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags); in ice_check_module_power()
1070 * ice_check_link_cfg_err - check if link configuration failed
1084 * ice_link_event - process the link event
1103 phy_info = &pi->phy; in ice_link_event()
1104 phy_info->link_info_old = phy_info->link_info; in ice_link_event()
1106 old_link = !!(phy_info->link_info_old.link_info & ICE_AQ_LINK_UP); in ice_link_event()
1107 old_link_speed = phy_info->link_info_old.link_speed; in ice_link_event()
1109 /* update the link info structures and re-enable link events, in ice_link_event()
1115 pi->lport, status, in ice_link_event()
1116 ice_aq_str(pi->hw->adminq.sq_last_status)); in ice_link_event()
1118 ice_check_link_cfg_err(pf, pi->phy.link_info.link_cfg_err); in ice_link_event()
1123 if (phy_info->link_info.link_info & ICE_AQ_LINK_UP) in ice_link_event()
1127 if (!vsi || !vsi->port_info) in ice_link_event()
1128 return -EINVAL; in ice_link_event()
1131 if (!test_bit(ICE_FLAG_NO_MEDIA, pf->flags) && in ice_link_event()
1132 !(pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) { in ice_link_event()
1133 set_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_link_event()
1141 ice_ptp_link_change(pf, pf->hw.pf_id, link_up); in ice_link_event()
1144 if (test_bit(ICE_FLAG_DCB_ENA, pf->flags)) in ice_link_event()
1159 * ice_watchdog_subtask - periodic tasks not using event driven scheduling
1167 if (test_bit(ICE_DOWN, pf->state) || in ice_watchdog_subtask()
1168 test_bit(ICE_CFG_BUSY, pf->state)) in ice_watchdog_subtask()
1173 pf->serv_tmr_prev + pf->serv_tmr_period)) in ice_watchdog_subtask()
1176 pf->serv_tmr_prev = jiffies; in ice_watchdog_subtask()
1183 if (pf->vsi[i] && pf->vsi[i]->netdev) in ice_watchdog_subtask()
1184 ice_update_vsi_stats(pf->vsi[i]); in ice_watchdog_subtask()
1188 * ice_init_link_events - enable/initialize link events
1191 * Returns -EIO on failure, 0 on success
1201 if (ice_aq_set_event_mask(pi->hw, pi->lport, mask, NULL)) { in ice_init_link_events()
1202 dev_dbg(ice_hw_to_dev(pi->hw), "Failed to set link event mask for port %d\n", in ice_init_link_events()
1203 pi->lport); in ice_init_link_events()
1204 return -EIO; in ice_init_link_events()
1208 dev_dbg(ice_hw_to_dev(pi->hw), "Failed to enable link events for port %d\n", in ice_init_link_events()
1209 pi->lport); in ice_init_link_events()
1210 return -EIO; in ice_init_link_events()
1217 * ice_handle_link_event - handle link event via ARQ
1228 link_data = (struct ice_aqc_get_link_status_data *)event->msg_buf; in ice_handle_link_event()
1229 port_info = pf->hw.port_info; in ice_handle_link_event()
1231 return -EINVAL; in ice_handle_link_event()
1234 !!(link_data->link_info & ICE_AQ_LINK_UP), in ice_handle_link_event()
1235 le16_to_cpu(link_data->link_speed)); in ice_handle_link_event()
1244 * ice_aq_prep_for_event - Prepare to wait for an AdminQ event from firmware
1255 * To obtain only the descriptor contents, pass an task->event with null
1257 * task->event.msg_buf with enough space ahead of time.
1262 INIT_HLIST_NODE(&task->entry); in ice_aq_prep_for_event()
1263 task->opcode = opcode; in ice_aq_prep_for_event()
1264 task->state = ICE_AQ_TASK_WAITING; in ice_aq_prep_for_event()
1266 spin_lock_bh(&pf->aq_wait_lock); in ice_aq_prep_for_event()
1267 hlist_add_head(&task->entry, &pf->aq_wait_list); in ice_aq_prep_for_event()
1268 spin_unlock_bh(&pf->aq_wait_lock); in ice_aq_prep_for_event()
1272 * ice_aq_wait_for_event - Wait for an AdminQ event from firmware
1286 enum ice_aq_task_state *state = &task->state; in ice_aq_wait_for_event()
1292 ret = wait_event_interruptible_timeout(pf->aq_wait_queue, in ice_aq_wait_for_event()
1298 err = -EINVAL; in ice_aq_wait_for_event()
1301 err = ret < 0 ? ret : -ETIMEDOUT; in ice_aq_wait_for_event()
1304 err = ret < 0 ? ret : -ECANCELED; in ice_aq_wait_for_event()
1311 err = -EINVAL; in ice_aq_wait_for_event()
1316 jiffies_to_msecs(jiffies - start), in ice_aq_wait_for_event()
1318 task->opcode); in ice_aq_wait_for_event()
1320 spin_lock_bh(&pf->aq_wait_lock); in ice_aq_wait_for_event()
1321 hlist_del(&task->entry); in ice_aq_wait_for_event()
1322 spin_unlock_bh(&pf->aq_wait_lock); in ice_aq_wait_for_event()
1328 * ice_aq_check_events - Check if any thread is waiting for an AdminQ event
1339 * Note that event->msg_buf will only be duplicated if the event has a buffer
1352 spin_lock_bh(&pf->aq_wait_lock); in ice_aq_check_events()
1353 hlist_for_each_entry(task, &pf->aq_wait_list, entry) { in ice_aq_check_events()
1354 if (task->state != ICE_AQ_TASK_WAITING) in ice_aq_check_events()
1356 if (task->opcode != opcode) in ice_aq_check_events()
1359 task_ev = &task->event; in ice_aq_check_events()
1360 memcpy(&task_ev->desc, &event->desc, sizeof(event->desc)); in ice_aq_check_events()
1361 task_ev->msg_len = event->msg_len; in ice_aq_check_events()
1364 if (task_ev->msg_buf && task_ev->buf_len >= event->buf_len) { in ice_aq_check_events()
1365 memcpy(task_ev->msg_buf, event->msg_buf, in ice_aq_check_events()
1366 event->buf_len); in ice_aq_check_events()
1367 task_ev->buf_len = event->buf_len; in ice_aq_check_events()
1370 task->state = ICE_AQ_TASK_COMPLETE; in ice_aq_check_events()
1373 spin_unlock_bh(&pf->aq_wait_lock); in ice_aq_check_events()
1376 wake_up(&pf->aq_wait_queue); in ice_aq_check_events()
1380 * ice_aq_cancel_waiting_tasks - Immediately cancel all waiting tasks
1384 * This will then cause ice_aq_wait_for_event to exit with -ECANCELED.
1390 spin_lock_bh(&pf->aq_wait_lock); in ice_aq_cancel_waiting_tasks()
1391 hlist_for_each_entry(task, &pf->aq_wait_list, entry) in ice_aq_cancel_waiting_tasks()
1392 task->state = ICE_AQ_TASK_CANCELED; in ice_aq_cancel_waiting_tasks()
1393 spin_unlock_bh(&pf->aq_wait_lock); in ice_aq_cancel_waiting_tasks()
1395 wake_up(&pf->aq_wait_queue); in ice_aq_cancel_waiting_tasks()
1401 * __ice_clean_ctrlq - helper function to clean controlq rings
1409 struct ice_hw *hw = &pf->hw; in __ice_clean_ctrlq()
1416 if (test_bit(ICE_RESET_FAILED, pf->state)) in __ice_clean_ctrlq()
1421 cq = &hw->adminq; in __ice_clean_ctrlq()
1425 cq = &hw->sbq; in __ice_clean_ctrlq()
1429 cq = &hw->mailboxq; in __ice_clean_ctrlq()
1434 hw->mbx_snapshot.mbx_buf.state = ICE_MAL_VF_DETECT_STATE_NEW_SNAPSHOT; in __ice_clean_ctrlq()
1441 /* check for error indications - PF_xx_AxQLEN register layout for in __ice_clean_ctrlq()
1444 val = rd32(hw, cq->rq.len); in __ice_clean_ctrlq()
1461 wr32(hw, cq->rq.len, val); in __ice_clean_ctrlq()
1464 val = rd32(hw, cq->sq.len); in __ice_clean_ctrlq()
1481 wr32(hw, cq->sq.len, val); in __ice_clean_ctrlq()
1484 event.buf_len = cq->rq_buf_size; in __ice_clean_ctrlq()
1495 if (ret == -EALREADY) in __ice_clean_ctrlq()
1521 u16 val = hw->mailboxq.num_rq_entries; in __ice_clean_ctrlq()
1551 * ice_ctrlq_pending - check if there is a difference between ntc and ntu
1561 ntu = (u16)(rd32(hw, cq->rq.head) & cq->rq.head_mask); in ice_ctrlq_pending()
1562 return cq->rq.next_to_clean != ntu; in ice_ctrlq_pending()
1566 * ice_clean_adminq_subtask - clean the AdminQ rings
1571 struct ice_hw *hw = &pf->hw; in ice_clean_adminq_subtask()
1573 if (!test_bit(ICE_ADMINQ_EVENT_PENDING, pf->state)) in ice_clean_adminq_subtask()
1579 clear_bit(ICE_ADMINQ_EVENT_PENDING, pf->state); in ice_clean_adminq_subtask()
1586 if (ice_ctrlq_pending(hw, &hw->adminq)) in ice_clean_adminq_subtask()
1593 * ice_clean_mailboxq_subtask - clean the MailboxQ rings
1598 struct ice_hw *hw = &pf->hw; in ice_clean_mailboxq_subtask()
1600 if (!test_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state)) in ice_clean_mailboxq_subtask()
1606 clear_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state); in ice_clean_mailboxq_subtask()
1608 if (ice_ctrlq_pending(hw, &hw->mailboxq)) in ice_clean_mailboxq_subtask()
1615 * ice_clean_sbq_subtask - clean the Sideband Queue rings
1620 struct ice_hw *hw = &pf->hw; in ice_clean_sbq_subtask()
1624 clear_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state); in ice_clean_sbq_subtask()
1628 if (!test_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state)) in ice_clean_sbq_subtask()
1634 clear_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state); in ice_clean_sbq_subtask()
1636 if (ice_ctrlq_pending(hw, &hw->sbq)) in ice_clean_sbq_subtask()
1643 * ice_service_task_schedule - schedule the service task to wake up
1650 if (!test_bit(ICE_SERVICE_DIS, pf->state) && in ice_service_task_schedule()
1651 !test_and_set_bit(ICE_SERVICE_SCHED, pf->state) && in ice_service_task_schedule()
1652 !test_bit(ICE_NEEDS_RESTART, pf->state)) in ice_service_task_schedule()
1653 queue_work(ice_wq, &pf->serv_task); in ice_service_task_schedule()
1657 * ice_service_task_complete - finish up the service task
1662 WARN_ON(!test_bit(ICE_SERVICE_SCHED, pf->state)); in ice_service_task_complete()
1664 /* force memory (pf->state) to sync before next service task */ in ice_service_task_complete()
1666 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_service_task_complete()
1670 * ice_service_task_stop - stop service task and cancel works
1680 ret = test_and_set_bit(ICE_SERVICE_DIS, pf->state); in ice_service_task_stop()
1682 if (pf->serv_tmr.function) in ice_service_task_stop()
1683 del_timer_sync(&pf->serv_tmr); in ice_service_task_stop()
1684 if (pf->serv_task.func) in ice_service_task_stop()
1685 cancel_work_sync(&pf->serv_task); in ice_service_task_stop()
1687 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_service_task_stop()
1692 * ice_service_task_restart - restart service task and schedule works
1699 clear_bit(ICE_SERVICE_DIS, pf->state); in ice_service_task_restart()
1704 * ice_service_timer - timer callback to schedule service task
1711 mod_timer(&pf->serv_tmr, round_jiffies(pf->serv_tmr_period + jiffies)); in ice_service_timer()
1716 * ice_handle_mdd_event - handle malicious driver detect event
1723 * private flag mdd-auto-reset-vf.
1728 struct ice_hw *hw = &pf->hw; in ice_handle_mdd_event()
1733 if (!test_and_clear_bit(ICE_MDD_EVENT_PENDING, pf->state)) { in ice_handle_mdd_event()
1818 mutex_lock(&pf->vfs.table_lock); in ice_handle_mdd_event()
1820 reg = rd32(hw, VP_MDET_TX_PQM(vf->vf_id)); in ice_handle_mdd_event()
1822 wr32(hw, VP_MDET_TX_PQM(vf->vf_id), 0xFFFF); in ice_handle_mdd_event()
1823 vf->mdd_tx_events.count++; in ice_handle_mdd_event()
1824 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1827 vf->vf_id); in ice_handle_mdd_event()
1830 reg = rd32(hw, VP_MDET_TX_TCLAN(vf->vf_id)); in ice_handle_mdd_event()
1832 wr32(hw, VP_MDET_TX_TCLAN(vf->vf_id), 0xFFFF); in ice_handle_mdd_event()
1833 vf->mdd_tx_events.count++; in ice_handle_mdd_event()
1834 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1837 vf->vf_id); in ice_handle_mdd_event()
1840 reg = rd32(hw, VP_MDET_TX_TDPU(vf->vf_id)); in ice_handle_mdd_event()
1842 wr32(hw, VP_MDET_TX_TDPU(vf->vf_id), 0xFFFF); in ice_handle_mdd_event()
1843 vf->mdd_tx_events.count++; in ice_handle_mdd_event()
1844 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1847 vf->vf_id); in ice_handle_mdd_event()
1850 reg = rd32(hw, VP_MDET_RX(vf->vf_id)); in ice_handle_mdd_event()
1852 wr32(hw, VP_MDET_RX(vf->vf_id), 0xFFFF); in ice_handle_mdd_event()
1853 vf->mdd_rx_events.count++; in ice_handle_mdd_event()
1854 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1857 vf->vf_id); in ice_handle_mdd_event()
1861 * private flag mdd-auto-reset-vf. in ice_handle_mdd_event()
1863 if (test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf->flags)) { in ice_handle_mdd_event()
1872 mutex_unlock(&pf->vfs.table_lock); in ice_handle_mdd_event()
1878 * ice_force_phys_link_state - Force the physical link state
1897 if (!vsi || !vsi->port_info || !vsi->back) in ice_force_phys_link_state()
1898 return -EINVAL; in ice_force_phys_link_state()
1899 if (vsi->type != ICE_VSI_PF) in ice_force_phys_link_state()
1902 dev = ice_pf_to_dev(vsi->back); in ice_force_phys_link_state()
1904 pi = vsi->port_info; in ice_force_phys_link_state()
1908 return -ENOMEM; in ice_force_phys_link_state()
1914 vsi->vsi_num, retcode); in ice_force_phys_link_state()
1915 retcode = -EIO; in ice_force_phys_link_state()
1920 if (link_up == !!(pcaps->caps & ICE_AQC_PHY_EN_LINK) && in ice_force_phys_link_state()
1921 link_up == !!(pi->phy.link_info.link_info & ICE_AQ_LINK_UP)) in ice_force_phys_link_state()
1928 cfg = kmemdup(&pi->phy.curr_user_phy_cfg, sizeof(*cfg), GFP_KERNEL); in ice_force_phys_link_state()
1930 retcode = -ENOMEM; in ice_force_phys_link_state()
1934 cfg->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT; in ice_force_phys_link_state()
1936 cfg->caps |= ICE_AQ_PHY_ENA_LINK; in ice_force_phys_link_state()
1938 cfg->caps &= ~ICE_AQ_PHY_ENA_LINK; in ice_force_phys_link_state()
1940 retcode = ice_aq_set_phy_cfg(&vsi->back->hw, pi, cfg, NULL); in ice_force_phys_link_state()
1943 vsi->vsi_num, retcode); in ice_force_phys_link_state()
1944 retcode = -EIO; in ice_force_phys_link_state()
1954 * ice_init_nvm_phy_type - Initialize the NVM PHY type
1962 struct ice_pf *pf = pi->hw->back; in ice_init_nvm_phy_type()
1967 return -ENOMEM; in ice_init_nvm_phy_type()
1977 pf->nvm_phy_type_hi = pcaps->phy_type_high; in ice_init_nvm_phy_type()
1978 pf->nvm_phy_type_lo = pcaps->phy_type_low; in ice_init_nvm_phy_type()
1986 * ice_init_link_dflt_override - Initialize link default override
1994 struct ice_pf *pf = pi->hw->back; in ice_init_link_dflt_override()
1996 ldo = &pf->link_dflt_override; in ice_init_link_dflt_override()
2000 if (!(ldo->options & ICE_LINK_OVERRIDE_PORT_DIS)) in ice_init_link_dflt_override()
2003 /* Enable Total Port Shutdown (override/replace link-down-on-close in ice_init_link_dflt_override()
2006 set_bit(ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags); in ice_init_link_dflt_override()
2007 set_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags); in ice_init_link_dflt_override()
2011 * ice_init_phy_cfg_dflt_override - Initialize PHY cfg default override settings
2031 struct ice_phy_info *phy = &pi->phy; in ice_init_phy_cfg_dflt_override()
2032 struct ice_pf *pf = pi->hw->back; in ice_init_phy_cfg_dflt_override()
2034 ldo = &pf->link_dflt_override; in ice_init_phy_cfg_dflt_override()
2039 cfg = &phy->curr_user_phy_cfg; in ice_init_phy_cfg_dflt_override()
2041 if (ldo->phy_type_low || ldo->phy_type_high) { in ice_init_phy_cfg_dflt_override()
2042 cfg->phy_type_low = pf->nvm_phy_type_lo & in ice_init_phy_cfg_dflt_override()
2043 cpu_to_le64(ldo->phy_type_low); in ice_init_phy_cfg_dflt_override()
2044 cfg->phy_type_high = pf->nvm_phy_type_hi & in ice_init_phy_cfg_dflt_override()
2045 cpu_to_le64(ldo->phy_type_high); in ice_init_phy_cfg_dflt_override()
2047 cfg->link_fec_opt = ldo->fec_options; in ice_init_phy_cfg_dflt_override()
2048 phy->curr_user_fec_req = ICE_FEC_AUTO; in ice_init_phy_cfg_dflt_override()
2050 set_bit(ICE_LINK_DEFAULT_OVERRIDE_PENDING, pf->state); in ice_init_phy_cfg_dflt_override()
2054 * ice_init_phy_user_cfg - Initialize the PHY user configuration
2070 struct ice_phy_info *phy = &pi->phy; in ice_init_phy_user_cfg()
2071 struct ice_pf *pf = pi->hw->back; in ice_init_phy_user_cfg()
2074 if (!(phy->link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) in ice_init_phy_user_cfg()
2075 return -EIO; in ice_init_phy_user_cfg()
2079 return -ENOMEM; in ice_init_phy_user_cfg()
2081 if (ice_fw_supports_report_dflt_cfg(pi->hw)) in ice_init_phy_user_cfg()
2092 ice_copy_phy_caps_to_cfg(pi, pcaps, &pi->phy.curr_user_phy_cfg); in ice_init_phy_user_cfg()
2095 if (ice_fw_supports_link_override(pi->hw) && in ice_init_phy_user_cfg()
2096 !(pcaps->module_compliance_enforcement & in ice_init_phy_user_cfg()
2098 set_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags); in ice_init_phy_user_cfg()
2104 if (!ice_fw_supports_report_dflt_cfg(pi->hw) && in ice_init_phy_user_cfg()
2105 (pf->link_dflt_override.options & ICE_LINK_OVERRIDE_EN)) { in ice_init_phy_user_cfg()
2114 phy->curr_user_fec_req = ice_caps_to_fec_mode(pcaps->caps, in ice_init_phy_user_cfg()
2115 pcaps->link_fec_options); in ice_init_phy_user_cfg()
2116 phy->curr_user_fc_req = ice_caps_to_fc_mode(pcaps->caps); in ice_init_phy_user_cfg()
2119 phy->curr_user_speed_req = ICE_AQ_LINK_SPEED_M; in ice_init_phy_user_cfg()
2120 set_bit(ICE_PHY_INIT_COMPLETE, pf->state); in ice_init_phy_user_cfg()
2127 * ice_configure_phy - configure PHY
2136 struct device *dev = ice_pf_to_dev(vsi->back); in ice_configure_phy()
2137 struct ice_port_info *pi = vsi->port_info; in ice_configure_phy()
2140 struct ice_phy_info *phy = &pi->phy; in ice_configure_phy()
2141 struct ice_pf *pf = vsi->back; in ice_configure_phy()
2145 if (!(phy->link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) in ice_configure_phy()
2146 return -ENOMEDIUM; in ice_configure_phy()
2150 if (!test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags) && in ice_configure_phy()
2151 phy->link_info.topo_media_conflict == ICE_AQ_LINK_TOPO_UNSUPP_MEDIA) in ice_configure_phy()
2152 return -EPERM; in ice_configure_phy()
2154 if (test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags)) in ice_configure_phy()
2159 return -ENOMEM; in ice_configure_phy()
2166 vsi->vsi_num, err); in ice_configure_phy()
2173 if (pcaps->caps & ICE_AQC_PHY_EN_LINK && in ice_configure_phy()
2174 ice_phy_caps_equals_cfg(pcaps, &phy->curr_user_phy_cfg)) in ice_configure_phy()
2179 if (ice_fw_supports_report_dflt_cfg(pi->hw)) in ice_configure_phy()
2187 vsi->vsi_num, err); in ice_configure_phy()
2193 err = -ENOMEM; in ice_configure_phy()
2199 /* Speed - If default override pending, use curr_user_phy_cfg set in in ice_configure_phy()
2203 vsi->back->state)) { in ice_configure_phy()
2204 cfg->phy_type_low = phy->curr_user_phy_cfg.phy_type_low; in ice_configure_phy()
2205 cfg->phy_type_high = phy->curr_user_phy_cfg.phy_type_high; in ice_configure_phy()
2210 pi->phy.curr_user_speed_req); in ice_configure_phy()
2211 cfg->phy_type_low = pcaps->phy_type_low & cpu_to_le64(phy_low); in ice_configure_phy()
2212 cfg->phy_type_high = pcaps->phy_type_high & in ice_configure_phy()
2217 if (!cfg->phy_type_low && !cfg->phy_type_high) { in ice_configure_phy()
2218 cfg->phy_type_low = pcaps->phy_type_low; in ice_configure_phy()
2219 cfg->phy_type_high = pcaps->phy_type_high; in ice_configure_phy()
2223 ice_cfg_phy_fec(pi, cfg, phy->curr_user_fec_req); in ice_configure_phy()
2226 if (cfg->link_fec_opt != in ice_configure_phy()
2227 (cfg->link_fec_opt & pcaps->link_fec_options)) { in ice_configure_phy()
2228 cfg->caps |= pcaps->caps & ICE_AQC_PHY_EN_AUTO_FEC; in ice_configure_phy()
2229 cfg->link_fec_opt = pcaps->link_fec_options; in ice_configure_phy()
2232 /* Flow Control - always supported; no need to check against in ice_configure_phy()
2235 ice_cfg_phy_fc(pi, cfg, phy->curr_user_fc_req); in ice_configure_phy()
2238 cfg->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT | ICE_AQ_PHY_ENA_LINK; in ice_configure_phy()
2240 err = ice_aq_set_phy_cfg(&pf->hw, pi, cfg, NULL); in ice_configure_phy()
2243 vsi->vsi_num, err); in ice_configure_phy()
2252 * ice_check_media_subtask - Check for media
2265 if (!test_bit(ICE_FLAG_NO_MEDIA, pf->flags)) in ice_check_media_subtask()
2273 pi = vsi->port_info; in ice_check_media_subtask()
2278 ice_check_link_cfg_err(pf, pi->phy.link_info.link_cfg_err); in ice_check_media_subtask()
2280 if (pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE) { in ice_check_media_subtask()
2281 if (!test_bit(ICE_PHY_INIT_COMPLETE, pf->state)) in ice_check_media_subtask()
2287 if (test_bit(ICE_VSI_DOWN, vsi->state) && in ice_check_media_subtask()
2288 test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, vsi->back->flags)) in ice_check_media_subtask()
2293 clear_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_check_media_subtask()
2302 * ice_service_task - manage and run subtasks
2316 if (ice_is_reset_in_progress(pf->state) || in ice_service_task()
2317 test_bit(ICE_SUSPENDED, pf->state) || in ice_service_task()
2318 test_bit(ICE_NEEDS_RESTART, pf->state)) { in ice_service_task()
2323 if (test_and_clear_bit(ICE_AUX_ERR_PENDING, pf->state)) { in ice_service_task()
2328 set_bit(IIDC_EVENT_CRIT_ERR, event->type); in ice_service_task()
2330 swap(event->reg, pf->oicr_err_reg); in ice_service_task()
2339 if (test_and_clear_bit(ICE_FLAG_UNPLUG_AUX_DEV, pf->flags)) in ice_service_task()
2343 if (test_and_clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags)) in ice_service_task()
2346 if (test_and_clear_bit(ICE_FLAG_MTU_CHANGED, pf->flags)) { in ice_service_task()
2351 set_bit(IIDC_EVENT_AFTER_MTU_CHANGE, event->type); in ice_service_task()
2382 if (time_after(jiffies, (start_time + pf->serv_tmr_period)) || in ice_service_task()
2383 test_bit(ICE_MDD_EVENT_PENDING, pf->state) || in ice_service_task()
2384 test_bit(ICE_VFLR_EVENT_PENDING, pf->state) || in ice_service_task()
2385 test_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state) || in ice_service_task()
2386 test_bit(ICE_FD_VF_FLUSH_CTX, pf->state) || in ice_service_task()
2387 test_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state) || in ice_service_task()
2388 test_bit(ICE_ADMINQ_EVENT_PENDING, pf->state)) in ice_service_task()
2389 mod_timer(&pf->serv_tmr, jiffies); in ice_service_task()
2393 * ice_set_ctrlq_len - helper function to set controlq length
2398 hw->adminq.num_rq_entries = ICE_AQ_LEN; in ice_set_ctrlq_len()
2399 hw->adminq.num_sq_entries = ICE_AQ_LEN; in ice_set_ctrlq_len()
2400 hw->adminq.rq_buf_size = ICE_AQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2401 hw->adminq.sq_buf_size = ICE_AQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2402 hw->mailboxq.num_rq_entries = PF_MBX_ARQLEN_ARQLEN_M; in ice_set_ctrlq_len()
2403 hw->mailboxq.num_sq_entries = ICE_MBXSQ_LEN; in ice_set_ctrlq_len()
2404 hw->mailboxq.rq_buf_size = ICE_MBXQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2405 hw->mailboxq.sq_buf_size = ICE_MBXQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2406 hw->sbq.num_rq_entries = ICE_SBQ_LEN; in ice_set_ctrlq_len()
2407 hw->sbq.num_sq_entries = ICE_SBQ_LEN; in ice_set_ctrlq_len()
2408 hw->sbq.rq_buf_size = ICE_SBQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2409 hw->sbq.sq_buf_size = ICE_SBQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2413 * ice_schedule_reset - schedule a reset
2422 if (test_bit(ICE_RESET_FAILED, pf->state)) { in ice_schedule_reset()
2424 return -EIO; in ice_schedule_reset()
2427 if (ice_is_reset_in_progress(pf->state)) { in ice_schedule_reset()
2429 return -EBUSY; in ice_schedule_reset()
2434 set_bit(ICE_PFR_REQ, pf->state); in ice_schedule_reset()
2437 set_bit(ICE_CORER_REQ, pf->state); in ice_schedule_reset()
2440 set_bit(ICE_GLOBR_REQ, pf->state); in ice_schedule_reset()
2443 return -EINVAL; in ice_schedule_reset()
2451 * ice_irq_affinity_notify - Callback for affinity changes
2465 cpumask_copy(&q_vector->affinity_mask, mask); in ice_irq_affinity_notify()
2469 * ice_irq_affinity_release - Callback for affinity notifier release
2479 * ice_vsi_ena_irq - Enable IRQ for the given VSI
2484 struct ice_hw *hw = &vsi->back->hw; in ice_vsi_ena_irq()
2488 ice_irq_dynamic_ena(hw, vsi, vsi->q_vectors[i]); in ice_vsi_ena_irq()
2495 * ice_vsi_req_irq_msix - get MSI-X vectors from the OS for the VSI
2501 int q_vectors = vsi->num_q_vectors; in ice_vsi_req_irq_msix()
2502 struct ice_pf *pf = vsi->back; in ice_vsi_req_irq_msix()
2511 struct ice_q_vector *q_vector = vsi->q_vectors[vector]; in ice_vsi_req_irq_msix()
2513 irq_num = q_vector->irq.virq; in ice_vsi_req_irq_msix()
2515 if (q_vector->tx.tx_ring && q_vector->rx.rx_ring) { in ice_vsi_req_irq_msix()
2516 snprintf(q_vector->name, sizeof(q_vector->name) - 1, in ice_vsi_req_irq_msix()
2517 "%s-%s-%d", basename, "TxRx", rx_int_idx++); in ice_vsi_req_irq_msix()
2519 } else if (q_vector->rx.rx_ring) { in ice_vsi_req_irq_msix()
2520 snprintf(q_vector->name, sizeof(q_vector->name) - 1, in ice_vsi_req_irq_msix()
2521 "%s-%s-%d", basename, "rx", rx_int_idx++); in ice_vsi_req_irq_msix()
2522 } else if (q_vector->tx.tx_ring) { in ice_vsi_req_irq_msix()
2523 snprintf(q_vector->name, sizeof(q_vector->name) - 1, in ice_vsi_req_irq_msix()
2524 "%s-%s-%d", basename, "tx", tx_int_idx++); in ice_vsi_req_irq_msix()
2529 if (vsi->type == ICE_VSI_CTRL && vsi->vf) in ice_vsi_req_irq_msix()
2530 err = devm_request_irq(dev, irq_num, vsi->irq_handler, in ice_vsi_req_irq_msix()
2531 IRQF_SHARED, q_vector->name, in ice_vsi_req_irq_msix()
2534 err = devm_request_irq(dev, irq_num, vsi->irq_handler, in ice_vsi_req_irq_msix()
2535 0, q_vector->name, q_vector); in ice_vsi_req_irq_msix()
2537 netdev_err(vsi->netdev, "MSIX request_irq failed, error: %d\n", in ice_vsi_req_irq_msix()
2546 affinity_notify = &q_vector->affinity_notify; in ice_vsi_req_irq_msix()
2547 affinity_notify->notify = ice_irq_affinity_notify; in ice_vsi_req_irq_msix()
2548 affinity_notify->release = ice_irq_affinity_release; in ice_vsi_req_irq_msix()
2553 irq_set_affinity_hint(irq_num, &q_vector->affinity_mask); in ice_vsi_req_irq_msix()
2558 netdev_err(vsi->netdev, "Failed to setup CPU RMAP on VSI %u: %pe\n", in ice_vsi_req_irq_msix()
2559 vsi->vsi_num, ERR_PTR(err)); in ice_vsi_req_irq_msix()
2563 vsi->irqs_ready = true; in ice_vsi_req_irq_msix()
2567 while (vector--) { in ice_vsi_req_irq_msix()
2568 irq_num = vsi->q_vectors[vector]->irq.virq; in ice_vsi_req_irq_msix()
2572 devm_free_irq(dev, irq_num, &vsi->q_vectors[vector]); in ice_vsi_req_irq_msix()
2578 * ice_xdp_alloc_setup_rings - Allocate and setup Tx rings for XDP
2585 struct device *dev = ice_pf_to_dev(vsi->back); in ice_xdp_alloc_setup_rings()
2590 u16 xdp_q_idx = vsi->alloc_txq + i; in ice_xdp_alloc_setup_rings()
2604 xdp_ring->ring_stats = ring_stats; in ice_xdp_alloc_setup_rings()
2605 xdp_ring->q_index = xdp_q_idx; in ice_xdp_alloc_setup_rings()
2606 xdp_ring->reg_idx = vsi->txq_map[xdp_q_idx]; in ice_xdp_alloc_setup_rings()
2607 xdp_ring->vsi = vsi; in ice_xdp_alloc_setup_rings()
2608 xdp_ring->netdev = NULL; in ice_xdp_alloc_setup_rings()
2609 xdp_ring->dev = dev; in ice_xdp_alloc_setup_rings()
2610 xdp_ring->count = vsi->num_tx_desc; in ice_xdp_alloc_setup_rings()
2611 WRITE_ONCE(vsi->xdp_rings[i], xdp_ring); in ice_xdp_alloc_setup_rings()
2615 spin_lock_init(&xdp_ring->tx_lock); in ice_xdp_alloc_setup_rings()
2616 for (j = 0; j < xdp_ring->count; j++) { in ice_xdp_alloc_setup_rings()
2618 tx_desc->cmd_type_offset_bsz = 0; in ice_xdp_alloc_setup_rings()
2625 for (; i >= 0; i--) { in ice_xdp_alloc_setup_rings()
2626 if (vsi->xdp_rings[i] && vsi->xdp_rings[i]->desc) { in ice_xdp_alloc_setup_rings()
2627 kfree_rcu(vsi->xdp_rings[i]->ring_stats, rcu); in ice_xdp_alloc_setup_rings()
2628 vsi->xdp_rings[i]->ring_stats = NULL; in ice_xdp_alloc_setup_rings()
2629 ice_free_tx_ring(vsi->xdp_rings[i]); in ice_xdp_alloc_setup_rings()
2632 return -ENOMEM; in ice_xdp_alloc_setup_rings()
2636 * ice_vsi_assign_bpf_prog - set or clear bpf prog pointer on VSI
2645 old_prog = xchg(&vsi->xdp_prog, prog); in ice_vsi_assign_bpf_prog()
2647 WRITE_ONCE(vsi->rx_rings[i]->xdp_prog, vsi->xdp_prog); in ice_vsi_assign_bpf_prog()
2654 * ice_prepare_xdp_rings - Allocate, configure and setup Tx rings for XDP
2665 int xdp_rings_rem = vsi->num_xdp_txq; in ice_prepare_xdp_rings()
2666 struct ice_pf *pf = vsi->back; in ice_prepare_xdp_rings()
2668 .qs_mutex = &pf->avail_q_mutex, in ice_prepare_xdp_rings()
2669 .pf_map = pf->avail_txqs, in ice_prepare_xdp_rings()
2670 .pf_map_size = pf->max_pf_txqs, in ice_prepare_xdp_rings()
2671 .q_count = vsi->num_xdp_txq, in ice_prepare_xdp_rings()
2673 .vsi_map = vsi->txq_map, in ice_prepare_xdp_rings()
2674 .vsi_map_offset = vsi->alloc_txq, in ice_prepare_xdp_rings()
2682 vsi->xdp_rings = devm_kcalloc(dev, vsi->num_xdp_txq, in ice_prepare_xdp_rings()
2683 sizeof(*vsi->xdp_rings), GFP_KERNEL); in ice_prepare_xdp_rings()
2684 if (!vsi->xdp_rings) in ice_prepare_xdp_rings()
2685 return -ENOMEM; in ice_prepare_xdp_rings()
2687 vsi->xdp_mapping_mode = xdp_qs_cfg.mapping_mode; in ice_prepare_xdp_rings()
2692 netdev_warn(vsi->netdev, in ice_prepare_xdp_rings()
2700 struct ice_q_vector *q_vector = vsi->q_vectors[v_idx]; in ice_prepare_xdp_rings()
2704 vsi->num_q_vectors - v_idx); in ice_prepare_xdp_rings()
2705 q_base = vsi->num_xdp_txq - xdp_rings_rem; in ice_prepare_xdp_rings()
2708 struct ice_tx_ring *xdp_ring = vsi->xdp_rings[q_id]; in ice_prepare_xdp_rings()
2710 xdp_ring->q_vector = q_vector; in ice_prepare_xdp_rings()
2711 xdp_ring->next = q_vector->tx.tx_ring; in ice_prepare_xdp_rings()
2712 q_vector->tx.tx_ring = xdp_ring; in ice_prepare_xdp_rings()
2714 xdp_rings_rem -= xdp_rings_per_v; in ice_prepare_xdp_rings()
2719 vsi->rx_rings[i]->xdp_ring = vsi->xdp_rings[i % vsi->num_xdp_txq]; in ice_prepare_xdp_rings()
2721 struct ice_q_vector *q_vector = vsi->rx_rings[i]->q_vector; in ice_prepare_xdp_rings()
2724 ice_for_each_tx_ring(ring, q_vector->tx) { in ice_prepare_xdp_rings()
2726 vsi->rx_rings[i]->xdp_ring = ring; in ice_prepare_xdp_rings()
2744 for (i = 0; i < vsi->tc_cfg.numtc; i++) in ice_prepare_xdp_rings()
2745 max_txqs[i] = vsi->num_txq + vsi->num_xdp_txq; in ice_prepare_xdp_rings()
2747 status = ice_cfg_vsi_lan(vsi->port_info, vsi->idx, vsi->tc_cfg.ena_tc, in ice_prepare_xdp_rings()
2756 * this flow is a subject of both ethtool -L and ndo_bpf flows; in ice_prepare_xdp_rings()
2757 * VSI rebuild that happens under ethtool -L can expose us to in ice_prepare_xdp_rings()
2759 * bpf_prog pointers from vsi->xdp_prog and calling bpf_prog_put in ice_prepare_xdp_rings()
2770 if (vsi->xdp_rings[i]) { in ice_prepare_xdp_rings()
2771 kfree_rcu(vsi->xdp_rings[i], rcu); in ice_prepare_xdp_rings()
2772 vsi->xdp_rings[i] = NULL; in ice_prepare_xdp_rings()
2776 mutex_lock(&pf->avail_q_mutex); in ice_prepare_xdp_rings()
2778 clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs); in ice_prepare_xdp_rings()
2779 vsi->txq_map[i + vsi->alloc_txq] = ICE_INVAL_Q_INDEX; in ice_prepare_xdp_rings()
2781 mutex_unlock(&pf->avail_q_mutex); in ice_prepare_xdp_rings()
2783 devm_kfree(dev, vsi->xdp_rings); in ice_prepare_xdp_rings()
2784 return -ENOMEM; in ice_prepare_xdp_rings()
2788 * ice_destroy_xdp_rings - undo the configuration made by ice_prepare_xdp_rings
2798 struct ice_pf *pf = vsi->back; in ice_destroy_xdp_rings()
2808 struct ice_q_vector *q_vector = vsi->q_vectors[v_idx]; in ice_destroy_xdp_rings()
2811 ice_for_each_tx_ring(ring, q_vector->tx) in ice_destroy_xdp_rings()
2812 if (!ring->tx_buf || !ice_ring_is_xdp(ring)) in ice_destroy_xdp_rings()
2816 q_vector->tx.tx_ring = ring; in ice_destroy_xdp_rings()
2820 mutex_lock(&pf->avail_q_mutex); in ice_destroy_xdp_rings()
2822 clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs); in ice_destroy_xdp_rings()
2823 vsi->txq_map[i + vsi->alloc_txq] = ICE_INVAL_Q_INDEX; in ice_destroy_xdp_rings()
2825 mutex_unlock(&pf->avail_q_mutex); in ice_destroy_xdp_rings()
2828 if (vsi->xdp_rings[i]) { in ice_destroy_xdp_rings()
2829 if (vsi->xdp_rings[i]->desc) { in ice_destroy_xdp_rings()
2831 ice_free_tx_ring(vsi->xdp_rings[i]); in ice_destroy_xdp_rings()
2833 kfree_rcu(vsi->xdp_rings[i]->ring_stats, rcu); in ice_destroy_xdp_rings()
2834 vsi->xdp_rings[i]->ring_stats = NULL; in ice_destroy_xdp_rings()
2835 kfree_rcu(vsi->xdp_rings[i], rcu); in ice_destroy_xdp_rings()
2836 vsi->xdp_rings[i] = NULL; in ice_destroy_xdp_rings()
2839 devm_kfree(ice_pf_to_dev(pf), vsi->xdp_rings); in ice_destroy_xdp_rings()
2840 vsi->xdp_rings = NULL; in ice_destroy_xdp_rings()
2853 for (i = 0; i < vsi->tc_cfg.numtc; i++) in ice_destroy_xdp_rings()
2854 max_txqs[i] = vsi->num_txq; in ice_destroy_xdp_rings()
2857 vsi->num_xdp_txq = 0; in ice_destroy_xdp_rings()
2859 return ice_cfg_vsi_lan(vsi->port_info, vsi->idx, vsi->tc_cfg.ena_tc, in ice_destroy_xdp_rings()
2864 * ice_vsi_rx_napi_schedule - Schedule napi on RX queues from VSI
2872 struct ice_rx_ring *rx_ring = vsi->rx_rings[i]; in ice_vsi_rx_napi_schedule()
2874 if (rx_ring->xsk_pool) in ice_vsi_rx_napi_schedule()
2875 napi_schedule(&rx_ring->q_vector->napi); in ice_vsi_rx_napi_schedule()
2880 * ice_vsi_determine_xdp_res - figure out how many Tx qs can XDP have
2884 * -ENOMEM otherwise
2888 u16 avail = ice_get_avail_txq_count(vsi->back); in ice_vsi_determine_xdp_res()
2892 return -ENOMEM; in ice_vsi_determine_xdp_res()
2894 vsi->num_xdp_txq = min_t(u16, avail, cpus); in ice_vsi_determine_xdp_res()
2896 if (vsi->num_xdp_txq < cpus) in ice_vsi_determine_xdp_res()
2903 * ice_max_xdp_frame_size - returns the maximum allowed frame size for XDP
2908 if (test_bit(ICE_FLAG_LEGACY_RX, vsi->back->flags)) in ice_max_xdp_frame_size()
2915 * ice_xdp_setup_prog - Add or remove XDP eBPF program
2924 unsigned int frame_size = vsi->netdev->mtu + ICE_ETH_PKT_HDR_PAD; in ice_xdp_setup_prog()
2928 if (prog && !prog->aux->xdp_has_frags) { in ice_xdp_setup_prog()
2932 return -EOPNOTSUPP; in ice_xdp_setup_prog()
2938 test_bit(ICE_VSI_REBUILD_PENDING, vsi->state)) { in ice_xdp_setup_prog()
2943 if_running = netif_running(vsi->netdev) && in ice_xdp_setup_prog()
2944 !test_and_set_bit(ICE_VSI_DOWN, vsi->state); in ice_xdp_setup_prog()
2965 xdp_features_set_redirect_target(vsi->netdev, true); in ice_xdp_setup_prog()
2966 /* reallocate Rx queues that are used for zero-copy */ in ice_xdp_setup_prog()
2971 xdp_features_clear_redirect_target(vsi->netdev); in ice_xdp_setup_prog()
2975 /* reallocate Rx queues that were used for zero-copy */ in ice_xdp_setup_prog()
2987 return (ret || xdp_ring_err) ? -ENOMEM : 0; in ice_xdp_setup_prog()
2991 * ice_xdp_safe_mode - XDP handler for safe mode
2998 NL_SET_ERR_MSG_MOD(xdp->extack, in ice_xdp_safe_mode()
3001 return -EOPNOTSUPP; in ice_xdp_safe_mode()
3005 * ice_xdp - implements XDP handler
3012 struct ice_vsi *vsi = np->vsi; in ice_xdp()
3015 if (vsi->type != ICE_VSI_PF) { in ice_xdp()
3016 NL_SET_ERR_MSG_MOD(xdp->extack, "XDP can be loaded only on PF VSI"); in ice_xdp()
3017 return -EINVAL; in ice_xdp()
3020 mutex_lock(&vsi->xdp_state_lock); in ice_xdp()
3022 switch (xdp->command) { in ice_xdp()
3024 ret = ice_xdp_setup_prog(vsi, xdp->prog, xdp->extack); in ice_xdp()
3027 ret = ice_xsk_pool_setup(vsi, xdp->xsk.pool, xdp->xsk.queue_id); in ice_xdp()
3030 ret = -EINVAL; in ice_xdp()
3033 mutex_unlock(&vsi->xdp_state_lock); in ice_xdp()
3038 * ice_ena_misc_vector - enable the non-queue interrupts
3043 struct ice_hw *hw = &pf->hw; in ice_ena_misc_vector()
3046 /* Disable anti-spoof detection interrupt to prevent spurious event in ice_ena_misc_vector()
3047 * interrupts during a function reset. Anti-spoof functionally is in ice_ena_misc_vector()
3070 wr32(hw, GLINT_DYN_CTL(pf->oicr_irq.index), in ice_ena_misc_vector()
3075 * ice_misc_intr - misc interrupt handler
3082 struct ice_hw *hw = &pf->hw; in ice_misc_intr()
3087 set_bit(ICE_ADMINQ_EVENT_PENDING, pf->state); in ice_misc_intr()
3088 set_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state); in ice_misc_intr()
3089 set_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state); in ice_misc_intr()
3096 pf->sw_int_count++; in ice_misc_intr()
3101 set_bit(ICE_MDD_EVENT_PENDING, pf->state); in ice_misc_intr()
3105 if (test_bit(ICE_VF_RESETS_DISABLED, pf->state)) { in ice_misc_intr()
3112 set_bit(ICE_VFLR_EVENT_PENDING, pf->state); in ice_misc_intr()
3125 pf->corer_count++; in ice_misc_intr()
3127 pf->globr_count++; in ice_misc_intr()
3129 pf->empr_count++; in ice_misc_intr()
3134 * pf->state so that the service task can start a reset/rebuild. in ice_misc_intr()
3136 if (!test_and_set_bit(ICE_RESET_OICR_RECV, pf->state)) { in ice_misc_intr()
3138 set_bit(ICE_CORER_RECV, pf->state); in ice_misc_intr()
3140 set_bit(ICE_GLOBR_RECV, pf->state); in ice_misc_intr()
3142 set_bit(ICE_EMPR_RECV, pf->state); in ice_misc_intr()
3145 * hw->reset_ongoing indicates whether the hardware is in ice_misc_intr()
3150 * ICE_RESET_OICR_RECV in pf->state indicates in ice_misc_intr()
3157 hw->reset_ongoing = true; in ice_misc_intr()
3163 if (!hw->reset_ongoing) in ice_misc_intr()
3164 set_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread); in ice_misc_intr()
3168 u8 tmr_idx = hw->func_caps.ts_func_info.tmr_index_owned; in ice_misc_intr()
3173 if (hw->func_caps.ts_func_info.src_tmr_owned) { in ice_misc_intr()
3175 pf->ptp.ext_ts_irq |= gltsyn_stat & in ice_misc_intr()
3180 set_bit(ICE_MISC_THREAD_EXTTS_EVENT, pf->misc_thread); in ice_misc_intr()
3186 pf->oicr_err_reg |= oicr; in ice_misc_intr()
3187 set_bit(ICE_AUX_ERR_PENDING, pf->state); in ice_misc_intr()
3200 set_bit(ICE_PFR_REQ, pf->state); in ice_misc_intr()
3208 * ice_misc_intr_thread_fn - misc interrupt thread function
3217 hw = &pf->hw; in ice_misc_intr_thread_fn()
3219 if (ice_is_reset_in_progress(pf->state)) in ice_misc_intr_thread_fn()
3224 if (test_and_clear_bit(ICE_MISC_THREAD_EXTTS_EVENT, pf->misc_thread)) in ice_misc_intr_thread_fn()
3227 if (test_and_clear_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread)) { in ice_misc_intr_thread_fn()
3229 * re-arm the interrupt to trigger again. in ice_misc_intr_thread_fn()
3243 * ice_dis_ctrlq_interrupts - disable control queue interrupts
3267 * ice_free_irq_msix_misc - Unroll misc vector setup
3272 int misc_irq_num = pf->oicr_irq.virq; in ice_free_irq_msix_misc()
3273 struct ice_hw *hw = &pf->hw; in ice_free_irq_msix_misc()
3284 ice_free_irq(pf, pf->oicr_irq); in ice_free_irq_msix_misc()
3288 * ice_ena_ctrlq_interrupts - enable control queue interrupts
3319 * ice_req_irq_msix_misc - Setup the misc vector to handle non queue events
3323 * non-queue interrupts, e.g. AdminQ and errors. This is not used
3329 struct ice_hw *hw = &pf->hw; in ice_req_irq_msix_misc()
3333 if (!pf->int_name[0]) in ice_req_irq_msix_misc()
3334 snprintf(pf->int_name, sizeof(pf->int_name) - 1, "%s-%s:misc", in ice_req_irq_msix_misc()
3341 if (ice_is_reset_in_progress(pf->state)) in ice_req_irq_msix_misc()
3349 pf->oicr_irq = oicr_irq; in ice_req_irq_msix_misc()
3350 err = devm_request_threaded_irq(dev, pf->oicr_irq.virq, ice_misc_intr, in ice_req_irq_msix_misc()
3352 pf->int_name, pf); in ice_req_irq_msix_misc()
3355 pf->int_name, err); in ice_req_irq_msix_misc()
3356 ice_free_irq(pf, pf->oicr_irq); in ice_req_irq_msix_misc()
3363 ice_ena_ctrlq_interrupts(hw, pf->oicr_irq.index); in ice_req_irq_msix_misc()
3364 wr32(hw, GLINT_ITR(ICE_RX_ITR, pf->oicr_irq.index), in ice_req_irq_msix_misc()
3374 * ice_napi_add - register NAPI handler for the VSI
3385 if (!vsi->netdev) in ice_napi_add()
3389 netif_napi_add(vsi->netdev, &vsi->q_vectors[v_idx]->napi, in ice_napi_add()
3394 * ice_set_ops - set netdev and ethtools ops for the given netdev
3399 struct net_device *netdev = vsi->netdev; in ice_set_ops()
3403 netdev->netdev_ops = &ice_netdev_safe_mode_ops; in ice_set_ops()
3408 netdev->netdev_ops = &ice_netdev_ops; in ice_set_ops()
3409 netdev->udp_tunnel_nic_info = &pf->hw.udp_tunnel_nic; in ice_set_ops()
3412 if (vsi->type != ICE_VSI_PF) in ice_set_ops()
3415 netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | in ice_set_ops()
3418 netdev->xdp_zc_max_segs = ICE_MAX_BUF_TXD; in ice_set_ops()
3422 * ice_set_netdev_features - set features for the given netdev
3428 bool is_dvm_ena = ice_is_dvm_ena(&pf->hw); in ice_set_netdev_features()
3436 netdev->features = NETIF_F_SG | NETIF_F_HIGHDMA; in ice_set_netdev_features()
3437 netdev->hw_features = netdev->features; in ice_set_netdev_features()
3471 netdev->gso_partial_features |= NETIF_F_GSO_UDP_TUNNEL_CSUM | in ice_set_netdev_features()
3474 netdev->hw_features = dflt_features | csumo_features | in ice_set_netdev_features()
3478 netdev->mpls_features = NETIF_F_HW_CSUM | in ice_set_netdev_features()
3483 netdev->features |= netdev->hw_features; in ice_set_netdev_features()
3485 netdev->hw_features |= NETIF_F_HW_TC; in ice_set_netdev_features()
3486 netdev->hw_features |= NETIF_F_LOOPBACK; in ice_set_netdev_features()
3489 netdev->hw_enc_features |= dflt_features | csumo_features | in ice_set_netdev_features()
3491 netdev->vlan_features |= dflt_features | csumo_features | in ice_set_netdev_features()
3500 netdev->hw_features |= NETIF_F_HW_VLAN_STAG_RX | in ice_set_netdev_features()
3506 netdev->hw_features |= NETIF_F_RXFCS; in ice_set_netdev_features()
3512 * ice_fill_rss_lut - Fill the RSS lookup table with default values
3526 * ice_pf_vsi_setup - Set up a PF VSI
3560 * ice_ctrl_vsi_setup - Set up a control VSI
3580 * ice_lb_vsi_setup - Set up a loopback VSI
3600 * ice_vlan_rx_add_vid - Add a VLAN ID filter to HW offload
3612 struct ice_vsi *vsi = np->vsi; in ice_vlan_rx_add_vid()
3620 while (test_and_set_bit(ICE_CFG_BUSY, vsi->state)) in ice_vlan_rx_add_vid()
3624 * all-multicast is currently enabled. in ice_vlan_rx_add_vid()
3626 if (vsi->current_netdev_flags & IFF_ALLMULTI) { in ice_vlan_rx_add_vid()
3627 ret = ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_add_vid()
3640 ret = vlan_ops->add_vlan(vsi, &vlan); in ice_vlan_rx_add_vid()
3644 /* If all-multicast is currently enabled and this VLAN ID is only one in ice_vlan_rx_add_vid()
3645 * besides VLAN-0 we have to update look-up type of multicast promisc in ice_vlan_rx_add_vid()
3646 * rule for VLAN-0 from ICE_SW_LKUP_PROMISC to ICE_SW_LKUP_PROMISC_VLAN. in ice_vlan_rx_add_vid()
3648 if ((vsi->current_netdev_flags & IFF_ALLMULTI) && in ice_vlan_rx_add_vid()
3650 ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_add_vid()
3652 ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_add_vid()
3657 clear_bit(ICE_CFG_BUSY, vsi->state); in ice_vlan_rx_add_vid()
3663 * ice_vlan_rx_kill_vid - Remove a VLAN ID filter from HW offload
3675 struct ice_vsi *vsi = np->vsi; in ice_vlan_rx_kill_vid()
3683 while (test_and_set_bit(ICE_CFG_BUSY, vsi->state)) in ice_vlan_rx_kill_vid()
3686 ret = ice_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_kill_vid()
3690 vsi->vsi_num); in ice_vlan_rx_kill_vid()
3691 vsi->current_netdev_flags |= IFF_ALLMULTI; in ice_vlan_rx_kill_vid()
3700 ret = vlan_ops->del_vlan(vsi, &vlan); in ice_vlan_rx_kill_vid()
3705 * all-multicast is enabled. in ice_vlan_rx_kill_vid()
3707 if (vsi->current_netdev_flags & IFF_ALLMULTI) in ice_vlan_rx_kill_vid()
3708 ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_kill_vid()
3712 /* Update look-up type of multicast promisc rule for VLAN 0 in ice_vlan_rx_kill_vid()
3714 * all-multicast is enabled and VLAN 0 is the only VLAN rule. in ice_vlan_rx_kill_vid()
3716 if (vsi->current_netdev_flags & IFF_ALLMULTI) { in ice_vlan_rx_kill_vid()
3717 ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_kill_vid()
3720 ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_kill_vid()
3726 clear_bit(ICE_CFG_BUSY, vsi->state); in ice_vlan_rx_kill_vid()
3739 list_del(&indr_priv->list); in ice_rep_indr_tc_block_unbind()
3744 * ice_tc_indir_block_unregister - Unregister TC indirect block notifications
3749 struct ice_netdev_priv *np = netdev_priv(vsi->netdev); in ice_tc_indir_block_unregister()
3756 * ice_tc_indir_block_register - Register TC indirect block notifications
3765 if (!vsi || !vsi->netdev) in ice_tc_indir_block_register()
3766 return -EINVAL; in ice_tc_indir_block_register()
3768 np = netdev_priv(vsi->netdev); in ice_tc_indir_block_register()
3770 INIT_LIST_HEAD(&np->tc_indr_block_priv_list); in ice_tc_indir_block_register()
3775 * ice_get_avail_q_count - Get count of queues in use
3795 * ice_get_avail_txq_count - Get count of Tx queues in use
3800 return ice_get_avail_q_count(pf->avail_txqs, &pf->avail_q_mutex, in ice_get_avail_txq_count()
3801 pf->max_pf_txqs); in ice_get_avail_txq_count()
3805 * ice_get_avail_rxq_count - Get count of Rx queues in use
3810 return ice_get_avail_q_count(pf->avail_rxqs, &pf->avail_q_mutex, in ice_get_avail_rxq_count()
3811 pf->max_pf_rxqs); in ice_get_avail_rxq_count()
3815 * ice_deinit_pf - Unrolls initialziations done by ice_init_pf
3821 mutex_destroy(&pf->lag_mutex); in ice_deinit_pf()
3822 mutex_destroy(&pf->adev_mutex); in ice_deinit_pf()
3823 mutex_destroy(&pf->sw_mutex); in ice_deinit_pf()
3824 mutex_destroy(&pf->tc_mutex); in ice_deinit_pf()
3825 mutex_destroy(&pf->avail_q_mutex); in ice_deinit_pf()
3826 mutex_destroy(&pf->vfs.table_lock); in ice_deinit_pf()
3828 if (pf->avail_txqs) { in ice_deinit_pf()
3829 bitmap_free(pf->avail_txqs); in ice_deinit_pf()
3830 pf->avail_txqs = NULL; in ice_deinit_pf()
3833 if (pf->avail_rxqs) { in ice_deinit_pf()
3834 bitmap_free(pf->avail_rxqs); in ice_deinit_pf()
3835 pf->avail_rxqs = NULL; in ice_deinit_pf()
3838 if (pf->ptp.clock) in ice_deinit_pf()
3839 ptp_clock_unregister(pf->ptp.clock); in ice_deinit_pf()
3843 * ice_set_pf_caps - set PFs capability flags
3848 struct ice_hw_func_caps *func_caps = &pf->hw.func_caps; in ice_set_pf_caps()
3850 clear_bit(ICE_FLAG_RDMA_ENA, pf->flags); in ice_set_pf_caps()
3851 if (func_caps->common_cap.rdma) in ice_set_pf_caps()
3852 set_bit(ICE_FLAG_RDMA_ENA, pf->flags); in ice_set_pf_caps()
3853 clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); in ice_set_pf_caps()
3854 if (func_caps->common_cap.dcb) in ice_set_pf_caps()
3855 set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); in ice_set_pf_caps()
3856 clear_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); in ice_set_pf_caps()
3857 if (func_caps->common_cap.sr_iov_1_1) { in ice_set_pf_caps()
3858 set_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); in ice_set_pf_caps()
3859 pf->vfs.num_supported = min_t(int, func_caps->num_allocd_vfs, in ice_set_pf_caps()
3862 clear_bit(ICE_FLAG_RSS_ENA, pf->flags); in ice_set_pf_caps()
3863 if (func_caps->common_cap.rss_table_size) in ice_set_pf_caps()
3864 set_bit(ICE_FLAG_RSS_ENA, pf->flags); in ice_set_pf_caps()
3866 clear_bit(ICE_FLAG_FD_ENA, pf->flags); in ice_set_pf_caps()
3867 if (func_caps->fd_fltr_guar > 0 || func_caps->fd_fltr_best_effort > 0) { in ice_set_pf_caps()
3873 pf->ctrl_vsi_idx = ICE_NO_VSI; in ice_set_pf_caps()
3874 set_bit(ICE_FLAG_FD_ENA, pf->flags); in ice_set_pf_caps()
3876 ice_alloc_fd_guar_item(&pf->hw, &unused, in ice_set_pf_caps()
3877 func_caps->fd_fltr_guar); in ice_set_pf_caps()
3879 ice_alloc_fd_shrd_item(&pf->hw, &unused, in ice_set_pf_caps()
3880 func_caps->fd_fltr_best_effort); in ice_set_pf_caps()
3883 clear_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags); in ice_set_pf_caps()
3884 if (func_caps->common_cap.ieee_1588 && in ice_set_pf_caps()
3885 !(pf->hw.mac_type == ICE_MAC_E830)) in ice_set_pf_caps()
3886 set_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags); in ice_set_pf_caps()
3888 pf->max_pf_txqs = func_caps->common_cap.num_txq; in ice_set_pf_caps()
3889 pf->max_pf_rxqs = func_caps->common_cap.num_rxq; in ice_set_pf_caps()
3893 * ice_init_pf - Initialize general software structures (struct ice_pf)
3900 mutex_init(&pf->sw_mutex); in ice_init_pf()
3901 mutex_init(&pf->tc_mutex); in ice_init_pf()
3902 mutex_init(&pf->adev_mutex); in ice_init_pf()
3903 mutex_init(&pf->lag_mutex); in ice_init_pf()
3905 INIT_HLIST_HEAD(&pf->aq_wait_list); in ice_init_pf()
3906 spin_lock_init(&pf->aq_wait_lock); in ice_init_pf()
3907 init_waitqueue_head(&pf->aq_wait_queue); in ice_init_pf()
3909 init_waitqueue_head(&pf->reset_wait_queue); in ice_init_pf()
3912 timer_setup(&pf->serv_tmr, ice_service_timer, 0); in ice_init_pf()
3913 pf->serv_tmr_period = HZ; in ice_init_pf()
3914 INIT_WORK(&pf->serv_task, ice_service_task); in ice_init_pf()
3915 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_init_pf()
3917 mutex_init(&pf->avail_q_mutex); in ice_init_pf()
3918 pf->avail_txqs = bitmap_zalloc(pf->max_pf_txqs, GFP_KERNEL); in ice_init_pf()
3919 if (!pf->avail_txqs) in ice_init_pf()
3920 return -ENOMEM; in ice_init_pf()
3922 pf->avail_rxqs = bitmap_zalloc(pf->max_pf_rxqs, GFP_KERNEL); in ice_init_pf()
3923 if (!pf->avail_rxqs) { in ice_init_pf()
3924 bitmap_free(pf->avail_txqs); in ice_init_pf()
3925 pf->avail_txqs = NULL; in ice_init_pf()
3926 return -ENOMEM; in ice_init_pf()
3929 mutex_init(&pf->vfs.table_lock); in ice_init_pf()
3930 hash_init(pf->vfs.table); in ice_init_pf()
3932 wr32(&pf->hw, E830_MBX_PF_IN_FLIGHT_VF_MSGS_THRESH, in ice_init_pf()
3935 ice_mbx_init_snapshot(&pf->hw); in ice_init_pf()
3941 * ice_is_wol_supported - check if WoL is supported
3957 return !(BIT(hw->port_info->lport) & wol_ctrl); in ice_is_wol_supported()
3961 * ice_vsi_recfg_qs - Change the number of queues on a VSI
3967 * Only change the number of queues if new_tx, or new_rx is non-0.
3973 struct ice_pf *pf = vsi->back; in ice_vsi_recfg_qs()
3977 return -EINVAL; in ice_vsi_recfg_qs()
3979 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) { in ice_vsi_recfg_qs()
3980 timeout--; in ice_vsi_recfg_qs()
3982 return -EBUSY; in ice_vsi_recfg_qs()
3987 vsi->req_txq = (u16)new_tx; in ice_vsi_recfg_qs()
3989 vsi->req_rxq = (u16)new_rx; in ice_vsi_recfg_qs()
3992 if (!netif_running(vsi->netdev)) { in ice_vsi_recfg_qs()
4006 if (vsi->tc_cfg.ena_tc & BIT(i)) in ice_vsi_recfg_qs()
4007 netdev_set_tc_queue(vsi->netdev, in ice_vsi_recfg_qs()
4008 vsi->tc_cfg.tc_info[i].netdev_tc, in ice_vsi_recfg_qs()
4009 vsi->tc_cfg.tc_info[i].qcount_tx, in ice_vsi_recfg_qs()
4010 vsi->tc_cfg.tc_info[i].qoffset); in ice_vsi_recfg_qs()
4020 clear_bit(ICE_CFG_BUSY, pf->state); in ice_vsi_recfg_qs()
4025 * ice_set_safe_mode_vlan_cfg - configure PF VSI to allow all VLANs in safe mode
4045 hw = &pf->hw; in ice_set_safe_mode_vlan_cfg()
4046 ctxt->info = vsi->info; in ice_set_safe_mode_vlan_cfg()
4048 ctxt->info.valid_sections = in ice_set_safe_mode_vlan_cfg()
4053 /* disable VLAN anti-spoof */ in ice_set_safe_mode_vlan_cfg()
4054 ctxt->info.sec_flags &= ~(ICE_AQ_VSI_SEC_TX_VLAN_PRUNE_ENA << in ice_set_safe_mode_vlan_cfg()
4058 ctxt->info.sw_flags2 &= ~ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA; in ice_set_safe_mode_vlan_cfg()
4061 ctxt->info.inner_vlan_flags = ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL | in ice_set_safe_mode_vlan_cfg()
4064 status = ice_update_vsi(hw, vsi->idx, ctxt, NULL); in ice_set_safe_mode_vlan_cfg()
4066 dev_err(ice_pf_to_dev(vsi->back), "Failed to update VSI for safe mode VLANs, err %d aq_err %s\n", in ice_set_safe_mode_vlan_cfg()
4067 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_safe_mode_vlan_cfg()
4069 vsi->info.sec_flags = ctxt->info.sec_flags; in ice_set_safe_mode_vlan_cfg()
4070 vsi->info.sw_flags2 = ctxt->info.sw_flags2; in ice_set_safe_mode_vlan_cfg()
4071 vsi->info.inner_vlan_flags = ctxt->info.inner_vlan_flags; in ice_set_safe_mode_vlan_cfg()
4078 * ice_log_pkg_init - log result of DDP package load
4084 struct ice_pf *pf = hw->back; in ice_log_pkg_init()
4092 hw->active_pkg_name, in ice_log_pkg_init()
4093 hw->active_pkg_ver.major, in ice_log_pkg_init()
4094 hw->active_pkg_ver.minor, in ice_log_pkg_init()
4095 hw->active_pkg_ver.update, in ice_log_pkg_init()
4096 hw->active_pkg_ver.draft); in ice_log_pkg_init()
4100 hw->active_pkg_name, in ice_log_pkg_init()
4101 hw->active_pkg_ver.major, in ice_log_pkg_init()
4102 hw->active_pkg_ver.minor, in ice_log_pkg_init()
4103 hw->active_pkg_ver.update, in ice_log_pkg_init()
4104 hw->active_pkg_ver.draft); in ice_log_pkg_init()
4108 hw->active_pkg_name, in ice_log_pkg_init()
4109 hw->active_pkg_ver.major, in ice_log_pkg_init()
4110 hw->active_pkg_ver.minor, in ice_log_pkg_init()
4115 hw->active_pkg_name, in ice_log_pkg_init()
4116 hw->active_pkg_ver.major, in ice_log_pkg_init()
4117 hw->active_pkg_ver.minor, in ice_log_pkg_init()
4118 hw->active_pkg_ver.update, in ice_log_pkg_init()
4119 hw->active_pkg_ver.draft, in ice_log_pkg_init()
4120 hw->pkg_name, in ice_log_pkg_init()
4121 hw->pkg_ver.major, in ice_log_pkg_init()
4122 hw->pkg_ver.minor, in ice_log_pkg_init()
4123 hw->pkg_ver.update, in ice_log_pkg_init()
4124 hw->pkg_ver.draft); in ice_log_pkg_init()
4159 * ice_load_pkg - load/reload the DDP Package file
4171 struct ice_hw *hw = &pf->hw; in ice_load_pkg()
4174 if (firmware && !hw->pkg_copy) { in ice_load_pkg()
4175 state = ice_copy_and_init_pkg(hw, firmware->data, in ice_load_pkg()
4176 firmware->size); in ice_load_pkg()
4178 } else if (!firmware && hw->pkg_copy) { in ice_load_pkg()
4180 state = ice_init_pkg(hw, hw->pkg_copy, hw->pkg_size); in ice_load_pkg()
4188 clear_bit(ICE_FLAG_ADV_FEATURES, pf->flags); in ice_load_pkg()
4195 set_bit(ICE_FLAG_ADV_FEATURES, pf->flags); in ice_load_pkg()
4199 * ice_verify_cacheline_size - verify driver's assumption of 64 Byte cache lines
4208 if (rd32(&pf->hw, GLPCI_CNF2) & GLPCI_CNF2_CACHELINE_SIZE_M) in ice_verify_cacheline_size()
4214 * ice_send_version - update firmware with driver version
4229 return ice_aq_send_driver_ver(&pf->hw, &dv, NULL); in ice_send_version()
4233 * ice_init_fdir - Initialize flow director VSI and configuration
4247 ctrl_vsi = ice_ctrl_vsi_setup(pf, pf->hw.port_info); in ice_init_fdir()
4250 return -ENOMEM; in ice_init_fdir()
4259 mutex_init(&pf->hw.fdir_fltr_lock); in ice_init_fdir()
4268 ice_fdir_release_flows(&pf->hw); in ice_init_fdir()
4272 if (pf->ctrl_vsi_idx != ICE_NO_VSI) { in ice_init_fdir()
4273 pf->vsi[pf->ctrl_vsi_idx] = NULL; in ice_init_fdir()
4274 pf->ctrl_vsi_idx = ICE_NO_VSI; in ice_init_fdir()
4288 if (pf->ctrl_vsi_idx != ICE_NO_VSI) { in ice_deinit_fdir()
4289 pf->vsi[pf->ctrl_vsi_idx] = NULL; in ice_deinit_fdir()
4290 pf->ctrl_vsi_idx = ICE_NO_VSI; in ice_deinit_fdir()
4293 mutex_destroy(&(&pf->hw)->fdir_fltr_lock); in ice_deinit_fdir()
4297 * ice_get_opt_fw_name - return optional firmware file name or NULL
4303 * followed by a EUI-64 identifier (PCIe Device Serial Number) in ice_get_opt_fw_name()
4305 struct pci_dev *pdev = pf->pdev; in ice_get_opt_fw_name()
4320 snprintf(opt_fw_filename, NAME_MAX, "%sice-%016llx.pkg", in ice_get_opt_fw_name()
4327 * ice_request_fw - Device initialization routine
4337 /* optional device-specific DDP (if present) overrides the default DDP in ice_request_fw()
4368 * ice_print_wake_reason - show the wake up cause in the log
4373 u32 wus = pf->wakeup_reason; in ice_print_wake_reason()
4395 * ice_register_netdev - register netdev
4402 if (!vsi || !vsi->netdev) in ice_register_netdev()
4403 return -EIO; in ice_register_netdev()
4405 err = register_netdev(vsi->netdev); in ice_register_netdev()
4409 set_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state); in ice_register_netdev()
4410 netif_carrier_off(vsi->netdev); in ice_register_netdev()
4411 netif_tx_stop_all_queues(vsi->netdev); in ice_register_netdev()
4418 if (!vsi || !vsi->netdev) in ice_unregister_netdev()
4421 unregister_netdev(vsi->netdev); in ice_unregister_netdev()
4422 clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state); in ice_unregister_netdev()
4426 * ice_cfg_netdev - Allocate, configure and register a netdev
4437 netdev = alloc_etherdev_mqs(sizeof(*np), vsi->alloc_txq, in ice_cfg_netdev()
4438 vsi->alloc_rxq); in ice_cfg_netdev()
4440 return -ENOMEM; in ice_cfg_netdev()
4442 set_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state); in ice_cfg_netdev()
4443 vsi->netdev = netdev; in ice_cfg_netdev()
4445 np->vsi = vsi; in ice_cfg_netdev()
4450 if (vsi->type == ICE_VSI_PF) { in ice_cfg_netdev()
4451 SET_NETDEV_DEV(netdev, ice_pf_to_dev(vsi->back)); in ice_cfg_netdev()
4452 ether_addr_copy(mac_addr, vsi->port_info->mac.perm_addr); in ice_cfg_netdev()
4456 netdev->priv_flags |= IFF_UNICAST_FLT; in ice_cfg_netdev()
4459 ice_vsi_cfg_netdev_tc(vsi, vsi->tc_cfg.ena_tc); in ice_cfg_netdev()
4461 netdev->max_mtu = ICE_MAX_MTU; in ice_cfg_netdev()
4468 clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state); in ice_decfg_netdev()
4469 free_netdev(vsi->netdev); in ice_decfg_netdev()
4470 vsi->netdev = NULL; in ice_decfg_netdev()
4477 err = ice_init_mac_fltr(vsi->back); in ice_start_eth()
4500 return -EINVAL; in ice_init_eth()
4503 INIT_LIST_HEAD(&vsi->ch_list); in ice_init_eth()
4519 SET_NETDEV_DEVLINK_PORT(vsi->netdev, &pf->devlink_port); in ice_init_eth()
4558 * ice_wait_for_fw - wait for full FW readiness
4579 return -ETIMEDOUT; in ice_wait_for_fw()
4585 struct ice_hw *hw = &pf->hw; in ice_init_dev()
4611 * set in pf->state, which will cause ice_is_safe_mode to return in ice_init_dev()
4629 pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port; in ice_init_dev()
4630 pf->hw.udp_tunnel_nic.unset_port = ice_udp_tunnel_unset_port; in ice_init_dev()
4631 pf->hw.udp_tunnel_nic.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP; in ice_init_dev()
4632 pf->hw.udp_tunnel_nic.shared = &pf->hw.udp_tunnel_shared; in ice_init_dev()
4633 if (pf->hw.tnl.valid_count[TNL_VXLAN]) { in ice_init_dev()
4634 pf->hw.udp_tunnel_nic.tables[0].n_entries = in ice_init_dev()
4635 pf->hw.tnl.valid_count[TNL_VXLAN]; in ice_init_dev()
4636 pf->hw.udp_tunnel_nic.tables[0].tunnel_types = in ice_init_dev()
4639 if (pf->hw.tnl.valid_count[TNL_GENEVE]) { in ice_init_dev()
4640 pf->hw.udp_tunnel_nic.tables[1].n_entries = in ice_init_dev()
4641 pf->hw.tnl.valid_count[TNL_GENEVE]; in ice_init_dev()
4642 pf->hw.udp_tunnel_nic.tables[1].tunnel_types = in ice_init_dev()
4649 err = -EIO; in ice_init_dev()
4679 ice_deinit_hw(&pf->hw); in ice_deinit_dev()
4682 ice_reset(&pf->hw, ICE_RESET_PFR); in ice_deinit_dev()
4683 pci_wait_for_pending_transaction(pf->pdev); in ice_deinit_dev()
4695 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_init_features()
4701 /* Note: Flow director init failure is non-fatal to load */ in ice_init_features()
4705 /* Note: DCB init failure is non-fatal to load */ in ice_init_features()
4707 clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); in ice_init_features()
4708 clear_bit(ICE_FLAG_DCB_ENA, pf->flags); in ice_init_features()
4710 ice_cfg_lldp_mib_change(&pf->hw, true); in ice_init_features()
4723 if (test_bit(ICE_FLAG_DCB_CAPABLE, pf->flags)) in ice_deinit_features()
4724 ice_cfg_lldp_mib_change(&pf->hw, false); in ice_deinit_features()
4728 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_deinit_features()
4735 pf->wakeup_reason = rd32(&pf->hw, PFPM_WUS); in ice_init_wakeup()
4741 wr32(&pf->hw, PFPM_WUS, U32_MAX); in ice_init_wakeup()
4752 err = ice_init_link_events(pf->hw.port_info); in ice_init_link()
4759 err = ice_init_nvm_phy_type(pf->hw.port_info); in ice_init_link()
4764 err = ice_update_link_info(pf->hw.port_info); in ice_init_link()
4768 ice_init_link_dflt_override(pf->hw.port_info); in ice_init_link()
4771 pf->hw.port_info->phy.link_info.link_cfg_err); in ice_init_link()
4774 if (pf->hw.port_info->phy.link_info.link_info & in ice_init_link()
4777 err = ice_init_phy_user_cfg(pf->hw.port_info); in ice_init_link()
4781 if (!test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags)) { in ice_init_link()
4788 set_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_init_link()
4796 bool dvm = ice_is_dvm_ena(&pf->hw); in ice_init_pf_sw()
4801 pf->first_sw = kzalloc(sizeof(*pf->first_sw), GFP_KERNEL); in ice_init_pf_sw()
4802 if (!pf->first_sw) in ice_init_pf_sw()
4803 return -ENOMEM; in ice_init_pf_sw()
4805 if (pf->hw.evb_veb) in ice_init_pf_sw()
4806 pf->first_sw->bridge_mode = BRIDGE_MODE_VEB; in ice_init_pf_sw()
4808 pf->first_sw->bridge_mode = BRIDGE_MODE_VEPA; in ice_init_pf_sw()
4810 pf->first_sw->pf = pf; in ice_init_pf_sw()
4813 pf->first_sw->sw_id = pf->hw.port_info->sw_id; in ice_init_pf_sw()
4815 err = ice_aq_set_port_params(pf->hw.port_info, dvm, NULL); in ice_init_pf_sw()
4819 vsi = ice_pf_vsi_setup(pf, pf->hw.port_info); in ice_init_pf_sw()
4821 err = -ENOMEM; in ice_init_pf_sw()
4829 kfree(pf->first_sw); in ice_init_pf_sw()
4841 kfree(pf->first_sw); in ice_deinit_pf_sw()
4848 pf->num_alloc_vsi = pf->hw.func_caps.guar_num_vsi; in ice_alloc_vsis()
4849 if (!pf->num_alloc_vsi) in ice_alloc_vsis()
4850 return -EIO; in ice_alloc_vsis()
4852 if (pf->num_alloc_vsi > UDP_TUNNEL_NIC_MAX_SHARING_DEVICES) { in ice_alloc_vsis()
4855 pf->num_alloc_vsi, UDP_TUNNEL_NIC_MAX_SHARING_DEVICES); in ice_alloc_vsis()
4856 pf->num_alloc_vsi = UDP_TUNNEL_NIC_MAX_SHARING_DEVICES; in ice_alloc_vsis()
4859 pf->vsi = devm_kcalloc(dev, pf->num_alloc_vsi, sizeof(*pf->vsi), in ice_alloc_vsis()
4861 if (!pf->vsi) in ice_alloc_vsis()
4862 return -ENOMEM; in ice_alloc_vsis()
4864 pf->vsi_stats = devm_kcalloc(dev, pf->num_alloc_vsi, in ice_alloc_vsis()
4865 sizeof(*pf->vsi_stats), GFP_KERNEL); in ice_alloc_vsis()
4866 if (!pf->vsi_stats) { in ice_alloc_vsis()
4867 devm_kfree(dev, pf->vsi); in ice_alloc_vsis()
4868 return -ENOMEM; in ice_alloc_vsis()
4876 devm_kfree(ice_pf_to_dev(pf), pf->vsi_stats); in ice_dealloc_vsis()
4877 pf->vsi_stats = NULL; in ice_dealloc_vsis()
4879 pf->num_alloc_vsi = 0; in ice_dealloc_vsis()
4880 devm_kfree(ice_pf_to_dev(pf), pf->vsi); in ice_dealloc_vsis()
4881 pf->vsi = NULL; in ice_dealloc_vsis()
4937 pcie_print_link_status(pf->pdev); in ice_init()
4940 clear_bit(ICE_DOWN, pf->state); in ice_init()
4941 clear_bit(ICE_SERVICE_DIS, pf->state); in ice_init()
4944 mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period)); in ice_init()
4959 set_bit(ICE_SERVICE_DIS, pf->state); in ice_deinit()
4960 set_bit(ICE_DOWN, pf->state); in ice_deinit()
4968 * ice_load - load pf by init hw and starting VSI
5003 clear_bit(ICE_DOWN, pf->state); in ice_load()
5019 * ice_unload - unload pf by stopping VSI and deinit hw
5034 * ice_probe - Device initialization routine
5043 struct device *dev = &pdev->dev; in ice_probe()
5048 if (pdev->is_virtfn) { in ice_probe()
5050 return -EINVAL; in ice_probe()
5068 * Documentation/driver-api/driver-model/devres.rst in ice_probe()
5082 return -ENOMEM; in ice_probe()
5085 pf->aux_idx = -1; in ice_probe()
5096 pf->pdev = pdev; in ice_probe()
5098 set_bit(ICE_DOWN, pf->state); in ice_probe()
5100 set_bit(ICE_SERVICE_DIS, pf->state); in ice_probe()
5102 hw = &pf->hw; in ice_probe()
5103 hw->hw_addr = pcim_iomap_table(pdev)[ICE_BAR0]; in ice_probe()
5106 hw->back = pf; in ice_probe()
5107 hw->port_info = NULL; in ice_probe()
5108 hw->vendor_id = pdev->vendor; in ice_probe()
5109 hw->device_id = pdev->device; in ice_probe()
5110 pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id); in ice_probe()
5111 hw->subsystem_vendor_id = pdev->subsystem_vendor; in ice_probe()
5112 hw->subsystem_device_id = pdev->subsystem_device; in ice_probe()
5113 hw->bus.device = PCI_SLOT(pdev->devfn); in ice_probe()
5114 hw->bus.func = PCI_FUNC(pdev->devfn); in ice_probe()
5117 pf->msg_enable = netif_msg_init(debug, ICE_DFLT_NETIF_M); in ice_probe()
5120 if (debug < -1) in ice_probe()
5121 hw->debug_mask = debug; in ice_probe()
5156 * ice_set_wake - enable or disable Wake on LAN
5163 struct ice_hw *hw = &pf->hw; in ice_set_wake()
5164 bool wol = pf->wol_ena; in ice_set_wake()
5177 * ice_setup_mc_magic_wake - setup device to wake on multicast magic packet
5187 struct ice_hw *hw = &pf->hw; in ice_setup_mc_magic_wake()
5193 if (!pf->wol_ena) in ice_setup_mc_magic_wake()
5201 if (vsi->netdev) in ice_setup_mc_magic_wake()
5202 ether_addr_copy(mac_addr, vsi->netdev->dev_addr); in ice_setup_mc_magic_wake()
5204 ether_addr_copy(mac_addr, vsi->port_info->mac.perm_addr); in ice_setup_mc_magic_wake()
5213 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_setup_mc_magic_wake()
5217 * ice_remove - Device removal routine
5226 if (!ice_is_reset_in_progress(pf->state)) in ice_remove()
5231 if (test_bit(ICE_FLAG_SRIOV_ENA, pf->flags)) { in ice_remove()
5232 set_bit(ICE_VF_RESETS_DISABLED, pf->state); in ice_remove()
5238 set_bit(ICE_DOWN, pf->state); in ice_remove()
5257 * ice_shutdown - PCI callback for shutting down device
5267 pci_wake_from_d3(pdev, pf->wol_ena); in ice_shutdown()
5274 * ice_prepare_for_shutdown - prep for PCI shutdown
5281 struct ice_hw *hw = &pf->hw; in ice_prepare_for_shutdown()
5285 if (ice_check_sq_alive(hw, &hw->mailboxq)) in ice_prepare_for_shutdown()
5294 if (pf->vsi[v]) in ice_prepare_for_shutdown()
5295 pf->vsi[v]->vsi_num = 0; in ice_prepare_for_shutdown()
5301 * ice_reinit_interrupt_scheme - Reinitialize interrupt scheme
5307 * This should be called during resume routine to re-allocate the q_vectors
5321 dev_err(dev, "Failed to re-initialize interrupt %d\n", ret); in ice_reinit_interrupt_scheme()
5325 /* Remap vectors and rings, after successful re-init interrupts */ in ice_reinit_interrupt_scheme()
5327 if (!pf->vsi[v]) in ice_reinit_interrupt_scheme()
5330 ret = ice_vsi_alloc_q_vectors(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5333 ice_vsi_map_rings_to_vectors(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5346 while (v--) in ice_reinit_interrupt_scheme()
5347 if (pf->vsi[v]) in ice_reinit_interrupt_scheme()
5348 ice_vsi_free_q_vectors(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5370 return -EBUSY; in ice_suspend()
5384 if (test_and_set_bit(ICE_SUSPENDED, pf->state)) { in ice_suspend()
5390 if (test_bit(ICE_DOWN, pf->state) || in ice_suspend()
5391 ice_is_reset_in_progress(pf->state)) { in ice_suspend()
5411 if (!pf->vsi[v]) in ice_suspend()
5413 ice_vsi_free_q_vectors(pf->vsi[v]); in ice_suspend()
5418 pci_wake_from_d3(pdev, pf->wol_ena); in ice_suspend()
5424 * ice_resume - PM callback for waking up from D3
5440 return -ENODEV; in ice_resume()
5449 hw = &pf->hw; in ice_resume()
5451 pf->wakeup_reason = rd32(hw, PFPM_WUS); in ice_resume()
5466 clear_bit(ICE_DOWN, pf->state); in ice_resume()
5469 /* re-enable service task for reset, but allow reset to schedule it */ in ice_resume()
5470 clear_bit(ICE_SERVICE_DIS, pf->state); in ice_resume()
5475 clear_bit(ICE_SUSPENDED, pf->state); in ice_resume()
5479 mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period)); in ice_resume()
5486 * ice_pci_err_detected - warning that PCI error has been detected
5499 dev_err(&pdev->dev, "%s: unrecoverable device error %d\n", in ice_pci_err_detected()
5504 if (!test_bit(ICE_SUSPENDED, pf->state)) { in ice_pci_err_detected()
5507 if (!test_bit(ICE_PREPARED_FOR_RESET, pf->state)) { in ice_pci_err_detected()
5508 set_bit(ICE_PFR_REQ, pf->state); in ice_pci_err_detected()
5517 * ice_pci_err_slot_reset - a PCI slot reset has just happened
5532 dev_err(&pdev->dev, "Cannot re-enable PCI device after reset, error %d\n", in ice_pci_err_slot_reset()
5542 reg = rd32(&pf->hw, GLGEN_RTRIG); in ice_pci_err_slot_reset()
5553 * ice_pci_err_resume - restart operations after PCI error recovery
5564 dev_err(&pdev->dev, "%s failed, device is unrecoverable\n", in ice_pci_err_resume()
5569 if (test_bit(ICE_SUSPENDED, pf->state)) { in ice_pci_err_resume()
5570 dev_dbg(&pdev->dev, "%s failed to resume normal operations!\n", in ice_pci_err_resume()
5579 mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period)); in ice_pci_err_resume()
5583 * ice_pci_err_reset_prepare - prepare device driver for PCI reset
5590 if (!test_bit(ICE_SUSPENDED, pf->state)) { in ice_pci_err_reset_prepare()
5593 if (!test_bit(ICE_PREPARED_FOR_RESET, pf->state)) { in ice_pci_err_reset_prepare()
5594 set_bit(ICE_PFR_REQ, pf->state); in ice_pci_err_reset_prepare()
5601 * ice_pci_err_reset_done - PCI reset done, device driver reset can begin
5609 /* ice_pci_tbl - PCI Device ID Table
5673 * ice_module_init - Driver registration routine
5680 int status = -ENOMEM; in ice_module_init()
5714 * ice_module_exit - Driver exit cleanup routine
5729 * ice_set_mac_address - NDO callback to set MAC address
5738 struct ice_vsi *vsi = np->vsi; in ice_set_mac_address()
5739 struct ice_pf *pf = vsi->back; in ice_set_mac_address()
5740 struct ice_hw *hw = &pf->hw; in ice_set_mac_address()
5747 mac = (u8 *)addr->sa_data; in ice_set_mac_address()
5750 return -EADDRNOTAVAIL; in ice_set_mac_address()
5752 if (test_bit(ICE_DOWN, pf->state) || in ice_set_mac_address()
5753 ice_is_reset_in_progress(pf->state)) { in ice_set_mac_address()
5756 return -EBUSY; in ice_set_mac_address()
5760 …netdev_err(netdev, "can't set mac %pM. Device has tc-flower filters, delete all of them and try ag… in ice_set_mac_address()
5762 return -EAGAIN; in ice_set_mac_address()
5766 ether_addr_copy(old_mac, netdev->dev_addr); in ice_set_mac_address()
5773 if (err && err != -ENOENT) { in ice_set_mac_address()
5774 err = -EADDRNOTAVAIL; in ice_set_mac_address()
5780 if (err == -EEXIST) { in ice_set_mac_address()
5791 err = -EADDRNOTAVAIL; in ice_set_mac_address()
5804 netdev_dbg(vsi->netdev, "updated MAC address to %pM\n", in ice_set_mac_address()
5805 netdev->dev_addr); in ice_set_mac_address()
5818 * ice_set_rx_mode - NDO callback to set the netdev filters
5824 struct ice_vsi *vsi = np->vsi; in ice_set_rx_mode()
5826 if (!vsi || ice_is_switchdev_running(vsi->back)) in ice_set_rx_mode()
5833 set_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state); in ice_set_rx_mode()
5834 set_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state); in ice_set_rx_mode()
5835 set_bit(ICE_FLAG_FLTR_SYNC, vsi->back->flags); in ice_set_rx_mode()
5840 ice_service_task_schedule(vsi->back); in ice_set_rx_mode()
5844 * ice_set_tx_maxrate - NDO callback to set the maximum per-queue bitrate
5853 struct ice_vsi *vsi = np->vsi; in ice_set_tx_maxrate()
5862 return -EINVAL; in ice_set_tx_maxrate()
5865 q_handle = vsi->tx_rings[queue_index]->q_handle; in ice_set_tx_maxrate()
5872 return -EINVAL; in ice_set_tx_maxrate()
5877 status = ice_cfg_q_bw_dflt_lmt(vsi->port_info, vsi->idx, tc, in ice_set_tx_maxrate()
5880 status = ice_cfg_q_bw_lmt(vsi->port_info, vsi->idx, tc, in ice_set_tx_maxrate()
5890 * ice_fdb_add - add an entry to the hardware database
5908 return -EINVAL; in ice_fdb_add()
5910 if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) { in ice_fdb_add()
5912 return -EINVAL; in ice_fdb_add()
5920 err = -EINVAL; in ice_fdb_add()
5923 if (err == -EEXIST && !(flags & NLM_F_EXCL)) in ice_fdb_add()
5930 * ice_fdb_del - delete an entry from the hardware database
5945 if (ndm->ndm_state & NUD_PERMANENT) { in ice_fdb_del()
5947 return -EINVAL; in ice_fdb_del()
5955 err = -EINVAL; in ice_fdb_del()
5972 * ice_fix_features - fix the netdev features flags based on device limitations
6015 cur_vlan_fltr = netdev->features & NETIF_VLAN_FILTERING_FEATURES; in ice_fix_features()
6024 if (ice_is_dvm_ena(&np->vsi->back->hw)) { in ice_fix_features()
6054 if (!(netdev->features & NETIF_F_RXFCS) && in ice_fix_features()
6057 !ice_vsi_has_non_zero_vlans(np->vsi)) { in ice_fix_features()
6066 * ice_set_vlan_offload_features - set VLAN offload features for the PF VSI
6095 strip_err = vlan_ops->ena_stripping(vsi, vlan_ethertype); in ice_set_vlan_offload_features()
6097 strip_err = vlan_ops->dis_stripping(vsi); in ice_set_vlan_offload_features()
6100 insert_err = vlan_ops->ena_insertion(vsi, vlan_ethertype); in ice_set_vlan_offload_features()
6102 insert_err = vlan_ops->dis_insertion(vsi); in ice_set_vlan_offload_features()
6105 return -EIO; in ice_set_vlan_offload_features()
6111 * ice_set_vlan_filtering_features - set VLAN filtering features for the PF VSI
6129 err = vlan_ops->ena_rx_filtering(vsi); in ice_set_vlan_filtering_features()
6131 err = vlan_ops->dis_rx_filtering(vsi); in ice_set_vlan_filtering_features()
6137 * ice_set_vlan_features - set VLAN settings based on suggested feature set
6149 struct ice_vsi *vsi = np->vsi; in ice_set_vlan_features()
6152 current_vlan_features = netdev->features & NETIF_VLAN_OFFLOAD_FEATURES; in ice_set_vlan_features()
6157 dev_err(ice_pf_to_dev(vsi->back), in ice_set_vlan_features()
6159 return -EIO; in ice_set_vlan_features()
6167 current_vlan_features = netdev->features & in ice_set_vlan_features()
6180 * ice_set_loopback - turn on/off loopback mode on underlying PF
6186 bool if_running = netif_running(vsi->netdev); in ice_set_loopback()
6189 if (if_running && !test_and_set_bit(ICE_VSI_DOWN, vsi->state)) { in ice_set_loopback()
6192 netdev_err(vsi->netdev, "Preparing device to toggle loopback failed\n"); in ice_set_loopback()
6196 ret = ice_aq_set_mac_loopback(&vsi->back->hw, ena, NULL); in ice_set_loopback()
6198 netdev_err(vsi->netdev, "Failed to toggle loopback state\n"); in ice_set_loopback()
6206 * ice_set_features - set the netdev feature flags
6213 netdev_features_t changed = netdev->features ^ features; in ice_set_features()
6215 struct ice_vsi *vsi = np->vsi; in ice_set_features()
6216 struct ice_pf *pf = vsi->back; in ice_set_features()
6222 "Device is in Safe Mode - not enabling advanced netdev features\n"); in ice_set_features()
6227 if (ice_is_reset_in_progress(pf->state)) { in ice_set_features()
6230 return -EBUSY; in ice_set_features()
6249 dev_err(ice_pf_to_dev(vsi->back), in ice_set_features()
6251 return -EIO; in ice_set_features()
6270 return -EACCES; in ice_set_features()
6276 ena ? set_bit(ICE_FLAG_CLS_FLOWER, pf->flags) : in ice_set_features()
6277 clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags); in ice_set_features()
6287 * ice_vsi_vlan_setup - Setup VLAN offload properties on a PF VSI
6294 err = ice_set_vlan_offload_features(vsi, vsi->netdev->features); in ice_vsi_vlan_setup()
6298 err = ice_set_vlan_filtering_features(vsi, vsi->netdev->features); in ice_vsi_vlan_setup()
6306 * ice_vsi_cfg_lan - Setup the VSI lan related config
6315 if (vsi->netdev && vsi->type == ICE_VSI_PF) { in ice_vsi_cfg_lan()
6316 ice_set_rx_mode(vsi->netdev); in ice_vsi_cfg_lan()
6337 * which is hard-coded to a limit of 250,000 ints/second.
6339 * by ethtool rx-usecs-high.
6378 rc = dim->priv; in ice_tx_dim_work()
6380 WARN_ON(dim->profile_ix >= ARRAY_SIZE(tx_profile)); in ice_tx_dim_work()
6383 itr = tx_profile[dim->profile_ix].itr; in ice_tx_dim_work()
6388 dim->state = DIM_START_MEASURE; in ice_tx_dim_work()
6398 rc = dim->priv; in ice_rx_dim_work()
6400 WARN_ON(dim->profile_ix >= ARRAY_SIZE(rx_profile)); in ice_rx_dim_work()
6403 itr = rx_profile[dim->profile_ix].itr; in ice_rx_dim_work()
6408 dim->state = DIM_START_MEASURE; in ice_rx_dim_work()
6414 * ice_init_moderation - set up interrupt moderation
6428 rc = &q_vector->tx; in ice_init_moderation()
6429 INIT_WORK(&rc->dim.work, ice_tx_dim_work); in ice_init_moderation()
6430 rc->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; in ice_init_moderation()
6431 rc->dim.profile_ix = ICE_DIM_DEFAULT_PROFILE_IX; in ice_init_moderation()
6432 rc->dim.priv = rc; in ice_init_moderation()
6437 tx_profile[rc->dim.profile_ix].itr : rc->itr_setting); in ice_init_moderation()
6439 rc = &q_vector->rx; in ice_init_moderation()
6440 INIT_WORK(&rc->dim.work, ice_rx_dim_work); in ice_init_moderation()
6441 rc->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; in ice_init_moderation()
6442 rc->dim.profile_ix = ICE_DIM_DEFAULT_PROFILE_IX; in ice_init_moderation()
6443 rc->dim.priv = rc; in ice_init_moderation()
6447 ice_write_itr(rc, rx_dynamic ? rx_profile[rc->dim.profile_ix].itr : in ice_init_moderation()
6448 rc->itr_setting); in ice_init_moderation()
6454 * ice_napi_enable_all - Enable NAPI for all q_vectors in the VSI
6461 if (!vsi->netdev) in ice_napi_enable_all()
6465 struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; in ice_napi_enable_all()
6469 if (q_vector->rx.rx_ring || q_vector->tx.tx_ring) in ice_napi_enable_all()
6470 napi_enable(&q_vector->napi); in ice_napi_enable_all()
6475 * ice_up_complete - Finish the last steps of bringing up a connection
6482 struct ice_pf *pf = vsi->back; in ice_up_complete()
6495 clear_bit(ICE_VSI_DOWN, vsi->state); in ice_up_complete()
6499 if (vsi->port_info && in ice_up_complete()
6500 (vsi->port_info->phy.link_info.link_info & ICE_AQ_LINK_UP) && in ice_up_complete()
6501 vsi->netdev && vsi->type == ICE_VSI_PF) { in ice_up_complete()
6503 netif_tx_start_all_queues(vsi->netdev); in ice_up_complete()
6504 netif_carrier_on(vsi->netdev); in ice_up_complete()
6505 ice_ptp_link_change(pf, pf->hw.pf_id, true); in ice_up_complete()
6513 if (vsi->type == ICE_VSI_PF) in ice_up_complete()
6520 * ice_up - Bring the connection back up after being down
6535 * ice_fetch_u64_stats_per_ring - get packets and bytes stats per ring
6558 * ice_update_vsi_tx_ring_stats - Update VSI Tx ring stats counters
6576 if (!ring || !ring->ring_stats) in ice_update_vsi_tx_ring_stats()
6578 ice_fetch_u64_stats_per_ring(&ring->ring_stats->syncp, in ice_update_vsi_tx_ring_stats()
6579 ring->ring_stats->stats, &pkts, in ice_update_vsi_tx_ring_stats()
6581 vsi_stats->tx_packets += pkts; in ice_update_vsi_tx_ring_stats()
6582 vsi_stats->tx_bytes += bytes; in ice_update_vsi_tx_ring_stats()
6583 vsi->tx_restart += ring->ring_stats->tx_stats.restart_q; in ice_update_vsi_tx_ring_stats()
6584 vsi->tx_busy += ring->ring_stats->tx_stats.tx_busy; in ice_update_vsi_tx_ring_stats()
6585 vsi->tx_linearize += ring->ring_stats->tx_stats.tx_linearize; in ice_update_vsi_tx_ring_stats()
6590 * ice_update_vsi_ring_stats - Update VSI stats counters
6597 struct ice_pf *pf = vsi->back; in ice_update_vsi_ring_stats()
6605 /* reset non-netdev (extended) stats */ in ice_update_vsi_ring_stats()
6606 vsi->tx_restart = 0; in ice_update_vsi_ring_stats()
6607 vsi->tx_busy = 0; in ice_update_vsi_ring_stats()
6608 vsi->tx_linearize = 0; in ice_update_vsi_ring_stats()
6609 vsi->rx_buf_failed = 0; in ice_update_vsi_ring_stats()
6610 vsi->rx_page_failed = 0; in ice_update_vsi_ring_stats()
6615 ice_update_vsi_tx_ring_stats(vsi, vsi_stats, vsi->tx_rings, in ice_update_vsi_ring_stats()
6616 vsi->num_txq); in ice_update_vsi_ring_stats()
6620 struct ice_rx_ring *ring = READ_ONCE(vsi->rx_rings[i]); in ice_update_vsi_ring_stats()
6623 ring_stats = ring->ring_stats; in ice_update_vsi_ring_stats()
6624 ice_fetch_u64_stats_per_ring(&ring_stats->syncp, in ice_update_vsi_ring_stats()
6625 ring_stats->stats, &pkts, in ice_update_vsi_ring_stats()
6627 vsi_stats->rx_packets += pkts; in ice_update_vsi_ring_stats()
6628 vsi_stats->rx_bytes += bytes; in ice_update_vsi_ring_stats()
6629 vsi->rx_buf_failed += ring_stats->rx_stats.alloc_buf_failed; in ice_update_vsi_ring_stats()
6630 vsi->rx_page_failed += ring_stats->rx_stats.alloc_page_failed; in ice_update_vsi_ring_stats()
6635 ice_update_vsi_tx_ring_stats(vsi, vsi_stats, vsi->xdp_rings, in ice_update_vsi_ring_stats()
6636 vsi->num_xdp_txq); in ice_update_vsi_ring_stats()
6640 net_stats = &vsi->net_stats; in ice_update_vsi_ring_stats()
6641 stats_prev = &vsi->net_stats_prev; in ice_update_vsi_ring_stats()
6645 * diff of Prev-Cur, we need to be sure that Prev is valid. If it's not, in ice_update_vsi_ring_stats()
6648 if (likely(pf->stat_prev_loaded)) { in ice_update_vsi_ring_stats()
6649 net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets; in ice_update_vsi_ring_stats()
6650 net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes; in ice_update_vsi_ring_stats()
6651 net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets; in ice_update_vsi_ring_stats()
6652 net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes; in ice_update_vsi_ring_stats()
6655 stats_prev->tx_packets = vsi_stats->tx_packets; in ice_update_vsi_ring_stats()
6656 stats_prev->tx_bytes = vsi_stats->tx_bytes; in ice_update_vsi_ring_stats()
6657 stats_prev->rx_packets = vsi_stats->rx_packets; in ice_update_vsi_ring_stats()
6658 stats_prev->rx_bytes = vsi_stats->rx_bytes; in ice_update_vsi_ring_stats()
6664 * ice_update_vsi_stats - Update VSI stats counters
6669 struct rtnl_link_stats64 *cur_ns = &vsi->net_stats; in ice_update_vsi_stats()
6670 struct ice_eth_stats *cur_es = &vsi->eth_stats; in ice_update_vsi_stats()
6671 struct ice_pf *pf = vsi->back; in ice_update_vsi_stats()
6673 if (test_bit(ICE_VSI_DOWN, vsi->state) || in ice_update_vsi_stats()
6674 test_bit(ICE_CFG_BUSY, pf->state)) in ice_update_vsi_stats()
6683 cur_ns->tx_errors = cur_es->tx_errors; in ice_update_vsi_stats()
6684 cur_ns->rx_dropped = cur_es->rx_discards; in ice_update_vsi_stats()
6685 cur_ns->tx_dropped = cur_es->tx_discards; in ice_update_vsi_stats()
6686 cur_ns->multicast = cur_es->rx_multicast; in ice_update_vsi_stats()
6689 if (vsi->type == ICE_VSI_PF) { in ice_update_vsi_stats()
6690 cur_ns->rx_crc_errors = pf->stats.crc_errors; in ice_update_vsi_stats()
6691 cur_ns->rx_errors = pf->stats.crc_errors + in ice_update_vsi_stats()
6692 pf->stats.illegal_bytes + in ice_update_vsi_stats()
6693 pf->stats.rx_len_errors + in ice_update_vsi_stats()
6694 pf->stats.rx_undersize + in ice_update_vsi_stats()
6695 pf->hw_csum_rx_error + in ice_update_vsi_stats()
6696 pf->stats.rx_jabber + in ice_update_vsi_stats()
6697 pf->stats.rx_fragments + in ice_update_vsi_stats()
6698 pf->stats.rx_oversize; in ice_update_vsi_stats()
6699 cur_ns->rx_length_errors = pf->stats.rx_len_errors; in ice_update_vsi_stats()
6701 cur_ns->rx_missed_errors = pf->stats.eth.rx_discards; in ice_update_vsi_stats()
6706 * ice_update_pf_stats - Update PF port stats counters
6712 struct ice_hw *hw = &pf->hw; in ice_update_pf_stats()
6716 port = hw->port_info->lport; in ice_update_pf_stats()
6717 prev_ps = &pf->stats_prev; in ice_update_pf_stats()
6718 cur_ps = &pf->stats; in ice_update_pf_stats()
6720 if (ice_is_reset_in_progress(pf->state)) in ice_update_pf_stats()
6721 pf->stat_prev_loaded = false; in ice_update_pf_stats()
6723 ice_stat_update40(hw, GLPRT_GORCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6724 &prev_ps->eth.rx_bytes, in ice_update_pf_stats()
6725 &cur_ps->eth.rx_bytes); in ice_update_pf_stats()
6727 ice_stat_update40(hw, GLPRT_UPRCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6728 &prev_ps->eth.rx_unicast, in ice_update_pf_stats()
6729 &cur_ps->eth.rx_unicast); in ice_update_pf_stats()
6731 ice_stat_update40(hw, GLPRT_MPRCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6732 &prev_ps->eth.rx_multicast, in ice_update_pf_stats()
6733 &cur_ps->eth.rx_multicast); in ice_update_pf_stats()
6735 ice_stat_update40(hw, GLPRT_BPRCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6736 &prev_ps->eth.rx_broadcast, in ice_update_pf_stats()
6737 &cur_ps->eth.rx_broadcast); in ice_update_pf_stats()
6739 ice_stat_update32(hw, PRTRPB_RDPC, pf->stat_prev_loaded, in ice_update_pf_stats()
6740 &prev_ps->eth.rx_discards, in ice_update_pf_stats()
6741 &cur_ps->eth.rx_discards); in ice_update_pf_stats()
6743 ice_stat_update40(hw, GLPRT_GOTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6744 &prev_ps->eth.tx_bytes, in ice_update_pf_stats()
6745 &cur_ps->eth.tx_bytes); in ice_update_pf_stats()
6747 ice_stat_update40(hw, GLPRT_UPTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6748 &prev_ps->eth.tx_unicast, in ice_update_pf_stats()
6749 &cur_ps->eth.tx_unicast); in ice_update_pf_stats()
6751 ice_stat_update40(hw, GLPRT_MPTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6752 &prev_ps->eth.tx_multicast, in ice_update_pf_stats()
6753 &cur_ps->eth.tx_multicast); in ice_update_pf_stats()
6755 ice_stat_update40(hw, GLPRT_BPTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6756 &prev_ps->eth.tx_broadcast, in ice_update_pf_stats()
6757 &cur_ps->eth.tx_broadcast); in ice_update_pf_stats()
6759 ice_stat_update32(hw, GLPRT_TDOLD(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6760 &prev_ps->tx_dropped_link_down, in ice_update_pf_stats()
6761 &cur_ps->tx_dropped_link_down); in ice_update_pf_stats()
6763 ice_stat_update40(hw, GLPRT_PRC64L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6764 &prev_ps->rx_size_64, &cur_ps->rx_size_64); in ice_update_pf_stats()
6766 ice_stat_update40(hw, GLPRT_PRC127L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6767 &prev_ps->rx_size_127, &cur_ps->rx_size_127); in ice_update_pf_stats()
6769 ice_stat_update40(hw, GLPRT_PRC255L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6770 &prev_ps->rx_size_255, &cur_ps->rx_size_255); in ice_update_pf_stats()
6772 ice_stat_update40(hw, GLPRT_PRC511L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6773 &prev_ps->rx_size_511, &cur_ps->rx_size_511); in ice_update_pf_stats()
6775 ice_stat_update40(hw, GLPRT_PRC1023L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6776 &prev_ps->rx_size_1023, &cur_ps->rx_size_1023); in ice_update_pf_stats()
6778 ice_stat_update40(hw, GLPRT_PRC1522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6779 &prev_ps->rx_size_1522, &cur_ps->rx_size_1522); in ice_update_pf_stats()
6781 ice_stat_update40(hw, GLPRT_PRC9522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6782 &prev_ps->rx_size_big, &cur_ps->rx_size_big); in ice_update_pf_stats()
6784 ice_stat_update40(hw, GLPRT_PTC64L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6785 &prev_ps->tx_size_64, &cur_ps->tx_size_64); in ice_update_pf_stats()
6787 ice_stat_update40(hw, GLPRT_PTC127L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6788 &prev_ps->tx_size_127, &cur_ps->tx_size_127); in ice_update_pf_stats()
6790 ice_stat_update40(hw, GLPRT_PTC255L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6791 &prev_ps->tx_size_255, &cur_ps->tx_size_255); in ice_update_pf_stats()
6793 ice_stat_update40(hw, GLPRT_PTC511L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6794 &prev_ps->tx_size_511, &cur_ps->tx_size_511); in ice_update_pf_stats()
6796 ice_stat_update40(hw, GLPRT_PTC1023L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6797 &prev_ps->tx_size_1023, &cur_ps->tx_size_1023); in ice_update_pf_stats()
6799 ice_stat_update40(hw, GLPRT_PTC1522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6800 &prev_ps->tx_size_1522, &cur_ps->tx_size_1522); in ice_update_pf_stats()
6802 ice_stat_update40(hw, GLPRT_PTC9522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6803 &prev_ps->tx_size_big, &cur_ps->tx_size_big); in ice_update_pf_stats()
6805 fd_ctr_base = hw->fd_ctr_base; in ice_update_pf_stats()
6809 pf->stat_prev_loaded, &prev_ps->fd_sb_match, in ice_update_pf_stats()
6810 &cur_ps->fd_sb_match); in ice_update_pf_stats()
6811 ice_stat_update32(hw, GLPRT_LXONRXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6812 &prev_ps->link_xon_rx, &cur_ps->link_xon_rx); in ice_update_pf_stats()
6814 ice_stat_update32(hw, GLPRT_LXOFFRXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6815 &prev_ps->link_xoff_rx, &cur_ps->link_xoff_rx); in ice_update_pf_stats()
6817 ice_stat_update32(hw, GLPRT_LXONTXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6818 &prev_ps->link_xon_tx, &cur_ps->link_xon_tx); in ice_update_pf_stats()
6820 ice_stat_update32(hw, GLPRT_LXOFFTXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6821 &prev_ps->link_xoff_tx, &cur_ps->link_xoff_tx); in ice_update_pf_stats()
6825 ice_stat_update32(hw, GLPRT_CRCERRS(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6826 &prev_ps->crc_errors, &cur_ps->crc_errors); in ice_update_pf_stats()
6828 ice_stat_update32(hw, GLPRT_ILLERRC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6829 &prev_ps->illegal_bytes, &cur_ps->illegal_bytes); in ice_update_pf_stats()
6831 ice_stat_update32(hw, GLPRT_MLFC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6832 &prev_ps->mac_local_faults, in ice_update_pf_stats()
6833 &cur_ps->mac_local_faults); in ice_update_pf_stats()
6835 ice_stat_update32(hw, GLPRT_MRFC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6836 &prev_ps->mac_remote_faults, in ice_update_pf_stats()
6837 &cur_ps->mac_remote_faults); in ice_update_pf_stats()
6839 ice_stat_update32(hw, GLPRT_RLEC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6840 &prev_ps->rx_len_errors, &cur_ps->rx_len_errors); in ice_update_pf_stats()
6842 ice_stat_update32(hw, GLPRT_RUC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6843 &prev_ps->rx_undersize, &cur_ps->rx_undersize); in ice_update_pf_stats()
6845 ice_stat_update32(hw, GLPRT_RFC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6846 &prev_ps->rx_fragments, &cur_ps->rx_fragments); in ice_update_pf_stats()
6848 ice_stat_update32(hw, GLPRT_ROC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6849 &prev_ps->rx_oversize, &cur_ps->rx_oversize); in ice_update_pf_stats()
6851 ice_stat_update32(hw, GLPRT_RJC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6852 &prev_ps->rx_jabber, &cur_ps->rx_jabber); in ice_update_pf_stats()
6854 cur_ps->fd_sb_status = test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1 : 0; in ice_update_pf_stats()
6856 pf->stat_prev_loaded = true; in ice_update_pf_stats()
6860 * ice_get_stats64 - get statistics for network device structure
6869 struct ice_vsi *vsi = np->vsi; in ice_get_stats64()
6871 vsi_stats = &vsi->net_stats; in ice_get_stats64()
6873 if (!vsi->num_txq || !vsi->num_rxq) in ice_get_stats64()
6881 if (!test_bit(ICE_VSI_DOWN, vsi->state)) in ice_get_stats64()
6883 stats->tx_packets = vsi_stats->tx_packets; in ice_get_stats64()
6884 stats->tx_bytes = vsi_stats->tx_bytes; in ice_get_stats64()
6885 stats->rx_packets = vsi_stats->rx_packets; in ice_get_stats64()
6886 stats->rx_bytes = vsi_stats->rx_bytes; in ice_get_stats64()
6892 stats->multicast = vsi_stats->multicast; in ice_get_stats64()
6893 stats->tx_errors = vsi_stats->tx_errors; in ice_get_stats64()
6894 stats->tx_dropped = vsi_stats->tx_dropped; in ice_get_stats64()
6895 stats->rx_errors = vsi_stats->rx_errors; in ice_get_stats64()
6896 stats->rx_dropped = vsi_stats->rx_dropped; in ice_get_stats64()
6897 stats->rx_crc_errors = vsi_stats->rx_crc_errors; in ice_get_stats64()
6898 stats->rx_length_errors = vsi_stats->rx_length_errors; in ice_get_stats64()
6902 * ice_napi_disable_all - Disable NAPI for all q_vectors in the VSI
6909 if (!vsi->netdev) in ice_napi_disable_all()
6913 struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; in ice_napi_disable_all()
6915 if (q_vector->rx.rx_ring || q_vector->tx.tx_ring) in ice_napi_disable_all()
6916 napi_disable(&q_vector->napi); in ice_napi_disable_all()
6918 cancel_work_sync(&q_vector->tx.dim.work); in ice_napi_disable_all()
6919 cancel_work_sync(&q_vector->rx.dim.work); in ice_napi_disable_all()
6924 * ice_down - Shutdown the connection
6927 * Caller of this function is expected to set the vsi->state ICE_DOWN bit
6933 WARN_ON(!test_bit(ICE_VSI_DOWN, vsi->state)); in ice_down()
6935 if (vsi->netdev && vsi->type == ICE_VSI_PF) { in ice_down()
6937 ice_ptp_link_change(vsi->back, vsi->back->hw.pf_id, false); in ice_down()
6938 netif_carrier_off(vsi->netdev); in ice_down()
6939 netif_tx_disable(vsi->netdev); in ice_down()
6940 } else if (vsi->type == ICE_VSI_SWITCHDEV_CTRL) { in ice_down()
6941 ice_eswitch_stop_all_tx_queues(vsi->back); in ice_down()
6948 netdev_err(vsi->netdev, "Failed stop Tx rings, VSI %d error %d\n", in ice_down()
6949 vsi->vsi_num, tx_err); in ice_down()
6953 netdev_err(vsi->netdev, "Failed stop XDP rings, VSI %d error %d\n", in ice_down()
6954 vsi->vsi_num, tx_err); in ice_down()
6959 netdev_err(vsi->netdev, "Failed stop Rx rings, VSI %d error %d\n", in ice_down()
6960 vsi->vsi_num, rx_err); in ice_down()
6965 ice_clean_tx_ring(vsi->tx_rings[i]); in ice_down()
6969 ice_clean_tx_ring(vsi->xdp_rings[i]); in ice_down()
6972 ice_clean_rx_ring(vsi->rx_rings[i]); in ice_down()
6975 netdev_err(vsi->netdev, "Failed to close VSI 0x%04X on switch 0x%04X\n", in ice_down()
6976 vsi->vsi_num, vsi->vsw->sw_id); in ice_down()
6977 return -EIO; in ice_down()
6984 * ice_down_up - shutdown the VSI connection and bring it up
6992 if (test_and_set_bit(ICE_VSI_DOWN, vsi->state)) in ice_down_up()
7001 …netdev_err(vsi->netdev, "reallocating resources failed during netdev features change, may need to … in ice_down_up()
7009 * ice_vsi_setup_tx_rings - Allocate VSI Tx queue resources
7018 if (!vsi->num_txq) { in ice_vsi_setup_tx_rings()
7019 dev_err(ice_pf_to_dev(vsi->back), "VSI %d has 0 Tx queues\n", in ice_vsi_setup_tx_rings()
7020 vsi->vsi_num); in ice_vsi_setup_tx_rings()
7021 return -EINVAL; in ice_vsi_setup_tx_rings()
7025 struct ice_tx_ring *ring = vsi->tx_rings[i]; in ice_vsi_setup_tx_rings()
7028 return -EINVAL; in ice_vsi_setup_tx_rings()
7030 if (vsi->netdev) in ice_vsi_setup_tx_rings()
7031 ring->netdev = vsi->netdev; in ice_vsi_setup_tx_rings()
7041 * ice_vsi_setup_rx_rings - Allocate VSI Rx queue resources
7050 if (!vsi->num_rxq) { in ice_vsi_setup_rx_rings()
7051 dev_err(ice_pf_to_dev(vsi->back), "VSI %d has 0 Rx queues\n", in ice_vsi_setup_rx_rings()
7052 vsi->vsi_num); in ice_vsi_setup_rx_rings()
7053 return -EINVAL; in ice_vsi_setup_rx_rings()
7057 struct ice_rx_ring *ring = vsi->rx_rings[i]; in ice_vsi_setup_rx_rings()
7060 return -EINVAL; in ice_vsi_setup_rx_rings()
7062 if (vsi->netdev) in ice_vsi_setup_rx_rings()
7063 ring->netdev = vsi->netdev; in ice_vsi_setup_rx_rings()
7073 * ice_vsi_open_ctrl - open control VSI for use
7083 struct ice_pf *pf = vsi->back; in ice_vsi_open_ctrl()
7101 snprintf(int_name, sizeof(int_name) - 1, "%s-%s:ctrl", in ice_vsi_open_ctrl()
7113 clear_bit(ICE_VSI_DOWN, vsi->state); in ice_vsi_open_ctrl()
7129 * ice_vsi_open - Called when a network interface is made active
7139 struct ice_pf *pf = vsi->back; in ice_vsi_open()
7155 snprintf(int_name, sizeof(int_name) - 1, "%s-%s", in ice_vsi_open()
7156 dev_driver_string(ice_pf_to_dev(pf)), vsi->netdev->name); in ice_vsi_open()
7161 ice_vsi_cfg_netdev_tc(vsi, vsi->tc_cfg.ena_tc); in ice_vsi_open()
7163 if (vsi->type == ICE_VSI_PF) { in ice_vsi_open()
7165 err = netif_set_real_num_tx_queues(vsi->netdev, vsi->num_txq); in ice_vsi_open()
7169 err = netif_set_real_num_rx_queues(vsi->netdev, vsi->num_rxq); in ice_vsi_open()
7193 * ice_vsi_release_all - Delete all VSIs
7200 if (!pf->vsi) in ice_vsi_release_all()
7204 if (!pf->vsi[i]) in ice_vsi_release_all()
7207 if (pf->vsi[i]->type == ICE_VSI_CHNL) in ice_vsi_release_all()
7210 err = ice_vsi_release(pf->vsi[i]); in ice_vsi_release_all()
7212 dev_dbg(ice_pf_to_dev(pf), "Failed to release pf->vsi[%d], err %d, vsi_num = %d\n", in ice_vsi_release_all()
7213 i, err, pf->vsi[i]->vsi_num); in ice_vsi_release_all()
7218 * ice_vsi_rebuild_by_type - Rebuild VSI of a given type
7222 * Iterates through the pf->vsi array and rebuilds VSIs of the requested type
7230 struct ice_vsi *vsi = pf->vsi[i]; in ice_vsi_rebuild_by_type()
7232 if (!vsi || vsi->type != type) in ice_vsi_rebuild_by_type()
7239 err, vsi->idx, ice_vsi_type_str(type)); in ice_vsi_rebuild_by_type()
7244 err = ice_replay_vsi(&pf->hw, vsi->idx); in ice_vsi_rebuild_by_type()
7247 err, vsi->idx, ice_vsi_type_str(type)); in ice_vsi_rebuild_by_type()
7251 /* Re-map HW VSI number, using VSI handle that has been in ice_vsi_rebuild_by_type()
7254 vsi->vsi_num = ice_get_hw_vsi_num(&pf->hw, vsi->idx); in ice_vsi_rebuild_by_type()
7260 err, vsi->idx, ice_vsi_type_str(type)); in ice_vsi_rebuild_by_type()
7264 dev_info(dev, "VSI rebuilt. VSI index %d, type %s\n", vsi->idx, in ice_vsi_rebuild_by_type()
7272 * ice_update_pf_netdev_link - Update PF netdev link status
7281 struct ice_vsi *vsi = pf->vsi[i]; in ice_update_pf_netdev_link()
7283 if (!vsi || vsi->type != ICE_VSI_PF) in ice_update_pf_netdev_link()
7286 ice_get_link_status(pf->vsi[i]->port_info, &link_up); in ice_update_pf_netdev_link()
7288 netif_carrier_on(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7289 netif_tx_wake_all_queues(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7291 netif_carrier_off(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7292 netif_tx_stop_all_queues(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7298 * ice_rebuild - rebuild after reset
7311 struct ice_hw *hw = &pf->hw; in ice_rebuild()
7315 if (test_bit(ICE_DOWN, pf->state)) in ice_rebuild()
7326 pf->fw_emp_reset_disabled = false; in ice_rebuild()
7375 err = ice_aq_set_port_params(pf->hw.port_info, dvm, NULL); in ice_rebuild()
7379 err = ice_sched_init_port(hw->port_info); in ice_rebuild()
7390 if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) { in ice_rebuild()
7395 guar = hw->func_caps.fd_fltr_guar; in ice_rebuild()
7396 b_effort = hw->func_caps.fd_fltr_best_effort; in ice_rebuild()
7405 if (test_bit(ICE_FLAG_DCB_ENA, pf->flags)) in ice_rebuild()
7412 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_rebuild()
7426 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_rebuild()
7445 if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) { in ice_rebuild()
7453 if (hw->fdir_prof) in ice_rebuild()
7462 if (vsi && vsi->netdev) in ice_rebuild()
7463 netif_device_attach(vsi->netdev); in ice_rebuild()
7478 clear_bit(ICE_RESET_FAILED, pf->state); in ice_rebuild()
7490 set_bit(ICE_RESET_FAILED, pf->state); in ice_rebuild()
7493 set_bit(ICE_NEEDS_RESTART, pf->state); in ice_rebuild()
7498 * ice_change_mtu - NDO callback to change the MTU
7507 struct ice_vsi *vsi = np->vsi; in ice_change_mtu()
7508 struct ice_pf *pf = vsi->back; in ice_change_mtu()
7513 if (new_mtu == (int)netdev->mtu) { in ice_change_mtu()
7514 netdev_warn(netdev, "MTU is already %u\n", netdev->mtu); in ice_change_mtu()
7518 prog = vsi->xdp_prog; in ice_change_mtu()
7519 if (prog && !prog->aux->xdp_has_frags) { in ice_change_mtu()
7524 frame_size - ICE_ETH_PKT_HDR_PAD); in ice_change_mtu()
7525 return -EINVAL; in ice_change_mtu()
7527 } else if (test_bit(ICE_FLAG_LEGACY_RX, pf->flags)) { in ice_change_mtu()
7529 netdev_err(netdev, "Too big MTU for legacy-rx; Max is %d\n", in ice_change_mtu()
7530 ICE_MAX_FRAME_LEGACY_RX - ICE_ETH_PKT_HDR_PAD); in ice_change_mtu()
7531 return -EINVAL; in ice_change_mtu()
7537 if (ice_is_reset_in_progress(pf->state)) { in ice_change_mtu()
7548 return -EBUSY; in ice_change_mtu()
7551 netdev->mtu = (unsigned int)new_mtu; in ice_change_mtu()
7557 set_bit(ICE_FLAG_MTU_CHANGED, pf->flags); in ice_change_mtu()
7563 * ice_eth_ioctl - Access the hwtstamp interface
7571 struct ice_pf *pf = np->vsi->back; in ice_eth_ioctl()
7579 return -EOPNOTSUPP; in ice_eth_ioctl()
7584 * ice_aq_str - convert AQ err code to a string
7626 * ice_set_rss_lut - Set RSS LUT
7636 struct ice_hw *hw = &vsi->back->hw; in ice_set_rss_lut()
7640 return -EINVAL; in ice_set_rss_lut()
7642 params.vsi_handle = vsi->idx; in ice_set_rss_lut()
7644 params.lut_type = vsi->rss_lut_type; in ice_set_rss_lut()
7649 dev_err(ice_pf_to_dev(vsi->back), "Cannot set RSS lut, err %d aq_err %s\n", in ice_set_rss_lut()
7650 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_rss_lut()
7656 * ice_set_rss_key - Set RSS key
7664 struct ice_hw *hw = &vsi->back->hw; in ice_set_rss_key()
7668 return -EINVAL; in ice_set_rss_key()
7670 status = ice_aq_set_rss_key(hw, vsi->idx, (struct ice_aqc_get_set_rss_keys *)seed); in ice_set_rss_key()
7672 dev_err(ice_pf_to_dev(vsi->back), "Cannot set RSS key, err %d aq_err %s\n", in ice_set_rss_key()
7673 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_rss_key()
7679 * ice_get_rss_lut - Get RSS LUT
7689 struct ice_hw *hw = &vsi->back->hw; in ice_get_rss_lut()
7693 return -EINVAL; in ice_get_rss_lut()
7695 params.vsi_handle = vsi->idx; in ice_get_rss_lut()
7697 params.lut_type = vsi->rss_lut_type; in ice_get_rss_lut()
7702 dev_err(ice_pf_to_dev(vsi->back), "Cannot get RSS lut, err %d aq_err %s\n", in ice_get_rss_lut()
7703 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_rss_lut()
7709 * ice_get_rss_key - Get RSS key
7717 struct ice_hw *hw = &vsi->back->hw; in ice_get_rss_key()
7721 return -EINVAL; in ice_get_rss_key()
7723 status = ice_aq_get_rss_key(hw, vsi->idx, (struct ice_aqc_get_set_rss_keys *)seed); in ice_get_rss_key()
7725 dev_err(ice_pf_to_dev(vsi->back), "Cannot get RSS key, err %d aq_err %s\n", in ice_get_rss_key()
7726 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_rss_key()
7732 * ice_bridge_getlink - Get the hardware bridge mode
7747 struct ice_vsi *vsi = np->vsi; in ice_bridge_getlink()
7748 struct ice_pf *pf = vsi->back; in ice_bridge_getlink()
7751 bmode = pf->first_sw->bridge_mode; in ice_bridge_getlink()
7758 * ice_vsi_update_bridge_mode - Update VSI for switching bridge mode (VEB/VEPA)
7767 struct ice_hw *hw = &vsi->back->hw; in ice_vsi_update_bridge_mode()
7771 vsi_props = &vsi->info; in ice_vsi_update_bridge_mode()
7775 return -ENOMEM; in ice_vsi_update_bridge_mode()
7777 ctxt->info = vsi->info; in ice_vsi_update_bridge_mode()
7781 ctxt->info.sw_flags |= ICE_AQ_VSI_SW_FLAG_ALLOW_LB; in ice_vsi_update_bridge_mode()
7784 ctxt->info.sw_flags &= ~ICE_AQ_VSI_SW_FLAG_ALLOW_LB; in ice_vsi_update_bridge_mode()
7785 ctxt->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_SW_VALID); in ice_vsi_update_bridge_mode()
7787 ret = ice_update_vsi(hw, vsi->idx, ctxt, NULL); in ice_vsi_update_bridge_mode()
7789 …dev_err(ice_pf_to_dev(vsi->back), "update VSI for bridge mode failed, bmode = %d err %d aq_err %s\… in ice_vsi_update_bridge_mode()
7790 bmode, ret, ice_aq_str(hw->adminq.sq_last_status)); in ice_vsi_update_bridge_mode()
7794 vsi_props->sw_flags = ctxt->info.sw_flags; in ice_vsi_update_bridge_mode()
7802 * ice_bridge_setlink - Set the hardware bridge mode
7819 struct ice_pf *pf = np->vsi->back; in ice_bridge_setlink()
7821 struct ice_hw *hw = &pf->hw; in ice_bridge_setlink()
7825 pf_sw = pf->first_sw; in ice_bridge_setlink()
7829 return -EINVAL; in ice_bridge_setlink()
7838 return -EINVAL; in ice_bridge_setlink()
7840 if (mode == pf_sw->bridge_mode) in ice_bridge_setlink()
7846 if (!pf->vsi[v]) in ice_bridge_setlink()
7848 err = ice_vsi_update_bridge_mode(pf->vsi[v], mode); in ice_bridge_setlink()
7853 hw->evb_veb = (mode == BRIDGE_MODE_VEB); in ice_bridge_setlink()
7861 ice_aq_str(hw->adminq.sq_last_status)); in ice_bridge_setlink()
7862 /* revert hw->evb_veb */ in ice_bridge_setlink()
7863 hw->evb_veb = (pf_sw->bridge_mode == BRIDGE_MODE_VEB); in ice_bridge_setlink()
7867 pf_sw->bridge_mode = mode; in ice_bridge_setlink()
7874 * ice_tx_timeout - Respond to a Tx Hang
7882 struct ice_vsi *vsi = np->vsi; in ice_tx_timeout()
7883 struct ice_pf *pf = vsi->back; in ice_tx_timeout()
7886 pf->tx_timeout_count++; in ice_tx_timeout()
7900 if (vsi->tx_rings[i] && vsi->tx_rings[i]->desc) in ice_tx_timeout()
7901 if (txqueue == vsi->tx_rings[i]->q_index) { in ice_tx_timeout()
7902 tx_ring = vsi->tx_rings[i]; in ice_tx_timeout()
7909 if (time_after(jiffies, (pf->tx_timeout_last_recovery + HZ * 20))) in ice_tx_timeout()
7910 pf->tx_timeout_recovery_level = 1; in ice_tx_timeout()
7911 else if (time_before(jiffies, (pf->tx_timeout_last_recovery + in ice_tx_timeout()
7912 netdev->watchdog_timeo))) in ice_tx_timeout()
7916 struct ice_hw *hw = &pf->hw; in ice_tx_timeout()
7919 head = (rd32(hw, QTX_COMM_HEAD(vsi->txq_map[txqueue])) & in ice_tx_timeout()
7922 val = rd32(hw, GLINT_DYN_CTL(tx_ring->q_vector->reg_idx)); in ice_tx_timeout()
7925 vsi->vsi_num, txqueue, tx_ring->next_to_clean, in ice_tx_timeout()
7926 head, tx_ring->next_to_use, val); in ice_tx_timeout()
7929 pf->tx_timeout_last_recovery = jiffies; in ice_tx_timeout()
7931 pf->tx_timeout_recovery_level, txqueue); in ice_tx_timeout()
7933 switch (pf->tx_timeout_recovery_level) { in ice_tx_timeout()
7935 set_bit(ICE_PFR_REQ, pf->state); in ice_tx_timeout()
7938 set_bit(ICE_CORER_REQ, pf->state); in ice_tx_timeout()
7941 set_bit(ICE_GLOBR_REQ, pf->state); in ice_tx_timeout()
7945 set_bit(ICE_DOWN, pf->state); in ice_tx_timeout()
7946 set_bit(ICE_VSI_NEEDS_RESTART, vsi->state); in ice_tx_timeout()
7947 set_bit(ICE_SERVICE_DIS, pf->state); in ice_tx_timeout()
7952 pf->tx_timeout_recovery_level++; in ice_tx_timeout()
7956 * ice_setup_tc_cls_flower - flower classifier offloads
7966 struct ice_vsi *vsi = np->vsi; in ice_setup_tc_cls_flower()
7968 if (cls_flower->common.chain_index) in ice_setup_tc_cls_flower()
7969 return -EOPNOTSUPP; in ice_setup_tc_cls_flower()
7971 switch (cls_flower->command) { in ice_setup_tc_cls_flower()
7977 return -EINVAL; in ice_setup_tc_cls_flower()
7982 * ice_setup_tc_block_cb - callback handler registered for TC block
7994 return ice_setup_tc_cls_flower(np, np->vsi->netdev, in ice_setup_tc_block_cb()
7997 return -EOPNOTSUPP; in ice_setup_tc_block_cb()
8002 * ice_validate_mqprio_qopt - Validate TCF input parameters
8015 struct ice_pf *pf = vsi->back; in ice_validate_mqprio_qopt()
8022 if (vsi->type != ICE_VSI_PF) in ice_validate_mqprio_qopt()
8023 return -EINVAL; in ice_validate_mqprio_qopt()
8025 if (mqprio_qopt->qopt.offset[0] != 0 || in ice_validate_mqprio_qopt()
8026 mqprio_qopt->qopt.num_tc < 1 || in ice_validate_mqprio_qopt()
8027 mqprio_qopt->qopt.num_tc > ICE_CHNL_MAX_TC) in ice_validate_mqprio_qopt()
8028 return -EINVAL; in ice_validate_mqprio_qopt()
8031 vsi->ch_rss_size = 0; in ice_validate_mqprio_qopt()
8032 num_tc = mqprio_qopt->qopt.num_tc; in ice_validate_mqprio_qopt()
8036 int qcount = mqprio_qopt->qopt.count[i]; in ice_validate_mqprio_qopt()
8040 return -EINVAL; in ice_validate_mqprio_qopt()
8047 return -EINVAL; in ice_validate_mqprio_qopt()
8056 return -EINVAL; in ice_validate_mqprio_qopt()
8061 return -EINVAL; in ice_validate_mqprio_qopt()
8072 max_rate = mqprio_qopt->max_rate[i]; in ice_validate_mqprio_qopt()
8076 min_rate = mqprio_qopt->min_rate[i]; in ice_validate_mqprio_qopt()
8083 return -EINVAL; in ice_validate_mqprio_qopt()
8089 return -EINVAL; in ice_validate_mqprio_qopt()
8096 return -EINVAL; in ice_validate_mqprio_qopt()
8103 return -EINVAL; in ice_validate_mqprio_qopt()
8113 return -EINVAL; in ice_validate_mqprio_qopt()
8116 if (i >= mqprio_qopt->qopt.num_tc - 1) in ice_validate_mqprio_qopt()
8118 if (mqprio_qopt->qopt.offset[i + 1] != in ice_validate_mqprio_qopt()
8119 (mqprio_qopt->qopt.offset[i] + qcount)) in ice_validate_mqprio_qopt()
8120 return -EINVAL; in ice_validate_mqprio_qopt()
8122 if (vsi->num_rxq < in ice_validate_mqprio_qopt()
8123 (mqprio_qopt->qopt.offset[i] + mqprio_qopt->qopt.count[i])) in ice_validate_mqprio_qopt()
8124 return -EINVAL; in ice_validate_mqprio_qopt()
8125 if (vsi->num_txq < in ice_validate_mqprio_qopt()
8126 (mqprio_qopt->qopt.offset[i] + mqprio_qopt->qopt.count[i])) in ice_validate_mqprio_qopt()
8127 return -EINVAL; in ice_validate_mqprio_qopt()
8132 return -EINVAL; in ice_validate_mqprio_qopt()
8135 /* make sure vsi->ch_rss_size is set correctly based on TC's qcount */ in ice_validate_mqprio_qopt()
8136 vsi->ch_rss_size = max_rss_q_cnt; in ice_validate_mqprio_qopt()
8142 * ice_add_vsi_to_fdir - add a VSI to the flow director group for PF
8153 if (!(vsi->num_gfltr || vsi->num_bfltr)) in ice_add_vsi_to_fdir()
8154 return -EINVAL; in ice_add_vsi_to_fdir()
8156 hw = &pf->hw; in ice_add_vsi_to_fdir()
8162 if (!(hw->fdir_prof && hw->fdir_prof[flow] && in ice_add_vsi_to_fdir()
8163 hw->fdir_prof[flow]->cnt)) in ice_add_vsi_to_fdir()
8172 prof = hw->fdir_prof[flow]; in ice_add_vsi_to_fdir()
8175 prof->vsi_h[0], vsi->idx, in ice_add_vsi_to_fdir()
8176 prio, prof->fdir_seg[tun], in ice_add_vsi_to_fdir()
8180 vsi->idx, flow); in ice_add_vsi_to_fdir()
8184 prof->entry_h[prof->cnt][tun] = entry_h; in ice_add_vsi_to_fdir()
8188 prof->vsi_h[prof->cnt] = vsi->idx; in ice_add_vsi_to_fdir()
8189 prof->cnt++; in ice_add_vsi_to_fdir()
8192 dev_dbg(dev, "VSI idx %d added to fdir group %d\n", vsi->idx, in ice_add_vsi_to_fdir()
8197 dev_dbg(dev, "VSI idx %d not added to fdir groups\n", vsi->idx); in ice_add_vsi_to_fdir()
8203 * ice_add_channel - add a channel by adding VSI
8215 if (ch->type != ICE_VSI_CHNL) { in ice_add_channel()
8216 dev_err(dev, "add new VSI failed, ch->type %d\n", ch->type); in ice_add_channel()
8217 return -EINVAL; in ice_add_channel()
8220 vsi = ice_chnl_vsi_setup(pf, pf->hw.port_info, ch); in ice_add_channel()
8221 if (!vsi || vsi->type != ICE_VSI_CHNL) { in ice_add_channel()
8223 return -EINVAL; in ice_add_channel()
8228 ch->sw_id = sw_id; in ice_add_channel()
8229 ch->vsi_num = vsi->vsi_num; in ice_add_channel()
8230 ch->info.mapping_flags = vsi->info.mapping_flags; in ice_add_channel()
8231 ch->ch_vsi = vsi; in ice_add_channel()
8233 vsi->ch = ch; in ice_add_channel()
8235 memcpy(&ch->info.q_mapping, &vsi->info.q_mapping, in ice_add_channel()
8236 sizeof(vsi->info.q_mapping)); in ice_add_channel()
8237 memcpy(&ch->info.tc_mapping, vsi->info.tc_mapping, in ice_add_channel()
8238 sizeof(vsi->info.tc_mapping)); in ice_add_channel()
8254 for (i = 0; i < ch->num_txq; i++) { in ice_chnl_cfg_res()
8260 tx_ring = vsi->tx_rings[ch->base_q + i]; in ice_chnl_cfg_res()
8261 rx_ring = vsi->rx_rings[ch->base_q + i]; in ice_chnl_cfg_res()
8266 tx_ring->ch = ch; in ice_chnl_cfg_res()
8267 rx_ring->ch = ch; in ice_chnl_cfg_res()
8270 tx_q_vector = tx_ring->q_vector; in ice_chnl_cfg_res()
8271 rx_q_vector = rx_ring->q_vector; in ice_chnl_cfg_res()
8276 tx_q_vector->ch = ch; in ice_chnl_cfg_res()
8278 rc = &tx_q_vector->tx; in ice_chnl_cfg_res()
8280 ice_write_itr(rc, rc->itr_setting); in ice_chnl_cfg_res()
8283 rx_q_vector->ch = ch; in ice_chnl_cfg_res()
8285 rc = &rx_q_vector->rx; in ice_chnl_cfg_res()
8287 ice_write_itr(rc, rc->itr_setting); in ice_chnl_cfg_res()
8291 /* it is safe to assume that, if channel has non-zero num_t[r]xq, then in ice_chnl_cfg_res()
8292 * GLINT_ITR register would have written to perform in-context in ice_chnl_cfg_res()
8295 if (ch->num_txq || ch->num_rxq) in ice_chnl_cfg_res()
8296 ice_flush(&vsi->back->hw); in ice_chnl_cfg_res()
8300 * ice_cfg_chnl_all_res - configure channel resources
8304 * This function configures channel specific resources such as flow-director
8317 * ice_setup_hw_channel - setup new channel
8334 ch->base_q = vsi->next_base_q; in ice_setup_hw_channel()
8335 ch->type = type; in ice_setup_hw_channel()
8349 vsi->next_base_q = vsi->next_base_q + ch->num_rxq; in ice_setup_hw_channel()
8350 dev_dbg(dev, "added channel: vsi_num %u, num_rxq %u\n", ch->vsi_num, in ice_setup_hw_channel()
8351 ch->num_rxq); in ice_setup_hw_channel()
8357 * ice_setup_channel - setup new channel using uplink element
8373 if (vsi->type != ICE_VSI_PF) { in ice_setup_channel()
8374 dev_err(dev, "unsupported parent VSI type(%d)\n", vsi->type); in ice_setup_channel()
8378 sw_id = pf->first_sw->sw_id; in ice_setup_channel()
8388 return ch->ch_vsi ? true : false; in ice_setup_channel()
8392 * ice_set_bw_limit - setup BW limit for Tx traffic based on max_tx_rate
8410 * ice_create_q_channel - function to create channel
8419 struct ice_pf *pf = vsi->back; in ice_create_q_channel()
8423 return -EINVAL; in ice_create_q_channel()
8426 if (!ch->num_txq || !ch->num_rxq) { in ice_create_q_channel()
8427 dev_err(dev, "Invalid num_queues requested: %d\n", ch->num_rxq); in ice_create_q_channel()
8428 return -EINVAL; in ice_create_q_channel()
8431 if (!vsi->cnt_q_avail || vsi->cnt_q_avail < ch->num_txq) { in ice_create_q_channel()
8433 vsi->cnt_q_avail, ch->num_txq); in ice_create_q_channel()
8434 return -EINVAL; in ice_create_q_channel()
8439 return -EINVAL; in ice_create_q_channel()
8442 if (ch->ch_vsi && (ch->max_tx_rate || ch->min_tx_rate)) { in ice_create_q_channel()
8445 ret = ice_set_bw_limit(ch->ch_vsi, ch->max_tx_rate, in ice_create_q_channel()
8446 ch->min_tx_rate); in ice_create_q_channel()
8449 ch->max_tx_rate, ch->ch_vsi->vsi_num); in ice_create_q_channel()
8452 ch->max_tx_rate, ch->ch_vsi->vsi_num); in ice_create_q_channel()
8455 vsi->cnt_q_avail -= ch->num_txq; in ice_create_q_channel()
8461 * ice_rem_all_chnl_fltrs - removes all channel filters
8462 * @pf: ptr to PF, TC-flower based filter are tracked at PF level
8465 * tc-flower based filter
8474 &pf->tc_flower_fltr_list, in ice_rem_all_chnl_fltrs()
8483 rule.rid = fltr->rid; in ice_rem_all_chnl_fltrs()
8484 rule.rule_id = fltr->rule_id; in ice_rem_all_chnl_fltrs()
8485 rule.vsi_handle = fltr->dest_vsi_handle; in ice_rem_all_chnl_fltrs()
8486 status = ice_rem_adv_rule_by_id(&pf->hw, &rule); in ice_rem_all_chnl_fltrs()
8488 if (status == -ENOENT) in ice_rem_all_chnl_fltrs()
8494 } else if (fltr->dest_vsi) { in ice_rem_all_chnl_fltrs()
8496 if (fltr->dest_vsi->type == ICE_VSI_CHNL) { in ice_rem_all_chnl_fltrs()
8497 u32 flags = fltr->flags; in ice_rem_all_chnl_fltrs()
8499 fltr->dest_vsi->num_chnl_fltr--; in ice_rem_all_chnl_fltrs()
8502 pf->num_dmac_chnl_fltrs--; in ice_rem_all_chnl_fltrs()
8506 hlist_del(&fltr->tc_flower_node); in ice_rem_all_chnl_fltrs()
8512 * ice_remove_q_channels - Remove queue channels for the TCs
8521 struct ice_pf *pf = vsi->back; in ice_remove_q_channels()
8524 /* remove all tc-flower based filter if they are channel filters only */ in ice_remove_q_channels()
8529 if (vsi->netdev->features & NETIF_F_NTUPLE) { in ice_remove_q_channels()
8530 struct ice_hw *hw = &pf->hw; in ice_remove_q_channels()
8532 mutex_lock(&hw->fdir_fltr_lock); in ice_remove_q_channels()
8534 mutex_unlock(&hw->fdir_fltr_lock); in ice_remove_q_channels()
8538 list_for_each_entry_safe(ch, ch_tmp, &vsi->ch_list, list) { in ice_remove_q_channels()
8541 list_del(&ch->list); in ice_remove_q_channels()
8542 ch_vsi = ch->ch_vsi; in ice_remove_q_channels()
8549 for (i = 0; i < ch->num_rxq; i++) { in ice_remove_q_channels()
8553 tx_ring = vsi->tx_rings[ch->base_q + i]; in ice_remove_q_channels()
8554 rx_ring = vsi->rx_rings[ch->base_q + i]; in ice_remove_q_channels()
8556 tx_ring->ch = NULL; in ice_remove_q_channels()
8557 if (tx_ring->q_vector) in ice_remove_q_channels()
8558 tx_ring->q_vector->ch = NULL; in ice_remove_q_channels()
8561 rx_ring->ch = NULL; in ice_remove_q_channels()
8562 if (rx_ring->q_vector) in ice_remove_q_channels()
8563 rx_ring->q_vector->ch = NULL; in ice_remove_q_channels()
8568 ice_fdir_rem_adq_chnl(&pf->hw, ch->ch_vsi->idx); in ice_remove_q_channels()
8571 ice_rm_vsi_lan_cfg(ch->ch_vsi->port_info, ch->ch_vsi->idx); in ice_remove_q_channels()
8574 ice_vsi_delete(ch->ch_vsi); in ice_remove_q_channels()
8582 vsi->tc_map_vsi[i] = NULL; in ice_remove_q_channels()
8585 vsi->all_enatc = 0; in ice_remove_q_channels()
8586 vsi->all_numtc = 0; in ice_remove_q_channels()
8590 * ice_rebuild_channels - rebuild channel
8609 if (!test_bit(ICE_FLAG_TC_MQPRIO, pf->flags) || in ice_rebuild_channels()
8610 main_vsi->old_numtc == 1) in ice_rebuild_channels()
8616 err = ice_vsi_cfg_tc(main_vsi, main_vsi->old_ena_tc); in ice_rebuild_channels()
8619 main_vsi->old_ena_tc, main_vsi->vsi_num); in ice_rebuild_channels()
8627 vsi = pf->vsi[i]; in ice_rebuild_channels()
8628 if (!vsi || vsi->type != ICE_VSI_CHNL) in ice_rebuild_channels()
8631 type = vsi->type; in ice_rebuild_channels()
8637 ice_vsi_type_str(type), vsi->idx, err); in ice_rebuild_channels()
8641 /* Re-map HW VSI number, using VSI handle that has been in ice_rebuild_channels()
8644 vsi->vsi_num = ice_get_hw_vsi_num(&pf->hw, vsi->idx); in ice_rebuild_channels()
8647 err = ice_replay_vsi(&pf->hw, vsi->idx); in ice_rebuild_channels()
8650 ice_vsi_type_str(type), err, vsi->idx); in ice_rebuild_channels()
8655 ice_vsi_type_str(type), vsi->idx); in ice_rebuild_channels()
8660 main_vsi->tc_map_vsi[tc_idx++] = vsi; in ice_rebuild_channels()
8666 list_for_each_entry(ch, &main_vsi->ch_list, list) { in ice_rebuild_channels()
8669 ch_vsi = ch->ch_vsi; in ice_rebuild_channels()
8676 /* replay BW rate limit if it is non-zero */ in ice_rebuild_channels()
8677 if (!ch->max_tx_rate && !ch->min_tx_rate) in ice_rebuild_channels()
8680 err = ice_set_bw_limit(ch_vsi, ch->max_tx_rate, in ice_rebuild_channels()
8681 ch->min_tx_rate); in ice_rebuild_channels()
8684 err, ch->max_tx_rate, ch->min_tx_rate, in ice_rebuild_channels()
8685 ch_vsi->vsi_num); in ice_rebuild_channels()
8688 ch->max_tx_rate, ch->min_tx_rate, in ice_rebuild_channels()
8689 ch_vsi->vsi_num); in ice_rebuild_channels()
8693 if (main_vsi->ch_rss_size) in ice_rebuild_channels()
8704 * ice_create_q_channels - Add queue channel for the given TCs
8711 struct ice_pf *pf = vsi->back; in ice_create_q_channels()
8716 if (!(vsi->all_enatc & BIT(i))) in ice_create_q_channels()
8721 ret = -ENOMEM; in ice_create_q_channels()
8724 INIT_LIST_HEAD(&ch->list); in ice_create_q_channels()
8725 ch->num_rxq = vsi->mqprio_qopt.qopt.count[i]; in ice_create_q_channels()
8726 ch->num_txq = vsi->mqprio_qopt.qopt.count[i]; in ice_create_q_channels()
8727 ch->base_q = vsi->mqprio_qopt.qopt.offset[i]; in ice_create_q_channels()
8728 ch->max_tx_rate = vsi->mqprio_qopt.max_rate[i]; in ice_create_q_channels()
8729 ch->min_tx_rate = vsi->mqprio_qopt.min_rate[i]; in ice_create_q_channels()
8732 if (ch->max_tx_rate) in ice_create_q_channels()
8733 ch->max_tx_rate = div_u64(ch->max_tx_rate, in ice_create_q_channels()
8735 if (ch->min_tx_rate) in ice_create_q_channels()
8736 ch->min_tx_rate = div_u64(ch->min_tx_rate, in ice_create_q_channels()
8746 list_add_tail(&ch->list, &vsi->ch_list); in ice_create_q_channels()
8747 vsi->tc_map_vsi[i] = ch->ch_vsi; in ice_create_q_channels()
8749 "successfully created channel: VSI %pK\n", ch->ch_vsi); in ice_create_q_channels()
8760 * ice_setup_tc_mqprio_qdisc - configure multiple traffic classes
8768 struct ice_vsi *vsi = np->vsi; in ice_setup_tc_mqprio_qdisc()
8769 struct ice_pf *pf = vsi->back; in ice_setup_tc_mqprio_qdisc()
8777 num_tcf = mqprio_qopt->qopt.num_tc; in ice_setup_tc_mqprio_qdisc()
8778 hw = mqprio_qopt->qopt.hw; in ice_setup_tc_mqprio_qdisc()
8779 mode = mqprio_qopt->mode; in ice_setup_tc_mqprio_qdisc()
8781 clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags); in ice_setup_tc_mqprio_qdisc()
8782 vsi->ch_rss_size = 0; in ice_setup_tc_mqprio_qdisc()
8783 memcpy(&vsi->mqprio_qopt, mqprio_qopt, sizeof(*mqprio_qopt)); in ice_setup_tc_mqprio_qdisc()
8794 if (pf->hw.port_info->is_custom_tx_enabled) { in ice_setup_tc_mqprio_qdisc()
8796 return -EBUSY; in ice_setup_tc_mqprio_qdisc()
8806 memcpy(&vsi->mqprio_qopt, mqprio_qopt, sizeof(*mqprio_qopt)); in ice_setup_tc_mqprio_qdisc()
8807 set_bit(ICE_FLAG_TC_MQPRIO, pf->flags); in ice_setup_tc_mqprio_qdisc()
8812 if (vsi->netdev->features & NETIF_F_HW_TC) in ice_setup_tc_mqprio_qdisc()
8813 set_bit(ICE_FLAG_CLS_FLOWER, pf->flags); in ice_setup_tc_mqprio_qdisc()
8816 return -EINVAL; in ice_setup_tc_mqprio_qdisc()
8822 if (ena_tc_qdisc == vsi->tc_cfg.ena_tc && in ice_setup_tc_mqprio_qdisc()
8829 if (!hw && !test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) in ice_setup_tc_mqprio_qdisc()
8832 if (!hw && !test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) { in ice_setup_tc_mqprio_qdisc()
8833 vsi->req_txq = min_t(int, ice_get_avail_txq_count(pf), in ice_setup_tc_mqprio_qdisc()
8835 vsi->req_rxq = min_t(int, ice_get_avail_rxq_count(pf), in ice_setup_tc_mqprio_qdisc()
8838 /* logic to rebuild VSI, same like ethtool -L */ in ice_setup_tc_mqprio_qdisc()
8845 offset = vsi->mqprio_qopt.qopt.offset[i]; in ice_setup_tc_mqprio_qdisc()
8846 qcount_rx = vsi->mqprio_qopt.qopt.count[i]; in ice_setup_tc_mqprio_qdisc()
8847 qcount_tx = vsi->mqprio_qopt.qopt.count[i]; in ice_setup_tc_mqprio_qdisc()
8849 vsi->req_txq = offset + qcount_tx; in ice_setup_tc_mqprio_qdisc()
8850 vsi->req_rxq = offset + qcount_rx; in ice_setup_tc_mqprio_qdisc()
8853 * form ice_vsi_rebuild during tc-qdisc delete stage - to in ice_setup_tc_mqprio_qdisc()
8856 vsi->orig_rss_size = vsi->rss_size; in ice_setup_tc_mqprio_qdisc()
8862 cur_txq = vsi->num_txq; in ice_setup_tc_mqprio_qdisc()
8863 cur_rxq = vsi->num_rxq; in ice_setup_tc_mqprio_qdisc()
8870 vsi->req_txq = cur_txq; in ice_setup_tc_mqprio_qdisc()
8871 vsi->req_rxq = cur_rxq; in ice_setup_tc_mqprio_qdisc()
8872 clear_bit(ICE_RESET_FAILED, pf->state); in ice_setup_tc_mqprio_qdisc()
8879 vsi->all_numtc = num_tcf; in ice_setup_tc_mqprio_qdisc()
8880 vsi->all_enatc = ena_tc_qdisc; in ice_setup_tc_mqprio_qdisc()
8884 vsi->vsi_num); in ice_setup_tc_mqprio_qdisc()
8888 if (test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) { in ice_setup_tc_mqprio_qdisc()
8889 u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0]; in ice_setup_tc_mqprio_qdisc()
8890 u64 min_tx_rate = vsi->mqprio_qopt.min_rate[0]; in ice_setup_tc_mqprio_qdisc()
8903 max_tx_rate, min_tx_rate, vsi->vsi_num); in ice_setup_tc_mqprio_qdisc()
8906 max_tx_rate, min_tx_rate, vsi->vsi_num); in ice_setup_tc_mqprio_qdisc()
8919 if (vsi->ch_rss_size) in ice_setup_tc_mqprio_qdisc()
8925 vsi->all_numtc = 0; in ice_setup_tc_mqprio_qdisc()
8926 vsi->all_enatc = 0; in ice_setup_tc_mqprio_qdisc()
8941 struct ice_pf *pf = np->vsi->back; in ice_setup_tc()
8954 return -EOPNOTSUPP; in ice_setup_tc()
8957 if (pf->adev) { in ice_setup_tc()
8958 mutex_lock(&pf->adev_mutex); in ice_setup_tc()
8959 device_lock(&pf->adev->dev); in ice_setup_tc()
8961 if (pf->adev->dev.driver) { in ice_setup_tc()
8963 err = -EBUSY; in ice_setup_tc()
8969 mutex_lock(&pf->tc_mutex); in ice_setup_tc()
8971 mutex_unlock(&pf->tc_mutex); in ice_setup_tc()
8975 device_unlock(&pf->adev->dev); in ice_setup_tc()
8976 mutex_unlock(&pf->adev_mutex); in ice_setup_tc()
8980 return -EOPNOTSUPP; in ice_setup_tc()
8982 return -EOPNOTSUPP; in ice_setup_tc()
8991 list_for_each_entry(cb_priv, &np->tc_indr_block_priv_list, list) { in ice_indr_block_priv_lookup()
8992 if (!cb_priv->netdev) in ice_indr_block_priv_lookup()
8994 if (cb_priv->netdev == netdev) in ice_indr_block_priv_lookup()
9005 struct ice_netdev_priv *np = priv->np; in ice_indr_setup_block_cb()
9009 return ice_setup_tc_cls_flower(np, priv->netdev, in ice_indr_setup_block_cb()
9013 return -EOPNOTSUPP; in ice_indr_setup_block_cb()
9028 vlan_dev_real_dev(netdev) == np->vsi->netdev)) in ice_indr_setup_tc_block()
9029 return -EOPNOTSUPP; in ice_indr_setup_tc_block()
9031 if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) in ice_indr_setup_tc_block()
9032 return -EOPNOTSUPP; in ice_indr_setup_tc_block()
9034 switch (f->command) { in ice_indr_setup_tc_block()
9038 return -EEXIST; in ice_indr_setup_tc_block()
9042 return -ENOMEM; in ice_indr_setup_tc_block()
9044 indr_priv->netdev = netdev; in ice_indr_setup_tc_block()
9045 indr_priv->np = np; in ice_indr_setup_tc_block()
9046 list_add(&indr_priv->list, &np->tc_indr_block_priv_list); in ice_indr_setup_tc_block()
9056 list_del(&indr_priv->list); in ice_indr_setup_tc_block()
9061 list_add_tail(&block_cb->driver_list, &ice_block_cb_list); in ice_indr_setup_tc_block()
9066 return -ENOENT; in ice_indr_setup_tc_block()
9068 block_cb = flow_block_cb_lookup(f->block, in ice_indr_setup_tc_block()
9072 return -ENOENT; in ice_indr_setup_tc_block()
9076 list_del(&block_cb->driver_list); in ice_indr_setup_tc_block()
9079 return -EOPNOTSUPP; in ice_indr_setup_tc_block()
9096 return -EOPNOTSUPP; in ice_indr_setup_tc_cb()
9101 * ice_open - Called when a network interface becomes active
9115 struct ice_pf *pf = np->vsi->back; in ice_open()
9117 if (ice_is_reset_in_progress(pf->state)) { in ice_open()
9119 return -EBUSY; in ice_open()
9126 * ice_open_internal - Called when a network interface becomes active
9137 struct ice_vsi *vsi = np->vsi; in ice_open_internal()
9138 struct ice_pf *pf = vsi->back; in ice_open_internal()
9142 if (test_bit(ICE_NEEDS_RESTART, pf->state)) { in ice_open_internal()
9144 return -EIO; in ice_open_internal()
9149 pi = vsi->port_info; in ice_open_internal()
9156 ice_check_link_cfg_err(pf, pi->phy.link_info.link_cfg_err); in ice_open_internal()
9159 if (pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE) { in ice_open_internal()
9160 clear_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_open_internal()
9161 if (!test_bit(ICE_PHY_INIT_COMPLETE, pf->state)) { in ice_open_internal()
9177 set_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_open_internal()
9184 vsi->vsi_num, vsi->vsw->sw_id); in ice_open_internal()
9193 * ice_stop - Disables a network interface
9196 * The stop entry point is called when an interface is de-activated by the OS,
9200 * Returns success only - not allowed to fail
9205 struct ice_vsi *vsi = np->vsi; in ice_stop()
9206 struct ice_pf *pf = vsi->back; in ice_stop()
9208 if (ice_is_reset_in_progress(pf->state)) { in ice_stop()
9210 return -EBUSY; in ice_stop()
9213 if (test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, vsi->back->flags)) { in ice_stop()
9217 if (link_err == -ENOMEDIUM) in ice_stop()
9218 netdev_info(vsi->netdev, "Skipping link reconfig - no media attached, VSI %d\n", in ice_stop()
9219 vsi->vsi_num); in ice_stop()
9221 netdev_err(vsi->netdev, "Failed to set physical link down, VSI %d error %d\n", in ice_stop()
9222 vsi->vsi_num, link_err); in ice_stop()
9225 return -EIO; in ice_stop()
9235 * ice_features_check - Validate encapsulated packet conforms to limits
9252 if (skb->ip_summed != CHECKSUM_PARTIAL) in ice_features_check()
9258 if (gso && (skb_shinfo(skb)->gso_size < ICE_TXD_CTX_MIN_MSS)) in ice_features_check()
9269 if (skb->encapsulation) { in ice_features_check()
9275 if (gso && (skb_shinfo(skb)->gso_type & in ice_features_check()
9277 len = skb_inner_network_header(skb) - in ice_features_check()