BSD 4_2 development
[unix-history] / usr / src / sys / vaxif / if_hyreg.h
CommitLineData
2011a241
C
1/* if_hyreg.h 6.1 83/07/29 */
2
3/*
4 * Network Systems Corporation Hyperchannel interface
5 *
6 * supports A410 adapter interfaced via a DEC DR-11B, NSC PI-13 or PI-14
7 * (PI-14 is a PI-13 with different line drivers, software is
8 * identical to a PI-13)
9 *
10 * Written by Steve Glaser, Tektronix Inc., July 1982
11 *
12 * NOTE:
13 *
14 * DR11B code has not been fully checked out with 4.1a.
15 * The first adapters at Tek came with DR11Bs, and the code once worked,
16 * but those have been upgraded to PI-13s.
17 */
18#define PI13 1 /* PI13 vs. DR11B device depandant code */
19#ifndef HYLOG
20#define HYLOG 1 /* enable logging of errors */
21#endif
22
23/*
24 * Structure of a HYPERchannel adapter header
25 */
26struct hy_hdr {
27 short hyh_ctl; /* control */
28 short hyh_access; /* access code */
29 union { /* to/from addresses */
30 short hyh_addr; /* full address */
31 char hyh_baddr[2]; /* adapter/port number from address */
32 } hyhu_to, hyhu_from;
33#define hyh_to hyhu_to.hyh_addr
34#define hyh_from hyhu_from.hyh_addr
35#define hyh_to_adapter hyhu_to.hyh_baddr[0]
36#define hyh_to_port hyhu_to.hyh_baddr[1]
37#define hyh_from_adapter hyhu_from.hyh_baddr[0]
38#define hyh_from_port hyhu_from.hyh_baddr[1]
39 short hyh_param; /* parameter (for loopback) */
40 char hyh_type; /* record type */
41 char hyh_off; /* offset from end of hy_hdr to ip data */
42};
43
44/*
45 * Structure of a HYPERchannel message header (from software)
46 */
47struct hym_data {
48 short hymd_mplen; /* message proper length, if associated data */
49};
50
51struct hym_hdr {
52 struct hym_data hym_d;
53#define hym_mplen hym_d.hymd_mplen
54 struct hy_hdr hym_hdr; /* hardware header, MUST BE LAST */
55};
56
57/*
58 * HYPERchannel header word control bits
59 */
60#define H_XTRUNKS 0x00F0 /* transmit trunks */
61#define H_RTRUNKS 0x000F /* remote trunks to transmit on for loopback */
62#define H_ASSOC 0x0100 /* has associated data */
63#define H_LOOPBK 0x00FF /* loopback command */
64
65/*
66 * Structure of Statistics Record (counters)
67 */
68struct hy_stat {
69 u_long hyc_msgcnt; /* # messages transmitted */
70 u_long hyc_dbcnt; /* # data buffers transmitted */
71 u_long hyc_tbusy; /* # available trunks busy */
72 u_long hyc_hwret; /* # hardware retransmits */
73 u_long hyc_crcbad; /* # crc errors on trunk */
74 u_long hyc_mcret; /* # microcode retransmits */
75 u_long hyc_tdabort; /* # trunk driver aborts */
76 u_char hyc_atype[3]; /* adapter type and revision level */
77 u_char hyc_uaddr; /* adapter unit number */
78};
79
80/*
81 * Structure of the Status Record
82 */
83struct hy_status {
84 u_char hys_gen_status; /* general status byte */
85 u_char hys_last_fcn; /* last function code issued */
86 u_char hys_resp_trunk; /* trunk response byte */
87 u_char hys_status_trunk; /* trunk status byte */
88 u_char hys_recd_resp; /* recieved response byte */
89 u_char hys_error; /* error code */
90 u_char hys_caddr; /* compressed addr of 1st msg on chain */
91 u_char hys_pad; /* not used */
92};
93
94/*
95 * Get port number from status record
96 */
97#define PORTNUM(p) (((p)->hys_gen_status >> 6) & 0x03)
98
99/*
100 * The HYPERchannel driver sends and receives messages formatted:
101 *
102 * +---------------------------------------+ ---
103 * | | /|\
104 * | HYPERchannel adapter header (hy_hdr) | |
105 * | | |
106 * +---------------------------------------+ |
107 * | | |
108 * | Internet Protocol header (ip) | message proper
109 * | | (64 bytes max)
110 * +---------------------------------------+ |
111 * | | |
112 * | TCP header + user data | |
113 * | (if it all fits here) | |
114 * | | \|/
115 * +---------------------------------------+ ---
116 *
117 * +---------------------------------------+ ---
118 * | | /|\
119 * | | |
120 * | TCP header + user data | associated data
121 * | | |
122 * | | \|/
123 * +---------------------------------------+ ---
124 *
125 * If all of the datagram will fit in the message proper (including
126 * the TCP header and user data) the entire datagram is passed in
127 * the message proper and the associated data feature of the HYPERchannel
128 * is not used.
129 *
130 * The mapping from internet addresses to HYPERchannel addresses is:
131 *
132 * 0 7 8 15 16 31
133 * +---------+---------+-----------------------+
134 * | network | special | HYPERchannel address |
135 * +---------+---------+-----------------------+
136 *
137 * |<------------ internet address ----------->|
138 *
139 * The hyperchannel address is decoded as follows:
140 *
141 * 0 7 8 13 14 15
142 * +-------------------+----------------+------+
143 * | adapter number | zero | port |
144 * +-------------------+----------------+------+
145 *
146 * The low 2 bits are port number (interpreted by hyperchannel hardware).
147 *
148 * The encoding of special bits is:
149 *
150 * 00 normal packet
151 *
152 * 01 loop this packet back to the sender at the
153 * specified adapter (ip header source/destination addresses
154 * swapped before sending, command bits added to tell the
155 * remote HYPERchannel adapter debug & performance studies]
156 * this code acts like 02 (below) if the ip destination (before
157 * any swapping) and the destination address don't match (e.g.
158 * this packet is being routed through a gateway)
159 *
160 * 02 loop this packet back to the sender at the
161 * specified adapter, but go through the specified adapter's
162 * IP. This is for testing IP's store and forward mechanism.
163 *
164 * other undefined, currently treated as normal packet
165 *
166 */
167#define MPSIZE 64 /* "Message Proper" size */
168#define MAXRETRY 4
169
170/*
171 * Device registers
172 */
173struct hydevice {
174 short hyd_wcr; /* word count (negated) */
175 u_short hyd_bar; /* bus address bits 15-0 */
176 u_short hyd_csr; /* control and status */
177 u_short hyd_dbuf; /* data buffer */
178};
179
180/*
181 * CSR bit layout
182 */
183#define S_ERROR 0100000 /* error */
184#define S_NEX 0040000 /* non-existent memory error */
185#define S_ATTN 0020000 /* attn (always zero) */
186#ifdef PI13
187#define S_STKINTR 0010000 /* stacked interrupt */
188#else
189#define S_MAINT 0010000 /* maintenance (not used) */
190#endif
191#define S_A 0004000 /* device status A (recieve data available) */
192#define S_B 0002000 /* device status B (normal termination) */
193#define S_C 0001000 /* device status C (abnormal termination) */
194#ifdef PI13
195#define S_POWEROFF 0000400 /* power off indicator */
196#else
197#define S_CYCLE 0000400 /* cycle (not used) */
198#endif
199#define S_READY 0000200 /* ready */
200#define S_IE 0000100 /* interrupt enable */
201#define S_XBA 0000060 /* bus address bit bits 17 and 16 */
202#define S_CLRINT 0000014 /* clear stacked interrupt */
203#define S_IATTN 0000010 /* interrupt on attention only */
204#define S_WC 0000004 /* interrupt on word count == 0 only */
205#define S_IATTNWC 0000000 /* interrupt on word count == 0 and attention */
206#define S_BURST 0000002 /* burst mode DMA (not used) */
207#define S_GO 0000001 /* go */
208
209#define XBASHIFT 12
210
211#define HY_CSR_BITS "\20\20ERROR\17NEX\16ATTN\15STKINTR\14RECV_DATA\13NORMAL\12ABNORMAL\11POWER\10READY\07IENABLE\06XBA17\05XBA16\04IATTN\03IWC\02BURST\01GO"
212
213/*
214 * PI13 status conditions
215 */
216#define HYS_RECVDATA(x) (((x)->hyd_csr & S_A) != 0) /* get adapter data */
217#define HYS_NORMAL(x) (((x)->hyd_csr & S_B) != 0) /* done normally */
218#define HYS_ABNORMAL(x) (((x)->hyd_csr & S_C) != 0) /* done abnormally */
219#define HYS_ERROR(x) (((x)->hyd_csr & S_ERROR) != 0) /* error condition */
220#define HYS_DONE(x) (((x)->hyd_csr & (S_ERROR|S_B|S_C)) != 0)
221
222/*
223 * Function Codes for the Hyperchannel Adapter
224 * The codes are offset so they can be "or"ed into
225 * the reg data buffer
226 */
227#define HYF_XMITMSG 0x04 /* transmit message */
228#define HYF_XMITDATA 0x08 /* transmit associated data */
229#define HYF_XMITLSTDATA 0x0C /* transmit last associated data */
230#define HYF_XMITLOCMSG 0x10 /* transmit local message */
231#define HYF_INPUTMSG 0x24 /* input message proper */
232#define HYF_INPUTDATA 0x28 /* input assiciated data */
233#define HYF_STATUS 0x40 /* request status */
234#define HYF_DUMPREGS 0x50 /* dump extention registers */
235#define HYF_MARKP0 0x60 /* mark down port 0 */
236#define HYF_MARKP1 0x64 /* mark down port 1 */
237#define HYF_MARKP2 0x68 /* mark down port 2 */
238#define HYF_MARKP3 0x6C /* mark down port 3 */
239#define HYF_MP0RR 0x70 /* mark down port 0 and reroute messages */
240#define HYF_MP1RR 0x74 /* mark down port 1 and reroute messages */
241#define HYF_MP2RR 0x78 /* mark down port 2 and reroute messages */
242#define HYF_MP3RR 0x7C /* mark down port 3 and reroute messages */
243#define HYF_RSTATS 0xA0 /* read statistics */
244#define HYF_RCSTATS 0xA4 /* read and clear statistics */
245#define HYF_SETTEST 0xC0 /* enable test operations *set test mode) */
246#define HYF_SADDR_LEN 0xC4 /* test mode: set address and length */
247#define HYF_WBUFF 0xC8 /* test mode: write buffer */
248#define HYF_RBUFF 0xCC /* test mode: read buffer */
249#define HYF_CLRADAPTER 0xE0 /* clear adapter */
250#define HYF_END_OP 0xE4 /* end operation */
251#define HYF_CLRWFMSG 0xE6 /* clear wait for mwssage */
252#define HYF_WAITFORMSG 0xE8 /* wait for message */
253
254/*
255 * Hyperchannel record types
256 */
257#define HYLINK_IP 0 /* Internet Protocol Packet */
258
259#ifdef HYLOG
260#define HYL_SIZE 16*1024
261struct hy_log {
262 struct hy_log *hyl_self;
263 u_char hyl_enable; /* logging enabled? */
264 u_char hyl_onerr; /* state to enter on error */
265 u_char *hyl_eptr; /* &hy_log.hyl_buf[HYL_SIZE] */
266 u_char *hyl_ptr; /* pointer into hyl_buf */
267 u_char hyl_buf[HYL_SIZE]; /* log buffer space */
268};
269
270#define HYL_NOP 0
271#define HYL_UP 1 /* markup */
272#define HYL_STATUS 2 /* status results (struct hy_status) */
273#define HYL_STATISTICS 3 /* statistics (struct hy_stat) */
274#define HYL_XMIT 4 /* packed being send (struct hym_hdr) */
275#define HYL_RECV 5 /* recieved packet (short len; struct hy_hdr) */
276#define HYL_CMD 6 /* cmd issued (uchar cmd, state; short count) */
277#define HYL_INT 7 /* interrupt (short csr, wcr) */
278
279#define HYL_DISABLED 0 /* logging disabled */
280#define HYL_CONTINUOUS 1 /* continuous logging */
281#define HYL_CAUGHT1 2 /* one buffer full captured */
282#define HYL_CATCH1 3 /* one buffer full being captured */
283#define HYL_CAUGHTSTATUS 4 /* one buffer of status captured */
284#define HYL_CATCHSTATUS 5 /* one buffer fill of status being captured */
285
286#ifdef KERNEL
287struct hy_log hy_log;
288#endif
289#endif