ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/netback/common.h @ 6689:7d0fb56b4a91

merge?
author cl349@firebug.cl.cam.ac.uk
date Wed Sep 07 19:01:31 2005 +0000 (2005-09-07)
parents 549f4256ab3c 291e816acbf4
children b2f4823b6ff0 b35215021b32 9af349b055e5 3233e7ecfa9f
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/evtchn.h>
18 #include <asm-xen/xen-public/io/netif.h>
19 #include <asm/io.h>
20 #include <asm/pgalloc.h>
22 #ifdef CONFIG_XEN_NETDEV_GRANT
23 #include <asm-xen/xen-public/grant_table.h>
24 #include <asm-xen/gnttab.h>
26 #define GRANT_INVALID_REF (0xFFFF)
28 #endif
32 #if 0
33 #define ASSERT(_p) \
34 if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
35 __LINE__, __FILE__); *(int*)0=0; }
36 #define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
37 __FILE__ , __LINE__ , ## _a )
38 #else
39 #define ASSERT(_p) ((void)0)
40 #define DPRINTK(_f, _a...) ((void)0)
41 #endif
42 #define IPRINTK(fmt, args...) \
43 printk(KERN_INFO "xen_net: " fmt, ##args)
44 #define WPRINTK(fmt, args...) \
45 printk(KERN_WARNING "xen_net: " fmt, ##args)
48 typedef struct netif_st {
49 /* Unique identifier for this interface. */
50 domid_t domid;
51 unsigned int handle;
53 u8 fe_dev_addr[6];
55 /* Physical parameters of the comms window. */
56 unsigned long tx_shmem_frame;
57 #ifdef CONFIG_XEN_NETDEV_GRANT
58 u16 tx_shmem_handle;
59 unsigned long tx_shmem_vaddr;
60 grant_ref_t tx_shmem_ref;
61 #endif
62 unsigned long rx_shmem_frame;
63 #ifdef CONFIG_XEN_NETDEV_GRANT
64 u16 rx_shmem_handle;
65 unsigned long rx_shmem_vaddr;
66 grant_ref_t rx_shmem_ref;
67 #endif
68 unsigned int evtchn;
69 unsigned int remote_evtchn;
71 /* The shared rings and indexes. */
72 netif_tx_interface_t *tx;
73 netif_rx_interface_t *rx;
75 /* Private indexes into shared ring. */
76 NETIF_RING_IDX rx_req_cons;
77 NETIF_RING_IDX rx_resp_prod; /* private version of shared variable */
78 #ifdef CONFIG_XEN_NETDEV_GRANT
79 NETIF_RING_IDX rx_resp_prod_copy; /* private version of shared variable */
80 #endif
81 NETIF_RING_IDX tx_req_cons;
82 NETIF_RING_IDX tx_resp_prod; /* private version of shared variable */
84 /* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */
85 unsigned long credit_bytes;
86 unsigned long credit_usec;
87 unsigned long remaining_credit;
88 struct timer_list credit_timeout;
90 /* Miscellaneous private stuff. */
91 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
92 int active;
93 struct list_head list; /* scheduling list */
94 atomic_t refcnt;
95 struct net_device *dev;
96 struct net_device_stats stats;
98 struct work_struct free_work;
99 } netif_t;
101 void netif_creditlimit(netif_t *netif);
102 int netif_disconnect(netif_t *netif);
104 netif_t *alloc_netif(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN]);
105 void free_netif_callback(netif_t *netif);
106 int netif_map(netif_t *netif, unsigned long tx_ring_ref,
107 unsigned long rx_ring_ref, unsigned int evtchn);
109 #define netif_get(_b) (atomic_inc(&(_b)->refcnt))
110 #define netif_put(_b) \
111 do { \
112 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
113 free_netif_callback(_b); \
114 } while (0)
116 void netif_xenbus_init(void);
118 void netif_schedule_work(netif_t *netif);
119 void netif_deschedule_work(netif_t *netif);
121 int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev);
122 struct net_device_stats *netif_be_get_stats(struct net_device *dev);
123 irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs);
125 #endif /* __NETIF__BACKEND__COMMON_H__ */