1 /*	if_imp.h	4.3	82/02/12	*/
2 
3 /*
4  * Structure of IMP 1822 long leader.
5  */
6 struct control_leader {
7 	u_char	dl_format;	/* leader format */
8 	u_char	dl_network;	/* src/dest network */
9 	u_char	dl_flags;	/* leader flags */
10 	u_char	dl_mtype;	/* message type */
11 	u_char	dl_htype;	/* handling type */
12 	u_char	dl_host;	/* host number */
13 	union {
14 		u_short	dl_short;
15 		u_char	dl_char[2];
16 	} dlun;
17 #define dl_imp		dlun.dl_short	/* imp field */
18 #define dl_impno	dlun.dl_char[1]	/* imp number */
19 #define dl_lh		dlun.dl_char[0]	/* logical host */
20 	u_char	dl_link;	/* link number */
21 	u_char	dl_subtype;	/* 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_impno	il_dl.dl_impno
34 #define	il_lh		il_dl.dl_lh
35 #define	il_link		il_dl.dl_link
36 #define	il_subtype	il_dl.dl_subtype
37 	u_short	il_length;	/* message length */
38 };
39 
40 #define	IMP_DROPCNT	2	/* # of noops from imp to ignore */
41 /* don't use 1019 here, 'cuz odd numbers and word counts are confusing */
42 #define	IMP_MTU		(sizeof (struct imp_leader) + 1018)
43 
44 /*
45  * IMP-host flags
46  */
47 #define	IMP_NFF		0xf	/* 96-bit (new) format */
48 #define	IMP_TRACE	0x8	/* trace message route */
49 
50 #define IMP_DMASK	0x3	/* host going down mask */
51 
52 /*
53  * IMP-host message types.
54  */
55 #define	IMPTYPE_DATA		0	/* data for protocol */
56 #define	IMPTYPE_BADLEADER	1	/* leader error */
57 #define	IMPTYPE_DOWN		2	/* imp going down */
58 #define	IMPTYPE_NOOP		4	/* noop seen during initialization */
59 #define	IMPTYPE_RFNM		5	/* request for new messages */
60 #define	IMPTYPE_HOSTDEAD	6	/* host doesn't respond */
61 #define	IMPTYPE_HOSTUNREACH	7	/* host unreachable */
62 #define	IMPTYPE_BADDATA		8	/* data error */
63 #define	IMPTYPE_INCOMPLETE	9	/* incomplete message, send rest */
64 #define	IMPTYPE_RESET		10	/* reset complete */
65 /* non-blocking IMP interface */
66 #define	IMPTYPE_RETRY		11	/* IMP refused, try again */
67 #define	IMPTYPE_NOTIFY		12	/* IMP refused, will notify */
68 #define	IMPTYPE_TRYING		13	/* IMP refused, still rexmt'ng */
69 #define	IMPTYPE_READY		14	/* ready for next message */
70 
71 /*
72  * IMPTYPE_DOWN subtypes.
73  */
74 #define	IMPDOWN_GOING		0	/* 30 secs */
75 #define	IMPDOWN_PM		1	/* hardware PM */
76 #define	IMPDOWN_RELOAD		2	/* software reload */
77 #define	IMPDOWN_RESTART		3	/* emergency restart */
78 
79 /*
80  * IMPTYPE_BADLEADER subtypes.
81  */
82 #define	IMPLEADER_ERR		0	/* error flip-flop set */
83 #define	IMPLEADER_SHORT		1	/* leader < 80 bits */
84 #define	IMPLEADER_TYPE		2	/* illegal type field */
85 #define	IMPLEADER_OPPOSITE	3	/* opposite leader type */
86 
87 /*
88  * IMPTYPE_HOSTDEAD subtypes.
89  */
90 #define	IMPHOST_NORDY		1	/* ready-line negated */
91 #define	IMPHOST_TARDY		2	/* tardy receiving mesgs */
92 #define	IMPHOST_NOEXIST		3	/* NCC doesn't know host */
93 #define	IMPHOST_IMPSOFT		4	/* IMP software won't allow mesgs */
94 #define	IMPHOST_PM		5	/* host down for scheduled PM */
95 #define	IMPHOST_HARDSCHED	6	/* " " " " hardware work */
96 #define	IMPHOST_SOFTSCHED	7	/* " " " " software work */
97 #define	IMPHOST_RESTART		8	/* host down for emergency restart */
98 #define	IMPHOST_POWER		9	/* down because of power outage */
99 #define	IMPHOST_BREAKPOINT	10	/* host stopped at a breakpoint */
100 #define	IMPHOST_HARDWARE	11	/* hardware failure */
101 #define	IMPHOST_NOTUP		12	/* host not scheduled to be up */
102 /* 13-14 currently unused */
103 #define	IMPHOST_COMINGUP	15	/* host in process of coming up */
104 
105 /*
106  * IMPTYPE_HOSTUNREACH subtypes.
107  */
108 #define	IMPREACH_IMP		0	/* destination IMP can't be reached */
109 #define	IMPREACH_HOSTUP		1	/* destination host isn't up */
110 #define	IMPREACH_LEADER		2	/* host doesn't support long leader */
111 #define	IMPREACH_PROHIBITED	3	/* communication is prohibited */
112 
113 /*
114  * IMPTYPE_INCOMPLETE subtypes.
115  */
116 #define	IMPCOMPLETE_SLOW	0	/* host didn't take data fast enough */
117 #define	IMPCOMPLETE_TOOLONG	1	/* message was too long */
118 #define	IMPCOMPLETE_TIMEOUT	2	/* mesg transmission time > 15 sec. */
119 #define	IMPCOMPLETE_FAILURE	3	/* IMP/circuit failure */
120 #define	IMPCOMPLETE_NOSPACE	4	/* no resources within 15 sec. */
121 #define	IMPCOMPLETE_IMPIO	5	/* src IMP I/O failure during receipt */
122 
123 /*
124  * IMPTYPE_RETRY subtypes.
125  */
126 #define	IMPRETRY_BUFFER		0	/* IMP buffer wasn't available */
127 #define	IMPRETRY_BLOCK		1	/* connection block unavailable */
128 
129 /*
130  * Data structure shared between IMP protocol module and hardware
131  * interface driver.  Used to allow layering of IMP routines on top
132  * of varying device drivers.  NOTE: there's a possible problem
133  * with ambiguity in the ``unit'' definition which is implicitly
134  * shared by the both IMP and device code.  If we have two IMPs,
135  * with each on top of a device of the same unit, things won't work.
136  * The assumption is if you've got multiple IMPs, then they all run
137  * on top of the same type of device, or they must have different units.
138  */
139 struct	impcb {
140 	char	ic_oactive;		/* output in progress */
141 	int	(*ic_init)();		/* hardware init routine */
142 	int	(*ic_start)();		/* hardware start output routine */
143 };
144 
145 /*
146  * State of an IMP.
147  */
148 #define	IMPS_DOWN	0		/* unavailable, don't use */
149 #define	IMPS_GOINGDOWN	1		/* been told we go down soon */
150 #define	IMPS_INIT	2		/* coming up */
151 #define	IMPS_UP		3		/* ready to go */
152 #define	IMPS_RESET	4		/* reset in progress */
153 
154 #define	IMPTV_DOWN	(30*60)		/* going down timer 30 secs */
155 
156 #ifdef IMPLEADERS
157 char * impleaders[IMPTYPE_READY+1] = {
158 	"DATA", "BADLEADER", "DOWN", "bad", "NOOP", "RFNM", "HOSTDEAD",
159 	"HOSTUNREACH", "BADDATA", "INCOMPLETE", "RESET", "RETRY",
160 	"NOTIFY", "TRYING", "READY"
161 };
162 #endif
163