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/pdq/pdq_freebsd.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: pdqvar.h,v 1.27 2000/05/03 19:17:54 thorpej Exp $      */
    2 
    3 /*-
    4  * Copyright (c) 1995, 1996 Matt Thomas <matt@3am-software.com>
    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. The name of the author may not be used to endorse or promote products
   13  *    derived from this software without specific prior written permission
   14  *
   15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   25  *
   26  * Id: pdqvar.h,v 1.21 1997/03/21 21:16:04 thomas Exp
   27  * $FreeBSD: releng/10.4/sys/dev/pdq/pdq_freebsd.h 243857 2012-12-04 09:32:43Z glebius $
   28  *
   29  */
   30 
   31 /*
   32  * DEC PDQ FDDI Controller; PDQ O/S dependent definitions
   33  *
   34  * Written by Matt Thomas
   35  *
   36  */
   37 
   38 #if defined(PDQ_HWSUPPORT)
   39 #include <sys/param.h>
   40 #include <sys/systm.h>
   41 #include <sys/kernel.h>
   42 #include <sys/lock.h>
   43 #include <sys/mutex.h>
   44 #include <sys/malloc.h>
   45 #include <sys/socket.h>
   46 #include <sys/sockio.h>
   47 
   48 #include <sys/module.h>
   49 #include <sys/bus.h>
   50 
   51 #include <machine/bus.h>
   52 #include <machine/resource.h>
   53 #include <sys/rman.h>
   54         
   55 #include <net/if.h>
   56 #include <net/if_arp.h>
   57 #include <net/if_dl.h>
   58 #include <net/if_media.h>
   59 #include <net/fddi.h>
   60 
   61 #include <net/bpf.h>
   62 
   63 #include <vm/vm.h>              /* for vtophys */
   64 #include <vm/pmap.h>            /* for vtophys */
   65 
   66 #endif  /* PDQ_HWSUPPORT */
   67 
   68 typedef struct _pdq_t pdq_t;
   69 typedef struct _pdq_csrs_t pdq_csrs_t;
   70 typedef struct _pdq_pci_csrs_t pdq_pci_csrs_t;
   71 typedef struct _pdq_lanaddr_t pdq_lanaddr_t;
   72 typedef unsigned int pdq_uint32_t;
   73 typedef unsigned short pdq_uint16_t;
   74 typedef unsigned char pdq_uint8_t;
   75 typedef enum _pdq_boolean_t pdq_boolean_t;
   76 typedef enum _pdq_type_t pdq_type_t;
   77 typedef enum _pdq_state_t pdq_state_t;
   78 typedef struct mbuf PDQ_OS_DATABUF_T;
   79 
   80 typedef bus_space_tag_t pdq_bus_t;
   81 typedef bus_space_handle_t pdq_bus_memaddr_t;
   82 typedef pdq_bus_memaddr_t pdq_bus_memoffset_t;
   83 
   84 extern devclass_t pdq_devclass;
   85 
   86 enum _pdq_type_t {
   87     PDQ_DEFPA,          /* PCI-bus */
   88     PDQ_DEFEA,          /* EISA-bus */
   89     PDQ_DEFTA,          /* TurboChannel */
   90     PDQ_DEFAA,          /* FutureBus+ */
   91     PDQ_DEFQA           /* Q-bus */
   92 };
   93 
   94 #define sc_ifmedia      ifmedia
   95 #if 0 /* ALTQ */
   96 #define IFQ_DEQUEUE     IF_DEQUEUE
   97 #define IFQ_IS_EMPTY(q) ((q)->ifq_len == 0)
   98 #endif
   99 
  100 typedef struct _pdq_os_ctx_t {
  101         struct ifnet            *ifp;
  102         struct ifmedia          ifmedia;
  103         device_t                dev;
  104         int                     debug;
  105 
  106         pdq_t *                 sc_pdq;
  107         int                     sc_flags;
  108 #define PDQIF_DOWNCALL          0x0001  /* active calling from if to pdq */
  109 
  110         struct resource *       io;
  111         int                     io_rid;
  112         int                     io_type;
  113         bus_space_handle_t      io_bsh;
  114         bus_space_tag_t         io_bst;
  115 
  116         struct resource *       mem;
  117         int                     mem_rid;
  118         int                     mem_type;
  119         bus_space_handle_t      mem_bsh;
  120         bus_space_tag_t         mem_bst;
  121 
  122         struct resource *       irq;
  123         int                     irq_rid;
  124         void *                  irq_ih;
  125 
  126         struct mtx              mtx;
  127         struct callout          watchdog;
  128         int                     timer;
  129 } pdq_softc_t;
  130 
  131 #define PDQ_LOCK(_sc)           mtx_lock(&(_sc)->mtx)
  132 #define PDQ_UNLOCK(_sc)         mtx_unlock(&(_sc)->mtx)
  133 #define PDQ_LOCK_ASSERT(_sc)    mtx_assert(&(_sc)->mtx, MA_OWNED)
  134 
  135 #define PDQ_OS_HDR_OFFSET       PDQ_RX_FC_OFFSET
  136 
  137 #define PDQ_OS_PAGESIZE         PAGE_SIZE
  138 #define PDQ_OS_TX_TRANSMIT      5
  139 
  140 #define PDQ_OS_IORD_32(bt, bh, off)             bus_space_read_4(bt, bh, off)
  141 #define PDQ_OS_IOWR_32(bt, bh, off, data)       bus_space_write_4(bt, bh, off, data)
  142 #define PDQ_OS_IORD_8(bt, bh, off)              bus_space_read_1(bt, bh, off)
  143 #define PDQ_OS_IOWR_8(bt, bh, off, data)        bus_space_write_1(bt, bh, off, data)
  144 
  145 #define PDQ_CSR_OFFSET(base, offset)            (0 + (offset)*sizeof(pdq_uint32_t))
  146 #define PDQ_CSR_WRITE(csr, name, data)          PDQ_OS_IOWR_32((csr)->csr_bus, (csr)->csr_base, (csr)->name, data)
  147 #define PDQ_CSR_READ(csr, name)                 PDQ_OS_IORD_32((csr)->csr_bus, (csr)->csr_base, (csr)->name)
  148 
  149 #define PDQ_OS_DATABUF_FREE(pdq, b)             (m_freem(b))
  150 
  151 #if defined(PDQ_OSSUPPORT)
  152 #define PDQ_OS_TX_TIMEOUT               5       /* seconds */
  153 
  154 #define PDQ_OS_IFP_TO_SOFTC(ifp)        ((pdq_softc_t *) (ifp)->if_softc)
  155 #define PDQ_BPF_MTAP(sc, m)             BPF_MTAP((sc)->ifp, m)
  156 #define PDQ_IFNET(sc)                   ((sc)->ifp)
  157 
  158 #endif  /* PDQ_OSSUPPORT */
  159 
  160 #if defined(PDQ_HWSUPPORT)
  161 
  162 #define PDQ_OS_PREFIX                   "%s: "
  163 #define PDQ_OS_PREFIX_ARGS              pdq->pdq_os_name
  164 
  165 #define PDQ_OS_PTR_FMT  "%p"
  166 #define PDQ_OS_CSR_FMT  "0x%x"
  167 
  168 #define PDQ_OS_USEC_DELAY(n)            DELAY(n)
  169 #define PDQ_OS_VA_TO_BUSPA(pdq, p)      vtophys(p)
  170 
  171 #define PDQ_OS_MEMALLOC(n)              malloc(n, M_DEVBUF, M_NOWAIT)
  172 #define PDQ_OS_MEMFREE(p, n)            free((void *) p, M_DEVBUF)
  173 #define PDQ_OS_MEMZERO(p, n)            bzero((caddr_t)(p), (n))
  174 #define PDQ_OS_MEMALLOC_CONTIG(n)       contigmalloc(n, M_DEVBUF, M_NOWAIT, 0x800000, ~0, PAGE_SIZE, 0)
  175 #define PDQ_OS_MEMFREE_CONTIG(p, n)     contigfree(p, n, M_DEVBUF)
  176 
  177 #define PDQ_OS_DATABUF_SIZE                     (MCLBYTES)
  178 #define PDQ_OS_DATABUF_NEXT(b)                  ((b)->m_next)
  179 #define PDQ_OS_DATABUF_NEXT_SET(b, b1)          ((b)->m_next = (b1))
  180 #define PDQ_OS_DATABUF_NEXTPKT(b)               ((b)->m_nextpkt)
  181 #define PDQ_OS_DATABUF_NEXTPKT_SET(b, b1)       ((b)->m_nextpkt = (b1))
  182 #define PDQ_OS_DATABUF_LEN(b)                   ((b)->m_len)
  183 #define PDQ_OS_DATABUF_LEN_SET(b, n)            ((b)->m_len = (n))
  184 /* #define      PDQ_OS_DATABUF_LEN_ADJ(b, n)            ((b)->m_len += (n)) */
  185 #define PDQ_OS_DATABUF_PTR(b)                   (mtod((b), pdq_uint8_t *))
  186 #define PDQ_OS_DATABUF_ADJ(b, n)                ((b)->m_data += (n), (b)->m_len -= (n))
  187 
  188 #define PDQ_OS_DATABUF_ALLOC(pdq, b) do { \
  189     PDQ_OS_DATABUF_T *x_m0; \
  190     MGETHDR(x_m0, M_NOWAIT, MT_DATA); \
  191     if (x_m0 != NULL) { \
  192         MCLGET(x_m0, M_NOWAIT); \
  193         if ((x_m0->m_flags & M_EXT) == 0) { \
  194             m_free(x_m0); \
  195             (b) = NULL; \
  196         } else { \
  197             (b) = x_m0; \
  198             x_m0->m_len = PDQ_OS_DATABUF_SIZE; \
  199         } \
  200     } else { \
  201         (b) = NULL; \
  202     } \
  203 } while (0)
  204 
  205 #define PDQ_OS_DATABUF_RESET(b) ((b)->m_data = (b)->m_ext.ext_buf, (b)->m_len = MCLBYTES)
  206 
  207 #define PDQ_OS_DATABUF_ENQUEUE(q, b)    do { \
  208     PDQ_OS_DATABUF_NEXTPKT_SET(b, NULL); \
  209     if ((q)->q_tail == NULL) \
  210         (q)->q_head = (b); \
  211     else \
  212         PDQ_OS_DATABUF_NEXTPKT_SET(((PDQ_OS_DATABUF_T *)(q)->q_tail), b); \
  213     (q)->q_tail = (b); \
  214 } while (0)
  215 
  216 #define PDQ_OS_DATABUF_DEQUEUE(q, b)    do { \
  217     if (((b) = (PDQ_OS_DATABUF_T *) (q)->q_head) != NULL) { \
  218         if (((q)->q_head = PDQ_OS_DATABUF_NEXTPKT(b)) == NULL) \
  219             (q)->q_tail = NULL; \
  220         PDQ_OS_DATABUF_NEXTPKT_SET(b, NULL); \
  221     } \
  222 } while (0)
  223 
  224 #define PDQ_OS_DATABUF_BUSPA(pdq, b)    PDQ_OS_VA_TO_BUSPA(pdq, PDQ_OS_DATABUF_PTR(b))
  225 
  226 #define PDQ_OS_CONSUMER_PRESYNC(pdq)            do { } while(0)
  227 #define PDQ_OS_CONSUMER_POSTSYNC(pdq)           do { } while(0)
  228 #define PDQ_OS_DESC_PRESYNC(pdq, d, s)          do { } while(0)
  229 #define PDQ_OS_DESC_POSTSYNC(pdq, d, s)         do { } while(0)
  230 #define PDQ_OS_CMDRQST_PRESYNC(pdq, s)          do { } while(0)
  231 #define PDQ_OS_CMDRQST_POSTSYNC(pdq, s)         do { } while(0)
  232 #define PDQ_OS_CMDRSP_PRESYNC(pdq, s)           do { } while(0)
  233 #define PDQ_OS_CMDRSP_POSTSYNC(pdq, s)          do { } while(0)
  234 #define PDQ_OS_RXPDU_PRESYNC(pdq, b, o, l)      do { } while(0)
  235 #define PDQ_OS_RXPDU_POSTSYNC(pdq, b, o, l)     do { } while(0)
  236 #define PDQ_OS_UNSOL_EVENT_PRESYNC(pdq, e)      do { } while(0)
  237 #define PDQ_OS_UNSOL_EVENT_POSTSYNC(pdq, e)     do { } while(0)
  238 
  239 #endif  /* PDQ_HWSUPPORT */
  240 
  241 /*
  242  * OS dependent functions provided by pdq_ifsubr.c to pdq.c
  243  */
  244 void    pdq_os_addr_fill (pdq_t *pdq, pdq_lanaddr_t *addrs, size_t numaddrs);
  245 void    pdq_os_receive_pdu (pdq_t *, PDQ_OS_DATABUF_T *, size_t, int);
  246 void    pdq_os_restart_transmitter (pdq_t *pdq);
  247 void    pdq_os_transmit_done (pdq_t *, PDQ_OS_DATABUF_T *);
  248 void    pdq_os_update_status (pdq_t *, const void *);
  249 
  250 /*
  251  * Driver interfaces functions provided by pdq.c to pdq_ifsubr.c
  252  */
  253 pdq_boolean_t   pdq_queue_transmit_data (pdq_t *pdq, PDQ_OS_DATABUF_T *pdu);
  254 void            pdq_run  (pdq_t *pdq);
  255 pdq_state_t     pdq_stop (pdq_t *pdq);
  256 
  257 /*
  258  * OS dependent functions provided by
  259  * pdq_ifsubr.c or pdq.c to the bus front ends
  260  */
  261 int             pdq_ifattach (pdq_softc_t *, const pdq_uint8_t *,
  262                               pdq_type_t type);
  263 void            pdq_ifdetach (pdq_softc_t *);
  264 void            pdq_free (device_t);
  265 int             pdq_interrupt (pdq_t *pdq);
  266 void            pdq_hwreset (pdq_t *pdq);
  267 pdq_t *         pdq_initialize (pdq_bus_t bus, pdq_bus_memaddr_t csr_va,
  268                                 const char *name, int unit,
  269                                 void *ctx, pdq_type_t type);
  270 /*
  271  * Misc prototypes.
  272  */
  273 void            pdq_flush_transmitter(pdq_t *pdq);

Cache object: af625abd3be6f972d3d6c08369d5a9b3


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