The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/iwi/if_iwivar.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $FreeBSD$       */
    2 
    3 /*-
    4  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
    5  *
    6  * Copyright (c) 2004, 2005
    7  *      Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice unmodified, this list of conditions, and the following
   14  *    disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  */
   31 
   32 struct iwi_rx_radiotap_header {
   33         struct ieee80211_radiotap_header wr_ihdr;
   34         uint8_t         wr_flags;
   35         uint8_t         wr_rate;
   36         uint16_t        wr_chan_freq;
   37         uint16_t        wr_chan_flags;
   38         int8_t          wr_antsignal;
   39         int8_t          wr_antnoise;
   40         uint8_t         wr_antenna;
   41 } __packed __aligned(8);
   42 
   43 #define IWI_RX_RADIOTAP_PRESENT                                         \
   44         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
   45          (1 << IEEE80211_RADIOTAP_RATE) |                               \
   46          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
   47          (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |                      \
   48          (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |                       \
   49          (1 << IEEE80211_RADIOTAP_ANTENNA))
   50 
   51 struct iwi_tx_radiotap_header {
   52         struct ieee80211_radiotap_header wt_ihdr;
   53         uint8_t         wt_flags;
   54         uint8_t         wt_pad;
   55         uint16_t        wt_chan_freq;
   56         uint16_t        wt_chan_flags;
   57 } __packed;
   58 
   59 #define IWI_TX_RADIOTAP_PRESENT                                         \
   60         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
   61          (1 << IEEE80211_RADIOTAP_CHANNEL))
   62 
   63 struct iwi_cmd_ring {
   64         bus_dma_tag_t           desc_dmat;
   65         bus_dmamap_t            desc_map;
   66         bus_addr_t              physaddr;
   67         struct iwi_cmd_desc     *desc;
   68         int                     count;
   69         int                     queued;
   70         int                     cur;
   71         int                     next;
   72 };
   73 
   74 struct iwi_tx_data {
   75         bus_dmamap_t            map;
   76         struct mbuf             *m;
   77         struct ieee80211_node   *ni;
   78 };
   79 
   80 struct iwi_tx_ring {
   81         bus_dma_tag_t           desc_dmat;
   82         bus_dma_tag_t           data_dmat;
   83         bus_dmamap_t            desc_map;
   84         bus_addr_t              physaddr;
   85         bus_addr_t              csr_ridx;
   86         bus_addr_t              csr_widx;
   87         struct iwi_tx_desc      *desc;
   88         struct iwi_tx_data      *data;
   89         int                     count;
   90         int                     queued;
   91         int                     cur;
   92         int                     next;
   93 };
   94 
   95 struct iwi_rx_data {
   96         bus_dmamap_t    map;
   97         bus_addr_t      physaddr;
   98         uint32_t        reg;
   99         struct mbuf     *m;
  100 };
  101 
  102 struct iwi_rx_ring {
  103         bus_dma_tag_t           data_dmat;
  104         struct iwi_rx_data      *data;
  105         int                     count;
  106         int                     cur;
  107 };
  108 
  109 struct iwi_node {
  110         struct ieee80211_node   in_node;
  111         int                     in_station;
  112 #define IWI_MAX_IBSSNODE        32
  113 };
  114 
  115 struct iwi_fw {
  116         const struct firmware   *fp;            /* image handle */
  117         const char              *data;          /* firmware image data */
  118         size_t                  size;           /* firmware image size */
  119         const char              *name;          /* associated image name */
  120 };
  121 
  122 struct iwi_vap {
  123         struct ieee80211vap     iwi_vap;
  124 
  125         int                     (*iwi_newstate)(struct ieee80211vap *,
  126                                     enum ieee80211_state, int);
  127 };
  128 #define IWI_VAP(vap)    ((struct iwi_vap *)(vap))
  129 
  130 struct iwi_softc {
  131         struct mtx              sc_mtx;
  132         struct ieee80211com     sc_ic;
  133         struct mbufq            sc_snd;
  134         device_t                sc_dev;
  135 
  136         void                    (*sc_node_free)(struct ieee80211_node *);
  137 
  138         uint8_t                 sc_mcast[IEEE80211_ADDR_LEN];
  139         struct unrhdr           *sc_unr;
  140 
  141         uint32_t                flags;
  142 #define IWI_FLAG_FW_INITED      (1 << 0)
  143 #define IWI_FLAG_BUSY           (1 << 3)        /* busy sending a command */
  144 #define IWI_FLAG_ASSOCIATED     (1 << 4)        /* currently associated  */
  145 #define IWI_FLAG_CHANNEL_SCAN   (1 << 5)
  146         uint32_t                fw_state;
  147 #define IWI_FW_IDLE             0
  148 #define IWI_FW_LOADING          1
  149 #define IWI_FW_ASSOCIATING      2
  150 #define IWI_FW_DISASSOCIATING   3
  151 #define IWI_FW_SCANNING         4
  152         struct iwi_cmd_ring     cmdq;
  153         struct iwi_tx_ring      txq[WME_NUM_AC];
  154         struct iwi_rx_ring      rxq;
  155 
  156         struct resource         *irq;
  157         struct resource         *mem;
  158         bus_space_tag_t         sc_st;
  159         bus_space_handle_t      sc_sh;
  160         void                    *sc_ih;
  161 
  162         /*
  163          * The card needs external firmware images to work, which is made of a
  164          * bootloader, microcode and firmware proper. In version 3.00 and
  165          * above, all pieces are contained in a single image, preceded by a
  166          * struct iwi_firmware_hdr indicating the size of the 3 pieces.
  167          * Old firmware < 3.0 has separate boot and ucode, so we need to
  168          * load all of them explicitly.
  169          * To avoid issues related to fragmentation, we keep the block of
  170          * dma-ble memory around until detach time, and reallocate it when
  171          * it becomes too small. fw_dma_size is the size currently allocated.
  172          */
  173         int                     fw_dma_size;
  174         uint32_t                fw_flags;       /* allocation status */
  175 #define IWI_FW_HAVE_DMAT        0x01
  176 #define IWI_FW_HAVE_MAP         0x02
  177 #define IWI_FW_HAVE_PHY         0x04
  178         bus_dma_tag_t           fw_dmat;
  179         bus_dmamap_t            fw_map;
  180         bus_addr_t              fw_physaddr;
  181         void                    *fw_virtaddr;
  182         enum ieee80211_opmode   fw_mode;        /* mode of current firmware */
  183         struct iwi_fw           fw_boot;        /* boot firmware */
  184         struct iwi_fw           fw_uc;          /* microcode */
  185         struct iwi_fw           fw_fw;          /* operating mode support */
  186 
  187         int                     curchan;        /* current h/w channel # */
  188         int                     antenna;
  189         int                     bluetooth;
  190         struct iwi_associate    assoc;
  191         struct iwi_wme_params   wme[3];
  192         u_int                   sc_scangen;
  193 
  194         struct task             sc_radiontask;  /* radio on processing */
  195         struct task             sc_radiofftask; /* radio off processing */
  196         struct task             sc_restarttask; /* restart adapter processing */
  197         struct task             sc_disassoctask;
  198         struct task             sc_monitortask;
  199 
  200         unsigned int            sc_running : 1, /* initialized */
  201                                 sc_softled : 1, /* enable LED gpio status */
  202                                 sc_ledstate: 1, /* LED on/off state */
  203                                 sc_blinking: 1; /* LED blink operation active */
  204         u_int                   sc_nictype;     /* NIC type from EEPROM */
  205         u_int                   sc_ledpin;      /* mask for activity LED */
  206         u_int                   sc_ledidle;     /* idle polling interval */
  207         int                     sc_ledevent;    /* time of last LED event */
  208         u_int8_t                sc_rxrate;      /* current rx rate for LED */
  209         u_int8_t                sc_rxrix;
  210         u_int8_t                sc_txrate;      /* current tx rate for LED */
  211         u_int8_t                sc_txrix;
  212         u_int16_t               sc_ledoff;      /* off time for current blink */
  213         struct callout          sc_ledtimer;    /* led off timer */
  214         struct callout          sc_wdtimer;     /* watchdog timer */
  215         struct callout          sc_rftimer;     /* rfkill timer */
  216 
  217         int                     sc_tx_timer;
  218         int                     sc_state_timer; /* firmware state timer */
  219         int                     sc_busy_timer;  /* firmware cmd timer */
  220 
  221         struct iwi_rx_radiotap_header sc_rxtap;
  222         struct iwi_tx_radiotap_header sc_txtap;
  223 
  224         struct iwi_notif_link_quality sc_linkqual;
  225         int                     sc_linkqual_valid;
  226 };
  227 
  228 #define IWI_STATE_BEGIN(_sc, _state)    do {                    \
  229         KASSERT(_sc->fw_state == IWI_FW_IDLE,                   \
  230             ("iwi firmware not idle, state %s", iwi_fw_states[_sc->fw_state]));\
  231         _sc->fw_state = _state;                                 \
  232         _sc->sc_state_timer = 5;                                \
  233         DPRINTF(("enter %s state\n", iwi_fw_states[_state]));   \
  234 } while (0)
  235 
  236 #define IWI_STATE_END(_sc, _state)      do {                    \
  237         if (_sc->fw_state == _state)                            \
  238                 DPRINTF(("exit %s state\n", iwi_fw_states[_state])); \
  239          else                                                   \
  240                 DPRINTF(("expected %s state, got %s\n", \
  241                     iwi_fw_states[_state], iwi_fw_states[_sc->fw_state])); \
  242         _sc->fw_state = IWI_FW_IDLE;                            \
  243         wakeup(_sc);                                            \
  244         _sc->sc_state_timer = 0;                                \
  245 } while (0)
  246 /*
  247  * NB.: This models the only instance of async locking in iwi_init_locked
  248  *      and must be kept in sync.
  249  */
  250 #define IWI_LOCK_INIT(sc) \
  251         mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->sc_dev), \
  252             MTX_NETWORK_LOCK, MTX_DEF)
  253 #define IWI_LOCK_DESTROY(sc)    mtx_destroy(&(sc)->sc_mtx)
  254 #define IWI_LOCK_DECL   int     __waslocked = 0
  255 #define IWI_LOCK_ASSERT(sc)     mtx_assert(&(sc)->sc_mtx, MA_OWNED)
  256 #define IWI_LOCK(sc)    do {                            \
  257         if (!(__waslocked = mtx_owned(&(sc)->sc_mtx)))  \
  258                 mtx_lock(&(sc)->sc_mtx);                \
  259 } while (0)
  260 #define IWI_UNLOCK(sc)  do {                    \
  261         if (!__waslocked)                       \
  262                 mtx_unlock(&(sc)->sc_mtx);      \
  263 } while (0)

Cache object: bca826f89a08c6d6af6a937a1f215dae


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.