1/* virtpci.h
2 *
3 * Copyright (C) 2010 - 2013 UNISYS CORPORATION
4 * All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
14 * NON INFRINGEMENT.  See the GNU General Public License for more
15 * details.
16 */
17
18/*
19 * Unisys Virtual PCI driver header
20 */
21
22#ifndef __VIRTPCI_H__
23#define __VIRTPCI_H__
24
25#include "uisqueue.h"
26#include <linux/version.h>
27#include <linux/uuid.h>
28
29#define PCI_DEVICE_ID_VIRTHBA 0xAA00
30#define PCI_DEVICE_ID_VIRTNIC 0xAB00
31
32struct scsi_adap_info {
33	void *scsihost;		/* scsi host if this device is a scsi hba */
34	struct vhba_wwnn wwnn;	/* the world wide node name of vhba */
35	struct vhba_config_max max;	/* various max specifications used
36					 * to config vhba */
37};
38
39struct net_adap_info {
40	struct net_device *netdev;	/* network device if this
41					 * device is a NIC */
42	u8 mac_addr[MAX_MACADDR_LEN];
43	int num_rcv_bufs;
44	unsigned mtu;
45	uuid_le zone_uuid;
46};
47
48enum virtpci_dev_type {
49	VIRTHBA_TYPE = 0,
50	VIRTNIC_TYPE = 1,
51	VIRTBUS_TYPE = 6,
52};
53
54struct virtpci_dev {
55	enum virtpci_dev_type devtype;	/* indicates type of the
56					 * virtual pci device */
57	struct virtpci_driver *mydriver;	/* which driver has allocated
58						 * this device */
59	unsigned short vendor;	/* vendor id for device */
60	unsigned short device;	/* device id for device */
61	u32 bus_no;		/* number of bus on which device exists */
62	u32 device_no;		/* device's number on the bus */
63	struct irq_info intr;	/* interrupt info */
64	struct device generic_dev;	/* generic device */
65	union {
66		struct scsi_adap_info scsi;
67		struct net_adap_info net;
68	};
69
70	struct uisqueue_info queueinfo;	/* holds ptr to channel where cmds &
71					 * rsps are queued & retrieved */
72	struct virtpci_dev *next;	/* points to next virtpci device */
73};
74
75struct virtpci_driver {
76	struct list_head node;
77	const char *name;	/* the name of the driver in sysfs */
78	const char *version;
79	const char *vertag;
80	const struct pci_device_id *id_table;	/* must be non-NULL for probe
81						 * to be called */
82	int (*probe)(struct virtpci_dev *dev,
83		     const struct pci_device_id *id); /* device inserted */
84	void (*remove)(struct virtpci_dev *dev); /* Device removed (NULL if
85						    * not a hot-plug capable
86						    * driver) */
87	int (*suspend)(struct virtpci_dev *dev,
88		       u32 state);		   /* Device suspended */
89	int (*resume)(struct virtpci_dev *dev);	/* Device woken up */
90	int (*enable_wake)(struct virtpci_dev *dev,
91			   u32 state, int enable);	/* Enable wake event */
92	struct device_driver core_driver;	/* VIRTPCI core fills this in */
93};
94
95#define	driver_to_virtpci_driver(in_drv) \
96	container_of(in_drv, struct virtpci_driver, core_driver)
97#define device_to_virtpci_dev(in_dev) \
98	container_of(in_dev, struct virtpci_dev, generic_dev)
99
100int virtpci_register_driver(struct virtpci_driver *);
101void virtpci_unregister_driver(struct virtpci_driver *);
102
103#endif /* __VIRTPCI_H__ */
104