Lines Matching full:pf
65 struct ice_pf *pf = container_of(hw, struct ice_pf, hw); in ice_hw_to_dev() local
67 return &pf->pdev->dev; in ice_hw_to_dev()
75 static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type);
77 static void ice_vsi_release_all(struct ice_pf *pf);
79 static int ice_rebuild_channels(struct ice_pf *pf);
113 * @pf: pointer to PF struct
115 static void ice_check_for_hang_subtask(struct ice_pf *pf) in ice_check_for_hang_subtask() argument
123 ice_for_each_vsi(pf, v) in ice_check_for_hang_subtask()
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()
177 * @pf: board private structure
179 * Set initial set of MAC filters for PF VSI; configure filters for permanent
183 static int ice_init_mac_fltr(struct ice_pf *pf) in ice_init_mac_fltr() argument
188 vsi = ice_get_main_vsi(pf); in ice_init_mac_fltr()
261 * ice_set_promisc - Enable promiscuous mode for a given PF
290 * ice_clear_promisc - Disable promiscuous mode for a given PF
328 struct ice_pf *pf = vsi->back; in ice_vsi_sync_fltr() local
329 struct ice_hw *hw = &pf->hw; in ice_vsi_sync_fltr()
483 * @pf: board private structure
485 static void ice_sync_fltr_subtask(struct ice_pf *pf) in ice_sync_fltr_subtask() argument
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()
494 ice_for_each_vsi(pf, v) 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
505 * @pf: the PF
508 static void ice_pf_dis_all_vsi(struct ice_pf *pf, bool locked) in ice_pf_dis_all_vsi() argument
513 ice_for_each_vsi(pf, v) in ice_pf_dis_all_vsi()
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()
526 * @pf: board private structure
532 ice_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) in ice_prepare_for_reset() argument
534 struct ice_hw *hw = &pf->hw; in ice_prepare_for_reset()
539 dev_dbg(ice_pf_to_dev(pf), "reset_type=%d\n", reset_type); 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()
547 ice_unplug_aux_dev(pf); in ice_prepare_for_reset()
551 ice_vc_notify_reset(pf); in ice_prepare_for_reset()
554 mutex_lock(&pf->vfs.table_lock); in ice_prepare_for_reset()
555 ice_for_each_vf(pf, bkt, vf) in ice_prepare_for_reset()
557 mutex_unlock(&pf->vfs.table_lock); in ice_prepare_for_reset()
559 if (ice_is_eswitch_mode_switchdev(pf)) { in ice_prepare_for_reset()
561 ice_eswitch_br_fdb_flush(pf->eswitch.br_offloads->bridge); in ice_prepare_for_reset()
566 vsi = ice_get_main_vsi(pf); in ice_prepare_for_reset()
575 if (test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) { in ice_prepare_for_reset()
591 clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags); in ice_prepare_for_reset()
603 set_bit(ICE_VSI_REBUILD_PENDING, ice_get_main_vsi(pf)->state); in ice_prepare_for_reset()
604 ice_pf_dis_all_vsi(pf, false); in ice_prepare_for_reset()
606 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_prepare_for_reset()
607 ice_ptp_prepare_for_reset(pf, reset_type); in ice_prepare_for_reset()
609 if (ice_is_feature_supported(pf, ICE_F_GNSS)) in ice_prepare_for_reset()
610 ice_gnss_exit(pf); in ice_prepare_for_reset()
617 set_bit(ICE_PREPARED_FOR_RESET, pf->state); in ice_prepare_for_reset()
622 * @pf: board private structure
625 static void ice_do_reset(struct ice_pf *pf, enum ice_reset_req reset_type) in ice_do_reset() argument
627 struct device *dev = ice_pf_to_dev(pf); in ice_do_reset()
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()
637 ice_prepare_for_reset(pf, reset_type); 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()
657 pf->pfr_count++; in ice_do_reset()
658 ice_rebuild(pf, reset_type); 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()
662 ice_reset_all_vfs(pf); in ice_do_reset()
668 * @pf: board private structure
670 static void ice_reset_subtask(struct ice_pf *pf) in ice_reset_subtask() argument
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()
695 ice_prepare_for_reset(pf, reset_type); 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()
703 ice_rebuild(pf, reset_type); 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()
713 ice_reset_all_vfs(pf); 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()
723 dev_dbg(ice_pf_to_dev(pf), "PFR on a bonded interface, promoting to CORER\n"); 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()
738 ice_do_reset(pf, reset_type); in ice_reset_subtask()
934 * @pf: private PF struct
943 static void ice_set_dflt_mib(struct ice_pf *pf) in ice_set_dflt_mib() argument
945 struct device *dev = ice_pf_to_dev(pf); in ice_set_dflt_mib()
949 struct ice_hw *hw = &pf->hw; in ice_set_dflt_mib()
1022 * @pf: pointer to PF struct
1027 static void ice_check_phy_fw_load(struct ice_pf *pf, u8 link_cfg_err) in ice_check_phy_fw_load() argument
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()
1038 …dev_err(ice_pf_to_dev(pf), "Device failed to load the FW for the external PHY. Please download and… in ice_check_phy_fw_load()
1039 set_bit(ICE_FLAG_PHY_FW_LOAD_FAILED, pf->flags); in ice_check_phy_fw_load()
1045 * @pf: pointer to PF struct
1051 static void ice_check_module_power(struct ice_pf *pf, u8 link_cfg_err) in ice_check_module_power() argument
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()
1067 …dev_err(ice_pf_to_dev(pf), "The installed module is incompatible with the device's NVM image. Cann… in ice_check_module_power()
1068 set_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags); in ice_check_module_power()
1070 …dev_err(ice_pf_to_dev(pf), "The module's power requirements exceed the device's power supply. Cann… in ice_check_module_power()
1071 set_bit(ICE_FLAG_MOD_POWER_UNSUPPORTED, pf->flags); in ice_check_module_power()
1077 * @pf: pointer to the PF struct
1083 static void ice_check_link_cfg_err(struct ice_pf *pf, u8 link_cfg_err) in ice_check_link_cfg_err() argument
1085 ice_check_module_power(pf, link_cfg_err); in ice_check_link_cfg_err()
1086 ice_check_phy_fw_load(pf, link_cfg_err); in ice_check_link_cfg_err()
1091 * @pf: PF that the link event is associated with
1099 ice_link_event(struct ice_pf *pf, struct ice_port_info *pi, bool link_up, in ice_link_event() argument
1102 struct device *dev = ice_pf_to_dev(pf); in ice_link_event()
1124 ice_check_link_cfg_err(pf, pi->phy.link_info.link_cfg_err); in ice_link_event()
1132 vsi = ice_get_main_vsi(pf); in ice_link_event()
1137 if (!test_bit(ICE_FLAG_NO_MEDIA, pf->flags) && in ice_link_event()
1139 set_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_link_event()
1147 ice_ptp_link_change(pf, link_up); in ice_link_event()
1149 if (ice_is_dcb_active(pf)) { in ice_link_event()
1150 if (test_bit(ICE_FLAG_DCB_ENA, pf->flags)) in ice_link_event()
1151 ice_dcb_rebuild(pf); in ice_link_event()
1154 ice_set_dflt_mib(pf); in ice_link_event()
1159 ice_vc_notify_link_state(pf); in ice_link_event()
1166 * @pf: board private structure
1168 static void ice_watchdog_subtask(struct ice_pf *pf) in ice_watchdog_subtask() argument
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()
1187 ice_update_pf_stats(pf); in ice_watchdog_subtask()
1188 ice_for_each_vsi(pf, i) 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()
1224 * @pf: PF that the link event is associated with
1228 ice_handle_link_event(struct ice_pf *pf, struct ice_rq_event_info *event) in ice_handle_link_event() argument
1235 port_info = pf->hw.port_info; in ice_handle_link_event()
1239 status = ice_link_event(pf, port_info, in ice_handle_link_event()
1243 dev_dbg(ice_pf_to_dev(pf), "Could not process link event, error %d\n", in ice_handle_link_event()
1251 * @pf: PF that the FW log event is associated with
1255 ice_get_fwlog_data(struct ice_pf *pf, struct ice_rq_event_info *event) in ice_get_fwlog_data() argument
1258 struct ice_hw *hw = &pf->hw; in ice_get_fwlog_data()
1277 * @pf: pointer to the PF private structure
1282 * a given PF. Actual wait would be done by a call to ice_aq_wait_for_event().
1291 void ice_aq_prep_for_event(struct ice_pf *pf, struct ice_aq_task *task, in ice_aq_prep_for_event() argument
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()
1305 * @pf: pointer to the PF private structure
1309 * Waits for a specific AdminQ completion event on the ARQ for a given PF. The
1315 int ice_aq_wait_for_event(struct ice_pf *pf, struct ice_aq_task *task, in ice_aq_wait_for_event() argument
1319 struct device *dev = ice_pf_to_dev(pf); in ice_aq_wait_for_event()
1324 ret = wait_event_interruptible_timeout(pf->aq_wait_queue, in ice_aq_wait_for_event()
1352 spin_lock_bh(&pf->aq_wait_lock); in ice_aq_wait_for_event()
1354 spin_unlock_bh(&pf->aq_wait_lock); in ice_aq_wait_for_event()
1361 * @pf: pointer to the PF private structure
1377 static void ice_aq_check_events(struct ice_pf *pf, u16 opcode, in ice_aq_check_events() argument
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()
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()
1413 * @pf: the PF private structure
1418 static void ice_aq_cancel_waiting_tasks(struct ice_pf *pf) in ice_aq_cancel_waiting_tasks() argument
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()
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()
1434 * @pf: ptr to struct ice_pf
1437 static int __ice_clean_ctrlq(struct ice_pf *pf, enum ice_ctl_q q_type) in __ice_clean_ctrlq() argument
1439 struct device *dev = ice_pf_to_dev(pf); in __ice_clean_ctrlq()
1441 struct ice_hw *hw = &pf->hw; in __ice_clean_ctrlq()
1447 /* Do not clean control queue if/when PF reset fails */ in __ice_clean_ctrlq()
1448 if (test_bit(ICE_RESET_FAILED, pf->state)) in __ice_clean_ctrlq()
1538 ice_aq_check_events(pf, opcode, &event); in __ice_clean_ctrlq()
1542 if (ice_handle_link_event(pf, &event)) in __ice_clean_ctrlq()
1546 ice_vf_lan_overflow_event(pf, &event); in __ice_clean_ctrlq()
1549 if (ice_is_feature_supported(pf, ICE_F_MBX_LIMIT)) { in __ice_clean_ctrlq()
1550 ice_vc_process_vf_msg(pf, &event, NULL); in __ice_clean_ctrlq()
1561 ice_vc_process_vf_msg(pf, &event, &data); in __ice_clean_ctrlq()
1565 ice_get_fwlog_data(pf, &event); in __ice_clean_ctrlq()
1568 ice_dcb_process_lldp_set_mib_change(pf, &event); in __ice_clean_ctrlq()
1571 ice_process_health_status_event(pf, &event); in __ice_clean_ctrlq()
1602 * @pf: board private structure
1604 static void ice_clean_adminq_subtask(struct ice_pf *pf) in ice_clean_adminq_subtask() argument
1606 struct ice_hw *hw = &pf->hw; in ice_clean_adminq_subtask()
1608 if (!test_bit(ICE_ADMINQ_EVENT_PENDING, pf->state)) in ice_clean_adminq_subtask()
1611 if (__ice_clean_ctrlq(pf, ICE_CTL_Q_ADMIN)) in ice_clean_adminq_subtask()
1614 clear_bit(ICE_ADMINQ_EVENT_PENDING, pf->state); in ice_clean_adminq_subtask()
1622 __ice_clean_ctrlq(pf, ICE_CTL_Q_ADMIN); in ice_clean_adminq_subtask()
1629 * @pf: board private structure
1631 static void ice_clean_mailboxq_subtask(struct ice_pf *pf) in ice_clean_mailboxq_subtask() argument
1633 struct ice_hw *hw = &pf->hw; in ice_clean_mailboxq_subtask()
1635 if (!test_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state)) in ice_clean_mailboxq_subtask()
1638 if (__ice_clean_ctrlq(pf, ICE_CTL_Q_MAILBOX)) in ice_clean_mailboxq_subtask()
1641 clear_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state); in ice_clean_mailboxq_subtask()
1644 __ice_clean_ctrlq(pf, ICE_CTL_Q_MAILBOX); in ice_clean_mailboxq_subtask()
1651 * @pf: board private structure
1653 static void ice_clean_sbq_subtask(struct ice_pf *pf) in ice_clean_sbq_subtask() argument
1655 struct ice_hw *hw = &pf->hw; in ice_clean_sbq_subtask()
1661 clear_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state); in ice_clean_sbq_subtask()
1665 if (!test_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state)) in ice_clean_sbq_subtask()
1668 if (__ice_clean_ctrlq(pf, ICE_CTL_Q_SB)) in ice_clean_sbq_subtask()
1671 clear_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state); in ice_clean_sbq_subtask()
1674 __ice_clean_ctrlq(pf, ICE_CTL_Q_SB); in ice_clean_sbq_subtask()
1681 * @pf: board private structure
1685 void ice_service_task_schedule(struct ice_pf *pf) in ice_service_task_schedule() argument
1687 if (!test_bit(ICE_SERVICE_DIS, pf->state) && in ice_service_task_schedule()
1688 !test_and_set_bit(ICE_SERVICE_SCHED, pf->state) && in ice_service_task_schedule()
1689 !test_bit(ICE_NEEDS_RESTART, pf->state)) in ice_service_task_schedule()
1690 queue_work(ice_wq, &pf->serv_task); in ice_service_task_schedule()
1695 * @pf: board private structure
1697 static void ice_service_task_complete(struct ice_pf *pf) in ice_service_task_complete() argument
1699 WARN_ON(!test_bit(ICE_SERVICE_SCHED, pf->state)); in ice_service_task_complete()
1701 /* force memory (pf->state) to sync before next service task */ in ice_service_task_complete()
1703 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_service_task_complete()
1708 * @pf: board private structure
1713 static int ice_service_task_stop(struct ice_pf *pf) in ice_service_task_stop() argument
1717 ret = test_and_set_bit(ICE_SERVICE_DIS, pf->state); in ice_service_task_stop()
1719 if (pf->serv_tmr.function) in ice_service_task_stop()
1720 del_timer_sync(&pf->serv_tmr); in ice_service_task_stop()
1721 if (pf->serv_task.func) in ice_service_task_stop()
1722 cancel_work_sync(&pf->serv_task); in ice_service_task_stop()
1724 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_service_task_stop()
1730 * @pf: board private structure
1734 static void ice_service_task_restart(struct ice_pf *pf) in ice_service_task_restart() argument
1736 clear_bit(ICE_SERVICE_DIS, pf->state); in ice_service_task_restart()
1737 ice_service_task_schedule(pf); in ice_service_task_restart()
1746 struct ice_pf *pf = from_timer(pf, t, serv_tmr); in ice_service_timer() local
1748 mod_timer(&pf->serv_tmr, round_jiffies(pf->serv_tmr_period + jiffies)); in ice_service_timer()
1749 ice_service_task_schedule(pf); in ice_service_timer()
1754 * @pf: pointer to the PF structure
1759 * Since the queue can get stuck on VF MDD events, the PF can be configured to
1763 static void ice_mdd_maybe_reset_vf(struct ice_pf *pf, struct ice_vf *vf, in ice_mdd_maybe_reset_vf() argument
1766 struct device *dev = ice_pf_to_dev(pf); in ice_mdd_maybe_reset_vf()
1768 if (!test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf->flags)) in ice_mdd_maybe_reset_vf()
1780 dev_info(dev, "PF-to-VF reset on PF %d VF %d due to MDD event\n", in ice_mdd_maybe_reset_vf()
1781 pf->hw.pf_id, vf->vf_id); in ice_mdd_maybe_reset_vf()
1787 * @pf: pointer to the PF structure
1790 * VF MDD logging is guarded by net_ratelimit. Additional PF and VF log
1792 * disable the queue, the PF can be configured to reset the VF using ethtool
1795 static void ice_handle_mdd_event(struct ice_pf *pf) in ice_handle_mdd_event() argument
1797 struct device *dev = ice_pf_to_dev(pf); in ice_handle_mdd_event()
1798 struct ice_hw *hw = &pf->hw; in ice_handle_mdd_event()
1803 if (!test_and_clear_bit(ICE_MDD_EVENT_PENDING, pf->state)) { in ice_handle_mdd_event()
1807 ice_print_vfs_mdd_events(pf); in ice_handle_mdd_event()
1819 if (netif_msg_tx_err(pf)) in ice_handle_mdd_event()
1820 dev_info(dev, "Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\n", in ice_handle_mdd_event()
1822 ice_report_mdd_event(pf, ICE_MDD_SRC_TX_PQM, pf_num, vf_num, in ice_handle_mdd_event()
1834 if (netif_msg_tx_err(pf)) in ice_handle_mdd_event()
1835 dev_info(dev, "Malicious Driver Detection event %d on TX queue %d PF# %d VF# %d\n", in ice_handle_mdd_event()
1837 ice_report_mdd_event(pf, ICE_MDD_SRC_TX_TCLAN, pf_num, vf_num, in ice_handle_mdd_event()
1849 if (netif_msg_rx_err(pf)) in ice_handle_mdd_event()
1850 dev_info(dev, "Malicious Driver Detection event %d on RX queue %d PF# %d VF# %d\n", in ice_handle_mdd_event()
1852 ice_report_mdd_event(pf, ICE_MDD_SRC_RX, pf_num, vf_num, event, in ice_handle_mdd_event()
1857 /* check to see if this PF caused an MDD event */ in ice_handle_mdd_event()
1861 if (netif_msg_tx_err(pf)) in ice_handle_mdd_event()
1862 dev_info(dev, "Malicious Driver Detection event TX_PQM detected on PF\n"); in ice_handle_mdd_event()
1868 if (netif_msg_tx_err(pf)) in ice_handle_mdd_event()
1869 dev_info(dev, "Malicious Driver Detection event TX_TCLAN detected on PF\n"); in ice_handle_mdd_event()
1875 if (netif_msg_rx_err(pf)) in ice_handle_mdd_event()
1876 dev_info(dev, "Malicious Driver Detection event RX detected on PF\n"); in ice_handle_mdd_event()
1882 mutex_lock(&pf->vfs.table_lock); in ice_handle_mdd_event()
1883 ice_for_each_vf(pf, bkt, vf) { in ice_handle_mdd_event()
1890 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1891 if (netif_msg_tx_err(pf)) in ice_handle_mdd_event()
1902 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1903 if (netif_msg_tx_err(pf)) in ice_handle_mdd_event()
1914 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1915 if (netif_msg_tx_err(pf)) in ice_handle_mdd_event()
1926 set_bit(ICE_MDD_VF_PRINT_PENDING, pf->state); in ice_handle_mdd_event()
1927 if (netif_msg_rx_err(pf)) in ice_handle_mdd_event()
1935 ice_mdd_maybe_reset_vf(pf, vf, reset_vf_tx, in ice_handle_mdd_event()
1938 mutex_unlock(&pf->vfs.table_lock); in ice_handle_mdd_event()
1940 ice_print_vfs_mdd_events(pf); in ice_handle_mdd_event()
2028 struct ice_pf *pf = pi->hw->back; in ice_init_nvm_phy_type() local
2039 dev_err(ice_pf_to_dev(pf), "Get PHY capability failed.\n"); in ice_init_nvm_phy_type()
2043 pf->nvm_phy_type_hi = pcaps->phy_type_high; in ice_init_nvm_phy_type()
2044 pf->nvm_phy_type_lo = pcaps->phy_type_low; in ice_init_nvm_phy_type()
2060 struct ice_pf *pf = pi->hw->back; in ice_init_link_dflt_override() local
2062 ldo = &pf->link_dflt_override; in ice_init_link_dflt_override()
2072 set_bit(ICE_FLAG_TOTAL_PORT_SHUTDOWN_ENA, pf->flags); in ice_init_link_dflt_override()
2073 set_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags); in ice_init_link_dflt_override()
2098 struct ice_pf *pf = pi->hw->back; in ice_init_phy_cfg_dflt_override() local
2100 ldo = &pf->link_dflt_override; in ice_init_phy_cfg_dflt_override()
2108 cfg->phy_type_low = pf->nvm_phy_type_lo & in ice_init_phy_cfg_dflt_override()
2110 cfg->phy_type_high = pf->nvm_phy_type_hi & in ice_init_phy_cfg_dflt_override()
2116 set_bit(ICE_LINK_DEFAULT_OVERRIDE_PENDING, pf->state); in ice_init_phy_cfg_dflt_override()
2137 struct ice_pf *pf = pi->hw->back; in ice_init_phy_user_cfg() local
2154 dev_err(ice_pf_to_dev(pf), "Get PHY capability failed.\n"); in ice_init_phy_user_cfg()
2164 set_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags); in ice_init_phy_user_cfg()
2171 (pf->link_dflt_override.options & ICE_LINK_OVERRIDE_EN)) { in ice_init_phy_user_cfg()
2186 set_bit(ICE_PHY_INIT_COMPLETE, pf->state); in ice_init_phy_user_cfg()
2207 struct ice_pf *pf = vsi->back; in ice_configure_phy() local
2216 if (!test_bit(ICE_FLAG_LINK_LENIENT_MODE_ENA, pf->flags) && in ice_configure_phy()
2220 if (test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags)) in ice_configure_phy()
2306 err = ice_aq_set_phy_cfg(&pf->hw, pi, cfg, NULL); in ice_configure_phy()
2319 * @pf: pointer to PF struct
2324 static void ice_check_media_subtask(struct ice_pf *pf) in ice_check_media_subtask() argument
2331 if (!test_bit(ICE_FLAG_NO_MEDIA, pf->flags)) in ice_check_media_subtask()
2334 vsi = ice_get_main_vsi(pf); in ice_check_media_subtask()
2344 ice_check_link_cfg_err(pf, pi->phy.link_info.link_cfg_err); in ice_check_media_subtask()
2347 if (!test_bit(ICE_PHY_INIT_COMPLETE, pf->state)) in ice_check_media_subtask()
2359 clear_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_check_media_subtask()
2369 struct ice_pf *pf = container_of(work, struct ice_pf, serv_task); in ice_service_task_recovery_mode() local
2371 set_bit(ICE_ADMINQ_EVENT_PENDING, pf->state); in ice_service_task_recovery_mode()
2372 ice_clean_adminq_subtask(pf); in ice_service_task_recovery_mode()
2374 ice_service_task_complete(pf); in ice_service_task_recovery_mode()
2376 mod_timer(&pf->serv_tmr, jiffies + msecs_to_jiffies(100)); in ice_service_task_recovery_mode()
2381 * @work: pointer to work_struct contained by the PF struct
2385 struct ice_pf *pf = container_of(work, struct ice_pf, serv_task); in ice_service_task() local
2388 if (pf->health_reporters.tx_hang_buf.tx_ring) { in ice_service_task()
2389 ice_report_tx_hang(pf); in ice_service_task()
2390 pf->health_reporters.tx_hang_buf.tx_ring = NULL; in ice_service_task()
2393 ice_reset_subtask(pf); in ice_service_task()
2396 if (ice_is_reset_in_progress(pf->state) || in ice_service_task()
2397 test_bit(ICE_SUSPENDED, pf->state) || in ice_service_task()
2398 test_bit(ICE_NEEDS_RESTART, pf->state)) { in ice_service_task()
2399 ice_service_task_complete(pf); in ice_service_task()
2403 if (test_and_clear_bit(ICE_AUX_ERR_PENDING, pf->state)) { in ice_service_task()
2410 swap(event->reg, pf->oicr_err_reg); in ice_service_task()
2411 ice_send_event_to_aux(pf, event); in ice_service_task()
2419 if (test_and_clear_bit(ICE_FLAG_UNPLUG_AUX_DEV, pf->flags)) in ice_service_task()
2420 ice_unplug_aux_dev(pf); in ice_service_task()
2423 if (test_and_clear_bit(ICE_FLAG_PLUG_AUX_DEV, pf->flags)) in ice_service_task()
2424 ice_plug_aux_dev(pf); in ice_service_task()
2426 if (test_and_clear_bit(ICE_FLAG_MTU_CHANGED, pf->flags)) { in ice_service_task()
2432 ice_send_event_to_aux(pf, event); in ice_service_task()
2437 ice_clean_adminq_subtask(pf); in ice_service_task()
2438 ice_check_media_subtask(pf); in ice_service_task()
2439 ice_check_for_hang_subtask(pf); in ice_service_task()
2440 ice_sync_fltr_subtask(pf); in ice_service_task()
2441 ice_handle_mdd_event(pf); in ice_service_task()
2442 ice_watchdog_subtask(pf); in ice_service_task()
2444 if (ice_is_safe_mode(pf)) { in ice_service_task()
2445 ice_service_task_complete(pf); in ice_service_task()
2449 ice_process_vflr_event(pf); in ice_service_task()
2450 ice_clean_mailboxq_subtask(pf); in ice_service_task()
2451 ice_clean_sbq_subtask(pf); in ice_service_task()
2452 ice_sync_arfs_fltrs(pf); in ice_service_task()
2453 ice_flush_fdir_ctx(pf); in ice_service_task()
2456 ice_service_task_complete(pf); in ice_service_task()
2462 if (time_after(jiffies, (start_time + pf->serv_tmr_period)) || in ice_service_task()
2463 test_bit(ICE_MDD_EVENT_PENDING, pf->state) || in ice_service_task()
2464 test_bit(ICE_VFLR_EVENT_PENDING, pf->state) || in ice_service_task()
2465 test_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state) || in ice_service_task()
2466 test_bit(ICE_FD_VF_FLUSH_CTX, pf->state) || in ice_service_task()
2467 test_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state) || in ice_service_task()
2468 test_bit(ICE_ADMINQ_EVENT_PENDING, pf->state)) in ice_service_task()
2469 mod_timer(&pf->serv_tmr, jiffies); in ice_service_task()
2494 * @pf: board private structure
2497 int ice_schedule_reset(struct ice_pf *pf, enum ice_reset_req reset) in ice_schedule_reset() argument
2499 struct device *dev = ice_pf_to_dev(pf); in ice_schedule_reset()
2502 if (test_bit(ICE_RESET_FAILED, pf->state)) { in ice_schedule_reset()
2507 if (ice_is_reset_in_progress(pf->state)) { in ice_schedule_reset()
2514 set_bit(ICE_PFR_REQ, pf->state); in ice_schedule_reset()
2517 set_bit(ICE_CORER_REQ, pf->state); in ice_schedule_reset()
2520 set_bit(ICE_GLOBR_REQ, pf->state); in ice_schedule_reset()
2526 ice_service_task_schedule(pf); in ice_schedule_reset()
2582 struct ice_pf *pf = vsi->back; in ice_vsi_req_irq_msix() local
2589 dev = ice_pf_to_dev(pf); in ice_vsi_req_irq_msix()
2799 struct ice_pf *pf = vsi->back; in ice_prepare_xdp_rings() local
2801 .qs_mutex = &pf->avail_q_mutex, in ice_prepare_xdp_rings()
2802 .pf_map = pf->avail_txqs, in ice_prepare_xdp_rings()
2803 .pf_map_size = pf->max_pf_txqs, in ice_prepare_xdp_rings()
2813 dev = ice_pf_to_dev(pf); in ice_prepare_xdp_rings()
2874 mutex_lock(&pf->avail_q_mutex); in ice_prepare_xdp_rings()
2876 clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs); in ice_prepare_xdp_rings()
2879 mutex_unlock(&pf->avail_q_mutex); in ice_prepare_xdp_rings()
2890 * Detach XDP rings from irq vectors, clean up the PF bitmap and free
2896 struct ice_pf *pf = vsi->back; in ice_destroy_xdp_rings() local
2918 mutex_lock(&pf->avail_q_mutex); in ice_destroy_xdp_rings()
2920 clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs); in ice_destroy_xdp_rings()
2923 mutex_unlock(&pf->avail_q_mutex); in ice_destroy_xdp_rings()
2937 devm_kfree(ice_pf_to_dev(pf), vsi->xdp_rings); in ice_destroy_xdp_rings()
3117 NL_SET_ERR_MSG_MOD(xdp->extack, "XDP can be loaded only on PF or SF VSI"); in ice_xdp()
3140 * @pf: board private structure
3142 static void ice_ena_misc_vector(struct ice_pf *pf) in ice_ena_misc_vector() argument
3144 struct ice_hw *hw = &pf->hw; in ice_ena_misc_vector()
3172 wr32(hw, GLINT_DYN_CTL(pf->oicr_irq.index), in ice_ena_misc_vector()
3175 if (!pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) in ice_ena_misc_vector()
3178 wr32(hw, GLINT_DYN_CTL(pf->ll_ts_irq.index + pf_intr_start_offset), in ice_ena_misc_vector()
3189 struct ice_pf *pf = data; in ice_ll_ts_intr() local
3197 hw = &pf->hw; in ice_ll_ts_intr()
3198 tx = &pf->ptp.port.tx; in ice_ll_ts_intr()
3211 wr32(hw, GLINT_DYN_CTL(pf->ll_ts_irq.index + pf_intr_start_offset), in ice_ll_ts_intr()
3224 struct ice_pf *pf = (struct ice_pf *)data; in ice_misc_intr() local
3226 struct ice_hw *hw = &pf->hw; in ice_misc_intr()
3230 dev = ice_pf_to_dev(pf); in ice_misc_intr()
3231 set_bit(ICE_ADMINQ_EVENT_PENDING, pf->state); in ice_misc_intr()
3232 set_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state); in ice_misc_intr()
3233 set_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state); in ice_misc_intr()
3240 pf->sw_int_count++; in ice_misc_intr()
3245 set_bit(ICE_MDD_EVENT_PENDING, pf->state); in ice_misc_intr()
3249 if (test_bit(ICE_VF_RESETS_DISABLED, pf->state)) { in ice_misc_intr()
3256 set_bit(ICE_VFLR_EVENT_PENDING, pf->state); in ice_misc_intr()
3269 pf->corer_count++; in ice_misc_intr()
3271 pf->globr_count++; in ice_misc_intr()
3273 pf->empr_count++; in ice_misc_intr()
3278 * pf->state so that the service task can start a reset/rebuild. in ice_misc_intr()
3280 if (!test_and_set_bit(ICE_RESET_OICR_RECV, pf->state)) { in ice_misc_intr()
3282 set_bit(ICE_CORER_RECV, pf->state); in ice_misc_intr()
3284 set_bit(ICE_GLOBR_RECV, pf->state); in ice_misc_intr()
3286 set_bit(ICE_EMPR_RECV, pf->state); in ice_misc_intr()
3294 * ICE_RESET_OICR_RECV in pf->state indicates in ice_misc_intr()
3307 if (ice_pf_state_is_nominal(pf) && in ice_misc_intr()
3308 pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) { in ice_misc_intr()
3309 struct ice_ptp_tx *tx = &pf->ptp.port.tx; in ice_misc_intr()
3319 } else if (ice_ptp_pf_handles_tx_interrupt(pf)) { in ice_misc_intr()
3320 set_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread); in ice_misc_intr()
3331 if (ice_pf_src_tmr_owned(pf)) { in ice_misc_intr()
3333 pf->ptp.ext_ts_irq |= gltsyn_stat & in ice_misc_intr()
3338 ice_ptp_extts_event(pf); in ice_misc_intr()
3344 pf->oicr_err_reg |= oicr; in ice_misc_intr()
3345 set_bit(ICE_AUX_ERR_PENDING, pf->state); in ice_misc_intr()
3358 set_bit(ICE_PFR_REQ, pf->state); in ice_misc_intr()
3361 ice_service_task_schedule(pf); in ice_misc_intr()
3375 struct ice_pf *pf = data; in ice_misc_intr_thread_fn() local
3378 hw = &pf->hw; in ice_misc_intr_thread_fn()
3380 if (ice_is_reset_in_progress(pf->state)) in ice_misc_intr_thread_fn()
3383 if (test_and_clear_bit(ICE_MISC_THREAD_TX_TSTAMP, pf->misc_thread)) { in ice_misc_intr_thread_fn()
3387 if (ice_ptp_process_ts(pf) == ICE_TX_TSTAMP_WORK_PENDING) { in ice_misc_intr_thread_fn()
3425 * @pf: board private structure
3427 static void ice_free_irq_msix_ll_ts(struct ice_pf *pf) in ice_free_irq_msix_ll_ts() argument
3429 int irq_num = pf->ll_ts_irq.virq; in ice_free_irq_msix_ll_ts()
3432 devm_free_irq(ice_pf_to_dev(pf), irq_num, pf); in ice_free_irq_msix_ll_ts()
3434 ice_free_irq(pf, pf->ll_ts_irq); in ice_free_irq_msix_ll_ts()
3439 * @pf: board private structure
3441 static void ice_free_irq_msix_misc(struct ice_pf *pf) in ice_free_irq_msix_misc() argument
3443 int misc_irq_num = pf->oicr_irq.virq; in ice_free_irq_msix_misc()
3444 struct ice_hw *hw = &pf->hw; in ice_free_irq_msix_misc()
3453 devm_free_irq(ice_pf_to_dev(pf), misc_irq_num, pf); in ice_free_irq_msix_misc()
3455 ice_free_irq(pf, pf->oicr_irq); in ice_free_irq_msix_misc()
3456 if (pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) in ice_free_irq_msix_misc()
3457 ice_free_irq_msix_ll_ts(pf); in ice_free_irq_msix_misc()
3495 * @pf: board private structure
3501 static int ice_req_irq_msix_misc(struct ice_pf *pf) in ice_req_irq_msix_misc() argument
3503 struct device *dev = ice_pf_to_dev(pf); in ice_req_irq_msix_misc()
3504 struct ice_hw *hw = &pf->hw; in ice_req_irq_msix_misc()
3509 if (!pf->int_name[0]) in ice_req_irq_msix_misc()
3510 snprintf(pf->int_name, sizeof(pf->int_name) - 1, "%s-%s:misc", in ice_req_irq_msix_misc()
3513 if (!pf->int_name_ll_ts[0]) in ice_req_irq_msix_misc()
3514 snprintf(pf->int_name_ll_ts, sizeof(pf->int_name_ll_ts) - 1, in ice_req_irq_msix_misc()
3520 if (ice_is_reset_in_progress(pf->state)) in ice_req_irq_msix_misc()
3524 irq = ice_alloc_irq(pf, false); in ice_req_irq_msix_misc()
3528 pf->oicr_irq = irq; in ice_req_irq_msix_misc()
3529 err = devm_request_threaded_irq(dev, pf->oicr_irq.virq, ice_misc_intr, in ice_req_irq_msix_misc()
3531 pf->int_name, pf); in ice_req_irq_msix_misc()
3534 pf->int_name, err); in ice_req_irq_msix_misc()
3535 ice_free_irq(pf, pf->oicr_irq); in ice_req_irq_msix_misc()
3540 if (!pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) in ice_req_irq_msix_misc()
3543 irq = ice_alloc_irq(pf, false); in ice_req_irq_msix_misc()
3547 pf->ll_ts_irq = irq; in ice_req_irq_msix_misc()
3548 err = devm_request_irq(dev, pf->ll_ts_irq.virq, ice_ll_ts_intr, 0, in ice_req_irq_msix_misc()
3549 pf->int_name_ll_ts, pf); in ice_req_irq_msix_misc()
3552 pf->int_name_ll_ts, err); in ice_req_irq_msix_misc()
3553 ice_free_irq(pf, pf->ll_ts_irq); in ice_req_irq_msix_misc()
3558 ice_ena_misc_vector(pf); in ice_req_irq_msix_misc()
3560 ice_ena_ctrlq_interrupts(hw, pf->oicr_irq.index); in ice_req_irq_msix_misc()
3563 if (pf->hw.dev_caps.ts_dev_info.ts_ll_int_read) in ice_req_irq_msix_misc()
3565 ((pf->ll_ts_irq.index + pf_intr_start_offset) & in ice_req_irq_msix_misc()
3567 wr32(hw, GLINT_ITR(ICE_RX_ITR, pf->oicr_irq.index), in ice_req_irq_msix_misc()
3583 struct ice_pf *pf = ice_netdev_to_pf(netdev); in ice_set_ops() local
3585 if (ice_is_safe_mode(pf)) { in ice_set_ops()
3592 netdev->udp_tunnel_nic_info = &pf->hw.udp_tunnel_nic; in ice_set_ops()
3611 struct ice_pf *pf = ice_netdev_to_pf(netdev); in ice_set_netdev_features() local
3612 bool is_dvm_ena = ice_is_dvm_ena(&pf->hw); in ice_set_netdev_features()
3618 if (ice_is_safe_mode(pf)) { in ice_set_netdev_features()
3710 * ice_pf_vsi_setup - Set up a PF VSI
3711 * @pf: board private structure
3718 ice_pf_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi) in ice_pf_vsi_setup() argument
3726 return ice_vsi_setup(pf, ¶ms); in ice_pf_vsi_setup()
3730 ice_chnl_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi, in ice_chnl_vsi_setup() argument
3740 return ice_vsi_setup(pf, ¶ms); in ice_chnl_vsi_setup()
3745 * @pf: board private structure
3752 ice_ctrl_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi) in ice_ctrl_vsi_setup() argument
3760 return ice_vsi_setup(pf, ¶ms); in ice_ctrl_vsi_setup()
3765 * @pf: board private structure
3772 ice_lb_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi) in ice_lb_vsi_setup() argument
3780 return ice_vsi_setup(pf, ¶ms); in ice_lb_vsi_setup()
3978 * @pf: pointer to an ice_pf instance
3980 u16 ice_get_avail_txq_count(struct ice_pf *pf) in ice_get_avail_txq_count() argument
3982 return ice_get_avail_q_count(pf->avail_txqs, &pf->avail_q_mutex, in ice_get_avail_txq_count()
3983 pf->max_pf_txqs); in ice_get_avail_txq_count()
3988 * @pf: pointer to an ice_pf instance
3990 u16 ice_get_avail_rxq_count(struct ice_pf *pf) in ice_get_avail_rxq_count() argument
3992 return ice_get_avail_q_count(pf->avail_rxqs, &pf->avail_q_mutex, in ice_get_avail_rxq_count()
3993 pf->max_pf_rxqs); in ice_get_avail_rxq_count()
3998 * @pf: board private structure to initialize
4000 static void ice_deinit_pf(struct ice_pf *pf) in ice_deinit_pf() argument
4002 ice_service_task_stop(pf); in ice_deinit_pf()
4003 mutex_destroy(&pf->lag_mutex); in ice_deinit_pf()
4004 mutex_destroy(&pf->adev_mutex); in ice_deinit_pf()
4005 mutex_destroy(&pf->sw_mutex); in ice_deinit_pf()
4006 mutex_destroy(&pf->tc_mutex); in ice_deinit_pf()
4007 mutex_destroy(&pf->avail_q_mutex); in ice_deinit_pf()
4008 mutex_destroy(&pf->vfs.table_lock); in ice_deinit_pf()
4010 if (pf->avail_txqs) { in ice_deinit_pf()
4011 bitmap_free(pf->avail_txqs); in ice_deinit_pf()
4012 pf->avail_txqs = NULL; in ice_deinit_pf()
4015 if (pf->avail_rxqs) { in ice_deinit_pf()
4016 bitmap_free(pf->avail_rxqs); in ice_deinit_pf()
4017 pf->avail_rxqs = NULL; in ice_deinit_pf()
4020 if (pf->ptp.clock) in ice_deinit_pf()
4021 ptp_clock_unregister(pf->ptp.clock); in ice_deinit_pf()
4023 xa_destroy(&pf->dyn_ports); in ice_deinit_pf()
4024 xa_destroy(&pf->sf_nums); in ice_deinit_pf()
4029 * @pf: pointer to the PF instance
4031 static void ice_set_pf_caps(struct ice_pf *pf) in ice_set_pf_caps() argument
4033 struct ice_hw_func_caps *func_caps = &pf->hw.func_caps; in ice_set_pf_caps()
4035 clear_bit(ICE_FLAG_RDMA_ENA, pf->flags); in ice_set_pf_caps()
4037 set_bit(ICE_FLAG_RDMA_ENA, pf->flags); in ice_set_pf_caps()
4038 clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); in ice_set_pf_caps()
4040 set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); in ice_set_pf_caps()
4041 clear_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); in ice_set_pf_caps()
4043 set_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags); in ice_set_pf_caps()
4044 pf->vfs.num_supported = min_t(int, func_caps->num_allocd_vfs, in ice_set_pf_caps()
4047 clear_bit(ICE_FLAG_RSS_ENA, pf->flags); in ice_set_pf_caps()
4049 set_bit(ICE_FLAG_RSS_ENA, pf->flags); in ice_set_pf_caps()
4051 clear_bit(ICE_FLAG_FD_ENA, pf->flags); in ice_set_pf_caps()
4058 pf->ctrl_vsi_idx = ICE_NO_VSI; in ice_set_pf_caps()
4059 set_bit(ICE_FLAG_FD_ENA, pf->flags); in ice_set_pf_caps()
4060 /* force guaranteed filter pool for PF */ in ice_set_pf_caps()
4061 ice_alloc_fd_guar_item(&pf->hw, &unused, in ice_set_pf_caps()
4063 /* force shared filter pool for PF */ in ice_set_pf_caps()
4064 ice_alloc_fd_shrd_item(&pf->hw, &unused, in ice_set_pf_caps()
4068 clear_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags); in ice_set_pf_caps()
4070 !(pf->hw.mac_type == ICE_MAC_E830)) in ice_set_pf_caps()
4071 set_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags); in ice_set_pf_caps()
4073 pf->max_pf_txqs = func_caps->common_cap.num_txq; in ice_set_pf_caps()
4074 pf->max_pf_rxqs = func_caps->common_cap.num_rxq; in ice_set_pf_caps()
4079 * @pf: board private structure to initialize
4081 static int ice_init_pf(struct ice_pf *pf) in ice_init_pf() argument
4083 ice_set_pf_caps(pf); in ice_init_pf()
4085 mutex_init(&pf->sw_mutex); in ice_init_pf()
4086 mutex_init(&pf->tc_mutex); in ice_init_pf()
4087 mutex_init(&pf->adev_mutex); in ice_init_pf()
4088 mutex_init(&pf->lag_mutex); in ice_init_pf()
4090 INIT_HLIST_HEAD(&pf->aq_wait_list); in ice_init_pf()
4091 spin_lock_init(&pf->aq_wait_lock); in ice_init_pf()
4092 init_waitqueue_head(&pf->aq_wait_queue); in ice_init_pf()
4094 init_waitqueue_head(&pf->reset_wait_queue); in ice_init_pf()
4097 timer_setup(&pf->serv_tmr, ice_service_timer, 0); in ice_init_pf()
4098 pf->serv_tmr_period = HZ; in ice_init_pf()
4099 INIT_WORK(&pf->serv_task, ice_service_task); in ice_init_pf()
4100 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_init_pf()
4102 mutex_init(&pf->avail_q_mutex); in ice_init_pf()
4103 pf->avail_txqs = bitmap_zalloc(pf->max_pf_txqs, GFP_KERNEL); in ice_init_pf()
4104 if (!pf->avail_txqs) in ice_init_pf()
4107 pf->avail_rxqs = bitmap_zalloc(pf->max_pf_rxqs, GFP_KERNEL); in ice_init_pf()
4108 if (!pf->avail_rxqs) { in ice_init_pf()
4109 bitmap_free(pf->avail_txqs); in ice_init_pf()
4110 pf->avail_txqs = NULL; in ice_init_pf()
4114 mutex_init(&pf->vfs.table_lock); in ice_init_pf()
4115 hash_init(pf->vfs.table); in ice_init_pf()
4116 if (ice_is_feature_supported(pf, ICE_F_MBX_LIMIT)) in ice_init_pf()
4117 wr32(&pf->hw, E830_MBX_PF_IN_FLIGHT_VF_MSGS_THRESH, in ice_init_pf()
4120 ice_mbx_init_snapshot(&pf->hw); in ice_init_pf()
4122 xa_init(&pf->dyn_ports); in ice_init_pf()
4123 xa_init(&pf->sf_nums); in ice_init_pf()
4140 * word) indicates WoL is not supported on the corresponding PF ID. in ice_is_wol_supported()
4161 struct ice_pf *pf = vsi->back; in ice_vsi_recfg_qs() local
4167 while (test_and_set_bit(ICE_CFG_BUSY, pf->state)) { in ice_vsi_recfg_qs()
4184 dev_dbg(ice_pf_to_dev(pf), "Link is down, queue count change happens when link is brought up\n"); in ice_vsi_recfg_qs()
4200 ice_pf_dcb_recfg(pf, locked); in ice_vsi_recfg_qs()
4205 dev_err(ice_pf_to_dev(pf), "Error during VSI rebuild: %d. Unload and reload the driver.\n", in ice_vsi_recfg_qs()
4208 clear_bit(ICE_CFG_BUSY, pf->state); in ice_vsi_recfg_qs()
4213 * ice_set_safe_mode_vlan_cfg - configure PF VSI to allow all VLANs in safe mode
4214 * @pf: PF to configure
4216 * No VLAN offloads/filtering are advertised in safe mode so make sure the PF
4219 static void ice_set_safe_mode_vlan_cfg(struct ice_pf *pf) in ice_set_safe_mode_vlan_cfg() argument
4221 struct ice_vsi *vsi = ice_get_main_vsi(pf); in ice_set_safe_mode_vlan_cfg()
4233 hw = &pf->hw; in ice_set_safe_mode_vlan_cfg()
4272 struct ice_pf *pf = hw->back; in ice_log_pkg_init() local
4275 dev = ice_pf_to_dev(pf); in ice_log_pkg_init()
4349 * @pf: pointer to the PF instance
4355 ice_load_pkg(const struct firmware *firmware, struct ice_pf *pf) in ice_load_pkg() argument
4358 struct device *dev = ice_pf_to_dev(pf); in ice_load_pkg()
4359 struct ice_hw *hw = &pf->hw; in ice_load_pkg()
4376 clear_bit(ICE_FLAG_ADV_FEATURES, pf->flags); in ice_load_pkg()
4383 set_bit(ICE_FLAG_ADV_FEATURES, pf->flags); in ice_load_pkg()
4388 * @pf: pointer to the PF structure
4394 static void ice_verify_cacheline_size(struct ice_pf *pf) in ice_verify_cacheline_size() argument
4396 if (rd32(&pf->hw, GLPCI_CNF2) & GLPCI_CNF2_CACHELINE_SIZE_M) in ice_verify_cacheline_size()
4397 …dev_warn(ice_pf_to_dev(pf), "%d Byte cache line assumption is invalid, driver may have Tx timeouts… in ice_verify_cacheline_size()
4403 * @pf: PF struct
4407 static int ice_send_version(struct ice_pf *pf) in ice_send_version() argument
4417 return ice_aq_send_driver_ver(&pf->hw, &dv, NULL); in ice_send_version()
4422 * @pf: pointer to the PF instance
4426 static int ice_init_fdir(struct ice_pf *pf) in ice_init_fdir() argument
4428 struct device *dev = ice_pf_to_dev(pf); in ice_init_fdir()
4433 * Allocate it and store it in the PF. in ice_init_fdir()
4435 ctrl_vsi = ice_ctrl_vsi_setup(pf, pf->hw.port_info); in ice_init_fdir()
4447 mutex_init(&pf->hw.fdir_fltr_lock); in ice_init_fdir()
4449 err = ice_fdir_create_dflt_rules(pf); in ice_init_fdir()
4456 ice_fdir_release_flows(&pf->hw); in ice_init_fdir()
4460 if (pf->ctrl_vsi_idx != ICE_NO_VSI) { in ice_init_fdir()
4461 pf->vsi[pf->ctrl_vsi_idx] = NULL; in ice_init_fdir()
4462 pf->ctrl_vsi_idx = ICE_NO_VSI; in ice_init_fdir()
4467 static void ice_deinit_fdir(struct ice_pf *pf) in ice_deinit_fdir() argument
4469 struct ice_vsi *vsi = ice_get_ctrl_vsi(pf); in ice_deinit_fdir()
4476 if (pf->ctrl_vsi_idx != ICE_NO_VSI) { in ice_deinit_fdir()
4477 pf->vsi[pf->ctrl_vsi_idx] = NULL; in ice_deinit_fdir()
4478 pf->ctrl_vsi_idx = ICE_NO_VSI; in ice_deinit_fdir()
4481 mutex_destroy(&(&pf->hw)->fdir_fltr_lock); in ice_deinit_fdir()
4486 * @pf: pointer to the PF instance
4488 static char *ice_get_opt_fw_name(struct ice_pf *pf) in ice_get_opt_fw_name() argument
4493 struct pci_dev *pdev = pf->pdev; in ice_get_opt_fw_name()
4516 * @pf: pointer to the PF instance
4521 static int ice_request_fw(struct ice_pf *pf, const struct firmware **firmware) in ice_request_fw() argument
4523 char *opt_fw_filename = ice_get_opt_fw_name(pf); in ice_request_fw()
4524 struct device *dev = ice_pf_to_dev(pf); in ice_request_fw()
4555 struct ice_pf *pf = hw->back; in ice_init_tx_topology() local
4559 dev = ice_pf_to_dev(pf); in ice_init_tx_topology()
4583 * @pf: pointer to pf structure
4585 * The pf->supported_rxdids bitmap is used to indicate to VFs which descriptor
4586 * formats the PF hardware supports. The exact list of supported RXDIDs
4594 static void ice_init_supported_rxdids(struct ice_hw *hw, struct ice_pf *pf) in ice_init_supported_rxdids() argument
4596 pf->supported_rxdids = BIT(ICE_RXDID_LEGACY_1); in ice_init_supported_rxdids()
4604 pf->supported_rxdids |= BIT(i); in ice_init_supported_rxdids()
4611 * @pf: pointer to pf structure
4618 static int ice_init_ddp_config(struct ice_hw *hw, struct ice_pf *pf) in ice_init_ddp_config() argument
4620 struct device *dev = ice_pf_to_dev(pf); in ice_init_ddp_config()
4624 err = ice_request_fw(pf, &firmware); in ice_init_ddp_config()
4639 ice_load_pkg(firmware, pf); in ice_init_ddp_config()
4643 ice_init_supported_rxdids(hw, pf); in ice_init_ddp_config()
4650 * @pf: pointer to the PF struct
4652 static void ice_print_wake_reason(struct ice_pf *pf) in ice_print_wake_reason() argument
4654 u32 wus = pf->wakeup_reason; in ice_print_wake_reason()
4672 dev_info(ice_pf_to_dev(pf), "Wake reason: %s", wake_str); in ice_print_wake_reason()
4677 * @pf: pointer to the PF struct
4681 void ice_pf_fwlog_update_module(struct ice_pf *pf, int log_level, int module) in ice_pf_fwlog_update_module() argument
4683 struct ice_hw *hw = &pf->hw; in ice_pf_fwlog_update_module()
4767 int ice_init_dev(struct ice_pf *pf) in ice_init_dev() argument
4769 struct device *dev = ice_pf_to_dev(pf); in ice_init_dev()
4770 struct ice_hw *hw = &pf->hw; in ice_init_dev()
4773 ice_init_feature_support(pf); in ice_init_dev()
4775 err = ice_init_ddp_config(hw, pf); in ice_init_dev()
4778 * set in pf->state, which will cause ice_is_safe_mode to return in ice_init_dev()
4781 if (err || ice_is_safe_mode(pf)) { in ice_init_dev()
4790 err = ice_init_pf(pf); in ice_init_dev()
4796 pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port; in ice_init_dev()
4797 pf->hw.udp_tunnel_nic.unset_port = ice_udp_tunnel_unset_port; in ice_init_dev()
4798 pf->hw.udp_tunnel_nic.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP; in ice_init_dev()
4799 pf->hw.udp_tunnel_nic.shared = &pf->hw.udp_tunnel_shared; in ice_init_dev()
4800 if (pf->hw.tnl.valid_count[TNL_VXLAN]) { in ice_init_dev()
4801 pf->hw.udp_tunnel_nic.tables[0].n_entries = in ice_init_dev()
4802 pf->hw.tnl.valid_count[TNL_VXLAN]; in ice_init_dev()
4803 pf->hw.udp_tunnel_nic.tables[0].tunnel_types = in ice_init_dev()
4806 if (pf->hw.tnl.valid_count[TNL_GENEVE]) { in ice_init_dev()
4807 pf->hw.udp_tunnel_nic.tables[1].n_entries = in ice_init_dev()
4808 pf->hw.tnl.valid_count[TNL_GENEVE]; in ice_init_dev()
4809 pf->hw.udp_tunnel_nic.tables[1].tunnel_types = in ice_init_dev()
4813 err = ice_init_interrupt_scheme(pf); in ice_init_dev()
4825 err = ice_req_irq_msix_misc(pf); in ice_init_dev()
4834 ice_clear_interrupt_scheme(pf); in ice_init_dev()
4836 ice_deinit_pf(pf); in ice_init_dev()
4840 void ice_deinit_dev(struct ice_pf *pf) in ice_deinit_dev() argument
4842 ice_free_irq_msix_misc(pf); in ice_deinit_dev()
4843 ice_deinit_pf(pf); in ice_deinit_dev()
4844 ice_deinit_hw(&pf->hw); in ice_deinit_dev()
4847 ice_reset(&pf->hw, ICE_RESET_PFR); in ice_deinit_dev()
4848 pci_wait_for_pending_transaction(pf->pdev); in ice_deinit_dev()
4849 ice_clear_interrupt_scheme(pf); in ice_deinit_dev()
4852 static void ice_init_features(struct ice_pf *pf) in ice_init_features() argument
4854 struct device *dev = ice_pf_to_dev(pf); in ice_init_features()
4856 if (ice_is_safe_mode(pf)) in ice_init_features()
4860 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_init_features()
4861 ice_ptp_init(pf); in ice_init_features()
4863 if (ice_is_feature_supported(pf, ICE_F_GNSS)) in ice_init_features()
4864 ice_gnss_init(pf); in ice_init_features()
4866 if (ice_is_feature_supported(pf, ICE_F_CGU) || in ice_init_features()
4867 ice_is_feature_supported(pf, ICE_F_PHY_RCLK)) in ice_init_features()
4868 ice_dpll_init(pf); in ice_init_features()
4871 if (ice_init_fdir(pf)) in ice_init_features()
4875 if (ice_init_pf_dcb(pf, false)) { in ice_init_features()
4876 clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); in ice_init_features()
4877 clear_bit(ICE_FLAG_DCB_ENA, pf->flags); in ice_init_features()
4879 ice_cfg_lldp_mib_change(&pf->hw, true); in ice_init_features()
4882 if (ice_init_lag(pf)) in ice_init_features()
4885 ice_hwmon_init(pf); in ice_init_features()
4888 static void ice_deinit_features(struct ice_pf *pf) in ice_deinit_features() argument
4890 if (ice_is_safe_mode(pf)) in ice_deinit_features()
4893 ice_deinit_lag(pf); in ice_deinit_features()
4894 if (test_bit(ICE_FLAG_DCB_CAPABLE, pf->flags)) in ice_deinit_features()
4895 ice_cfg_lldp_mib_change(&pf->hw, false); in ice_deinit_features()
4896 ice_deinit_fdir(pf); in ice_deinit_features()
4897 if (ice_is_feature_supported(pf, ICE_F_GNSS)) in ice_deinit_features()
4898 ice_gnss_exit(pf); in ice_deinit_features()
4899 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_deinit_features()
4900 ice_ptp_release(pf); in ice_deinit_features()
4901 if (test_bit(ICE_FLAG_DPLL, pf->flags)) in ice_deinit_features()
4902 ice_dpll_deinit(pf); in ice_deinit_features()
4903 if (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_SWITCHDEV) in ice_deinit_features()
4904 xa_destroy(&pf->eswitch.reprs); in ice_deinit_features()
4907 static void ice_init_wakeup(struct ice_pf *pf) in ice_init_wakeup() argument
4910 pf->wakeup_reason = rd32(&pf->hw, PFPM_WUS); in ice_init_wakeup()
4913 ice_print_wake_reason(pf); in ice_init_wakeup()
4916 wr32(&pf->hw, PFPM_WUS, U32_MAX); in ice_init_wakeup()
4919 device_set_wakeup_enable(ice_pf_to_dev(pf), false); in ice_init_wakeup()
4922 static int ice_init_link(struct ice_pf *pf) in ice_init_link() argument
4924 struct device *dev = ice_pf_to_dev(pf); in ice_init_link()
4927 err = ice_init_link_events(pf->hw.port_info); in ice_init_link()
4934 err = ice_init_nvm_phy_type(pf->hw.port_info); in ice_init_link()
4939 err = ice_update_link_info(pf->hw.port_info); in ice_init_link()
4943 ice_init_link_dflt_override(pf->hw.port_info); in ice_init_link()
4945 ice_check_link_cfg_err(pf, in ice_init_link()
4946 pf->hw.port_info->phy.link_info.link_cfg_err); in ice_init_link()
4949 if (pf->hw.port_info->phy.link_info.link_info & in ice_init_link()
4952 err = ice_init_phy_user_cfg(pf->hw.port_info); in ice_init_link()
4956 if (!test_bit(ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, pf->flags)) { in ice_init_link()
4957 struct ice_vsi *vsi = ice_get_main_vsi(pf); in ice_init_link()
4963 set_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_init_link()
4969 static int ice_init_pf_sw(struct ice_pf *pf) in ice_init_pf_sw() argument
4971 bool dvm = ice_is_dvm_ena(&pf->hw); in ice_init_pf_sw()
4976 pf->first_sw = kzalloc(sizeof(*pf->first_sw), GFP_KERNEL); in ice_init_pf_sw()
4977 if (!pf->first_sw) in ice_init_pf_sw()
4980 if (pf->hw.evb_veb) in ice_init_pf_sw()
4981 pf->first_sw->bridge_mode = BRIDGE_MODE_VEB; in ice_init_pf_sw()
4983 pf->first_sw->bridge_mode = BRIDGE_MODE_VEPA; in ice_init_pf_sw()
4985 pf->first_sw->pf = pf; in ice_init_pf_sw()
4988 pf->first_sw->sw_id = pf->hw.port_info->sw_id; in ice_init_pf_sw()
4990 err = ice_aq_set_port_params(pf->hw.port_info, dvm, NULL); in ice_init_pf_sw()
4994 vsi = ice_pf_vsi_setup(pf, pf->hw.port_info); in ice_init_pf_sw()
5004 kfree(pf->first_sw); in ice_init_pf_sw()
5008 static void ice_deinit_pf_sw(struct ice_pf *pf) in ice_deinit_pf_sw() argument
5010 struct ice_vsi *vsi = ice_get_main_vsi(pf); in ice_deinit_pf_sw()
5016 kfree(pf->first_sw); in ice_deinit_pf_sw()
5019 static int ice_alloc_vsis(struct ice_pf *pf) in ice_alloc_vsis() argument
5021 struct device *dev = ice_pf_to_dev(pf); in ice_alloc_vsis()
5023 pf->num_alloc_vsi = pf->hw.func_caps.guar_num_vsi; in ice_alloc_vsis()
5024 if (!pf->num_alloc_vsi) in ice_alloc_vsis()
5027 if (pf->num_alloc_vsi > UDP_TUNNEL_NIC_MAX_SHARING_DEVICES) { in ice_alloc_vsis()
5030 pf->num_alloc_vsi, UDP_TUNNEL_NIC_MAX_SHARING_DEVICES); in ice_alloc_vsis()
5031 pf->num_alloc_vsi = UDP_TUNNEL_NIC_MAX_SHARING_DEVICES; in ice_alloc_vsis()
5034 pf->vsi = devm_kcalloc(dev, pf->num_alloc_vsi, sizeof(*pf->vsi), in ice_alloc_vsis()
5036 if (!pf->vsi) in ice_alloc_vsis()
5039 pf->vsi_stats = devm_kcalloc(dev, pf->num_alloc_vsi, in ice_alloc_vsis()
5040 sizeof(*pf->vsi_stats), GFP_KERNEL); in ice_alloc_vsis()
5041 if (!pf->vsi_stats) { in ice_alloc_vsis()
5042 devm_kfree(dev, pf->vsi); in ice_alloc_vsis()
5049 static void ice_dealloc_vsis(struct ice_pf *pf) in ice_dealloc_vsis() argument
5051 devm_kfree(ice_pf_to_dev(pf), pf->vsi_stats); in ice_dealloc_vsis()
5052 pf->vsi_stats = NULL; in ice_dealloc_vsis()
5054 pf->num_alloc_vsi = 0; in ice_dealloc_vsis()
5055 devm_kfree(ice_pf_to_dev(pf), pf->vsi); in ice_dealloc_vsis()
5056 pf->vsi = NULL; in ice_dealloc_vsis()
5059 static int ice_init_devlink(struct ice_pf *pf) in ice_init_devlink() argument
5063 err = ice_devlink_register_params(pf); in ice_init_devlink()
5067 ice_devlink_init_regions(pf); in ice_init_devlink()
5068 ice_devlink_register(pf); in ice_init_devlink()
5069 ice_health_init(pf); in ice_init_devlink()
5074 static void ice_deinit_devlink(struct ice_pf *pf) in ice_deinit_devlink() argument
5076 ice_health_deinit(pf); in ice_deinit_devlink()
5077 ice_devlink_unregister(pf); in ice_deinit_devlink()
5078 ice_devlink_destroy_regions(pf); in ice_deinit_devlink()
5079 ice_devlink_unregister_params(pf); in ice_deinit_devlink()
5082 static int ice_init(struct ice_pf *pf) in ice_init() argument
5086 err = ice_init_dev(pf); in ice_init()
5090 err = ice_alloc_vsis(pf); in ice_init()
5094 err = ice_init_pf_sw(pf); in ice_init()
5098 ice_init_wakeup(pf); in ice_init()
5100 err = ice_init_link(pf); in ice_init()
5104 err = ice_send_version(pf); in ice_init()
5108 ice_verify_cacheline_size(pf); in ice_init()
5110 if (ice_is_safe_mode(pf)) in ice_init()
5111 ice_set_safe_mode_vlan_cfg(pf); in ice_init()
5114 pcie_print_link_status(pf->pdev); in ice_init()
5117 clear_bit(ICE_DOWN, pf->state); in ice_init()
5118 clear_bit(ICE_SERVICE_DIS, pf->state); in ice_init()
5121 mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period)); in ice_init()
5126 ice_deinit_pf_sw(pf); in ice_init()
5128 ice_dealloc_vsis(pf); in ice_init()
5130 ice_deinit_dev(pf); in ice_init()
5134 static void ice_deinit(struct ice_pf *pf) in ice_deinit() argument
5136 set_bit(ICE_SERVICE_DIS, pf->state); in ice_deinit()
5137 set_bit(ICE_DOWN, pf->state); in ice_deinit()
5139 ice_deinit_pf_sw(pf); in ice_deinit()
5140 ice_dealloc_vsis(pf); in ice_deinit()
5141 ice_deinit_dev(pf); in ice_deinit()
5145 * ice_load - load pf by init hw and starting VSI
5146 * @pf: pointer to the pf instance
5150 int ice_load(struct ice_pf *pf) in ice_load() argument
5155 devl_assert_locked(priv_to_devlink(pf)); in ice_load()
5157 vsi = ice_get_main_vsi(pf); in ice_load()
5169 err = ice_init_mac_fltr(pf); in ice_load()
5173 err = ice_devlink_create_pf_port(pf); in ice_load()
5177 SET_NETDEV_DEVLINK_PORT(vsi->netdev, &pf->devlink_port); in ice_load()
5189 err = ice_init_rdma(pf); in ice_load()
5193 ice_init_features(pf); in ice_load()
5194 ice_service_task_restart(pf); in ice_load()
5196 clear_bit(ICE_DOWN, pf->state); in ice_load()
5205 ice_devlink_destroy_pf_port(pf); in ice_load()
5213 * ice_unload - unload pf by stopping VSI and deinit hw
5214 * @pf: pointer to the pf instance
5218 void ice_unload(struct ice_pf *pf) in ice_unload() argument
5220 struct ice_vsi *vsi = ice_get_main_vsi(pf); in ice_unload()
5222 devl_assert_locked(priv_to_devlink(pf)); in ice_unload()
5224 ice_deinit_features(pf); in ice_unload()
5225 ice_deinit_rdma(pf); in ice_unload()
5228 ice_devlink_destroy_pf_port(pf); in ice_unload()
5232 static int ice_probe_recovery_mode(struct ice_pf *pf) in ice_probe_recovery_mode() argument
5234 struct device *dev = ice_pf_to_dev(pf); in ice_probe_recovery_mode()
5239 INIT_HLIST_HEAD(&pf->aq_wait_list); in ice_probe_recovery_mode()
5240 spin_lock_init(&pf->aq_wait_lock); in ice_probe_recovery_mode()
5241 init_waitqueue_head(&pf->aq_wait_queue); in ice_probe_recovery_mode()
5243 timer_setup(&pf->serv_tmr, ice_service_timer, 0); in ice_probe_recovery_mode()
5244 pf->serv_tmr_period = HZ; in ice_probe_recovery_mode()
5245 INIT_WORK(&pf->serv_task, ice_service_task_recovery_mode); in ice_probe_recovery_mode()
5246 clear_bit(ICE_SERVICE_SCHED, pf->state); in ice_probe_recovery_mode()
5247 err = ice_create_all_ctrlq(&pf->hw); in ice_probe_recovery_mode()
5251 scoped_guard(devl, priv_to_devlink(pf)) { in ice_probe_recovery_mode()
5252 err = ice_init_devlink(pf); in ice_probe_recovery_mode()
5257 ice_service_task_restart(pf); in ice_probe_recovery_mode()
5274 struct ice_pf *pf; in ice_probe() local
5310 pf = ice_allocate_pf(dev); in ice_probe()
5311 if (!pf) in ice_probe()
5315 pf->aux_idx = -1; in ice_probe()
5325 pf->pdev = pdev; in ice_probe()
5326 pci_set_drvdata(pdev, pf); in ice_probe()
5327 set_bit(ICE_DOWN, pf->state); in ice_probe()
5329 set_bit(ICE_SERVICE_DIS, pf->state); in ice_probe()
5331 hw = &pf->hw; in ice_probe()
5335 hw->back = pf; in ice_probe()
5346 pf->msg_enable = netif_msg_init(debug, ICE_DFLT_NETIF_M); in ice_probe()
5354 return ice_probe_recovery_mode(pf); in ice_probe()
5367 pf->adapter = adapter; in ice_probe()
5369 err = ice_init(pf); in ice_probe()
5373 devl_lock(priv_to_devlink(pf)); in ice_probe()
5374 err = ice_load(pf); in ice_probe()
5378 err = ice_init_devlink(pf); in ice_probe()
5381 devl_unlock(priv_to_devlink(pf)); in ice_probe()
5386 ice_unload(pf); in ice_probe()
5388 devl_unlock(priv_to_devlink(pf)); in ice_probe()
5389 ice_deinit(pf); in ice_probe()
5399 * @pf: pointer to the PF struct
5403 static void ice_set_wake(struct ice_pf *pf) in ice_set_wake() argument
5405 struct ice_hw *hw = &pf->hw; in ice_set_wake()
5406 bool wol = pf->wol_ena; in ice_set_wake()
5420 * @pf: pointer to the PF struct
5424 * wake, and that PF reset doesn't undo the LAA.
5426 static void ice_setup_mc_magic_wake(struct ice_pf *pf) in ice_setup_mc_magic_wake() argument
5428 struct device *dev = ice_pf_to_dev(pf); in ice_setup_mc_magic_wake()
5429 struct ice_hw *hw = &pf->hw; in ice_setup_mc_magic_wake()
5435 if (!pf->wol_ena) in ice_setup_mc_magic_wake()
5438 vsi = ice_get_main_vsi(pf); in ice_setup_mc_magic_wake()
5464 struct ice_pf *pf = pci_get_drvdata(pdev); in ice_remove() local
5468 if (!ice_is_reset_in_progress(pf->state)) in ice_remove()
5473 if (ice_is_recovery_mode(&pf->hw)) { in ice_remove()
5474 ice_service_task_stop(pf); in ice_remove()
5475 scoped_guard(devl, priv_to_devlink(pf)) { in ice_remove()
5476 ice_deinit_devlink(pf); in ice_remove()
5481 if (test_bit(ICE_FLAG_SRIOV_ENA, pf->flags)) { in ice_remove()
5482 set_bit(ICE_VF_RESETS_DISABLED, pf->state); in ice_remove()
5483 ice_free_vfs(pf); in ice_remove()
5486 ice_hwmon_exit(pf); in ice_remove()
5488 ice_service_task_stop(pf); in ice_remove()
5489 ice_aq_cancel_waiting_tasks(pf); in ice_remove()
5490 set_bit(ICE_DOWN, pf->state); in ice_remove()
5492 if (!ice_is_safe_mode(pf)) in ice_remove()
5493 ice_remove_arfs(pf); in ice_remove()
5495 devl_lock(priv_to_devlink(pf)); in ice_remove()
5496 ice_dealloc_all_dynamic_ports(pf); in ice_remove()
5497 ice_deinit_devlink(pf); in ice_remove()
5499 ice_unload(pf); in ice_remove()
5500 devl_unlock(priv_to_devlink(pf)); in ice_remove()
5502 ice_deinit(pf); in ice_remove()
5503 ice_vsi_release_all(pf); in ice_remove()
5505 ice_setup_mc_magic_wake(pf); in ice_remove()
5506 ice_set_wake(pf); in ice_remove()
5517 struct ice_pf *pf = pci_get_drvdata(pdev); in ice_shutdown() local
5522 pci_wake_from_d3(pdev, pf->wol_ena); in ice_shutdown()
5529 * @pf: board private structure
5533 static void ice_prepare_for_shutdown(struct ice_pf *pf) in ice_prepare_for_shutdown() argument
5535 struct ice_hw *hw = &pf->hw; in ice_prepare_for_shutdown()
5540 ice_vc_notify_reset(pf); in ice_prepare_for_shutdown()
5542 dev_dbg(ice_pf_to_dev(pf), "Tearing down internal switch for shutdown\n"); in ice_prepare_for_shutdown()
5545 ice_pf_dis_all_vsi(pf, false); in ice_prepare_for_shutdown()
5547 ice_for_each_vsi(pf, v) in ice_prepare_for_shutdown()
5548 if (pf->vsi[v]) in ice_prepare_for_shutdown()
5549 pf->vsi[v]->vsi_num = 0; in ice_prepare_for_shutdown()
5556 * @pf: board private structure to reinitialize
5564 static int ice_reinit_interrupt_scheme(struct ice_pf *pf) in ice_reinit_interrupt_scheme() argument
5566 struct device *dev = ice_pf_to_dev(pf); in ice_reinit_interrupt_scheme()
5573 ret = ice_init_interrupt_scheme(pf); in ice_reinit_interrupt_scheme()
5580 ice_for_each_vsi(pf, v) { in ice_reinit_interrupt_scheme()
5581 if (!pf->vsi[v]) in ice_reinit_interrupt_scheme()
5584 ret = ice_vsi_alloc_q_vectors(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5587 ice_vsi_map_rings_to_vectors(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5589 ice_vsi_set_napi_queues(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5593 ret = ice_req_irq_msix_misc(pf); in ice_reinit_interrupt_scheme()
5604 if (pf->vsi[v]) { in ice_reinit_interrupt_scheme()
5606 ice_vsi_clear_napi_queues(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5608 ice_vsi_free_q_vectors(pf->vsi[v]); in ice_reinit_interrupt_scheme()
5624 struct ice_pf *pf; in ice_suspend() local
5627 pf = pci_get_drvdata(pdev); in ice_suspend()
5629 if (!ice_pf_state_is_nominal(pf)) { in ice_suspend()
5640 disabled = ice_service_task_stop(pf); in ice_suspend()
5642 ice_deinit_rdma(pf); in ice_suspend()
5645 if (test_and_set_bit(ICE_SUSPENDED, pf->state)) { in ice_suspend()
5647 ice_service_task_restart(pf); in ice_suspend()
5651 if (test_bit(ICE_DOWN, pf->state) || in ice_suspend()
5652 ice_is_reset_in_progress(pf->state)) { in ice_suspend()
5655 ice_service_task_restart(pf); in ice_suspend()
5659 ice_setup_mc_magic_wake(pf); in ice_suspend()
5661 ice_prepare_for_shutdown(pf); in ice_suspend()
5663 ice_set_wake(pf); in ice_suspend()
5670 ice_free_irq_msix_misc(pf); in ice_suspend()
5671 ice_for_each_vsi(pf, v) { in ice_suspend()
5672 if (!pf->vsi[v]) in ice_suspend()
5675 ice_vsi_clear_napi_queues(pf->vsi[v]); in ice_suspend()
5677 ice_vsi_free_q_vectors(pf->vsi[v]); in ice_suspend()
5679 ice_clear_interrupt_scheme(pf); in ice_suspend()
5682 pci_wake_from_d3(pdev, pf->wol_ena); in ice_suspend()
5695 struct ice_pf *pf; in ice_resume() local
5712 pf = pci_get_drvdata(pdev); in ice_resume()
5713 hw = &pf->hw; in ice_resume()
5715 pf->wakeup_reason = rd32(hw, PFPM_WUS); in ice_resume()
5716 ice_print_wake_reason(pf); in ice_resume()
5721 ret = ice_reinit_interrupt_scheme(pf); in ice_resume()
5725 ret = ice_init_rdma(pf); in ice_resume()
5730 clear_bit(ICE_DOWN, pf->state); in ice_resume()
5731 /* Now perform PF reset and rebuild */ in ice_resume()
5734 clear_bit(ICE_SERVICE_DIS, pf->state); in ice_resume()
5736 if (ice_schedule_reset(pf, reset_type)) in ice_resume()
5739 clear_bit(ICE_SUSPENDED, pf->state); in ice_resume()
5740 ice_service_task_restart(pf); in ice_resume()
5743 mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period)); in ice_resume()
5759 struct ice_pf *pf = pci_get_drvdata(pdev); in ice_pci_err_detected() local
5761 if (!pf) { in ice_pci_err_detected()
5767 if (!test_bit(ICE_SUSPENDED, pf->state)) { in ice_pci_err_detected()
5768 ice_service_task_stop(pf); in ice_pci_err_detected()
5770 if (!test_bit(ICE_PREPARED_FOR_RESET, pf->state)) { in ice_pci_err_detected()
5771 set_bit(ICE_PFR_REQ, pf->state); in ice_pci_err_detected()
5772 ice_prepare_for_reset(pf, ICE_RESET_PFR); in ice_pci_err_detected()
5788 struct ice_pf *pf = pci_get_drvdata(pdev); in ice_pci_err_slot_reset() local
5805 reg = rd32(&pf->hw, GLGEN_RTRIG); in ice_pci_err_slot_reset()
5824 struct ice_pf *pf = pci_get_drvdata(pdev); in ice_pci_err_resume() local
5826 if (!pf) { in ice_pci_err_resume()
5832 if (test_bit(ICE_SUSPENDED, pf->state)) { in ice_pci_err_resume()
5838 ice_restore_all_vfs_msi_state(pf); in ice_pci_err_resume()
5840 ice_do_reset(pf, ICE_RESET_PFR); in ice_pci_err_resume()
5841 ice_service_task_restart(pf); in ice_pci_err_resume()
5842 mod_timer(&pf->serv_tmr, round_jiffies(jiffies + pf->serv_tmr_period)); in ice_pci_err_resume()
5851 struct ice_pf *pf = pci_get_drvdata(pdev); in ice_pci_err_reset_prepare() local
5853 if (!test_bit(ICE_SUSPENDED, pf->state)) { in ice_pci_err_reset_prepare()
5854 ice_service_task_stop(pf); in ice_pci_err_reset_prepare()
5856 if (!test_bit(ICE_PREPARED_FOR_RESET, pf->state)) { in ice_pci_err_reset_prepare()
5857 set_bit(ICE_PFR_REQ, pf->state); in ice_pci_err_reset_prepare()
5858 ice_prepare_for_reset(pf, ICE_RESET_PFR); in ice_pci_err_reset_prepare()
6031 struct ice_pf *pf = vsi->back; in ice_set_mac_address() local
6032 struct ice_hw *hw = &pf->hw; in ice_set_mac_address()
6044 if (test_bit(ICE_DOWN, pf->state) || in ice_set_mac_address()
6045 ice_is_reset_in_progress(pf->state)) { in ice_set_mac_address()
6051 if (ice_chnl_dmac_fltr_cnt(pf)) { in ice_set_mac_address()
6363 * @vsi: PF's VSI
6379 * ice_set_vlan_offload_features - set VLAN offload features for the PF VSI
6380 * @vsi: PF's VSI
6427 * ice_set_vlan_filtering_features - set VLAN filtering features for the PF VSI
6428 * @vsi: PF's VSI
6498 * ice_set_loopback - turn on/off loopback mode on underlying PF
6534 struct ice_pf *pf = vsi->back; in ice_set_features() local
6538 if (ice_is_safe_mode(pf)) { in ice_set_features()
6539 dev_err(ice_pf_to_dev(pf), in ice_set_features()
6545 if (ice_is_reset_in_progress(pf->state)) { in ice_set_features()
6546 dev_err(ice_pf_to_dev(pf), in ice_set_features()
6586 if (!(features & NETIF_F_HW_TC) && ice_is_adq_active(pf)) { in ice_set_features()
6587 dev_err(ice_pf_to_dev(pf), "ADQ is active, can't turn hw_tc_offload off\n"); in ice_set_features()
6594 assign_bit(ICE_FLAG_CLS_FLOWER, pf->flags, ena); in ice_set_features()
6604 * ice_vsi_vlan_setup - Setup VLAN offload properties on a PF VSI
6799 struct ice_pf *pf = vsi->back; in ice_up_complete() local
6823 ice_ptp_link_change(pf, true); in ice_up_complete()
6832 ice_service_task_schedule(pf); in ice_up_complete()
6915 struct ice_pf *pf = vsi->back; in ice_update_vsi_ring_stats() local
6962 * random value after PF reset. And as we increase the reported stat by in ice_update_vsi_ring_stats()
6966 if (likely(pf->stat_prev_loaded)) { in ice_update_vsi_ring_stats()
6989 struct ice_pf *pf = vsi->back; in ice_update_vsi_stats() local
6992 test_bit(ICE_CFG_BUSY, pf->state)) in ice_update_vsi_stats()
7008 cur_ns->rx_crc_errors = pf->stats.crc_errors; in ice_update_vsi_stats()
7009 cur_ns->rx_errors = pf->stats.crc_errors + in ice_update_vsi_stats()
7010 pf->stats.illegal_bytes + in ice_update_vsi_stats()
7011 pf->stats.rx_undersize + in ice_update_vsi_stats()
7012 pf->hw_csum_rx_error + in ice_update_vsi_stats()
7013 pf->stats.rx_jabber + in ice_update_vsi_stats()
7014 pf->stats.rx_fragments + in ice_update_vsi_stats()
7015 pf->stats.rx_oversize; in ice_update_vsi_stats()
7017 cur_ns->rx_missed_errors = pf->stats.eth.rx_discards; in ice_update_vsi_stats()
7022 * ice_update_pf_stats - Update PF port stats counters
7023 * @pf: PF whose stats needs to be updated
7025 void ice_update_pf_stats(struct ice_pf *pf) in ice_update_pf_stats() argument
7028 struct ice_hw *hw = &pf->hw; in ice_update_pf_stats()
7033 prev_ps = &pf->stats_prev; in ice_update_pf_stats()
7034 cur_ps = &pf->stats; in ice_update_pf_stats()
7036 if (ice_is_reset_in_progress(pf->state)) in ice_update_pf_stats()
7037 pf->stat_prev_loaded = false; in ice_update_pf_stats()
7039 ice_stat_update40(hw, GLPRT_GORCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7043 ice_stat_update40(hw, GLPRT_UPRCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7047 ice_stat_update40(hw, GLPRT_MPRCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7051 ice_stat_update40(hw, GLPRT_BPRCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7055 ice_stat_update32(hw, PRTRPB_RDPC, pf->stat_prev_loaded, in ice_update_pf_stats()
7059 ice_stat_update40(hw, GLPRT_GOTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7063 ice_stat_update40(hw, GLPRT_UPTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7067 ice_stat_update40(hw, GLPRT_MPTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7071 ice_stat_update40(hw, GLPRT_BPTCL(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7075 ice_stat_update32(hw, GLPRT_TDOLD(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7079 ice_stat_update40(hw, GLPRT_PRC64L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7082 ice_stat_update40(hw, GLPRT_PRC127L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7085 ice_stat_update40(hw, GLPRT_PRC255L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7088 ice_stat_update40(hw, GLPRT_PRC511L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7091 ice_stat_update40(hw, GLPRT_PRC1023L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7094 ice_stat_update40(hw, GLPRT_PRC1522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7097 ice_stat_update40(hw, GLPRT_PRC9522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7100 ice_stat_update40(hw, GLPRT_PTC64L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7103 ice_stat_update40(hw, GLPRT_PTC127L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7106 ice_stat_update40(hw, GLPRT_PTC255L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7109 ice_stat_update40(hw, GLPRT_PTC511L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7112 ice_stat_update40(hw, GLPRT_PTC1023L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7115 ice_stat_update40(hw, GLPRT_PTC1522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7118 ice_stat_update40(hw, GLPRT_PTC9522L(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7125 pf->stat_prev_loaded, &prev_ps->fd_sb_match, in ice_update_pf_stats()
7127 ice_stat_update32(hw, GLPRT_LXONRXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7130 ice_stat_update32(hw, GLPRT_LXOFFRXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7133 ice_stat_update32(hw, GLPRT_LXONTXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7136 ice_stat_update32(hw, GLPRT_LXOFFTXC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7139 ice_update_dcb_stats(pf); in ice_update_pf_stats()
7141 ice_stat_update32(hw, GLPRT_CRCERRS(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7144 ice_stat_update32(hw, GLPRT_ILLERRC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7147 ice_stat_update32(hw, GLPRT_MLFC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7151 ice_stat_update32(hw, GLPRT_MRFC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7155 ice_stat_update32(hw, GLPRT_RUC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7158 ice_stat_update32(hw, GLPRT_RFC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7161 ice_stat_update32(hw, GLPRT_ROC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7164 ice_stat_update32(hw, GLPRT_RJC(port), pf->stat_prev_loaded, in ice_update_pf_stats()
7167 cur_ps->fd_sb_status = test_bit(ICE_FLAG_FD_ENA, pf->flags) ? 1 : 0; in ice_update_pf_stats()
7169 pf->stat_prev_loaded = true; in ice_update_pf_stats()
7241 struct ice_pf *pf = vsi->back; in ice_vsi_dis_irq() local
7242 struct ice_hw *hw = &pf->hw; in ice_vsi_dis_irq()
7437 struct ice_pf *pf = vsi->back; in ice_vsi_open_ctrl() local
7441 dev = ice_pf_to_dev(pf); in ice_vsi_open_ctrl()
7493 struct ice_pf *pf = vsi->back; in ice_vsi_open() local
7510 dev_driver_string(ice_pf_to_dev(pf)), vsi->netdev->name); in ice_vsi_open()
7550 * @pf: PF from which all VSIs are being removed
7552 static void ice_vsi_release_all(struct ice_pf *pf) in ice_vsi_release_all() argument
7556 if (!pf->vsi) in ice_vsi_release_all()
7559 ice_for_each_vsi(pf, i) { in ice_vsi_release_all()
7560 if (!pf->vsi[i]) in ice_vsi_release_all()
7563 if (pf->vsi[i]->type == ICE_VSI_CHNL) in ice_vsi_release_all()
7566 err = ice_vsi_release(pf->vsi[i]); in ice_vsi_release_all()
7568 dev_dbg(ice_pf_to_dev(pf), "Failed to release pf->vsi[%d], err %d, vsi_num = %d\n", in ice_vsi_release_all()
7569 i, err, pf->vsi[i]->vsi_num); in ice_vsi_release_all()
7575 * @pf: pointer to the PF instance
7578 * Iterates through the pf->vsi array and rebuilds VSIs of the requested type
7580 static int ice_vsi_rebuild_by_type(struct ice_pf *pf, enum ice_vsi_type type) in ice_vsi_rebuild_by_type() argument
7582 struct device *dev = ice_pf_to_dev(pf); in ice_vsi_rebuild_by_type()
7585 ice_for_each_vsi(pf, i) { in ice_vsi_rebuild_by_type()
7586 struct ice_vsi *vsi = pf->vsi[i]; in ice_vsi_rebuild_by_type()
7600 err = ice_replay_vsi(&pf->hw, vsi->idx); in ice_vsi_rebuild_by_type()
7610 vsi->vsi_num = ice_get_hw_vsi_num(&pf->hw, vsi->idx); in ice_vsi_rebuild_by_type()
7628 * ice_update_pf_netdev_link - Update PF netdev link status
7629 * @pf: pointer to the PF instance
7631 static void ice_update_pf_netdev_link(struct ice_pf *pf) in ice_update_pf_netdev_link() argument
7636 ice_for_each_vsi(pf, i) { in ice_update_pf_netdev_link()
7637 struct ice_vsi *vsi = pf->vsi[i]; in ice_update_pf_netdev_link()
7642 ice_get_link_status(pf->vsi[i]->port_info, &link_up); in ice_update_pf_netdev_link()
7644 netif_carrier_on(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7645 netif_tx_wake_all_queues(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7647 netif_carrier_off(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7648 netif_tx_stop_all_queues(pf->vsi[i]->netdev); in ice_update_pf_netdev_link()
7655 * @pf: PF to rebuild
7663 static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) in ice_rebuild() argument
7665 struct ice_vsi *vsi = ice_get_main_vsi(pf); in ice_rebuild()
7666 struct device *dev = ice_pf_to_dev(pf); in ice_rebuild()
7667 struct ice_hw *hw = &pf->hw; in ice_rebuild()
7671 if (test_bit(ICE_DOWN, pf->state)) in ice_rebuild()
7674 dev_dbg(dev, "rebuilding PF after reset_type=%d\n", reset_type); in ice_rebuild()
7682 pf->fw_emp_reset_disabled = false; in ice_rebuild()
7694 if (!ice_is_safe_mode(pf)) { in ice_rebuild()
7700 ice_load_pkg(NULL, pf); in ice_rebuild()
7705 dev_err(dev, "clear PF configuration failed %d\n", err); in ice_rebuild()
7731 err = ice_aq_set_port_params(pf->hw.port_info, dvm, NULL); in ice_rebuild()
7740 err = ice_req_irq_msix_misc(pf); in ice_rebuild()
7746 if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) { in ice_rebuild()
7754 /* force guaranteed filter pool for PF */ in ice_rebuild()
7756 /* force shared filter pool for PF */ in ice_rebuild()
7761 if (test_bit(ICE_FLAG_DCB_ENA, pf->flags)) in ice_rebuild()
7762 ice_dcb_rebuild(pf); in ice_rebuild()
7764 /* If the PF previously had enabled PTP, PTP init needs to happen before in ice_rebuild()
7768 if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) in ice_rebuild()
7769 ice_ptp_rebuild(pf, reset_type); in ice_rebuild()
7771 if (ice_is_feature_supported(pf, ICE_F_GNSS)) in ice_rebuild()
7772 ice_gnss_init(pf); in ice_rebuild()
7774 /* rebuild PF VSI */ in ice_rebuild()
7775 err = ice_vsi_rebuild_by_type(pf, ICE_VSI_PF); in ice_rebuild()
7777 dev_err(dev, "PF VSI rebuild failed: %d\n", err); in ice_rebuild()
7782 err = ice_rebuild_channels(pf); in ice_rebuild()
7791 if (test_bit(ICE_FLAG_FD_ENA, pf->flags)) { in ice_rebuild()
7792 err = ice_vsi_rebuild_by_type(pf, ICE_VSI_CTRL); in ice_rebuild()
7803 ice_fdir_replay_fltrs(pf); in ice_rebuild()
7805 ice_rebuild_arfs(pf); in ice_rebuild()
7811 ice_update_pf_netdev_link(pf); in ice_rebuild()
7814 err = ice_send_version(pf); in ice_rebuild()
7824 clear_bit(ICE_RESET_FAILED, pf->state); in ice_rebuild()
7826 ice_health_clear(pf); in ice_rebuild()
7828 ice_plug_aux_dev(pf); in ice_rebuild()
7829 if (ice_is_feature_supported(pf, ICE_F_SRIOV_LAG)) in ice_rebuild()
7830 ice_lag_rebuild(pf); in ice_rebuild()
7833 ice_ptp_restore_timestamp_mode(pf); in ice_rebuild()
7841 set_bit(ICE_RESET_FAILED, pf->state); in ice_rebuild()
7843 /* set this bit in PF state to control service task scheduling */ in ice_rebuild()
7844 set_bit(ICE_NEEDS_RESTART, pf->state); in ice_rebuild()
7859 struct ice_pf *pf = vsi->back; in ice_change_mtu() local
7878 } else if (test_bit(ICE_FLAG_LEGACY_RX, pf->flags)) { in ice_change_mtu()
7888 if (ice_is_reset_in_progress(pf->state)) { in ice_change_mtu()
7908 set_bit(ICE_FLAG_MTU_CHANGED, pf->flags); in ice_change_mtu()
7922 struct ice_pf *pf = np->vsi->back; in ice_eth_ioctl() local
7926 return ice_ptp_get_ts_config(pf, ifr); in ice_eth_ioctl()
7928 return ice_ptp_set_ts_config(pf, ifr); in ice_eth_ioctl()
8152 struct ice_pf *pf = vsi->back; in ice_bridge_getlink() local
8155 bmode = pf->first_sw->bridge_mode; in ice_bridge_getlink()
8213 * hooked up to. Iterates through the PF VSI list and sets the loopback mode (if
8223 struct ice_pf *pf = np->vsi->back; in ice_bridge_setlink() local
8225 struct ice_hw *hw = &pf->hw; in ice_bridge_setlink()
8229 pf_sw = pf->first_sw; in ice_bridge_setlink()
8243 /* Iterates through the PF VSI list and update the loopback in ice_bridge_setlink()
8246 ice_for_each_vsi(pf, v) { in ice_bridge_setlink()
8247 if (!pf->vsi[v]) in ice_bridge_setlink()
8249 err = ice_vsi_update_bridge_mode(pf->vsi[v], mode); in ice_bridge_setlink()
8284 struct ice_pf *pf = vsi->back; in ice_tx_timeout() local
8287 pf->tx_timeout_count++; in ice_tx_timeout()
8293 if (ice_is_pfc_causing_hung_q(pf, txqueue)) { in ice_tx_timeout()
8294 dev_info(ice_pf_to_dev(pf), "Fake Tx hang detected on queue %u, timeout caused by PFC storm\n", in ice_tx_timeout()
8310 if (time_after(jiffies, (pf->tx_timeout_last_recovery + HZ * 20))) in ice_tx_timeout()
8311 pf->tx_timeout_recovery_level = 1; in ice_tx_timeout()
8312 else if (time_before(jiffies, (pf->tx_timeout_last_recovery + in ice_tx_timeout()
8317 struct ice_hw *hw = &pf->hw; in ice_tx_timeout()
8329 ice_prep_tx_hang_report(pf, tx_ring, vsi->vsi_num, head, intr); in ice_tx_timeout()
8332 pf->tx_timeout_last_recovery = jiffies; in ice_tx_timeout()
8334 pf->tx_timeout_recovery_level, txqueue); in ice_tx_timeout()
8336 switch (pf->tx_timeout_recovery_level) { in ice_tx_timeout()
8338 set_bit(ICE_PFR_REQ, pf->state); in ice_tx_timeout()
8341 set_bit(ICE_CORER_REQ, pf->state); in ice_tx_timeout()
8344 set_bit(ICE_GLOBR_REQ, pf->state); in ice_tx_timeout()
8348 set_bit(ICE_DOWN, pf->state); in ice_tx_timeout()
8350 set_bit(ICE_SERVICE_DIS, pf->state); in ice_tx_timeout()
8354 ice_service_task_schedule(pf); in ice_tx_timeout()
8355 pf->tx_timeout_recovery_level++; in ice_tx_timeout()
8418 struct ice_pf *pf = vsi->back; in ice_validate_mqprio_qopt() local
8433 dev = ice_pf_to_dev(pf); in ice_validate_mqprio_qopt()
8545 * ice_add_vsi_to_fdir - add a VSI to the flow director group for PF
8546 * @pf: ptr to PF device
8549 static int ice_add_vsi_to_fdir(struct ice_pf *pf, struct ice_vsi *vsi) in ice_add_vsi_to_fdir() argument
8551 struct device *dev = ice_pf_to_dev(pf); in ice_add_vsi_to_fdir()
8559 hw = &pf->hw; in ice_add_vsi_to_fdir()
8606 * @pf: ptr to PF device
8612 static int ice_add_channel(struct ice_pf *pf, u16 sw_id, struct ice_channel *ch) in ice_add_channel() argument
8614 struct device *dev = ice_pf_to_dev(pf); in ice_add_channel()
8622 vsi = ice_chnl_vsi_setup(pf, pf->hw.port_info, ch); in ice_add_channel()
8628 ice_add_vsi_to_fdir(pf, vsi); in ice_add_channel()
8720 * @pf: ptr to PF device
8730 ice_setup_hw_channel(struct ice_pf *pf, struct ice_vsi *vsi, in ice_setup_hw_channel() argument
8733 struct device *dev = ice_pf_to_dev(pf); in ice_setup_hw_channel()
8739 ret = ice_add_channel(pf, sw_id, ch); in ice_setup_hw_channel()
8760 * @pf: ptr to PF device
8768 ice_setup_channel(struct ice_pf *pf, struct ice_vsi *vsi, in ice_setup_channel() argument
8771 struct device *dev = ice_pf_to_dev(pf); in ice_setup_channel()
8780 sw_id = pf->first_sw->sw_id; in ice_setup_channel()
8783 ret = ice_setup_hw_channel(pf, vsi, ch, sw_id, ICE_VSI_CHNL); in ice_setup_channel()
8821 struct ice_pf *pf = vsi->back; in ice_create_q_channel() local
8827 dev = ice_pf_to_dev(pf); in ice_create_q_channel()
8839 if (!ice_setup_channel(pf, vsi, ch)) { in ice_create_q_channel()
8864 * @pf: ptr to PF, TC-flower based filter are tracked at PF level
8869 static void ice_rem_all_chnl_fltrs(struct ice_pf *pf) in ice_rem_all_chnl_fltrs() argument
8876 &pf->tc_flower_fltr_list, in ice_rem_all_chnl_fltrs()
8888 status = ice_rem_adv_rule_by_id(&pf->hw, &rule); in ice_rem_all_chnl_fltrs()
8891 dev_dbg(ice_pf_to_dev(pf), "TC flower filter (rule_id %u) does not exist\n", in ice_rem_all_chnl_fltrs()
8894 dev_err(ice_pf_to_dev(pf), "failed to delete TC flower filter, status %d\n", in ice_rem_all_chnl_fltrs()
8904 pf->num_dmac_chnl_fltrs--; in ice_rem_all_chnl_fltrs()
8923 struct ice_pf *pf = vsi->back; in ice_remove_q_channels() local
8928 ice_rem_all_chnl_fltrs(pf); in ice_remove_q_channels()
8932 struct ice_hw *hw = &pf->hw; in ice_remove_q_channels()
8970 ice_fdir_rem_adq_chnl(&pf->hw, ch->ch_vsi->idx); in ice_remove_q_channels()
8975 /* Delete VSI from FW, PF and HW VSI arrays */ in ice_remove_q_channels()
8993 * @pf: ptr to PF
8997 static int ice_rebuild_channels(struct ice_pf *pf) in ice_rebuild_channels() argument
8999 struct device *dev = ice_pf_to_dev(pf); in ice_rebuild_channels()
9007 main_vsi = ice_get_main_vsi(pf); in ice_rebuild_channels()
9011 if (!test_bit(ICE_FLAG_TC_MQPRIO, pf->flags) || in ice_rebuild_channels()
9026 ice_for_each_vsi(pf, i) { in ice_rebuild_channels()
9029 vsi = pf->vsi[i]; in ice_rebuild_channels()
9046 vsi->vsi_num = ice_get_hw_vsi_num(&pf->hw, vsi->idx); in ice_rebuild_channels()
9049 err = ice_replay_vsi(&pf->hw, vsi->idx); in ice_rebuild_channels()
9113 struct ice_pf *pf = vsi->back; in ice_create_q_channels() local
9143 dev_err(ice_pf_to_dev(pf), in ice_create_q_channels()
9150 dev_dbg(ice_pf_to_dev(pf), in ice_create_q_channels()
9171 struct ice_pf *pf = vsi->back; in ice_setup_tc_mqprio_qdisc() local
9178 dev = ice_pf_to_dev(pf); in ice_setup_tc_mqprio_qdisc()
9183 clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags); in ice_setup_tc_mqprio_qdisc()
9196 if (pf->hw.port_info->is_custom_tx_enabled) { in ice_setup_tc_mqprio_qdisc()
9200 ice_tear_down_devlink_rate_tree(pf); in ice_setup_tc_mqprio_qdisc()
9209 set_bit(ICE_FLAG_TC_MQPRIO, pf->flags); in ice_setup_tc_mqprio_qdisc()
9215 set_bit(ICE_FLAG_CLS_FLOWER, pf->flags); in ice_setup_tc_mqprio_qdisc()
9231 if (!hw && !test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) in ice_setup_tc_mqprio_qdisc()
9234 if (!hw && !test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) { in ice_setup_tc_mqprio_qdisc()
9235 vsi->req_txq = min_t(int, ice_get_avail_txq_count(pf), in ice_setup_tc_mqprio_qdisc()
9237 vsi->req_rxq = min_t(int, ice_get_avail_rxq_count(pf), in ice_setup_tc_mqprio_qdisc()
9274 clear_bit(ICE_RESET_FAILED, pf->state); in ice_setup_tc_mqprio_qdisc()
9290 if (test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) { in ice_setup_tc_mqprio_qdisc()
9343 struct ice_pf *pf = np->vsi->back; in ice_setup_tc() local
9354 if (ice_is_eswitch_mode_switchdev(pf)) { in ice_setup_tc()
9359 if (pf->adev) { in ice_setup_tc()
9360 mutex_lock(&pf->adev_mutex); in ice_setup_tc()
9361 device_lock(&pf->adev->dev); in ice_setup_tc()
9363 if (pf->adev->dev.driver) { in ice_setup_tc()
9371 mutex_lock(&pf->tc_mutex); in ice_setup_tc()
9373 mutex_unlock(&pf->tc_mutex); in ice_setup_tc()
9377 device_unlock(&pf->adev->dev); in ice_setup_tc()
9378 mutex_unlock(&pf->adev_mutex); in ice_setup_tc()
9517 struct ice_pf *pf = np->vsi->back; in ice_open() local
9519 if (ice_is_reset_in_progress(pf->state)) { in ice_open()
9540 struct ice_pf *pf = vsi->back; in ice_open_internal() local
9544 if (test_bit(ICE_NEEDS_RESTART, pf->state)) { in ice_open_internal()
9558 ice_check_link_cfg_err(pf, pi->phy.link_info.link_cfg_err); in ice_open_internal()
9562 clear_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_open_internal()
9563 if (!test_bit(ICE_PHY_INIT_COMPLETE, pf->state)) { in ice_open_internal()
9579 set_bit(ICE_FLAG_NO_MEDIA, pf->flags); in ice_open_internal()
9608 struct ice_pf *pf = vsi->back; in ice_stop() local
9610 if (ice_is_reset_in_progress(pf->state)) { in ice_stop()