1 /* 2 * Copyright (c) 1982, 1986, 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 * 17 * @(#)if_imp.h 7.6 (Berkeley) 06/28/90 18 */ 19 20 /* 21 * Structure of IMP 1822 long leader. 22 */ 23 struct control_leader { 24 u_char dl_format; /* 1-8 leader format */ 25 u_char dl_network; /* 9-16 src/dest network */ 26 u_char dl_flags; /* 17-24 leader flags */ 27 u_char dl_mtype; /* 25-32 message type */ 28 u_char dl_htype; /* 33-40 handling type */ 29 u_char dl_host; /* 41-48 host number */ 30 u_short dl_imp; /* 49-64 imp field */ 31 u_char dl_link; /* 65-72 link number */ 32 u_char dl_subtype; /* 73-80 message subtype */ 33 }; 34 35 struct imp_leader { 36 struct control_leader il_dl; 37 #define il_format il_dl.dl_format 38 #define il_network il_dl.dl_network 39 #define il_flags il_dl.dl_flags 40 #define il_mtype il_dl.dl_mtype 41 #define il_htype il_dl.dl_htype 42 #define il_host il_dl.dl_host 43 #define il_imp il_dl.dl_imp 44 #define il_link il_dl.dl_link 45 #define il_subtype il_dl.dl_subtype 46 u_short il_length; /* message length */ 47 }; 48 49 #define IMP_MAXHOSTMSG 8 /* max messages in flight to a host */ 50 #define IMP_NOOPCNT 3 /* # of noops to send imp on reset */ 51 /* insure things are even... */ 52 #define IMPMTU ((8159 / NBBY) & ~01) 53 #define IMP_RCVBUF ((8159 / NBBY + 2) & ~01) 54 55 /* 56 * IMP-host flags 57 */ 58 #define IMP_1822L_H2I 0xd /* 1822L host-to-imp, 96-bit format */ 59 #define IMP_1822L_I2H 0xe /* 1822L imp-to-host, 96-bit format */ 60 #define IMP_NFF 0xf /* 96-bit (new) format */ 61 #define IMP_TRACE 0x8 /* trace message route */ 62 63 /* 64 * IMP-host message types. 65 */ 66 #define IMPTYPE_DATA 0 /* data for protocol */ 67 #define IMPTYPE_BADLEADER 1 /* leader error */ 68 #define IMPTYPE_DOWN 2 /* imp going down */ 69 #define IMPTYPE_NOOP 4 /* noop seen during initialization */ 70 #define IMPTYPE_RFNM 5 /* request for new messages */ 71 #define IMPTYPE_HOSTDEAD 6 /* host doesn't respond */ 72 #define IMPTYPE_HOSTUNREACH 7 /* host unreachable */ 73 #define IMPTYPE_BADDATA 8 /* data error */ 74 #define IMPTYPE_INCOMPLETE 9 /* incomplete message, send rest */ 75 #define IMPTYPE_RESET 10 /* reset complete */ 76 /* non-blocking IMP interface */ 77 #define IMPTYPE_RETRY 11 /* IMP refused, try again */ 78 #define IMPTYPE_NOTIFY 12 /* IMP refused, will notify */ 79 #define IMPTYPE_TRYING 13 /* IMP refused, still rexmt'ng */ 80 #define IMPTYPE_READY 14 /* ready for next message */ 81 82 /* 83 * Link numbers 84 */ 85 #define IMPLINK_IP 155 86 #define IMPLINK_LOWEXPER 156 87 #define IMPLINK_HIGHEXPER 158 88 89 /* 90 * IMPTYPE_DOWN subtypes, in link number field. 91 */ 92 #define IMP_DMASK 0x3 /* host going down mask */ 93 #define IMPDOWN_GOING 0 /* 30 secs */ 94 #define IMPDOWN_PM 1 /* hardware PM */ 95 #define IMPDOWN_RELOAD 2 /* software reload */ 96 #define IMPDOWN_RESTART 3 /* emergency restart */ 97 #define IMPDOWN_WHENMASK 0x3c /* mask for "how soon" */ 98 #define IMPDOWN_WHENSHIFT 2 /* shift for "how soon" */ 99 #define IMPDOWN_WHENUNIT 5 /* unit for "how soon", 5 min. */ 100 101 #define IMPTV_DOWN 30 /* going down timer 30 secs */ 102 103 #ifdef IMPMESSAGES 104 /* 105 * Messages from IMP regarding why 106 * it's going down. 107 */ 108 char *impmessage[] = { 109 "in 30 seconds", 110 "for hardware PM", 111 "to reload software", 112 "for emergency reset" 113 }; 114 #endif 115 116 /* 117 * IMPTYPE_BADLEADER subtypes. 118 */ 119 #define IMPLEADER_ERR 0 /* error flip-flop set */ 120 #define IMPLEADER_SHORT 1 /* leader < 80 bits */ 121 #define IMPLEADER_TYPE 2 /* illegal type field */ 122 #define IMPLEADER_OPPOSITE 3 /* opposite leader type */ 123 124 /* 125 * IMPTYPE_HOSTDEAD subtypes. 126 */ 127 #define IMPHOST_NORDY 1 /* ready-line negated */ 128 #define IMPHOST_TARDY 2 /* tardy receiving mesgs */ 129 #define IMPHOST_NOEXIST 3 /* NCC doesn't know host */ 130 #define IMPHOST_IMPSOFT 4 /* IMP software won't allow mesgs */ 131 #define IMPHOST_PM 5 /* host down for scheduled PM */ 132 #define IMPHOST_HARDSCHED 6 /* " " " " hardware work */ 133 #define IMPHOST_SOFTSCHED 7 /* " " " " software work */ 134 #define IMPHOST_RESTART 8 /* host down for emergency restart */ 135 #define IMPHOST_POWER 9 /* down because of power outage */ 136 #define IMPHOST_BREAKPOINT 10 /* host stopped at a breakpoint */ 137 #define IMPHOST_HARDWARE 11 /* hardware failure */ 138 #define IMPHOST_NOTUP 12 /* host not scheduled to be up */ 139 /* 13-14 currently unused */ 140 #define IMPHOST_COMINGUP 15 /* host in process of coming up */ 141 142 /* 143 * IMPTYPE_HOSTUNREACH subtypes. 144 */ 145 #define IMPREACH_IMP 0 /* destination IMP can't be reached */ 146 #define IMPREACH_HOSTUP 1 /* destination host isn't up */ 147 #define IMPREACH_LEADER 2 /* host doesn't support long leader */ 148 #define IMPREACH_PROHIBITED 3 /* communication is prohibited */ 149 150 /* 151 * IMPTYPE_INCOMPLETE subtypes. 152 */ 153 #define IMPCOMPLETE_SLOW 0 /* host didn't take data fast enough */ 154 #define IMPCOMPLETE_TOOLONG 1 /* message was too long */ 155 #define IMPCOMPLETE_TIMEOUT 2 /* mesg transmission time > 15 sec. */ 156 #define IMPCOMPLETE_FAILURE 3 /* IMP/circuit failure */ 157 #define IMPCOMPLETE_NOSPACE 4 /* no resources within 15 sec. */ 158 #define IMPCOMPLETE_IMPIO 5 /* src IMP I/O failure during receipt */ 159 160 /* 161 * IMPTYPE_RETRY subtypes. 162 */ 163 #define IMPRETRY_BUFFER 0 /* IMP buffer wasn't available */ 164 #define IMPRETRY_BLOCK 1 /* connection block unavailable */ 165 166 #define RFNMTIMER (120*PR_SLOWHZ) /* time to wait for RFNM for msg. */ 167 #define IMP_OTIMER (5*IFNET_SLOWHZ) /* max output time unless blocked */ 168 169 /* 170 * Data structure shared between IMP protocol module and hardware 171 * interface driver. Used to allow layering of IMP routines on top 172 * of varying device drivers. 173 */ 174 struct impcb { 175 int ic_hwunit; /* H/W unit number */ 176 char *ic_hwname; /* H/W type name */ 177 char ic_oactive; /* output in progress */ 178 int (*ic_init)(); /* hardware init routine */ 179 int (*ic_output)(); /* hardware output routine */ 180 int (*ic_down)(); /* hardware "drop ready" routine */ 181 }; 182 183 /* 184 * IMP software status per interface. 185 * (partially shared with the hardware specific module) 186 * 187 * Each interface is referenced by a network interface structure, 188 * imp_if, which the routing code uses to locate the interface. 189 * This structure contains the output queue for the interface, its 190 * address, ... IMP specific structures used in connecting the 191 * IMP software modules to the hardware specific interface routines 192 * are stored here. The common structures are made visible to the 193 * interface driver by passing a pointer to the hardware routine 194 * at "attach" time. 195 */ 196 struct imp_softc { 197 struct ifnet imp_if; /* network visible interface */ 198 struct impcb imp_cb; /* hooks to hardware module */ 199 int imp_state; /* current state of IMP */ 200 int imp_dropcnt; /* used during initialization */ 201 struct mbuf *imp_hosts; /* Head of host table hash chains. */ 202 struct mbuf *imp_hostq; /* current round-robin-output mark */ 203 u_int imp_hostent; /* current round-robin-output mark */ 204 int imp_msgready; /* number of messages ready to send */ 205 u_long imp_block; /* times imp blocked output */ 206 u_long imp_lostrfnm; /* rfnm's timed out */ 207 u_long imp_badrfnm; /* rfnm/incompl after timeout/bogus */ 208 u_long imp_incomplete; /* incomplete's received */ 209 u_long imp_garbage; /* bad messages received */ 210 }; 211 212 struct imp_softc *impattach(); 213 214 /* 215 * State of an IMP. 216 */ 217 #define IMPS_DOWN 0 /* unavailable, host not ready */ 218 #define IMPS_WINIT 1 /* imp not ready, waiting for init */ 219 #define IMPS_INIT 2 /* coming up */ 220 #define IMPS_UP 3 /* ready to go */ 221 #define IMPS_GOINGDOWN 4 /* been told we go down soon */ 222 223 #define IMPS_RUNNING(s) ((s) >= IMPS_UP) /* ready for messages */ 224 #define IMPS_IMPREADY(s) ((s) >= IMPS_INIT) /* IMP ready line on */ 225 226 #ifdef IMPLEADERS 227 char *impleaders[IMPTYPE_READY+1] = { 228 "DATA", "BADLEADER", "DOWN", "bad", "NOOP", "RFNM", "HOSTDEAD", 229 "HOSTUNREACH", "BADDATA", "INCOMPLETE", "RESET", "RETRY", 230 "NOTIFY", "TRYING", "READY" 231 }; 232 #endif 233