2 * Copyright (c) 1998,1999,2000
3 * Traakan, Inc., Los Altos, CA
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice unmodified, this list of conditions, and the following
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #define SMC_MAX_SENSE_DATA 127
40 /* carefully layed out so that 16-byte/line hex dumps look nice */
42 unsigned char completion_status;
43 unsigned char status_byte;
44 unsigned char data_dir;
47 unsigned char cmd[12];
50 unsigned n_data_avail;
54 unsigned char n_sense_data;
55 unsigned char sense_data[SMC_MAX_SENSE_DATA];
58 #define SMCSR_CS_GOOD 0
59 #define SMCSR_CS_FAIL 1
62 #define SMCSR_DD_NONE 0
63 #define SMCSR_DD_IN 1 /* adapter->app */
64 #define SMCSR_DD_OUT 2 /* app->adapter */
68 struct smc_volume_tag {
69 unsigned char volume_id[32];
70 unsigned short volume_seq;
75 struct smc_element_address_assignment {
76 unsigned mte_addr; /* media transport element */
79 unsigned se_addr; /* storage element */
82 unsigned iee_addr; /* import/export element */
85 unsigned dte_addr; /* data transfer element */
90 #define SMC_ELEM_TYPE_ALL 0
91 #define SMC_ELEM_TYPE_MTE 1
92 #define SMC_ELEM_TYPE_SE 2
93 #define SMC_ELEM_TYPE_IEE 3
94 #define SMC_ELEM_TYPE_DTE 4
96 struct smc_element_descriptor {
97 unsigned char element_type_code;
98 unsigned short element_address;
100 /* Flags, use SCSI spec names for convenience */
101 unsigned PVolTag : 1; /* MSID primary vol tag info present */
102 unsigned AVolTag : 1; /* MSID alternate vol tag present */
103 unsigned InEnab : 1; /* --I- supports import */
104 unsigned ExEnab : 1; /* --I- supports export */
105 unsigned Access : 1; /* -SID access by a MTE allowed */
106 unsigned Except : 1; /* MSID element in abnormal state */
107 unsigned ImpExp : 1; /* --I- placed by operator */
108 unsigned Full : 1; /* MSID contains a unit of media */
109 unsigned Not_bus : 1; /* ---D if ID_valid, not same bus */
110 unsigned ID_valid: 1; /* ---D scsi_sid valid */
111 unsigned LU_valid: 1; /* ---D scsi_lun valid */
112 unsigned SValid : 1; /* MSID src_se_addr and Invert valid */
113 unsigned Invert : 1; /* MSID inverted by MOVE/EXCHANGE */
115 unsigned char asc; /* Additional sense code */
116 unsigned char ascq; /* Additional sense code qualifier */
117 unsigned short src_se_addr; /* if Svalid, last *STORAGE* element */
119 unsigned char scsi_sid; /* if ID_valid, SID of drive */
120 unsigned char scsi_lun; /* if LU_valid, LUN of drive */
122 struct smc_volume_tag primary_vol_tag; /* if PVolTag */
123 struct smc_volume_tag alternate_vol_tag;/* if AVolTag */
128 #ifndef SMC_MAX_ELEMENT
129 #define SMC_MAX_ELEMENT 80
132 struct smc_ctrl_block {
133 unsigned char ident[32];
135 unsigned char valid_elem_aa;
136 unsigned char valid_elem_desc;
138 struct smc_element_address_assignment
141 struct smc_element_descriptor
142 elem_desc[SMC_MAX_ELEMENT];
143 unsigned n_elem_desc;
145 struct smc_scsi_req scsi_req;
147 int (*issue_scsi_req)(struct smc_ctrl_block *smc);
150 int dont_ask_for_voltags;
156 extern int smc_inquire (struct smc_ctrl_block *smc);
157 extern int smc_test_unit_ready (struct smc_ctrl_block *smc);
158 extern int smc_get_elem_aa (struct smc_ctrl_block *smc);
159 extern int smc_init_elem_status (struct smc_ctrl_block *smc);
160 extern int smc_read_elem_status (struct smc_ctrl_block *smc);
162 extern int smc_move (struct smc_ctrl_block *smc,
163 unsigned from_addr, unsigned to_addr, int invert,
165 extern int smc_position (struct smc_ctrl_block *smc,
166 unsigned to_addr, int invert);
168 extern int smc_handy_move_to_drive (struct smc_ctrl_block *smc,
169 unsigned from_se_ix);
170 extern int smc_handy_move_from_drive (struct smc_ctrl_block *smc,
173 extern char * smc_elem_type_code_to_str(int code);
175 extern int smc_pp_element_address_assignments (
176 struct smc_element_address_assignment *eaa,
177 int lineno, char *buf);
179 extern int smc_pp_element_descriptor (struct smc_element_descriptor *edp,
180 int lineno, char *ret_buf);