2 * Structure and function declarations for the
3 * SCSI Sequential Access Peripheral driver for CAM.
5 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
7 * Copyright (c) 1999, 2000 Matthew Jacob
8 * Copyright (c) 2013, 2014, 2015 Spectra Logic Corporation
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification, immediately at the beginning of the file.
17 * 2. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #ifndef _SCSI_SCSI_SA_H
36 #define _SCSI_SCSI_SA_H 1
38 #include <sys/cdefs.h>
40 struct scsi_read_block_limits
48 struct scsi_read_block_limits_data
51 #define RBL_GRAN_MASK 0x1F
52 #define RBL_GRAN(rblim) ((rblim)->gran & RBL_GRAN_MASK)
62 #define SARW_FIXED 0x01
67 struct scsi_load_unload
71 #define SLU_IMMED 0x01
73 u_int8_t eot_reten_load;
75 #define SLU_RETEN 0x02
84 #define SREW_IMMED 0x01
102 #define SREW_IMMED 0x01
107 struct scsi_write_filemarks
111 #define SWFMRK_IMMED 0x01
112 #define SWFMRK_WSMK 0x02
113 u_int8_t num_marks[3];
118 * Reserve and release unit have the same exact cdb format, but different
121 struct scsi_reserve_release_unit
124 u_int8_t lun_thirdparty;
125 #define SRRU_LUN_MASK 0xE0
126 #define SRRU_3RD_PARTY 0x10
127 #define SRRU_3RD_SHAMT 1
128 #define SRRU_3RD_MASK 0xE
129 u_int8_t reserved[3];
139 u_int8_t lun_imm_long;
140 #define SE_LUN_MASK 0xE0
143 u_int8_t reserved[3];
150 struct scsi_set_capacity
154 #define SA_SSC_IMMED 0x01
156 u_int8_t cap_proportion[2];
161 * Format tape media. The CDB opcode is the same as the disk-specific
162 * FORMAT UNIT command, but the fields are different inside the CDB. Thus
163 * the reason for a separate definition here.
165 struct scsi_format_medium
169 #define SFM_IMMED 0x01
170 #define SFM_VERIFY 0x02
172 #define SFM_FORMAT_DEFAULT 0x00
173 #define SFM_FORMAT_PARTITION 0x01
174 #define SFM_FORMAT_DEF_PART 0x02
175 #define SFM_FORMAT_MASK 0x0f
180 struct scsi_allow_overwrite
184 u_int8_t allow_overwrite;
185 #define SAO_ALLOW_OVERWRITE_DISABLED 0x00
186 #define SAO_ALLOW_OVERWRITE_CUR_POS 0x01
187 #define SAO_ALLOW_OVERWRITE_FORMAT 0x02
189 u_int8_t logical_id[8];
190 u_int8_t reserved2[3];
195 * Dev specific mode page masks.
197 #define SMH_SA_WP 0x80
198 #define SMH_SA_BUF_MODE_MASK 0x70
199 #define SMH_SA_BUF_MODE_NOBUF 0x00
200 #define SMH_SA_BUF_MODE_SIBUF 0x10 /* Single-Initiator buffering */
201 #define SMH_SA_BUF_MODE_MIBUF 0x20 /* Multi-Initiator buffering */
202 #define SMH_SA_SPEED_MASK 0x0F
203 #define SMH_SA_SPEED_DEFAULT 0x00
206 * Sequential-access specific mode page numbers.
208 #define SA_DEVICE_CONFIGURATION_PAGE 0x10
209 #define SA_MEDIUM_PARTITION_PAGE_1 0x11
210 #define SA_MEDIUM_PARTITION_PAGE_2 0x12
211 #define SA_MEDIUM_PARTITION_PAGE_3 0x13
212 #define SA_MEDIUM_PARTITION_PAGE_4 0x14
213 #define SA_DATA_COMPRESSION_PAGE 0x0f /* SCSI-3 */
216 * Mode page definitions.
219 /* See SCSI-II spec 9.3.3.1 */
220 struct scsi_dev_conf_page {
221 u_int8_t pagecode; /* 0x10 */
222 u_int8_t pagelength; /* 0x0e */
223 u_int8_t byte2; /* CAP, CAF, Active Format */
224 u_int8_t active_partition;
225 u_int8_t wb_full_ratio;
226 u_int8_t rb_empty_ratio;
227 u_int8_t wrdelay_time[2];
229 #define SA_DBR 0x80 /* data buffer recovery */
230 #define SA_BIS 0x40 /* block identifiers supported */
231 #define SA_RSMK 0x20 /* report setmarks */
232 #define SA_AVC 0x10 /* automatic velocity control */
233 #define SA_SOCF_MASK 0x0c /* stop on consecutive formats */
234 #define SA_RBO 0x02 /* recover buffer order */
235 #define SA_REW 0x01 /* report early warning */
238 /* from SCSI-3: SSC-4 Working draft (2/14) 8.3.3 */
239 #define SA_EOD_DEF_MASK 0xe0 /* EOD defined */
240 #define SA_EEG 0x10 /* Enable EOD Generation */
241 #define SA_SEW 0x08 /* Synchronize at Early Warning */
242 #define SA_SOFT_WP 0x04 /* Software Write Protect */
243 #define SA_BAML 0x02 /* Block Address Mode Lock */
244 #define SA_BAM 0x01 /* Block Address Mode */
245 u_int8_t ew_bufsize[3];
246 u_int8_t sel_comp_alg;
247 #define SA_COMP_NONE 0x00
248 #define SA_COMP_DEFAULT 0x01
249 /* the following is 'reserved' in SCSI-2 but is defined in SSC-r22 */
251 #define SA_ASOC_WP 0x04 /* Associated Write Protect */
252 #define SA_PERS_WP 0x02 /* Persistent Write Protect */
253 #define SA_PERM_WP 0x01 /* Permanent Write Protect */
256 /* from SCSI-3: SSC-Rev10 (6/97) */
257 struct scsi_data_compression_page {
258 u_int8_t page_code; /* 0x0f */
259 u_int8_t page_length; /* 0x0e */
260 u_int8_t dce_and_dcc;
261 #define SA_DCP_DCE 0x80 /* Data compression enable */
262 #define SA_DCP_DCC 0x40 /* Data compression capable */
263 u_int8_t dde_and_red;
264 #define SA_DCP_DDE 0x80 /* Data decompression enable */
265 #define SA_DCP_RED_MASK 0x60 /* Report Exception on Decomp. */
266 #define SA_DCP_RED_SHAMT 5
267 #define SA_DCP_RED_0 0x00
268 #define SA_DCP_RED_1 0x20
269 #define SA_DCP_RED_2 0x40
270 u_int8_t comp_algorithm[4];
271 u_int8_t decomp_algorithm[4];
272 u_int8_t reserved[4];
276 struct { u_int8_t pagecode, pagelength; } hdr;
277 struct scsi_dev_conf_page dconf;
278 struct scsi_data_compression_page dcomp;
282 * Control Data Protection subpage. This is as defined in SSC3r03.
284 struct scsi_control_data_prot_subpage {
286 #define SA_CTRL_DP_PAGE_CODE 0x0a
287 uint8_t subpage_code;
288 #define SA_CTRL_DP_SUBPAGE_CODE 0xf0
291 #define SA_CTRL_DP_NO_LBP 0x00
292 #define SA_CTRL_DP_REED_SOLOMON 0x01
293 #define SA_CTRL_DP_METHOD_MAX 0xff
295 #define SA_CTRL_DP_PI_LENGTH_MASK 0x3f
296 #define SA_CTRL_DP_RS_LENGTH 4
298 #define SA_CTRL_DP_LBP_W 0x80
299 #define SA_CTRL_DP_LBP_R 0x40
300 #define SA_CTRL_DP_RBDP 0x20
305 * This is the Read/Write Control mode page used on IBM Enterprise Tape
306 * Drives. They are known as 3592, TS, or Jaguar drives. The SCSI inquiry
307 * data will show a Product ID "03592XXX", where XXX is 'J1A', 'E05' (TS1120),
308 * 'E06' (TS1130), 'E07' (TS1140) or 'E08' (TS1150).
310 * This page definition is current as of the 3592 SCSI Reference v6,
311 * released on December 16th, 2014.
313 struct scsi_tape_ibm_rw_control {
315 #define SA_IBM_RW_CTRL_PAGE_CODE 0x25
317 uint8_t ignore_seq_checks;
318 #define SA_IBM_RW_CTRL_LOC_IGNORE_SEQ 0x04
319 #define SA_IBM_RW_CTRL_SPC_BLK_IGNORE_SEQ 0x02
320 #define SA_IBM_RW_CTRL_SPC_FM_IGNORE_SEQ 0x01
321 uint8_t ignore_data_checks;
322 #define SA_IBM_RW_CTRL_LOC_IGNORE_DATA 0x04
323 #define SA_IBM_RW_CTRL_SPC_BLK_IGNORE_DATA 0x02
324 #define SA_IBM_RW_CTRL_SPC_FM_IGNORE_DATA 0x01
327 #define SA_IBM_RW_CTRL_LEOP_DEFAULT 0x00
328 #define SA_IBM_RW_CTRL_LEOP_MAX_CAP 0x01
329 #define SA_IBM_RW_CTRL_LEOP_CONST_CAP 0x02
332 #define SA_IBM_RW_CTRL_DISABLE_FASTSYNC 0x80
333 #define SA_IBM_RW_CTRL_DISABLE_SKIPSYNC 0x40
334 #define SA_IBM_RW_CTRL_DISABLE_CROSS_EOD 0x08
335 #define SA_IBM_RW_CTRL_DISABLE_CROSS_PERM_ERR 0x04
336 #define SA_IBM_RW_CTRL_REPORT_SEG_EW 0x02
337 #define SA_IBM_RW_CTRL_REPORT_HOUSEKEEPING_ERR 0x01
338 uint8_t default_write_dens_bop_0;
339 uint8_t pending_write_dens_bop_0;
340 uint8_t reserved2[21];
343 struct scsi_tape_read_position {
344 u_int8_t opcode; /* READ_POSITION */
345 u_int8_t byte1; /* set LSB to read hardware block pos */
346 #define SA_RPOS_SHORT_FORM 0x00
347 #define SA_RPOS_SHORT_VENDOR 0x01
348 #define SA_RPOS_LONG_FORM 0x06
349 #define SA_RPOS_EXTENDED_FORM 0x08
350 u_int8_t reserved[5];
355 struct scsi_tape_position_data { /* Short Form */
357 #define SA_RPOS_BOP 0x80 /* Beginning of Partition */
358 #define SA_RPOS_EOP 0x40 /* End of Partition */
359 #define SA_RPOS_BCU 0x20 /* Block Count Unknown (SCSI3) */
360 #define SA_RPOS_BYCU 0x10 /* Byte Count Unknown (SCSI3) */
361 #define SA_RPOS_BPU 0x04 /* Block Position Unknown */
362 #define SA_RPOS_PERR 0x02 /* Position Error (SCSI3) */
363 #define SA_RPOS_BPEW 0x01 /* Beyond Programmable Early Warning */
364 #define SA_RPOS_UNCERTAIN SA_RPOS_BPU
366 u_int8_t reserved[2];
367 u_int8_t firstblk[4];
371 u_int8_t nbufbyte[4];
374 struct scsi_tape_position_long_data {
376 #define SA_RPOS_LONG_BOP 0x80 /* Beginning of Partition */
377 #define SA_RPOS_LONG_EOP 0x40 /* End of Partition */
378 #define SA_RPOS_LONG_MPU 0x08 /* Mark Position Unknown */
379 #define SA_RPOS_LONG_LONU 0x04 /* Logical Object Number Unknown */
380 #define SA_RPOS_LONG_BPEW 0x01 /* Beyond Programmable Early Warning */
381 u_int8_t reserved[3];
382 u_int8_t partition[4];
383 u_int8_t logical_object_num[8];
384 u_int8_t logical_file_num[8];
388 struct scsi_tape_position_ext_data {
390 #define SA_RPOS_EXT_BOP 0x80 /* Beginning of Partition */
391 #define SA_RPOS_EXT_EOP 0x40 /* End of Partition */
392 #define SA_RPOS_EXT_LOCU 0x20 /* Logical Object Count Unknown */
393 #define SA_RPOS_EXT_BYCU 0x10 /* Byte Count Unknown */
394 #define SA_RPOS_EXT_LOLU 0x04 /* Logical Object Location Unknown */
395 #define SA_RPOS_EXT_PERR 0x02 /* Position Error */
396 #define SA_RPOS_EXT_BPEW 0x01 /* Beyond Programmable Early Warning */
400 u_int8_t num_objects[3];
401 u_int8_t first_object[8];
402 u_int8_t last_object[8];
403 u_int8_t bytes_in_buffer[8];
406 struct scsi_tape_locate {
409 #define SA_SPOS_IMMED 0x01
410 #define SA_SPOS_CP 0x02
411 #define SA_SPOS_BT 0x04
414 #define SA_SPOS_MAX_BLK 0xffffffff
420 struct scsi_locate_16 {
423 #define SA_LC_IMMEDIATE 0x01
424 #define SA_LC_CP 0x02
425 #define SA_LC_DEST_TYPE_MASK 0x38
426 #define SA_LC_DEST_TYPE_SHIFT 3
427 #define SA_LC_DEST_OBJECT 0x00
428 #define SA_LC_DEST_FILE 0x01
429 #define SA_LC_DEST_SET 0x02
430 #define SA_LC_DEST_EOD 0x03
432 #define SA_LC_BAM_IMPLICIT 0x00
433 #define SA_LC_BAM_EXPLICIT 0x01
435 u_int8_t logical_id[8];
436 u_int8_t reserved[3];
440 struct scsi_report_density_support {
443 #define SRDS_MEDIA 0x01
444 #define SRDS_MEDIUM_TYPE 0x02
445 u_int8_t reserved[5];
447 #define SRDS_MAX_LENGTH 0xffff
451 struct scsi_density_hdr {
453 u_int8_t reserved[2];
454 u_int8_t descriptor[];
457 struct scsi_density_data {
458 u_int8_t primary_density_code;
459 u_int8_t secondary_density_code;
462 #define SDD_DEFLT 0x20
464 #define SDD_WRTOK 0x80
466 #define SDD_DEFAULT_LENGTH 52
467 u_int8_t bits_per_mm[3];
468 u_int8_t media_width[2];
470 u_int8_t capacity[4];
471 u_int8_t assigning_org[8];
472 u_int8_t density_name[8];
473 u_int8_t description[20];
476 struct scsi_medium_type_data {
477 u_int8_t medium_type;
480 #define SMTD_DEFAULT_LENGTH 52
481 u_int8_t num_density_codes;
482 u_int8_t primary_density_codes[9];
483 u_int8_t media_width[2];
484 u_int8_t medium_length[2];
485 u_int8_t reserved2[2];
486 u_int8_t assigning_org[8];
487 u_int8_t medium_type_name[8];
488 u_int8_t description[20];
492 * Manufacturer-assigned Serial Number VPD page.
493 * Current as of SSC-5r03, 28 September 2016.
495 struct scsi_vpd_mfg_serial_number
499 #define SVPD_MFG_SERIAL_NUMBER_PAGE_CODE 0xB1
500 u_int8_t page_length[2];
501 u_int8_t mfg_serial_num[];
505 * Security Protocol Specific values for the Tape Data Encryption protocol
506 * (0x20) used with SECURITY PROTOCOL IN. See below for values used with
507 * SECURITY PROTOCOL OUT. Current as of SSC4r03.
509 #define TDE_IN_SUPPORT_PAGE 0x0000
510 #define TDE_OUT_SUPPORT_PAGE 0x0001
511 #define TDE_DATA_ENC_CAP_PAGE 0x0010
512 #define TDE_SUPPORTED_KEY_FORMATS_PAGE 0x0011
513 #define TDE_DATA_ENC_MAN_CAP_PAGE 0x0012
514 #define TDE_DATA_ENC_STATUS_PAGE 0x0020
515 #define TDE_NEXT_BLOCK_ENC_STATUS_PAGE 0x0021
516 #define TDE_GET_ENC_MAN_ATTR_PAGE 0x0022
517 #define TDE_RANDOM_NUM_PAGE 0x0030
518 #define TDE_KEY_WRAP_PK_PAGE 0x0031
521 * Tape Data Encryption protocol pages used with SECURITY PROTOCOL IN and
522 * SECURITY PROTOCOL OUT.
525 * Tape Data Encryption In Support page (0x0000).
527 struct tde_in_support_page {
528 uint8_t page_code[2];
529 uint8_t page_length[2];
530 uint8_t page_codes[];
534 * Tape Data Encryption Out Support page (0x0001).
536 struct tde_out_support_page {
537 uint8_t page_code[2];
538 uint8_t page_length[2];
539 uint8_t page_codes[];
543 * Logical block encryption algorithm descriptor. This is reported in the
544 * Data Encryption Capabilities page.
546 struct tde_block_enc_alg_desc {
549 uint8_t desc_length[2];
551 #define TDE_BEA_AVFMV 0x80
552 #define TDE_BEA_SDK_C 0x40
553 #define TDE_BEA_MAC_C 0x20
554 #define TDE_BEA_DELB_C 0x10
555 #define TDE_BEA_DECRYPT_C_MASK 0x0c
556 #define TDE_BEA_DECRYPT_C_EXT 0x0c
557 #define TDE_BEA_DECRYPT_C_HARD 0x08
558 #define TDE_BEA_DECRYPT_C_SOFT 0x04
559 #define TDE_BEA_DECRYPT_C_NO_CAP 0x00
560 #define TDE_BEA_ENCRYPT_C_MASK 0x03
561 #define TDE_BEA_ENCRYPT_C_EXT 0x03
562 #define TDE_BEA_ENCRYPT_C_HARD 0x02
563 #define TDE_BEA_ENCRYPT_C_SOFT 0x01
564 #define TDE_BEA_ENCRYPT_C_NO_CAP 0x00
566 #define TDE_BEA_AVFCLP_MASK 0xc0
567 #define TDE_BEA_AVFCLP_VALID 0x80
568 #define TDE_BEA_AVFCLP_NOT_VALID 0x40
569 #define TDE_BEA_AVFCLP_NOT_APP 0x00
570 #define TDE_BEA_NONCE_C_MASK 0x30
571 #define TDE_BEA_NONCE_C_SUPPORTED 0x30
572 #define TDE_BEA_NONCE_C_PROVIDED 0x20
573 #define TDE_BEA_NONCE_C_GENERATED 0x10
574 #define TDE_BEA_NONCE_C_NOT_REQUIRED 0x00
575 #define TDE_BEA_KADF_C 0x08
576 #define TDE_BEA_VCELB_C 0x04
577 #define TDE_BEA_UKADF 0x02
578 #define TDE_BEA_AKADF 0x01
579 uint8_t max_unauth_key_bytes[2];
580 uint8_t max_auth_key_bytes[2];
581 uint8_t lbe_key_size[2];
583 #define TDE_BEA_DKAD_C_MASK 0xc0
584 #define TDE_BEA_DKAD_C_CAPABLE 0xc0
585 #define TDE_BEA_DKAD_C_NOT_ALLOWED 0x80
586 #define TDE_BEA_DKAD_C_REQUIRED 0x40
587 #define TDE_BEA_EEMC_C_MASK 0x30
588 #define TDE_BEA_EEMC_C_ALLOWED 0x20
589 #define TDE_BEA_EEMC_C_NOT_ALLOWED 0x10
590 #define TDE_BEA_EEMC_C_NOT_SPECIFIED 0x00
592 * Raw Decryption Mode Control Capabilities (RDMC_C) field. The
593 * descriptions are too complex to represent as a simple name.
595 #define TDE_BEA_RDMC_C_MASK 0x0e
596 #define TDE_BEA_RDMC_C_MODE_7 0x0e
597 #define TDE_BEA_RDMC_C_MODE_6 0x0c
598 #define TDE_BEA_RDMC_C_MODE_5 0x0a
599 #define TDE_BEA_RDMC_C_MODE_4 0x08
600 #define TDE_BEA_RDMC_C_MODE_1 0x02
601 #define TDE_BEA_EAREM 0x01
603 #define TDE_BEA_MAX_EEDKS_MASK 0x0f
604 uint8_t msdk_count[2];
605 uint8_t max_eedk_size[2];
606 uint8_t reserved2[2];
607 uint8_t security_algo_code[4];
611 * Data Encryption Capabilities page (0x0010).
613 struct tde_data_enc_cap_page {
614 uint8_t page_code[2];
617 #define DATA_ENC_CAP_EXTDECC_MASK 0x0c
618 #define DATA_ENC_CAP_EXTDECC_NOT_REPORTED 0x00
619 #define DATA_ENC_CAP_EXTDECC_NOT_CAPABLE 0x04
620 #define DATA_ENC_CAP_EXTDECC_CAPABLE 0x08
621 #define DATA_ENC_CAP_CFG_P_MASK 0x03
622 #define DATA_ENC_CAP_CFG_P_NOT_REPORTED 0x00
623 #define DATA_ENC_CAP_CFG_P_ALLOWED 0x01
624 #define DATA_ENC_CAP_CFG_P_NOT_ALLOWED 0x02
625 uint8_t reserved[15];
626 struct tde_block_enc_alg_desc alg_descs[];
630 * Tape Data Encryption Supported Key Formats page (0x0011).
632 struct tde_supported_key_formats_page {
633 uint8_t page_code[2];
634 uint8_t page_length[2];
635 uint8_t key_formats_list[];
639 * Tape Data Encryption Management Capabilities page (0x0012).
641 struct tde_data_enc_man_cap_page {
642 uint8_t page_code[2];
643 uint8_t page_length[2];
645 #define TDE_DEMC_LOCK_C 0x01
647 #define TDE_DEMC_CKOD_C 0x04
648 #define TDE_DEMC_CKORP_C 0x02
649 #define TDE_DEMC_CKORL_C 0x01
652 #define TDE_DEMC_AITN_C 0x04
653 #define TDE_DEMC_LOCAL_C 0x02
654 #define TDE_DEMC_PUBLIC_C 0x01
655 uint8_t reserved2[8];
659 * Tape Data Encryption Status Page (0x0020).
661 struct tde_data_enc_status_page {
662 uint8_t page_code[2];
663 uint8_t page_length[2];
665 #define TDE_DES_IT_NEXUS_SCOPE_MASK 0xe0
666 #define TDE_DES_LBE_SCOPE_MASK 0x07
667 uint8_t encryption_mode;
668 uint8_t decryption_mode;
670 uint8_t key_instance_counter[4];
672 #define TDE_DES_PARAM_CTRL_MASK 0x70
673 #define TDE_DES_PARAM_CTRL_MGMT 0x40
674 #define TDE_DES_PARAM_CTRL_CHANGER 0x30
675 #define TDE_DES_PARAM_CTRL_DRIVE 0x20
676 #define TDE_DES_PARAM_CTRL_EXT 0x10
677 #define TDE_DES_PARAM_CTRL_NOT_REPORTED 0x00
678 #define TDE_DES_VCELB 0x08
679 #define TDE_DES_CEEMS_MASK 0x06
680 #define TDE_DES_RDMD 0x01
681 uint8_t enc_params_kad_format;
682 uint8_t asdk_count[2];
684 uint8_t key_assoc_data_desc[];
688 * Tape Data Encryption Next Block Encryption Status page (0x0021).
690 struct tde_next_block_enc_status_page {
691 uint8_t page_code[2];
692 uint8_t page_length[2];
693 uint8_t logical_obj_number[8];
695 #define TDE_NBES_COMP_STATUS_MASK 0xf0
696 #define TDE_NBES_COMP_INCAPABLE 0x00
697 #define TDE_NBES_COMP_NOT_YET 0x10
698 #define TDE_NBES_COMP_NOT_A_BLOCK 0x20
699 #define TDE_NBES_COMP_NOT_COMPRESSED 0x30
700 #define TDE_NBES_COMP_COMPRESSED 0x40
701 #define TDE_NBES_ENC_STATUS_MASK 0x0f
702 #define TDE_NBES_ENC_INCAPABLE 0x00
703 #define TDE_NBES_ENC_NOT_YET 0x01
704 #define TDE_NBES_ENC_NOT_A_BLOCK 0x02
705 #define TDE_NBES_ENC_NOT_ENCRYPTED 0x03
706 #define TDE_NBES_ENC_ALG_NOT_SUPPORTED 0x04
707 #define TDE_NBES_ENC_SUPPORTED_ALG 0x05
708 #define TDE_NBES_ENC_NO_KEY 0x06
711 #define TDE_NBES_EMES 0x02
712 #define TDE_NBES_RDMDS 0x01
713 uint8_t next_block_kad_format;
714 uint8_t key_assoc_data_desc[];
718 * Tape Data Encryption Get Encryption Management Attributes page (0x0022).
720 struct tde_get_enc_man_attr_page {
721 uint8_t page_code[2];
724 #define TDE_GEMA_CAOD 0x01
725 uint8_t page_length[2];
726 uint8_t enc_mgmt_attr_desc[];
730 * Tape Data Encryption Random Number page (0x0030).
732 struct tde_random_num_page {
733 uint8_t page_code[2];
734 uint8_t page_length[2];
735 uint8_t random_number[32];
739 * Tape Data Encryption Device Server Key Wrapping Public Key page (0x0031).
741 struct tde_key_wrap_pk_page {
742 uint8_t page_code[2];
743 uint8_t page_length[2];
744 uint8_t public_key_type[4];
745 uint8_t public_key_format[4];
746 uint8_t public_key_length[2];
747 uint8_t public_key[];
751 * Security Protocol Specific values for the Tape Data Encryption protocol
752 * (0x20) used with SECURITY PROTOCOL OUT. See above for values used with
753 * SECURITY PROTOCOL IN. Current as of SSCr03.
755 #define TDE_SET_DATA_ENC_PAGE 0x0010
756 #define TDE_SA_ENCAP_PAGE 0x0011
757 #define TDE_SET_ENC_MGMT_ATTR_PAGE 0x0022
760 * Tape Data Encryption Set Data Encryption page (0x0010).
762 struct tde_set_data_enc_page {
763 uint8_t page_code[2];
764 uint8_t page_length[2];
766 #define TDE_SDE_SCOPE_MASK 0xe0
767 #define TDE_SDE_SCOPE_ALL_IT_NEXUS 0x80
768 #define TDE_SDE_SCOPE_LOCAL 0x40
769 #define TDE_SDE_SCOPE_PUBLIC 0x00
770 #define TDE_SDE_LOCK 0x01
772 #define TDE_SDE_CEEM_MASK 0xc0
773 #define TDE_SDE_CEEM_ENCRYPT 0xc0
774 #define TDE_SDE_CEEM_EXTERNAL 0x80
775 #define TDE_SDE_CEEM_NO_CHECK 0x40
776 #define TDE_SDE_RDMC_MASK 0x30
777 #define TDE_SDE_RDMC_DISABLED 0x30
778 #define TDE_SDE_RDMC_ENABLED 0x20
779 #define TDE_SDE_RDMC_DEFAULT 0x00
780 #define TDE_SDE_SDK 0x08
781 #define TDE_SDE_CKOD 0x04
782 #define TDE_SDE_CKORP 0x02
783 #define TDE_SDE_CKORL 0x01
784 uint8_t encryption_mode;
785 #define TDE_SDE_ENC_MODE_DISABLE 0x00
786 #define TDE_SDE_ENC_MODE_EXTERNAL 0x01
787 #define TDE_SDE_ENC_MODE_ENCRYPT 0x02
788 uint8_t decryption_mode;
789 #define TDE_SDE_DEC_MODE_DISABLE 0x00
790 #define TDE_SDE_DEC_MODE_RAW 0x01
791 #define TDE_SDE_DEC_MODE_DECRYPT 0x02
792 #define TDE_SDE_DEC_MODE_MIXED 0x03
794 uint8_t lbe_key_format;
795 #define TDE_SDE_KEY_PLAINTEXT 0x00
796 #define TDE_SDE_KEY_VENDOR_SPEC 0x01
797 #define TDE_SDE_KEY_PUBLIC_WRAP 0x02
798 #define TDE_SDE_KEY_ESP_SCSI 0x03
800 #define TDE_SDE_KAD_ASCII 0x02
801 #define TDE_SDE_KAD_BINARY 0x01
802 #define TDE_SDE_KAD_UNSPECIFIED 0x00
804 uint8_t lbe_key_length[2];
809 * Used for the Vendor Specific key format (0x01).
811 struct tde_key_format_vendor {
812 uint8_t t10_vendor_id[8];
813 uint8_t vendor_key[];
817 * Used for the public key wrapped format (0x02).
819 struct tde_key_format_public_wrap {
820 uint8_t parameter_set[2];
821 #define TDE_PARAM_SET_RSA2048 0x0000
822 #define TDE_PARAM_SET_ECC521 0x0010
823 uint8_t label_length[2];
828 * Tape Data Encryption SA Encapsulation page (0x0011).
830 struct tde_sa_encap_page {
831 uint8_t page_code[2];
836 * Tape Data Encryption Set Encryption Management Attributes page (0x0022).
838 struct tde_set_enc_mgmt_attr_page {
839 uint8_t page_code[2];
842 #define TDE_SEMA_CAOD 0x01
843 uint8_t page_length[2];
848 * Tape Data Encryption descriptor format.
849 * SSC4r03 Section 8.5.4.2.1 Table 197
851 struct tde_data_enc_desc {
852 uint8_t key_desc_type;
853 #define TDE_KEY_DESC_WK_KAD 0x04
854 #define TDE_KEY_DESC_M_KAD 0x03
855 #define TDE_KEY_DESC_NONCE_VALUE 0x02
856 #define TDE_KEY_DESC_A_KAD 0x01
857 #define TDE_KEY_DESC_U_KAD 0x00
859 #define TDE_KEY_DESC_AUTH_MASK 0x07
860 #define TDE_KEY_DESC_AUTH_FAILED 0x04
861 #define TDE_KEY_DESC_AUTH_SUCCESS 0x03
862 #define TDE_KEY_DESC_AUTH_NO_ATTEMPT 0x02
863 #define TDE_KEY_DESC_AUTH_U_KAD 0x01
864 uint8_t key_desc_length[2];
869 * Wrapped Key descriptor format.
870 * SSC4r03 Section 8.5.4.3.1 Table 200
872 struct tde_wrapped_key_desc {
873 uint8_t wrapped_key_type;
874 #define TDE_WRAP_KEY_DESC_LENGTH 0x04
875 #define TDE_WRAP_KEY_DESC_IDENT 0x03
876 #define TDE_WRAP_KEY_DESC_INFO 0x02
877 #define TDE_WRAP_KEY_DESC_ENTITY_ID 0x01
878 #define TDE_WRAP_KEY_DESC_DEVICE_ID 0x00
880 uint8_t wrapped_desc_length[2];
881 uint8_t wrapped_desc[];
885 * Encryption management attributes descriptor format.
886 * SSC4r03 Section 8.5.4.4.1 Table 202
888 struct tde_enc_mgmt_attr_desc {
889 uint8_t enc_mgmt_attr_type[2];
890 #define TDE_EMAD_DESIRED_KEY_MGR_OP 0x0000
891 #define TDE_EMAD_LOG_BLOCK_ENC_KEY_CRIT 0x0001
892 #define TDE_EMAD_LOG_BLOCK_ENC_KEY_WRAP 0x0002
895 #define TDE_EMAD_CRIT 0x80
896 uint8_t attr_length[2];
897 uint8_t attributes[];
898 #define TDE_EMAD_DESIRED_KEY_CREATE 0x0001
899 #define TDE_EMAD_DESIRED_KEY_RESOLVE 0x0002
903 * Logical block encryption key selection criteria descriptor format.
904 * SSC4r03 Section 8.5.4.4.3.1 Table 206
906 struct tde_lb_enc_key_sel_desc {
907 uint8_t lbe_key_sel_crit_type[2];
909 * The CRIT bit is the top bit of the first byte of the type.
911 #define TDE_LBE_KEY_SEL_CRIT 0x80
912 #define TDE_LBE_KEY_SEL_ALGO 0x0001
913 #define TDE_LBE_KEY_SEL_ID 0x0002
914 uint8_t lbe_key_sel_crit_length[2];
915 uint8_t lbe_key_sel_crit[];
919 * Logical block encryption key wrapping attribute descriptor format.
920 * SSC4r03 Section 8.5.4.4.4.1 Table 209
922 struct tde_lb_enc_key_wrap_desc {
923 uint8_t lbe_key_wrap_type[2];
925 * The CRIT bit is the top bit of the first byte of the type.
927 #define TDE_LBE_KEY_WRAP_CRIT 0x80
928 #define TDE_LBE_KEY_WRAP_KEKS 0x0001
929 uint8_t lbe_key_wrap_length[2];
930 uint8_t lbe_key_wrap_attr[];
937 #define FORMAT_MEDIUM 0x04
938 #define READ_BLOCK_LIMITS 0x05
940 #define SA_WRITE 0x0A
941 #define SET_CAPACITY 0x0B
942 #define WRITE_FILEMARKS 0x10
944 #define RESERVE_UNIT 0x16
945 #define RELEASE_UNIT 0x17
947 #define LOAD_UNLOAD 0x1B
949 #define READ_POSITION 0x34
950 #define REPORT_DENSITY_SUPPORT 0x44
951 #define ALLOW_OVERWRITE 0x82
952 #define LOCATE_16 0x92
955 * Tape specific density codes- only enough of them here to recognize
956 * some specific older units so we can choose 2FM@EOD or FIXED blocksize
959 #define SCSI_DENSITY_HALFINCH_800 0x01
960 #define SCSI_DENSITY_HALFINCH_1600 0x02
961 #define SCSI_DENSITY_HALFINCH_6250 0x03
962 #define SCSI_DENSITY_HALFINCH_6250C 0xC3 /* HP Compressed 6250 */
963 #define SCSI_DENSITY_QIC_11_4TRK 0x04
964 #define SCSI_DENSITY_QIC_11_9TRK 0x84 /* Vendor Unique Emulex */
965 #define SCSI_DENSITY_QIC_24 0x05
966 #define SCSI_DENSITY_HALFINCH_PE 0x06
967 #define SCSI_DENSITY_QIC_120 0x0f
968 #define SCSI_DENSITY_QIC_150 0x10
969 #define SCSI_DENSITY_QIC_525_320 0x11
970 #define SCSI_DENSITY_QIC_1320 0x12
971 #define SCSI_DENSITY_QIC_2GB 0x22
972 #define SCSI_DENSITY_QIC_4GB 0x26
973 #define SCSI_DENSITY_QIC_3080 0x29
976 void scsi_read_block_limits(struct ccb_scsiio *, u_int32_t,
977 void (*cbfcnp)(struct cam_periph *, union ccb *),
978 u_int8_t, struct scsi_read_block_limits_data *,
979 u_int8_t , u_int32_t);
981 void scsi_sa_read_write(struct ccb_scsiio *csio, u_int32_t retries,
982 void (*cbfcnp)(struct cam_periph *, union ccb *),
983 u_int8_t tag_action, int readop, int sli,
984 int fixed, u_int32_t length, u_int8_t *data_ptr,
985 u_int32_t dxfer_len, u_int8_t sense_len,
988 void scsi_rewind(struct ccb_scsiio *csio, u_int32_t retries,
989 void (*cbfcnp)(struct cam_periph *, union ccb *),
990 u_int8_t tag_action, int immediate, u_int8_t sense_len,
993 void scsi_space(struct ccb_scsiio *csio, u_int32_t retries,
994 void (*cbfcnp)(struct cam_periph *, union ccb *),
995 u_int8_t tag_action, scsi_space_code code,
996 u_int32_t count, u_int8_t sense_len, u_int32_t timeout);
998 void scsi_load_unload(struct ccb_scsiio *csio, u_int32_t retries,
999 void (*cbfcnp)(struct cam_periph *, union ccb *),
1000 u_int8_t tag_action, int immediate, int eot,
1001 int reten, int load, u_int8_t sense_len,
1004 void scsi_write_filemarks(struct ccb_scsiio *csio, u_int32_t retries,
1005 void (*cbfcnp)(struct cam_periph *, union ccb *),
1006 u_int8_t tag_action, int immediate, int setmark,
1007 u_int32_t num_marks, u_int8_t sense_len,
1010 void scsi_reserve_release_unit(struct ccb_scsiio *csio, u_int32_t retries,
1011 void (*cbfcnp)(struct cam_periph *,
1012 union ccb *), u_int8_t tag_action,
1013 int third_party, int third_party_id,
1014 u_int8_t sense_len, u_int32_t timeout,
1017 void scsi_erase(struct ccb_scsiio *csio, u_int32_t retries,
1018 void (*cbfcnp)(struct cam_periph *, union ccb *),
1019 u_int8_t tag_action, int immediate, int long_erase,
1020 u_int8_t sense_len, u_int32_t timeout);
1022 void scsi_data_comp_page(struct scsi_data_compression_page *page,
1023 u_int8_t dce, u_int8_t dde, u_int8_t red,
1024 u_int32_t comp_algorithm,
1025 u_int32_t decomp_algorithm);
1027 void scsi_read_position(struct ccb_scsiio *csio, u_int32_t retries,
1028 void (*cbfcnp)(struct cam_periph *, union ccb *),
1029 u_int8_t tag_action, int hardsoft,
1030 struct scsi_tape_position_data *sbp,
1031 u_int8_t sense_len, u_int32_t timeout);
1032 void scsi_read_position_10(struct ccb_scsiio *csio, u_int32_t retries,
1033 void (*cbfcnp)(struct cam_periph *, union ccb *),
1034 u_int8_t tag_action, int service_action,
1035 u_int8_t *data_ptr, u_int32_t length,
1036 u_int32_t sense_len, u_int32_t timeout);
1038 void scsi_set_position(struct ccb_scsiio *csio, u_int32_t retries,
1039 void (*cbfcnp)(struct cam_periph *, union ccb *),
1040 u_int8_t tag_action, int hardsoft, u_int32_t blkno,
1041 u_int8_t sense_len, u_int32_t timeout);
1043 void scsi_locate_10(struct ccb_scsiio *csio, u_int32_t retries,
1044 void (*cbfcnp)(struct cam_periph *, union ccb *),
1045 u_int8_t tag_action, int immed, int cp, int hard,
1046 int64_t partition, u_int32_t block_address,
1047 int sense_len, u_int32_t timeout);
1049 void scsi_locate_16(struct ccb_scsiio *csio, u_int32_t retries,
1050 void (*cbfcnp)(struct cam_periph *, union ccb *),
1051 u_int8_t tag_action, int immed, int cp,
1052 u_int8_t dest_type, int bam, int64_t partition,
1053 u_int64_t logical_id, int sense_len,
1056 void scsi_report_density_support(struct ccb_scsiio *csio, u_int32_t retries,
1057 void (*cbfcnp)(struct cam_periph *,
1059 u_int8_t tag_action, int media,
1060 int medium_type, u_int8_t *data_ptr,
1061 u_int32_t length, u_int32_t sense_len,
1064 void scsi_set_capacity(struct ccb_scsiio *csio, u_int32_t retries,
1065 void (*cbfcnp)(struct cam_periph *, union ccb *),
1066 u_int8_t tag_action, int byte1, u_int32_t proportion,
1067 u_int32_t sense_len, u_int32_t timeout);
1069 void scsi_format_medium(struct ccb_scsiio *csio, u_int32_t retries,
1070 void (*cbfcnp)(struct cam_periph *, union ccb *),
1071 u_int8_t tag_action, int byte1, int byte2,
1072 u_int8_t *data_ptr, u_int32_t length,
1073 u_int32_t sense_len, u_int32_t timeout);
1075 void scsi_allow_overwrite(struct ccb_scsiio *csio, u_int32_t retries,
1076 void (*cbfcnp)(struct cam_periph *, union ccb *),
1077 u_int8_t tag_action, int allow_overwrite,
1078 int partition, u_int64_t logical_id,
1079 u_int32_t sense_len, u_int32_t timeout);
1083 #endif /* _SCSI_SCSI_SA_H */