Lines Matching +full:dont +full:- +full:validate
1 // SPDX-License-Identifier: GPL-2.0-only
131 * Platform neutral description of a scsi request -
144 * Sense buffer size changed in win8; have a run-time
147 * to start by assuming pre-Win8.
165 "Logging level, 0 - None, 1 - Error (default), 2 - Warning.");
175 dev_warn(&(dev)->device, fmt, ##__VA_ARGS__); \
227 * valid to start by assuming pre-Win8.
294 * Revision number is auto-incremented whenever this file is changed
296 * definitely indicate incompatibility--but it does indicate mismatched
311 /* Flags - see below for values */
334 /* Number of sub-channels to create */
351 /* Matches Windows-end */
359 * SRB status codes and masks. In the 8-bit field, the two high order bits
462 * Number of sub-channels we will open.
512 sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun); in storvsc_device_scan()
515 scsi_rescan_device(&sdev->sdev_gendev); in storvsc_device_scan()
529 host = host_device->host; in storvsc_host_scan()
541 mutex_lock(&host->scan_mutex); in storvsc_host_scan()
544 mutex_unlock(&host->scan_mutex); in storvsc_host_scan()
557 if (!scsi_host_get(wrk->host)) in storvsc_remove_lun()
560 sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun); in storvsc_remove_lun()
566 scsi_host_put(wrk->host); in storvsc_remove_lun()
595 if (stor_device && stor_device->destroy) in get_out_stor_device()
604 dev->drain_notify = true; in storvsc_wait_to_drain()
605 wait_event(dev->waiting_to_drain, in storvsc_wait_to_drain()
606 atomic_read(&dev->num_outstanding_req) == 0); in storvsc_wait_to_drain()
607 dev->drain_notify = false; in storvsc_wait_to_drain()
625 if (stor_device->destroy && in get_in_stor_device()
626 (atomic_read(&stor_device->num_outstanding_req) == 0)) in get_in_stor_device()
644 device = channel->primary_channel ? in storvsc_change_target_cpu()
645 channel->primary_channel->device_obj in storvsc_change_target_cpu()
646 : channel->device_obj; in storvsc_change_target_cpu()
651 /* See storvsc_do_io() -> get_og_chn(). */ in storvsc_change_target_cpu()
652 spin_lock_irqsave(&stor_device->lock, flags); in storvsc_change_target_cpu()
659 if (device->channel != channel && device->channel->target_cpu == old) { in storvsc_change_target_cpu()
660 cur_chn = device->channel; in storvsc_change_target_cpu()
664 list_for_each_entry(cur_chn, &device->channel->sc_list, sc_list) { in storvsc_change_target_cpu()
667 if (cur_chn->target_cpu == old) { in storvsc_change_target_cpu()
675 WRITE_ONCE(stor_device->stor_chns[old], cur_chn); in storvsc_change_target_cpu()
677 cpumask_clear_cpu(old, &stor_device->alloced_cpus); in storvsc_change_target_cpu()
681 if (stor_device->stor_chns[cpu] && !cpumask_test_cpu( in storvsc_change_target_cpu()
682 cpu, &stor_device->alloced_cpus)) in storvsc_change_target_cpu()
683 WRITE_ONCE(stor_device->stor_chns[cpu], NULL); in storvsc_change_target_cpu()
686 WRITE_ONCE(stor_device->stor_chns[new], channel); in storvsc_change_target_cpu()
687 cpumask_set_cpu(new, &stor_device->alloced_cpus); in storvsc_change_target_cpu()
689 spin_unlock_irqrestore(&stor_device->lock, flags); in storvsc_change_target_cpu()
694 struct hv_device *device = new_sc->primary_channel->device_obj; in handle_sc_creation()
695 struct device *dev = &device->device; in handle_sc_creation()
713 /* In case vmbus_open() fails, we don't use the sub-channel. */ in handle_sc_creation()
715 dev_err(dev, "Failed to open sub-channel: err=%d\n", ret); in handle_sc_creation()
719 new_sc->change_target_cpu_callback = storvsc_change_target_cpu; in handle_sc_creation()
721 /* Add the sub-channel to the array of available channels. */ in handle_sc_creation()
722 stor_device->stor_chns[new_sc->target_cpu] = new_sc; in handle_sc_creation()
723 cpumask_set_cpu(new_sc->target_cpu, &stor_device->alloced_cpus); in handle_sc_creation()
728 struct device *dev = &device->device; in handle_multichannel_storage()
737 * with maxcpus=1 on the kernel boot line, Hyper-V could offer in handle_multichannel_storage()
738 * sub-channels >= the number of CPUs. These sub-channels in handle_multichannel_storage()
740 * and assigned to one CPU, so check against # CPUs - 1. in handle_multichannel_storage()
742 num_sc = min((int)(num_online_cpus() - 1), max_chns); in handle_multichannel_storage()
750 stor_device->num_sc = num_sc; in handle_multichannel_storage()
751 request = &stor_device->init_request; in handle_multichannel_storage()
752 vstor_packet = &request->vstor_packet; in handle_multichannel_storage()
757 vmbus_set_sc_create_callback(device->channel, handle_sc_creation); in handle_multichannel_storage()
760 * Request the host to create sub-channels. in handle_multichannel_storage()
763 init_completion(&request->wait_event); in handle_multichannel_storage()
764 vstor_packet->operation = VSTOR_OPERATION_CREATE_SUB_CHANNELS; in handle_multichannel_storage()
765 vstor_packet->flags = REQUEST_COMPLETION_FLAG; in handle_multichannel_storage()
766 vstor_packet->sub_channel_count = num_sc; in handle_multichannel_storage()
768 ret = vmbus_sendpacket(device->channel, vstor_packet, in handle_multichannel_storage()
769 (sizeof(struct vstor_packet) - in handle_multichannel_storage()
776 dev_err(dev, "Failed to create sub-channel: err=%d\n", ret); in handle_multichannel_storage()
780 t = wait_for_completion_timeout(&request->wait_event, 10*HZ); in handle_multichannel_storage()
782 dev_err(dev, "Failed to create sub-channel: timed out\n"); in handle_multichannel_storage()
786 if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || in handle_multichannel_storage()
787 vstor_packet->status != 0) { in handle_multichannel_storage()
788 dev_err(dev, "Failed to create sub-channel: op=%d, sts=%d\n", in handle_multichannel_storage()
789 vstor_packet->operation, vstor_packet->status); in handle_multichannel_storage()
795 * invokes channel->sc_creation_callback, which will open and use in handle_multichannel_storage()
796 * the sub-channel(s). in handle_multichannel_storage()
806 if (vstor_packet->wwn_packet.primary_active) { in cache_wwn()
807 stor_device->node_name = in cache_wwn()
808 wwn_to_u64(vstor_packet->wwn_packet.primary_node_wwn); in cache_wwn()
809 stor_device->port_name = in cache_wwn()
810 wwn_to_u64(vstor_packet->wwn_packet.primary_port_wwn); in cache_wwn()
812 stor_device->node_name = in cache_wwn()
813 wwn_to_u64(vstor_packet->wwn_packet.secondary_node_wwn); in cache_wwn()
814 stor_device->port_name = in cache_wwn()
815 wwn_to_u64(vstor_packet->wwn_packet.secondary_port_wwn); in cache_wwn()
827 vstor_packet = &request->vstor_packet; in storvsc_execute_vstor_op()
829 init_completion(&request->wait_event); in storvsc_execute_vstor_op()
830 vstor_packet->flags = REQUEST_COMPLETION_FLAG; in storvsc_execute_vstor_op()
832 ret = vmbus_sendpacket(device->channel, vstor_packet, in storvsc_execute_vstor_op()
833 (sizeof(struct vstor_packet) - in storvsc_execute_vstor_op()
841 t = wait_for_completion_timeout(&request->wait_event, 5*HZ); in storvsc_execute_vstor_op()
843 return -ETIMEDOUT; in storvsc_execute_vstor_op()
848 if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO || in storvsc_execute_vstor_op()
849 vstor_packet->status != 0) in storvsc_execute_vstor_op()
850 return -EINVAL; in storvsc_execute_vstor_op()
866 return -ENODEV; in storvsc_channel_init()
868 request = &stor_device->init_request; in storvsc_channel_init()
869 vstor_packet = &request->vstor_packet; in storvsc_channel_init()
876 vstor_packet->operation = VSTOR_OPERATION_BEGIN_INITIALIZATION; in storvsc_channel_init()
887 vstor_packet->operation = in storvsc_channel_init()
890 vstor_packet->version.major_minor = in storvsc_channel_init()
896 vstor_packet->version.revision = 0; in storvsc_channel_init()
901 if (vstor_packet->operation != VSTOR_OPERATION_COMPLETE_IO) in storvsc_channel_init()
902 return -EINVAL; in storvsc_channel_init()
904 if (vstor_packet->status == 0) { in storvsc_channel_init()
918 if (vstor_packet->status != 0) in storvsc_channel_init()
919 return -EINVAL; in storvsc_channel_init()
923 vstor_packet->operation = VSTOR_OPERATION_QUERY_PROPERTIES; in storvsc_channel_init()
929 * Check to see if multi-channel support is there. in storvsc_channel_init()
931 * support multi-channel. in storvsc_channel_init()
933 max_chns = vstor_packet->storage_channel_properties.max_channel_cnt; in storvsc_channel_init()
936 * Allocate state to manage the sub-channels. in storvsc_channel_init()
938 * (Hyper-V does not support cpu online/offline). in storvsc_channel_init()
940 * channels - primary + sub-channels. in storvsc_channel_init()
944 stor_device->stor_chns = kcalloc(num_possible_cpus(), sizeof(void *), in storvsc_channel_init()
946 if (stor_device->stor_chns == NULL) in storvsc_channel_init()
947 return -ENOMEM; in storvsc_channel_init()
949 device->channel->change_target_cpu_callback = storvsc_change_target_cpu; in storvsc_channel_init()
951 stor_device->stor_chns[device->channel->target_cpu] = device->channel; in storvsc_channel_init()
952 cpumask_set_cpu(device->channel->target_cpu, in storvsc_channel_init()
953 &stor_device->alloced_cpus); in storvsc_channel_init()
956 if (vstor_packet->storage_channel_properties.flags & in storvsc_channel_init()
960 stor_device->max_transfer_bytes = in storvsc_channel_init()
961 vstor_packet->storage_channel_properties.max_transfer_bytes; in storvsc_channel_init()
970 vstor_packet->operation = VSTOR_OPERATION_FCHBA_DATA; in storvsc_channel_init()
983 vstor_packet->operation = VSTOR_OPERATION_END_INITIALIZATION; in storvsc_channel_init()
1003 switch (SRB_STATUS(vm_srb->srb_status)) { in storvsc_handle_error()
1007 if (vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID) { in storvsc_handle_error()
1018 * due to Hyper-V changing the VHD/VHDX BlockSize in storvsc_handle_error()
1043 * were a pass-through command deal with it appropriately. in storvsc_handle_error()
1045 switch (scmnd->cmnd[0]) { in storvsc_handle_error()
1051 * On some Hyper-V hosts TEST_UNIT_READY command can in storvsc_handle_error()
1080 wrk->host = host; in storvsc_handle_error()
1081 wrk->lun = vm_srb->lun; in storvsc_handle_error()
1082 wrk->tgt_id = vm_srb->target_id; in storvsc_handle_error()
1083 INIT_WORK(&wrk->work, process_err_fn); in storvsc_handle_error()
1084 queue_work(host_dev->handle_error_wq, &wrk->work); in storvsc_handle_error()
1091 struct scsi_cmnd *scmnd = cmd_request->cmd; in storvsc_command_completion()
1096 u32 payload_sz = cmd_request->payload_sz; in storvsc_command_completion()
1097 void *payload = cmd_request->payload; in storvsc_command_completion()
1099 host = stor_dev->host; in storvsc_command_completion()
1101 vm_srb = &cmd_request->vstor_packet.vm_srb; in storvsc_command_completion()
1102 data_transfer_length = vm_srb->data_transfer_length; in storvsc_command_completion()
1104 scmnd->result = vm_srb->scsi_status; in storvsc_command_completion()
1106 if (scmnd->result) { in storvsc_command_completion()
1107 if (scsi_normalize_sense(scmnd->sense_buffer, in storvsc_command_completion()
1112 scsi_print_sense_hdr(scmnd->device, "storvsc", in storvsc_command_completion()
1116 if (vm_srb->srb_status != SRB_STATUS_SUCCESS) { in storvsc_command_completion()
1124 if (vm_srb->srb_status != SRB_STATUS_DATA_OVERRUN) in storvsc_command_completion()
1128 /* Validate data_transfer_length (from Hyper-V) */ in storvsc_command_completion()
1129 if (data_transfer_length > cmd_request->payload->range.len) in storvsc_command_completion()
1130 data_transfer_length = cmd_request->payload->range.len; in storvsc_command_completion()
1133 cmd_request->payload->range.len - data_transfer_length); in storvsc_command_completion()
1135 scmnd->scsi_done(scmnd); in storvsc_command_completion()
1147 struct hv_device *device = stor_device->device; in storvsc_on_io_completion()
1149 stor_pkt = &request->vstor_packet; in storvsc_on_io_completion()
1159 * (srb status == 0x4) and off-line the device in that case. in storvsc_on_io_completion()
1162 if ((stor_pkt->vm_srb.cdb[0] == INQUIRY) || in storvsc_on_io_completion()
1163 (stor_pkt->vm_srb.cdb[0] == MODE_SENSE)) { in storvsc_on_io_completion()
1164 vstor_packet->vm_srb.scsi_status = 0; in storvsc_on_io_completion()
1165 vstor_packet->vm_srb.srb_status = SRB_STATUS_SUCCESS; in storvsc_on_io_completion()
1170 stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status; in storvsc_on_io_completion()
1171 stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status; in storvsc_on_io_completion()
1173 /* Validate sense_info_length (from Hyper-V) */ in storvsc_on_io_completion()
1174 if (vstor_packet->vm_srb.sense_info_length > sense_buffer_size) in storvsc_on_io_completion()
1175 vstor_packet->vm_srb.sense_info_length = sense_buffer_size; in storvsc_on_io_completion()
1177 stor_pkt->vm_srb.sense_info_length = in storvsc_on_io_completion()
1178 vstor_packet->vm_srb.sense_info_length; in storvsc_on_io_completion()
1180 if (vstor_packet->vm_srb.scsi_status != 0 || in storvsc_on_io_completion()
1181 vstor_packet->vm_srb.srb_status != SRB_STATUS_SUCCESS) in storvsc_on_io_completion()
1184 stor_pkt->vm_srb.cdb[0], in storvsc_on_io_completion()
1185 vstor_packet->vm_srb.scsi_status, in storvsc_on_io_completion()
1186 vstor_packet->vm_srb.srb_status); in storvsc_on_io_completion()
1188 if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) { in storvsc_on_io_completion()
1190 if (vstor_packet->vm_srb.srb_status & in storvsc_on_io_completion()
1195 "stor pkt %p autosense data valid - len %d\n", in storvsc_on_io_completion()
1196 request, vstor_packet->vm_srb.sense_info_length); in storvsc_on_io_completion()
1198 memcpy(request->cmd->sense_buffer, in storvsc_on_io_completion()
1199 vstor_packet->vm_srb.sense_data, in storvsc_on_io_completion()
1200 vstor_packet->vm_srb.sense_info_length); in storvsc_on_io_completion()
1205 stor_pkt->vm_srb.data_transfer_length = in storvsc_on_io_completion()
1206 vstor_packet->vm_srb.data_transfer_length; in storvsc_on_io_completion()
1210 if (atomic_dec_and_test(&stor_device->num_outstanding_req) && in storvsc_on_io_completion()
1211 stor_device->drain_notify) in storvsc_on_io_completion()
1212 wake_up(&stor_device->waiting_to_drain); in storvsc_on_io_completion()
1222 switch (vstor_packet->operation) { in storvsc_on_receive()
1229 host_dev = shost_priv(stor_device->host); in storvsc_on_receive()
1231 host_dev->handle_error_wq, &host_dev->host_scan_work); in storvsc_on_receive()
1237 fc_host_node_name(stor_device->host) = stor_device->node_name; in storvsc_on_receive()
1238 fc_host_port_name(stor_device->host) = stor_device->port_name; in storvsc_on_receive()
1253 if (channel->primary_channel != NULL) in storvsc_on_channel_callback()
1254 device = channel->primary_channel->device_obj; in storvsc_on_channel_callback()
1256 device = channel->device_obj; in storvsc_on_channel_callback()
1267 ((unsigned long)desc->trans_id); in storvsc_on_channel_callback()
1269 if (request == &stor_device->init_request || in storvsc_on_channel_callback()
1270 request == &stor_device->reset_request) { in storvsc_on_channel_callback()
1271 memcpy(&request->vstor_packet, packet, in storvsc_on_channel_callback()
1272 (sizeof(struct vstor_packet) - vmscsi_size_delta)); in storvsc_on_channel_callback()
1273 complete(&request->wait_event); in storvsc_on_channel_callback()
1288 ret = vmbus_open(device->channel, in storvsc_connect_to_vsp()
1293 storvsc_on_channel_callback, device->channel); in storvsc_connect_to_vsp()
1309 stor_device->destroy = true; in storvsc_dev_remove()
1326 * we have drained - to drain the outgoing packets, we need to in storvsc_dev_remove()
1332 vmbus_close(device->channel); in storvsc_dev_remove()
1334 kfree(stor_device->stor_chns); in storvsc_dev_remove()
1347 if (stor_device->num_sc == 0) { in get_og_chn()
1348 stor_device->stor_chns[q_num] = stor_device->device->channel; in get_og_chn()
1349 return stor_device->device->channel; in get_og_chn()
1354 * initiated I/O on a processor/hw-q that does not in get_og_chn()
1364 for_each_cpu(tgt_cpu, &stor_device->alloced_cpus) { in get_og_chn()
1369 stor_device->stor_chns[q_num] = stor_device->device->channel; in get_og_chn()
1370 return stor_device->device->channel; in get_og_chn()
1375 hash_qnum -= num_channels; in get_og_chn()
1377 for_each_cpu(tgt_cpu, &stor_device->alloced_cpus) { in get_og_chn()
1385 stor_device->stor_chns[q_num] = stor_device->stor_chns[tgt_cpu]; in get_og_chn()
1387 return stor_device->stor_chns[q_num]; in get_og_chn()
1402 vstor_packet = &request->vstor_packet; in storvsc_do_io()
1406 return -ENODEV; in storvsc_do_io()
1409 request->device = device; in storvsc_do_io()
1414 outgoing_channel = READ_ONCE(stor_device->stor_chns[q_num]); in storvsc_do_io()
1416 if (outgoing_channel->target_cpu == q_num) { in storvsc_do_io()
1423 &stor_device->alloced_cpus, q_num + 1) { in storvsc_do_io()
1429 stor_device->stor_chns[tgt_cpu]); in storvsc_do_io()
1433 &channel->outbound) in storvsc_do_io()
1445 &outgoing_channel->outbound) in storvsc_do_io()
1454 for_each_cpu(tgt_cpu, &stor_device->alloced_cpus) { in storvsc_do_io()
1458 stor_device->stor_chns[tgt_cpu]); in storvsc_do_io()
1462 &channel->outbound) in storvsc_do_io()
1470 spin_lock_irqsave(&stor_device->lock, flags); in storvsc_do_io()
1471 outgoing_channel = stor_device->stor_chns[q_num]; in storvsc_do_io()
1473 spin_unlock_irqrestore(&stor_device->lock, flags); in storvsc_do_io()
1477 spin_unlock_irqrestore(&stor_device->lock, flags); in storvsc_do_io()
1481 vstor_packet->flags |= REQUEST_COMPLETION_FLAG; in storvsc_do_io()
1483 vstor_packet->vm_srb.length = (sizeof(struct vmscsi_request) - in storvsc_do_io()
1487 vstor_packet->vm_srb.sense_info_length = sense_buffer_size; in storvsc_do_io()
1490 vstor_packet->vm_srb.data_transfer_length = in storvsc_do_io()
1491 request->payload->range.len; in storvsc_do_io()
1493 vstor_packet->operation = VSTOR_OPERATION_EXECUTE_SRB; in storvsc_do_io()
1495 if (request->payload->range.len) { in storvsc_do_io()
1498 request->payload, request->payload_sz, in storvsc_do_io()
1500 (sizeof(struct vstor_packet) - in storvsc_do_io()
1505 (sizeof(struct vstor_packet) - in storvsc_do_io()
1515 atomic_inc(&stor_device->num_outstanding_req); in storvsc_do_io()
1524 * the target may claim SPC-2 compliance. MSFT targets currently in storvsc_device_alloc()
1525 * claim SPC-2 compliance while they implement post SPC-2 features. in storvsc_device_alloc()
1531 sdevice->sdev_bflags = BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES; in storvsc_device_alloc()
1538 blk_queue_rq_timeout(sdevice->request_queue, (storvsc_timeout * HZ)); in storvsc_device_configure()
1541 sdevice->no_report_opcodes = 1; in storvsc_device_configure()
1542 sdevice->no_write_same = 1; in storvsc_device_configure()
1545 * If the host is WIN8 or WIN8 R2, claim conformance to SPC-3 in storvsc_device_configure()
1549 if (!strncmp(sdevice->vendor, "Msft", 4)) { in storvsc_device_configure()
1553 sdevice->scsi_level = SCSI_SPC_3; in storvsc_device_configure()
1558 sdevice->no_write_same = 0; in storvsc_device_configure()
1589 struct hv_host_device *host_dev = shost_priv(scmnd->device->host); in storvsc_host_reset_handler()
1590 struct hv_device *device = host_dev->dev; in storvsc_host_reset_handler()
1602 request = &stor_device->reset_request; in storvsc_host_reset_handler()
1603 vstor_packet = &request->vstor_packet; in storvsc_host_reset_handler()
1606 init_completion(&request->wait_event); in storvsc_host_reset_handler()
1608 vstor_packet->operation = VSTOR_OPERATION_RESET_BUS; in storvsc_host_reset_handler()
1609 vstor_packet->flags = REQUEST_COMPLETION_FLAG; in storvsc_host_reset_handler()
1610 vstor_packet->vm_srb.path_id = stor_device->path_id; in storvsc_host_reset_handler()
1612 ret = vmbus_sendpacket(device->channel, vstor_packet, in storvsc_host_reset_handler()
1613 (sizeof(struct vstor_packet) - in storvsc_host_reset_handler()
1615 (unsigned long)&stor_device->reset_request, in storvsc_host_reset_handler()
1621 t = wait_for_completion_timeout(&request->wait_event, 5*HZ); in storvsc_host_reset_handler()
1631 * Just wait for all in-transit packets to be accounted for in storvsc_host_reset_handler()
1652 u8 scsi_op = scmnd->cmnd[0]; in storvsc_scsi_cmd_ok()
1662 scmnd->result = ILLEGAL_REQUEST << 16; in storvsc_scsi_cmd_ok()
1675 struct hv_device *dev = host_dev->dev; in storvsc_queuecommand()
1696 scmnd->scsi_done(scmnd); in storvsc_queuecommand()
1702 cmd_request->cmd = scmnd; in storvsc_queuecommand()
1704 memset(&cmd_request->vstor_packet, 0, sizeof(struct vstor_packet)); in storvsc_queuecommand()
1705 vm_srb = &cmd_request->vstor_packet.vm_srb; in storvsc_queuecommand()
1706 vm_srb->win8_extension.time_out_value = 60; in storvsc_queuecommand()
1708 vm_srb->win8_extension.srb_flags |= in storvsc_queuecommand()
1711 if (scmnd->device->tagged_supported) { in storvsc_queuecommand()
1712 vm_srb->win8_extension.srb_flags |= in storvsc_queuecommand()
1714 vm_srb->win8_extension.queue_tag = SP_UNTAGGED; in storvsc_queuecommand()
1715 vm_srb->win8_extension.queue_action = SRB_SIMPLE_TAG_REQUEST; in storvsc_queuecommand()
1719 switch (scmnd->sc_data_direction) { in storvsc_queuecommand()
1721 vm_srb->data_in = WRITE_TYPE; in storvsc_queuecommand()
1722 vm_srb->win8_extension.srb_flags |= SRB_FLAGS_DATA_OUT; in storvsc_queuecommand()
1725 vm_srb->data_in = READ_TYPE; in storvsc_queuecommand()
1726 vm_srb->win8_extension.srb_flags |= SRB_FLAGS_DATA_IN; in storvsc_queuecommand()
1729 vm_srb->data_in = UNKNOWN_TYPE; in storvsc_queuecommand()
1730 vm_srb->win8_extension.srb_flags |= SRB_FLAGS_NO_DATA_TRANSFER; in storvsc_queuecommand()
1738 scmnd->sc_data_direction); in storvsc_queuecommand()
1739 return -EINVAL; in storvsc_queuecommand()
1743 vm_srb->port_number = host_dev->port; in storvsc_queuecommand()
1744 vm_srb->path_id = scmnd->device->channel; in storvsc_queuecommand()
1745 vm_srb->target_id = scmnd->device->id; in storvsc_queuecommand()
1746 vm_srb->lun = scmnd->device->lun; in storvsc_queuecommand()
1748 vm_srb->cdb_length = scmnd->cmd_len; in storvsc_queuecommand()
1750 memcpy(vm_srb->cdb, scmnd->cmnd, vm_srb->cdb_length); in storvsc_queuecommand()
1756 payload = (struct vmbus_packet_mpb_array *)&cmd_request->mpb; in storvsc_queuecommand()
1761 unsigned long offset_in_hvpg = sgl->offset & ~HV_HYP_PAGE_MASK; in storvsc_queuecommand()
1775 * sgl is a list of PAGEs, and payload->range.pfn_array in storvsc_queuecommand()
1777 * page size that Hyper-V uses, so here we need to divide PAGEs in storvsc_queuecommand()
1779 * Besides, payload->range.offset should be the offset in one in storvsc_queuecommand()
1782 payload->range.len = length; in storvsc_queuecommand()
1783 payload->range.offset = offset_in_hvpg; in storvsc_queuecommand()
1784 hvpgoff = sgl->offset >> HV_HYP_PAGE_SHIFT; in storvsc_queuecommand()
1796 * |------------------ PAGE -------------------| in storvsc_queuecommand()
1800 * +-hvpgoff-+ +-hvpgoff_in_page-+ in storvsc_queuecommand()
1802 * +--------------------- i ---------------------------+ in storvsc_queuecommand()
1818 payload->range.pfn_array[i] = hvpfn + hvpgoff_in_page; in storvsc_queuecommand()
1822 cmd_request->payload = payload; in storvsc_queuecommand()
1823 cmd_request->payload_sz = payload_sz; in storvsc_queuecommand()
1829 if (ret == -EAGAIN) { in storvsc_queuecommand()
1830 if (payload_sz > sizeof(cmd_request->mpb)) in storvsc_queuecommand()
1851 .this_id = -1,
1852 /* Make sure we dont get a sg segment crosses a page boundary */
1853 .dma_boundary = PAGE_SIZE-1,
1855 .virt_boundary_mask = PAGE_SIZE-1,
1890 return guid_equal(&fc_guid.guid, &hv_dev->dev_type); in hv_dev_is_fc()
1900 bool dev_is_ide = ((dev_id->driver_data == IDE_GUID) ? true : false); in storvsc_probe()
1901 bool is_fc = ((dev_id->driver_data == SFC_GUID) ? true : false); in storvsc_probe()
1923 * On Windows8 and above, we support sub-channels for storage in storvsc_probe()
1925 * The number of sub-channels offerred is based on the number of in storvsc_probe()
1930 (num_cpus - 1) / storvsc_vcpus_per_sub_channel; in storvsc_probe()
1935 (100 - ring_avail_percent_lowater) / 100; in storvsc_probe()
1940 return -ENOMEM; in storvsc_probe()
1945 host_dev->port = host->host_no; in storvsc_probe()
1946 host_dev->dev = device; in storvsc_probe()
1947 host_dev->host = host; in storvsc_probe()
1952 ret = -ENOMEM; in storvsc_probe()
1956 stor_device->destroy = false; in storvsc_probe()
1957 init_waitqueue_head(&stor_device->waiting_to_drain); in storvsc_probe()
1958 stor_device->device = device; in storvsc_probe()
1959 stor_device->host = host; in storvsc_probe()
1960 spin_lock_init(&stor_device->lock); in storvsc_probe()
1963 stor_device->port_number = host->host_no; in storvsc_probe()
1968 host_dev->path = stor_device->path_id; in storvsc_probe()
1969 host_dev->target = stor_device->target_id; in storvsc_probe()
1971 switch (dev_id->driver_data) { in storvsc_probe()
1973 host->max_lun = STORVSC_FC_MAX_LUNS_PER_TARGET; in storvsc_probe()
1974 host->max_id = STORVSC_FC_MAX_TARGETS; in storvsc_probe()
1975 host->max_channel = STORVSC_FC_MAX_CHANNELS - 1; in storvsc_probe()
1977 host->transportt = fc_transport_template; in storvsc_probe()
1982 host->max_lun = max_luns_per_target; in storvsc_probe()
1983 host->max_id = max_targets; in storvsc_probe()
1984 host->max_channel = max_channels - 1; in storvsc_probe()
1988 host->max_lun = STORVSC_IDE_MAX_LUNS_PER_TARGET; in storvsc_probe()
1989 host->max_id = STORVSC_IDE_MAX_TARGETS; in storvsc_probe()
1990 host->max_channel = STORVSC_IDE_MAX_CHANNELS - 1; in storvsc_probe()
1994 host->max_cmd_len = STORVSC_MAX_CMD_LEN; in storvsc_probe()
2000 host->sg_tablesize = (stor_device->max_transfer_bytes >> PAGE_SHIFT); in storvsc_probe()
2002 * For non-IDE disks, the host supports multiple channels. in storvsc_probe()
2006 host->nr_hw_queues = num_present_cpus(); in storvsc_probe()
2011 host_dev->handle_error_wq = in storvsc_probe()
2014 host->host_no); in storvsc_probe()
2015 if (!host_dev->handle_error_wq) { in storvsc_probe()
2016 ret = -ENOMEM; in storvsc_probe()
2019 INIT_WORK(&host_dev->host_scan_work, storvsc_host_scan); in storvsc_probe()
2021 ret = scsi_add_host(host, &device->device); in storvsc_probe()
2028 target = (device->dev_instance.b[5] << 8 | in storvsc_probe()
2029 device->dev_instance.b[4]); in storvsc_probe()
2035 if (host->transportt == fc_transport_template) { in storvsc_probe()
2040 fc_host_node_name(host) = stor_device->node_name; in storvsc_probe()
2041 fc_host_port_name(host) = stor_device->port_name; in storvsc_probe()
2042 stor_device->rport = fc_remote_port_add(host, 0, &ids); in storvsc_probe()
2043 if (!stor_device->rport) { in storvsc_probe()
2044 ret = -ENOMEM; in storvsc_probe()
2055 destroy_workqueue(host_dev->handle_error_wq); in storvsc_probe()
2068 kfree(stor_device->stor_chns); in storvsc_probe()
2088 struct Scsi_Host *host = stor_device->host; in storvsc_remove()
2092 if (host->transportt == fc_transport_template) { in storvsc_remove()
2093 fc_remote_port_delete(stor_device->rport); in storvsc_remove()
2097 destroy_workqueue(host_dev->handle_error_wq); in storvsc_remove()
2108 struct Scsi_Host *host = stor_device->host; in storvsc_suspend()
2113 drain_workqueue(host_dev->handle_error_wq); in storvsc_suspend()
2115 vmbus_close(hv_dev->channel); in storvsc_suspend()
2117 kfree(stor_device->stor_chns); in storvsc_suspend()
2118 stor_device->stor_chns = NULL; in storvsc_suspend()
2120 cpumask_clear(&stor_device->alloced_cpus); in storvsc_suspend()
2164 ((storvsc_ringbuffer_size - PAGE_SIZE) / in storvsc_drv_init()
2166 sizeof(struct vstor_packet) + sizeof(u64) - in storvsc_drv_init()
2173 return -ENODEV; in storvsc_drv_init()
2195 MODULE_DESCRIPTION("Microsoft Hyper-V virtual storage driver");