xref: /csrg-svn/sys/vax/if/if_uba.h (revision 24795)
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*24795Skarels  *	@(#)if_uba.h	6.3 (Berkeley) 09/16/85
723304Smckusick  */
85079Swnj 
95079Swnj /*
105079Swnj  * Structure and routine definitions
115079Swnj  * for UNIBUS network interfaces.
125079Swnj  */
135079Swnj 
145172Swnj #define	IF_MAXNUBAMR	10
155079Swnj /*
16*24795Skarels  * Each interface has structures giving information
17*24795Skarels  * about UNIBUS resources held by the interface
18*24795Skarels  * 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  */
37*24795Skarels 
38*24795Skarels /*
39*24795Skarels  * Information per interface.
40*24795Skarels  */
41*24795Skarels struct	ifubinfo {
42*24795Skarels 	short	iff_uban;			/* uba number */
43*24795Skarels 	short	iff_hlen;			/* local net header length */
44*24795Skarels 	struct	uba_regs *iff_uba;		/* uba regs, in vm */
45*24795Skarels 	short	iff_flags;			/* used during uballoc's */
465079Swnj };
475084Swnj 
48*24795Skarels /*
49*24795Skarels  * Information per buffer.
50*24795Skarels  */
51*24795Skarels struct ifrw {
52*24795Skarels 	caddr_t	ifrw_addr;			/* virt addr of header */
53*24795Skarels 	int	ifrw_bdp;			/* unibus bdp */
54*24795Skarels 	int	ifrw_info;			/* value from ubaalloc */
55*24795Skarels 	int	ifrw_proto;			/* map register prototype */
56*24795Skarels 	struct	pte *ifrw_mr;			/* base of map registers */
57*24795Skarels };
58*24795Skarels 
59*24795Skarels /*
60*24795Skarels  * Information per transmit buffer, including the above.
61*24795Skarels  */
62*24795Skarels struct ifxmt {
63*24795Skarels 	struct	ifrw ifrw;
64*24795Skarels 	caddr_t	ifw_base;			/* virt addr of buffer */
65*24795Skarels 	struct	pte ifw_wmap[IF_MAXNUBAMR];	/* base pages for output */
66*24795Skarels 	struct	mbuf *ifw_xtofree;		/* pages being dma'd out */
67*24795Skarels 	short	ifw_xswapd;			/* mask of clusters swapped */
68*24795Skarels };
69*24795Skarels #define	ifw_addr	ifrw.ifrw_addr
70*24795Skarels #define	ifw_bdp		ifrw.ifrw_bdp
71*24795Skarels #define	ifw_info	ifrw.ifrw_info
72*24795Skarels #define	ifw_proto	ifrw.ifrw_proto
73*24795Skarels #define	ifw_mr		ifrw.ifrw_mr
74*24795Skarels 
75*24795Skarels /*
76*24795Skarels  * Most interfaces have a single receive and a single transmit buffer,
77*24795Skarels  * and use struct ifuba to store all of the unibus information.
78*24795Skarels  */
79*24795Skarels struct ifuba {
80*24795Skarels 	struct	ifubinfo ifu_info;
81*24795Skarels 	struct	ifrw ifu_r;
82*24795Skarels 	struct	ifxmt ifu_xmt;
83*24795Skarels };
84*24795Skarels 
85*24795Skarels #define	ifu_uban	ifu_info.iff_uban
86*24795Skarels #define	ifu_hlen	ifu_info.iff_hlen
87*24795Skarels #define	ifu_uba		ifu_info.iff_uba
88*24795Skarels #define	ifu_flags	ifu_info.iff_flags
89*24795Skarels #define	ifu_w		ifu_xmt.ifrw
90*24795Skarels #define	ifu_xtofree	ifu_xmt.ifw_xtofree
91*24795Skarels 
925084Swnj #ifdef 	KERNEL
93*24795Skarels #define	if_ubainit(ifuba, uban, hlen, nmr) \
94*24795Skarels 		if_ubaminit(&(ifuba)->ifu_info, uban, hlen, nmr, \
95*24795Skarels 			&(ifuba)->ifu_r, 1, &(ifuba)->ifu_w, 1)
96*24795Skarels #define	if_rubaget(ifu, totlen, off0, ifp) \
97*24795Skarels 		if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, totlen, off0, ifp)
98*24795Skarels #define	if_wubaput(ifu, m) \
99*24795Skarels 		if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_w, m)
100*24795Skarels struct	mbuf *if_ubaget();
1015084Swnj #endif
102