1 /**********************************************************************
4 * Contact: support@cavium.com
5 * Please include "LiquidIO" in the subject.
7 * Copyright (c) 2003-2016 Cavium, Inc.
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
13 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more details.
17 ***********************************************************************/
18 #include <linux/pci.h>
19 #include <net/vxlan.h>
20 #include "liquidio_common.h"
21 #include "octeon_droq.h"
22 #include "octeon_iq.h"
23 #include "response_manager.h"
24 #include "octeon_device.h"
26 MODULE_AUTHOR("Cavium Networks, <support@cavium.com>");
27 MODULE_DESCRIPTION("Cavium LiquidIO Intelligent Server Adapter Virtual Function Driver");
28 MODULE_LICENSE("GPL");
29 MODULE_VERSION(LIQUIDIO_VERSION);
31 struct octeon_device_priv {
32 /* Tasklet structures for this device. */
33 struct tasklet_struct droq_tasklet;
34 unsigned long napi_mask;
38 liquidio_vf_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
39 static void liquidio_vf_remove(struct pci_dev *pdev);
41 static const struct pci_device_id liquidio_vf_pci_tbl[] = {
43 PCI_VENDOR_ID_CAVIUM, OCTEON_CN23XX_VF_VID,
44 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0
50 MODULE_DEVICE_TABLE(pci, liquidio_vf_pci_tbl);
52 static struct pci_driver liquidio_vf_pci_driver = {
53 .name = "LiquidIO_VF",
54 .id_table = liquidio_vf_pci_tbl,
55 .probe = liquidio_vf_probe,
56 .remove = liquidio_vf_remove,
60 * \brief PCI probe handler
61 * @param pdev PCI device structure
65 liquidio_vf_probe(struct pci_dev *pdev,
66 const struct pci_device_id *ent __attribute__((unused)))
68 struct octeon_device *oct_dev = NULL;
70 oct_dev = octeon_allocate_device(pdev->device,
71 sizeof(struct octeon_device_priv));
74 dev_err(&pdev->dev, "Unable to allocate device\n");
78 dev_info(&pdev->dev, "Initializing device %x:%x.\n",
79 (u32)pdev->vendor, (u32)pdev->device);
81 /* Assign octeon_device for this device to the private data area. */
82 pci_set_drvdata(pdev, oct_dev);
84 /* set linux specific device pointer */
85 oct_dev->pci_dev = pdev;
91 * \brief Cleans up resources at unload time
92 * @param pdev PCI device structure
94 static void liquidio_vf_remove(struct pci_dev *pdev)
96 struct octeon_device *oct_dev = pci_get_drvdata(pdev);
98 dev_dbg(&oct_dev->pci_dev->dev, "Stopping device\n");
100 /* This octeon device has been removed. Update the global
101 * data structure to reflect this. Free the device structure.
103 octeon_free_device_mem(oct_dev);
106 static int __init liquidio_vf_init(void)
108 octeon_init_device_list(0);
109 return pci_register_driver(&liquidio_vf_pci_driver);
112 static void __exit liquidio_vf_exit(void)
114 pci_unregister_driver(&liquidio_vf_pci_driver);
116 pr_info("LiquidIO_VF network module is now unloaded\n");
119 module_init(liquidio_vf_init);
120 module_exit(liquidio_vf_exit);