ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/netback/common.h @ 6435:b4b3f6be5226

merge?
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 25 17:27:49 2005 +0000 (2005-08-25)
parents 0610add7c3fe 522bc50588ed
children 8799d14bef77 9312a3e8a6f8 112d44270733
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 unsigned long 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 unsigned long rx_shmem_vaddr;
59 grant_ref_t rx_shmem_ref;
60 #endif
61 unsigned int evtchn;
62 unsigned int remote_evtchn;
64 /* The shared rings and indexes. */
65 netif_tx_interface_t *tx;
66 netif_rx_interface_t *rx;
68 /* Private indexes into shared ring. */
69 NETIF_RING_IDX rx_req_cons;
70 NETIF_RING_IDX rx_resp_prod; /* private version of shared variable */
71 #ifdef CONFIG_XEN_NETDEV_GRANT_RX
72 NETIF_RING_IDX rx_resp_prod_copy; /* private version of shared variable */
73 #endif
74 NETIF_RING_IDX tx_req_cons;
75 NETIF_RING_IDX tx_resp_prod; /* private version of shared variable */
77 /* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */
78 unsigned long credit_bytes;
79 unsigned long credit_usec;
80 unsigned long remaining_credit;
81 struct timer_list credit_timeout;
83 /* Miscellaneous private stuff. */
84 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
85 int active;
86 struct list_head list; /* scheduling list */
87 atomic_t refcnt;
88 struct net_device *dev;
89 struct net_device_stats stats;
91 struct work_struct free_work;
92 } netif_t;
94 void netif_creditlimit(netif_t *netif);
95 int netif_disconnect(netif_t *netif);
97 netif_t *alloc_netif(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN]);
98 void free_netif_callback(netif_t *netif);
99 int netif_map(netif_t *netif, unsigned long tx_ring_ref,
100 unsigned long rx_ring_ref, unsigned int evtchn);
102 #define netif_get(_b) (atomic_inc(&(_b)->refcnt))
103 #define netif_put(_b) \
104 do { \
105 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
106 free_netif_callback(_b); \
107 } while (0)
109 void netif_xenbus_init(void);
111 void netif_schedule_work(netif_t *netif);
112 void netif_deschedule_work(netif_t *netif);
114 int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev);
115 struct net_device_stats *netif_be_get_stats(struct net_device *dev);
116 irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs);
118 #endif /* __NETIF__BACKEND__COMMON_H__ */