123296Smckusick /* 229282Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 3*35322Sbostic * All rights reserved. 423296Smckusick * 5*35322Sbostic * This code is derived from software contributed to Berkeley by 6*35322Sbostic * Tektronix Inc. 7*35322Sbostic * 8*35322Sbostic * Redistribution and use in source and binary forms are permitted 9*35322Sbostic * provided that the above copyright notice and this paragraph are 10*35322Sbostic * duplicated in all such forms and that any documentation, 11*35322Sbostic * advertising materials, and other materials related to such 12*35322Sbostic * distribution and use acknowledge that the software was developed 13*35322Sbostic * by the University of California, Berkeley. The name of the 14*35322Sbostic * University may not be used to endorse or promote products derived 15*35322Sbostic * from this software without specific prior written permission. 16*35322Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17*35322Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18*35322Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19*35322Sbostic * 20*35322Sbostic * @(#)if_hy.h 7.3 (Berkeley) 08/04/88 2123296Smckusick */ 2211196Ssam 2311196Ssam /* 2421129Skarels * 4.2 BSD Unix Kernel - Vax Network Interface Support 2521129Skarels * 2621129Skarels * $Header: if_hy.h,v 10.0 84/06/30 19:51:21 steveg Stable $ 2721129Skarels * $Locker: $ 2821129Skarels * 2921129Skarels * Modifications from Berkeley 4.2 BSD 3021129Skarels * Copyright (c) 1983, Tektronix Inc. 3121129Skarels * All Rights Reserved 3221129Skarels * 3321129Skarels * 3421129Skarels * $Log: if_hy.h,v $ 3521129Skarels * Revision 10.0 84/06/30 19:51:21 steveg 3621129Skarels * Big Build 3721129Skarels * 3821129Skarels * Revision 3.13 84/05/30 19:40:58 steveg 3921129Skarels * update hy_stat to reflect new microcode 4021129Skarels * 4121129Skarels * Revision 3.12 84/05/30 19:06:57 steveg 4221129Skarels * move driver state number definition here from if_hy.c 4321129Skarels * 4421129Skarels * Revision 3.11 84/05/30 18:56:15 steveg 4521129Skarels * add definition of HYE_MAX and HYE_SIZE 4621129Skarels * 4721129Skarels * Revision 3.10 84/05/30 17:14:04 steveg 4821129Skarels * add hyl_filter 4921129Skarels * 5021129Skarels * Revision 3.9 84/05/30 13:45:24 steveg 5121129Skarels * rework logging 5221129Skarels * 5321129Skarels * Revision 3.8 84/05/04 05:18:59 steveg 5421129Skarels * hyr_key now a u_long 5521129Skarels * 5621129Skarels * Revision 3.7 84/05/01 22:45:20 steveg 5721129Skarels * add H_RLOOPBK for A710 remote end loopback command 5821129Skarels * 5921129Skarels * 6011196Ssam */ 6111196Ssam 6221129Skarels 6321129Skarels /* 6421129Skarels * Structure of a HYPERchannel adapter header 6521129Skarels */ 6621129Skarels struct hy_hdr { 6721129Skarels short hyh_ctl; /* control */ 6821129Skarels short hyh_access; /* access code */ 6921129Skarels union { 7021129Skarels short hyh_addr; 7121129Skarels char hyh_baddr[2]; 7221129Skarels } hyh_uto, hyh_ufrom; /* to/from address */ 7321129Skarels short hyh_param; /* parameter word */ 7421129Skarels short hyh_type; /* record type */ 7521129Skarels }; 7621129Skarels 7721129Skarels 7821129Skarels #define hyh_to hyh_uto.hyh_addr 7921129Skarels #define hyh_to_port hyh_uto.hyh_baddr[1] 8021129Skarels #define hyh_to_adapter hyh_uto.hyh_baddr[0] 8121129Skarels 8221129Skarels #define hyh_from hyh_ufrom.hyh_addr 8321129Skarels #define hyh_from_port hyh_ufrom.hyh_baddr[1] 8421129Skarels #define hyh_from_adapter hyh_ufrom.hyh_baddr[0] 8521129Skarels 8621129Skarels /* 8721129Skarels * Structure of a HYPERchannel message header (from software) 8821129Skarels */ 8921129Skarels struct hym_hdr { 9021129Skarels struct { 9121129Skarels short hymd_mplen; /* message proper len, if associated data */ 9221129Skarels } hym_d; 9321129Skarels struct hy_hdr hym_h; /* hardware header, MUST BE LAST */ 9421129Skarels }; 9521129Skarels 9621129Skarels #define hym_mplen hym_d.hymd_mplen 9721129Skarels 9821129Skarels #define hym_ctl hym_h.hyh_ctl 9921129Skarels #define hym_access hym_h.hyh_access 10021129Skarels #define hym_param hym_h.hyh_param 10121129Skarels #define hym_type hym_h.hyh_type 10221129Skarels 10321129Skarels #define hym_to hym_h.hyh_to 10421129Skarels #define hym_to_port hym_h.hyh_to_port 10521129Skarels #define hym_to_adapter hym_h.hyh_to_adapter 10621129Skarels 10721129Skarels #define hym_from hym_h.hyh_from 10821129Skarels #define hym_from_port hym_h.hyh_from_port 10921129Skarels #define hym_from_adapter hym_h.hyh_from_adapter 11021129Skarels 11121129Skarels #define HYM_SWLEN (sizeof(struct hym_hdr) - sizeof(struct hy_hdr)) 11221129Skarels 11321129Skarels /* 11421129Skarels * HYPERchannel header word control bits 11521129Skarels */ 11621129Skarels #define H_XTRUNKS 0x00F0 /* transmit trunks */ 11721129Skarels #define H_RTRUNKS 0x000F /* remote trunks to transmit on for loopback */ 11821129Skarels #define H_ASSOC 0x0100 /* has associated data */ 11921129Skarels #define H_LOOPBK 0x00FF /* loopback command */ 12021129Skarels #define H_RLOOPBK 0x008F /* A710 remote loopback command */ 12121129Skarels 12221129Skarels /* 12321129Skarels * Hyperchannel record types 12421129Skarels */ 12521129Skarels #define HYLINK_IP 0 /* Internet Protocol Packet */ 12621129Skarels 12721129Skarels /* 12821129Skarels * Routing database 12921129Skarels */ 13011196Ssam #define HYRSIZE 37 /* max number of adapters in routing tables */ 13111196Ssam 13221129Skarels struct hy_route { 13321129Skarels time_t hyr_lasttime; /* last update time */ 13421129Skarels u_char hyr_gateway[256]; 13521129Skarels struct hyr_hash { 13621129Skarels u_long hyr_key; /* desired address */ 13711196Ssam u_short hyr_flags; /* status flags - see below */ 13821129Skarels u_short hyr_size; /* number of entries */ 13911196Ssam union { 14011196Ssam /* 14111196Ssam * direct entry (can get there directly) 14211196Ssam */ 14311196Ssam struct { 14421129Skarels u_short hyru_dst; /* adapter number & port */ 14521129Skarels u_short hyru_ctl; /* trunks to try */ 14611196Ssam u_short hyru_access; /* access code (mostly unused) */ 14711196Ssam } hyr_d; 14821129Skarels #define hyr_dst hyr_u.hyr_d.hyru_dst 14921129Skarels #define hyr_ctl hyr_u.hyr_d.hyru_ctl 15021129Skarels #define hyr_access hyr_u.hyr_d.hyru_access 15111196Ssam /* 15211196Ssam * indirect entry (one or more hops required) 15311196Ssam */ 15411196Ssam struct { 15511196Ssam u_char hyru_pgate; /* 1st gateway slot */ 15611196Ssam u_char hyru_egate; /* # gateways */ 15711196Ssam u_char hyru_nextgate; /* gateway to use next */ 15811196Ssam } hyr_i; 15921129Skarels #define hyr_pgate hyr_u.hyr_i.hyru_pgate 16021129Skarels #define hyr_egate hyr_u.hyr_i.hyru_egate 16121129Skarels #define hyr_nextgate hyr_u.hyr_i.hyru_nextgate 16211196Ssam } hyr_u; 16311196Ssam } hyr_hash[HYRSIZE]; 16411196Ssam }; 16511196Ssam 16621129Skarels /* 16721129Skarels * routing table set/get structure 16821129Skarels * 16921129Skarels * used to just pass the entire routing table through, but 4.2 ioctls 17021129Skarels * limit the data part of an ioctl to 128 bytes or so and use the 17121129Skarels * interface name to get things sent the right place. 17221129Skarels * see ../net/if.h for additional details. 17321129Skarels */ 17421129Skarels struct hyrsetget { 17521129Skarels char hyrsg_name[IFNAMSIZ]; /* if name, e.g. "hy0" */ 17621129Skarels struct hy_route *hyrsg_ptr; /* pointer to routing table */ 17721129Skarels unsigned hyrsg_len; /* size of routing table provided */ 17821129Skarels }; 17911196Ssam 18011196Ssam #define HYR_INUSE 0x01 /* entry in use */ 18111196Ssam #define HYR_DIR 0x02 /* direct entry */ 18211196Ssam #define HYR_GATE 0x04 /* gateway entry */ 18321129Skarels #define HYR_LOOP 0x08 /* hardware loopback entry */ 18421129Skarels #define HYR_RLOOP 0x10 /* remote adapter hardware loopback entry */ 18511196Ssam 18611196Ssam #define HYRHASH(x) (((x) ^ ((x) >> 16)) % HYRSIZE) 18711196Ssam 18833099Sbostic #define HYSETROUTE _IOW('i', 0x80, struct hyrsetget) 18933099Sbostic #define HYGETROUTE _IOW('i', 0x81, struct hyrsetget) 19021129Skarels 19121129Skarels struct hylsetget { 19221129Skarels char hylsg_name[IFNAMSIZ]; /* if name, e.g. "hy0" */ 19321129Skarels int hylsg_cmd; /* logging command */ 19421129Skarels caddr_t hylsg_ptr; /* pointer to table */ 19521129Skarels u_long hylsg_len; /* size of table provided */ 19621129Skarels }; 19721129Skarels 19833099Sbostic #define HYSETLOG _IOW('i', 0x82, struct hylsetget) 19933099Sbostic #define HYGETLOG _IOW('i', 0x83, struct hylsetget) 20033099Sbostic #define HYGETELOG _IOW('i', 0x84, struct hylsetget) 20121129Skarels 20221129Skarels /* 20321129Skarels * Structure of Statistics Record (counters) 20421129Skarels */ 20521129Skarels struct hy_stat { 20621129Skarels u_char hyc_df0[3]; /* # data frames trunk 0 */ 20721129Skarels u_char hyc_df1[3]; /* # data frames trunk 1 */ 20821129Skarels u_char hyc_df2[3]; /* # data frames trunk 2 */ 20921129Skarels u_char hyc_df3[3]; /* # data frames trunk 3 */ 21021129Skarels u_char hyc_cancel[2]; /* # cancel operations */ 21121129Skarels u_char hyc_abort[2]; /* # aborts */ 21221129Skarels u_char hyc_ret0[3]; /* # retransmissions trunk 0 */ 21321129Skarels u_char hyc_ret1[3]; /* # retransmissions trunk 1 */ 21421129Skarels u_char hyc_ret2[3]; /* # retransmissions trunk 2 */ 21521129Skarels u_char hyc_ret3[3]; /* # retransmissions trunk 3 */ 21621129Skarels u_char hyc_atype[3]; /* adapter type and revision level */ 21721129Skarels u_char hyc_uaddr; /* adapter unit number */ 21821129Skarels }; 21921129Skarels 22021129Skarels /* 22121129Skarels * Structure of the Status Record 22221129Skarels */ 22321129Skarels struct hy_status { 22421129Skarels u_char hys_gen_status; /* general status byte */ 22521129Skarels u_char hys_last_fcn; /* last function code issued */ 22621129Skarels u_char hys_resp_trunk; /* trunk response byte */ 22721129Skarels u_char hys_status_trunk; /* trunk status byte */ 22821129Skarels u_char hys_recd_resp; /* recieved response byte */ 22921129Skarels u_char hys_error; /* error code */ 23021129Skarels u_char hys_caddr; /* compressed addr of 1st msg on chain */ 23121129Skarels u_char hys_pad; /* not used */ 23221129Skarels }; 23321129Skarels 23421129Skarels /* 23521129Skarels * Get port number from status record 23621129Skarels */ 23721129Skarels #define PORTNUM(p) (((p)->hys_gen_status >> 6) & 0x03) 23821129Skarels 23921129Skarels #define HYL_SIZE 16*1024 24021129Skarels struct hy_log { 24121129Skarels struct hy_log *hyl_self; 24221129Skarels u_char hyl_enable; /* logging enabled? */ 24321129Skarels u_char hyl_onerr; /* state to enter on error */ 24421129Skarels u_short hyl_wait; /* number of bytes till next wakeup */ 24521129Skarels u_short hyl_count; /* number of samples till stop */ 24621129Skarels u_short hyl_icount; /* initial value of hyl_count */ 24721129Skarels u_long hyl_filter; /* log items with specific bits set */ 24821129Skarels u_char *hyl_eptr; /* &hy_log.hyl_buf[HYL_SIZE] */ 24921129Skarels u_char *hyl_ptr; /* pointer into hyl_buf */ 25021129Skarels u_char hyl_buf[HYL_SIZE]; /* log buffer space */ 25121129Skarels }; 25221129Skarels 25321129Skarels #define HYL_NOP 0 25421129Skarels #define HYL_UP 1 /* markup */ 25521129Skarels #define HYL_STATUS 2 /* status results (struct hy_status) */ 25621129Skarels #define HYL_STATISTICS 3 /* statistics (struct hy_stat) */ 25721129Skarels #define HYL_XMIT 4 /* packed being send (struct hym_hdr) */ 25821129Skarels #define HYL_RECV 5 /* recieved pkt (short len; struct hym_hdr) */ 25921129Skarels #define HYL_CMD 6 /* cmd issued (uchar cmd, state; short count) */ 26021129Skarels #define HYL_INT 7 /* interrupt (short csr, wcr) */ 26121129Skarels #define HYL_CANCEL 8 /* cancel transmit attempt */ 26221129Skarels #define HYL_RESET 9 /* hyinit or unibus reset */ 26321129Skarels #define HYL_IOCTL 10 /* hyioctl */ 26421129Skarels 26521129Skarels #define HYL_DISABLED 0 /* logging disabled */ 26621129Skarels #define HYL_CONTINUOUS 1 /* continuous logging */ 26721129Skarels #define HYL_CATCHN 2 /* hyl_count transactions being captured */ 26821129Skarels 26921129Skarels /* 27021129Skarels * error code histograms 27121129Skarels */ 27221129Skarels #define HYE_MAX 0x18 /* maximum adapter error code */ 27321129Skarels #define HYE_BINS 4 /* number of command bins */ 27421129Skarels #define HYE_SIZE (HYE_MAX+1)*HYE_BINS /* size of histogram buffer */ 27521129Skarels 27621129Skarels /* 27721129Skarels * Requests for service (in order by descending priority). 27821129Skarels */ 27921129Skarels #define RQ_ENDOP 001 /* end the last adapter function */ 28021129Skarels #define RQ_REISSUE 002 /* reissue previous cmd after status */ 28121129Skarels #define RQ_STATUS 004 /* get the status of the adapter */ 28221129Skarels #define RQ_STATISTICS 010 /* get the statistics of the adapter */ 28321129Skarels #define RQ_MARKDOWN 020 /* mark this adapter port down */ 28421129Skarels #define RQ_MARKUP 040 /* mark this interface up */ 28521129Skarels 28621129Skarels #define RQ_XASSOC 0100 /* associated data to transmit */ 28721129Skarels 28821129Skarels /* 28921129Skarels * Driver states. 29021129Skarels */ 29121129Skarels #define STARTUP 0 /* initial state (before fully there) */ 29221129Skarels #define IDLE 1 /* idle state */ 29321129Skarels #define STATSENT 2 /* status cmd sent to adapter */ 29421129Skarels #define ENDOPSENT 3 /* end operation cmd sent */ 29521129Skarels #define RECVSENT 4 /* input message cmd sent */ 29621129Skarels #define RECVDATASENT 5 /* input data cmd sent */ 29721129Skarels #define XMITSENT 6 /* transmit message cmd sent */ 29821129Skarels #define XMITDATASENT 7 /* transmit data cmd sent */ 29921129Skarels #define WAITING 8 /* waiting for messages */ 30021129Skarels #define CLEARSENT 9 /* clear wait for message cmd sent */ 30121129Skarels #define MARKPORT 10 /* mark this host's adapter port down issued */ 30221129Skarels #define RSTATSENT 11 /* read statistics cmd sent to adapter */ 30321129Skarels 30421129Skarels #ifdef HYLOG 30521129Skarels char *hy_state_names[] = { 30621129Skarels "Startup", 30721129Skarels "Idle", 30821129Skarels "Status Sent", 30921129Skarels "End op Sent", 31021129Skarels "Recieve Message Proper Sent", 31121129Skarels "Recieve Data Sent", 31221129Skarels "Transmit Message Proper Sent", 31321129Skarels "Transmit Data Sent", 31421129Skarels "Wait for Message Sent", 31521129Skarels "Clear Wait for Message Sent", 31621129Skarels "Mark Port Down Sent", 31721129Skarels "Read Statistics Sent" 31821129Skarels }; 31921129Skarels #endif 32021129Skarels 321