1 /****************************************************************************
2 * Solarflare driver for Xen network acceleration
4 * Copyright 2006-2008: Solarflare Communications Inc,
5 * 9501 Jeronimo Road, Suite 250,
6 * Irvine, CA 92618, USA
8 * Maintained by Solarflare Communications <linux-xen-drivers@solarflare.com>
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.
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.
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 ****************************************************************************
25 #ifndef NETBACK_ACCEL_UTIL_H
26 #define NETBACK_ACCEL_UTIL_H
32 #define FILE_LEAF strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__
35 #define VPRINTK(_f, _a...)
37 #define VPRINTK(_f, _a...) \
38 printk("(file=%s, line=%d) " _f, \
39 FILE_LEAF , __LINE__ , ## _a )
43 #define DPRINTK(_f, _a...)
45 #define DPRINTK(_f, _a...) \
46 printk("(file=%s, line=%d) " _f, \
47 FILE_LEAF , __LINE__ , ## _a )
50 #define EPRINTK(_f, _a...) \
51 printk("(file=%s, line=%d) " _f, \
52 FILE_LEAF , __LINE__ , ## _a )
54 #define EPRINTK_ON(exp) \
57 EPRINTK("%s at %s:%d\n", #exp, __FILE__, __LINE__); \
60 #define DPRINTK_ON(exp) \
63 DPRINTK("%s at %s:%d\n", #exp, __FILE__, __LINE__); \
66 #include <xen/xenbus.h>
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
73 void *net_accel_map_grants_contig(struct xenbus_device *dev,
74 unsigned *grants, int npages,
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
82 void net_accel_unmap_grants_contig(struct xenbus_device *dev, void *priv);
84 /*! Read the MAC address of a device from xenstore */
86 int net_accel_xen_net_read_mac(struct xenbus_device *dev, u8 mac[]);
88 /*! Update the accelstate field for a device in xenstore */
90 void net_accel_update_state(struct xenbus_device *dev, int state);
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
98 int net_accel_map_device_page(struct xenbus_device *dev,
99 int gnt_ref, grant_handle_t *handle,
102 int net_accel_unmap_device_page(struct xenbus_device *dev,
103 grant_handle_t handle, u64 dev_bus_addr);
105 void *net_accel_map_iomem_page(struct xenbus_device *dev, int gnt_ref,
108 void net_accel_unmap_iomem_page(struct xenbus_device *dev, void *priv);
110 /*! Grrant a page to remote domain */
112 int net_accel_grant_page(struct xenbus_device *dev, unsigned long mfn,
114 /*! Undo a net_accel_grant_page */
116 int net_accel_ungrant_page(grant_ref_t gntref);
119 /*! Shutdown remote domain that is misbehaving */
121 int net_accel_shutdown_remote(int domain);