1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1991,1997-1998 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _SYS_SER_SYNC_H 28*0Sstevel@tonic-gate #define _SYS_SER_SYNC_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * Initial port setup parameters for sync lines 34*0Sstevel@tonic-gate */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <sys/stream.h> 37*0Sstevel@tonic-gate #include <sys/time_impl.h> 38*0Sstevel@tonic-gate #include <sys/ioccom.h> 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #ifdef __cplusplus 41*0Sstevel@tonic-gate extern "C" { 42*0Sstevel@tonic-gate #endif 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #define zIOC ('z' << 8) 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate #define S_IOCGETMODE (zIOC|01) /* return struct scc_mode */ 47*0Sstevel@tonic-gate #define S_IOCSETMODE (zIOC|02) /* set SCC from struct scc_mode */ 48*0Sstevel@tonic-gate #define S_IOCGETSTATS (zIOC|03) /* return sync data stats */ 49*0Sstevel@tonic-gate #define S_IOCCLRSTATS (zIOC|04) /* clear sync stats */ 50*0Sstevel@tonic-gate #define S_IOCGETSPEED (zIOC|05) /* return int baudrate */ 51*0Sstevel@tonic-gate #define S_IOCGETMRU (zIOC|06) /* return int max receive unit */ 52*0Sstevel@tonic-gate #define S_IOCSETMRU (zIOC|07) /* set max receive unit */ 53*0Sstevel@tonic-gate #define S_IOCGETMTU (zIOC|010) /* return int max transmission unit */ 54*0Sstevel@tonic-gate #define S_IOCSETMTU (zIOC|011) /* set max transmission unit */ 55*0Sstevel@tonic-gate #define S_IOCGETMCTL (zIOC|012) /* return current CD/CTS state */ 56*0Sstevel@tonic-gate #define S_IOCSETDTR (zIOC|013) /* Drive DTR signal */ 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate /* reason codes for IOCSETMODE */ 59*0Sstevel@tonic-gate #define SMERR_TXC 0x0001 /* transmit clock source not valid */ 60*0Sstevel@tonic-gate #define SMERR_RXC 0x0002 /* receive clock source not valid */ 61*0Sstevel@tonic-gate #define SMERR_IFLAGS 0x0004 /* inversion flags not valid */ 62*0Sstevel@tonic-gate #define SMERR_HDX 0x0008 /* CONN_HDX set without CONN_IBM */ 63*0Sstevel@tonic-gate #define SMERR_MPT 0x0010 /* CONN_MPT set without CONN_IBM */ 64*0Sstevel@tonic-gate #define SMERR_LPBKS 0x0020 /* invalid loopback/echo combination */ 65*0Sstevel@tonic-gate #define SMERR_BAUDRATE 0x0040 /* baudrate translates to 0 timeconst */ 66*0Sstevel@tonic-gate #define SMERR_PLL 0x0080 /* PLL set with BRG or w/o NRZI */ 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate /* 69*0Sstevel@tonic-gate * Definitions for modes of operations of 70*0Sstevel@tonic-gate * synchronous lines, both RS-232 and RS-449 71*0Sstevel@tonic-gate */ 72*0Sstevel@tonic-gate struct scc_mode { 73*0Sstevel@tonic-gate char sm_txclock; /* enum - transmit clock sources */ 74*0Sstevel@tonic-gate char sm_rxclock; /* enum - receive clock sources */ 75*0Sstevel@tonic-gate char sm_iflags; /* data and clock invert flags: see hsparam.h */ 76*0Sstevel@tonic-gate uchar_t sm_config; /* see CONN defines below */ 77*0Sstevel@tonic-gate int sm_baudrate; 78*0Sstevel@tonic-gate int sm_retval; /* SMERR codes go here, query with GETMODE */ 79*0Sstevel@tonic-gate }; 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate /* 82*0Sstevel@tonic-gate * defines for txclock 83*0Sstevel@tonic-gate */ 84*0Sstevel@tonic-gate #define TXC_IS_TXC 0 /* use incoming transmit clock */ 85*0Sstevel@tonic-gate #define TXC_IS_RXC 1 /* use incoming receive clock */ 86*0Sstevel@tonic-gate #define TXC_IS_BAUD 2 /* use baud rate generator */ 87*0Sstevel@tonic-gate #define TXC_IS_PLL 3 /* use phase-lock loop output */ 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate /* 90*0Sstevel@tonic-gate * defines for rxclock 91*0Sstevel@tonic-gate */ 92*0Sstevel@tonic-gate #define RXC_IS_RXC 0 /* use incoming receive clock */ 93*0Sstevel@tonic-gate #define RXC_IS_TXC 1 /* use incoming transmit clock */ 94*0Sstevel@tonic-gate #define RXC_IS_BAUD 2 /* use baud rate - only good for loopback */ 95*0Sstevel@tonic-gate #define RXC_IS_PLL 3 /* use phase-lock loop */ 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate /* 98*0Sstevel@tonic-gate * defines for clock/data inversion: from hsparam.h 99*0Sstevel@tonic-gate */ 100*0Sstevel@tonic-gate #define TXC_IS_SYSCLK 4 101*0Sstevel@tonic-gate #define RXC_IS_SYSCLK 4 102*0Sstevel@tonic-gate #define TXC_IS_INVERT 5 103*0Sstevel@tonic-gate #define RXC_IS_INVERT 5 104*0Sstevel@tonic-gate #define TRXD_NO_INVERT 0 105*0Sstevel@tonic-gate #define RXD_IS_INVERT 1 106*0Sstevel@tonic-gate #define TXD_IS_INVERT 2 107*0Sstevel@tonic-gate #define TRXD_IS_INVERT 3 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate /* 110*0Sstevel@tonic-gate * defines for config 111*0Sstevel@tonic-gate */ 112*0Sstevel@tonic-gate #define CONN_HDX 0x01 /* half-duplex if set, else full-duplex */ 113*0Sstevel@tonic-gate #define CONN_MPT 0x02 /* multipoint if set, else point-point */ 114*0Sstevel@tonic-gate #define CONN_IBM 0x04 /* set up in IBM-SDLC mode */ 115*0Sstevel@tonic-gate #define CONN_SIGNAL 0x08 /* report modem signal changes asynchronously */ 116*0Sstevel@tonic-gate #define CONN_NRZI 0x10 /* boolean - use NRZI */ 117*0Sstevel@tonic-gate #define CONN_LPBK 0x20 /* do internal loopback */ 118*0Sstevel@tonic-gate #define CONN_ECHO 0x40 /* place in auto echo mode */ 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate struct sl_status { 121*0Sstevel@tonic-gate int type; 122*0Sstevel@tonic-gate int status; 123*0Sstevel@tonic-gate timestruc_t tstamp; 124*0Sstevel@tonic-gate }; 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate #if defined(_SYSCALL32) 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate struct sl_status32 { 129*0Sstevel@tonic-gate int32_t type; 130*0Sstevel@tonic-gate int32_t status; 131*0Sstevel@tonic-gate timestruc32_t tstamp; 132*0Sstevel@tonic-gate }; 133*0Sstevel@tonic-gate 134*0Sstevel@tonic-gate #endif /* _SYSCALL32 */ 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate /* 137*0Sstevel@tonic-gate * defines for type field in sl_status 138*0Sstevel@tonic-gate */ 139*0Sstevel@tonic-gate #define SLS_MDMSTAT 0x01 /* Non-IBM modem line status change */ 140*0Sstevel@tonic-gate #define SLS_LINKERR 0x02 /* IBM mode Link Error, usually modem line. */ 141*0Sstevel@tonic-gate 142*0Sstevel@tonic-gate /* 143*0Sstevel@tonic-gate * defines for status field in sl_status 144*0Sstevel@tonic-gate * DO NOT change the values for CS_(DCD|CTS)_(UP|DOWN)!!! 145*0Sstevel@tonic-gate */ 146*0Sstevel@tonic-gate #define CS_DCD_DOWN 0x08 147*0Sstevel@tonic-gate #define CS_DCD_UP 0x0c 148*0Sstevel@tonic-gate #define CS_DCD_DROP 0x10 149*0Sstevel@tonic-gate #define CS_CTS_DOWN 0x20 150*0Sstevel@tonic-gate #define CS_CTS_UP 0x30 151*0Sstevel@tonic-gate #define CS_CTS_DROP 0x40 152*0Sstevel@tonic-gate #define CS_CTS_TO 0x80 153*0Sstevel@tonic-gate #define CS_DCD CS_DCD_DOWN 154*0Sstevel@tonic-gate #define CS_CTS CS_CTS_DOWN 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate /* 157*0Sstevel@tonic-gate * Event statistics reported by hardware. 158*0Sstevel@tonic-gate */ 159*0Sstevel@tonic-gate struct sl_stats { 160*0Sstevel@tonic-gate int ipack; /* input packets */ 161*0Sstevel@tonic-gate int opack; /* output packets */ 162*0Sstevel@tonic-gate int ichar; /* input bytes */ 163*0Sstevel@tonic-gate int ochar; /* output bytes */ 164*0Sstevel@tonic-gate int abort; /* abort received */ 165*0Sstevel@tonic-gate int crc; /* CRC error */ 166*0Sstevel@tonic-gate int cts; /* CTS timeouts */ 167*0Sstevel@tonic-gate int dcd; /* Carrier drops */ 168*0Sstevel@tonic-gate int overrun; /* receiver overrun */ 169*0Sstevel@tonic-gate int underrun; /* xmitter underrun */ 170*0Sstevel@tonic-gate int ierror; /* input error (rxbad) */ 171*0Sstevel@tonic-gate int oerror; /* output error (watchdog timeout) */ 172*0Sstevel@tonic-gate int nobuffers; /* no active receive block available */ 173*0Sstevel@tonic-gate }; 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate /* 178*0Sstevel@tonic-gate * Per-stream structure. Each of these points to only one device instance, 179*0Sstevel@tonic-gate * but there may be more than one doing so. If marked as ST_CLONE, it has 180*0Sstevel@tonic-gate * been opened throught the clone device, and cannot have the data path. 181*0Sstevel@tonic-gate */ 182*0Sstevel@tonic-gate struct ser_str { 183*0Sstevel@tonic-gate queue_t *str_rq; /* This stream's read queue */ 184*0Sstevel@tonic-gate caddr_t str_com; /* Back pointer to device struct */ 185*0Sstevel@tonic-gate int str_inst; /* Device instance (unit) number */ 186*0Sstevel@tonic-gate int str_state; /* see below */ 187*0Sstevel@tonic-gate }; 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gate /* 190*0Sstevel@tonic-gate * Synchronous Protocol Private Data Structure 191*0Sstevel@tonic-gate */ 192*0Sstevel@tonic-gate #define ZSH_MAX_RSTANDBY 6 193*0Sstevel@tonic-gate #define ZSH_RDONE_MAX 20 194*0Sstevel@tonic-gate struct syncline { 195*0Sstevel@tonic-gate struct ser_str sl_stream; /* data path device points thru here */ 196*0Sstevel@tonic-gate struct scc_mode sl_mode; /* clock, etc. modes */ 197*0Sstevel@tonic-gate struct sl_stats sl_st; /* Data and error statistics */ 198*0Sstevel@tonic-gate mblk_t *sl_rhead; /* receive: head of active message */ 199*0Sstevel@tonic-gate mblk_t *sl_ractb; /* receive: active message block */ 200*0Sstevel@tonic-gate mblk_t *sl_rstandby[ZSH_MAX_RSTANDBY]; 201*0Sstevel@tonic-gate /* receive: standby message blocks */ 202*0Sstevel@tonic-gate mblk_t *sl_xhead; /* transmit: head of active message */ 203*0Sstevel@tonic-gate mblk_t *sl_xactb; /* transmit: active message block */ 204*0Sstevel@tonic-gate mblk_t *sl_xstandby; /* transmit: next available message */ 205*0Sstevel@tonic-gate mblk_t *sl_rdone[ZSH_RDONE_MAX]; 206*0Sstevel@tonic-gate /* complete messages to be sent up */ 207*0Sstevel@tonic-gate int sl_rdone_wptr; 208*0Sstevel@tonic-gate int sl_rdone_rptr; 209*0Sstevel@tonic-gate mblk_t *sl_mstat; /* most recent modem status change */ 210*0Sstevel@tonic-gate bufcall_id_t sl_bufcid; /* pending bufcall ID */ 211*0Sstevel@tonic-gate timeout_id_t sl_wd_id; /* watchdog timeout ID */ 212*0Sstevel@tonic-gate int sl_wd_count; /* watchdog counter */ 213*0Sstevel@tonic-gate int sl_ocnt; /* output message size */ 214*0Sstevel@tonic-gate int sl_mru; /* Maximum Receive Unit */ 215*0Sstevel@tonic-gate int sl_bad_count_int; 216*0Sstevel@tonic-gate uchar_t sl_rr0; /* saved RR0 */ 217*0Sstevel@tonic-gate uchar_t sl_address; /* station address */ 218*0Sstevel@tonic-gate uchar_t sl_txstate; /* transmit state */ 219*0Sstevel@tonic-gate uchar_t sl_flags; /* see below */ 220*0Sstevel@tonic-gate uchar_t sl_m_error; 221*0Sstevel@tonic-gate volatile uchar_t sl_soft_active; /* */ 222*0Sstevel@tonic-gate }; 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gate /* 225*0Sstevel@tonic-gate * Bit definitions for sl_txstate. 226*0Sstevel@tonic-gate */ 227*0Sstevel@tonic-gate #define TX_OFF 0x0 /* Not available */ 228*0Sstevel@tonic-gate #define TX_IDLE 0x1 /* Initialized */ 229*0Sstevel@tonic-gate #define TX_RTS 0x2 /* IBM: RTS up, okay to transmit */ 230*0Sstevel@tonic-gate #define TX_ACTIVE 0x4 /* Transmission in progress */ 231*0Sstevel@tonic-gate #define TX_CRC 0x8 /* Sent all Data */ 232*0Sstevel@tonic-gate #define TX_FLAG 0x10 /* Sent CRC bytes */ 233*0Sstevel@tonic-gate #define TX_LAST 0x20 /* End-Of-Frame, OK to start new msg */ 234*0Sstevel@tonic-gate #define TX_ABORTED 0x40 /* Transmit was aborted */ 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate /* 237*0Sstevel@tonic-gate * Bit definitions for sl_flags. 238*0Sstevel@tonic-gate */ 239*0Sstevel@tonic-gate #define SF_FDXPTP 0x1 /* Full duplex AND Point-To-Point */ 240*0Sstevel@tonic-gate #define SF_XMT_INPROG 0x2 /* Write queue is not empty */ 241*0Sstevel@tonic-gate #define SF_LINKERR 0x4 /* Underrun or CTS/DCD drop */ 242*0Sstevel@tonic-gate #define SF_FLUSH_WQ 0x8 /* */ 243*0Sstevel@tonic-gate #define SF_INITIALIZED 0x10 /* This channel programmed for this protocol */ 244*0Sstevel@tonic-gate #define SF_PHONY 0x20 /* Dummy frame has been sent to close frame */ 245*0Sstevel@tonic-gate #define SF_ZSH_START 0x40 /* */ 246*0Sstevel@tonic-gate /* 247*0Sstevel@tonic-gate * Bit definitions for str_state. 248*0Sstevel@tonic-gate */ 249*0Sstevel@tonic-gate #define STR_CLONE 1 /* This was opened thru clone device */ 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate extern int hz; 252*0Sstevel@tonic-gate #define SIO_WATCHDOG_TICK (2 * hz) /* Two second timeout */ 253*0Sstevel@tonic-gate #define SIO_WATCHDOG_ON (zss->sl_wd_id > 0) /* Is it on? */ 254*0Sstevel@tonic-gate 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate #ifdef __cplusplus 257*0Sstevel@tonic-gate } 258*0Sstevel@tonic-gate #endif 259*0Sstevel@tonic-gate 260*0Sstevel@tonic-gate #endif /* !_SYS_SER_SYNC_H */ 261