summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/lib/pkcs11/pkcs11_softtoken/common/softAESCrypt.c16
-rw-r--r--usr/src/pkg/manifests/system-test-cryptotest.mf6
-rw-r--r--usr/src/uts/common/io/sata/adapters/ahci/ahci.c22
-rw-r--r--usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c131
-rw-r--r--usr/src/uts/common/sys/usb/scsa2usb/scsa2usb.h22
5 files changed, 158 insertions, 39 deletions
diff --git a/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAESCrypt.c b/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAESCrypt.c
index 781b205b77..94486bbc20 100644
--- a/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAESCrypt.c
+++ b/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAESCrypt.c
@@ -970,10 +970,10 @@ soft_aes_decrypt_update(soft_session_t *session_p, CK_BYTE_PTR pEncryptedData,
*
* Some things to note:
* - The above semantics will cause aes_ctx->ac_remainder to
- * never accumulate more than AES_BLOCK_LEN bytes of ciphertext.
- * Once we reach at least AES_BLOCK_LEN + 1 bytes, we will
- * decrypt the contents of aes_ctx->ac_remainder by one of
- * the last two scenarios described above.
+ * never accumulate more than AES_BLOCK_LEN bytes of
+ * ciphertext. Once we reach at least AES_BLOCK_LEN + 1 bytes,
+ * we will decrypt the contents of aes_ctx->ac_remainder by one
+ * of the last two scenarios described above.
*
* - We must always end up with AES_BLOCK_LEN bytes of data
* in aes_ctx->ac_remainder when C_DecryptFinal() is called.
@@ -1115,6 +1115,14 @@ soft_aes_decrypt_update(soft_session_t *session_p, CK_BYTE_PTR pEncryptedData,
*pulDataLen = out.cd_offset;
switch (mech) {
+ case CKM_AES_CTR:
+ if (aes_ctx->ac_remainder_len == 0) {
+ break;
+ }
+ rc = ctr_mode_final((ctr_ctx_t *)aes_ctx, &out,
+ aes_encrypt_block);
+ rv = crypto2pkcs11_error_number(rc);
+ break;
case CKM_AES_CBC_PAD:
if (buffer_block == NULL) {
break;
diff --git a/usr/src/pkg/manifests/system-test-cryptotest.mf b/usr/src/pkg/manifests/system-test-cryptotest.mf
index 723180d417..2ef1c75749 100644
--- a/usr/src/pkg/manifests/system-test-cryptotest.mf
+++ b/usr/src/pkg/manifests/system-test-cryptotest.mf
@@ -85,6 +85,12 @@ file opt/crypto-tests/tests/aes/pkcs/aes_cbc_32 \
file opt/crypto-tests/tests/aes/pkcs/aes_cbc_64 \
path=opt/crypto-tests/tests/aes/pkcs/aes_cbc_64 group=root mode=0555 \
owner=root
+file opt/crypto-tests/tests/aes/pkcs/aes_cbc_pad_32 \
+ path=opt/crypto-tests/tests/aes/pkcs/aes_cbc_pad_32 group=root mode=0555 \
+ owner=root
+file opt/crypto-tests/tests/aes/pkcs/aes_cbc_pad_64 \
+ path=opt/crypto-tests/tests/aes/pkcs/aes_cbc_pad_64 group=root mode=0555 \
+ owner=root
file opt/crypto-tests/tests/aes/pkcs/aes_ccm_32 \
path=opt/crypto-tests/tests/aes/pkcs/aes_ccm_32 group=root mode=0555 \
owner=root
diff --git a/usr/src/uts/common/io/sata/adapters/ahci/ahci.c b/usr/src/uts/common/io/sata/adapters/ahci/ahci.c
index 5e5016dd1c..0e342e8bcc 100644
--- a/usr/src/uts/common/io/sata/adapters/ahci/ahci.c
+++ b/usr/src/uts/common/io/sata/adapters/ahci/ahci.c
@@ -10663,8 +10663,6 @@ ahci_em_init(ahci_ctl_t *ahci_ctlp)
return (B_TRUE);
}
- ahci_ctlp->ahcictl_em_flags |= AHCI_EM_PRESENT;
-
ahci_ctlp->ahcictl_em_tx_off = ((ahci_ctlp->ahcictl_em_loc &
AHCI_HBA_EM_LOC_OFST_MASK) >> AHCI_HBA_EM_LOC_OFST_SHIFT) * 4;
ahci_ctlp->ahcictl_em_tx_off += ahci_ctlp->ahcictl_ahci_addr;
@@ -10683,7 +10681,7 @@ ahci_em_init(ahci_ctl_t *ahci_ctlp)
}
mutex_enter(&ahci_ctlp->ahcictl_mutex);
- ahci_ctlp->ahcictl_em_flags |= AHCI_EM_RESETTING;
+ ahci_ctlp->ahcictl_em_flags |= AHCI_EM_PRESENT | AHCI_EM_RESETTING;
mutex_exit(&ahci_ctlp->ahcictl_mutex);
(void) ddi_taskq_dispatch(ahci_ctlp->ahcictl_em_taskq, ahci_em_reset,
ahci_ctlp, DDI_SLEEP);
@@ -10697,6 +10695,10 @@ ahci_em_ioctl_get(ahci_ctl_t *ahci_ctlp, intptr_t arg)
int i;
ahci_ioc_em_get_t get;
+ if ((ahci_ctlp->ahcictl_em_flags & AHCI_EM_PRESENT) == 0) {
+ return (ENOTSUP);
+ }
+
bzero(&get, sizeof (get));
get.aiemg_nports = ahci_ctlp->ahcictl_ports_implemented;
if ((ahci_ctlp->ahcictl_em_ctl & AHCI_HBA_EM_CTL_ATTR_ALHD) == 0) {
@@ -10751,6 +10753,10 @@ ahci_em_ioctl_set(ahci_ctl_t *ahci_ctlp, intptr_t arg)
return (EINVAL);
}
+ if ((ahci_ctlp->ahcictl_em_flags & AHCI_EM_PRESENT) == 0) {
+ return (ENOTSUP);
+ }
+
if ((set.aiems_leds & AHCI_EM_LED_ACTIVITY_DISABLE) != 0 &&
((ahci_ctlp->ahcictl_em_ctl & AHCI_HBA_EM_CTL_ATTR_ALHD) != 0)) {
return (ENOTSUP);
@@ -10838,9 +10844,11 @@ ahci_em_ioctl(dev_info_t *dip, int cmd, intptr_t arg)
static void
ahci_em_quiesce(ahci_ctl_t *ahci_ctlp)
{
- ASSERT(ahci_ctlp->ahcictl_em_flags & AHCI_EM_PRESENT);
-
mutex_enter(&ahci_ctlp->ahcictl_mutex);
+ if ((ahci_ctlp->ahcictl_em_flags & AHCI_EM_PRESENT) == 0) {
+ mutex_exit(&ahci_ctlp->ahcictl_mutex);
+ return;
+ }
ahci_ctlp->ahcictl_em_flags |= AHCI_EM_QUIESCE;
mutex_exit(&ahci_ctlp->ahcictl_mutex);
@@ -10861,6 +10869,10 @@ static void
ahci_em_resume(ahci_ctl_t *ahci_ctlp)
{
mutex_enter(&ahci_ctlp->ahcictl_mutex);
+ if ((ahci_ctlp->ahcictl_em_flags & AHCI_EM_PRESENT) == 0) {
+ mutex_exit(&ahci_ctlp->ahcictl_mutex);
+ return;
+ }
ahci_ctlp->ahcictl_em_flags |= AHCI_EM_RESETTING;
mutex_exit(&ahci_ctlp->ahcictl_mutex);
diff --git a/usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c b/usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c
index fc20795a8b..c35e1bdb6a 100644
--- a/usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c
+++ b/usr/src/uts/common/io/usb/scsa2usb/scsa2usb.c
@@ -24,6 +24,7 @@
*
* Copyright 2016 Joyent, Inc.
* Copyright (c) 2016 by Delphix. All rights reserved.
+ * Copyright 2019 Joshua M. Clulow <josh@sysmgr.org>
*/
@@ -150,9 +151,11 @@ static int scsa2usb_open_usb_pipes(scsa2usb_state_t *);
void scsa2usb_close_usb_pipes(scsa2usb_state_t *);
static void scsa2usb_fill_up_cdb_len(scsa2usb_cmd_t *, int);
-static void scsa2usb_fill_up_cdb_lba(scsa2usb_cmd_t *, int);
+static void scsa2usb_fill_up_cdb_lba(scsa2usb_cmd_t *, uint64_t);
+static void scsa2usb_fill_up_g4_cdb_lba(scsa2usb_cmd_t *, uint64_t);
static void scsa2usb_fill_up_ReadCD_cdb_len(scsa2usb_cmd_t *, int, int);
static void scsa2usb_fill_up_12byte_cdb_len(scsa2usb_cmd_t *, int, int);
+static void scsa2usb_fill_up_16byte_cdb_len(scsa2usb_cmd_t *, int, int);
static int scsa2usb_read_cd_blk_size(uchar_t);
int scsa2usb_rw_transport(scsa2usb_state_t *, struct scsi_pkt *);
void scsa2usb_setup_next_xfer(scsa2usb_state_t *, scsa2usb_cmd_t *);
@@ -242,6 +245,8 @@ static char *scsa2usb_cmds[] = {
"\135sendcuesheet",
"\136prin",
"\137prout",
+ "\210read16",
+ "\212write16",
"\241blankcd",
"\245playaudio12",
"\250read12",
@@ -477,7 +482,7 @@ static struct cb_ops scsa2usb_cbops = {
ddi_prop_op, /* prop_op */
NULL, /* stream */
D_MP, /* cb_flag */
- CB_REV, /* rev */
+ CB_REV, /* rev */
nodev, /* int (*cb_aread)() */
nodev /* int (*cb_awrite)() */
};
@@ -627,7 +632,7 @@ scsa2usb_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
usb_ep_data_t *ep_data;
usb_client_dev_data_t *dev_data;
usb_alt_if_data_t *altif_data;
- usb_ugen_info_t usb_ugen_info;
+ usb_ugen_info_t usb_ugen_info;
USB_DPRINTF_L4(DPRINT_MASK_SCSA, NULL,
"scsa2usb_attach: dip = 0x%p", (void *)dip);
@@ -663,7 +668,7 @@ scsa2usb_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
return (DDI_FAILURE);
}
- scsa2usbp->scsa2usb_dip = dip;
+ scsa2usbp->scsa2usb_dip = dip;
scsa2usbp->scsa2usb_instance = instance;
/* allocate a log handle for debug/error messages */
@@ -698,7 +703,7 @@ scsa2usb_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
dev_data->dev_iblock_cookie);
}
mutex_enter(&scsa2usbp->scsa2usb_mutex);
- scsa2usbp->scsa2usb_dip = dip;
+ scsa2usbp->scsa2usb_dip = dip;
scsa2usbp->scsa2usb_instance = instance;
scsa2usbp->scsa2usb_attrs = SCSA2USB_ALL_ATTRS;
scsa2usbp->scsa2usb_dev_data = dev_data;
@@ -3375,6 +3380,8 @@ scsa2usb_handle_scsi_cmd_sub_class(scsa2usb_state_t *scsa2usbp,
case SCMD_WRITE:
case SCMD_READ_G1:
case SCMD_WRITE_G1:
+ case SCMD_READ_G4:
+ case SCMD_WRITE_G4:
case SCMD_READ_G5:
case SCMD_WRITE_G5:
case SCMD_READ_LONG:
@@ -3719,12 +3726,13 @@ scsa2usb_handle_ufi_subclass_cmd(scsa2usb_state_t *scsa2usbp,
case SCMD_WRITE:
case SCMD_READ_G1:
case SCMD_WRITE_G1:
+ case SCMD_READ_G4:
+ case SCMD_WRITE_G4:
case SCMD_READ_G5:
case SCMD_WRITE_G5:
case SCMD_READ_LONG:
case SCMD_WRITE_LONG:
case SCMD_READ_CD:
-
return (scsa2usb_rw_transport(scsa2usbp, pkt));
case SCMD_TEST_UNIT_READY:
@@ -3811,7 +3819,8 @@ int
scsa2usb_rw_transport(scsa2usb_state_t *scsa2usbp, struct scsi_pkt *pkt)
{
scsa2usb_cmd_t *cmd = PKT2CMD(pkt);
- int lba, dir, opcode;
+ int dir, opcode;
+ uint64_t lba;
struct buf *bp = cmd->cmd_bp;
size_t len, xfer_count;
size_t blk_size; /* calculate the block size to be used */
@@ -3823,7 +3832,7 @@ scsa2usb_rw_transport(scsa2usb_state_t *scsa2usbp, struct scsi_pkt *pkt)
ASSERT(mutex_owned(&scsa2usbp->scsa2usb_mutex));
opcode = pkt->pkt_cdbp[0];
- blk_size = scsa2usbp->scsa2usb_lbasize[pkt->pkt_address.a_lun];
+ blk_size = scsa2usbp->scsa2usb_lbasize[pkt->pkt_address.a_lun];
/* set to default */
switch (opcode) {
@@ -3854,8 +3863,9 @@ scsa2usb_rw_transport(scsa2usb_state_t *scsa2usbp, struct scsi_pkt *pkt)
lba = SCSA2USB_LBA_10BYTE(pkt);
len = SCSA2USB_LEN_10BYTE(pkt);
dir = USB_EP_DIR_OUT;
- if (len) {
- sz = SCSA2USB_CDRW_BLKSZ(bp ? bp->b_bcount : 0, len);
+ if (len > 0) {
+ sz = SCSA2USB_CDRW_BLKSZ(bp != NULL ?
+ bp->b_bcount : 0, len);
if (SCSA2USB_VALID_CDRW_BLKSZ(sz)) {
blk_size = sz; /* change it accordingly */
}
@@ -3869,6 +3879,16 @@ scsa2usb_rw_transport(scsa2usb_state_t *scsa2usbp, struct scsi_pkt *pkt)
/* Figure out the block size */
blk_size = scsa2usb_read_cd_blk_size(pkt->pkt_cdbp[1] >> 2);
break;
+ case SCMD_READ_G4:
+ lba = SCSA2USB_LBA_16BYTE(pkt);
+ len = SCSA2USB_LEN_16BYTE(pkt);
+ dir = USB_EP_DIR_IN;
+ break;
+ case SCMD_WRITE_G4:
+ lba = SCSA2USB_LBA_16BYTE(pkt);
+ len = SCSA2USB_LEN_16BYTE(pkt);
+ dir = USB_EP_DIR_OUT;
+ break;
case SCMD_READ_G5:
lba = SCSA2USB_LBA_12BYTE(pkt);
len = SCSA2USB_LEN_12BYTE(pkt);
@@ -3884,8 +3904,8 @@ scsa2usb_rw_transport(scsa2usb_state_t *scsa2usbp, struct scsi_pkt *pkt)
cmd->cmd_total_xfercount = xfer_count = len * blk_size;
/* reduce xfer count if necessary */
- if (blk_size &&
- (xfer_count > scsa2usbp->scsa2usb_max_bulk_xfer_size)) {
+ if (blk_size != 0 &&
+ xfer_count > scsa2usbp->scsa2usb_max_bulk_xfer_size) {
/*
* For CD-RW devices reduce the xfer count based
* on the block size used by these devices. The
@@ -3898,13 +3918,13 @@ scsa2usb_rw_transport(scsa2usb_state_t *scsa2usbp, struct scsi_pkt *pkt)
* The len part of the cdb changes as a result of that.
*/
if (SCSA2USB_VALID_CDRW_BLKSZ(blk_size)) {
- xfer_count = ((scsa2usbp->scsa2usb_max_bulk_xfer_size/
- blk_size) * blk_size);
- len = xfer_count/blk_size;
+ xfer_count = (scsa2usbp->scsa2usb_max_bulk_xfer_size /
+ blk_size) * blk_size;
+ len = xfer_count / blk_size;
xfer_count = blk_size * len;
} else {
xfer_count = scsa2usbp->scsa2usb_max_bulk_xfer_size;
- len = xfer_count/blk_size;
+ len = xfer_count / blk_size;
}
}
@@ -3921,19 +3941,25 @@ scsa2usb_rw_transport(scsa2usb_state_t *scsa2usbp, struct scsi_pkt *pkt)
case SCMD_READ_CD:
bcopy(pkt->pkt_cdbp, &cmd->cmd_cdb, cmd->cmd_cdblen);
scsa2usb_fill_up_ReadCD_cdb_len(cmd, len, CDB_GROUP5);
+ scsa2usb_fill_up_cdb_lba(cmd, lba);
+ break;
+ case SCMD_WRITE_G4:
+ case SCMD_READ_G4:
+ scsa2usb_fill_up_16byte_cdb_len(cmd, len, CDB_GROUP4);
+ scsa2usb_fill_up_g4_cdb_lba(cmd, lba);
break;
case SCMD_WRITE_G5:
case SCMD_READ_G5:
scsa2usb_fill_up_12byte_cdb_len(cmd, len, CDB_GROUP5);
+ scsa2usb_fill_up_cdb_lba(cmd, lba);
break;
default:
scsa2usb_fill_up_cdb_len(cmd, len);
cmd->cmd_actual_len = CDB_GROUP1;
+ scsa2usb_fill_up_cdb_lba(cmd, lba);
break;
}
- scsa2usb_fill_up_cdb_lba(cmd, lba);
-
USB_DPRINTF_L3(DPRINT_MASK_SCSA, scsa2usbp->scsa2usb_log_handle,
"bcount=0x%lx lba=0x%x len=0x%lx xfercount=0x%lx total=0x%lx",
bp ? bp->b_bcount : 0, lba, len, cmd->cmd_xfercount,
@@ -4011,10 +4037,23 @@ scsa2usb_setup_next_xfer(scsa2usb_state_t *scsa2usbp, scsa2usb_cmd_t *cmd)
/* calculate lba = current_lba + len_of_prev_cmd */
cmd->cmd_lba += (cmd->cmd_cdb[6] << 16) +
(cmd->cmd_cdb[7] << 8) + cmd->cmd_cdb[8];
- cdb_len = xfer_len/cmd->cmd_blksize;
+ cdb_len = xfer_len / cmd->cmd_blksize;
cmd->cmd_cdb[SCSA2USB_READ_CD_LEN_2] = (uchar_t)cdb_len;
/* re-adjust xfer count */
cmd->cmd_xfercount = cdb_len * cmd->cmd_blksize;
+ scsa2usb_fill_up_cdb_lba(cmd, cmd->cmd_lba);
+ break;
+ case SCMD_WRITE_G4:
+ case SCMD_READ_G4:
+ /* calculate lba = current_lba + len_of_prev_cmd */
+ cmd->cmd_lba += (cmd->cmd_cdb[10] << 24) +
+ (cmd->cmd_cdb[11] << 16) + (cmd->cmd_cdb[12] << 8) +
+ cmd->cmd_cdb[13];
+ if (blk_size != 0) {
+ xfer_len /= blk_size;
+ }
+ scsa2usb_fill_up_16byte_cdb_len(cmd, xfer_len, CDB_GROUP5);
+ scsa2usb_fill_up_g4_cdb_lba(cmd, cmd->cmd_lba);
break;
case SCMD_WRITE_G5:
case SCMD_READ_G5:
@@ -4022,10 +4061,11 @@ scsa2usb_setup_next_xfer(scsa2usb_state_t *scsa2usbp, scsa2usb_cmd_t *cmd)
cmd->cmd_lba += (cmd->cmd_cdb[6] << 24) +
(cmd->cmd_cdb[7] << 16) + (cmd->cmd_cdb[8] << 8) +
cmd->cmd_cdb[9];
- if (blk_size) {
+ if (blk_size != 0) {
xfer_len /= blk_size;
}
scsa2usb_fill_up_12byte_cdb_len(cmd, xfer_len, CDB_GROUP5);
+ scsa2usb_fill_up_cdb_lba(cmd, cmd->cmd_lba);
break;
case SCMD_WRITE_G1:
case SCMD_WRITE_LONG:
@@ -4034,22 +4074,23 @@ scsa2usb_setup_next_xfer(scsa2usb_state_t *scsa2usbp, scsa2usb_cmd_t *cmd)
if (SCSA2USB_VALID_CDRW_BLKSZ(cmd->cmd_blksize)) {
blk_size = cmd->cmd_blksize;
}
- cdb_len = xfer_len/blk_size;
+ cdb_len = xfer_len / blk_size;
scsa2usb_fill_up_cdb_len(cmd, cdb_len);
/* re-adjust xfer count */
cmd->cmd_xfercount = cdb_len * blk_size;
+ scsa2usb_fill_up_cdb_lba(cmd, cmd->cmd_lba);
break;
default:
- if (blk_size) {
+ if (blk_size != 0) {
xfer_len /= blk_size;
}
scsa2usb_fill_up_cdb_len(cmd, xfer_len);
- cmd->cmd_lba += scsa2usbp->scsa2usb_max_bulk_xfer_size/blk_size;
+ cmd->cmd_lba += scsa2usbp->scsa2usb_max_bulk_xfer_size /
+ blk_size;
+ scsa2usb_fill_up_cdb_lba(cmd, cmd->cmd_lba);
+ break;
}
- /* fill in the lba */
- scsa2usb_fill_up_cdb_lba(cmd, cmd->cmd_lba);
-
USB_DPRINTF_L4(DPRINT_MASK_SCSA, scsa2usbp->scsa2usb_log_handle,
"scsa2usb_setup_next_xfer:\n\tlba = 0x%x xfer_len = 0x%x "
"xfercount = 0x%lx total = 0x%lx", cmd->cmd_lba, xfer_len,
@@ -4694,7 +4735,7 @@ scsa2usb_close_usb_pipes(scsa2usb_state_t *scsa2usbp)
* fill up command CDBs' LBA part
*/
static void
-scsa2usb_fill_up_cdb_lba(scsa2usb_cmd_t *cmd, int lba)
+scsa2usb_fill_up_cdb_lba(scsa2usb_cmd_t *cmd, uint64_t lba)
{
/* zero cdb1, lba bits so they won't get copied in the new cdb */
cmd->cmd_cdb[SCSA2USB_LUN] &= 0xE0;
@@ -4707,6 +4748,27 @@ scsa2usb_fill_up_cdb_lba(scsa2usb_cmd_t *cmd, int lba)
/*
+ * scsa2usb_fill_up_g4_cdb_lba:
+ * fill in the CDB for a Group 4 command (16-byte CDB)
+ */
+static void
+scsa2usb_fill_up_g4_cdb_lba(scsa2usb_cmd_t *cmd, uint64_t lba)
+{
+ /* zero cdb1, lba bits so they won't get copied in the new cdb */
+ cmd->cmd_cdb[SCSA2USB_LUN] &= 0xE0;
+ cmd->cmd_cdb[2] = lba >> 56;
+ cmd->cmd_cdb[3] = lba >> 48;
+ cmd->cmd_cdb[4] = lba >> 40;
+ cmd->cmd_cdb[5] = lba >> 32;
+ cmd->cmd_cdb[6] = lba >> 24;
+ cmd->cmd_cdb[7] = lba >> 16;
+ cmd->cmd_cdb[8] = lba >> 8;
+ cmd->cmd_cdb[9] = lba;
+ cmd->cmd_lba = lba;
+}
+
+
+/*
* scsa2usb_fill_up_ReadCD_cdb_len:
* fill up READ_CD command CDBs' len part
*/
@@ -4721,6 +4783,21 @@ scsa2usb_fill_up_ReadCD_cdb_len(scsa2usb_cmd_t *cmd, int len, int actual_len)
/*
+ * scsa2usb_fill_up_16byte_cdb_len:
+ * populate CDB length field for SCMD_WRITE_G4 and SCMD_READ_G4
+ */
+static void
+scsa2usb_fill_up_16byte_cdb_len(scsa2usb_cmd_t *cmd, int len, int actual_len)
+{
+ cmd->cmd_cdb[10] = len >> 24;
+ cmd->cmd_cdb[11] = len >> 16;
+ cmd->cmd_cdb[12] = len >> 8;
+ cmd->cmd_cdb[13] = len;
+ cmd->cmd_actual_len = actual_len;
+}
+
+
+/*
* scsa2usb_fill_up_12byte_cdb_len:
* fill up generic 12-byte command CDBs' len part
*/
diff --git a/usr/src/uts/common/sys/usb/scsa2usb/scsa2usb.h b/usr/src/uts/common/sys/usb/scsa2usb/scsa2usb.h
index 32de7e6eca..c619a32e64 100644
--- a/usr/src/uts/common/sys/usb/scsa2usb/scsa2usb.h
+++ b/usr/src/uts/common/sys/usb/scsa2usb/scsa2usb.h
@@ -22,6 +22,7 @@
* Use is subject to license terms.
*
* Copyright 2019, Joyent, Inc.
+ * Copyright 2019 Joshua M. Clulow <josh@sysmgr.org>
*/
#ifndef _SYS_USB_SCSA2USB_H
@@ -546,7 +547,7 @@ typedef struct scsa2usb_cmd {
/* used in multiple xfers */
size_t cmd_total_xfercount; /* total xfer val */
size_t cmd_offset; /* offset into buf */
- int cmd_lba; /* current xfer lba */
+ uint64_t cmd_lba; /* current xfer lba */
int cmd_done; /* command done? */
int cmd_blksize; /* block size */
usba_list_entry_t cmd_waitQ; /* waitQ element */
@@ -567,7 +568,9 @@ _NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_device scsi_address))
#define SCSA2USB_LEN_0 7 /* LEN[0] field */
#define SCSA2USB_LEN_1 8 /* LEN[1] field */
-/* macros to calculate LBA for 6/10/12-byte commands */
+/*
+ * Extract LBA and length from 6, 10, 12, and 16-byte commands:
+ */
#define SCSA2USB_LBA_6BYTE(pkt) \
(((pkt)->pkt_cdbp[1] & 0x1f) << 16) + \
((pkt)->pkt_cdbp[2] << 8) + (pkt)->pkt_cdbp[3]
@@ -586,9 +589,22 @@ _NOTE(SCHEME_PROTECTS_DATA("stable data", scsi_device scsi_address))
((pkt)->pkt_cdbp[2] << 24) + ((pkt)->pkt_cdbp[3] << 16) + \
((pkt)->pkt_cdbp[4] << 8) + (pkt)->pkt_cdbp[5]
+#define SCSA2USB_LEN_16BYTE(pkt) \
+ (((pkt)->pkt_cdbp[10] << 24) + ((pkt)->pkt_cdbp[11] << 16) + \
+ ((pkt)->pkt_cdbp[12] << 8) + (pkt)->pkt_cdbp[13])
+#define SCSA2USB_LBA_16BYTE(pkt) ((uint64_t)( \
+ ((uint64_t)(pkt)->pkt_cdbp[2] << 56) + \
+ ((uint64_t)(pkt)->pkt_cdbp[3] << 48) + \
+ ((uint64_t)(pkt)->pkt_cdbp[4] << 40) + \
+ ((uint64_t)(pkt)->pkt_cdbp[5] << 32) + \
+ ((uint64_t)(pkt)->pkt_cdbp[6] << 24) + \
+ ((uint64_t)(pkt)->pkt_cdbp[7] << 16) + \
+ ((uint64_t)(pkt)->pkt_cdbp[8] << 8) + \
+ ((uint64_t)(pkt)->pkt_cdbp[9])))
+
/* macros to convert a pkt to cmd and vice-versa */
#define PKT2CMD(pkt) ((scsa2usb_cmd_t *)(pkt)->pkt_ha_private)
-#define CMD2PKT(sp) ((sp)->cmd_pkt
+#define CMD2PKT(sp) ((sp)->cmd_pkt)
/* bulk pipe default timeout value - how long the command to be tried? */
#define SCSA2USB_BULK_PIPE_TIMEOUT (2 * USB_PIPE_TIMEOUT)