1 /* Intel Ethernet Switch Host Interface Driver
2 * Copyright(c) 2013 - 2014 Intel Corporation.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * The full GNU General Public License is included in this distribution in
14 * the file called "COPYING".
16 * Contact Information:
17 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
18 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
21 #include <linux/module.h>
26 * fm10k_pci_tbl - PCI Device ID Table
28 * Wildcard entries (PCI_ANY_ID) should come last
29 * Last entry must be all 0s
31 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
32 * Class, Class Mask, private data (not used) }
34 static const struct pci_device_id fm10k_pci_tbl
[] = {
35 { PCI_VDEVICE(INTEL
, FM10K_DEV_ID_PF
) },
36 /* required last entry */
39 MODULE_DEVICE_TABLE(pci
, fm10k_pci_tbl
);
42 * fm10k_probe - Device Initialization Routine
43 * @pdev: PCI device information struct
44 * @ent: entry in fm10k_pci_tbl
46 * Returns 0 on success, negative on failure
48 * fm10k_probe initializes an interface identified by a pci_dev structure.
49 * The OS initialization, configuring of the interface private structure,
50 * and a hardware reset occur.
52 static int fm10k_probe(struct pci_dev
*pdev
,
53 const struct pci_device_id
*ent
)
58 err
= pci_enable_device_mem(pdev
);
62 /* By default fm10k only supports a 48 bit DMA mask */
63 dma_mask
= DMA_BIT_MASK(48) | dma_get_required_mask(&pdev
->dev
);
65 if ((dma_mask
<= DMA_BIT_MASK(32)) ||
66 dma_set_mask_and_coherent(&pdev
->dev
, dma_mask
)) {
67 dma_mask
&= DMA_BIT_MASK(32);
69 err
= dma_set_mask_and_coherent(&pdev
->dev
, DMA_BIT_MASK(32));
70 err
= dma_set_mask(&pdev
->dev
, DMA_BIT_MASK(32));
72 err
= dma_set_coherent_mask(&pdev
->dev
,
76 "No usable DMA configuration, aborting\n");
82 err
= pci_request_selected_regions(pdev
,
88 "pci_request_selected_regions failed 0x%x\n", err
);
99 pci_disable_device(pdev
);
104 * fm10k_remove - Device Removal Routine
105 * @pdev: PCI device information struct
107 * fm10k_remove is called by the PCI subsystem to alert the driver
108 * that it should release a PCI device. The could be caused by a
109 * Hot-Plug event, or because the driver is going to be removed from
112 static void fm10k_remove(struct pci_dev
*pdev
)
114 pci_release_selected_regions(pdev
,
115 pci_select_bars(pdev
, IORESOURCE_MEM
));
117 pci_disable_device(pdev
);
120 static struct pci_driver fm10k_driver
= {
121 .name
= fm10k_driver_name
,
122 .id_table
= fm10k_pci_tbl
,
123 .probe
= fm10k_probe
,
124 .remove
= fm10k_remove
,
128 * fm10k_register_pci_driver - register driver interface
130 * This funciton is called on module load in order to register the driver.
132 int fm10k_register_pci_driver(void)
134 return pci_register_driver(&fm10k_driver
);
138 * fm10k_unregister_pci_driver - unregister driver interface
140 * This funciton is called on module unload in order to remove the driver.
142 void fm10k_unregister_pci_driver(void)
144 pci_unregister_driver(&fm10k_driver
);