1 1.15 christos /* $NetBSD: if_uba.h,v 1.15 2007/03/04 06:02:29 christos Exp $ */ 2 1.2 cgd 3 1.1 ragge /* 4 1.1 ragge * Copyright (c) 1982, 1986 Regents of the University of California. 5 1.1 ragge * All rights reserved. 6 1.1 ragge * 7 1.1 ragge * Redistribution and use in source and binary forms, with or without 8 1.1 ragge * modification, are permitted provided that the following conditions 9 1.1 ragge * are met: 10 1.1 ragge * 1. Redistributions of source code must retain the above copyright 11 1.1 ragge * notice, this list of conditions and the following disclaimer. 12 1.1 ragge * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 ragge * notice, this list of conditions and the following disclaimer in the 14 1.1 ragge * documentation and/or other materials provided with the distribution. 15 1.12 agc * 3. Neither the name of the University nor the names of its contributors 16 1.1 ragge * may be used to endorse or promote products derived from this software 17 1.1 ragge * without specific prior written permission. 18 1.1 ragge * 19 1.1 ragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 1.1 ragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 1.1 ragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 1.1 ragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 1.1 ragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 1.1 ragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 1.1 ragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 1.1 ragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 1.1 ragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 1.1 ragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 1.1 ragge * SUCH DAMAGE. 30 1.1 ragge * 31 1.1 ragge * @(#)if_uba.h 7.4 (Berkeley) 6/28/90 32 1.1 ragge */ 33 1.1 ragge 34 1.1 ragge /* 35 1.1 ragge * Structure and routine definitions 36 1.1 ragge * for UNIBUS network interfaces. 37 1.1 ragge */ 38 1.1 ragge 39 1.1 ragge /* 40 1.1 ragge * Each interface has structures giving information 41 1.1 ragge * about UNIBUS resources held by the interface 42 1.1 ragge * for each send and receive buffer. 43 1.1 ragge * 44 1.1 ragge * We hold IF_NUBAMR map registers for datagram data, starting 45 1.1 ragge * at ifr_mr. Map register ifr_mr[-1] maps the local network header 46 1.1 ragge * ending on the page boundary. Bdp's are reserved for read and for 47 1.1 ragge * write, given by ifr_bdp. The prototype of the map register for 48 1.1 ragge * read and for write is saved in ifr_proto. 49 1.1 ragge * 50 1.1 ragge * When write transfers are not full pages on page boundaries we just 51 1.1 ragge * copy the data into the pages mapped on the UNIBUS and start the 52 1.1 ragge * transfer. If a write transfer is of a (1024 byte) page on a page 53 1.1 ragge * boundary, we swap in UNIBUS pte's to reference the pages, and then 54 1.1 ragge * remap the initial pages (from ifu_wmap) when the transfer completes. 55 1.1 ragge * 56 1.1 ragge * When read transfers give whole pages of data to be input, we 57 1.1 ragge * allocate page frames from a network page list and trade them 58 1.1 ragge * with the pages already containing the data, mapping the allocated 59 1.1 ragge * pages to replace the input pages for the next UNIBUS data input. 60 1.1 ragge */ 61 1.1 ragge 62 1.1 ragge /* 63 1.1 ragge * Information per interface. 64 1.1 ragge */ 65 1.1 ragge struct ifubinfo { 66 1.6 ragge struct uba_softc *iff_softc; /* uba */ 67 1.1 ragge }; 68 1.1 ragge 69 1.1 ragge /* 70 1.1 ragge * Information per buffer. 71 1.1 ragge */ 72 1.1 ragge struct ifrw { 73 1.1 ragge short ifrw_bdp; /* unibus bdp */ 74 1.1 ragge short ifrw_flags; /* type, etc. */ 75 1.9 ragge #define IFRW_MBUF 0x01 /* uses DMA from mbuf */ 76 1.9 ragge bus_dmamap_t ifrw_map; /* DMA map */ 77 1.9 ragge struct mbuf *ifrw_mbuf; 78 1.1 ragge }; 79 1.1 ragge 80 1.1 ragge /* 81 1.1 ragge * Information per transmit buffer, including the above. 82 1.1 ragge */ 83 1.1 ragge struct ifxmt { 84 1.1 ragge struct ifrw ifrw; 85 1.15 christos void * ifw_vaddr; /* DMA memory virtual addr */ 86 1.9 ragge int ifw_size; /* Size of this DMA block */ 87 1.1 ragge }; 88 1.9 ragge #define ifrw_addr ifrw_mbuf->m_data 89 1.9 ragge #define ifrw_info ifrw_map->dm_segs[0].ds_addr 90 1.1 ragge #define ifw_addr ifrw.ifrw_addr 91 1.1 ragge #define ifw_bdp ifrw.ifrw_bdp 92 1.1 ragge #define ifw_flags ifrw.ifrw_flags 93 1.1 ragge #define ifw_info ifrw.ifrw_info 94 1.1 ragge #define ifw_proto ifrw.ifrw_proto 95 1.1 ragge #define ifw_mr ifrw.ifrw_mr 96 1.9 ragge #define ifw_map ifrw.ifrw_map 97 1.9 ragge #define ifw_mbuf ifrw.ifrw_mbuf 98 1.1 ragge 99 1.1 ragge /* 100 1.1 ragge * Most interfaces have a single receive and a single transmit buffer, 101 1.1 ragge * and use struct ifuba to store all of the unibus information. 102 1.1 ragge */ 103 1.1 ragge struct ifuba { 104 1.1 ragge struct ifubinfo ifu_info; 105 1.1 ragge struct ifrw ifu_r; 106 1.1 ragge struct ifxmt ifu_xmt; 107 1.1 ragge }; 108 1.1 ragge 109 1.6 ragge #define ifu_softc ifu_info.iff_softc 110 1.1 ragge #define ifu_hlen ifu_info.iff_hlen 111 1.1 ragge #define ifu_uba ifu_info.iff_uba 112 1.1 ragge #define ifu_ubamr ifu_info.iff_ubamr 113 1.1 ragge #define ifu_flags ifu_info.iff_flags 114 1.1 ragge #define ifu_w ifu_xmt.ifrw 115 1.1 ragge #define ifu_xtofree ifu_xmt.ifw_xtofree 116 1.1 ragge 117 1.13 simonb #ifdef _KERNEL 118 1.9 ragge #define if_ubainit(ifuba, uban, size) \ 119 1.9 ragge if_ubaminit(&(ifuba)->ifu_info, uban, size, \ 120 1.1 ragge &(ifuba)->ifu_r, 1, &(ifuba)->ifu_xmt, 1) 121 1.9 ragge #define if_rubaget(ifu, ifp, len) \ 122 1.9 ragge if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, ifp, len) 123 1.1 ragge #define if_wubaput(ifu, m) \ 124 1.1 ragge if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_xmt, m) 125 1.9 ragge #define if_wubaend(ifu) \ 126 1.9 ragge if_ubaend(&(ifu)->ifu_info, &(ifu)->ifu_xmt) 127 1.4 ragge 128 1.5 ragge /* Prototypes */ 129 1.9 ragge int if_ubaminit(struct ifubinfo *, struct uba_softc *, int, 130 1.9 ragge struct ifrw *, int, struct ifxmt *, int); 131 1.9 ragge int if_ubaput(struct ifubinfo *, struct ifxmt *, struct mbuf *); 132 1.9 ragge struct mbuf *if_ubaget(struct ifubinfo *, struct ifrw *, struct ifnet *, int); 133 1.9 ragge void if_ubaend(struct ifubinfo *ifu, struct ifxmt *); 134 1.1 ragge #endif 135