xref: /csrg-svn/sys/deprecated/netimp/if_imp.h (revision 33427)
1 /*
2  * Copyright (c) 1982, 1986 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_imp.h	7.2 (Berkeley) 02/03/88
7  */
8 
9 /*
10  * Structure of IMP 1822 long leader.
11  */
12 struct control_leader {
13 	u_char	dl_format;	/* 1-8   leader format */
14 	u_char	dl_network;	/* 9-16  src/dest network */
15 	u_char	dl_flags;	/* 17-24 leader flags */
16 	u_char	dl_mtype;	/* 25-32 message type */
17 	u_char	dl_htype;	/* 33-40 handling type */
18 	u_char	dl_host;	/* 41-48 host number */
19 	u_short	dl_imp;		/* 49-64 imp field */
20 	u_char	dl_link;	/* 65-72 link number */
21 	u_char	dl_subtype;	/* 73-80 message subtype */
22 };
23 
24 struct imp_leader {
25 	struct	control_leader il_dl;
26 #define	il_format	il_dl.dl_format
27 #define	il_network	il_dl.dl_network
28 #define	il_flags	il_dl.dl_flags
29 #define	il_mtype	il_dl.dl_mtype
30 #define	il_htype	il_dl.dl_htype
31 #define	il_host		il_dl.dl_host
32 #define	il_imp		il_dl.dl_imp
33 #define	il_link		il_dl.dl_link
34 #define	il_subtype	il_dl.dl_subtype
35 	u_short	il_length;	/* message length */
36 };
37 
38 #define	IMP_NOOPCNT	3	/* # of noops to send imp on reset */
39 /* insure things are even... */
40 #define	IMPMTU		((8159 / NBBY) & ~01)
41 #define	IMP_RCVBUF	((8159 / NBBY + 2) & ~01)
42 
43 /*
44  * IMP-host flags
45  */
46 #define	IMP_NFF		0xf	/* 96-bit (new) format */
47 #define	IMP_TRACE	0x8	/* trace message route */
48 
49 /*
50  * IMP-host message types.
51  */
52 #define	IMPTYPE_DATA		0	/* data for protocol */
53 #define	IMPTYPE_BADLEADER	1	/* leader error */
54 #define	IMPTYPE_DOWN		2	/* imp going down */
55 #define	IMPTYPE_NOOP		4	/* noop seen during initialization */
56 #define	IMPTYPE_RFNM		5	/* request for new messages */
57 #define	IMPTYPE_HOSTDEAD	6	/* host doesn't respond */
58 #define	IMPTYPE_HOSTUNREACH	7	/* host unreachable */
59 #define	IMPTYPE_BADDATA		8	/* data error */
60 #define	IMPTYPE_INCOMPLETE	9	/* incomplete message, send rest */
61 #define	IMPTYPE_RESET		10	/* reset complete */
62 /* non-blocking IMP interface */
63 #define	IMPTYPE_RETRY		11	/* IMP refused, try again */
64 #define	IMPTYPE_NOTIFY		12	/* IMP refused, will notify */
65 #define	IMPTYPE_TRYING		13	/* IMP refused, still rexmt'ng */
66 #define	IMPTYPE_READY		14	/* ready for next message */
67 
68 /*
69  * IMPTYPE_DOWN subtypes, in link number field.
70  */
71 #define	IMP_DMASK		0x3	/* host going down mask */
72 #define	IMPDOWN_GOING		0	/* 30 secs */
73 #define	IMPDOWN_PM		1	/* hardware PM */
74 #define	IMPDOWN_RELOAD		2	/* software reload */
75 #define	IMPDOWN_RESTART		3	/* emergency restart */
76 #define	IMPDOWN_WHENMASK	0x3c	/* mask for "how soon" */
77 #define	IMPDOWN_WHENSHIFT	2	/* shift for "how soon" */
78 #define	IMPDOWN_WHENUNIT	5	/* unit for "how soon", 5 min. */
79 
80 #define	IMPTV_DOWN	30		/* going down timer 30 secs */
81 
82 #ifdef IMPMESSAGES
83 /*
84  * Messages from IMP regarding why
85  * it's going down.
86  */
87 char *impmessage[] = {
88 	"in 30 seconds",
89 	"for hardware PM",
90 	"to reload software",
91 	"for emergency reset"
92 };
93 #endif
94 
95 /*
96  * IMPTYPE_BADLEADER subtypes.
97  */
98 #define	IMPLEADER_ERR		0	/* error flip-flop set */
99 #define	IMPLEADER_SHORT		1	/* leader < 80 bits */
100 #define	IMPLEADER_TYPE		2	/* illegal type field */
101 #define	IMPLEADER_OPPOSITE	3	/* opposite leader type */
102 
103 /*
104  * IMPTYPE_HOSTDEAD subtypes.
105  */
106 #define	IMPHOST_NORDY		1	/* ready-line negated */
107 #define	IMPHOST_TARDY		2	/* tardy receiving mesgs */
108 #define	IMPHOST_NOEXIST		3	/* NCC doesn't know host */
109 #define	IMPHOST_IMPSOFT		4	/* IMP software won't allow mesgs */
110 #define	IMPHOST_PM		5	/* host down for scheduled PM */
111 #define	IMPHOST_HARDSCHED	6	/* " " " " hardware work */
112 #define	IMPHOST_SOFTSCHED	7	/* " " " " software work */
113 #define	IMPHOST_RESTART		8	/* host down for emergency restart */
114 #define	IMPHOST_POWER		9	/* down because of power outage */
115 #define	IMPHOST_BREAKPOINT	10	/* host stopped at a breakpoint */
116 #define	IMPHOST_HARDWARE	11	/* hardware failure */
117 #define	IMPHOST_NOTUP		12	/* host not scheduled to be up */
118 /* 13-14 currently unused */
119 #define	IMPHOST_COMINGUP	15	/* host in process of coming up */
120 
121 /*
122  * IMPTYPE_HOSTUNREACH subtypes.
123  */
124 #define	IMPREACH_IMP		0	/* destination IMP can't be reached */
125 #define	IMPREACH_HOSTUP		1	/* destination host isn't up */
126 #define	IMPREACH_LEADER		2	/* host doesn't support long leader */
127 #define	IMPREACH_PROHIBITED	3	/* communication is prohibited */
128 
129 /*
130  * IMPTYPE_INCOMPLETE subtypes.
131  */
132 #define	IMPCOMPLETE_SLOW	0	/* host didn't take data fast enough */
133 #define	IMPCOMPLETE_TOOLONG	1	/* message was too long */
134 #define	IMPCOMPLETE_TIMEOUT	2	/* mesg transmission time > 15 sec. */
135 #define	IMPCOMPLETE_FAILURE	3	/* IMP/circuit failure */
136 #define	IMPCOMPLETE_NOSPACE	4	/* no resources within 15 sec. */
137 #define	IMPCOMPLETE_IMPIO	5	/* src IMP I/O failure during receipt */
138 
139 /*
140  * IMPTYPE_RETRY subtypes.
141  */
142 #define	IMPRETRY_BUFFER		0	/* IMP buffer wasn't available */
143 #define	IMPRETRY_BLOCK		1	/* connection block unavailable */
144 
145 #define	RFNMTIMER	(120*PR_SLOWHZ)	/* time to wait for RFNM for msg. */
146 /*
147  * Data structure shared between IMP protocol module and hardware
148  * interface driver.  Used to allow layering of IMP routines on top
149  * of varying device drivers.
150  */
151 struct impcb {
152 	int	ic_hwunit;		/* H/W unit number */
153 	char	*ic_hwname;		/* H/W type name */
154 	char	ic_oactive;		/* output in progress */
155 	int	(*ic_init)();		/* hardware init routine */
156 	int	(*ic_start)();		/* hardware start output routine */
157 	int	(*ic_stop)();		/* hardware "drop ready" routine */
158 };
159 
160 /*
161  * IMP software status per interface.
162  * (partially shared with the hardware specific module)
163  *
164  * Each interface is referenced by a network interface structure,
165  * imp_if, which the routing code uses to locate the interface.
166  * This structure contains the output queue for the interface, its
167  * address, ...  IMP specific structures used in connecting the
168  * IMP software modules to the hardware specific interface routines
169  * are stored here.  The common structures are made visible to the
170  * interface driver by passing a pointer to the hardware routine
171  * at "attach" time.
172  */
173 struct imp_softc {
174 	struct	ifnet imp_if;		/* network visible interface */
175 	struct	impcb imp_cb;		/* hooks to hardware module */
176 	int	imp_state;		/* current state of IMP */
177 	int	imp_dropcnt;		/* used during initialization */
178 	u_long	imp_lostrfnm;		/* rfnm's timed out */
179 	u_long	imp_badrfnm;		/* rfnm/incompl after timeout/bogus */
180 	u_long	imp_incomplete;		/* incomplete's received */
181 	u_long	imp_garbage;		/* bad messages received */
182 };
183 struct	imp_softc *impattach();
184 
185 /*
186  * State of an IMP.
187  */
188 #define	IMPS_DOWN	0		/* unavailable, host not ready */
189 #define	IMPS_WINIT	1		/* imp not ready, waiting for init */
190 #define	IMPS_INIT	2		/* coming up */
191 #define	IMPS_UP		3		/* ready to go */
192 #define	IMPS_GOINGDOWN	4		/* been told we go down soon */
193 
194 #define	IMPS_RUNNING(s)	((s) >= IMPS_UP)	/* ready for messages */
195 #define	IMPS_IMPREADY(s) ((s) >= IMPS_INIT)	/* IMP ready line on */
196 
197 #ifdef IMPLEADERS
198 char *impleaders[IMPTYPE_READY+1] = {
199 	"DATA", "BADLEADER", "DOWN", "bad", "NOOP", "RFNM", "HOSTDEAD",
200 	"HOSTUNREACH", "BADDATA", "INCOMPLETE", "RESET", "RETRY",
201 	"NOTIFY", "TRYING", "READY"
202 };
203 #endif
204