-/* $OpenBSD: vioscsi.c,v 1.8 2018/07/15 14:36:54 reyk Exp $ */
+/* $OpenBSD: vioscsi.c,v 1.9 2018/07/15 14:42:04 reyk Exp $ */
/*
* Copyright (c) 2017 Carlos Cardenas <ccardenas@openbsd.org>
inq = (struct scsi_inquiry *)(req->cdb);
inq_len = (uint16_t)_2btol(inq->length);
- DPRINTF("%s: INQ - EVPD %d PAGE_CODE 0x%08x LEN %d", __func__,
+ log_debug("%s: INQ - EVPD %d PAGE_CODE 0x%08x LEN %d", __func__,
inq->flags & SI_EVPD, inq->pagecode, inq_len);
vioscsi_prepare_resp(&resp,
mode_page_ctl = mode_sense->page & SMS_PAGE_CTRL;
mode_page_code = mode_sense->page & SMS_PAGE_CODE;
- DPRINTF("%s: M_SENSE - DBD %d Page Ctrl 0x%x Code 0x%x Len %u",
+ log_debug("%s: M_SENSE - DBD %d Page Ctrl 0x%x Code 0x%x Len %u",
__func__, mode_sense->byte2 & SMS_DBD, mode_page_ctl,
mode_page_code, mode_sense->length);
mode_page_code = mode_sense_10->page & SMS_PAGE_CODE;
mode_sense_len = (uint16_t)_2btol(mode_sense_10->length);
- DPRINTF("%s: M_SENSE_10 - DBD %d Page Ctrl 0x%x Code 0x%x Len %u",
+ log_debug("%s: M_SENSE_10 - DBD %d Page Ctrl 0x%x Code 0x%x Len %u",
__func__, mode_sense_10->byte2 & SMS_DBD, mode_page_ctl,
mode_page_code, mode_sense_len);
memset(&resp, 0, sizeof(resp));
r_cap = (struct scsi_read_capacity *)(req->cdb);
r_cap_addr = _4btol(r_cap->addr);
- DPRINTF("%s: %s - Addr 0x%08x", __func__,
+ log_debug("%s: %s - Addr 0x%08x", __func__,
vioscsi_op_names(r_cap->opcode), r_cap_addr);
vioscsi_prepare_resp(&resp,
goto read_capacity_out;
}
- DPRINTF("%s: ISO has %lld bytes and %lld blocks",
+ log_debug("%s: ISO has %lld bytes and %lld blocks",
__func__, dev->sz, dev->n_blocks);
/*
memset(&resp, 0, sizeof(resp));
r_cap_16 = (struct scsi_read_capacity_16 *)(req->cdb);
r_cap_addr_16 = _8btol(r_cap_16->addr);
- DPRINTF("%s: %s - Addr 0x%016llx", __func__,
+ log_debug("%s: %s - Addr 0x%016llx", __func__,
vioscsi_op_names(r_cap_16->opcode), r_cap_addr_16);
vioscsi_prepare_resp(&resp, VIRTIO_SCSI_S_OK, SCSI_OK, 0, 0, 0);
goto read_capacity_16_out;
}
- DPRINTF("%s: ISO has %lld bytes and %lld blocks", __func__,
+ log_debug("%s: ISO has %lld bytes and %lld blocks", __func__,
dev->sz, dev->n_blocks);
_lto8b(dev->n_blocks - 1, r_cap_data_16->addr);
rpl = (struct scsi_report_luns *)(req->cdb);
rpl_length = _4btol(rpl->length);
- DPRINTF("%s: REPORT_LUNS Report 0x%x Length %d", __func__,
+ log_debug("%s: REPORT_LUNS Report 0x%x Length %d", __func__,
rpl->selectreport, rpl_length);
if (rpl_length < RPL_MIN_SIZE) {
- DPRINTF("%s: RPL_Length %d < %d (RPL_MIN_SIZE)", __func__,
+ log_debug("%s: RPL_Length %d < %d (RPL_MIN_SIZE)", __func__,
rpl_length, RPL_MIN_SIZE);
vioscsi_prepare_resp(&resp,
read_lba = ((read_6->addr[0] & SRW_TOPADDR) << 16 ) |
(read_6->addr[1] << 8) | read_6->addr[2];
- DPRINTF("%s: READ Addr 0x%08x Len %d (%d)",
+ log_debug("%s: READ Addr 0x%08x Len %d (%d)",
__func__, read_lba, read_6->length, read_6->length * dev->max_xfer);
/* check if lba is in range */
if (read_lba > dev->n_blocks - 1) {
- DPRINTF("%s: requested block out of range req: %ud max: %lld",
+ log_debug("%s: requested block out of range req: %ud max: %lld",
__func__, read_lba, dev->n_blocks);
vioscsi_prepare_resp(&resp,
read_10_len = _2btol(read_10->length);
chunk_offset = 0;
- DPRINTF("%s: READ_10 Addr 0x%08x Len %d (%d)",
+ log_debug("%s: READ_10 Addr 0x%08x Len %d (%d)",
__func__, read_lba, read_10_len, read_10_len * dev->max_xfer);
/* check if lba is in range */
if (read_lba > dev->n_blocks - 1) {
- DPRINTF("%s: requested block out of range req: %ud max: %lld",
+ log_debug("%s: requested block out of range req: %ud max: %lld",
__func__, read_lba, dev->n_blocks);
vioscsi_prepare_resp(&resp,
vioscsi_prepare_resp(&resp, VIRTIO_SCSI_S_OK, SCSI_OK, 0, 0, 0);
if (dev->locked) {
- DPRINTF("%s: unlocking medium", __func__);
+ log_debug("%s: unlocking medium", __func__);
} else {
- DPRINTF("%s: locking medium", __func__);
+ log_debug("%s: locking medium", __func__);
}
dev->locked = dev->locked ? 0 : 1;
memset(&resp, 0, sizeof(resp));
mech_status = (struct scsi_mechanism_status *)(req->cdb);
mech_status_len = (uint16_t)_2btol(mech_status->length);
- DPRINTF("%s: MECH_STATUS Len %u", __func__, mech_status_len);
+ log_debug("%s: MECH_STATUS Len %u", __func__, mech_status_len);
mech_status_header = calloc(1, sizeof(*mech_status_header));
memset(&resp, 0, sizeof(resp));
toc = (struct scsi_read_toc *)(req->cdb);
toc_len = (uint16_t)_2btol(toc->data_len);
- DPRINTF("%s: %s - MSF %d Track 0x%02x Addr 0x%04x",
+ log_debug("%s: %s - MSF %d Track 0x%02x Addr 0x%04x",
__func__, vioscsi_op_names(toc->opcode),
((toc->byte2 >> 1) & 1), toc->from_track, toc_len);
if (toc->from_track > 1 &&
toc->from_track != READ_TOC_LEAD_OUT_TRACK) {
/* illegal request */
- DPRINTF("%s: illegal request Track 0x%02x",
+ log_debug("%s: illegal request Track 0x%02x",
__func__, toc->from_track);
vioscsi_prepare_resp(&resp,
memset(&resp, 0, sizeof(resp));
read_disc =
(struct scsi_read_disc_information *)(req->cdb);
- DPRINTF("%s: Disc Info %x", __func__, read_disc->byte2);
+ log_debug("%s: Disc Info %x", __func__, read_disc->byte2);
/* send back unsupported */
vioscsi_prepare_resp(&resp,
memset(&resp, 0, sizeof(resp));
gesn = (struct scsi_gesn *)(req->cdb);
- DPRINTF("%s: GESN Method %s", __func__,
+ log_debug("%s: GESN Method %s", __func__,
gesn->byte2 ? "Polling" : "Asynchronous");
if (gesn->byte2 == 0) {
get_configuration = (struct scsi_get_configuration *)(req->cdb);
get_conf_feature = (uint16_t)_2btol(get_configuration->feature);
get_conf_len = (uint16_t)_2btol(get_configuration->length);
- DPRINTF("%s: Conf RT %x Feature %d Len %d", __func__,
+ log_debug("%s: Conf RT %x Feature %d Len %d", __func__,
get_configuration->byte2, get_conf_feature, get_conf_len);
get_conf_reply = (uint8_t*)calloc(G_CONFIG_REPLY_SIZE, sizeof(uint8_t));
*intr = 0xFF;
- DPRINTF("%s: request %s reg %u,%s sz %u", __func__,
+ log_debug("%s: request %s reg %u,%s sz %u", __func__,
dir ? "READ" : "WRITE", reg, vioscsi_reg_name(reg), sz);
if (dir == 0) {
break;
case VIRTIO_CONFIG_GUEST_FEATURES:
dev->cfg.guest_feature = *data;
- DPRINTF("%s: guest feature set to %u",
+ log_debug("%s: guest feature set to %u",
__func__, dev->cfg.guest_feature);
break;
case VIRTIO_CONFIG_QUEUE_ADDRESS:
break;
case VIRTIO_CONFIG_DEVICE_STATUS:
dev->cfg.device_status = *data;
- DPRINTF("%s: device status set to %u",
+ log_debug("%s: device status set to %u",
__func__, dev->cfg.device_status);
if (dev->cfg.device_status == 0) {
- DPRINTF("%s: device reset", __func__);
+ log_debug("%s: device reset", __func__);
dev->cfg.guest_feature = 0;
dev->cfg.queue_address = 0;
vioscsi_update_qa(dev);
* respond with a BAD_TARGET response.
*/
if (req.lun[1] >= VIOSCSI_MAX_TARGET || req.lun[3] > 0) {
- DPRINTF("%s: Ignore CMD 0x%02x,%s on lun %u:%u:%u:%u",
+ log_debug("%s: Ignore CMD 0x%02x,%s on lun %u:%u:%u:%u",
__func__, req.cdb[0], vioscsi_op_names(req.cdb[0]),
req.lun[0], req.lun[1], req.lun[2], req.lun[3]);
/* Move index for response */
goto next_msg;
}
- DPRINTF("%s: Queue %d id 0x%llx lun %u:%u:%u:%u"
+ log_debug("%s: Queue %d id 0x%llx lun %u:%u:%u:%u"
" cdb OP 0x%02x,%s",
__func__, dev->cfg.queue_notify, req.id,
req.lun[0], req.lun[1], req.lun[2], req.lun[3],