1
#ifndef LINUX_26_24_COMPAT_H
2
#define LINUX_26_24_COMPAT_H
4
#include <linux/version.h>
6
/* Compat work for 2.6.21, 2.6.22 and 2.6.23 */
7
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
9
#include <asm/atomic.h>
10
#include <linux/netdevice.h>
11
#include <linux/skbuff.h>
12
#include <linux/usb.h>
13
#include <linux/types.h>
14
#include <linux/list.h>
15
#include <linux/scatterlist.h>
17
#define KEY_BLUETOOTH 237
21
#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
23
struct proc_dir_entry;
26
atomic_t count; /* To decided when the network
27
* namespace should be freed.
29
atomic_t use_count; /* To track references we
32
struct list_head list; /* list of network namespaces */
33
struct work_struct work; /* work struct for freeing */
35
struct proc_dir_entry *proc_net;
36
struct proc_dir_entry *proc_net_stat;
37
struct proc_dir_entry *proc_net_root;
39
struct net_device *loopback_dev; /* The loopback */
41
struct list_head dev_base_head;
42
struct hlist_head *dev_name_head;
43
struct hlist_head *dev_index_head;
47
/* Init's network namespace */
48
extern struct net init_net;
49
#define INIT_NET_NS(net_ns) .net_ns = &init_net,
51
#define INIT_NET_NS(net_ns)
54
/* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */
55
typedef unsigned long uintptr_t;
57
/* From include/linux/net.h */
58
enum sock_shutdown_cmd {
64
#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) /* Local check */
65
/* Added as of 2.6.24 in include/linux/skbuff.h.
67
* Although 2.6.23 does support for CONFIG_NETDEVICES_MULTIQUEUE
68
* this helper was not added until 2.6.24. This implementation
69
* is exactly as it is on newer kernels.
71
* For older kernels we use the an internal mac80211 hack.
72
* For details see changes to include/net/mac80211.h through
73
* compat.diff and compat/mq_compat.h */
74
static inline u16 skb_get_queue_mapping(struct sk_buff *skb)
76
#ifdef CONFIG_NETDEVICES_MULTIQUEUE
77
return skb->queue_mapping;
82
#endif /* Local 2.6.23 check */
84
/* On older kernels we handle this a bit differently, so we yield to that
85
* code for its implementation in mq_compat.h as we want to make
86
* use of the internal mac80211 __ieee80211_queue_stopped() which itself
87
* uses internal mac80211 data structure hacks. */
88
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) /* Local check */
90
* netif_subqueue_stopped - test status of subqueue
91
* @dev: network device
92
* @queue_index: sub queue index
94
* Check individual transmit queue of a device with multiple transmit queues.
96
static inline int __netif_subqueue_stopped(const struct net_device *dev,
99
#ifdef CONFIG_NETDEVICES_MULTIQUEUE
100
return test_bit(__LINK_STATE_XOFF,
101
&dev->egress_subqueue[queue_index].state);
107
/* Note: although the backport implementation for netif_subqueue_stopped
108
* on older kernels is identical to upstream __netif_subqueue_stopped()
109
* (except for a const qualifier) we implement netif_subqueue_stopped()
110
* as part of mac80211 as it relies on internal mac80211 structures we
111
* use for MQ support. We this implement it in mq_compat.h */
113
#endif /* Local 2.6.23 check */
116
* Force link bug if constructor is used, can't be done compatibly
117
* because constructor arguments were swapped since then!
119
extern void __incompatible_kmem_cache_create(void);
121
/* 2.6.21 and 2.6.22 kmem_cache_create() takes 6 arguments */
122
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
123
#define kmem_cache_create(name, objsize, align, flags, ctor) \
125
if (ctor) __incompatible_kmem_cache_create(); \
126
kmem_cache_create((name), (objsize), (align), \
127
(flags), NULL, NULL); \
131
/* 2.6.23 kmem_cache_create() takes 5 arguments */
132
#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23))
133
#define kmem_cache_create(name, objsize, align, flags, ctor) \
135
if (ctor) __incompatible_kmem_cache_create(); \
136
kmem_cache_create((name), (objsize), (align), \
141
/* From include/linux/mod_devicetable.h */
143
/* SSB core, see drivers/ssb/ */
145
struct ssb_device_id {
150
#define SSB_DEVICE(_vendor, _coreid, _revision) \
151
{ .vendor = _vendor, .coreid = _coreid, .revision = _revision, }
152
#define SSB_DEVTABLE_END \
155
#define SSB_ANY_VENDOR 0xFFFF
156
#define SSB_ANY_ID 0xFFFF
157
#define SSB_ANY_REV 0xFF
161
/* Namespace stuff, introduced on 2.6.24 */
162
#define dev_get_by_index(a, b) dev_get_by_index(b)
163
#define __dev_get_by_index(a, b) __dev_get_by_index(b)
165
extern int eth_header(struct sk_buff *skb, struct net_device *dev,
166
unsigned short type, void *daddr,
167
void *saddr, unsigned len);
168
extern int eth_rebuild_header(struct sk_buff *skb);
169
extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev,
170
unsigned char * haddr);
171
extern int eth_header_cache(struct neighbour *neigh,
172
struct hh_cache *hh);
174
/* This structure is simply not present on 2.6.22 and 2.6.23 */
176
int (*create) (struct sk_buff *skb, struct net_device *dev,
177
unsigned short type, void *daddr,
178
void *saddr, unsigned len);
179
int (*parse)(const struct sk_buff *skb, unsigned char *haddr);
180
int (*rebuild)(struct sk_buff *skb);
181
#define HAVE_HEADER_CACHE
182
int (*cache)(struct neighbour *neigh, struct hh_cache *hh);
183
void (*cache_update)(struct hh_cache *hh,
184
struct net_device *dev,
185
unsigned char *haddr);
188
/* net/ieee80211/ieee80211_crypt_tkip uses sg_init_table. This was added on
189
* 2.6.24. CONFIG_DEBUG_SG was added in 2.6.24 as well, so lets just ignore
190
* the debug stuff. Note that adding this required changes to the struct
191
* scatterlist on include/asm/scatterlist*, so the right way to port this
192
* is to simply ignore the new structure changes and zero the scatterlist
193
* array. We lave the kdoc intact for reference.
197
* sg_mark_end - Mark the end of the scatterlist
198
* @sg: SG entryScatterlist
201
* Marks the passed in sg entry as the termination point for the sg
202
* table. A call to sg_next() on this entry will return NULL.
205
static inline void sg_mark_end(struct scatterlist *sg)
207
#ifdef CONFIG_DEBUG_SG
208
BUG_ON(sg->sg_magic != SG_MAGIC);
210
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
212
* Set termination bit, clear potential chain bit
214
sg->page_link |= 0x02;
215
sg->page_link &= ~0x01;
220
* sg_init_table - Initialize SG table
222
* @nents: Number of entries in table
225
* If this is part of a chained sg table, sg_mark_end() should be
226
* used only on the last table part.
229
static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
231
memset(sgl, 0, sizeof(*sgl) * nents);
235
* usb_endpoint_num - get the endpoint's number
236
* @epd: endpoint to be checked
238
* Returns @epd's number: 0 to 15.
240
static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
242
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
245
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */
247
#endif /* LINUX_26_24_COMPAT_H */