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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _SYS_1394_TARGETS_SCSA1394_IMPL_H 287c478bd9Sstevel@tonic-gate #define _SYS_1394_TARGETS_SCSA1394_IMPL_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* 337c478bd9Sstevel@tonic-gate * scsa1394 definitions 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #include <sys/1394/t1394.h> 377c478bd9Sstevel@tonic-gate #include <sys/sbp2/driver.h> 387c478bd9Sstevel@tonic-gate #include <sys/scsi/scsi.h> 397c478bd9Sstevel@tonic-gate #include <sys/cdio.h> 407c478bd9Sstevel@tonic-gate #include <sys/1394/targets/scsa1394/cmd.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #ifdef __cplusplus 437c478bd9Sstevel@tonic-gate extern "C" { 447c478bd9Sstevel@tonic-gate #endif 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* 477c478bd9Sstevel@tonic-gate * each lun uses a worker thread for various deferred processing 487c478bd9Sstevel@tonic-gate */ 497c478bd9Sstevel@tonic-gate typedef enum { 507c478bd9Sstevel@tonic-gate SCSA1394_THR_INIT, /* initial state */ 517c478bd9Sstevel@tonic-gate SCSA1394_THR_RUN, /* thread is running */ 527c478bd9Sstevel@tonic-gate SCSA1394_THR_EXIT /* thread exited */ 537c478bd9Sstevel@tonic-gate } scsa1394_thr_state_t; 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* thread requests */ 567c478bd9Sstevel@tonic-gate enum { 577c478bd9Sstevel@tonic-gate SCSA1394_THREQ_EXIT = 0x1, /* thread has to exit */ 587c478bd9Sstevel@tonic-gate SCSA1394_THREQ_TASK_STATUS = 0x2, /* task status received */ 597c478bd9Sstevel@tonic-gate SCSA1394_THREQ_NUDGE = 0x4, /* nudge SBP-2 layer */ 607c478bd9Sstevel@tonic-gate SCSA1394_THREQ_BUS_RESET = 0x8, 617c478bd9Sstevel@tonic-gate SCSA1394_THREQ_DISCONNECT = 0x10, 627c478bd9Sstevel@tonic-gate SCSA1394_THREQ_RECONNECT = 0x20 637c478bd9Sstevel@tonic-gate }; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate typedef struct scsa1394_thread { 667c478bd9Sstevel@tonic-gate void (*thr_func)(void *); /* function to be run */ 677c478bd9Sstevel@tonic-gate void *thr_arg; /* function argument */ 687c478bd9Sstevel@tonic-gate struct scsa1394_lun *thr_lun; /* lun we belong to */ 697c478bd9Sstevel@tonic-gate scsa1394_thr_state_t thr_state; /* state */ 707c478bd9Sstevel@tonic-gate kcondvar_t thr_cv; /* cv for request wait */ 717c478bd9Sstevel@tonic-gate int thr_req; /* request mask */ 727c478bd9Sstevel@tonic-gate } scsa1394_thread_t; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* 1394 device state */ 767c478bd9Sstevel@tonic-gate typedef enum { 777c478bd9Sstevel@tonic-gate SCSA1394_DEV_INIT = 0, 787c478bd9Sstevel@tonic-gate SCSA1394_DEV_ONLINE, 797c478bd9Sstevel@tonic-gate SCSA1394_DEV_BUS_RESET, 807c478bd9Sstevel@tonic-gate SCSA1394_DEV_DISCONNECTED 817c478bd9Sstevel@tonic-gate } scsa1394_dev_state_t; 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate enum { SCSA1394_STAT_NCMD_LAST = 8 }; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* per-lun statistics */ 867c478bd9Sstevel@tonic-gate typedef struct scsa1394_lun_stat { 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * ring buffer of the last N failed commands. stat_cmd_fail_last_idx 897c478bd9Sstevel@tonic-gate * is an index into stat_cmd_fail_last the array and points to the 907c478bd9Sstevel@tonic-gate * entry to be written next. The first 16 bytes are CDB bytes, 917c478bd9Sstevel@tonic-gate * the last 8 bytes are a timestamp (lbolt). 927c478bd9Sstevel@tonic-gate */ 937c478bd9Sstevel@tonic-gate uint64_t stat_cmd_last_fail[SCSA1394_STAT_NCMD_LAST][3]; 947c478bd9Sstevel@tonic-gate int stat_cmd_last_fail_idx; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate uint_t stat_cmd_cnt; /* # of commands submitted */ 977c478bd9Sstevel@tonic-gate uint_t stat_cmd_buf_max_nsegs; 98f2b7ce3eSartem uint_t stat_cmd_buf_dma_partial; 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* 1017c478bd9Sstevel@tonic-gate * errors 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate uint_t stat_err_pkt_kmem_alloc; 1047c478bd9Sstevel@tonic-gate uint_t stat_err_cmd_cdb_dmem_alloc; 1057c478bd9Sstevel@tonic-gate uint_t stat_err_cmd_cdb_dbind; 1067c478bd9Sstevel@tonic-gate uint_t stat_err_cmd_cdb_addr_alloc; 1077c478bd9Sstevel@tonic-gate uint_t stat_err_cmd_buf_dbind; 1087c478bd9Sstevel@tonic-gate uint_t stat_err_cmd_buf_addr_alloc; 1097c478bd9Sstevel@tonic-gate uint_t stat_err_cmd_pt_kmem_alloc; 1107c478bd9Sstevel@tonic-gate uint_t stat_err_cmd_pt_dmem_alloc; 1117c478bd9Sstevel@tonic-gate uint_t stat_err_cmd_pt_addr_alloc; 1127c478bd9Sstevel@tonic-gate uint_t stat_err_status_tran_err; 1137c478bd9Sstevel@tonic-gate uint_t stat_err_status_conv; 1147c478bd9Sstevel@tonic-gate uint_t stat_err_status_resp; 1157c478bd9Sstevel@tonic-gate } scsa1394_lun_stat_t; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* logical unit */ 1187c478bd9Sstevel@tonic-gate typedef struct scsa1394_lun { 1197c478bd9Sstevel@tonic-gate kmutex_t l_mutex; /* structure lock */ 1207c478bd9Sstevel@tonic-gate struct scsa1394_state *l_sp; /* soft state */ 1217c478bd9Sstevel@tonic-gate sbp2_lun_t *l_lun; /* SBP2 lun */ 1227c478bd9Sstevel@tonic-gate sbp2_ses_t *l_ses; /* login session */ 1237c478bd9Sstevel@tonic-gate dev_info_t *l_cdip; /* child devinfo */ 1247c478bd9Sstevel@tonic-gate scsa1394_thread_t l_worker_thread; /* worker thread */ 1257c478bd9Sstevel@tonic-gate ddi_softintr_t l_softintr_id; /* soft interrupt */ 1267c478bd9Sstevel@tonic-gate boolean_t l_softintr_triggered; /* trigger indicator */ 1277c478bd9Sstevel@tonic-gate int l_softintr_req; /* soft intr request mask */ 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* workarounds */ 1307c478bd9Sstevel@tonic-gate int l_lba_size; /* LBA size */ 1317c478bd9Sstevel@tonic-gate int l_dtype_orig; /* original DTYPE value */ 1327c478bd9Sstevel@tonic-gate int l_rmb_orig; /* original RMB value */ 1337c478bd9Sstevel@tonic-gate int l_start_stop_fail_cnt; /* start/stop failures */ 1347c478bd9Sstevel@tonic-gate boolean_t l_start_stop_fake; /* fake start/stop unit */ 1357c478bd9Sstevel@tonic-gate int l_mode_sense_fail_cnt; /* mode sense failures */ 1367c478bd9Sstevel@tonic-gate boolean_t l_mode_sense_fake; /* fake mode sense command */ 1377c478bd9Sstevel@tonic-gate boolean_t l_nosup_tur; 1387c478bd9Sstevel@tonic-gate boolean_t l_nosup_start_stop; 1397c478bd9Sstevel@tonic-gate boolean_t l_nosup_inquiry; 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate struct scsi_inquiry l_fake_inq; 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate scsa1394_lun_stat_t l_stat; /* statistics */ 1447c478bd9Sstevel@tonic-gate } scsa1394_lun_t; 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(scsa1394_lun::l_mutex, scsa1394_lun)) 1477c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", scsa1394_lun::{ 1487c478bd9Sstevel@tonic-gate l_sp l_lun l_ses l_cdip l_worker_thread l_softintr_id 1497c478bd9Sstevel@tonic-gate l_nosup_tur l_nosup_start_stop l_nosup_inquiry })) 1507c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("statistics", scsa1394_lun::l_stat)) 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* l_softintr_req */ 1537c478bd9Sstevel@tonic-gate enum { 1547c478bd9Sstevel@tonic-gate SCSA1394_SOFTINTR_STATUS_RCVD = 0x1, /* task status received */ 1557c478bd9Sstevel@tonic-gate SCSA1394_SOFTINTR_RECONNECT = 0x2 /* perform reconnect */ 1567c478bd9Sstevel@tonic-gate }; 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate /* per-instance statistics */ 1597c478bd9Sstevel@tonic-gate typedef struct scsa1394_inst_stat { 1607c478bd9Sstevel@tonic-gate uint_t stat_bus_reset_cnt; 1617c478bd9Sstevel@tonic-gate uint_t stat_disconnect_cnt; 1627c478bd9Sstevel@tonic-gate uint_t stat_reconnect_cnt; 1637c478bd9Sstevel@tonic-gate /* 1647c478bd9Sstevel@tonic-gate * errors 1657c478bd9Sstevel@tonic-gate */ 1667c478bd9Sstevel@tonic-gate } scsa1394_inst_stat_t; 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate /* per-instance soft state structure */ 1697c478bd9Sstevel@tonic-gate typedef struct scsa1394_state { 1707c478bd9Sstevel@tonic-gate kmutex_t s_mutex; /* structure mutex */ 1717c478bd9Sstevel@tonic-gate dev_info_t *s_dip; /* device information */ 1727c478bd9Sstevel@tonic-gate int s_instance; /* instance number */ 1737c478bd9Sstevel@tonic-gate scsa1394_dev_state_t s_dev_state; /* device state */ 1747c478bd9Sstevel@tonic-gate t1394_handle_t s_t1394_hdl; /* 1394 handle */ 1757c478bd9Sstevel@tonic-gate t1394_attachinfo_t s_attachinfo; /* 1394 attach info */ 1767c478bd9Sstevel@tonic-gate t1394_targetinfo_t s_targetinfo; /* 1394 target info */ 1777c478bd9Sstevel@tonic-gate ddi_callback_id_t s_reset_cb_id; /* reset event cb id */ 1787c478bd9Sstevel@tonic-gate ddi_callback_id_t s_remove_cb_id; /* remove event cb id */ 1797c478bd9Sstevel@tonic-gate ddi_callback_id_t s_insert_cb_id; /* insert event cb id */ 1807c478bd9Sstevel@tonic-gate boolean_t s_event_entered; /* event serialization */ 1817c478bd9Sstevel@tonic-gate kcondvar_t s_event_cv; /* event serialization cv */ 1827c478bd9Sstevel@tonic-gate ddi_dma_attr_t s_buf_dma_attr; /* data buffer DMA attrs */ 1837c478bd9Sstevel@tonic-gate ddi_dma_attr_t s_pt_dma_attr; /* page table DMA attrs */ 1847c478bd9Sstevel@tonic-gate scsi_hba_tran_t *s_tran; /* SCSA HBA tran structure */ 1857c478bd9Sstevel@tonic-gate sbp2_tgt_t *s_tgt; /* SBP-2 target */ 1867c478bd9Sstevel@tonic-gate sbp2_cfgrom_t *s_cfgrom; /* Config ROM */ 1877c478bd9Sstevel@tonic-gate int s_nluns; /* # of logical units */ 1887c478bd9Sstevel@tonic-gate scsa1394_lun_t *s_lun; /* logical units */ 1897c478bd9Sstevel@tonic-gate kmem_cache_t *s_cmd_cache; /* command kmem cache */ 1907c478bd9Sstevel@tonic-gate ddi_taskq_t *s_taskq; /* common taskq for all luns */ 1917c478bd9Sstevel@tonic-gate boolean_t s_symbios; /* need Symbios workaround? */ 1927c478bd9Sstevel@tonic-gate boolean_t s_disconnect_warned; /* disconnect warning */ 1937c478bd9Sstevel@tonic-gate size_t s_totalsec; /* total sectors */ 1947c478bd9Sstevel@tonic-gate size_t s_secsz; /* sector size */ 1957c478bd9Sstevel@tonic-gate scsa1394_inst_stat_t s_stat; /* statistics */ 1967c478bd9Sstevel@tonic-gate } scsa1394_state_t; 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(scsa1394_state::s_mutex, scsa1394_state)) 1997c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", scsa1394_state::{ 2007c478bd9Sstevel@tonic-gate s_dip s_instance s_t1394_hdl s_attachinfo s_reset_cb_id s_remove_cb_id 2017c478bd9Sstevel@tonic-gate s_insert_cb_id s_buf_dma_attr s_pt_dma_attr s_tran s_tgt s_cfgrom 2027c478bd9Sstevel@tonic-gate s_nluns s_lun s_cmd_cache s_taskq s_symbios s_targetinfo 2037c478bd9Sstevel@tonic-gate s_totalsec s_secsz})) 2047c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("statistics", scsa1394_state::s_stat)) 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate _NOTE(LOCK_ORDER(scsa1394_state::s_mutex scsa1394_lun::l_mutex)) 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate /* for sbp2_bus_buf.bb_hdl */ 2097c478bd9Sstevel@tonic-gate typedef struct scsa1394_bus_buf { 2107c478bd9Sstevel@tonic-gate scsa1394_state_t *sbb_state; /* soft state */ 2117c478bd9Sstevel@tonic-gate t1394_addr_handle_t sbb_addr_hdl; /* 1394 address handle */ 2127c478bd9Sstevel@tonic-gate ddi_dma_handle_t sbb_dma_hdl; /* DMA handle */ 2137c478bd9Sstevel@tonic-gate ddi_acc_handle_t sbb_acc_hdl; /* access handle */ 2147c478bd9Sstevel@tonic-gate } scsa1394_bus_buf_t; 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per task", scsa1394_bus_buf)) 217*d291d9f2Sfrits _NOTE(SCHEME_PROTECTS_DATA("dev_info::devi_lock", dev_info::devi_state)) 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate /* various translation macros */ 2207c478bd9Sstevel@tonic-gate #define ADDR2TRAN(ap) ((ap)->a_hba_tran) 2217c478bd9Sstevel@tonic-gate #define TRAN2STATE(hba) ((scsa1394_state_t *)(hba)->tran_hba_private) 2227c478bd9Sstevel@tonic-gate #define ADDR2STATE(ap) (TRAN2STATE(ADDR2TRAN(ap))) 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate #define SCSA1394_NODEID(sp) ((sp)->s_attachinfo.localinfo.local_nodeID) 2257c478bd9Sstevel@tonic-gate #define SCSA1394_BUSGEN(sp) ((sp)->s_attachinfo.localinfo.bus_generation) 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate #define SCSA1394_ORB_SIZE_ROUNDUP(sp, sz) SBP2_ORB_SIZE_ROUNDUP(sp->s_tgt, sz) 2287c478bd9Sstevel@tonic-gate #define SCSA1394_ADDR_SET(sp, var, addr) \ 2297c478bd9Sstevel@tonic-gate SBP2_ADDR_SET(var, addr, SCSA1394_NODEID(sp)) 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate /* macros to calculate LBA for 6/10/12-byte commands */ 2327c478bd9Sstevel@tonic-gate #define SCSA1394_LBA_6BYTE(pkt) \ 2337c478bd9Sstevel@tonic-gate (((pkt)->pkt_cdbp[1] & 0x1f) << 16) + \ 2347c478bd9Sstevel@tonic-gate ((pkt)->pkt_cdbp[2] << 8) + (pkt)->pkt_cdbp[3] 2357c478bd9Sstevel@tonic-gate #define SCSA1394_LEN_6BYTE(pkt) \ 2367c478bd9Sstevel@tonic-gate (pkt)->pkt_cdbp[4] 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate #define SCSA1394_LEN_10BYTE(pkt) \ 2397c478bd9Sstevel@tonic-gate ((pkt)->pkt_cdbp[7] << 8) + (pkt)->pkt_cdbp[8] 2407c478bd9Sstevel@tonic-gate #define SCSA1394_LBA_10BYTE(pkt) \ 2417c478bd9Sstevel@tonic-gate ((pkt)->pkt_cdbp[2] << 24) + ((pkt)->pkt_cdbp[3] << 16) + \ 2427c478bd9Sstevel@tonic-gate ((pkt)->pkt_cdbp[4] << 8) + (pkt)->pkt_cdbp[5] 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate #define SCSA1394_LEN_12BYTE(pkt) \ 2457c478bd9Sstevel@tonic-gate ((pkt)->pkt_cdbp[6] << 24) + ((pkt)->pkt_cdbp[7] << 16) + \ 2467c478bd9Sstevel@tonic-gate ((pkt)->pkt_cdbp[8] << 8) + (pkt)->pkt_cdbp[9] 2477c478bd9Sstevel@tonic-gate #define SCSA1394_LBA_12BYTE(pkt) \ 2487c478bd9Sstevel@tonic-gate ((pkt)->pkt_cdbp[2] << 24) + ((pkt)->pkt_cdbp[3] << 16) + \ 2497c478bd9Sstevel@tonic-gate ((pkt)->pkt_cdbp[4] << 8) + (pkt)->pkt_cdbp[5] 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate /* macro to calculate LEN for SCMD_READ_CD command */ 2527c478bd9Sstevel@tonic-gate #define SCSA1394_LEN_READ_CD(pkt) \ 2537c478bd9Sstevel@tonic-gate (((pkt)->pkt_cdbp[6] << 16) + ((pkt)->pkt_cdbp[7] << 8) + \ 2547c478bd9Sstevel@tonic-gate (pkt)->pkt_cdbp[8]) 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate /* calculate block size for CD-RW writes */ 2577c478bd9Sstevel@tonic-gate #define SCSA1394_CDRW_BLKSZ(bcount, len) ((bcount) / (len)) 2587c478bd9Sstevel@tonic-gate #define SCSA1394_VALID_CDRW_BLKSZ(blksz) \ 2597c478bd9Sstevel@tonic-gate (((blksz) == CDROM_BLK_2048) || ((blksz) == CDROM_BLK_2352) || \ 2607c478bd9Sstevel@tonic-gate ((blksz) == CDROM_BLK_2336) || ((blksz) == CDROM_BLK_2324)) 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate /* black/white list */ 2637c478bd9Sstevel@tonic-gate typedef struct scsa1394_bw_list { 2647c478bd9Sstevel@tonic-gate int vid_match; 2657c478bd9Sstevel@tonic-gate int vid; 2667c478bd9Sstevel@tonic-gate } scsa1394_bw_list_t; 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate /* match type */ 2697c478bd9Sstevel@tonic-gate enum { 2707c478bd9Sstevel@tonic-gate SCSA1394_BW_ONE, 2717c478bd9Sstevel@tonic-gate SCSA1394_BW_ALL 2727c478bd9Sstevel@tonic-gate }; 2737c478bd9Sstevel@tonic-gate 2747c478bd9Sstevel@tonic-gate #define NELEM(a) (sizeof (a) / sizeof (*(a))) 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate /* misc constants */ 2777c478bd9Sstevel@tonic-gate enum { 2787c478bd9Sstevel@tonic-gate SCSA1394_COMPAT_MAX = 1, /* max @ of compatible names */ 2797c478bd9Sstevel@tonic-gate SCSA1394_CLEANUP_LEVEL_MAX = 256, 2807c478bd9Sstevel@tonic-gate SCSA1394_START_STOP_FAIL_MAX = 3, /* max start/stop failures */ 2817c478bd9Sstevel@tonic-gate SCSA1394_MODE_SENSE_FAIL_MAX = 3, /* max mode sense failures */ 2827c478bd9Sstevel@tonic-gate SCSA1394_START_STOP_TIMEOUT_MAX = 30, 2837c478bd9Sstevel@tonic-gate SCSA1394_MAPIN_SIZE_MAX = 512, 2847c478bd9Sstevel@tonic-gate SCSA1394_PROBE_TIMEOUT = 15, /* in seconds */ 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate SCSA1394_DTYPE_RBC = 0x0E 2877c478bd9Sstevel@tonic-gate }; 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate /* SBP-2 routines */ 2917c478bd9Sstevel@tonic-gate int scsa1394_sbp2_attach(scsa1394_state_t *); 2927c478bd9Sstevel@tonic-gate void scsa1394_sbp2_detach(scsa1394_state_t *); 2937c478bd9Sstevel@tonic-gate void scsa1394_sbp2_fake_inquiry(scsa1394_state_t *, struct scsi_inquiry *); 2947c478bd9Sstevel@tonic-gate int scsa1394_sbp2_threads_init(scsa1394_state_t *); 2957c478bd9Sstevel@tonic-gate void scsa1394_sbp2_threads_fini(scsa1394_state_t *); 2967c478bd9Sstevel@tonic-gate int scsa1394_sbp2_get_lun_type(scsa1394_lun_t *); 2977c478bd9Sstevel@tonic-gate int scsa1394_sbp2_login(scsa1394_state_t *, int); 2987c478bd9Sstevel@tonic-gate void scsa1394_sbp2_logout(scsa1394_state_t *, int, boolean_t); 2997c478bd9Sstevel@tonic-gate void scsa1394_sbp2_req(scsa1394_state_t *, int, int); 3007c478bd9Sstevel@tonic-gate void scsa1394_sbp2_disconnect(scsa1394_state_t *); 3017c478bd9Sstevel@tonic-gate void scsa1394_sbp2_seg2pt(scsa1394_lun_t *, scsa1394_cmd_t *); 3027c478bd9Sstevel@tonic-gate void scsa1394_sbp2_cmd2orb(scsa1394_lun_t *, scsa1394_cmd_t *); 3037c478bd9Sstevel@tonic-gate int scsa1394_sbp2_start(scsa1394_lun_t *, scsa1394_cmd_t *); 3047c478bd9Sstevel@tonic-gate void scsa1394_sbp2_nudge(scsa1394_lun_t *); 3057c478bd9Sstevel@tonic-gate int scsa1394_sbp2_reset(scsa1394_lun_t *, int, scsa1394_cmd_t *); 3067c478bd9Sstevel@tonic-gate void scsa1394_sbp2_flush_cmds(scsa1394_lun_t *, int, int, int); 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate /* HBA public routines */ 3107c478bd9Sstevel@tonic-gate int scsa1394_thr_dispatch(scsa1394_thread_t *); 3117c478bd9Sstevel@tonic-gate void scsa1394_thr_cancel(scsa1394_thread_t *); 3127c478bd9Sstevel@tonic-gate void scsa1394_thr_wake(scsa1394_thread_t *, int); 3137c478bd9Sstevel@tonic-gate void scsa1394_thr_clear_req(scsa1394_thread_t *, int); 3147c478bd9Sstevel@tonic-gate void scsa1394_cmd_status_proc(scsa1394_lun_t *, scsa1394_cmd_t *); 3157c478bd9Sstevel@tonic-gate boolean_t scsa1394_dev_is_online(scsa1394_state_t *); 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate 3187c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3197c478bd9Sstevel@tonic-gate } 3207c478bd9Sstevel@tonic-gate #endif 3217c478bd9Sstevel@tonic-gate 3227c478bd9Sstevel@tonic-gate #endif /* _SYS_1394_TARGETS_SCSA1394_IMPL_H */ 323