Commit | Line | Data |
---|---|---|
834e23dd SS |
1 | /**************************************************************************** |
2 | * Driver for Solarflare network controllers and boards | |
3 | * Copyright 2015 Solarflare Communications Inc. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License version 2 as published | |
7 | * by the Free Software Foundation, incorporated herein by reference. | |
8 | */ | |
9 | #include <linux/pci.h> | |
10 | #include <linux/module.h> | |
11 | #include "net_driver.h" | |
12 | #include "ef10_sriov.h" | |
13 | #include "efx.h" | |
14 | #include "nic.h" | |
15 | #include "mcdi_pcol.h" | |
16 | ||
17 | static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs) | |
18 | { | |
19 | int rc = 0; | |
20 | struct pci_dev *dev = efx->pci_dev; | |
21 | ||
22 | efx->vf_count = num_vfs; | |
23 | rc = pci_enable_sriov(dev, num_vfs); | |
24 | if (rc) { | |
25 | efx->vf_count = 0; | |
26 | netif_err(efx, probe, efx->net_dev, | |
27 | "Failed to enable SRIOV VFs\n"); | |
28 | } | |
29 | return rc; | |
30 | } | |
31 | ||
32 | static int efx_ef10_pci_sriov_disable(struct efx_nic *efx) | |
33 | { | |
34 | struct pci_dev *dev = efx->pci_dev; | |
35 | ||
36 | efx->vf_count = 0; | |
37 | pci_disable_sriov(dev); | |
38 | return 0; | |
39 | } | |
40 | ||
41 | int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs) | |
42 | { | |
43 | if (num_vfs == 0) | |
44 | return efx_ef10_pci_sriov_disable(efx); | |
45 | else | |
46 | return efx_ef10_pci_sriov_enable(efx, num_vfs); | |
47 | } |