123304Smckusick /* 229289Smckusick * Copyright (c) 1982, 1986 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*29740Skarels * @(#)if_uba.h 7.2 (Berkeley) 08/09/86 723304Smckusick */ 85079Swnj 95079Swnj /* 105079Swnj * Structure and routine definitions 115079Swnj * for UNIBUS network interfaces. 125079Swnj */ 135079Swnj 145172Swnj #define IF_MAXNUBAMR 10 155079Swnj /* 1624795Skarels * Each interface has structures giving information 1724795Skarels * about UNIBUS resources held by the interface 1824795Skarels * 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 */ 3724795Skarels 3824795Skarels /* 3924795Skarels * Information per interface. 4024795Skarels */ 4124795Skarels struct ifubinfo { 4224795Skarels short iff_uban; /* uba number */ 4324795Skarels short iff_hlen; /* local net header length */ 44*29740Skarels struct uba_regs *iff_uba; /* uba adaptor regs, in vm */ 45*29740Skarels struct pte *iff_ubamr; /* uba map regs, in vm */ 4624795Skarels short iff_flags; /* used during uballoc's */ 475079Swnj }; 485084Swnj 4924795Skarels /* 5024795Skarels * Information per buffer. 5124795Skarels */ 5224795Skarels struct ifrw { 5324795Skarels caddr_t ifrw_addr; /* virt addr of header */ 5425417Skarels short ifrw_bdp; /* unibus bdp */ 5525417Skarels short ifrw_flags; /* type, etc. */ 5625417Skarels #define IFRW_W 0x01 /* is a transmit buffer */ 5724795Skarels int ifrw_info; /* value from ubaalloc */ 5824795Skarels int ifrw_proto; /* map register prototype */ 5924795Skarels struct pte *ifrw_mr; /* base of map registers */ 6024795Skarels }; 6124795Skarels 6224795Skarels /* 6324795Skarels * Information per transmit buffer, including the above. 6424795Skarels */ 6524795Skarels struct ifxmt { 6624795Skarels struct ifrw ifrw; 6724795Skarels caddr_t ifw_base; /* virt addr of buffer */ 6824795Skarels struct pte ifw_wmap[IF_MAXNUBAMR]; /* base pages for output */ 6924795Skarels struct mbuf *ifw_xtofree; /* pages being dma'd out */ 7024795Skarels short ifw_xswapd; /* mask of clusters swapped */ 7125625Skarels short ifw_nmr; /* number of entries in wmap */ 7224795Skarels }; 7324795Skarels #define ifw_addr ifrw.ifrw_addr 7424795Skarels #define ifw_bdp ifrw.ifrw_bdp 7525417Skarels #define ifw_flags ifrw.ifrw_flags 7624795Skarels #define ifw_info ifrw.ifrw_info 7724795Skarels #define ifw_proto ifrw.ifrw_proto 7824795Skarels #define ifw_mr ifrw.ifrw_mr 7924795Skarels 8024795Skarels /* 8124795Skarels * Most interfaces have a single receive and a single transmit buffer, 8224795Skarels * and use struct ifuba to store all of the unibus information. 8324795Skarels */ 8424795Skarels struct ifuba { 8524795Skarels struct ifubinfo ifu_info; 8624795Skarels struct ifrw ifu_r; 8724795Skarels struct ifxmt ifu_xmt; 8824795Skarels }; 8924795Skarels 9024795Skarels #define ifu_uban ifu_info.iff_uban 9124795Skarels #define ifu_hlen ifu_info.iff_hlen 9224795Skarels #define ifu_uba ifu_info.iff_uba 93*29740Skarels #define ifu_ubamr ifu_info.iff_ubamr 9424795Skarels #define ifu_flags ifu_info.iff_flags 9524795Skarels #define ifu_w ifu_xmt.ifrw 9624795Skarels #define ifu_xtofree ifu_xmt.ifw_xtofree 9724795Skarels 985084Swnj #ifdef KERNEL 9924795Skarels #define if_ubainit(ifuba, uban, hlen, nmr) \ 10024795Skarels if_ubaminit(&(ifuba)->ifu_info, uban, hlen, nmr, \ 10126394Skarels &(ifuba)->ifu_r, 1, &(ifuba)->ifu_xmt, 1) 10224795Skarels #define if_rubaget(ifu, totlen, off0, ifp) \ 10324795Skarels if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, totlen, off0, ifp) 10424795Skarels #define if_wubaput(ifu, m) \ 10526394Skarels if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_xmt, m) 10624795Skarels struct mbuf *if_ubaget(); 1075084Swnj #endif 108