Lines Matching +full:programmable +full:- +full:security
1 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
78 #define ERESTART -1 /* restart syscall */
79 #define EJUSTRETURN -2 /* don't modify regs, just return */
91 * a minimum value of 100ms. Note that this is pertinent only for SPI-
142 { 0xD8, R, "CD-DA READ" }
149 * to read CD-DA data. I'm not sure which Plextor CDROM
152 * 12-20X does. I don't know about any earlier models,
156 {T_CDROM, SIP_MEDIA_REMOVABLE, "PLEXTOR", "CD-ROM PX*", "*"},
164 * From: http://www.t10.org/lists/op-num.txt
166 * and Jung-uk Kim (jkim@FreeBSD.org)
174 /* File: OP-NUM.TXT
180 * D - DIRECT ACCESS DEVICE (SBC-2) device column key
181 * .T - SEQUENTIAL ACCESS DEVICE (SSC-2) -----------------
182 * . L - PRINTER DEVICE (SSC) M = Mandatory
183 * . P - PROCESSOR DEVICE (SPC) O = Optional
184 * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC-2) V = Vendor spec.
185 * . . R - CD/DVE DEVICE (MMC-3) Z = Obsolete
186 * . . O - OPTICAL MEMORY DEVICE (SBC-2)
187 * . . .M - MEDIA CHANGER DEVICE (SMC-2)
188 * . . . A - STORAGE ARRAY DEVICE (SCC-2)
189 * . . . .E - ENCLOSURE SERVICES DEVICE (SES)
190 * . . . .B - SIMPLIFIED DIRECT-ACCESS DEVICE (RBC)
191 * . . . . K - OPTICAL CARD READER/WRITER DEVICE (OCRW)
192 * . . . . V - AUTOMATION/DRIVE INTERFACE (ADC)
193 * . . . . .F - OBJECT-BASED STORAGE (OSD)
195 * -- -------------- ---------------------------------------------- */
345 /* 34 O O O O PRE-FETCH(10) */
346 { 0x34, D | W | O | K, "PRE-FETCH(10)" },
381 /* 42 O READ SUB-CHANNEL */
382 { 0x42, R, "READ SUB-CHANNEL" },
491 /* 90 O O O O PRE-FETCH(16) */
492 { 0x90, D | W | O | B, "PRE-FETCH(16)" },
521 /* XXX KDM ALL for this? op-num.txt defines it for none.. */
532 /* A2 OO O O SECURITY PROTOCOL IN */
533 { 0xA2, D | T | R | V, "SECURITY PROTOCOL IN" },
586 /* B5 OO O O SECURITY PROTOCOL OUT */
587 { 0xB5, D | T | R | V, "SECURITY PROTOCOL OUT" },
654 table[0] = ((struct scsi_op_quirk_entry *)match)->op_table;
655 num_ops[0] = ((struct scsi_op_quirk_entry *)match)->num_ops;
756 "Vendor Unique - Logical Unit Not Ready") },
764 "Unrecovered Self-Test Hard-Cache Test Fail") },
766 "Unrecovered Self-Test OTF-Cache Fail") },
778 "Vendor Unique - Internal Target Failure") },
780 "Vendor Unique - Internal Target Failure") },
782 "Vendor Unique - Internal Target Failure") },
784 "Vendor Unique - Internal Target Failure") },
786 "Vendor Unique - Internal Target Failure") },
788 "Extreme Over-Temperature Warning") },
792 "Vendor Unique - Internal Logic Error") },
794 "Vendor Unique - Internal Key Seed Error") },
807 "Pre-SMART Warning") },
813 "Write Error - Too many error recovery revs") },
815 "Unrecovered Read Error - Too many error recovery revs") },
829 "Invalid Field Parameter - CAP File") },
831 "Invalid Field Parameter - RAP File") },
833 "Invalid Field Parameter - TMS Firmware Tag") },
835 "Invalid Field Parameter - Check Sum") },
837 "Invalid Field Parameter - Firmware Tag") },
851 "Defect List - Length exceeds Command Allocated Length") },
937 {T_DIRECT, SIP_MEDIA_REMOVABLE, "SONY", "SMO-*", "*"},
945 * HGST vendor-specific error codes
955 * SEAGATE vendor-specific error codes
969 * From: http://www.t10.org/lists/asc-num.txt
970 * Modifications by Jung-uk Kim (jkim@FreeBSD.org)
973 * File: ASC-NUM.TXT
979 * D - DIRECT ACCESS DEVICE (SBC-2) device column key
980 * .T - SEQUENTIAL ACCESS DEVICE (SSC) -------------------
981 * . L - PRINTER DEVICE (SSC) blank = reserved
982 * . P - PROCESSOR DEVICE (SPC) not blank = allowed
983 * . .W - WRITE ONCE READ MULTIPLE DEVICE (SBC-2)
984 * . . R - CD DEVICE (MMC)
985 * . . O - OPTICAL MEMORY DEVICE (SBC-2)
986 * . . .M - MEDIA CHANGER DEVICE (SMC)
987 * . . . A - STORAGE ARRAY DEVICE (SCC)
988 * . . . E - ENCLOSURE SERVICES DEVICE (SES)
989 * . . . .B - SIMPLIFIED DIRECT-ACCESS DEVICE (RBC)
990 * . . . . K - OPTICAL CARD READER/WRITER DEVICE (OCRW)
991 * . . . . V - AUTOMATION/DRIVE INTERFACE (ADC)
992 * . . . . .F - OBJECT-BASED STORAGE (OSD)
1005 "End-of-partition/medium detected") },
1011 "Beginning-of-partition/medium detected") },
1014 "End-of-data detected") },
1020 "Programmable early warning detected") },
1122 "Logical unit not ready, self-test in progress") },
1137 "Logical unit not ready, security session in progress") },
1218 "Logical unit communication time-out") },
1224 "Logical unit communication CRC error (Ultra-DMA/32)") },
1254 "Warning - specified temperature exceeded") },
1257 "Warning - enclosure degraded") },
1260 "Warning - background self-test failed") },
1263 "Warning - background pre-scan detected medium error") },
1266 "Warning - background medium scan detected medium error") },
1269 "Warning - non-volatile cache now volatile") },
1272 "Warning - degraded power to non-volatile cache") },
1275 "Warning - power loss expected") },
1278 "Warning - device statistics notification available") },
1281 "Warning - High critical temperature limit exceeded") },
1284 "Warning - Low critical temperature limit exceeded") },
1287 "Warning - High operating temperature limit exceeded") },
1290 "Warning - Low operating temperature limit exceeded") },
1293 "Warning - High citical humidity limit exceeded") },
1296 "Warning - Low citical humidity limit exceeded") },
1299 "Warning - High operating humidity limit exceeded") },
1302 "Warning - Low operating humidity limit exceeded") },
1305 "Warning - Microcode security at risk") },
1308 "Warning - Microcode digital signature validation failure") },
1311 "Warning - Physical element status change") },
1317 "Write error - recovered with auto reallocation") },
1320 "Write error - auto reallocation failed") },
1323 "Write error - recommend reassignment") },
1335 "Write error - recovery needed") },
1338 "Write error - recovery failed") },
1341 "Write error - loss of streaming") },
1344 "Write error - padding blocks added") },
1350 "Write error - unexpected unsolicited data") },
1353 "Write error - not enough unsolicited data") },
1365 "Write error - recovery scan needed") },
1368 "Write error - insufficient zone resources") },
1431 "Unrecovered read error - auto reallocate failed") },
1434 "L-EC uncorrectable error") },
1440 "Data re-synchronization error") },
1452 "Unrecovered read error - recommend reassignment") },
1455 "Unrecovered read error - recommend rewrite the data") },
1458 "De-compression CRC error") },
1470 "Read error - loss of streaming") },
1476 "Read error - failed retransmission request") },
1479 "Read error - LBA marked bad by application client") },
1500 "End-of-data not found") },
1506 "Record not found - recommend reassignment") },
1509 "Record not found - data auto-reallocated") },
1527 "Data sync error - data rewritten") },
1530 "Data sync error - recommend rewrite") },
1533 "Data sync error - data auto-reallocated") },
1536 "Data sync error - recommend reassignment") },
1557 "Recovered data without ECC - data auto-reallocated") },
1560 "Recovered data without ECC - recommend reassignment") },
1563 "Recovered data without ECC - recommend rewrite") },
1566 "Recovered data without ECC - data rewritten") },
1575 "Recovered data - data auto-reallocated") },
1581 "Recovered data with L-EC") },
1584 "Recovered data - recommend reassignment") },
1587 "Recovered data - recommend rewrite") },
1590 "Recovered data with ECC - data rewritten") },
1638 "Access denied - initiator pending-enrolled") },
1641 "Access denied - no access rights") },
1644 "Access denied - invalid mgmt ID key") },
1659 "Access denied - enrollment conflict") },
1662 "Access denied - invalid LU identifier") },
1665 "Access denied - invalid proxy token") },
1668 "Access denied - ACL LUN conflict") },
1671 "Illegal command when not in append-only mode") },
1761 "Security audit value frozen") },
1764 "Security working key frozen") },
1827 "Invalid data-out buffer integrity check value") },
1833 "Incomplete key-associated data set") },
1884 "Format-layer may have changed") },
1889 * XXX JGibbs - All of these should use the same errno, but I don't
1910 "Transceiver mode changed to single-ended") },
2075 "Cannot read medium - unknown format") },
2078 "Cannot read medium - incompatible format") },
2084 "Cannot write medium - unknown format") },
2087 "Cannot write medium - incompatible format") },
2090 "Cannot format medium - incompatible medium") },
2096 "Cannot write - application code mismatch") },
2105 "WORM medium - overwrite attempted") },
2108 "WORM medium - integrity check") },
2180 "ESN - power management class event") },
2183 "ESN - media class event") },
2186 "ESN - device busy class event") },
2201 "Medium not present - tray closed") },
2204 "Medium not present - tray open") },
2207 "Medium not present - loadable") },
2210 "Medium not present - medium auxiliary memory accessible") },
2216 "Tape position error at beginning-of-medium") },
2219 "Tape position error at end-of-medium") },
2231 "Failed to sense top-of-form") },
2234 "Failed to sense bottom-of-form") },
2303 "Logical unit has not self-configured yet") },
2312 "Logical unit failed self-test") },
2315 "Logical unit unable to update self-test log") },
2398 "RAM failure") }, /* deprecated - use 40 NN instead */
2404 NULL) }, /* Range 0x80->0xFF */
2407 "Data path failure") }, /* deprecated - use 40 NN instead */
2410 "Power-on or self-test failure") },
2411 /* deprecated - use 40 NN instead */
2489 "Data-in buffer overflow - data buffer size") },
2492 "Data-in buffer overflow - data buffer descriptor area") },
2495 "Data-in buffer error") },
2498 "Data-out buffer overflow - data buffer size") },
2501 "Data-out buffer overflow - data buffer descriptor area") },
2504 "Data-out buffer error") },
2531 "Logical unit failed self-configuration") },
2537 NULL) }, /* Range 0x00->0xFF */
2555 "Erase failure - incomplete erase operation detected") },
2588 "Data transfer device error - load failed") },
2591 "Data transfer device error - unload failed") },
2594 "Data transfer device error - unload missing") },
2597 "Data transfer device error - eject failed") },
2600 "Data transfer device error - library communication failed") },
2660 "Unable to recover table-of-contents") },
2747 "Hardware impending failure spin-up retry count") },
2789 "Controller impending failure spin-up retry count") },
2828 "Data channel impending failure spin-up retry count") },
2867 "Servo impending failure spin-up retry count") },
2906 "Spindle impending failure spin-up retry count") },
2945 "Firmware impending failure spin-up retry count") },
2972 "Idle-B condition activated by timer") },
2975 "Idle-B condition activated by command") },
2978 "Idle-C condition activated by timer") },
2981 "Idle-C condition activated by command") },
2984 "Standby-Y condition activated by timer") },
2987 "Standby-Y condition activated by command") },
3125 "Copy protection key exchange failure - authentication failure") },
3128 "Copy protection key exchange failure - key not present") },
3131 "Copy protection key exchange failure - key not established") },
3152 "Invalid drive-host pairing server") },
3155 "Drive-host pairing suspended") },
3161 NULL) }, /* Range 0x00 -> 0xFF */
3167 NULL) }, /* Range 0x00 -> 0xFF */
3173 "Session fixation error writing lead-in") },
3176 "Session fixation error writing lead-out") },
3179 "Session fixation error - incomplete track in session") },
3224 "Security error") },
3305 "Security conflict in translated device") }
3323 asc = ((const struct asc_key *)key)->asc;
3324 ascq = ((const struct asc_key *)key)->ascq;
3327 if (asc >= table_entry->asc) {
3328 if (asc > table_entry->asc)
3331 if (ascq <= table_entry->ascq) {
3333 if (ascq == table_entry->ascq
3334 || ((table_entry->action & SSQ_RANGE) != 0
3335 && ascq >= (table_entry - 1)->ascq))
3337 return (-1);
3341 return (-1);
3353 if (sense_key >= table_entry->sense_key) {
3354 if (sense_key == table_entry->sense_key)
3358 return (-1);
3392 asc_tables[0] = quirk->asc_info;
3393 asc_tables_size[0] = quirk->num_ascs;
3397 sense_tables[0] = quirk->sense_key_info;
3398 sense_tables_size[0] = quirk->num_sense_keys;
3457 *sense_key_desc = sense_entry->desc;
3462 *asc_desc = asc_entry->desc;
3526 action = asc_entry->action;
3528 action = sense_entry->action;
3606 * This is taken from the SCSI-3 draft spec.
3650 switch(csio->scsi_status) {
3660 return("Intermediate-Condition Met");
3674 csio->scsi_status);
3681 * scsi_command_string() returns 0 for success and -1 for failure.
3699 return(-1);
3703 xpt_setup_ccb(&cgd->ccb_h,
3704 csio->ccb_h.path,
3706 cgd->ccb_h.func_code = XPT_GDEV_TYPE;
3713 if (cgd->ccb_h.status == CAM_DEV_NOT_THERE)
3714 cgd->inq_data.device = T_DIRECT;
3716 inq_data = &cgd->inq_data;
3720 inq_data = &device->inq_data;
3738 * returns non-zero, list traversal is stopped.
3759 desc_len = sense_len -offsetof(struct scsi_sense_data_desc, sense_desc);
3765 desc_len = MIN(desc_len, MIN(sense->extra_len, SSD_EXTRA_MAX));
3773 desc_len -= sizeof(struct scsi_sense_desc_header);
3779 &sense->sense_desc[cur_pos];
3789 * desc_len - cur_pos is correct.
3791 if (header->length > (desc_len - cur_pos))
3797 cur_pos += sizeof(*header) + header->length;
3814 if (header->desc_type == desc_info->desc_type) {
3815 desc_info->header = header;
3858 sense->error_code = SSD_DESC_CURRENT_ERROR;
3860 sense->error_code = SSD_DESC_DEFERRED_ERROR;
3861 sense->sense_key = sense_key;
3862 sense->add_sense_code = asc;
3863 sense->add_sense_code_qual = ascq;
3864 sense->flags = 0;
3866 desc = &sense->sense_desc[0];
3867 space = *sense_len - offsetof(struct scsi_sense_data_desc, sense_desc);
3883 sense->flags |= SSDD_SDAT_OVFL;
3888 space -= len;
3893 if (len > sizeof(sks->sense_key_spec))
3896 sense->flags |= SSDD_SDAT_OVFL;
3899 sks->desc_type = SSD_DESC_SKS;
3900 sks->length = sizeof(*sks) -
3902 bcopy(data, &sks->sense_key_spec, len);
3904 space -= sizeof(*sks);
3910 if (len > sizeof(cmd->command_info))
3913 sense->flags |= SSDD_SDAT_OVFL;
3916 cmd->desc_type = SSD_DESC_COMMAND;
3917 cmd->length = sizeof(*cmd) -
3919 bcopy(data, &cmd->command_info[
3920 sizeof(cmd->command_info) - len], len);
3922 space -= sizeof(*cmd);
3928 if (len > sizeof(info->info))
3931 sense->flags |= SSDD_SDAT_OVFL;
3934 info->desc_type = SSD_DESC_INFO;
3935 info->length = sizeof(*info) -
3937 info->byte2 = SSD_INFO_VALID;
3938 bcopy(data, &info->info[sizeof(info->info) - len], len);
3940 space -= sizeof(*info);
3946 if (len > sizeof(fru->fru))
3949 sense->flags |= SSDD_SDAT_OVFL;
3952 fru->desc_type = SSD_DESC_FRU;
3953 fru->length = sizeof(*fru) -
3955 fru->fru = *data;
3957 space -= sizeof(*fru);
3963 if (len > sizeof(stream->byte3))
3966 sense->flags |= SSDD_SDAT_OVFL;
3969 stream->desc_type = SSD_DESC_STREAM;
3970 stream->length = sizeof(*stream) -
3972 stream->byte3 = *data;
3974 space -= sizeof(*stream);
3985 sense->extra_len = desc - &sense->sense_desc[0];
3987 sense->extra_len;
4006 sense->error_code = SSD_CURRENT_ERROR;
4008 sense->error_code = SSD_DEFERRED_ERROR;
4009 sense->flags = sense_key & SSD_KEY;
4010 sense->extra_len = 0;
4012 sense->add_sense_code = asc;
4013 sense->extra_len = MAX(sense->extra_len, 5);
4015 sense->flags |= SSD_SDAT_OVFL;
4017 sense->add_sense_code_qual = ascq;
4018 sense->extra_len = MAX(sense->extra_len, 6);
4020 sense->flags |= SSD_SDAT_OVFL;
4036 if (len > sizeof(sense->sense_key_spec))
4039 sense->flags |= SSD_SDAT_OVFL;
4042 bcopy(data, &sense->sense_key_spec[0], len);
4043 sense->extra_len = MAX(sense->extra_len, 10);
4047 sense->flags |= SSD_SDAT_OVFL;
4050 if (len > sizeof(sense->cmd_spec_info)) {
4051 data += len - sizeof(sense->cmd_spec_info);
4052 len = sizeof(sense->cmd_spec_info);
4054 bcopy(data, &sense->cmd_spec_info[
4055 sizeof(sense->cmd_spec_info) - len], len);
4056 sense->extra_len = MAX(sense->extra_len, 4);
4060 sense->error_code |= SSD_ERRCODE_VALID;
4061 while (len > sizeof(sense->info)) {
4063 sense->error_code &= ~SSD_ERRCODE_VALID;
4065 len --;
4067 bcopy(data, &sense->info[sizeof(sense->info) - len], len);
4071 sense->flags |= SSD_SDAT_OVFL;
4074 sense->fru = *data;
4075 sense->extra_len = MAX(sense->extra_len, 7);
4078 sense->flags |= *data &
4090 sense->extra_len;
4171 if ((info_desc->byte2 & SSD_INFO_VALID) == 0)
4174 *info = scsi_8btou64(info_desc->info);
4184 *info = scsi_8btou64(cmd_desc->command_info);
4194 if (fru_desc->fru == 0)
4197 *info = fru_desc->fru;
4199 *signed_info = (int8_t)fru_desc->fru;
4217 if ((sense->error_code & SSD_ERRCODE_VALID) == 0)
4223 info_val = scsi_4btoul(sense->info);
4238 cmd_val = scsi_4btoul(sense->cmd_spec_info);
4252 if (sense->fru == 0)
4255 *info = sense->fru;
4257 *signed_info = (int8_t)sense->fru;
4297 if ((desc->sense_key_spec[0] & SSD_SKS_VALID) == 0)
4300 bcopy(desc->sense_key_spec, sks, sizeof(desc->sense_key_spec));
4312 if ((sense->sense_key_spec[0] & SSD_SCS_VALID) == 0)
4315 bcopy(sense->sense_key_spec, sks,sizeof(sense->sense_key_spec));
4329 * whether we have block-specific sense information. It is clear by the
4365 *block_bits = block->byte3;
4376 *block_bits = sense->flags & SSD_ILI;
4418 *stream_bits = stream->byte3;
4429 *stream_bits = sense->flags & (SSD_ILI|SSD_EOM|SSD_FILEMARK);
4479 if (field->byte0 & SSD_SKS_FIELD_CMD)
4487 if (field->byte0 & SSD_SKS_BPV)
4489 field->byte0 & SSD_SKS_BIT_VALUE);
4493 scsi_2btoul(field->field), tmpstr);
4503 (overflow->byte0 & SSD_SKS_OVERFLOW_SET) ?
4516 scsi_2btoul(retry->actual_retry_count));
4526 progress_val = scsi_2btoul(progress->progress);
4540 if (segment->byte0 & SSD_SKS_SEGMENT_BPV)
4542 segment->byte0 & SSD_SKS_SEGMENT_BITPTR);
4544 sbuf_printf(sb, "%s byte %d %sis invalid", (segment->byte0 &
4546 scsi_2btoul(segment->field), tmpstr);
4607 if ((info->byte2 & SSD_INFO_VALID) == 0)
4610 scsi_info_sbuf(sb, cdb, cdb_len, inq_data, scsi_8btou64(info->info));
4624 scsi_8btou64(command->command_info));
4638 if ((sks->sense_key_spec[0] & SSD_SKS_VALID) == 0)
4644 scsi_sks_sbuf(sb, sense_key, sks->sense_key_spec);
4657 if (fru->fru == 0)
4660 scsi_fru_sbuf(sb, (uint64_t)fru->fru);
4672 scsi_stream_sbuf(sb, stream->byte3);
4684 scsi_block_sbuf(sb, block->byte3);
4705 scsi_sense_desc(progress->sense_key, progress->add_sense_code,
4706 progress->add_sense_code_qual, inq_data,
4709 progress_val = scsi_2btoul(progress->progress);
4716 sbuf_printf(sb, " asc:%x,%x (%s): ", progress->add_sense_code,
4717 progress->add_sense_code_qual, asc_desc);
4732 res->status,
4733 (res->status & 0x80) ? "BSY " : "",
4734 (res->status & 0x40) ? "DRDY " : "",
4735 (res->status & 0x20) ? "DF " : "",
4736 (res->status & 0x10) ? "SERV " : "",
4737 (res->status & 0x08) ? "DRQ " : "",
4738 (res->status & 0x04) ? "CORR " : "",
4739 (res->status & 0x02) ? "IDX " : "",
4740 (res->status & 0x01) ? "ERR" : "");
4741 if (res->status & 1) {
4743 res->error,
4744 (res->error & 0x80) ? "ICRC " : "",
4745 (res->error & 0x40) ? "UNC " : "",
4746 (res->error & 0x20) ? "MC " : "",
4747 (res->error & 0x10) ? "IDNF " : "",
4748 (res->error & 0x08) ? "MCR " : "",
4749 (res->error & 0x04) ? "ABRT " : "",
4750 (res->error & 0x02) ? "NM " : "",
4751 (res->error & 0x01) ? "ILI" : "");
4754 if (res->flags & SSD_DESC_ATA_FLAG_EXTEND) {
4756 res->count_15_8, res->count_7_0);
4758 res->lba_47_40, res->lba_39_32, res->lba_31_24,
4759 res->lba_23_16, res->lba_15_8, res->lba_7_0);
4761 sbuf_printf(sb, "count: %02x, ", res->count_7_0);
4763 res->lba_23_16, res->lba_15_8, res->lba_7_0);
4765 sbuf_printf(sb, "device: %02x, ", res->device);
4780 scsi_extract_sense_len((struct scsi_sense_data *)forwarded->sense_data,
4781 forwarded->length - 2, &error_code, &sense_key, &asc, &ascq, 1);
4801 sbuf_printf(sb, "Descriptor %#x:", header->desc_type);
4805 for (i = 0; i < header->length; i++, buf_ptr++)
4856 if (printer->desc_type > header->desc_type)
4859 if (printer->desc_type != header->desc_type)
4862 printer->print_func(sb, sense, sense_len, cdb, cdb_len,
4878 switch (sense_data->error_code & SSD_ERRCODE) {
4910 switch (header->desc_type) {
4923 sbuf_printf(print_info->sb, "%s", print_info->path_str);
4924 scsi_sense_desc_sbuf(print_info->sb,
4926 print_info->cdb, print_info->cdb_len,
4927 print_info->inq_data, header);
4928 sbuf_putc(print_info->sb, '\n');
4974 * data isn't long enough), the -1 values that
4988 * Print any block or stream device-specific information.
5023 * Print any command-specific information.
5033 * Print out any sense-key-specific information.
5064 case -1:
5066 * scsi_extract_sense_len() sets values to -1 if the
5074 if (sense->error_code & SSD_ERRCODE_VALID) {
5082 info = scsi_4btoul(fixed_sense->info);
5095 * scsi_sense_sbuf() returns 0 for success and -1 for failure.
5116 return(-1);
5119 return(-1);
5124 if ((csio->ccb_h.flags & CAM_CDB_PHYS) != 0)
5128 xpt_path_string(csio->ccb_h.path, path_str, sizeof(path_str));
5135 return(-1);
5139 xpt_setup_ccb(&cgd->ccb_h,
5140 csio->ccb_h.path,
5142 cgd->ccb_h.func_code = XPT_GDEV_TYPE;
5149 if (cgd->ccb_h.status == CAM_DEV_NOT_THERE)
5150 cgd->inq_data.device = T_DIRECT;
5152 inq_data = &cgd->inq_data;
5156 inq_data = &device->inq_data;
5176 if (csio->ccb_h.flags & CAM_SENSE_PTR) {
5177 if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
5181 return(-1);
5188 bcopy((struct scsi_sense_data **)&csio->sense_data,
5200 if (csio->ccb_h.flags & CAM_SENSE_PHYS) {
5204 return(-1);
5206 sense = &csio->sense_data;
5209 scsi_sense_only_sbuf(sense, csio->sense_len - csio->sense_resid, sb,
5210 path_str, inq_data, scsiio_cdb_ptr(csio), csio->cdb_len);
5281 * Extract basic sense information. This is backward-compatible with the
5303 if (ccb->ccb_h.func_code != XPT_SCSI_IO ||
5304 (ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_SCSI_STATUS_ERROR ||
5305 (ccb->csio.scsi_status != SCSI_STATUS_CHECK_COND) ||
5306 (ccb->ccb_h.status & CAM_AUTOSNS_VALID) == 0 ||
5307 (ccb->ccb_h.flags & CAM_SENSE_PHYS))
5310 if (ccb->ccb_h.flags & CAM_SENSE_PTR)
5311 bcopy((struct scsi_sense_data **)&ccb->csio.sense_data,
5314 sense_data = &ccb->csio.sense_data;
5316 ccb->csio.sense_len - ccb->csio.sense_resid,
5318 if (*error_code == -1)
5325 * will be set to -1 if they are not present.
5342 *error_code = -1;
5343 *sense_key = -1;
5344 *asc = -1;
5345 *ascq = -1;
5350 *error_code = sense_data->error_code & SSD_ERRCODE;
5360 *sense_key = sense->sense_key & SSD_KEY;
5362 *sense_key = (show_errors) ? -1 : 0;
5365 *asc = sense->add_sense_code;
5367 *asc = (show_errors) ? -1 : 0;
5370 *ascq = sense->add_sense_code_qual;
5372 *ascq = (show_errors) ? -1 : 0;
5383 *sense_key = sense->flags & SSD_KEY;
5385 *sense_key = (show_errors) ? -1 : 0;
5389 *asc = sense->add_sense_code;
5391 *asc = (show_errors) ? -1 : 0;
5395 *ascq = sense->add_sense_code_qual;
5397 *ascq = (show_errors) ? -1 : 0;
5458 qtype = " (vendor-unique qualifier)";
5496 dtype = "CD-ROM";
5523 dtype = "Object-Based Storage";
5546 sbuf_printf(sb, "SCSI-%d ", SID_ANSI_REV(inq_data));
5548 sbuf_printf(sb, "SPC-%d SCSI ", SID_ANSI_REV(inq_data) - 2);
5570 cam_strvis_sbuf(sb, inq_data->vendor, sizeof(inq_data->vendor), 0);
5572 cam_strvis_sbuf(sb, inq_data->product, sizeof(inq_data->product), 0);
5574 cam_strvis_sbuf(sb, inq_data->revision, sizeof(inq_data->revision), 0);
5598 { 0x08, 625 }, /* FAST-160 */
5599 { 0x09, 1250 }, /* FAST-80 */
5600 { 0x0a, 2500 }, /* FAST-40 40MHz */
5601 { 0x0b, 3030 }, /* FAST-40 33MHz */
5602 { 0x0c, 5000 } /* FAST-20 */
5617 * die with a divide fault- instead return something which
5679 naa = (struct scsi_vpd_id_naa_basic *)descr->identifier;
5680 if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_NAA)
5682 if (descr->length < sizeof(struct scsi_vpd_id_naa_ieee_reg))
5684 n = naa->naa >> SVPD_ID_NAA_NAA_SHIFT;
5698 if ((descr->id_type & SVPD_ID_PIV) == 0) /* proto field reserved */
5700 if ((descr->proto_codeset >> SVPD_ID_PROTO_SHIFT) != SCSI_PROTO_SAS)
5711 if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN)
5713 if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_EUI64)
5724 if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN)
5726 if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_NAA)
5737 if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN)
5739 if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_T10)
5750 if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN)
5752 if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_SCSI_NAME)
5763 if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN)
5765 if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_MD5_LUN_ID)
5776 if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_LUN)
5778 if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_UUID)
5789 if ((descr->id_type & SVPD_ID_ASSOC_MASK) != SVPD_ID_ASSOC_PORT)
5791 if ((descr->id_type & SVPD_ID_TYPE_MASK) != SVPD_ID_TYPE_NAA)
5804 for (; desc->identifier <= desc_buf_end &&
5805 desc->identifier + desc->length <= desc_buf_end;
5806 desc = (struct scsi_vpd_id_descriptor *)(desc->identifier
5807 + desc->length)) {
5822 len = MIN(scsi_2btoul(id->length), page_len - sizeof(*id));
5824 id->desc_list, len, ck_fn));
5831 switch (hdr->format_protocol & SCSI_TRN_PROTO_MASK) {
5838 n_port_name = scsi_8btou64(fcp->n_port_name);
5849 scsi_2btoul(spi->scsi_addr),
5850 scsi_2btoul(spi->rel_trgt_port_id));
5855 * XXX KDM there is no transport ID defined in SPC-4 for
5865 eui64 = scsi_8btou64(sbp->eui64);
5876 for (i = 0; i < sizeof(rdma->initiator_port_id); i++)
5877 sbuf_printf(sb, "%02x", rdma->initiator_port_id[i]);
5886 if ((hdr->format_protocol & SCSI_TRN_FORMAT_MASK) ==
5895 add_len = scsi_2btoul(dev->additional_length);
5896 add_len = MIN(add_len, valid_len -
5899 iscsi_name = &dev->iscsi_name[0];
5901 } else if ((hdr->format_protocol & SCSI_TRN_FORMAT_MASK) ==
5907 add_len = scsi_2btoul(port->additional_length);
5908 add_len = MIN(add_len, valid_len -
5911 iscsi_name = &port->iscsi_name[0];
5914 (hdr->format_protocol &
5924 * This is supposed to be a NUL-terminated ASCII
5951 sas_addr = scsi_8btou64(sas->sas_address);
5960 * SPC-4.
5963 "%#x", hdr->format_protocol & SCSI_TRN_PROTO_MASK);
5970 rid = (struct scsi_sop_routing_id_norm *)sop->routing_id;
5973 * Note that there is no alternate format specified in SPC-4
5980 rid->bus, rid->devfunc >> SCSI_TRN_SOP_DEV_SHIFT,
5981 rid->devfunc & SCSI_TRN_SOP_FUNC_NORM_MAX);
5987 hdr->format_protocol & SCSI_TRN_PROTO_MASK);
6028 * SCSI_NV_FOUND - match found
6029 * SCSI_NV_AMBIGUOUS - more than one match, none of them exact
6030 * SCSI_NV_NOT_FOUND - no match found
6077 * all 64-bit numbers, the code is similar.
6099 "parsing ID %s, 64-bit number required",
6148 fcp->format_protocol = SCSI_PROTO_FC |
6150 scsi_u64to8b(value, fcp->n_port_name);
6157 sbp->format_protocol = SCSI_PROTO_1394 |
6159 scsi_u64to8b(value, sbp->eui64);
6166 sas->format_protocol = SCSI_PROTO_SAS |
6168 scsi_u64to8b(value, sas->sas_address);
6252 spi->format_protocol = SCSI_PROTO_SPI | SCSI_TRN_SPI_FORMAT_DEFAULT;
6253 scsi_ulto2b(scsi_addr, spi->scsi_addr);
6254 scsi_ulto2b(target_port, spi->rel_trgt_port_id);
6321 * 128-bit integer type, and so no strtou128t() routine to convert
6346 c -= '0';
6348 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
6397 rdma->format_protocol = SCSI_PROTO_RDMA | SCSI_TRN_RDMA_FORMAT_DEFAULT;
6398 bcopy(rdma_id, rdma->initiator_port_id, SCSI_TRN_RDMA_PORT_LEN);
6409 * iqn.2012-06.com.example:target0
6412 * iqn.2012-06.com.example:target0,i,0x123
6508 iscsi->format_protocol = SCSI_PROTO_ISCSI;
6510 iscsi->format_protocol |= SCSI_TRN_ISCSI_FORMAT_DEVICE;
6512 iscsi->format_protocol |= SCSI_TRN_ISCSI_FORMAT_PORT;
6513 name_len = id_size - sizeof(*iscsi);
6514 scsi_ulto2b(name_len, iscsi->additional_length);
6515 snprintf(iscsi->iscsi_name, name_len, "%s%s", iqn_prefix, id_str);
6661 sop->format_protocol = SCSI_PROTO_SOP | SCSI_TRN_SOP_FORMAT_DEFAULT;
6667 bcopy(&rid, sop->routing_id, MIN(sizeof(rid),
6668 sizeof(sop->routing_id)));
6674 bcopy(&rid, sop->routing_id, MIN(sizeof(rid),
6675 sizeof(sop->routing_id)));
6684 * transportid_str: NUL-terminated string with format: protcol,id
6690 * error_str: If non-NULL, it will contain error information (without
6694 * Returns 0 for success, non-zero for failure.
6849 "Device Vendor/Serial at Last Load - 1",
6853 "Device Vendor/Serial at Last Load - 2",
6857 "Device Vendor/Serial at Last Load - 3",
7063 field_size = scsi_2btoul(hdr->length);
7064 avail_len = valid_len - sizeof(*hdr);
7069 "length %u", scsi_2btoul(hdr->id), avail_len,
7082 cur_ptr = hdr->attribute;
7169 field_size = scsi_2btoul(hdr->length);
7170 avail_len = valid_len - sizeof(*hdr);
7175 "length %u", scsi_2btoul(hdr->id), avail_len,
7189 scsi_2btoul(hdr->id));
7194 vendser = (struct scsi_attrib_vendser *)hdr->attribute;
7208 cam_strvis_sbuf(sb, vendser->vendor, sizeof(vendser->vendor),
7211 cam_strvis_sbuf(sb, vendser->serial_num, sizeof(vendser->serial_num),
7229 field_size = scsi_2btoul(hdr->length);
7230 avail_len = valid_len - sizeof(*hdr);
7232 num_ptr = hdr->attribute;
7253 number_size = scsi_2btoul(hdr->length);
7255 avail_len = valid_len - sizeof(*hdr);
7260 "length %u", scsi_2btoul(hdr->id), avail_len,
7277 print_number = hdr->attribute[0];
7280 print_number = scsi_2btoul(hdr->attribute);
7283 print_number = scsi_3btoul(hdr->attribute);
7286 print_number = scsi_4btoul(hdr->attribute);
7289 print_number = scsi_8btou64(hdr->attribute);
7337 avail_len = valid_len - sizeof(*hdr);
7338 field_size = scsi_2btoul(hdr->length);
7356 cam_strvis_sbuf(sb, hdr->attribute, print_size, strvis_flags);
7362 * e.g. in SPC-4r37, section 7.4.2.2.5, VOLUME IDENTIFIER
7364 * (see SMC-3) of the medium. If the device server supports
7372 "length %u", scsi_2btoul(hdr->id), avail_len,
7392 avail_len = valid_len - sizeof(*hdr);
7393 field_size = scsi_2btoul(hdr->length);
7404 if (hdr->attribute[i] == '\0')
7406 else if (((unsigned char)hdr->attribute[i] < 0x80)
7408 sbuf_putc(sb, hdr->attribute[i]);
7411 (unsigned char)hdr->attribute[i]);
7421 "length %u", scsi_2btoul(hdr->id), avail_len,
7458 switch (hdr->byte2 & SMA_FORMAT_MASK) {
7464 if (scsi_2btoul(hdr->length) <= 8)
7481 "format 0x%x", hdr->byte2 & SMA_FORMAT_MASK);
7511 id = scsi_2btoul(hdr->id);
7520 len = scsi_2btoul(hdr->length);
7543 (hdr->byte2 & SMA_READ_ONLY) ? "RO" : "RW");
7567 id = scsi_2btoul(hdr->id);
7589 entry->desc);
7590 if (entry->to_str == NULL)
7592 retval = entry->to_str(sb, hdr, valid_len, entry->flags,
7599 if (entry->to_str == NULL)
7603 valid_len, entry->desc);
7604 retval = entry->to_str(sb, hdr, valid_len, entry->flags,
7619 && (entry->suffix != NULL))
7620 sbuf_printf(sb, " %s", entry->suffix);
7647 scsi_cmd = (struct scsi_test_unit_ready *)&csio->cdb_io.cdb_bytes;
7649 scsi_cmd->opcode = TEST_UNIT_READY;
7671 scsi_cmd = (struct scsi_request_sense *)&csio->cdb_io.cdb_bytes;
7673 scsi_cmd->opcode = REQUEST_SENSE;
7674 scsi_cmd->length = dxfer_len;
7697 scsi_cmd = (struct scsi_inquiry *)&csio->cdb_io.cdb_bytes;
7699 scsi_cmd->opcode = INQUIRY;
7701 scsi_cmd->byte2 |= SI_EVPD;
7702 scsi_cmd->page_code = page_code;
7704 scsi_ulto2b(inq_len, scsi_cmd->length);
7749 scsi_cmd = (struct scsi_mode_sense_6 *)&csio->cdb_io.cdb_bytes;
7751 scsi_cmd->opcode = MODE_SENSE_6;
7753 scsi_cmd->byte2 |= SMS_DBD;
7754 scsi_cmd->page = pc | page;
7755 scsi_cmd->subpage = subpage;
7756 scsi_cmd->length = param_len;
7764 scsi_cmd = (struct scsi_mode_sense_10 *)&csio->cdb_io.cdb_bytes;
7766 scsi_cmd->opcode = MODE_SENSE_10;
7768 scsi_cmd->byte2 |= SMS_DBD;
7769 scsi_cmd->page = pc | page;
7770 scsi_cmd->subpage = subpage;
7771 scsi_ulto2b(param_len, scsi_cmd->length);
7818 scsi_cmd = (struct scsi_mode_select_6 *)&csio->cdb_io.cdb_bytes;
7820 scsi_cmd->opcode = MODE_SELECT_6;
7822 scsi_cmd->byte2 |= SMS_PF;
7824 scsi_cmd->byte2 |= SMS_SP;
7825 scsi_cmd->length = param_len;
7834 (struct scsi_mode_select_10 *)&csio->cdb_io.cdb_bytes;
7836 scsi_cmd->opcode = MODE_SELECT_10;
7838 scsi_cmd->byte2 |= SMS_PF;
7840 scsi_cmd->byte2 |= SMS_SP;
7841 scsi_ulto2b(param_len, scsi_cmd->length);
7867 scsi_cmd = (struct scsi_log_sense *)&csio->cdb_io.cdb_bytes;
7869 scsi_cmd->opcode = LOG_SENSE;
7870 scsi_cmd->page = page_code | page;
7872 scsi_cmd->byte2 |= SLS_SP;
7874 scsi_cmd->byte2 |= SLS_PPC;
7875 scsi_ulto2b(paramptr, scsi_cmd->paramptr);
7876 scsi_ulto2b(param_len, scsi_cmd->length);
7901 scsi_cmd = (struct scsi_log_select *)&csio->cdb_io.cdb_bytes;
7903 scsi_cmd->opcode = LOG_SELECT;
7904 scsi_cmd->page = page_code & SLS_PAGE_CODE;
7906 scsi_cmd->byte2 |= SLS_SP;
7908 scsi_cmd->byte2 |= SLS_PCR;
7909 scsi_ulto2b(param_len, scsi_cmd->length);
7946 scsi_cmd = (struct scsi_prevent *)&csio->cdb_io.cdb_bytes;
7948 scsi_cmd->opcode = PREVENT_ALLOW;
7949 scsi_cmd->how = action;
7973 scsi_cmd = (struct scsi_read_capacity *)&csio->cdb_io.cdb_bytes;
7975 scsi_cmd->opcode = READ_CAPACITY;
7997 scsi_cmd = (struct scsi_read_capacity_16 *)&csio->cdb_io.cdb_bytes;
7999 scsi_cmd->opcode = SERVICE_ACTION_IN;
8000 scsi_cmd->service_action = SRC16_SERVICE_ACTION;
8001 scsi_u64to8b(lba, scsi_cmd->addr);
8002 scsi_ulto4b(rcap_buf_len, scsi_cmd->alloc_len);
8028 scsi_cmd = (struct scsi_report_luns *)&csio->cdb_io.cdb_bytes;
8030 scsi_cmd->opcode = REPORT_LUNS;
8031 scsi_cmd->select_report = select_report;
8032 scsi_ulto4b(alloc_len, scsi_cmd->length);
8054 scsi_cmd = (struct scsi_target_group *)&csio->cdb_io.cdb_bytes;
8056 scsi_cmd->opcode = MAINTENANCE_IN;
8057 scsi_cmd->service_action = REPORT_TARGET_PORT_GROUPS | pdf;
8058 scsi_ulto4b(alloc_len, scsi_cmd->length);
8080 scsi_cmd = (struct scsi_timestamp *)&csio->cdb_io.cdb_bytes;
8082 scsi_cmd->opcode = MAINTENANCE_IN;
8083 scsi_cmd->service_action = REPORT_TIMESTAMP | pdf;
8084 scsi_ulto4b(alloc_len, scsi_cmd->length);
8105 scsi_cmd = (struct scsi_target_group *)&csio->cdb_io.cdb_bytes;
8107 scsi_cmd->opcode = MAINTENANCE_OUT;
8108 scsi_cmd->service_action = SET_TARGET_PORT_GROUPS;
8109 scsi_ulto4b(alloc_len, scsi_cmd->length);
8144 scsi_cmd = (struct scsi_timestamp *)&csio->cdb_io.cdb_bytes;
8146 scsi_cmd->opcode = MAINTENANCE_OUT;
8147 scsi_cmd->service_action = SET_TIMESTAMP;
8148 scsi_ulto4b(alloc_len, scsi_cmd->length);
8176 scsi_cmd = (struct scsi_sync_cache *)&csio->cdb_io.cdb_bytes;
8178 scsi_cmd->opcode = SYNCHRONIZE_CACHE;
8179 scsi_ulto4b(begin_lba, scsi_cmd->begin_lba);
8180 scsi_ulto2b(lb_count, scsi_cmd->lb_count);
8211 scsi_cmd = (struct scsi_rw_6 *)&csio->cdb_io.cdb_bytes;
8212 scsi_cmd->opcode = read ? READ_6 : WRITE_6;
8213 scsi_ulto3b(lba, scsi_cmd->addr);
8214 scsi_cmd->length = block_count & 0xff;
8215 scsi_cmd->control = 0;
8218 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
8219 ("6byte: %x%x%x:%d:%d\n", scsi_cmd->addr[0],
8220 scsi_cmd->addr[1], scsi_cmd->addr[2],
8221 scsi_cmd->length, dxfer_len));
8230 scsi_cmd = (struct scsi_rw_10 *)&csio->cdb_io.cdb_bytes;
8231 scsi_cmd->opcode = read ? READ_10 : WRITE_10;
8232 scsi_cmd->byte2 = byte2;
8233 scsi_ulto4b(lba, scsi_cmd->addr);
8234 scsi_cmd->reserved = 0;
8235 scsi_ulto2b(block_count, scsi_cmd->length);
8236 scsi_cmd->control = 0;
8239 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
8240 ("10byte: %x%x%x%x:%x%x: %d\n", scsi_cmd->addr[0],
8241 scsi_cmd->addr[1], scsi_cmd->addr[2],
8242 scsi_cmd->addr[3], scsi_cmd->length[0],
8243 scsi_cmd->length[1], dxfer_len));
8253 scsi_cmd = (struct scsi_rw_12 *)&csio->cdb_io.cdb_bytes;
8254 scsi_cmd->opcode = read ? READ_12 : WRITE_12;
8255 scsi_cmd->byte2 = byte2;
8256 scsi_ulto4b(lba, scsi_cmd->addr);
8257 scsi_cmd->reserved = 0;
8258 scsi_ulto4b(block_count, scsi_cmd->length);
8259 scsi_cmd->control = 0;
8262 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
8263 ("12byte: %x%x%x%x:%x%x%x%x: %d\n", scsi_cmd->addr[0],
8264 scsi_cmd->addr[1], scsi_cmd->addr[2],
8265 scsi_cmd->addr[3], scsi_cmd->length[0],
8266 scsi_cmd->length[1], scsi_cmd->length[2],
8267 scsi_cmd->length[3], dxfer_len));
8275 scsi_cmd = (struct scsi_rw_16 *)&csio->cdb_io.cdb_bytes;
8276 scsi_cmd->opcode = read ? READ_16 : WRITE_16;
8277 scsi_cmd->byte2 = byte2;
8278 scsi_u64to8b(lba, scsi_cmd->addr);
8279 scsi_cmd->reserved = 0;
8280 scsi_ulto4b(block_count, scsi_cmd->length);
8281 scsi_cmd->control = 0;
8314 scsi_cmd = (struct scsi_write_same_10 *)&csio->cdb_io.cdb_bytes;
8315 scsi_cmd->opcode = WRITE_SAME_10;
8316 scsi_cmd->byte2 = byte2;
8317 scsi_ulto4b(lba, scsi_cmd->addr);
8318 scsi_cmd->group = 0;
8319 scsi_ulto2b(block_count, scsi_cmd->length);
8320 scsi_cmd->control = 0;
8323 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
8324 ("10byte: %x%x%x%x:%x%x: %d\n", scsi_cmd->addr[0],
8325 scsi_cmd->addr[1], scsi_cmd->addr[2],
8326 scsi_cmd->addr[3], scsi_cmd->length[0],
8327 scsi_cmd->length[1], dxfer_len));
8335 scsi_cmd = (struct scsi_write_same_16 *)&csio->cdb_io.cdb_bytes;
8336 scsi_cmd->opcode = WRITE_SAME_16;
8337 scsi_cmd->byte2 = byte2;
8338 scsi_u64to8b(lba, scsi_cmd->addr);
8339 scsi_ulto4b(block_count, scsi_cmd->length);
8340 scsi_cmd->group = 0;
8341 scsi_cmd->control = 0;
8344 CAM_DEBUG(csio->ccb_h.path, CAM_DEBUG_SUBTRACE,
8346 scsi_cmd->addr[0], scsi_cmd->addr[1],
8347 scsi_cmd->addr[2], scsi_cmd->addr[3],
8348 scsi_cmd->addr[4], scsi_cmd->addr[5],
8349 scsi_cmd->addr[6], scsi_cmd->addr[7],
8350 scsi_cmd->length[0], scsi_cmd->length[1],
8351 scsi_cmd->length[2], scsi_cmd->length[3],
8558 * If we have parameters that require a 48-bit ATA command, we have to
8559 * use the 16 byte ATA PASS-THROUGH command at least.
8574 * 32-byte version of the ATA PASS-THROUGH command.
8582 if ((cmd_size > sizeof(csio->cdb_io.cdb_bytes))
8591 * in one place or another. We prefer the built-in array, but used
8594 if (cmd_size <= sizeof(csio->cdb_io.cdb_bytes))
8595 cdb_ptr = csio->cdb_io.cdb_bytes;
8608 cdb->opcode = ATA_PASS_12;
8609 cdb->protocol = protocol;
8610 cdb->flags = ata_flags;
8611 cdb->features = features;
8612 cdb->sector_count = sector_count;
8613 cdb->lba_low = lba & 0xff;
8614 cdb->lba_mid = (lba >> 8) & 0xff;
8615 cdb->lba_high = (lba >> 16) & 0xff;
8616 cdb->device = ((lba >> 24) & 0xf) | ATA_DEV_LBA;
8617 cdb->command = command;
8618 cdb->control = control;
8626 cdb->opcode = ATA_PASS_16;
8627 cdb->protocol = protocol;
8628 cdb->flags = ata_flags;
8629 cdb->features = features & 0xff;
8630 cdb->sector_count = sector_count & 0xff;
8631 cdb->lba_low = lba & 0xff;
8632 cdb->lba_mid = (lba >> 8) & 0xff;
8633 cdb->lba_high = (lba >> 16) & 0xff;
8635 * If AP_EXTEND is set, we're sending a 48-bit command.
8636 * Otherwise it's a 28-bit command.
8639 cdb->lba_low_ext = (lba >> 24) & 0xff;
8640 cdb->lba_mid_ext = (lba >> 32) & 0xff;
8641 cdb->lba_high_ext = (lba >> 40) & 0xff;
8642 cdb->features_ext = (features >> 8) & 0xff;
8643 cdb->sector_count_ext = (sector_count >> 8) & 0xff;
8644 cdb->device = device | ATA_DEV_LBA;
8646 cdb->lba_low_ext = (lba >> 24) & 0xf;
8647 cdb->device = ((lba >> 24) & 0xf) | ATA_DEV_LBA;
8649 cdb->command = command;
8650 cdb->control = control;
8658 cdb->opcode = VARIABLE_LEN_CDB;
8659 cdb->control = control;
8660 cdb->length = sizeof(*cdb) - __offsetof(struct ata_pass_32,
8662 scsi_ulto2b(ATA_PASS_32_SA, cdb->service_action);
8663 cdb->protocol = protocol;
8664 cdb->flags = ata_flags;
8668 cdb->device = ((lba >> 24) & 0xf) | ATA_DEV_LBA;
8672 cdb->device = device | ATA_DEV_LBA;
8675 bcopy(&tmp_lba[2], cdb->lba, sizeof(cdb->lba));
8676 scsi_ulto2b(features, cdb->features);
8677 scsi_ulto2b(sector_count, cdb->count);
8678 cdb->command = command;
8679 cdb->icc = icc;
8680 scsi_ulto4b(auxiliary, cdb->auxiliary);
8708 ata_cmd = (struct ata_pass_16 *)&csio->cdb_io.cdb_bytes;
8709 ata_cmd->opcode = ATA_PASS_16;
8710 ata_cmd->protocol = protocol;
8711 ata_cmd->flags = ata_flags;
8712 ata_cmd->features_ext = features >> 8;
8713 ata_cmd->features = features;
8714 ata_cmd->sector_count_ext = sector_count >> 8;
8715 ata_cmd->sector_count = sector_count;
8716 ata_cmd->lba_low = lba;
8717 ata_cmd->lba_mid = lba >> 8;
8718 ata_cmd->lba_high = lba >> 16;
8719 ata_cmd->device = ATA_DEV_LBA;
8721 ata_cmd->lba_low_ext = lba >> 24;
8722 ata_cmd->lba_mid_ext = lba >> 32;
8723 ata_cmd->lba_high_ext = lba >> 40;
8725 ata_cmd->device |= (lba >> 24) & 0x0f;
8726 ata_cmd->command = command;
8727 ata_cmd->control = control;
8750 scsi_cmd = (struct scsi_unmap *)&csio->cdb_io.cdb_bytes;
8751 scsi_cmd->opcode = UNMAP;
8752 scsi_cmd->byte2 = byte2;
8753 scsi_ulto4b(0, scsi_cmd->reserved);
8754 scsi_cmd->group = 0;
8755 scsi_ulto2b(dxfer_len, scsi_cmd->length);
8756 scsi_cmd->control = 0;
8779 scsi_cmd = (struct scsi_receive_diag *)&csio->cdb_io.cdb_bytes;
8781 scsi_cmd->opcode = RECEIVE_DIAGNOSTIC;
8783 scsi_cmd->byte2 |= SRD_PCV;
8784 scsi_cmd->page_code = page_code;
8786 scsi_ulto2b(allocation_length, scsi_cmd->length);
8810 scsi_cmd = (struct scsi_send_diag *)&csio->cdb_io.cdb_bytes;
8812 scsi_cmd->opcode = SEND_DIAGNOSTIC;
8815 * The default self-test mode control and specific test
8821 scsi_cmd->byte2 = ((self_test_code << SSD_SELF_TEST_CODE_SHIFT)
8827 scsi_ulto2b(param_list_length, scsi_cmd->length);
8851 scsi_cmd = (struct scsi_get_physical_element_status *)&csio->cdb_io.cdb_bytes;
8853 scsi_cmd->opcode = SERVICE_ACTION_IN;
8854 scsi_cmd->service_action = GET_PHYSICAL_ELEMENT_STATUS;
8855 scsi_ulto4b(starting_element, scsi_cmd->starting_element);
8856 scsi_ulto4b(allocation_length, scsi_cmd->allocation_length);
8879 scsi_cmd = (struct scsi_remove_element_and_truncate *)&csio->cdb_io.cdb_bytes;
8881 scsi_cmd->opcode = SERVICE_ACTION_IN;
8882 scsi_cmd->service_action = REMOVE_ELEMENT_AND_TRUNCATE;
8883 scsi_u64to8b(requested_capacity, scsi_cmd->requested_capacity);
8884 scsi_ulto4b(element_id, scsi_cmd->element_identifier);
8906 scsi_cmd = (struct scsi_service_action_in *)&csio->cdb_io.cdb_bytes;
8908 scsi_cmd->opcode = SERVICE_ACTION_IN;
8909 scsi_cmd->service_action = RESTORE_ELEMENTS_AND_REBUILD;
8933 scsi_cmd = (struct scsi_read_buffer *)&csio->cdb_io.cdb_bytes;
8935 scsi_cmd->opcode = READ_BUFFER;
8936 scsi_cmd->byte2 = mode;
8937 scsi_cmd->buffer_id = buffer_id;
8938 scsi_ulto3b(offset, scsi_cmd->offset);
8939 scsi_ulto3b(allocation_length, scsi_cmd->length);
8963 scsi_cmd = (struct scsi_write_buffer *)&csio->cdb_io.cdb_bytes;
8965 scsi_cmd->opcode = WRITE_BUFFER;
8966 scsi_cmd->byte2 = mode;
8967 scsi_cmd->buffer_id = buffer_id;
8968 scsi_ulto3b(offset, scsi_cmd->offset);
8969 scsi_ulto3b(param_list_length, scsi_cmd->length);
8992 scsi_cmd = (struct scsi_start_stop_unit *)&csio->cdb_io.cdb_bytes;
8994 scsi_cmd->opcode = START_STOP_UNIT;
8996 scsi_cmd->how |= SSS_START;
9001 scsi_cmd->how |= SSS_LOEJ;
9003 scsi_cmd->byte2 |= SSS_IMMED;
9028 scsi_cmd = (struct scsi_read_attribute *)&csio->cdb_io.cdb_bytes;
9031 scsi_cmd->opcode = READ_ATTRIBUTE;
9032 scsi_cmd->service_action = service_action;
9033 scsi_ulto2b(element, scsi_cmd->element);
9034 scsi_cmd->elem_type = elem_type;
9035 scsi_cmd->logical_volume = logical_volume;
9036 scsi_cmd->partition = partition;
9037 scsi_ulto2b(first_attribute, scsi_cmd->first_attribute);
9038 scsi_ulto4b(length, scsi_cmd->length);
9040 scsi_cmd->cache |= SRA_CACHE;
9063 scsi_cmd = (struct scsi_write_attribute *)&csio->cdb_io.cdb_bytes;
9066 scsi_cmd->opcode = WRITE_ATTRIBUTE;
9068 scsi_cmd->byte2 = SWA_WTC;
9069 scsi_ulto3b(element, scsi_cmd->element);
9070 scsi_cmd->logical_volume = logical_volume;
9071 scsi_cmd->partition = partition;
9072 scsi_ulto4b(length, scsi_cmd->length);
9095 scsi_cmd = (struct scsi_per_res_in *)&csio->cdb_io.cdb_bytes;
9098 scsi_cmd->opcode = PERSISTENT_RES_IN;
9099 scsi_cmd->action = service_action;
9100 scsi_ulto2b(dxfer_len, scsi_cmd->length);
9123 scsi_cmd = (struct scsi_per_res_out *)&csio->cdb_io.cdb_bytes;
9126 scsi_cmd->opcode = PERSISTENT_RES_OUT;
9127 scsi_cmd->action = service_action;
9128 scsi_cmd->scope_type = scope | res_type;
9129 scsi_ulto4b(dxfer_len, scsi_cmd->length);
9153 scsi_cmd = (struct scsi_security_protocol_in *)&csio->cdb_io.cdb_bytes;
9156 scsi_cmd->opcode = SECURITY_PROTOCOL_IN;
9158 scsi_cmd->security_protocol = security_protocol;
9160 scsi_cmd->security_protocol_specific);
9161 scsi_cmd->byte4 = byte4;
9162 scsi_ulto4b(dxfer_len, scsi_cmd->length);
9186 scsi_cmd = (struct scsi_security_protocol_out *)&csio->cdb_io.cdb_bytes;
9189 scsi_cmd->opcode = SECURITY_PROTOCOL_OUT;
9191 scsi_cmd->security_protocol = security_protocol;
9193 scsi_cmd->security_protocol_specific);
9194 scsi_cmd->byte4 = byte4;
9195 scsi_ulto4b(dxfer_len, scsi_cmd->length);
9219 &csio->cdb_io.cdb_bytes;
9222 scsi_cmd->opcode = MAINTENANCE_IN;
9223 scsi_cmd->service_action = REPORT_SUPPORTED_OPERATION_CODES;
9224 scsi_cmd->options = options;
9225 scsi_cmd->requested_opcode = req_opcode;
9226 scsi_ulto2b(req_service_action, scsi_cmd->requested_service_action);
9227 scsi_ulto4b(dxfer_len, scsi_cmd->length);
9254 if (((SID_TYPE(inq) == entry->type)
9255 || (entry->type == T_ANY))
9256 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE
9257 : entry->media_type & SIP_MEDIA_FIXED)
9258 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0)
9259 && (cam_strmatch(inq->product, entry->product,
9260 sizeof(inq->product)) == 0)
9261 && (cam_strmatch(inq->revision, entry->revision,
9262 sizeof(inq->revision)) == 0)) {
9265 return (-1);
9281 if (((SID_TYPE(inq) == entry->type)
9282 || (entry->type == T_ANY))
9283 && (SID_IS_REMOVABLE(inq) ? entry->media_type & SIP_MEDIA_REMOVABLE
9284 : entry->media_type & SIP_MEDIA_FIXED)
9285 && (cam_strmatch(inq->vendor, entry->vendor, sizeof(inq->vendor)) == 0)
9286 && (cam_strmatch(inq->product, entry->product,
9287 sizeof(inq->product)) == 0)
9288 && (cam_strmatch(inq->revision, entry->revision,
9289 sizeof(inq->revision)) == 0)) {
9292 return (-1);
9303 * \return 0 on a match, -1 otherwise.
9328 (lhs_end - __offsetof(struct scsi_vpd_id_descriptor, identifier));
9330 (rhs_end - __offsetof(struct scsi_vpd_id_descriptor, identifier));
9334 && (lhs_id->identifier + lhs_id->length) <= lhs_end) {
9339 && (rhs_id->identifier + rhs_id->length) <= rhs_end) {
9340 if ((rhs_id->id_type &
9342 (lhs_id->id_type &
9344 && rhs_id->length == lhs_id->length
9345 && memcmp(rhs_id->identifier, lhs_id->identifier,
9346 rhs_id->length) == 0)
9350 (rhs_id->identifier + rhs_id->length);
9353 (lhs_id->identifier + lhs_id->length);
9355 return (-1);
9366 device = periph->path->device;
9367 vpds = (struct scsi_vpd_supported_pages *)device->supported_vpds;
9370 num_pages = device->supported_vpds_len -
9373 if (vpds->page_list[i] == page_id)
9403 if (error != 0 || req->newptr == NULL)