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/pdqvar.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 /*      $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: src/sys/dev/pdq/pdqvar.h,v 1.11 2004/01/13 20:36:03 alc Exp $
   28  *
   29  */
   30 
   31 /*
   32  * DEC PDQ FDDI Controller; PDQ O/S dependent definitions
   33  *
   34  * Written by Matt Thomas
   35  *
   36  */
   37 
   38 #ifndef _PDQ_OS_H
   39 #define _PDQ_OS_H
   40 
   41 #define PDQ_OS_TX_TIMEOUT               5       /* seconds */
   42 
   43 typedef struct _pdq_t pdq_t;
   44 typedef struct _pdq_csrs_t pdq_csrs_t;
   45 typedef struct _pdq_pci_csrs_t pdq_pci_csrs_t;
   46 typedef struct _pdq_lanaddr_t pdq_lanaddr_t;
   47 typedef unsigned int pdq_uint32_t;
   48 typedef unsigned short pdq_uint16_t;
   49 typedef unsigned char pdq_uint8_t;
   50 typedef enum _pdq_boolean_t pdq_boolean_t;
   51 typedef enum _pdq_type_t pdq_type_t;
   52 typedef enum _pdq_state_t pdq_state_t;
   53 
   54 enum _pdq_type_t {
   55     PDQ_DEFPA,          /* PCI-bus */
   56     PDQ_DEFEA,          /* EISA-bus */
   57     PDQ_DEFTA,          /* TurboChannel */
   58     PDQ_DEFAA,          /* FutureBus+ */
   59     PDQ_DEFQA           /* Q-bus */
   60 };
   61 
   62 #if defined(PDQTEST)
   63 #include <pdq_os_test.h>
   64 #elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__NetBSD__)
   65 
   66 #include <sys/param.h>
   67 #include <sys/systm.h>
   68 #ifndef M_MCAST
   69 #include <sys/mbuf.h>
   70 #endif /* M_CAST */
   71 #include <sys/malloc.h>
   72 #include <vm/vm.h>
   73 #include <vm/vm_kern.h>
   74 
   75 #define PDQ_USE_MBUFS
   76 #if defined(__NetBSD__) || defined(__FreeBSD__)
   77 #define PDQ_OS_PREFIX                   "%s: "
   78 #define PDQ_OS_PREFIX_ARGS              pdq->pdq_os_name
   79 #else
   80 #define PDQ_OS_PREFIX                   "%s%d: "
   81 #define PDQ_OS_PREFIX_ARGS              pdq->pdq_os_name, pdq->pdq_unit
   82 #endif
   83 #if defined(__FreeBSD__) && BSD >= 199506
   84 #define PDQ_OS_PAGESIZE                 PAGE_SIZE
   85 #else
   86 #define PDQ_OS_PAGESIZE                 NBPG
   87 #endif
   88 #define PDQ_OS_USEC_DELAY(n)            DELAY(n)
   89 #define PDQ_OS_MEMZERO(p, n)            bzero((caddr_t)(p), (n))
   90 #if defined(__NetBSD__) && !defined(PDQ_NO_BUS_DMA)
   91 #define PDQ_BUS_DMA
   92 #endif
   93 #if !defined(PDQ_BUS_DMA)
   94 #define PDQ_OS_VA_TO_BUSPA(pdq, p)              vtophys(p)
   95 #endif
   96 #define PDQ_OS_MEMALLOC(n)              malloc(n, M_DEVBUF, M_NOWAIT)
   97 #define PDQ_OS_MEMFREE(p, n)            free((void *) p, M_DEVBUF)
   98 #ifdef __FreeBSD__
   99 #define PDQ_OS_MEMALLOC_CONTIG(n)       contigmalloc(n, M_DEVBUF, M_NOWAIT, 0, 0xffffffff, PAGE_SIZE, 0)
  100 #define PDQ_OS_MEMFREE_CONTIG(p, n)     contigfree((void *) p, n, M_DEVBUF)
  101 #else
  102 #if !defined(PDQ_BUS_DMA)
  103 #define PDQ_OS_MEMALLOC_CONTIG(n)       uvm_km_alloc(kernel_map, round_page(n))
  104 #define PDQ_OS_MEMFREE_CONTIG(p, n)     uvm_km_free(kernel_map, (vaddr_t) p, n)
  105 #endif
  106 #endif /* __FreeBSD__ */
  107 
  108 #if defined(__FreeBSD__)
  109 #include <vm/pmap.h>
  110 #include <vm/vm_extern.h>
  111 #include <machine/cpufunc.h>
  112 #include <machine/clock.h>
  113 #define ifnet_ret_t void
  114 typedef int ioctl_cmd_t;
  115 typedef enum { PDQ_BUS_EISA, PDQ_BUS_PCI } pdq_bus_t;
  116 typedef u_int16_t pdq_bus_ioport_t;
  117 typedef volatile pdq_uint32_t *pdq_bus_memaddr_t;
  118 typedef pdq_bus_memaddr_t pdq_bus_memoffset_t;
  119 #if BSD >= 199506       /* __FreeBSD__ */
  120 #define PDQ_BPF_MTAP(sc, m)     bpf_mtap(&(sc)->sc_if, m)
  121 #define PDQ_BPFATTACH(sc, t, s) bpfattach(&(sc)->sc_if, t, s)
  122 #endif
  123 
  124 #define pdq_os_update_status(a, b)      ((void) 0)
  125 
  126 #elif defined(__bsdi__)
  127 #if !defined(PDQ_HWSUPPORT) && (_BSDI_VERSION >= 199701)
  128 #include <net/if_media.h>
  129 #endif
  130 #include <machine/inline.h>
  131 #define ifnet_ret_t int
  132 typedef int ioctl_cmd_t;
  133 typedef enum { PDQ_BUS_EISA, PDQ_BUS_PCI } pdq_bus_t;
  134 typedef u_int16_t pdq_bus_ioport_t;
  135 typedef volatile pdq_uint32_t *pdq_bus_memaddr_t;
  136 typedef pdq_bus_memaddr_t pdq_bus_memoffset_t;
  137 
  138 
  139 #elif defined(__NetBSD__)
  140 #if !defined(PDQ_HWSUPPORT)
  141 #include <net/if_media.h>
  142 #endif
  143 #include <machine/bus.h>
  144 #include <machine/intr.h>
  145 #define PDQ_OS_HDR_OFFSET       (PDQ_RX_FC_OFFSET-3)
  146 #define PDQ_OS_PTR_FMT          "%p"
  147 #define PDQ_OS_CSR_FMT          "0x%lx"
  148 #define ifnet_ret_t void
  149 typedef u_long ioctl_cmd_t;
  150 typedef bus_space_tag_t pdq_bus_t;
  151 typedef bus_space_handle_t pdq_bus_ioport_t;
  152 typedef bus_space_handle_t pdq_bus_memaddr_t;
  153 typedef bus_addr_t pdq_bus_memoffset_t;
  154 #define PDQ_OS_SPL_RAISE()      splnet()
  155 #define PDQ_OS_IOMEM
  156 #define PDQ_OS_IORD_32(t, base, offset)         bus_space_read_4  (t, base, offset)
  157 #define PDQ_OS_IOWR_32(t, base, offset, data)   bus_space_write_4 (t, base, offset, data)
  158 #define PDQ_OS_IORD_8(t, base, offset)          bus_space_read_1  (t, base, offset)
  159 #define PDQ_OS_IOWR_8(t, base, offset, data)    bus_space_write_1 (t, base, offset, data)
  160 #define PDQ_CSR_OFFSET(base, offset)            (0 + (offset)*sizeof(pdq_uint32_t))
  161 
  162 #ifdef PDQ_BUS_DMA
  163 #define PDQ_OS_UNSOL_EVENT_PRESYNC(pdq, event) \
  164         pdq_os_unsolicited_event_sync((pdq)->pdq_os_ctx, \
  165                         (u_int8_t *) (event) - \
  166                                 (u_int8_t *) (pdq)->pdq_unsolicited_info.ui_events, \
  167                         sizeof(*event), BUS_DMASYNC_PREREAD)
  168 #define PDQ_OS_UNSOL_EVENT_POSTSYNC(pdq, event) \
  169         pdq_os_unsolicited_event_sync((pdq)->pdq_os_ctx, \
  170                         (u_int8_t *) (event) - \
  171                                 (u_int8_t *) (pdq)->pdq_unsolicited_info.ui_events, \
  172                         sizeof(*event), BUS_DMASYNC_POSTREAD)
  173 #define PDQ_OS_DESCBLOCK_SYNC(pdq, what, length, why) \
  174         pdq_os_descriptor_block_sync((pdq)->pdq_os_ctx, \
  175                         (u_int8_t *) (what) - (u_int8_t *) (pdq)->pdq_dbp, \
  176                         (length), (why))
  177 #define PDQ_OS_CONSUMER_PRESYNC(pdq) \
  178         pdq_os_consumer_block_sync((pdq)->pdq_os_ctx, \
  179                               BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)
  180 #define PDQ_OS_CONSUMER_POSTSYNC(pdq) \
  181         pdq_os_consumer_block_sync((pdq)->pdq_os_ctx, \
  182                               BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)
  183 #define PDQ_OS_DESC_PRESYNC(pdq, d, s) \
  184         PDQ_OS_DESCBLOCK_SYNC((pdq), (d), (s), BUS_DMASYNC_PREWRITE)
  185 #define PDQ_OS_DESC_POSTSYNC(pdq, d, s) \
  186         PDQ_OS_DESCBLOCK_SYNC((pdq), (d), (s), BUS_DMASYNC_POSTWRITE)
  187 #define PDQ_OS_CMDRQST_PRESYNC(pdq, s) \
  188         PDQ_OS_DESCBLOCK_SYNC((pdq), \
  189                               (pdq)->pdq_command_info.ci_request_bufstart, \
  190                               (s), BUS_DMASYNC_PREWRITE)
  191 #define PDQ_OS_CMDRSP_PRESYNC(pdq, s) \
  192         PDQ_OS_DESCBLOCK_SYNC((pdq), \
  193                               (pdq)->pdq_command_info.ci_response_bufstart, \
  194                               (s), BUS_DMASYNC_PREREAD)
  195 #define PDQ_OS_CMDRQST_POSTSYNC(pdq, s) \
  196         PDQ_OS_DESCBLOCK_SYNC((pdq), \
  197                               (pdq)->pdq_command_info.ci_request_bufstart, \
  198                               (s), BUS_DMASYNC_POSTWRITE)
  199 #define PDQ_OS_CMDRSP_POSTSYNC(pdq, s) \
  200         PDQ_OS_DESCBLOCK_SYNC((pdq), \
  201                               (pdq)->pdq_command_info.ci_response_bufstart, \
  202                               (s), BUS_DMASYNC_POSTREAD)
  203 #define PDQ_OS_RXPDU_PRESYNC(pdq, b, o, l) \
  204         pdq_os_databuf_sync((pdq)->pdq_os_ctx, (b), (o), (l), \
  205                             BUS_DMASYNC_PREREAD)
  206 #define PDQ_OS_RXPDU_POSTSYNC(pdq, b, o, l) \
  207         pdq_os_databuf_sync((pdq)->pdq_os_ctx, (b), (o), (l), \
  208                             BUS_DMASYNC_POSTREAD)
  209 #define PDQ_OS_DATABUF_ALLOC(pdq, b)    ((void)((b) = pdq_os_databuf_alloc((pdq)->pdq_os_ctx)))
  210 #define PDQ_OS_DATABUF_FREE(pdq, b)     pdq_os_databuf_free((pdq)->pdq_os_ctx, (b))
  211 #define PDQ_OS_DATABUF_BUSPA(pdq, b)    (M_GETCTX((b), bus_dmamap_t)->dm_segs[0].ds_addr + 0)
  212 struct _pdq_os_ctx_t;
  213 extern void pdq_os_descriptor_block_sync(struct _pdq_os_ctx_t *osctx, size_t offset,
  214                                          size_t length, int ops);
  215 extern void pdq_os_consumer_block_sync(struct _pdq_os_ctx_t *osctx, int ops);
  216 extern void pdq_os_unsolicited_event_sync(struct _pdq_os_ctx_t *osctx, size_t offset,
  217                                           size_t length, int ops);
  218 extern struct mbuf *pdq_os_databuf_alloc(struct _pdq_os_ctx_t *osctx);
  219 extern void pdq_os_databuf_sync(struct _pdq_os_ctx_t *osctx, struct mbuf *b,
  220                                 size_t offset, size_t length, int ops);
  221 extern void pdq_os_databuf_free(struct _pdq_os_ctx_t *osctx, struct mbuf *m);
  222 #define M_HASTXDMAMAP           M_LINK1
  223 #define M_HASRXDMAMAP           M_LINK2
  224 #endif
  225 
  226 #define PDQ_CSR_WRITE(csr, name, data)          PDQ_OS_IOWR_32((csr)->csr_bus, (csr)->csr_base, (csr)->name, data)
  227 #define PDQ_CSR_READ(csr, name)                 PDQ_OS_IORD_32((csr)->csr_bus, (csr)->csr_base, (csr)->name)
  228 
  229 #define PDQ_OS_IFP_TO_SOFTC(ifp)                ((pdq_softc_t *) (ifp)->if_softc)
  230 #define PDQ_ARP_IFINIT(sc, ifa)                 arp_ifinit(&(sc)->sc_if, (ifa))
  231 #define PDQ_FDDICOM(sc)                         (&(sc)->sc_ec)
  232 #define PDQ_LANADDR(sc)                         LLADDR((sc)->sc_if.if_sadl)
  233 #define PDQ_LANADDR_SIZE(sc)                    ((sc)->sc_if.if_sadl->sdl_alen)
  234 #endif
  235 
  236 #if !defined(PDQ_BPF_MTAP)
  237 #define PDQ_BPF_MTAP(sc, m)     bpf_mtap((sc)->sc_bpf, m)
  238 #endif
  239 
  240 #if !defined(PDQ_BPFATTACH)
  241 #define PDQ_BPFATTACH(sc, t, s) bpfattach(&(sc)->sc_bpf, &(sc)->sc_if, t, s)
  242 #endif
  243 
  244 #if !defined(PDQ_OS_SPL_RAISE)
  245 #define PDQ_OS_SPL_RAISE()      splimp()
  246 #endif
  247 
  248 #if !defined(PDQ_OS_SPL_LOWER)
  249 #define PDQ_OS_SPL_LOWER(s)     splx(s)
  250 #endif
  251 
  252 #if !defined(PDQ_FDDICOM)
  253 #define PDQ_FDDICOM(sc)         (&(sc)->sc_ac)
  254 #endif
  255 
  256 #if !defined(PDQ_ARP_IFINIT)
  257 #define PDQ_ARP_IFINIT(sc, ifa) arp_ifinit(&(sc)->sc_ac, (ifa))
  258 #endif
  259 
  260 #if !defined(PDQ_OS_PTR_FMT)
  261 #define PDQ_OS_PTR_FMT  "0x%x"
  262 #endif
  263 
  264 #if !defined(PDQ_OS_CSR_FMT)
  265 #define PDQ_OS_CSR_FMT  "0x%x"
  266 #endif
  267 
  268 #if !defined(PDQ_LANADDR)
  269 #define PDQ_LANADDR(sc)         ((sc)->sc_ac.ac_enaddr)
  270 #define PDQ_LANADDR_SIZE(sc)    (sizeof((sc)->sc_ac.ac_enaddr))
  271 #endif
  272 
  273 #if !defined(PDQ_OS_IOMEM)
  274 #define PDQ_OS_IORD_32(t, base, offset)         inl((base) + (offset))
  275 #define PDQ_OS_IOWR_32(t, base, offset, data)   outl((base) + (offset), data)
  276 #define PDQ_OS_IORD_8(t, base, offset)          inb((base) + (offset))
  277 #define PDQ_OS_IOWR_8(t, base, offset, data)    outb((base) + (offset), data)
  278 #define PDQ_OS_MEMRD_32(t, base, offset)        (0 + *((base) + (offset)))
  279 #define PDQ_OS_MEMWR_32(t, base, offset, data)  do *((base) + (offset)) = (data); while (0)
  280 #endif
  281 #ifndef PDQ_CSR_OFFSET
  282 #define PDQ_CSR_OFFSET(base, offset)            (0 + (base) + (offset))
  283 #endif
  284 
  285 #ifndef PDQ_CSR_WRITE
  286 #define PDQ_CSR_WRITE(csr, name, data)          PDQ_OS_MEMWR_32((csr)->csr_bus, (csr)->name, 0, data)
  287 #define PDQ_CSR_READ(csr, name)                 PDQ_OS_MEMRD_32((csr)->csr_bus, (csr)->name, 0)
  288 #endif
  289 
  290 #ifndef PDQ_OS_IFP_TO_SOFTC
  291 #define PDQ_OS_IFP_TO_SOFTC(ifp)        ((pdq_softc_t *) ((caddr_t) ifp - offsetof(pdq_softc_t, sc_ac.ac_if)))
  292 #endif
  293 
  294 
  295 #if !defined(PDQ_HWSUPPORT)
  296 
  297 typedef struct _pdq_os_ctx_t {
  298 #if defined(__bsdi__)
  299     struct device sc_dev;               /* base device */
  300     struct isadev sc_id;                /* ISA device */
  301     struct intrhand sc_ih;              /* interrupt vectoring */
  302     struct atshutdown sc_ats;           /* shutdown routine */
  303     struct arpcom sc_ac;
  304 #define sc_if           sc_ac.ac_if
  305 #elif defined(__NetBSD__)
  306     struct device sc_dev;               /* base device */
  307     void *sc_ih;                        /* interrupt vectoring */
  308     void *sc_ats;                       /* shutdown hook */
  309     struct ethercom sc_ec;
  310     bus_dma_tag_t sc_dmatag;
  311 #define sc_if           sc_ec.ec_if
  312 #elif defined(__FreeBSD__)
  313     struct kern_devconf *sc_kdc;        /* freebsd cruft */
  314     struct arpcom sc_ac;
  315 #define sc_if           sc_ac.ac_if
  316 #endif
  317 #if defined(IFM_FDDI)
  318     struct ifmedia sc_ifmedia;
  319 #endif
  320     pdq_t *sc_pdq;
  321 #if defined(__alpha__) || defined(__i386__)
  322     pdq_bus_ioport_t sc_iobase;
  323 #endif
  324 #if defined(PDQ_IOMAPPED) && !defined(__NetBSD__)
  325 #define sc_membase      sc_iobase
  326 #else
  327     pdq_bus_memaddr_t sc_membase;
  328 #endif
  329     pdq_bus_t sc_iotag;
  330     pdq_bus_t sc_csrtag;
  331 #if !defined(__bsdi__) || _BSDI_VERSION >= 199401
  332 #define sc_bpf          sc_if.if_bpf
  333 #else
  334     caddr_t sc_bpf;
  335 #endif
  336 #if defined(PDQ_BUS_DMA)
  337 #if !defined(__NetBSD__)
  338      bus_dma_tag_t sc_dmatag;
  339 #endif
  340      bus_dmamap_t sc_dbmap;             /* DMA map for descriptor block */
  341      bus_dmamap_t sc_uimap;             /* DMA map for unsolicited events */
  342      bus_dmamap_t sc_cbmap;             /* DMA map for consumer block */
  343 #endif
  344 } pdq_softc_t;
  345 
  346 
  347 extern void pdq_ifreset(pdq_softc_t *sc);
  348 extern void pdq_ifinit(pdq_softc_t *sc);
  349 extern void pdq_ifwatchdog(struct ifnet *ifp);
  350 extern ifnet_ret_t pdq_ifstart(struct ifnet *ifp);
  351 extern int pdq_ifioctl(struct ifnet *ifp, ioctl_cmd_t cmd, caddr_t data);
  352 extern void pdq_ifattach(pdq_softc_t *sc, ifnet_ret_t (*ifwatchdog)(int unit));
  353 #endif /* !PDQ_HWSUPPORT */
  354 
  355 
  356 #elif defined(DLPI_PDQ)
  357 #include <sys/param.h>
  358 #include <sys/kmem.h>
  359 #include <sys/ddi.h>
  360 #include <sys/stream.h>
  361 
  362 #define PDQ_USE_STREAMS
  363 #define PDQ_OS_PREFIX                   "%s board %d "
  364 #define PDQ_OS_PREFIX_ARGS              pdq->pdq_os_name, pdq->pdq_unit
  365 
  366 #define PDQ_OS_PAGESIZE                 PAGESIZE
  367 #define PDQ_OS_USEC_DELAY(n)            drv_usecwait(n)
  368 #define PDQ_OS_MEMZERO(p, n)            bzero((caddr_t)(p), (n))
  369 #define PDQ_OS_VA_TO_BUSPA(pdq, p)              vtop((caddr_t)p, NULL)
  370 #define PDQ_OS_MEMALLOC(n)              kmem_zalloc(n, KM_NOSLEEP)
  371 #define PDQ_OS_MEMFREE(p, n)            kmem_free((caddr_t) p, n)
  372 #define PDQ_OS_MEMALLOC_CONTIG(n)       kmem_zalloc_physreq(n, decfddiphysreq_db, KM_NOSLEEP)
  373 #define PDQ_OS_MEMFREE_CONTIG(p, n)     PDQ_OS_MEMFREE(p, n)
  374 
  375 extern physreq_t *decfddiphysreq_db;
  376 extern physreq_t *decfddiphysreq_mblk;
  377 
  378 #define PDQ_OS_DATABUF_ALLOC(pdq, b)            ((void) (((b) = allocb_physreq(PDQ_OS_DATABUF_SIZE, BPRI_MED, decfddiphysreq_mblk)) && ((b)->b_wptr = (b)->b_rptr + PDQ_OS_DATABUF_SIZE)))
  379 
  380 #define PDQ_OS_IORD_8(port)             inb(port)
  381 #define PDQ_OS_IOWR_8(port, data)       outb(port, data)
  382 #endif
  383 
  384 
  385 #ifdef PDQ_USE_MBUFS
  386 #define PDQ_OS_DATABUF_SIZE                     (MCLBYTES)
  387 #ifndef PDQ_OS_DATABUF_FREE
  388 #define PDQ_OS_DATABUF_FREE(pdq, b)             (m_freem(b))
  389 #endif
  390 #define PDQ_OS_DATABUF_NEXT(b)                  ((b)->m_next)
  391 #define PDQ_OS_DATABUF_NEXT_SET(b, b1)          ((b)->m_next = (b1))
  392 #define PDQ_OS_DATABUF_NEXTPKT(b)               ((b)->m_nextpkt)
  393 #define PDQ_OS_DATABUF_NEXTPKT_SET(b, b1)       ((b)->m_nextpkt = (b1))
  394 #define PDQ_OS_DATABUF_LEN(b)                   ((b)->m_len)
  395 #define PDQ_OS_DATABUF_LEN_SET(b, n)            ((b)->m_len = (n))
  396 /* #define      PDQ_OS_DATABUF_LEN_ADJ(b, n)            ((b)->m_len += (n)) */
  397 #define PDQ_OS_DATABUF_PTR(b)                   (mtod((b), pdq_uint8_t *))
  398 #define PDQ_OS_DATABUF_ADJ(b, n)                ((b)->m_data += (n), (b)->m_len -= (n))
  399 typedef struct mbuf PDQ_OS_DATABUF_T;
  400 
  401 #ifndef PDQ_OS_DATABUF_ALLOC
  402 #define PDQ_OS_DATABUF_ALLOC(pdq, b) do { \
  403     PDQ_OS_DATABUF_T *x_m0; \
  404     MGETHDR(x_m0, M_DONTWAIT, MT_DATA); \
  405     if (x_m0 != NULL) { \
  406         MCLGET(x_m0, M_DONTWAIT);       \
  407         if ((x_m0->m_flags & M_EXT) == 0) { \
  408             m_free(x_m0); \
  409             (b) = NULL; \
  410         } else { \
  411             (b) = x_m0; \
  412             x_m0->m_len = PDQ_OS_DATABUF_SIZE; \
  413         } \
  414     } else { \
  415         (b) = NULL; \
  416     } \
  417 } while (0)
  418 #endif
  419 #define PDQ_OS_DATABUF_RESET(b) ((b)->m_data = (b)->m_ext.ext_buf, (b)->m_len = MCLBYTES)
  420 #endif /* PDQ_USE_MBUFS */
  421 
  422 #ifdef PDQ_USE_STREAMS
  423 #define PDQ_OS_DATABUF_SIZE                     (2048)
  424 #define PDQ_OS_DATABUF_FREE(pdq, b)             (freemsg(b))
  425 #define PDQ_OS_DATABUF_NEXT(b)                  ((b)->b_cont)
  426 #define PDQ_OS_DATABUF_NEXT_SET(b, b1)          ((b)->b_cont = (b1))
  427 #define PDQ_OS_DATABUF_NEXTPKT(b)               ((b)->b_next)
  428 #define PDQ_OS_DATABUF_NEXTPKT_SET(b, b1)       ((b)->b_next = (b1))
  429 #define PDQ_OS_DATABUF_LEN(b)                   ((b)->b_wptr - (b)->b_rptr)
  430 #define PDQ_OS_DATABUF_LEN_SET(b, n)            ((b)->b_wptr = (b)->b_rptr + (n))
  431 /*#define       PDQ_OS_DATABUF_LEN_ADJ(b, n)            ((b)->b_wptr += (n))*/
  432 #define PDQ_OS_DATABUF_PTR(b)                   ((pdq_uint8_t *) (b)->b_rptr)
  433 #define PDQ_OS_DATABUF_ADJ(b, n)                ((b)->b_rptr += (n))
  434 typedef mblk_t PDQ_OS_DATABUF_T;
  435 
  436 #ifndef PDQ_OS_DATABUF_ALLOC
  437 #define PDQ_OS_DATABUF_ALLOC(pdq, b)                    ((void) (((b) = allocb(PDQ_OS_DATABUF_SIZE, BPRI_MED)) && ((b)->b_wptr = (b)->b_rptr + PDQ_OS_DATABUF_SIZE)))
  438 #endif /* PDQ_OS_DATABUF_ALLOC */
  439 #endif /* PDQ_USE_STREAMS */
  440 
  441 #define PDQ_OS_TX_TRANSMIT              5
  442 
  443 #define PDQ_OS_DATABUF_ENQUEUE(q, b)    do { \
  444     PDQ_OS_DATABUF_NEXTPKT_SET(b, NULL); \
  445     if ((q)->q_tail == NULL) \
  446         (q)->q_head = (b); \
  447     else \
  448         PDQ_OS_DATABUF_NEXTPKT_SET(((PDQ_OS_DATABUF_T *)(q)->q_tail), b); \
  449     (q)->q_tail = (b); \
  450 } while (0)
  451 
  452 #define PDQ_OS_DATABUF_DEQUEUE(q, b)    do { \
  453     if (((b) = (PDQ_OS_DATABUF_T *) (q)->q_head) != NULL) { \
  454         if (((q)->q_head = PDQ_OS_DATABUF_NEXTPKT(b)) == NULL) \
  455             (q)->q_tail = NULL; \
  456         PDQ_OS_DATABUF_NEXTPKT_SET(b, NULL); \
  457     } \
  458 } while (0)
  459 
  460 #if !defined(PDQ_OS_CONSUMER_PRESYNC)
  461 #define PDQ_OS_CONSUMER_PRESYNC(pdq)            do { } while(0)
  462 #define PDQ_OS_CONSUMER_POSTSYNC(pdq)           do { } while(0)
  463 #define PDQ_OS_DESC_PRESYNC(pdq, d, s)          do { } while(0)
  464 #define PDQ_OS_DESC_POSTSYNC(pdq, d, s)         do { } while(0)
  465 #define PDQ_OS_CMDRQST_PRESYNC(pdq, s)          do { } while(0)
  466 #define PDQ_OS_CMDRQST_POSTSYNC(pdq, s)         do { } while(0)
  467 #define PDQ_OS_CMDRSP_PRESYNC(pdq, s)           do { } while(0)
  468 #define PDQ_OS_CMDRSP_POSTSYNC(pdq, s)          do { } while(0)
  469 #define PDQ_OS_RXPDU_PRESYNC(pdq, b, o, l)      do { } while(0)
  470 #define PDQ_OS_RXPDU_POSTSYNC(pdq, b, o, l)     do { } while(0)
  471 #define PDQ_OS_UNSOL_EVENT_PRESYNC(pdq, e)      do { } while(0)
  472 #define PDQ_OS_UNSOL_EVENT_POSTSYNC(pdq, e)     do { } while(0)
  473 #endif
  474 
  475 #ifndef PDQ_OS_DATABUF_BUSPA
  476 #define PDQ_OS_DATABUF_BUSPA(pdq, b)    PDQ_OS_VA_TO_BUSPA(pdq, PDQ_OS_DATABUF_PTR(b))
  477 #endif
  478 
  479 #ifndef PDQ_OS_HDR_OFFSET
  480 #define PDQ_OS_HDR_OFFSET       PDQ_RX_FC_OFFSET
  481 #endif
  482 
  483 extern void pdq_os_addr_fill(pdq_t *pdq, pdq_lanaddr_t *addrs, size_t numaddrs);
  484 extern void pdq_os_receive_pdu(pdq_t *, PDQ_OS_DATABUF_T *pdu, size_t pdulen, int drop);
  485 extern void pdq_os_restart_transmitter(pdq_t *pdq);
  486 extern void pdq_os_transmit_done(pdq_t *pdq, PDQ_OS_DATABUF_T *pdu);
  487 #if !defined(pdq_os_update_status)
  488 extern void pdq_os_update_status(pdq_t *pdq, const void *rsp);
  489 #endif
  490 #if !defined(PDQ_OS_MEMALLOC_CONTIG)
  491 extern int pdq_os_memalloc_contig(pdq_t *pdq);
  492 #endif
  493 extern pdq_boolean_t pdq_queue_transmit_data(pdq_t *pdq, PDQ_OS_DATABUF_T *pdu);
  494 extern void pdq_flush_transmitter(pdq_t *pdq);
  495 
  496 extern void pdq_run(pdq_t *pdq);
  497 extern pdq_state_t pdq_stop(pdq_t *pdq);
  498 extern void pdq_hwreset(pdq_t *pdq);
  499 
  500 extern int pdq_interrupt(pdq_t *pdq);
  501 extern pdq_t *pdq_initialize(pdq_bus_t bus, pdq_bus_memaddr_t csr_va,
  502                              const char *name, int unit,
  503                              void *ctx, pdq_type_t type);
  504 #endif /* _PDQ_OS_H */

Cache object: 8891f8b89999a0d6ba3192fff4e88191


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