Lines Matching refs:target
216 static int srp_target_is_topspin(struct srp_target_port *target) in srp_target_is_topspin() argument
222 (!memcmp(&target->ioc_guid, topspin_oui, sizeof topspin_oui) || in srp_target_is_topspin()
223 !memcmp(&target->ioc_guid, cisco_oui, sizeof cisco_oui)); in srp_target_is_topspin()
275 static int srp_init_ib_qp(struct srp_target_port *target, in srp_init_ib_qp() argument
285 ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev, in srp_init_ib_qp()
286 target->srp_host->port, in srp_init_ib_qp()
287 be16_to_cpu(target->ib_cm.pkey), in srp_init_ib_qp()
295 attr->port_num = target->srp_host->port; in srp_init_ib_qp()
310 struct srp_target_port *target = ch->target; in srp_new_ib_cm_id() local
313 new_cm_id = ib_create_cm_id(target->srp_host->srp_dev->dev, in srp_new_ib_cm_id()
321 if (rdma_cap_opa_ah(target->srp_host->srp_dev->dev, in srp_new_ib_cm_id()
322 target->srp_host->port)) in srp_new_ib_cm_id()
326 ch->ib_cm.path.sgid = target->sgid; in srp_new_ib_cm_id()
327 ch->ib_cm.path.dgid = target->ib_cm.orig_dgid; in srp_new_ib_cm_id()
328 ch->ib_cm.path.pkey = target->ib_cm.pkey; in srp_new_ib_cm_id()
329 ch->ib_cm.path.service_id = target->ib_cm.service_id; in srp_new_ib_cm_id()
336 struct srp_target_port *target = ch->target; in srp_new_rdma_cm_id() local
340 new_cm_id = rdma_create_id(target->net, srp_rdma_cm_handler, ch, in srp_new_rdma_cm_id()
349 ret = rdma_resolve_addr(new_cm_id, target->rdma_cm.src_specified ? in srp_new_rdma_cm_id()
350 &target->rdma_cm.src.sa : NULL, in srp_new_rdma_cm_id()
351 &target->rdma_cm.dst.sa, in srp_new_rdma_cm_id()
355 &target->rdma_cm.src, &target->rdma_cm.dst, ret); in srp_new_rdma_cm_id()
365 &target->rdma_cm.dst, ret); in srp_new_rdma_cm_id()
380 struct srp_target_port *target = ch->target; in srp_new_cm_id() local
382 return target->using_rdma_cm ? srp_new_rdma_cm_id(ch) : in srp_new_cm_id()
502 static struct srp_fr_pool *srp_alloc_fr_pool(struct srp_target_port *target) in srp_alloc_fr_pool() argument
504 struct srp_device *dev = target->srp_host->srp_dev; in srp_alloc_fr_pool()
506 return srp_create_fr_pool(dev->dev, dev->pd, target->mr_pool_size, in srp_alloc_fr_pool()
530 struct srp_target_port *target = ch->target; in srp_create_ch_ib() local
531 struct srp_device *dev = target->srp_host->srp_dev; in srp_create_ch_ib()
537 const int m = 1 + dev->use_fast_reg * target->mr_per_cmd * 2; in srp_create_ch_ib()
545 recv_cq = ib_alloc_cq(dev->dev, ch, target->queue_size + 1, in srp_create_ch_ib()
552 send_cq = ib_alloc_cq(dev->dev, ch, m * target->queue_size, in srp_create_ch_ib()
560 init_attr->cap.max_send_wr = m * target->queue_size; in srp_create_ch_ib()
561 init_attr->cap.max_recv_wr = target->queue_size + 1; in srp_create_ch_ib()
571 if (target->using_rdma_cm) { in srp_create_ch_ib()
577 ret = srp_init_ib_qp(target, qp); in srp_create_ch_ib()
591 fr_pool = srp_alloc_fr_pool(target); in srp_create_ch_ib()
594 shost_printk(KERN_WARNING, target->scsi_host, PFX in srp_create_ch_ib()
621 if (target->using_rdma_cm) in srp_create_ch_ib()
641 static void srp_free_ch_ib(struct srp_target_port *target, in srp_free_ch_ib() argument
644 struct srp_device *dev = target->srp_host->srp_dev; in srp_free_ch_ib()
647 if (!ch->target) in srp_free_ch_ib()
650 if (target->using_rdma_cm) { in srp_free_ch_ib()
681 ch->target = NULL; in srp_free_ch_ib()
687 for (i = 0; i < target->queue_size; ++i) in srp_free_ch_ib()
688 srp_free_iu(target->srp_host, ch->rx_ring[i]); in srp_free_ch_ib()
693 for (i = 0; i < target->queue_size; ++i) in srp_free_ch_ib()
694 srp_free_iu(target->srp_host, ch->tx_ring[i]); in srp_free_ch_ib()
705 struct srp_target_port *target = ch->target; in srp_path_rec_completion() local
709 shost_printk(KERN_ERR, target->scsi_host, in srp_path_rec_completion()
718 struct srp_target_port *target = ch->target; in srp_ib_lookup_path() local
726 target->srp_host->srp_dev->dev, in srp_ib_lookup_path()
727 target->srp_host->port, in srp_ib_lookup_path()
746 shost_printk(KERN_WARNING, target->scsi_host, in srp_ib_lookup_path()
749 be16_to_cpu(target->ib_cm.pkey), in srp_ib_lookup_path()
750 be64_to_cpu(target->ib_cm.service_id)); in srp_ib_lookup_path()
757 struct srp_target_port *target = ch->target; in srp_rdma_lookup_path() local
769 shost_printk(KERN_WARNING, target->scsi_host, in srp_rdma_lookup_path()
777 struct srp_target_port *target = ch->target; in srp_lookup_path() local
779 return target->using_rdma_cm ? srp_rdma_lookup_path(ch) : in srp_lookup_path()
803 struct srp_target_port *target = ch->target; in srp_send_req() local
818 req->ib_param.retry_count = target->tl_retry_count; in srp_send_req()
840 if (target->using_rdma_cm) { in srp_send_req()
862 subnet_timeout = srp_get_subnet_timeout(target->srp_host); in srp_send_req()
866 req->ib_param.service_id = target->ib_cm.service_id; in srp_send_req()
889 if (target->io_class == SRP_REV10_IB_IO_CLASS) { in srp_send_req()
890 memcpy(ipi, &target->sgid.global.interface_id, 8); in srp_send_req()
891 memcpy(ipi + 8, &target->initiator_ext, 8); in srp_send_req()
892 memcpy(tpi, &target->ioc_guid, 8); in srp_send_req()
893 memcpy(tpi + 8, &target->id_ext, 8); in srp_send_req()
895 memcpy(ipi, &target->initiator_ext, 8); in srp_send_req()
896 memcpy(ipi + 8, &target->sgid.global.interface_id, 8); in srp_send_req()
897 memcpy(tpi, &target->id_ext, 8); in srp_send_req()
898 memcpy(tpi + 8, &target->ioc_guid, 8); in srp_send_req()
906 if (srp_target_is_topspin(target)) { in srp_send_req()
907 shost_printk(KERN_DEBUG, target->scsi_host, in srp_send_req()
910 be64_to_cpu(target->ioc_guid)); in srp_send_req()
912 memcpy(ipi + 8, &target->srp_host->srp_dev->dev->node_guid, 8); in srp_send_req()
915 if (target->using_rdma_cm) in srp_send_req()
925 static bool srp_queue_remove_work(struct srp_target_port *target) in srp_queue_remove_work() argument
929 spin_lock_irq(&target->lock); in srp_queue_remove_work()
930 if (target->state != SRP_TARGET_REMOVED) { in srp_queue_remove_work()
931 target->state = SRP_TARGET_REMOVED; in srp_queue_remove_work()
934 spin_unlock_irq(&target->lock); in srp_queue_remove_work()
937 queue_work(srp_remove_wq, &target->remove_work); in srp_queue_remove_work()
942 static void srp_disconnect_target(struct srp_target_port *target) in srp_disconnect_target() argument
949 for (i = 0; i < target->ch_count; i++) { in srp_disconnect_target()
950 ch = &target->ch[i]; in srp_disconnect_target()
953 if (target->using_rdma_cm) { in srp_disconnect_target()
962 shost_printk(KERN_DEBUG, target->scsi_host, in srp_disconnect_target()
970 struct srp_target_port *target = host_to_target(shost); in srp_exit_cmd_priv() local
971 struct srp_device *dev = target->srp_host->srp_dev; in srp_exit_cmd_priv()
978 target->indirect_size, in srp_exit_cmd_priv()
988 struct srp_target_port *target = host_to_target(shost); in srp_init_cmd_priv() local
989 struct srp_device *srp_dev = target->srp_host->srp_dev; in srp_init_cmd_priv()
996 req->fr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *), in srp_init_cmd_priv()
1001 req->indirect_desc = kmalloc(target->indirect_size, GFP_KERNEL); in srp_init_cmd_priv()
1006 target->indirect_size, in srp_init_cmd_priv()
1042 static void srp_remove_target(struct srp_target_port *target) in srp_remove_target() argument
1047 WARN_ON_ONCE(target->state != SRP_TARGET_REMOVED); in srp_remove_target()
1049 srp_del_scsi_host_attr(target->scsi_host); in srp_remove_target()
1050 srp_rport_get(target->rport); in srp_remove_target()
1051 srp_remove_host(target->scsi_host); in srp_remove_target()
1052 scsi_remove_host(target->scsi_host); in srp_remove_target()
1053 srp_stop_rport_timers(target->rport); in srp_remove_target()
1054 srp_disconnect_target(target); in srp_remove_target()
1055 kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net); in srp_remove_target()
1056 for (i = 0; i < target->ch_count; i++) { in srp_remove_target()
1057 ch = &target->ch[i]; in srp_remove_target()
1058 srp_free_ch_ib(target, ch); in srp_remove_target()
1060 cancel_work_sync(&target->tl_err_work); in srp_remove_target()
1061 srp_rport_put(target->rport); in srp_remove_target()
1062 kfree(target->ch); in srp_remove_target()
1063 target->ch = NULL; in srp_remove_target()
1065 spin_lock(&target->srp_host->target_lock); in srp_remove_target()
1066 list_del(&target->list); in srp_remove_target()
1067 spin_unlock(&target->srp_host->target_lock); in srp_remove_target()
1069 scsi_host_put(target->scsi_host); in srp_remove_target()
1074 struct srp_target_port *target = in srp_remove_work() local
1077 WARN_ON_ONCE(target->state != SRP_TARGET_REMOVED); in srp_remove_work()
1079 srp_remove_target(target); in srp_remove_work()
1084 struct srp_target_port *target = rport->lld_data; in srp_rport_delete() local
1086 srp_queue_remove_work(target); in srp_rport_delete()
1093 static int srp_connected_ch(struct srp_target_port *target) in srp_connected_ch() argument
1097 for (i = 0; i < target->ch_count; i++) in srp_connected_ch()
1098 c += target->ch[i].connected; in srp_connected_ch()
1106 struct srp_target_port *target = ch->target; in srp_connect_ch() local
1109 WARN_ON_ONCE(!multich && srp_connected_ch(target) > 0); in srp_connect_ch()
1146 shost_printk(KERN_ERR, target->scsi_host, PFX in srp_connect_ch()
1185 struct srp_target_port *target = ch->target; in srp_unmap_data() local
1186 struct srp_device *dev = target->srp_host->srp_dev; in srp_unmap_data()
1201 shost_printk(KERN_ERR, target->scsi_host, PFX in srp_unmap_data()
1205 &target->tl_err_work); in srp_unmap_data()
1289 struct srp_target_port *target = context->srp_target; in srp_terminate_cmd() local
1291 struct srp_rdma_ch *ch = &target->ch[blk_mq_unique_tag_to_hwq(tag)]; in srp_terminate_cmd()
1301 struct srp_target_port *target = rport->lld_data; in srp_terminate_io() local
1302 struct srp_terminate_context context = { .srp_target = target, in srp_terminate_io()
1305 scsi_host_busy_iter(target->scsi_host, srp_terminate_cmd, &context); in srp_terminate_io()
1339 struct srp_target_port *target = rport->lld_data; in srp_rport_reconnect() local
1341 uint32_t max_iu_len = srp_max_it_iu_len(target->cmd_sg_cnt, in srp_rport_reconnect()
1343 target->max_it_iu_size); in srp_rport_reconnect()
1347 srp_disconnect_target(target); in srp_rport_reconnect()
1349 if (target->state == SRP_TARGET_SCANNING) in srp_rport_reconnect()
1357 for (i = 0; i < target->ch_count; i++) { in srp_rport_reconnect()
1358 ch = &target->ch[i]; in srp_rport_reconnect()
1363 .srp_target = target, .scsi_result = DID_RESET << 16}; in srp_rport_reconnect()
1365 scsi_host_busy_iter(target->scsi_host, srp_terminate_cmd, in srp_rport_reconnect()
1368 for (i = 0; i < target->ch_count; i++) { in srp_rport_reconnect()
1369 ch = &target->ch[i]; in srp_rport_reconnect()
1378 for (j = 0; j < target->queue_size; ++j) in srp_rport_reconnect()
1382 target->qp_in_error = false; in srp_rport_reconnect()
1384 for (i = 0; i < target->ch_count; i++) { in srp_rport_reconnect()
1385 ch = &target->ch[i]; in srp_rport_reconnect()
1393 shost_printk(KERN_INFO, target->scsi_host, in srp_rport_reconnect()
1431 struct srp_target_port *target = ch->target; in srp_map_finish_fr() local
1432 struct srp_device *dev = target->srp_host->srp_dev; in srp_map_finish_fr()
1439 shost_printk(KERN_ERR, ch->target->scsi_host, in srp_map_finish_fr()
1441 ch->target->mr_per_cmd); in srp_map_finish_fr()
1447 if (sg_nents == 1 && target->global_rkey) { in srp_map_finish_fr()
1452 target->global_rkey); in srp_map_finish_fr()
1512 state->fr.end = req->fr_list + ch->target->mr_per_cmd; in srp_map_sg_fr()
1537 struct srp_target_port *target = ch->target; in srp_map_sg_dma() local
1543 target->global_rkey); in srp_map_sg_dma()
1560 struct srp_target_port *target = ch->target; in srp_map_idb() local
1561 struct srp_device *dev = target->srp_host->srp_dev; in srp_map_idb()
1599 struct srp_device *dev = ch->target->srp_host->srp_dev; in srp_check_mapping()
1629 struct srp_target_port *target = ch->target; in srp_map_data() local
1649 shost_printk(KERN_WARNING, target->scsi_host, in srp_map_data()
1659 dev = target->srp_host->srp_dev; in srp_map_data()
1682 sge[i].lkey = target->lkey; in srp_map_data()
1692 if (count == 1 && target->global_rkey) { in srp_map_data()
1703 buf->key = cpu_to_be32(target->global_rkey); in srp_map_data()
1717 target->indirect_size, DMA_TO_DEVICE); in srp_map_data()
1754 if (unlikely(target->cmd_sg_cnt < state.ndesc && in srp_map_data()
1755 !target->allow_ext_sg)) { in srp_map_data()
1756 shost_printk(KERN_ERR, target->scsi_host, in srp_map_data()
1762 count = min(state.ndesc, target->cmd_sg_cnt); in srp_map_data()
1774 if (!target->global_rkey) { in srp_map_data()
1781 idb_rkey = cpu_to_be32(target->global_rkey); in srp_map_data()
1807 if (ret == -ENOMEM && req->nmdesc >= target->mr_pool_size) in srp_map_data()
1843 struct srp_target_port *target = ch->target; in __srp_get_tx_iu() local
1857 ++target->zero_req_lim; in __srp_get_tx_iu()
1897 struct srp_target_port *target = ch->target; in srp_post_send() local
1905 iu->sge[0].lkey = target->lkey; in srp_post_send()
1921 struct srp_target_port *target = ch->target; in srp_post_recv() local
1927 list.lkey = target->lkey; in srp_post_recv()
1941 struct srp_target_port *target = ch->target; in srp_process_rsp() local
1955 shost_printk(KERN_ERR, target->scsi_host, in srp_process_rsp()
1961 scmnd = scsi_host_find_tag(target->scsi_host, rsp->tag); in srp_process_rsp()
1966 shost_printk(KERN_ERR, target->scsi_host, in srp_process_rsp()
1968 rsp->tag, ch - target->ch, ch->qp->qp_num); in srp_process_rsp()
2004 struct srp_target_port *target = ch->target; in srp_response_common() local
2005 struct ib_device *dev = target->srp_host->srp_dev->dev; in srp_response_common()
2016 shost_printk(KERN_ERR, target->scsi_host, PFX in srp_response_common()
2028 shost_printk(KERN_ERR, target->scsi_host, PFX in srp_response_common()
2046 shost_printk(KERN_ERR, ch->target->scsi_host, PFX in srp_process_cred_req()
2053 struct srp_target_port *target = ch->target; in srp_process_aer_req() local
2060 shost_printk(KERN_ERR, target->scsi_host, PFX in srp_process_aer_req()
2064 shost_printk(KERN_ERR, target->scsi_host, PFX in srp_process_aer_req()
2072 struct srp_target_port *target = ch->target; in srp_recv_done() local
2073 struct ib_device *dev = target->srp_host->srp_dev->dev; in srp_recv_done()
2088 shost_printk(KERN_ERR, target->scsi_host, in srp_recv_done()
2109 shost_printk(KERN_WARNING, target->scsi_host, in srp_recv_done()
2114 shost_printk(KERN_WARNING, target->scsi_host, in srp_recv_done()
2124 shost_printk(KERN_ERR, target->scsi_host, in srp_recv_done()
2137 struct srp_target_port *target; in srp_tl_err_work() local
2139 target = container_of(work, struct srp_target_port, tl_err_work); in srp_tl_err_work()
2140 if (target->rport) in srp_tl_err_work()
2141 srp_start_tl_fail_timers(target->rport); in srp_tl_err_work()
2148 struct srp_target_port *target = ch->target; in srp_handle_qp_err() local
2150 if (ch->connected && !target->qp_in_error) { in srp_handle_qp_err()
2151 shost_printk(KERN_ERR, target->scsi_host, in srp_handle_qp_err()
2155 queue_work(system_long_wq, &target->tl_err_work); in srp_handle_qp_err()
2157 target->qp_in_error = true; in srp_handle_qp_err()
2163 struct srp_target_port *target = host_to_target(shost); in srp_queuecommand() local
2173 scmnd->result = srp_chkready(target->rport); in srp_queuecommand()
2179 ch = &target->ch[blk_mq_unique_tag_to_hwq(tag)]; in srp_queuecommand()
2188 dev = target->srp_host->srp_dev->dev; in srp_queuecommand()
2211 shost_printk(KERN_ERR, target->scsi_host, in srp_queuecommand()
2228 shost_printk(KERN_ERR, target->scsi_host, PFX "Send failed\n"); in srp_queuecommand()
2264 struct srp_target_port *target = ch->target; in srp_alloc_iu_bufs() local
2267 ch->rx_ring = kcalloc(target->queue_size, sizeof(*ch->rx_ring), in srp_alloc_iu_bufs()
2271 ch->tx_ring = kcalloc(target->queue_size, sizeof(*ch->tx_ring), in srp_alloc_iu_bufs()
2276 for (i = 0; i < target->queue_size; ++i) { in srp_alloc_iu_bufs()
2277 ch->rx_ring[i] = srp_alloc_iu(target->srp_host, in srp_alloc_iu_bufs()
2284 for (i = 0; i < target->queue_size; ++i) { in srp_alloc_iu_bufs()
2285 ch->tx_ring[i] = srp_alloc_iu(target->srp_host, in srp_alloc_iu_bufs()
2297 for (i = 0; i < target->queue_size; ++i) { in srp_alloc_iu_bufs()
2298 srp_free_iu(target->srp_host, ch->rx_ring[i]); in srp_alloc_iu_bufs()
2299 srp_free_iu(target->srp_host, ch->tx_ring[i]); in srp_alloc_iu_bufs()
2343 struct srp_target_port *target = ch->target; in srp_cm_rep_handler() local
2354 ch->max_it_iu_len = srp_max_it_iu_len(target->cmd_sg_cnt, in srp_cm_rep_handler()
2356 target->max_it_iu_size); in srp_cm_rep_handler()
2361 shost_printk(KERN_DEBUG, target->scsi_host, in srp_cm_rep_handler()
2368 target->scsi_host->can_queue in srp_cm_rep_handler()
2370 target->scsi_host->can_queue); in srp_cm_rep_handler()
2371 target->scsi_host->cmd_per_lun in srp_cm_rep_handler()
2372 = min_t(int, target->scsi_host->can_queue, in srp_cm_rep_handler()
2373 target->scsi_host->cmd_per_lun); in srp_cm_rep_handler()
2375 shost_printk(KERN_WARNING, target->scsi_host, in srp_cm_rep_handler()
2387 for (i = 0; i < target->queue_size; i++) { in srp_cm_rep_handler()
2395 if (!target->using_rdma_cm) { in srp_cm_rep_handler()
2415 target->rq_tmo_jiffies = srp_compute_rq_tmo(qp_attr, attr_mask); in srp_cm_rep_handler()
2435 struct srp_target_port *target = ch->target; in srp_ib_cm_rej_handler() local
2436 struct Scsi_Host *shost = target->scsi_host; in srp_ib_cm_rej_handler()
2454 if (srp_target_is_topspin(target)) { in srp_ib_cm_rej_handler()
2495 target->sgid.raw, in srp_ib_cm_rej_handler()
2496 target->ib_cm.orig_dgid.raw, in srp_ib_cm_rej_handler()
2521 struct srp_target_port *target = ch->target; in srp_ib_cm_handler() local
2526 shost_printk(KERN_DEBUG, target->scsi_host, in srp_ib_cm_handler()
2538 shost_printk(KERN_DEBUG, target->scsi_host, PFX "REJ received\n"); in srp_ib_cm_handler()
2545 shost_printk(KERN_WARNING, target->scsi_host, in srp_ib_cm_handler()
2549 shost_printk(KERN_ERR, target->scsi_host, in srp_ib_cm_handler()
2551 queue_work(system_long_wq, &target->tl_err_work); in srp_ib_cm_handler()
2555 shost_printk(KERN_ERR, target->scsi_host, in srp_ib_cm_handler()
2568 shost_printk(KERN_WARNING, target->scsi_host, in srp_ib_cm_handler()
2582 struct srp_target_port *target = ch->target; in srp_rdma_cm_rej_handler() local
2583 struct Scsi_Host *shost = target->scsi_host; in srp_rdma_cm_rej_handler()
2633 struct srp_target_port *target = ch->target; in srp_rdma_cm_handler() local
2659 shost_printk(KERN_DEBUG, target->scsi_host, in srp_rdma_cm_handler()
2671 shost_printk(KERN_DEBUG, target->scsi_host, PFX "REJ received\n"); in srp_rdma_cm_handler()
2679 shost_printk(KERN_WARNING, target->scsi_host, in srp_rdma_cm_handler()
2684 queue_work(system_long_wq, &target->tl_err_work); in srp_rdma_cm_handler()
2689 shost_printk(KERN_ERR, target->scsi_host, in srp_rdma_cm_handler()
2697 shost_printk(KERN_WARNING, target->scsi_host, in srp_rdma_cm_handler()
2726 struct srp_target_port *target = ch->target; in srp_send_tsk_mgmt() local
2727 struct srp_rport *rport = target->rport; in srp_send_tsk_mgmt()
2728 struct ib_device *dev = target->srp_host->srp_dev->dev; in srp_send_tsk_mgmt()
2733 if (!ch->connected || target->qp_in_error) in srp_send_tsk_mgmt()
2791 struct srp_target_port *target = host_to_target(scmnd->device->host); in srp_abort() local
2798 shost_printk(KERN_ERR, target->scsi_host, "SRP abort called\n"); in srp_abort()
2804 if (WARN_ON_ONCE(ch_idx >= target->ch_count)) in srp_abort()
2806 ch = &target->ch[ch_idx]; in srp_abort()
2809 shost_printk(KERN_ERR, target->scsi_host, in srp_abort()
2814 else if (target->rport->state == SRP_RPORT_LOST) in srp_abort()
2829 struct srp_target_port *target = host_to_target(scmnd->device->host); in srp_reset_device() local
2833 shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n"); in srp_reset_device()
2835 ch = &target->ch[0]; in srp_reset_device()
2847 struct srp_target_port *target = host_to_target(scmnd->device->host); in srp_reset_host() local
2849 shost_printk(KERN_ERR, target->scsi_host, PFX "SRP reset_host called\n"); in srp_reset_host()
2851 return srp_reconnect_rport(target->rport) == 0 ? SUCCESS : FAILED; in srp_reset_host()
2857 struct srp_target_port *target = host_to_target(shost); in srp_target_alloc() local
2859 if (target->target_can_queue) in srp_target_alloc()
2860 starget->can_queue = target->target_can_queue; in srp_target_alloc()
2867 struct srp_target_port *target = host_to_target(shost); in srp_slave_configure() local
2872 timeout = max_t(unsigned, 30 * HZ, target->rq_tmo_jiffies); in srp_slave_configure()
2882 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in id_ext_show() local
2884 return sysfs_emit(buf, "0x%016llx\n", be64_to_cpu(target->id_ext)); in id_ext_show()
2892 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in ioc_guid_show() local
2894 return sysfs_emit(buf, "0x%016llx\n", be64_to_cpu(target->ioc_guid)); in ioc_guid_show()
2902 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in service_id_show() local
2904 if (target->using_rdma_cm) in service_id_show()
2907 be64_to_cpu(target->ib_cm.service_id)); in service_id_show()
2915 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in pkey_show() local
2917 if (target->using_rdma_cm) in pkey_show()
2920 return sysfs_emit(buf, "0x%04x\n", be16_to_cpu(target->ib_cm.pkey)); in pkey_show()
2928 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in sgid_show() local
2930 return sysfs_emit(buf, "%pI6\n", target->sgid.raw); in sgid_show()
2938 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in dgid_show() local
2939 struct srp_rdma_ch *ch = &target->ch[0]; in dgid_show()
2941 if (target->using_rdma_cm) in dgid_show()
2952 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in orig_dgid_show() local
2954 if (target->using_rdma_cm) in orig_dgid_show()
2957 return sysfs_emit(buf, "%pI6\n", target->ib_cm.orig_dgid.raw); in orig_dgid_show()
2965 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in req_lim_show() local
2969 for (i = 0; i < target->ch_count; i++) { in req_lim_show()
2970 ch = &target->ch[i]; in req_lim_show()
2982 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in zero_req_lim_show() local
2984 return sysfs_emit(buf, "%d\n", target->zero_req_lim); in zero_req_lim_show()
2992 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in local_ib_port_show() local
2994 return sysfs_emit(buf, "%d\n", target->srp_host->port); in local_ib_port_show()
3002 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in local_ib_device_show() local
3005 dev_name(&target->srp_host->srp_dev->dev->dev)); in local_ib_device_show()
3013 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in ch_count_show() local
3015 return sysfs_emit(buf, "%d\n", target->ch_count); in ch_count_show()
3023 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in comp_vector_show() local
3025 return sysfs_emit(buf, "%d\n", target->comp_vector); in comp_vector_show()
3033 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in tl_retry_count_show() local
3035 return sysfs_emit(buf, "%d\n", target->tl_retry_count); in tl_retry_count_show()
3043 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in cmd_sg_entries_show() local
3045 return sysfs_emit(buf, "%u\n", target->cmd_sg_cnt); in cmd_sg_entries_show()
3053 struct srp_target_port *target = host_to_target(class_to_shost(dev)); in allow_ext_sg_show() local
3055 return sysfs_emit(buf, "%s\n", target->allow_ext_sg ? "true" : "false"); in allow_ext_sg_show()
3125 static int srp_add_target(struct srp_host *host, struct srp_target_port *target) in srp_add_target() argument
3130 target->state = SRP_TARGET_SCANNING; in srp_add_target()
3131 sprintf(target->target_name, "SRP.T10:%016llX", in srp_add_target()
3132 be64_to_cpu(target->id_ext)); in srp_add_target()
3134 if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dev.parent)) in srp_add_target()
3137 memcpy(ids.port_id, &target->id_ext, 8); in srp_add_target()
3138 memcpy(ids.port_id + 8, &target->ioc_guid, 8); in srp_add_target()
3140 rport = srp_rport_add(target->scsi_host, &ids); in srp_add_target()
3142 scsi_remove_host(target->scsi_host); in srp_add_target()
3146 rport->lld_data = target; in srp_add_target()
3147 target->rport = rport; in srp_add_target()
3150 list_add_tail(&target->list, &host->target_list); in srp_add_target()
3153 scsi_scan_target(&target->scsi_host->shost_gendev, in srp_add_target()
3154 0, target->scsi_id, SCAN_WILD_CARD, SCSI_SCAN_INITIAL); in srp_add_target()
3156 if (srp_connected_ch(target) < target->ch_count || in srp_add_target()
3157 target->qp_in_error) { in srp_add_target()
3158 shost_printk(KERN_INFO, target->scsi_host, in srp_add_target()
3160 srp_queue_remove_work(target); in srp_add_target()
3165 dev_name(&target->scsi_host->shost_gendev), in srp_add_target()
3166 srp_sdev_count(target->scsi_host)); in srp_add_target()
3168 spin_lock_irq(&target->lock); in srp_add_target()
3169 if (target->state == SRP_TARGET_SCANNING) in srp_add_target()
3170 target->state = SRP_TARGET_LIVE; in srp_add_target()
3171 spin_unlock_irq(&target->lock); in srp_add_target()
3196 struct srp_target_port *target) in srp_conn_unique() argument
3201 if (target->state == SRP_TARGET_REMOVED) in srp_conn_unique()
3208 if (t != target && in srp_conn_unique()
3209 target->id_ext == t->id_ext && in srp_conn_unique()
3210 target->ioc_guid == t->ioc_guid && in srp_conn_unique()
3211 target->initiator_ext == t->initiator_ext) { in srp_conn_unique()
3334 struct srp_target_port *target) in srp_parse_options() argument
3371 target->id_ext = cpu_to_be64(ull); in srp_parse_options()
3387 target->ioc_guid = cpu_to_be64(ull); in srp_parse_options()
3403 ret = hex2bin(target->ib_cm.orig_dgid.raw, p, 16); in srp_parse_options()
3414 target->ib_cm.pkey = cpu_to_be16(token); in srp_parse_options()
3429 target->ib_cm.service_id = cpu_to_be64(ull); in srp_parse_options()
3439 ret = srp_parse_in(net, &target->rdma_cm.src.ss, p, in srp_parse_options()
3446 target->rdma_cm.src_specified = true; in srp_parse_options()
3456 ret = srp_parse_in(net, &target->rdma_cm.dst.ss, p, in srp_parse_options()
3465 target->using_rdma_cm = true; in srp_parse_options()
3474 target->scsi_host->max_sectors = token; in srp_parse_options()
3482 target->scsi_host->can_queue = token; in srp_parse_options()
3483 target->queue_size = token + SRP_RSP_SQ_SIZE + in srp_parse_options()
3486 target->scsi_host->cmd_per_lun = token; in srp_parse_options()
3495 target->scsi_host->cmd_per_lun = token; in srp_parse_options()
3504 target->target_can_queue = token; in srp_parse_options()
3519 target->io_class = token; in srp_parse_options()
3534 target->initiator_ext = cpu_to_be64(ull); in srp_parse_options()
3544 target->cmd_sg_cnt = token; in srp_parse_options()
3552 target->allow_ext_sg = !!token; in srp_parse_options()
3562 target->sg_tablesize = token; in srp_parse_options()
3570 target->comp_vector = token; in srp_parse_options()
3579 target->tl_retry_count = token; in srp_parse_options()
3587 target->max_it_iu_size = token; in srp_parse_options()
3595 target->ch_count = token; in srp_parse_options()
3614 if (target->scsi_host->cmd_per_lun > target->scsi_host->can_queue in srp_parse_options()
3617 target->scsi_host->cmd_per_lun, in srp_parse_options()
3618 target->scsi_host->can_queue); in srp_parse_options()
3632 struct srp_target_port *target; in add_target_store() local
3656 target = host_to_target(target_host); in add_target_store()
3658 target->net = kobj_ns_grab_current(KOBJ_NS_TYPE_NET); in add_target_store()
3659 target->io_class = SRP_REV16A_IB_IO_CLASS; in add_target_store()
3660 target->scsi_host = target_host; in add_target_store()
3661 target->srp_host = host; in add_target_store()
3662 target->lkey = host->srp_dev->pd->local_dma_lkey; in add_target_store()
3663 target->global_rkey = host->srp_dev->global_rkey; in add_target_store()
3664 target->cmd_sg_cnt = cmd_sg_entries; in add_target_store()
3665 target->sg_tablesize = indirect_sg_entries ? : cmd_sg_entries; in add_target_store()
3666 target->allow_ext_sg = allow_ext_sg; in add_target_store()
3667 target->tl_retry_count = 7; in add_target_store()
3668 target->queue_size = SRP_DEFAULT_QUEUE_SIZE; in add_target_store()
3674 scsi_host_get(target->scsi_host); in add_target_store()
3680 ret = srp_parse_options(target->net, buf, target); in add_target_store()
3684 if (!srp_conn_unique(target->srp_host, target)) { in add_target_store()
3685 if (target->using_rdma_cm) { in add_target_store()
3686 shost_printk(KERN_INFO, target->scsi_host, in add_target_store()
3688 be64_to_cpu(target->id_ext), in add_target_store()
3689 be64_to_cpu(target->ioc_guid), in add_target_store()
3690 &target->rdma_cm.dst); in add_target_store()
3692 shost_printk(KERN_INFO, target->scsi_host, in add_target_store()
3694 be64_to_cpu(target->id_ext), in add_target_store()
3695 be64_to_cpu(target->ioc_guid), in add_target_store()
3696 be64_to_cpu(target->initiator_ext)); in add_target_store()
3702 if (!srp_dev->has_fr && !target->allow_ext_sg && in add_target_store()
3703 target->cmd_sg_cnt < target->sg_tablesize) { in add_target_store()
3705 target->sg_tablesize = target->cmd_sg_cnt; in add_target_store()
3729 (target->scsi_host->max_sectors + 1 + in add_target_store()
3733 (target->sg_tablesize + in add_target_store()
3738 target->scsi_host->max_sectors, srp_dev->max_pages_per_mr, srp_dev->mr_page_size, in add_target_store()
3742 target_host->sg_tablesize = target->sg_tablesize; in add_target_store()
3743 target->mr_pool_size = target->scsi_host->can_queue * mr_per_cmd; in add_target_store()
3744 target->mr_per_cmd = mr_per_cmd; in add_target_store()
3745 target->indirect_size = target->sg_tablesize * in add_target_store()
3747 max_iu_len = srp_max_it_iu_len(target->cmd_sg_cnt, in add_target_store()
3749 target->max_it_iu_size); in add_target_store()
3751 INIT_WORK(&target->tl_err_work, srp_tl_err_work); in add_target_store()
3752 INIT_WORK(&target->remove_work, srp_remove_work); in add_target_store()
3753 spin_lock_init(&target->lock); in add_target_store()
3754 ret = rdma_query_gid(ibdev, host->port, 0, &target->sgid); in add_target_store()
3759 if (target->ch_count == 0) { in add_target_store()
3760 target->ch_count = in add_target_store()
3767 target->ch = kcalloc(target->ch_count, sizeof(*target->ch), in add_target_store()
3769 if (!target->ch) in add_target_store()
3772 for (ch_idx = 0; ch_idx < target->ch_count; ++ch_idx) { in add_target_store()
3773 ch = &target->ch[ch_idx]; in add_target_store()
3774 ch->target = target; in add_target_store()
3790 if (target->using_rdma_cm) in add_target_store()
3792 &target->rdma_cm.dst); in add_target_store()
3795 target->ib_cm.orig_dgid.raw); in add_target_store()
3796 shost_printk(KERN_ERR, target->scsi_host, in add_target_store()
3799 target->ch_count, dst); in add_target_store()
3803 srp_free_ch_ib(target, ch); in add_target_store()
3804 target->ch_count = ch - target->ch; in add_target_store()
3812 target->scsi_host->nr_hw_queues = target->ch_count; in add_target_store()
3814 ret = srp_add_target(host, target); in add_target_store()
3818 if (target->state != SRP_TARGET_REMOVED) { in add_target_store()
3819 if (target->using_rdma_cm) { in add_target_store()
3820 shost_printk(KERN_DEBUG, target->scsi_host, PFX in add_target_store()
3822 be64_to_cpu(target->id_ext), in add_target_store()
3823 be64_to_cpu(target->ioc_guid), in add_target_store()
3824 target->sgid.raw, &target->rdma_cm.dst); in add_target_store()
3826 shost_printk(KERN_DEBUG, target->scsi_host, PFX in add_target_store()
3828 be64_to_cpu(target->id_ext), in add_target_store()
3829 be64_to_cpu(target->ioc_guid), in add_target_store()
3830 be16_to_cpu(target->ib_cm.pkey), in add_target_store()
3831 be64_to_cpu(target->ib_cm.service_id), in add_target_store()
3832 target->sgid.raw, in add_target_store()
3833 target->ib_cm.orig_dgid.raw); in add_target_store()
3843 scsi_host_put(target->scsi_host); in add_target_store()
3850 if (target->state != SRP_TARGET_REMOVED) in add_target_store()
3851 kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net); in add_target_store()
3852 scsi_host_put(target->scsi_host); in add_target_store()
3858 srp_disconnect_target(target); in add_target_store()
3861 for (i = 0; i < target->ch_count; i++) { in add_target_store()
3862 ch = &target->ch[i]; in add_target_store()
3863 srp_free_ch_ib(target, ch); in add_target_store()
3866 kfree(target->ch); in add_target_store()
4029 struct srp_target_port *target; in srp_remove_one() local
4045 list_for_each_entry(target, &host->target_list, list) in srp_remove_one()
4046 srp_queue_remove_work(target); in srp_remove_one()