1*11208Ssam /* if_hyreg.h 4.2 83/02/21 */ 211194Ssam 311194Ssam /* 411194Ssam * Network Systems Corporation Hyperchannel interface 511194Ssam * 611194Ssam * supports A410 adapter interfaced via a DEC DR-11B, NSC PI-13 or PI-14 711194Ssam * (PI-14 is a PI-13 with different line drivers, software is 811194Ssam * identical to a PI-13) 911194Ssam * 1011194Ssam * Written by Steve Glaser, Tektronix Inc., July 1982 1111194Ssam * 1211194Ssam * NOTE: 1311194Ssam * 1411194Ssam * DR11B code has not been fully checked out with 4.1a. 1511194Ssam * The first adapters at Tek came with DR11Bs, and the code once worked, 1611194Ssam * but those have been upgraded to PI-13s. 1711194Ssam */ 18*11208Ssam #define PI13 1 /* PI13 vs. DR11B device depandant code */ 1911194Ssam #ifndef HYLOG 20*11208Ssam #define HYLOG 1 /* enable logging of errors */ 2111194Ssam #endif 2211194Ssam 2311194Ssam /* 2411194Ssam * Structure of a HYPERchannel adapter header 2511194Ssam */ 2611194Ssam struct hy_hdr { 2711194Ssam short hyh_ctl; /* control */ 2811194Ssam short hyh_access; /* access code */ 2911194Ssam union { /* to/from addresses */ 30*11208Ssam short hyh_addr; /* full address */ 31*11208Ssam char hyh_baddr[2]; /* adapter/port number from address */ 3211194Ssam } hyhu_to, hyhu_from; 3311194Ssam #define hyh_to hyhu_to.hyh_addr 3411194Ssam #define hyh_from hyhu_from.hyh_addr 3511194Ssam #define hyh_to_adapter hyhu_to.hyh_baddr[0] 3611194Ssam #define hyh_to_port hyhu_to.hyh_baddr[1] 3711194Ssam #define hyh_from_adapter hyhu_from.hyh_baddr[0] 3811194Ssam #define hyh_from_port hyhu_from.hyh_baddr[1] 3911194Ssam short hyh_param; /* parameter (for loopback) */ 4011194Ssam char hyh_type; /* record type */ 4111194Ssam char hyh_off; /* offset from end of hy_hdr to ip data */ 4211194Ssam }; 4311194Ssam 4411194Ssam /* 4511194Ssam * Structure of a HYPERchannel message header (from software) 4611194Ssam */ 47*11208Ssam struct hym_data { 48*11208Ssam short hymd_mplen; /* message proper length, if associated data */ 4911194Ssam }; 5011194Ssam 51*11208Ssam struct hym_hdr { 52*11208Ssam struct hym_data hym_d; 5311194Ssam #define hym_mplen hym_d.hymd_mplen 54*11208Ssam struct hy_hdr hym_hdr; /* hardware header, MUST BE LAST */ 5511194Ssam }; 5611194Ssam 5711194Ssam /* 5811194Ssam * HYPERchannel header word control bits 5911194Ssam */ 6011194Ssam #define H_XTRUNKS 0x00F0 /* transmit trunks */ 6111194Ssam #define H_RTRUNKS 0x000F /* remote trunks to transmit on for loopback */ 6211194Ssam #define H_ASSOC 0x0100 /* has associated data */ 6311194Ssam #define H_LOOPBK 0x00FF /* loopback command */ 6411194Ssam 6511194Ssam /* 6611194Ssam * Structure of Statistics Record (counters) 6711194Ssam */ 6811194Ssam struct hy_stat { 6911194Ssam u_long hyc_msgcnt; /* # messages transmitted */ 7011194Ssam u_long hyc_dbcnt; /* # data buffers transmitted */ 7111194Ssam u_long hyc_tbusy; /* # available trunks busy */ 7211194Ssam u_long hyc_hwret; /* # hardware retransmits */ 7311194Ssam u_long hyc_crcbad; /* # crc errors on trunk */ 7411194Ssam u_long hyc_mcret; /* # microcode retransmits */ 7511194Ssam u_long hyc_tdabort; /* # trunk driver aborts */ 7611194Ssam u_char hyc_atype[3]; /* adapter type and revision level */ 7711194Ssam u_char hyc_uaddr; /* adapter unit number */ 7811194Ssam }; 7911194Ssam 8011194Ssam /* 8111194Ssam * Structure of the Status Record 8211194Ssam */ 8311194Ssam struct hy_status { 8411194Ssam u_char hys_gen_status; /* general status byte */ 8511194Ssam u_char hys_last_fcn; /* last function code issued */ 8611194Ssam u_char hys_resp_trunk; /* trunk response byte */ 8711194Ssam u_char hys_status_trunk; /* trunk status byte */ 8811194Ssam u_char hys_recd_resp; /* recieved response byte */ 8911194Ssam u_char hys_error; /* error code */ 9011194Ssam u_char hys_caddr; /* compressed addr of 1st msg on chain */ 9111194Ssam u_char hys_pad; /* not used */ 9211194Ssam }; 9311194Ssam 9411194Ssam /* 95*11208Ssam * Get port number from status record 9611194Ssam */ 97*11208Ssam #define PORTNUM(p) (((p)->hys_gen_status >> 6) & 0x03) 9811194Ssam 9911194Ssam /* 10011194Ssam * The HYPERchannel driver sends and receives messages formatted: 10111194Ssam * 10211194Ssam * +---------------------------------------+ --- 10311194Ssam * | | /|\ 10411194Ssam * | HYPERchannel adapter header (hy_hdr) | | 10511194Ssam * | | | 10611194Ssam * +---------------------------------------+ | 10711194Ssam * | | | 10811194Ssam * | Internet Protocol header (ip) | message proper 10911194Ssam * | | (64 bytes max) 11011194Ssam * +---------------------------------------+ | 11111194Ssam * | | | 11211194Ssam * | TCP header + user data | | 11311194Ssam * | (if it all fits here) | | 11411194Ssam * | | \|/ 11511194Ssam * +---------------------------------------+ --- 11611194Ssam * 11711194Ssam * +---------------------------------------+ --- 11811194Ssam * | | /|\ 11911194Ssam * | | | 12011194Ssam * | TCP header + user data | associated data 12111194Ssam * | | | 12211194Ssam * | | \|/ 12311194Ssam * +---------------------------------------+ --- 12411194Ssam * 12511194Ssam * If all of the datagram will fit in the message proper (including 12611194Ssam * the TCP header and user data) the entire datagram is passed in 12711194Ssam * the message proper and the associated data feature of the HYPERchannel 12811194Ssam * is not used. 12911194Ssam * 13011194Ssam * The mapping from internet addresses to HYPERchannel addresses is: 13111194Ssam * 13211194Ssam * 0 7 8 15 16 31 13311194Ssam * +---------+---------+-----------------------+ 13411194Ssam * | network | special | HYPERchannel address | 13511194Ssam * +---------+---------+-----------------------+ 13611194Ssam * 13711194Ssam * |<------------ internet address ----------->| 13811194Ssam * 13911194Ssam * The hyperchannel address is decoded as follows: 14011194Ssam * 14111194Ssam * 0 7 8 13 14 15 14211194Ssam * +-------------------+----------------+------+ 14311194Ssam * | adapter number | zero | port | 14411194Ssam * +-------------------+----------------+------+ 14511194Ssam * 14611194Ssam * The low 2 bits are port number (interpreted by hyperchannel hardware). 14711194Ssam * 14811194Ssam * The encoding of special bits is: 14911194Ssam * 15011194Ssam * 00 normal packet 15111194Ssam * 15211194Ssam * 01 loop this packet back to the sender at the 15311194Ssam * specified adapter (ip header source/destination addresses 15411194Ssam * swapped before sending, command bits added to tell the 15511194Ssam * remote HYPERchannel adapter debug & performance studies] 15611194Ssam * this code acts like 02 (below) if the ip destination (before 15711194Ssam * any swapping) and the destination address don't match (e.g. 15811194Ssam * this packet is being routed through a gateway) 15911194Ssam * 16011194Ssam * 02 loop this packet back to the sender at the 16111194Ssam * specified adapter, but go through the specified adapter's 16211194Ssam * IP. This is for testing IP's store and forward mechanism. 16311194Ssam * 16411194Ssam * other undefined, currently treated as normal packet 16511194Ssam * 16611194Ssam */ 16711194Ssam #define MPSIZE 64 /* "Message Proper" size */ 16811194Ssam #define MAXRETRY 4 16911194Ssam 17011194Ssam /* 171*11208Ssam * Device registers 17211194Ssam */ 17311194Ssam struct hydevice { 174*11208Ssam short hyd_wcr; /* word count (negated) */ 175*11208Ssam u_short hyd_bar; /* bus address bits 15-0 */ 176*11208Ssam u_short hyd_csr; /* control and status */ 177*11208Ssam u_short hyd_dbuf; /* data buffer */ 17811194Ssam }; 17911194Ssam 18011194Ssam /* 181*11208Ssam * CSR bit layout 18211194Ssam */ 18311194Ssam #define S_ERROR 0100000 /* error */ 18411194Ssam #define S_NEX 0040000 /* non-existent memory error */ 18511194Ssam #define S_ATTN 0020000 /* attn (always zero) */ 18611194Ssam #ifdef PI13 18711194Ssam #define S_STKINTR 0010000 /* stacked interrupt */ 18811194Ssam #else 18911194Ssam #define S_MAINT 0010000 /* maintenance (not used) */ 19011194Ssam #endif 19111194Ssam #define S_A 0004000 /* device status A (recieve data available) */ 19211194Ssam #define S_B 0002000 /* device status B (normal termination) */ 19311194Ssam #define S_C 0001000 /* device status C (abnormal termination) */ 19411194Ssam #ifdef PI13 19511194Ssam #define S_POWEROFF 0000400 /* power off indicator */ 19611194Ssam #else 19711194Ssam #define S_CYCLE 0000400 /* cycle (not used) */ 19811194Ssam #endif 19911194Ssam #define S_READY 0000200 /* ready */ 20011194Ssam #define S_IE 0000100 /* interrupt enable */ 20111194Ssam #define S_XBA 0000060 /* bus address bit bits 17 and 16 */ 20211194Ssam #define S_CLRINT 0000014 /* clear stacked interrupt */ 20311194Ssam #define S_IATTN 0000010 /* interrupt on attention only */ 20411194Ssam #define S_WC 0000004 /* interrupt on word count == 0 only */ 20511194Ssam #define S_IATTNWC 0000000 /* interrupt on word count == 0 and attention */ 20611194Ssam #define S_BURST 0000002 /* burst mode DMA (not used) */ 20711194Ssam #define S_GO 0000001 /* go */ 20811194Ssam 209*11208Ssam #define XBASHIFT 12 21011194Ssam 21111194Ssam #define HY_CSR_BITS "\20\20ERROR\17NEX\16ATTN\15STKINTR\14RECV_DATA\13NORMAL\12ABNORMAL\11POWER\10READY\07IENABLE\06XBA17\05XBA16\04IATTN\03IWC\02BURST\01GO" 21211194Ssam 21311194Ssam /* 21411194Ssam * PI13 status conditions 21511194Ssam */ 216*11208Ssam #define HYS_RECVDATA(x) (((x)->hyd_csr & S_A) != 0) /* get adapter data */ 217*11208Ssam #define HYS_NORMAL(x) (((x)->hyd_csr & S_B) != 0) /* done normally */ 218*11208Ssam #define HYS_ABNORMAL(x) (((x)->hyd_csr & S_C) != 0) /* done abnormally */ 219*11208Ssam #define HYS_ERROR(x) (((x)->hyd_csr & S_ERROR) != 0) /* error condition */ 220*11208Ssam #define HYS_DONE(x) (((x)->hyd_csr & (S_ERROR|S_B|S_C)) != 0) 22111194Ssam 22211194Ssam /* 22311194Ssam * Function Codes for the Hyperchannel Adapter 22411194Ssam * The codes are offset so they can be "or"ed into 22511194Ssam * the reg data buffer 22611194Ssam */ 22711194Ssam #define HYF_XMITMSG 0x04 /* transmit message */ 22811194Ssam #define HYF_XMITDATA 0x08 /* transmit associated data */ 22911194Ssam #define HYF_XMITLSTDATA 0x0C /* transmit last associated data */ 23011194Ssam #define HYF_XMITLOCMSG 0x10 /* transmit local message */ 23111194Ssam #define HYF_INPUTMSG 0x24 /* input message proper */ 23211194Ssam #define HYF_INPUTDATA 0x28 /* input assiciated data */ 23311194Ssam #define HYF_STATUS 0x40 /* request status */ 23411194Ssam #define HYF_DUMPREGS 0x50 /* dump extention registers */ 23511194Ssam #define HYF_MARKP0 0x60 /* mark down port 0 */ 23611194Ssam #define HYF_MARKP1 0x64 /* mark down port 1 */ 23711194Ssam #define HYF_MARKP2 0x68 /* mark down port 2 */ 23811194Ssam #define HYF_MARKP3 0x6C /* mark down port 3 */ 23911194Ssam #define HYF_MP0RR 0x70 /* mark down port 0 and reroute messages */ 24011194Ssam #define HYF_MP1RR 0x74 /* mark down port 1 and reroute messages */ 24111194Ssam #define HYF_MP2RR 0x78 /* mark down port 2 and reroute messages */ 24211194Ssam #define HYF_MP3RR 0x7C /* mark down port 3 and reroute messages */ 24311194Ssam #define HYF_RSTATS 0xA0 /* read statistics */ 24411194Ssam #define HYF_RCSTATS 0xA4 /* read and clear statistics */ 24511194Ssam #define HYF_SETTEST 0xC0 /* enable test operations *set test mode) */ 24611194Ssam #define HYF_SADDR_LEN 0xC4 /* test mode: set address and length */ 24711194Ssam #define HYF_WBUFF 0xC8 /* test mode: write buffer */ 24811194Ssam #define HYF_RBUFF 0xCC /* test mode: read buffer */ 24911194Ssam #define HYF_CLRADAPTER 0xE0 /* clear adapter */ 25011194Ssam #define HYF_END_OP 0xE4 /* end operation */ 25111194Ssam #define HYF_CLRWFMSG 0xE6 /* clear wait for mwssage */ 25211194Ssam #define HYF_WAITFORMSG 0xE8 /* wait for message */ 25311194Ssam 25411194Ssam /* 25511194Ssam * Hyperchannel record types 25611194Ssam */ 25711194Ssam #define HYLINK_IP 0 /* Internet Protocol Packet */ 25811194Ssam 25911194Ssam #ifdef HYLOG 26011194Ssam #define HYL_SIZE 16*1024 26111194Ssam struct hy_log { 262*11208Ssam struct hy_log *hyl_self; 263*11208Ssam u_char hyl_enable; /* logging enabled? */ 264*11208Ssam u_char hyl_onerr; /* state to enter on error */ 265*11208Ssam u_char *hyl_eptr; /* &hy_log.hyl_buf[HYL_SIZE] */ 266*11208Ssam u_char *hyl_ptr; /* pointer into hyl_buf */ 267*11208Ssam u_char hyl_buf[HYL_SIZE]; /* log buffer space */ 26811194Ssam }; 26911194Ssam 27011194Ssam #define HYL_NOP 0 27111194Ssam #define HYL_UP 1 /* markup */ 27211194Ssam #define HYL_STATUS 2 /* status results (struct hy_status) */ 27311194Ssam #define HYL_STATISTICS 3 /* statistics (struct hy_stat) */ 27411194Ssam #define HYL_XMIT 4 /* packed being send (struct hym_hdr) */ 27511194Ssam #define HYL_RECV 5 /* recieved packet (short len; struct hy_hdr) */ 27611194Ssam #define HYL_CMD 6 /* cmd issued (uchar cmd, state; short count) */ 27711194Ssam #define HYL_INT 7 /* interrupt (short csr, wcr) */ 27811194Ssam 27911194Ssam #define HYL_DISABLED 0 /* logging disabled */ 28011194Ssam #define HYL_CONTINUOUS 1 /* continuous logging */ 28111194Ssam #define HYL_CAUGHT1 2 /* one buffer full captured */ 28211194Ssam #define HYL_CATCH1 3 /* one buffer full being captured */ 28311194Ssam #define HYL_CAUGHTSTATUS 4 /* one buffer of status captured */ 28411194Ssam #define HYL_CATCHSTATUS 5 /* one buffer fill of status being captured */ 28511194Ssam 286*11208Ssam #ifdef KERNEL 287*11208Ssam struct hy_log hy_log; 28811194Ssam #endif 289*11208Ssam #endif 290