Remove support for Linux kernels older than 2.6.13
[madwifi/.git] / net80211 / ieee80211_linux.h
index 47476c0fb1cc6875da8b7c27dbde0b27f0b2a371..4bb8dcd8eb44788c2f434620587687b9a30ce9e7 100644 (file)
 #ifndef _NET80211_IEEE80211_LINUX_H_
 #define _NET80211_IEEE80211_LINUX_H_
 
-#define        IEEE80211_DEBUG
-#define        IEEE80211_DEBUG_REFCNT                  /* Node reference count debugging */
-/* #define ATH_DEBUG_SPINLOCKS */              /* announce before spinlocking */
-
 #include <linux/wireless.h>
 #include <linux/fs.h>
 
@@ -149,7 +145,7 @@ typedef spinlock_t ieee80211com_lock_t;
 #define        IEEE80211_LOCK_CHECK(_ic) do { \
        if (spin_is_locked(&(_ic)->ic_comlock)) \
                printk("%s:%d - about to block on ieee80211com lock!\n", __func__, __LINE__); \
-} while(0)
+} while (0)
 #else /* #if (defined(ATH_DEBUG_SPINLOCKS)) */
 #define        IEEE80211_LOCK_CHECK(_ic)
 #endif 
@@ -178,7 +174,7 @@ typedef spinlock_t ieee80211com_lock_t;
 #define        IEEE80211_VAPS_LOCK_CHECK(_ic) do { \
        if (spin_is_locked(&(_ic)->ic_vapslock)) \
                printk("%s:%d - about to block on ieee80211com_vaps lock!\n", __func__, __LINE__); \
-} while(0)
+} while (0)
 #else /* #if (defined(ATH_DEBUG_SPINLOCKS)) */
 #define IEEE80211_VAPS_LOCK_CHECK(_ic)
 #endif /* #if (defined(ATH_DEBUG_SPINLOCKS)) */
@@ -204,6 +200,14 @@ typedef spinlock_t ieee80211_node_lock_t;
        IEEE80211_NODE_LOCK_ASSERT(_ni); \
        spin_unlock_irqrestore(&(_ni)->ni_nodelock, __node_lockflags); \
 } while (0)
+#define IEEE80211_NODE_LOCK_IRQ_INSIDE(_tq) do { \
+       IEEE80211_NODE_LOCK_CHECK(_ni);         \
+       spin_lock(&(_ni)->ni_nodelock);
+} while (0)
+#define IEEE80211_NODE_UNLOCK_IRQ_INSIDE(_tq) do { \
+       IEEE80211_NODE_LOCK_ASSERT(_ni); \
+       spin_unlock(&(_ni)->ni_nodelock); \
+}while (0)
 #define        IEEE80211_NODE_UNLOCK_IRQ_EARLY(_ni)            \
        IEEE80211_NODE_LOCK_ASSERT(_ni); \
        spin_unlock_irqrestore(&(_ni)->ni_nodelock, __node_lockflags);
@@ -216,7 +220,7 @@ typedef spinlock_t ieee80211_node_lock_t;
 #define        IEEE80211_NODE_LOCK_CHECK(_ni) do { \
        if (spin_is_locked(&(_ni)->ni_nodelock)) \
                printk("%s:%d - about to block on node lock!\n", __func__, __LINE__); \
-} while(0)
+} while (0)
 #else /* #if (defined(ATH_DEBUG_SPINLOCKS)) */
 #define        IEEE80211_NODE_LOCK_CHECK(_ni)
 #endif /* #if (defined(ATH_DEBUG_SPINLOCKS)) */
@@ -290,7 +294,7 @@ typedef spinlock_t acl_lock_t;
 #define        ACL_UNLOCK(_as)                         \
        ACL_LOCK_ASSERT(_as);                   \
        spin_unlock(&(_as)->as_lock);           \
-} while(0)
+} while (0)
 #define ACL_UNLOCK_EARLY(_as)                  \
        ACL_LOCK_ASSERT(_as);                   \
        spin_unlock(&(_as)->as_lock);
@@ -302,7 +306,7 @@ typedef spinlock_t acl_lock_t;
 #define        ACL_LOCK_CHECK(_as) do { \
        if (spin_is_locked(&(_as)->as_lock)) \
                printk("%s:%d - about to block on ACL lock!\n", __func__, __LINE__); \
-} while(0)
+} while (0)
 #else /* #if (defined(ATH_DEBUG_SPINLOCKS)) */
 #define        ACL_LOCK_CHECK(_as)
 #endif /* #if (defined(ATH_DEBUG_SPINLOCKS)) */
@@ -311,11 +315,6 @@ typedef spinlock_t acl_lock_t;
 #define        ACL_LOCK_CHECK(_as)
 #endif
 
-/* __skb_append got a third parameter in 2.6.14 */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)
-#define __skb_append(a,b,c)    __skb_append(a, b)
-#endif
-
 /*
  * Per-node power-save queue definitions.  Beware of control
  * flow with IEEE80211_NODE_SAVEQ_LOCK/IEEE80211_NODE_SAVEQ_UNLOCK.
@@ -333,6 +332,14 @@ typedef spinlock_t acl_lock_t;
        IEEE80211_NODE_SAVEQ_LOCK_ASSERT(_ni);                  \
        spin_unlock_irqrestore(&(_ni)->ni_savedq.lock, __qlockflags); \
 } while (0)
+#define IEEE80211_NODE_SAVEQ_LOCK_IRQ_INSIDE(_ni)   do {       \
+       IEEE80211_NODE_SAVEQ_LOCK_CHECK(_ni);                   \
+       spin_lock(&(_ni)->ni_savedq.lock);                      \
+} while (0)
+#define IEEE80211_NODE_SAVEQ_UNLOCK_IRQ_INSIDE(_ni) do {       \
+       IEEE80211_NODE_SAVEQ_LOCK_ASSERT(_ni);                  \
+       spin_unlock(&(_ni)->ni_savedq.lock);                    \
+} while (0)
 #define        IEEE80211_NODE_SAVEQ_UNLOCK_IRQ_EARLY(_ni)              \
        IEEE80211_NODE_SAVEQ_LOCK_ASSERT(_ni);                  \
        spin_unlock_irqrestore(&(_ni)->ni_savedq.lock, __qlockflags);
@@ -345,7 +352,7 @@ typedef spinlock_t acl_lock_t;
 #define IEEE80211_NODE_SAVEQ_LOCK_CHECK(_ni) do { \
        if (spin_is_locked(&(_ni)->ni_savedq.lock)) \
                printk("%s:%d - about to block on node saveq lock!\n", __func__, __LINE__); \
-} while(0)
+} while (0)
 #else /* #if (defined(ATH_DEBUG_SPINLOCKS)) */
 #define IEEE80211_NODE_SAVEQ_LOCK_CHECK(_ni)
 #endif /* #if (defined(ATH_DEBUG_SPINLOCKS)) */
@@ -355,20 +362,20 @@ typedef spinlock_t acl_lock_t;
 #endif
 
 /* caller MUST lock IEEE80211_NODE_SAVEQ */
-#define        IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _skb, _qlen) do {     \
+#define        IEEE80211_NODE_SAVEQ_DEQUEUE(_ni, _skb) ({              \
        _skb = __skb_dequeue(&(_ni)->ni_savedq);                \
-       (_qlen) = skb_queue_len(&(_ni)->ni_savedq);             \
-} while (0)
-#define        _IEEE80211_NODE_SAVEQ_ENQUEUE(_ni, _skb, _qlen, _age) do {\
-       struct sk_buff *tail = skb_peek_tail(&(_ni)->ni_savedq);\
-       if (tail != NULL) {                                     \
-               _age -= M_AGE_GET(tail);                        \
-               __skb_append(tail, _skb, &(_ni)->ni_savedq);    \
-       } else {                                                \
-               __skb_queue_head(&(_ni)->ni_savedq, _skb);      \
-       }                                                       \
-       M_AGE_SET(_skb, _age);                                  \
-       (_qlen) = skb_queue_len(&(_ni)->ni_savedq);             \
+       skb_queue_len(&(_ni)->ni_savedq);                       \
+})
+#define        _IEEE80211_NODE_SAVEQ_ENQUEUE(_ni, _skb, _qlen, _age) do {      \
+       struct sk_buff *tail = skb_peek_tail(&(_ni)->ni_savedq);        \
+       if (tail != NULL) {                                             \
+               _age -= M_AGE_GET(tail);                                \
+               __skb_queue_after(&(_ni)->ni_savedq, tail, _skb);       \
+       } else {                                                        \
+               __skb_queue_head(&(_ni)->ni_savedq, _skb);              \
+       }                                                               \
+       M_AGE_SET(_skb, _age);                                          \
+       (_qlen) = skb_queue_len(&(_ni)->ni_savedq);                     \
 } while (0)
 
 /*
@@ -381,8 +388,18 @@ typedef spinlock_t acl_lock_t;
  * NB: sizeof(cb) == 48 and the vlan code grabs the first
  *     8 bytes so we reserve/avoid it.
  */
+
+struct ieee80211_phy_params {
+       u_int8_t rate[4];
+       u_int8_t try[4];
+
+       u_int8_t power;
+       u_int32_t flags;
+};
+
 struct ieee80211_cb {
-       u_int8_t vlan[8];                       /* reserve for vlan tag info */
+       u_int8_t __reserved_vlan[8];            /* reserve for vlan tag info */
+       struct ieee80211_phy_params phy;
        struct ieee80211_node *ni;
        u_int32_t flags;
 #define        M_LINK0         0x01                    /* frame needs WEP encryption */
@@ -391,42 +408,14 @@ struct ieee80211_cb {
 #define M_UAPSD                0x08                    /* frame flagged for u-apsd handling */
 #define M_RAW           0x10
 #ifdef IEEE80211_DEBUG_REFCNT
-       int tracked;
+#define M_SKB_TRACKED  0x20
+       void            (*next_destructor)(struct sk_buff *skb);
 #endif
-       struct sk_buff *next;                   /* fast frame sk_buf chain */
 };
 
-
-#define        SKB_CB(_skb)            ((struct ieee80211_cb *)(_skb)->cb)
-
-#define M_FLAG_SET(_skb, _flag) \
-       (SKB_CB(_skb)->flags |= (_flag))
-#define        M_FLAG_CLR(_skb, _flag) \
-       (SKB_CB(_skb)->flags &= ~(_flag))
-#define        M_FLAG_GET(_skb, _flag) \
-       (SKB_CB(_skb)->flags & (_flag))
-#define M_FLAG_KEEP_ONLY(_skb, _flag) \
-       (SKB_CB(_skb)->flags &= (_flag))
-
-#define        M_PWR_SAV_SET(skb) M_FLAG_SET((skb), M_PWR_SAV)
-#define        M_PWR_SAV_CLR(skb) M_FLAG_CLR((skb), M_PWR_SAV)
-#define        M_PWR_SAV_GET(skb) M_FLAG_GET((skb), M_PWR_SAV)
-
-/*
- * Skbufs on the power save queue are tagged with an age and
- * timed out.  We reuse the hardware checksum field in the
- * mbuf packet header to store this data.
- * XXX use private cb area
- */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
-#define skb_age csum_offset
-#else
-#define skb_age csum
-#endif
-
-#define        M_AGE_SET(skb,v)        (skb->skb_age = v)
-#define        M_AGE_GET(skb)          (skb->skb_age)
-#define        M_AGE_SUB(skb,adj)      (skb->skb_age -= adj)
+struct __assert {
+       int __ieee80211_cb_size[sizeof(struct ieee80211_cb) <= 48 ? 0 : -1];
+};
 
 struct ieee80211com;
 struct ieee80211vap;
@@ -471,7 +460,6 @@ ieee80211_malloc(size_t size, int flags)
 #define printf(...) printk(__VA_ARGS__)
 struct ieee80211com;
 extern void if_printf(struct net_device *, const char *, ...);
-extern const char *ether_sprintf(const u_int8_t *);
 
 /*
  * Queue write-arounds and support routines.
@@ -480,7 +468,7 @@ extern const char *ether_sprintf(const u_int8_t *);
 #define ieee80211_getmgtframe(_ppfrm, _pktlen) \
        ieee80211_getmgtframe_debug(_ppfrm, _pktlen, __func__, __LINE__)
 extern struct sk_buff * ieee80211_getmgtframe_debug(u_int8_t **frm, u_int pktlen, 
-                                                   const charfunc, int line);
+                                                   const char *func, int line);
 #else
 extern struct sk_buff * ieee80211_getmgtframe(u_int8_t **frm, u_int pktlen);
 #endif
@@ -504,60 +492,7 @@ extern     void skb_queue_drain(struct sk_buff_head *q);
 #define        _MOD_DEC_USE(_m)        MOD_DEC_USE_COUNT
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-static __inline u_int64_t
-get_jiffies_64(void)
-{
-       return (u_int64_t) jiffies;             /* XXX not right */
-}
-#endif
-
-/* msecs_to_jiffies appeared in 2.6.7 and 2.4.29 */
-#include <linux/delay.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && \
-        LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) || \
-       LINUX_VERSION_CODE < KERNEL_VERSION(2,4,29)
-
-/* The following definitions and inline functions are
- * copied from the kernel src, include/linux/jiffies.h */
-
-#ifndef MSEC_PER_SEC
-#define MSEC_PER_SEC (1000L)
-#endif
-
-#ifndef MAX_JIFFY_OFFSET
-#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
-#endif
-
-static __inline unsigned int jiffies_to_msecs(const unsigned long j)
-{
-#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
-       return (MSEC_PER_SEC / HZ) * j;
-#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
-       return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
-#else
-       return (j * MSEC_PER_SEC) / HZ;
-#endif
-}
-
-static __inline unsigned long msecs_to_jiffies(const unsigned int m)
-{
-       if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
-               return MAX_JIFFY_OFFSET;
-#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
-       return (m + (MSEC_PER_SEC / HZ) - 1) / (MSEC_PER_SEC / HZ);
-#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
-       return m * (HZ / MSEC_PER_SEC);
-#else
-       return (m * HZ + MSEC_PER_SEC - 1) / MSEC_PER_SEC;
-#endif
-}
-
-#endif
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,7)
 #include <linux/jiffies.h>
-#endif
 
 #ifndef CLONE_KERNEL
 /*
@@ -601,18 +536,18 @@ static __inline unsigned long msecs_to_jiffies(const unsigned int m)
 /*
  * Deal with the sysctl handler api changing.
  */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,8)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
 #define        IEEE80211_SYSCTL_DECL(f, ctl, write, filp, buffer, lenp, ppos) \
        f(ctl_table *ctl, int write, struct file *filp, \
-         void __user *buffer, size_t *lenp)
+         void __user *buffer, size_t *lenp, loff_t *ppos)
 #define        IEEE80211_SYSCTL_PROC_DOINTVEC(ctl, write, filp, buffer, lenp, ppos) \
-       proc_dointvec(ctl, write, filp, buffer, lenp)
-#else
+       proc_dointvec(ctl, write, filp, buffer, lenp, ppos)
+#else /* Linux 2.6.32+ */
 #define        IEEE80211_SYSCTL_DECL(f, ctl, write, filp, buffer, lenp, ppos) \
-       f(ctl_table *ctl, int write, struct file *filp, \
+       f(ctl_table *ctl, int write, \
          void __user *buffer, size_t *lenp, loff_t *ppos)
 #define        IEEE80211_SYSCTL_PROC_DOINTVEC(ctl, write, filp, buffer, lenp, ppos) \
-       proc_dointvec(ctl, write, filp, buffer, lenp, ppos)
+       proc_dointvec(ctl, write, buffer, lenp, ppos)
 #endif
 
 void ieee80211_virtfs_latevattach(struct ieee80211vap *);
@@ -621,13 +556,10 @@ int ieee80211_proc_vcreate(struct ieee80211vap *, struct file_operations *,
               char *);
 void ieee80211_proc_cleanup(struct ieee80211vap *);
 
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0) && \
+    (defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE))
 #define IEEE80211_VLAN_TAG_USED 1
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20)
-#define        vlan_hwaccel_receive_skb(skb, grp, tag) vlan_hwaccel_rx(skb, grp, tag)
-#endif
-
 #ifndef VLAN_GROUP_ARRAY_PART_LEN
 #define vlan_group_set_device(group, vid, dev) do { \
        group->vlan_devices[vid] = dev; \
@@ -639,11 +571,7 @@ void ieee80211_proc_cleanup(struct ieee80211vap *);
 #endif
 void ieee80211_vlan_vattach(struct ieee80211vap *);
 void ieee80211_vlan_vdetach(struct ieee80211vap *);
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-#define        free_netdev(dev)        kfree(dev)
-#endif
-
+int ieee80211_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
 void ieee80211_ioctl_vattach(struct ieee80211vap *);
 void ieee80211_ioctl_vdetach(struct ieee80211vap *);
 struct ifreq;
@@ -651,4 +579,11 @@ int ieee80211_ioctl_create_vap(struct ieee80211com *, struct ifreq *,
        struct net_device *);
 struct ieee80211vap *ieee80211_create_vap(struct ieee80211com *, char *,
        struct net_device *, int, int);
+
+#if IEEE80211_VLAN_TAG_USED
+void ieee80211_vlan_register(struct net_device *dev, struct vlan_group *grp);
+void ieee80211_vlan_add_vid(struct net_device *dev, unsigned short vid);
+void ieee80211_vlan_kill_vid(struct net_device *dev, unsigned short vid);
+#endif
+
 #endif /* _NET80211_IEEE80211_LINUX_H_ */