📄 ieee80211_linux.h.svn-base
字号:
/*- * Copyright (c) 2003-2005 Sam Leffler, Errno Consulting * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $Id$ */#ifndef _NET80211_IEEE80211_LINUX_H_#define _NET80211_IEEE80211_LINUX_H_#include <linux/wireless.h>#include <linux/fs.h>/* * Compatibility definition of statistics flags * (bitmask in (struct iw_quality *)->updated) */#ifndef IW_QUAL_QUAL_UPDATED#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */#define IW_QUAL_LEVEL_UPDATED 0x02#define IW_QUAL_NOISE_UPDATED 0x04#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */#define IW_QUAL_LEVEL_INVALID 0x20#define IW_QUAL_NOISE_INVALID 0x40#endif /* IW_QUAL_QUAL_UPDATED */#ifndef IW_QUAL_ALL_UPDATED#define IW_QUAL_ALL_UPDATED \ (IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_UPDATED)#endif#ifndef IW_QUAL_ALL_INVALID#define IW_QUAL_ALL_INVALID \ (IW_QUAL_QUAL_INVALID | IW_QUAL_LEVEL_INVALID | IW_QUAL_NOISE_INVALID)#endif/* * The RSSI values reported in the TX/RX descriptors in the driver are the SNR * expressed in dBm. Thus 'rssi' is signal level above the noise floor in dBm. * * Noise is measured in dBm and is negative unless there is an unimaginable * level of RF noise. * * The signal level is noise + rssi. * * Note that the iw_quality values are 1 byte, and can be signed, unsigned or * negative depending on context. * */static __inline voidset_quality(struct iw_quality *iq, u_int rssi, int noise){ iq->qual = rssi; iq->noise = noise; iq->level = ((((int)rssi + noise) <= 0) ? ((int)rssi + noise) : 0); iq->updated = IW_QUAL_ALL_UPDATED;#if WIRELESS_EXT >= 19 iq->updated |= IW_QUAL_DBM;#endif}/* * Task deferral * * Deduce if tasklets are available. If not then * fall back to using the immediate work queue. */#include <linux/interrupt.h>#ifdef DECLARE_TASKLET /* native tasklets */#define IEEE80211_TQ_STRUCT tasklet_struct#define IEEE80211_INIT_TQUEUE(a,b,c) tasklet_init((a), (b), (unsigned long)(c))#define IEEE80211_SCHEDULE_TQUEUE(a) tasklet_schedule((a))#define IEEE80211_CANCEL_TQUEUE(a) if (!in_interrupt()) tasklet_kill((a))typedef unsigned long IEEE80211_TQUEUE_ARG;#define mark_bh(a) do {} while (0)#else /* immediate work queue */#define IEEE80211_TQ_STRUCT tq_struct#define IEEE80211_INIT_TQUEUE(a,b,c) INIT_TQUEUE(a,b,c)#define IEEE80211_SCHEDULE_TQUEUE(a) do { \ int __macro_needmark; \ __macro_needmark |= queue_task((a), &tq_immediate); \ if (__macro_needmark) \ mark_bh(IMMEDIATE_BH); \} while (0)typedef void *IEEE80211_TQUEUE_ARG;#define tasklet_disable(t) do { (void) t; local_bh_disable(); } while (0)#define tasklet_enable(t) do { (void) t; local_bh_enable(); } while (0)/* XXX: not supporting cancel in old kernels! */#define IEEE80211_CANCEL_TQUEUE(a) ((a), 0)#endif /* !DECLARE_TASKLET */#define IEEE80211_RESCHEDULE schedule/* Locking *//* NB: beware, spin_is_locked() is not usefully defined for !(DEBUG || SMP) * because spinlocks do not exist in this configuration. Instead IRQs * or pre-emption are simply disabled, as this is all that is needed. *//* * Beacon handler locking definitions. * Beacon locking * UAPSD locking */typedef spinlock_t ieee80211com_lock_t;#define IEEE80211_LOCK_INIT(_ic, _name) \ spin_lock_init(&(_ic)->ic_comlock)#define IEEE80211_LOCK_DESTROY(_ic)#define IEEE80211_LOCK_IRQ(_ic) do { \ unsigned long __ilockflags; \ IEEE80211_LOCK_CHECK(_ic); \ spin_lock_irqsave(&(_ic)->ic_comlock, __ilockflags);#define IEEE80211_UNLOCK_IRQ(_ic) \ IEEE80211_LOCK_ASSERT(_ic); \ spin_unlock_irqrestore(&(_ic)->ic_comlock, __ilockflags); \} while (0)#define IEEE80211_UNLOCK_IRQ_EARLY(_ic) \ IEEE80211_LOCK_ASSERT(_ic); \ spin_unlock_irqrestore(&(_ic)->ic_comlock, __ilockflags);#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)#define IEEE80211_LOCK_ASSERT(_ic) \ KASSERT(spin_is_locked(&(_ic)->ic_comlock), ("ieee80211com not locked!"))#if (defined(ATH_DEBUG_SPINLOCKS))#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)#else /* #if (defined(ATH_DEBUG_SPINLOCKS)) */#define IEEE80211_LOCK_CHECK(_ic)#endif #else#define IEEE80211_LOCK_ASSERT(_ic)#define IEEE80211_LOCK_CHECK(_ic)#endif#define IEEE80211_VAPS_LOCK_INIT(_ic, _name) \ spin_lock_init(&(_ic)->ic_vapslock)#define IEEE80211_VAPS_LOCK_DESTROY(_ic)#define IEEE80211_VAPS_LOCK_BH(_ic) do { \ IEEE80211_VAPS_LOCK_CHECK(_ic); \ spin_lock_bh(&(_ic)->ic_vapslock);#define IEEE80211_VAPS_UNLOCK_BH(_ic) \ IEEE80211_VAPS_LOCK_ASSERT(_ic); \ spin_unlock_bh(&(_ic)->ic_vapslock); \} while (0)#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)#define IEEE80211_VAPS_LOCK_ASSERT(_ic) \ KASSERT(spin_is_locked(&(_ic)->ic_vapslock), \ ("ieee80211com_vaps not locked!"))#if (defined(ATH_DEBUG_SPINLOCKS))#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)#else /* #if (defined(ATH_DEBUG_SPINLOCKS)) */#define IEEE80211_VAPS_LOCK_CHECK(_ic)#endif /* #if (defined(ATH_DEBUG_SPINLOCKS)) */#else#define IEEE80211_VAPS_LOCK_ASSERT(_ic)#define IEEE80211_VAPS_LOCK_CHECK(_ic)#endif/* * Node locking definitions. */#if 0typedef spinlock_t ieee80211_node_lock_t;#define IEEE80211_NODE_LOCK_INIT(_ni, _name) spin_lock_init(&(_ni)->ni_nodelock)#define IEEE80211_NODE_LOCK_DESTROY(_ni)#define IEEE80211_NODE_LOCK_IRQ(_ni) do { \ unsigned long __node_lockflags; \ IEEE80211_NODE_LOCK_CHECK(_ni); \ spin_lock_irqsave(&(_ni)->ni_nodelock, __node_lockflags);#define IEEE80211_NODE_UNLOCK_IRQ(_ni) \ 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);#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)#define IEEE80211_NODE_LOCK_ASSERT(_ni) \ KASSERT(spin_is_locked(&(_ni)->ni_nodelock), \ ("802.11 node not locked!"))#if (defined(ATH_DEBUG_SPINLOCKS))#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)#else /* #if (defined(ATH_DEBUG_SPINLOCKS)) */#define IEEE80211_NODE_LOCK_CHECK(_ni)#endif /* #if (defined(ATH_DEBUG_SPINLOCKS)) */#else#define IEEE80211_NODE_LOCK_ASSERT(_ni)#define IEEE80211_NODE_LOCK_CHECK(_ni)#endif#endif /* node lock *//* * Node table locking definitions. */typedef spinlock_t ieee80211_node_table_lock_t;#define IEEE80211_NODE_TABLE_LOCK_INIT(_nt, _name) spin_lock_init(&(_nt)->nt_nodelock)#define IEEE80211_NODE_TABLE_LOCK_DESTROY(_nt)#if 0 /* We should always be contesting in the same contexts */#define IEEE80211_NODE_TABLE_LOCK(_nt) spin_lock(&(_nt)->nt_nodelock)#define IEEE80211_NODE_TABLE_UNLOCK(_nt) spin_unlock(&(_nt)->nt_nodelock)#define IEEE80211_NODE_TABLE_LOCK_BH(_nt) spin_lock_bh(&(_nt)->nt_nodelock)#define IEEE80211_NODE_TABLE_UNLOCK_BH(_nt) spin_unlock_bh(&(_nt)->nt_nodelock)#endif#define IEEE80211_NODE_TABLE_LOCK_IRQ(_nt) do { \ unsigned long __node_lockflags; \ spin_lock_irqsave(&(_nt)->nt_nodelock, __node_lockflags);#define IEEE80211_NODE_TABLE_UNLOCK_IRQ(_nt) \ spin_unlock_irqrestore(&(_nt)->nt_nodelock, __node_lockflags); \} while (0)#define IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(_nt) \ spin_unlock_irqrestore(&(_nt)->nt_nodelock, __node_lockflags);#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)#define IEEE80211_NODE_TABLE_LOCK_ASSERT(_nt) \ KASSERT(spin_is_locked(&(_nt)->nt_nodelock), \ ("802.11 node table not locked!"))#else#define IEEE80211_NODE_TABLE_LOCK_ASSERT(_nt)#endif/* * Node table scangen locking definitions. */typedef spinlock_t ieee80211_scan_lock_t;#define IEEE80211_SCAN_LOCK_INIT(_nt, _name) spin_lock_init(&(_nt)->nt_scanlock)#define IEEE80211_SCAN_LOCK_DESTROY(_nt)#define IEEE80211_SCAN_LOCK_IRQ(_nt) do { \ unsigned long __scan_lockflags; \ spin_lock_irqsave(&(_nt)->nt_scanlock, __scan_lockflags);#define IEEE80211_SCAN_UNLOCK_IRQ(_nt) \ spin_unlock_irqrestore(&(_nt)->nt_scanlock, __scan_lockflags); \} while (0)#define IEEE80211_SCAN_UNLOCK_IRQ_EARLY(_nt) \ spin_unlock_irqrestore(&(_nt)->nt_scanlock, __scan_lockflags);#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)#define IEEE80211_SCAN_LOCK_ASSERT(_nt) \ KASSERT(spin_is_locked(&(_nt)->nt_scanlock), ("scangen not locked!"))#else#define IEEE80211_SCAN_LOCK_ASSERT(_nt)#endif/* * 802.1x MAC ACL database locking definitions. */typedef spinlock_t acl_lock_t;#define ACL_LOCK_INIT(_as, _name) spin_lock_init(&(_as)->as_lock)#define ACL_LOCK_DESTROY(_as)#define ACL_LOCK(_as) do { \ ACL_LOCK_CHECK(_as); \ spin_lock(&(_as)->as_lock);#define ACL_UNLOCK(_as) \ ACL_LOCK_ASSERT(_as); \ spin_unlock(&(_as)->as_lock); \} while (0)#define ACL_UNLOCK_EARLY(_as) \ ACL_LOCK_ASSERT(_as); \ spin_unlock(&(_as)->as_lock);#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked)#define ACL_LOCK_ASSERT(_as) \ KASSERT(spin_is_locked(&(_as)->as_lock), ("ACL not locked!"))#if (defined(ATH_DEBUG_SPINLOCKS))#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)#else /* #if (defined(ATH_DEBUG_SPINLOCKS)) */#define ACL_LOCK_CHECK(_as)#endif /* #if (defined(ATH_DEBUG_SPINLOCKS)) */#else#define ACL_LOCK_ASSERT(_as)#define ACL_LOCK_CHECK(_as)#endif/* * Per-node power-save queue definitions. Beware of control * flow with IEEE80211_NODE_SAVEQ_LOCK/IEEE80211_NODE_SAVEQ_UNLOCK.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -