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/ray/if_rayvar.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 /*-
    2  * Copyright (C) 2000
    3  * Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk.
    4  *
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Neither the name of the author nor the names of any co-contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY 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 DUNCAN BARCLAY 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  * $FreeBSD: src/sys/dev/ray/if_rayvar.h,v 1.17.8.1 2005/01/30 00:59:59 imp Exp $
   32  *
   33  */
   34 
   35 /*
   36  * Network parameters, used twice in softc to store what we want and what
   37  * we have.
   38  *
   39  * The current parameters are ONLY valid in a function called from the runq
   40  * and should not be accessed directly from ioctls.
   41  */
   42 struct ray_nw_param {
   43     struct ray_cmd_net  p_1;
   44     struct ray_net_params \
   45                         p_2;
   46     u_int8_t            np_ap_status;
   47     int                 np_promisc;     /* Promiscious mode status      */
   48     int                 np_framing;     /* Packet framing types         */
   49     int                 np_auth;        /* Authentication status        */
   50     int                 np_havenet;     /* True if we have a network    */
   51 };
   52 #define np_upd_param    p_1.c_upd_param
   53 #define np_bss_id       p_1.c_bss_id
   54 #define np_inited       p_1.c_inited
   55 #define np_def_txrate   p_1.c_def_txrate
   56 #define np_encrypt      p_1.c_encrypt
   57 #define np_net_type     p_2.p_net_type
   58 #define np_ssid         p_2.p_ssid
   59 #define np_priv_start   p_2.p_privacy_must_start
   60 #define np_priv_join    p_2.p_privacy_can_join
   61 
   62 /*
   63  * One of these structures per allocated device
   64  */
   65 struct ray_softc {
   66 
   67     device_t dev;                       /* Device */
   68     struct arpcom       arpcom;         /* Ethernet common              */
   69     struct callout_handle
   70                         tx_timerh;      /* Handle for tx timer  */
   71     struct callout_handle
   72                         com_timerh;     /* Handle for command timer     */
   73 
   74     bus_space_tag_t     am_bst;         /* Bus space tag for attribute memory */
   75     bus_space_handle_t  am_bsh;         /* Bus space handle for attribute mem */
   76     int                 am_rid;         /* Resource id for attribute memory */
   77     struct resource*    am_res;         /* Resource for attribute memory */
   78     bus_space_tag_t     cm_bst;         /* Bus space tag for common memory */
   79     bus_space_handle_t  cm_bsh;         /* Bus space handle for common memory */
   80     int                 cm_rid;         /* Resource id for common memory */
   81     struct resource*    cm_res;         /* Resource for common memory */
   82     int                 irq_rid;        /* Resource id for irq */
   83     struct resource*    irq_res;        /* Resource for irq */
   84     void *              irq_handle;     /* Handle for irq handler */
   85 
   86     u_int8_t            sc_ccsinuse[64];/* ccss' in use -- not for tx   */
   87     u_char              sc_gone;        /* 1 = Card bailed out          */
   88 
   89     struct ray_ecf_startup_v5
   90                         sc_ecf_startup; /* Startup info from card       */
   91 
   92     TAILQ_HEAD(ray_comq, ray_comq_entry) 
   93                         sc_comq;        /* Command queue                */
   94 
   95     struct ray_nw_param sc_c;           /* current network params       */
   96     struct ray_nw_param sc_d;           /* desired network params       */
   97 
   98     int                 sc_checkcounters;
   99     u_int64_t           sc_rxoverflow;  /* Number of rx overflows       */
  100     u_int64_t           sc_rxcksum;     /* Number of checksum errors    */
  101     u_int64_t           sc_rxhcksum;    /* Number of header checksum errors */
  102     u_int8_t            sc_rxnoise;     /* Average receiver level       */
  103     struct ray_siglev   sc_siglevs[RAY_NSIGLEVRECS]; /* Antenna/levels  */
  104 };
  105 
  106 #define sc_station_addr sc_ecf_startup.e_station_addr
  107 #define sc_version      sc_ecf_startup.e_fw_build_string
  108 #define sc_tibsize      sc_ecf_startup.e_tibsize
  109 
  110 /*
  111  * Command queue definitions
  112  */
  113 typedef void (*ray_comqfn_t)(struct ray_softc *sc, struct ray_comq_entry *com);
  114 MALLOC_DECLARE(M_RAYCOM);
  115 MALLOC_DEFINE(M_RAYCOM, "raycom", "Raylink command queue entry");
  116 struct ray_comq_entry {
  117         TAILQ_ENTRY(ray_comq_entry) c_chain;    /* Tail queue.          */
  118         ray_comqfn_t    c_function;             /* Function to call */
  119         int             c_flags;                /* Flags                */
  120         u_int8_t        c_retval;               /* Return value         */
  121         void            *c_wakeup;              /* Sleeping on this     */
  122         size_t          c_ccs;                  /* CCS structure        */
  123         struct ray_nw_param
  124                         c_desired;              /* network settings     */
  125         struct ray_param_req
  126                         *c_pr;                  /* MIB report/update    */
  127         char            *c_mesg;
  128 };
  129 
  130 /*
  131  * Macro's and constants
  132  */
  133 static int mib_info[RAY_MIB_MAX+1][3] = RAY_MIB_INFO;
  134 
  135 /* Indirections for reading/writing memory - from NetBSD/if_ray.c */
  136 #ifndef offsetof
  137 #define offsetof(type, member) \
  138     ((size_t)(&((type *)0)->member))
  139 #endif /* offsetof */
  140 
  141 #define ATTR_READ_1(sc, off) \
  142     ((u_int8_t)bus_space_read_1((sc)->am_bst, (sc)->am_bsh, (off)))
  143 
  144 #define ATTR_WRITE_1(sc, off, val) \
  145     bus_space_write_1((sc)->am_bst, (sc)->am_bsh, (off), (val))
  146 
  147 #define SRAM_READ_1(sc, off) \
  148     ((u_int8_t)bus_space_read_1((sc)->cm_bst, (sc)->cm_bsh, (off)))
  149 
  150 #define SRAM_READ_REGION(sc, off, p, n) \
  151     bus_space_read_region_1((sc)->cm_bst, (sc)->cm_bsh, (off), (void *)(p), (n))
  152 
  153 #define SRAM_READ_FIELD_1(sc, off, s, f) \
  154     SRAM_READ_1((sc), (off) + offsetof(struct s, f))
  155 
  156 #define SRAM_READ_FIELD_2(sc, off, s, f)                        \
  157     ((((u_int16_t)SRAM_READ_1((sc), (off) + offsetof(struct s, f)) << 8) \
  158     |(SRAM_READ_1((sc), (off) + 1 + offsetof(struct s, f)))))
  159 
  160 #define SRAM_READ_FIELD_N(sc, off, s, f, p, n)  \
  161     SRAM_READ_REGION((sc), (off) + offsetof(struct s, f), (p), (n))
  162 
  163 #define SRAM_WRITE_1(sc, off, val)      \
  164     bus_space_write_1((sc)->cm_bst, (sc)->cm_bsh, (off), (val))
  165 
  166 #define SRAM_WRITE_REGION(sc, off, p, n) \
  167     bus_space_write_region_1((sc)->cm_bst, (sc)->cm_bsh, (off), (void *)(p), (n))
  168 
  169 #define SRAM_WRITE_FIELD_1(sc, off, s, f, v)    \
  170     SRAM_WRITE_1((sc), (off) + offsetof(struct s, f), (v))
  171 
  172 #define SRAM_WRITE_FIELD_2(sc, off, s, f, v) do {       \
  173     SRAM_WRITE_1((sc), (off) + offsetof(struct s, f), (((v) >> 8 ) & 0xff)); \
  174     SRAM_WRITE_1((sc), (off) + 1 + offsetof(struct s, f), ((v) & 0xff)); \
  175 } while (0)
  176 
  177 #define SRAM_WRITE_FIELD_N(sc, off, s, f, p, n) \
  178     SRAM_WRITE_REGION((sc), (off) + offsetof(struct s, f), (p), (n))
  179 
  180 /* Framing types */
  181 /* XXX maybe better as part of the if structure? */
  182 #define RAY_FRAMING_ENCAPSULATION       0
  183 #define RAY_FRAMING_TRANSLATION         1
  184 
  185 /* Authentication states */
  186 #define RAY_AUTH_UNAUTH         0
  187 #define RAY_AUTH_WAITING        1
  188 #define RAY_AUTH_AUTH           2
  189 #define RAY_AUTH_NEEDED         3
  190 
  191 /* Flags for runq entries */
  192 #define RAY_COM_FWOK            0x0001          /* Wakeup on completion */
  193 #define RAY_COM_FRUNNING        0x0002          /* This one running     */
  194 #define RAY_COM_FCOMPLETED      0x0004          /* This one completed   */
  195 #define RAY_COM_FWAIT           0x0008          /* Do not run the queue */
  196 #define RAY_COM_FCHKRUNNING     0x0010          /* Check IFF_RUNNING    */
  197 #define RAY_COM_FDETACHED       0x0020          /* Card is gone         */
  198 #define RAY_COM_FWOKEN          0x0040          /* Woken by detach      */
  199 #define RAY_COM_FLAGS_PRINTFB   \
  200         "\020"                  \
  201         "\001WOK"               \
  202         "\002RUNNING"           \
  203         "\003COMPLETED"         \
  204         "\004WAIT"              \
  205         "\005CHKRUNNING"        \
  206         "\006DETACHED"
  207 
  208 #define RAY_COM_NEEDS_TIMO(cmd) (               \
  209          (cmd == RAY_CMD_DOWNLOAD_PARAMS) ||    \
  210          (cmd == RAY_CMD_UPDATE_PARAMS) ||      \
  211          (cmd == RAY_CMD_UPDATE_MCAST)          \
  212         )
  213 
  214 #ifndef RAY_COM_TIMEOUT
  215 #define RAY_COM_TIMEOUT         (hz / 2)
  216 #endif
  217 
  218 #ifndef RAY_RESET_TIMEOUT
  219 #define RAY_RESET_TIMEOUT       (10 * hz)
  220 #endif
  221 
  222 #ifndef RAY_TX_TIMEOUT
  223 #define RAY_TX_TIMEOUT          (hz / 2)
  224 #endif
  225 
  226 #define RAY_CCS_FREE(sc, ccs) \
  227     SRAM_WRITE_FIELD_1((sc), (ccs), ray_cmd, c_status, RAY_CCS_STATUS_FREE)
  228 
  229 #define RAY_ECF_READY(sc) \
  230     (!(ATTR_READ_1((sc), RAY_ECFIR) & RAY_ECFIR_IRQ))
  231 
  232 #define RAY_ECF_START_CMD(sc)   ATTR_WRITE_1((sc), RAY_ECFIR, RAY_ECFIR_IRQ)
  233 
  234 #define RAY_HCS_CLEAR_INTR(sc)  ATTR_WRITE_1((sc), RAY_HCSIR, 0)
  235 
  236 #define RAY_HCS_INTR(sc)        (ATTR_READ_1((sc), RAY_HCSIR) & RAY_HCSIR_IRQ)
  237 
  238 #define RAY_PANIC(sc, fmt, args...) do {                                \
  239     panic("ray%d: %s(%d) " fmt "\n", device_get_unit((sc)->dev),        \
  240         __func__ , __LINE__ , ##args);                                  \
  241 } while (0)
  242 
  243 #define RAY_PRINTF(sc, fmt, args...) do {                               \
  244     device_printf((sc)->dev, "%s(%d) " fmt "\n",                        \
  245         __func__ , __LINE__ , ##args);                                  \
  246 } while (0)
  247 
  248 #define RAY_COM_MALLOC(function, flags) \
  249     ray_com_malloc((function), (flags), __STRING(function));
  250 
  251 #define RAY_COM_FREE(com, ncom) do {                                    \
  252     int i;                                                              \
  253     for (i = 0; i < ncom; i++)                                          \
  254             FREE(com[i], M_RAYCOM);                                     \
  255 } while (0)
  256 
  257 /*
  258  * This macro handles adding commands to the runq and quickly
  259  * getting away when the card is detached. The macro returns
  260  * from the current function with ENXIO.
  261  */
  262 #define RAY_COM_RUNQ(sc, com, ncom, mesg, error) do {                   \
  263     (error) = ray_com_runq_add((sc), (com), (ncom), (mesg));            \
  264     if ((error) == ENXIO) {                                             \
  265             RAY_COM_FREE((com), (ncom));                                \
  266             return (error);                                             \
  267     } else if ((error) && ((error) != ENXIO))                           \
  268             RAY_PRINTF(sc, "got error from runq 0x%x", (error));        \
  269 } while (0)
  270 
  271 /*
  272  * There are a number of entry points into the ray_init_xxx routines.
  273  * These can be classed into two types: a) those that happen as a result
  274  * of a change to the cards operating parameters (e.g. BSSID change), and
  275  * b) those that happen as a result of a change to the interface parameters
  276  * (e.g. a change to the IP address). The second set of entries need not
  277  * send a command to the card when the card is IFF_RUNNING. The
  278  * RAY_COM_FCHKRUNNING flags indicates when the RUNNING flag should be
  279  * checked, and this macro does the necessary check and command abort.
  280  */
  281 #define RAY_COM_CHKRUNNING(sc, com, ifp) do {                           \
  282     if (((com)->c_flags & RAY_COM_FCHKRUNNING) &&                       \
  283         ((ifp)->if_flags & IFF_RUNNING)) {                              \
  284             ray_com_runq_done(sc);                                      \
  285             return;                                                     \
  286 } } while (0)
  287     
  288     
  289 
  290 #define RAY_COM_INIT(com, function, flags)      \
  291     ray_com_init((com), (function), (flags), __STRING(function));
  292 
  293 #ifndef RAY_COM_CHECK
  294 #define RAY_COM_CHECK(sc, com)
  295 #endif /* RAY_COM_CHECK */
  296 
  297 #ifndef RAY_MBUF_DUMP
  298 #define RAY_MBUF_DUMP(sc, mask, m, s)
  299 #endif /* RAY_MBUF_DUMP */
  300 
  301 #ifndef RAY_RECERR
  302 #define RAY_RECERR(sc, fmt, args...) do {                               \
  303     struct ifnet *ifp = &(sc)->arpcom.ac_if;                            \
  304     if (ifp->if_flags & IFF_DEBUG) {                                    \
  305             device_printf((sc)->dev, "%s(%d) " fmt "\n",                \
  306                 __func__ , __LINE__ , ##args);                          \
  307 } } while (0)
  308 #endif /* RAY_RECERR */
  309 
  310 /* XXX this should be in CCSERR but don't work - probably need to use ##ifp->(iferrcounter)++;                                          \*/
  311 #ifndef RAY_CCSERR
  312 #define RAY_CCSERR(sc, status, iferrcounter) do {                       \
  313     struct ifnet *ifp = &(sc)->arpcom.ac_if;                            \
  314     char *ss[] = RAY_CCS_STATUS_STRINGS;                                \
  315     if ((status) != RAY_CCS_STATUS_COMPLETE) {                          \
  316         if (ifp->if_flags & IFF_DEBUG) {                                \
  317             device_printf((sc)->dev,                                    \
  318                 "%s(%d) ECF command completed with status %s\n",        \
  319                 __func__ , __LINE__ , ss[(status)]);                    \
  320 } } } while (0)
  321 #endif /* RAY_CCSERR */
  322 
  323 #ifndef RAY_MAP_CM
  324 #define RAY_MAP_CM(sc)
  325 #endif /* RAY_MAP_CM */

Cache object: 20bc936961ce75c8694d8aae2b6dff42


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