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