Skip to content

Commit 05c1668

Browse files
Michal Swiatkowskidavem330
authored andcommitted
ice: set MSI-X vector count on VF
Implement ops needed to set MSI-X vector count on VF. sriov_get_vf_total_msix() should return total number of MSI-X that can be used by the VFs. Return the value set by devlink resources API (pf->req_msix.vf). sriov_set_msix_vec_count() will set number of MSI-X on particular VF. Disable VF register mapping, rebuild VSI with new MSI-X and queues values and enable new VF register mapping. For best performance set number of queues equal to number of MSI-X. Signed-off-by: Michal Swiatkowski <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ea4af9b commit 05c1668

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5635,6 +5635,8 @@ static struct pci_driver ice_driver = {
56355635
#endif /* CONFIG_PM */
56365636
.shutdown = ice_shutdown,
56375637
.sriov_configure = ice_sriov_configure,
5638+
.sriov_get_vf_total_msix = ice_sriov_get_vf_total_msix,
5639+
.sriov_set_msix_vec_count = ice_sriov_set_msix_vec_count,
56385640
.err_handler = &ice_pci_err_handler
56395641
};
56405642

drivers/net/ethernet/intel/ice/ice_sriov.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,75 @@ static int ice_check_sriov_allowed(struct ice_pf *pf)
987987
return 0;
988988
}
989989

990+
/**
991+
* ice_sriov_get_vf_total_msix - return number of MSI-X used by VFs
992+
* @pdev: pointer to pci_dev struct
993+
*
994+
* The function is called via sysfs ops
995+
*/
996+
u32 ice_sriov_get_vf_total_msix(struct pci_dev *pdev)
997+
{
998+
struct ice_pf *pf = pci_get_drvdata(pdev);
999+
1000+
return pf->sriov_irq_size - ice_get_max_used_msix_vector(pf);
1001+
}
1002+
1003+
/**
1004+
* ice_sriov_set_msix_vec_count
1005+
* @vf_dev: pointer to pci_dev struct of VF device
1006+
* @msix_vec_count: new value for MSI-X amount on this VF
1007+
*
1008+
* Set requested MSI-X, queues and registers for @vf_dev.
1009+
*
1010+
* First do some sanity checks like if there are any VFs, if the new value
1011+
* is correct etc. Then disable old mapping (MSI-X and queues registers), change
1012+
* MSI-X and queues, rebuild VSI and enable new mapping.
1013+
*
1014+
* If it is possible (driver not binded to VF) try to remap also other VFs to
1015+
* linearize irqs register usage.
1016+
*/
1017+
int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
1018+
{
1019+
struct pci_dev *pdev = pci_physfn(vf_dev);
1020+
struct ice_pf *pf = pci_get_drvdata(pdev);
1021+
struct ice_vf *vf;
1022+
u16 queues;
1023+
int id;
1024+
1025+
if (!ice_get_num_vfs(pf))
1026+
return -ENOENT;
1027+
1028+
if (!msix_vec_count)
1029+
return 0;
1030+
1031+
queues = msix_vec_count;
1032+
/* add 1 MSI-X for OICR */
1033+
msix_vec_count += 1;
1034+
1035+
/* Transition of PCI VF function number to function_id */
1036+
for (id = 0; id < pci_num_vf(pdev); id++) {
1037+
if (vf_dev->devfn == pci_iov_virtfn_devfn(pdev, id))
1038+
break;
1039+
}
1040+
1041+
if (id == pci_num_vf(pdev))
1042+
return -ENOENT;
1043+
1044+
vf = ice_get_vf_by_id(pf, id);
1045+
1046+
if (!vf)
1047+
return -ENOENT;
1048+
1049+
ice_dis_vf_mappings(vf);
1050+
vf->num_msix = msix_vec_count;
1051+
vf->num_vf_qs = queues;
1052+
ice_vsi_rebuild(ice_get_vf_vsi(vf), ICE_VSI_FLAG_NO_INIT);
1053+
ice_ena_vf_mappings(vf);
1054+
ice_put_vf(vf);
1055+
1056+
return 0;
1057+
}
1058+
9901059
/**
9911060
* ice_sriov_configure - Enable or change number of VFs via sysfs
9921061
* @pdev: pointer to a pci_dev structure

drivers/net/ethernet/intel/ice/ice_sriov.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ void ice_print_vfs_mdd_events(struct ice_pf *pf);
6060
void ice_print_vf_rx_mdd_event(struct ice_vf *vf);
6161
bool
6262
ice_vc_validate_pattern(struct ice_vf *vf, struct virtchnl_proto_hdrs *proto);
63+
u32 ice_sriov_get_vf_total_msix(struct pci_dev *pdev);
64+
int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count);
6365
#else /* CONFIG_PCI_IOV */
6466
static inline void ice_process_vflr_event(struct ice_pf *pf) { }
6567
static inline void ice_free_vfs(struct ice_pf *pf) { }
@@ -142,5 +144,16 @@ ice_get_vf_stats(struct net_device __always_unused *netdev,
142144
{
143145
return -EOPNOTSUPP;
144146
}
147+
148+
static inline u32 ice_sriov_get_vf_total_msix(struct pci_dev *pdev)
149+
{
150+
return 0;
151+
}
152+
153+
static inline int
154+
ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
155+
{
156+
return -EOPNOTSUPP;
157+
}
145158
#endif /* CONFIG_PCI_IOV */
146159
#endif /* _ICE_SRIOV_H_ */

0 commit comments

Comments
 (0)