Lines Matching refs:dev
285 void target_dev_ua_allocate(struct se_device *dev, u8 asc, u8 ascq) in target_dev_ua_allocate() argument
290 spin_lock(&dev->se_port_lock); in target_dev_ua_allocate()
291 list_for_each_entry(lun, &dev->dev_sep_list, lun_dev_link) { in target_dev_ua_allocate()
298 spin_unlock(&dev->se_port_lock); in target_dev_ua_allocate()
410 struct se_device *dev = rcu_dereference_raw(lun->lun_se_dev); in core_disable_device_list_for_node() local
449 core_scsi3_free_pr_reg_from_nacl(dev, nacl); in core_disable_device_list_for_node()
477 static void se_release_vpd_for_dev(struct se_device *dev) in se_release_vpd_for_dev() argument
481 spin_lock(&dev->t10_wwn.t10_vpd_lock); in se_release_vpd_for_dev()
483 &dev->t10_wwn.t10_vpd_list, vpd_list) { in se_release_vpd_for_dev()
487 spin_unlock(&dev->t10_wwn.t10_vpd_lock); in se_release_vpd_for_dev()
510 struct se_device *dev, in core_dev_add_lun() argument
515 rc = core_tpg_add_lun(tpg, lun, false, dev); in core_dev_add_lun()
522 tpg->se_tpg_tfo->fabric_name, dev->se_hba->hba_id); in core_dev_add_lun()
598 struct se_device *dev = rcu_dereference_raw(lun->lun_se_dev); in core_dev_add_initiator_node_lun_acl() local
621 core_scsi3_check_aptpl_registration(dev, tpg, lun, nacl, in core_dev_add_initiator_node_lun_acl()
666 static void scsi_dump_inquiry(struct se_device *dev) in scsi_dump_inquiry() argument
668 struct t10_wwn *wwn = &dev->t10_wwn; in scsi_dump_inquiry()
669 int device_type = dev->transport->get_device_type(dev); in scsi_dump_inquiry()
685 struct se_device *dev; in target_alloc_device() local
689 dev = hba->backend->ops->alloc_device(hba, name); in target_alloc_device()
690 if (!dev) in target_alloc_device()
693 dev->queues = kcalloc(nr_cpu_ids, sizeof(*dev->queues), GFP_KERNEL); in target_alloc_device()
694 if (!dev->queues) { in target_alloc_device()
695 hba->backend->ops->free_device(dev); in target_alloc_device()
699 dev->queue_cnt = nr_cpu_ids; in target_alloc_device()
700 for (i = 0; i < dev->queue_cnt; i++) { in target_alloc_device()
703 q = &dev->queues[i]; in target_alloc_device()
711 dev->se_hba = hba; in target_alloc_device()
712 dev->transport = hba->backend->ops; in target_alloc_device()
713 dev->transport_flags = dev->transport->transport_flags_default; in target_alloc_device()
714 dev->prot_length = sizeof(struct t10_pi_tuple); in target_alloc_device()
715 dev->hba_index = hba->hba_index; in target_alloc_device()
717 INIT_LIST_HEAD(&dev->dev_sep_list); in target_alloc_device()
718 INIT_LIST_HEAD(&dev->dev_tmr_list); in target_alloc_device()
719 INIT_LIST_HEAD(&dev->delayed_cmd_list); in target_alloc_device()
720 INIT_LIST_HEAD(&dev->qf_cmd_list); in target_alloc_device()
721 spin_lock_init(&dev->delayed_cmd_lock); in target_alloc_device()
722 spin_lock_init(&dev->dev_reservation_lock); in target_alloc_device()
723 spin_lock_init(&dev->se_port_lock); in target_alloc_device()
724 spin_lock_init(&dev->se_tmr_lock); in target_alloc_device()
725 spin_lock_init(&dev->qf_cmd_lock); in target_alloc_device()
726 sema_init(&dev->caw_sem, 1); in target_alloc_device()
727 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list); in target_alloc_device()
728 spin_lock_init(&dev->t10_wwn.t10_vpd_lock); in target_alloc_device()
729 INIT_LIST_HEAD(&dev->t10_pr.registration_list); in target_alloc_device()
730 INIT_LIST_HEAD(&dev->t10_pr.aptpl_reg_list); in target_alloc_device()
731 spin_lock_init(&dev->t10_pr.registration_lock); in target_alloc_device()
732 spin_lock_init(&dev->t10_pr.aptpl_reg_lock); in target_alloc_device()
733 INIT_LIST_HEAD(&dev->t10_alua.tg_pt_gps_list); in target_alloc_device()
734 spin_lock_init(&dev->t10_alua.tg_pt_gps_lock); in target_alloc_device()
735 INIT_LIST_HEAD(&dev->t10_alua.lba_map_list); in target_alloc_device()
736 spin_lock_init(&dev->t10_alua.lba_map_lock); in target_alloc_device()
738 INIT_WORK(&dev->delayed_cmd_work, target_do_delayed_work); in target_alloc_device()
739 mutex_init(&dev->lun_reset_mutex); in target_alloc_device()
741 dev->t10_wwn.t10_dev = dev; in target_alloc_device()
745 dev->t10_wwn.company_id = 0x001405; in target_alloc_device()
747 dev->t10_alua.t10_dev = dev; in target_alloc_device()
749 dev->dev_attrib.da_dev = dev; in target_alloc_device()
750 dev->dev_attrib.emulate_model_alias = DA_EMULATE_MODEL_ALIAS; in target_alloc_device()
751 dev->dev_attrib.emulate_dpo = 1; in target_alloc_device()
752 dev->dev_attrib.emulate_fua_write = 1; in target_alloc_device()
753 dev->dev_attrib.emulate_fua_read = 1; in target_alloc_device()
754 dev->dev_attrib.emulate_write_cache = DA_EMULATE_WRITE_CACHE; in target_alloc_device()
755 dev->dev_attrib.emulate_ua_intlck_ctrl = TARGET_UA_INTLCK_CTRL_CLEAR; in target_alloc_device()
756 dev->dev_attrib.emulate_tas = DA_EMULATE_TAS; in target_alloc_device()
757 dev->dev_attrib.emulate_tpu = DA_EMULATE_TPU; in target_alloc_device()
758 dev->dev_attrib.emulate_tpws = DA_EMULATE_TPWS; in target_alloc_device()
759 dev->dev_attrib.emulate_caw = DA_EMULATE_CAW; in target_alloc_device()
760 dev->dev_attrib.emulate_3pc = DA_EMULATE_3PC; in target_alloc_device()
761 dev->dev_attrib.emulate_pr = DA_EMULATE_PR; in target_alloc_device()
762 dev->dev_attrib.emulate_rsoc = DA_EMULATE_RSOC; in target_alloc_device()
763 dev->dev_attrib.pi_prot_type = TARGET_DIF_TYPE0_PROT; in target_alloc_device()
764 dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS; in target_alloc_device()
765 dev->dev_attrib.force_pr_aptpl = DA_FORCE_PR_APTPL; in target_alloc_device()
766 dev->dev_attrib.is_nonrot = DA_IS_NONROT; in target_alloc_device()
767 dev->dev_attrib.emulate_rest_reord = DA_EMULATE_REST_REORD; in target_alloc_device()
768 dev->dev_attrib.max_unmap_lba_count = DA_MAX_UNMAP_LBA_COUNT; in target_alloc_device()
769 dev->dev_attrib.max_unmap_block_desc_count = in target_alloc_device()
771 dev->dev_attrib.unmap_granularity = DA_UNMAP_GRANULARITY_DEFAULT; in target_alloc_device()
772 dev->dev_attrib.unmap_granularity_alignment = in target_alloc_device()
774 dev->dev_attrib.unmap_zeroes_data = in target_alloc_device()
776 dev->dev_attrib.max_write_same_len = DA_MAX_WRITE_SAME_LEN; in target_alloc_device()
778 xcopy_lun = &dev->xcopy_lun; in target_alloc_device()
779 rcu_assign_pointer(xcopy_lun->lun_se_dev, dev); in target_alloc_device()
787 strscpy(dev->t10_wwn.vendor, "LIO-ORG", sizeof(dev->t10_wwn.vendor)); in target_alloc_device()
788 strscpy(dev->t10_wwn.model, dev->transport->inquiry_prod, in target_alloc_device()
789 sizeof(dev->t10_wwn.model)); in target_alloc_device()
790 strscpy(dev->t10_wwn.revision, dev->transport->inquiry_rev, in target_alloc_device()
791 sizeof(dev->t10_wwn.revision)); in target_alloc_device()
793 return dev; in target_alloc_device()
825 sector_t target_to_linux_sector(struct se_device *dev, sector_t lb) in target_to_linux_sector() argument
827 switch (dev->dev_attrib.block_size) { in target_to_linux_sector()
841 int (*fn)(struct se_device *dev, void *data);
849 struct se_device *dev = p; in target_devices_idr_iter() local
859 if (!target_dev_configured(dev)) in target_devices_idr_iter()
862 item = config_item_get_unless_zero(&dev->dev_group.cg_item); in target_devices_idr_iter()
867 ret = iter->fn(dev, iter->data); in target_devices_idr_iter()
882 int target_for_each_device(int (*fn)(struct se_device *dev, void *data), in target_for_each_device() argument
894 int target_configure_device(struct se_device *dev) in target_configure_device() argument
896 struct se_hba *hba = dev->se_hba; in target_configure_device()
899 if (target_dev_configured(dev)) { in target_configure_device()
914 id = idr_alloc_cyclic(&devices_idr, dev, 0, INT_MAX, GFP_KERNEL); in target_configure_device()
920 dev->dev_index = id; in target_configure_device()
922 ret = dev->transport->configure_device(dev); in target_configure_device()
926 if (dev->transport->configure_unmap && in target_configure_device()
927 dev->transport->configure_unmap(dev)) { in target_configure_device()
934 dev->dev_attrib.block_size = dev->dev_attrib.hw_block_size; in target_configure_device()
935 dev->dev_attrib.queue_depth = dev->dev_attrib.hw_queue_depth; in target_configure_device()
940 dev->dev_attrib.hw_max_sectors = in target_configure_device()
941 se_dev_align_max_sectors(dev->dev_attrib.hw_max_sectors, in target_configure_device()
942 dev->dev_attrib.hw_block_size); in target_configure_device()
943 dev->dev_attrib.optimal_sectors = dev->dev_attrib.hw_max_sectors; in target_configure_device()
945 dev->creation_time = get_jiffies_64(); in target_configure_device()
947 ret = core_setup_alua(dev); in target_configure_device()
954 INIT_WORK(&dev->qf_work_queue, target_qf_do_work); in target_configure_device()
956 scsi_dump_inquiry(dev); in target_configure_device()
962 dev->dev_flags |= DF_CONFIGURED; in target_configure_device()
967 dev->transport->destroy_device(dev); in target_configure_device()
970 idr_remove(&devices_idr, dev->dev_index); in target_configure_device()
973 se_release_vpd_for_dev(dev); in target_configure_device()
977 void target_free_device(struct se_device *dev) in target_free_device() argument
979 struct se_hba *hba = dev->se_hba; in target_free_device()
981 WARN_ON(!list_empty(&dev->dev_sep_list)); in target_free_device()
983 if (target_dev_configured(dev)) { in target_free_device()
984 dev->transport->destroy_device(dev); in target_free_device()
987 idr_remove(&devices_idr, dev->dev_index); in target_free_device()
995 core_alua_free_lu_gp_mem(dev); in target_free_device()
996 core_alua_set_lba_map(dev, NULL, 0, 0); in target_free_device()
997 core_scsi3_free_all_registrations(dev); in target_free_device()
998 se_release_vpd_for_dev(dev); in target_free_device()
1000 if (dev->transport->free_prot) in target_free_device()
1001 dev->transport->free_prot(dev); in target_free_device()
1003 kfree(dev->queues); in target_free_device()
1004 dev->transport->free_device(dev); in target_free_device()
1010 struct se_device *dev; in core_dev_setup_virtual_lun0() local
1018 dev = target_alloc_device(hba, "virt_lun0"); in core_dev_setup_virtual_lun0()
1019 if (!dev) { in core_dev_setup_virtual_lun0()
1024 hba->backend->ops->set_configfs_dev_params(dev, buf, sizeof(buf)); in core_dev_setup_virtual_lun0()
1026 ret = target_configure_device(dev); in core_dev_setup_virtual_lun0()
1031 g_lun0_dev = dev; in core_dev_setup_virtual_lun0()
1035 target_free_device(dev); in core_dev_setup_virtual_lun0()
1062 struct se_device *dev = cmd->se_dev; in passthrough_parse_cdb() local
1078 if (!dev->dev_attrib.emulate_pr && in passthrough_parse_cdb()
1091 if (!(dev->transport_flags & in passthrough_parse_cdb()