ia64/linux-2.6.18-xen.hg

view drivers/net/sfc/kernel_compat.h @ 847:ad4d307bf9ce

net sfc: Update sfc and sfc_resource driver to latest release

...and update sfc_netfront, sfc_netback, sfc_netutil for any API changes

sfc_netback: Fix asymmetric use of SFC buffer table alloc and free
sfc_netback: Clean up if no SFC accel device found
sfc_netback: Gracefully handle case where page grant fails
sfc_netback: Disable net acceleration if the physical link goes down
sfc_netfront: Less verbose error messages, more verbose counters for
rx discard errors
sfc_netfront: Gracefully handle case where SFC netfront fails during
initialisation

Signed-off-by: Kieran Mansley <kmansley@solarflare.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:59:10 2009 +0100 (2009-03-31)
parents fc90e9b2c12b
children
line source
1 /****************************************************************************
2 * Driver for Solarflare network controllers
3 * (including support for SFE4001 10GBT NIC)
4 *
5 * Copyright 2005-2006: Fen Systems Ltd.
6 * Copyright 2005-2008: Solarflare Communications Inc,
7 * 9501 Jeronimo Road, Suite 250,
8 * Irvine, CA 92618, USA
9 *
10 * Initially developed by Michael Brown <mbrown@fensystems.co.uk>
11 * Maintained by Solarflare Communications <linux-net-drivers@solarflare.com>
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License version 2 as published
15 * by the Free Software Foundation, incorporated herein by reference.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 ****************************************************************************
26 */
28 #ifndef EFX_KERNEL_COMPAT_H
29 #define EFX_KERNEL_COMPAT_H
31 #include <linux/version.h>
32 #include <linux/sched.h>
33 #include <linux/errno.h>
34 #include <linux/pci.h>
35 #include <linux/workqueue.h>
36 #include <linux/moduleparam.h>
37 #include <linux/interrupt.h>
38 #include <linux/skbuff.h>
39 #include <linux/netdevice.h>
40 #include <linux/rtnetlink.h>
42 /*
43 * Kernel backwards compatibility
44 *
45 * This file provides macros to facilitate backporting the driver.
46 */
48 #ifdef __ia64__
49 /* csum_tcpudp_nofold() is extern but not exported */
50 #define EFX_NEED_CSUM_TCPUDP_NOFOLD yes
51 #endif
52 #ifdef CONFIG_PPC64
53 /* __raw_writel and friends are broken on ppc64 */
54 #define EFX_NEED_RAW_READ_AND_WRITE_FIX yes
55 #endif
57 typedef irqreturn_t (*irq_handler_t)(int, void *, struct pt_regs *);
59 #define skb_mac_header(skb) (skb)->mac.raw
60 #define skb_network_header(skb) (skb)->nh.raw
61 #define eth_hdr(skb) ((struct ethhdr *)skb_mac_header(skb))
62 #define tcp_hdr(skb) (skb)->h.th
63 #define ip_hdr(skb) (skb)->nh.iph
64 #define skb_tail_pointer(skb) (skb)->tail
67 #ifdef EFX_NEED_RAW_READ_AND_WRITE_FIX
68 #include <asm/io.h>
69 static inline void
70 efx_raw_writeb(u8 value, volatile void __iomem *addr)
71 {
72 writeb(value, addr);
73 }
74 static inline void
75 efx_raw_writew(u16 value, volatile void __iomem *addr)
76 {
77 writew(le16_to_cpu(value), addr);
78 }
79 static inline void
80 efx_raw_writel(u32 value, volatile void __iomem *addr)
81 {
82 writel(le32_to_cpu(value), addr);
83 }
84 static inline void
85 efx_raw_writeq(u64 value, volatile void __iomem *addr)
86 {
87 writeq(le64_to_cpu(value), addr);
88 }
89 static inline u8
90 efx_raw_readb(const volatile void __iomem *addr)
91 {
92 return readb(addr);
93 }
94 static inline u16
95 efx_raw_readw(const volatile void __iomem *addr)
96 {
97 return cpu_to_le16(readw(addr));
98 }
99 static inline u32
100 efx_raw_readl(const volatile void __iomem *addr)
101 {
102 return cpu_to_le32(readl(addr));
103 }
104 static inline u64
105 efx_raw_readq(const volatile void __iomem *addr)
106 {
107 return cpu_to_le64(readq(addr));
108 }
110 #undef __raw_writeb
111 #undef __raw_writew
112 #undef __raw_writel
113 #undef __raw_writeq
114 #undef __raw_readb
115 #undef __raw_readw
116 #undef __raw_readl
117 #undef __raw_readq
118 #define __raw_writeb efx_raw_writeb
119 #define __raw_writew efx_raw_writew
120 #define __raw_writel efx_raw_writel
121 #define __raw_writeq efx_raw_writeq
122 #define __raw_readb efx_raw_readb
123 #define __raw_readw efx_raw_readw
124 #define __raw_readl efx_raw_readl
125 #define __raw_readq efx_raw_readq
126 #endif
128 typedef u32 __wsum;
129 #define csum_unfold(x) ((__force __wsum) x)
131 #define DECLARE_MAC_BUF(var) char var[18] __attribute__((unused))
132 extern char *print_mac(char *buf, const u8 *addr);
134 /**
135 * queue_delayed_work in pre 2.6.20 can't rearm from inside
136 * the work member. So instead do a rather hacky sleep
137 */
138 #define delayed_work work_struct
139 #define INIT_DELAYED_WORK INIT_WORK
141 static int inline efx_queue_delayed_work(struct workqueue_struct *wq,
142 struct work_struct *work,
143 unsigned long delay)
144 {
145 if (unlikely(delay > 0))
146 schedule_timeout_uninterruptible(delay);
147 return queue_work(wq, work);
148 }
149 #define queue_delayed_work efx_queue_delayed_work
151 /**
152 * The old and new work-function prototypes just differ
153 * in the type of the pointer returned, so it's safe
154 * to cast between the prototypes.
155 */
156 typedef void (*efx_old_work_func_t)(void *p);
158 #undef INIT_WORK
159 #define INIT_WORK(_work, _func) \
160 do { \
161 INIT_LIST_HEAD(&(_work)->entry); \
162 (_work)->pending = 0; \
163 PREPARE_WORK((_work), \
164 (efx_old_work_func_t) (_func), \
165 (_work)); \
166 } while (0)
168 #define napi_str napi_dev[0]
170 static inline void netif_napi_add(struct net_device *dev,
171 struct net_device *dummy,
172 int (*poll) (struct net_device *, int *),
173 int weight)
174 {
175 dev->weight = weight;
176 dev->poll = poll;
177 }
179 #define napi_enable netif_poll_enable
180 #define napi_disable netif_poll_disable
182 #define netif_rx_complete(dev, dummy) netif_rx_complete(dev)
184 #endif /* EFX_KERNEL_COMPAT_H */