1 #ifndef LINUX_26_24_COMPAT_H
2 #define LINUX_26_24_COMPAT_H
4 #include <linux/autoconf.h>
5 #include <linux/version.h>
7 /* Compat work for 2.6.21, 2.6.22 and 2.6.23 */
8 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
10 #include <asm/atomic.h>
11 #include <linux/netdevice.h>
12 #include <linux/skbuff.h>
13 #include <linux/usb.h>
14 #include <linux/types.h>
15 #include <linux/list.h>
17 #define KEY_BLUETOOTH 237
21 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
23 /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */
24 typedef unsigned long uintptr_t;
26 /* From include/linux/net.h */
27 enum sock_shutdown_cmd {
33 #if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) /* Local check */
34 /* Added as of 2.6.24 in include/linux/skbuff.h.
36 * Although 2.6.23 does support for CONFIG_NETDEVICES_MULTIQUEUE
37 * this helper was not added until 2.6.24. This implementation
38 * is exactly as it is on newer kernels.
40 * For older kernels we use the an internal mac80211 hack.
41 * For details see changes to include/net/mac80211.h through
42 * compat.diff and compat/mq_compat.h */
43 static inline u16 skb_get_queue_mapping(struct sk_buff *skb)
45 #ifdef CONFIG_NETDEVICES_MULTIQUEUE
46 return skb->queue_mapping;
51 #endif /* Local 2.6.23 check */
53 /* On older kernels we handle this a bit differently, so we yield to that
54 * code for its implementation in mq_compat.h as we want to make
55 * use of the internal mac80211 __ieee80211_queue_stopped() which itself
56 * uses internal mac80211 data structure hacks. */
57 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) /* Local check */
59 * netif_subqueue_stopped - test status of subqueue
60 * @dev: network device
61 * @queue_index: sub queue index
63 * Check individual transmit queue of a device with multiple transmit queues.
65 static inline int __netif_subqueue_stopped(const struct net_device *dev,
68 #ifdef CONFIG_NETDEVICES_MULTIQUEUE
69 return test_bit(__LINK_STATE_XOFF,
70 &dev->egress_subqueue[queue_index].state);
76 /* Note: although the backport implementation for netif_subqueue_stopped
77 * on older kernels is identical to upstream __netif_subqueue_stopped()
78 * (except for a const qualifier) we implement netif_subqueue_stopped()
79 * as part of mac80211 as it relies on internal mac80211 structures we
80 * use for MQ support. We this implement it in mq_compat.h */
82 #endif /* Local 2.6.23 check */
85 * Force link bug if constructor is used, can't be done compatibly
86 * because constructor arguments were swapped since then!
88 extern void __incompatible_kmem_cache_create(void);
90 /* 2.6.21 and 2.6.22 kmem_cache_create() takes 6 arguments */
91 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
92 #define kmem_cache_create(name, objsize, align, flags, ctor) \
94 if (ctor) __incompatible_kmem_cache_create(); \
95 kmem_cache_create((name), (objsize), (align), \
96 (flags), NULL, NULL); \
100 /* 2.6.23 kmem_cache_create() takes 5 arguments */
101 #if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23))
102 #define kmem_cache_create(name, objsize, align, flags, ctor) \
104 if (ctor) __incompatible_kmem_cache_create(); \
105 kmem_cache_create((name), (objsize), (align), \
110 /* From include/linux/mod_devicetable.h */
112 /* SSB core, see drivers/ssb/ */
114 struct ssb_device_id {
119 #define SSB_DEVICE(_vendor, _coreid, _revision) \
120 { .vendor = _vendor, .coreid = _coreid, .revision = _revision, }
121 #define SSB_DEVTABLE_END \
124 #define SSB_ANY_VENDOR 0xFFFF
125 #define SSB_ANY_ID 0xFFFF
126 #define SSB_ANY_REV 0xFF
130 /* Namespace stuff, introduced on 2.6.24 */
131 #define dev_get_by_index(a, b) dev_get_by_index(b)
132 #define __dev_get_by_index(a, b) __dev_get_by_index(b)
135 * Display a 6 byte device address (MAC) in a readable format.
137 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
138 extern char *print_mac(char *buf, const u8 *addr);
139 #define DECLARE_MAC_BUF(var) char var[18] __maybe_unused
141 extern int eth_header(struct sk_buff *skb, struct net_device *dev,
142 unsigned short type, void *daddr,
143 void *saddr, unsigned len);
144 extern int eth_rebuild_header(struct sk_buff *skb);
145 extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev,
146 unsigned char * haddr);
147 extern int eth_header_cache(struct neighbour *neigh,
148 struct hh_cache *hh);
150 /* This structure is simply not present on 2.6.22 and 2.6.23 */
152 int (*create) (struct sk_buff *skb, struct net_device *dev,
153 unsigned short type, void *daddr,
154 void *saddr, unsigned len);
155 int (*parse)(const struct sk_buff *skb, unsigned char *haddr);
156 int (*rebuild)(struct sk_buff *skb);
157 #define HAVE_HEADER_CACHE
158 int (*cache)(struct neighbour *neigh, struct hh_cache *hh);
159 void (*cache_update)(struct hh_cache *hh,
160 struct net_device *dev,
161 unsigned char *haddr);
164 /* net/ieee80211/ieee80211_crypt_tkip uses sg_init_table. This was added on
165 * 2.6.24. CONFIG_DEBUG_SG was added in 2.6.24 as well, so lets just ignore
166 * the debug stuff. Note that adding this required changes to the struct
167 * scatterlist on include/asm/scatterlist*, so the right way to port this
168 * is to simply ignore the new structure changes and zero the scatterlist
169 * array. We lave the kdoc intact for reference.
173 * sg_mark_end - Mark the end of the scatterlist
174 * @sg: SG entryScatterlist
177 * Marks the passed in sg entry as the termination point for the sg
178 * table. A call to sg_next() on this entry will return NULL.
181 static inline void sg_mark_end(struct scatterlist *sg)
186 * sg_init_table - Initialize SG table
188 * @nents: Number of entries in table
191 * If this is part of a chained sg table, sg_mark_end() should be
192 * used only on the last table part.
195 static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
197 memset(sgl, 0, sizeof(*sgl) * nents);
201 * usb_endpoint_num - get the endpoint's number
202 * @epd: endpoint to be checked
204 * Returns @epd's number: 0 to 15.
206 static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
208 return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
211 /* Helper to make struct pci_dev is_pcie compatibility code smaller */
212 int compat_is_pcie(struct pci_dev *pdev);
214 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */
216 #endif /* LINUX_26_24_COMPAT_H */