ia64/xen-unstable

annotate linux-2.6-xen-sparse/drivers/xen/netback/common.h @ 14100:e47738923a05

[LINUX] Purge include <linux/config.h>. It has been obsolete for some time now.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Fri Feb 23 16:56:45 2007 +0000 (2007-02-23)
parents d275951acf10
children 42b29f084c31
rev   line source
cl349@4087 1 /******************************************************************************
cl349@4087 2 * arch/xen/drivers/netif/backend/common.h
kaf24@9386 3 *
kaf24@9386 4 * This program is free software; you can redistribute it and/or
kaf24@9386 5 * modify it under the terms of the GNU General Public License version 2
kaf24@9386 6 * as published by the Free Software Foundation; or, when distributed
kaf24@9386 7 * separately from the Linux kernel or incorporated into other
kaf24@9386 8 * software packages, subject to the following license:
kaf24@9386 9 *
kaf24@9386 10 * Permission is hereby granted, free of charge, to any person obtaining a copy
kaf24@9386 11 * of this source file (the "Software"), to deal in the Software without
kaf24@9386 12 * restriction, including without limitation the rights to use, copy, modify,
kaf24@9386 13 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
kaf24@9386 14 * and to permit persons to whom the Software is furnished to do so, subject to
kaf24@9386 15 * the following conditions:
kaf24@9386 16 *
kaf24@9386 17 * The above copyright notice and this permission notice shall be included in
kaf24@9386 18 * all copies or substantial portions of the Software.
kaf24@9386 19 *
kaf24@9386 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
kaf24@9386 21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
kaf24@9386 22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
kaf24@9386 23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
kaf24@9386 24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
kaf24@9386 25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
kaf24@9386 26 * IN THE SOFTWARE.
cl349@4087 27 */
cl349@4087 28
cl349@4087 29 #ifndef __NETIF__BACKEND__COMMON_H__
cl349@4087 30 #define __NETIF__BACKEND__COMMON_H__
cl349@4087 31
cl349@4087 32 #include <linux/version.h>
cl349@4087 33 #include <linux/module.h>
cl349@4087 34 #include <linux/interrupt.h>
cl349@4087 35 #include <linux/slab.h>
cl349@4087 36 #include <linux/ip.h>
cl349@4087 37 #include <linux/in.h>
cl349@4087 38 #include <linux/netdevice.h>
cl349@4087 39 #include <linux/etherdevice.h>
kaf24@10029 40 #include <linux/wait.h>
cl349@8706 41 #include <xen/evtchn.h>
cl349@8706 42 #include <xen/interface/io/netif.h>
cl349@4087 43 #include <asm/io.h>
cl349@4087 44 #include <asm/pgalloc.h>
cl349@8706 45 #include <xen/interface/grant_table.h>
cl349@8706 46 #include <xen/gnttab.h>
cl349@8706 47 #include <xen/driver_util.h>
shand@6593 48
kfraser@10368 49 #define DPRINTK(_f, _a...) \
kfraser@10368 50 pr_debug("(file=%s, line=%d) " _f, \
kfraser@10368 51 __FILE__ , __LINE__ , ## _a )
kfraser@10368 52 #define IPRINTK(fmt, args...) \
kfraser@10368 53 printk(KERN_INFO "xen_net: " fmt, ##args)
kfraser@10368 54 #define WPRINTK(fmt, args...) \
kfraser@10368 55 printk(KERN_WARNING "xen_net: " fmt, ##args)
shand@6593 56
cl349@4087 57 typedef struct netif_st {
kaf24@6910 58 /* Unique identifier for this interface. */
kaf24@6910 59 domid_t domid;
kaf24@6910 60 unsigned int handle;
cl349@4087 61
kaf24@6910 62 u8 fe_dev_addr[6];
cl349@4087 63
kaf24@6910 64 /* Physical parameters of the comms window. */
kaf24@8137 65 grant_handle_t tx_shmem_handle;
shand@11156 66 grant_ref_t tx_shmem_ref;
kaf24@8137 67 grant_handle_t rx_shmem_handle;
shand@11156 68 grant_ref_t rx_shmem_ref;
kaf24@7128 69 unsigned int irq;
cl349@4087 70
kaf24@6910 71 /* The shared rings and indexes. */
kaf24@8164 72 netif_tx_back_ring_t tx;
kaf24@8164 73 netif_rx_back_ring_t rx;
kaf24@8292 74 struct vm_struct *tx_comms_area;
kaf24@8292 75 struct vm_struct *rx_comms_area;
cl349@4087 76
kfraser@10880 77 /* Set of features that can be turned on in dev->features. */
kfraser@10880 78 int features;
kfraser@11165 79
kfraser@11165 80 /* Internal feature information. */
kfraser@11165 81 int can_queue:1; /* can queue packets for receiver? */
kfraser@11165 82 int copying_receiver:1; /* copy packets to receiver? */
kfraser@10880 83
kaf24@8164 84 /* Allow netif_be_start_xmit() to peek ahead in the rx request ring. */
kaf24@8164 85 RING_IDX rx_req_cons_peek;
kaf24@6910 86
kaf24@6910 87 /* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */
kaf24@6910 88 unsigned long credit_bytes;
kaf24@6910 89 unsigned long credit_usec;
kaf24@6910 90 unsigned long remaining_credit;
kaf24@6910 91 struct timer_list credit_timeout;
kaf24@6910 92
kfraser@11938 93 /* Enforce draining of the transmit queue. */
kfraser@11938 94 struct timer_list tx_queue_timeout;
kfraser@11938 95
kaf24@6910 96 /* Miscellaneous private stuff. */
kaf24@6910 97 struct list_head list; /* scheduling list */
kaf24@6910 98 atomic_t refcnt;
kaf24@6910 99 struct net_device *dev;
kaf24@6910 100 struct net_device_stats stats;
kaf24@6910 101
kaf24@10029 102 wait_queue_head_t waiting_to_free;
cl349@4087 103 } netif_t;
cl349@4087 104
kaf24@8164 105 #define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
kaf24@8164 106 #define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
kaf24@8164 107
kaf24@8451 108 void netif_disconnect(netif_t *netif);
cl349@6419 109
kfraser@11801 110 netif_t *netif_alloc(domid_t domid, unsigned int handle);
cl349@6419 111 int netif_map(netif_t *netif, unsigned long tx_ring_ref,
cl349@6419 112 unsigned long rx_ring_ref, unsigned int evtchn);
cl349@6419 113
cl349@4087 114 #define netif_get(_b) (atomic_inc(&(_b)->refcnt))
kaf24@6910 115 #define netif_put(_b) \
kaf24@6910 116 do { \
kaf24@6910 117 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
kaf24@10029 118 wake_up(&(_b)->waiting_to_free); \
kaf24@6910 119 } while (0)
cl349@4087 120
cl349@6425 121 void netif_xenbus_init(void);
cl349@4087 122
kfraser@11938 123 #define netif_schedulable(dev) (netif_running(dev) && netif_carrier_ok(dev))
kfraser@11938 124
cl349@4087 125 void netif_schedule_work(netif_t *netif);
cl349@4087 126 void netif_deschedule_work(netif_t *netif);
cl349@4087 127
cl349@4087 128 int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev);
cl349@4087 129 struct net_device_stats *netif_be_get_stats(struct net_device *dev);
cl349@4087 130 irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs);
cl349@4087 131
kfraser@10880 132 static inline int netbk_can_queue(struct net_device *dev)
kfraser@10880 133 {
kfraser@10880 134 netif_t *netif = netdev_priv(dev);
kfraser@10880 135 return netif->can_queue;
kfraser@10880 136 }
kfraser@10880 137
kfraser@10882 138 static inline int netbk_can_sg(struct net_device *dev)
kfraser@10882 139 {
kfraser@10882 140 netif_t *netif = netdev_priv(dev);
kfraser@10882 141 return netif->features & NETIF_F_SG;
kfraser@10882 142 }
kfraser@10882 143
cl349@4087 144 #endif /* __NETIF__BACKEND__COMMON_H__ */