xref: /csrg-svn/sys/vax/if/if_uba.h (revision 25417)
123304Smckusick /*
223304Smckusick  * Copyright (c) 1982 Regents of the University of California.
323304Smckusick  * All rights reserved.  The Berkeley software License Agreement
423304Smckusick  * specifies the terms and conditions for redistribution.
523304Smckusick  *
6*25417Skarels  *	@(#)if_uba.h	6.4 (Berkeley) 11/07/85
723304Smckusick  */
85079Swnj 
95079Swnj /*
105079Swnj  * Structure and routine definitions
115079Swnj  * for UNIBUS network interfaces.
125079Swnj  */
135079Swnj 
145172Swnj #define	IF_MAXNUBAMR	10
155079Swnj /*
1624795Skarels  * Each interface has structures giving information
1724795Skarels  * about UNIBUS resources held by the interface
1824795Skarels  * for each send and receive buffer.
195079Swnj  *
205079Swnj  * We hold IF_NUBAMR map registers for datagram data, starting
215079Swnj  * at ifr_mr.  Map register ifr_mr[-1] maps the local network header
225079Swnj  * ending on the page boundary.  Bdp's are reserved for read and for
235079Swnj  * write, given by ifr_bdp.  The prototype of the map register for
245079Swnj  * read and for write is saved in ifr_proto.
255079Swnj  *
265079Swnj  * When write transfers are not full pages on page boundaries we just
275079Swnj  * copy the data into the pages mapped on the UNIBUS and start the
285079Swnj  * transfer.  If a write transfer is of a (1024 byte) page on a page
295079Swnj  * boundary, we swap in UNIBUS pte's to reference the pages, and then
305079Swnj  * remap the initial pages (from ifu_wmap) when the transfer completes.
315079Swnj  *
325079Swnj  * When read transfers give whole pages of data to be input, we
335079Swnj  * allocate page frames from a network page list and trade them
345079Swnj  * with the pages already containing the data, mapping the allocated
355079Swnj  * pages to replace the input pages for the next UNIBUS data input.
365079Swnj  */
3724795Skarels 
3824795Skarels /*
3924795Skarels  * Information per interface.
4024795Skarels  */
4124795Skarels struct	ifubinfo {
4224795Skarels 	short	iff_uban;			/* uba number */
4324795Skarels 	short	iff_hlen;			/* local net header length */
4424795Skarels 	struct	uba_regs *iff_uba;		/* uba regs, in vm */
4524795Skarels 	short	iff_flags;			/* used during uballoc's */
465079Swnj };
475084Swnj 
4824795Skarels /*
4924795Skarels  * Information per buffer.
5024795Skarels  */
5124795Skarels struct ifrw {
5224795Skarels 	caddr_t	ifrw_addr;			/* virt addr of header */
53*25417Skarels 	short	ifrw_bdp;			/* unibus bdp */
54*25417Skarels 	short	ifrw_flags;			/* type, etc. */
55*25417Skarels #define	IFRW_W	0x01				/* is a transmit buffer */
5624795Skarels 	int	ifrw_info;			/* value from ubaalloc */
5724795Skarels 	int	ifrw_proto;			/* map register prototype */
5824795Skarels 	struct	pte *ifrw_mr;			/* base of map registers */
5924795Skarels };
6024795Skarels 
6124795Skarels /*
6224795Skarels  * Information per transmit buffer, including the above.
6324795Skarels  */
6424795Skarels struct ifxmt {
6524795Skarels 	struct	ifrw ifrw;
6624795Skarels 	caddr_t	ifw_base;			/* virt addr of buffer */
6724795Skarels 	struct	pte ifw_wmap[IF_MAXNUBAMR];	/* base pages for output */
6824795Skarels 	struct	mbuf *ifw_xtofree;		/* pages being dma'd out */
6924795Skarels 	short	ifw_xswapd;			/* mask of clusters swapped */
7024795Skarels };
7124795Skarels #define	ifw_addr	ifrw.ifrw_addr
7224795Skarels #define	ifw_bdp		ifrw.ifrw_bdp
73*25417Skarels #define	ifw_flags	ifrw.ifrw_flags
7424795Skarels #define	ifw_info	ifrw.ifrw_info
7524795Skarels #define	ifw_proto	ifrw.ifrw_proto
7624795Skarels #define	ifw_mr		ifrw.ifrw_mr
7724795Skarels 
7824795Skarels /*
7924795Skarels  * Most interfaces have a single receive and a single transmit buffer,
8024795Skarels  * and use struct ifuba to store all of the unibus information.
8124795Skarels  */
8224795Skarels struct ifuba {
8324795Skarels 	struct	ifubinfo ifu_info;
8424795Skarels 	struct	ifrw ifu_r;
8524795Skarels 	struct	ifxmt ifu_xmt;
8624795Skarels };
8724795Skarels 
8824795Skarels #define	ifu_uban	ifu_info.iff_uban
8924795Skarels #define	ifu_hlen	ifu_info.iff_hlen
9024795Skarels #define	ifu_uba		ifu_info.iff_uba
9124795Skarels #define	ifu_flags	ifu_info.iff_flags
9224795Skarels #define	ifu_w		ifu_xmt.ifrw
9324795Skarels #define	ifu_xtofree	ifu_xmt.ifw_xtofree
9424795Skarels 
955084Swnj #ifdef 	KERNEL
9624795Skarels #define	if_ubainit(ifuba, uban, hlen, nmr) \
9724795Skarels 		if_ubaminit(&(ifuba)->ifu_info, uban, hlen, nmr, \
9824795Skarels 			&(ifuba)->ifu_r, 1, &(ifuba)->ifu_w, 1)
9924795Skarels #define	if_rubaget(ifu, totlen, off0, ifp) \
10024795Skarels 		if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, totlen, off0, ifp)
10124795Skarels #define	if_wubaput(ifu, m) \
10224795Skarels 		if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_w, m)
10324795Skarels struct	mbuf *if_ubaget();
1045084Swnj #endif
105