ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/netback/common.h @ 6169:e59f04598620

Allow use of grant tables for netdev tx+rx rings. Code is kinda
ugly due at least in part to the fact that we still have separate
_TX and _RX grant config options - expect this to be unified soon.

Signed-off-by: Steven Hand <steven@xensource.com>
author smh22@firebug.cl.cam.ac.uk
date Sun Aug 14 20:34:13 2005 +0000 (2005-08-14)
parents f46bb706a38d
children d47c61f72572
line source
1 /******************************************************************************
2 * arch/xen/drivers/netif/backend/common.h
3 */
5 #ifndef __NETIF__BACKEND__COMMON_H__
6 #define __NETIF__BACKEND__COMMON_H__
8 #include <linux/config.h>
9 #include <linux/version.h>
10 #include <linux/module.h>
11 #include <linux/interrupt.h>
12 #include <linux/slab.h>
13 #include <linux/ip.h>
14 #include <linux/in.h>
15 #include <linux/netdevice.h>
16 #include <linux/etherdevice.h>
17 #include <asm-xen/ctrl_if.h>
18 #include <asm-xen/evtchn.h>
19 #include <asm-xen/xen-public/io/netif.h>
20 #include <asm/io.h>
21 #include <asm/pgalloc.h>
23 #if defined(CONFIG_XEN_NETDEV_GRANT_TX) || defined(CONFIG_XEN_NETDEV_GRANT_RX)
24 #include <asm-xen/xen-public/grant_table.h>
25 #include <asm-xen/gnttab.h>
26 #endif
30 #if 0
31 #define ASSERT(_p) \
32 if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
33 __LINE__, __FILE__); *(int*)0=0; }
34 #define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
35 __FILE__ , __LINE__ , ## _a )
36 #else
37 #define ASSERT(_p) ((void)0)
38 #define DPRINTK(_f, _a...) ((void)0)
39 #endif
41 typedef struct netif_st {
42 /* Unique identifier for this interface. */
43 domid_t domid;
44 unsigned int handle;
46 u8 fe_dev_addr[6];
48 /* Physical parameters of the comms window. */
49 unsigned long tx_shmem_frame;
50 #ifdef CONFIG_XEN_NETDEV_GRANT_TX
51 u16 tx_shmem_handle;
52 memory_t tx_shmem_vaddr;
53 grant_ref_t tx_shmem_ref;
54 #endif
55 unsigned long rx_shmem_frame;
56 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
57 u16 rx_shmem_handle;
58 memory_t rx_shmem_vaddr;
59 grant_ref_t rx_shmem_ref;
60 #endif
61 unsigned int evtchn;
63 /* The shared rings and indexes. */
64 netif_tx_interface_t *tx;
65 netif_rx_interface_t *rx;
67 /* Private indexes into shared ring. */
68 NETIF_RING_IDX rx_req_cons;
69 NETIF_RING_IDX rx_resp_prod; /* private version of shared variable */
70 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
71 NETIF_RING_IDX rx_resp_prod_copy; /* private version of shared variable */
72 #endif
73 NETIF_RING_IDX tx_req_cons;
74 NETIF_RING_IDX tx_resp_prod; /* private version of shared variable */
76 /* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */
77 unsigned long credit_bytes;
78 unsigned long credit_usec;
79 unsigned long remaining_credit;
80 struct timer_list credit_timeout;
82 /* Miscellaneous private stuff. */
83 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
84 int active;
85 /*
86 * DISCONNECT response is deferred until pending requests are ack'ed.
87 * We therefore need to store the id from the original request.
88 */
89 u8 disconnect_rspid;
90 struct netif_st *hash_next;
91 struct list_head list; /* scheduling list */
92 atomic_t refcnt;
93 struct net_device *dev;
94 struct net_device_stats stats;
96 struct work_struct work;
97 } netif_t;
99 void netif_create(netif_be_create_t *create);
100 void netif_destroy(netif_be_destroy_t *destroy);
101 void netif_creditlimit(netif_be_creditlimit_t *creditlimit);
102 void netif_connect(netif_be_connect_t *connect);
103 int netif_disconnect(netif_be_disconnect_t *disconnect, u8 rsp_id);
104 void netif_disconnect_complete(netif_t *netif);
105 netif_t *netif_find_by_handle(domid_t domid, unsigned int handle);
106 #define netif_get(_b) (atomic_inc(&(_b)->refcnt))
107 #define netif_put(_b) \
108 do { \
109 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
110 netif_disconnect_complete(_b); \
111 } while (0)
113 void netif_interface_init(void);
114 void netif_ctrlif_init(void);
116 void netif_schedule_work(netif_t *netif);
117 void netif_deschedule_work(netif_t *netif);
119 int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev);
120 struct net_device_stats *netif_be_get_stats(struct net_device *dev);
121 irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs);
123 #endif /* __NETIF__BACKEND__COMMON_H__ */