Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 // Copyright 2019 IBM Corp.
0003 #include <linux/module.h>
0004 #include "ocxl_internal.h"
0005 
0006 /*
0007  * Any opencapi device which wants to use this 'generic' driver should
0008  * use the 0x062B device ID. Vendors should define the subsystem
0009  * vendor/device ID to help differentiate devices.
0010  */
0011 static const struct pci_device_id ocxl_pci_tbl[] = {
0012     { PCI_DEVICE(PCI_VENDOR_ID_IBM, 0x062B), },
0013     { }
0014 };
0015 MODULE_DEVICE_TABLE(pci, ocxl_pci_tbl);
0016 
0017 static int ocxl_probe(struct pci_dev *dev, const struct pci_device_id *id)
0018 {
0019     int rc;
0020     struct ocxl_afu *afu, *tmp;
0021     struct ocxl_fn *fn;
0022     struct list_head *afu_list;
0023 
0024     fn = ocxl_function_open(dev);
0025     if (IS_ERR(fn))
0026         return PTR_ERR(fn);
0027 
0028     pci_set_drvdata(dev, fn);
0029 
0030     afu_list = ocxl_function_afu_list(fn);
0031 
0032     list_for_each_entry_safe(afu, tmp, afu_list, list) {
0033         // Cleanup handled within ocxl_file_register_afu()
0034         rc = ocxl_file_register_afu(afu);
0035         if (rc) {
0036             dev_err(&dev->dev, "Failed to register AFU '%s' index %d",
0037                     afu->config.name, afu->config.idx);
0038         }
0039     }
0040 
0041     return 0;
0042 }
0043 
0044 static void ocxl_remove(struct pci_dev *dev)
0045 {
0046     struct ocxl_fn *fn;
0047     struct ocxl_afu *afu;
0048     struct list_head *afu_list;
0049 
0050     fn = pci_get_drvdata(dev);
0051     afu_list = ocxl_function_afu_list(fn);
0052 
0053     list_for_each_entry(afu, afu_list, list) {
0054         ocxl_file_unregister_afu(afu);
0055     }
0056 
0057     ocxl_function_close(fn);
0058 }
0059 
0060 struct pci_driver ocxl_pci_driver = {
0061     .name = "ocxl",
0062     .id_table = ocxl_pci_tbl,
0063     .probe = ocxl_probe,
0064     .remove = ocxl_remove,
0065     .shutdown = ocxl_remove,
0066 };