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 /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */
11 typedef unsigned long uintptr_t;
13 /* From include/linux/net.h */
14 enum sock_shutdown_cmd {
20 #if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) /* Local check */
21 /* Added as of 2.6.24 in include/linux/skbuff.h.
23 * Although 2.6.23 does support for CONFIG_NETDEVICES_MULTIQUEUE
24 * this helper was not added until 2.6.24. This implementation
25 * is exactly as it is on newer kernels.
27 * For older kernels we use the an internal mac80211 hack.
28 * For details see changes to include/net/mac80211.h through
29 * compat.diff and compat/mq_compat.h */
30 static inline u16 skb_get_queue_mapping(struct sk_buff *skb)
32 #ifdef CONFIG_NETDEVICES_MULTIQUEUE
33 return skb->queue_mapping;
38 #endif /* Local 2.6.23 check */
40 /* On older kernels we handle this a bit differently, so we yield to that
41 * code for its implementation in mq_compat.h as we want to make
42 * use of the internal mac80211 __ieee80211_queue_stopped() which itself
43 * uses internal mac80211 data structure hacks. */
44 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) /* Local check */
46 * netif_subqueue_stopped - test status of subqueue
47 * @dev: network device
48 * @queue_index: sub queue index
50 * Check individual transmit queue of a device with multiple transmit queues.
52 static inline int __netif_subqueue_stopped(const struct net_device *dev,
55 #ifdef CONFIG_NETDEVICES_MULTIQUEUE
56 return test_bit(__LINK_STATE_XOFF,
57 &dev->egress_subqueue[queue_index].state);
63 /* Note: although the backport implementation for netif_subqueue_stopped
64 * on older kernels is identical to upstream __netif_subqueue_stopped()
65 * (except for a const qualifier) we implement netif_subqueue_stopped()
66 * as part of mac80211 as it relies on internal mac80211 structures we
67 * use for MQ support. We this implement it in mq_compat.h */
69 #endif /* Local 2.6.23 check */
72 * Force link bug if constructor is used, can't be done compatibly
73 * because constructor arguments were swapped since then!
75 extern void __incompatible_kmem_cache_create(void);
77 /* 2.6.21 and 2.6.22 kmem_cache_create() takes 6 arguments */
78 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23))
79 #define kmem_cache_create(name, objsize, align, flags, ctor) \
81 if (ctor) __incompatible_kmem_cache_create(); \
82 kmem_cache_create((name), (objsize), (align), \
83 (flags), NULL, NULL); \
87 /* 2.6.23 kmem_cache_create() takes 5 arguments */
88 #if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23))
89 #define kmem_cache_create(name, objsize, align, flags, ctor) \
91 if (ctor) __incompatible_kmem_cache_create(); \
92 kmem_cache_create((name), (objsize), (align), \
97 /* From include/linux/mod_devicetable.h */
99 /* SSB core, see drivers/ssb/ */
101 struct ssb_device_id {
106 #define SSB_DEVICE(_vendor, _coreid, _revision) \
107 { .vendor = _vendor, .coreid = _coreid, .revision = _revision, }
108 #define SSB_DEVTABLE_END \
111 #define SSB_ANY_VENDOR 0xFFFF
112 #define SSB_ANY_ID 0xFFFF
113 #define SSB_ANY_REV 0xFF
117 /* Namespace stuff, introduced on 2.6.24 */
118 #define dev_get_by_index(a, b) dev_get_by_index(b)
119 #define __dev_get_by_index(a, b) __dev_get_by_index(b)
122 * Display a 6 byte device address (MAC) in a readable format.
124 #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
125 extern char *print_mac(char *buf, const u8 *addr);
126 #define DECLARE_MAC_BUF(var) char var[18] __maybe_unused
128 extern int eth_header(struct sk_buff *skb, struct net_device *dev,
129 unsigned short type, void *daddr,
130 void *saddr, unsigned len);
131 extern int eth_rebuild_header(struct sk_buff *skb);
132 extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev,
133 unsigned char * haddr);
134 extern int eth_header_cache(struct neighbour *neigh,
135 struct hh_cache *hh);
137 /* This structure is simply not present on 2.6.22 and 2.6.23 */
139 int (*create) (struct sk_buff *skb, struct net_device *dev,
140 unsigned short type, void *daddr,
141 void *saddr, unsigned len);
142 int (*parse)(const struct sk_buff *skb, unsigned char *haddr);
143 int (*rebuild)(struct sk_buff *skb);
144 #define HAVE_HEADER_CACHE
145 int (*cache)(struct neighbour *neigh, struct hh_cache *hh);
146 void (*cache_update)(struct hh_cache *hh,
147 struct net_device *dev,
148 unsigned char *haddr);
151 /* net/ieee80211/ieee80211_crypt_tkip uses sg_init_table. This was added on
152 * 2.6.24. CONFIG_DEBUG_SG was added in 2.6.24 as well, so lets just ignore
153 * the debug stuff. Note that adding this required changes to the struct
154 * scatterlist on include/asm/scatterlist*, so the right way to port this
155 * is to simply ignore the new structure changes and zero the scatterlist
156 * array. We lave the kdoc intact for reference.
160 * sg_mark_end - Mark the end of the scatterlist
161 * @sg: SG entryScatterlist
164 * Marks the passed in sg entry as the termination point for the sg
165 * table. A call to sg_next() on this entry will return NULL.
168 static inline void sg_mark_end(struct scatterlist *sg)
173 * sg_init_table - Initialize SG table
175 * @nents: Number of entries in table
178 * If this is part of a chained sg table, sg_mark_end() should be
179 * used only on the last table part.
183 memset(sgl, 0, sizeof(*sgl) * nents);
187 * usb_endpoint_num - get the endpoint's number
188 * @epd: endpoint to be checked
190 * Returns @epd's number: 0 to 15.
192 static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
194 return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
197 /* Helper to make struct pci_dev is_pcie compatibility code smaller */
198 int compat_is_pcie(struct pci_dev *pdev);
200 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */
202 #endif /* LINUX_26_24_COMPAT_H */