ia64/linux-2.6.18-xen.hg

diff drivers/xen/netback/common.h @ 26:a533be77c572

Imported linux-2.6-xen-sparse from xen-unstable.hg 15200:bd3d6b4c52ec
author Ian Campbell <ian.campbell@xensource.com>
date Mon Jun 04 10:05:28 2007 +0100 (2007-06-04)
parents
children 45dfe4cfc5ef
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/drivers/xen/netback/common.h	Mon Jun 04 10:05:28 2007 +0100
     1.3 @@ -0,0 +1,165 @@
     1.4 +/******************************************************************************
     1.5 + * arch/xen/drivers/netif/backend/common.h
     1.6 + * 
     1.7 + * This program is free software; you can redistribute it and/or
     1.8 + * modify it under the terms of the GNU General Public License version 2
     1.9 + * as published by the Free Software Foundation; or, when distributed
    1.10 + * separately from the Linux kernel or incorporated into other
    1.11 + * software packages, subject to the following license:
    1.12 + * 
    1.13 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    1.14 + * of this source file (the "Software"), to deal in the Software without
    1.15 + * restriction, including without limitation the rights to use, copy, modify,
    1.16 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
    1.17 + * and to permit persons to whom the Software is furnished to do so, subject to
    1.18 + * the following conditions:
    1.19 + * 
    1.20 + * The above copyright notice and this permission notice shall be included in
    1.21 + * all copies or substantial portions of the Software.
    1.22 + * 
    1.23 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.24 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.25 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.26 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    1.27 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    1.28 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    1.29 + * IN THE SOFTWARE.
    1.30 + */
    1.31 +
    1.32 +#ifndef __NETIF__BACKEND__COMMON_H__
    1.33 +#define __NETIF__BACKEND__COMMON_H__
    1.34 +
    1.35 +#include <linux/version.h>
    1.36 +#include <linux/module.h>
    1.37 +#include <linux/interrupt.h>
    1.38 +#include <linux/slab.h>
    1.39 +#include <linux/ip.h>
    1.40 +#include <linux/in.h>
    1.41 +#include <linux/netdevice.h>
    1.42 +#include <linux/etherdevice.h>
    1.43 +#include <linux/wait.h>
    1.44 +#include <xen/evtchn.h>
    1.45 +#include <xen/interface/io/netif.h>
    1.46 +#include <asm/io.h>
    1.47 +#include <asm/pgalloc.h>
    1.48 +#include <xen/interface/grant_table.h>
    1.49 +#include <xen/gnttab.h>
    1.50 +#include <xen/driver_util.h>
    1.51 +
    1.52 +#define DPRINTK(_f, _a...)			\
    1.53 +	pr_debug("(file=%s, line=%d) " _f,	\
    1.54 +		 __FILE__ , __LINE__ , ## _a )
    1.55 +#define IPRINTK(fmt, args...)				\
    1.56 +	printk(KERN_INFO "xen_net: " fmt, ##args)
    1.57 +#define WPRINTK(fmt, args...)				\
    1.58 +	printk(KERN_WARNING "xen_net: " fmt, ##args)
    1.59 +
    1.60 +typedef struct netif_st {
    1.61 +	/* Unique identifier for this interface. */
    1.62 +	domid_t          domid;
    1.63 +	unsigned int     handle;
    1.64 +
    1.65 +	u8               fe_dev_addr[6];
    1.66 +
    1.67 +	/* Physical parameters of the comms window. */
    1.68 +	grant_handle_t   tx_shmem_handle;
    1.69 +	grant_ref_t      tx_shmem_ref;
    1.70 +	grant_handle_t   rx_shmem_handle;
    1.71 +	grant_ref_t      rx_shmem_ref;
    1.72 +	unsigned int     irq;
    1.73 +
    1.74 +	/* The shared rings and indexes. */
    1.75 +	netif_tx_back_ring_t tx;
    1.76 +	netif_rx_back_ring_t rx;
    1.77 +	struct vm_struct *tx_comms_area;
    1.78 +	struct vm_struct *rx_comms_area;
    1.79 +
    1.80 +	/* Set of features that can be turned on in dev->features. */
    1.81 +	int features;
    1.82 +
    1.83 +	/* Internal feature information. */
    1.84 +	int can_queue:1;	/* can queue packets for receiver? */
    1.85 +	int copying_receiver:1;	/* copy packets to receiver?       */
    1.86 +
    1.87 +	/* Allow netif_be_start_xmit() to peek ahead in the rx request ring. */
    1.88 +	RING_IDX rx_req_cons_peek;
    1.89 +
    1.90 +	/* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */
    1.91 +	unsigned long   credit_bytes;
    1.92 +	unsigned long   credit_usec;
    1.93 +	unsigned long   remaining_credit;
    1.94 +	struct timer_list credit_timeout;
    1.95 +
    1.96 +	/* Enforce draining of the transmit queue. */
    1.97 +	struct timer_list tx_queue_timeout;
    1.98 +
    1.99 +	/* Miscellaneous private stuff. */
   1.100 +	struct list_head list;  /* scheduling list */
   1.101 +	atomic_t         refcnt;
   1.102 +	struct net_device *dev;
   1.103 +	struct net_device_stats stats;
   1.104 +
   1.105 +	unsigned int carrier;
   1.106 +
   1.107 +	wait_queue_head_t waiting_to_free;
   1.108 +} netif_t;
   1.109 +
   1.110 +/*
   1.111 + * Implement our own carrier flag: the network stack's version causes delays
   1.112 + * when the carrier is re-enabled (in particular, dev_activate() may not
   1.113 + * immediately be called, which can cause packet loss; also the etherbridge
   1.114 + * can be rather lazy in activating its port).
   1.115 + */
   1.116 +#define netback_carrier_on(netif)	((netif)->carrier = 1)
   1.117 +#define netback_carrier_off(netif)	((netif)->carrier = 0)
   1.118 +#define netback_carrier_ok(netif)	((netif)->carrier)
   1.119 +
   1.120 +enum {
   1.121 +	NETBK_DONT_COPY_SKB,
   1.122 +	NETBK_DELAYED_COPY_SKB,
   1.123 +	NETBK_ALWAYS_COPY_SKB,
   1.124 +};
   1.125 +
   1.126 +extern int netbk_copy_skb_mode;
   1.127 +
   1.128 +#define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
   1.129 +#define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
   1.130 +
   1.131 +void netif_disconnect(netif_t *netif);
   1.132 +
   1.133 +netif_t *netif_alloc(domid_t domid, unsigned int handle);
   1.134 +int netif_map(netif_t *netif, unsigned long tx_ring_ref,
   1.135 +	      unsigned long rx_ring_ref, unsigned int evtchn);
   1.136 +
   1.137 +#define netif_get(_b) (atomic_inc(&(_b)->refcnt))
   1.138 +#define netif_put(_b)						\
   1.139 +	do {							\
   1.140 +		if ( atomic_dec_and_test(&(_b)->refcnt) )	\
   1.141 +			wake_up(&(_b)->waiting_to_free);	\
   1.142 +	} while (0)
   1.143 +
   1.144 +void netif_xenbus_init(void);
   1.145 +
   1.146 +#define netif_schedulable(netif)				\
   1.147 +	(netif_running((netif)->dev) && netback_carrier_ok(netif))
   1.148 +
   1.149 +void netif_schedule_work(netif_t *netif);
   1.150 +void netif_deschedule_work(netif_t *netif);
   1.151 +
   1.152 +int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev);
   1.153 +struct net_device_stats *netif_be_get_stats(struct net_device *dev);
   1.154 +irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs);
   1.155 +
   1.156 +static inline int netbk_can_queue(struct net_device *dev)
   1.157 +{
   1.158 +	netif_t *netif = netdev_priv(dev);
   1.159 +	return netif->can_queue;
   1.160 +}
   1.161 +
   1.162 +static inline int netbk_can_sg(struct net_device *dev)
   1.163 +{
   1.164 +	netif_t *netif = netdev_priv(dev);
   1.165 +	return netif->features & NETIF_F_SG;
   1.166 +}
   1.167 +
   1.168 +#endif /* __NETIF__BACKEND__COMMON_H__ */