Lines Matching full:pf

19  * @pf: pointer to the PF structure
24 static void ice_free_vf_entries(struct ice_pf *pf) in ice_free_vf_entries() argument
26 struct ice_vfs *vfs = &pf->vfs; in ice_free_vf_entries()
50 struct ice_pf *pf = vf->pf; in ice_free_vf_res() local
76 wr32(&pf->hw, GLINT_DYN_CTL(i), GLINT_DYN_CTL_CLEARPBA_M); in ice_free_vf_res()
77 ice_flush(&pf->hw); in ice_free_vf_res()
90 struct ice_pf *pf = vf->pf; in ice_dis_vf_mappings() local
96 hw = &pf->hw; in ice_dis_vf_mappings()
101 dev = ice_pf_to_dev(pf); in ice_dis_vf_mappings()
128 * @pf: pointer to the PF structure
130 * Since no MSIX entries are taken from the pf->irq_tracker then just clear
131 * the pf->sriov_base_vector.
135 static int ice_sriov_free_msix_res(struct ice_pf *pf) in ice_sriov_free_msix_res() argument
137 if (!pf) in ice_sriov_free_msix_res()
140 bitmap_free(pf->sriov_irq_bm); in ice_sriov_free_msix_res()
141 pf->sriov_irq_size = 0; in ice_sriov_free_msix_res()
142 pf->sriov_base_vector = 0; in ice_sriov_free_msix_res()
149 * @pf: pointer to the PF structure
151 void ice_free_vfs(struct ice_pf *pf) in ice_free_vfs() argument
153 struct device *dev = ice_pf_to_dev(pf); in ice_free_vfs()
154 struct ice_vfs *vfs = &pf->vfs; in ice_free_vfs()
155 struct ice_hw *hw = &pf->hw; in ice_free_vfs()
159 if (!ice_has_vfs(pf)) in ice_free_vfs()
162 while (test_and_set_bit(ICE_VF_DIS, pf->state)) in ice_free_vfs()
169 if (!pci_vfs_assigned(pf->pdev)) in ice_free_vfs()
170 pci_disable_sriov(pf->pdev); in ice_free_vfs()
176 ice_for_each_vf(pf, bkt, vf) { in ice_free_vfs()
179 ice_eswitch_detach_vf(pf, vf); in ice_free_vfs()
189 if (!pci_vfs_assigned(pf->pdev)) { in ice_free_vfs()
200 if (ice_sriov_free_msix_res(pf)) in ice_free_vfs()
204 ice_free_vf_entries(pf); in ice_free_vfs()
208 clear_bit(ICE_VF_DIS, pf->state); in ice_free_vfs()
209 clear_bit(ICE_FLAG_SRIOV_ENA, pf->flags); in ice_free_vfs()
222 struct ice_pf *pf = vf->pf; in ice_vf_vsi_setup() local
230 vsi = ice_vsi_setup(pf, &params); in ice_vf_vsi_setup()
233 dev_err(ice_pf_to_dev(pf), "Failed to create VF VSI\n"); in ice_vf_vsi_setup()
249 * device values and other registers need 0-based values, which represent PF
256 struct ice_pf *pf = vf->pf; in ice_ena_vf_msix_mappings() local
261 hw = &pf->hw; in ice_ena_vf_msix_mappings()
266 pf->hw.func_caps.common_cap.msix_vector_first_id; in ice_ena_vf_msix_mappings()
300 struct device *dev = ice_pf_to_dev(vf->pf); in ice_ena_vf_q_mappings()
302 struct ice_hw *hw = &vf->pf->hw; in ice_ena_vf_q_mappings()
313 /* set the VF PF Tx queue range in ice_ena_vf_q_mappings()
329 /* set the VF PF Rx queue range in ice_ena_vf_q_mappings()
357 * ice_calc_vf_reg_idx - Calculate the VF's register index in the PF space
373 * @pf: pointer to PF structure
376 * This function allows SR-IOV resources to be taken from the end of the PF's
378 * just set the pf->sriov_base_vector and return success.
384 * in the PF's space available for SR-IOV.
386 static int ice_sriov_set_msix_res(struct ice_pf *pf, u16 num_msix_needed) in ice_sriov_set_msix_res() argument
388 u16 total_vectors = pf->hw.func_caps.common_cap.num_msix_vectors; in ice_sriov_set_msix_res()
389 int vectors_used = ice_get_max_used_msix_vector(pf); in ice_sriov_set_msix_res()
400 pf->sriov_base_vector = sriov_base_vector; in ice_sriov_set_msix_res()
407 * @pf: pointer to the PF structure
424 * Lastly, set queue and MSI-X VF variables tracked by the PF so it can be used
427 static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs) in ice_set_per_vf_res() argument
429 int vectors_used = ice_get_max_used_msix_vector(pf); in ice_set_per_vf_res()
432 struct device *dev = ice_pf_to_dev(pf); in ice_set_per_vf_res()
435 lockdep_assert_held(&pf->vfs.table_lock); in ice_set_per_vf_res()
441 msix_avail_for_sriov = pf->hw.func_caps.common_cap.num_msix_vectors - in ice_set_per_vf_res()
461 avail_qs = ice_get_avail_txq_count(pf) / num_vfs; in ice_set_per_vf_res()
469 avail_qs = ice_get_avail_rxq_count(pf) / num_vfs; in ice_set_per_vf_res()
481 err = ice_sriov_set_msix_res(pf, num_msix_per_vf * num_vfs); in ice_set_per_vf_res()
489 pf->vfs.num_qps_per = min_t(int, num_txq, num_rxq); in ice_set_per_vf_res()
490 pf->vfs.num_msix_per = num_msix_per_vf; in ice_set_per_vf_res()
492 num_vfs, pf->vfs.num_msix_per, pf->vfs.num_qps_per); in ice_set_per_vf_res()
499 * @pf: pointer to PF structure
502 * This returns the first MSI-X vector index in PF space that is used by this
503 * VF. This index is used when accessing PF relative registers such as
515 static int ice_sriov_get_irqs(struct ice_pf *pf, u16 needed) in ice_sriov_get_irqs() argument
517 int res = bitmap_find_next_zero_area(pf->sriov_irq_bm, in ice_sriov_get_irqs()
518 pf->sriov_irq_size, 0, needed, 0); in ice_sriov_get_irqs()
520 int index = pf->sriov_irq_size - res - needed; in ice_sriov_get_irqs()
522 if (res >= pf->sriov_irq_size || index < pf->sriov_base_vector) in ice_sriov_get_irqs()
525 bitmap_set(pf->sriov_irq_bm, res, needed); in ice_sriov_get_irqs()
531 * @pf: pointer to PF structure
534 static void ice_sriov_free_irqs(struct ice_pf *pf, struct ice_vf *vf) in ice_sriov_free_irqs() argument
537 int bm_i = pf->sriov_irq_size - vf->first_vector_idx - vf->num_msix; in ice_sriov_free_irqs()
539 bitmap_clear(pf->sriov_irq_bm, bm_i, vf->num_msix); in ice_sriov_free_irqs()
552 struct ice_pf *pf = vf->pf; in ice_init_vf_vsi_res() local
556 vf->first_vector_idx = ice_sriov_get_irqs(pf, vf->num_msix); in ice_init_vf_vsi_res()
577 * @pf: PF the VFs are associated with
579 static int ice_start_vfs(struct ice_pf *pf) in ice_start_vfs() argument
581 struct ice_hw *hw = &pf->hw; in ice_start_vfs()
586 lockdep_assert_held(&pf->vfs.table_lock); in ice_start_vfs()
589 ice_for_each_vf(pf, bkt, vf) { in ice_start_vfs()
594 dev_err(ice_pf_to_dev(pf), "Failed to initialize VSI resources for VF %d, error %d\n", in ice_start_vfs()
599 retval = ice_eswitch_attach_vf(pf, vf); in ice_start_vfs()
601 dev_err(ice_pf_to_dev(pf), "Failed to attach VF %d to eswitch, error %d", in ice_start_vfs()
617 ice_for_each_vf(pf, bkt, vf) { in ice_start_vfs()
649 struct ice_hw *hw = &vf->pf->hw; in ice_sriov_clear_reset_state()
664 struct ice_pf *pf = vf->pf; in ice_sriov_clear_mbx_register() local
666 wr32(&pf->hw, VF_MBX_ARQLEN(vf->vf_id), 0); in ice_sriov_clear_mbx_register()
667 wr32(&pf->hw, VF_MBX_ATQLEN(vf->vf_id), 0); in ice_sriov_clear_mbx_register()
679 struct ice_pf *pf = vf->pf; in ice_sriov_trigger_reset_register() local
685 dev = ice_pf_to_dev(pf); in ice_sriov_trigger_reset_register()
686 hw = &pf->hw; in ice_sriov_trigger_reset_register()
726 struct ice_pf *pf = vf->pf; in ice_sriov_poll_reset_status() local
735 reg = rd32(&pf->hw, VPGEN_VFRSTAT(vf->vf_id)); in ice_sriov_poll_reset_status()
751 struct ice_hw *hw = &vf->pf->hw; in ice_sriov_clear_reset_trigger()
767 wr32(&vf->pf->hw, VFGEN_RSTAT(vf->vf_id), VIRTCHNL_VFR_VFACTIVE); in ice_sriov_post_vsi_rebuild()
784 * @pf: pointer to the PF structure
795 static int ice_create_vf_entries(struct ice_pf *pf, u16 num_vfs) in ice_create_vf_entries() argument
797 struct pci_dev *pdev = pf->pdev; in ice_create_vf_entries()
798 struct ice_vfs *vfs = &pf->vfs; in ice_create_vf_entries()
817 vf->pf = pf; in ice_create_vf_entries()
829 vf->vf_sw_id = pf->first_sw; in ice_create_vf_entries()
845 ice_free_vf_entries(pf); in ice_create_vf_entries()
851 * @pf: pointer to the PF structure
854 static int ice_ena_vfs(struct ice_pf *pf, u16 num_vfs) in ice_ena_vfs() argument
856 int total_vectors = pf->hw.func_caps.common_cap.num_msix_vectors; in ice_ena_vfs()
857 struct device *dev = ice_pf_to_dev(pf); in ice_ena_vfs()
858 struct ice_hw *hw = &pf->hw; in ice_ena_vfs()
861 pf->sriov_irq_bm = bitmap_zalloc(total_vectors, GFP_KERNEL); in ice_ena_vfs()
862 if (!pf->sriov_irq_bm) in ice_ena_vfs()
864 pf->sriov_irq_size = total_vectors; in ice_ena_vfs()
867 wr32(hw, GLINT_DYN_CTL(pf->oicr_irq.index), in ice_ena_vfs()
869 set_bit(ICE_OICR_INTR_DIS, pf->state); in ice_ena_vfs()
872 ret = pci_enable_sriov(pf->pdev, num_vfs); in ice_ena_vfs()
876 mutex_lock(&pf->vfs.table_lock); in ice_ena_vfs()
878 ret = ice_set_per_vf_res(pf, num_vfs); in ice_ena_vfs()
885 ret = ice_create_vf_entries(pf, num_vfs); in ice_ena_vfs()
892 ret = ice_start_vfs(pf); in ice_ena_vfs()
899 clear_bit(ICE_VF_DIS, pf->state); in ice_ena_vfs()
902 if (test_and_clear_bit(ICE_OICR_INTR_DIS, pf->state)) in ice_ena_vfs()
905 mutex_unlock(&pf->vfs.table_lock); in ice_ena_vfs()
910 ice_free_vf_entries(pf); in ice_ena_vfs()
912 mutex_unlock(&pf->vfs.table_lock); in ice_ena_vfs()
913 pci_disable_sriov(pf->pdev); in ice_ena_vfs()
917 clear_bit(ICE_OICR_INTR_DIS, pf->state); in ice_ena_vfs()
918 bitmap_free(pf->sriov_irq_bm); in ice_ena_vfs()
924 * @pf: pointer to the PF structure
929 static int ice_pci_sriov_ena(struct ice_pf *pf, int num_vfs) in ice_pci_sriov_ena() argument
931 struct device *dev = ice_pf_to_dev(pf); in ice_pci_sriov_ena()
935 ice_free_vfs(pf); in ice_pci_sriov_ena()
939 if (num_vfs > pf->vfs.num_supported) { in ice_pci_sriov_ena()
941 num_vfs, pf->vfs.num_supported); in ice_pci_sriov_ena()
946 err = ice_ena_vfs(pf, num_vfs); in ice_pci_sriov_ena()
952 set_bit(ICE_FLAG_SRIOV_ENA, pf->flags); in ice_pci_sriov_ena()
958 * @pf: PF to enabled SR-IOV on
960 static int ice_check_sriov_allowed(struct ice_pf *pf) in ice_check_sriov_allowed() argument
962 struct device *dev = ice_pf_to_dev(pf); in ice_check_sriov_allowed()
964 if (!test_bit(ICE_FLAG_SRIOV_CAPABLE, pf->flags)) { in ice_check_sriov_allowed()
969 if (ice_is_safe_mode(pf)) { in ice_check_sriov_allowed()
974 if (!ice_pf_state_is_nominal(pf)) { in ice_check_sriov_allowed()
990 struct ice_pf *pf = pci_get_drvdata(pdev); in ice_sriov_get_vf_total_msix() local
992 return pf->sriov_irq_size - ice_get_max_used_msix_vector(pf); in ice_sriov_get_vf_total_msix()
995 static int ice_sriov_move_base_vector(struct ice_pf *pf, int move) in ice_sriov_move_base_vector() argument
997 if (pf->sriov_base_vector - move < ice_get_max_used_msix_vector(pf)) in ice_sriov_move_base_vector()
1000 pf->sriov_base_vector -= move; in ice_sriov_move_base_vector()
1004 static void ice_sriov_remap_vectors(struct ice_pf *pf, u16 restricted_id) in ice_sriov_remap_vectors() argument
1013 ice_for_each_vf(pf, bkt, tmp_vf) { in ice_sriov_remap_vectors()
1020 ice_sriov_free_irqs(pf, tmp_vf); in ice_sriov_remap_vectors()
1027 tmp_vf = ice_get_vf_by_id(pf, vf_ids[i]); in ice_sriov_remap_vectors()
1032 ice_sriov_get_irqs(pf, tmp_vf->num_msix); in ice_sriov_remap_vectors()
1058 struct ice_pf *pf = pci_get_drvdata(pdev); in ice_sriov_set_msix_vec_count() local
1065 if (!ice_get_num_vfs(pf)) in ice_sriov_set_msix_vec_count()
1075 if (queues > min(ice_get_avail_txq_count(pf), in ice_sriov_set_msix_vec_count()
1076 ice_get_avail_rxq_count(pf))) in ice_sriov_set_msix_vec_count()
1091 vf = ice_get_vf_by_id(pf, id); in ice_sriov_set_msix_vec_count()
1105 if (ice_sriov_move_base_vector(pf, msix_vec_count - prev_msix)) { in ice_sriov_set_msix_vec_count()
1111 ice_sriov_free_irqs(pf, vf); in ice_sriov_set_msix_vec_count()
1114 ice_sriov_remap_vectors(pf, vf->vf_id); in ice_sriov_set_msix_vec_count()
1118 vf->first_vector_idx = ice_sriov_get_irqs(pf, vf->num_msix); in ice_sriov_set_msix_vec_count()
1131 dev_info(ice_pf_to_dev(pf), in ice_sriov_set_msix_vec_count()
1141 dev_info(ice_pf_to_dev(pf), in ice_sriov_set_msix_vec_count()
1147 vf->first_vector_idx = ice_sriov_get_irqs(pf, vf->num_msix); in ice_sriov_set_msix_vec_count()
1177 struct ice_pf *pf = pci_get_drvdata(pdev); in ice_sriov_configure() local
1178 struct device *dev = ice_pf_to_dev(pf); in ice_sriov_configure()
1181 err = ice_check_sriov_allowed(pf); in ice_sriov_configure()
1187 ice_free_vfs(pf); in ice_sriov_configure()
1195 err = ice_pci_sriov_ena(pf, num_vfs); in ice_sriov_configure()
1204 * @pf: pointer to the PF structure
1209 void ice_process_vflr_event(struct ice_pf *pf) in ice_process_vflr_event() argument
1211 struct ice_hw *hw = &pf->hw; in ice_process_vflr_event()
1216 if (!test_and_clear_bit(ICE_VFLR_EVENT_PENDING, pf->state) || in ice_process_vflr_event()
1217 !ice_has_vfs(pf)) in ice_process_vflr_event()
1220 mutex_lock(&pf->vfs.table_lock); in ice_process_vflr_event()
1221 ice_for_each_vf(pf, bkt, vf) { in ice_process_vflr_event()
1232 mutex_unlock(&pf->vfs.table_lock); in ice_process_vflr_event()
1236 * ice_get_vf_from_pfq - get the VF who owns the PF space queue passed in
1237 * @pf: PF used to index all VFs
1238 * @pfq: queue index relative to the PF's function space
1247 static struct ice_vf *ice_get_vf_from_pfq(struct ice_pf *pf, u16 pfq) in ice_get_vf_from_pfq() argument
1253 ice_for_each_vf_rcu(pf, bkt, vf) { in ice_get_vf_from_pfq()
1279 * ice_globalq_to_pfq - convert from global queue index to PF space queue index
1280 * @pf: PF used for conversion
1281 * @globalq: global queue index used to convert to PF space queue index
1283 static u32 ice_globalq_to_pfq(struct ice_pf *pf, u32 globalq) in ice_globalq_to_pfq() argument
1285 return globalq - pf->hw.func_caps.common_cap.rxq_first_id; in ice_globalq_to_pfq()
1290 * @pf: PF that the LAN overflow event happened on
1298 ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event) in ice_vf_lan_overflow_event() argument
1304 dev_dbg(ice_pf_to_dev(pf), "GLDCB_RTCTQ: 0x%08x\n", gldcb_rtctq); in ice_vf_lan_overflow_event()
1309 vf = ice_get_vf_from_pfq(pf, ice_globalq_to_pfq(pf, queue)); in ice_vf_lan_overflow_event()
1328 struct ice_pf *pf = np->vsi->back; in ice_set_vf_spoofchk() local
1334 dev = ice_pf_to_dev(pf); in ice_set_vf_spoofchk()
1336 vf = ice_get_vf_by_id(pf, vf_id); in ice_set_vf_spoofchk()
1388 struct ice_pf *pf = ice_netdev_to_pf(netdev); in ice_get_vf_cfg() local
1392 vf = ice_get_vf_by_id(pf, vf_id); in ice_get_vf_cfg()
1427 * @pf: PF to be configure
1434 int __ice_set_vf_mac(struct ice_pf *pf, u16 vf_id, const u8 *mac) in __ice_set_vf_mac() argument
1440 dev = ice_pf_to_dev(pf); in __ice_set_vf_mac()
1446 vf = ice_get_vf_by_id(pf, vf_id); in __ice_set_vf_mac()
1463 /* VF is notified of its new MAC via the PF's response to the in __ice_set_vf_mac()
1474 /* PF will add MAC rule for the VF */ in __ice_set_vf_mac()
1512 struct ice_pf *pf = ice_netdev_to_pf(netdev); in ice_set_vf_trust() local
1516 vf = ice_get_vf_by_id(pf, vf_id); in ice_set_vf_trust()
1520 if (ice_is_eswitch_mode_switchdev(pf)) { in ice_set_vf_trust()
1521 dev_info(ice_pf_to_dev(pf), "Trusted VF is forbidden in switchdev mode\n"); in ice_set_vf_trust()
1539 dev_info(ice_pf_to_dev(pf), "VF %u is now %strusted\n", in ice_set_vf_trust()
1559 struct ice_pf *pf = ice_netdev_to_pf(netdev); in ice_set_vf_link_state() local
1563 vf = ice_get_vf_by_id(pf, vf_id); in ice_set_vf_link_state()
1597 * @pf: PF associated with VFs
1599 static int ice_calc_all_vfs_min_tx_rate(struct ice_pf *pf) in ice_calc_all_vfs_min_tx_rate() argument
1606 ice_for_each_vf_rcu(pf, bkt, vf) in ice_calc_all_vfs_min_tx_rate()
1636 all_vfs_min_tx_rate = ice_calc_all_vfs_min_tx_rate(vf->pf); in ice_min_tx_rate_oversubscribed()
1642 …dev_err(ice_pf_to_dev(vf->pf), "min_tx_rate of %d Mbps on VF %u would cause oversubscription of %d… in ice_min_tx_rate_oversubscribed()
1663 struct ice_pf *pf = ice_netdev_to_pf(netdev); in ice_set_vf_bw() local
1669 dev = ice_pf_to_dev(pf); in ice_set_vf_bw()
1671 vf = ice_get_vf_by_id(pf, vf_id); in ice_set_vf_bw()
1685 if (min_tx_rate && ice_is_dcb_active(pf)) { in ice_set_vf_bw()
1686 dev_err(dev, "DCB on PF is currently enabled. VF min Tx rate limiting not allowed on this PF.\n"); in ice_set_vf_bw()
1725 * @netdev: the netdev of the PF
1732 struct ice_pf *pf = ice_netdev_to_pf(netdev); in ice_get_vf_stats() local
1738 vf = ice_get_vf_by_id(pf, vf_id); in ice_get_vf_stats()
1814 struct ice_pf *pf = ice_netdev_to_pf(netdev); in ice_set_vf_port_vlan() local
1820 dev = ice_pf_to_dev(pf); in ice_set_vf_port_vlan()
1828 if (!ice_is_supported_port_vlan_proto(&pf->hw, local_vlan_proto)) { in ice_set_vf_port_vlan()
1834 vf = ice_get_vf_by_id(pf, vf_id); in ice_set_vf_port_vlan()
1875 struct ice_pf *pf = vf->pf; in ice_print_vf_rx_mdd_event() local
1878 dev = ice_pf_to_dev(pf); in ice_print_vf_rx_mdd_event()
1880 …dev_info(dev, "%d Rx Malicious Driver Detection events detected on PF %d VF %d MAC %pM. mdd-auto-r… in ice_print_vf_rx_mdd_event()
1881 vf->mdd_rx_events.count, pf->hw.pf_id, vf->vf_id, in ice_print_vf_rx_mdd_event()
1883 test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf->flags) in ice_print_vf_rx_mdd_event()
1893 struct ice_pf *pf = vf->pf; in ice_print_vf_tx_mdd_event() local
1896 dev = ice_pf_to_dev(pf); in ice_print_vf_tx_mdd_event()
1898 …dev_info(dev, "%d Tx Malicious Driver Detection events detected on PF %d VF %d MAC %pM. mdd-auto-r… in ice_print_vf_tx_mdd_event()
1899 vf->mdd_tx_events.count, pf->hw.pf_id, vf->vf_id, in ice_print_vf_tx_mdd_event()
1901 test_bit(ICE_FLAG_MDD_AUTO_RESET_VF, pf->flags) in ice_print_vf_tx_mdd_event()
1907 * @pf: pointer to the PF structure
1911 void ice_print_vfs_mdd_events(struct ice_pf *pf) in ice_print_vfs_mdd_events() argument
1917 if (!test_and_clear_bit(ICE_MDD_VF_PRINT_PENDING, pf->state)) in ice_print_vfs_mdd_events()
1921 if (time_is_after_jiffies(pf->vfs.last_printed_mdd_jiffies + HZ * 1)) in ice_print_vfs_mdd_events()
1924 pf->vfs.last_printed_mdd_jiffies = jiffies; in ice_print_vfs_mdd_events()
1926 mutex_lock(&pf->vfs.table_lock); in ice_print_vfs_mdd_events()
1927 ice_for_each_vf(pf, bkt, vf) { in ice_print_vfs_mdd_events()
1942 mutex_unlock(&pf->vfs.table_lock); in ice_print_vfs_mdd_events()
1946 * ice_restore_all_vfs_msi_state - restore VF MSI state after PF FLR
1947 * @pf: pointer to the PF structure
1949 * Called when recovering from a PF FLR to restore interrupt capability to
1952 void ice_restore_all_vfs_msi_state(struct ice_pf *pf) in ice_restore_all_vfs_msi_state() argument
1957 ice_for_each_vf(pf, bkt, vf) in ice_restore_all_vfs_msi_state()