-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vfio/pds: register with the pds_core PF
The pds_core driver will supply adminq services, so find the PF and register with the DSC services. Use the following commands to enable a VF: echo 1 > /sys/bus/pci/drivers/pds_core/$PF_BDF/sriov_numvfs Signed-off-by: Brett Creeley <brett.creeley@amd.com> Signed-off-by: Shannon Nelson <shannon.nelson@amd.com> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/20230807205755.29579-5-brett.creeley@amd.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
- Loading branch information
Brett Creeley
authored and
Alex Williamson
committed
Aug 16, 2023
1 parent
b021d05
commit 63f77a7
Showing
8 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
obj-$(CONFIG_PDS_VFIO_PCI) += pds-vfio-pci.o | ||
|
||
pds-vfio-pci-y := \ | ||
cmds.o \ | ||
pci_drv.o \ | ||
vfio_dev.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright(c) 2023 Advanced Micro Devices, Inc. */ | ||
|
||
#include <linux/io.h> | ||
#include <linux/types.h> | ||
|
||
#include <linux/pds/pds_common.h> | ||
#include <linux/pds/pds_core_if.h> | ||
#include <linux/pds/pds_adminq.h> | ||
|
||
#include "vfio_dev.h" | ||
#include "cmds.h" | ||
|
||
int pds_vfio_register_client_cmd(struct pds_vfio_pci_device *pds_vfio) | ||
{ | ||
struct pci_dev *pdev = pds_vfio_to_pci_dev(pds_vfio); | ||
char devname[PDS_DEVNAME_LEN]; | ||
struct pdsc *pdsc; | ||
int ci; | ||
|
||
snprintf(devname, sizeof(devname), "%s.%d-%u", PDS_VFIO_LM_DEV_NAME, | ||
pci_domain_nr(pdev->bus), | ||
PCI_DEVID(pdev->bus->number, pdev->devfn)); | ||
|
||
pdsc = pdsc_get_pf_struct(pdev); | ||
if (IS_ERR(pdsc)) | ||
return PTR_ERR(pdsc); | ||
|
||
ci = pds_client_register(pdsc, devname); | ||
if (ci < 0) | ||
return ci; | ||
|
||
pds_vfio->client_id = ci; | ||
|
||
return 0; | ||
} | ||
|
||
void pds_vfio_unregister_client_cmd(struct pds_vfio_pci_device *pds_vfio) | ||
{ | ||
struct pci_dev *pdev = pds_vfio_to_pci_dev(pds_vfio); | ||
struct pdsc *pdsc; | ||
int err; | ||
|
||
pdsc = pdsc_get_pf_struct(pdev); | ||
if (IS_ERR(pdsc)) | ||
return; | ||
|
||
err = pds_client_unregister(pdsc, pds_vfio->client_id); | ||
if (err) | ||
dev_err(&pdev->dev, "unregister from DSC failed: %pe\n", | ||
ERR_PTR(err)); | ||
|
||
pds_vfio->client_id = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright(c) 2023 Advanced Micro Devices, Inc. */ | ||
|
||
#ifndef _CMDS_H_ | ||
#define _CMDS_H_ | ||
|
||
int pds_vfio_register_client_cmd(struct pds_vfio_pci_device *pds_vfio); | ||
void pds_vfio_unregister_client_cmd(struct pds_vfio_pci_device *pds_vfio); | ||
|
||
#endif /* _CMDS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright(c) 2023 Advanced Micro Devices, Inc. */ | ||
|
||
#ifndef _PCI_DRV_H | ||
#define _PCI_DRV_H | ||
|
||
#include <linux/pci.h> | ||
|
||
#endif /* _PCI_DRV_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters