Lines Matching +full:precondition +full:- +full:timeout

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2018-2023, Intel Corporation. */
44 static int debug = -1;
56 * ice_hw_to_dev - Get device pointer from the hardware structure
67 return &pf->pdev->dev; in ice_hw_to_dev()
90 return dev && (dev->netdev_ops == &ice_netdev_ops || in netif_is_ice()
91 dev->netdev_ops == &ice_netdev_safe_mode_ops); in netif_is_ice()
95 * ice_get_tx_pending - returns number of Tx descriptors not processed
102 head = ring->next_to_clean; in ice_get_tx_pending()
103 tail = ring->next_to_use; in ice_get_tx_pending()
107 tail - head : (tail + ring->count - head); in ice_get_tx_pending()
112 * ice_check_for_hang_subtask - check for and recover hung queues
124 if (pf->vsi[v] && pf->vsi[v]->type == ICE_VSI_PF) { in ice_check_for_hang_subtask()
125 vsi = pf->vsi[v]; in ice_check_for_hang_subtask()
129 if (!vsi || test_bit(ICE_VSI_DOWN, vsi->state)) in ice_check_for_hang_subtask()
132 if (!(vsi->netdev && netif_carrier_ok(vsi->netdev))) in ice_check_for_hang_subtask()
135 hw = &vsi->back->hw; in ice_check_for_hang_subtask()
138 struct ice_tx_ring *tx_ring = vsi->tx_rings[i]; in ice_check_for_hang_subtask()
146 ring_stats = tx_ring->ring_stats; in ice_check_for_hang_subtask()
150 if (tx_ring->desc) { in ice_check_for_hang_subtask()
158 packets = ring_stats->stats.pkts & INT_MAX; in ice_check_for_hang_subtask()
159 if (ring_stats->tx_stats.prev_pkt == packets) { in ice_check_for_hang_subtask()
161 ice_trigger_sw_intr(hw, tx_ring->q_vector); in ice_check_for_hang_subtask()
169 ring_stats->tx_stats.prev_pkt = in ice_check_for_hang_subtask()
170 ice_get_tx_pending(tx_ring) ? packets : -1; in ice_check_for_hang_subtask()
176 * ice_init_mac_fltr - Set initial MAC filters
190 return -EINVAL; in ice_init_mac_fltr()
192 perm_addr = vsi->port_info->mac.perm_addr; in ice_init_mac_fltr()
197 * ice_add_mac_to_sync_list - creates list of MAC addresses to be synced
209 struct ice_vsi *vsi = np->vsi; in ice_add_mac_to_sync_list()
211 if (ice_fltr_add_mac_to_list(vsi, &vsi->tmp_sync_list, addr, in ice_add_mac_to_sync_list()
213 return -EINVAL; in ice_add_mac_to_sync_list()
219 * ice_add_mac_to_unsync_list - creates list of MAC addresses to be unsynced
231 struct ice_vsi *vsi = np->vsi; in ice_add_mac_to_unsync_list()
238 if (ether_addr_equal(addr, netdev->dev_addr)) in ice_add_mac_to_unsync_list()
241 if (ice_fltr_add_mac_to_list(vsi, &vsi->tmp_unsync_list, addr, in ice_add_mac_to_unsync_list()
243 return -EINVAL; in ice_add_mac_to_unsync_list()
249 * ice_vsi_fltr_changed - check if filter state changed
256 return test_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state) || in ice_vsi_fltr_changed()
257 test_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state); in ice_vsi_fltr_changed()
261 * ice_set_promisc - Enable promiscuous mode for a given PF
270 if (vsi->type != ICE_VSI_PF) in ice_set_promisc()
275 status = ice_fltr_set_vlan_vsi_promisc(&vsi->back->hw, vsi, in ice_set_promisc()
278 status = ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_set_promisc()
281 if (status && status != -EEXIST) in ice_set_promisc()
284 netdev_dbg(vsi->netdev, "set promisc filter bits for VSI %i: 0x%x\n", in ice_set_promisc()
285 vsi->vsi_num, promisc_m); in ice_set_promisc()
290 * ice_clear_promisc - Disable promiscuous mode for a given PF
299 if (vsi->type != ICE_VSI_PF) in ice_clear_promisc()
304 status = ice_fltr_clear_vlan_vsi_promisc(&vsi->back->hw, vsi, in ice_clear_promisc()
307 status = ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_clear_promisc()
311 netdev_dbg(vsi->netdev, "clear promisc filter bits for VSI %i: 0x%x\n", in ice_clear_promisc()
312 vsi->vsi_num, promisc_m); in ice_clear_promisc()
317 * ice_vsi_sync_fltr - Update the VSI filter list to the HW
325 struct device *dev = ice_pf_to_dev(vsi->back); in ice_vsi_sync_fltr()
326 struct net_device *netdev = vsi->netdev; in ice_vsi_sync_fltr()
328 struct ice_pf *pf = vsi->back; in ice_vsi_sync_fltr()
329 struct ice_hw *hw = &pf->hw; in ice_vsi_sync_fltr()
333 if (!vsi->netdev) in ice_vsi_sync_fltr()
334 return -EINVAL; in ice_vsi_sync_fltr()
336 while (test_and_set_bit(ICE_CFG_BUSY, vsi->state)) in ice_vsi_sync_fltr()
339 changed_flags = vsi->current_netdev_flags ^ vsi->netdev->flags; in ice_vsi_sync_fltr()
340 vsi->current_netdev_flags = vsi->netdev->flags; in ice_vsi_sync_fltr()
342 INIT_LIST_HEAD(&vsi->tmp_sync_list); in ice_vsi_sync_fltr()
343 INIT_LIST_HEAD(&vsi->tmp_unsync_list); in ice_vsi_sync_fltr()
346 clear_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state); in ice_vsi_sync_fltr()
347 clear_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state); in ice_vsi_sync_fltr()
360 err = ice_fltr_remove_mac_list(vsi, &vsi->tmp_unsync_list); in ice_vsi_sync_fltr()
361 ice_fltr_free_list(dev, &vsi->tmp_unsync_list); in ice_vsi_sync_fltr()
365 if (err == -ENOMEM) in ice_vsi_sync_fltr()
370 err = ice_fltr_add_mac_list(vsi, &vsi->tmp_sync_list); in ice_vsi_sync_fltr()
371 ice_fltr_free_list(dev, &vsi->tmp_sync_list); in ice_vsi_sync_fltr()
376 if (err && err != -EEXIST) { in ice_vsi_sync_fltr()
382 if (hw->adminq.sq_last_status == ICE_AQ_RC_ENOSPC && in ice_vsi_sync_fltr()
384 vsi->state)) { in ice_vsi_sync_fltr()
387 vsi->vsi_num); in ice_vsi_sync_fltr()
395 if (vsi->current_netdev_flags & IFF_ALLMULTI) { in ice_vsi_sync_fltr()
398 vsi->current_netdev_flags &= ~IFF_ALLMULTI; in ice_vsi_sync_fltr()
402 /* !(vsi->current_netdev_flags & IFF_ALLMULTI) */ in ice_vsi_sync_fltr()
405 vsi->current_netdev_flags |= IFF_ALLMULTI; in ice_vsi_sync_fltr()
412 test_bit(ICE_VSI_PROMISC_CHANGED, vsi->state)) { in ice_vsi_sync_fltr()
413 clear_bit(ICE_VSI_PROMISC_CHANGED, vsi->state); in ice_vsi_sync_fltr()
414 if (vsi->current_netdev_flags & IFF_PROMISC) { in ice_vsi_sync_fltr()
416 if (!ice_is_dflt_vsi_in_use(vsi->port_info)) { in ice_vsi_sync_fltr()
418 if (err && err != -EEXIST) { in ice_vsi_sync_fltr()
420 err, vsi->vsi_num); in ice_vsi_sync_fltr()
421 vsi->current_netdev_flags &= in ice_vsi_sync_fltr()
426 vlan_ops->dis_rx_filtering(vsi); in ice_vsi_sync_fltr()
444 err, vsi->vsi_num); in ice_vsi_sync_fltr()
445 vsi->current_netdev_flags |= in ice_vsi_sync_fltr()
449 if (vsi->netdev->features & in ice_vsi_sync_fltr()
451 vlan_ops->ena_rx_filtering(vsi); in ice_vsi_sync_fltr()
457 if (!(vsi->current_netdev_flags & IFF_ALLMULTI)) { in ice_vsi_sync_fltr()
462 err, vsi->vsi_num); in ice_vsi_sync_fltr()
470 set_bit(ICE_VSI_PROMISC_CHANGED, vsi->state); in ice_vsi_sync_fltr()
474 set_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state); in ice_vsi_sync_fltr()
475 set_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state); in ice_vsi_sync_fltr()
477 clear_bit(ICE_CFG_BUSY, vsi->state); in ice_vsi_sync_fltr()
482 * ice_sync_fltr_subtask - Sync the VSI filter list with HW
489 if (!pf || !(test_bit(ICE_FLAG_FLTR_SYNC, pf->flags))) in ice_sync_fltr_subtask()
492 clear_bit(ICE_FLAG_FLTR_SYNC, pf->flags); in ice_sync_fltr_subtask()
495 if (pf->vsi[v] && ice_vsi_fltr_changed(pf->vsi[v]) && in ice_sync_fltr_subtask()
496 ice_vsi_sync_fltr(pf->vsi[v])) { in ice_sync_fltr_subtask()
498 set_bit(ICE_FLAG_FLTR_SYNC, pf->flags); in ice_sync_fltr_subtask()
504 * ice_pf_dis_all_vsi - Pause all VSIs on a PF
514 if (pf->vsi[v]) in ice_pf_dis_all_vsi()
515 ice_dis_vsi(pf->vsi[v], locked); in ice_pf_dis_all_vsi()
518 pf->pf_agg_node[node].num_vsis = 0; in ice_pf_dis_all_vsi()
521 pf->vf_agg_node[node].num_vsis = 0; in ice_pf_dis_all_vsi()
525 * ice_prepare_for_reset - prep for reset
534 struct ice_hw *hw = &pf->hw; in ice_prepare_for_reset()
542 if (test_bit(ICE_PREPARED_FOR_RESET, pf->state)) in ice_prepare_for_reset()
545 synchronize_irq(pf->oicr_irq.virq); in ice_prepare_for_reset()
550 if (ice_check_sq_alive(hw, &hw->mailboxq)) in ice_prepare_for_reset()
554 mutex_lock(&pf->vfs.table_lock); in ice_prepare_for_reset()
557 mutex_unlock(&pf->vfs.table_lock); in ice_prepare_for_reset()
561 ice_eswitch_br_fdb_flush(pf->eswitch.br_offloads->bridge); in ice_prepare_for_reset()
573 vsi->orig_rss_size = 0; in ice_prepare_for_reset()
575 if (test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) { in ice_prepare_for_reset()
577 vsi->old_ena_tc = vsi->all_enatc; in ice_prepare_for_reset()
578 vsi->old_numtc = vsi->all_numtc; in ice_prepare_for_reset()
585 vsi->old_ena_tc = 0; in ice_prepare_for_reset()
586 vsi->all_enatc = 0; in ice_prepare_for_reset()
587 vsi->old_numtc = 0; in ice_prepare_for_reset()
588 vsi->all_numtc = 0; in ice_prepare_for_reset()
589 vsi->req_txq = 0; in ice_prepare_for_reset()
590 vsi->req_rxq = 0; in ice_prepare_for_reset()
591 clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags); in ice_prepare_for_reset()
592 memset(&vsi->mqprio_qopt, 0, sizeof(vsi->mqprio_qopt)); in ice_prepare_for_reset()
596 if (vsi->netdev) in ice_prepare_for_reset()
597 netif_device_detach(vsi->netdev); in ice_prepare_for_reset()
603 set_bit(ICE_VSI_REBUILD_PENDING, ice_get_main_vsi(pf)->state); in ice_prepare_for_reset()
606 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_prepare_for_reset()
612 if (hw->port_info) in ice_prepare_for_reset()
613 ice_sched_clear_port(hw->port_info); in ice_prepare_for_reset()
617 set_bit(ICE_PREPARED_FOR_RESET, pf->state); in ice_prepare_for_reset()
621 * ice_do_reset - Initiate one of many types of resets
628 struct ice_hw *hw = &pf->hw; in ice_do_reset()
632 if (pf->lag && pf->lag->bonded && reset_type == ICE_RESET_PFR) { in ice_do_reset()
642 set_bit(ICE_RESET_FAILED, pf->state); in ice_do_reset()
643 clear_bit(ICE_RESET_OICR_RECV, pf->state); in ice_do_reset()
644 clear_bit(ICE_PREPARED_FOR_RESET, pf->state); in ice_do_reset()
645 clear_bit(ICE_PFR_REQ, pf->state); in ice_do_reset()
646 clear_bit(ICE_CORER_REQ, pf->state); in ice_do_reset()
647 clear_bit(ICE_GLOBR_REQ, pf->state); in ice_do_reset()
648 wake_up(&pf->reset_wait_queue); in ice_do_reset()
653 * interrupt. So for PFR, rebuild after the reset and clear the reset- in ice_do_reset()
657 pf->pfr_count++; in ice_do_reset()
659 clear_bit(ICE_PREPARED_FOR_RESET, pf->state); in ice_do_reset()
660 clear_bit(ICE_PFR_REQ, pf->state); in ice_do_reset()
661 wake_up(&pf->reset_wait_queue); in ice_do_reset()
667 * ice_reset_subtask - Set up for resetting the device and driver
676 * of reset is pending and sets bits in pf->state indicating the reset in ice_reset_subtask()
678 * prepare for pending reset if not already (for PF software-initiated in ice_reset_subtask()
684 if (test_bit(ICE_RESET_OICR_RECV, pf->state)) { in ice_reset_subtask()
686 if (test_and_clear_bit(ICE_CORER_RECV, pf->state)) in ice_reset_subtask()
688 if (test_and_clear_bit(ICE_GLOBR_RECV, pf->state)) in ice_reset_subtask()
690 if (test_and_clear_bit(ICE_EMPR_RECV, pf->state)) in ice_reset_subtask()
698 if (ice_check_reset(&pf->hw)) { in ice_reset_subtask()
699 set_bit(ICE_RESET_FAILED, pf->state); in ice_reset_subtask()
702 pf->hw.reset_ongoing = false; in ice_reset_subtask()
707 clear_bit(ICE_RESET_OICR_RECV, pf->state); in ice_reset_subtask()
708 clear_bit(ICE_PREPARED_FOR_RESET, pf->state); in ice_reset_subtask()
709 clear_bit(ICE_PFR_REQ, pf->state); in ice_reset_subtask()
710 clear_bit(ICE_CORER_REQ, pf->state); in ice_reset_subtask()
711 clear_bit(ICE_GLOBR_REQ, pf->state); in ice_reset_subtask()
712 wake_up(&pf->reset_wait_queue); in ice_reset_subtask()
720 if (test_bit(ICE_PFR_REQ, pf->state)) { in ice_reset_subtask()
722 if (pf->lag && pf->lag->bonded) { in ice_reset_subtask()
727 if (test_bit(ICE_CORER_REQ, pf->state)) in ice_reset_subtask()
729 if (test_bit(ICE_GLOBR_REQ, pf->state)) in ice_reset_subtask()
736 if (!test_bit(ICE_DOWN, pf->state) && in ice_reset_subtask()
737 !test_bit(ICE_CFG_BUSY, pf->state)) { in ice_reset_subtask()
743 * ice_print_topo_conflict - print topology conflict message
748 switch (vsi->port_info->phy.link_info.topo_media_conflict) { in ice_print_topo_conflict()
754 …netdev_info(vsi->netdev, "Potential misconfiguration of the Ethernet port detected. If it was not … in ice_print_topo_conflict()
757 if (test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, vsi->back->flags)) in ice_print_topo_conflict()
758 …netdev_warn(vsi->netdev, "An unsupported module type was detected. Refer to the Intel(R) Ethernet … in ice_print_topo_conflict()
760 …netdev_err(vsi->netdev, "Rx/Tx is disabled on this device because an unsupported module type was d… in ice_print_topo_conflict()
768 * ice_print_link_msg - print link up or down message
786 if (vsi->current_isup == isup) in ice_print_link_msg()
789 vsi->current_isup = isup; in ice_print_link_msg()
792 netdev_info(vsi->netdev, "NIC Link is Down\n"); in ice_print_link_msg()
796 switch (vsi->port_info->phy.link_info.link_speed) { in ice_print_link_msg()
835 switch (vsi->port_info->fc.current_mode) { in ice_print_link_msg()
854 switch (vsi->port_info->phy.link_info.fec_info) { in ice_print_link_msg()
857 fec = "RS-FEC"; in ice_print_link_msg()
860 fec = "FC-FEC/BASE-R"; in ice_print_link_msg()
868 if (vsi->port_info->phy.link_info.an_info & ICE_AQ_AN_COMPLETED) in ice_print_link_msg()
881 status = ice_aq_get_phy_caps(vsi->port_info, false, in ice_print_link_msg()
884 netdev_info(vsi->netdev, "Get phy capability failed.\n"); in ice_print_link_msg()
888 if (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ || in ice_print_link_msg()
889 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ) in ice_print_link_msg()
890 fec_req = "RS-FEC"; in ice_print_link_msg()
891 else if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ || in ice_print_link_msg()
892 caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ) in ice_print_link_msg()
893 fec_req = "FC-FEC/BASE-R"; in ice_print_link_msg()
900 …netdev_info(vsi->netdev, "NIC Link is up %sbps Full Duplex, Requested FEC: %s, Negotiated FEC: %s,… in ice_print_link_msg()
906 * ice_vsi_link_event - update the VSI's netdev
915 if (test_bit(ICE_VSI_DOWN, vsi->state) || !vsi->netdev) in ice_vsi_link_event()
918 if (vsi->type == ICE_VSI_PF) { in ice_vsi_link_event()
919 if (link_up == netif_carrier_ok(vsi->netdev)) in ice_vsi_link_event()
923 netif_carrier_on(vsi->netdev); in ice_vsi_link_event()
924 netif_tx_wake_all_queues(vsi->netdev); in ice_vsi_link_event()
926 netif_carrier_off(vsi->netdev); in ice_vsi_link_event()
927 netif_tx_stop_all_queues(vsi->netdev); in ice_vsi_link_event()
933 * ice_set_dflt_mib - send a default config MIB to the FW
949 struct ice_hw *hw = &pf->hw; in ice_set_dflt_mib()
964 tlv->typelen = htons(typelen); in ice_set_dflt_mib()
967 tlv->ouisubtype = htonl(ouisubtype); in ice_set_dflt_mib()
969 buf = tlv->tlvinfo; in ice_set_dflt_mib()
972 /* ETS CFG all UPs map to TC 0. Next 4 (1 - 4) Octets = 0. in ice_set_dflt_mib()
973 * Octets 5 - 12 are BW values, set octet 5 to 100% BW. in ice_set_dflt_mib()
974 * Octets 13 - 20 are TSA values - leave as zeros in ice_set_dflt_mib()
980 ((char *)tlv + sizeof(tlv->typelen) + len); in ice_set_dflt_mib()
983 buf = tlv->tlvinfo; in ice_set_dflt_mib()
984 tlv->typelen = htons(typelen); in ice_set_dflt_mib()
988 tlv->ouisubtype = htonl(ouisubtype); in ice_set_dflt_mib()
991 * Octets 1 - 4 map UP to TC - all UPs map to zero in ice_set_dflt_mib()
992 * Octets 5 - 12 are BW values - set TC 0 to 100%. in ice_set_dflt_mib()
993 * Octets 13 - 20 are TSA value - leave as zeros in ice_set_dflt_mib()
998 ((char *)tlv + sizeof(tlv->typelen) + len); in ice_set_dflt_mib()
1003 tlv->typelen = htons(typelen); in ice_set_dflt_mib()
1007 tlv->ouisubtype = htonl(ouisubtype); in ice_set_dflt_mib()
1009 /* Octet 1 left as all zeros - PFC disabled */ in ice_set_dflt_mib()
1021 * ice_check_phy_fw_load - check if PHY FW load failed
1030 clear_bit(ICE_FLAG_PHY_FW_LOAD_FAILED, pf->flags); in ice_check_phy_fw_load()
1034 if (test_bit(ICE_FLAG_PHY_FW_LOAD_FAILED, pf->flags)) in ice_check_phy_fw_load()
1039 set_bit(ICE_FLAG_PHY_FW_LOAD_FAILED, pf->flags); in ice_check_phy_fw_load()
1056 clear_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags); in ice_check_module_power()
1063 if (test_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags)) in ice_check_module_power()
1068 set_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags); in ice_check_module_power()
1071 set_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags); in ice_check_module_power()
1076 * ice_check_link_cfg_err - check if link configuration failed
1090 * ice_link_event - process the link event
1109 phy_info = &pi->phy; in ice_link_event()
1110 phy_info->link_info_old = phy_info->link_info; in ice_link_event()
1112 old_link = !!(phy_info->link_info_old.link_info & ICE_AQ_LINK_UP); in ice_link_event()
1113 old_link_speed = phy_info->link_info_old.link_speed; in ice_link_event()
1115 /* update the link info structures and re-enable link events, in ice_link_event()
1121 pi->lport, status, in ice_link_event()
1122 ice_aq_str(pi->hw->adminq.sq_last_status)); in ice_link_event()
1124 ice_check_link_cfg_err(pf, pi->phy.link_info.link_cfg_err); in ice_link_event()
1129 if (phy_info->link_info.link_info & ICE_AQ_LINK_UP) in ice_link_event()
1133 if (!vsi || !vsi->port_info) in ice_link_event()
1134 return -EINVAL; in ice_link_event()
1137 if (!test_bit(ICE_FLAG_NO_MEDIA, pf->flags) && in ice_link_event()
1138 !(pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) { in ice_link_event()
1139 set_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_link_event()
1147 ice_ptp_link_change(pf, pf->hw.pf_id, link_up); in ice_link_event()
1150 if (test_bit(ICE_FLAG_DCB_ENA, pf->flags)) in ice_link_event()
1165 * ice_watchdog_subtask - periodic tasks not using event driven scheduling
1173 if (test_bit(ICE_DOWN, pf->state) || in ice_watchdog_subtask()
1174 test_bit(ICE_CFG_BUSY, pf->state)) in ice_watchdog_subtask()
1179 pf->serv_tmr_prev + pf->serv_tmr_period)) in ice_watchdog_subtask()
1182 pf->serv_tmr_prev = jiffies; in ice_watchdog_subtask()
1189 if (pf->vsi[i] && pf->vsi[i]->netdev) in ice_watchdog_subtask()
1190 ice_update_vsi_stats(pf->vsi[i]); in ice_watchdog_subtask()
1194 * ice_init_link_events - enable/initialize link events
1197 * Returns -EIO on failure, 0 on success
1207 if (ice_aq_set_event_mask(pi->hw, pi->lport, mask, NULL)) { in ice_init_link_events()
1208 dev_dbg(ice_hw_to_dev(pi->hw), "Failed to set link event mask 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()
1214 dev_dbg(ice_hw_to_dev(pi->hw), "Failed to enable link events for port %d\n", in ice_init_link_events()
1215 pi->lport); in ice_init_link_events()
1216 return -EIO; in ice_init_link_events()
1223 * ice_handle_link_event - handle link event via ARQ
1234 link_data = (struct ice_aqc_get_link_status_data *)event->msg_buf; in ice_handle_link_event()
1235 port_info = pf->hw.port_info; in ice_handle_link_event()
1237 return -EINVAL; in ice_handle_link_event()
1240 !!(link_data->link_info & ICE_AQ_LINK_UP), in ice_handle_link_event()
1241 le16_to_cpu(link_data->link_speed)); in ice_handle_link_event()
1250 * ice_get_fwlog_data - copy the FW log data from ARQ event
1258 struct ice_hw *hw = &pf->hw; in ice_get_fwlog_data()
1260 fwlog = &hw->fwlog_ring.rings[hw->fwlog_ring.tail]; in ice_get_fwlog_data()
1262 memset(fwlog->data, 0, PAGE_SIZE); in ice_get_fwlog_data()
1263 fwlog->data_size = le16_to_cpu(event->desc.datalen); in ice_get_fwlog_data()
1265 memcpy(fwlog->data, event->msg_buf, fwlog->data_size); in ice_get_fwlog_data()
1266 ice_fwlog_ring_increment(&hw->fwlog_ring.tail, hw->fwlog_ring.size); in ice_get_fwlog_data()
1268 if (ice_fwlog_ring_full(&hw->fwlog_ring)) { in ice_get_fwlog_data()
1270 ice_fwlog_ring_increment(&hw->fwlog_ring.head, in ice_get_fwlog_data()
1271 hw->fwlog_ring.size); in ice_get_fwlog_data()
1276 * ice_aq_prep_for_event - Prepare to wait for an AdminQ event from firmware
1287 * To obtain only the descriptor contents, pass an task->event with null
1289 * task->event.msg_buf with enough space ahead of time.
1294 INIT_HLIST_NODE(&task->entry); in ice_aq_prep_for_event()
1295 task->opcode = opcode; in ice_aq_prep_for_event()
1296 task->state = ICE_AQ_TASK_WAITING; in ice_aq_prep_for_event()
1298 spin_lock_bh(&pf->aq_wait_lock); in ice_aq_prep_for_event()
1299 hlist_add_head(&task->entry, &pf->aq_wait_list); in ice_aq_prep_for_event()
1300 spin_unlock_bh(&pf->aq_wait_lock); in ice_aq_prep_for_event()
1304 * ice_aq_wait_for_event - Wait for an AdminQ event from firmware
1307 * @timeout: how long to wait, in jiffies
1311 * until the given timeout is reached.
1316 unsigned long timeout) in ice_aq_wait_for_event() argument
1318 enum ice_aq_task_state *state = &task->state; in ice_aq_wait_for_event()
1324 ret = wait_event_interruptible_timeout(pf->aq_wait_queue, in ice_aq_wait_for_event()
1326 timeout); in ice_aq_wait_for_event()
1330 err = -EINVAL; in ice_aq_wait_for_event()
1333 err = ret < 0 ? ret : -ETIMEDOUT; in ice_aq_wait_for_event()
1336 err = ret < 0 ? ret : -ECANCELED; in ice_aq_wait_for_event()
1343 err = -EINVAL; in ice_aq_wait_for_event()
1348 jiffies_to_msecs(jiffies - start), in ice_aq_wait_for_event()
1349 jiffies_to_msecs(timeout), in ice_aq_wait_for_event()
1350 task->opcode); in ice_aq_wait_for_event()
1352 spin_lock_bh(&pf->aq_wait_lock); in ice_aq_wait_for_event()
1353 hlist_del(&task->entry); in ice_aq_wait_for_event()
1354 spin_unlock_bh(&pf->aq_wait_lock); in ice_aq_wait_for_event()
1360 * ice_aq_check_events - Check if any thread is waiting for an AdminQ event
1371 * Note that event->msg_buf will only be duplicated if the event has a buffer
1384 spin_lock_bh(&pf->aq_wait_lock); in ice_aq_check_events()
1385 hlist_for_each_entry(task, &pf->aq_wait_list, entry) { in ice_aq_check_events()
1386 if (task->state != ICE_AQ_TASK_WAITING) in ice_aq_check_events()
1388 if (task->opcode != opcode) in ice_aq_check_events()
1391 task_ev = &task->event; in ice_aq_check_events()
1392 memcpy(&task_ev->desc, &event->desc, sizeof(event->desc)); in ice_aq_check_events()
1393 task_ev->msg_len = event->msg_len; in ice_aq_check_events()
1396 if (task_ev->msg_buf && task_ev->buf_len >= event->buf_len) { in ice_aq_check_events()
1397 memcpy(task_ev->msg_buf, event->msg_buf, in ice_aq_check_events()
1398 event->buf_len); in ice_aq_check_events()
1399 task_ev->buf_len = event->buf_len; in ice_aq_check_events()
1402 task->state = ICE_AQ_TASK_COMPLETE; in ice_aq_check_events()
1405 spin_unlock_bh(&pf->aq_wait_lock); in ice_aq_check_events()
1408 wake_up(&pf->aq_wait_queue); in ice_aq_check_events()
1412 * ice_aq_cancel_waiting_tasks - Immediately cancel all waiting tasks
1416 * This will then cause ice_aq_wait_for_event to exit with -ECANCELED.
1422 spin_lock_bh(&pf->aq_wait_lock); in ice_aq_cancel_waiting_tasks()
1423 hlist_for_each_entry(task, &pf->aq_wait_list, entry) in ice_aq_cancel_waiting_tasks()
1424 task->state = ICE_AQ_TASK_CANCELED; in ice_aq_cancel_waiting_tasks()
1425 spin_unlock_bh(&pf->aq_wait_lock); in ice_aq_cancel_waiting_tasks()
1427 wake_up(&pf->aq_wait_queue); in ice_aq_cancel_waiting_tasks()
1433 * __ice_clean_ctrlq - helper function to clean controlq rings
1441 struct ice_hw *hw = &pf->hw; in __ice_clean_ctrlq()
1448 if (test_bit(ICE_RESET_FAILED, pf->state)) in __ice_clean_ctrlq()
1453 cq = &hw->adminq; in __ice_clean_ctrlq()
1457 cq = &hw->sbq; in __ice_clean_ctrlq()
1461 cq = &hw->mailboxq; in __ice_clean_ctrlq()
1466 hw->mbx_snapshot.mbx_buf.state = ICE_MAL_VF_DETECT_STATE_NEW_SNAPSHOT; in __ice_clean_ctrlq()
1473 /* check for error indications - PF_xx_AxQLEN register layout for in __ice_clean_ctrlq()
1476 val = rd32(hw, cq->rq.len); in __ice_clean_ctrlq()
1493 wr32(hw, cq->rq.len, val); in __ice_clean_ctrlq()
1496 val = rd32(hw, cq->sq.len); in __ice_clean_ctrlq()
1513 wr32(hw, cq->sq.len, val); in __ice_clean_ctrlq()
1516 event.buf_len = cq->rq_buf_size; in __ice_clean_ctrlq()
1527 if (ret == -EALREADY) in __ice_clean_ctrlq()
1551 data.max_num_msgs_mbx = hw->mailboxq.num_rq_entries; in __ice_clean_ctrlq()
1575 * ice_ctrlq_pending - check if there is a difference between ntc and ntu
1585 ntu = (u16)(rd32(hw, cq->rq.head) & cq->rq.head_mask); in ice_ctrlq_pending()
1586 return cq->rq.next_to_clean != ntu; in ice_ctrlq_pending()
1590 * ice_clean_adminq_subtask - clean the AdminQ rings
1595 struct ice_hw *hw = &pf->hw; in ice_clean_adminq_subtask()
1597 if (!test_bit(ICE_ADMINQ_EVENT_PENDING, pf->state)) in ice_clean_adminq_subtask()
1603 clear_bit(ICE_ADMINQ_EVENT_PENDING, pf->state); in ice_clean_adminq_subtask()
1610 if (ice_ctrlq_pending(hw, &hw->adminq)) in ice_clean_adminq_subtask()
1617 * ice_clean_mailboxq_subtask - clean the MailboxQ rings
1622 struct ice_hw *hw = &pf->hw; in ice_clean_mailboxq_subtask()
1624 if (!test_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state)) in ice_clean_mailboxq_subtask()
1630 clear_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state); in ice_clean_mailboxq_subtask()
1632 if (ice_ctrlq_pending(hw, &hw->mailboxq)) in ice_clean_mailboxq_subtask()
1639 * ice_clean_sbq_subtask - clean the Sideband Queue rings
1644 struct ice_hw *hw = &pf->hw; in ice_clean_sbq_subtask()
1650 clear_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state); in ice_clean_sbq_subtask()
1654 if (!test_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state)) in ice_clean_sbq_subtask()
1660 clear_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state); in ice_clean_sbq_subtask()
1662 if (ice_ctrlq_pending(hw, &hw->sbq)) in ice_clean_sbq_subtask()
1669 * ice_service_task_schedule - schedule the service task to wake up
1676 if (!test_bit(ICE_SERVICE_DIS, pf->state) && in ice_service_task_schedule()
1677 !test_and_set_bit(ICE_SERVICE_SCHED, pf->state) && in ice_service_task_schedule()
1678 !test_bit(ICE_NEEDS_RESTART, pf->state)) in ice_service_task_schedule()
1679 queue_work(ice_wq, &pf->serv_task); in ice_service_task_schedule()
1683 * ice_service_task_complete - finish up the service task
1688 WARN_ON(!test_bit(ICE_SERVICE_SCHED, pf->state)); in ice_service_task_complete()
1690 /* force memory (pf->state) to sync before next service task */ in ice_service_task_complete()
1692 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_service_task_complete()
1696 * ice_service_task_stop - stop service task and cancel works
1706 ret = test_and_set_bit(ICE_SERVICE_DIS, pf->state); in ice_service_task_stop()
1708 if (pf->serv_tmr.function) in ice_service_task_stop()
1709 del_timer_sync(&pf->serv_tmr); in ice_service_task_stop()
1710 if (pf->serv_task.func) in ice_service_task_stop()
1711 cancel_work_sync(&pf->serv_task); in ice_service_task_stop()
1713 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_service_task_stop()
1718 * ice_service_task_restart - restart service task and schedule works
1725 clear_bit(ICE_SERVICE_DIS, pf->state); in ice_service_task_restart()
1730 * ice_service_timer - timer callback to schedule service task
1737 mod_timer(&pf->serv_tmr, round_jiffies(pf->serv_tmr_period + jiffies)); in ice_service_timer()
1742 * ice_mdd_maybe_reset_vf - reset VF after MDD event
1750 * mdd-auto-reset-vf.
1757 if (!test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf->flags)) in ice_mdd_maybe_reset_vf()
1769 dev_info(dev, "PF-to-VF reset on PF %d VF %d due to MDD event\n", in ice_mdd_maybe_reset_vf()
1770 pf->hw.pf_id, vf->vf_id); in ice_mdd_maybe_reset_vf()
1775 * ice_handle_mdd_event - handle malicious driver detect event
1782 * private flag mdd-auto-reset-vf.
1787 struct ice_hw *hw = &pf->hw; in ice_handle_mdd_event()
1792 if (!test_and_clear_bit(ICE_MDD_EVENT_PENDING, pf->state)) { in ice_handle_mdd_event()
1865 mutex_lock(&pf->vfs.table_lock); in ice_handle_mdd_event()
1869 reg = rd32(hw, VP_MDET_TX_PQM(vf->vf_id)); in ice_handle_mdd_event()
1871 wr32(hw, VP_MDET_TX_PQM(vf->vf_id), 0xFFFF); in ice_handle_mdd_event()
1872 vf->mdd_tx_events.count++; in ice_handle_mdd_event()
1873 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1876 vf->vf_id); in ice_handle_mdd_event()
1881 reg = rd32(hw, VP_MDET_TX_TCLAN(vf->vf_id)); in ice_handle_mdd_event()
1883 wr32(hw, VP_MDET_TX_TCLAN(vf->vf_id), 0xFFFF); in ice_handle_mdd_event()
1884 vf->mdd_tx_events.count++; in ice_handle_mdd_event()
1885 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1888 vf->vf_id); in ice_handle_mdd_event()
1893 reg = rd32(hw, VP_MDET_TX_TDPU(vf->vf_id)); in ice_handle_mdd_event()
1895 wr32(hw, VP_MDET_TX_TDPU(vf->vf_id), 0xFFFF); in ice_handle_mdd_event()
1896 vf->mdd_tx_events.count++; in ice_handle_mdd_event()
1897 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1900 vf->vf_id); in ice_handle_mdd_event()
1905 reg = rd32(hw, VP_MDET_RX(vf->vf_id)); in ice_handle_mdd_event()
1907 wr32(hw, VP_MDET_RX(vf->vf_id), 0xFFFF); in ice_handle_mdd_event()
1908 vf->mdd_rx_events.count++; in ice_handle_mdd_event()
1909 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1912 vf->vf_id); in ice_handle_mdd_event()
1921 mutex_unlock(&pf->vfs.table_lock); in ice_handle_mdd_event()
1927 * ice_force_phys_link_state - Force the physical link state
1946 if (!vsi || !vsi->port_info || !vsi->back) in ice_force_phys_link_state()
1947 return -EINVAL; in ice_force_phys_link_state()
1948 if (vsi->type != ICE_VSI_PF) in ice_force_phys_link_state()
1951 dev = ice_pf_to_dev(vsi->back); in ice_force_phys_link_state()
1953 pi = vsi->port_info; in ice_force_phys_link_state()
1957 return -ENOMEM; in ice_force_phys_link_state()
1963 vsi->vsi_num, retcode); in ice_force_phys_link_state()
1964 retcode = -EIO; in ice_force_phys_link_state()
1969 if (link_up == !!(pcaps->caps & ICE_AQC_PHY_EN_LINK) && in ice_force_phys_link_state()
1970 link_up == !!(pi->phy.link_info.link_info & ICE_AQ_LINK_UP)) in ice_force_phys_link_state()
1977 cfg = kmemdup(&pi->phy.curr_user_phy_cfg, sizeof(*cfg), GFP_KERNEL); in ice_force_phys_link_state()
1979 retcode = -ENOMEM; in ice_force_phys_link_state()
1983 cfg->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT; in ice_force_phys_link_state()
1985 cfg->caps |= ICE_AQ_PHY_ENA_LINK; in ice_force_phys_link_state()
1987 cfg->caps &= ~ICE_AQ_PHY_ENA_LINK; in ice_force_phys_link_state()
1989 retcode = ice_aq_set_phy_cfg(&vsi->back->hw, pi, cfg, NULL); in ice_force_phys_link_state()
1992 vsi->vsi_num, retcode); in ice_force_phys_link_state()
1993 retcode = -EIO; in ice_force_phys_link_state()
2003 * ice_init_nvm_phy_type - Initialize the NVM PHY type
2011 struct ice_pf *pf = pi->hw->back; in ice_init_nvm_phy_type()
2016 return -ENOMEM; in ice_init_nvm_phy_type()
2026 pf->nvm_phy_type_hi = pcaps->phy_type_high; in ice_init_nvm_phy_type()
2027 pf->nvm_phy_type_lo = pcaps->phy_type_low; in ice_init_nvm_phy_type()
2035 * ice_init_link_dflt_override - Initialize link default override
2043 struct ice_pf *pf = pi->hw->back; in ice_init_link_dflt_override()
2045 ldo = &pf->link_dflt_override; in ice_init_link_dflt_override()
2049 if (!(ldo->options & ICE_LINK_OVERRIDE_PORT_DIS)) in ice_init_link_dflt_override()
2052 /* Enable Total Port Shutdown (override/replace link-down-on-close in ice_init_link_dflt_override()
2055 set_bit(ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags); in ice_init_link_dflt_override()
2056 set_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags); in ice_init_link_dflt_override()
2060 * ice_init_phy_cfg_dflt_override - Initialize PHY cfg default override settings
2080 struct ice_phy_info *phy = &pi->phy; in ice_init_phy_cfg_dflt_override()
2081 struct ice_pf *pf = pi->hw->back; in ice_init_phy_cfg_dflt_override()
2083 ldo = &pf->link_dflt_override; in ice_init_phy_cfg_dflt_override()
2088 cfg = &phy->curr_user_phy_cfg; in ice_init_phy_cfg_dflt_override()
2090 if (ldo->phy_type_low || ldo->phy_type_high) { in ice_init_phy_cfg_dflt_override()
2091 cfg->phy_type_low = pf->nvm_phy_type_lo & in ice_init_phy_cfg_dflt_override()
2092 cpu_to_le64(ldo->phy_type_low); in ice_init_phy_cfg_dflt_override()
2093 cfg->phy_type_high = pf->nvm_phy_type_hi & in ice_init_phy_cfg_dflt_override()
2094 cpu_to_le64(ldo->phy_type_high); in ice_init_phy_cfg_dflt_override()
2096 cfg->link_fec_opt = ldo->fec_options; in ice_init_phy_cfg_dflt_override()
2097 phy->curr_user_fec_req = ICE_FEC_AUTO; in ice_init_phy_cfg_dflt_override()
2099 set_bit(ICE_LINK_DEFAULT_OVERRIDE_PENDING, pf->state); in ice_init_phy_cfg_dflt_override()
2103 * ice_init_phy_user_cfg - Initialize the PHY user configuration
2119 struct ice_phy_info *phy = &pi->phy; in ice_init_phy_user_cfg()
2120 struct ice_pf *pf = pi->hw->back; in ice_init_phy_user_cfg()
2123 if (!(phy->link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) in ice_init_phy_user_cfg()
2124 return -EIO; in ice_init_phy_user_cfg()
2128 return -ENOMEM; in ice_init_phy_user_cfg()
2130 if (ice_fw_supports_report_dflt_cfg(pi->hw)) in ice_init_phy_user_cfg()
2141 ice_copy_phy_caps_to_cfg(pi, pcaps, &pi->phy.curr_user_phy_cfg); in ice_init_phy_user_cfg()
2144 if (ice_fw_supports_link_override(pi->hw) && in ice_init_phy_user_cfg()
2145 !(pcaps->module_compliance_enforcement & in ice_init_phy_user_cfg()
2147 set_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags); in ice_init_phy_user_cfg()
2153 if (!ice_fw_supports_report_dflt_cfg(pi->hw) && in ice_init_phy_user_cfg()
2154 (pf->link_dflt_override.options & ICE_LINK_OVERRIDE_EN)) { in ice_init_phy_user_cfg()
2163 phy->curr_user_fec_req = ice_caps_to_fec_mode(pcaps->caps, in ice_init_phy_user_cfg()
2164 pcaps->link_fec_options); in ice_init_phy_user_cfg()
2165 phy->curr_user_fc_req = ice_caps_to_fc_mode(pcaps->caps); in ice_init_phy_user_cfg()
2168 phy->curr_user_speed_req = ICE_AQ_LINK_SPEED_M; in ice_init_phy_user_cfg()
2169 set_bit(ICE_PHY_INIT_COMPLETE, pf->state); in ice_init_phy_user_cfg()
2176 * ice_configure_phy - configure PHY
2185 struct device *dev = ice_pf_to_dev(vsi->back); in ice_configure_phy()
2186 struct ice_port_info *pi = vsi->port_info; in ice_configure_phy()
2189 struct ice_phy_info *phy = &pi->phy; in ice_configure_phy()
2190 struct ice_pf *pf = vsi->back; in ice_configure_phy()
2194 if (!(phy->link_info.link_info & ICE_AQ_MEDIA_AVAILABLE)) in ice_configure_phy()
2195 return -ENOMEDIUM; in ice_configure_phy()
2199 if (!test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags) && in ice_configure_phy()
2200 phy->link_info.topo_media_conflict == ICE_AQ_LINK_TOPO_UNSUPP_MEDIA) in ice_configure_phy()
2201 return -EPERM; in ice_configure_phy()
2203 if (test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags)) in ice_configure_phy()
2208 return -ENOMEM; in ice_configure_phy()
2215 vsi->vsi_num, err); in ice_configure_phy()
2222 if (pcaps->caps & ICE_AQC_PHY_EN_LINK && in ice_configure_phy()
2223 ice_phy_caps_equals_cfg(pcaps, &phy->curr_user_phy_cfg)) in ice_configure_phy()
2228 if (ice_fw_supports_report_dflt_cfg(pi->hw)) in ice_configure_phy()
2236 vsi->vsi_num, err); in ice_configure_phy()
2242 err = -ENOMEM; in ice_configure_phy()
2248 /* Speed - If default override pending, use curr_user_phy_cfg set in in ice_configure_phy()
2252 vsi->back->state)) { in ice_configure_phy()
2253 cfg->phy_type_low = phy->curr_user_phy_cfg.phy_type_low; in ice_configure_phy()
2254 cfg->phy_type_high = phy->curr_user_phy_cfg.phy_type_high; in ice_configure_phy()
2259 pi->phy.curr_user_speed_req); in ice_configure_phy()
2260 cfg->phy_type_low = pcaps->phy_type_low & cpu_to_le64(phy_low); in ice_configure_phy()
2261 cfg->phy_type_high = pcaps->phy_type_high & in ice_configure_phy()
2266 if (!cfg->phy_type_low && !cfg->phy_type_high) { in ice_configure_phy()
2267 cfg->phy_type_low = pcaps->phy_type_low; in ice_configure_phy()
2268 cfg->phy_type_high = pcaps->phy_type_high; in ice_configure_phy()
2272 ice_cfg_phy_fec(pi, cfg, phy->curr_user_fec_req); in ice_configure_phy()
2275 if (cfg->link_fec_opt != in ice_configure_phy()
2276 (cfg->link_fec_opt & pcaps->link_fec_options)) { in ice_configure_phy()
2277 cfg->caps |= pcaps->caps & ICE_AQC_PHY_EN_AUTO_FEC; in ice_configure_phy()
2278 cfg->link_fec_opt = pcaps->link_fec_options; in ice_configure_phy()
2281 /* Flow Control - always supported; no need to check against in ice_configure_phy()
2284 ice_cfg_phy_fc(pi, cfg, phy->curr_user_fc_req); in ice_configure_phy()
2287 cfg->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT | ICE_AQ_PHY_ENA_LINK; in ice_configure_phy()
2289 err = ice_aq_set_phy_cfg(&pf->hw, pi, cfg, NULL); in ice_configure_phy()
2292 vsi->vsi_num, err); in ice_configure_phy()
2301 * ice_check_media_subtask - Check for media
2314 if (!test_bit(ICE_FLAG_NO_MEDIA, pf->flags)) in ice_check_media_subtask()
2322 pi = vsi->port_info; in ice_check_media_subtask()
2327 ice_check_link_cfg_err(pf, pi->phy.link_info.link_cfg_err); in ice_check_media_subtask()
2329 if (pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE) { in ice_check_media_subtask()
2330 if (!test_bit(ICE_PHY_INIT_COMPLETE, pf->state)) in ice_check_media_subtask()
2336 if (test_bit(ICE_VSI_DOWN, vsi->state) && in ice_check_media_subtask()
2337 test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, vsi->back->flags)) in ice_check_media_subtask()
2342 clear_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_check_media_subtask()
2351 * ice_service_task - manage and run subtasks
2365 if (ice_is_reset_in_progress(pf->state) || in ice_service_task()
2366 test_bit(ICE_SUSPENDED, pf->state) || in ice_service_task()
2367 test_bit(ICE_NEEDS_RESTART, pf->state)) { in ice_service_task()
2372 if (test_and_clear_bit(ICE_AUX_ERR_PENDING, pf->state)) { in ice_service_task()
2377 set_bit(IIDC_EVENT_CRIT_ERR, event->type); in ice_service_task()
2379 swap(event->reg, pf->oicr_err_reg); in ice_service_task()
2388 if (test_and_clear_bit(ICE_FLAG_UNPLUG_AUX_DEV, pf->flags)) in ice_service_task()
2392 if (test_and_clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags)) in ice_service_task()
2395 if (test_and_clear_bit(ICE_FLAG_MTU_CHANGED, pf->flags)) { in ice_service_task()
2400 set_bit(IIDC_EVENT_AFTER_MTU_CHANGE, event->type); in ice_service_task()
2431 if (time_after(jiffies, (start_time + pf->serv_tmr_period)) || in ice_service_task()
2432 test_bit(ICE_MDD_EVENT_PENDING, pf->state) || in ice_service_task()
2433 test_bit(ICE_VFLR_EVENT_PENDING, pf->state) || in ice_service_task()
2434 test_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state) || in ice_service_task()
2435 test_bit(ICE_FD_VF_FLUSH_CTX, pf->state) || in ice_service_task()
2436 test_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state) || in ice_service_task()
2437 test_bit(ICE_ADMINQ_EVENT_PENDING, pf->state)) in ice_service_task()
2438 mod_timer(&pf->serv_tmr, jiffies); in ice_service_task()
2442 * ice_set_ctrlq_len - helper function to set controlq length
2447 hw->adminq.num_rq_entries = ICE_AQ_LEN; in ice_set_ctrlq_len()
2448 hw->adminq.num_sq_entries = ICE_AQ_LEN; in ice_set_ctrlq_len()
2449 hw->adminq.rq_buf_size = ICE_AQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2450 hw->adminq.sq_buf_size = ICE_AQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2451 hw->mailboxq.num_rq_entries = PF_MBX_ARQLEN_ARQLEN_M; in ice_set_ctrlq_len()
2452 hw->mailboxq.num_sq_entries = ICE_MBXSQ_LEN; in ice_set_ctrlq_len()
2453 hw->mailboxq.rq_buf_size = ICE_MBXQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2454 hw->mailboxq.sq_buf_size = ICE_MBXQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2455 hw->sbq.num_rq_entries = ICE_SBQ_LEN; in ice_set_ctrlq_len()
2456 hw->sbq.num_sq_entries = ICE_SBQ_LEN; in ice_set_ctrlq_len()
2457 hw->sbq.rq_buf_size = ICE_SBQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2458 hw->sbq.sq_buf_size = ICE_SBQ_MAX_BUF_LEN; in ice_set_ctrlq_len()
2462 * ice_schedule_reset - schedule a reset
2471 if (test_bit(ICE_RESET_FAILED, pf->state)) { in ice_schedule_reset()
2473 return -EIO; in ice_schedule_reset()
2476 if (ice_is_reset_in_progress(pf->state)) { in ice_schedule_reset()
2478 return -EBUSY; in ice_schedule_reset()
2483 set_bit(ICE_PFR_REQ, pf->state); in ice_schedule_reset()
2486 set_bit(ICE_CORER_REQ, pf->state); in ice_schedule_reset()
2489 set_bit(ICE_GLOBR_REQ, pf->state); in ice_schedule_reset()
2492 return -EINVAL; in ice_schedule_reset()
2500 * ice_irq_affinity_notify - Callback for affinity changes
2514 cpumask_copy(&q_vector->affinity_mask, mask); in ice_irq_affinity_notify()
2518 * ice_irq_affinity_release - Callback for affinity notifier release
2528 * ice_vsi_ena_irq - Enable IRQ for the given VSI
2533 struct ice_hw *hw = &vsi->back->hw; in ice_vsi_ena_irq()
2537 ice_irq_dynamic_ena(hw, vsi, vsi->q_vectors[i]); in ice_vsi_ena_irq()
2544 * ice_vsi_req_irq_msix - get MSI-X vectors from the OS for the VSI
2550 int q_vectors = vsi->num_q_vectors; in ice_vsi_req_irq_msix()
2551 struct ice_pf *pf = vsi->back; in ice_vsi_req_irq_msix()
2560 struct ice_q_vector *q_vector = vsi->q_vectors[vector]; in ice_vsi_req_irq_msix()
2562 irq_num = q_vector->irq.virq; in ice_vsi_req_irq_msix()
2564 if (q_vector->tx.tx_ring && q_vector->rx.rx_ring) { in ice_vsi_req_irq_msix()
2565 snprintf(q_vector->name, sizeof(q_vector->name) - 1, in ice_vsi_req_irq_msix()
2566 "%s-%s-%d", basename, "TxRx", rx_int_idx++); in ice_vsi_req_irq_msix()
2568 } else if (q_vector->rx.rx_ring) { in ice_vsi_req_irq_msix()
2569 snprintf(q_vector->name, sizeof(q_vector->name) - 1, in ice_vsi_req_irq_msix()
2570 "%s-%s-%d", basename, "rx", rx_int_idx++); in ice_vsi_req_irq_msix()
2571 } else if (q_vector->tx.tx_ring) { in ice_vsi_req_irq_msix()
2572 snprintf(q_vector->name, sizeof(q_vector->name) - 1, in ice_vsi_req_irq_msix()
2573 "%s-%s-%d", basename, "tx", tx_int_idx++); in ice_vsi_req_irq_msix()
2578 if (vsi->type == ICE_VSI_CTRL && vsi->vf) in ice_vsi_req_irq_msix()
2579 err = devm_request_irq(dev, irq_num, vsi->irq_handler, in ice_vsi_req_irq_msix()
2580 IRQF_SHARED, q_vector->name, in ice_vsi_req_irq_msix()
2583 err = devm_request_irq(dev, irq_num, vsi->irq_handler, in ice_vsi_req_irq_msix()
2584 0, q_vector->name, q_vector); in ice_vsi_req_irq_msix()
2586 netdev_err(vsi->netdev, "MSIX request_irq failed, error: %d\n", in ice_vsi_req_irq_msix()
2595 affinity_notify = &q_vector->affinity_notify; in ice_vsi_req_irq_msix()
2596 affinity_notify->notify = ice_irq_affinity_notify; in ice_vsi_req_irq_msix()
2597 affinity_notify->release = ice_irq_affinity_release; in ice_vsi_req_irq_msix()
2602 irq_update_affinity_hint(irq_num, &q_vector->affinity_mask); in ice_vsi_req_irq_msix()
2607 netdev_err(vsi->netdev, "Failed to setup CPU RMAP on VSI %u: %pe\n", in ice_vsi_req_irq_msix()
2608 vsi->vsi_num, ERR_PTR(err)); in ice_vsi_req_irq_msix()
2612 vsi->irqs_ready = true; in ice_vsi_req_irq_msix()
2616 while (vector--) { in ice_vsi_req_irq_msix()
2617 irq_num = vsi->q_vectors[vector]->irq.virq; in ice_vsi_req_irq_msix()
2621 devm_free_irq(dev, irq_num, &vsi->q_vectors[vector]); in ice_vsi_req_irq_msix()
2627 * ice_xdp_alloc_setup_rings - Allocate and setup Tx rings for XDP
2634 struct device *dev = ice_pf_to_dev(vsi->back); in ice_xdp_alloc_setup_rings()
2639 u16 xdp_q_idx = vsi->alloc_txq + i; in ice_xdp_alloc_setup_rings()
2653 xdp_ring->ring_stats = ring_stats; in ice_xdp_alloc_setup_rings()
2654 xdp_ring->q_index = xdp_q_idx; in ice_xdp_alloc_setup_rings()
2655 xdp_ring->reg_idx = vsi->txq_map[xdp_q_idx]; in ice_xdp_alloc_setup_rings()
2656 xdp_ring->vsi = vsi; in ice_xdp_alloc_setup_rings()
2657 xdp_ring->netdev = NULL; in ice_xdp_alloc_setup_rings()
2658 xdp_ring->dev = dev; in ice_xdp_alloc_setup_rings()
2659 xdp_ring->count = vsi->num_tx_desc; in ice_xdp_alloc_setup_rings()
2660 WRITE_ONCE(vsi->xdp_rings[i], xdp_ring); in ice_xdp_alloc_setup_rings()
2664 spin_lock_init(&xdp_ring->tx_lock); in ice_xdp_alloc_setup_rings()
2665 for (j = 0; j < xdp_ring->count; j++) { in ice_xdp_alloc_setup_rings()
2667 tx_desc->cmd_type_offset_bsz = 0; in ice_xdp_alloc_setup_rings()
2674 for (; i >= 0; i--) { in ice_xdp_alloc_setup_rings()
2675 if (vsi->xdp_rings[i] && vsi->xdp_rings[i]->desc) { in ice_xdp_alloc_setup_rings()
2676 kfree_rcu(vsi->xdp_rings[i]->ring_stats, rcu); in ice_xdp_alloc_setup_rings()
2677 vsi->xdp_rings[i]->ring_stats = NULL; in ice_xdp_alloc_setup_rings()
2678 ice_free_tx_ring(vsi->xdp_rings[i]); in ice_xdp_alloc_setup_rings()
2681 return -ENOMEM; in ice_xdp_alloc_setup_rings()
2685 * ice_vsi_assign_bpf_prog - set or clear bpf prog pointer on VSI
2694 old_prog = xchg(&vsi->xdp_prog, prog); in ice_vsi_assign_bpf_prog()
2696 WRITE_ONCE(vsi->rx_rings[i]->xdp_prog, vsi->xdp_prog); in ice_vsi_assign_bpf_prog()
2708 return vsi->xdp_rings[qid % vsi->num_xdp_txq]; in ice_xdp_ring_from_qid()
2710 q_vector = vsi->rx_rings[qid]->q_vector; in ice_xdp_ring_from_qid()
2711 ice_for_each_tx_ring(ring, q_vector->tx) in ice_xdp_ring_from_qid()
2719 * ice_map_xdp_rings - Map XDP rings to interrupt vectors
2727 int xdp_rings_rem = vsi->num_xdp_txq; in ice_map_xdp_rings()
2732 struct ice_q_vector *q_vector = vsi->q_vectors[v_idx]; in ice_map_xdp_rings()
2736 vsi->num_q_vectors - v_idx); in ice_map_xdp_rings()
2737 q_base = vsi->num_xdp_txq - xdp_rings_rem; in ice_map_xdp_rings()
2740 struct ice_tx_ring *xdp_ring = vsi->xdp_rings[q_id]; in ice_map_xdp_rings()
2742 xdp_ring->q_vector = q_vector; in ice_map_xdp_rings()
2743 xdp_ring->next = q_vector->tx.tx_ring; in ice_map_xdp_rings()
2744 q_vector->tx.tx_ring = xdp_ring; in ice_map_xdp_rings()
2746 xdp_rings_rem -= xdp_rings_per_v; in ice_map_xdp_rings()
2750 vsi->rx_rings[q_idx]->xdp_ring = ice_xdp_ring_from_qid(vsi, in ice_map_xdp_rings()
2757 * ice_prepare_xdp_rings - Allocate, configure and setup Tx rings for XDP
2768 struct ice_pf *pf = vsi->back; in ice_prepare_xdp_rings()
2770 .qs_mutex = &pf->avail_q_mutex, in ice_prepare_xdp_rings()
2771 .pf_map = pf->avail_txqs, in ice_prepare_xdp_rings()
2772 .pf_map_size = pf->max_pf_txqs, in ice_prepare_xdp_rings()
2773 .q_count = vsi->num_xdp_txq, in ice_prepare_xdp_rings()
2775 .vsi_map = vsi->txq_map, in ice_prepare_xdp_rings()
2776 .vsi_map_offset = vsi->alloc_txq, in ice_prepare_xdp_rings()
2783 vsi->xdp_rings = devm_kcalloc(dev, vsi->num_xdp_txq, in ice_prepare_xdp_rings()
2784 sizeof(*vsi->xdp_rings), GFP_KERNEL); in ice_prepare_xdp_rings()
2785 if (!vsi->xdp_rings) in ice_prepare_xdp_rings()
2786 return -ENOMEM; in ice_prepare_xdp_rings()
2788 vsi->xdp_mapping_mode = xdp_qs_cfg.mapping_mode; in ice_prepare_xdp_rings()
2793 netdev_warn(vsi->netdev, in ice_prepare_xdp_rings()
2811 for (i = 0; i < vsi->tc_cfg.numtc; i++) in ice_prepare_xdp_rings()
2812 max_txqs[i] = vsi->num_txq + vsi->num_xdp_txq; in ice_prepare_xdp_rings()
2814 status = ice_cfg_vsi_lan(vsi->port_info, vsi->idx, vsi->tc_cfg.ena_tc, in ice_prepare_xdp_rings()
2823 * this flow is a subject of both ethtool -L and ndo_bpf flows; in ice_prepare_xdp_rings()
2824 * VSI rebuild that happens under ethtool -L can expose us to in ice_prepare_xdp_rings()
2826 * bpf_prog pointers from vsi->xdp_prog and calling bpf_prog_put in ice_prepare_xdp_rings()
2837 if (vsi->xdp_rings[i]) { in ice_prepare_xdp_rings()
2838 kfree_rcu(vsi->xdp_rings[i], rcu); in ice_prepare_xdp_rings()
2839 vsi->xdp_rings[i] = NULL; in ice_prepare_xdp_rings()
2843 mutex_lock(&pf->avail_q_mutex); in ice_prepare_xdp_rings()
2845 clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs); in ice_prepare_xdp_rings()
2846 vsi->txq_map[i + vsi->alloc_txq] = ICE_INVAL_Q_INDEX; in ice_prepare_xdp_rings()
2848 mutex_unlock(&pf->avail_q_mutex); in ice_prepare_xdp_rings()
2850 devm_kfree(dev, vsi->xdp_rings); in ice_prepare_xdp_rings()
2851 return -ENOMEM; in ice_prepare_xdp_rings()
2855 * ice_destroy_xdp_rings - undo the configuration made by ice_prepare_xdp_rings
2865 struct ice_pf *pf = vsi->back; in ice_destroy_xdp_rings()
2875 struct ice_q_vector *q_vector = vsi->q_vectors[v_idx]; in ice_destroy_xdp_rings()
2878 ice_for_each_tx_ring(ring, q_vector->tx) in ice_destroy_xdp_rings()
2879 if (!ring->tx_buf || !ice_ring_is_xdp(ring)) in ice_destroy_xdp_rings()
2883 q_vector->tx.tx_ring = ring; in ice_destroy_xdp_rings()
2887 mutex_lock(&pf->avail_q_mutex); in ice_destroy_xdp_rings()
2889 clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs); in ice_destroy_xdp_rings()
2890 vsi->txq_map[i + vsi->alloc_txq] = ICE_INVAL_Q_INDEX; in ice_destroy_xdp_rings()
2892 mutex_unlock(&pf->avail_q_mutex); in ice_destroy_xdp_rings()
2895 if (vsi->xdp_rings[i]) { in ice_destroy_xdp_rings()
2896 if (vsi->xdp_rings[i]->desc) { in ice_destroy_xdp_rings()
2898 ice_free_tx_ring(vsi->xdp_rings[i]); in ice_destroy_xdp_rings()
2900 kfree_rcu(vsi->xdp_rings[i]->ring_stats, rcu); in ice_destroy_xdp_rings()
2901 vsi->xdp_rings[i]->ring_stats = NULL; in ice_destroy_xdp_rings()
2902 kfree_rcu(vsi->xdp_rings[i], rcu); in ice_destroy_xdp_rings()
2903 vsi->xdp_rings[i] = NULL; in ice_destroy_xdp_rings()
2906 devm_kfree(ice_pf_to_dev(pf), vsi->xdp_rings); in ice_destroy_xdp_rings()
2907 vsi->xdp_rings = NULL; in ice_destroy_xdp_rings()
2920 for (i = 0; i < vsi->tc_cfg.numtc; i++) in ice_destroy_xdp_rings()
2921 max_txqs[i] = vsi->num_txq; in ice_destroy_xdp_rings()
2924 vsi->num_xdp_txq = 0; in ice_destroy_xdp_rings()
2926 return ice_cfg_vsi_lan(vsi->port_info, vsi->idx, vsi->tc_cfg.ena_tc, in ice_destroy_xdp_rings()
2931 * ice_vsi_rx_napi_schedule - Schedule napi on RX queues from VSI
2939 struct ice_rx_ring *rx_ring = vsi->rx_rings[i]; in ice_vsi_rx_napi_schedule()
2941 if (READ_ONCE(rx_ring->xsk_pool)) in ice_vsi_rx_napi_schedule()
2942 napi_schedule(&rx_ring->q_vector->napi); in ice_vsi_rx_napi_schedule()
2947 * ice_vsi_determine_xdp_res - figure out how many Tx qs can XDP have
2951 * -ENOMEM otherwise
2955 u16 avail = ice_get_avail_txq_count(vsi->back); in ice_vsi_determine_xdp_res()
2959 return -ENOMEM; in ice_vsi_determine_xdp_res()
2961 if (vsi->type == ICE_VSI_SF) in ice_vsi_determine_xdp_res()
2962 avail = vsi->alloc_txq; in ice_vsi_determine_xdp_res()
2964 vsi->num_xdp_txq = min_t(u16, avail, cpus); in ice_vsi_determine_xdp_res()
2966 if (vsi->num_xdp_txq < cpus) in ice_vsi_determine_xdp_res()
2973 * ice_max_xdp_frame_size - returns the maximum allowed frame size for XDP
2978 if (test_bit(ICE_FLAG_LEGACY_RX, vsi->back->flags)) in ice_max_xdp_frame_size()
2985 * ice_xdp_setup_prog - Add or remove XDP eBPF program
2994 unsigned int frame_size = vsi->netdev->mtu + ICE_ETH_PKT_HDR_PAD; in ice_xdp_setup_prog()
2998 if (prog && !prog->aux->xdp_has_frags) { in ice_xdp_setup_prog()
3002 return -EOPNOTSUPP; in ice_xdp_setup_prog()
3008 test_bit(ICE_VSI_REBUILD_PENDING, vsi->state)) { in ice_xdp_setup_prog()
3013 if_running = netif_running(vsi->netdev) && in ice_xdp_setup_prog()
3014 !test_and_set_bit(ICE_VSI_DOWN, vsi->state); in ice_xdp_setup_prog()
3035 xdp_features_set_redirect_target(vsi->netdev, true); in ice_xdp_setup_prog()
3036 /* reallocate Rx queues that are used for zero-copy */ in ice_xdp_setup_prog()
3041 xdp_features_clear_redirect_target(vsi->netdev); in ice_xdp_setup_prog()
3045 /* reallocate Rx queues that were used for zero-copy */ in ice_xdp_setup_prog()
3057 return (ret || xdp_ring_err) ? -ENOMEM : 0; in ice_xdp_setup_prog()
3061 * ice_xdp_safe_mode - XDP handler for safe mode
3068 NL_SET_ERR_MSG_MOD(xdp->extack, in ice_xdp_safe_mode()
3071 return -EOPNOTSUPP; in ice_xdp_safe_mode()
3075 * ice_xdp - implements XDP handler
3082 struct ice_vsi *vsi = np->vsi; in ice_xdp()
3085 if (vsi->type != ICE_VSI_PF && vsi->type != ICE_VSI_SF) { in ice_xdp()
3086 NL_SET_ERR_MSG_MOD(xdp->extack, "XDP can be loaded only on PF or SF VSI"); in ice_xdp()
3087 return -EINVAL; in ice_xdp()
3090 mutex_lock(&vsi->xdp_state_lock); in ice_xdp()
3092 switch (xdp->command) { in ice_xdp()
3094 ret = ice_xdp_setup_prog(vsi, xdp->prog, xdp->extack); in ice_xdp()
3097 ret = ice_xsk_pool_setup(vsi, xdp->xsk.pool, xdp->xsk.queue_id); in ice_xdp()
3100 ret = -EINVAL; in ice_xdp()
3103 mutex_unlock(&vsi->xdp_state_lock); in ice_xdp()
3108 * ice_ena_misc_vector - enable the non-queue interrupts
3113 struct ice_hw *hw = &pf->hw; in ice_ena_misc_vector()
3117 /* Disable anti-spoof detection interrupt to prevent spurious event in ice_ena_misc_vector()
3118 * interrupts during a function reset. Anti-spoof functionally is in ice_ena_misc_vector()
3141 wr32(hw, GLINT_DYN_CTL(pf->oicr_irq.index), in ice_ena_misc_vector()
3144 if (!pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) in ice_ena_misc_vector()
3147 wr32(hw, GLINT_DYN_CTL(pf->ll_ts_irq.index + pf_intr_start_offset), in ice_ena_misc_vector()
3152 * ice_ll_ts_intr - ll_ts interrupt handler
3166 hw = &pf->hw; in ice_ll_ts_intr()
3167 tx = &pf->ptp.port.tx; in ice_ll_ts_intr()
3168 spin_lock_irqsave(&tx->lock, flags); in ice_ll_ts_intr()
3171 idx = find_next_bit_wrap(tx->in_use, tx->len, in ice_ll_ts_intr()
3172 tx->last_ll_ts_idx_read + 1); in ice_ll_ts_intr()
3173 if (idx != tx->len) in ice_ll_ts_intr()
3175 spin_unlock_irqrestore(&tx->lock, flags); in ice_ll_ts_intr()
3180 wr32(hw, GLINT_DYN_CTL(pf->ll_ts_irq.index + pf_intr_start_offset), in ice_ll_ts_intr()
3187 * ice_misc_intr - misc interrupt handler
3195 struct ice_hw *hw = &pf->hw; in ice_misc_intr()
3200 set_bit(ICE_ADMINQ_EVENT_PENDING, pf->state); in ice_misc_intr()
3201 set_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state); in ice_misc_intr()
3202 set_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state); in ice_misc_intr()
3209 pf->sw_int_count++; in ice_misc_intr()
3214 set_bit(ICE_MDD_EVENT_PENDING, pf->state); in ice_misc_intr()
3218 if (test_bit(ICE_VF_RESETS_DISABLED, pf->state)) { in ice_misc_intr()
3225 set_bit(ICE_VFLR_EVENT_PENDING, pf->state); in ice_misc_intr()
3238 pf->corer_count++; in ice_misc_intr()
3240 pf->globr_count++; in ice_misc_intr()
3242 pf->empr_count++; in ice_misc_intr()
3247 * pf->state so that the service task can start a reset/rebuild. in ice_misc_intr()
3249 if (!test_and_set_bit(ICE_RESET_OICR_RECV, pf->state)) { in ice_misc_intr()
3251 set_bit(ICE_CORER_RECV, pf->state); in ice_misc_intr()
3253 set_bit(ICE_GLOBR_RECV, pf->state); in ice_misc_intr()
3255 set_bit(ICE_EMPR_RECV, pf->state); in ice_misc_intr()
3258 * hw->reset_ongoing indicates whether the hardware is in ice_misc_intr()
3263 * ICE_RESET_OICR_RECV in pf->state indicates in ice_misc_intr()
3270 hw->reset_ongoing = true; in ice_misc_intr()
3277 pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) { in ice_misc_intr()
3278 struct ice_ptp_tx *tx = &pf->ptp.port.tx; in ice_misc_intr()
3282 spin_lock_irqsave(&tx->lock, flags); in ice_misc_intr()
3283 idx = find_next_bit_wrap(tx->in_use, tx->len, in ice_misc_intr()
3284 tx->last_ll_ts_idx_read + 1); in ice_misc_intr()
3285 if (idx != tx->len) in ice_misc_intr()
3287 spin_unlock_irqrestore(&tx->lock, flags); in ice_misc_intr()
3289 set_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread); in ice_misc_intr()
3295 u8 tmr_idx = hw->func_caps.ts_func_info.tmr_index_owned; in ice_misc_intr()
3302 pf->ptp.ext_ts_irq |= gltsyn_stat & in ice_misc_intr()
3313 pf->oicr_err_reg |= oicr; in ice_misc_intr()
3314 set_bit(ICE_AUX_ERR_PENDING, pf->state); in ice_misc_intr()
3327 set_bit(ICE_PFR_REQ, pf->state); in ice_misc_intr()
3338 * ice_misc_intr_thread_fn - misc interrupt thread function
3347 hw = &pf->hw; in ice_misc_intr_thread_fn()
3349 if (ice_is_reset_in_progress(pf->state)) in ice_misc_intr_thread_fn()
3352 if (test_and_clear_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread)) { in ice_misc_intr_thread_fn()
3354 * re-arm the interrupt to trigger again. in ice_misc_intr_thread_fn()
3369 * ice_dis_ctrlq_interrupts - disable control queue interrupts
3393 * ice_free_irq_msix_ll_ts- Unroll ll_ts vector setup
3398 int irq_num = pf->ll_ts_irq.virq; in ice_free_irq_msix_ll_ts()
3403 ice_free_irq(pf, pf->ll_ts_irq); in ice_free_irq_msix_ll_ts()
3407 * ice_free_irq_msix_misc - Unroll misc vector setup
3412 int misc_irq_num = pf->oicr_irq.virq; in ice_free_irq_msix_misc()
3413 struct ice_hw *hw = &pf->hw; in ice_free_irq_msix_misc()
3424 ice_free_irq(pf, pf->oicr_irq); in ice_free_irq_msix_misc()
3425 if (pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) in ice_free_irq_msix_misc()
3430 * ice_ena_ctrlq_interrupts - enable control queue interrupts
3452 if (!hw->dev_caps.ts_dev_info.ts_ll_int_read) { in ice_ena_ctrlq_interrupts()
3463 * ice_req_irq_msix_misc - Setup the misc vector to handle non queue events
3467 * non-queue interrupts, e.g. AdminQ and errors. This is not used
3473 struct ice_hw *hw = &pf->hw; in ice_req_irq_msix_misc()
3478 if (!pf->int_name[0]) in ice_req_irq_msix_misc()
3479 snprintf(pf->int_name, sizeof(pf->int_name) - 1, "%s-%s:misc", in ice_req_irq_msix_misc()
3482 if (!pf->int_name_ll_ts[0]) in ice_req_irq_msix_misc()
3483 snprintf(pf->int_name_ll_ts, sizeof(pf->int_name_ll_ts) - 1, in ice_req_irq_msix_misc()
3484 "%s-%s:ll_ts", dev_driver_string(dev), dev_name(dev)); in ice_req_irq_msix_misc()
3489 if (ice_is_reset_in_progress(pf->state)) in ice_req_irq_msix_misc()
3497 pf->oicr_irq = irq; in ice_req_irq_msix_misc()
3498 err = devm_request_threaded_irq(dev, pf->oicr_irq.virq, ice_misc_intr, in ice_req_irq_msix_misc()
3500 pf->int_name, pf); in ice_req_irq_msix_misc()
3503 pf->int_name, err); in ice_req_irq_msix_misc()
3504 ice_free_irq(pf, pf->oicr_irq); in ice_req_irq_msix_misc()
3509 if (!pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) in ice_req_irq_msix_misc()
3516 pf->ll_ts_irq = irq; in ice_req_irq_msix_misc()
3517 err = devm_request_irq(dev, pf->ll_ts_irq.virq, ice_ll_ts_intr, 0, in ice_req_irq_msix_misc()
3518 pf->int_name_ll_ts, pf); in ice_req_irq_msix_misc()
3521 pf->int_name_ll_ts, err); in ice_req_irq_msix_misc()
3522 ice_free_irq(pf, pf->ll_ts_irq); in ice_req_irq_msix_misc()
3529 ice_ena_ctrlq_interrupts(hw, pf->oicr_irq.index); in ice_req_irq_msix_misc()
3532 if (pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) in ice_req_irq_msix_misc()
3534 ((pf->ll_ts_irq.index + pf_intr_start_offset) & in ice_req_irq_msix_misc()
3536 wr32(hw, GLINT_ITR(ICE_RX_ITR, pf->oicr_irq.index), in ice_req_irq_msix_misc()
3546 * ice_set_ops - set netdev and ethtools ops for the given netdev
3551 struct net_device *netdev = vsi->netdev; in ice_set_ops()
3555 netdev->netdev_ops = &ice_netdev_safe_mode_ops; in ice_set_ops()
3560 netdev->netdev_ops = &ice_netdev_ops; in ice_set_ops()
3561 netdev->udp_tunnel_nic_info = &pf->hw.udp_tunnel_nic; in ice_set_ops()
3562 netdev->xdp_metadata_ops = &ice_xdp_md_ops; in ice_set_ops()
3565 if (vsi->type != ICE_VSI_PF) in ice_set_ops()
3568 netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | in ice_set_ops()
3571 netdev->xdp_zc_max_segs = ICE_MAX_BUF_TXD; in ice_set_ops()
3575 * ice_set_netdev_features - set features for the given netdev
3581 bool is_dvm_ena = ice_is_dvm_ena(&pf->hw); in ice_set_netdev_features()
3589 netdev->features = NETIF_F_SG | NETIF_F_HIGHDMA; in ice_set_netdev_features()
3590 netdev->hw_features = netdev->features; in ice_set_netdev_features()
3624 netdev->gso_partial_features |= NETIF_F_GSO_UDP_TUNNEL_CSUM | in ice_set_netdev_features()
3627 netdev->hw_features = dflt_features | csumo_features | in ice_set_netdev_features()
3631 netdev->mpls_features = NETIF_F_HW_CSUM | in ice_set_netdev_features()
3636 netdev->features |= netdev->hw_features; in ice_set_netdev_features()
3638 netdev->hw_features |= NETIF_F_HW_TC; in ice_set_netdev_features()
3639 netdev->hw_features |= NETIF_F_LOOPBACK; in ice_set_netdev_features()
3642 netdev->hw_enc_features |= dflt_features | csumo_features | in ice_set_netdev_features()
3644 netdev->vlan_features |= dflt_features | csumo_features | in ice_set_netdev_features()
3653 netdev->hw_features |= NETIF_F_HW_VLAN_STAG_RX | in ice_set_netdev_features()
3659 netdev->hw_features |= NETIF_F_RXFCS; in ice_set_netdev_features()
3665 * ice_fill_rss_lut - Fill the RSS lookup table with default values
3679 * ice_pf_vsi_setup - Set up a PF VSI
3713 * ice_ctrl_vsi_setup - Set up a control VSI
3733 * ice_lb_vsi_setup - Set up a loopback VSI
3753 * ice_vlan_rx_add_vid - Add a VLAN ID filter to HW offload
3764 struct ice_vsi *vsi = np->vsi; in ice_vlan_rx_add_vid()
3772 while (test_and_set_bit(ICE_CFG_BUSY, vsi->state)) in ice_vlan_rx_add_vid()
3776 * all-multicast is currently enabled. in ice_vlan_rx_add_vid()
3778 if (vsi->current_netdev_flags & IFF_ALLMULTI) { in ice_vlan_rx_add_vid()
3779 ret = ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_add_vid()
3792 ret = vlan_ops->add_vlan(vsi, &vlan); in ice_vlan_rx_add_vid()
3796 /* If all-multicast is currently enabled and this VLAN ID is only one in ice_vlan_rx_add_vid()
3797 * besides VLAN-0 we have to update look-up type of multicast promisc in ice_vlan_rx_add_vid()
3798 * rule for VLAN-0 from ICE_SW_LKUP_PROMISC to ICE_SW_LKUP_PROMISC_VLAN. in ice_vlan_rx_add_vid()
3800 if ((vsi->current_netdev_flags & IFF_ALLMULTI) && in ice_vlan_rx_add_vid()
3802 ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_add_vid()
3804 ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_add_vid()
3809 clear_bit(ICE_CFG_BUSY, vsi->state); in ice_vlan_rx_add_vid()
3815 * ice_vlan_rx_kill_vid - Remove a VLAN ID filter from HW offload
3826 struct ice_vsi *vsi = np->vsi; in ice_vlan_rx_kill_vid()
3834 while (test_and_set_bit(ICE_CFG_BUSY, vsi->state)) in ice_vlan_rx_kill_vid()
3837 ret = ice_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_kill_vid()
3841 vsi->vsi_num); in ice_vlan_rx_kill_vid()
3842 vsi->current_netdev_flags |= IFF_ALLMULTI; in ice_vlan_rx_kill_vid()
3851 ret = vlan_ops->del_vlan(vsi, &vlan); in ice_vlan_rx_kill_vid()
3856 * all-multicast is enabled. in ice_vlan_rx_kill_vid()
3858 if (vsi->current_netdev_flags & IFF_ALLMULTI) in ice_vlan_rx_kill_vid()
3859 ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_kill_vid()
3863 /* Update look-up type of multicast promisc rule for VLAN 0 in ice_vlan_rx_kill_vid()
3865 * all-multicast is enabled and VLAN 0 is the only VLAN rule. in ice_vlan_rx_kill_vid()
3867 if (vsi->current_netdev_flags & IFF_ALLMULTI) { in ice_vlan_rx_kill_vid()
3868 ice_fltr_clear_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_kill_vid()
3871 ice_fltr_set_vsi_promisc(&vsi->back->hw, vsi->idx, in ice_vlan_rx_kill_vid()
3877 clear_bit(ICE_CFG_BUSY, vsi->state); in ice_vlan_rx_kill_vid()
3890 list_del(&indr_priv->list); in ice_rep_indr_tc_block_unbind()
3895 * ice_tc_indir_block_unregister - Unregister TC indirect block notifications
3900 struct ice_netdev_priv *np = netdev_priv(vsi->netdev); in ice_tc_indir_block_unregister()
3907 * ice_tc_indir_block_register - Register TC indirect block notifications
3916 if (!vsi || !vsi->netdev) in ice_tc_indir_block_register()
3917 return -EINVAL; in ice_tc_indir_block_register()
3919 np = netdev_priv(vsi->netdev); in ice_tc_indir_block_register()
3921 INIT_LIST_HEAD(&np->tc_indr_block_priv_list); in ice_tc_indir_block_register()
3926 * ice_get_avail_q_count - Get count of queues in use
3946 * ice_get_avail_txq_count - Get count of Tx queues in use
3951 return ice_get_avail_q_count(pf->avail_txqs, &pf->avail_q_mutex, in ice_get_avail_txq_count()
3952 pf->max_pf_txqs); in ice_get_avail_txq_count()
3956 * ice_get_avail_rxq_count - Get count of Rx queues in use
3961 return ice_get_avail_q_count(pf->avail_rxqs, &pf->avail_q_mutex, in ice_get_avail_rxq_count()
3962 pf->max_pf_rxqs); in ice_get_avail_rxq_count()
3966 * ice_deinit_pf - Unrolls initialziations done by ice_init_pf
3972 mutex_destroy(&pf->lag_mutex); in ice_deinit_pf()
3973 mutex_destroy(&pf->adev_mutex); in ice_deinit_pf()
3974 mutex_destroy(&pf->sw_mutex); in ice_deinit_pf()
3975 mutex_destroy(&pf->tc_mutex); in ice_deinit_pf()
3976 mutex_destroy(&pf->avail_q_mutex); in ice_deinit_pf()
3977 mutex_destroy(&pf->vfs.table_lock); in ice_deinit_pf()
3979 if (pf->avail_txqs) { in ice_deinit_pf()
3980 bitmap_free(pf->avail_txqs); in ice_deinit_pf()
3981 pf->avail_txqs = NULL; in ice_deinit_pf()
3984 if (pf->avail_rxqs) { in ice_deinit_pf()
3985 bitmap_free(pf->avail_rxqs); in ice_deinit_pf()
3986 pf->avail_rxqs = NULL; in ice_deinit_pf()
3989 if (pf->ptp.clock) in ice_deinit_pf()
3990 ptp_clock_unregister(pf->ptp.clock); in ice_deinit_pf()
3992 xa_destroy(&pf->dyn_ports); in ice_deinit_pf()
3993 xa_destroy(&pf->sf_nums); in ice_deinit_pf()
3997 * ice_set_pf_caps - set PFs capability flags
4002 struct ice_hw_func_caps *func_caps = &pf->hw.func_caps; in ice_set_pf_caps()
4004 clear_bit(ICE_FLAG_RDMA_ENA, pf->flags); in ice_set_pf_caps()
4005 if (func_caps->common_cap.rdma) in ice_set_pf_caps()
4006 set_bit(ICE_FLAG_RDMA_ENA, pf->flags); in ice_set_pf_caps()
4007 clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); in ice_set_pf_caps()
4008 if (func_caps->common_cap.dcb) in ice_set_pf_caps()
4009 set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); in ice_set_pf_caps()
4010 clear_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); in ice_set_pf_caps()
4011 if (func_caps->common_cap.sr_iov_1_1) { in ice_set_pf_caps()
4012 set_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); in ice_set_pf_caps()
4013 pf->vfs.num_supported = min_t(int, func_caps->num_allocd_vfs, in ice_set_pf_caps()
4016 clear_bit(ICE_FLAG_RSS_ENA, pf->flags); in ice_set_pf_caps()
4017 if (func_caps->common_cap.rss_table_size) in ice_set_pf_caps()
4018 set_bit(ICE_FLAG_RSS_ENA, pf->flags); in ice_set_pf_caps()
4020 clear_bit(ICE_FLAG_FD_ENA, pf->flags); in ice_set_pf_caps()
4021 if (func_caps->fd_fltr_guar > 0 || func_caps->fd_fltr_best_effort > 0) { in ice_set_pf_caps()
4027 pf->ctrl_vsi_idx = ICE_NO_VSI; in ice_set_pf_caps()
4028 set_bit(ICE_FLAG_FD_ENA, pf->flags); in ice_set_pf_caps()
4030 ice_alloc_fd_guar_item(&pf->hw, &unused, in ice_set_pf_caps()
4031 func_caps->fd_fltr_guar); in ice_set_pf_caps()
4033 ice_alloc_fd_shrd_item(&pf->hw, &unused, in ice_set_pf_caps()
4034 func_caps->fd_fltr_best_effort); in ice_set_pf_caps()
4037 clear_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags); in ice_set_pf_caps()
4038 if (func_caps->common_cap.ieee_1588 && in ice_set_pf_caps()
4039 !(pf->hw.mac_type == ICE_MAC_E830)) in ice_set_pf_caps()
4040 set_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags); in ice_set_pf_caps()
4042 pf->max_pf_txqs = func_caps->common_cap.num_txq; in ice_set_pf_caps()
4043 pf->max_pf_rxqs = func_caps->common_cap.num_rxq; in ice_set_pf_caps()
4047 * ice_init_pf - Initialize general software structures (struct ice_pf)
4054 mutex_init(&pf->sw_mutex); in ice_init_pf()
4055 mutex_init(&pf->tc_mutex); in ice_init_pf()
4056 mutex_init(&pf->adev_mutex); in ice_init_pf()
4057 mutex_init(&pf->lag_mutex); in ice_init_pf()
4059 INIT_HLIST_HEAD(&pf->aq_wait_list); in ice_init_pf()
4060 spin_lock_init(&pf->aq_wait_lock); in ice_init_pf()
4061 init_waitqueue_head(&pf->aq_wait_queue); in ice_init_pf()
4063 init_waitqueue_head(&pf->reset_wait_queue); in ice_init_pf()
4066 timer_setup(&pf->serv_tmr, ice_service_timer, 0); in ice_init_pf()
4067 pf->serv_tmr_period = HZ; in ice_init_pf()
4068 INIT_WORK(&pf->serv_task, ice_service_task); in ice_init_pf()
4069 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_init_pf()
4071 mutex_init(&pf->avail_q_mutex); in ice_init_pf()
4072 pf->avail_txqs = bitmap_zalloc(pf->max_pf_txqs, GFP_KERNEL); in ice_init_pf()
4073 if (!pf->avail_txqs) in ice_init_pf()
4074 return -ENOMEM; in ice_init_pf()
4076 pf->avail_rxqs = bitmap_zalloc(pf->max_pf_rxqs, GFP_KERNEL); in ice_init_pf()
4077 if (!pf->avail_rxqs) { in ice_init_pf()
4078 bitmap_free(pf->avail_txqs); in ice_init_pf()
4079 pf->avail_txqs = NULL; in ice_init_pf()
4080 return -ENOMEM; in ice_init_pf()
4083 mutex_init(&pf->vfs.table_lock); in ice_init_pf()
4084 hash_init(pf->vfs.table); in ice_init_pf()
4085 ice_mbx_init_snapshot(&pf->hw); in ice_init_pf()
4087 xa_init(&pf->dyn_ports); in ice_init_pf()
4088 xa_init(&pf->sf_nums); in ice_init_pf()
4094 * ice_is_wol_supported - check if WoL is supported
4110 return !(BIT(hw->port_info->lport) & wol_ctrl); in ice_is_wol_supported()
4114 * ice_vsi_recfg_qs - Change the number of queues on a VSI
4120 * Only change the number of queues if new_tx, or new_rx is non-0.
4126 struct ice_pf *pf = vsi->back; in ice_vsi_recfg_qs()
4127 int i, err = 0, timeout = 50; in ice_vsi_recfg_qs() local
4130 return -EINVAL; in ice_vsi_recfg_qs()
4132 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) { in ice_vsi_recfg_qs()
4133 timeout--; in ice_vsi_recfg_qs()
4134 if (!timeout) in ice_vsi_recfg_qs()
4135 return -EBUSY; in ice_vsi_recfg_qs()
4140 vsi->req_txq = (u16)new_tx; in ice_vsi_recfg_qs()
4142 vsi->req_rxq = (u16)new_rx; in ice_vsi_recfg_qs()
4145 if (!netif_running(vsi->netdev)) { in ice_vsi_recfg_qs()
4159 if (vsi->tc_cfg.ena_tc & BIT(i)) in ice_vsi_recfg_qs()
4160 netdev_set_tc_queue(vsi->netdev, in ice_vsi_recfg_qs()
4161 vsi->tc_cfg.tc_info[i].netdev_tc, in ice_vsi_recfg_qs()
4162 vsi->tc_cfg.tc_info[i].qcount_tx, in ice_vsi_recfg_qs()
4163 vsi->tc_cfg.tc_info[i].qoffset); in ice_vsi_recfg_qs()
4173 clear_bit(ICE_CFG_BUSY, pf->state); in ice_vsi_recfg_qs()
4178 * ice_set_safe_mode_vlan_cfg - configure PF VSI to allow all VLANs in safe mode
4198 hw = &pf->hw; in ice_set_safe_mode_vlan_cfg()
4199 ctxt->info = vsi->info; in ice_set_safe_mode_vlan_cfg()
4201 ctxt->info.valid_sections = in ice_set_safe_mode_vlan_cfg()
4206 /* disable VLAN anti-spoof */ in ice_set_safe_mode_vlan_cfg()
4207 ctxt->info.sec_flags &= ~(ICE_AQ_VSI_SEC_TX_VLAN_PRUNE_ENA << in ice_set_safe_mode_vlan_cfg()
4211 ctxt->info.sw_flags2 &= ~ICE_AQ_VSI_SW_FLAG_RX_VLAN_PRUNE_ENA; in ice_set_safe_mode_vlan_cfg()
4214 ctxt->info.inner_vlan_flags = ICE_AQ_VSI_INNER_VLAN_TX_MODE_ALL | in ice_set_safe_mode_vlan_cfg()
4217 status = ice_update_vsi(hw, vsi->idx, ctxt, NULL); in ice_set_safe_mode_vlan_cfg()
4219 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()
4220 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_safe_mode_vlan_cfg()
4222 vsi->info.sec_flags = ctxt->info.sec_flags; in ice_set_safe_mode_vlan_cfg()
4223 vsi->info.sw_flags2 = ctxt->info.sw_flags2; in ice_set_safe_mode_vlan_cfg()
4224 vsi->info.inner_vlan_flags = ctxt->info.inner_vlan_flags; in ice_set_safe_mode_vlan_cfg()
4231 * ice_log_pkg_init - log result of DDP package load
4237 struct ice_pf *pf = hw->back; in ice_log_pkg_init()
4245 hw->active_pkg_name, in ice_log_pkg_init()
4246 hw->active_pkg_ver.major, in ice_log_pkg_init()
4247 hw->active_pkg_ver.minor, in ice_log_pkg_init()
4248 hw->active_pkg_ver.update, in ice_log_pkg_init()
4249 hw->active_pkg_ver.draft); in ice_log_pkg_init()
4253 hw->active_pkg_name, in ice_log_pkg_init()
4254 hw->active_pkg_ver.major, in ice_log_pkg_init()
4255 hw->active_pkg_ver.minor, in ice_log_pkg_init()
4256 hw->active_pkg_ver.update, in ice_log_pkg_init()
4257 hw->active_pkg_ver.draft); in ice_log_pkg_init()
4261 hw->active_pkg_name, in ice_log_pkg_init()
4262 hw->active_pkg_ver.major, in ice_log_pkg_init()
4263 hw->active_pkg_ver.minor, in ice_log_pkg_init()
4268 hw->active_pkg_name, in ice_log_pkg_init()
4269 hw->active_pkg_ver.major, in ice_log_pkg_init()
4270 hw->active_pkg_ver.minor, in ice_log_pkg_init()
4271 hw->active_pkg_ver.update, in ice_log_pkg_init()
4272 hw->active_pkg_ver.draft, in ice_log_pkg_init()
4273 hw->pkg_name, in ice_log_pkg_init()
4274 hw->pkg_ver.major, in ice_log_pkg_init()
4275 hw->pkg_ver.minor, in ice_log_pkg_init()
4276 hw->pkg_ver.update, in ice_log_pkg_init()
4277 hw->pkg_ver.draft); in ice_log_pkg_init()
4312 * ice_load_pkg - load/reload the DDP Package file
4324 struct ice_hw *hw = &pf->hw; in ice_load_pkg()
4327 if (firmware && !hw->pkg_copy) { in ice_load_pkg()
4328 state = ice_copy_and_init_pkg(hw, firmware->data, in ice_load_pkg()
4329 firmware->size); in ice_load_pkg()
4331 } else if (!firmware && hw->pkg_copy) { in ice_load_pkg()
4333 state = ice_init_pkg(hw, hw->pkg_copy, hw->pkg_size); in ice_load_pkg()
4341 clear_bit(ICE_FLAG_ADV_FEATURES, pf->flags); in ice_load_pkg()
4345 /* Successful download package is the precondition for advanced in ice_load_pkg()
4348 set_bit(ICE_FLAG_ADV_FEATURES, pf->flags); in ice_load_pkg()
4352 * ice_verify_cacheline_size - verify driver's assumption of 64 Byte cache lines
4361 if (rd32(&pf->hw, GLPCI_CNF2) & GLPCI_CNF2_CACHELINE_SIZE_M) in ice_verify_cacheline_size()
4367 * ice_send_version - update firmware with driver version
4382 return ice_aq_send_driver_ver(&pf->hw, &dv, NULL); in ice_send_version()
4386 * ice_init_fdir - Initialize flow director VSI and configuration
4400 ctrl_vsi = ice_ctrl_vsi_setup(pf, pf->hw.port_info); in ice_init_fdir()
4403 return -ENOMEM; in ice_init_fdir()
4412 mutex_init(&pf->hw.fdir_fltr_lock); in ice_init_fdir()
4421 ice_fdir_release_flows(&pf->hw); in ice_init_fdir()
4425 if (pf->ctrl_vsi_idx != ICE_NO_VSI) { in ice_init_fdir()
4426 pf->vsi[pf->ctrl_vsi_idx] = NULL; in ice_init_fdir()
4427 pf->ctrl_vsi_idx = ICE_NO_VSI; in ice_init_fdir()
4441 if (pf->ctrl_vsi_idx != ICE_NO_VSI) { in ice_deinit_fdir()
4442 pf->vsi[pf->ctrl_vsi_idx] = NULL; in ice_deinit_fdir()
4443 pf->ctrl_vsi_idx = ICE_NO_VSI; in ice_deinit_fdir()
4446 mutex_destroy(&(&pf->hw)->fdir_fltr_lock); in ice_deinit_fdir()
4450 * ice_get_opt_fw_name - return optional firmware file name or NULL
4456 * followed by a EUI-64 identifier (PCIe Device Serial Number) in ice_get_opt_fw_name()
4458 struct pci_dev *pdev = pf->pdev; in ice_get_opt_fw_name()
4473 snprintf(opt_fw_filename, NAME_MAX, "%sice-%016llx.pkg", in ice_get_opt_fw_name()
4480 * ice_request_fw - Device initialization routine
4492 /* optional device-specific DDP (if present) overrides the default DDP in ice_request_fw()
4510 * ice_init_tx_topology - performs Tx topology initialization
4519 u8 num_tx_sched_layers = hw->num_tx_sched_layers; in ice_init_tx_topology()
4520 struct ice_pf *pf = hw->back; in ice_init_tx_topology()
4525 err = ice_cfg_tx_topo(hw, firmware->data, firmware->size); in ice_init_tx_topology()
4527 if (hw->num_tx_sched_layers > num_tx_sched_layers) in ice_init_tx_topology()
4532 * a CORER and we need to re-init hw in ice_init_tx_topology()
4538 } else if (err == -EIO) { in ice_init_tx_topology()
4539 …dev_info(dev, "DDP package does not support Tx scheduling layers switching feature - please update… in ice_init_tx_topology()
4546 * ice_init_ddp_config - DDP related configuration
4583 * ice_print_wake_reason - show the wake up cause in the log
4588 u32 wus = pf->wakeup_reason; in ice_print_wake_reason()
4610 * ice_pf_fwlog_update_module - update 1 module
4617 struct ice_hw *hw = &pf->hw; in ice_pf_fwlog_update_module()
4619 hw->fwlog_cfg.module_entries[module].log_level = log_level; in ice_pf_fwlog_update_module()
4623 * ice_register_netdev - register netdev
4630 if (!vsi || !vsi->netdev) in ice_register_netdev()
4631 return -EIO; in ice_register_netdev()
4633 err = register_netdev(vsi->netdev); in ice_register_netdev()
4637 set_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state); in ice_register_netdev()
4638 netif_carrier_off(vsi->netdev); in ice_register_netdev()
4639 netif_tx_stop_all_queues(vsi->netdev); in ice_register_netdev()
4646 if (!vsi || !vsi->netdev) in ice_unregister_netdev()
4649 unregister_netdev(vsi->netdev); in ice_unregister_netdev()
4650 clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state); in ice_unregister_netdev()
4654 * ice_cfg_netdev - Allocate, configure and register a netdev
4665 netdev = alloc_etherdev_mqs(sizeof(*np), vsi->alloc_txq, in ice_cfg_netdev()
4666 vsi->alloc_rxq); in ice_cfg_netdev()
4668 return -ENOMEM; in ice_cfg_netdev()
4670 set_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state); in ice_cfg_netdev()
4671 vsi->netdev = netdev; in ice_cfg_netdev()
4673 np->vsi = vsi; in ice_cfg_netdev()
4678 if (vsi->type == ICE_VSI_PF) { in ice_cfg_netdev()
4679 SET_NETDEV_DEV(netdev, ice_pf_to_dev(vsi->back)); in ice_cfg_netdev()
4680 ether_addr_copy(mac_addr, vsi->port_info->mac.perm_addr); in ice_cfg_netdev()
4684 netdev->priv_flags |= IFF_UNICAST_FLT; in ice_cfg_netdev()
4687 ice_vsi_cfg_netdev_tc(vsi, vsi->tc_cfg.ena_tc); in ice_cfg_netdev()
4689 netdev->max_mtu = ICE_MAX_MTU; in ice_cfg_netdev()
4696 clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state); in ice_decfg_netdev()
4697 free_netdev(vsi->netdev); in ice_decfg_netdev()
4698 vsi->netdev = NULL; in ice_decfg_netdev()
4702 * ice_wait_for_fw - wait for full FW readiness
4704 * @timeout: milliseconds that can elapse before timing out
4706 static int ice_wait_for_fw(struct ice_hw *hw, u32 timeout) in ice_wait_for_fw() argument
4711 while (elapsed <= timeout) { in ice_wait_for_fw()
4723 return -ETIMEDOUT; in ice_wait_for_fw()
4729 struct ice_hw *hw = &pf->hw; in ice_init_dev()
4755 * set in pf->state, which will cause ice_is_safe_mode to return in ice_init_dev()
4773 pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port; in ice_init_dev()
4774 pf->hw.udp_tunnel_nic.unset_port = ice_udp_tunnel_unset_port; in ice_init_dev()
4775 pf->hw.udp_tunnel_nic.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP; in ice_init_dev()
4776 pf->hw.udp_tunnel_nic.shared = &pf->hw.udp_tunnel_shared; in ice_init_dev()
4777 if (pf->hw.tnl.valid_count[TNL_VXLAN]) { in ice_init_dev()
4778 pf->hw.udp_tunnel_nic.tables[0].n_entries = in ice_init_dev()
4779 pf->hw.tnl.valid_count[TNL_VXLAN]; in ice_init_dev()
4780 pf->hw.udp_tunnel_nic.tables[0].tunnel_types = in ice_init_dev()
4783 if (pf->hw.tnl.valid_count[TNL_GENEVE]) { in ice_init_dev()
4784 pf->hw.udp_tunnel_nic.tables[1].n_entries = in ice_init_dev()
4785 pf->hw.tnl.valid_count[TNL_GENEVE]; in ice_init_dev()
4786 pf->hw.udp_tunnel_nic.tables[1].tunnel_types = in ice_init_dev()
4793 err = -EIO; in ice_init_dev()
4823 ice_deinit_hw(&pf->hw); in ice_deinit_dev()
4826 ice_reset(&pf->hw, ICE_RESET_PFR); in ice_deinit_dev()
4827 pci_wait_for_pending_transaction(pf->pdev); in ice_deinit_dev()
4839 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_init_features()
4849 /* Note: Flow director init failure is non-fatal to load */ in ice_init_features()
4853 /* Note: DCB init failure is non-fatal to load */ in ice_init_features()
4855 clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); in ice_init_features()
4856 clear_bit(ICE_FLAG_DCB_ENA, pf->flags); in ice_init_features()
4858 ice_cfg_lldp_mib_change(&pf->hw, true); in ice_init_features()
4873 if (test_bit(ICE_FLAG_DCB_CAPABLE, pf->flags)) in ice_deinit_features()
4874 ice_cfg_lldp_mib_change(&pf->hw, false); in ice_deinit_features()
4878 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_deinit_features()
4880 if (test_bit(ICE_FLAG_DPLL, pf->flags)) in ice_deinit_features()
4882 if (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_SWITCHDEV) in ice_deinit_features()
4883 xa_destroy(&pf->eswitch.reprs); in ice_deinit_features()
4889 pf->wakeup_reason = rd32(&pf->hw, PFPM_WUS); in ice_init_wakeup()
4895 wr32(&pf->hw, PFPM_WUS, U32_MAX); in ice_init_wakeup()
4906 err = ice_init_link_events(pf->hw.port_info); in ice_init_link()
4913 err = ice_init_nvm_phy_type(pf->hw.port_info); in ice_init_link()
4918 err = ice_update_link_info(pf->hw.port_info); in ice_init_link()
4922 ice_init_link_dflt_override(pf->hw.port_info); in ice_init_link()
4925 pf->hw.port_info->phy.link_info.link_cfg_err); in ice_init_link()
4928 if (pf->hw.port_info->phy.link_info.link_info & in ice_init_link()
4931 err = ice_init_phy_user_cfg(pf->hw.port_info); in ice_init_link()
4935 if (!test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags)) { in ice_init_link()
4942 set_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_init_link()
4950 bool dvm = ice_is_dvm_ena(&pf->hw); in ice_init_pf_sw()
4955 pf->first_sw = kzalloc(sizeof(*pf->first_sw), GFP_KERNEL); in ice_init_pf_sw()
4956 if (!pf->first_sw) in ice_init_pf_sw()
4957 return -ENOMEM; in ice_init_pf_sw()
4959 if (pf->hw.evb_veb) in ice_init_pf_sw()
4960 pf->first_sw->bridge_mode = BRIDGE_MODE_VEB; in ice_init_pf_sw()
4962 pf->first_sw->bridge_mode = BRIDGE_MODE_VEPA; in ice_init_pf_sw()
4964 pf->first_sw->pf = pf; in ice_init_pf_sw()
4967 pf->first_sw->sw_id = pf->hw.port_info->sw_id; in ice_init_pf_sw()
4969 err = ice_aq_set_port_params(pf->hw.port_info, dvm, NULL); in ice_init_pf_sw()
4973 vsi = ice_pf_vsi_setup(pf, pf->hw.port_info); in ice_init_pf_sw()
4975 err = -ENOMEM; in ice_init_pf_sw()
4983 kfree(pf->first_sw); in ice_init_pf_sw()
4995 kfree(pf->first_sw); in ice_deinit_pf_sw()
5002 pf->num_alloc_vsi = pf->hw.func_caps.guar_num_vsi; in ice_alloc_vsis()
5003 if (!pf->num_alloc_vsi) in ice_alloc_vsis()
5004 return -EIO; in ice_alloc_vsis()
5006 if (pf->num_alloc_vsi > UDP_TUNNEL_NIC_MAX_SHARING_DEVICES) { in ice_alloc_vsis()
5009 pf->num_alloc_vsi, UDP_TUNNEL_NIC_MAX_SHARING_DEVICES); in ice_alloc_vsis()
5010 pf->num_alloc_vsi = UDP_TUNNEL_NIC_MAX_SHARING_DEVICES; in ice_alloc_vsis()
5013 pf->vsi = devm_kcalloc(dev, pf->num_alloc_vsi, sizeof(*pf->vsi), in ice_alloc_vsis()
5015 if (!pf->vsi) in ice_alloc_vsis()
5016 return -ENOMEM; in ice_alloc_vsis()
5018 pf->vsi_stats = devm_kcalloc(dev, pf->num_alloc_vsi, in ice_alloc_vsis()
5019 sizeof(*pf->vsi_stats), GFP_KERNEL); in ice_alloc_vsis()
5020 if (!pf->vsi_stats) { in ice_alloc_vsis()
5021 devm_kfree(dev, pf->vsi); in ice_alloc_vsis()
5022 return -ENOMEM; in ice_alloc_vsis()
5030 devm_kfree(ice_pf_to_dev(pf), pf->vsi_stats); in ice_dealloc_vsis()
5031 pf->vsi_stats = NULL; in ice_dealloc_vsis()
5033 pf->num_alloc_vsi = 0; in ice_dealloc_vsis()
5034 devm_kfree(ice_pf_to_dev(pf), pf->vsi); in ice_dealloc_vsis()
5035 pf->vsi = NULL; in ice_dealloc_vsis()
5091 pcie_print_link_status(pf->pdev); in ice_init()
5094 clear_bit(ICE_DOWN, pf->state); in ice_init()
5095 clear_bit(ICE_SERVICE_DIS, pf->state); in ice_init()
5098 mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period)); in ice_init()
5113 set_bit(ICE_SERVICE_DIS, pf->state); in ice_deinit()
5114 set_bit(ICE_DOWN, pf->state); in ice_deinit()
5122 * ice_load - load pf by init hw and starting VSI
5137 INIT_LIST_HEAD(&vsi->ch_list); in ice_load()
5154 SET_NETDEV_DEVLINK_PORT(vsi->netdev, &pf->devlink_port); in ice_load()
5173 clear_bit(ICE_DOWN, pf->state); in ice_load()
5190 * ice_unload - unload pf by stopping VSI and deinit hw
5210 * ice_probe - Device initialization routine
5219 struct device *dev = &pdev->dev; in ice_probe()
5225 if (pdev->is_virtfn) { in ice_probe()
5227 return -EINVAL; in ice_probe()
5245 * Documentation/driver-api/driver-model/devres.rst in ice_probe()
5259 return -ENOMEM; in ice_probe()
5262 pf->aux_idx = -1; in ice_probe()
5277 pf->pdev = pdev; in ice_probe()
5278 pf->adapter = adapter; in ice_probe()
5280 set_bit(ICE_DOWN, pf->state); in ice_probe()
5282 set_bit(ICE_SERVICE_DIS, pf->state); in ice_probe()
5284 hw = &pf->hw; in ice_probe()
5285 hw->hw_addr = pcim_iomap_table(pdev)[ICE_BAR0]; in ice_probe()
5288 hw->back = pf; in ice_probe()
5289 hw->port_info = NULL; in ice_probe()
5290 hw->vendor_id = pdev->vendor; in ice_probe()
5291 hw->device_id = pdev->device; in ice_probe()
5292 pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id); in ice_probe()
5293 hw->subsystem_vendor_id = pdev->subsystem_vendor; in ice_probe()
5294 hw->subsystem_device_id = pdev->subsystem_device; in ice_probe()
5295 hw->bus.device = PCI_SLOT(pdev->devfn); in ice_probe()
5296 hw->bus.func = PCI_FUNC(pdev->devfn); in ice_probe()
5299 pf->msg_enable = netif_msg_init(debug, ICE_DFLT_NETIF_M); in ice_probe()
5302 if (debug < -1) in ice_probe()
5303 hw->debug_mask = debug; in ice_probe()
5333 * ice_set_wake - enable or disable Wake on LAN
5340 struct ice_hw *hw = &pf->hw; in ice_set_wake()
5341 bool wol = pf->wol_ena; in ice_set_wake()
5354 * ice_setup_mc_magic_wake - setup device to wake on multicast magic packet
5364 struct ice_hw *hw = &pf->hw; in ice_setup_mc_magic_wake()
5370 if (!pf->wol_ena) in ice_setup_mc_magic_wake()
5378 if (vsi->netdev) in ice_setup_mc_magic_wake()
5379 ether_addr_copy(mac_addr, vsi->netdev->dev_addr); in ice_setup_mc_magic_wake()
5381 ether_addr_copy(mac_addr, vsi->port_info->mac.perm_addr); in ice_setup_mc_magic_wake()
5390 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_setup_mc_magic_wake()
5394 * ice_remove - Device removal routine
5403 if (!ice_is_reset_in_progress(pf->state)) in ice_remove()
5408 if (test_bit(ICE_FLAG_SRIOV_ENA, pf->flags)) { in ice_remove()
5409 set_bit(ICE_VF_RESETS_DISABLED, pf->state); in ice_remove()
5417 set_bit(ICE_DOWN, pf->state); in ice_remove()
5439 * ice_shutdown - PCI callback for shutting down device
5449 pci_wake_from_d3(pdev, pf->wol_ena); in ice_shutdown()
5455 * ice_prepare_for_shutdown - prep for PCI shutdown
5462 struct ice_hw *hw = &pf->hw; in ice_prepare_for_shutdown()
5466 if (ice_check_sq_alive(hw, &hw->mailboxq)) in ice_prepare_for_shutdown()
5475 if (pf->vsi[v]) in ice_prepare_for_shutdown()
5476 pf->vsi[v]->vsi_num = 0; in ice_prepare_for_shutdown()
5482 * ice_reinit_interrupt_scheme - Reinitialize interrupt scheme
5488 * This should be called during resume routine to re-allocate the q_vectors
5502 dev_err(dev, "Failed to re-initialize interrupt %d\n", ret); in ice_reinit_interrupt_scheme()
5506 /* Remap vectors and rings, after successful re-init interrupts */ in ice_reinit_interrupt_scheme()
5508 if (!pf->vsi[v]) in ice_reinit_interrupt_scheme()
5511 ret = ice_vsi_alloc_q_vectors(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5514 ice_vsi_map_rings_to_vectors(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5516 ice_vsi_set_napi_queues(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5530 while (v--) in ice_reinit_interrupt_scheme()
5531 if (pf->vsi[v]) { in ice_reinit_interrupt_scheme()
5533 ice_vsi_clear_napi_queues(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5535 ice_vsi_free_q_vectors(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5558 return -EBUSY; in ice_suspend()
5572 if (test_and_set_bit(ICE_SUSPENDED, pf->state)) { in ice_suspend()
5578 if (test_bit(ICE_DOWN, pf->state) || in ice_suspend()
5579 ice_is_reset_in_progress(pf->state)) { in ice_suspend()
5599 if (!pf->vsi[v]) in ice_suspend()
5602 ice_vsi_clear_napi_queues(pf->vsi[v]); in ice_suspend()
5604 ice_vsi_free_q_vectors(pf->vsi[v]); in ice_suspend()
5609 pci_wake_from_d3(pdev, pf->wol_ena); in ice_suspend()
5615 * ice_resume - PM callback for waking up from D3
5631 return -ENODEV; in ice_resume()
5640 hw = &pf->hw; in ice_resume()
5642 pf->wakeup_reason = rd32(hw, PFPM_WUS); in ice_resume()
5657 clear_bit(ICE_DOWN, pf->state); in ice_resume()
5660 /* re-enable service task for reset, but allow reset to schedule it */ in ice_resume()
5661 clear_bit(ICE_SERVICE_DIS, pf->state); in ice_resume()
5666 clear_bit(ICE_SUSPENDED, pf->state); in ice_resume()
5670 mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period)); in ice_resume()
5676 * ice_pci_err_detected - warning that PCI error has been detected
5689 dev_err(&pdev->dev, "%s: unrecoverable device error %d\n", in ice_pci_err_detected()
5694 if (!test_bit(ICE_SUSPENDED, pf->state)) { in ice_pci_err_detected()
5697 if (!test_bit(ICE_PREPARED_FOR_RESET, pf->state)) { in ice_pci_err_detected()
5698 set_bit(ICE_PFR_REQ, pf->state); in ice_pci_err_detected()
5707 * ice_pci_err_slot_reset - a PCI slot reset has just happened
5722 dev_err(&pdev->dev, "Cannot re-enable PCI device after reset, error %d\n", in ice_pci_err_slot_reset()
5732 reg = rd32(&pf->hw, GLGEN_RTRIG); in ice_pci_err_slot_reset()
5743 * ice_pci_err_resume - restart operations after PCI error recovery
5754 dev_err(&pdev->dev, "%s failed, device is unrecoverable\n", in ice_pci_err_resume()
5759 if (test_bit(ICE_SUSPENDED, pf->state)) { in ice_pci_err_resume()
5760 dev_dbg(&pdev->dev, "%s failed to resume normal operations!\n", in ice_pci_err_resume()
5769 mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period)); in ice_pci_err_resume()
5773 * ice_pci_err_reset_prepare - prepare device driver for PCI reset
5780 if (!test_bit(ICE_SUSPENDED, pf->state)) { in ice_pci_err_reset_prepare()
5783 if (!test_bit(ICE_PREPARED_FOR_RESET, pf->state)) { in ice_pci_err_reset_prepare()
5784 set_bit(ICE_PFR_REQ, pf->state); in ice_pci_err_reset_prepare()
5791 * ice_pci_err_reset_done - PCI reset done, device driver reset can begin
5799 /* ice_pci_tbl - PCI Device ID Table
5877 * ice_module_init - Driver registration routine
5884 int status = -ENOMEM; in ice_module_init()
5931 * ice_module_exit - Driver exit cleanup routine
5948 * ice_set_mac_address - NDO callback to set MAC address
5957 struct ice_vsi *vsi = np->vsi; in ice_set_mac_address()
5958 struct ice_pf *pf = vsi->back; in ice_set_mac_address()
5959 struct ice_hw *hw = &pf->hw; in ice_set_mac_address()
5966 mac = (u8 *)addr->sa_data; in ice_set_mac_address()
5969 return -EADDRNOTAVAIL; in ice_set_mac_address()
5971 if (test_bit(ICE_DOWN, pf->state) || in ice_set_mac_address()
5972 ice_is_reset_in_progress(pf->state)) { in ice_set_mac_address()
5975 return -EBUSY; in ice_set_mac_address()
5979 …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()
5981 return -EAGAIN; in ice_set_mac_address()
5985 ether_addr_copy(old_mac, netdev->dev_addr); in ice_set_mac_address()
5992 if (err && err != -ENOENT) { in ice_set_mac_address()
5993 err = -EADDRNOTAVAIL; in ice_set_mac_address()
5999 if (err == -EEXIST) { in ice_set_mac_address()
6010 err = -EADDRNOTAVAIL; in ice_set_mac_address()
6023 netdev_dbg(vsi->netdev, "updated MAC address to %pM\n", in ice_set_mac_address()
6024 netdev->dev_addr); in ice_set_mac_address()
6037 * ice_set_rx_mode - NDO callback to set the netdev filters
6043 struct ice_vsi *vsi = np->vsi; in ice_set_rx_mode()
6045 if (!vsi || ice_is_switchdev_running(vsi->back)) in ice_set_rx_mode()
6052 set_bit(ICE_VSI_UMAC_FLTR_CHANGED, vsi->state); in ice_set_rx_mode()
6053 set_bit(ICE_VSI_MMAC_FLTR_CHANGED, vsi->state); in ice_set_rx_mode()
6054 set_bit(ICE_FLAG_FLTR_SYNC, vsi->back->flags); in ice_set_rx_mode()
6059 ice_service_task_schedule(vsi->back); in ice_set_rx_mode()
6063 * ice_set_tx_maxrate - NDO callback to set the maximum per-queue bitrate
6072 struct ice_vsi *vsi = np->vsi; in ice_set_tx_maxrate()
6081 return -EINVAL; in ice_set_tx_maxrate()
6084 q_handle = vsi->tx_rings[queue_index]->q_handle; in ice_set_tx_maxrate()
6091 return -EINVAL; in ice_set_tx_maxrate()
6096 status = ice_cfg_q_bw_dflt_lmt(vsi->port_info, vsi->idx, tc, in ice_set_tx_maxrate()
6099 status = ice_cfg_q_bw_lmt(vsi->port_info, vsi->idx, tc, in ice_set_tx_maxrate()
6109 * ice_fdb_add - add an entry to the hardware database
6127 return -EINVAL; in ice_fdb_add()
6129 if (ndm->ndm_state && !(ndm->ndm_state & NUD_PERMANENT)) { in ice_fdb_add()
6131 return -EINVAL; in ice_fdb_add()
6139 err = -EINVAL; in ice_fdb_add()
6142 if (err == -EEXIST && !(flags & NLM_F_EXCL)) in ice_fdb_add()
6149 * ice_fdb_del - delete an entry from the hardware database
6164 if (ndm->ndm_state & NUD_PERMANENT) { in ice_fdb_del()
6166 return -EINVAL; in ice_fdb_del()
6174 err = -EINVAL; in ice_fdb_del()
6191 * ice_fix_features - fix the netdev features flags based on device limitations
6234 cur_vlan_fltr = netdev->features & NETIF_VLAN_FILTERING_FEATURES; in ice_fix_features()
6243 if (ice_is_dvm_ena(&np->vsi->back->hw)) { in ice_fix_features()
6273 if (!(netdev->features & NETIF_F_RXFCS) && in ice_fix_features()
6276 !ice_vsi_has_non_zero_vlans(np->vsi)) { in ice_fix_features()
6285 * ice_set_rx_rings_vlan_proto - update rings with new stripped VLAN proto
6298 vsi->rx_rings[i]->pkt_ctx.vlan_proto = vlan_ethertype; in ice_set_rx_rings_vlan_proto()
6302 * ice_set_vlan_offload_features - set VLAN offload features for the PF VSI
6331 strip_err = vlan_ops->ena_stripping(vsi, vlan_ethertype); in ice_set_vlan_offload_features()
6333 strip_err = vlan_ops->dis_stripping(vsi); in ice_set_vlan_offload_features()
6336 insert_err = vlan_ops->ena_insertion(vsi, vlan_ethertype); in ice_set_vlan_offload_features()
6338 insert_err = vlan_ops->dis_insertion(vsi); in ice_set_vlan_offload_features()
6341 return -EIO; in ice_set_vlan_offload_features()
6350 * ice_set_vlan_filtering_features - set VLAN filtering features for the PF VSI
6368 err = vlan_ops->ena_rx_filtering(vsi); in ice_set_vlan_filtering_features()
6370 err = vlan_ops->dis_rx_filtering(vsi); in ice_set_vlan_filtering_features()
6376 * ice_set_vlan_features - set VLAN settings based on suggested feature set
6388 struct ice_vsi *vsi = np->vsi; in ice_set_vlan_features()
6391 current_vlan_features = netdev->features & NETIF_VLAN_OFFLOAD_FEATURES; in ice_set_vlan_features()
6396 dev_err(ice_pf_to_dev(vsi->back), in ice_set_vlan_features()
6398 return -EIO; in ice_set_vlan_features()
6406 current_vlan_features = netdev->features & in ice_set_vlan_features()
6419 * ice_set_loopback - turn on/off loopback mode on underlying PF
6425 bool if_running = netif_running(vsi->netdev); in ice_set_loopback()
6428 if (if_running && !test_and_set_bit(ICE_VSI_DOWN, vsi->state)) { in ice_set_loopback()
6431 netdev_err(vsi->netdev, "Preparing device to toggle loopback failed\n"); in ice_set_loopback()
6435 ret = ice_aq_set_mac_loopback(&vsi->back->hw, ena, NULL); in ice_set_loopback()
6437 netdev_err(vsi->netdev, "Failed to toggle loopback state\n"); in ice_set_loopback()
6445 * ice_set_features - set the netdev feature flags
6452 netdev_features_t changed = netdev->features ^ features; in ice_set_features()
6454 struct ice_vsi *vsi = np->vsi; in ice_set_features()
6455 struct ice_pf *pf = vsi->back; in ice_set_features()
6461 "Device is in Safe Mode - not enabling advanced netdev features\n"); in ice_set_features()
6466 if (ice_is_reset_in_progress(pf->state)) { in ice_set_features()
6469 return -EBUSY; in ice_set_features()
6488 dev_err(ice_pf_to_dev(vsi->back), in ice_set_features()
6490 return -EIO; in ice_set_features()
6509 return -EACCES; in ice_set_features()
6515 ena ? set_bit(ICE_FLAG_CLS_FLOWER, pf->flags) : in ice_set_features()
6516 clear_bit(ICE_FLAG_CLS_FLOWER, pf->flags); in ice_set_features()
6526 * ice_vsi_vlan_setup - Setup VLAN offload properties on a PF VSI
6533 err = ice_set_vlan_offload_features(vsi, vsi->netdev->features); in ice_vsi_vlan_setup()
6537 err = ice_set_vlan_filtering_features(vsi, vsi->netdev->features); in ice_vsi_vlan_setup()
6545 * ice_vsi_cfg_lan - Setup the VSI lan related config
6554 if (vsi->netdev && vsi->type == ICE_VSI_PF) { in ice_vsi_cfg_lan()
6555 ice_set_rx_mode(vsi->netdev); in ice_vsi_cfg_lan()
6576 * which is hard-coded to a limit of 250,000 ints/second.
6578 * by ethtool rx-usecs-high.
6617 rc = dim->priv; in ice_tx_dim_work()
6619 WARN_ON(dim->profile_ix >= ARRAY_SIZE(tx_profile)); in ice_tx_dim_work()
6622 itr = tx_profile[dim->profile_ix].itr; in ice_tx_dim_work()
6627 dim->state = DIM_START_MEASURE; in ice_tx_dim_work()
6637 rc = dim->priv; in ice_rx_dim_work()
6639 WARN_ON(dim->profile_ix >= ARRAY_SIZE(rx_profile)); in ice_rx_dim_work()
6642 itr = rx_profile[dim->profile_ix].itr; in ice_rx_dim_work()
6647 dim->state = DIM_START_MEASURE; in ice_rx_dim_work()
6653 * ice_init_moderation - set up interrupt moderation
6667 rc = &q_vector->tx; in ice_init_moderation()
6668 INIT_WORK(&rc->dim.work, ice_tx_dim_work); in ice_init_moderation()
6669 rc->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; in ice_init_moderation()
6670 rc->dim.profile_ix = ICE_DIM_DEFAULT_PROFILE_IX; in ice_init_moderation()
6671 rc->dim.priv = rc; in ice_init_moderation()
6676 tx_profile[rc->dim.profile_ix].itr : rc->itr_setting); in ice_init_moderation()
6678 rc = &q_vector->rx; in ice_init_moderation()
6679 INIT_WORK(&rc->dim.work, ice_rx_dim_work); in ice_init_moderation()
6680 rc->dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; in ice_init_moderation()
6681 rc->dim.profile_ix = ICE_DIM_DEFAULT_PROFILE_IX; in ice_init_moderation()
6682 rc->dim.priv = rc; in ice_init_moderation()
6686 ice_write_itr(rc, rx_dynamic ? rx_profile[rc->dim.profile_ix].itr : in ice_init_moderation()
6687 rc->itr_setting); in ice_init_moderation()
6693 * ice_napi_enable_all - Enable NAPI for all q_vectors in the VSI
6700 if (!vsi->netdev) in ice_napi_enable_all()
6704 struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; in ice_napi_enable_all()
6708 if (q_vector->rx.rx_ring || q_vector->tx.tx_ring) in ice_napi_enable_all()
6709 napi_enable(&q_vector->napi); in ice_napi_enable_all()
6714 * ice_up_complete - Finish the last steps of bringing up a connection
6721 struct ice_pf *pf = vsi->back; in ice_up_complete()
6734 clear_bit(ICE_VSI_DOWN, vsi->state); in ice_up_complete()
6738 if (vsi->port_info && in ice_up_complete()
6739 (vsi->port_info->phy.link_info.link_info & ICE_AQ_LINK_UP) && in ice_up_complete()
6740 ((vsi->netdev && (vsi->type == ICE_VSI_PF || in ice_up_complete()
6741 vsi->type == ICE_VSI_SF)))) { in ice_up_complete()
6743 netif_tx_start_all_queues(vsi->netdev); in ice_up_complete()
6744 netif_carrier_on(vsi->netdev); in ice_up_complete()
6745 ice_ptp_link_change(pf, pf->hw.pf_id, true); in ice_up_complete()
6753 if (vsi->type == ICE_VSI_PF) in ice_up_complete()
6760 * ice_up - Bring the connection back up after being down
6775 * ice_fetch_u64_stats_per_ring - get packets and bytes stats per ring
6798 * ice_update_vsi_tx_ring_stats - Update VSI Tx ring stats counters
6816 if (!ring || !ring->ring_stats) in ice_update_vsi_tx_ring_stats()
6818 ice_fetch_u64_stats_per_ring(&ring->ring_stats->syncp, in ice_update_vsi_tx_ring_stats()
6819 ring->ring_stats->stats, &pkts, in ice_update_vsi_tx_ring_stats()
6821 vsi_stats->tx_packets += pkts; in ice_update_vsi_tx_ring_stats()
6822 vsi_stats->tx_bytes += bytes; in ice_update_vsi_tx_ring_stats()
6823 vsi->tx_restart += ring->ring_stats->tx_stats.restart_q; in ice_update_vsi_tx_ring_stats()
6824 vsi->tx_busy += ring->ring_stats->tx_stats.tx_busy; in ice_update_vsi_tx_ring_stats()
6825 vsi->tx_linearize += ring->ring_stats->tx_stats.tx_linearize; in ice_update_vsi_tx_ring_stats()
6830 * ice_update_vsi_ring_stats - Update VSI stats counters
6837 struct ice_pf *pf = vsi->back; in ice_update_vsi_ring_stats()
6845 /* reset non-netdev (extended) stats */ in ice_update_vsi_ring_stats()
6846 vsi->tx_restart = 0; in ice_update_vsi_ring_stats()
6847 vsi->tx_busy = 0; in ice_update_vsi_ring_stats()
6848 vsi->tx_linearize = 0; in ice_update_vsi_ring_stats()
6849 vsi->rx_buf_failed = 0; in ice_update_vsi_ring_stats()
6850 vsi->rx_page_failed = 0; in ice_update_vsi_ring_stats()
6855 ice_update_vsi_tx_ring_stats(vsi, vsi_stats, vsi->tx_rings, in ice_update_vsi_ring_stats()
6856 vsi->num_txq); in ice_update_vsi_ring_stats()
6860 struct ice_rx_ring *ring = READ_ONCE(vsi->rx_rings[i]); in ice_update_vsi_ring_stats()
6863 ring_stats = ring->ring_stats; in ice_update_vsi_ring_stats()
6864 ice_fetch_u64_stats_per_ring(&ring_stats->syncp, in ice_update_vsi_ring_stats()
6865 ring_stats->stats, &pkts, in ice_update_vsi_ring_stats()
6867 vsi_stats->rx_packets += pkts; in ice_update_vsi_ring_stats()
6868 vsi_stats->rx_bytes += bytes; in ice_update_vsi_ring_stats()
6869 vsi->rx_buf_failed += ring_stats->rx_stats.alloc_buf_failed; in ice_update_vsi_ring_stats()
6870 vsi->rx_page_failed += ring_stats->rx_stats.alloc_page_failed; in ice_update_vsi_ring_stats()
6875 ice_update_vsi_tx_ring_stats(vsi, vsi_stats, vsi->xdp_rings, in ice_update_vsi_ring_stats()
6876 vsi->num_xdp_txq); in ice_update_vsi_ring_stats()
6880 net_stats = &vsi->net_stats; in ice_update_vsi_ring_stats()
6881 stats_prev = &vsi->net_stats_prev; in ice_update_vsi_ring_stats()
6885 * diff of Prev-Cur, we need to be sure that Prev is valid. If it's not, in ice_update_vsi_ring_stats()
6888 if (likely(pf->stat_prev_loaded)) { in ice_update_vsi_ring_stats()
6889 net_stats->tx_packets += vsi_stats->tx_packets - stats_prev->tx_packets; in ice_update_vsi_ring_stats()
6890 net_stats->tx_bytes += vsi_stats->tx_bytes - stats_prev->tx_bytes; in ice_update_vsi_ring_stats()
6891 net_stats->rx_packets += vsi_stats->rx_packets - stats_prev->rx_packets; in ice_update_vsi_ring_stats()
6892 net_stats->rx_bytes += vsi_stats->rx_bytes - stats_prev->rx_bytes; in ice_update_vsi_ring_stats()
6895 stats_prev->tx_packets = vsi_stats->tx_packets; in ice_update_vsi_ring_stats()
6896 stats_prev->tx_bytes = vsi_stats->tx_bytes; in ice_update_vsi_ring_stats()
6897 stats_prev->rx_packets = vsi_stats->rx_packets; in ice_update_vsi_ring_stats()
6898 stats_prev->rx_bytes = vsi_stats->rx_bytes; in ice_update_vsi_ring_stats()
6904 * ice_update_vsi_stats - Update VSI stats counters
6909 struct rtnl_link_stats64 *cur_ns = &vsi->net_stats; in ice_update_vsi_stats()
6910 struct ice_eth_stats *cur_es = &vsi->eth_stats; in ice_update_vsi_stats()
6911 struct ice_pf *pf = vsi->back; in ice_update_vsi_stats()
6913 if (test_bit(ICE_VSI_DOWN, vsi->state) || in ice_update_vsi_stats()
6914 test_bit(ICE_CFG_BUSY, pf->state)) in ice_update_vsi_stats()
6923 cur_ns->tx_errors = cur_es->tx_errors; in ice_update_vsi_stats()
6924 cur_ns->rx_dropped = cur_es->rx_discards; in ice_update_vsi_stats()
6925 cur_ns->tx_dropped = cur_es->tx_discards; in ice_update_vsi_stats()
6926 cur_ns->multicast = cur_es->rx_multicast; in ice_update_vsi_stats()
6929 if (vsi->type == ICE_VSI_PF) { in ice_update_vsi_stats()
6930 cur_ns->rx_crc_errors = pf->stats.crc_errors; in ice_update_vsi_stats()
6931 cur_ns->rx_errors = pf->stats.crc_errors + in ice_update_vsi_stats()
6932 pf->stats.illegal_bytes + in ice_update_vsi_stats()
6933 pf->stats.rx_undersize + in ice_update_vsi_stats()
6934 pf->hw_csum_rx_error + in ice_update_vsi_stats()
6935 pf->stats.rx_jabber + in ice_update_vsi_stats()
6936 pf->stats.rx_fragments + in ice_update_vsi_stats()
6937 pf->stats.rx_oversize; in ice_update_vsi_stats()
6939 cur_ns->rx_missed_errors = pf->stats.eth.rx_discards; in ice_update_vsi_stats()
6944 * ice_update_pf_stats - Update PF port stats counters
6950 struct ice_hw *hw = &pf->hw; in ice_update_pf_stats()
6954 port = hw->port_info->lport; in ice_update_pf_stats()
6955 prev_ps = &pf->stats_prev; in ice_update_pf_stats()
6956 cur_ps = &pf->stats; in ice_update_pf_stats()
6958 if (ice_is_reset_in_progress(pf->state)) in ice_update_pf_stats()
6959 pf->stat_prev_loaded = false; in ice_update_pf_stats()
6961 ice_stat_update40(hw, GLPRT_GORCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6962 &prev_ps->eth.rx_bytes, in ice_update_pf_stats()
6963 &cur_ps->eth.rx_bytes); in ice_update_pf_stats()
6965 ice_stat_update40(hw, GLPRT_UPRCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6966 &prev_ps->eth.rx_unicast, in ice_update_pf_stats()
6967 &cur_ps->eth.rx_unicast); in ice_update_pf_stats()
6969 ice_stat_update40(hw, GLPRT_MPRCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6970 &prev_ps->eth.rx_multicast, in ice_update_pf_stats()
6971 &cur_ps->eth.rx_multicast); in ice_update_pf_stats()
6973 ice_stat_update40(hw, GLPRT_BPRCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6974 &prev_ps->eth.rx_broadcast, in ice_update_pf_stats()
6975 &cur_ps->eth.rx_broadcast); in ice_update_pf_stats()
6977 ice_stat_update32(hw, PRTRPB_RDPC, pf->stat_prev_loaded, in ice_update_pf_stats()
6978 &prev_ps->eth.rx_discards, in ice_update_pf_stats()
6979 &cur_ps->eth.rx_discards); in ice_update_pf_stats()
6981 ice_stat_update40(hw, GLPRT_GOTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6982 &prev_ps->eth.tx_bytes, in ice_update_pf_stats()
6983 &cur_ps->eth.tx_bytes); in ice_update_pf_stats()
6985 ice_stat_update40(hw, GLPRT_UPTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6986 &prev_ps->eth.tx_unicast, in ice_update_pf_stats()
6987 &cur_ps->eth.tx_unicast); in ice_update_pf_stats()
6989 ice_stat_update40(hw, GLPRT_MPTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6990 &prev_ps->eth.tx_multicast, in ice_update_pf_stats()
6991 &cur_ps->eth.tx_multicast); in ice_update_pf_stats()
6993 ice_stat_update40(hw, GLPRT_BPTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6994 &prev_ps->eth.tx_broadcast, in ice_update_pf_stats()
6995 &cur_ps->eth.tx_broadcast); in ice_update_pf_stats()
6997 ice_stat_update32(hw, GLPRT_TDOLD(port), pf->stat_prev_loaded, in ice_update_pf_stats()
6998 &prev_ps->tx_dropped_link_down, in ice_update_pf_stats()
6999 &cur_ps->tx_dropped_link_down); in ice_update_pf_stats()
7001 ice_stat_update40(hw, GLPRT_PRC64L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7002 &prev_ps->rx_size_64, &cur_ps->rx_size_64); in ice_update_pf_stats()
7004 ice_stat_update40(hw, GLPRT_PRC127L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7005 &prev_ps->rx_size_127, &cur_ps->rx_size_127); in ice_update_pf_stats()
7007 ice_stat_update40(hw, GLPRT_PRC255L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7008 &prev_ps->rx_size_255, &cur_ps->rx_size_255); in ice_update_pf_stats()
7010 ice_stat_update40(hw, GLPRT_PRC511L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7011 &prev_ps->rx_size_511, &cur_ps->rx_size_511); in ice_update_pf_stats()
7013 ice_stat_update40(hw, GLPRT_PRC1023L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7014 &prev_ps->rx_size_1023, &cur_ps->rx_size_1023); in ice_update_pf_stats()
7016 ice_stat_update40(hw, GLPRT_PRC1522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7017 &prev_ps->rx_size_1522, &cur_ps->rx_size_1522); in ice_update_pf_stats()
7019 ice_stat_update40(hw, GLPRT_PRC9522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7020 &prev_ps->rx_size_big, &cur_ps->rx_size_big); in ice_update_pf_stats()
7022 ice_stat_update40(hw, GLPRT_PTC64L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7023 &prev_ps->tx_size_64, &cur_ps->tx_size_64); in ice_update_pf_stats()
7025 ice_stat_update40(hw, GLPRT_PTC127L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7026 &prev_ps->tx_size_127, &cur_ps->tx_size_127); in ice_update_pf_stats()
7028 ice_stat_update40(hw, GLPRT_PTC255L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7029 &prev_ps->tx_size_255, &cur_ps->tx_size_255); in ice_update_pf_stats()
7031 ice_stat_update40(hw, GLPRT_PTC511L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7032 &prev_ps->tx_size_511, &cur_ps->tx_size_511); in ice_update_pf_stats()
7034 ice_stat_update40(hw, GLPRT_PTC1023L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7035 &prev_ps->tx_size_1023, &cur_ps->tx_size_1023); in ice_update_pf_stats()
7037 ice_stat_update40(hw, GLPRT_PTC1522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7038 &prev_ps->tx_size_1522, &cur_ps->tx_size_1522); in ice_update_pf_stats()
7040 ice_stat_update40(hw, GLPRT_PTC9522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7041 &prev_ps->tx_size_big, &cur_ps->tx_size_big); in ice_update_pf_stats()
7043 fd_ctr_base = hw->fd_ctr_base; in ice_update_pf_stats()
7047 pf->stat_prev_loaded, &prev_ps->fd_sb_match, in ice_update_pf_stats()
7048 &cur_ps->fd_sb_match); in ice_update_pf_stats()
7049 ice_stat_update32(hw, GLPRT_LXONRXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7050 &prev_ps->link_xon_rx, &cur_ps->link_xon_rx); in ice_update_pf_stats()
7052 ice_stat_update32(hw, GLPRT_LXOFFRXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7053 &prev_ps->link_xoff_rx, &cur_ps->link_xoff_rx); in ice_update_pf_stats()
7055 ice_stat_update32(hw, GLPRT_LXONTXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7056 &prev_ps->link_xon_tx, &cur_ps->link_xon_tx); in ice_update_pf_stats()
7058 ice_stat_update32(hw, GLPRT_LXOFFTXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7059 &prev_ps->link_xoff_tx, &cur_ps->link_xoff_tx); in ice_update_pf_stats()
7063 ice_stat_update32(hw, GLPRT_CRCERRS(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7064 &prev_ps->crc_errors, &cur_ps->crc_errors); in ice_update_pf_stats()
7066 ice_stat_update32(hw, GLPRT_ILLERRC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7067 &prev_ps->illegal_bytes, &cur_ps->illegal_bytes); in ice_update_pf_stats()
7069 ice_stat_update32(hw, GLPRT_MLFC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7070 &prev_ps->mac_local_faults, in ice_update_pf_stats()
7071 &cur_ps->mac_local_faults); in ice_update_pf_stats()
7073 ice_stat_update32(hw, GLPRT_MRFC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7074 &prev_ps->mac_remote_faults, in ice_update_pf_stats()
7075 &cur_ps->mac_remote_faults); in ice_update_pf_stats()
7077 ice_stat_update32(hw, GLPRT_RUC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7078 &prev_ps->rx_undersize, &cur_ps->rx_undersize); in ice_update_pf_stats()
7080 ice_stat_update32(hw, GLPRT_RFC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7081 &prev_ps->rx_fragments, &cur_ps->rx_fragments); in ice_update_pf_stats()
7083 ice_stat_update32(hw, GLPRT_ROC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7084 &prev_ps->rx_oversize, &cur_ps->rx_oversize); in ice_update_pf_stats()
7086 ice_stat_update32(hw, GLPRT_RJC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7087 &prev_ps->rx_jabber, &cur_ps->rx_jabber); in ice_update_pf_stats()
7089 cur_ps->fd_sb_status = test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1 : 0; in ice_update_pf_stats()
7091 pf->stat_prev_loaded = true; in ice_update_pf_stats()
7095 * ice_get_stats64 - get statistics for network device structure
7103 struct ice_vsi *vsi = np->vsi; in ice_get_stats64()
7105 vsi_stats = &vsi->net_stats; in ice_get_stats64()
7107 if (!vsi->num_txq || !vsi->num_rxq) in ice_get_stats64()
7115 if (!test_bit(ICE_VSI_DOWN, vsi->state)) in ice_get_stats64()
7117 stats->tx_packets = vsi_stats->tx_packets; in ice_get_stats64()
7118 stats->tx_bytes = vsi_stats->tx_bytes; in ice_get_stats64()
7119 stats->rx_packets = vsi_stats->rx_packets; in ice_get_stats64()
7120 stats->rx_bytes = vsi_stats->rx_bytes; in ice_get_stats64()
7126 stats->multicast = vsi_stats->multicast; in ice_get_stats64()
7127 stats->tx_errors = vsi_stats->tx_errors; in ice_get_stats64()
7128 stats->tx_dropped = vsi_stats->tx_dropped; in ice_get_stats64()
7129 stats->rx_errors = vsi_stats->rx_errors; in ice_get_stats64()
7130 stats->rx_dropped = vsi_stats->rx_dropped; in ice_get_stats64()
7131 stats->rx_crc_errors = vsi_stats->rx_crc_errors; in ice_get_stats64()
7132 stats->rx_length_errors = vsi_stats->rx_length_errors; in ice_get_stats64()
7136 * ice_napi_disable_all - Disable NAPI for all q_vectors in the VSI
7143 if (!vsi->netdev) in ice_napi_disable_all()
7147 struct ice_q_vector *q_vector = vsi->q_vectors[q_idx]; in ice_napi_disable_all()
7149 if (q_vector->rx.rx_ring || q_vector->tx.tx_ring) in ice_napi_disable_all()
7150 napi_disable(&q_vector->napi); in ice_napi_disable_all()
7152 cancel_work_sync(&q_vector->tx.dim.work); in ice_napi_disable_all()
7153 cancel_work_sync(&q_vector->rx.dim.work); in ice_napi_disable_all()
7158 * ice_vsi_dis_irq - Mask off queue interrupt generation on the VSI
7159 * @vsi: the VSI being un-configured
7163 struct ice_pf *pf = vsi->back; in ice_vsi_dis_irq()
7164 struct ice_hw *hw = &pf->hw; in ice_vsi_dis_irq()
7171 if (vsi->rx_rings) { in ice_vsi_dis_irq()
7173 if (vsi->rx_rings[i]) { in ice_vsi_dis_irq()
7176 reg = vsi->rx_rings[i]->reg_idx; in ice_vsi_dis_irq()
7186 if (!vsi->q_vectors[i]) in ice_vsi_dis_irq()
7188 wr32(hw, GLINT_DYN_CTL(vsi->q_vectors[i]->reg_idx), 0); in ice_vsi_dis_irq()
7194 if (vsi->type == ICE_VSI_VF) in ice_vsi_dis_irq()
7198 synchronize_irq(vsi->q_vectors[i]->irq.virq); in ice_vsi_dis_irq()
7202 * ice_down - Shutdown the connection
7205 * Caller of this function is expected to set the vsi->state ICE_DOWN bit
7211 WARN_ON(!test_bit(ICE_VSI_DOWN, vsi->state)); in ice_down()
7213 if (vsi->netdev) { in ice_down()
7215 ice_ptp_link_change(vsi->back, vsi->back->hw.pf_id, false); in ice_down()
7216 netif_carrier_off(vsi->netdev); in ice_down()
7217 netif_tx_disable(vsi->netdev); in ice_down()
7224 netdev_err(vsi->netdev, "Failed stop Tx rings, VSI %d error %d\n", in ice_down()
7225 vsi->vsi_num, tx_err); in ice_down()
7226 if (!tx_err && vsi->xdp_rings) { in ice_down()
7229 netdev_err(vsi->netdev, "Failed stop XDP rings, VSI %d error %d\n", in ice_down()
7230 vsi->vsi_num, tx_err); in ice_down()
7235 netdev_err(vsi->netdev, "Failed stop Rx rings, VSI %d error %d\n", in ice_down()
7236 vsi->vsi_num, rx_err); in ice_down()
7241 ice_clean_tx_ring(vsi->tx_rings[i]); in ice_down()
7243 if (vsi->xdp_rings) in ice_down()
7245 ice_clean_tx_ring(vsi->xdp_rings[i]); in ice_down()
7248 ice_clean_rx_ring(vsi->rx_rings[i]); in ice_down()
7251 netdev_err(vsi->netdev, "Failed to close VSI 0x%04X on switch 0x%04X\n", in ice_down()
7252 vsi->vsi_num, vsi->vsw->sw_id); in ice_down()
7253 return -EIO; in ice_down()
7260 * ice_down_up - shutdown the VSI connection and bring it up
7268 if (test_and_set_bit(ICE_VSI_DOWN, vsi->state)) in ice_down_up()
7277 …netdev_err(vsi->netdev, "reallocating resources failed during netdev features change, may need to … in ice_down_up()
7285 * ice_vsi_setup_tx_rings - Allocate VSI Tx queue resources
7294 if (!vsi->num_txq) { in ice_vsi_setup_tx_rings()
7295 dev_err(ice_pf_to_dev(vsi->back), "VSI %d has 0 Tx queues\n", in ice_vsi_setup_tx_rings()
7296 vsi->vsi_num); in ice_vsi_setup_tx_rings()
7297 return -EINVAL; in ice_vsi_setup_tx_rings()
7301 struct ice_tx_ring *ring = vsi->tx_rings[i]; in ice_vsi_setup_tx_rings()
7304 return -EINVAL; in ice_vsi_setup_tx_rings()
7306 if (vsi->netdev) in ice_vsi_setup_tx_rings()
7307 ring->netdev = vsi->netdev; in ice_vsi_setup_tx_rings()
7317 * ice_vsi_setup_rx_rings - Allocate VSI Rx queue resources
7326 if (!vsi->num_rxq) { in ice_vsi_setup_rx_rings()
7327 dev_err(ice_pf_to_dev(vsi->back), "VSI %d has 0 Rx queues\n", in ice_vsi_setup_rx_rings()
7328 vsi->vsi_num); in ice_vsi_setup_rx_rings()
7329 return -EINVAL; in ice_vsi_setup_rx_rings()
7333 struct ice_rx_ring *ring = vsi->rx_rings[i]; in ice_vsi_setup_rx_rings()
7336 return -EINVAL; in ice_vsi_setup_rx_rings()
7338 if (vsi->netdev) in ice_vsi_setup_rx_rings()
7339 ring->netdev = vsi->netdev; in ice_vsi_setup_rx_rings()
7349 * ice_vsi_open_ctrl - open control VSI for use
7359 struct ice_pf *pf = vsi->back; in ice_vsi_open_ctrl()
7377 snprintf(int_name, sizeof(int_name) - 1, "%s-%s:ctrl", in ice_vsi_open_ctrl()
7389 clear_bit(ICE_VSI_DOWN, vsi->state); in ice_vsi_open_ctrl()
7405 * ice_vsi_open - Called when a network interface is made active
7415 struct ice_pf *pf = vsi->back; in ice_vsi_open()
7431 snprintf(int_name, sizeof(int_name) - 1, "%s-%s", in ice_vsi_open()
7432 dev_driver_string(ice_pf_to_dev(pf)), vsi->netdev->name); in ice_vsi_open()
7437 ice_vsi_cfg_netdev_tc(vsi, vsi->tc_cfg.ena_tc); in ice_vsi_open()
7439 if (vsi->type == ICE_VSI_PF || vsi->type == ICE_VSI_SF) { in ice_vsi_open()
7441 err = netif_set_real_num_tx_queues(vsi->netdev, vsi->num_txq); in ice_vsi_open()
7445 err = netif_set_real_num_rx_queues(vsi->netdev, vsi->num_rxq); in ice_vsi_open()
7471 * ice_vsi_release_all - Delete all VSIs
7478 if (!pf->vsi) in ice_vsi_release_all()
7482 if (!pf->vsi[i]) in ice_vsi_release_all()
7485 if (pf->vsi[i]->type == ICE_VSI_CHNL) in ice_vsi_release_all()
7488 err = ice_vsi_release(pf->vsi[i]); in ice_vsi_release_all()
7490 dev_dbg(ice_pf_to_dev(pf), "Failed to release pf->vsi[%d], err %d, vsi_num = %d\n", in ice_vsi_release_all()
7491 i, err, pf->vsi[i]->vsi_num); in ice_vsi_release_all()
7496 * ice_vsi_rebuild_by_type - Rebuild VSI of a given type
7500 * Iterates through the pf->vsi array and rebuilds VSIs of the requested type
7508 struct ice_vsi *vsi = pf->vsi[i]; in ice_vsi_rebuild_by_type()
7510 if (!vsi || vsi->type != type) in ice_vsi_rebuild_by_type()
7517 err, vsi->idx, ice_vsi_type_str(type)); in ice_vsi_rebuild_by_type()
7522 err = ice_replay_vsi(&pf->hw, vsi->idx); in ice_vsi_rebuild_by_type()
7525 err, vsi->idx, ice_vsi_type_str(type)); in ice_vsi_rebuild_by_type()
7529 /* Re-map HW VSI number, using VSI handle that has been in ice_vsi_rebuild_by_type()
7532 vsi->vsi_num = ice_get_hw_vsi_num(&pf->hw, vsi->idx); in ice_vsi_rebuild_by_type()
7538 err, vsi->idx, ice_vsi_type_str(type)); in ice_vsi_rebuild_by_type()
7542 dev_info(dev, "VSI rebuilt. VSI index %d, type %s\n", vsi->idx, in ice_vsi_rebuild_by_type()
7550 * ice_update_pf_netdev_link - Update PF netdev link status
7559 struct ice_vsi *vsi = pf->vsi[i]; in ice_update_pf_netdev_link()
7561 if (!vsi || vsi->type != ICE_VSI_PF) in ice_update_pf_netdev_link()
7564 ice_get_link_status(pf->vsi[i]->port_info, &link_up); in ice_update_pf_netdev_link()
7566 netif_carrier_on(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7567 netif_tx_wake_all_queues(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7569 netif_carrier_off(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7570 netif_tx_stop_all_queues(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7576 * ice_rebuild - rebuild after reset
7589 struct ice_hw *hw = &pf->hw; in ice_rebuild()
7593 if (test_bit(ICE_DOWN, pf->state)) in ice_rebuild()
7604 pf->fw_emp_reset_disabled = false; in ice_rebuild()
7653 err = ice_aq_set_port_params(pf->hw.port_info, dvm, NULL); in ice_rebuild()
7657 err = ice_sched_init_port(hw->port_info); in ice_rebuild()
7668 if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) { in ice_rebuild()
7673 guar = hw->func_caps.fd_fltr_guar; in ice_rebuild()
7674 b_effort = hw->func_caps.fd_fltr_best_effort; in ice_rebuild()
7683 if (test_bit(ICE_FLAG_DCB_ENA, pf->flags)) in ice_rebuild()
7690 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_rebuild()
7713 if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) { in ice_rebuild()
7721 if (hw->fdir_prof) in ice_rebuild()
7730 if (vsi && vsi->netdev) in ice_rebuild()
7731 netif_device_attach(vsi->netdev); in ice_rebuild()
7746 clear_bit(ICE_RESET_FAILED, pf->state); in ice_rebuild()
7761 set_bit(ICE_RESET_FAILED, pf->state); in ice_rebuild()
7764 set_bit(ICE_NEEDS_RESTART, pf->state); in ice_rebuild()
7769 * ice_change_mtu - NDO callback to change the MTU
7778 struct ice_vsi *vsi = np->vsi; in ice_change_mtu()
7779 struct ice_pf *pf = vsi->back; in ice_change_mtu()
7784 if (new_mtu == (int)netdev->mtu) { in ice_change_mtu()
7785 netdev_warn(netdev, "MTU is already %u\n", netdev->mtu); in ice_change_mtu()
7789 prog = vsi->xdp_prog; in ice_change_mtu()
7790 if (prog && !prog->aux->xdp_has_frags) { in ice_change_mtu()
7795 frame_size - ICE_ETH_PKT_HDR_PAD); in ice_change_mtu()
7796 return -EINVAL; in ice_change_mtu()
7798 } else if (test_bit(ICE_FLAG_LEGACY_RX, pf->flags)) { in ice_change_mtu()
7800 netdev_err(netdev, "Too big MTU for legacy-rx; Max is %d\n", in ice_change_mtu()
7801 ICE_MAX_FRAME_LEGACY_RX - ICE_ETH_PKT_HDR_PAD); in ice_change_mtu()
7802 return -EINVAL; in ice_change_mtu()
7808 if (ice_is_reset_in_progress(pf->state)) { in ice_change_mtu()
7819 return -EBUSY; in ice_change_mtu()
7822 WRITE_ONCE(netdev->mtu, (unsigned int)new_mtu); in ice_change_mtu()
7828 set_bit(ICE_FLAG_MTU_CHANGED, pf->flags); in ice_change_mtu()
7834 * ice_eth_ioctl - Access the hwtstamp interface
7842 struct ice_pf *pf = np->vsi->back; in ice_eth_ioctl()
7850 return -EOPNOTSUPP; in ice_eth_ioctl()
7855 * ice_aq_str - convert AQ err code to a string
7897 * ice_set_rss_lut - Set RSS LUT
7907 struct ice_hw *hw = &vsi->back->hw; in ice_set_rss_lut()
7911 return -EINVAL; in ice_set_rss_lut()
7913 params.vsi_handle = vsi->idx; in ice_set_rss_lut()
7915 params.lut_type = vsi->rss_lut_type; in ice_set_rss_lut()
7920 dev_err(ice_pf_to_dev(vsi->back), "Cannot set RSS lut, err %d aq_err %s\n", in ice_set_rss_lut()
7921 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_rss_lut()
7927 * ice_set_rss_key - Set RSS key
7935 struct ice_hw *hw = &vsi->back->hw; in ice_set_rss_key()
7939 return -EINVAL; in ice_set_rss_key()
7941 status = ice_aq_set_rss_key(hw, vsi->idx, (struct ice_aqc_get_set_rss_keys *)seed); in ice_set_rss_key()
7943 dev_err(ice_pf_to_dev(vsi->back), "Cannot set RSS key, err %d aq_err %s\n", in ice_set_rss_key()
7944 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_set_rss_key()
7950 * ice_get_rss_lut - Get RSS LUT
7960 struct ice_hw *hw = &vsi->back->hw; in ice_get_rss_lut()
7964 return -EINVAL; in ice_get_rss_lut()
7966 params.vsi_handle = vsi->idx; in ice_get_rss_lut()
7968 params.lut_type = vsi->rss_lut_type; in ice_get_rss_lut()
7973 dev_err(ice_pf_to_dev(vsi->back), "Cannot get RSS lut, err %d aq_err %s\n", in ice_get_rss_lut()
7974 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_rss_lut()
7980 * ice_get_rss_key - Get RSS key
7988 struct ice_hw *hw = &vsi->back->hw; in ice_get_rss_key()
7992 return -EINVAL; in ice_get_rss_key()
7994 status = ice_aq_get_rss_key(hw, vsi->idx, (struct ice_aqc_get_set_rss_keys *)seed); in ice_get_rss_key()
7996 dev_err(ice_pf_to_dev(vsi->back), "Cannot get RSS key, err %d aq_err %s\n", in ice_get_rss_key()
7997 status, ice_aq_str(hw->adminq.sq_last_status)); in ice_get_rss_key()
8003 * ice_set_rss_hfunc - Set RSS HASH function
8011 struct ice_hw *hw = &vsi->back->hw; in ice_set_rss_hfunc()
8016 if (hfunc == vsi->rss_hfunc) in ice_set_rss_hfunc()
8021 return -EOPNOTSUPP; in ice_set_rss_hfunc()
8025 return -ENOMEM; in ice_set_rss_hfunc()
8027 ctx->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_Q_OPT_VALID); in ice_set_rss_hfunc()
8028 ctx->info.q_opt_rss = vsi->info.q_opt_rss; in ice_set_rss_hfunc()
8029 ctx->info.q_opt_rss &= ~ICE_AQ_VSI_Q_OPT_RSS_HASH_M; in ice_set_rss_hfunc()
8030 ctx->info.q_opt_rss |= in ice_set_rss_hfunc()
8032 ctx->info.q_opt_tc = vsi->info.q_opt_tc; in ice_set_rss_hfunc()
8033 ctx->info.q_opt_flags = vsi->info.q_opt_rss; in ice_set_rss_hfunc()
8035 err = ice_update_vsi(hw, vsi->idx, ctx, NULL); in ice_set_rss_hfunc()
8037 dev_err(ice_pf_to_dev(vsi->back), "Failed to configure RSS hash for VSI %d, error %d\n", in ice_set_rss_hfunc()
8038 vsi->vsi_num, err); in ice_set_rss_hfunc()
8040 vsi->info.q_opt_rss = ctx->info.q_opt_rss; in ice_set_rss_hfunc()
8041 vsi->rss_hfunc = hfunc; in ice_set_rss_hfunc()
8042 netdev_info(vsi->netdev, "Hash function set to: %sToeplitz\n", in ice_set_rss_hfunc()
8056 * ice_bridge_getlink - Get the hardware bridge mode
8071 struct ice_vsi *vsi = np->vsi; in ice_bridge_getlink()
8072 struct ice_pf *pf = vsi->back; in ice_bridge_getlink()
8075 bmode = pf->first_sw->bridge_mode; in ice_bridge_getlink()
8082 * ice_vsi_update_bridge_mode - Update VSI for switching bridge mode (VEB/VEPA)
8091 struct ice_hw *hw = &vsi->back->hw; in ice_vsi_update_bridge_mode()
8095 vsi_props = &vsi->info; in ice_vsi_update_bridge_mode()
8099 return -ENOMEM; in ice_vsi_update_bridge_mode()
8101 ctxt->info = vsi->info; in ice_vsi_update_bridge_mode()
8105 ctxt->info.sw_flags |= ICE_AQ_VSI_SW_FLAG_ALLOW_LB; in ice_vsi_update_bridge_mode()
8108 ctxt->info.sw_flags &= ~ICE_AQ_VSI_SW_FLAG_ALLOW_LB; in ice_vsi_update_bridge_mode()
8109 ctxt->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_SW_VALID); in ice_vsi_update_bridge_mode()
8111 ret = ice_update_vsi(hw, vsi->idx, ctxt, NULL); in ice_vsi_update_bridge_mode()
8113 …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()
8114 bmode, ret, ice_aq_str(hw->adminq.sq_last_status)); in ice_vsi_update_bridge_mode()
8118 vsi_props->sw_flags = ctxt->info.sw_flags; in ice_vsi_update_bridge_mode()
8126 * ice_bridge_setlink - Set the hardware bridge mode
8143 struct ice_pf *pf = np->vsi->back; in ice_bridge_setlink()
8145 struct ice_hw *hw = &pf->hw; in ice_bridge_setlink()
8149 pf_sw = pf->first_sw; in ice_bridge_setlink()
8153 return -EINVAL; in ice_bridge_setlink()
8159 return -EINVAL; in ice_bridge_setlink()
8161 if (mode == pf_sw->bridge_mode) in ice_bridge_setlink()
8167 if (!pf->vsi[v]) in ice_bridge_setlink()
8169 err = ice_vsi_update_bridge_mode(pf->vsi[v], mode); in ice_bridge_setlink()
8174 hw->evb_veb = (mode == BRIDGE_MODE_VEB); in ice_bridge_setlink()
8182 ice_aq_str(hw->adminq.sq_last_status)); in ice_bridge_setlink()
8183 /* revert hw->evb_veb */ in ice_bridge_setlink()
8184 hw->evb_veb = (pf_sw->bridge_mode == BRIDGE_MODE_VEB); in ice_bridge_setlink()
8188 pf_sw->bridge_mode = mode; in ice_bridge_setlink()
8195 * ice_tx_timeout - Respond to a Tx Hang
8203 struct ice_vsi *vsi = np->vsi; in ice_tx_timeout()
8204 struct ice_pf *pf = vsi->back; in ice_tx_timeout()
8207 pf->tx_timeout_count++; in ice_tx_timeout()
8210 * to. If yes then Tx timeout is not caused by a hung queue, no in ice_tx_timeout()
8214 dev_info(ice_pf_to_dev(pf), "Fake Tx hang detected on queue %u, timeout caused by PFC storm\n", in ice_tx_timeout()
8221 if (vsi->tx_rings[i] && vsi->tx_rings[i]->desc) in ice_tx_timeout()
8222 if (txqueue == vsi->tx_rings[i]->q_index) { in ice_tx_timeout()
8223 tx_ring = vsi->tx_rings[i]; in ice_tx_timeout()
8227 /* Reset recovery level if enough time has elapsed after last timeout. in ice_tx_timeout()
8228 * Also ensure no new reset action happens before next timeout period. in ice_tx_timeout()
8230 if (time_after(jiffies, (pf->tx_timeout_last_recovery + HZ * 20))) in ice_tx_timeout()
8231 pf->tx_timeout_recovery_level = 1; in ice_tx_timeout()
8232 else if (time_before(jiffies, (pf->tx_timeout_last_recovery + in ice_tx_timeout()
8233 netdev->watchdog_timeo))) in ice_tx_timeout()
8237 struct ice_hw *hw = &pf->hw; in ice_tx_timeout()
8241 rd32(hw, QTX_COMM_HEAD(vsi->txq_map[txqueue]))); in ice_tx_timeout()
8243 val = rd32(hw, GLINT_DYN_CTL(tx_ring->q_vector->reg_idx)); in ice_tx_timeout()
8246 vsi->vsi_num, txqueue, tx_ring->next_to_clean, in ice_tx_timeout()
8247 head, tx_ring->next_to_use, val); in ice_tx_timeout()
8250 pf->tx_timeout_last_recovery = jiffies; in ice_tx_timeout()
8252 pf->tx_timeout_recovery_level, txqueue); in ice_tx_timeout()
8254 switch (pf->tx_timeout_recovery_level) { in ice_tx_timeout()
8256 set_bit(ICE_PFR_REQ, pf->state); in ice_tx_timeout()
8259 set_bit(ICE_CORER_REQ, pf->state); in ice_tx_timeout()
8262 set_bit(ICE_GLOBR_REQ, pf->state); in ice_tx_timeout()
8266 set_bit(ICE_DOWN, pf->state); in ice_tx_timeout()
8267 set_bit(ICE_VSI_NEEDS_RESTART, vsi->state); in ice_tx_timeout()
8268 set_bit(ICE_SERVICE_DIS, pf->state); in ice_tx_timeout()
8273 pf->tx_timeout_recovery_level++; in ice_tx_timeout()
8277 * ice_setup_tc_cls_flower - flower classifier offloads
8287 struct ice_vsi *vsi = np->vsi; in ice_setup_tc_cls_flower()
8289 if (cls_flower->common.chain_index) in ice_setup_tc_cls_flower()
8290 return -EOPNOTSUPP; in ice_setup_tc_cls_flower()
8292 switch (cls_flower->command) { in ice_setup_tc_cls_flower()
8298 return -EINVAL; in ice_setup_tc_cls_flower()
8303 * ice_setup_tc_block_cb - callback handler registered for TC block
8315 return ice_setup_tc_cls_flower(np, np->vsi->netdev, in ice_setup_tc_block_cb()
8318 return -EOPNOTSUPP; in ice_setup_tc_block_cb()
8323 * ice_validate_mqprio_qopt - Validate TCF input parameters
8336 struct ice_pf *pf = vsi->back; in ice_validate_mqprio_qopt()
8343 if (vsi->type != ICE_VSI_PF) in ice_validate_mqprio_qopt()
8344 return -EINVAL; in ice_validate_mqprio_qopt()
8346 if (mqprio_qopt->qopt.offset[0] != 0 || in ice_validate_mqprio_qopt()
8347 mqprio_qopt->qopt.num_tc < 1 || in ice_validate_mqprio_qopt()
8348 mqprio_qopt->qopt.num_tc > ICE_CHNL_MAX_TC) in ice_validate_mqprio_qopt()
8349 return -EINVAL; in ice_validate_mqprio_qopt()
8352 vsi->ch_rss_size = 0; in ice_validate_mqprio_qopt()
8353 num_tc = mqprio_qopt->qopt.num_tc; in ice_validate_mqprio_qopt()
8357 int qcount = mqprio_qopt->qopt.count[i]; in ice_validate_mqprio_qopt()
8361 return -EINVAL; in ice_validate_mqprio_qopt()
8368 return -EINVAL; in ice_validate_mqprio_qopt()
8377 return -EINVAL; in ice_validate_mqprio_qopt()
8382 return -EINVAL; in ice_validate_mqprio_qopt()
8393 max_rate = mqprio_qopt->max_rate[i]; in ice_validate_mqprio_qopt()
8397 min_rate = mqprio_qopt->min_rate[i]; in ice_validate_mqprio_qopt()
8404 return -EINVAL; in ice_validate_mqprio_qopt()
8410 return -EINVAL; in ice_validate_mqprio_qopt()
8417 return -EINVAL; in ice_validate_mqprio_qopt()
8424 return -EINVAL; in ice_validate_mqprio_qopt()
8434 return -EINVAL; in ice_validate_mqprio_qopt()
8437 if (i >= mqprio_qopt->qopt.num_tc - 1) in ice_validate_mqprio_qopt()
8439 if (mqprio_qopt->qopt.offset[i + 1] != in ice_validate_mqprio_qopt()
8440 (mqprio_qopt->qopt.offset[i] + qcount)) in ice_validate_mqprio_qopt()
8441 return -EINVAL; in ice_validate_mqprio_qopt()
8443 if (vsi->num_rxq < in ice_validate_mqprio_qopt()
8444 (mqprio_qopt->qopt.offset[i] + mqprio_qopt->qopt.count[i])) in ice_validate_mqprio_qopt()
8445 return -EINVAL; in ice_validate_mqprio_qopt()
8446 if (vsi->num_txq < in ice_validate_mqprio_qopt()
8447 (mqprio_qopt->qopt.offset[i] + mqprio_qopt->qopt.count[i])) in ice_validate_mqprio_qopt()
8448 return -EINVAL; in ice_validate_mqprio_qopt()
8453 return -EINVAL; in ice_validate_mqprio_qopt()
8456 /* make sure vsi->ch_rss_size is set correctly based on TC's qcount */ in ice_validate_mqprio_qopt()
8457 vsi->ch_rss_size = max_rss_q_cnt; in ice_validate_mqprio_qopt()
8463 * ice_add_vsi_to_fdir - add a VSI to the flow director group for PF
8474 if (!(vsi->num_gfltr || vsi->num_bfltr)) in ice_add_vsi_to_fdir()
8475 return -EINVAL; in ice_add_vsi_to_fdir()
8477 hw = &pf->hw; in ice_add_vsi_to_fdir()
8483 if (!(hw->fdir_prof && hw->fdir_prof[flow] && in ice_add_vsi_to_fdir()
8484 hw->fdir_prof[flow]->cnt)) in ice_add_vsi_to_fdir()
8492 prof = hw->fdir_prof[flow]; in ice_add_vsi_to_fdir()
8494 prof->prof_id[tun], in ice_add_vsi_to_fdir()
8495 prof->vsi_h[0], vsi->idx, in ice_add_vsi_to_fdir()
8496 prio, prof->fdir_seg[tun], in ice_add_vsi_to_fdir()
8500 vsi->idx, flow); in ice_add_vsi_to_fdir()
8504 prof->entry_h[prof->cnt][tun] = entry_h; in ice_add_vsi_to_fdir()
8508 prof->vsi_h[prof->cnt] = vsi->idx; in ice_add_vsi_to_fdir()
8509 prof->cnt++; in ice_add_vsi_to_fdir()
8512 dev_dbg(dev, "VSI idx %d added to fdir group %d\n", vsi->idx, in ice_add_vsi_to_fdir()
8517 dev_dbg(dev, "VSI idx %d not added to fdir groups\n", vsi->idx); in ice_add_vsi_to_fdir()
8523 * ice_add_channel - add a channel by adding VSI
8535 if (ch->type != ICE_VSI_CHNL) { in ice_add_channel()
8536 dev_err(dev, "add new VSI failed, ch->type %d\n", ch->type); in ice_add_channel()
8537 return -EINVAL; in ice_add_channel()
8540 vsi = ice_chnl_vsi_setup(pf, pf->hw.port_info, ch); in ice_add_channel()
8541 if (!vsi || vsi->type != ICE_VSI_CHNL) { in ice_add_channel()
8543 return -EINVAL; in ice_add_channel()
8548 ch->sw_id = sw_id; in ice_add_channel()
8549 ch->vsi_num = vsi->vsi_num; in ice_add_channel()
8550 ch->info.mapping_flags = vsi->info.mapping_flags; in ice_add_channel()
8551 ch->ch_vsi = vsi; in ice_add_channel()
8553 vsi->ch = ch; in ice_add_channel()
8555 memcpy(&ch->info.q_mapping, &vsi->info.q_mapping, in ice_add_channel()
8556 sizeof(vsi->info.q_mapping)); in ice_add_channel()
8557 memcpy(&ch->info.tc_mapping, vsi->info.tc_mapping, in ice_add_channel()
8558 sizeof(vsi->info.tc_mapping)); in ice_add_channel()
8574 for (i = 0; i < ch->num_txq; i++) { in ice_chnl_cfg_res()
8580 tx_ring = vsi->tx_rings[ch->base_q + i]; in ice_chnl_cfg_res()
8581 rx_ring = vsi->rx_rings[ch->base_q + i]; in ice_chnl_cfg_res()
8586 tx_ring->ch = ch; in ice_chnl_cfg_res()
8587 rx_ring->ch = ch; in ice_chnl_cfg_res()
8590 tx_q_vector = tx_ring->q_vector; in ice_chnl_cfg_res()
8591 rx_q_vector = rx_ring->q_vector; in ice_chnl_cfg_res()
8596 tx_q_vector->ch = ch; in ice_chnl_cfg_res()
8598 rc = &tx_q_vector->tx; in ice_chnl_cfg_res()
8600 ice_write_itr(rc, rc->itr_setting); in ice_chnl_cfg_res()
8603 rx_q_vector->ch = ch; in ice_chnl_cfg_res()
8605 rc = &rx_q_vector->rx; in ice_chnl_cfg_res()
8607 ice_write_itr(rc, rc->itr_setting); in ice_chnl_cfg_res()
8611 /* it is safe to assume that, if channel has non-zero num_t[r]xq, then in ice_chnl_cfg_res()
8612 * GLINT_ITR register would have written to perform in-context in ice_chnl_cfg_res()
8615 if (ch->num_txq || ch->num_rxq) in ice_chnl_cfg_res()
8616 ice_flush(&vsi->back->hw); in ice_chnl_cfg_res()
8620 * ice_cfg_chnl_all_res - configure channel resources
8624 * This function configures channel specific resources such as flow-director
8637 * ice_setup_hw_channel - setup new channel
8654 ch->base_q = vsi->next_base_q; in ice_setup_hw_channel()
8655 ch->type = type; in ice_setup_hw_channel()
8669 vsi->next_base_q = vsi->next_base_q + ch->num_rxq; in ice_setup_hw_channel()
8670 dev_dbg(dev, "added channel: vsi_num %u, num_rxq %u\n", ch->vsi_num, in ice_setup_hw_channel()
8671 ch->num_rxq); in ice_setup_hw_channel()
8677 * ice_setup_channel - setup new channel using uplink element
8693 if (vsi->type != ICE_VSI_PF) { in ice_setup_channel()
8694 dev_err(dev, "unsupported parent VSI type(%d)\n", vsi->type); in ice_setup_channel()
8698 sw_id = pf->first_sw->sw_id; in ice_setup_channel()
8708 return ch->ch_vsi ? true : false; in ice_setup_channel()
8712 * ice_set_bw_limit - setup BW limit for Tx traffic based on max_tx_rate
8730 * ice_create_q_channel - function to create channel
8739 struct ice_pf *pf = vsi->back; in ice_create_q_channel()
8743 return -EINVAL; in ice_create_q_channel()
8746 if (!ch->num_txq || !ch->num_rxq) { in ice_create_q_channel()
8747 dev_err(dev, "Invalid num_queues requested: %d\n", ch->num_rxq); in ice_create_q_channel()
8748 return -EINVAL; in ice_create_q_channel()
8751 if (!vsi->cnt_q_avail || vsi->cnt_q_avail < ch->num_txq) { in ice_create_q_channel()
8753 vsi->cnt_q_avail, ch->num_txq); in ice_create_q_channel()
8754 return -EINVAL; in ice_create_q_channel()
8759 return -EINVAL; in ice_create_q_channel()
8762 if (ch->ch_vsi && (ch->max_tx_rate || ch->min_tx_rate)) { in ice_create_q_channel()
8765 ret = ice_set_bw_limit(ch->ch_vsi, ch->max_tx_rate, in ice_create_q_channel()
8766 ch->min_tx_rate); in ice_create_q_channel()
8769 ch->max_tx_rate, ch->ch_vsi->vsi_num); in ice_create_q_channel()
8772 ch->max_tx_rate, ch->ch_vsi->vsi_num); in ice_create_q_channel()
8775 vsi->cnt_q_avail -= ch->num_txq; in ice_create_q_channel()
8781 * ice_rem_all_chnl_fltrs - removes all channel filters
8782 * @pf: ptr to PF, TC-flower based filter are tracked at PF level
8785 * tc-flower based filter
8794 &pf->tc_flower_fltr_list, in ice_rem_all_chnl_fltrs()
8803 rule.rid = fltr->rid; in ice_rem_all_chnl_fltrs()
8804 rule.rule_id = fltr->rule_id; in ice_rem_all_chnl_fltrs()
8805 rule.vsi_handle = fltr->dest_vsi_handle; in ice_rem_all_chnl_fltrs()
8806 status = ice_rem_adv_rule_by_id(&pf->hw, &rule); in ice_rem_all_chnl_fltrs()
8808 if (status == -ENOENT) in ice_rem_all_chnl_fltrs()
8814 } else if (fltr->dest_vsi) { in ice_rem_all_chnl_fltrs()
8816 if (fltr->dest_vsi->type == ICE_VSI_CHNL) { in ice_rem_all_chnl_fltrs()
8817 u32 flags = fltr->flags; in ice_rem_all_chnl_fltrs()
8819 fltr->dest_vsi->num_chnl_fltr--; in ice_rem_all_chnl_fltrs()
8822 pf->num_dmac_chnl_fltrs--; in ice_rem_all_chnl_fltrs()
8826 hlist_del(&fltr->tc_flower_node); in ice_rem_all_chnl_fltrs()
8832 * ice_remove_q_channels - Remove queue channels for the TCs
8841 struct ice_pf *pf = vsi->back; in ice_remove_q_channels()
8844 /* remove all tc-flower based filter if they are channel filters only */ in ice_remove_q_channels()
8849 if (vsi->netdev->features & NETIF_F_NTUPLE) { in ice_remove_q_channels()
8850 struct ice_hw *hw = &pf->hw; in ice_remove_q_channels()
8852 mutex_lock(&hw->fdir_fltr_lock); in ice_remove_q_channels()
8854 mutex_unlock(&hw->fdir_fltr_lock); in ice_remove_q_channels()
8858 list_for_each_entry_safe(ch, ch_tmp, &vsi->ch_list, list) { in ice_remove_q_channels()
8861 list_del(&ch->list); in ice_remove_q_channels()
8862 ch_vsi = ch->ch_vsi; in ice_remove_q_channels()
8869 for (i = 0; i < ch->num_rxq; i++) { in ice_remove_q_channels()
8873 tx_ring = vsi->tx_rings[ch->base_q + i]; in ice_remove_q_channels()
8874 rx_ring = vsi->rx_rings[ch->base_q + i]; in ice_remove_q_channels()
8876 tx_ring->ch = NULL; in ice_remove_q_channels()
8877 if (tx_ring->q_vector) in ice_remove_q_channels()
8878 tx_ring->q_vector->ch = NULL; in ice_remove_q_channels()
8881 rx_ring->ch = NULL; in ice_remove_q_channels()
8882 if (rx_ring->q_vector) in ice_remove_q_channels()
8883 rx_ring->q_vector->ch = NULL; in ice_remove_q_channels()
8888 ice_fdir_rem_adq_chnl(&pf->hw, ch->ch_vsi->idx); in ice_remove_q_channels()
8891 ice_rm_vsi_lan_cfg(ch->ch_vsi->port_info, ch->ch_vsi->idx); in ice_remove_q_channels()
8894 ice_vsi_delete(ch->ch_vsi); in ice_remove_q_channels()
8902 vsi->tc_map_vsi[i] = NULL; in ice_remove_q_channels()
8905 vsi->all_enatc = 0; in ice_remove_q_channels()
8906 vsi->all_numtc = 0; in ice_remove_q_channels()
8910 * ice_rebuild_channels - rebuild channel
8929 if (!test_bit(ICE_FLAG_TC_MQPRIO, pf->flags) || in ice_rebuild_channels()
8930 main_vsi->old_numtc == 1) in ice_rebuild_channels()
8936 err = ice_vsi_cfg_tc(main_vsi, main_vsi->old_ena_tc); in ice_rebuild_channels()
8939 main_vsi->old_ena_tc, main_vsi->vsi_num); in ice_rebuild_channels()
8947 vsi = pf->vsi[i]; in ice_rebuild_channels()
8948 if (!vsi || vsi->type != ICE_VSI_CHNL) in ice_rebuild_channels()
8951 type = vsi->type; in ice_rebuild_channels()
8957 ice_vsi_type_str(type), vsi->idx, err); in ice_rebuild_channels()
8961 /* Re-map HW VSI number, using VSI handle that has been in ice_rebuild_channels()
8964 vsi->vsi_num = ice_get_hw_vsi_num(&pf->hw, vsi->idx); in ice_rebuild_channels()
8967 err = ice_replay_vsi(&pf->hw, vsi->idx); in ice_rebuild_channels()
8970 ice_vsi_type_str(type), err, vsi->idx); in ice_rebuild_channels()
8975 ice_vsi_type_str(type), vsi->idx); in ice_rebuild_channels()
8980 main_vsi->tc_map_vsi[tc_idx++] = vsi; in ice_rebuild_channels()
8986 list_for_each_entry(ch, &main_vsi->ch_list, list) { in ice_rebuild_channels()
8989 ch_vsi = ch->ch_vsi; in ice_rebuild_channels()
8996 /* replay BW rate limit if it is non-zero */ in ice_rebuild_channels()
8997 if (!ch->max_tx_rate && !ch->min_tx_rate) in ice_rebuild_channels()
9000 err = ice_set_bw_limit(ch_vsi, ch->max_tx_rate, in ice_rebuild_channels()
9001 ch->min_tx_rate); in ice_rebuild_channels()
9004 err, ch->max_tx_rate, ch->min_tx_rate, in ice_rebuild_channels()
9005 ch_vsi->vsi_num); in ice_rebuild_channels()
9008 ch->max_tx_rate, ch->min_tx_rate, in ice_rebuild_channels()
9009 ch_vsi->vsi_num); in ice_rebuild_channels()
9013 if (main_vsi->ch_rss_size) in ice_rebuild_channels()
9024 * ice_create_q_channels - Add queue channel for the given TCs
9031 struct ice_pf *pf = vsi->back; in ice_create_q_channels()
9036 if (!(vsi->all_enatc & BIT(i))) in ice_create_q_channels()
9041 ret = -ENOMEM; in ice_create_q_channels()
9044 INIT_LIST_HEAD(&ch->list); in ice_create_q_channels()
9045 ch->num_rxq = vsi->mqprio_qopt.qopt.count[i]; in ice_create_q_channels()
9046 ch->num_txq = vsi->mqprio_qopt.qopt.count[i]; in ice_create_q_channels()
9047 ch->base_q = vsi->mqprio_qopt.qopt.offset[i]; in ice_create_q_channels()
9048 ch->max_tx_rate = vsi->mqprio_qopt.max_rate[i]; in ice_create_q_channels()
9049 ch->min_tx_rate = vsi->mqprio_qopt.min_rate[i]; in ice_create_q_channels()
9052 if (ch->max_tx_rate) in ice_create_q_channels()
9053 ch->max_tx_rate = div_u64(ch->max_tx_rate, in ice_create_q_channels()
9055 if (ch->min_tx_rate) in ice_create_q_channels()
9056 ch->min_tx_rate = div_u64(ch->min_tx_rate, in ice_create_q_channels()
9066 list_add_tail(&ch->list, &vsi->ch_list); in ice_create_q_channels()
9067 vsi->tc_map_vsi[i] = ch->ch_vsi; in ice_create_q_channels()
9069 "successfully created channel: VSI %pK\n", ch->ch_vsi); in ice_create_q_channels()
9080 * ice_setup_tc_mqprio_qdisc - configure multiple traffic classes
9088 struct ice_vsi *vsi = np->vsi; in ice_setup_tc_mqprio_qdisc()
9089 struct ice_pf *pf = vsi->back; in ice_setup_tc_mqprio_qdisc()
9097 num_tcf = mqprio_qopt->qopt.num_tc; in ice_setup_tc_mqprio_qdisc()
9098 hw = mqprio_qopt->qopt.hw; in ice_setup_tc_mqprio_qdisc()
9099 mode = mqprio_qopt->mode; in ice_setup_tc_mqprio_qdisc()
9101 clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags); in ice_setup_tc_mqprio_qdisc()
9102 vsi->ch_rss_size = 0; in ice_setup_tc_mqprio_qdisc()
9103 memcpy(&vsi->mqprio_qopt, mqprio_qopt, sizeof(*mqprio_qopt)); in ice_setup_tc_mqprio_qdisc()
9114 if (pf->hw.port_info->is_custom_tx_enabled) { in ice_setup_tc_mqprio_qdisc()
9116 return -EBUSY; in ice_setup_tc_mqprio_qdisc()
9126 memcpy(&vsi->mqprio_qopt, mqprio_qopt, sizeof(*mqprio_qopt)); in ice_setup_tc_mqprio_qdisc()
9127 set_bit(ICE_FLAG_TC_MQPRIO, pf->flags); in ice_setup_tc_mqprio_qdisc()
9132 if (vsi->netdev->features & NETIF_F_HW_TC) in ice_setup_tc_mqprio_qdisc()
9133 set_bit(ICE_FLAG_CLS_FLOWER, pf->flags); in ice_setup_tc_mqprio_qdisc()
9136 return -EINVAL; in ice_setup_tc_mqprio_qdisc()
9142 if (ena_tc_qdisc == vsi->tc_cfg.ena_tc && in ice_setup_tc_mqprio_qdisc()
9149 if (!hw && !test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) in ice_setup_tc_mqprio_qdisc()
9152 if (!hw && !test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) { in ice_setup_tc_mqprio_qdisc()
9153 vsi->req_txq = min_t(int, ice_get_avail_txq_count(pf), in ice_setup_tc_mqprio_qdisc()
9155 vsi->req_rxq = min_t(int, ice_get_avail_rxq_count(pf), in ice_setup_tc_mqprio_qdisc()
9158 /* logic to rebuild VSI, same like ethtool -L */ in ice_setup_tc_mqprio_qdisc()
9165 offset = vsi->mqprio_qopt.qopt.offset[i]; in ice_setup_tc_mqprio_qdisc()
9166 qcount_rx = vsi->mqprio_qopt.qopt.count[i]; in ice_setup_tc_mqprio_qdisc()
9167 qcount_tx = vsi->mqprio_qopt.qopt.count[i]; in ice_setup_tc_mqprio_qdisc()
9169 vsi->req_txq = offset + qcount_tx; in ice_setup_tc_mqprio_qdisc()
9170 vsi->req_rxq = offset + qcount_rx; in ice_setup_tc_mqprio_qdisc()
9173 * form ice_vsi_rebuild during tc-qdisc delete stage - to in ice_setup_tc_mqprio_qdisc()
9176 vsi->orig_rss_size = vsi->rss_size; in ice_setup_tc_mqprio_qdisc()
9182 cur_txq = vsi->num_txq; in ice_setup_tc_mqprio_qdisc()
9183 cur_rxq = vsi->num_rxq; in ice_setup_tc_mqprio_qdisc()
9190 vsi->req_txq = cur_txq; in ice_setup_tc_mqprio_qdisc()
9191 vsi->req_rxq = cur_rxq; in ice_setup_tc_mqprio_qdisc()
9192 clear_bit(ICE_RESET_FAILED, pf->state); in ice_setup_tc_mqprio_qdisc()
9199 vsi->all_numtc = num_tcf; in ice_setup_tc_mqprio_qdisc()
9200 vsi->all_enatc = ena_tc_qdisc; in ice_setup_tc_mqprio_qdisc()
9204 vsi->vsi_num); in ice_setup_tc_mqprio_qdisc()
9208 if (test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) { in ice_setup_tc_mqprio_qdisc()
9209 u64 max_tx_rate = vsi->mqprio_qopt.max_rate[0]; in ice_setup_tc_mqprio_qdisc()
9210 u64 min_tx_rate = vsi->mqprio_qopt.min_rate[0]; in ice_setup_tc_mqprio_qdisc()
9223 max_tx_rate, min_tx_rate, vsi->vsi_num); in ice_setup_tc_mqprio_qdisc()
9226 max_tx_rate, min_tx_rate, vsi->vsi_num); in ice_setup_tc_mqprio_qdisc()
9239 if (vsi->ch_rss_size) in ice_setup_tc_mqprio_qdisc()
9245 vsi->all_numtc = 0; in ice_setup_tc_mqprio_qdisc()
9246 vsi->all_enatc = 0; in ice_setup_tc_mqprio_qdisc()
9261 struct ice_pf *pf = np->vsi->back; in ice_setup_tc()
9274 return -EOPNOTSUPP; in ice_setup_tc()
9277 if (pf->adev) { in ice_setup_tc()
9278 mutex_lock(&pf->adev_mutex); in ice_setup_tc()
9279 device_lock(&pf->adev->dev); in ice_setup_tc()
9281 if (pf->adev->dev.driver) { in ice_setup_tc()
9283 err = -EBUSY; in ice_setup_tc()
9289 mutex_lock(&pf->tc_mutex); in ice_setup_tc()
9291 mutex_unlock(&pf->tc_mutex); in ice_setup_tc()
9295 device_unlock(&pf->adev->dev); in ice_setup_tc()
9296 mutex_unlock(&pf->adev_mutex); in ice_setup_tc()
9300 return -EOPNOTSUPP; in ice_setup_tc()
9302 return -EOPNOTSUPP; in ice_setup_tc()
9311 list_for_each_entry(cb_priv, &np->tc_indr_block_priv_list, list) { in ice_indr_block_priv_lookup()
9312 if (!cb_priv->netdev) in ice_indr_block_priv_lookup()
9314 if (cb_priv->netdev == netdev) in ice_indr_block_priv_lookup()
9325 struct ice_netdev_priv *np = priv->np; in ice_indr_setup_block_cb()
9329 return ice_setup_tc_cls_flower(np, priv->netdev, in ice_indr_setup_block_cb()
9333 return -EOPNOTSUPP; in ice_indr_setup_block_cb()
9348 vlan_dev_real_dev(netdev) == np->vsi->netdev)) in ice_indr_setup_tc_block()
9349 return -EOPNOTSUPP; in ice_indr_setup_tc_block()
9351 if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) in ice_indr_setup_tc_block()
9352 return -EOPNOTSUPP; in ice_indr_setup_tc_block()
9354 switch (f->command) { in ice_indr_setup_tc_block()
9358 return -EEXIST; in ice_indr_setup_tc_block()
9362 return -ENOMEM; in ice_indr_setup_tc_block()
9364 indr_priv->netdev = netdev; in ice_indr_setup_tc_block()
9365 indr_priv->np = np; in ice_indr_setup_tc_block()
9366 list_add(&indr_priv->list, &np->tc_indr_block_priv_list); in ice_indr_setup_tc_block()
9376 list_del(&indr_priv->list); in ice_indr_setup_tc_block()
9381 list_add_tail(&block_cb->driver_list, &ice_block_cb_list); in ice_indr_setup_tc_block()
9386 return -ENOENT; in ice_indr_setup_tc_block()
9388 block_cb = flow_block_cb_lookup(f->block, in ice_indr_setup_tc_block()
9392 return -ENOENT; in ice_indr_setup_tc_block()
9396 list_del(&block_cb->driver_list); in ice_indr_setup_tc_block()
9399 return -EOPNOTSUPP; in ice_indr_setup_tc_block()
9416 return -EOPNOTSUPP; in ice_indr_setup_tc_cb()
9421 * ice_open - Called when a network interface becomes active
9435 struct ice_pf *pf = np->vsi->back; in ice_open()
9437 if (ice_is_reset_in_progress(pf->state)) { in ice_open()
9439 return -EBUSY; in ice_open()
9446 * ice_open_internal - Called when a network interface becomes active
9457 struct ice_vsi *vsi = np->vsi; in ice_open_internal()
9458 struct ice_pf *pf = vsi->back; in ice_open_internal()
9462 if (test_bit(ICE_NEEDS_RESTART, pf->state)) { in ice_open_internal()
9464 return -EIO; in ice_open_internal()
9469 pi = vsi->port_info; in ice_open_internal()
9476 ice_check_link_cfg_err(pf, pi->phy.link_info.link_cfg_err); in ice_open_internal()
9479 if (pi->phy.link_info.link_info & ICE_AQ_MEDIA_AVAILABLE) { in ice_open_internal()
9480 clear_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_open_internal()
9481 if (!test_bit(ICE_PHY_INIT_COMPLETE, pf->state)) { in ice_open_internal()
9497 set_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_open_internal()
9504 vsi->vsi_num, vsi->vsw->sw_id); in ice_open_internal()
9513 * ice_stop - Disables a network interface
9516 * The stop entry point is called when an interface is de-activated by the OS,
9520 * Returns success only - not allowed to fail
9525 struct ice_vsi *vsi = np->vsi; in ice_stop()
9526 struct ice_pf *pf = vsi->back; in ice_stop()
9528 if (ice_is_reset_in_progress(pf->state)) { in ice_stop()
9530 return -EBUSY; in ice_stop()
9533 if (test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, vsi->back->flags)) { in ice_stop()
9537 if (link_err == -ENOMEDIUM) in ice_stop()
9538 netdev_info(vsi->netdev, "Skipping link reconfig - no media attached, VSI %d\n", in ice_stop()
9539 vsi->vsi_num); in ice_stop()
9541 netdev_err(vsi->netdev, "Failed to set physical link down, VSI %d error %d\n", in ice_stop()
9542 vsi->vsi_num, link_err); in ice_stop()
9545 return -EIO; in ice_stop()
9555 * ice_features_check - Validate encapsulated packet conforms to limits
9572 if (skb->ip_summed != CHECKSUM_PARTIAL) in ice_features_check()
9578 if (gso && (skb_shinfo(skb)->gso_size < ICE_TXD_CTX_MIN_MSS)) in ice_features_check()
9589 if (skb->encapsulation) { in ice_features_check()
9595 if (gso && (skb_shinfo(skb)->gso_type & in ice_features_check()
9597 len = skb_inner_network_header(skb) - in ice_features_check()