1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)if_uba.h 7.3 (Berkeley) 08/04/88 18 */ 19 20 /* 21 * Structure and routine definitions 22 * for UNIBUS network interfaces. 23 */ 24 25 #define IF_MAXNUBAMR 10 26 /* 27 * Each interface has structures giving information 28 * about UNIBUS resources held by the interface 29 * for each send and receive buffer. 30 * 31 * We hold IF_NUBAMR map registers for datagram data, starting 32 * at ifr_mr. Map register ifr_mr[-1] maps the local network header 33 * ending on the page boundary. Bdp's are reserved for read and for 34 * write, given by ifr_bdp. The prototype of the map register for 35 * read and for write is saved in ifr_proto. 36 * 37 * When write transfers are not full pages on page boundaries we just 38 * copy the data into the pages mapped on the UNIBUS and start the 39 * transfer. If a write transfer is of a (1024 byte) page on a page 40 * boundary, we swap in UNIBUS pte's to reference the pages, and then 41 * remap the initial pages (from ifu_wmap) when the transfer completes. 42 * 43 * When read transfers give whole pages of data to be input, we 44 * allocate page frames from a network page list and trade them 45 * with the pages already containing the data, mapping the allocated 46 * pages to replace the input pages for the next UNIBUS data input. 47 */ 48 49 /* 50 * Information per interface. 51 */ 52 struct ifubinfo { 53 short iff_uban; /* uba number */ 54 short iff_hlen; /* local net header length */ 55 struct uba_regs *iff_uba; /* uba adaptor regs, in vm */ 56 struct pte *iff_ubamr; /* uba map regs, in vm */ 57 short iff_flags; /* used during uballoc's */ 58 }; 59 60 /* 61 * Information per buffer. 62 */ 63 struct ifrw { 64 caddr_t ifrw_addr; /* virt addr of header */ 65 short ifrw_bdp; /* unibus bdp */ 66 short ifrw_flags; /* type, etc. */ 67 #define IFRW_W 0x01 /* is a transmit buffer */ 68 int ifrw_info; /* value from ubaalloc */ 69 int ifrw_proto; /* map register prototype */ 70 struct pte *ifrw_mr; /* base of map registers */ 71 }; 72 73 /* 74 * Information per transmit buffer, including the above. 75 */ 76 struct ifxmt { 77 struct ifrw ifrw; 78 caddr_t ifw_base; /* virt addr of buffer */ 79 struct pte ifw_wmap[IF_MAXNUBAMR]; /* base pages for output */ 80 struct mbuf *ifw_xtofree; /* pages being dma'd out */ 81 short ifw_xswapd; /* mask of clusters swapped */ 82 short ifw_nmr; /* number of entries in wmap */ 83 }; 84 #define ifw_addr ifrw.ifrw_addr 85 #define ifw_bdp ifrw.ifrw_bdp 86 #define ifw_flags ifrw.ifrw_flags 87 #define ifw_info ifrw.ifrw_info 88 #define ifw_proto ifrw.ifrw_proto 89 #define ifw_mr ifrw.ifrw_mr 90 91 /* 92 * Most interfaces have a single receive and a single transmit buffer, 93 * and use struct ifuba to store all of the unibus information. 94 */ 95 struct ifuba { 96 struct ifubinfo ifu_info; 97 struct ifrw ifu_r; 98 struct ifxmt ifu_xmt; 99 }; 100 101 #define ifu_uban ifu_info.iff_uban 102 #define ifu_hlen ifu_info.iff_hlen 103 #define ifu_uba ifu_info.iff_uba 104 #define ifu_ubamr ifu_info.iff_ubamr 105 #define ifu_flags ifu_info.iff_flags 106 #define ifu_w ifu_xmt.ifrw 107 #define ifu_xtofree ifu_xmt.ifw_xtofree 108 109 #ifdef KERNEL 110 #define if_ubainit(ifuba, uban, hlen, nmr) \ 111 if_ubaminit(&(ifuba)->ifu_info, uban, hlen, nmr, \ 112 &(ifuba)->ifu_r, 1, &(ifuba)->ifu_xmt, 1) 113 #define if_rubaget(ifu, totlen, off0, ifp) \ 114 if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, totlen, off0, ifp) 115 #define if_wubaput(ifu, m) \ 116 if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_xmt, m) 117 struct mbuf *if_ubaget(); 118 #endif 119