2 * Structure and function declarations for the
3 * SCSI Sequential Access Peripheral driver for CAM.
5 * Copyright (c) 1999, 2000 Matthew Jacob
6 * Copyright (c) 2013, 2014, 2015 Spectra Logic Corporation
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions, and the following disclaimer,
14 * without modification, immediately at the beginning of the file.
15 * 2. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #ifndef _SCSI_SCSI_SA_H
34 #define _SCSI_SCSI_SA_H 1
36 #include <sys/cdefs.h>
38 struct scsi_read_block_limits
46 struct scsi_read_block_limits_data
49 #define RBL_GRAN_MASK 0x1F
50 #define RBL_GRAN(rblim) ((rblim)->gran & RBL_GRAN_MASK)
60 #define SARW_FIXED 0x01
65 struct scsi_load_unload
69 #define SLU_IMMED 0x01
71 u_int8_t eot_reten_load;
73 #define SLU_RETEN 0x02
82 #define SREW_IMMED 0x01
100 #define SREW_IMMED 0x01
105 struct scsi_write_filemarks
109 #define SWFMRK_IMMED 0x01
110 #define SWFMRK_WSMK 0x02
111 u_int8_t num_marks[3];
116 * Reserve and release unit have the same exact cdb format, but different
119 struct scsi_reserve_release_unit
122 u_int8_t lun_thirdparty;
123 #define SRRU_LUN_MASK 0xE0
124 #define SRRU_3RD_PARTY 0x10
125 #define SRRU_3RD_SHAMT 1
126 #define SRRU_3RD_MASK 0xE
127 u_int8_t reserved[3];
137 u_int8_t lun_imm_long;
138 #define SE_LUN_MASK 0xE0
141 u_int8_t reserved[3];
148 struct scsi_set_capacity
152 #define SA_SSC_IMMED 0x01
154 u_int8_t cap_proportion[2];
159 * Format tape media. The CDB opcode is the same as the disk-specific
160 * FORMAT UNIT command, but the fields are different inside the CDB. Thus
161 * the reason for a separate definition here.
163 struct scsi_format_medium
167 #define SFM_IMMED 0x01
168 #define SFM_VERIFY 0x02
170 #define SFM_FORMAT_DEFAULT 0x00
171 #define SFM_FORMAT_PARTITION 0x01
172 #define SFM_FORMAT_DEF_PART 0x02
173 #define SFM_FORMAT_MASK 0x0f
178 struct scsi_allow_overwrite
182 u_int8_t allow_overwrite;
183 #define SAO_ALLOW_OVERWRITE_DISABLED 0x00
184 #define SAO_ALLOW_OVERWRITE_CUR_POS 0x01
185 #define SAO_ALLOW_OVERWRITE_FORMAT 0x02
187 u_int8_t logical_id[8];
188 u_int8_t reserved2[3];
193 * Dev specific mode page masks.
195 #define SMH_SA_WP 0x80
196 #define SMH_SA_BUF_MODE_MASK 0x70
197 #define SMH_SA_BUF_MODE_NOBUF 0x00
198 #define SMH_SA_BUF_MODE_SIBUF 0x10 /* Single-Initiator buffering */
199 #define SMH_SA_BUF_MODE_MIBUF 0x20 /* Multi-Initiator buffering */
200 #define SMH_SA_SPEED_MASK 0x0F
201 #define SMH_SA_SPEED_DEFAULT 0x00
204 * Sequential-access specific mode page numbers.
206 #define SA_DEVICE_CONFIGURATION_PAGE 0x10
207 #define SA_MEDIUM_PARTITION_PAGE_1 0x11
208 #define SA_MEDIUM_PARTITION_PAGE_2 0x12
209 #define SA_MEDIUM_PARTITION_PAGE_3 0x13
210 #define SA_MEDIUM_PARTITION_PAGE_4 0x14
211 #define SA_DATA_COMPRESSION_PAGE 0x0f /* SCSI-3 */
214 * Mode page definitions.
217 /* See SCSI-II spec 9.3.3.1 */
218 struct scsi_dev_conf_page {
219 u_int8_t pagecode; /* 0x10 */
220 u_int8_t pagelength; /* 0x0e */
221 u_int8_t byte2; /* CAP, CAF, Active Format */
222 u_int8_t active_partition;
223 u_int8_t wb_full_ratio;
224 u_int8_t rb_empty_ratio;
225 u_int8_t wrdelay_time[2];
227 #define SA_DBR 0x80 /* data buffer recovery */
228 #define SA_BIS 0x40 /* block identifiers supported */
229 #define SA_RSMK 0x20 /* report setmarks */
230 #define SA_AVC 0x10 /* automatic velocity control */
231 #define SA_SOCF_MASK 0x0c /* stop on consecutive formats */
232 #define SA_RBO 0x02 /* recover buffer order */
233 #define SA_REW 0x01 /* report early warning */
236 /* from SCSI-3: SSC-4 Working draft (2/14) 8.3.3 */
237 #define SA_EOD_DEF_MASK 0xe0 /* EOD defined */
238 #define SA_EEG 0x10 /* Enable EOD Generation */
239 #define SA_SEW 0x08 /* Synchronize at Early Warning */
240 #define SA_SOFT_WP 0x04 /* Software Write Protect */
241 #define SA_BAML 0x02 /* Block Address Mode Lock */
242 #define SA_BAM 0x01 /* Block Address Mode */
243 u_int8_t ew_bufsize[3];
244 u_int8_t sel_comp_alg;
245 #define SA_COMP_NONE 0x00
246 #define SA_COMP_DEFAULT 0x01
247 /* the following is 'reserved' in SCSI-2 but is defined in SSC-r22 */
249 #define SA_ASOC_WP 0x04 /* Associated Write Protect */
250 #define SA_PERS_WP 0x02 /* Persistent Write Protect */
251 #define SA_PERM_WP 0x01 /* Permanent Write Protect */
254 /* from SCSI-3: SSC-Rev10 (6/97) */
255 struct scsi_data_compression_page {
256 u_int8_t page_code; /* 0x0f */
257 u_int8_t page_length; /* 0x0e */
258 u_int8_t dce_and_dcc;
259 #define SA_DCP_DCE 0x80 /* Data compression enable */
260 #define SA_DCP_DCC 0x40 /* Data compression capable */
261 u_int8_t dde_and_red;
262 #define SA_DCP_DDE 0x80 /* Data decompression enable */
263 #define SA_DCP_RED_MASK 0x60 /* Report Exception on Decomp. */
264 #define SA_DCP_RED_SHAMT 5
265 #define SA_DCP_RED_0 0x00
266 #define SA_DCP_RED_1 0x20
267 #define SA_DCP_RED_2 0x40
268 u_int8_t comp_algorithm[4];
269 u_int8_t decomp_algorithm[4];
270 u_int8_t reserved[4];
274 struct { u_int8_t pagecode, pagelength; } hdr;
275 struct scsi_dev_conf_page dconf;
276 struct scsi_data_compression_page dcomp;
280 * Control Data Protection subpage. This is as defined in SSC3r03.
282 struct scsi_control_data_prot_subpage {
284 #define SA_CTRL_DP_PAGE_CODE 0x0a
285 uint8_t subpage_code;
286 #define SA_CTRL_DP_SUBPAGE_CODE 0xf0
289 #define SA_CTRL_DP_NO_LBP 0x00
290 #define SA_CTRL_DP_REED_SOLOMON 0x01
291 #define SA_CTRL_DP_METHOD_MAX 0xff
293 #define SA_CTRL_DP_PI_LENGTH_MASK 0x3f
294 #define SA_CTRL_DP_RS_LENGTH 4
296 #define SA_CTRL_DP_LBP_W 0x80
297 #define SA_CTRL_DP_LBP_R 0x40
298 #define SA_CTRL_DP_RBDP 0x20
303 * This is the Read/Write Control mode page used on IBM Enterprise Tape
304 * Drives. They are known as 3592, TS, or Jaguar drives. The SCSI inquiry
305 * data will show a Product ID "03592XXX", where XXX is 'J1A', 'E05' (TS1120),
306 * 'E06' (TS1130), 'E07' (TS1140) or 'E08' (TS1150).
308 * This page definition is current as of the 3592 SCSI Reference v6,
309 * released on December 16th, 2014.
311 struct scsi_tape_ibm_rw_control {
313 #define SA_IBM_RW_CTRL_PAGE_CODE 0x25
315 uint8_t ignore_seq_checks;
316 #define SA_IBM_RW_CTRL_LOC_IGNORE_SEQ 0x04
317 #define SA_IBM_RW_CTRL_SPC_BLK_IGNORE_SEQ 0x02
318 #define SA_IBM_RW_CTRL_SPC_FM_IGNORE_SEQ 0x01
319 uint8_t ignore_data_checks;
320 #define SA_IBM_RW_CTRL_LOC_IGNORE_DATA 0x04
321 #define SA_IBM_RW_CTRL_SPC_BLK_IGNORE_DATA 0x02
322 #define SA_IBM_RW_CTRL_SPC_FM_IGNORE_DATA 0x01
325 #define SA_IBM_RW_CTRL_LEOP_DEFAULT 0x00
326 #define SA_IBM_RW_CTRL_LEOP_MAX_CAP 0x01
327 #define SA_IBM_RW_CTRL_LEOP_CONST_CAP 0x02
330 #define SA_IBM_RW_CTRL_DISABLE_FASTSYNC 0x80
331 #define SA_IBM_RW_CTRL_DISABLE_SKIPSYNC 0x40
332 #define SA_IBM_RW_CTRL_DISABLE_CROSS_EOD 0x08
333 #define SA_IBM_RW_CTRL_DISABLE_CROSS_PERM_ERR 0x04
334 #define SA_IBM_RW_CTRL_REPORT_SEG_EW 0x02
335 #define SA_IBM_RW_CTRL_REPORT_HOUSEKEEPING_ERR 0x01
336 uint8_t default_write_dens_bop_0;
337 uint8_t pending_write_dens_bop_0;
338 uint8_t reserved2[21];
341 struct scsi_tape_read_position {
342 u_int8_t opcode; /* READ_POSITION */
343 u_int8_t byte1; /* set LSB to read hardware block pos */
344 #define SA_RPOS_SHORT_FORM 0x00
345 #define SA_RPOS_SHORT_VENDOR 0x01
346 #define SA_RPOS_LONG_FORM 0x06
347 #define SA_RPOS_EXTENDED_FORM 0x08
348 u_int8_t reserved[5];
353 struct scsi_tape_position_data { /* Short Form */
355 #define SA_RPOS_BOP 0x80 /* Beginning of Partition */
356 #define SA_RPOS_EOP 0x40 /* End of Partition */
357 #define SA_RPOS_BCU 0x20 /* Block Count Unknown (SCSI3) */
358 #define SA_RPOS_BYCU 0x10 /* Byte Count Unknown (SCSI3) */
359 #define SA_RPOS_BPU 0x04 /* Block Position Unknown */
360 #define SA_RPOS_PERR 0x02 /* Position Error (SCSI3) */
361 #define SA_RPOS_BPEW 0x01 /* Beyond Programmable Early Warning */
362 #define SA_RPOS_UNCERTAIN SA_RPOS_BPU
364 u_int8_t reserved[2];
365 u_int8_t firstblk[4];
369 u_int8_t nbufbyte[4];
372 struct scsi_tape_position_long_data {
374 #define SA_RPOS_LONG_BOP 0x80 /* Beginning of Partition */
375 #define SA_RPOS_LONG_EOP 0x40 /* End of Partition */
376 #define SA_RPOS_LONG_MPU 0x08 /* Mark Position Unknown */
377 #define SA_RPOS_LONG_LONU 0x04 /* Logical Object Number Unknown */
378 #define SA_RPOS_LONG_BPEW 0x01 /* Beyond Programmable Early Warning */
379 u_int8_t reserved[3];
380 u_int8_t partition[4];
381 u_int8_t logical_object_num[8];
382 u_int8_t logical_file_num[8];
386 struct scsi_tape_position_ext_data {
388 #define SA_RPOS_EXT_BOP 0x80 /* Beginning of Partition */
389 #define SA_RPOS_EXT_EOP 0x40 /* End of Partition */
390 #define SA_RPOS_EXT_LOCU 0x20 /* Logical Object Count Unknown */
391 #define SA_RPOS_EXT_BYCU 0x10 /* Byte Count Unknown */
392 #define SA_RPOS_EXT_LOLU 0x04 /* Logical Object Location Unknown */
393 #define SA_RPOS_EXT_PERR 0x02 /* Position Error */
394 #define SA_RPOS_EXT_BPEW 0x01 /* Beyond Programmable Early Warning */
398 u_int8_t num_objects[3];
399 u_int8_t first_object[8];
400 u_int8_t last_object[8];
401 u_int8_t bytes_in_buffer[8];
404 struct scsi_tape_locate {
407 #define SA_SPOS_IMMED 0x01
408 #define SA_SPOS_CP 0x02
409 #define SA_SPOS_BT 0x04
412 #define SA_SPOS_MAX_BLK 0xffffffff
418 struct scsi_locate_16 {
421 #define SA_LC_IMMEDIATE 0x01
422 #define SA_LC_CP 0x02
423 #define SA_LC_DEST_TYPE_MASK 0x38
424 #define SA_LC_DEST_TYPE_SHIFT 3
425 #define SA_LC_DEST_OBJECT 0x00
426 #define SA_LC_DEST_FILE 0x01
427 #define SA_LC_DEST_SET 0x02
428 #define SA_LC_DEST_EOD 0x03
430 #define SA_LC_BAM_IMPLICIT 0x00
431 #define SA_LC_BAM_EXPLICIT 0x01
433 u_int8_t logical_id[8];
434 u_int8_t reserved[3];
438 struct scsi_report_density_support {
441 #define SRDS_MEDIA 0x01
442 #define SRDS_MEDIUM_TYPE 0x02
443 u_int8_t reserved[5];
445 #define SRDS_MAX_LENGTH 0xffff
449 struct scsi_density_hdr {
451 u_int8_t reserved[2];
452 u_int8_t descriptor[];
455 struct scsi_density_data {
456 u_int8_t primary_density_code;
457 u_int8_t secondary_density_code;
460 #define SDD_DEFLT 0x20
462 #define SDD_WRTOK 0x80
464 #define SDD_DEFAULT_LENGTH 52
465 u_int8_t bits_per_mm[3];
466 u_int8_t media_width[2];
468 u_int8_t capacity[4];
469 u_int8_t assigning_org[8];
470 u_int8_t density_name[8];
471 u_int8_t description[20];
474 struct scsi_medium_type_data {
475 u_int8_t medium_type;
478 #define SMTD_DEFAULT_LENGTH 52
479 u_int8_t num_density_codes;
480 u_int8_t primary_density_codes[9];
481 u_int8_t media_width[2];
482 u_int8_t medium_length[2];
483 u_int8_t reserved2[2];
484 u_int8_t assigning_org[8];
485 u_int8_t medium_type_name[8];
486 u_int8_t description[20];
490 * Manufacturer-assigned Serial Number VPD page.
491 * Current as of SSC-5r03, 28 September 2016.
493 struct scsi_vpd_mfg_serial_number
497 #define SVPD_MFG_SERIAL_NUMBER_PAGE_CODE 0xB1
498 u_int8_t page_length[2];
499 u_int8_t mfg_serial_num[];
503 * Security Protocol Specific values for the Tape Data Encryption protocol
504 * (0x20) used with SECURITY PROTOCOL IN. See below for values used with
505 * SECURITY PROTOCOL OUT. Current as of SSC4r03.
507 #define TDE_IN_SUPPORT_PAGE 0x0000
508 #define TDE_OUT_SUPPORT_PAGE 0x0001
509 #define TDE_DATA_ENC_CAP_PAGE 0x0010
510 #define TDE_SUPPORTED_KEY_FORMATS_PAGE 0x0011
511 #define TDE_DATA_ENC_MAN_CAP_PAGE 0x0012
512 #define TDE_DATA_ENC_STATUS_PAGE 0x0020
513 #define TDE_NEXT_BLOCK_ENC_STATUS_PAGE 0x0021
514 #define TDE_GET_ENC_MAN_ATTR_PAGE 0x0022
515 #define TDE_RANDOM_NUM_PAGE 0x0030
516 #define TDE_KEY_WRAP_PK_PAGE 0x0031
519 * Tape Data Encryption protocol pages used with SECURITY PROTOCOL IN and
520 * SECURITY PROTOCOL OUT.
523 * Tape Data Encryption In Support page (0x0000).
525 struct tde_in_support_page {
526 uint8_t page_code[2];
527 uint8_t page_length[2];
528 uint8_t page_codes[];
532 * Tape Data Encryption Out Support page (0x0001).
534 struct tde_out_support_page {
535 uint8_t page_code[2];
536 uint8_t page_length[2];
537 uint8_t page_codes[];
541 * Logical block encryption algorithm descriptor. This is reported in the
542 * Data Encryption Capabilities page.
544 struct tde_block_enc_alg_desc {
547 uint8_t desc_length[2];
549 #define TDE_BEA_AVFMV 0x80
550 #define TDE_BEA_SDK_C 0x40
551 #define TDE_BEA_MAC_C 0x20
552 #define TDE_BEA_DELB_C 0x10
553 #define TDE_BEA_DECRYPT_C_MASK 0x0c
554 #define TDE_BEA_DECRYPT_C_EXT 0x0c
555 #define TDE_BEA_DECRYPT_C_HARD 0x08
556 #define TDE_BEA_DECRYPT_C_SOFT 0x04
557 #define TDE_BEA_DECRYPT_C_NO_CAP 0x00
558 #define TDE_BEA_ENCRYPT_C_MASK 0x03
559 #define TDE_BEA_ENCRYPT_C_EXT 0x03
560 #define TDE_BEA_ENCRYPT_C_HARD 0x02
561 #define TDE_BEA_ENCRYPT_C_SOFT 0x01
562 #define TDE_BEA_ENCRYPT_C_NO_CAP 0x00
564 #define TDE_BEA_AVFCLP_MASK 0xc0
565 #define TDE_BEA_AVFCLP_VALID 0x80
566 #define TDE_BEA_AVFCLP_NOT_VALID 0x40
567 #define TDE_BEA_AVFCLP_NOT_APP 0x00
568 #define TDE_BEA_NONCE_C_MASK 0x30
569 #define TDE_BEA_NONCE_C_SUPPORTED 0x30
570 #define TDE_BEA_NONCE_C_PROVIDED 0x20
571 #define TDE_BEA_NONCE_C_GENERATED 0x10
572 #define TDE_BEA_NONCE_C_NOT_REQUIRED 0x00
573 #define TDE_BEA_KADF_C 0x08
574 #define TDE_BEA_VCELB_C 0x04
575 #define TDE_BEA_UKADF 0x02
576 #define TDE_BEA_AKADF 0x01
577 uint8_t max_unauth_key_bytes[2];
578 uint8_t max_auth_key_bytes[2];
579 uint8_t lbe_key_size[2];
581 #define TDE_BEA_DKAD_C_MASK 0xc0
582 #define TDE_BEA_DKAD_C_CAPABLE 0xc0
583 #define TDE_BEA_DKAD_C_NOT_ALLOWED 0x80
584 #define TDE_BEA_DKAD_C_REQUIRED 0x40
585 #define TDE_BEA_EEMC_C_MASK 0x30
586 #define TDE_BEA_EEMC_C_ALLOWED 0x20
587 #define TDE_BEA_EEMC_C_NOT_ALLOWED 0x10
588 #define TDE_BEA_EEMC_C_NOT_SPECIFIED 0x00
590 * Raw Decryption Mode Control Capabilities (RDMC_C) field. The
591 * descriptions are too complex to represent as a simple name.
593 #define TDE_BEA_RDMC_C_MASK 0x0e
594 #define TDE_BEA_RDMC_C_MODE_7 0x0e
595 #define TDE_BEA_RDMC_C_MODE_6 0x0c
596 #define TDE_BEA_RDMC_C_MODE_5 0x0a
597 #define TDE_BEA_RDMC_C_MODE_4 0x08
598 #define TDE_BEA_RDMC_C_MODE_1 0x02
599 #define TDE_BEA_EAREM 0x01
601 #define TDE_BEA_MAX_EEDKS_MASK 0x0f
602 uint8_t msdk_count[2];
603 uint8_t max_eedk_size[2];
604 uint8_t reserved2[2];
605 uint8_t security_algo_code[4];
609 * Data Encryption Capabilities page (0x0010).
611 struct tde_data_enc_cap_page {
612 uint8_t page_code[2];
615 #define DATA_ENC_CAP_EXTDECC_MASK 0x0c
616 #define DATA_ENC_CAP_EXTDECC_NOT_REPORTED 0x00
617 #define DATA_ENC_CAP_EXTDECC_NOT_CAPABLE 0x04
618 #define DATA_ENC_CAP_EXTDECC_CAPABLE 0x08
619 #define DATA_ENC_CAP_CFG_P_MASK 0x03
620 #define DATA_ENC_CAP_CFG_P_NOT_REPORTED 0x00
621 #define DATA_ENC_CAP_CFG_P_ALLOWED 0x01
622 #define DATA_ENC_CAP_CFG_P_NOT_ALLOWED 0x02
623 uint8_t reserved[15];
624 struct tde_block_enc_alg_desc alg_descs[];
628 * Tape Data Encryption Supported Key Formats page (0x0011).
630 struct tde_supported_key_formats_page {
631 uint8_t page_code[2];
632 uint8_t page_length[2];
633 uint8_t key_formats_list[];
637 * Tape Data Encryption Management Capabilities page (0x0012).
639 struct tde_data_enc_man_cap_page {
640 uint8_t page_code[2];
641 uint8_t page_length[2];
643 #define TDE_DEMC_LOCK_C 0x01
645 #define TDE_DEMC_CKOD_C 0x04
646 #define TDE_DEMC_CKORP_C 0x02
647 #define TDE_DEMC_CKORL_C 0x01
650 #define TDE_DEMC_AITN_C 0x04
651 #define TDE_DEMC_LOCAL_C 0x02
652 #define TDE_DEMC_PUBLIC_C 0x01
653 uint8_t reserved2[8];
657 * Tape Data Encryption Status Page (0x0020).
659 struct tde_data_enc_status_page {
660 uint8_t page_code[2];
661 uint8_t page_length[2];
663 #define TDE_DES_IT_NEXUS_SCOPE_MASK 0xe0
664 #define TDE_DES_LBE_SCOPE_MASK 0x07
665 uint8_t encryption_mode;
666 uint8_t decryption_mode;
668 uint8_t key_instance_counter[4];
670 #define TDE_DES_PARAM_CTRL_MASK 0x70
671 #define TDE_DES_PARAM_CTRL_MGMT 0x40
672 #define TDE_DES_PARAM_CTRL_CHANGER 0x30
673 #define TDE_DES_PARAM_CTRL_DRIVE 0x20
674 #define TDE_DES_PARAM_CTRL_EXT 0x10
675 #define TDE_DES_PARAM_CTRL_NOT_REPORTED 0x00
676 #define TDE_DES_VCELB 0x08
677 #define TDE_DES_CEEMS_MASK 0x06
678 #define TDE_DES_RDMD 0x01
679 uint8_t enc_params_kad_format;
680 uint8_t asdk_count[2];
682 uint8_t key_assoc_data_desc[];
686 * Tape Data Encryption Next Block Encryption Status page (0x0021).
688 struct tde_next_block_enc_status_page {
689 uint8_t page_code[2];
690 uint8_t page_length[2];
691 uint8_t logical_obj_number[8];
693 #define TDE_NBES_COMP_STATUS_MASK 0xf0
694 #define TDE_NBES_COMP_INCAPABLE 0x00
695 #define TDE_NBES_COMP_NOT_YET 0x10
696 #define TDE_NBES_COMP_NOT_A_BLOCK 0x20
697 #define TDE_NBES_COMP_NOT_COMPRESSED 0x30
698 #define TDE_NBES_COMP_COMPRESSED 0x40
699 #define TDE_NBES_ENC_STATUS_MASK 0x0f
700 #define TDE_NBES_ENC_INCAPABLE 0x00
701 #define TDE_NBES_ENC_NOT_YET 0x01
702 #define TDE_NBES_ENC_NOT_A_BLOCK 0x02
703 #define TDE_NBES_ENC_NOT_ENCRYPTED 0x03
704 #define TDE_NBES_ENC_ALG_NOT_SUPPORTED 0x04
705 #define TDE_NBES_ENC_SUPPORTED_ALG 0x05
706 #define TDE_NBES_ENC_NO_KEY 0x06
709 #define TDE_NBES_EMES 0x02
710 #define TDE_NBES_RDMDS 0x01
711 uint8_t next_block_kad_format;
712 uint8_t key_assoc_data_desc[];
716 * Tape Data Encryption Get Encryption Management Attributes page (0x0022).
718 struct tde_get_enc_man_attr_page {
719 uint8_t page_code[2];
722 #define TDE_GEMA_CAOD 0x01
723 uint8_t page_length[2];
724 uint8_t enc_mgmt_attr_desc[];
728 * Tape Data Encryption Random Number page (0x0030).
730 struct tde_random_num_page {
731 uint8_t page_code[2];
732 uint8_t page_length[2];
733 uint8_t random_number[32];
737 * Tape Data Encryption Device Server Key Wrapping Public Key page (0x0031).
739 struct tde_key_wrap_pk_page {
740 uint8_t page_code[2];
741 uint8_t page_length[2];
742 uint8_t public_key_type[4];
743 uint8_t public_key_format[4];
744 uint8_t public_key_length[2];
745 uint8_t public_key[];
749 * Security Protocol Specific values for the Tape Data Encryption protocol
750 * (0x20) used with SECURITY PROTOCOL OUT. See above for values used with
751 * SECURITY PROTOCOL IN. Current as of SSCr03.
753 #define TDE_SET_DATA_ENC_PAGE 0x0010
754 #define TDE_SA_ENCAP_PAGE 0x0011
755 #define TDE_SET_ENC_MGMT_ATTR_PAGE 0x0022
758 * Tape Data Encryption Set Data Encryption page (0x0010).
760 struct tde_set_data_enc_page {
761 uint8_t page_code[2];
762 uint8_t page_length[2];
764 #define TDE_SDE_SCOPE_MASK 0xe0
765 #define TDE_SDE_SCOPE_ALL_IT_NEXUS 0x80
766 #define TDE_SDE_SCOPE_LOCAL 0x40
767 #define TDE_SDE_SCOPE_PUBLIC 0x00
768 #define TDE_SDE_LOCK 0x01
770 #define TDE_SDE_CEEM_MASK 0xc0
771 #define TDE_SDE_CEEM_ENCRYPT 0xc0
772 #define TDE_SDE_CEEM_EXTERNAL 0x80
773 #define TDE_SDE_CEEM_NO_CHECK 0x40
774 #define TDE_SDE_RDMC_MASK 0x30
775 #define TDE_SDE_RDMC_DISABLED 0x30
776 #define TDE_SDE_RDMC_ENABLED 0x20
777 #define TDE_SDE_RDMC_DEFAULT 0x00
778 #define TDE_SDE_SDK 0x08
779 #define TDE_SDE_CKOD 0x04
780 #define TDE_SDE_CKORP 0x02
781 #define TDE_SDE_CKORL 0x01
782 uint8_t encryption_mode;
783 #define TDE_SDE_ENC_MODE_DISABLE 0x00
784 #define TDE_SDE_ENC_MODE_EXTERNAL 0x01
785 #define TDE_SDE_ENC_MODE_ENCRYPT 0x02
786 uint8_t decryption_mode;
787 #define TDE_SDE_DEC_MODE_DISABLE 0x00
788 #define TDE_SDE_DEC_MODE_RAW 0x01
789 #define TDE_SDE_DEC_MODE_DECRYPT 0x02
790 #define TDE_SDE_DEC_MODE_MIXED 0x03
792 uint8_t lbe_key_format;
793 #define TDE_SDE_KEY_PLAINTEXT 0x00
794 #define TDE_SDE_KEY_VENDOR_SPEC 0x01
795 #define TDE_SDE_KEY_PUBLIC_WRAP 0x02
796 #define TDE_SDE_KEY_ESP_SCSI 0x03
798 #define TDE_SDE_KAD_ASCII 0x02
799 #define TDE_SDE_KAD_BINARY 0x01
800 #define TDE_SDE_KAD_UNSPECIFIED 0x00
802 uint8_t lbe_key_length[2];
807 * Used for the Vendor Specific key format (0x01).
809 struct tde_key_format_vendor {
810 uint8_t t10_vendor_id[8];
811 uint8_t vendor_key[];
815 * Used for the public key wrapped format (0x02).
817 struct tde_key_format_public_wrap {
818 uint8_t parameter_set[2];
819 #define TDE_PARAM_SET_RSA2048 0x0000
820 #define TDE_PARAM_SET_ECC521 0x0010
821 uint8_t label_length[2];
826 * Tape Data Encryption SA Encapsulation page (0x0011).
828 struct tde_sa_encap_page {
829 uint8_t page_code[2];
834 * Tape Data Encryption Set Encryption Management Attributes page (0x0022).
836 struct tde_set_enc_mgmt_attr_page {
837 uint8_t page_code[2];
840 #define TDE_SEMA_CAOD 0x01
841 uint8_t page_length[2];
846 * Tape Data Encryption descriptor format.
847 * SSC4r03 Section 8.5.4.2.1 Table 197
849 struct tde_data_enc_desc {
850 uint8_t key_desc_type;
851 #define TDE_KEY_DESC_WK_KAD 0x04
852 #define TDE_KEY_DESC_M_KAD 0x03
853 #define TDE_KEY_DESC_NONCE_VALUE 0x02
854 #define TDE_KEY_DESC_A_KAD 0x01
855 #define TDE_KEY_DESC_U_KAD 0x00
857 #define TDE_KEY_DESC_AUTH_MASK 0x07
858 #define TDE_KEY_DESC_AUTH_FAILED 0x04
859 #define TDE_KEY_DESC_AUTH_SUCCESS 0x03
860 #define TDE_KEY_DESC_AUTH_NO_ATTEMPT 0x02
861 #define TDE_KEY_DESC_AUTH_U_KAD 0x01
862 uint8_t key_desc_length[2];
867 * Wrapped Key descriptor format.
868 * SSC4r03 Section 8.5.4.3.1 Table 200
870 struct tde_wrapped_key_desc {
871 uint8_t wrapped_key_type;
872 #define TDE_WRAP_KEY_DESC_LENGTH 0x04
873 #define TDE_WRAP_KEY_DESC_IDENT 0x03
874 #define TDE_WRAP_KEY_DESC_INFO 0x02
875 #define TDE_WRAP_KEY_DESC_ENTITY_ID 0x01
876 #define TDE_WRAP_KEY_DESC_DEVICE_ID 0x00
878 uint8_t wrapped_desc_length[2];
879 uint8_t wrapped_desc[];
883 * Encryption management attributes descriptor format.
884 * SSC4r03 Section 8.5.4.4.1 Table 202
886 struct tde_enc_mgmt_attr_desc {
887 uint8_t enc_mgmt_attr_type[2];
888 #define TDE_EMAD_DESIRED_KEY_MGR_OP 0x0000
889 #define TDE_EMAD_LOG_BLOCK_ENC_KEY_CRIT 0x0001
890 #define TDE_EMAD_LOG_BLOCK_ENC_KEY_WRAP 0x0002
893 #define TDE_EMAD_CRIT 0x80
894 uint8_t attr_length[2];
895 uint8_t attributes[];
896 #define TDE_EMAD_DESIRED_KEY_CREATE 0x0001
897 #define TDE_EMAD_DESIRED_KEY_RESOLVE 0x0002
901 * Logical block encryption key selection criteria descriptor format.
902 * SSC4r03 Section 8.5.4.4.3.1 Table 206
904 struct tde_lb_enc_key_sel_desc {
905 uint8_t lbe_key_sel_crit_type[2];
907 * The CRIT bit is the top bit of the first byte of the type.
909 #define TDE_LBE_KEY_SEL_CRIT 0x80
910 #define TDE_LBE_KEY_SEL_ALGO 0x0001
911 #define TDE_LBE_KEY_SEL_ID 0x0002
912 uint8_t lbe_key_sel_crit_length[2];
913 uint8_t lbe_key_sel_crit[];
917 * Logical block encryption key wrapping attribute descriptor format.
918 * SSC4r03 Section 8.5.4.4.4.1 Table 209
920 struct tde_lb_enc_key_wrap_desc {
921 uint8_t lbe_key_wrap_type[2];
923 * The CRIT bit is the top bit of the first byte of the type.
925 #define TDE_LBE_KEY_WRAP_CRIT 0x80
926 #define TDE_LBE_KEY_WRAP_KEKS 0x0001
927 uint8_t lbe_key_wrap_length[2];
928 uint8_t lbe_key_wrap_attr[];
935 #define FORMAT_MEDIUM 0x04
936 #define READ_BLOCK_LIMITS 0x05
938 #define SA_WRITE 0x0A
939 #define SET_CAPACITY 0x0B
940 #define WRITE_FILEMARKS 0x10
942 #define RESERVE_UNIT 0x16
943 #define RELEASE_UNIT 0x17
945 #define LOAD_UNLOAD 0x1B
947 #define READ_POSITION 0x34
948 #define REPORT_DENSITY_SUPPORT 0x44
949 #define ALLOW_OVERWRITE 0x82
950 #define LOCATE_16 0x92
953 * Tape specific density codes- only enough of them here to recognize
954 * some specific older units so we can choose 2FM@EOD or FIXED blocksize
957 #define SCSI_DENSITY_HALFINCH_800 0x01
958 #define SCSI_DENSITY_HALFINCH_1600 0x02
959 #define SCSI_DENSITY_HALFINCH_6250 0x03
960 #define SCSI_DENSITY_HALFINCH_6250C 0xC3 /* HP Compressed 6250 */
961 #define SCSI_DENSITY_QIC_11_4TRK 0x04
962 #define SCSI_DENSITY_QIC_11_9TRK 0x84 /* Vendor Unique Emulex */
963 #define SCSI_DENSITY_QIC_24 0x05
964 #define SCSI_DENSITY_HALFINCH_PE 0x06
965 #define SCSI_DENSITY_QIC_120 0x0f
966 #define SCSI_DENSITY_QIC_150 0x10
967 #define SCSI_DENSITY_QIC_525_320 0x11
968 #define SCSI_DENSITY_QIC_1320 0x12
969 #define SCSI_DENSITY_QIC_2GB 0x22
970 #define SCSI_DENSITY_QIC_4GB 0x26
971 #define SCSI_DENSITY_QIC_3080 0x29
974 void scsi_read_block_limits(struct ccb_scsiio *, u_int32_t,
975 void (*cbfcnp)(struct cam_periph *, union ccb *),
976 u_int8_t, struct scsi_read_block_limits_data *,
977 u_int8_t , u_int32_t);
979 void scsi_sa_read_write(struct ccb_scsiio *csio, u_int32_t retries,
980 void (*cbfcnp)(struct cam_periph *, union ccb *),
981 u_int8_t tag_action, int readop, int sli,
982 int fixed, u_int32_t length, u_int8_t *data_ptr,
983 u_int32_t dxfer_len, u_int8_t sense_len,
986 void scsi_rewind(struct ccb_scsiio *csio, u_int32_t retries,
987 void (*cbfcnp)(struct cam_periph *, union ccb *),
988 u_int8_t tag_action, int immediate, u_int8_t sense_len,
991 void scsi_space(struct ccb_scsiio *csio, u_int32_t retries,
992 void (*cbfcnp)(struct cam_periph *, union ccb *),
993 u_int8_t tag_action, scsi_space_code code,
994 u_int32_t count, u_int8_t sense_len, u_int32_t timeout);
996 void scsi_load_unload(struct ccb_scsiio *csio, u_int32_t retries,
997 void (*cbfcnp)(struct cam_periph *, union ccb *),
998 u_int8_t tag_action, int immediate, int eot,
999 int reten, int load, u_int8_t sense_len,
1002 void scsi_write_filemarks(struct ccb_scsiio *csio, u_int32_t retries,
1003 void (*cbfcnp)(struct cam_periph *, union ccb *),
1004 u_int8_t tag_action, int immediate, int setmark,
1005 u_int32_t num_marks, u_int8_t sense_len,
1008 void scsi_reserve_release_unit(struct ccb_scsiio *csio, u_int32_t retries,
1009 void (*cbfcnp)(struct cam_periph *,
1010 union ccb *), u_int8_t tag_action,
1011 int third_party, int third_party_id,
1012 u_int8_t sense_len, u_int32_t timeout,
1015 void scsi_erase(struct ccb_scsiio *csio, u_int32_t retries,
1016 void (*cbfcnp)(struct cam_periph *, union ccb *),
1017 u_int8_t tag_action, int immediate, int long_erase,
1018 u_int8_t sense_len, u_int32_t timeout);
1020 void scsi_data_comp_page(struct scsi_data_compression_page *page,
1021 u_int8_t dce, u_int8_t dde, u_int8_t red,
1022 u_int32_t comp_algorithm,
1023 u_int32_t decomp_algorithm);
1025 void scsi_read_position(struct ccb_scsiio *csio, u_int32_t retries,
1026 void (*cbfcnp)(struct cam_periph *, union ccb *),
1027 u_int8_t tag_action, int hardsoft,
1028 struct scsi_tape_position_data *sbp,
1029 u_int8_t sense_len, u_int32_t timeout);
1030 void scsi_read_position_10(struct ccb_scsiio *csio, u_int32_t retries,
1031 void (*cbfcnp)(struct cam_periph *, union ccb *),
1032 u_int8_t tag_action, int service_action,
1033 u_int8_t *data_ptr, u_int32_t length,
1034 u_int32_t sense_len, u_int32_t timeout);
1036 void scsi_set_position(struct ccb_scsiio *csio, u_int32_t retries,
1037 void (*cbfcnp)(struct cam_periph *, union ccb *),
1038 u_int8_t tag_action, int hardsoft, u_int32_t blkno,
1039 u_int8_t sense_len, u_int32_t timeout);
1041 void scsi_locate_10(struct ccb_scsiio *csio, u_int32_t retries,
1042 void (*cbfcnp)(struct cam_periph *, union ccb *),
1043 u_int8_t tag_action, int immed, int cp, int hard,
1044 int64_t partition, u_int32_t block_address,
1045 int sense_len, u_int32_t timeout);
1047 void scsi_locate_16(struct ccb_scsiio *csio, u_int32_t retries,
1048 void (*cbfcnp)(struct cam_periph *, union ccb *),
1049 u_int8_t tag_action, int immed, int cp,
1050 u_int8_t dest_type, int bam, int64_t partition,
1051 u_int64_t logical_id, int sense_len,
1054 void scsi_report_density_support(struct ccb_scsiio *csio, u_int32_t retries,
1055 void (*cbfcnp)(struct cam_periph *,
1057 u_int8_t tag_action, int media,
1058 int medium_type, u_int8_t *data_ptr,
1059 u_int32_t length, u_int32_t sense_len,
1062 void scsi_set_capacity(struct ccb_scsiio *csio, u_int32_t retries,
1063 void (*cbfcnp)(struct cam_periph *, union ccb *),
1064 u_int8_t tag_action, int byte1, u_int32_t proportion,
1065 u_int32_t sense_len, u_int32_t timeout);
1067 void scsi_format_medium(struct ccb_scsiio *csio, u_int32_t retries,
1068 void (*cbfcnp)(struct cam_periph *, union ccb *),
1069 u_int8_t tag_action, int byte1, int byte2,
1070 u_int8_t *data_ptr, u_int32_t length,
1071 u_int32_t sense_len, u_int32_t timeout);
1073 void scsi_allow_overwrite(struct ccb_scsiio *csio, u_int32_t retries,
1074 void (*cbfcnp)(struct cam_periph *, union ccb *),
1075 u_int8_t tag_action, int allow_overwrite,
1076 int partition, u_int64_t logical_id,
1077 u_int32_t sense_len, u_int32_t timeout);
1081 #endif /* _SCSI_SCSI_SA_H */