- Update Xen patches to 3.3-rc5 and c/s 1157.
[linux-flexiantxendom0-3.2.10.git] / drivers / xen / sfc_netutil / accel_util.h
1 /****************************************************************************
2  * Solarflare driver for Xen network acceleration
3  *
4  * Copyright 2006-2008: Solarflare Communications Inc,
5  *                      9501 Jeronimo Road, Suite 250,
6  *                      Irvine, CA 92618, USA
7  *
8  * Maintained by Solarflare Communications <linux-xen-drivers@solarflare.com>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License version 2 as published
12  * by the Free Software Foundation, incorporated herein by reference.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  ****************************************************************************
23  */
24
25 #ifndef NETBACK_ACCEL_UTIL_H
26 #define NETBACK_ACCEL_UTIL_H
27
28 #ifdef DPRINTK
29 #undef DPRINTK
30 #endif
31
32 #define FILE_LEAF strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__
33
34 #if 1
35 #define VPRINTK(_f, _a...) 
36 #else
37 #define VPRINTK(_f, _a...)                      \
38         printk("(file=%s, line=%d) " _f,        \
39                FILE_LEAF , __LINE__ , ## _a )
40 #endif
41
42 #if 1
43 #define DPRINTK(_f, _a...) 
44 #else
45 #define DPRINTK(_f, _a...)                      \
46         printk("(file=%s, line=%d) " _f,        \
47                FILE_LEAF , __LINE__ , ## _a )
48 #endif
49
50 #define EPRINTK(_f, _a...)                      \
51         printk("(file=%s, line=%d) " _f,        \
52                FILE_LEAF , __LINE__ , ## _a )
53
54 #define EPRINTK_ON(exp)                                                 \
55         do {                                                            \
56                 if (exp)                                                \
57                         EPRINTK("%s at %s:%d\n", #exp, __FILE__, __LINE__); \
58         } while(0)
59
60 #define DPRINTK_ON(exp)                                                 \
61         do {                                                            \
62                 if (exp)                                                \
63                         DPRINTK("%s at %s:%d\n", #exp, __FILE__, __LINE__); \
64         } while(0)
65
66 #include <xen/xenbus.h>
67
68 /*! Map a set of pages from another domain
69  * \param dev The xenbus device context
70  * \param priv The private data returned by the mapping function 
71  */
72 extern 
73 void *net_accel_map_grants_contig(struct xenbus_device *dev, 
74                                   unsigned *grants, int npages, 
75                                   void **priv);
76
77 /*! Unmap a set of pages mapped using net_accel_map_grants_contig.
78  * \param dev The xenbus device context
79  * \param priv The private data returned by the mapping function 
80  */
81 extern 
82 void net_accel_unmap_grants_contig(struct xenbus_device *dev, void *priv);
83
84 /*! Read the MAC address of a device from xenstore */
85 extern
86 int net_accel_xen_net_read_mac(struct xenbus_device *dev, u8 mac[]);
87
88 /*! Update the accelstate field for a device in xenstore */
89 extern
90 void net_accel_update_state(struct xenbus_device *dev, int state);
91
92 /* These four map/unmap functions are based on
93  * xenbus_backend_client.c:xenbus_map_ring().  However, they are not
94  * used for ring buffers, instead just to map pages between domains,
95  * or to map a page so that it is accessible by a device
96  */
97 extern
98 int net_accel_map_device_page(struct xenbus_device *dev,  
99                               int gnt_ref, grant_handle_t *handle,
100                               u64 *dev_bus_addr);
101 extern
102 int net_accel_unmap_device_page(struct xenbus_device *dev,
103                                 grant_handle_t handle, u64 dev_bus_addr);
104 extern
105 void *net_accel_map_iomem_page(struct xenbus_device *dev, int gnt_ref,
106                              void **priv);
107 extern
108 void net_accel_unmap_iomem_page(struct xenbus_device *dev, void *priv);
109
110 /*! Grrant a page to remote domain */
111 extern
112 int net_accel_grant_page(struct xenbus_device *dev, unsigned long mfn, 
113                          int is_iomem);
114 /*! Undo a net_accel_grant_page */
115 extern
116 int net_accel_ungrant_page(grant_ref_t gntref);
117
118
119 /*! Shutdown remote domain that is misbehaving */
120 extern
121 int net_accel_shutdown_remote(int domain);
122
123
124 #endif