Lines Matching defs:pf
19 * @pf: pointer to the PF structure
24 static void ice_free_vf_entries(struct ice_pf *pf)
26 struct ice_vfs *vfs = &pf->vfs;
50 struct ice_pf *pf = vf->pf;
77 wr32(&pf->hw, GLINT_DYN_CTL(i), GLINT_DYN_CTL_CLEARPBA_M);
78 ice_flush(&pf->hw);
91 struct ice_pf *pf = vf->pf;
97 hw = &pf->hw;
102 dev = ice_pf_to_dev(pf);
129 * @pf: pointer to the PF structure
131 void ice_free_vfs(struct ice_pf *pf)
133 struct device *dev = ice_pf_to_dev(pf);
134 struct ice_vfs *vfs = &pf->vfs;
135 struct ice_hw *hw = &pf->hw;
139 if (!ice_has_vfs(pf))
142 while (test_and_set_bit(ICE_VF_DIS, pf->state))
149 if (!pci_vfs_assigned(pf->pdev))
150 pci_disable_sriov(pf->pdev);
156 ice_for_each_vf(pf, bkt, vf) {
159 ice_eswitch_detach_vf(pf, vf);
161 ice_virt_free_irqs(pf, vf->first_vector_idx, vf->num_msix);
170 if (!pci_vfs_assigned(pf->pdev)) {
182 ice_free_vf_entries(pf);
186 clear_bit(ICE_VF_DIS, pf->state);
187 clear_bit(ICE_FLAG_SRIOV_ENA, pf->flags);
200 struct ice_pf *pf = vf->pf;
208 vsi = ice_vsi_setup(pf, ¶ms);
211 dev_err(ice_pf_to_dev(pf), "Failed to create VF VSI\n");
234 struct ice_pf *pf = vf->pf;
239 hw = &pf->hw;
244 pf->hw.func_caps.common_cap.msix_vector_first_id;
278 struct device *dev = ice_pf_to_dev(vf->pf);
280 struct ice_hw *hw = &vf->pf->hw;
351 * @pf: pointer to the PF structure
371 static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)
375 struct device *dev = ice_pf_to_dev(pf);
377 lockdep_assert_held(&pf->vfs.table_lock);
383 msix_avail_for_sriov = pf->virt_irq_tracker.num_entries;
402 avail_qs = ice_get_avail_txq_count(pf) / num_vfs;
410 avail_qs = ice_get_avail_rxq_count(pf) / num_vfs;
423 pf->vfs.num_qps_per = min_t(int, num_txq, num_rxq);
424 pf->vfs.num_msix_per = num_msix_per_vf;
426 num_vfs, pf->vfs.num_msix_per, pf->vfs.num_qps_per);
440 struct ice_pf *pf = vf->pf;
444 vf->first_vector_idx = ice_virt_get_irqs(pf, vf->num_msix);
465 * @pf: PF the VFs are associated with
467 static int ice_start_vfs(struct ice_pf *pf)
469 struct ice_hw *hw = &pf->hw;
474 lockdep_assert_held(&pf->vfs.table_lock);
477 ice_for_each_vf(pf, bkt, vf) {
482 dev_err(ice_pf_to_dev(pf), "Failed to initialize VSI resources for VF %d, error %d\n",
487 retval = ice_eswitch_attach_vf(pf, vf);
489 dev_err(ice_pf_to_dev(pf), "Failed to attach VF %d to eswitch, error %d",
505 ice_for_each_vf(pf, bkt, vf) {
537 struct ice_hw *hw = &vf->pf->hw;
552 struct ice_pf *pf = vf->pf;
554 wr32(&pf->hw, VF_MBX_ARQLEN(vf->vf_id), 0);
555 wr32(&pf->hw, VF_MBX_ATQLEN(vf->vf_id), 0);
567 struct ice_pf *pf = vf->pf;
573 dev = ice_pf_to_dev(pf);
574 hw = &pf->hw;
614 struct ice_pf *pf = vf->pf;
623 reg = rd32(&pf->hw, VPGEN_VFRSTAT(vf->vf_id));
639 struct ice_hw *hw = &vf->pf->hw;
655 wr32(&vf->pf->hw, VFGEN_RSTAT(vf->vf_id), VIRTCHNL_VFR_VFACTIVE);
672 * @pf: pointer to the PF structure
683 static int ice_create_vf_entries(struct ice_pf *pf, u16 num_vfs)
685 struct pci_dev *pdev = pf->pdev;
686 struct ice_vfs *vfs = &pf->vfs;
705 vf->pf = pf;
717 vf->vf_sw_id = pf->first_sw;
733 ice_free_vf_entries(pf);
739 * @pf: pointer to the PF structure
742 static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs)
744 struct device *dev = ice_pf_to_dev(pf);
745 struct ice_hw *hw = &pf->hw;
749 wr32(hw, GLINT_DYN_CTL(pf->oicr_irq.index),
751 set_bit(ICE_OICR_INTR_DIS, pf->state);
754 ret = pci_enable_sriov(pf->pdev, num_vfs);
758 mutex_lock(&pf->vfs.table_lock);
760 ret = ice_set_per_vf_res(pf, num_vfs);
767 ret = ice_create_vf_entries(pf, num_vfs);
774 ret = ice_start_vfs(pf);
781 clear_bit(ICE_VF_DIS, pf->state);
784 if (test_and_clear_bit(ICE_OICR_INTR_DIS, pf->state))
787 mutex_unlock(&pf->vfs.table_lock);
792 ice_free_vf_entries(pf);
794 mutex_unlock(&pf->vfs.table_lock);
795 pci_disable_sriov(pf->pdev);
799 clear_bit(ICE_OICR_INTR_DIS, pf->state);
805 * @pf: pointer to the PF structure
810 static int ice_pci_sriov_ena(struct ice_pf *pf, int num_vfs)
812 struct device *dev = ice_pf_to_dev(pf);
816 ice_free_vfs(pf);
820 if (num_vfs > pf->vfs.num_supported) {
822 num_vfs, pf->vfs.num_supported);
827 err = ice_ena_vfs(pf, num_vfs);
833 set_bit(ICE_FLAG_SRIOV_ENA, pf->flags);
839 * @pf: PF to enabled SR-IOV on
841 static int ice_check_sriov_allowed(struct ice_pf *pf)
843 struct device *dev = ice_pf_to_dev(pf);
845 if (!test_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags)) {
850 if (ice_is_safe_mode(pf)) {
855 if (!ice_pf_state_is_nominal(pf)) {
871 struct ice_pf *pf = pci_get_drvdata(pdev);
873 return pf->virt_irq_tracker.num_entries;
876 static void ice_sriov_remap_vectors(struct ice_pf *pf, u16 restricted_id)
885 ice_for_each_vf(pf, bkt, tmp_vf) {
892 ice_virt_free_irqs(pf, tmp_vf->first_vector_idx,
900 tmp_vf = ice_get_vf_by_id(pf, vf_ids[i]);
905 ice_virt_get_irqs(pf, tmp_vf->num_msix);
931 struct ice_pf *pf = pci_get_drvdata(pdev);
938 if (!ice_get_num_vfs(pf))
948 if (queues > min(ice_get_avail_txq_count(pf),
949 ice_get_avail_rxq_count(pf)))
964 vf = ice_get_vf_by_id(pf, id);
979 ice_virt_free_irqs(pf, vf->first_vector_idx, vf->num_msix);
982 ice_sriov_remap_vectors(pf, vf->vf_id);
986 vf->first_vector_idx = ice_virt_get_irqs(pf, vf->num_msix);
999 dev_info(ice_pf_to_dev(pf),
1009 dev_info(ice_pf_to_dev(pf),
1016 vf->first_vector_idx = ice_virt_get_irqs(pf, vf->num_msix);
1046 struct ice_pf *pf = pci_get_drvdata(pdev);
1047 struct device *dev = ice_pf_to_dev(pf);
1050 err = ice_check_sriov_allowed(pf);
1056 ice_free_vfs(pf);
1064 err = ice_pci_sriov_ena(pf, num_vfs);
1073 * @pf: pointer to the PF structure
1078 void ice_process_vflr_event(struct ice_pf *pf)
1080 struct ice_hw *hw = &pf->hw;
1085 if (!test_and_clear_bit(ICE_VFLR_EVENT_PENDING, pf->state) ||
1086 !ice_has_vfs(pf))
1089 mutex_lock(&pf->vfs.table_lock);
1090 ice_for_each_vf(pf, bkt, vf) {
1101 mutex_unlock(&pf->vfs.table_lock);
1106 * @pf: PF used to index all VFs
1116 static struct ice_vf *ice_get_vf_from_pfq(struct ice_pf *pf, u16 pfq)
1122 ice_for_each_vf_rcu(pf, bkt, vf) {
1149 * @pf: PF used for conversion
1152 static u32 ice_globalq_to_pfq(struct ice_pf *pf, u32 globalq)
1154 return globalq - pf->hw.func_caps.common_cap.rxq_first_id;
1159 * @pf: PF that the LAN overflow event happened on
1167 ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event)
1173 dev_dbg(ice_pf_to_dev(pf), "GLDCB_RTCTQ: 0x%08x\n", gldcb_rtctq);
1178 vf = ice_get_vf_from_pfq(pf, ice_globalq_to_pfq(pf, queue));
1197 struct ice_pf *pf = np->vsi->back;
1203 dev = ice_pf_to_dev(pf);
1205 vf = ice_get_vf_by_id(pf, vf_id);
1257 struct ice_pf *pf = ice_netdev_to_pf(netdev);
1261 vf = ice_get_vf_by_id(pf, vf_id);
1296 * @pf: PF to be configure
1303 int __ice_set_vf_mac(struct ice_pf *pf, u16 vf_id, const u8 *mac)
1309 dev = ice_pf_to_dev(pf);
1315 vf = ice_get_vf_by_id(pf, vf_id);
1381 struct ice_pf *pf = ice_netdev_to_pf(netdev);
1385 vf = ice_get_vf_by_id(pf, vf_id);
1389 if (ice_is_eswitch_mode_switchdev(pf)) {
1390 dev_info(ice_pf_to_dev(pf), "Trusted VF is forbidden in switchdev mode\n");
1411 dev_info(ice_pf_to_dev(pf), "VF %u is now %strusted\n",
1431 struct ice_pf *pf = ice_netdev_to_pf(netdev);
1435 vf = ice_get_vf_by_id(pf, vf_id);
1469 * @pf: PF associated with VFs
1471 static int ice_calc_all_vfs_min_tx_rate(struct ice_pf *pf)
1478 ice_for_each_vf_rcu(pf, bkt, vf)
1508 all_vfs_min_tx_rate = ice_calc_all_vfs_min_tx_rate(vf->pf);
1514 dev_err(ice_pf_to_dev(vf->pf), "min_tx_rate of %d Mbps on VF %u would cause oversubscription of %d Mbps based on the current link speed %d Mbps\n",
1535 struct ice_pf *pf = ice_netdev_to_pf(netdev);
1541 dev = ice_pf_to_dev(pf);
1543 vf = ice_get_vf_by_id(pf, vf_id);
1557 if (min_tx_rate && ice_is_dcb_active(pf)) {
1604 struct ice_pf *pf = ice_netdev_to_pf(netdev);
1610 vf = ice_get_vf_by_id(pf, vf_id);
1686 struct ice_pf *pf = ice_netdev_to_pf(netdev);
1692 dev = ice_pf_to_dev(pf);
1700 if (!ice_is_supported_port_vlan_proto(&pf->hw, local_vlan_proto)) {
1706 vf = ice_get_vf_by_id(pf, vf_id);
1747 struct ice_pf *pf = vf->pf;
1750 dev = ice_pf_to_dev(pf);
1753 vf->mdd_rx_events.count, pf->hw.pf_id, vf->vf_id,
1755 test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf->flags)
1765 struct ice_pf *pf = vf->pf;
1768 dev = ice_pf_to_dev(pf);
1771 vf->mdd_tx_events.count, pf->hw.pf_id, vf->vf_id,
1773 test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf->flags)
1779 * @pf: pointer to the PF structure
1783 void ice_print_vfs_mdd_events(struct ice_pf *pf)
1789 if (!test_and_clear_bit(ICE_MDD_VF_PRINT_PENDING, pf->state))
1793 if (time_is_after_jiffies(pf->vfs.last_printed_mdd_jiffies + HZ * 1))
1796 pf->vfs.last_printed_mdd_jiffies = jiffies;
1798 mutex_lock(&pf->vfs.table_lock);
1799 ice_for_each_vf(pf, bkt, vf) {
1814 mutex_unlock(&pf->vfs.table_lock);
1819 * @pf: pointer to the PF structure
1824 void ice_restore_all_vfs_msi_state(struct ice_pf *pf)
1829 ice_for_each_vf(pf, bkt, vf)