Lines Matching refs:lu

143 static void sbp2_queue_work(struct sbp2_logical_unit *lu, unsigned long delay)
145 queue_delayed_work(fw_workqueue, &lu->work, delay);
180 static const struct device *lu_dev(const struct sbp2_logical_unit *lu)
182 return &lu->tgt->unit->device;
262 struct sbp2_logical_unit *lu;
411 struct sbp2_logical_unit *lu = callback_data;
429 dev_notice(lu_dev(lu),
436 spin_lock_irqsave(&lu->tgt->lock, flags);
437 list_for_each_entry(iter, &lu->orb_list, link) {
446 spin_unlock_irqrestore(&lu->tgt->lock, flags);
452 dev_err(lu_dev(lu), "status write for unknown ORB\n");
473 spin_lock_irqsave(&orb->lu->tgt->lock, flags);
479 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags);
484 spin_unlock_irqrestore(&orb->lu->tgt->lock, flags);
490 static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu,
493 struct fw_device *device = target_parent_device(lu->tgt);
500 orb->lu = lu;
501 spin_lock_irqsave(&lu->tgt->lock, flags);
502 list_add_tail(&orb->link, &lu->orb_list);
503 spin_unlock_irqrestore(&lu->tgt->lock, flags);
513 static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu)
515 struct fw_device *device = target_parent_device(lu->tgt);
521 spin_lock_irq(&lu->tgt->lock);
522 list_splice_init(&lu->orb_list, &list);
523 spin_unlock_irq(&lu->tgt->lock);
549 static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id,
553 struct fw_device *device = target_parent_device(lu->tgt);
583 cpu_to_be32(lu->address_handler.offset >> 32);
585 cpu_to_be32(lu->address_handler.offset);
592 timeout = lu->tgt->mgt_orb_timeout;
606 sbp2_send_orb(&orb->base, lu, node_id, generation,
607 lu->tgt->management_agent_address);
612 if (sbp2_cancel_orbs(lu) == 0) {
613 dev_err(lu_dev(lu), "ORB reply timed out, rcode 0x%02x\n",
619 dev_err(lu_dev(lu), "management write failed, rcode 0x%02x\n",
626 dev_err(lu_dev(lu), "error status: %d:%d\n",
647 static void sbp2_agent_reset(struct sbp2_logical_unit *lu)
649 struct fw_device *device = target_parent_device(lu->tgt);
653 lu->tgt->node_id, lu->generation, device->max_speed,
654 lu->command_block_agent_address + SBP2_AGENT_RESET,
664 static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu)
666 struct fw_device *device = target_parent_device(lu->tgt);
675 lu->tgt->node_id, lu->generation, device->max_speed,
676 lu->command_block_agent_address + SBP2_AGENT_RESET,
688 * Blocks lu->tgt if all of the following conditions are met:
691 * - lu->generation is stale.
697 static void sbp2_conditionally_block(struct sbp2_logical_unit *lu)
699 struct sbp2_target *tgt = lu->tgt;
706 if (!tgt->dont_block && !lu->blocked &&
707 lu->generation != card->generation) {
708 lu->blocked = true;
716 * Unblocks lu->tgt as soon as all its logical units can be unblocked.
721 static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu)
723 struct sbp2_target *tgt = lu->tgt;
730 if (lu->blocked && lu->generation == card->generation) {
731 lu->blocked = false;
785 static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu)
787 struct fw_device *device = target_parent_device(lu->tgt);
791 lu->tgt->node_id, lu->generation, device->max_speed,
799 struct sbp2_logical_unit *lu =
801 struct sbp2_target *tgt = lu->tgt;
817 if (lu->has_sdev)
818 sbp2_send_management_orb(lu, device->node_id, generation,
819 SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
821 if (sbp2_send_management_orb(lu, node_id, generation,
822 SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) {
823 if (lu->retries++ < 5) {
824 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
827 lu->lun);
829 sbp2_unblock(lu->tgt);
837 lu->generation = generation;
839 lu->command_block_agent_address =
842 lu->login_id = be32_to_cpu(response.misc) & 0xffff;
845 lu->lun, lu->retries);
848 sbp2_set_busy_timeout(lu);
850 lu->workfn = sbp2_reconnect;
851 sbp2_agent_reset(lu);
854 if (lu->has_sdev) {
855 sbp2_cancel_orbs(lu);
856 sbp2_conditionally_unblock(lu);
861 if (lu->tgt->workarounds & SBP2_WORKAROUND_DELAY_INQUIRY)
865 sdev = __scsi_add_device(shost, 0, 0, sbp2_lun2int(lu->lun), lu);
887 lu->has_sdev = true;
898 sbp2_send_management_orb(lu, device->node_id, generation,
899 SBP2_LOGOUT_REQUEST, lu->login_id, NULL);
902 * lu->work already. Reset the work from reconnect to login.
904 lu->workfn = sbp2_login;
909 struct sbp2_logical_unit *lu =
911 struct sbp2_target *tgt = lu->tgt;
923 if (sbp2_send_management_orb(lu, node_id, generation,
925 lu->login_id, NULL) < 0) {
935 lu->retries++ >= 5) {
937 lu->retries = 0;
938 lu->workfn = sbp2_login;
940 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
948 lu->generation = generation;
951 lu->lun, lu->retries);
953 sbp2_agent_reset(lu);
954 sbp2_cancel_orbs(lu);
955 sbp2_conditionally_unblock(lu);
960 struct sbp2_logical_unit *lu = container_of(to_delayed_work(work),
962 lu->workfn(work);
967 struct sbp2_logical_unit *lu;
969 lu = kmalloc(sizeof(*lu), GFP_KERNEL);
970 if (!lu)
973 lu->address_handler.length = 0x100;
974 lu->address_handler.address_callback = sbp2_status_write;
975 lu->address_handler.callback_data = lu;
977 if (fw_core_add_address_handler(&lu->address_handler,
979 kfree(lu);
983 lu->tgt = tgt;
984 lu->lun = lun_entry & 0xffff;
985 lu->login_id = INVALID_LOGIN_ID;
986 lu->retries = 0;
987 lu->has_sdev = false;
988 lu->blocked = false;
990 INIT_LIST_HEAD(&lu->orb_list);
991 lu->workfn = sbp2_login;
992 INIT_DELAYED_WORK(&lu->work, sbp2_lu_workfn);
994 list_add_tail(&lu->link, &tgt->lu_list);
1128 struct sbp2_logical_unit *lu;
1180 list_for_each_entry(lu, &tgt->lu_list, link)
1181 sbp2_queue_work(lu, DIV_ROUND_UP(HZ, 5));
1197 struct sbp2_logical_unit *lu;
1205 list_for_each_entry(lu, &tgt->lu_list, link) {
1206 sbp2_conditionally_block(lu);
1207 lu->retries = 0;
1208 sbp2_queue_work(lu, 0);
1216 struct sbp2_logical_unit *lu, *next;
1224 list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
1225 cancel_delayed_work_sync(&lu->work);
1226 sdev = scsi_device_lookup(shost, 0, 0, sbp2_lun2int(lu->lun));
1231 if (lu->login_id != INVALID_LOGIN_ID) {
1241 sbp2_send_management_orb(lu, node_id, generation,
1243 lu->login_id, NULL);
1245 fw_core_remove_address_handler(&lu->address_handler);
1246 list_del(&lu->link);
1247 kfree(lu);
1341 struct fw_device *device = target_parent_device(base_orb->lu->tgt);
1346 sbp2_agent_reset_no_wait(base_orb->lu);
1372 sbp2_conditionally_block(base_orb->lu);
1384 struct fw_device *device, struct sbp2_logical_unit *lu)
1402 cpu_to_be32(lu->tgt->address_high);
1428 orb->request.data_descriptor.high = cpu_to_be32(lu->tgt->address_high);
1446 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1447 struct fw_device *device = target_parent_device(lu->tgt);
1461 COMMAND_ORB_MAX_PAYLOAD(lu->tgt->max_payload) |
1471 if (scsi_sg_count(cmd) && sbp2_map_scatterlist(orb, device, lu) < 0)
1485 sbp2_send_orb(&orb->base, lu, lu->tgt->node_id, generation,
1486 lu->command_block_agent_address + SBP2_ORB_POINTER);
1495 struct sbp2_logical_unit *lu = sdev->hostdata;
1498 if (!lu)
1503 if (lu->tgt->workarounds & SBP2_WORKAROUND_INQUIRY_36)
1512 struct sbp2_logical_unit *lu = sdev->hostdata;
1526 lu->tgt->workarounds & SBP2_WORKAROUND_MODE_SENSE_8)
1529 if (lu->tgt->workarounds & SBP2_WORKAROUND_FIX_CAPACITY)
1532 if (lu->tgt->workarounds & SBP2_WORKAROUND_POWER_CONDITION)
1535 if (lu->tgt->workarounds & SBP2_WORKAROUND_128K_MAX_TRANS)
1547 struct sbp2_logical_unit *lu = cmd->device->hostdata;
1549 dev_notice(lu_dev(lu), "sbp2_scsi_abort\n");
1550 sbp2_agent_reset(lu);
1551 sbp2_cancel_orbs(lu);
1567 struct sbp2_logical_unit *lu;
1572 lu = sdev->hostdata;
1575 (unsigned long long)lu->tgt->guid,
1576 lu->tgt->directory_id, lu->lun);