diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2011-03-01 15:45:20 +1100 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2011-03-01 15:45:20 +1100 |
commit | 85f2e058be04463349f1cf85d7c0d9f6d7492826 (patch) | |
tree | 1008bd85e2259a18c07c5fc1421a54223d12c2fd /include | |
parent | 4028d93b54ecdc17993d52ec284fe369d8d5f288 (diff) | |
parent | 17d1061f5d87eff7d50942399414845d1f7a8a08 (diff) |
Merge remote-tracking branch 'alacrity/linux-next'
Conflicts:
drivers/Makefile
include/linux/Kbuild
lib/Kconfig
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/Kbuild | 4 | ||||
-rw-r--r-- | include/linux/ioq.h | 414 | ||||
-rw-r--r-- | include/linux/shm_signal.h | 189 | ||||
-rw-r--r-- | include/linux/vbus_driver.h | 83 | ||||
-rw-r--r-- | include/linux/vbus_pci.h | 145 | ||||
-rw-r--r-- | include/linux/venet.h | 133 |
6 files changed, 968 insertions, 0 deletions
diff --git a/include/linux/Kbuild b/include/linux/Kbuild index b0ada6f37dd6..525a565c2f7e 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild @@ -196,6 +196,7 @@ header-y += inet_diag.h header-y += inotify.h header-y += input.h header-y += ioctl.h +header-y += ioq.h header-y += ip.h header-y += ip6_tunnel.h header-y += ip_vs.h @@ -330,6 +331,7 @@ header-y += serial_core.h header-y += serial_reg.h header-y += serio.h header-y += shm.h +header-y += shm_signal.h header-y += signal.h header-y += signalfd.h header-y += snmp.h @@ -370,6 +372,8 @@ header-y += unistd.h header-y += usbdevice_fs.h header-y += utime.h header-y += utsname.h +header-y += vbus_pci.h +header-y += venet.h header-y += veth.h header-y += vhost.h header-y += videodev2.h diff --git a/include/linux/ioq.h b/include/linux/ioq.h new file mode 100644 index 000000000000..7c6d6cad83c7 --- /dev/null +++ b/include/linux/ioq.h @@ -0,0 +1,414 @@ +/* + * Copyright 2009 Novell. All Rights Reserved. + * + * IOQ is a generic shared-memory, lockless queue mechanism. It can be used + * in a variety of ways, though its intended purpose is to become the + * asynchronous communication path for virtual-bus drivers. + * + * The following are a list of key design points: + * + * #) All shared-memory is always allocated on explicitly one side of the + * link. This typically would be the guest side in a VM/VMM scenario. + * #) Each IOQ has the concept of "north" and "south" locales, where + * north denotes the memory-owner side (e.g. guest). + * #) An IOQ is manipulated using an iterator idiom. + * #) Provides a bi-directional signaling/notification infrastructure on + * a per-queue basis, which includes an event mitigation strategy + * to reduce boundary switching. + * #) The signaling path is abstracted so that various technologies and + * topologies can define their own specific implementation while sharing + * the basic structures and code. + * + * Author: + * Gregory Haskins <ghaskins@novell.com> + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _LINUX_IOQ_H +#define _LINUX_IOQ_H + +#include <linux/types.h> +#include <linux/shm_signal.h> + +/* + *--------- + * The following structures represent data that is shared across boundaries + * which may be quite disparate from one another (e.g. Windows vs Linux, + * 32 vs 64 bit, etc). Therefore, care has been taken to make sure they + * present data in a manner that is independent of the environment. + *----------- + */ +struct ioq_ring_desc { + __u64 cookie; /* for arbitrary use by north-side */ + __le64 ptr; + __le64 len; + __u8 valid; + __u8 sown; /* South owned = 1, North owned = 0 */ +}; + +#define IOQ_RING_MAGIC cpu_to_le32(0x47fa2fe4) +#define IOQ_RING_VER cpu_to_le32(4) + +struct ioq_ring_idx { + __le32 head; /* 0 based index to head of ptr array */ + __le32 tail; /* 0 based index to tail of ptr array */ + __u8 full; +}; + +enum ioq_locality { + ioq_locality_north, + ioq_locality_south, +}; + +struct ioq_ring_head { + __le32 magic; + __le32 ver; + struct shm_signal_desc signal; + struct ioq_ring_idx idx[2]; + __le32 count; + struct ioq_ring_desc ring[1]; /* "count" elements will be allocated */ +}; + +#define IOQ_HEAD_DESC_SIZE(count) \ + (sizeof(struct ioq_ring_head) + sizeof(struct ioq_ring_desc) * (count - 1)) + +/* --- END SHARED STRUCTURES --- */ + +#ifdef __KERNEL__ + +#include <linux/sched.h> +#include <linux/wait.h> +#include <linux/interrupt.h> +#include <linux/kref.h> + +enum ioq_idx_type { + ioq_idxtype_valid, + ioq_idxtype_inuse, + ioq_idxtype_both, + ioq_idxtype_invalid, +}; + +enum ioq_seek_type { + ioq_seek_tail, + ioq_seek_next, + ioq_seek_head, + ioq_seek_set +}; + +struct ioq_iterator { + struct ioq *ioq; + struct ioq_ring_idx *idx; + u32 pos; + struct ioq_ring_desc *desc; + bool update; + bool dualidx; + bool flipowner; +}; + +struct ioq_notifier { + void (*signal)(struct ioq_notifier *); +}; + +struct ioq_ops { + void (*release)(struct ioq *ioq); +}; + +struct ioq { + struct ioq_ops *ops; + + struct kref kref; + enum ioq_locality locale; + struct ioq_ring_head *head_desc; + struct ioq_ring_desc *ring; + struct shm_signal *signal; + wait_queue_head_t wq; + struct ioq_notifier *notifier; + size_t count; + struct shm_signal_notifier shm_notifier; +}; + +#define IOQ_ITER_AUTOUPDATE (1 << 0) +#define IOQ_ITER_NOFLIPOWNER (1 << 1) + +/** + * ioq_init() - initialize an IOQ + * @ioq: IOQ context + * + * Initializes IOQ context before first use + * + **/ +void ioq_init(struct ioq *ioq, + struct ioq_ops *ops, + enum ioq_locality locale, + struct ioq_ring_head *head, + struct shm_signal *signal, + size_t count); + +/** + * ioq_get() - acquire an IOQ context reference + * @ioq: IOQ context + * + **/ +static inline struct ioq *ioq_get(struct ioq *ioq) +{ + kref_get(&ioq->kref); + + return ioq; +} + +static inline void _ioq_kref_release(struct kref *kref) +{ + struct ioq *ioq = container_of(kref, struct ioq, kref); + + shm_signal_put(ioq->signal); + ioq->ops->release(ioq); +} + +/** + * ioq_put() - release an IOQ context reference + * @ioq: IOQ context + * + **/ +static inline void ioq_put(struct ioq *ioq) +{ + kref_put(&ioq->kref, _ioq_kref_release); +} + +/** + * ioq_notify_enable() - enables local notifications on an IOQ + * @ioq: IOQ context + * @flags: Reserved for future use, must be 0 + * + * Enables/unmasks the registered ioq_notifier (if applicable) and waitq to + * receive wakeups whenever the remote side performs an ioq_signal() operation. + * A notification will be dispatched immediately if any pending signals have + * already been issued prior to invoking this call. + * + * This is synonymous with unmasking an interrupt. + * + * Returns: success = 0, <0 = ERRNO + * + **/ +static inline int ioq_notify_enable(struct ioq *ioq, int flags) +{ + return shm_signal_enable(ioq->signal, 0); +} + +/** + * ioq_notify_disable() - disable local notifications on an IOQ + * @ioq: IOQ context + * @flags: Reserved for future use, must be 0 + * + * Disables/masks the registered ioq_notifier (if applicable) and waitq + * from receiving any further notifications. Any subsequent calls to + * ioq_signal() by the remote side will update the ring as dirty, but + * will not traverse the locale boundary and will not invoke the notifier + * callback or wakeup the waitq. Signals delivered while masked will + * be deferred until ioq_notify_enable() is invoked + * + * This is synonymous with masking an interrupt + * + * Returns: success = 0, <0 = ERRNO + * + **/ +static inline int ioq_notify_disable(struct ioq *ioq, int flags) +{ + return shm_signal_disable(ioq->signal, 0); +} + +/** + * ioq_signal() - notify the remote side about ring changes + * @ioq: IOQ context + * @flags: Reserved for future use, must be 0 + * + * Marks the ring state as "dirty" and, if enabled, will traverse + * a locale boundary to invoke a remote notification. The remote + * side controls whether the notification should be delivered via + * the ioq_notify_enable/disable() interface. + * + * The specifics of how to traverse a locale boundary are abstracted + * by the ioq_ops->signal() interface and provided by a particular + * implementation. However, typically going north to south would be + * something like a syscall/hypercall, and going south to north would be + * something like a posix-signal/guest-interrupt. + * + * Returns: success = 0, <0 = ERRNO + * + **/ +static inline int ioq_signal(struct ioq *ioq, int flags) +{ + return shm_signal_inject(ioq->signal, 0); +} + +/** + * ioq_count() - counts the number of outstanding descriptors in an index + * @ioq: IOQ context + * @type: Specifies the index type + * (*) valid: the descriptor is valid. This is usually + * used to keep track of descriptors that may not + * be carrying a useful payload, but still need to + * be tracked carefully. + * (*) inuse: Descriptors that carry useful payload + * + * Returns: + * (*) >=0: # of descriptors outstanding in the index + * (*) <0 = ERRNO + * + **/ +int ioq_count(struct ioq *ioq, enum ioq_idx_type type); + +/** + * ioq_remain() - counts the number of remaining descriptors in an index + * @ioq: IOQ context + * @type: Specifies the index type + * (*) valid: the descriptor is valid. This is usually + * used to keep track of descriptors that may not + * be carrying a useful payload, but still need to + * be tracked carefully. + * (*) inuse: Descriptors that carry useful payload + * + * This is the converse of ioq_count(). This function returns the number + * of "free" descriptors left in a particular index + * + * Returns: + * (*) >=0: # of descriptors remaining in the index + * (*) <0 = ERRNO + * + **/ +int ioq_remain(struct ioq *ioq, enum ioq_idx_type type); + +/** + * ioq_size() - counts the maximum number of descriptors in an ring + * @ioq: IOQ context + * + * This function returns the maximum number of descriptors supported in + * a ring, regardless of their current state (free or inuse). + * + * Returns: + * (*) >=0: total # of descriptors in the ring + * (*) <0 = ERRNO + * + **/ +int ioq_size(struct ioq *ioq); + +/** + * ioq_full() - determines if a specific index is "full" + * @ioq: IOQ context + * @type: Specifies the index type + * (*) valid: the descriptor is valid. This is usually + * used to keep track of descriptors that may not + * be carrying a useful payload, but still need to + * be tracked carefully. + * (*) inuse: Descriptors that carry useful payload + * + * Returns: + * (*) 0: index is not full + * (*) 1: index is full + * (*) <0 = ERRNO + * + **/ +int ioq_full(struct ioq *ioq, enum ioq_idx_type type); + +/** + * ioq_empty() - determines if a specific index is "empty" + * @ioq: IOQ context + * @type: Specifies the index type + * (*) valid: the descriptor is valid. This is usually + * used to keep track of descriptors that may not + * be carrying a useful payload, but still need to + * be tracked carefully. + * (*) inuse: Descriptors that carry useful payload + * + * Returns: + * (*) 0: index is not empty + * (*) 1: index is empty + * (*) <0 = ERRNO + * + **/ +static inline int ioq_empty(struct ioq *ioq, enum ioq_idx_type type) +{ + return !ioq_count(ioq, type); +} + +/** + * ioq_iter_init() - initialize an iterator for IOQ descriptor traversal + * @ioq: IOQ context to iterate on + * @iter: Iterator context to init (usually from stack) + * @type: Specifies the index type to iterate against + * (*) valid: iterate against the "valid" index + * (*) inuse: iterate against the "inuse" index + * (*) both: iterate against both indexes simultaneously + * @flags: Bitfield with 0 or more bits set to alter behavior + * (*) autoupdate: automatically signal the remote side + * whenever the iterator pushes/pops to a new desc + * (*) noflipowner: do not flip the ownership bit during + * a push/pop operation + * + * Returns: success = 0, <0 = ERRNO + * + **/ +int ioq_iter_init(struct ioq *ioq, struct ioq_iterator *iter, + enum ioq_idx_type type, int flags); + +/** + * ioq_iter_seek() - seek to a specific location in the IOQ ring + * @iter: Iterator context (must be initialized with ioq_iter_init) + * @type: Specifies the type of seek operation + * (*) tail: seek to the absolute tail, offset is ignored + * (*) next: seek to the relative next, offset is ignored + * (*) head: seek to the absolute head, offset is ignored + * (*) set: seek to the absolute offset + * @offset: Offset for ioq_seek_set operations + * @flags: Reserved for future use, must be 0 + * + * Returns: success = 0, <0 = ERRNO + * + **/ +int ioq_iter_seek(struct ioq_iterator *iter, enum ioq_seek_type type, + long offset, int flags); + +/** + * ioq_iter_push() - push the tail pointer forward + * @iter: Iterator context (must be initialized with ioq_iter_init) + * @flags: Reserved for future use, must be 0 + * + * This function will simultaneously advance the tail ptr in the current + * index (valid/inuse, as specified in the ioq_iter_init) as well as + * perform a seek(next) operation. This effectively "pushes" a new pointer + * onto the tail of the index. + * + * Returns: success = 0, <0 = ERRNO + * + **/ +int ioq_iter_push(struct ioq_iterator *iter, int flags); + +/** + * ioq_iter_pop() - pop the head pointer from the ring + * @iter: Iterator context (must be initialized with ioq_iter_init) + * @flags: Reserved for future use, must be 0 + * + * This function will simultaneously advance the head ptr in the current + * index (valid/inuse, as specified in the ioq_iter_init) as well as + * perform a seek(next) operation. This effectively "pops" a pointer + * from the head of the index. + * + * Returns: success = 0, <0 = ERRNO + * + **/ +int ioq_iter_pop(struct ioq_iterator *iter, int flags); + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_IOQ_H */ diff --git a/include/linux/shm_signal.h b/include/linux/shm_signal.h new file mode 100644 index 000000000000..b2efd72669fb --- /dev/null +++ b/include/linux/shm_signal.h @@ -0,0 +1,189 @@ +/* + * Copyright 2009 Novell. All Rights Reserved. + * + * Author: + * Gregory Haskins <ghaskins@novell.com> + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _LINUX_SHM_SIGNAL_H +#define _LINUX_SHM_SIGNAL_H + +#include <linux/types.h> + +/* + *--------- + * The following structures represent data that is shared across boundaries + * which may be quite disparate from one another (e.g. Windows vs Linux, + * 32 vs 64 bit, etc). Therefore, care has been taken to make sure they + * present data in a manner that is independent of the environment. + *----------- + */ + +#define SHM_SIGNAL_MAGIC cpu_to_le32(0x58fa39df) +#define SHM_SIGNAL_VER cpu_to_le32(1) + +struct shm_signal_irq { + __u8 enabled; + __u8 pending; + __u8 dirty; +}; + +enum shm_signal_locality { + shm_locality_north, + shm_locality_south, +}; + +struct shm_signal_desc { + __le32 magic; + __le32 ver; + struct shm_signal_irq irq[2]; +}; + +/* --- END SHARED STRUCTURES --- */ + +#ifdef __KERNEL__ + +#include <linux/kref.h> +#include <linux/interrupt.h> + +struct shm_signal_notifier { + void (*signal)(struct shm_signal_notifier *); +}; + +struct shm_signal; + +struct shm_signal_ops { + int (*inject)(struct shm_signal *s); + void (*fault)(struct shm_signal *s, const char *fmt, ...); + void (*release)(struct shm_signal *s); +}; + +enum { + shm_signal_in_wakeup, +}; + +struct shm_signal { + struct kref kref; + spinlock_t lock; + enum shm_signal_locality locale; + unsigned long flags; + struct shm_signal_ops *ops; + struct shm_signal_desc *desc; + struct shm_signal_notifier *notifier; + struct tasklet_struct deferred_notify; +}; + +#define SHM_SIGNAL_FAULT(s, fmt, args...) \ + ((s)->ops->fault ? (s)->ops->fault((s), fmt, ## args) : panic(fmt, ## args)) + + /* + * These functions should only be used internally + */ +void _shm_signal_release(struct kref *kref); +void _shm_signal_wakeup(struct shm_signal *s); + +/** + * shm_signal_init() - initialize an SHM_SIGNAL + * @s: SHM_SIGNAL context + * + * Initializes SHM_SIGNAL context before first use + * + **/ +void shm_signal_init(struct shm_signal *s, enum shm_signal_locality locale, + struct shm_signal_ops *ops, struct shm_signal_desc *desc); + +/** + * shm_signal_get() - acquire an SHM_SIGNAL context reference + * @s: SHM_SIGNAL context + * + **/ +static inline struct shm_signal *shm_signal_get(struct shm_signal *s) +{ + kref_get(&s->kref); + + return s; +} + +/** + * shm_signal_put() - release an SHM_SIGNAL context reference + * @s: SHM_SIGNAL context + * + **/ +static inline void shm_signal_put(struct shm_signal *s) +{ + kref_put(&s->kref, _shm_signal_release); +} + +/** + * shm_signal_enable() - enables local notifications on an SHM_SIGNAL + * @s: SHM_SIGNAL context + * @flags: Reserved for future use, must be 0 + * + * Enables/unmasks the registered notifier (if applicable) to receive wakeups + * whenever the remote side performs an shm_signal() operation. A notification + * will be dispatched immediately if any pending signals have already been + * issued prior to invoking this call. + * + * This is synonymous with unmasking an interrupt. + * + * Returns: success = 0, <0 = ERRNO + * + **/ +int shm_signal_enable(struct shm_signal *s, int flags); + +/** + * shm_signal_disable() - disable local notifications on an SHM_SIGNAL + * @s: SHM_SIGNAL context + * @flags: Reserved for future use, must be 0 + * + * Disables/masks the registered shm_signal_notifier (if applicable) from + * receiving any further notifications. Any subsequent calls to shm_signal() + * by the remote side will update the shm as dirty, but will not traverse the + * locale boundary and will not invoke the notifier callback. Signals + * delivered while masked will be deferred until shm_signal_enable() is + * invoked. + * + * This is synonymous with masking an interrupt + * + * Returns: success = 0, <0 = ERRNO + * + **/ +int shm_signal_disable(struct shm_signal *s, int flags); + +/** + * shm_signal_inject() - notify the remote side about shm changes + * @s: SHM_SIGNAL context + * @flags: Reserved for future use, must be 0 + * + * Marks the shm state as "dirty" and, if enabled, will traverse + * a locale boundary to inject a remote notification. The remote + * side controls whether the notification should be delivered via + * the shm_signal_enable/disable() interface. + * + * The specifics of how to traverse a locale boundary are abstracted + * by the shm_signal_ops->signal() interface and provided by a particular + * implementation. However, typically going north to south would be + * something like a syscall/hypercall, and going south to north would be + * something like a posix-signal/guest-interrupt. + * + * Returns: success = 0, <0 = ERRNO + * + **/ +int shm_signal_inject(struct shm_signal *s, int flags); + +#endif /* __KERNEL__ */ + +#endif /* _LINUX_SHM_SIGNAL_H */ diff --git a/include/linux/vbus_driver.h b/include/linux/vbus_driver.h new file mode 100644 index 000000000000..8a7acb1a7a05 --- /dev/null +++ b/include/linux/vbus_driver.h @@ -0,0 +1,83 @@ +/* + * Copyright 2009 Novell. All Rights Reserved. + * + * Mediates access to a host VBUS from a guest kernel by providing a + * global view of all VBUS devices + * + * Author: + * Gregory Haskins <ghaskins@novell.com> + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _LINUX_VBUS_DRIVER_H +#define _LINUX_VBUS_DRIVER_H + +#include <linux/device.h> +#include <linux/shm_signal.h> +#include <linux/ioq.h> + +struct vbus_device_proxy; +struct vbus_driver; + +struct vbus_device_proxy_ops { + int (*open)(struct vbus_device_proxy *dev, int version, int flags); + int (*close)(struct vbus_device_proxy *dev, int flags); + int (*shm)(struct vbus_device_proxy *dev, const char *name, + int id, int prio, + void *ptr, size_t len, + struct shm_signal_desc *sigdesc, struct shm_signal **signal, + int flags); + int (*call)(struct vbus_device_proxy *dev, u32 func, + void *data, size_t len, int flags); + void (*release)(struct vbus_device_proxy *dev); +}; + +struct vbus_device_proxy { + char *type; + u64 id; + void *priv; /* Used by drivers */ + struct vbus_device_proxy_ops *ops; + struct device dev; +}; + +int vbus_device_proxy_register(struct vbus_device_proxy *dev); +void vbus_device_proxy_unregister(struct vbus_device_proxy *dev); + +struct vbus_device_proxy *vbus_device_proxy_find(u64 id); + +struct vbus_driver_ops { + int (*probe)(struct vbus_device_proxy *dev); + int (*remove)(struct vbus_device_proxy *dev); +}; + +struct vbus_driver { + char *type; + struct module *owner; + struct vbus_driver_ops *ops; + struct device_driver drv; +}; + +int vbus_driver_register(struct vbus_driver *drv); +void vbus_driver_unregister(struct vbus_driver *drv); + +/* + * driver-side IOQ helper - allocates device-shm and maps an IOQ on it + */ +int vbus_driver_ioq_alloc(struct vbus_device_proxy *dev, const char *name, + int id, int prio, size_t ringsize, struct ioq **ioq); + +#define VBUS_DRIVER_AUTOPROBE(name) MODULE_ALIAS("vbus-proxy:" name) + +#endif /* _LINUX_VBUS_DRIVER_H */ diff --git a/include/linux/vbus_pci.h b/include/linux/vbus_pci.h new file mode 100644 index 000000000000..fe337590e644 --- /dev/null +++ b/include/linux/vbus_pci.h @@ -0,0 +1,145 @@ +/* + * Copyright 2009 Novell. All Rights Reserved. + * + * PCI to Virtual-Bus Bridge + * + * Author: + * Gregory Haskins <ghaskins@novell.com> + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _LINUX_VBUS_PCI_H +#define _LINUX_VBUS_PCI_H + +#include <linux/ioctl.h> +#include <linux/types.h> + +#define VBUS_PCI_ABI_MAGIC 0xbf53eef5 +#define VBUS_PCI_ABI_VERSION 2 +#define VBUS_PCI_HC_VERSION 1 + +enum { + VBUS_PCI_BRIDGE_NEGOTIATE, + VBUS_PCI_BRIDGE_QREG, + VBUS_PCI_BRIDGE_SLOWCALL, + VBUS_PCI_BRIDGE_FASTCALL_ADD, + VBUS_PCI_BRIDGE_FASTCALL_DROP, + + VBUS_PCI_BRIDGE_MAX, /* must be last */ +}; + +enum { + VBUS_PCI_HC_DEVOPEN, + VBUS_PCI_HC_DEVCLOSE, + VBUS_PCI_HC_DEVCALL, + VBUS_PCI_HC_DEVSHM, + + VBUS_PCI_HC_MAX, /* must be last */ +}; + +struct vbus_pci_bridge_negotiate { + __u32 magic; + __u32 version; + __u64 capabilities; +}; + +struct vbus_pci_deviceopen { + __u32 devid; + __u32 version; /* device ABI version */ + __u64 handle; /* return value for devh */ +}; + +struct vbus_pci_devicecall { + __u64 devh; /* device-handle (returned from DEVICEOPEN */ + __u32 func; + __u32 len; + __u32 flags; + __u64 datap; +}; + +struct vbus_pci_deviceshm { + __u64 devh; /* device-handle (returned from DEVICEOPEN */ + __u32 id; + __u32 len; + __u32 flags; + struct { + __u32 offset; + __u32 prio; + __u64 cookie; /* token to pass back when signaling client */ + } signal; + __u64 datap; +}; + +struct vbus_pci_call_desc { + __u32 vector; + __u32 len; + __u64 datap; +}; + +struct vbus_pci_fastcall_desc { + struct vbus_pci_call_desc call; + __u32 result; +}; + +struct vbus_pci_regs { + struct vbus_pci_call_desc bridgecall; + __u8 pad[48]; +}; + +struct vbus_pci_signals { + __u32 eventq; + __u32 fastcall; + __u32 shmsignal; + __u8 pad[20]; +}; + +struct vbus_pci_eventqreg { + __u32 count; + __u64 ring; + __u64 data; +}; + +struct vbus_pci_busreg { + __u32 count; /* supporting multiple queues allows for prio, etc */ + struct vbus_pci_eventqreg eventq[1]; +}; + +enum vbus_pci_eventid { + VBUS_PCI_EVENT_DEVADD, + VBUS_PCI_EVENT_DEVDROP, + VBUS_PCI_EVENT_SHMSIGNAL, + VBUS_PCI_EVENT_SHMCLOSE, +}; + +#define VBUS_MAX_DEVTYPE_LEN 128 + +struct vbus_pci_add_event { + __u64 id; + char type[VBUS_MAX_DEVTYPE_LEN]; +}; + +struct vbus_pci_handle_event { + __u64 handle; +}; + +struct vbus_pci_event { + __u32 eventid; + union { + struct vbus_pci_add_event add; + struct vbus_pci_handle_event handle; + } data; +}; + +#endif /* _LINUX_VBUS_PCI_H */ diff --git a/include/linux/venet.h b/include/linux/venet.h new file mode 100644 index 000000000000..0578d797c973 --- /dev/null +++ b/include/linux/venet.h @@ -0,0 +1,133 @@ +/* + * Copyright 2009 Novell. All Rights Reserved. + * + * Virtual-Ethernet adapter + * + * Author: + * Gregory Haskins <ghaskins@novell.com> + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef _LINUX_VENET_H +#define _LINUX_VENET_H + +#include <linux/types.h> + +#define VENET_VERSION 1 + +#define VENET_TYPE "virtual-ethernet" + +#define VENET_QUEUE_RX 0 +#define VENET_QUEUE_TX 1 + +struct venet_capabilities { + __u32 gid; + __u32 bits; +}; + +#define VENET_CAP_GROUP_SG 0 +#define VENET_CAP_GROUP_EVENTQ 1 +#define VENET_CAP_GROUP_L4RO 2 /* layer-4 reassem offloading */ + +/* CAPABILITIES-GROUP SG */ +#define VENET_CAP_SG (1 << 0) +#define VENET_CAP_TSO4 (1 << 1) +#define VENET_CAP_TSO6 (1 << 2) +#define VENET_CAP_ECN (1 << 3) +#define VENET_CAP_UFO (1 << 4) +#define VENET_CAP_PMTD (1 << 5) /* pre-mapped tx desc */ + +/* CAPABILITIES-GROUP EVENTQ */ +#define VENET_CAP_EVQ_LINKSTATE (1 << 0) +#define VENET_CAP_EVQ_TXC (1 << 1) /* tx-complete */ + +struct venet_iov { + __u32 len; + __u64 ptr; +}; + +#define VENET_SG_FLAG_NEEDS_CSUM (1 << 0) +#define VENET_SG_FLAG_GSO (1 << 1) +#define VENET_SG_FLAG_ECN (1 << 2) + +struct venet_sg { + __u64 cookie; + __u32 flags; + __u32 len; /* total length of all iovs */ + struct { + __u16 start; /* csum starting position */ + __u16 offset; /* offset to place csum */ + } csum; + struct { +#define VENET_GSO_TYPE_TCPV4 0 /* IPv4 TCP (TSO) */ +#define VENET_GSO_TYPE_UDP 1 /* IPv4 UDP (UFO) */ +#define VENET_GSO_TYPE_TCPV6 2 /* IPv6 TCP */ + __u8 type; + __u16 hdrlen; + __u16 size; + } gso; + __u32 count; /* nr of iovs */ + struct venet_iov iov[1]; +}; + +struct venet_eventq_query { + __u32 flags; + __u32 evsize; /* size of each event */ + __u32 dpid; /* descriptor pool-id */ + __u32 qid; + __u8 pad[16]; +}; + +#define VENET_EVENT_LINKSTATE 0 +#define VENET_EVENT_TXC 1 + +struct venet_event_header { + __u32 flags; + __u32 size; + __u32 id; +}; + +struct venet_event_linkstate { + struct venet_event_header header; + __u8 state; /* 0 = down, 1 = up */ +}; + +struct venet_event_txc { + struct venet_event_header header; + __u32 txqid; + __u64 cookie; +}; + +struct venet_l4ro_query { + __u32 flags; + __u32 dpid; /* descriptor pool-id */ + __u32 pqid; /* page queue-id */ + __u8 pad[20]; +}; + + +#define VSG_DESC_SIZE(count) (sizeof(struct venet_sg) + \ + sizeof(struct venet_iov) * ((count) - 1)) + +#define VENET_FUNC_LINKUP 0 +#define VENET_FUNC_LINKDOWN 1 +#define VENET_FUNC_MACQUERY 2 +#define VENET_FUNC_NEGCAP 3 /* negotiate capabilities */ +#define VENET_FUNC_FLUSHRX 4 +#define VENET_FUNC_PMTDQUERY 5 +#define VENET_FUNC_EVQQUERY 6 +#define VENET_FUNC_L4ROQUERY 7 + +#endif /* _LINUX_VENET_H */ |