Latest fixes from Nesheim@cornell
[unix-history] / usr / src / sys / vax / if / if_hy.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 *
6 * @(#)if_hy.h 6.3 (Berkeley) %G%
7 */
fe3ce306
SL
8
9/*
bdddb192
MK
10 * 4.2 BSD Unix Kernel - Vax Network Interface Support
11 *
12 * $Header: if_hy.h,v 10.0 84/06/30 19:51:21 steveg Stable $
13 * $Locker: $
14 *
15 * Modifications from Berkeley 4.2 BSD
16 * Copyright (c) 1983, Tektronix Inc.
17 * All Rights Reserved
18 *
19 *
20 * $Log: if_hy.h,v $
21 * Revision 10.0 84/06/30 19:51:21 steveg
22 * Big Build
23 *
24 * Revision 3.13 84/05/30 19:40:58 steveg
25 * update hy_stat to reflect new microcode
26 *
27 * Revision 3.12 84/05/30 19:06:57 steveg
28 * move driver state number definition here from if_hy.c
29 *
30 * Revision 3.11 84/05/30 18:56:15 steveg
31 * add definition of HYE_MAX and HYE_SIZE
32 *
33 * Revision 3.10 84/05/30 17:14:04 steveg
34 * add hyl_filter
35 *
36 * Revision 3.9 84/05/30 13:45:24 steveg
37 * rework logging
38 *
39 * Revision 3.8 84/05/04 05:18:59 steveg
40 * hyr_key now a u_long
41 *
42 * Revision 3.7 84/05/01 22:45:20 steveg
43 * add H_RLOOPBK for A710 remote end loopback command
44 *
45 *
fe3ce306
SL
46 */
47
bdddb192
MK
48
49/*
50 * Structure of a HYPERchannel adapter header
51 */
52struct hy_hdr {
53 short hyh_ctl; /* control */
54 short hyh_access; /* access code */
55 union {
56 short hyh_addr;
57 char hyh_baddr[2];
58 } hyh_uto, hyh_ufrom; /* to/from address */
59 short hyh_param; /* parameter word */
60 short hyh_type; /* record type */
61};
62
63
64#define hyh_to hyh_uto.hyh_addr
65#define hyh_to_port hyh_uto.hyh_baddr[1]
66#define hyh_to_adapter hyh_uto.hyh_baddr[0]
67
68#define hyh_from hyh_ufrom.hyh_addr
69#define hyh_from_port hyh_ufrom.hyh_baddr[1]
70#define hyh_from_adapter hyh_ufrom.hyh_baddr[0]
71
72/*
73 * Structure of a HYPERchannel message header (from software)
74 */
75struct hym_hdr {
76 struct {
77 short hymd_mplen; /* message proper len, if associated data */
78 } hym_d;
79 struct hy_hdr hym_h; /* hardware header, MUST BE LAST */
80};
81
82#define hym_mplen hym_d.hymd_mplen
83
84#define hym_ctl hym_h.hyh_ctl
85#define hym_access hym_h.hyh_access
86#define hym_param hym_h.hyh_param
87#define hym_type hym_h.hyh_type
88
89#define hym_to hym_h.hyh_to
90#define hym_to_port hym_h.hyh_to_port
91#define hym_to_adapter hym_h.hyh_to_adapter
92
93#define hym_from hym_h.hyh_from
94#define hym_from_port hym_h.hyh_from_port
95#define hym_from_adapter hym_h.hyh_from_adapter
96
97#define HYM_SWLEN (sizeof(struct hym_hdr) - sizeof(struct hy_hdr))
98
99/*
100 * HYPERchannel header word control bits
101 */
102#define H_XTRUNKS 0x00F0 /* transmit trunks */
103#define H_RTRUNKS 0x000F /* remote trunks to transmit on for loopback */
104#define H_ASSOC 0x0100 /* has associated data */
105#define H_LOOPBK 0x00FF /* loopback command */
106#define H_RLOOPBK 0x008F /* A710 remote loopback command */
107
108/*
109 * Hyperchannel record types
110 */
111#define HYLINK_IP 0 /* Internet Protocol Packet */
112
113/*
114 * Routing database
115 */
fe3ce306
SL
116#define HYRSIZE 37 /* max number of adapters in routing tables */
117
bdddb192
MK
118struct hy_route {
119 time_t hyr_lasttime; /* last update time */
120 u_char hyr_gateway[256];
121 struct hyr_hash {
122 u_long hyr_key; /* desired address */
fe3ce306 123 u_short hyr_flags; /* status flags - see below */
bdddb192 124 u_short hyr_size; /* number of entries */
fe3ce306
SL
125 union {
126 /*
127 * direct entry (can get there directly)
128 */
129 struct {
bdddb192
MK
130 u_short hyru_dst; /* adapter number & port */
131 u_short hyru_ctl; /* trunks to try */
fe3ce306
SL
132 u_short hyru_access; /* access code (mostly unused) */
133 } hyr_d;
bdddb192
MK
134#define hyr_dst hyr_u.hyr_d.hyru_dst
135#define hyr_ctl hyr_u.hyr_d.hyru_ctl
136#define hyr_access hyr_u.hyr_d.hyru_access
fe3ce306
SL
137 /*
138 * indirect entry (one or more hops required)
139 */
140 struct {
141 u_char hyru_pgate; /* 1st gateway slot */
142 u_char hyru_egate; /* # gateways */
143 u_char hyru_nextgate; /* gateway to use next */
144 } hyr_i;
bdddb192
MK
145#define hyr_pgate hyr_u.hyr_i.hyru_pgate
146#define hyr_egate hyr_u.hyr_i.hyru_egate
147#define hyr_nextgate hyr_u.hyr_i.hyru_nextgate
fe3ce306
SL
148 } hyr_u;
149 } hyr_hash[HYRSIZE];
fe3ce306
SL
150};
151
bdddb192
MK
152/*
153 * routing table set/get structure
154 *
155 * used to just pass the entire routing table through, but 4.2 ioctls
156 * limit the data part of an ioctl to 128 bytes or so and use the
157 * interface name to get things sent the right place.
158 * see ../net/if.h for additional details.
159 */
160struct hyrsetget {
161 char hyrsg_name[IFNAMSIZ]; /* if name, e.g. "hy0" */
162 struct hy_route *hyrsg_ptr; /* pointer to routing table */
163 unsigned hyrsg_len; /* size of routing table provided */
164};
fe3ce306
SL
165
166#define HYR_INUSE 0x01 /* entry in use */
167#define HYR_DIR 0x02 /* direct entry */
168#define HYR_GATE 0x04 /* gateway entry */
bdddb192
MK
169#define HYR_LOOP 0x08 /* hardware loopback entry */
170#define HYR_RLOOP 0x10 /* remote adapter hardware loopback entry */
fe3ce306
SL
171
172#define HYRHASH(x) (((x) ^ ((x) >> 16)) % HYRSIZE)
173
bdddb192
MK
174#define HYSETROUTE _IOW(i, 0x80, struct hyrsetget)
175#define HYGETROUTE _IOW(i, 0x81, struct hyrsetget)
176
177struct hylsetget {
178 char hylsg_name[IFNAMSIZ]; /* if name, e.g. "hy0" */
179 int hylsg_cmd; /* logging command */
180 caddr_t hylsg_ptr; /* pointer to table */
181 u_long hylsg_len; /* size of table provided */
182};
183
184#define HYSETLOG _IOW(i, 0x82, struct hylsetget)
185#define HYGETLOG _IOW(i, 0x83, struct hylsetget)
186#define HYGETELOG _IOW(i, 0x84, struct hylsetget)
187
188/*
189 * Structure of Statistics Record (counters)
190 */
191struct hy_stat {
192 u_char hyc_df0[3]; /* # data frames trunk 0 */
193 u_char hyc_df1[3]; /* # data frames trunk 1 */
194 u_char hyc_df2[3]; /* # data frames trunk 2 */
195 u_char hyc_df3[3]; /* # data frames trunk 3 */
196 u_char hyc_cancel[2]; /* # cancel operations */
197 u_char hyc_abort[2]; /* # aborts */
198 u_char hyc_ret0[3]; /* # retransmissions trunk 0 */
199 u_char hyc_ret1[3]; /* # retransmissions trunk 1 */
200 u_char hyc_ret2[3]; /* # retransmissions trunk 2 */
201 u_char hyc_ret3[3]; /* # retransmissions trunk 3 */
202 u_char hyc_atype[3]; /* adapter type and revision level */
203 u_char hyc_uaddr; /* adapter unit number */
204};
205
206/*
207 * Structure of the Status Record
208 */
209struct hy_status {
210 u_char hys_gen_status; /* general status byte */
211 u_char hys_last_fcn; /* last function code issued */
212 u_char hys_resp_trunk; /* trunk response byte */
213 u_char hys_status_trunk; /* trunk status byte */
214 u_char hys_recd_resp; /* recieved response byte */
215 u_char hys_error; /* error code */
216 u_char hys_caddr; /* compressed addr of 1st msg on chain */
217 u_char hys_pad; /* not used */
218};
219
220/*
221 * Get port number from status record
222 */
223#define PORTNUM(p) (((p)->hys_gen_status >> 6) & 0x03)
224
225#define HYL_SIZE 16*1024
226struct hy_log {
227 struct hy_log *hyl_self;
228 u_char hyl_enable; /* logging enabled? */
229 u_char hyl_onerr; /* state to enter on error */
230 u_short hyl_wait; /* number of bytes till next wakeup */
231 u_short hyl_count; /* number of samples till stop */
232 u_short hyl_icount; /* initial value of hyl_count */
233 u_long hyl_filter; /* log items with specific bits set */
234 u_char *hyl_eptr; /* &hy_log.hyl_buf[HYL_SIZE] */
235 u_char *hyl_ptr; /* pointer into hyl_buf */
236 u_char hyl_buf[HYL_SIZE]; /* log buffer space */
237};
238
239#define HYL_NOP 0
240#define HYL_UP 1 /* markup */
241#define HYL_STATUS 2 /* status results (struct hy_status) */
242#define HYL_STATISTICS 3 /* statistics (struct hy_stat) */
243#define HYL_XMIT 4 /* packed being send (struct hym_hdr) */
244#define HYL_RECV 5 /* recieved pkt (short len; struct hym_hdr) */
245#define HYL_CMD 6 /* cmd issued (uchar cmd, state; short count) */
246#define HYL_INT 7 /* interrupt (short csr, wcr) */
247#define HYL_CANCEL 8 /* cancel transmit attempt */
248#define HYL_RESET 9 /* hyinit or unibus reset */
249#define HYL_IOCTL 10 /* hyioctl */
250
251#define HYL_DISABLED 0 /* logging disabled */
252#define HYL_CONTINUOUS 1 /* continuous logging */
253#define HYL_CATCHN 2 /* hyl_count transactions being captured */
254
255/*
256 * error code histograms
257 */
258#define HYE_MAX 0x18 /* maximum adapter error code */
259#define HYE_BINS 4 /* number of command bins */
260#define HYE_SIZE (HYE_MAX+1)*HYE_BINS /* size of histogram buffer */
261
262/*
263 * Requests for service (in order by descending priority).
264 */
265#define RQ_ENDOP 001 /* end the last adapter function */
266#define RQ_REISSUE 002 /* reissue previous cmd after status */
267#define RQ_STATUS 004 /* get the status of the adapter */
268#define RQ_STATISTICS 010 /* get the statistics of the adapter */
269#define RQ_MARKDOWN 020 /* mark this adapter port down */
270#define RQ_MARKUP 040 /* mark this interface up */
271
272#define RQ_XASSOC 0100 /* associated data to transmit */
273
274/*
275 * Driver states.
276 */
277#define STARTUP 0 /* initial state (before fully there) */
278#define IDLE 1 /* idle state */
279#define STATSENT 2 /* status cmd sent to adapter */
280#define ENDOPSENT 3 /* end operation cmd sent */
281#define RECVSENT 4 /* input message cmd sent */
282#define RECVDATASENT 5 /* input data cmd sent */
283#define XMITSENT 6 /* transmit message cmd sent */
284#define XMITDATASENT 7 /* transmit data cmd sent */
285#define WAITING 8 /* waiting for messages */
286#define CLEARSENT 9 /* clear wait for message cmd sent */
287#define MARKPORT 10 /* mark this host's adapter port down issued */
288#define RSTATSENT 11 /* read statistics cmd sent to adapter */
289
290#ifdef HYLOG
291char *hy_state_names[] = {
292 "Startup",
293 "Idle",
294 "Status Sent",
295 "End op Sent",
296 "Recieve Message Proper Sent",
297 "Recieve Data Sent",
298 "Transmit Message Proper Sent",
299 "Transmit Data Sent",
300 "Wait for Message Sent",
301 "Clear Wait for Message Sent",
302 "Mark Port Down Sent",
303 "Read Statistics Sent"
304};
305#endif
306