/** * iscsi_iser_session_create() - create an iscsi-iser session * @ep: iscsi end-point handle * @cmds_max: maximum commands in this session * @qdepth: session command queue depth * @initial_cmdsn: initiator command sequnce number * * Allocates and adds a scsi host, expose DIF supprot if * exists, and sets up an iscsi session. */ static struct iscsi_cls_session * iscsi_iser_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, uint16_t qdepth, uint32_t initial_cmdsn) { struct iscsi_cls_session *cls_session; struct iscsi_session *session; struct Scsi_Host *shost; struct iser_conn *iser_conn = NULL; struct ib_conn *ib_conn; u32 max_fr_sectors; u16 max_cmds; shost = iscsi_host_alloc(&iscsi_iser_sht, 0, 0); if (!shost) return NULL; shost->transportt = iscsi_iser_scsi_transport; shost->cmd_per_lun = qdepth; shost->max_lun = iscsi_max_lun; shost->max_id = 0; shost->max_channel = 0; shost->max_cmd_len = 16; /* * older userspace tools (before 2.0-870) did not pass us * the leading conn's ep so this will be NULL; */ if (ep) { iser_conn = ep->dd_data; max_cmds = iser_conn->max_cmds; shost->sg_tablesize = iser_conn->scsi_sg_tablesize; mutex_lock(&iser_conn->state_mutex); if (iser_conn->state != ISER_CONN_UP) { iser_err("iser conn %p already started teardown\n", iser_conn); mutex_unlock(&iser_conn->state_mutex); goto free_host; } ib_conn = &iser_conn->ib_conn; if (ib_conn->pi_support) { u32 sig_caps = ib_conn->device->ib_device->attrs.sig_prot_cap; scsi_host_set_prot(shost, iser_dif_prot_caps(sig_caps)); scsi_host_set_guard(shost, SHOST_DIX_GUARD_IP | SHOST_DIX_GUARD_CRC); } /* * Limit the sg_tablesize and max_sectors based on the device * max fastreg page list length. */ shost->sg_tablesize = min_t(unsigned short, shost->sg_tablesize, ib_conn->device->ib_device->attrs.max_fast_reg_page_list_len); if (iscsi_host_add(shost, ib_conn->device->ib_device->dma_device)) { mutex_unlock(&iser_conn->state_mutex); goto free_host; } mutex_unlock(&iser_conn->state_mutex); } else {
static struct iscsi_cls_session * iscsi_iser_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, uint16_t qdepth, uint32_t initial_cmdsn) { struct iscsi_cls_session *cls_session; struct iscsi_session *session; struct Scsi_Host *shost; struct iser_conn *ib_conn = NULL; shost = iscsi_host_alloc(&iscsi_iser_sht, 0, 0); if (!shost) return NULL; shost->transportt = iscsi_iser_scsi_transport; shost->cmd_per_lun = qdepth; shost->max_lun = iscsi_max_lun; shost->max_id = 0; shost->max_channel = 0; shost->max_cmd_len = 16; /* * older userspace tools (before 2.0-870) did not pass us * the leading conn's ep so this will be NULL; */ if (ep) { ib_conn = ep->dd_data; if (ib_conn->pi_support) { u32 sig_caps = ib_conn->device->dev_attr.sig_prot_cap; scsi_host_set_prot(shost, iser_dif_prot_caps(sig_caps)); if (iser_pi_guard) scsi_host_set_guard(shost, SHOST_DIX_GUARD_IP); else scsi_host_set_guard(shost, SHOST_DIX_GUARD_CRC); } } if (iscsi_host_add(shost, ep ? ib_conn->device->ib_device->dma_device : NULL)) goto free_host; if (cmds_max > ISER_DEF_XMIT_CMDS_MAX) { iser_info("cmds_max changed from %u to %u\n", cmds_max, ISER_DEF_XMIT_CMDS_MAX); cmds_max = ISER_DEF_XMIT_CMDS_MAX; } cls_session = iscsi_session_setup(&iscsi_iser_transport, shost, cmds_max, 0, sizeof(struct iscsi_iser_task), initial_cmdsn, 0); if (!cls_session) goto remove_host; session = cls_session->dd_data; shost->can_queue = session->scsi_cmds_max; return cls_session; remove_host: iscsi_host_remove(shost); free_host: iscsi_host_free(shost); return NULL; }