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/wpi/if_wpivar.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  * Copyright (c) 2006,2007
    5  *      Damien Bergamini <damien.bergamini@free.fr>
    6  *
    7  * Permission to use, copy, modify, and distribute this software for any
    8  * purpose with or without fee is hereby granted, provided that the above
    9  * copyright notice and this permission notice appear in all copies.
   10  *
   11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
   12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
   13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
   14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
   15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
   16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
   17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   18  */
   19 #if ( __FreeBSD_version > 700000 )
   20 #include <net80211/ieee80211_amrr.h>
   21 #else
   22 #include <dev/wpi/ieee80211_amrr.h>
   23 #endif
   24 
   25 /* DMA mapping */
   26 struct wpi_mapping {
   27         int nsegs;
   28         bus_dma_segment_t segs[WPI_MAX_SCATTER];
   29 };
   30 
   31 struct wpi_rx_radiotap_header {
   32         struct ieee80211_radiotap_header wr_ihdr;
   33         uint64_t        wr_tsft;
   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_dbm_antsignal;
   39         int8_t          wr_dbm_antnoise;
   40         uint8_t         wr_antenna;
   41 };
   42 
   43 #define WPI_RX_RADIOTAP_PRESENT                                         \
   44         ((1 << IEEE80211_RADIOTAP_TSFT) |                               \
   45          (1 << IEEE80211_RADIOTAP_FLAGS) |                              \
   46          (1 << IEEE80211_RADIOTAP_RATE) |                               \
   47          (1 << IEEE80211_RADIOTAP_CHANNEL) |                            \
   48          (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |                      \
   49          (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) |                       \
   50          (1 << IEEE80211_RADIOTAP_ANTENNA))
   51 
   52 struct wpi_tx_radiotap_header {
   53         struct ieee80211_radiotap_header wt_ihdr;
   54         uint8_t         wt_flags;
   55         uint8_t         wt_rate;
   56         uint16_t        wt_chan_freq;
   57         uint16_t        wt_chan_flags;
   58         uint8_t         wt_hwqueue;
   59 };
   60 
   61 #define WPI_TX_RADIOTAP_PRESENT                                         \
   62         ((1 << IEEE80211_RADIOTAP_FLAGS) |                              \
   63          (1 << IEEE80211_RADIOTAP_RATE) |                               \
   64          (1 << IEEE80211_RADIOTAP_CHANNEL))
   65 
   66 struct wpi_dma_info {
   67         bus_dma_tag_t           tag;
   68         bus_dmamap_t            map;
   69         bus_addr_t              paddr;
   70         caddr_t                 vaddr;
   71         bus_size_t              size;
   72 };
   73 
   74 struct wpi_tx_data {
   75         bus_dmamap_t            map;
   76         struct mbuf             *m;
   77         struct ieee80211_node   *ni;
   78 };
   79 
   80 struct wpi_tx_ring {
   81         struct wpi_dma_info     desc_dma;
   82         struct wpi_dma_info     cmd_dma;
   83         struct wpi_tx_desc      *desc;
   84         struct wpi_tx_cmd       *cmd;
   85         struct wpi_tx_data      *data;
   86         bus_dma_tag_t           data_dmat;
   87         int                     qid;
   88         int                     count;
   89         int                     queued;
   90         int                     cur;
   91 };
   92 
   93 #define WPI_RBUF_COUNT ( WPI_RX_RING_COUNT + 16 )
   94 
   95 struct wpi_softc;
   96 
   97 struct wpi_rbuf {
   98         struct wpi_softc        *sc;
   99         bus_addr_t              paddr;
  100         caddr_t                 vaddr;
  101         SLIST_ENTRY(wpi_rbuf)   next;
  102 };
  103 
  104 struct wpi_rx_data {
  105         struct mbuf     *m;
  106 };
  107 
  108 struct wpi_rx_ring {
  109         struct wpi_dma_info     desc_dma;
  110         struct wpi_dma_info     buf_dma;
  111         uint32_t                *desc;
  112         struct wpi_rx_data      data[WPI_RX_RING_COUNT];
  113         struct wpi_rbuf         rbuf[WPI_RBUF_COUNT];
  114         SLIST_HEAD(, wpi_rbuf)  freelist;
  115         int                     cur;
  116 };
  117 
  118 struct wpi_amrr {
  119         struct  ieee80211_node ni;      /* must be the first */
  120         int     txcnt;
  121         int     retrycnt;
  122         int     success;
  123         int     success_threshold;
  124         int     recovery;
  125 };
  126 
  127 struct wpi_node {
  128         struct  ieee80211_node ni;      /* must be the first */
  129         struct  ieee80211_amrr_node     amn;
  130 };
  131 
  132 struct wpi_power_sample {
  133         uint8_t index;
  134         int8_t  power;
  135 };
  136 
  137 struct wpi_power_group {
  138 #define WPI_SAMPLES_COUNT       5
  139     struct wpi_power_sample samples[WPI_SAMPLES_COUNT];
  140     uint8_t     chan;
  141     int8_t      maxpwr;
  142     int16_t     temp;
  143 };
  144 
  145 struct wpi_softc {
  146         device_t                sc_dev;
  147         struct ifnet            *sc_ifp;
  148 
  149         /* net80211 driver specifics */
  150         struct ieee80211com     sc_ic;
  151         int                     (*sc_newstate)(struct ieee80211com *,
  152                                     enum ieee80211_state, int);
  153         unsigned long           maxdwell; /* Max dwell time whilst scanning */
  154 
  155         struct mtx              sc_mtx;
  156 
  157         struct ieee80211_amrr   amrr;
  158 
  159         /* Flags indicating the current state the driver
  160          * expects the hardware to be in
  161          */
  162         uint32_t                flags;
  163 #define WPI_FLAG_HW_RADIO_OFF   (1 << 0)
  164 #define WPI_FLAG_SCANNING       (1 << 1)
  165 #define WPI_FLAG_BUSY           (1 << 2)
  166 #define WPI_FLAG_AUTH           (1 << 3)
  167 
  168         /* Flags indicating the state of the firmware */
  169         uint32_t                fw_state;
  170 #define WPI_FW_IDLE             (1 << 0 )
  171 
  172         /* shared area */
  173         struct wpi_dma_info     shared_dma;
  174         struct wpi_shared       *shared;
  175 
  176         struct wpi_tx_ring      txq[WME_NUM_AC];
  177         struct wpi_tx_ring      cmdq;
  178         struct wpi_rx_ring      rxq;
  179 
  180         /* TX Thermal Callibration */
  181         struct callout          calib_to;
  182         int                     calib_cnt;
  183 
  184         /* Watch dog timer */
  185         struct callout          watchdog_to;
  186         int                     watchdog_cnt;
  187 
  188         struct resource         *irq;
  189         struct resource         *mem;
  190         bus_space_tag_t         sc_st;
  191         bus_space_handle_t      sc_sh;
  192         void                    *sc_ih;
  193         int                     mem_rid;
  194         int                     irq_rid;
  195 
  196         struct wpi_config       config;
  197         int                     temp;
  198 
  199 
  200         int                     sc_tx_timer;
  201 
  202         struct bpf_if           *sc_drvbpf;
  203 
  204         struct wpi_rx_radiotap_header sc_rxtap;
  205         int                     sc_rxtap_len;
  206         struct wpi_tx_radiotap_header sc_txtap;
  207         int                     sc_txtap_len;
  208 
  209         /* firmware image */
  210         const struct firmware   *fw_fp;
  211 
  212         /* firmware DMA transfer */
  213         struct wpi_dma_info     fw_dma;
  214 
  215         /* command queue related variables */
  216         #define WPI_CMD_MAXOPS          10
  217         #define WPI_SCAN_START          (1<<0)
  218         #define WPI_SCAN_CURCHAN        (1<<1)
  219         #define WPI_SCAN_STOP           (1<<2)
  220         #define WPI_SET_CHAN            (1<<3)
  221         #define WPI_AUTH                (1<<4)
  222         #define WPI_SCAN_NEXT           (1<<5)
  223         int                     sc_cmd[WPI_CMD_MAXOPS];
  224         int                     sc_cmd_cur;    /* current queued scan task */
  225         int                     sc_cmd_next;   /* last queued scan task */
  226         struct mtx              sc_cmdlock;
  227 
  228        /* Task queues used to control the driver */
  229        struct taskqueue         *sc_tq; /* Main command task queue */
  230        struct taskqueue         *sc_tq2;/* firmware reset task queue */
  231 
  232        /* Tasks used by the driver */
  233        struct task              sc_radioontask; /* enable rf transmitter task*/
  234        struct task              sc_radioofftask;/* disable rf transmitter task*/
  235         struct task             sc_opstask; /* operation handling task */
  236         struct task             sc_restarttask; /* reset firmware task */
  237 
  238        /* Eeprom info */
  239         uint8_t                 cap;
  240         uint16_t                rev;
  241         uint8_t                 type;
  242         struct wpi_power_group  groups[WPI_POWER_GROUPS_COUNT];
  243         int8_t                  maxpwr[IEEE80211_CHAN_MAX];
  244         char                    domain[4]; //reglatory domain //XXX
  245 };
  246 #define WPI_LOCK_INIT(_sc) \
  247         mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
  248             MTX_NETWORK_LOCK, MTX_DEF)
  249 #define WPI_LOCK_DECL   int     __waslocked = 0
  250 #define WPI_LOCK(_sc) do {\
  251       if (!(__waslocked = mtx_owned(&(_sc)->sc_mtx)))  \
  252                 mtx_lock(&(_sc)->sc_mtx);                \
  253 }    while(0)
  254 #define WPI_UNLOCK(_sc) do {                    \
  255     if (!__waslocked)                       \
  256     mtx_unlock(&(_sc)->sc_mtx);      \
  257 } while (0)
  258 
  259 #define WPI_LOCK_DESTROY(_sc)   mtx_destroy(&(_sc)->sc_mtx)
  260 #define WPI_CMD_LOCK_INIT(_sc)  \
  261         mtx_init(&(_sc)->sc_cmdlock, device_get_nameunit((_sc)->sc_dev), NULL, MTX_DEF);
  262 #define WPI_CMD_LOCK_DESTROY(_sc)        mtx_destroy(&(_sc)->sc_cmdlock)
  263 #define WPI_CMD_LOCK(_sc)                mtx_lock(&(_sc)->sc_cmdlock)
  264 #define WPI_CMD_UNLOCK(_sc)              mtx_unlock(&(_sc)->sc_cmdlock)
  265 #if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
  266 #define WPI_LOCK_ASSERT(sc)     mtx_assert(&(sc)->sc_mtx, MA_OWNED)
  267 #else
  268 #define WPI_LOCK_ASSERT(sc)
  269 #endif

Cache object: c595bd03f59a8f0264b22779968b906b


[ 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.