Ticket #907: madwifi-refcnt.11.diff

File madwifi-refcnt.11.diff, 91.2 kB (added by mike.taylor@apprion.com, 5 years ago)

Same as 10, but adds ieee80211_debug.h which was missing in the previous patch.

  • svn.madwifi.org-trunk-2115/ath/if_ath.c

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: if_ath.c 2104 2007-02-13 05:54:52Z proski
     36 * $Id: if_ath.c 2064 2007-02-01 20:49:37Z mentor
    3737 */ 
    3838 
    3939/* 
     
    159159static int ath_desc_alloc(struct ath_softc *); 
    160160static void ath_desc_free(struct ath_softc *); 
    161161static void ath_desc_swap(struct ath_desc *); 
    162 static struct ieee80211_node *ath_node_alloc(struct ieee80211_node_table *, 
    163         struct ieee80211vap *); 
     162static struct ieee80211_node *ath_node_alloc(struct ieee80211vap *); 
    164163static void ath_node_cleanup(struct ieee80211_node *); 
    165164static void ath_node_free(struct ieee80211_node *); 
    166165static u_int8_t ath_node_getrssi(const struct ieee80211_node *); 
     
    432431         * built with an ah.h that does not correspond to the HAL 
    433432         * module loaded in the kernel. 
    434433         */ 
    435         ah = _ath_hal_attach(devid, sc, tag, sc->sc_iobase, &status); 
     434        ah = _ath_hal_attach(devid, sc, tag, 
     435                             (__force HAL_BUS_HANDLE) sc->sc_iobase, 
     436                             &status); 
    436437        if (ah == NULL) { 
    437438                printk(KERN_ERR "%s: unable to attach hardware: '%s' (HAL status %u)\n", 
    438439                        dev->name, ath_get_hal_status_desc(status), status); 
     
    24512452                if (ath_tx_start(sc->sc_dev, ni, bf_ff, bf_ff->bf_skb, 0) == 0) 
    24522453                        continue; 
    24532454        bad: 
    2454                 ieee80211_free_node(ni); 
     2455                ieee80211_unref_node(&ni); 
    24552456                if (bf_ff->bf_skb != NULL) { 
    24562457                        dev_kfree_skb(bf_ff->bf_skb); 
    24572458                        bf_ff->bf_skb = NULL; 
     
    25922593                        ATH_FF_MAGIC_PUT(skb); 
    25932594 
    25942595                        /* decrement extra node reference made when an_tx_ffbuf[] was set */ 
    2595                         //ieee80211_free_node(ni); /* XXX where was it set ? */ 
     2596                        //ieee80211_unref_node(&ni); /* XXX where was it set ? */ 
    25962597 
    25972598                        DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 
    25982599                                "%s: aggregating fast-frame\n", __func__); 
     
    26512652                ff_flushbad: 
    26522653                        DPRINTF(sc, ATH_DEBUG_XMIT | ATH_DEBUG_FF, 
    26532654                                "%s: ff stageq flush failure\n", __func__); 
    2654                         ieee80211_free_node(ni); 
     2655                        ieee80211_unref_node(&ni); 
    26552656                        if (bf_ff->bf_skb) { 
    26562657                                dev_kfree_skb(bf_ff->bf_skb); 
    26572658                                bf_ff->bf_skb = NULL; 
     
    27762777                        tbf->bf_node = NULL; 
    27772778                         
    27782779                        if (ni != NULL)  
    2779                                 ieee80211_free_node(ni); 
     2780                                ieee80211_unref_node(&ni); 
    27802781 
    27812782                        STAILQ_INSERT_TAIL(&sc->sc_txbuf, tbf, bf_list); 
    27822783                } 
     
    28582859        /* fall thru... */ 
    28592860bad: 
    28602861        if (ni != NULL) 
    2861                 ieee80211_free_node(ni); 
     2862                ieee80211_unref_node(&ni); 
    28622863        if (bf != NULL) { 
    28632864                bf->bf_skb = NULL; 
    28642865                bf->bf_node = NULL; 
     
    32443245         */ 
    32453246        ni = sc->sc_keyixmap[keyix]; 
    32463247        if (ni != NULL) { 
    3247                 ieee80211_free_node(ni); 
     3248                ieee80211_unref_node(&ni); 
    32483249                sc->sc_keyixmap[keyix] = NULL; 
    32493250        } 
    32503251        /* 
     
    32553256                ath_hal_keyreset(ah, keyix + 32);       /* RX key */ 
    32563257                ni = sc->sc_keyixmap[keyix + 32]; 
    32573258                if (ni != NULL) {                       /* as above... */ 
    3258                         ieee80211_free_node(ni); 
     3259                        ieee80211_unref_node(&ni); 
    32593260                        sc->sc_keyixmap[keyix + 32] = NULL; 
    32603261                } 
    32613262        } 
     
    32683269                        ath_hal_keyreset(ah, keyix + rxkeyoff); 
    32693270                        ni = sc->sc_keyixmap[keyix + rxkeyoff]; 
    32703271                        if (ni != NULL) {       /* as above... */ 
    3271                                 ieee80211_free_node(ni); 
     3272                                ieee80211_unref_node(&ni); 
    32723273                                sc->sc_keyixmap[keyix + rxkeyoff] = NULL; 
    32733274                        } 
    32743275                } 
     
    38243825                dev_kfree_skb(bf->bf_skb); 
    38253826                bf->bf_skb = NULL; 
    38263827        } 
    3827         if (bf->bf_node != NULL) { 
    3828                 ieee80211_free_node(bf->bf_node); 
    3829                 bf->bf_node = NULL; 
    3830         } 
     3828        if (bf->bf_node != NULL) 
     3829                ieee80211_unref_node(&bf->bf_node); 
    38313830 
    38323831        /* 
    38333832         * NB: the beacon data buffer must be 32-bit aligned; 
     
    43714370                dev_kfree_skb(bf->bf_skb); 
    43724371                bf->bf_skb = NULL; 
    43734372        } 
    4374         if (bf->bf_node != NULL) { 
    4375                 ieee80211_free_node(bf->bf_node); 
    4376                 bf->bf_node = NULL; 
    4377         } 
     4373        if (bf->bf_node != NULL)  
     4374                ieee80211_unref_node(&bf->bf_node); 
    43784375        STAILQ_INSERT_TAIL(&sc->sc_bbuf, bf, bf_list); 
    43794376} 
    43804377 
     
    43934390                        dev_kfree_skb(bf->bf_skb); 
    43944391                        bf->bf_skb = NULL; 
    43954392                } 
    4396                 if (bf->bf_node != NULL) { 
    4397                         ieee80211_free_node(bf->bf_node); 
    4398                         bf->bf_node = NULL; 
    4399                 } 
     4393                if (bf->bf_node != NULL) 
     4394                        ieee80211_unref_node(&bf->bf_node); 
    44004395        } 
    44014396} 
    44024397 
     
    46814676                        /* 
    46824677                         * Reclaim node reference. 
    46834678                         */ 
    4684                         ieee80211_free_node(ni); 
     4679                        ieee80211_unref_node(&ni); 
    46854680                } 
    46864681        } 
    46874682 
     
    47404735} 
    47414736 
    47424737static struct ieee80211_node * 
    4743 ath_node_alloc(struct ieee80211_node_table *nt,struct ieee80211vap *vap) 
     4738ath_node_alloc(struct ieee80211vap *vap) 
    47444739{ 
    4745         struct ath_softc *sc = nt->nt_ic->ic_dev->priv; 
     4740        struct ath_softc *sc = vap->iv_ic->ic_dev->priv; 
    47464741        const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; 
    47474742        struct ath_node *an; 
    47484743 
    47494744        an = kmalloc(space, GFP_ATOMIC); 
    4750         if (an == NULL) 
    4751                 return NULL; 
    4752         memset(an, 0, space); 
    4753         an->an_decomp_index = INVALID_DECOMP_INDEX; 
    4754         an->an_avgrssi = ATH_RSSI_DUMMY_MARKER; 
    4755         an->an_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; 
    4756         an->an_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; 
    4757         an->an_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; 
    4758         /* 
    4759          * ath_rate_node_init needs a VAP pointer in node 
    4760          * to decide which mgt rate to use 
    4761          */ 
    4762         an->an_node.ni_vap = vap; 
    4763         sc->sc_rc->ops->node_init(sc, an); 
    4764  
    4765         /* U-APSD init */ 
    4766         STAILQ_INIT(&an->an_uapsd_q); 
    4767         an->an_uapsd_qdepth = 0; 
    4768         STAILQ_INIT(&an->an_uapsd_overflowq); 
    4769         an->an_uapsd_overflowqdepth = 0; 
    4770         ATH_NODE_UAPSD_LOCK_INIT(an); 
     4745        if (an != NULL) { 
     4746                memset(an, 0, space); 
     4747                an->an_decomp_index = INVALID_DECOMP_INDEX; 
     4748                an->an_avgrssi = ATH_RSSI_DUMMY_MARKER; 
     4749                an->an_halstats.ns_avgbrssi = ATH_RSSI_DUMMY_MARKER; 
     4750                an->an_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; 
     4751                an->an_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; 
     4752                /* 
     4753                 * ath_rate_node_init needs a vap pointer in node 
     4754                 * to decide which mgt rate to use 
     4755                 */ 
     4756                an->an_node.ni_vap = vap; 
     4757                sc->sc_rc->ops->node_init(sc, an); 
    47714758 
    4772         DPRINTF(sc, ATH_DEBUG_NODE, "%s: an %p\n", __func__, an); 
    4773         return &an->an_node; 
     4759                /* U-APSD init */ 
     4760                STAILQ_INIT(&an->an_uapsd_q); 
     4761                an->an_uapsd_qdepth = 0; 
     4762                STAILQ_INIT(&an->an_uapsd_overflowq); 
     4763                an->an_uapsd_overflowqdepth = 0; 
     4764                ATH_NODE_UAPSD_LOCK_INIT(an); 
     4765                 
     4766                DPRINTF(sc, ATH_DEBUG_NODE, "%s: an %p\n", __func__, an); 
     4767                return &an->an_node; 
     4768        } else { 
     4769                return NULL; 
     4770        } 
    47744771} 
    47754772 
    47764773static void 
     
    47804777        struct ath_softc *sc = ni->ni_ic->ic_dev->priv; 
    47814778        struct ath_node *an = ATH_NODE(ni); 
    47824779        struct ath_buf *bf; 
     4780        struct ieee80211_cb *cb = NULL; 
    47834781         
    47844782        /* 
    47854783         * U-APSD cleanup 
     
    47944792        while (an->an_uapsd_qdepth) { 
    47954793                bf = STAILQ_FIRST(&an->an_uapsd_q); 
    47964794                STAILQ_REMOVE_HEAD(&an->an_uapsd_q, bf_list); 
    4797                 bf->bf_desc->ds_link = (u_int32_t)NULL; 
    47984795 
     4796                cb = (struct ieee80211_cb *) bf->bf_skb->cb; 
     4797                ieee80211_unref_node(&cb->ni); 
    47994798                dev_kfree_skb_any(bf->bf_skb); 
     4799 
     4800                bf->bf_desc->ds_link = 0; 
    48004801                bf->bf_skb = NULL; 
    48014802                bf->bf_node = NULL; 
     4803 
    48024804                ATH_TXBUF_LOCK_IRQ(sc); 
    48034805                STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 
    48044806                ATH_TXBUF_UNLOCK_IRQ(sc); 
    4805                 ieee80211_free_node(ni); 
    48064807 
    48074808                an->an_uapsd_qdepth--; 
    48084809        } 
     
    48104811        while (an->an_uapsd_overflowqdepth) { 
    48114812                bf = STAILQ_FIRST(&an->an_uapsd_overflowq); 
    48124813                STAILQ_REMOVE_HEAD(&an->an_uapsd_overflowq, bf_list); 
    4813                 bf->bf_desc->ds_link = (u_int32_t)NULL; 
    48144814 
     4815                cb = (struct ieee80211_cb *) bf->bf_skb->cb; 
     4816                ieee80211_unref_node(&cb->ni); 
    48154817                dev_kfree_skb_any(bf->bf_skb); 
     4818 
    48164819                bf->bf_skb = NULL; 
    48174820                bf->bf_node = NULL; 
     4821                bf->bf_desc->ds_link = 0; 
     4822                 
    48184823                ATH_TXBUF_LOCK_IRQ(sc); 
    48194824                STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 
    48204825                ATH_TXBUF_UNLOCK_IRQ(sc); 
    4821                 ieee80211_free_node(ni); 
    48224826 
    48234827                an->an_uapsd_overflowqdepth--; 
    48244828        } 
    48254829 
     4830        // Clean up node-specific rate things - this currently appears to always be a no-op 
     4831        sc->sc_rc->ops->node_cleanup(sc, ATH_NODE(ni)); 
     4832 
    48264833        ATH_NODE_UAPSD_LOCK_IRQ(an); 
    48274834        sc->sc_node_cleanup(ni); 
    48284835        ATH_NODE_UAPSD_UNLOCK_IRQ(an); 
     
    48334840{ 
    48344841        struct ath_softc *sc = ni->ni_ic->ic_dev->priv; 
    48354842 
    4836         sc->sc_rc->ops->node_cleanup(sc, ATH_NODE(ni)); 
    48374843        sc->sc_node_free(ni); 
    48384844#ifdef ATH_SUPERG_XR 
    48394845        ath_grppoll_period_update(sc); 
     
    57165722                        ATH_RSSI_LPF(an->an_avgrssi, ds->ds_rxstat.rs_rssi); 
    57175723                        type = ieee80211_input(ni, skb, 
    57185724                                ds->ds_rxstat.rs_rssi, ds->ds_rxstat.rs_tstamp); 
    5719                         ieee80211_free_node(ni); 
     5725                        ieee80211_unref_node(&ni); 
    57205726                } else { 
    57215727                        /* 
    57225728                         * No key index or no entry, do a lookup and 
     
    57415747                                if (keyix != IEEE80211_KEYIX_NONE && 
    57425748                                    sc->sc_keyixmap[keyix] == NULL) 
    57435749                                        sc->sc_keyixmap[keyix] = ieee80211_ref_node(ni); 
    5744                                 ieee80211_free_node(ni);  
     5750                                ieee80211_unref_node(&ni);  
    57455751                        } else 
    57465752                                type = ieee80211_input_all(ic, skb, 
    57475753                                        ds->ds_rxstat.rs_rssi, 
     
    65416547                STAILQ_REMOVE_HEAD(&an->an_uapsd_q, bf_list); 
    65426548                dev_kfree_skb(lastbuf->bf_skb); 
    65436549                lastbuf->bf_skb = NULL; 
    6544                 ieee80211_free_node(lastbuf->bf_node); 
    6545                 lastbuf->bf_node = NULL; 
     6550                ieee80211_unref_node(&lastbuf->bf_node); 
    65466551                ATH_TXBUF_LOCK_IRQ(sc); 
    65476552                STAILQ_INSERT_TAIL(&sc->sc_txbuf, lastbuf, bf_list); 
    65486553                ATH_TXBUF_UNLOCK_IRQ(sc); 
     
    72937298                         *     this is a DEAUTH message that was sent and the 
    72947299                         *     node was timed out due to inactivity. 
    72957300                         */ 
    7296                          ieee80211_free_node(ni);  
     7301                         ieee80211_unref_node(&ni);  
    72977302                } 
    72987303 
    72997304                bus_unmap_single(sc->sc_bdev, bf->bf_skbaddr,  
     
    75417546                } 
    75427547#endif /* ATH_SUPERG_FF */ 
    75437548                if (bf->bf_node) 
    7544                         ieee80211_free_node(bf->bf_node); 
     7549                        ieee80211_unref_node(&bf->bf_node); 
    75457550 
    75467551                bf->bf_skb = NULL; 
    75477552                bf->bf_node = NULL; 
  • svn.madwifi.org-trunk-2115/ath/if_athvar.h

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: if_athvar.h 2104 2007-02-13 05:54:52Z proski $ 
     36 * $Id: if_athvar.h 2000 2007-01-26 01:59:37Z proski $ 
    3737 */ 
    3838 
    3939/* 
  • svn.madwifi.org-trunk-2115/ath_hal/ah_os.c

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: ah_os.c 2065 2007-02-01 23:14:59Z proski
     36 * $Id: ah_os.c 2093 2007-02-07 21:06:25Z mentor
    3737 */ 
    3838#include "opt_ah.h" 
    3939 
  • svn.madwifi.org-trunk-2115/ath_hal/ah_osdep.h

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: ah_osdep.h 2062 2007-02-01 20:47:22Z proski $ 
     36 * $Id: ah_osdep.h 1890 2007-01-11 02:52:41Z proski $ 
    3737 */ 
    3838#ifndef _ATH_AH_OSDEP_H_ 
    3939#define _ATH_AH_OSDEP_H_ 
     
    5454#define __packed        __attribute__((__packed__)) 
    5555#endif 
    5656 
    57 /* Replace non-annotated HAL_BUS_HANDLE from ah.h */ 
    58 typedef void __iomem* ath_iomem_t; 
    59 #define HAL_BUS_HANDLE ath_iomem_t 
    60  
    6157#endif /* _ATH_AH_OSDEP_H_ */ 
  • svn.madwifi.org-trunk-2115/ath_hal/ah_os.h

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: ah_os.h 2062 2007-02-01 20:47:22Z proski $ 
     36 * $Id: ah_os.h 2014 2007-01-30 00:50:37Z proski $ 
    3737 */ 
    3838#ifndef _ATH_AH_OS_H_ 
    3939#define _ATH_AH_OS_H_ 
     
    147147#if (AH_BYTE_ORDER == AH_BIG_ENDIAN) 
    148148#define _OS_REG_WRITE(_ah, _reg, _val) do {                             \ 
    149149        (0x4000 <= (_reg) && (_reg) < 0x5000) ?                         \ 
    150          writel((_val), (_ah)->ah_sh + (_reg)) :      \ 
    151          __raw_writel((_val), (_ah)->ah_sh + (_reg)); \ 
     150         writel((_val), (void __force __iomem *)((_ah)->ah_sh + (_reg))) :    \ 
     151         __raw_writel((_val), (void __force __iomem *)((_ah)->ah_sh + (_reg)));       \ 
    152152} while (0) 
    153153#define _OS_REG_READ(_ah, _reg)                                 \ 
    154154        ((0x4000 <= (_reg) && (_reg) < 0x5000) ?                \ 
    155          readl((_ah)->ah_sh + (_reg)) :       \ 
    156          __raw_readl((_ah)->ah_sh + (_reg))) 
     155         readl((void __force __iomem *)((_ah)->ah_sh + (_reg))) :     \ 
     156         __raw_readl((void __force __iomem *)((_ah)->ah_sh + (_reg)))) 
    157157#else /* AH_LITTLE_ENDIAN */ 
    158158#define _OS_REG_WRITE(_ah, _reg, _val) do {                     \ 
    159         writel(_val, (_ah)->ah_sh + (_reg));                  \ 
     159        writel(_val, (void __force __iomem *)((_ah)->ah_sh + (_reg)));        \ 
    160160} while (0) 
    161161#define _OS_REG_READ(_ah, _reg)                                 \ 
    162         readl((_ah)->ah_sh + (_reg)) 
     162        readl((void __force __iomem *)((_ah)->ah_sh + (_reg))) 
    163163#endif /* AH_BYTE_ORDER */ 
    164164 
    165165#if defined(AH_DEBUG) || defined(AH_REGOPS_FUNC) || defined(AH_DEBUG_ALQ) 
  • svn.madwifi.org-trunk-2115/include/compat.h

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: compat.h 2110 2007-02-14 04:18:36Z proski
     36 * $Id: compat.h 2093 2007-02-07 21:06:25Z mentor
    3737 */ 
    3838#ifndef _ATH_COMPAT_H_ 
    3939#define _ATH_COMPAT_H_ 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211.c

    old new  
    2929 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    3030 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 * 
    32  * $Id: ieee80211.c 2109 2007-02-14 03:40:19Z scottr
     32 * $Id: ieee80211.c 1849 2006-12-08 17:20:08Z proski
    3333 */ 
    3434#ifndef EXPORT_SYMTAB 
    3535#define EXPORT_SYMTAB 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_crypto_ccmp.c

    old new  
    2828 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    2929 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3030 * 
    31  * $Id: ieee80211_crypto_ccmp.c 2112 2007-02-14 04:26:06Z proski $ 
     31 * $Id: ieee80211_crypto_ccmp.c 1769 2006-10-24 15:30:26Z proski $ 
    3232 */ 
    3333 
    3434/* 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_debug.h

    old new  
     1/*- 
     2 * Copyright (c) 2001 Atsushi Onoe 
     3 * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 
     4 * All rights reserved. 
     5 * 
     6 * Redistribution and use in source and binary forms, with or without 
     7 * modification, are permitted provided that the following conditions 
     8 * are met: 
     9 * 1. Redistributions of source code must retain the above copyright 
     10 *    notice, this list of conditions and the following disclaimer. 
     11 * 2. Redistributions in binary form must reproduce the above copyright 
     12 *    notice, this list of conditions and the following disclaimer in the 
     13 *    documentation and/or other materials provided with the distribution. 
     14 * 3. The name of the author may not be used to endorse or promote products 
     15 *    derived from this software without specific prior written permission. 
     16 * 
     17 * Alternatively, this software may be distributed under the terms of the 
     18 * GNU General Public License ("GPL") version 2 as published by the Free 
     19 * Software Foundation. 
     20 * 
     21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 
     22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
     23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
     24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 
     25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
     26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
     30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     31 * 
     32 * $Id: ieee80211_var.h 1969 2007-01-16 03:05:18Z scottr $ 
     33 */ 
     34#ifndef _NET80211_IEEE80211_DEBUG_H_ 
     35#define _NET80211_IEEE80211_DEBUG_H_ 
     36 
     37#define IEEE80211_DEBUG 
     38#define IEEE80211_DEBUG_REFCNT                  /* node refcnt stuff */ 
     39 
     40#include <net80211/ieee80211.h> 
     41 
     42#define IEEE80211_MSG_DEBUG     0x40000000      /* IFF_DEBUG equivalent */ 
     43#define IEEE80211_MSG_DUMPPKTS  0x20000000      /* IFF_LINK2 equivalent */ 
     44#define IEEE80211_MSG_CRYPTO    0x10000000      /* crypto work */ 
     45#define IEEE80211_MSG_INPUT     0x08000000      /* input handling */ 
     46#define IEEE80211_MSG_XRATE     0x04000000      /* rate set handling */ 
     47#define IEEE80211_MSG_ELEMID    0x02000000      /* element id parsing */ 
     48#define IEEE80211_MSG_NODE      0x01000000      /* node handling */ 
     49#define IEEE80211_MSG_ASSOC     0x00800000      /* association handling */ 
     50#define IEEE80211_MSG_AUTH      0x00400000      /* authentication handling */ 
     51#define IEEE80211_MSG_SCAN      0x00200000      /* scanning */ 
     52#define IEEE80211_MSG_OUTPUT    0x00100000      /* output handling */ 
     53#define IEEE80211_MSG_STATE     0x00080000      /* state machine */ 
     54#define IEEE80211_MSG_POWER     0x00040000      /* power save handling */ 
     55#define IEEE80211_MSG_DOT1X     0x00020000      /* 802.1x authenticator */ 
     56#define IEEE80211_MSG_DOT1XSM   0x00010000      /* 802.1x state machine */ 
     57#define IEEE80211_MSG_RADIUS    0x00008000      /* 802.1x radius client */ 
     58#define IEEE80211_MSG_RADDUMP   0x00004000      /* dump 802.1x radius packets */ 
     59#define IEEE80211_MSG_RADKEYS   0x00002000      /* dump 802.1x keys */ 
     60#define IEEE80211_MSG_WPA       0x00001000      /* WPA/RSN protocol */ 
     61#define IEEE80211_MSG_ACL       0x00000800      /* ACL handling */ 
     62#define IEEE80211_MSG_WME       0x00000400      /* WME protocol */ 
     63#define IEEE80211_MSG_SUPG      0x00000200      /* SUPERG */ 
     64#define IEEE80211_MSG_DOTH      0x00000100      /* 11.h */ 
     65#define IEEE80211_MSG_INACT     0x00000080      /* inactivity handling */ 
     66#define IEEE80211_MSG_ROAM      0x00000040      /* sta-mode roaming */ 
     67 
     68#define IEEE80211_MSG_ANY       0xffffffff      /* anything */ 
     69 
     70#ifdef IEEE80211_DEBUG 
     71int ieee80211_msg_is_reported(struct ieee80211vap *, unsigned int msg); 
     72#define IEEE80211_DPRINTF(_vap, _m, _fmt, ...) do {                     \ 
     73        if (ieee80211_msg_is_reported(_vap, _m))                                        \ 
     74                ieee80211_note(_vap, _fmt, __VA_ARGS__);                \ 
     75} while (0) 
     76#define IEEE80211_NOTE(_vap, _m, _ni, _fmt, ...) do {                   \ 
     77        if (ieee80211_msg_is_reported(_vap, _m))                                        \ 
     78                ieee80211_note_mac(_vap, (_ni)->ni_macaddr, _fmt, __VA_ARGS__);\ 
     79} while (0) 
     80#define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...) do {              \ 
     81        if (ieee80211_msg_is_reported(_vap, _m))                                        \ 
     82                ieee80211_note_mac(_vap, _mac, _fmt, __VA_ARGS__);      \ 
     83} while (0) 
     84#define IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...) do {             \ 
     85        if (ieee80211_msg_is_reported(_vap, _m))                                        \ 
     86                ieee80211_note_frame(_vap, _wh, _fmt, __VA_ARGS__);     \ 
     87} while (0) 
     88struct ieee80211vap; 
     89struct ieee80211_frame; 
     90void ieee80211_note(struct ieee80211vap *, const char *, ...); 
     91void ieee80211_note_mac(struct ieee80211vap *, 
     92        const u_int8_t mac[IEEE80211_ADDR_LEN], const char *, ...); 
     93void ieee80211_note_frame(struct ieee80211vap *, 
     94        const struct ieee80211_frame *, const char *, ...); 
     95#define ieee80211_msg_debug(_vap) \ 
     96        ieee80211_msg_is_reported(_vap, IEEE80211_MSG_DEBUG) 
     97#define ieee80211_msg_dumppkts(_vap) \ 
     98        ieee80211_msg_is_reported(_vap, IEEE80211_MSG_DUMPPKTS) 
     99#define ieee80211_msg_input(_vap) \ 
     100        ieee80211_msg_is_reported(_vap, IEEE80211_MSG_INPUT) 
     101#define ieee80211_msg_radius(_vap) \ 
     102        ieee80211_msg_is_reported(_vap, IEEE80211_MSG_RADIUS) 
     103#define ieee80211_msg_dumpradius(_vap) \ 
     104        ieee80211_msg_is_reported(_vap, IEEE80211_MSG_RADDUMP) 
     105#define ieee80211_msg_dumpradkeys(_vap) \ 
     106        ieee80211_msg_is_reported(_vap, IEEE80211_MSG_RADKEYS) 
     107#define ieee80211_msg_scan(_vap) \ 
     108        ieee80211_msg_is_reported(_vap, IEEE80211_MSG_SCAN) 
     109#define ieee80211_msg_assoc(_vap) \ 
     110        ieee80211_msg_is_reported(_vap, IEEE80211_MSG_ASSOC) 
     111#else /* IEEE80211_DEBUG */ 
     112#define IEEE80211_DPRINTF(_vap, _m, _fmt, ...) 
     113#define IEEE80211_NOTE(_vap, _m, _wh, _fmt, ...) 
     114#define IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...) 
     115#define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...) 
     116#endif /* IEEE80211_DEBUG */ 
     117 
     118#endif /* _NET80211_IEEE80211_DEBUG_H_ */ 
     119 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_input.c

    old new  
    2929 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    3030 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 * 
    32  * $Id: ieee80211_input.c 2069 2007-02-02 20:01:51Z mentor $ 
     32 * $Id: ieee80211_input.c 2093 2007-02-07 21:06:25Z mentor $ 
    3333 */ 
    3434#ifndef EXPORT_SYMTAB 
    3535#define EXPORT_SYMTAB 
     
    489489                                        nt = &ic->ic_sta; 
    490490                                        ni_wds = ieee80211_find_wds_node(nt, wh->i_addr3); 
    491491                                        if (ni_wds) { 
    492                                                 ieee80211_free_node(ni_wds); /* Decr ref count */ 
     492                                                ieee80211_unref_node(&ni_wds); /* Decr ref count */ 
    493493                                                IEEE80211_DISCARD(vap, IEEE80211_MSG_INPUT, 
    494494                                                        wh, NULL, "%s", 
    495495                                                        "multicast echo originated from node behind me"); 
     
    569569                                if (ni_wds == NULL) 
    570570                                        ieee80211_add_wds_addr(nt, ni, wh4->i_addr4, 0); 
    571571                                else 
    572                                         ieee80211_free_node(ni_wds); /* Decr ref count */ 
     572                                        ieee80211_unref_node(&ni_wds); /* Decr ref count */ 
    573573                        } 
    574574                         
    575575                        /* 
     
    928928                } 
    929929                ni = ieee80211_ref_node(vap->iv_bss); 
    930930                type = ieee80211_input(ni, skb1, rssi, rstamp); 
    931                 ieee80211_free_node(ni); 
     931                ieee80211_unref_node(&ni); 
    932932        } 
    933933        if (skb != NULL)                /* no vaps, reclaim skb */ 
    934934                dev_kfree_skb(skb); 
     
    978978        } 
    979979 
    980980        /* 
    981          * Use this lock to make sure ni->ni_rxfrag is 
    982          * not freed by the timer process while we use it. 
    983          * XXX bogus 
    984          */ 
    985         IEEE80211_NODE_LOCK_IRQ(ni->ni_table); 
    986  
    987         /* 
    988981         * Update the time stamp.  As a side effect, it 
    989982         * also makes sure that the timer will not change 
    990983         * ni->ni_rxfrag for at least 1 second, or in 
    991984         * other words, for the remaining of this function. 
     985         * XXX HUGE HORRIFIC HACK 
    992986         */ 
    993987        ni->ni_rxfragstamp = jiffies; 
    994988 
    995         IEEE80211_NODE_UNLOCK_IRQ(ni->ni_table); 
    996  
    997989        /* 
    998990         * Validate that fragment is in order and 
    999991         * related to the previous ones. 
     
    11221114                                        skb = NULL; 
    11231115                                } 
    11241116                                /* XXX statistic? */ 
    1125                                 ieee80211_free_node(ni1); 
     1117                                ieee80211_unref_node(&ni1); 
    11261118                        } 
    11271119                } 
    11281120                if (skb1 != NULL) { 
     
    12461238        int rssi, u_int32_t rstamp, u_int16_t seq, u_int16_t status) 
    12471239{ 
    12481240        struct ieee80211vap *vap = ni->ni_vap; 
     1241        unsigned int tmpnode = 0; 
    12491242 
    12501243        if (ni->ni_authmode == IEEE80211_AUTH_SHARED) { 
    12511244                IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 
     
    12531246                        "bad sta auth mode %u", ni->ni_authmode); 
    12541247                vap->iv_stats.is_rx_bad_auth++; /* XXX maybe a unique error? */ 
    12551248                if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 
    1256                         /* XXX hack to workaround calling convention */ 
    1257  
    1258                         /* XXX To send the frame to the requesting STA, we have to 
    1259                          * create a node for the station that we're going to reject. 
    1260                          * The node will be freed automatically */ 
    12611249                        if (ni == vap->iv_bss) { 
    1262                                 ni = ieee80211_dup_bss(vap, wh->i_addr2); 
     1250                                ni = ieee80211_dup_bss(vap, wh->i_addr2, 0); 
    12631251                                if (ni == NULL) 
    12641252                                        return; 
    12651253 
    12661254                                IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
    12671255                                "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr),  
    12681256                                ieee80211_node_refcnt(ni)); 
     1257                                tmpnode = 1; 
    12691258                        } 
    12701259                        IEEE80211_SEND_MGMT(ni, IEEE80211_FC0_SUBTYPE_AUTH, 
    12711260                                (seq + 1) | (IEEE80211_STATUS_ALG << 16)); 
     1261                         
     1262                        if (tmpnode) 
     1263                                ieee80211_unref_node(&ni); 
    12721264                        return; 
    12731265                } 
    12741266        } 
     
    12961288                } 
    12971289                /* always accept open authentication requests */ 
    12981290                if (ni == vap->iv_bss) { 
    1299                         ni = ieee80211_dup_bss(vap, wh->i_addr2);  
     1291                        ni = ieee80211_dup_bss(vap, wh->i_addr2, 0);  
    13001292                        if (ni == NULL) 
    13011293                                return; 
    13021294 
    13031295                        IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
    13041296                        "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr),  
    13051297                        ieee80211_node_refcnt(ni)); 
    1306  
    1307                 } else if ((ni->ni_flags & IEEE80211_NODE_AREF) == 0) 
    1308                         (void) ieee80211_ref_node(ni); 
    1309                 /* 
    1310                  * Mark the node as referenced to reflect that it's 
    1311                  * reference count has been bumped to ensure it remains 
    1312                  * after the transaction completes. 
    1313                  */ 
    1314                 ni->ni_flags |= IEEE80211_NODE_AREF; 
    1315  
     1298                        tmpnode = 1; 
     1299                } 
     1300                 
    13161301                IEEE80211_SEND_MGMT(ni, IEEE80211_FC0_SUBTYPE_AUTH, seq + 1); 
    13171302                IEEE80211_NOTE(vap, IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH, 
    13181303                        ni, "station authenticated (%s)", "open"); 
     
    13221307                 */ 
    13231308                if (ni->ni_authmode != IEEE80211_AUTH_8021X) 
    13241309                        ieee80211_node_authorize(ni); 
     1310                if (tmpnode) 
     1311                        ieee80211_unref_node(&ni); 
    13251312                break; 
    13261313 
    13271314        case IEEE80211_M_STA: 
     
    13601347        int istmp; 
    13611348 
    13621349        if (ni == vap->iv_bss) { 
    1363                 ni = ieee80211_tmp_node(vap, mac); 
     1350                ni = ieee80211_dup_bss(vap, mac, 1); 
    13641351                if (ni == NULL) { 
    13651352                        /* XXX msg */ 
    13661353                        return; 
     
    13701357                istmp = 0; 
    13711358        IEEE80211_SEND_MGMT(ni, subtype, arg); 
    13721359        if (istmp) 
    1373                 ieee80211_free_node(ni); 
     1360                ieee80211_unref_node(&ni); 
    13741361} 
    13751362 
    13761363static int 
     
    13961383{ 
    13971384        struct ieee80211vap *vap = ni->ni_vap; 
    13981385        u_int8_t *challenge; 
    1399         int allocbs, estatus
     1386        int allocbs = 0, estatus = 0
    14001387 
    14011388        /* 
    14021389         * NB: this can happen as we allow pre-shared key 
     
    14061393         * ordering in which case this check would just be 
    14071394         * for sanity/consistency. 
    14081395         */ 
    1409         estatus = 0;                    /* NB: silence compiler */ 
    14101396        if ((vap->iv_flags & IEEE80211_F_PRIVACY) == 0) { 
    14111397                IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, 
    14121398                        ni->ni_macaddr, "shared key auth", 
     
    14861472                switch (seq) { 
    14871473                case IEEE80211_AUTH_SHARED_REQUEST: 
    14881474                        if (ni == vap->iv_bss) { 
    1489                                 ni = ieee80211_dup_bss(vap, wh->i_addr2); 
     1475                                ni = ieee80211_dup_bss(vap, wh->i_addr2, 0); 
    14901476                                if (ni == NULL) { 
    14911477                                        /* NB: no way to return an error */ 
    14921478                                        return; 
     
    14971483                                ieee80211_node_refcnt(ni)); 
    14981484 
    14991485                                allocbs = 1; 
    1500                         } else { 
    1501                                 if ((ni->ni_flags & IEEE80211_NODE_AREF) == 0) 
    1502                                         (void) ieee80211_ref_node(ni); 
    1503                                 allocbs = 0; 
    15041486                        } 
    1505                         /* 
    1506                          * Mark the node as referenced to reflect that it's 
    1507                          * reference count has been bumped to ensure it remains 
    1508                          * after the transaction completes. 
    1509                          */ 
    1510                         ni->ni_flags |= IEEE80211_NODE_AREF; 
     1487 
    15111488                        ni->ni_rssi = rssi; 
    15121489                        ni->ni_rstamp = rstamp; 
    15131490                        ni->ni_last_rx = jiffies; 
     
    16011578        } 
    16021579        return; 
    16031580bad: 
    1604         /* 
    1605          * Send an error response; but only when operating as an AP. 
    1606          */ 
     1581        /* Send an error response; but only when operating as an AP. */ 
    16071582        if (vap->iv_opmode == IEEE80211_M_HOSTAP) { 
    16081583                /* XXX hack to workaround calling convention */ 
    16091584                ieee80211_send_error(ni, wh->i_addr2,  
    16101585                        IEEE80211_FC0_SUBTYPE_AUTH, 
    16111586                        (seq + 1) | (estatus<<16)); 
     1587                ieee80211_node_leave(ni); 
    16121588        } else if (vap->iv_opmode == IEEE80211_M_STA) { 
    16131589                /* 
    16141590                 * Kick the state machine.  This short-circuits 
     
    20722048        /* optional RSN capabilities */ 
    20732049        if (len > 2) 
    20742050                rsn_parm->rsn_caps = LE_READ_2(frm); 
    2075         /* XXXPMKID */ 
     2051        /* XXX PMKID */ 
    20762052 
    20772053        return 0; 
    20782054} 
     
    25662542        u_int8_t *frm, *efrm; 
    25672543        u_int8_t *ssid, *rates, *xrates, *wpa, *rsn, *wme, *ath; 
    25682544        u_int8_t rate; 
    2569         int reassoc, resp, allocbs
     2545        int reassoc, resp, allocbs = 0
    25702546        u_int8_t qosinfo; 
    25712547 
    25722548        wh = (struct ieee80211_frame *) skb->data; 
     
    29622938                                ni = ieee80211_fakeup_adhoc_node(vap, 
    29632939                                        wh->i_addr2); 
    29642940                        } else { 
    2965                                 ni = ieee80211_tmp_node(vap, wh->i_addr2); 
     2941                                ni = ieee80211_dup_bss(vap, wh->i_addr2, 1); 
    29662942                        } 
    29672943                        if (ni == NULL) 
    29682944                                return; 
    29692945                        allocbs = 1; 
    2970                 } else 
    2971                         allocbs = 0; 
     2946                } 
     2947 
    29722948                IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_INPUT, wh->i_addr2, 
    29732949                        "%s", "recv probe req"); 
    29742950                ni->ni_rssi = rssi; 
     
    29912967                         * Temporary node created just to send a 
    29922968                         * response, reclaim immediately 
    29932969                         */ 
    2994                         ieee80211_free_node(ni); 
     2970                        ieee80211_unref_node(&ni); 
    29952971                } else if (ath != NULL) 
    29962972                        ieee80211_saveath(ni, ath); 
    29972973                break; 
     
    30212997                                        ni = vap->iv_xrvap->iv_bss; 
    30222998                                else { 
    30232999                                        ieee80211_node_leave(ni); 
     3000                                        /* This would be a stupid place to add a node to the table 
     3001                                         * XR stuff needs work anyway 
     3002                                         */ 
    30243003                                        ieee80211_node_reset(ni, vap->iv_xrvap); 
    30253004                                } 
    30263005                                vap = vap->iv_xrvap; 
     
    30333012#endif 
    30343013                IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_AUTH, wh->i_addr2, 
    30353014                        "recv auth frame with algorithm %d seq %d", algo, seq); 
    3036                 /* 
    3037                  * Consult the ACL policy module if setup. 
    3038                  */ 
     3015                /* Consult the ACL policy module if setup. */ 
    30393016                if (vap->iv_acl != NULL && 
    30403017                    !vap->iv_acl->iac_check(vap, wh->i_addr2)) { 
    30413018                        IEEE80211_DISCARD(vap, IEEE80211_MSG_ACL, 
     
    30683045                                /* XXX not right */ 
    30693046                                ieee80211_send_error(ni, wh->i_addr2, 
    30703047                                        IEEE80211_FC0_SUBTYPE_AUTH, 
    3071                                         (seq+1) | (IEEE80211_STATUS_ALG << 16)); 
     3048                                        (seq + 1) | (IEEE80211_STATUS_ALG << 16)); 
    30723049                        } 
    30733050                        return; 
    30743051                }  
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_linux.h

    old new  
    2424 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    2525 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    2626 * 
    27  * $Id: ieee80211_linux.h 2033 2007-01-31 03:27:59Z proski
     27 * $Id: ieee80211_linux.h 2064 2007-02-01 20:49:37Z mentor
    2828 */ 
    2929#ifndef _NET80211_IEEE80211_LINUX_H_ 
    3030#define _NET80211_IEEE80211_LINUX_H_ 
     
    6363 
    6464#define IEEE80211_RESCHEDULE    schedule 
    6565 
     66/* Locking */ 
     67/* NB: beware, spin_is_locked() is not usefully defined for !(DEBUG || SMP) 
     68 * because spinlocks do not exist in this configuration. Instead IRQs  
     69 * or pre-emption are simply disabled, as this is all that is needed. 
     70 */ 
     71 
    6672/* 
    6773 * Beacon handler locking definitions. 
    6874 * Beacon locking  
     
    8591#define IEEE80211_LOCK(_ic)     spin_lock(&(_ic)->ic_comlock) 
    8692#define IEEE80211_UNLOCK(_ic)   spin_unlock(&(_ic)->ic_comlock) 
    8793 
    88 /* NB: beware, spin_is_locked() is unusable for !SMP */ 
    89 #if defined(CONFIG_SMP) 
     94#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 
    9095#define IEEE80211_LOCK_ASSERT(_ic) \ 
    9196        KASSERT(spin_is_locked(&(_ic)->ic_comlock),("ieee80211com not locked!")) 
    9297#else 
    9398#define IEEE80211_LOCK_ASSERT(_ic) 
    9499#endif 
    95100 
     101 
    96102#define IEEE80211_VAPS_LOCK_INIT(_ic, _name)            \ 
    97103        spin_lock_init(&(_ic)->ic_vapslock) 
    98104#define IEEE80211_VAPS_LOCK_DESTROY(_ic) 
     
    108114} while (0) 
    109115#define IEEE80211_VAPS_UNLOCK_IRQ_EARLY(_ic)    spin_unlock_irqrestore(&(_ic)->ic_vapslock, _vaps_lockflags) 
    110116 
    111  
    112 /* NB: beware, spin_is_locked() is unusable for !SMP */ 
    113 #if defined(CONFIG_SMP) 
     117#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 
    114118#define IEEE80211_VAPS_LOCK_ASSERT(_ic) \ 
    115         KASSERT(spin_is_locked(&(_ic)->ic_vapslock),("ieee80211com_vaps not locked!")) 
     119        KASSERT(spin_is_locked(&(_ic)->ic_vapslock), \ 
     120                ("ieee80211com_vaps not locked!")) 
    116121#else 
    117122#define IEEE80211_VAPS_LOCK_ASSERT(_ic) 
    118123#endif 
     
    121126/* 
    122127 * Node locking definitions. 
    123128 */ 
     129#if 0 
     130 
    124131typedef spinlock_t ieee80211_node_lock_t; 
    125 #define IEEE80211_NODE_LOCK_INIT(_nt, _name)    spin_lock_init(&(_nt)->nt_nodelock) 
    126 #define IEEE80211_NODE_LOCK_DESTROY(_nt) 
    127 #define IEEE80211_NODE_LOCK(_nt)        spin_lock(&(_nt)->nt_nodelock) 
    128 #define IEEE80211_NODE_UNLOCK(_nt)      spin_unlock(&(_nt)->nt_nodelock) 
    129 #define IEEE80211_NODE_LOCK_BH(_nt)     spin_lock_bh(&(_nt)->nt_nodelock) 
    130 #define IEEE80211_NODE_UNLOCK_BH(_nt)   spin_unlock_bh(&(_nt)->nt_nodelock) 
    131 #define IEEE80211_NODE_LOCK_IRQ(_nt)    do {    \ 
     132#define IEEE80211_NODE_LOCK_INIT(_ni, _name)    spin_lock_init(&(_ni)->ni_nodelock) 
     133#define IEEE80211_NODE_LOCK_DESTROY(_ni) 
     134#if 0   /* We should always be contesting in the same contexts */ 
     135#define IEEE80211_NODE_LOCK(_ni)        spin_lock(&(_ni)->ni_nodelock) 
     136#define IEEE80211_NODE_UNLOCK(_ni)      spin_unlock(&(_ni)->ni_nodelock) 
     137#define IEEE80211_NODE_LOCK_BH(_ni)     spin_lock_bh(&(_ni)->ni_nodelock) 
     138#define IEEE80211_NODE_UNLOCK_BH(_ni)   spin_unlock_bh(&(_ni)->ni_nodelock) 
     139#endif 
     140#define IEEE80211_NODE_LOCK_IRQ(_ni)    do {    \ 
     141        unsigned long __node_lockflags;         \ 
     142        spin_lock_irqsave(&(_ni)->ni_nodelock, __node_lockflags); 
     143#define IEEE80211_NODE_UNLOCK_IRQ(_ni)          \ 
     144        spin_unlock_irqrestore(&(_ni)->ni_nodelock, __node_lockflags); \ 
     145} while(0) 
     146#define IEEE80211_NODE_UNLOCK_IRQ_EARLY(_ni)            \ 
     147        spin_unlock_irqrestore(&(_ni)->ni_nodelock, __node_lockflags); 
     148 
     149#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 
     150#define IEEE80211_NODE_LOCK_ASSERT(_nt) \ 
     151        KASSERT(spin_is_locked(&(_ni)->ni_nodelock), \ 
     152                ("802.11 node not locked!")) 
     153#else 
     154#define IEEE80211_NODE_LOCK_ASSERT(_ni) 
     155#endif 
     156 
     157#endif /* node lock */ 
     158 
     159/* 
     160 * Node table locking definitions. 
     161 */ 
     162typedef spinlock_t ieee80211_node_table_lock_t; 
     163#define IEEE80211_NODE_TABLE_LOCK_INIT(_nt, _name)      spin_lock_init(&(_nt)->nt_nodelock) 
     164#define IEEE80211_NODE_TABLE_LOCK_DESTROY(_nt) 
     165#if 0   /* We should always be contesting in the same contexts */ 
     166#define IEEE80211_NODE_TABLE_LOCK(_nt)  spin_lock(&(_nt)->nt_nodelock) 
     167#define IEEE80211_NODE_TABLE_UNLOCK(_nt)        spin_unlock(&(_nt)->nt_nodelock) 
     168#define IEEE80211_NODE_TABLE_LOCK_BH(_nt)       spin_lock_bh(&(_nt)->nt_nodelock) 
     169#define IEEE80211_NODE_TABLE_UNLOCK_BH(_nt)     spin_unlock_bh(&(_nt)->nt_nodelock) 
     170#endif 
     171#define IEEE80211_NODE_TABLE_LOCK_IRQ(_nt)      do {    \ 
    132172        unsigned long __node_lockflags;         \ 
    133173        spin_lock_irqsave(&(_nt)->nt_nodelock, __node_lockflags); 
    134 #define IEEE80211_NODE_UNLOCK_IRQ(_nt)                \ 
     174#define IEEE80211_NODE_TABLE_UNLOCK_IRQ(_nt)          \ 
    135175        spin_unlock_irqrestore(&(_nt)->nt_nodelock, __node_lockflags); \ 
    136176} while(0) 
    137 #define IEEE80211_NODE_UNLOCK_IRQ_EARLY(_nt)          \ 
     177#define IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(_nt)            \ 
    138178        spin_unlock_irqrestore(&(_nt)->nt_nodelock, __node_lockflags); 
    139179 
    140 /* NB: beware, *_is_locked() are bogusly defined for UP+!PREEMPT */ 
    141 #if (defined(CONFIG_SMP) || defined(CONFIG_PREEMPT)) && defined(spinlock_is_locked) 
    142 #define IEEE80211_NODE_LOCK_ASSERT(_nt) \ 
    143         KASSERT(spinlock_is_locked(&(_nt)->nt_nodelock), \ 
     180#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 
     181#define IEEE80211_NODE_TABLE_LOCK_ASSERT(_nt) \ 
     182        KASSERT(spin_is_locked(&(_nt)->nt_nodelock), \ 
    144183                ("802.11 node table not locked!")) 
    145184#else 
    146 #define IEEE80211_NODE_LOCK_ASSERT(_nt) 
     185#define IEEE80211_NODE_TABLE_LOCK_ASSERT(_nt) 
    147186#endif 
    148187 
    149188/* 
     
    163202#define IEEE80211_SCAN_UNLOCK_IRQ_EARLY(_nt)            \ 
    164203        spin_unlock_irqrestore(&(_nt)->nt_scanlock, __scan_lockflags); 
    165204 
    166 /* NB: beware, spin_is_locked() is unusable for !SMP */ 
    167 #if defined(CONFIG_SMP) 
     205#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 
    168206#define IEEE80211_SCAN_LOCK_ASSERT(_nt) \ 
    169207        KASSERT(spin_is_locked(&(_nt)->nt_scanlock), ("scangen not locked!")) 
    170208#else 
     
    182220#define ACL_LOCK_BH(_as)                spin_lock_bh(&(_as)->as_lock) 
    183221#define ACL_UNLOCK_BH(_as)              spin_unlock_bh(&(_as)->as_lock) 
    184222 
    185 /* NB: beware, spin_is_locked() is unusable for !SMP */ 
    186 #if defined(CONFIG_SMP) 
     223#if (defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)) && defined(spin_is_locked) 
    187224#define ACL_LOCK_ASSERT(_as) \ 
    188225        KASSERT(spin_is_locked(&(_as)->as_lock), ("ACL not locked!")) 
    189226#else 
     
    299336 *                              is the last reference, otherwise 0 
    300337 * ieee80211_node_refcnt        reference count for printing (only) 
    301338 */ 
     339typedef atomic_t ieee80211_node_ref_count_t;  
    302340#define ieee80211_node_initref(_ni)     atomic_set(&(_ni)->ni_refcnt, 1) 
    303341#define ieee80211_node_incref(_ni)      atomic_inc(&(_ni)->ni_refcnt) 
    304342#define ieee80211_node_decref(_ni)      atomic_dec(&(_ni)->ni_refcnt) 
     
    379417/* msecs_to_jiffies appeared in 2.6.7 and 2.4.29 */ 
    380418#include <linux/delay.h> 
    381419#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && \ 
    382       LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) || \ 
    383      LINUX_VERSION_CODE < KERNEL_VERSION(2,4,29) 
     420     LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) || \ 
     421    LINUX_VERSION_CODE < KERNEL_VERSION(2,4,29) 
    384422 
    385423/* The following definitions and inline functions are 
    386424 * copied from the kernel src, include/linux/jiffies.h */ 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_node.c

    old new  
    2929 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    3030 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 * 
    32  * $Id: ieee80211_node.c 2083 2007-02-06 15:33:38Z mentor $ 
     32 * $Id: ieee80211_node.c 2099 2007-02-09 01:16:01Z mentor $ 
    3333 */ 
    3434#ifndef EXPORT_SYMTAB 
    3535#define EXPORT_SYMTAB 
     
    6565#define IEEE80211_AID_ISSET(_vap, _b) \ 
    6666        ((_vap)->iv_aid_bitmap[IEEE80211_AID(_b) / 32] & (1 << (IEEE80211_AID(_b) % 32))) 
    6767 
     68static struct ieee80211_node *ieee80211_alloc_node(struct ieee80211vap *, const u_int8_t *); 
     69 
    6870static int ieee80211_sta_join1(struct ieee80211_node *); 
    6971 
    70 static struct ieee80211_node *node_alloc(struct ieee80211_node_table *, 
    71         struct ieee80211vap *); 
     72static struct ieee80211_node *node_alloc(struct ieee80211vap *); 
    7273static void node_cleanup(struct ieee80211_node *); 
    7374static void node_free(struct ieee80211_node *); 
    7475static u_int8_t node_getrssi(const struct ieee80211_node *); 
    7576 
    76 static void _ieee80211_free_node(struct ieee80211_node *); 
    77 static void node_reclaim(struct ieee80211_node_table *, struct ieee80211_node*); 
     77static void _node_table_leave(struct ieee80211_node_table *, struct ieee80211_node *); 
     78static void _node_table_join(struct ieee80211_node_table *, struct ieee80211_node *); 
    7879 
    7980static void ieee80211_node_timeout(unsigned long); 
    8081 
     
    194195 
    195196        ieee80211_node_table_reset(&ic->ic_sta, vap); 
    196197        if (vap->iv_bss != NULL) { 
    197                 ieee80211_free_node(vap->iv_bss); 
    198                 vap->iv_bss = NULL; 
     198                ieee80211_unref_node(&vap->iv_bss); 
    199199        } 
    200200        if (vap->iv_aid_bitmap != NULL) { 
    201201                FREE(vap->iv_aid_bitmap, M_DEVBUF); 
     
    203203        } 
    204204} 
    205205 
     206int ieee80211_msg_is_reported(struct ieee80211vap *vap, unsigned m) 
     207{ 
     208        return !!(vap->iv_debug & m); 
     209} 
     210EXPORT_SYMBOL(ieee80211_msg_is_reported); 
     211 
    206212/*  
    207213 * Port authorize/unauthorize interfaces for use by an authenticator. 
    208214 */ 
     
    263269                "%s: creating ibss on channel %u\n", __func__, 
    264270                ieee80211_chan2ieee(ic, chan)); 
    265271 
    266         /* Check to see if we already have a node for this mac */ 
     272        /* Check to see if we already have a node for this mac  
     273         * NB: we gain a node reference here 
     274         */ 
    267275        ni = ieee80211_find_node(&ic->ic_sta, vap->iv_myaddr); 
    268276        if (ni == NULL) { 
    269                 ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr); 
     277                ni = ieee80211_alloc_node_table(vap, vap->iv_myaddr); 
    270278                if (ni == NULL) { 
    271279                        /* XXX recovery? */ 
    272280                        return; 
    273281                } 
    274282        } 
    275         else 
    276                 ieee80211_free_node(ni); 
    277283 
    278284        IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: %p<%s> refcnt %d\n", 
    279285                __func__, vap->iv_bss, ether_sprintf(vap->iv_bss->ni_macaddr), 
     
    345351        else if (IEEE80211_IS_CHAN_QUARTER(chan)) 
    346352                ni->ni_rates = ic->ic_sup_quarter_rates; 
    347353 
    348         (void) ieee80211_sta_join1(ieee80211_ref_node(ni)); 
     354        (void) ieee80211_sta_join1(PASS_NODE(ni)); 
    349355} 
    350356EXPORT_SYMBOL(ieee80211_create_ibss); 
    351357 
     
    369375        /* XXX multi-bss wrong */ 
    370376        ieee80211_reset_erp(ic, ic->ic_curmode); 
    371377 
    372         ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->iv_myaddr); 
     378        ni = ieee80211_alloc_node_table(vap, vap->iv_myaddr); 
    373379        KASSERT(ni != NULL, ("unable to setup inital BSS node")); 
    374380        obss = vap->iv_bss; 
     381        // Caller's reference 
    375382        vap->iv_bss = ieee80211_ref_node(ni); 
    376383 
    377384        IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s: new bss %p<%s> refcnt %d\n", 
     
    381388        if (obss != NULL) { 
    382389                copy_bss(ni, obss); 
    383390                ni->ni_intval = ic->ic_lintval; 
    384                 ieee80211_free_node(obss); 
     391                // Caller's reference 
     392                ieee80211_unref_node(&obss); 
    385393        } 
    386394} 
    387395 
     
    587595                vap->iv_state == IEEE80211_S_RUN && ssid_equal(obss, selbs)); 
    588596        vap->iv_bss = selbs; 
    589597        if (obss != NULL) 
    590                 ieee80211_free_node(obss); 
     598                ieee80211_unref_node(&obss); 
    591599        ic->ic_bsschan = selbs->ni_chan; 
    592600        ic->ic_curchan = ic->ic_bsschan; 
    593601        ic->ic_curmode = ieee80211_chan2mode(ic->ic_curchan); 
     
    644652 
    645653        ni = ieee80211_find_node(&ic->ic_sta, se->se_macaddr); 
    646654        if (ni == NULL) { 
    647                 ni = ieee80211_alloc_node(&ic->ic_sta, vap, se->se_macaddr); 
     655                ni = ieee80211_alloc_node_table(vap, se->se_macaddr); 
    648656                if (ni == NULL) { 
    649657                        /* XXX msg */ 
    650658                        return 0; 
    651659                } 
    652         } else 
    653                 ieee80211_free_node(ni); 
     660        } 
    654661 
    655662        /* 
    656663         * Expand scan state into node's format. 
    657664         * XXX may not need all this stuff 
    658665         */ 
    659         ni->ni_authmode = vap->iv_bss->ni_authmode;            /* inherit authmode from iv_bss */ 
     666        ni->ni_authmode = vap->iv_bss->ni_authmode;     /* inherit authmode from iv_bss */ 
    660667        /* inherit the WPA setup as well (structure copy!) */ 
    661668        ni->ni_rsn = vap->iv_bss->ni_rsn;  
    662669        IEEE80211_ADDR_COPY(ni->ni_bssid, se->se_bssid); 
     
    690697 
    691698        IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
    692699        "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(ni->ni_macaddr),  
    693         ieee80211_node_refcnt(ni)+1); 
     700        ieee80211_node_refcnt(ni)); 
    694701 
    695         return ieee80211_sta_join1(ieee80211_ref_node(ni)); 
     702        return ieee80211_sta_join1(PASS_NODE(ni)); 
    696703} 
    697704EXPORT_SYMBOL(ieee80211_sta_join); 
    698705 
     
    704711ieee80211_sta_leave(struct ieee80211_node *ni) 
    705712{ 
    706713        struct ieee80211vap *vap = ni->ni_vap; 
    707         struct ieee80211com *ic = vap->iv_ic; 
    708714 
    709715        /* WDS/Repeater: Stop software beacon timer for STA */ 
    710716        if (vap->iv_opmode == IEEE80211_M_STA && 
    711717            vap->iv_flags_ext & IEEE80211_FEXT_SWBMISS) { 
    712718                del_timer(&vap->iv_swbmiss); 
    713719        } 
    714  
    715         ic->ic_node_cleanup(ni); 
     720         
    716721        ieee80211_notify_node_leave(ni); 
    717722} 
    718723 
     
    721726 */ 
    722727 
    723728static void 
    724 ieee80211_node_table_init(struct ieee80211com *ic, 
    725         struct ieee80211_node_table *nt,      const char *name, int inact) 
     729ieee80211_node_table_init(struct ieee80211com *ic, struct ieee80211_node_table *nt, 
     730              const char *name, int inact) 
    726731{ 
    727732        nt->nt_ic = ic; 
    728         IEEE80211_NODE_LOCK_INIT(nt, ic->ic_dev->name); 
     733        IEEE80211_NODE_TABLE_LOCK_INIT(nt, ic->ic_dev->name); 
    729734        IEEE80211_SCAN_LOCK_INIT(nt, ic->ic_dev->name); 
    730735        TAILQ_INIT(&nt->nt_node); 
    731736        nt->nt_name = name; 
     
    737742        mod_timer(&nt->nt_wds_aging_timer, jiffies + HZ * WDS_AGING_TIMER_VAL); 
    738743} 
    739744 
     745static __inline void _node_table_join(struct ieee80211_node_table *nt, struct ieee80211_node *ni) { 
     746        IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 
     747 
     748        ni->ni_table = nt; 
     749        TAILQ_INSERT_TAIL(&nt->nt_node, ieee80211_ref_node(ni), ni_list); 
     750        LIST_INSERT_HEAD(&nt->nt_hash[IEEE80211_NODE_HASH(ni->ni_macaddr)], ni, ni_hash); 
     751} 
     752 
     753static __inline void _node_table_leave(struct ieee80211_node_table *nt, struct ieee80211_node *ni) { 
     754        struct ieee80211_node *hni; 
     755        IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 
     756         
     757        TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 
     758        LIST_FOREACH(hni, &nt->nt_hash[IEEE80211_NODE_HASH(ni->ni_macaddr)], ni_hash) { 
     759                LIST_REMOVE(ni, ni_hash); 
     760        } 
     761        ni->ni_table = NULL; 
     762        _ieee80211_unref_node(ni); 
     763} 
     764 
     765/* This is overridden by ath_node_alloc in ath/if_ath.c, and so 
     766 * should never get called. 
     767 */ 
    740768static struct ieee80211_node * 
    741 node_alloc(struct ieee80211_node_table *nt, struct ieee80211vap *vap) 
     769node_alloc(struct ieee80211vap *vap) 
    742770{ 
    743771        struct ieee80211_node *ni; 
    744772 
     
    777805                        IEEE80211_UNLOCK_IRQ(ni->ni_ic); 
    778806                } 
    779807        } 
    780         /* 
    781          * Clear AREF flag that marks the authorization refcnt bump 
    782          * has happened.  This is probably not needed as the node 
    783          * should always be removed from the table so not found but 
    784          * do it just in case. 
    785          */ 
    786         ni->ni_flags &= ~IEEE80211_NODE_AREF; 
    787808 
    788809        /* 
    789810         * Drain power save queue and, if needed, clear TIM. 
     
    792813                vap->iv_set_tim(ni, 0); 
    793814 
    794815        ni->ni_associd = 0; 
    795         if (ni->ni_challenge != NULL) { 
    796                 FREE(ni->ni_challenge, M_DEVBUF); 
    797                 ni->ni_challenge = NULL; 
    798         } 
     816         
    799817        /* 
    800818         * Preserve SSID, WPA, and WME ie's so the bss node is 
    801819         * reusable during a re-auth/re-assoc state transition. 
     
    820838static void 
    821839node_free(struct ieee80211_node *ni) 
    822840{ 
     841#if 0 
     842        // We should 'cleanup' and then free'ing should be done automatically on decref 
    823843        struct ieee80211com *ic = ni->ni_ic; 
    824844 
    825845        ic->ic_node_cleanup(ni); 
     846#endif  
     847        KASSERT(ieee80211_node_refcnt(ni) == 0, ("node being free whilst still referenced")); 
     848 
     849        if (ni->ni_challenge != NULL)  
     850                FREE(ni->ni_challenge, M_DEVBUF); 
    826851        if (ni->ni_wpa_ie != NULL) 
    827852                FREE(ni->ni_wpa_ie, M_DEVBUF); 
    828853        if (ni->ni_rsn_ie != NULL) 
     
    832857        if (ni->ni_ath_ie != NULL) 
    833858                FREE(ni->ni_ath_ie, M_DEVBUF); 
    834859        IEEE80211_NODE_SAVEQ_DESTROY(ni); 
     860         
    835861        FREE(ni, M_80211_NODE); 
    836862} 
    837863 
     
    848874 * This interface is not intended for general use, it is 
    849875 * used by the routines below to create entries with a 
    850876 * specific purpose. 
     877 * Dont assume a BSS? 
    851878 */ 
    852879struct ieee80211_node * 
    853 ieee80211_alloc_node(struct ieee80211_node_table *nt, 
    854         struct ieee80211vap *vap, const u_int8_t *macaddr) 
     880ieee80211_alloc_node_table(struct ieee80211vap *vap,  
     881        const u_int8_t *macaddr) 
    855882{ 
    856         struct ieee80211com *ic = nt->nt_ic; 
     883        struct ieee80211com *ic = vap->iv_ic; 
     884        struct ieee80211_node_table *nt = &ic->ic_sta; 
    857885        struct ieee80211_node *ni; 
    858         int hash; 
    859886 
    860         ni = ic->ic_node_alloc(nt, vap); 
    861         if (ni == NULL) { 
    862                 /* XXX msg */ 
    863                 vap->iv_stats.is_rx_nodealloc++; 
    864                 return NULL; 
    865         } 
     887        ni = ieee80211_alloc_node(vap, macaddr); 
     888        if (ni != NULL) { 
     889                ni->ni_inact = ni->ni_inact_reload = nt->nt_inact_init; 
    866890 
    867         IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, 
    868                 "%s: %p<%s> in %s table, refcnt %d\n", __func__, ni, 
    869                 ether_sprintf(macaddr), nt->nt_name, 
    870                 ieee80211_node_refcnt(ni)+1); 
     891                WME_UAPSD_NODE_TRIGSEQINIT(ni); 
     892                IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); 
    871893 
    872         IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); 
    873         hash = IEEE80211_NODE_HASH(macaddr); 
    874         ieee80211_node_initref(ni);             /* mark referenced */ 
    875         ni->ni_chan = IEEE80211_CHAN_ANYC; 
    876         ni->ni_authmode = IEEE80211_AUTH_OPEN; 
    877         ni->ni_txpower = ic->ic_txpowlimit;     /* max power */ 
    878         ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey, IEEE80211_KEYIX_NONE); 
    879         ni->ni_inact_reload = nt->nt_inact_init; 
    880         ni->ni_inact = ni->ni_inact_reload; 
    881         ni->ni_ath_defkeyindex = IEEE80211_INVAL_DEFKEY; 
    882         ni->ni_rxkeyoff = 0; 
    883         IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); 
     894                IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
     895                _node_table_join(nt, ni); 
     896                IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
     897        } 
    884898 
    885         IEEE80211_NODE_LOCK_IRQ(nt); 
    886         ni->ni_vap = vap; 
    887         ni->ni_ic = ic; 
    888         ni->ni_table = nt; 
    889         TAILQ_INSERT_TAIL(&nt->nt_node, ni, ni_list); 
    890         LIST_INSERT_HEAD(&nt->nt_hash[hash], ni, ni_hash); 
    891         ni->ni_rxfrag = NULL; 
    892         ni->ni_challenge = NULL; 
    893         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     899        return ni; 
     900
     901EXPORT_SYMBOL(ieee80211_alloc_node_table); 
     902 
     903/* Allocate a node structure and initialise specialised structures 
     904 * This function does not add the node to the node table, thus this 
     905 * node will not be found using ieee80211_find_*node. 
     906 * This is useful when sending one off errors or request denials. 
     907 */ 
     908static struct ieee80211_node * 
     909ieee80211_alloc_node(struct ieee80211vap *vap, const u_int8_t *macaddr) 
     910
     911        struct ieee80211com *ic = vap->iv_ic; 
     912        struct ieee80211_node *ni; 
     913         
     914        /* This always allocates zeroed memoery */ 
     915        ni = ic->ic_node_alloc(vap); 
     916        if (ni != NULL) { 
     917                IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
     918                "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(macaddr),  
     919                ieee80211_node_refcnt(ni)+1); 
    894920 
    895         WME_UAPSD_NODE_TRIGSEQINIT(ni); 
     921                ieee80211_node_initref(ni);             /* mark referenced */ 
     922                 
     923                IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); 
     924                 
     925                ni->ni_chan = IEEE80211_CHAN_ANYC; 
     926                ni->ni_authmode = IEEE80211_AUTH_OPEN; 
     927                ni->ni_txpower = ic->ic_txpowlimit; 
     928                 
     929                ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey, 
     930                        IEEE80211_KEYIX_NONE); 
     931                ni->ni_ath_defkeyindex = IEEE80211_INVAL_DEFKEY; 
    896932 
     933                ni->ni_vap = vap; 
     934                ni->ni_ic = ic; 
     935        } else { 
     936                /* XXX msg */ 
     937                vap->iv_stats.is_rx_nodealloc++; 
     938        } 
    897939        return ni; 
    898940} 
    899 EXPORT_SYMBOL(ieee80211_alloc_node); 
    900941 
    901942/* Add wds address to the node table */ 
    902943int 
     
    918959                wds->wds_agingcount = WDS_AGING_COUNT; 
    919960        hash = IEEE80211_NODE_HASH(macaddr); 
    920961        IEEE80211_ADDR_COPY(wds->wds_macaddr, macaddr); 
    921         ieee80211_ref_node(ni);                /* Reference node */ 
    922         wds->wds_ni = ni
    923         IEEE80211_NODE_LOCK_IRQ(nt); 
     962         
     963        IEEE80211_NODE_TABLE_LOCK_IRQ(nt)
     964        wds->wds_ni = ieee80211_ref_node(ni); 
    924965        LIST_INSERT_HEAD(&nt->nt_wds_hash[hash], wds, wds_hash); 
    925         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     966        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    926967        return 0; 
    927968} 
    928969EXPORT_SYMBOL(ieee80211_add_wds_addr); 
     
    935976        struct ieee80211_wds_addr *wds; 
    936977 
    937978        hash = IEEE80211_NODE_HASH(macaddr); 
    938         IEEE80211_NODE_LOCK_IRQ(nt); 
     979        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    939980        LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    940981                if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 
    941                         if (ieee80211_node_dectestref(wds->wds_ni)) { 
    942                                 _ieee80211_free_node(wds->wds_ni); 
    943                                 LIST_REMOVE(wds, wds_hash); 
    944                                 FREE(wds, M_80211_WDS); 
    945                                 break; 
    946                         } 
     982                        LIST_REMOVE(wds, wds_hash); 
     983                        ieee80211_unref_node(&wds->wds_ni); 
     984                        FREE(wds, M_80211_WDS); 
     985                        break; 
    947986                } 
    948987        } 
    949         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     988        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    950989} 
    951990EXPORT_SYMBOL(ieee80211_remove_wds_addr); 
    952991 
     
    958997        int hash; 
    959998        struct ieee80211_wds_addr *wds; 
    960999 
    961         IEEE80211_NODE_LOCK_IRQ(nt); 
     1000        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    9621001        for (hash = 0; hash < IEEE80211_NODE_HASHSIZE; hash++) { 
    9631002                LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    9641003                        if (wds->wds_ni == ni) { 
    965                                 if (ieee80211_node_dectestref(ni)) { 
    966                                         _ieee80211_free_node(ni); 
    967                                         LIST_REMOVE(wds, wds_hash); 
    968                                         FREE(wds, M_80211_WDS); 
    969                                 } 
     1004                                LIST_REMOVE(wds, wds_hash); 
     1005                                ieee80211_unref_node(&wds->wds_ni); 
     1006                                FREE(wds, M_80211_WDS); 
    9701007                        } 
    9711008                } 
    9721009        } 
    973         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1010        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    9741011} 
    9751012EXPORT_SYMBOL(ieee80211_del_wds_node); 
    9761013 
     
    9811018        int hash; 
    9821019        struct ieee80211_wds_addr *wds; 
    9831020 
    984         IEEE80211_NODE_LOCK_IRQ(nt); 
     1021        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    9851022        for (hash = 0; hash < IEEE80211_NODE_HASHSIZE; hash++) { 
    9861023                LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    9871024                        if (wds->wds_agingcount != WDS_AGING_STATIC) { 
    9881025                                if (!wds->wds_agingcount) { 
    989                                         if (ieee80211_node_dectestref(wds->wds_ni)) { 
    990                                                 _ieee80211_free_node(wds->wds_ni);   
    991                                                 LIST_REMOVE(wds, wds_hash); 
    992                                                 FREE(wds, M_80211_WDS); 
    993                                         } 
     1026                                        LIST_REMOVE(wds, wds_hash); 
     1027                                        ieee80211_unref_node(&wds->wds_ni);   
     1028                                        FREE(wds, M_80211_WDS); 
    9941029                                } else 
    9951030                                        wds->wds_agingcount--; 
    9961031                        } 
    9971032                } 
    9981033        } 
    999         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1034        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    10001035        mod_timer(&nt->nt_wds_aging_timer, jiffies + HZ * WDS_AGING_TIMER_VAL); 
    10011036} 
    10021037 
    10031038 
    10041039/* 
    1005  * Craft a temporary node suitable for sending a management frame 
    1006  * to the specified station.  We craft only as much state as we 
    1007  * need to do the work since the node will be immediately reclaimed 
    1008  * once the send completes. 
    1009  */ 
    1010 struct ieee80211_node * 
    1011 ieee80211_tmp_node(struct ieee80211vap *vap, const u_int8_t *macaddr) 
    1012 { 
    1013         struct ieee80211com *ic = vap->iv_ic; 
    1014         struct ieee80211_node *ni; 
    1015  
    1016         ni = ic->ic_node_alloc(&ic->ic_sta,vap); 
    1017         if (ni != NULL) { 
    1018                 IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE,  
    1019                 "%s: %p<%s> refcnt %d\n", __func__, ni, ether_sprintf(macaddr),  
    1020                 ieee80211_node_refcnt(ni)+1); 
    1021  
    1022                 IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); 
    1023                 IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 
    1024                 ieee80211_node_initref(ni);             /* mark referenced */ 
    1025                 ni->ni_txpower = vap->iv_bss->ni_txpower; 
    1026                 ni->ni_vap = vap; 
    1027                 /* NB: required by ieee80211_fix_rate */ 
    1028                 ieee80211_node_set_chan(ic, ni); 
    1029                 ieee80211_crypto_resetkey(vap, &ni->ni_ucastkey, 
    1030                         IEEE80211_KEYIX_NONE); 
    1031                 /* XXX optimize away */ 
    1032                 IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); 
    1033  
    1034                 ni->ni_table = NULL;            /* NB: pedantic */ 
    1035                 ni->ni_ic = ic; 
    1036                 ni->ni_rxfrag = NULL; 
    1037                 ni->ni_challenge = NULL; 
    1038         } else { 
    1039                 /* XXX msg */ 
    1040                 vap->iv_stats.is_rx_nodealloc++; 
    1041         } 
    1042         return ni; 
    1043 } 
    1044  
    1045 /* 
    10461040 * Add the specified station to the station table. 
    10471041 */ 
    10481042struct ieee80211_node * 
    1049 ieee80211_dup_bss(struct ieee80211vap *vap, const u_int8_t *macaddr) 
     1043ieee80211_dup_bss(struct ieee80211vap *vap, const u_int8_t *macaddr,  
     1044                unsigned char tmp) 
    10501045{ 
    1051         struct ieee80211com *ic = vap->iv_ic; 
    10521046        struct ieee80211_node *ni; 
     1047         
     1048        // HACK 
     1049        if (tmp) 
     1050                ni = ieee80211_alloc_node(vap, macaddr); 
     1051        else 
     1052                ni = ieee80211_alloc_node_table(vap, macaddr); 
    10531053 
    1054         ni = ieee80211_alloc_node(&ic->ic_sta, vap, macaddr); 
    10551054        if (ni != NULL) { 
    1056                 /* 
    1057                  * Inherit from iv_bss. 
    1058                  */ 
    1059                 ni->ni_authmode = vap->iv_bss->ni_authmode; 
    1060                 ni->ni_txpower = vap->iv_bss->ni_txpower; 
    1061                 ni->ni_vlan = vap->iv_bss->ni_vlan;     /* XXX?? */ 
     1055                copy_bss(ni, vap->iv_bss); 
    10621056                IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 
    1063                 ieee80211_node_set_chan(ic, ni); 
    1064                 ni->ni_rsn = vap->iv_bss->ni_rsn; 
    1065                 ni->ni_rxfrag = NULL; 
     1057                /* Do this only for nodes that already have a BSS. Otherwise 
     1058                 * ic_bsschan is not set and we get a KASSERT failure. 
     1059                 * Required by ieee80211_fix_rate */ 
     1060                ieee80211_node_set_chan(vap->iv_ic, ni); 
    10661061        } 
    10671062        return ni; 
    10681063} 
     
    10701065static struct ieee80211_node * 
    10711066_ieee80211_find_wds_node(struct ieee80211_node_table *nt, const u_int8_t *macaddr) 
    10721067{ 
    1073         struct ieee80211_node *ni; 
    10741068        struct ieee80211_wds_addr *wds; 
    10751069        int hash; 
    1076         IEEE80211_NODE_LOCK_ASSERT(nt); 
     1070        IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 
    10771071 
    10781072        hash = IEEE80211_NODE_HASH(macaddr); 
    10791073        LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    10801074                if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 
    1081                         ni = wds->wds_ni; 
    10821075                        if (wds->wds_agingcount != WDS_AGING_STATIC) 
    10831076                                wds->wds_agingcount = WDS_AGING_COUNT; /* reset the aging count */ 
    1084                         ieee80211_ref_node(ni); 
    1085                         return ni; 
     1077                        return ieee80211_ref_node(wds->wds_ni); 
    10861078                } 
    10871079        } 
    10881080        return NULL; 
     
    11001092        int hash; 
    11011093        struct ieee80211_wds_addr *wds; 
    11021094 
    1103         IEEE80211_NODE_LOCK_ASSERT(nt); 
     1095        IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); 
    11041096 
    11051097        hash = IEEE80211_NODE_HASH(macaddr); 
    11061098        LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) { 
     
    11211113           nodes. */ 
    11221114        LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { 
    11231115                if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { 
    1124                         ni = wds->wds_ni; 
    1125                         ieee80211_ref_node(ni); 
    1126                         return ni; 
     1116                        return ieee80211_ref_node(wds->wds_ni); 
    11271117                } 
    11281118        } 
    11291119        return NULL; 
     
    11381128{ 
    11391129        struct ieee80211_node *ni; 
    11401130 
    1141         IEEE80211_NODE_LOCK_IRQ(nt); 
     1131        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    11421132        ni = _ieee80211_find_wds_node(nt, macaddr); 
    1143         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1133        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    11441134        return ni; 
    11451135} 
    11461136EXPORT_SYMBOL(ieee80211_find_wds_node); 
     
    11551145{ 
    11561146        struct ieee80211_node *ni; 
    11571147 
    1158         IEEE80211_NODE_LOCK_IRQ(nt); 
     1148        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    11591149        ni = _ieee80211_find_node(nt, macaddr); 
    1160         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1150        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    11611151        return ni; 
    11621152} 
    11631153#ifdef IEEE80211_DEBUG_REFCNT 
     
    11801170{ 
    11811171        struct ieee80211_node *ni; 
    11821172 
    1183         ni = ieee80211_dup_bss(vap, macaddr); 
     1173        ni = ieee80211_dup_bss(vap, macaddr, 0); 
    11841174        if (ni != NULL) { 
    11851175                /* XXX no rate negotiation; just dup */ 
    11861176                ni->ni_rates = vap->iv_bss->ni_rates; 
     
    12031193 * driver has an opportunity to setup it's private state. 
    12041194 */ 
    12051195struct ieee80211_node * 
    1206 ieee80211_add_neighbor(struct ieee80211vap *vap,       const struct ieee80211_frame *wh, 
     1196ieee80211_add_neighbor(struct ieee80211vap *vap, const struct ieee80211_frame *wh, 
    12071197        const struct ieee80211_scanparams *sp) 
    12081198{ 
    12091199        struct ieee80211com *ic = vap->iv_ic; 
    12101200        struct ieee80211_node *ni; 
    12111201 
    1212         ni = ieee80211_dup_bss(vap, wh->i_addr2);       /* XXX alloc_node? */ 
    1213         /* TODO: not really putting itself in a table */ 
     1202        ni = ieee80211_dup_bss(vap, wh->i_addr2, 1); 
    12141203        if (ni != NULL) { 
    12151204                ni->ni_esslen = sp->ssid[1]; 
    12161205                memcpy(ni->ni_essid, sp->ssid + 2, sp->ssid[1]); 
     
    12851274        /* XXX check ic_bss first in station mode */ 
    12861275        /* XXX 4-address frames? */ 
    12871276        nt = &ic->ic_sta; 
    1288         IEEE80211_NODE_LOCK_IRQ(nt); 
     1277        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    12891278        if (IS_CTL(wh) && !IS_PSPOLL(wh) /*&& !IS_RTS(ah)*/) 
    12901279                ni = _ieee80211_find_node(nt, wh->i_addr1); 
    12911280        else 
    12921281                ni = _ieee80211_find_node(nt, wh->i_addr2); 
    1293         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1282        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    12941283 
    12951284        return ni; 
    12961285#undef IS_PSPOLL 
     
    13271316 
    13281317        /* XXX can't hold lock across dup_bss due to recursive locking */ 
    13291318        nt = &vap->iv_ic->ic_sta; 
    1330         IEEE80211_NODE_LOCK_IRQ(nt); 
     1319        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    13311320        ni = _ieee80211_find_node(nt, mac); 
    1332         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1321        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    13331322 
    13341323        if (ni == NULL) { 
    13351324                if (vap->iv_opmode == IEEE80211_M_IBSS || 
     
    13561345EXPORT_SYMBOL(ieee80211_find_txnode); 
    13571346#endif 
    13581347 
    1359 /* Caller must lock the IEEE80211_NODE_LOCK 
    1360  * 
    1361  * Context: hwIRQ, softIRQ and process context 
     1348/* Context: hwIRQ, softIRQ and process context 
    13621349 */ 
    1363 static void 
     1350void 
    13641351_ieee80211_free_node(struct ieee80211_node *ni) 
    13651352{ 
    13661353        struct ieee80211vap *vap = ni->ni_vap; 
     
    13741361 
    13751362        if (vap->iv_aid_bitmap != NULL) 
    13761363                IEEE80211_AID_CLR(vap, ni->ni_associd); 
    1377         if (nt != NULL) { 
    1378                 TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 
    1379                 LIST_REMOVE(ni, ni_hash); 
    1380         } 
    1381         vap->iv_ic->ic_node_free(ni); 
    1382 } 
    13831364 
    1384 void 
    1385 #ifdef IEEE80211_DEBUG_REFCNT 
    1386 ieee80211_free_node_debug(struct ieee80211_node *ni, const char *func, int line) 
    1387 #else 
    1388 ieee80211_free_node(struct ieee80211_node *ni) 
    1389 #endif 
    1390 
    1391         struct ieee80211_node_table *nt = ni->ni_table; 
    1392         struct ieee80211com *ic = ni->ni_ic; 
    1393  
    1394 #ifdef IEEE80211_DEBUG_REFCNT 
    1395         IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, 
    1396                 "%s (%s:%u) %p<%s> refcnt %d\n", __func__, func, line, ni, 
    1397                  ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni) - 1); 
    1398 #endif 
    1399         /* 
    1400          * XXX: may need to lock out the following race. we dectestref 
    1401          *      and determine it's time to free the node. between the if() 
    1402          *      and lock, we take an rx intr to receive a frame from this 
    1403          *      node. the rx path (tasklet or intr) bumps this node's 
    1404          *      refcnt and xmits a response frame. eventually that response 
    1405          *      will get reaped, and the reaping code will attempt to use 
    1406          *      the node. the code below will delete the node prior 
    1407          *      to the reap and we could get a crash. 
    1408          * 
    1409          *      as a stopgap before delving deeper, lock intrs to 
    1410          *      prevent this case. 
    1411          */ 
    1412         IEEE80211_LOCK_IRQ(ic); 
    1413         if (ieee80211_node_dectestref(ni)) { 
    1414                 /* 
    1415                  * Beware; if the node is marked gone then it's already 
    1416                  * been removed from the table and we cannot assume the 
    1417                  * table still exists.  Regardless, there's no need to lock 
    1418                  * the table. 
    1419                  */ 
    1420                 if (ni->ni_table != NULL) { 
    1421                         IEEE80211_NODE_LOCK(nt); 
    1422                         _ieee80211_free_node(ni); 
    1423                         IEEE80211_NODE_UNLOCK(nt); 
    1424                 } else 
    1425                         _ieee80211_free_node(ni); 
    1426         } 
    1427         IEEE80211_UNLOCK_IRQ(ic); 
    1428 
    1429 #ifdef IEEE80211_DEBUG_REFCNT 
    1430 EXPORT_SYMBOL(ieee80211_free_node_debug); 
    1431 #else 
    1432 EXPORT_SYMBOL(ieee80211_free_node); 
    1433 #endif 
    1434  
    1435 /* 
    1436  * Reclaim a node.  If this is the last reference count then 
    1437  * do the normal free work.  Otherwise remove it from the node 
    1438  * table and mark it gone by clearing the back-reference. 
    1439  */ 
    1440 static void 
    1441 node_reclaim(struct ieee80211_node_table *nt, struct ieee80211_node *ni) 
    1442 
    1443  
    1444         IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, 
    1445                 "%s: remove %p<%s> from %s table, refcnt %d\n", 
    1446                 __func__, ni, ether_sprintf(ni->ni_macaddr), 
    1447                 nt->nt_name, ieee80211_node_refcnt(ni)-1); 
    1448         if (!ieee80211_node_dectestref(ni)) { 
    1449                 /* 
    1450                  * Other references are present, just remove the 
    1451                  * node from the table so it cannot be found.  When 
    1452                  * the references are dropped storage will be 
    1453                  * reclaimed.  This normally only happens for ic_bss. 
    1454                  */ 
    1455                 TAILQ_REMOVE(&nt->nt_node, ni, ni_list); 
    1456                 LIST_REMOVE(ni, ni_hash); 
    1457                 ni->ni_table = NULL;            /* clear reference */ 
    1458         } else 
    1459                 _ieee80211_free_node(ni); 
     1365        vap->iv_ic->ic_node_free(ni); 
    14601366} 
     1367EXPORT_SYMBOL(_ieee80211_free_node); 
    14611368 
    14621369static void 
    14631370ieee80211_node_table_reset(struct ieee80211_node_table *nt, 
     
    14651372{ 
    14661373        struct ieee80211_node *ni, *next; 
    14671374 
    1468         IEEE80211_NODE_LOCK_IRQ(nt); 
     1375        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    14691376        TAILQ_FOREACH_SAFE(ni, &nt->nt_node, ni_list, next) { 
    14701377                if (match != NULL && ni->ni_vap != match) 
    14711378                        continue; 
     
    14771384                        if (vap->iv_aid_bitmap != NULL) 
    14781385                                IEEE80211_AID_CLR(vap, ni->ni_associd); 
    14791386                } 
    1480                 node_reclaim(nt, ni); 
     1387                ieee80211_node_leave(ni); 
    14811388        } 
    1482         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1389        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    14831390} 
    14841391 
    14851392static void 
    14861393ieee80211_node_table_cleanup(struct ieee80211_node_table *nt) 
    14871394{ 
     1395        struct ieee80211com *ic = nt->nt_ic; 
    14881396        struct ieee80211_node *ni, *next; 
    14891397 
    14901398        TAILQ_FOREACH_SAFE(ni, &nt->nt_node, ni_list, next) { 
     
    14961404                        if (vap->iv_aid_bitmap != NULL) 
    14971405                                IEEE80211_AID_CLR(vap, ni->ni_associd); 
    14981406                } 
    1499                 node_reclaim(nt, ni); 
     1407                ic->ic_node_cleanup(ni); 
    15001408        } 
    15011409        del_timer(&nt->nt_wds_aging_timer); 
    15021410        IEEE80211_SCAN_LOCK_DESTROY(nt); 
    1503         IEEE80211_NODE_LOCK_DESTROY(nt); 
     1411        IEEE80211_NODE_TABLE_LOCK_DESTROY(nt); 
    15041412} 
    15051413 
    15061414/* 
     
    15281436        IEEE80211_SCAN_LOCK_IRQ(nt);  
    15291437        gen = ++nt->nt_scangen; 
    15301438restart: 
    1531         IEEE80211_NODE_LOCK_IRQ(nt); 
     1439        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    15321440        TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { 
    15331441                if (ni->ni_scangen == gen)      /* previously handled */ 
    15341442                        continue; 
     1443                /* Temporary entries should no longer be in the node table */ 
    15351444                /* 
    15361445                 * Ignore entries for which have yet to receive an 
    15371446                 * authentication frame.  These are transient and 
    15381447                 * will be reclaimed when the last reference to them 
    15391448                 * goes away (when frame xmits complete). 
    15401449                 */ 
    1541                 if (ic->ic_opmode == IEEE80211_M_HOSTAP && 
    1542                     (ni->ni_flags & IEEE80211_NODE_AREF) == 0) 
    1543                         continue; 
     1450                /* 
     1451                 *if (ic->ic_opmode == IEEE80211_M_HOSTAP && 
     1452                 *   (ni->ni_flags & IEEE80211_NODE_AREF) == 0) 
     1453                 *      continue; 
     1454                 */ 
    15441455                ni->ni_scangen = gen; 
    15451456                /* 
    15461457                 * Free fragment if not needed anymore 
     
    15921503                                 * ref for us as needed. 
    15931504                                 */ 
    15941505                                ieee80211_ref_node(ni); 
    1595                                 IEEE80211_NODE_UNLOCK_IRQ_EARLY(nt); 
     1506                                IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); 
    15961507                                ieee80211_send_nulldata(ni); 
    15971508                                /* XXX stat? */ 
    15981509                                goto restart; 
     
    16151526                         */ 
    16161527                        ni->ni_vap->iv_stats.is_node_timeout++; 
    16171528                        ieee80211_ref_node(ni); 
    1618                         IEEE80211_NODE_UNLOCK_IRQ_EARLY(nt); 
     1529                        IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); 
    16191530                        if (ni->ni_associd != 0) { 
    16201531                                IEEE80211_SEND_MGMT(ni, 
    16211532                                        IEEE80211_FC0_SUBTYPE_DEAUTH, 
    16221533                                        IEEE80211_REASON_AUTH_EXPIRE); 
    16231534                        } 
    16241535                        ieee80211_node_leave(ni); 
    1625                         ieee80211_free_node(ni); 
     1536                        ieee80211_unref_node(&ni); 
    16261537                        goto restart; 
    16271538                } 
    16281539        } 
    1629         IEEE80211_NODE_UNLOCK_IRQ(nt); 
     1540        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    16301541 
    16311542        IEEE80211_SCAN_UNLOCK_IRQ(nt); 
    16321543} 
     
    16611572 
    16621573        IEEE80211_SCAN_LOCK_IRQ(nt); 
    16631574        gen = ++nt->nt_scangen; 
     1575         
    16641576restart: 
    1665         IEEE80211_NODE_LOCK(nt); 
     1577        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
    16661578        TAILQ_FOREACH(ni, &nt->nt_node, ni_list) { 
    16671579                if (dev != NULL && ni->ni_vap->iv_dev != dev)  
    16681580                        continue;  /* skip node not for this vap */ 
    16691581                if (ni->ni_scangen != gen) { 
    16701582                        ni->ni_scangen = gen; 
    16711583                        (void) ieee80211_ref_node(ni); 
    1672                         IEEE80211_NODE_UNLOCK(nt); 
     1584                        IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); 
    16731585                        (*f)(arg, ni); 
    1674                         ieee80211_free_node(ni); 
     1586                         
     1587                        ieee80211_unref_node(&ni); 
    16751588                        goto restart; 
    16761589                } 
    16771590        } 
    1678         IEEE80211_NODE_UNLOCK(nt); 
     1591        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
    16791592 
    16801593        IEEE80211_SCAN_UNLOCK_IRQ(nt); 
    16811594} 
     
    19491862                "station with aid %d leaves (refcnt %u)", 
    19501863                IEEE80211_NODE_AID(ni), ieee80211_node_refcnt(ni)); 
    19511864 
     1865        /* From this point onwards we can no longer find the node, 
     1866         * so no more references are generated 
     1867         */ 
     1868        ieee80211_remove_wds_addr(nt, ni->ni_macaddr); 
     1869        ieee80211_del_wds_node(nt, ni); 
     1870        IEEE80211_NODE_TABLE_LOCK_IRQ(nt); 
     1871        _node_table_leave(nt, ni); 
     1872        IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); 
     1873 
    19521874        /* 
    19531875         * If node wasn't previously associated all 
    19541876         * we need to do is reclaim the reference. 
     1877         * This also goes for nodes that are auth'ed but 
     1878         * not associated. 
    19551879         */ 
    19561880        /* XXX ibss mode bypasses 11g and notification */ 
    19571881        if (ni->ni_associd == 0) 
     
    19691893        IEEE80211_LOCK_IRQ(ic); 
    19701894        if (vap->iv_aid_bitmap != NULL) 
    19711895                IEEE80211_AID_CLR(vap, ni->ni_associd); 
     1896 
    19721897        ni->ni_associd = 0; 
    19731898        vap->iv_sta_assoc--; 
    19741899        ic->ic_sta_assoc--; 
     1900 
    19751901#ifdef ATH_SUPERG_XR 
    19761902        if (ni->ni_vap->iv_flags & IEEE80211_F_XR) 
    19771903                ic->ic_xr_sta_assoc--; 
     
    19821908        if (IEEE80211_IS_CHAN_ANYG(ic->ic_bsschan)) 
    19831909                ieee80211_node_leave_11g(ni); 
    19841910        IEEE80211_UNLOCK_IRQ(ic); 
     1911 
    19851912        /* 
    19861913         * Cleanup station state.  In particular clear various 
    19871914         * state that might otherwise be reused if the node 
     
    19911918        ieee80211_sta_leave(ni); 
    19921919done: 
    19931920        /* 
    1994          * Remove the node from any table it's recorded in and 
    1995          * drop the caller's reference.  Removal from the table 
    1996          * is important to ensure the node is not reprocessed 
    1997          * for inactivity. 
    1998          */ 
    1999         if (nt != NULL) { 
    2000                 IEEE80211_NODE_LOCK_IRQ(nt); 
    2001                 node_reclaim(nt, ni); 
    2002                 IEEE80211_NODE_UNLOCK_IRQ(nt); 
    2003                 ieee80211_remove_wds_addr(nt,ni->ni_macaddr); 
    2004                 ieee80211_del_wds_node(nt,ni); 
    2005         } else 
    2006                 ieee80211_free_node(ni); 
     1921         * Run a cleanup and then drop the caller's reference 
     1922         */ 
     1923        ic->ic_node_cleanup(ni); 
     1924        ieee80211_unref_node(&ni); 
    20071925} 
    20081926EXPORT_SYMBOL(ieee80211_node_leave); 
    20091927 
     
    20631981void 
    20641982ieee80211_node_reset(struct ieee80211_node *ni, struct ieee80211vap *vap) 
    20651983{ 
    2066         if (ni != NULL) { 
    2067                 struct ieee80211_node_table *nt = ni->ni_table; 
    2068                 if (!nt) 
    2069                         nt = &vap->iv_ic->ic_sta; 
    2070                 IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 
    2071                 ni->ni_prev_vap = ni->ni_vap; 
    2072                 ni->ni_vap = vap; 
    2073                 ni->ni_ic = vap->iv_ic; 
    2074                 /*  
    2075                  * if node not found in the node table 
    2076                  * add it to the node table . 
    2077                  */ 
    2078                 if(nt && ieee80211_find_node(nt, ni->ni_macaddr) != ni) { 
    2079                         int hash = IEEE80211_NODE_HASH(ni->ni_macaddr); 
    2080                         IEEE80211_NODE_LOCK_IRQ(nt); 
    2081                         TAILQ_INSERT_TAIL(&nt->nt_node, ni, ni_list); 
    2082                         LIST_INSERT_HEAD(&nt->nt_hash[hash], ni, ni_hash); 
    2083                         ni->ni_table = nt; 
    2084                         IEEE80211_NODE_UNLOCK_IRQ(nt); 
    2085                 } 
    2086         } 
     1984        IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_bss->ni_bssid); 
     1985        ni->ni_prev_vap = ni->ni_vap; 
     1986        ni->ni_vap = vap; 
     1987        ni->ni_ic = vap->iv_ic; 
    20871988} 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_node.h

    old new  
    2929 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    3030 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 * 
    32  * $Id: ieee80211_node.h 2083 2007-02-06 15:33:38Z mentor $ 
     32 * $Id: ieee80211_node.h 2093 2007-02-07 21:06:25Z mentor $ 
    3333 */ 
    3434#ifndef _NET80211_IEEE80211_NODE_H_ 
    3535#define _NET80211_IEEE80211_NODE_H_ 
     
    5252 * authorized.  The latter timeout is shorter to more aggressively 
    5353 * reclaim nodes that leave part way through the 802.1x exchange. 
    5454 */ 
    55 #define IEEE80211_INACT_WAIT    15              /* inactivity interval (secs) */ 
     55#define IEEE80211_INACT_WAIT    15                             /* inactivity interval (secs) */ 
    5656#define IEEE80211_INACT_INIT    (30/IEEE80211_INACT_WAIT)       /* initial */ 
    5757#define IEEE80211_INACT_AUTH    (180/IEEE80211_INACT_WAIT)      /* associated but not authorized */ 
    5858#define IEEE80211_INACT_RUN     (300/IEEE80211_INACT_WAIT)      /* authorized */ 
    5959#define IEEE80211_INACT_PROBE   (30/IEEE80211_INACT_WAIT)       /* probe */ 
    6060#define IEEE80211_INACT_SCAN    (300/IEEE80211_INACT_WAIT)      /* scanned */ 
    6161 
    62 #define IEEE80211_TRANS_WAIT    5               /* mgt frame tx timer (secs) */ 
     62#define IEEE80211_TRANS_WAIT    5                              /* mgt frame tx timer (secs) */ 
    6363 
    6464#define IEEE80211_NODE_HASHSIZE 32 
    6565/* simple hash is enough for variation of macaddr */ 
     
    9494        struct ieee80211_node_table *ni_table; 
    9595        TAILQ_ENTRY(ieee80211_node) ni_list; 
    9696        LIST_ENTRY(ieee80211_node) ni_hash; 
    97         atomic_t ni_refcnt; 
     97        // ieee80211_node_lock_t ni_nodelock;   /* on node - notably for ref counting */ 
     98        ieee80211_node_ref_count_t ni_refcnt; 
    9899        u_int ni_scangen;                       /* gen# for timeout scan */ 
    99100        u_int8_t ni_authmode;                   /* authentication algorithm */ 
    100101        u_int16_t ni_flags;                     /* special-purpose state */ 
     
    121122        u_int16_t ni_associd;                   /* assoc response */ 
    122123        u_int16_t ni_txpower;                   /* current transmit power (in 0.5 dBm) */ 
    123124        u_int16_t ni_vlan;                      /* vlan tag */ 
    124         u_int32_t *ni_challenge;                       /* shared-key challenge */ 
     125        u_int32_t *ni_challenge;                /* shared-key challenge */ 
    125126        u_int8_t *ni_wpa_ie;                    /* captured WPA ie */ 
    126127        u_int8_t *ni_rsn_ie;                    /* captured RSN ie */ 
    127128        u_int8_t *ni_wme_ie;                    /* captured WME ie */ 
    128129        u_int8_t *ni_ath_ie;                    /* captured Atheros ie */ 
    129         u_int16_t ni_txseqs[17];                       /* tx seq per-tid */ 
    130         u_int16_t ni_rxseqs[17];                       /* rx seq previous per-tid*/ 
     130        u_int16_t ni_txseqs[17];                /* tx seq per-tid */ 
     131        u_int16_t ni_rxseqs[17];                /* rx seq previous per-tid*/ 
    131132        u_int32_t ni_rxfragstamp;               /* time stamp of last rx frag */ 
    132133        struct sk_buff *ni_rxfrag;              /* rx frag reassembly */ 
    133134        struct ieee80211_rsnparms ni_rsn;       /* RSN/WPA parameters */ 
     
    156157        struct ieee80211_channel *ni_chan; 
    157158        u_int16_t ni_fhdwell;                   /* FH only */ 
    158159        u_int8_t ni_fhindex;                    /* FH only */ 
    159         u_int8_t ni_erp;                               /* ERP from beacon/probe resp */ 
     160        u_int8_t ni_erp;                        /* ERP from beacon/probe resp */ 
    160161        u_int16_t ni_timoff;                    /* byte offset to TIM ie */ 
    161162 
    162163        /* others */ 
     
    168169        struct ieee80211vap *ni_prev_vap;       /* previously associated vap */ 
    169170        u_int8_t ni_uapsd;                      /* U-APSD per-node flags matching WMM STA Qos Info field */ 
    170171        u_int8_t ni_uapsd_maxsp;                /* maxsp from flags above */ 
    171         u_int16_t ni_uapsd_trigseq[WME_NUM_AC];       /* trigger suppression on retry */ 
     172        u_int16_t ni_uapsd_trigseq[WME_NUM_AC];       /* trigger suppression on retry */ 
    172173        __le16 ni_pschangeseq; 
    173174}; 
    174175MALLOC_DECLARE(M_80211_NODE); 
     
    186187#define WME_UAPSD_NODE_INVALIDSEQ       0xffff 
    187188#define WME_UAPSD_NODE_TRIGSEQINIT(_ni) (memset(&(_ni)->ni_uapsd_trigseq[0], 0xff, sizeof((_ni)->ni_uapsd_trigseq))) 
    188189 
    189 static __inline struct ieee80211_node * 
    190 ieee80211_ref_node(struct ieee80211_node *ni) 
    191 { 
    192         ieee80211_node_incref(ni); 
    193         return ni; 
    194 } 
    195  
    196 static __inline void 
    197 ieee80211_unref_node(struct ieee80211_node **ni) 
    198 { 
    199         ieee80211_node_decref(*ni); 
    200         *ni = NULL;                     /* guard against use */ 
    201 } 
    202  
    203190void ieee80211_node_attach(struct ieee80211com *); 
    204191void ieee80211_node_detach(struct ieee80211com *); 
    205192void ieee80211_node_vattach(struct ieee80211vap *); 
     
    242229 * is a second table for associated stations or neighbors. 
    243230 */ 
    244231struct ieee80211_node_table { 
     232        const char *nt_name;                    /* for debugging */ 
    245233        struct ieee80211com *nt_ic;             /* back reference */ 
    246         ieee80211_node_lock_t nt_nodelock;    /* on node table */ 
     234        ieee80211_node_table_lock_t nt_nodelock;      /* on node table */ 
    247235        TAILQ_HEAD(, ieee80211_node) nt_node;   /* information of all nodes */ 
    248236        ATH_LIST_HEAD(, ieee80211_node) nt_hash[IEEE80211_NODE_HASHSIZE]; 
    249237        ATH_LIST_HEAD(, ieee80211_wds_addr) nt_wds_hash[IEEE80211_NODE_HASHSIZE]; 
    250         const char *nt_name;                    /* for debugging */ 
    251238        ieee80211_scan_lock_t nt_scanlock;      /* on nt_scangen */ 
    252239        u_int nt_scangen;                       /* gen# for timeout scan */ 
    253240        int nt_inact_init;                      /* initial node inact setting */ 
    254241        struct timer_list nt_wds_aging_timer;   /* timer to age out wds entries */ 
    255242}; 
    256243 
    257 struct ieee80211_node *ieee80211_alloc_node(struct ieee80211_node_table *, 
    258         struct ieee80211vap *, const u_int8_t *); 
    259 struct ieee80211_node *ieee80211_tmp_node(struct ieee80211vap *, 
    260         const u_int8_t *); 
    261 struct ieee80211_node *ieee80211_dup_bss(struct ieee80211vap *, 
     244struct ieee80211_node *ieee80211_alloc_node_table(struct ieee80211vap *, 
    262245        const u_int8_t *); 
     246struct ieee80211_node *ieee80211_dup_bss(struct ieee80211vap *,  
     247        const u_int8_t *, unsigned char); 
    263248void ieee80211_node_reset(struct ieee80211_node *, struct ieee80211vap *); 
    264249#ifdef IEEE80211_DEBUG_REFCNT 
    265 void ieee80211_free_node_debug(struct ieee80211_node *, const char *, int); 
    266250struct ieee80211_node *ieee80211_find_node_debug(struct ieee80211_node_table *, 
    267251        const u_int8_t *, const char *, int); 
    268252struct ieee80211_node *ieee80211_find_rxnode_debug(struct ieee80211com *, 
    269253        const struct ieee80211_frame_min *, const char *, int); 
    270254struct ieee80211_node *ieee80211_find_txnode_debug(struct ieee80211vap *, 
    271255        const u_int8_t *, const char *, int); 
    272 #define ieee80211_free_node(ni) \ 
    273         ieee80211_free_node_debug(ni, __func__, __LINE__) 
    274 #define ieee80211_find_node(nt, mac) \ 
    275         ieee80211_find_node_debug(nt, mac, __func__, __LINE__) 
    276 #define ieee80211_find_rxnode(nt, wh) \ 
    277         ieee80211_find_rxnode_debug(nt, wh, __func__, __LINE__) 
    278 #define ieee80211_find_txnode(nt, mac) \ 
    279         ieee80211_find_txnode_debug(nt, mac, __func__, __LINE__) 
     256#define ieee80211_unref_node(_ni) \ 
     257        ieee80211_unref_node_debug(_ni, __func__, __LINE__) 
     258#define ieee80211_find_node(_nt, _mac) \ 
     259        ieee80211_find_node_debug(_nt, _mac, __func__, __LINE__) 
     260#define ieee80211_find_rxnode(_nt, _wh) \ 
     261        ieee80211_find_rxnode_debug(_nt, _wh, __func__, __LINE__) 
     262#define ieee80211_find_txnode(_nt, _mac) \ 
     263        ieee80211_find_txnode_debug(_nt, _mac, __func__, __LINE__) 
    280264#else 
    281 void ieee80211_free_node(struct ieee80211_node *); 
    282265 
    283266struct ieee80211_node *ieee80211_find_node(struct ieee80211_node_table *, 
    284267        const u_int8_t *); 
     
    287270struct ieee80211_node *ieee80211_find_txnode(struct ieee80211vap *, 
    288271        const u_int8_t *); 
    289272#endif 
     273 
     274void _ieee80211_free_node(struct ieee80211_node *); 
     275 
     276static __inline struct ieee80211_node * 
     277ieee80211_ref_node(struct ieee80211_node *ni) 
     278{ 
     279        ieee80211_node_incref(ni); 
     280        return ni; 
     281} 
     282 
     283static __inline struct ieee80211_node * 
     284_ieee80211_pass_node(struct ieee80211_node **pni) { 
     285        struct ieee80211_node *tmp = *pni; 
     286        *pni = NULL; 
     287        return (tmp); 
     288} 
     289 
     290#define PASS_NODE(_ni) \ 
     291        _ieee80211_pass_node(&_ni) 
     292 
     293static __inline int 
     294_ieee80211_unref_node(struct ieee80211_node *ni) { 
     295        if (ieee80211_node_dectestref(ni)) { 
     296                _ieee80211_free_node(ni); 
     297                return 1; 
     298        } else { 
     299                return 0; 
     300        } 
     301} 
     302 
     303static __inline void 
     304#ifdef IEEE80211_DEBUG_REFCNT 
     305ieee80211_unref_node_debug(struct ieee80211_node **pni, const char *func, int line) 
     306#else 
     307ieee80211_unref_node(struct ieee80211_node **pni) 
     308#endif 
     309{        
     310        struct ieee80211_node *ni = *pni; 
     311#ifdef IEEE80211_DEBUG_REFCNT 
     312        IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, 
     313                "%s (%s:%u) %p<%s> refcnt %d\n", __func__, func, line, ni, 
     314                 ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni) - 1); 
     315#endif 
     316        _ieee80211_unref_node(ni);  
     317        *pni = NULL;                    /* guard against use */ 
     318} 
     319 
    290320int ieee80211_add_wds_addr(struct ieee80211_node_table *, struct ieee80211_node *, 
    291321        const u_int8_t *, u_int8_t); 
    292322void ieee80211_remove_wds_addr(struct ieee80211_node_table *, const u_int8_t *); 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_output.c

    old new  
    2929 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    3030 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 * 
    32  * $Id: ieee80211_output.c 2076 2007-02-06 12:53:09Z kelmo
     32 * $Id: ieee80211_output.c 2093 2007-02-07 21:06:25Z mentor
    3333 */ 
    3434#ifndef EXPORT_SYMTAB 
    3535#define EXPORT_SYMTAB 
     
    254254                goto bad; 
    255255        } 
    256256         
    257         cb->ni = ni
     257        cb->ni = ieee80211_ref_node(ni)
    258258         
    259259        /* power-save checks */ 
    260260        if (WME_UAPSD_AC_CAN_TRIGGER(skb->priority, ni)) { 
     
    293293        } 
    294294#endif 
    295295        ieee80211_parent_queue_xmit(skb); 
     296        ieee80211_unref_node(&ni); 
    296297        return 0; 
    297298 
    298299bad: 
    299300        if (skb != NULL) 
    300301                dev_kfree_skb(skb); 
    301302        if (ni != NULL) 
    302                 ieee80211_free_node(ni); 
     303                ieee80211_unref_node(&ni); 
    303304        return 0; 
    304305} 
    305306 
     
    453454        if (skb == NULL) { 
    454455                /* XXX debug msg */ 
    455456                vap->iv_stats.is_tx_nobuf++; 
    456                 ieee80211_free_node(ni); 
     457                ieee80211_unref_node(&ni); 
    457458                return -ENOMEM; 
    458459        } 
    459460        cb = (struct ieee80211_cb *)skb->cb; 
     
    507508        u_int8_t *frm; 
    508509        int tid; 
    509510 
    510         ieee80211_ref_node(ni); 
    511511        skb = ieee80211_getmgtframe(&frm, 2); 
    512512        if (skb == NULL) { 
    513513                /* XXX debug msg */ 
    514514                vap->iv_stats.is_tx_nobuf++; 
    515                 ieee80211_free_node(ni); 
    516515                return -ENOMEM; 
    517516        } 
    518517        cb = (struct ieee80211_cb *)skb->cb; 
    519         cb->ni = ni
     518        cb->ni = ieee80211_ref_node(ni)
    520519 
    521520        skb->priority = ac; 
    522521        qwh = (struct ieee80211_qosframe *)skb_push(skb, sizeof(struct ieee80211_qosframe)); 
     
    865864                                nt = &ic->ic_sta; 
    866865                                ni_wds = ieee80211_find_wds_node(nt, eh.ether_shost); 
    867866                                if (ni_wds) 
    868                                         ieee80211_free_node(ni_wds); /* Decr ref count */ 
     867                                        ieee80211_unref_node(&ni_wds); /* Decr ref count */ 
    869868                                else 
    870869                                        ieee80211_add_wds_addr(nt, ni, eh.ether_shost, 0); 
    871870                        } 
     
    17191718                __func__, __LINE__, 
    17201719                ni, ether_sprintf(ni->ni_macaddr), 
    17211720                ieee80211_node_refcnt(ni) + 1); 
    1722         ieee80211_ref_node(ni); 
    17231721 
    17241722        /* 
    17251723         * prreq frame format 
     
    17351733               vap->app_ie[IEEE80211_APPIE_FRAME_PROBE_REQ].length); 
    17361734        if (skb == NULL) { 
    17371735                vap->iv_stats.is_tx_nobuf++; 
    1738                 ieee80211_free_node(ni); 
    17391736                return -ENOMEM; 
    17401737        } 
    17411738 
     
    17581755        skb_trim(skb, frm - skb->data); 
    17591756 
    17601757        cb = (struct ieee80211_cb *)skb->cb; 
    1761         cb->ni = ni
     1758        cb->ni = ieee80211_ref_node(ni)
    17621759 
    17631760        wh = (struct ieee80211_frame *) 
    17641761                skb_push(skb, sizeof(struct ieee80211_frame)); 
     
    22332230                mod_timer(&vap->iv_mgtsend, jiffies + timer * HZ); 
    22342231        return 0; 
    22352232bad: 
    2236         ieee80211_free_node(ni); 
     2233        ieee80211_unref_node(&ni); 
    22372234        return ret; 
    22382235#undef senderr 
    22392236} 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_power.c

    old new  
    2929 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    3030 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 * 
    32  * $Id: ieee80211_power.c 1721 2006-09-20 08:45:13Z mentor $ 
     32 * $Id: ieee80211_power.c 2064 2007-02-01 20:49:37Z mentor $ 
    3333 */ 
    3434#ifndef EXPORT_SYMTAB 
    3535#define EXPORT_SYMTAB 
     
    109109int 
    110110ieee80211_node_saveq_drain(struct ieee80211_node *ni) 
    111111{ 
     112        struct ieee80211_cb *cb = NULL; 
    112113        struct sk_buff *skb; 
    113114        int qlen; 
    114115 
    115116        IEEE80211_NODE_SAVEQ_LOCK(ni); 
    116117        qlen = skb_queue_len(&ni->ni_savedq); 
    117118        while ((skb = __skb_dequeue(&ni->ni_savedq)) != NULL) { 
    118                 ieee80211_free_node(ni); 
     119                cb = (struct ieee80211_cb *) skb->cb; 
     120                ieee80211_unref_node(&cb->ni); 
    119121                dev_kfree_skb_any(skb); 
    120122        } 
    121123        IEEE80211_NODE_SAVEQ_UNLOCK(ni); 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_proto.c

    old new  
    2929 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    3030 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 * 
    32  * $Id: ieee80211_proto.c 1849 2006-12-08 17:20:08Z proski
     32 * $Id: ieee80211_proto.c 2064 2007-02-01 20:49:37Z mentor
    3333 */ 
    3434#ifndef EXPORT_SYMTAB 
    3535#define EXPORT_SYMTAB 
     
    14561456                                 */                              
    14571457                                if (vap->iv_opmode == IEEE80211_M_WDS) { 
    14581458                                        struct ieee80211_node *wds_ni; 
    1459                                         wds_ni = ieee80211_alloc_node(&ic->ic_sta, vap, vap->wds_mac); 
     1459                                        wds_ni = ieee80211_alloc_node_table(vap, vap->wds_mac); 
    14601460                                        if (wds_ni != NULL) { 
    14611461                                                if (ieee80211_add_wds_addr(&ic->ic_sta, wds_ni, vap->wds_mac, 1) == 0) { 
    14621462                                                        ieee80211_node_authorize(wds_ni); 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_scan_sta.c

    old new  
    2828 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    2929 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3030 * 
    31  * $Id: ieee80211_scan_sta.c 1721 2006-09-20 08:45:13Z mentor $ 
     31 * $Id: ieee80211_scan_sta.c 2064 2007-02-01 20:49:37Z mentor $ 
    3232 */ 
    3333#ifndef EXPORT_SYMTAB 
    3434#define EXPORT_SYMTAB 
     
    762762        if (se->se_rssi < STA_RSSI_MIN) 
    763763                fail |= 0x100; 
    764764#ifdef IEEE80211_DEBUG 
    765         if (ieee80211_msg(vap, IEEE80211_MSG_SCAN | IEEE80211_MSG_ROAM)) { 
     765        if (ieee80211_msg_is_reported(vap, IEEE80211_MSG_SCAN | IEEE80211_MSG_ROAM)) { 
    766766                printf(" %03x", fail); 
    767767                printf(" %c %s", 
    768768                        fail & 0x40 ? '=' : fail & 0x80 ? '^' : fail ? '-' : '+', 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_var.h

    old new  
    2929 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
    3030 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    3131 * 
    32  * $Id: ieee80211_var.h 1988 2007-01-22 03:07:30Z proski
     32 * $Id: ieee80211_var.h 2092 2007-02-07 20:45:27Z mentor
    3333 */ 
    3434#ifndef _NET80211_IEEE80211_VAR_H_ 
    3535#define _NET80211_IEEE80211_VAR_H_ 
     
    3737/* 
    3838 * Definitions for IEEE 802.11 drivers. 
    3939 */ 
    40 #define IEEE80211_DEBUG 
    41 #undef  IEEE80211_DEBUG_REFCNT                  /* node refcnt stuff */ 
     40#include <net80211/ieee80211_debug.h> 
    4241 
    4342#include <net80211/ieee80211_linux.h> 
    4443 
     
    230229        /* new station association callback/notification */ 
    231230        void (*ic_newassoc)(struct ieee80211_node *, int); 
    232231        /* node state management */ 
    233         struct ieee80211_node *(*ic_node_alloc)(struct ieee80211_node_table *, 
    234                 struct ieee80211vap *); 
     232        struct ieee80211_node *(*ic_node_alloc)(struct ieee80211vap *); 
    235233        void (*ic_node_free)(struct ieee80211_node *); 
    236234        void (*ic_node_cleanup)(struct ieee80211_node *); 
    237235        u_int8_t (*ic_node_getrssi)(const struct ieee80211_node *); 
     
    406404        u_int32_t app_filter;                   /* filters which management frames are forwarded to app */ 
    407405 
    408406}; 
     407 
    409408MALLOC_DECLARE(M_80211_VAP); 
    410409 
    411410#define IEEE80211_ADDR_NULL(a1)         (memcmp(a1, "\x00\x00\x00\x00\x00\x00", \ 
     
    613612                size = roundup(size, sizeof(u_int32_t)); 
    614613        return size; 
    615614} 
    616  
    617 #define IEEE80211_MSG_DEBUG     0x40000000      /* IFF_DEBUG equivalent */ 
    618 #define IEEE80211_MSG_DUMPPKTS  0x20000000      /* IFF_LINK2 equivalent */ 
    619 #define IEEE80211_MSG_CRYPTO    0x10000000      /* crypto work */ 
    620 #define IEEE80211_MSG_INPUT     0x08000000      /* input handling */ 
    621 #define IEEE80211_MSG_XRATE     0x04000000      /* rate set handling */ 
    622 #define IEEE80211_MSG_ELEMID    0x02000000      /* element id parsing */ 
    623 #define IEEE80211_MSG_NODE      0x01000000      /* node handling */ 
    624 #define IEEE80211_MSG_ASSOC     0x00800000      /* association handling */ 
    625 #define IEEE80211_MSG_AUTH      0x00400000      /* authentication handling */ 
    626 #define IEEE80211_MSG_SCAN      0x00200000      /* scanning */ 
    627 #define IEEE80211_MSG_OUTPUT    0x00100000      /* output handling */ 
    628 #define IEEE80211_MSG_STATE     0x00080000      /* state machine */ 
    629 #define IEEE80211_MSG_POWER     0x00040000      /* power save handling */ 
    630 #define IEEE80211_MSG_DOT1X     0x00020000      /* 802.1x authenticator */ 
    631 #define IEEE80211_MSG_DOT1XSM   0x00010000      /* 802.1x state machine */ 
    632 #define IEEE80211_MSG_RADIUS    0x00008000      /* 802.1x radius client */ 
    633 #define IEEE80211_MSG_RADDUMP   0x00004000      /* dump 802.1x radius packets */ 
    634 #define IEEE80211_MSG_RADKEYS   0x00002000      /* dump 802.1x keys */ 
    635 #define IEEE80211_MSG_WPA       0x00001000      /* WPA/RSN protocol */ 
    636 #define IEEE80211_MSG_ACL       0x00000800      /* ACL handling */ 
    637 #define IEEE80211_MSG_WME       0x00000400      /* WME protocol */ 
    638 #define IEEE80211_MSG_SUPG      0x00000200      /* SUPERG */ 
    639 #define IEEE80211_MSG_DOTH      0x00000100      /* 11.h */ 
    640 #define IEEE80211_MSG_INACT     0x00000080      /* inactivity handling */ 
    641 #define IEEE80211_MSG_ROAM      0x00000040      /* sta-mode roaming */ 
    642  
    643 #define IEEE80211_MSG_ANY       0xffffffff      /* anything */ 
    644  
    645 #ifdef IEEE80211_DEBUG 
    646 #define ieee80211_msg(_vap, _m) ((_vap)->iv_debug & (_m)) 
    647 #define IEEE80211_DPRINTF(_vap, _m, _fmt, ...) do {                     \ 
    648         if (ieee80211_msg(_vap, _m))                                    \ 
    649                 ieee80211_note(_vap, _fmt, __VA_ARGS__);                \ 
    650 } while (0) 
    651 #define IEEE80211_NOTE(_vap, _m, _ni, _fmt, ...) do {                   \ 
    652         if (ieee80211_msg(_vap, _m))                                    \ 
    653                 ieee80211_note_mac(_vap, (_ni)->ni_macaddr, _fmt, __VA_ARGS__);\ 
    654 } while (0) 
    655 #define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...) do {              \ 
    656         if (ieee80211_msg(_vap, _m))                                    \ 
    657                 ieee80211_note_mac(_vap, _mac, _fmt, __VA_ARGS__);      \ 
    658 } while (0) 
    659 #define IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...) do {             \ 
    660         if (ieee80211_msg(_vap, _m))                                    \ 
    661                 ieee80211_note_frame(_vap, _wh, _fmt, __VA_ARGS__);     \ 
    662 } while (0) 
    663 void ieee80211_note(struct ieee80211vap *, const char *, ...); 
    664 void ieee80211_note_mac(struct ieee80211vap *, 
    665         const u_int8_t mac[IEEE80211_ADDR_LEN], const char *, ...); 
    666 void ieee80211_note_frame(struct ieee80211vap *, 
    667         const struct ieee80211_frame *, const char *, ...); 
    668 #define ieee80211_msg_debug(_vap) \ 
    669         ieee80211_msg(_vap, IEEE80211_MSG_DEBUG) 
    670 #define ieee80211_msg_dumppkts(_vap) \ 
    671         ieee80211_msg(_vap, IEEE80211_MSG_DUMPPKTS) 
    672 #define ieee80211_msg_input(_vap) \ 
    673         ieee80211_msg(_vap, IEEE80211_MSG_INPUT) 
    674 #define ieee80211_msg_radius(_vap) \ 
    675         ieee80211_msg(_vap, IEEE80211_MSG_RADIUS) 
    676 #define ieee80211_msg_dumpradius(_vap) \ 
    677         ieee80211_msg(_vap, IEEE80211_MSG_RADDUMP) 
    678 #define ieee80211_msg_dumpradkeys(_vap) \ 
    679         ieee80211_msg(_vap, IEEE80211_MSG_RADKEYS) 
    680 #define ieee80211_msg_scan(_vap) \ 
    681         ieee80211_msg(_vap, IEEE80211_MSG_SCAN) 
    682 #define ieee80211_msg_assoc(_vap) \ 
    683         ieee80211_msg(_vap, IEEE80211_MSG_ASSOC) 
    684 #else /* IEEE80211_DEBUG */ 
    685 #define IEEE80211_DPRINTF(_vap, _m, _fmt, ...) 
    686 #define IEEE80211_NOTE(_vap, _m, _wh, _fmt, ...) 
    687 #define IEEE80211_NOTE_FRAME(_vap, _m, _wh, _fmt, ...) 
    688 #define IEEE80211_NOTE_MAC(_vap, _m, _mac, _fmt, ...) 
    689 #endif /* IEEE80211_DEBUG */ 
    690  
    691615#endif /* _NET80211_IEEE80211_VAR_H_ */ 
  • svn.madwifi.org-trunk-2115/net80211/ieee80211_wireless.c

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: ieee80211_wireless.c 2103 2007-02-12 05:25:25Z proski
     36 * $Id: ieee80211_wireless.c 2098 2007-02-09 00:04:06Z mentor
    3737 */ 
    3838 
    3939/* 
     
    31813181                error = -ENXIO; 
    31823182        ieee80211_key_update_end(vap); 
    31833183        if (ni != NULL) 
    3184                 ieee80211_free_node(ni); 
     3184                ieee80211_unref_node(&ni); 
    31853185#ifdef ATH_SUPERG_XR 
    31863186        /* set the same params on the xr vap device if exists */ 
    31873187        if (vap->iv_xrvap && !(vap->iv_flags & IEEE80211_F_XR)) 
     
    32413241                memset(ik.ik_keydata, 0, sizeof(ik.ik_keydata)); 
    32423242        } 
    32433243        if (ni != NULL) 
    3244                 ieee80211_free_node(ni); 
     3244                ieee80211_unref_node(&ni); 
    32453245        return (copy_to_user(iwr->u.data.pointer, &ik, sizeof(ik)) ? -EFAULT : 0); 
    32463246} 
    32473247 
     
    32643264                        return -EINVAL;         /* XXX */ 
    32653265                /* XXX error return */ 
    32663266                ieee80211_crypto_delkey(vap, &ni->ni_ucastkey, ni); 
    3267                 ieee80211_free_node(ni); 
     3267                ieee80211_unref_node(&ni); 
    32683268        } else { 
    32693269                if (kid >= IEEE80211_WEP_NKID) 
    32703270                        return -EINVAL; 
     
    33673367                                        return -EINVAL; 
    33683368                                if (dev == ni->ni_vap->iv_dev) 
    33693369                                        domlme(mlme, ni); 
    3370                                 ieee80211_free_node(ni); 
     3370                                ieee80211_unref_node(&ni); 
    33713371                        } else 
    33723372                                ieee80211_iterate_dev_nodes(dev, &ic->ic_sta, domlme, mlme); 
    33733373                        break; 
     
    33863386                        ieee80211_node_authorize(ni); 
    33873387                else 
    33883388                        ieee80211_node_unauthorize(ni); 
    3389                 ieee80211_free_node(ni); 
     3389                ieee80211_unref_node(&ni); 
    33903390                break; 
    33913391        case IEEE80211_MLME_CLEAR_STATS: 
    33923392                if (vap->iv_opmode != IEEE80211_M_HOSTAP) 
     
    33973397                 
    33983398                /* clear statistics */ 
    33993399                memset(&ni->ni_stats, 0, sizeof(struct ieee80211_nodestats)); 
    3400                 ieee80211_free_node(ni); 
     3400                ieee80211_unref_node(&ni); 
    34013401                break; 
    34023402        default: 
    34033403                return -EINVAL; 
     
    37673767                        ielen = sizeof(wpaie.rsn_ie); 
    37683768                memcpy(wpaie.rsn_ie, ni->ni_rsn_ie, ielen); 
    37693769        } 
    3770         ieee80211_free_node(ni); 
     3770        ieee80211_unref_node(&ni); 
    37713771        return (copy_to_user(iwr->u.data.pointer, &wpaie, sizeof(wpaie)) ? 
    37723772                -EFAULT : 0); 
    37733773} 
     
    37943794        /* NB: copy out only the statistics */ 
    37953795        error = copy_to_user(iwr->u.data.pointer + off, &ni->ni_stats, 
    37963796                iwr->u.data.length - off); 
    3797         ieee80211_free_node(ni); 
     3797        ieee80211_unref_node(&ni); 
    37983798        return (error ? -EFAULT : 0); 
    37993799} 
    38003800 
  • svn.madwifi.org-trunk-2115/tools/80211stats.c

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: 80211stats.c 2088 2007-02-07 03:18:49Z proski
     36 * $Id: 80211stats.c 2093 2007-02-07 21:06:25Z mentor
    3737 */ 
    3838 
    3939/* 
  • svn.madwifi.org-trunk-2115/tools/athchans.c

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: athchans.c 2088 2007-02-07 03:18:49Z proski
     36 * $Id: athchans.c 2093 2007-02-07 21:06:25Z mentor
    3737 */ 
    3838 
    3939/* 
  • svn.madwifi.org-trunk-2115/tools/athkey.c

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: athkey.c 2088 2007-02-07 03:18:49Z proski
     36 * $Id: athkey.c 2093 2007-02-07 21:06:25Z mentor
    3737 */ 
    3838 
    3939/* 
  • svn.madwifi.org-trunk-2115/tools/wlanconfig.c

    old new  
    3333 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
    3434 * THE POSSIBILITY OF SUCH DAMAGES. 
    3535 * 
    36  * $Id: wlanconfig.c 2088 2007-02-07 03:18:49Z proski
     36 * $Id: wlanconfig.c 2093 2007-02-07 21:06:25Z mentor
    3737 */ 
    3838 
    3939/*