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