/** * beiscsi_session_create - creates a new iscsi session * @cmds_max: max commands supported * @qdepth: max queue depth supported * @initial_cmdsn: initial iscsi CMDSN */ struct iscsi_cls_session *beiscsi_session_create(struct iscsi_endpoint *ep, u16 cmds_max, u16 qdepth, u32 initial_cmdsn) { struct Scsi_Host *shost; struct beiscsi_endpoint *beiscsi_ep; struct iscsi_cls_session *cls_session; struct beiscsi_hba *phba; struct iscsi_session *sess; struct beiscsi_session *beiscsi_sess; struct beiscsi_io_task *io_task; SE_DEBUG(DBG_LVL_8, "In beiscsi_session_create\n"); if (!ep) { SE_DEBUG(DBG_LVL_1, "beiscsi_session_create: invalid ep \n"); return NULL; } beiscsi_ep = ep->dd_data; phba = beiscsi_ep->phba; shost = phba->shost; if (cmds_max > beiscsi_ep->phba->params.wrbs_per_cxn) { shost_printk(KERN_ERR, shost, "Cannot handle %d cmds." "Max cmds per session supported is %d. Using %d. " "\n", cmds_max, beiscsi_ep->phba->params.wrbs_per_cxn, beiscsi_ep->phba->params.wrbs_per_cxn); cmds_max = beiscsi_ep->phba->params.wrbs_per_cxn; } cls_session = iscsi2_session_setup(&beiscsi_iscsi_transport, shost, cmds_max, sizeof(*beiscsi_sess), sizeof(*io_task), initial_cmdsn, ISCSI_MAX_TARGET); if (!cls_session) return NULL; sess = cls_session->dd_data; beiscsi_sess = sess->dd_data; beiscsi_sess->bhs_pool = pci_pool_create("beiscsi_bhs_pool", phba->pcidev, sizeof(struct be_cmd_bhs), 64, 0); if (!beiscsi_sess->bhs_pool) goto destroy_sess; return cls_session; destroy_sess: iscsi2_session_teardown(cls_session); return NULL; }
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; shost = iscsi2_host_alloc(&iscsi_iser_sht, 0, 0); if (!shost) return NULL; shost->transportt = iscsi_iser_scsi_transport; 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 (iscsi2_host_add(shost, ep ? ib_conn->device->ib_device->dma_device : NULL)) goto free_host; /* * we do not support setting can_queue cmd_per_lun from userspace yet * because we preallocate so many resources */ cls_session = iscsi2_session_setup(&iscsi_iser_transport, shost, ISCSI_DEF_XMIT_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: iscsi2_host_remove(shost); free_host: iscsi2_host_free(shost); return NULL; }