Lines Matching refs:target

90 		 "Enable workarounds for Topspin/Cisco SRP target bugs if != 0");
137 "Number of RDMA channels to use for communication with an SRP target. Using more than one channel improves performance if the HCA supports multiple completion vectors. The default value is the minimum of four times the number of online CPU sockets and the number of completion vectors supported by the HCA.");
211 static int srp_target_is_topspin(struct srp_target_port *target)
217 (!memcmp(&target->ioc_guid, topspin_oui, sizeof topspin_oui) ||
218 !memcmp(&target->ioc_guid, cisco_oui, sizeof cisco_oui));
270 static int srp_init_ib_qp(struct srp_target_port *target,
280 ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev,
281 target->srp_host->port,
282 be16_to_cpu(target->ib_cm.pkey),
290 attr->port_num = target->srp_host->port;
305 struct srp_target_port *target = ch->target;
308 new_cm_id = ib_create_cm_id(target->srp_host->srp_dev->dev,
316 if (rdma_cap_opa_ah(target->srp_host->srp_dev->dev,
317 target->srp_host->port))
321 ch->ib_cm.path.sgid = target->sgid;
322 ch->ib_cm.path.dgid = target->ib_cm.orig_dgid;
323 ch->ib_cm.path.pkey = target->ib_cm.pkey;
324 ch->ib_cm.path.service_id = target->ib_cm.service_id;
331 struct srp_target_port *target = ch->target;
335 new_cm_id = rdma_create_id(target->net, srp_rdma_cm_handler, ch,
344 ret = rdma_resolve_addr(new_cm_id, target->rdma_cm.src_specified ?
345 &target->rdma_cm.src.sa : NULL,
346 &target->rdma_cm.dst.sa,
350 &target->rdma_cm.src, &target->rdma_cm.dst, ret);
360 &target->rdma_cm.dst, ret);
375 struct srp_target_port *target = ch->target;
377 return target->using_rdma_cm ? srp_new_rdma_cm_id(ch) :
497 static struct srp_fr_pool *srp_alloc_fr_pool(struct srp_target_port *target)
499 struct srp_device *dev = target->srp_host->srp_dev;
501 return srp_create_fr_pool(dev->dev, dev->pd, target->mr_pool_size,
525 struct srp_target_port *target = ch->target;
526 struct srp_device *dev = target->srp_host->srp_dev;
532 const int m = 1 + dev->use_fast_reg * target->mr_per_cmd * 2;
540 recv_cq = ib_alloc_cq(dev->dev, ch, target->queue_size + 1,
547 send_cq = ib_alloc_cq(dev->dev, ch, m * target->queue_size,
555 init_attr->cap.max_send_wr = m * target->queue_size;
556 init_attr->cap.max_recv_wr = target->queue_size + 1;
566 if (target->using_rdma_cm) {
572 ret = srp_init_ib_qp(target, qp);
586 fr_pool = srp_alloc_fr_pool(target);
589 shost_printk(KERN_WARNING, target->scsi_host, PFX
616 if (target->using_rdma_cm)
636 static void srp_free_ch_ib(struct srp_target_port *target,
639 struct srp_device *dev = target->srp_host->srp_dev;
642 if (!ch->target)
645 if (target->using_rdma_cm) {
676 ch->target = NULL;
682 for (i = 0; i < target->queue_size; ++i)
683 srp_free_iu(target->srp_host, ch->rx_ring[i]);
688 for (i = 0; i < target->queue_size; ++i)
689 srp_free_iu(target->srp_host, ch->tx_ring[i]);
700 struct srp_target_port *target = ch->target;
704 shost_printk(KERN_ERR, target->scsi_host,
713 struct srp_target_port *target = ch->target;
721 target->srp_host->srp_dev->dev,
722 target->srp_host->port,
741 shost_printk(KERN_WARNING, target->scsi_host,
744 be16_to_cpu(target->ib_cm.pkey),
745 be64_to_cpu(target->ib_cm.service_id));
752 struct srp_target_port *target = ch->target;
764 shost_printk(KERN_WARNING, target->scsi_host,
772 struct srp_target_port *target = ch->target;
774 return target->using_rdma_cm ? srp_rdma_lookup_path(ch) :
798 struct srp_target_port *target = ch->target;
813 req->ib_param.retry_count = target->tl_retry_count;
835 if (target->using_rdma_cm) {
857 subnet_timeout = srp_get_subnet_timeout(target->srp_host);
861 req->ib_param.service_id = target->ib_cm.service_id;
884 if (target->io_class == SRP_REV10_IB_IO_CLASS) {
885 memcpy(ipi, &target->sgid.global.interface_id, 8);
886 memcpy(ipi + 8, &target->initiator_ext, 8);
887 memcpy(tpi, &target->ioc_guid, 8);
888 memcpy(tpi + 8, &target->id_ext, 8);
890 memcpy(ipi, &target->initiator_ext, 8);
891 memcpy(ipi + 8, &target->sgid.global.interface_id, 8);
892 memcpy(tpi, &target->id_ext, 8);
893 memcpy(tpi + 8, &target->ioc_guid, 8);
901 if (srp_target_is_topspin(target)) {
902 shost_printk(KERN_DEBUG, target->scsi_host,
904 "activated for target GUID %016llx\n",
905 be64_to_cpu(target->ioc_guid));
907 memcpy(ipi + 8, &target->srp_host->srp_dev->dev->node_guid, 8);
910 if (target->using_rdma_cm)
920 static bool srp_queue_remove_work(struct srp_target_port *target)
924 spin_lock_irq(&target->lock);
925 if (target->state != SRP_TARGET_REMOVED) {
926 target->state = SRP_TARGET_REMOVED;
929 spin_unlock_irq(&target->lock);
932 queue_work(srp_remove_wq, &target->remove_work);
937 static void srp_disconnect_target(struct srp_target_port *target)
944 for (i = 0; i < target->ch_count; i++) {
945 ch = &target->ch[i];
948 if (target->using_rdma_cm) {
957 shost_printk(KERN_DEBUG, target->scsi_host,
965 struct srp_target_port *target = host_to_target(shost);
966 struct srp_device *dev = target->srp_host->srp_dev;
973 target->indirect_size,
983 struct srp_target_port *target = host_to_target(shost);
984 struct srp_device *srp_dev = target->srp_host->srp_dev;
991 req->fr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *),
996 req->indirect_desc = kmalloc(target->indirect_size, GFP_KERNEL);
1001 target->indirect_size,
1037 static void srp_remove_target(struct srp_target_port *target)
1042 WARN_ON_ONCE(target->state != SRP_TARGET_REMOVED);
1044 srp_del_scsi_host_attr(target->scsi_host);
1045 srp_rport_get(target->rport);
1046 srp_remove_host(target->scsi_host);
1047 scsi_remove_host(target->scsi_host);
1048 srp_stop_rport_timers(target->rport);
1049 srp_disconnect_target(target);
1050 kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net);
1051 for (i = 0; i < target->ch_count; i++) {
1052 ch = &target->ch[i];
1053 srp_free_ch_ib(target, ch);
1055 cancel_work_sync(&target->tl_err_work);
1056 srp_rport_put(target->rport);
1057 kfree(target->ch);
1058 target->ch = NULL;
1060 spin_lock(&target->srp_host->target_lock);
1061 list_del(&target->list);
1062 spin_unlock(&target->srp_host->target_lock);
1064 scsi_host_put(target->scsi_host);
1069 struct srp_target_port *target =
1072 WARN_ON_ONCE(target->state != SRP_TARGET_REMOVED);
1074 srp_remove_target(target);
1079 struct srp_target_port *target = rport->lld_data;
1081 srp_queue_remove_work(target);
1086 * @target: SRP target port.
1088 static int srp_connected_ch(struct srp_target_port *target)
1092 for (i = 0; i < target->ch_count; i++)
1093 c += target->ch[i].connected;
1101 struct srp_target_port *target = ch->target;
1104 WARN_ON_ONCE(!multich && srp_connected_ch(target) > 0);
1141 shost_printk(KERN_ERR, target->scsi_host, PFX
1180 struct srp_target_port *target = ch->target;
1181 struct srp_device *dev = target->srp_host->srp_dev;
1196 shost_printk(KERN_ERR, target->scsi_host, PFX
1200 &target->tl_err_work);
1249 * @req_lim_delta: Amount to be added to @target->req_lim.
1283 struct srp_target_port *target = context->srp_target;
1285 struct srp_rdma_ch *ch = &target->ch[blk_mq_unique_tag_to_hwq(tag)];
1295 struct srp_target_port *target = rport->lld_data;
1296 struct srp_terminate_context context = { .srp_target = target,
1299 scsi_host_busy_iter(target->scsi_host, srp_terminate_cmd, &context);
1302 /* Calculate maximum initiator to target information unit length. */
1333 struct srp_target_port *target = rport->lld_data;
1335 uint32_t max_iu_len = srp_max_it_iu_len(target->cmd_sg_cnt,
1337 target->max_it_iu_size);
1341 srp_disconnect_target(target);
1343 if (target->state == SRP_TARGET_SCANNING)
1347 * Now get a new local CM ID so that we avoid confusing the target in
1351 for (i = 0; i < target->ch_count; i++) {
1352 ch = &target->ch[i];
1357 .srp_target = target, .scsi_result = DID_RESET << 16};
1359 scsi_host_busy_iter(target->scsi_host, srp_terminate_cmd,
1362 for (i = 0; i < target->ch_count; i++) {
1363 ch = &target->ch[i];
1372 for (j = 0; j < target->queue_size; ++j)
1376 target->qp_in_error = false;
1378 for (i = 0; i < target->ch_count; i++) {
1379 ch = &target->ch[i];
1387 shost_printk(KERN_INFO, target->scsi_host,
1425 struct srp_target_port *target = ch->target;
1426 struct srp_device *dev = target->srp_host->srp_dev;
1433 shost_printk(KERN_ERR, ch->target->scsi_host,
1435 ch->target->mr_per_cmd);
1441 if (sg_nents == 1 && target->global_rkey) {
1446 target->global_rkey);
1506 state->fr.end = req->fr_list + ch->target->mr_per_cmd;
1531 struct srp_target_port *target = ch->target;
1537 target->global_rkey);
1554 struct srp_target_port *target = ch->target;
1555 struct srp_device *dev = target->srp_host->srp_dev;
1593 struct srp_device *dev = ch->target->srp_host->srp_dev;
1623 struct srp_target_port *target = ch->target;
1643 shost_printk(KERN_WARNING, target->scsi_host,
1653 dev = target->srp_host->srp_dev;
1676 sge[i].lkey = target->lkey;
1686 if (count == 1 && target->global_rkey) {
1697 buf->key = cpu_to_be32(target->global_rkey);
1711 target->indirect_size, DMA_TO_DEVICE);
1732 * target is not using an external indirect table, we are
1748 if (unlikely(target->cmd_sg_cnt < state.ndesc &&
1749 !target->allow_ext_sg)) {
1750 shost_printk(KERN_ERR, target->scsi_host,
1756 count = min(state.ndesc, target->cmd_sg_cnt);
1768 if (!target->global_rkey) {
1775 idb_rkey = cpu_to_be32(target->global_rkey);
1801 if (ret == -ENOMEM && req->nmdesc >= target->mr_pool_size)
1831 * - SRP_IU_RSP: 1, since a conforming SRP target never sends more than
1837 struct srp_target_port *target = ch->target;
1848 /* Initiator responses to target requests do not consume credits */
1851 ++target->zero_req_lim;
1891 struct srp_target_port *target = ch->target;
1899 iu->sge[0].lkey = target->lkey;
1915 struct srp_target_port *target = ch->target;
1921 list.lkey = target->lkey;
1935 struct srp_target_port *target = ch->target;
1949 shost_printk(KERN_ERR, target->scsi_host,
1955 scmnd = scsi_host_find_tag(target->scsi_host, rsp->tag);
1961 shost_printk(KERN_ERR, target->scsi_host,
1963 rsp->tag, ch - target->ch, ch->qp->qp_num);
1995 struct srp_target_port *target = ch->target;
1996 struct ib_device *dev = target->srp_host->srp_dev->dev;
2007 shost_printk(KERN_ERR, target->scsi_host, PFX
2019 shost_printk(KERN_ERR, target->scsi_host, PFX
2037 shost_printk(KERN_ERR, ch->target->scsi_host, PFX
2044 struct srp_target_port *target = ch->target;
2051 shost_printk(KERN_ERR, target->scsi_host, PFX
2055 shost_printk(KERN_ERR, target->scsi_host, PFX
2063 struct srp_target_port *target = ch->target;
2064 struct ib_device *dev = target->srp_host->srp_dev->dev;
2079 shost_printk(KERN_ERR, target->scsi_host,
2099 /* XXX Handle target logout */
2100 shost_printk(KERN_WARNING, target->scsi_host,
2101 PFX "Got target logout request\n");
2105 shost_printk(KERN_WARNING, target->scsi_host,
2115 shost_printk(KERN_ERR, target->scsi_host,
2121 * @work: Work structure embedded in an SRP target port.
2124 * hence the target->rport test.
2128 struct srp_target_port *target;
2130 target = container_of(work, struct srp_target_port, tl_err_work);
2131 if (target->rport)
2132 srp_start_tl_fail_timers(target->rport);
2139 struct srp_target_port *target = ch->target;
2141 if (ch->connected && !target->qp_in_error) {
2142 shost_printk(KERN_ERR, target->scsi_host,
2146 queue_work(system_long_wq, &target->tl_err_work);
2148 target->qp_in_error = true;
2154 struct srp_target_port *target = host_to_target(shost);
2164 scmnd->result = srp_chkready(target->rport);
2170 ch = &target->ch[blk_mq_unique_tag_to_hwq(tag)];
2179 dev = target->srp_host->srp_dev->dev;
2202 shost_printk(KERN_ERR, target->scsi_host,
2219 shost_printk(KERN_ERR, target->scsi_host, PFX "Send failed\n");
2255 struct srp_target_port *target = ch->target;
2258 ch->rx_ring = kcalloc(target->queue_size, sizeof(*ch->rx_ring),
2262 ch->tx_ring = kcalloc(target->queue_size, sizeof(*ch->tx_ring),
2267 for (i = 0; i < target->queue_size; ++i) {
2268 ch->rx_ring[i] = srp_alloc_iu(target->srp_host,
2275 for (i = 0; i < target->queue_size; ++i) {
2276 ch->tx_ring[i] = srp_alloc_iu(target->srp_host,
2288 for (i = 0; i < target->queue_size; ++i) {
2289 srp_free_iu(target->srp_host, ch->rx_ring[i]);
2290 srp_free_iu(target->srp_host, ch->tx_ring[i]);
2317 * Set target->rq_tmo_jiffies to one second more than the largest time
2334 struct srp_target_port *target = ch->target;
2345 ch->max_it_iu_len = srp_max_it_iu_len(target->cmd_sg_cnt,
2347 target->max_it_iu_size);
2352 shost_printk(KERN_DEBUG, target->scsi_host,
2359 target->scsi_host->can_queue
2361 target->scsi_host->can_queue);
2362 target->scsi_host->cmd_per_lun
2363 = min_t(int, target->scsi_host->can_queue,
2364 target->scsi_host->cmd_per_lun);
2366 shost_printk(KERN_WARNING, target->scsi_host,
2378 for (i = 0; i < target->queue_size; i++) {
2386 if (!target->using_rdma_cm) {
2406 target->rq_tmo_jiffies = srp_compute_rq_tmo(qp_attr, attr_mask);
2426 struct srp_target_port *target = ch->target;
2427 struct Scsi_Host *shost = target->scsi_host;
2445 if (srp_target_is_topspin(target)) {
2456 PFX "Topspin/Cisco redirect to target port GID %016llx%016llx\n",
2486 target->sgid.raw,
2487 target->ib_cm.orig_dgid.raw,
2512 struct srp_target_port *target = ch->target;
2517 shost_printk(KERN_DEBUG, target->scsi_host,
2529 shost_printk(KERN_DEBUG, target->scsi_host, PFX "REJ received\n");
2536 shost_printk(KERN_WARNING, target->scsi_host,
2540 shost_printk(KERN_ERR, target->scsi_host,
2542 queue_work(system_long_wq, &target->tl_err_work);
2546 shost_printk(KERN_ERR, target->scsi_host,
2559 shost_printk(KERN_WARNING, target->scsi_host,
2573 struct srp_target_port *target = ch->target;
2574 struct Scsi_Host *shost = target->scsi_host;
2624 struct srp_target_port *target = ch->target;
2650 shost_printk(KERN_DEBUG, target->scsi_host,
2662 shost_printk(KERN_DEBUG, target->scsi_host, PFX "REJ received\n");
2670 shost_printk(KERN_WARNING, target->scsi_host,
2675 queue_work(system_long_wq, &target->tl_err_work);
2680 shost_printk(KERN_ERR, target->scsi_host,
2688 shost_printk(KERN_WARNING, target->scsi_host,
2717 struct srp_target_port *target = ch->target;
2718 struct srp_rport *rport = target->rport;
2719 struct ib_device *dev = target->srp_host->srp_dev->dev;
2724 if (!ch->connected || target->qp_in_error)
2782 struct srp_target_port *target = host_to_target(scmnd->device->host);
2788 shost_printk(KERN_ERR, target->scsi_host, "SRP abort called\n");
2792 if (WARN_ON_ONCE(ch_idx >= target->ch_count))
2794 ch = &target->ch[ch_idx];
2797 shost_printk(KERN_ERR, target->scsi_host,
2804 if (target->rport->state == SRP_RPORT_LOST)
2812 struct srp_target_port *target = host_to_target(scmnd->device->host);
2816 shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n");
2818 ch = &target->ch[0];
2830 struct srp_target_port *target = host_to_target(scmnd->device->host);
2832 shost_printk(KERN_ERR, target->scsi_host, PFX "SRP reset_host called\n");
2834 return srp_reconnect_rport(target->rport) == 0 ? SUCCESS : FAILED;
2840 struct srp_target_port *target = host_to_target(shost);
2842 if (target->target_can_queue)
2843 starget->can_queue = target->target_can_queue;
2850 struct srp_target_port *target = host_to_target(shost);
2855 timeout = max_t(unsigned, 30 * HZ, target->rq_tmo_jiffies);
2865 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2867 return sysfs_emit(buf, "0x%016llx\n", be64_to_cpu(target->id_ext));
2875 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2877 return sysfs_emit(buf, "0x%016llx\n", be64_to_cpu(target->ioc_guid));
2885 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2887 if (target->using_rdma_cm)
2890 be64_to_cpu(target->ib_cm.service_id));
2898 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2900 if (target->using_rdma_cm)
2903 return sysfs_emit(buf, "0x%04x\n", be16_to_cpu(target->ib_cm.pkey));
2911 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2913 return sysfs_emit(buf, "%pI6\n", target->sgid.raw);
2921 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2922 struct srp_rdma_ch *ch = &target->ch[0];
2924 if (target->using_rdma_cm)
2935 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2937 if (target->using_rdma_cm)
2940 return sysfs_emit(buf, "%pI6\n", target->ib_cm.orig_dgid.raw);
2948 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2952 for (i = 0; i < target->ch_count; i++) {
2953 ch = &target->ch[i];
2965 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2967 return sysfs_emit(buf, "%d\n", target->zero_req_lim);
2975 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2977 return sysfs_emit(buf, "%u\n", target->srp_host->port);
2985 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2988 dev_name(&target->srp_host->srp_dev->dev->dev));
2996 struct srp_target_port *target = host_to_target(class_to_shost(dev));
2998 return sysfs_emit(buf, "%d\n", target->ch_count);
3006 struct srp_target_port *target = host_to_target(class_to_shost(dev));
3008 return sysfs_emit(buf, "%d\n", target->comp_vector);
3016 struct srp_target_port *target = host_to_target(class_to_shost(dev));
3018 return sysfs_emit(buf, "%d\n", target->tl_retry_count);
3026 struct srp_target_port *target = host_to_target(class_to_shost(dev));
3028 return sysfs_emit(buf, "%u\n", target->cmd_sg_cnt);
3036 struct srp_target_port *target = host_to_target(class_to_shost(dev));
3038 return sysfs_emit(buf, "%s\n", target->allow_ext_sg ? "true" : "false");
3103 * < 0 upon failure. Caller is responsible for SRP target port cleanup.
3104 * 0 and target->state == SRP_TARGET_REMOVED if asynchronous target port
3106 * 0 and target->state != SRP_TARGET_REMOVED upon success.
3108 static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
3113 target->state = SRP_TARGET_SCANNING;
3114 sprintf(target->target_name, "SRP.T10:%016llX",
3115 be64_to_cpu(target->id_ext));
3117 if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dev.parent))
3120 memcpy(ids.port_id, &target->id_ext, 8);
3121 memcpy(ids.port_id + 8, &target->ioc_guid, 8);
3123 rport = srp_rport_add(target->scsi_host, &ids);
3125 scsi_remove_host(target->scsi_host);
3129 rport->lld_data = target;
3130 target->rport = rport;
3133 list_add_tail(&target->list, &host->target_list);
3136 scsi_scan_target(&target->scsi_host->shost_gendev,
3137 0, target->scsi_id, SCAN_WILD_CARD, SCSI_SCAN_INITIAL);
3139 if (srp_connected_ch(target) < target->ch_count ||
3140 target->qp_in_error) {
3141 shost_printk(KERN_INFO, target->scsi_host,
3143 srp_queue_remove_work(target);
3148 dev_name(&target->scsi_host->shost_gendev),
3149 srp_sdev_count(target->scsi_host));
3151 spin_lock_irq(&target->lock);
3152 if (target->state == SRP_TARGET_SCANNING)
3153 target->state = SRP_TARGET_LIVE;
3154 spin_unlock_irq(&target->lock);
3179 * srp_conn_unique() - check whether the connection to a target is unique
3181 * @target: SRP target port.
3184 struct srp_target_port *target)
3189 if (target->state == SRP_TARGET_REMOVED)
3196 if (t != target &&
3197 target->id_ext == t->id_ext &&
3198 target->ioc_guid == t->ioc_guid &&
3199 target->initiator_ext == t->initiator_ext) {
3322 struct srp_target_port *target)
3359 target->id_ext = cpu_to_be64(ull);
3375 target->ioc_guid = cpu_to_be64(ull);
3391 ret = hex2bin(target->ib_cm.orig_dgid.raw, p, 16);
3403 target->ib_cm.pkey = cpu_to_be16(token);
3418 target->ib_cm.service_id = cpu_to_be64(ull);
3428 ret = srp_parse_in(net, &target->rdma_cm.src.ss, p,
3435 target->rdma_cm.src_specified = true;
3445 ret = srp_parse_in(net, &target->rdma_cm.dst.ss, p,
3454 target->using_rdma_cm = true;
3464 target->scsi_host->max_sectors = token;
3479 target->scsi_host->can_queue = token;
3480 target->queue_size = token + SRP_RSP_SQ_SIZE +
3483 target->scsi_host->cmd_per_lun = token;
3499 target->scsi_host->cmd_per_lun = token;
3515 target->target_can_queue = token;
3532 target->io_class = token;
3547 target->initiator_ext = cpu_to_be64(ull);
3564 target->cmd_sg_cnt = token;
3573 target->allow_ext_sg = !!token;
3589 target->sg_tablesize = token;
3604 target->comp_vector = token;
3620 target->tl_retry_count = token;
3631 pr_warn("bad maximum initiator to target IU size '%s'\n", p);
3635 target->max_it_iu_size = token;
3650 target->ch_count = token;
3654 pr_warn("unknown parameter or missing value '%s' in target creation request\n",
3668 pr_warn("target creation request is missing one or more parameters\n");
3670 if (target->scsi_host->cmd_per_lun > target->scsi_host->can_queue
3673 target->scsi_host->cmd_per_lun,
3674 target->scsi_host->can_queue);
3688 struct srp_target_port *target;
3712 target = host_to_target(target_host);
3714 target->net = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
3715 target->io_class = SRP_REV16A_IB_IO_CLASS;
3716 target->scsi_host = target_host;
3717 target->srp_host = host;
3718 target->lkey = host->srp_dev->pd->local_dma_lkey;
3719 target->global_rkey = host->srp_dev->global_rkey;
3720 target->cmd_sg_cnt = cmd_sg_entries;
3721 target->sg_tablesize = indirect_sg_entries ? : cmd_sg_entries;
3722 target->allow_ext_sg = allow_ext_sg;
3723 target->tl_retry_count = 7;
3724 target->queue_size = SRP_DEFAULT_QUEUE_SIZE;
3730 scsi_host_get(target->scsi_host);
3736 ret = srp_parse_options(target->net, buf, target);
3740 if (!srp_conn_unique(target->srp_host, target)) {
3741 if (target->using_rdma_cm) {
3742 shost_printk(KERN_INFO, target->scsi_host,
3743 PFX "Already connected to target port with id_ext=%016llx;ioc_guid=%016llx;dest=%pIS\n",
3744 be64_to_cpu(target->id_ext),
3745 be64_to_cpu(target->ioc_guid),
3746 &target->rdma_cm.dst);
3748 shost_printk(KERN_INFO, target->scsi_host,
3749 PFX "Already connected to target port with id_ext=%016llx;ioc_guid=%016llx;initiator_ext=%016llx\n",
3750 be64_to_cpu(target->id_ext),
3751 be64_to_cpu(target->ioc_guid),
3752 be64_to_cpu(target->initiator_ext));
3758 if (!srp_dev->has_fr && !target->allow_ext_sg &&
3759 target->cmd_sg_cnt < target->sg_tablesize) {
3761 target->sg_tablesize = target->cmd_sg_cnt;
3785 (target->scsi_host->max_sectors + 1 +
3789 (target->sg_tablesize +
3794 target->scsi_host->max_sectors, srp_dev->max_pages_per_mr, srp_dev->mr_page_size,
3798 target_host->sg_tablesize = target->sg_tablesize;
3799 target->mr_pool_size = target->scsi_host->can_queue * mr_per_cmd;
3800 target->mr_per_cmd = mr_per_cmd;
3801 target->indirect_size = target->sg_tablesize *
3803 max_iu_len = srp_max_it_iu_len(target->cmd_sg_cnt,
3805 target->max_it_iu_size);
3807 INIT_WORK(&target->tl_err_work, srp_tl_err_work);
3808 INIT_WORK(&target->remove_work, srp_remove_work);
3809 spin_lock_init(&target->lock);
3810 ret = rdma_query_gid(ibdev, host->port, 0, &target->sgid);
3815 if (target->ch_count == 0) {
3816 target->ch_count =
3823 target->ch = kcalloc(target->ch_count, sizeof(*target->ch),
3825 if (!target->ch)
3828 for (ch_idx = 0; ch_idx < target->ch_count; ++ch_idx) {
3829 ch = &target->ch[ch_idx];
3830 ch->target = target;
3846 if (target->using_rdma_cm)
3848 &target->rdma_cm.dst);
3851 target->ib_cm.orig_dgid.raw);
3852 shost_printk(KERN_ERR, target->scsi_host,
3855 target->ch_count, dst);
3859 srp_free_ch_ib(target, ch);
3860 target->ch_count = ch - target->ch;
3868 target->scsi_host->nr_hw_queues = target->ch_count;
3870 ret = srp_add_target(host, target);
3874 if (target->state != SRP_TARGET_REMOVED) {
3875 if (target->using_rdma_cm) {
3876 shost_printk(KERN_DEBUG, target->scsi_host, PFX
3877 "new target: id_ext %016llx ioc_guid %016llx sgid %pI6 dest %pIS\n",
3878 be64_to_cpu(target->id_ext),
3879 be64_to_cpu(target->ioc_guid),
3880 target->sgid.raw, &target->rdma_cm.dst);
3882 shost_printk(KERN_DEBUG, target->scsi_host, PFX
3883 "new target: id_ext %016llx ioc_guid %016llx pkey %04x service_id %016llx sgid %pI6 dgid %pI6\n",
3884 be64_to_cpu(target->id_ext),
3885 be64_to_cpu(target->ioc_guid),
3886 be16_to_cpu(target->ib_cm.pkey),
3887 be64_to_cpu(target->ib_cm.service_id),
3888 target->sgid.raw,
3889 target->ib_cm.orig_dgid.raw);
3899 scsi_host_put(target->scsi_host);
3906 if (target->state != SRP_TARGET_REMOVED)
3907 kobj_ns_drop(KOBJ_NS_TYPE_NET, target->net);
3908 scsi_host_put(target->scsi_host);
3914 srp_disconnect_target(target);
3917 for (i = 0; i < target->ch_count; i++) {
3918 ch = &target->ch[i];
3919 srp_free_ch_ib(target, ch);
3922 kfree(target->ch);
4083 struct srp_target_port *target;
4089 * Remove the add_target sysfs entry so that no new target ports
4095 * Remove all target ports.
4098 list_for_each_entry(target, &host->target_list, list)
4099 srp_queue_remove_work(target);
4105 * target->tl_err_work so waiting for the remove works to