xref: /csrg-svn/sys/vax/if/if_uba.h (revision 35327)
123304Smckusick /*
229289Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
3*35327Sbostic  * All rights reserved.
423304Smckusick  *
5*35327Sbostic  * Redistribution and use in source and binary forms are permitted
6*35327Sbostic  * provided that the above copyright notice and this paragraph are
7*35327Sbostic  * duplicated in all such forms and that any documentation,
8*35327Sbostic  * advertising materials, and other materials related to such
9*35327Sbostic  * distribution and use acknowledge that the software was developed
10*35327Sbostic  * by the University of California, Berkeley.  The name of the
11*35327Sbostic  * University may not be used to endorse or promote products derived
12*35327Sbostic  * from this software without specific prior written permission.
13*35327Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*35327Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*35327Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16*35327Sbostic  *
17*35327Sbostic  *	@(#)if_uba.h	7.3 (Berkeley) 08/04/88
1823304Smckusick  */
195079Swnj 
205079Swnj /*
215079Swnj  * Structure and routine definitions
225079Swnj  * for UNIBUS network interfaces.
235079Swnj  */
245079Swnj 
255172Swnj #define	IF_MAXNUBAMR	10
265079Swnj /*
2724795Skarels  * Each interface has structures giving information
2824795Skarels  * about UNIBUS resources held by the interface
2924795Skarels  * for each send and receive buffer.
305079Swnj  *
315079Swnj  * We hold IF_NUBAMR map registers for datagram data, starting
325079Swnj  * at ifr_mr.  Map register ifr_mr[-1] maps the local network header
335079Swnj  * ending on the page boundary.  Bdp's are reserved for read and for
345079Swnj  * write, given by ifr_bdp.  The prototype of the map register for
355079Swnj  * read and for write is saved in ifr_proto.
365079Swnj  *
375079Swnj  * When write transfers are not full pages on page boundaries we just
385079Swnj  * copy the data into the pages mapped on the UNIBUS and start the
395079Swnj  * transfer.  If a write transfer is of a (1024 byte) page on a page
405079Swnj  * boundary, we swap in UNIBUS pte's to reference the pages, and then
415079Swnj  * remap the initial pages (from ifu_wmap) when the transfer completes.
425079Swnj  *
435079Swnj  * When read transfers give whole pages of data to be input, we
445079Swnj  * allocate page frames from a network page list and trade them
455079Swnj  * with the pages already containing the data, mapping the allocated
465079Swnj  * pages to replace the input pages for the next UNIBUS data input.
475079Swnj  */
4824795Skarels 
4924795Skarels /*
5024795Skarels  * Information per interface.
5124795Skarels  */
5224795Skarels struct	ifubinfo {
5324795Skarels 	short	iff_uban;			/* uba number */
5424795Skarels 	short	iff_hlen;			/* local net header length */
5529740Skarels 	struct	uba_regs *iff_uba;		/* uba adaptor regs, in vm */
5629740Skarels 	struct	pte *iff_ubamr;			/* uba map regs, in vm */
5724795Skarels 	short	iff_flags;			/* used during uballoc's */
585079Swnj };
595084Swnj 
6024795Skarels /*
6124795Skarels  * Information per buffer.
6224795Skarels  */
6324795Skarels struct ifrw {
6424795Skarels 	caddr_t	ifrw_addr;			/* virt addr of header */
6525417Skarels 	short	ifrw_bdp;			/* unibus bdp */
6625417Skarels 	short	ifrw_flags;			/* type, etc. */
6725417Skarels #define	IFRW_W	0x01				/* is a transmit buffer */
6824795Skarels 	int	ifrw_info;			/* value from ubaalloc */
6924795Skarels 	int	ifrw_proto;			/* map register prototype */
7024795Skarels 	struct	pte *ifrw_mr;			/* base of map registers */
7124795Skarels };
7224795Skarels 
7324795Skarels /*
7424795Skarels  * Information per transmit buffer, including the above.
7524795Skarels  */
7624795Skarels struct ifxmt {
7724795Skarels 	struct	ifrw ifrw;
7824795Skarels 	caddr_t	ifw_base;			/* virt addr of buffer */
7924795Skarels 	struct	pte ifw_wmap[IF_MAXNUBAMR];	/* base pages for output */
8024795Skarels 	struct	mbuf *ifw_xtofree;		/* pages being dma'd out */
8124795Skarels 	short	ifw_xswapd;			/* mask of clusters swapped */
8225625Skarels 	short	ifw_nmr;			/* number of entries in wmap */
8324795Skarels };
8424795Skarels #define	ifw_addr	ifrw.ifrw_addr
8524795Skarels #define	ifw_bdp		ifrw.ifrw_bdp
8625417Skarels #define	ifw_flags	ifrw.ifrw_flags
8724795Skarels #define	ifw_info	ifrw.ifrw_info
8824795Skarels #define	ifw_proto	ifrw.ifrw_proto
8924795Skarels #define	ifw_mr		ifrw.ifrw_mr
9024795Skarels 
9124795Skarels /*
9224795Skarels  * Most interfaces have a single receive and a single transmit buffer,
9324795Skarels  * and use struct ifuba to store all of the unibus information.
9424795Skarels  */
9524795Skarels struct ifuba {
9624795Skarels 	struct	ifubinfo ifu_info;
9724795Skarels 	struct	ifrw ifu_r;
9824795Skarels 	struct	ifxmt ifu_xmt;
9924795Skarels };
10024795Skarels 
10124795Skarels #define	ifu_uban	ifu_info.iff_uban
10224795Skarels #define	ifu_hlen	ifu_info.iff_hlen
10324795Skarels #define	ifu_uba		ifu_info.iff_uba
10429740Skarels #define	ifu_ubamr	ifu_info.iff_ubamr
10524795Skarels #define	ifu_flags	ifu_info.iff_flags
10624795Skarels #define	ifu_w		ifu_xmt.ifrw
10724795Skarels #define	ifu_xtofree	ifu_xmt.ifw_xtofree
10824795Skarels 
1095084Swnj #ifdef 	KERNEL
11024795Skarels #define	if_ubainit(ifuba, uban, hlen, nmr) \
11124795Skarels 		if_ubaminit(&(ifuba)->ifu_info, uban, hlen, nmr, \
11226394Skarels 			&(ifuba)->ifu_r, 1, &(ifuba)->ifu_xmt, 1)
11324795Skarels #define	if_rubaget(ifu, totlen, off0, ifp) \
11424795Skarels 		if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, totlen, off0, ifp)
11524795Skarels #define	if_wubaput(ifu, m) \
11626394Skarels 		if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_xmt, m)
11724795Skarels struct	mbuf *if_ubaget();
1185084Swnj #endif
119