view linux-2.6-xen-sparse/drivers/xen/pciback/pciback.h @ 10842:4c97599398fe

[PCI] Allow per-device configuration for fine-grained control over PCI
configuration space writes, with a goal that was also previously
described by Ryan:

"Permissive mode should only be used as a fall back for unknown
I think the correct solution for dealing with these device-specific
configuration space registers is to identify them and add the
device-specific fields to the overlay. This patch adds a special
configuration space handler for network cards based on the tg3 linux
network device driver. This handler should allow for reads/writes to
all of the configuration space registers that the tg3 driver requires."

This patch attempts to address concerns with Ryan's original
submission by moving policy from the dom0 kernel into dom0 user-space.
As new quirky devices emerge they can be incorporated into the user-space
policy. An added benefit is that changes to the policy are effective
for domains created after the changes are written (no need rebuild the
hypervisor or restart xend).

Signed-off-by: Chris Bookholt <hap10@tycho.ncsc.mil>
author kfraser@localhost.localdomain
date Fri Jul 28 12:54:58 2006 +0100 (2006-07-28)
parents e42ed4332053
children 4f6d858ea570
line source
1 /*
2 * PCI Backend Common Data Structures & Function Declarations
3 *
4 * Author: Ryan Wilson <hap9@epoch.ncsc.mil>
5 */
6 #ifndef __XEN_PCIBACK_H__
7 #define __XEN_PCIBACK_H__
9 #include <linux/pci.h>
10 #include <linux/interrupt.h>
11 #include <xen/xenbus.h>
12 #include <linux/list.h>
13 #include <linux/spinlock.h>
14 #include <linux/workqueue.h>
15 #include <asm/atomic.h>
16 #include <xen/interface/io/pciif.h>
18 struct pci_dev_entry {
19 struct list_head list;
20 struct pci_dev *dev;
21 };
23 #define _PDEVF_op_active (0)
24 #define PDEVF_op_active (1<<(_PDEVF_op_active))
26 struct pciback_device {
27 void *pci_dev_data;
28 spinlock_t dev_lock;
30 struct xenbus_device *xdev;
32 struct xenbus_watch be_watch;
33 u8 be_watching;
35 int evtchn_irq;
37 struct vm_struct *sh_area;
38 struct xen_pci_sharedinfo *sh_info;
40 unsigned long flags;
42 struct work_struct op_work;
43 };
45 struct pciback_dev_data {
46 struct list_head config_fields;
47 int warned_on_write;
48 };
50 /* Get/Put PCI Devices that are hidden from the PCI Backend Domain */
51 struct pci_dev *pcistub_get_pci_dev_by_slot(struct pciback_device *pdev,
52 int domain, int bus,
53 int slot, int func);
54 struct pci_dev *pcistub_get_pci_dev(struct pciback_device *pdev,
55 struct pci_dev *dev);
56 void pcistub_put_pci_dev(struct pci_dev *dev);
58 /* Ensure a device is turned off or reset */
59 void pciback_reset_device(struct pci_dev *pdev);
61 /* Access a virtual configuration space for a PCI device */
62 int pciback_config_init(void);
63 int pciback_config_init_dev(struct pci_dev *dev);
64 void pciback_config_free_dyn_fields(struct pci_dev *dev);
65 void pciback_config_reset_dev(struct pci_dev *dev);
66 void pciback_config_free_dev(struct pci_dev *dev);
67 int pciback_config_read(struct pci_dev *dev, int offset, int size,
68 u32 * ret_val);
69 int pciback_config_write(struct pci_dev *dev, int offset, int size, u32 value);
71 /* Handle requests for specific devices from the frontend */
72 typedef int (*publish_pci_root_cb) (struct pciback_device * pdev,
73 unsigned int domain, unsigned int bus);
74 int pciback_add_pci_dev(struct pciback_device *pdev, struct pci_dev *dev);
75 void pciback_release_pci_dev(struct pciback_device *pdev, struct pci_dev *dev);
76 struct pci_dev *pciback_get_pci_dev(struct pciback_device *pdev,
77 unsigned int domain, unsigned int bus,
78 unsigned int devfn);
79 int pciback_init_devices(struct pciback_device *pdev);
80 int pciback_publish_pci_roots(struct pciback_device *pdev,
81 publish_pci_root_cb cb);
82 void pciback_release_devices(struct pciback_device *pdev);
84 /* Handles events from front-end */
85 irqreturn_t pciback_handle_event(int irq, void *dev_id, struct pt_regs *regs);
86 void pciback_do_op(void *data);
88 int pciback_xenbus_register(void);
89 void pciback_xenbus_unregister(void);
91 extern int verbose_request;
92 #endif