Skip to content

Commit 101600e

Browse files
kishonLorenzo Pieralisi
authored andcommitted
PCI: endpoint: Add support to link a physical function to a virtual function
While the physical function has to be linked to endpoint controller, the virtual function has to be linked to a physical function. Add support to link a physical function to a virtual function in pci-ep-cfs. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kishon Vijay Abraham I <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]>
1 parent 1cf362e commit 101600e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/pci/endpoint/pci-ep-cfs.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,28 @@ static struct configfs_attribute *pci_epf_attrs[] = {
475475
NULL,
476476
};
477477

478+
static int pci_epf_vepf_link(struct config_item *epf_pf_item,
479+
struct config_item *epf_vf_item)
480+
{
481+
struct pci_epf_group *epf_vf_group = to_pci_epf_group(epf_vf_item);
482+
struct pci_epf_group *epf_pf_group = to_pci_epf_group(epf_pf_item);
483+
struct pci_epf *epf_pf = epf_pf_group->epf;
484+
struct pci_epf *epf_vf = epf_vf_group->epf;
485+
486+
return pci_epf_add_vepf(epf_pf, epf_vf);
487+
}
488+
489+
static void pci_epf_vepf_unlink(struct config_item *epf_pf_item,
490+
struct config_item *epf_vf_item)
491+
{
492+
struct pci_epf_group *epf_vf_group = to_pci_epf_group(epf_vf_item);
493+
struct pci_epf_group *epf_pf_group = to_pci_epf_group(epf_pf_item);
494+
struct pci_epf *epf_pf = epf_pf_group->epf;
495+
struct pci_epf *epf_vf = epf_vf_group->epf;
496+
497+
pci_epf_remove_vepf(epf_pf, epf_vf);
498+
}
499+
478500
static void pci_epf_release(struct config_item *item)
479501
{
480502
struct pci_epf_group *epf_group = to_pci_epf_group(item);
@@ -487,6 +509,8 @@ static void pci_epf_release(struct config_item *item)
487509
}
488510

489511
static struct configfs_item_operations pci_epf_ops = {
512+
.allow_link = pci_epf_vepf_link,
513+
.drop_link = pci_epf_vepf_unlink,
490514
.release = pci_epf_release,
491515
};
492516

0 commit comments

Comments
 (0)