1*1772Sjl139090 /* 2*1772Sjl139090 * CDDL HEADER START 3*1772Sjl139090 * 4*1772Sjl139090 * The contents of this file are subject to the terms of the 5*1772Sjl139090 * Common Development and Distribution License (the "License"). 6*1772Sjl139090 * You may not use this file except in compliance with the License. 7*1772Sjl139090 * 8*1772Sjl139090 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*1772Sjl139090 * or http://www.opensolaris.org/os/licensing. 10*1772Sjl139090 * See the License for the specific language governing permissions 11*1772Sjl139090 * and limitations under the License. 12*1772Sjl139090 * 13*1772Sjl139090 * When distributing Covered Code, include this CDDL HEADER in each 14*1772Sjl139090 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*1772Sjl139090 * If applicable, add the following below this CDDL HEADER, with the 16*1772Sjl139090 * fields enclosed by brackets "[]" replaced with your own identifying 17*1772Sjl139090 * information: Portions Copyright [yyyy] [name of copyright owner] 18*1772Sjl139090 * 19*1772Sjl139090 * CDDL HEADER END 20*1772Sjl139090 */ 21*1772Sjl139090 /* 22*1772Sjl139090 * All Rights Reserved, Copyright (c) FUJITSU LIMITED 2006 23*1772Sjl139090 */ 24*1772Sjl139090 25*1772Sjl139090 #ifndef _OPLMSU_H 26*1772Sjl139090 #define _OPLMSU_H 27*1772Sjl139090 28*1772Sjl139090 #pragma ident "%Z%%M% %I% %E% SMI" 29*1772Sjl139090 30*1772Sjl139090 #ifdef __cplusplus 31*1772Sjl139090 extern "C" { 32*1772Sjl139090 #endif 33*1772Sjl139090 34*1772Sjl139090 /* ack_flag */ 35*1772Sjl139090 #define ACK_RES 0 36*1772Sjl139090 #define NAK_RES -1 37*1772Sjl139090 38*1772Sjl139090 /* active_flag */ 39*1772Sjl139090 #define ACTIVE_RES 0 40*1772Sjl139090 #define NOT_ACTIVE_RES -1 41*1772Sjl139090 42*1772Sjl139090 /* undefined path number */ 43*1772Sjl139090 #define UNDEFINED -1 44*1772Sjl139090 45*1772Sjl139090 /* sleep and wakeup control flag */ 46*1772Sjl139090 #define CV_WAKEUP 0 47*1772Sjl139090 #define CV_SLEEP 1 48*1772Sjl139090 49*1772Sjl139090 /* write/read control flag */ 50*1772Sjl139090 #define MSU_WRITE_SIDE 0 51*1772Sjl139090 #define MSU_READ_SIDE 1 52*1772Sjl139090 53*1772Sjl139090 /* message priority */ 54*1772Sjl139090 #define MSU_HIGH 1 55*1772Sjl139090 #define MSU_NORM 0 56*1772Sjl139090 57*1772Sjl139090 /* miscellaneous */ 58*1772Sjl139090 #define SUCCESS 0 59*1772Sjl139090 #define FAILURE -1 60*1772Sjl139090 #if !defined(BUSY) /* warning: macro redefined */ 61*1772Sjl139090 #define BUSY -2 62*1772Sjl139090 #endif 63*1772Sjl139090 64*1772Sjl139090 /* timeout interval */ 65*1772Sjl139090 #define MSU_TM_500MS 500000 /* 500ms */ 66*1772Sjl139090 67*1772Sjl139090 /* XON/XOFF code */ 68*1772Sjl139090 #define MSU_XON 0x11 69*1772Sjl139090 #define MSU_XOFF 0x13 70*1772Sjl139090 #define MSU_XON_4 (MSU_XON << 24|MSU_XON << 16|MSU_XON << 8|MSU_XON) 71*1772Sjl139090 #define MSU_XOFF_4 (MSU_XOFF << 24|MSU_XOFF << 16|MSU_XOFF << 8|MSU_XOFF) 72*1772Sjl139090 73*1772Sjl139090 /* main path code used by MSU_CMD_START ioctl */ 74*1772Sjl139090 #define MAINPATHCODE 0x1000 75*1772Sjl139090 #define MSU_OBP_CONSOLE -2 76*1772Sjl139090 77*1772Sjl139090 /* maximum number of minor device number */ 78*1772Sjl139090 #define MAXDEVMINOR 256 79*1772Sjl139090 80*1772Sjl139090 /* node mask */ 81*1772Sjl139090 #define USER_NODE_MASK 0x00000000 /* user control node */ 82*1772Sjl139090 #define META_NODE_MASK 0x00010000 /* meta control node */ 83*1772Sjl139090 84*1772Sjl139090 /* node_flag */ 85*1772Sjl139090 #define MSU_NODE_USER 0 /* user control node */ 86*1772Sjl139090 #define MSU_NODE_META 1 /* meta control node */ 87*1772Sjl139090 88*1772Sjl139090 /* node_flag check macro */ 89*1772Sjl139090 #define MSU_NODE_TYPE(dev) \ 90*1772Sjl139090 (((dev) & (META_NODE_MASK|USER_NODE_MASK)) >> 16) 91*1772Sjl139090 92*1772Sjl139090 /* termio_flag */ 93*1772Sjl139090 #define MSU_TIOS_TCSETS 1 /* TCSETS */ 94*1772Sjl139090 #define MSU_TIOS_MSET 2 /* TIOCMSET */ 95*1772Sjl139090 #define MSU_TIOS_PPS 3 /* TIOCSPPS */ 96*1772Sjl139090 #define MSU_TIOS_WINSZP 4 /* TIOCSWINSZ */ 97*1772Sjl139090 #define MSU_TIOS_SOFTCAR 5 /* TIOCSSOFTCAR */ 98*1772Sjl139090 #define MSU_TIOS_END 6 /* termios end */ 99*1772Sjl139090 100*1772Sjl139090 /* binding name */ 101*1772Sjl139090 #define MSU_CMUCH_FF "pci10cf,138f" 102*1772Sjl139090 #define MSU_CMUCH_DC "pci10cf,1390" 103*1772Sjl139090 #ifdef DEBUG 104*1772Sjl139090 #define MSU_CMUCH_DBG "pci108e,8000" 105*1772Sjl139090 #endif 106*1772Sjl139090 107*1772Sjl139090 /* tty-port# properties */ 108*1772Sjl139090 #define MSU_TTY_PORT_PROP "tty-port#" 109*1772Sjl139090 110*1772Sjl139090 /* board# properties */ 111*1772Sjl139090 #define MSU_BOARD_PROP "board#" 112*1772Sjl139090 113*1772Sjl139090 /* 114*1772Sjl139090 * oplmsu command code 115*1772Sjl139090 */ 116*1772Sjl139090 #define MSU_CMD ('f' << 8) 117*1772Sjl139090 #define MSU_CMD_STOP (MSU_CMD|0x14) 118*1772Sjl139090 #define MSU_CMD_START (MSU_CMD|0x15) 119*1772Sjl139090 #define MSU_CMD_ACTIVE (MSU_CMD|0x1a) 120*1772Sjl139090 121*1772Sjl139090 #define MSU_PATH_ALL (-1) /* path all instruction */ 122*1772Sjl139090 123*1772Sjl139090 /* 124*1772Sjl139090 * oplmsu path status for status member on upper path info table 125*1772Sjl139090 */ 126*1772Sjl139090 #define MSU_PSTAT_EMPTY 0 127*1772Sjl139090 #define MSU_PSTAT_ACTIVE 1 128*1772Sjl139090 #define MSU_PSTAT_STANDBY 2 129*1772Sjl139090 #define MSU_PSTAT_STOP 3 130*1772Sjl139090 #define MSU_PSTAT_FAIL 4 131*1772Sjl139090 #define MSU_PSTAT_DISCON 5 132*1772Sjl139090 #define MSU_PSTAT_ENCAP 6 133*1772Sjl139090 134*1772Sjl139090 /* 135*1772Sjl139090 * oplmsu additional status for traditional_status member on 136*1772Sjl139090 * upper path info table 137*1772Sjl139090 */ 138*1772Sjl139090 #define MSU_UNLINK 0 /* initial state */ 139*1772Sjl139090 #define MSU_EMPTY 1 /* MSU_STAT_EMPTY(00) state */ 140*1772Sjl139090 #define MSU_LINK_NU 2 /* link state(no link ID, no upper path info) */ 141*1772Sjl139090 #define MSU_SETID_NU 3 /* set ID state(link ID, no upper path info) */ 142*1772Sjl139090 #define MSU_MAKE_INST 4 /* create instance node state */ 143*1772Sjl139090 #define MSU_STOP 5 /* MSU_STAT_STOP(03) state */ 144*1772Sjl139090 #define MSU_WSTR_ACK 6 /* wait ack/nak of MSU_CMD_START state */ 145*1772Sjl139090 #define MSU_STANDBY 7 /* MSU_STAT_STANDBY(02) state */ 146*1772Sjl139090 #define MSU_WTCS_ACK 8 /* wait ack/nak of TCSETS state */ 147*1772Sjl139090 #define MSU_WTMS_ACK 9 /* wait ack/nak of TIOCMSET state */ 148*1772Sjl139090 #define MSU_WPPS_ACK 10 /* wait ack/nak of TIOCSPPS state */ 149*1772Sjl139090 #define MSU_WWSZ_ACK 11 /* wait ack/nak of TIOCSWINSZ state */ 150*1772Sjl139090 #define MSU_WCAR_ACK 12 /* wait ack/nak of TIOCSSOFTCAR state */ 151*1772Sjl139090 #define MSU_ACTIVE 13 /* MSU_STAT_ACTIVE(01) state */ 152*1772Sjl139090 #define MSU_WSTP_ACK 14 /* wait ack/nak of MSU_CMD_STOP state */ 153*1772Sjl139090 #define MSU_FAIL 15 /* MSU_STAT_FAIL(04) state */ 154*1772Sjl139090 #define MSU_WCHK_ACK 16 /* wait ack/nak of OPLMSUSELFTEST */ 155*1772Sjl139090 #define MSU_SETID 17 /* set ID state(link ID, upper path info) */ 156*1772Sjl139090 #define MSU_DISCON 18 /* MSU_STAT_DISCON(05) state */ 157*1772Sjl139090 #define MSU_LINK 19 /* link state(no link ID, upper path info) */ 158*1772Sjl139090 #define MSU_WPTH_CHG 20 /* wait ack/nak of OPLMSUPATHCHG state */ 159*1772Sjl139090 160*1772Sjl139090 /* 161*1772Sjl139090 * oplmsu instance status for inst_status member on 162*1772Sjl139090 * upper instance info talbe 163*1772Sjl139090 */ 164*1772Sjl139090 #define INST_STAT_BUSY -1 /* busy */ 165*1772Sjl139090 #define INST_STAT_ONLINE 10 /* online */ 166*1772Sjl139090 #define INST_STAT_OFFLINE 11 /* offline */ 167*1772Sjl139090 #define INST_STAT_UNCONFIGURED 12 /* unconfigured */ 168*1772Sjl139090 169*1772Sjl139090 /* 170*1772Sjl139090 * oplmsu lower path Info table ext status for ext member on 171*1772Sjl139090 * lower path info table 172*1772Sjl139090 */ 173*1772Sjl139090 #define MSU_EXT_NOTUSED -1 /* not used (default) */ 174*1772Sjl139090 #define MSU_EXT_ACTIVE_CANDIDATE -2 /* active path candidate by */ 175*1772Sjl139090 /* MSU_CMD_START */ 176*1772Sjl139090 #define MSU_EXT_VOID -3 /* void status */ 177*1772Sjl139090 178*1772Sjl139090 /* oplmsu/su pathname size */ 179*1772Sjl139090 #define MSU_PATHNAME_SIZE 128 180*1772Sjl139090 181*1772Sjl139090 /* control block(path parameter) */ 182*1772Sjl139090 struct msu_path { 183*1772Sjl139090 int num; /* total number of paths */ 184*1772Sjl139090 int reserved; /* reserved */ 185*1772Sjl139090 }; 186*1772Sjl139090 187*1772Sjl139090 /* control block(device parameter) */ 188*1772Sjl139090 struct msu_dev { 189*1772Sjl139090 dev_info_t *dip; /* pointer to dev_info_t */ 190*1772Sjl139090 }; 191*1772Sjl139090 192*1772Sjl139090 /* serial device control block */ 193*1772Sjl139090 typedef struct serial_devcb { 194*1772Sjl139090 dev_info_t *dip; /* pointer to dev_info_t */ 195*1772Sjl139090 int lsb; /* LSB number */ 196*1772Sjl139090 } ser_devcb_t; 197*1772Sjl139090 198*1772Sjl139090 /* serial device countrl block list */ 199*1772Sjl139090 typedef struct serial_devlist { 200*1772Sjl139090 struct serial_devlist *next; 201*1772Sjl139090 dev_info_t *dip; /* pointer to dev_info_t */ 202*1772Sjl139090 } ser_devl_t; 203*1772Sjl139090 204*1772Sjl139090 /* upper path table */ 205*1772Sjl139090 typedef struct upper_path_table { 206*1772Sjl139090 struct upper_path_table *u_next; 207*1772Sjl139090 struct upper_path_table *u_prev; 208*1772Sjl139090 struct lower_path_table *lpath; 209*1772Sjl139090 int path_no; 210*1772Sjl139090 int reserved; 211*1772Sjl139090 int status; 212*1772Sjl139090 int prev_status; 213*1772Sjl139090 ulong_t traditional_status; 214*1772Sjl139090 ser_devcb_t ser_devcb; 215*1772Sjl139090 } upath_t; 216*1772Sjl139090 217*1772Sjl139090 /* lower path table */ 218*1772Sjl139090 typedef struct lower_path_table { 219*1772Sjl139090 struct lower_path_table *l_next; 220*1772Sjl139090 struct lower_path_table *l_prev; 221*1772Sjl139090 mblk_t *first_lpri_hi; 222*1772Sjl139090 mblk_t *last_lpri_hi; 223*1772Sjl139090 mblk_t *hndl_mp; 224*1772Sjl139090 queue_t *hndl_uqueue; 225*1772Sjl139090 queue_t *lower_queue; 226*1772Sjl139090 queue_t *uwq_queue; 227*1772Sjl139090 struct upper_instance_table *uinst; 228*1772Sjl139090 char *abt_char; 229*1772Sjl139090 struct buf_tbl *rbuftbl; 230*1772Sjl139090 bufcall_id_t rbuf_id; 231*1772Sjl139090 timeout_id_t rtout_id; 232*1772Sjl139090 upath_t *src_upath; 233*1772Sjl139090 long status; 234*1772Sjl139090 int path_no; 235*1772Sjl139090 int link_id; 236*1772Sjl139090 int uwq_flag; 237*1772Sjl139090 int sw_flag; 238*1772Sjl139090 kcondvar_t sw_cv; 239*1772Sjl139090 } lpath_t; 240*1772Sjl139090 241*1772Sjl139090 /* control table */ 242*1772Sjl139090 typedef struct control_table { 243*1772Sjl139090 struct control_table *c_next; 244*1772Sjl139090 struct control_table *c_prev; 245*1772Sjl139090 mblk_t *first_upri_hi; 246*1772Sjl139090 mblk_t *last_upri_hi; 247*1772Sjl139090 queue_t *queue; 248*1772Sjl139090 queue_t *lrq_queue; 249*1772Sjl139090 queue_t *wait_queue; 250*1772Sjl139090 minor_t minor; 251*1772Sjl139090 int node_type; 252*1772Sjl139090 struct buf_tbl *wbuftbl; 253*1772Sjl139090 bufcall_id_t wbuf_id; 254*1772Sjl139090 timeout_id_t wtout_id; 255*1772Sjl139090 int lrq_flag; 256*1772Sjl139090 int sleep_flag; 257*1772Sjl139090 kcondvar_t cvp; 258*1772Sjl139090 } ctrl_t; 259*1772Sjl139090 260*1772Sjl139090 #define MSU_MAX_ABTSLEN 24 /* maximum length for abort sequence */ 261*1772Sjl139090 262*1772Sjl139090 /* upper instance table */ 263*1772Sjl139090 typedef struct upper_instance_table { 264*1772Sjl139090 upath_t *first_upath; 265*1772Sjl139090 upath_t *last_upath; 266*1772Sjl139090 lpath_t *first_lpath; 267*1772Sjl139090 lpath_t *last_lpath; 268*1772Sjl139090 ctrl_t *meta_ctrl; 269*1772Sjl139090 ctrl_t *user_ctrl; 270*1772Sjl139090 queue_t *lower_queue; 271*1772Sjl139090 dev_info_t *msu_dip; 272*1772Sjl139090 int inst_status; 273*1772Sjl139090 int path_num; 274*1772Sjl139090 int reserved[2]; 275*1772Sjl139090 krwlock_t lock; 276*1772Sjl139090 kmutex_t u_lock; 277*1772Sjl139090 kmutex_t l_lock; 278*1772Sjl139090 kmutex_t c_lock; 279*1772Sjl139090 mblk_t *tcsets_p; 280*1772Sjl139090 mblk_t *tiocmset_p; 281*1772Sjl139090 mblk_t *tiocspps_p; 282*1772Sjl139090 mblk_t *tiocswinsz_p; 283*1772Sjl139090 mblk_t *tiocssoftcar_p; 284*1772Sjl139090 char abts[MSU_MAX_ABTSLEN]; 285*1772Sjl139090 } uinst_t; 286*1772Sjl139090 287*1772Sjl139090 /* queue table for bufcall() and timeout() */ 288*1772Sjl139090 struct buf_tbl { 289*1772Sjl139090 queue_t *q; 290*1772Sjl139090 int rw_flag; 291*1772Sjl139090 }; 292*1772Sjl139090 293*1772Sjl139090 294*1772Sjl139090 /* rwlock macro */ 295*1772Sjl139090 #define OPLMSU_RWLOCK_UPGRADE() { \ 296*1772Sjl139090 if (rw_tryupgrade(&oplmsu_uinst->lock) == 0) { \ 297*1772Sjl139090 rw_exit(&oplmsu_uinst->lock); \ 298*1772Sjl139090 rw_enter(&oplmsu_uinst->lock, RW_WRITER); \ 299*1772Sjl139090 } \ 300*1772Sjl139090 } 301*1772Sjl139090 302*1772Sjl139090 #ifdef DEBUG 303*1772Sjl139090 typedef struct tracedata { 304*1772Sjl139090 queue_t *q; 305*1772Sjl139090 mblk_t *mp; 306*1772Sjl139090 char op[3]; 307*1772Sjl139090 uchar_t msg_type; 308*1772Sjl139090 int pathno; 309*1772Sjl139090 int msg_cmd; 310*1772Sjl139090 ulong_t data; 311*1772Sjl139090 } msu_trc_t; 312*1772Sjl139090 313*1772Sjl139090 #define MSU_TRC_USER ('u' << 24|'s' << 16|'e' << 8|'r') 314*1772Sjl139090 #define MSU_TRC_META ('m' << 24|'e' << 16|'t' << 8|'a') 315*1772Sjl139090 316*1772Sjl139090 /* oplmsu_trace_on */ 317*1772Sjl139090 #define MSU_TRACE_OFF 0 318*1772Sjl139090 #define MSU_TRACE_ON 1 319*1772Sjl139090 320*1772Sjl139090 /* oplmsu_debug_mode */ 321*1772Sjl139090 #define MSU_DPRINT_ON 1 /* enable print log */ 322*1772Sjl139090 323*1772Sjl139090 /* op type */ 324*1772Sjl139090 #define MSU_TRC_UI 0 /* upper input */ 325*1772Sjl139090 #define MSU_TRC_UO 1 /* upper output */ 326*1772Sjl139090 #define MSU_TRC_LI 2 /* lower input */ 327*1772Sjl139090 #define MSU_TRC_LO 3 /* lower output */ 328*1772Sjl139090 #define MSU_TRC_OPN 4 /* open */ 329*1772Sjl139090 #define MSU_TRC_CLS 5 /* close */ 330*1772Sjl139090 331*1772Sjl139090 /* trace macro */ 332*1772Sjl139090 #define OPLMSU_TRACE(q, mp, op) { \ 333*1772Sjl139090 if (oplmsu_trace_on == MSU_TRACE_ON) { \ 334*1772Sjl139090 oplmsu_cmn_trace(q, mp, op); \ 335*1772Sjl139090 } \ 336*1772Sjl139090 } 337*1772Sjl139090 338*1772Sjl139090 /* debug print macro */ 339*1772Sjl139090 #define DBG_PRINT(args) { \ 340*1772Sjl139090 if (oplmsu_debug_mode & MSU_DPRINT_ON) { \ 341*1772Sjl139090 cmn_err args; \ 342*1772Sjl139090 } \ 343*1772Sjl139090 } 344*1772Sjl139090 345*1772Sjl139090 #else /* ! DEBUG */ 346*1772Sjl139090 347*1772Sjl139090 /* trace macro */ 348*1772Sjl139090 #define OPLMSU_TRACE(q, mp, op) 349*1772Sjl139090 350*1772Sjl139090 /* debug print macro */ 351*1772Sjl139090 #define DBG_PRINT(args) 352*1772Sjl139090 #endif 353*1772Sjl139090 354*1772Sjl139090 #ifdef __cplusplus 355*1772Sjl139090 } 356*1772Sjl139090 #endif 357*1772Sjl139090 358*1772Sjl139090 #endif /* _OPLMSU_H */ 359