17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52439af76Slh195018 * Common Development and Distribution License (the "License"). 62439af76Slh195018 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22d88e498aSjiang wu - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_SCSI_IMPL_SERVICES_H 277c478bd9Sstevel@tonic-gate #define _SYS_SCSI_IMPL_SERVICES_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 317c478bd9Sstevel@tonic-gate extern "C" { 327c478bd9Sstevel@tonic-gate #endif 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /* 357c478bd9Sstevel@tonic-gate * Implementation services not classified by type 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef _KERNEL 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate struct scsi_key_strings { 417c478bd9Sstevel@tonic-gate int key; 427c478bd9Sstevel@tonic-gate char *message; 437c478bd9Sstevel@tonic-gate }; 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate struct scsi_asq_key_strings { 467c478bd9Sstevel@tonic-gate ushort_t asc; 477c478bd9Sstevel@tonic-gate ushort_t ascq; 487c478bd9Sstevel@tonic-gate char *message; 497c478bd9Sstevel@tonic-gate }; 507c478bd9Sstevel@tonic-gate 511e32c0dcScth int scsi_poll(struct scsi_pkt *); 521e32c0dcScth struct scsi_pkt *get_pktiopb(struct scsi_address *, 537c478bd9Sstevel@tonic-gate caddr_t *datap, int cdblen, int statuslen, 541e32c0dcScth int datalen, int readflag, int (*func)(void)); 551e32c0dcScth void free_pktiopb(struct scsi_pkt *, caddr_t datap, int datalen); 561e32c0dcScth 571e32c0dcScth char *scsi_dname(int dtyp); 581e32c0dcScth char *scsi_rname(uchar_t reason); 591e32c0dcScth char *scsi_mname(uchar_t msg); 601e32c0dcScth char *scsi_cname(uchar_t cmd, char **cmdvec); 611e32c0dcScth char *scsi_cmd_name(uchar_t cmd, struct scsi_key_strings *cmdlist, 627c478bd9Sstevel@tonic-gate char *tmpstr); 631e32c0dcScth char *scsi_sname(uchar_t sense_key); 641e32c0dcScth char *scsi_esname(uint_t sense_key, char *tmpstr); 651e32c0dcScth char *scsi_asc_name(uint_t asc, uint_t ascq, char *tmpstr); 669e1c849eSDavid Zhang - Sun Microsystems - Beijing China 679e1c849eSDavid Zhang - Sun Microsystems - Beijing China void scsi_generic_errmsg(struct scsi_device *devp, char *label, 689e1c849eSDavid Zhang - Sun Microsystems - Beijing China int severity, daddr_t blkno, daddr_t err_blkno, 699e1c849eSDavid Zhang - Sun Microsystems - Beijing China uchar_t cmd_name, struct scsi_key_strings *cmdlist, 709e1c849eSDavid Zhang - Sun Microsystems - Beijing China uint8_t *sensep, struct scsi_asq_key_strings *asc_list, 719e1c849eSDavid Zhang - Sun Microsystems - Beijing China char *(*decode_fru)(struct scsi_device *, char *, int, uchar_t)); 729e1c849eSDavid Zhang - Sun Microsystems - Beijing China 731e32c0dcScth void scsi_vu_errmsg(struct scsi_device *devp, struct scsi_pkt *pktp, 747c478bd9Sstevel@tonic-gate char *drv_name, int severity, daddr_t blkno, daddr_t err_blkno, 751e32c0dcScth struct scsi_key_strings *cmdlist, 761e32c0dcScth struct scsi_extended_sense *sensep, 777c478bd9Sstevel@tonic-gate struct scsi_asq_key_strings *asc_list, 787c478bd9Sstevel@tonic-gate char *(*decode_fru)(struct scsi_device *, char *, int, uchar_t)); 791e32c0dcScth void scsi_errmsg(struct scsi_device *devp, struct scsi_pkt *pkt, 807c478bd9Sstevel@tonic-gate char *label, int severity, daddr_t blkno, daddr_t err_blkno, 811e32c0dcScth struct scsi_key_strings *cmdlist, 821e32c0dcScth struct scsi_extended_sense *sensep); 839e1c849eSDavid Zhang - Sun Microsystems - Beijing China 849e1c849eSDavid Zhang - Sun Microsystems - Beijing China 859e1c849eSDavid Zhang - Sun Microsystems - Beijing China 869e1c849eSDavid Zhang - Sun Microsystems - Beijing China 877c478bd9Sstevel@tonic-gate /*PRINTFLIKE4*/ 881e32c0dcScth void scsi_log(dev_info_t *dev, char *label, 897c478bd9Sstevel@tonic-gate uint_t level, const char *fmt, ...) __KPRINTFLIKE(4); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate extern char *scsi_state_bits; 927c478bd9Sstevel@tonic-gate extern char *sense_keys[NUM_SENSE_KEYS + NUM_IMPL_SENSE_KEYS]; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate #define SCSI_DEBUG 0xDEB00000 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define SCSI_ERR_ALL 0 977c478bd9Sstevel@tonic-gate #define SCSI_ERR_UNKNOWN 1 987c478bd9Sstevel@tonic-gate #define SCSI_ERR_INFO 2 997c478bd9Sstevel@tonic-gate #define SCSI_ERR_RECOVERED 3 1007c478bd9Sstevel@tonic-gate #define SCSI_ERR_RETRYABLE 4 1017c478bd9Sstevel@tonic-gate #define SCSI_ERR_FATAL 5 1027c478bd9Sstevel@tonic-gate #define SCSI_ERR_NONE 6 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate /* 1067c478bd9Sstevel@tonic-gate * Common Capability Strings Array 1077c478bd9Sstevel@tonic-gate */ 1087c478bd9Sstevel@tonic-gate #define SCSI_CAP_DMA_MAX 0 1097c478bd9Sstevel@tonic-gate #define SCSI_CAP_MSG_OUT 1 1107c478bd9Sstevel@tonic-gate #define SCSI_CAP_DISCONNECT 2 1117c478bd9Sstevel@tonic-gate #define SCSI_CAP_SYNCHRONOUS 3 1127c478bd9Sstevel@tonic-gate #define SCSI_CAP_WIDE_XFER 4 1137c478bd9Sstevel@tonic-gate #define SCSI_CAP_PARITY 5 1147c478bd9Sstevel@tonic-gate #define SCSI_CAP_INITIATOR_ID 6 1157c478bd9Sstevel@tonic-gate #define SCSI_CAP_UNTAGGED_QING 7 1167c478bd9Sstevel@tonic-gate #define SCSI_CAP_TAGGED_QING 8 1177c478bd9Sstevel@tonic-gate #define SCSI_CAP_ARQ 9 1187c478bd9Sstevel@tonic-gate #define SCSI_CAP_LINKED_CMDS 10 1197c478bd9Sstevel@tonic-gate #define SCSI_CAP_SECTOR_SIZE 11 1207c478bd9Sstevel@tonic-gate #define SCSI_CAP_TOTAL_SECTORS 12 1217c478bd9Sstevel@tonic-gate #define SCSI_CAP_GEOMETRY 13 1227c478bd9Sstevel@tonic-gate #define SCSI_CAP_RESET_NOTIFICATION 14 1237c478bd9Sstevel@tonic-gate #define SCSI_CAP_QFULL_RETRIES 15 1247c478bd9Sstevel@tonic-gate #define SCSI_CAP_QFULL_RETRY_INTERVAL 16 1257c478bd9Sstevel@tonic-gate #define SCSI_CAP_SCSI_VERSION 17 1267c478bd9Sstevel@tonic-gate #define SCSI_CAP_INTERCONNECT_TYPE 18 1277c478bd9Sstevel@tonic-gate #define SCSI_CAP_LUN_RESET 19 1282439af76Slh195018 #define SCSI_CAP_CDB_LEN 20 12936945f79Smrj #define SCSI_CAP_DMA_MAX_ARCH 21 130*af483cc8Sjianfei wang - Sun Microsystems - Beijing China #define SCSI_CAP_TRAN_LAYER_RETRIES 22 1311e32c0dcScth #define SCSI_CAP_ASCII { \ 1321e32c0dcScth "dma-max", "msg-out", "disconnect", "synchronous", \ 1331e32c0dcScth "wide-xfer", "parity", "initiator-id", "untagged-qing", \ 1341e32c0dcScth "tagged-qing", "auto-rqsense", "linked-cmds", \ 1351e32c0dcScth "sector-size", "total-sectors", "geometry", \ 1361e32c0dcScth "reset-notification", "qfull-retries", \ 1371e32c0dcScth "qfull-retry-interval", "scsi-version", \ 1382439af76Slh195018 "interconnect-type", "lun-reset", \ 139*af483cc8Sjianfei wang - Sun Microsystems - Beijing China "max-cdb-length", "dma-max-arch", \ 140*af483cc8Sjianfei wang - Sun Microsystems - Beijing China "tran-layer-retries", NULL } 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * Definitions used by some capabilities 1447c478bd9Sstevel@tonic-gate */ 1457c478bd9Sstevel@tonic-gate /* SCSI_CAP_SCSI_VERSION */ 1467c478bd9Sstevel@tonic-gate #define SCSI_VERSION_1 1 1477c478bd9Sstevel@tonic-gate #define SCSI_VERSION_2 2 1487c478bd9Sstevel@tonic-gate #define SCSI_VERSION_3 3 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate /* SCSI_CAP_INTERCONNECT_TYPE */ 1517c478bd9Sstevel@tonic-gate #define INTERCONNECT_PARALLEL 1 1527c478bd9Sstevel@tonic-gate #define INTERCONNECT_FIBRE 2 /* PLDA or hard ALPA */ 1537c478bd9Sstevel@tonic-gate #define INTERCONNECT_1394 3 1547c478bd9Sstevel@tonic-gate #define INTERCONNECT_SSA 4 /* -EOLed */ 1557c478bd9Sstevel@tonic-gate #define INTERCONNECT_FABRIC 5 /* soft ALPA or Switch */ 1567c478bd9Sstevel@tonic-gate #define INTERCONNECT_USB 6 1571e32c0dcScth #define INTERCONNECT_ATAPI 7 1581e32c0dcScth #define INTERCONNECT_ISCSI 8 1591e32c0dcScth #define INTERCONNECT_IBSRP 9 1601e32c0dcScth #define INTERCONNECT_SATA 10 161d88e498aSjiang wu - Sun Microsystems - Beijing China #define INTERCONNECT_SAS 11 162d88e498aSjiang wu - Sun Microsystems - Beijing China #define INTERCONNECT_MAX 12 /* Change this appropriately, */ 1638c4f8890Srs135747 /* as new one(s) are added. */ 1648c4f8890Srs135747 /* Is always the last & max. */ 1658c4f8890Srs135747 1668c4f8890Srs135747 /* INTERCONNECT TYPE STRINGS */ 1678c4f8890Srs135747 #define INTERCONNECT_PARALLEL_STR "SPI" 1688c4f8890Srs135747 #define INTERCONNECT_FIBRE_STR "FIBRE" 1698c4f8890Srs135747 #define INTERCONNECT_1394_STR "1394" 1708c4f8890Srs135747 #define INTERCONNECT_SSA_STR "" 1718c4f8890Srs135747 #define INTERCONNECT_FABRIC_STR "FABRIC" 1728c4f8890Srs135747 #define INTERCONNECT_USB_STR "USB" 1738c4f8890Srs135747 #define INTERCONNECT_ATAPI_STR "ATAPI" 1748c4f8890Srs135747 #define INTERCONNECT_ISCSI_STR "iSCSI" 1758c4f8890Srs135747 #define INTERCONNECT_IBSRP_STR "IB" 1768c4f8890Srs135747 #define INTERCONNECT_SATA_STR "SATA" 177d88e498aSjiang wu - Sun Microsystems - Beijing China #define INTERCONNECT_SAS_STR "SAS" 1788c4f8890Srs135747 1791e32c0dcScth #define INTERCONNECT_TYPE_ASCII { \ 1808c4f8890Srs135747 "", \ 1818c4f8890Srs135747 INTERCONNECT_PARALLEL_STR, \ 1828c4f8890Srs135747 INTERCONNECT_FIBRE_STR, \ 1838c4f8890Srs135747 INTERCONNECT_1394_STR, \ 1848c4f8890Srs135747 INTERCONNECT_SSA_STR, \ 1858c4f8890Srs135747 INTERCONNECT_FABRIC_STR, \ 1868c4f8890Srs135747 INTERCONNECT_USB_STR, \ 1878c4f8890Srs135747 INTERCONNECT_ATAPI_STR, \ 1888c4f8890Srs135747 INTERCONNECT_ISCSI_STR, \ 1898c4f8890Srs135747 INTERCONNECT_IBSRP_STR, \ 1908c4f8890Srs135747 INTERCONNECT_SATA_STR, \ 191d88e498aSjiang wu - Sun Microsystems - Beijing China INTERCONNECT_SAS_STR, \ 1928c4f8890Srs135747 NULL \ 1938c4f8890Srs135747 }; 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate /* 1967c478bd9Sstevel@tonic-gate * Compatibility... 1977c478bd9Sstevel@tonic-gate */ 1987c478bd9Sstevel@tonic-gate #define scsi_cmd_decode scsi_cname 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2037c478bd9Sstevel@tonic-gate } 2047c478bd9Sstevel@tonic-gate #endif 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate #endif /* _SYS_SCSI_IMPL_SERVICES_H */ 207