Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / qbus / if_uba.h
blobd4cf62a297b0fd9169332d9beba7ef68ddb3669d
1 /* $NetBSD: if_uba.h,v 1.14 2005/12/11 12:23:29 christos Exp $ */
3 /*
4 * Copyright (c) 1982, 1986 Regents of the University of California.
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. 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 University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS 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.
31 * @(#)if_uba.h 7.4 (Berkeley) 6/28/90
35 * Structure and routine definitions
36 * for UNIBUS network interfaces.
40 * Each interface has structures giving information
41 * about UNIBUS resources held by the interface
42 * for each send and receive buffer.
44 * We hold IF_NUBAMR map registers for datagram data, starting
45 * at ifr_mr. Map register ifr_mr[-1] maps the local network header
46 * ending on the page boundary. Bdp's are reserved for read and for
47 * write, given by ifr_bdp. The prototype of the map register for
48 * read and for write is saved in ifr_proto.
50 * When write transfers are not full pages on page boundaries we just
51 * copy the data into the pages mapped on the UNIBUS and start the
52 * transfer. If a write transfer is of a (1024 byte) page on a page
53 * boundary, we swap in UNIBUS pte's to reference the pages, and then
54 * remap the initial pages (from ifu_wmap) when the transfer completes.
56 * When read transfers give whole pages of data to be input, we
57 * allocate page frames from a network page list and trade them
58 * with the pages already containing the data, mapping the allocated
59 * pages to replace the input pages for the next UNIBUS data input.
63 * Information per interface.
65 struct ifubinfo {
66 struct uba_softc *iff_softc; /* uba */
70 * Information per buffer.
72 struct ifrw {
73 short ifrw_bdp; /* unibus bdp */
74 short ifrw_flags; /* type, etc. */
75 #define IFRW_MBUF 0x01 /* uses DMA from mbuf */
76 bus_dmamap_t ifrw_map; /* DMA map */
77 struct mbuf *ifrw_mbuf;
81 * Information per transmit buffer, including the above.
83 struct ifxmt {
84 struct ifrw ifrw;
85 void * ifw_vaddr; /* DMA memory virtual addr */
86 int ifw_size; /* Size of this DMA block */
88 #define ifrw_addr ifrw_mbuf->m_data
89 #define ifrw_info ifrw_map->dm_segs[0].ds_addr
90 #define ifw_addr ifrw.ifrw_addr
91 #define ifw_bdp ifrw.ifrw_bdp
92 #define ifw_flags ifrw.ifrw_flags
93 #define ifw_info ifrw.ifrw_info
94 #define ifw_proto ifrw.ifrw_proto
95 #define ifw_mr ifrw.ifrw_mr
96 #define ifw_map ifrw.ifrw_map
97 #define ifw_mbuf ifrw.ifrw_mbuf
100 * Most interfaces have a single receive and a single transmit buffer,
101 * and use struct ifuba to store all of the unibus information.
103 struct ifuba {
104 struct ifubinfo ifu_info;
105 struct ifrw ifu_r;
106 struct ifxmt ifu_xmt;
109 #define ifu_softc ifu_info.iff_softc
110 #define ifu_hlen ifu_info.iff_hlen
111 #define ifu_uba ifu_info.iff_uba
112 #define ifu_ubamr ifu_info.iff_ubamr
113 #define ifu_flags ifu_info.iff_flags
114 #define ifu_w ifu_xmt.ifrw
115 #define ifu_xtofree ifu_xmt.ifw_xtofree
117 #ifdef _KERNEL
118 #define if_ubainit(ifuba, uban, size) \
119 if_ubaminit(&(ifuba)->ifu_info, uban, size, \
120 &(ifuba)->ifu_r, 1, &(ifuba)->ifu_xmt, 1)
121 #define if_rubaget(ifu, ifp, len) \
122 if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, ifp, len)
123 #define if_wubaput(ifu, m) \
124 if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_xmt, m)
125 #define if_wubaend(ifu) \
126 if_ubaend(&(ifu)->ifu_info, &(ifu)->ifu_xmt)
128 /* Prototypes */
129 int if_ubaminit(struct ifubinfo *, struct uba_softc *, int,
130 struct ifrw *, int, struct ifxmt *, int);
131 int if_ubaput(struct ifubinfo *, struct ifxmt *, struct mbuf *);
132 struct mbuf *if_ubaget(struct ifubinfo *, struct ifrw *, struct ifnet *, int);
133 void if_ubaend(struct ifubinfo *ifu, struct ifxmt *);
134 #endif