xref: /original-bsd/sys/vax/if/if_uba.h (revision e1db577d)
1 /*
2  * Copyright (c) 1982, 1986 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)if_uba.h	7.4 (Berkeley) 06/28/90
8  */
9 
10 /*
11  * Structure and routine definitions
12  * for UNIBUS network interfaces.
13  */
14 
15 #define	IF_MAXNUBAMR	10
16 /*
17  * Each interface has structures giving information
18  * about UNIBUS resources held by the interface
19  * for each send and receive buffer.
20  *
21  * We hold IF_NUBAMR map registers for datagram data, starting
22  * at ifr_mr.  Map register ifr_mr[-1] maps the local network header
23  * ending on the page boundary.  Bdp's are reserved for read and for
24  * write, given by ifr_bdp.  The prototype of the map register for
25  * read and for write is saved in ifr_proto.
26  *
27  * When write transfers are not full pages on page boundaries we just
28  * copy the data into the pages mapped on the UNIBUS and start the
29  * transfer.  If a write transfer is of a (1024 byte) page on a page
30  * boundary, we swap in UNIBUS pte's to reference the pages, and then
31  * remap the initial pages (from ifu_wmap) when the transfer completes.
32  *
33  * When read transfers give whole pages of data to be input, we
34  * allocate page frames from a network page list and trade them
35  * with the pages already containing the data, mapping the allocated
36  * pages to replace the input pages for the next UNIBUS data input.
37  */
38 
39 /*
40  * Information per interface.
41  */
42 struct	ifubinfo {
43 	short	iff_uban;			/* uba number */
44 	short	iff_hlen;			/* local net header length */
45 	struct	uba_regs *iff_uba;		/* uba adaptor regs, in vm */
46 	struct	pte *iff_ubamr;			/* uba map regs, in vm */
47 	short	iff_flags;			/* used during uballoc's */
48 };
49 
50 /*
51  * Information per buffer.
52  */
53 struct ifrw {
54 	caddr_t	ifrw_addr;			/* virt addr of header */
55 	short	ifrw_bdp;			/* unibus bdp */
56 	short	ifrw_flags;			/* type, etc. */
57 #define	IFRW_W	0x01				/* is a transmit buffer */
58 	int	ifrw_info;			/* value from ubaalloc */
59 	int	ifrw_proto;			/* map register prototype */
60 	struct	pte *ifrw_mr;			/* base of map registers */
61 };
62 
63 /*
64  * Information per transmit buffer, including the above.
65  */
66 struct ifxmt {
67 	struct	ifrw ifrw;
68 	caddr_t	ifw_base;			/* virt addr of buffer */
69 	struct	pte ifw_wmap[IF_MAXNUBAMR];	/* base pages for output */
70 	struct	mbuf *ifw_xtofree;		/* pages being dma'd out */
71 	short	ifw_xswapd;			/* mask of clusters swapped */
72 	short	ifw_nmr;			/* number of entries in wmap */
73 };
74 #define	ifw_addr	ifrw.ifrw_addr
75 #define	ifw_bdp		ifrw.ifrw_bdp
76 #define	ifw_flags	ifrw.ifrw_flags
77 #define	ifw_info	ifrw.ifrw_info
78 #define	ifw_proto	ifrw.ifrw_proto
79 #define	ifw_mr		ifrw.ifrw_mr
80 
81 /*
82  * Most interfaces have a single receive and a single transmit buffer,
83  * and use struct ifuba to store all of the unibus information.
84  */
85 struct ifuba {
86 	struct	ifubinfo ifu_info;
87 	struct	ifrw ifu_r;
88 	struct	ifxmt ifu_xmt;
89 };
90 
91 #define	ifu_uban	ifu_info.iff_uban
92 #define	ifu_hlen	ifu_info.iff_hlen
93 #define	ifu_uba		ifu_info.iff_uba
94 #define	ifu_ubamr	ifu_info.iff_ubamr
95 #define	ifu_flags	ifu_info.iff_flags
96 #define	ifu_w		ifu_xmt.ifrw
97 #define	ifu_xtofree	ifu_xmt.ifw_xtofree
98 
99 #ifdef 	KERNEL
100 #define	if_ubainit(ifuba, uban, hlen, nmr) \
101 		if_ubaminit(&(ifuba)->ifu_info, uban, hlen, nmr, \
102 			&(ifuba)->ifu_r, 1, &(ifuba)->ifu_xmt, 1)
103 #define	if_rubaget(ifu, totlen, off0, ifp) \
104 		if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, totlen, off0, ifp)
105 #define	if_wubaput(ifu, m) \
106 		if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_xmt, m)
107 struct	mbuf *if_ubaget();
108 #endif
109