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