1 /******************************************************************************
2 * arch/xen/drivers/netif/backend/common.h
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>
15 #include <linux/netdevice.h>
16 #include <linux/etherdevice.h>
17 #include <asm-xen/ctrl_if.h>
18 #include <asm-xen/xen-public/io/netif.h>
20 #include <asm/pgalloc.h>
24 if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
25 __LINE__, __FILE__); *(int*)0=0; }
26 #define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
27 __FILE__ , __LINE__ , ## _a )
29 #define ASSERT(_p) ((void)0)
30 #define DPRINTK(_f, _a...) ((void)0)
33 typedef struct netif_st {
34 /* Unique identifier for this interface. */
40 /* Physical parameters of the comms window. */
41 unsigned long tx_shmem_frame;
42 unsigned long rx_shmem_frame;
46 /* The shared rings and indexes. */
47 netif_tx_interface_t *tx;
48 netif_rx_interface_t *rx;
50 /* Private indexes into shared ring. */
51 NETIF_RING_IDX rx_req_cons;
52 NETIF_RING_IDX rx_resp_prod; /* private version of shared variable */
53 NETIF_RING_IDX tx_req_cons;
54 NETIF_RING_IDX tx_resp_prod; /* private version of shared variable */
56 /* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */
57 unsigned long credit_bytes;
58 unsigned long credit_usec;
59 unsigned long remaining_credit;
60 struct timer_list credit_timeout;
62 /* Miscellaneous private stuff. */
63 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
66 * DISCONNECT response is deferred until pending requests are ack'ed.
67 * We therefore need to store the id from the original request.
70 struct netif_st *hash_next;
71 struct list_head list; /* scheduling list */
73 struct net_device *dev;
74 struct net_device_stats stats;
76 struct work_struct work;
79 void netif_create(netif_be_create_t *create);
80 void netif_destroy(netif_be_destroy_t *destroy);
81 void netif_creditlimit(netif_be_creditlimit_t *creditlimit);
82 void netif_connect(netif_be_connect_t *connect);
83 int netif_disconnect(netif_be_disconnect_t *disconnect, u8 rsp_id);
84 void netif_disconnect_complete(netif_t *netif);
85 netif_t *netif_find_by_handle(domid_t domid, unsigned int handle);
86 #define netif_get(_b) (atomic_inc(&(_b)->refcnt))
87 #define netif_put(_b) \
89 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
90 netif_disconnect_complete(_b); \
93 void netif_interface_init(void);
94 void netif_ctrlif_init(void);
96 void netif_schedule_work(netif_t *netif);
97 void netif_deschedule_work(netif_t *netif);
99 int netif_be_start_xmit(struct sk_buff *skb, struct net_device *dev);
100 struct net_device_stats *netif_be_get_stats(struct net_device *dev);
101 irqreturn_t netif_be_int(int irq, void *dev_id, struct pt_regs *regs);
103 #endif /* __NETIF__BACKEND__COMMON_H__ */