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