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