123304Smckusick /* 229289Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 335327Sbostic * All rights reserved. 423304Smckusick * 5*44563Sbostic * %sccs.include.redist.c% 635327Sbostic * 7*44563Sbostic * @(#)if_uba.h 7.4 (Berkeley) 06/28/90 823304Smckusick */ 95079Swnj 105079Swnj /* 115079Swnj * Structure and routine definitions 125079Swnj * for UNIBUS network interfaces. 135079Swnj */ 145079Swnj 155172Swnj #define IF_MAXNUBAMR 10 165079Swnj /* 1724795Skarels * Each interface has structures giving information 1824795Skarels * about UNIBUS resources held by the interface 1924795Skarels * for each send and receive buffer. 205079Swnj * 215079Swnj * We hold IF_NUBAMR map registers for datagram data, starting 225079Swnj * at ifr_mr. Map register ifr_mr[-1] maps the local network header 235079Swnj * ending on the page boundary. Bdp's are reserved for read and for 245079Swnj * write, given by ifr_bdp. The prototype of the map register for 255079Swnj * read and for write is saved in ifr_proto. 265079Swnj * 275079Swnj * When write transfers are not full pages on page boundaries we just 285079Swnj * copy the data into the pages mapped on the UNIBUS and start the 295079Swnj * transfer. If a write transfer is of a (1024 byte) page on a page 305079Swnj * boundary, we swap in UNIBUS pte's to reference the pages, and then 315079Swnj * remap the initial pages (from ifu_wmap) when the transfer completes. 325079Swnj * 335079Swnj * When read transfers give whole pages of data to be input, we 345079Swnj * allocate page frames from a network page list and trade them 355079Swnj * with the pages already containing the data, mapping the allocated 365079Swnj * pages to replace the input pages for the next UNIBUS data input. 375079Swnj */ 3824795Skarels 3924795Skarels /* 4024795Skarels * Information per interface. 4124795Skarels */ 4224795Skarels struct ifubinfo { 4324795Skarels short iff_uban; /* uba number */ 4424795Skarels short iff_hlen; /* local net header length */ 4529740Skarels struct uba_regs *iff_uba; /* uba adaptor regs, in vm */ 4629740Skarels struct pte *iff_ubamr; /* uba map regs, in vm */ 4724795Skarels short iff_flags; /* used during uballoc's */ 485079Swnj }; 495084Swnj 5024795Skarels /* 5124795Skarels * Information per buffer. 5224795Skarels */ 5324795Skarels struct ifrw { 5424795Skarels caddr_t ifrw_addr; /* virt addr of header */ 5525417Skarels short ifrw_bdp; /* unibus bdp */ 5625417Skarels short ifrw_flags; /* type, etc. */ 5725417Skarels #define IFRW_W 0x01 /* is a transmit buffer */ 5824795Skarels int ifrw_info; /* value from ubaalloc */ 5924795Skarels int ifrw_proto; /* map register prototype */ 6024795Skarels struct pte *ifrw_mr; /* base of map registers */ 6124795Skarels }; 6224795Skarels 6324795Skarels /* 6424795Skarels * Information per transmit buffer, including the above. 6524795Skarels */ 6624795Skarels struct ifxmt { 6724795Skarels struct ifrw ifrw; 6824795Skarels caddr_t ifw_base; /* virt addr of buffer */ 6924795Skarels struct pte ifw_wmap[IF_MAXNUBAMR]; /* base pages for output */ 7024795Skarels struct mbuf *ifw_xtofree; /* pages being dma'd out */ 7124795Skarels short ifw_xswapd; /* mask of clusters swapped */ 7225625Skarels short ifw_nmr; /* number of entries in wmap */ 7324795Skarels }; 7424795Skarels #define ifw_addr ifrw.ifrw_addr 7524795Skarels #define ifw_bdp ifrw.ifrw_bdp 7625417Skarels #define ifw_flags ifrw.ifrw_flags 7724795Skarels #define ifw_info ifrw.ifrw_info 7824795Skarels #define ifw_proto ifrw.ifrw_proto 7924795Skarels #define ifw_mr ifrw.ifrw_mr 8024795Skarels 8124795Skarels /* 8224795Skarels * Most interfaces have a single receive and a single transmit buffer, 8324795Skarels * and use struct ifuba to store all of the unibus information. 8424795Skarels */ 8524795Skarels struct ifuba { 8624795Skarels struct ifubinfo ifu_info; 8724795Skarels struct ifrw ifu_r; 8824795Skarels struct ifxmt ifu_xmt; 8924795Skarels }; 9024795Skarels 9124795Skarels #define ifu_uban ifu_info.iff_uban 9224795Skarels #define ifu_hlen ifu_info.iff_hlen 9324795Skarels #define ifu_uba ifu_info.iff_uba 9429740Skarels #define ifu_ubamr ifu_info.iff_ubamr 9524795Skarels #define ifu_flags ifu_info.iff_flags 9624795Skarels #define ifu_w ifu_xmt.ifrw 9724795Skarels #define ifu_xtofree ifu_xmt.ifw_xtofree 9824795Skarels 995084Swnj #ifdef KERNEL 10024795Skarels #define if_ubainit(ifuba, uban, hlen, nmr) \ 10124795Skarels if_ubaminit(&(ifuba)->ifu_info, uban, hlen, nmr, \ 10226394Skarels &(ifuba)->ifu_r, 1, &(ifuba)->ifu_xmt, 1) 10324795Skarels #define if_rubaget(ifu, totlen, off0, ifp) \ 10424795Skarels if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, totlen, off0, ifp) 10524795Skarels #define if_wubaput(ifu, m) \ 10626394Skarels if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_xmt, m) 10724795Skarels struct mbuf *if_ubaget(); 1085084Swnj #endif 109