aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/xen-pciback/vpci.c
diff options
context:
space:
mode:
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-07-11 16:49:41 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-07-19 21:04:20 -0400
commit2ebdc4263022e0015341016b123fe7f44f9cf396 (patch)
tree098f12c4ebfcb7a87b409255e50997e484ca1b59 /drivers/xen/xen-pciback/vpci.c
parent778999703db6d875c22e1a8d02c8296ad4648958 (diff)
xen/pciback: Have 'passthrough' option instead of XEN_PCIDEV_BACKEND_PASS and XEN_PCIDEV_BACKEND_VPCI
.. compile options. This way the user can decide during runtime whether they want the default 'vpci' (virtual pci passthrough) or where the PCI devices are passed in without any BDF renumbering. The option 'passthrough' allows the user to toggle the it from 0 (vpci) to 1 (passthrough). Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/xen-pciback/vpci.c')
-rw-r--r--drivers/xen/xen-pciback/vpci.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/drivers/xen/xen-pciback/vpci.c b/drivers/xen/xen-pciback/vpci.c
index 7d5c192a1505..4a42cfb0959d 100644
--- a/drivers/xen/xen-pciback/vpci.c
+++ b/drivers/xen/xen-pciback/vpci.c
@@ -25,9 +25,10 @@ static inline struct list_head *list_first(struct list_head *head)
25 return head->next; 25 return head->next;
26} 26}
27 27
28struct pci_dev *xen_pcibk_get_pci_dev(struct xen_pcibk_device *pdev, 28static struct pci_dev *__xen_pcibk_get_pci_dev(struct xen_pcibk_device *pdev,
29 unsigned int domain, unsigned int bus, 29 unsigned int domain,
30 unsigned int devfn) 30 unsigned int bus,
31 unsigned int devfn)
31{ 32{
32 struct pci_dev_entry *entry; 33 struct pci_dev_entry *entry;
33 struct pci_dev *dev = NULL; 34 struct pci_dev *dev = NULL;
@@ -63,8 +64,9 @@ static inline int match_slot(struct pci_dev *l, struct pci_dev *r)
63 return 0; 64 return 0;
64} 65}
65 66
66int xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev, struct pci_dev *dev, 67static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
67 int devid, publish_pci_dev_cb publish_cb) 68 struct pci_dev *dev, int devid,
69 publish_pci_dev_cb publish_cb)
68{ 70{
69 int err = 0, slot, func = -1; 71 int err = 0, slot, func = -1;
70 struct pci_dev_entry *t, *dev_entry; 72 struct pci_dev_entry *t, *dev_entry;
@@ -137,8 +139,8 @@ out:
137 return err; 139 return err;
138} 140}
139 141
140void xen_pcibk_release_pci_dev(struct xen_pcibk_device *pdev, 142static void __xen_pcibk_release_pci_dev(struct xen_pcibk_device *pdev,
141 struct pci_dev *dev) 143 struct pci_dev *dev)
142{ 144{
143 int slot; 145 int slot;
144 struct vpci_dev_data *vpci_dev = pdev->pci_dev_data; 146 struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
@@ -167,7 +169,7 @@ out:
167 pcistub_put_pci_dev(found_dev); 169 pcistub_put_pci_dev(found_dev);
168} 170}
169 171
170int xen_pcibk_init_devices(struct xen_pcibk_device *pdev) 172static int __xen_pcibk_init_devices(struct xen_pcibk_device *pdev)
171{ 173{
172 int slot; 174 int slot;
173 struct vpci_dev_data *vpci_dev; 175 struct vpci_dev_data *vpci_dev;
@@ -186,14 +188,14 @@ int xen_pcibk_init_devices(struct xen_pcibk_device *pdev)
186 return 0; 188 return 0;
187} 189}
188 190
189int xen_pcibk_publish_pci_roots(struct xen_pcibk_device *pdev, 191static int __xen_pcibk_publish_pci_roots(struct xen_pcibk_device *pdev,
190 publish_pci_root_cb publish_cb) 192 publish_pci_root_cb publish_cb)
191{ 193{
192 /* The Virtual PCI bus has only one root */ 194 /* The Virtual PCI bus has only one root */
193 return publish_cb(pdev, 0, 0); 195 return publish_cb(pdev, 0, 0);
194} 196}
195 197
196void xen_pcibk_release_devices(struct xen_pcibk_device *pdev) 198static void __xen_pcibk_release_devices(struct xen_pcibk_device *pdev)
197{ 199{
198 int slot; 200 int slot;
199 struct vpci_dev_data *vpci_dev = pdev->pci_dev_data; 201 struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
@@ -212,10 +214,10 @@ void xen_pcibk_release_devices(struct xen_pcibk_device *pdev)
212 pdev->pci_dev_data = NULL; 214 pdev->pci_dev_data = NULL;
213} 215}
214 216
215int xen_pcibk_get_pcifront_dev(struct pci_dev *pcidev, 217static int __xen_pcibk_get_pcifront_dev(struct pci_dev *pcidev,
216 struct xen_pcibk_device *pdev, 218 struct xen_pcibk_device *pdev,
217 unsigned int *domain, unsigned int *bus, 219 unsigned int *domain, unsigned int *bus,
218 unsigned int *devfn) 220 unsigned int *devfn)
219{ 221{
220 struct pci_dev_entry *entry; 222 struct pci_dev_entry *entry;
221 struct pci_dev *dev = NULL; 223 struct pci_dev *dev = NULL;
@@ -244,3 +246,14 @@ int xen_pcibk_get_pcifront_dev(struct pci_dev *pcidev,
244 spin_unlock_irqrestore(&vpci_dev->lock, flags); 246 spin_unlock_irqrestore(&vpci_dev->lock, flags);
245 return found; 247 return found;
246} 248}
249
250struct xen_pcibk_backend xen_pcibk_vpci_backend = {
251 .name = "vpci",
252 .init = __xen_pcibk_init_devices,
253 .free = __xen_pcibk_release_devices,
254 .find = __xen_pcibk_get_pcifront_dev,
255 .publish = __xen_pcibk_publish_pci_roots,
256 .release = __xen_pcibk_release_pci_dev,
257 .add = __xen_pcibk_add_pci_dev,
258 .get = __xen_pcibk_get_pci_dev,
259};