Lines Matching +full:cmd +full:- +full:cnt +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0
29 efct_lio_parse_wwn(const char *name, u64 *wwp, u8 npiv) in efct_lio_parse_wwn() argument
35 num = sscanf(name, in efct_lio_parse_wwn()
40 num = sscanf(name, in efct_lio_parse_wwn()
47 return -EINVAL; in efct_lio_parse_wwn()
54 efct_lio_parse_npiv_wwn(const char *name, size_t size, u64 *wwpn, u64 *wwnn) in efct_lio_parse_npiv_wwn() argument
56 unsigned int cnt = size; in efct_lio_parse_npiv_wwn() local
60 if (name[cnt - 1] == '\n' || name[cnt - 1] == 0) in efct_lio_parse_npiv_wwn()
61 cnt--; in efct_lio_parse_npiv_wwn()
64 if ((cnt != (16 + 1 + 16)) || (name[16] != ':')) in efct_lio_parse_npiv_wwn()
65 return -EINVAL; in efct_lio_parse_npiv_wwn()
67 rc = efct_lio_parse_wwn(&name[0], wwpn, 1); in efct_lio_parse_npiv_wwn()
71 rc = efct_lio_parse_wwn(&name[17], wwnn, 1); in efct_lio_parse_npiv_wwn()
85 return snprintf(page, PAGE_SIZE, "%d\n", tpg->enabled); in efct_lio_tpg_enable_show()
99 if (!tpg->nport || !tpg->nport->efct) { in efct_lio_tpg_enable_store()
101 return -EINVAL; in efct_lio_tpg_enable_store()
104 efct = tpg->nport->efct; in efct_lio_tpg_enable_store()
105 efc = efct->efcport; in efct_lio_tpg_enable_store()
108 return -EINVAL; in efct_lio_tpg_enable_store()
113 tpg->enabled = true; in efct_lio_tpg_enable_store()
114 efc_log_debug(efct, "enable portal group %d\n", tpg->tpgt); in efct_lio_tpg_enable_store()
116 ret = efct_xport_control(efct->xport, EFCT_XPORT_PORT_ONLINE); in efct_lio_tpg_enable_store()
118 efct->tgt_efct.lio_nport = NULL; in efct_lio_tpg_enable_store()
123 efc_log_debug(efct, "disable portal group %d\n", tpg->tpgt); in efct_lio_tpg_enable_store()
125 if (efc->domain && efc->domain->nport) in efct_lio_tpg_enable_store()
126 efct_scsi_tgt_del_nport(efc, efc->domain->nport); in efct_lio_tpg_enable_store()
128 tpg->enabled = false; in efct_lio_tpg_enable_store()
130 return -EINVAL; in efct_lio_tpg_enable_store()
143 return snprintf(page, PAGE_SIZE, "%d\n", tpg->enabled); in efct_lio_npiv_tpg_enable_show()
153 struct efct_lio_vport *lio_vport = tpg->vport; in efct_lio_npiv_tpg_enable_store()
159 return -EINVAL; in efct_lio_npiv_tpg_enable_store()
163 return -EINVAL; in efct_lio_npiv_tpg_enable_store()
166 efct = lio_vport->efct; in efct_lio_npiv_tpg_enable_store()
167 efc = efct->efcport; in efct_lio_npiv_tpg_enable_store()
170 tpg->enabled = true; in efct_lio_npiv_tpg_enable_store()
171 efc_log_debug(efct, "enable portal group %d\n", tpg->tpgt); in efct_lio_npiv_tpg_enable_store()
173 if (efc->domain) { in efct_lio_npiv_tpg_enable_store()
176 ret = efc_nport_vport_new(efc->domain, in efct_lio_npiv_tpg_enable_store()
177 lio_vport->npiv_wwpn, in efct_lio_npiv_tpg_enable_store()
178 lio_vport->npiv_wwnn, in efct_lio_npiv_tpg_enable_store()
188 if (!(efc_vport_create_spec(efc, lio_vport->npiv_wwnn, in efct_lio_npiv_tpg_enable_store()
189 lio_vport->npiv_wwpn, U32_MAX, in efct_lio_npiv_tpg_enable_store()
191 return -ENOMEM; in efct_lio_npiv_tpg_enable_store()
194 efc_log_debug(efct, "disable portal group %d\n", tpg->tpgt); in efct_lio_npiv_tpg_enable_store()
196 tpg->enabled = false; in efct_lio_npiv_tpg_enable_store()
200 if (efc->domain) { in efct_lio_npiv_tpg_enable_store()
201 efc_nport_vport_del(efct->efcport, efc->domain, in efct_lio_npiv_tpg_enable_store()
202 lio_vport->npiv_wwpn, in efct_lio_npiv_tpg_enable_store()
203 lio_vport->npiv_wwnn); in efct_lio_npiv_tpg_enable_store()
207 return -EINVAL; in efct_lio_npiv_tpg_enable_store()
217 return tpg->nport->wwpn_str; in efct_lio_get_fabric_wwn()
225 return tpg->vport->wwpn_str; in efct_lio_get_npiv_fabric_wwn()
233 return tpg->tpgt; in efct_lio_get_tag()
241 return tpg->tpgt; in efct_lio_get_npiv_tag()
259 return tpg->tpg_attrib.demo_mode_write_protect; in efct_lio_check_demo_write_protect()
268 return tpg->tpg_attrib.demo_mode_write_protect; in efct_lio_npiv_check_demo_write_protect()
276 return tpg->tpg_attrib.prod_mode_write_protect; in efct_lio_check_prod_write_protect()
285 return tpg->tpg_attrib.prod_mode_write_protect; in efct_lio_npiv_check_prod_write_protect()
291 container_of(se_cmd, struct efct_scsi_tgt_io, cmd); in efct_lio_check_stop_free()
311 container_of(se_cmd, struct efct_scsi_tgt_io, cmd); in efct_lio_aborted_task()
316 if (ocp->rsp_sent) in efct_lio_aborted_task()
320 ocp->aborting = true; in efct_lio_aborted_task()
321 ocp->err = EFCT_SCSI_STATUS_ABORTED; in efct_lio_aborted_task()
329 container_of(se_cmd, struct efct_scsi_tgt_io, cmd); in efct_lio_release_cmd()
331 struct efct *efct = io->efct; in efct_lio_release_cmd()
336 atomic_sub_return(1, &efct->tgt_efct.ios_in_use); in efct_lio_release_cmd()
341 struct efc_node *node = se_sess->fabric_sess_ptr; in efct_lio_close_session()
353 static int efct_lio_get_cmd_state(struct se_cmd *cmd) in efct_lio_get_cmd_state() argument
356 container_of(cmd, struct efct_scsi_tgt_io, cmd); in efct_lio_get_cmd_state()
359 return io->tgt_io.state; in efct_lio_get_cmd_state()
365 struct efct_scsi_tgt_io *ocp = &io->tgt_io; in efct_lio_sg_map()
366 struct se_cmd *cmd = &ocp->cmd; in efct_lio_sg_map() local
368 ocp->seg_map_cnt = dma_map_sg(&io->efct->pci->dev, cmd->t_data_sg, in efct_lio_sg_map()
369 cmd->t_data_nents, cmd->data_direction); in efct_lio_sg_map()
370 if (ocp->seg_map_cnt == 0) in efct_lio_sg_map()
371 return -EFAULT; in efct_lio_sg_map()
378 struct efct_scsi_tgt_io *ocp = &io->tgt_io; in efct_lio_sg_unmap()
379 struct se_cmd *cmd = &ocp->cmd; in efct_lio_sg_unmap() local
381 if (WARN_ON(!ocp->seg_map_cnt || !cmd->t_data_sg)) in efct_lio_sg_unmap()
384 dma_unmap_sg(&io->efct->pci->dev, cmd->t_data_sg, in efct_lio_sg_unmap()
385 ocp->seg_map_cnt, cmd->data_direction); in efct_lio_sg_unmap()
386 ocp->seg_map_cnt = 0; in efct_lio_sg_unmap()
394 struct efct_scsi_tgt_io *ocp = &io->tgt_io; in efct_lio_status_done()
400 ocp->err = scsi_status; in efct_lio_status_done()
402 if (ocp->seg_map_cnt) in efct_lio_status_done()
406 scsi_status, ocp->err, flags, ocp->ddir); in efct_lio_status_done()
409 transport_generic_free_cmd(&io->tgt_io.cmd, 0); in efct_lio_status_done()
418 efct_lio_write_pending(struct se_cmd *cmd) in efct_lio_write_pending() argument
421 container_of(cmd, struct efct_scsi_tgt_io, cmd); in efct_lio_write_pending()
423 struct efct_scsi_sgl *sgl = io->sgl; in efct_lio_write_pending()
425 u32 flags = 0, cnt, curcnt; in efct_lio_write_pending() local
430 cmd->transport_state, cmd->se_cmd_flags); in efct_lio_write_pending()
432 if (ocp->seg_cnt == 0) { in efct_lio_write_pending()
433 ocp->seg_cnt = cmd->t_data_nents; in efct_lio_write_pending()
434 ocp->cur_seg = 0; in efct_lio_write_pending()
437 return -EFAULT; in efct_lio_write_pending()
440 curcnt = (ocp->seg_map_cnt - ocp->cur_seg); in efct_lio_write_pending()
441 curcnt = (curcnt < io->sgl_allocated) ? curcnt : io->sgl_allocated; in efct_lio_write_pending()
443 for (cnt = 0, sg = cmd->t_data_sg; cnt < ocp->cur_seg; cnt++, in efct_lio_write_pending()
447 for (cnt = 0; cnt < curcnt; cnt++, sg = sg_next(sg)) { in efct_lio_write_pending()
448 sgl[cnt].addr = sg_dma_address(sg); in efct_lio_write_pending()
449 sgl[cnt].dif_addr = 0; in efct_lio_write_pending()
450 sgl[cnt].len = sg_dma_len(sg); in efct_lio_write_pending()
451 length += sgl[cnt].len; in efct_lio_write_pending()
452 ocp->cur_seg++; in efct_lio_write_pending()
455 if (ocp->cur_seg == ocp->seg_cnt) in efct_lio_write_pending()
463 efct_lio_queue_data_in(struct se_cmd *cmd) in efct_lio_queue_data_in() argument
466 container_of(cmd, struct efct_scsi_tgt_io, cmd); in efct_lio_queue_data_in()
468 struct efct_scsi_sgl *sgl = io->sgl; in efct_lio_queue_data_in()
470 uint flags = 0, cnt = 0, curcnt = 0; in efct_lio_queue_data_in() local
475 if (ocp->seg_cnt == 0) { in efct_lio_queue_data_in()
476 if (cmd->data_length) { in efct_lio_queue_data_in()
477 ocp->seg_cnt = cmd->t_data_nents; in efct_lio_queue_data_in()
478 ocp->cur_seg = 0; in efct_lio_queue_data_in()
482 return -EAGAIN; in efct_lio_queue_data_in()
490 "cmd : %p length 0, send status\n", in efct_lio_queue_data_in()
491 cmd); in efct_lio_queue_data_in()
496 curcnt = min(ocp->seg_map_cnt - ocp->cur_seg, io->sgl_allocated); in efct_lio_queue_data_in()
498 while (cnt < curcnt) { in efct_lio_queue_data_in()
499 sg = &cmd->t_data_sg[ocp->cur_seg]; in efct_lio_queue_data_in()
500 sgl[cnt].addr = sg_dma_address(sg); in efct_lio_queue_data_in()
501 sgl[cnt].dif_addr = 0; in efct_lio_queue_data_in()
502 if (ocp->transferred_len + sg_dma_len(sg) >= cmd->data_length) in efct_lio_queue_data_in()
503 sgl[cnt].len = cmd->data_length - ocp->transferred_len; in efct_lio_queue_data_in()
505 sgl[cnt].len = sg_dma_len(sg); in efct_lio_queue_data_in()
507 ocp->transferred_len += sgl[cnt].len; in efct_lio_queue_data_in()
508 length += sgl[cnt].len; in efct_lio_queue_data_in()
509 ocp->cur_seg++; in efct_lio_queue_data_in()
510 cnt++; in efct_lio_queue_data_in()
511 if (ocp->transferred_len == cmd->data_length) in efct_lio_queue_data_in()
515 if (ocp->transferred_len == cmd->data_length) { in efct_lio_queue_data_in()
517 ocp->seg_cnt = ocp->cur_seg; in efct_lio_queue_data_in()
521 if (cmd->residual_count) in efct_lio_queue_data_in()
535 struct efct_scsi_tgt_io *ocp = &io->tgt_io; in efct_lio_send_resp()
536 struct se_cmd *cmd = &io->tgt_io.cmd; in efct_lio_send_resp() local
540 ocp->rsp_sent = true; in efct_lio_send_resp()
542 transport_generic_free_cmd(&io->tgt_io.cmd, 0); in efct_lio_send_resp()
548 rsp.scsi_status = cmd->scsi_status; in efct_lio_send_resp()
549 rsp.sense_data = (uint8_t *)io->tgt_io.sense_buffer; in efct_lio_send_resp()
550 rsp.sense_data_length = cmd->scsi_sense_length; in efct_lio_send_resp()
553 if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT) in efct_lio_send_resp()
554 rsp.residual = -cmd->residual_count; in efct_lio_send_resp()
555 else if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) in efct_lio_send_resp()
556 rsp.residual = cmd->residual_count; in efct_lio_send_resp()
563 transport_generic_free_cmd(&io->tgt_io.cmd, 0); in efct_lio_send_resp()
565 ocp->rsp_sent = true; in efct_lio_send_resp()
573 struct efct_scsi_tgt_io *ocp = &io->tgt_io; in efct_lio_datamove_done()
579 ocp->err = scsi_status; in efct_lio_datamove_done()
581 efct_lio_io_printf(io, "seg_map_cnt=%d\n", ocp->seg_map_cnt); in efct_lio_datamove_done()
582 if (ocp->seg_map_cnt) { in efct_lio_datamove_done()
583 if (ocp->err == EFCT_SCSI_STATUS_GOOD && in efct_lio_datamove_done()
584 ocp->cur_seg < ocp->seg_cnt) { in efct_lio_datamove_done()
587 efct_lio_io_printf(io, "continuing cmd at segm=%d\n", in efct_lio_datamove_done()
588 ocp->cur_seg); in efct_lio_datamove_done()
589 if (ocp->ddir == DMA_TO_DEVICE) in efct_lio_datamove_done()
590 rc = efct_lio_write_pending(&ocp->cmd); in efct_lio_datamove_done()
592 rc = efct_lio_queue_data_in(&ocp->cmd); in efct_lio_datamove_done()
596 ocp->err = EFCT_SCSI_STATUS_ERROR; in efct_lio_datamove_done()
602 if (io->tgt_io.aborting) { in efct_lio_datamove_done()
607 if (ocp->ddir == DMA_TO_DEVICE) { in efct_lio_datamove_done()
609 io->tgt_io.cmd.transport_state); in efct_lio_datamove_done()
611 transport_generic_request_failure(&io->tgt_io.cmd, in efct_lio_datamove_done()
618 target_execute_cmd(&io->tgt_io.cmd); in efct_lio_datamove_done()
630 efct_lio_tmfio_printf(io, "cmd=%p status=%d, flags=0x%x\n", in efct_lio_tmf_done()
631 &io->tgt_io.cmd, scsi_status, flags); in efct_lio_tmf_done()
634 transport_generic_free_cmd(&io->tgt_io.cmd, 0); in efct_lio_tmf_done()
643 efct_lio_tmfio_printf(tmfio, "cmd=%p status=%d, flags=0x%x\n", in efct_lio_null_tmf_done()
644 &tmfio->tgt_io.cmd, scsi_status, flags); in efct_lio_null_tmf_done()
652 efct_lio_queue_status(struct se_cmd *cmd) in efct_lio_queue_status() argument
656 container_of(cmd, struct efct_scsi_tgt_io, cmd); in efct_lio_queue_status()
663 cmd->scsi_status, cmd->transport_state, cmd->se_cmd_flags, in efct_lio_queue_status()
664 cmd->scsi_sense_length); in efct_lio_queue_status()
667 rsp.scsi_status = cmd->scsi_status; in efct_lio_queue_status()
668 rsp.sense_data = (u8 *)io->tgt_io.sense_buffer; in efct_lio_queue_status()
669 rsp.sense_data_length = cmd->scsi_sense_length; in efct_lio_queue_status()
674 if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT) in efct_lio_queue_status()
675 rsp.residual = -cmd->residual_count; in efct_lio_queue_status()
676 else if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) in efct_lio_queue_status()
677 rsp.residual = cmd->residual_count; in efct_lio_queue_status()
682 ocp->rsp_sent = true; in efct_lio_queue_status()
686 static void efct_lio_queue_tm_rsp(struct se_cmd *cmd) in efct_lio_queue_tm_rsp() argument
689 container_of(cmd, struct efct_scsi_tgt_io, cmd); in efct_lio_queue_tm_rsp()
691 struct se_tmr_req *se_tmr = cmd->se_tmr_req; in efct_lio_queue_tm_rsp()
694 efct_lio_tmfio_printf(tmfio, "cmd=%p function=0x%x tmr->response=%d\n", in efct_lio_queue_tm_rsp()
695 cmd, se_tmr->function, se_tmr->response); in efct_lio_queue_tm_rsp()
696 switch (se_tmr->response) { in efct_lio_queue_tm_rsp()
721 if (wwpn == efct_get_wwpn(&efct->hw)) in efct_find_wwpn()
730 struct config_group *group, const char *name) in efct_lio_make_nport() argument
737 ret = efct_lio_parse_wwn(name, &wwpn, 0); in efct_lio_make_nport()
743 pr_err("cannot find EFCT for base wwpn %s\n", name); in efct_lio_make_nport()
744 return ERR_PTR(-ENXIO); in efct_lio_make_nport()
749 return ERR_PTR(-ENOMEM); in efct_lio_make_nport()
751 lio_nport->efct = efct; in efct_lio_make_nport()
752 lio_nport->wwpn = wwpn; in efct_lio_make_nport()
753 efct_format_wwn(lio_nport->wwpn_str, sizeof(lio_nport->wwpn_str), in efct_lio_make_nport()
755 efct->tgt_efct.lio_nport = lio_nport; in efct_lio_make_nport()
757 return &lio_nport->nport_wwn; in efct_lio_make_nport()
762 struct config_group *group, const char *name) in efct_lio_npiv_make_nport() argument
774 snprintf(tmp, sizeof(tmp), "%s", name); in efct_lio_npiv_make_nport()
781 return ERR_PTR(-EINVAL); in efct_lio_npiv_make_nport()
795 pr_err("cannot find EFCT for base wwpn %s\n", name); in efct_lio_npiv_make_nport()
796 return ERR_PTR(-ENXIO); in efct_lio_npiv_make_nport()
801 return ERR_PTR(-ENOMEM); in efct_lio_npiv_make_nport()
803 lio_vport->efct = efct; in efct_lio_npiv_make_nport()
804 lio_vport->wwpn = p_wwpn; in efct_lio_npiv_make_nport()
805 lio_vport->npiv_wwpn = npiv_wwpn; in efct_lio_npiv_make_nport()
806 lio_vport->npiv_wwnn = npiv_wwnn; in efct_lio_npiv_make_nport()
808 efct_format_wwn(lio_vport->wwpn_str, sizeof(lio_vport->wwpn_str), in efct_lio_npiv_make_nport()
814 return ERR_PTR(-ENOMEM); in efct_lio_npiv_make_nport()
817 vport_list->lio_vport = lio_vport; in efct_lio_npiv_make_nport()
826 new_fc_vport = fc_vport_create(efct->shost, 0, &vport_id); in efct_lio_npiv_make_nport()
831 return ERR_PTR(-ENOMEM); in efct_lio_npiv_make_nport()
834 lio_vport->fc_vport = new_fc_vport; in efct_lio_npiv_make_nport()
835 spin_lock_irqsave(&efct->tgt_efct.efct_lio_lock, flags); in efct_lio_npiv_make_nport()
836 INIT_LIST_HEAD(&vport_list->list_entry); in efct_lio_npiv_make_nport()
837 list_add_tail(&vport_list->list_entry, &efct->tgt_efct.vport_list); in efct_lio_npiv_make_nport()
838 spin_unlock_irqrestore(&efct->tgt_efct.efct_lio_lock, flags); in efct_lio_npiv_make_nport()
840 return &lio_vport->vport_wwn; in efct_lio_npiv_make_nport()
848 struct efct *efct = lio_nport->efct; in efct_lio_drop_nport()
853 kfree(efct->tgt_efct.lio_nport); in efct_lio_drop_nport()
854 efct->tgt_efct.lio_nport = NULL; in efct_lio_drop_nport()
863 struct efct *efct = lio_vport->efct; in efct_lio_npiv_drop_nport()
866 if (lio_vport->fc_vport) in efct_lio_npiv_drop_nport()
867 fc_vport_terminate(lio_vport->fc_vport); in efct_lio_npiv_drop_nport()
869 spin_lock_irqsave(&efct->tgt_efct.efct_lio_lock, flags); in efct_lio_npiv_drop_nport()
871 list_for_each_entry_safe(vport, next_vport, &efct->tgt_efct.vport_list, in efct_lio_npiv_drop_nport()
873 if (vport->lio_vport == lio_vport) { in efct_lio_npiv_drop_nport()
874 list_del(&vport->list_entry); in efct_lio_npiv_drop_nport()
875 kfree(vport->lio_vport); in efct_lio_npiv_drop_nport()
880 spin_unlock_irqrestore(&efct->tgt_efct.efct_lio_lock, flags); in efct_lio_npiv_drop_nport()
884 efct_lio_make_tpg(struct se_wwn *wwn, const char *name) in efct_lio_make_tpg() argument
893 if (strstr(name, "tpgt_") != name) in efct_lio_make_tpg()
894 return ERR_PTR(-EINVAL); in efct_lio_make_tpg()
895 if (kstrtoul(name + 5, 10, &n) || n > USHRT_MAX) in efct_lio_make_tpg()
896 return ERR_PTR(-EINVAL); in efct_lio_make_tpg()
900 return ERR_PTR(-ENOMEM); in efct_lio_make_tpg()
902 tpg->nport = lio_nport; in efct_lio_make_tpg()
903 tpg->tpgt = n; in efct_lio_make_tpg()
904 tpg->enabled = false; in efct_lio_make_tpg()
906 tpg->tpg_attrib.generate_node_acls = 1; in efct_lio_make_tpg()
907 tpg->tpg_attrib.demo_mode_write_protect = 1; in efct_lio_make_tpg()
908 tpg->tpg_attrib.cache_dynamic_acls = 1; in efct_lio_make_tpg()
909 tpg->tpg_attrib.demo_mode_login_only = 1; in efct_lio_make_tpg()
910 tpg->tpg_attrib.session_deletion_wait = 1; in efct_lio_make_tpg()
912 ret = core_tpg_register(wwn, &tpg->tpg, SCSI_PROTOCOL_FCP); in efct_lio_make_tpg()
917 efct = lio_nport->efct; in efct_lio_make_tpg()
918 efct->tgt_efct.tpg = tpg; in efct_lio_make_tpg()
919 efc_log_debug(efct, "create portal group %d\n", tpg->tpgt); in efct_lio_make_tpg()
921 xa_init(&efct->lookup); in efct_lio_make_tpg()
922 return &tpg->tpg; in efct_lio_make_tpg()
931 struct efct *efct = tpg->nport->efct; in efct_lio_drop_tpg()
933 efc_log_debug(efct, "drop portal group %d\n", tpg->tpgt); in efct_lio_drop_tpg()
934 tpg->nport->efct->tgt_efct.tpg = NULL; in efct_lio_drop_tpg()
936 xa_destroy(&efct->lookup); in efct_lio_drop_tpg()
941 efct_lio_npiv_make_tpg(struct se_wwn *wwn, const char *name) in efct_lio_npiv_make_tpg() argument
950 efct = lio_vport->efct; in efct_lio_npiv_make_tpg()
951 if (strstr(name, "tpgt_") != name) in efct_lio_npiv_make_tpg()
952 return ERR_PTR(-EINVAL); in efct_lio_npiv_make_tpg()
953 if (kstrtoul(name + 5, 10, &n) || n > USHRT_MAX) in efct_lio_npiv_make_tpg()
954 return ERR_PTR(-EINVAL); in efct_lio_npiv_make_tpg()
958 return ERR_PTR(-EINVAL); in efct_lio_npiv_make_tpg()
963 return ERR_PTR(-ENOMEM); in efct_lio_npiv_make_tpg()
965 tpg->vport = lio_vport; in efct_lio_npiv_make_tpg()
966 tpg->tpgt = n; in efct_lio_npiv_make_tpg()
967 tpg->enabled = false; in efct_lio_npiv_make_tpg()
969 tpg->tpg_attrib.generate_node_acls = 1; in efct_lio_npiv_make_tpg()
970 tpg->tpg_attrib.demo_mode_write_protect = 1; in efct_lio_npiv_make_tpg()
971 tpg->tpg_attrib.cache_dynamic_acls = 1; in efct_lio_npiv_make_tpg()
972 tpg->tpg_attrib.demo_mode_login_only = 1; in efct_lio_npiv_make_tpg()
973 tpg->tpg_attrib.session_deletion_wait = 1; in efct_lio_npiv_make_tpg()
975 ret = core_tpg_register(wwn, &tpg->tpg, SCSI_PROTOCOL_FCP); in efct_lio_npiv_make_tpg()
981 lio_vport->tpg = tpg; in efct_lio_npiv_make_tpg()
982 efc_log_debug(efct, "create vport portal group %d\n", tpg->tpgt); in efct_lio_npiv_make_tpg()
984 return &tpg->tpg; in efct_lio_npiv_make_tpg()
993 efc_log_debug(tpg->vport->efct, "drop npiv portal group %d\n", in efct_lio_npiv_drop_tpg()
994 tpg->tpgt); in efct_lio_npiv_drop_tpg()
1000 efct_lio_init_nodeacl(struct se_node_acl *se_nacl, const char *name) in efct_lio_init_nodeacl() argument
1005 if (efct_lio_parse_wwn(name, &wwnn, 0) < 0) in efct_lio_init_nodeacl()
1006 return -EINVAL; in efct_lio_init_nodeacl()
1009 nacl->nport_wwnn = wwnn; in efct_lio_init_nodeacl()
1011 efct_format_wwn(nacl->nport_name, sizeof(nacl->nport_name), "", wwnn); in efct_lio_init_nodeacl()
1019 return tpg->tpg_attrib.demo_mode_login_only; in efct_lio_check_demo_mode_login_only()
1027 return tpg->tpg_attrib.demo_mode_login_only; in efct_lio_npiv_check_demo_mode_login_only()
1034 u64 wwpn = node->nport->wwpn; in efct_get_vport_tpg()
1040 efct = node->efc->base; in efct_get_vport_tpg()
1041 spin_lock_irqsave(&efct->tgt_efct.efct_lio_lock, flags); in efct_get_vport_tpg()
1042 list_for_each_entry_safe(vport, next, &efct->tgt_efct.vport_list, in efct_get_vport_tpg()
1044 lio_vport = vport->lio_vport; in efct_get_vport_tpg()
1045 if (wwpn && lio_vport && lio_vport->npiv_wwpn == wwpn) { in efct_get_vport_tpg()
1047 tpg = lio_vport->tpg; in efct_get_vport_tpg()
1051 spin_unlock_irqrestore(&efct->tgt_efct.efct_lio_lock, flags); in efct_get_vport_tpg()
1059 struct efc_node *node = tgt_node->node; in _efct_tgt_node_free()
1061 efc_scsi_del_initiator_complete(node->efc, node); in _efct_tgt_node_free()
1070 struct efct *efct = node->efc->base; in efct_session_cb()
1074 return -ENOMEM; in efct_session_cb()
1076 kref_init(&tgt_node->ref); in efct_session_cb()
1077 tgt_node->release = _efct_tgt_node_free; in efct_session_cb()
1079 tgt_node->session = se_sess; in efct_session_cb()
1080 node->tgt_node = tgt_node; in efct_session_cb()
1081 tgt_node->efct = efct; in efct_session_cb()
1083 tgt_node->node = node; in efct_session_cb()
1085 tgt_node->node_fc_id = node->rnode.fc_id; in efct_session_cb()
1086 tgt_node->port_fc_id = node->nport->fc_id; in efct_session_cb()
1087 tgt_node->vpi = node->nport->indicator; in efct_session_cb()
1088 tgt_node->rpi = node->rnode.indicator; in efct_session_cb()
1090 spin_lock_init(&tgt_node->active_ios_lock); in efct_session_cb()
1091 INIT_LIST_HEAD(&tgt_node->active_ios); in efct_session_cb()
1101 efct->tgt_efct.max_sge = sli_get_max_sge(&efct->hw.sli); in efct_scsi_tgt_new_device()
1102 efct->tgt_efct.max_sgl = sli_get_max_sgl(&efct->hw.sli); in efct_scsi_tgt_new_device()
1105 atomic_set(&efct->tgt_efct.ios_in_use, 0); in efct_scsi_tgt_new_device()
1106 total_ios = efct->hw.config.n_io; in efct_scsi_tgt_new_device()
1108 efct->tgt_efct.watermark_min = in efct_scsi_tgt_new_device()
1110 efct->tgt_efct.watermark_max = in efct_scsi_tgt_new_device()
1112 atomic_set(&efct->tgt_efct.io_high_watermark, in efct_scsi_tgt_new_device()
1113 efct->tgt_efct.watermark_max); in efct_scsi_tgt_new_device()
1114 atomic_set(&efct->tgt_efct.watermark_hit, 0); in efct_scsi_tgt_new_device()
1115 atomic_set(&efct->tgt_efct.initiator_count, 0); in efct_scsi_tgt_new_device()
1121 return -EIO; in efct_scsi_tgt_new_device()
1124 spin_lock_init(&efct->tgt_efct.efct_lio_lock); in efct_scsi_tgt_new_device()
1125 INIT_LIST_HEAD(&efct->tgt_efct.vport_list); in efct_scsi_tgt_new_device()
1140 struct efct *efct = nport->efc->base; in efct_scsi_tgt_new_nport()
1142 efc_log_debug(efct, "New SPORT: %s bound to %s\n", nport->display_name, in efct_scsi_tgt_new_nport()
1143 efct->tgt_efct.lio_nport->wwpn_str); in efct_scsi_tgt_new_nport()
1151 efc_log_debug(efc, "Del SPORT: %s\n", nport->display_name); in efct_scsi_tgt_del_nport()
1158 struct efct *efct = wq_data->efct; in efct_lio_setup_session()
1159 struct efc_node *node = wq_data->ptr; in efct_lio_setup_session()
1174 se_tpg = &tpg->tpg; in efct_lio_setup_session()
1175 } else if (efct->tgt_efct.tpg) { in efct_lio_setup_session()
1176 tpg = efct->tgt_efct.tpg; in efct_lio_setup_session()
1177 se_tpg = &tpg->tpg; in efct_lio_setup_session()
1195 efc_scsi_sess_reg_complete(node, -EIO); in efct_lio_setup_session()
1199 tgt_node = node->tgt_node; in efct_lio_setup_session()
1200 id = (u64) tgt_node->port_fc_id << 32 | tgt_node->node_fc_id; in efct_lio_setup_session()
1205 if (xa_err(xa_store(&efct->lookup, id, tgt_node, GFP_KERNEL))) in efct_lio_setup_session()
1211 ini_count = atomic_add_return(1, &efct->tgt_efct.initiator_count); in efct_lio_setup_session()
1212 watermark = efct->tgt_efct.watermark_max - in efct_lio_setup_session()
1214 watermark = (efct->tgt_efct.watermark_min > watermark) ? in efct_lio_setup_session()
1215 efct->tgt_efct.watermark_min : watermark; in efct_lio_setup_session()
1216 atomic_set(&efct->tgt_efct.io_high_watermark, watermark); in efct_lio_setup_session()
1223 struct efct *efct = node->efc->base; in efct_scsi_new_initiator()
1232 return -ENOMEM; in efct_scsi_new_initiator()
1234 wq_data->ptr = node; in efct_scsi_new_initiator()
1235 wq_data->efct = efct; in efct_scsi_new_initiator()
1236 INIT_WORK(&wq_data->work, efct_lio_setup_session); in efct_scsi_new_initiator()
1237 queue_work(lio_wq, &wq_data->work); in efct_scsi_new_initiator()
1245 struct efct *efct = wq_data->efct; in efct_lio_remove_session()
1246 struct efc_node *node = wq_data->ptr; in efct_lio_remove_session()
1250 tgt_node = node->tgt_node; in efct_lio_remove_session()
1252 /* base driver has sent back-to-back requests in efct_lio_remove_session()
1257 efc_scsi_del_initiator_complete(node->efc, node); in efct_lio_remove_session()
1261 se_sess = tgt_node->session; in efct_lio_remove_session()
1271 tgt_node->session = NULL; in efct_lio_remove_session()
1272 node->tgt_node = NULL; in efct_lio_remove_session()
1273 kref_put(&tgt_node->ref, tgt_node->release); in efct_lio_remove_session()
1280 struct efct *efct = node->efc->base; in efct_scsi_del_initiator()
1281 struct efct_node *tgt_node = node->tgt_node; in efct_scsi_del_initiator()
1292 return -EIO; in efct_scsi_del_initiator()
1297 return -ENOMEM; in efct_scsi_del_initiator()
1299 id = (u64) tgt_node->port_fc_id << 32 | tgt_node->node_fc_id; in efct_scsi_del_initiator()
1300 xa_erase(&efct->lookup, id); in efct_scsi_del_initiator()
1302 wq_data->ptr = node; in efct_scsi_del_initiator()
1303 wq_data->efct = efct; in efct_scsi_del_initiator()
1304 INIT_WORK(&wq_data->work, efct_lio_remove_session); in efct_scsi_del_initiator()
1305 queue_work(lio_wq, &wq_data->work); in efct_scsi_del_initiator()
1310 ini_count = atomic_sub_return(1, &efct->tgt_efct.initiator_count); in efct_scsi_del_initiator()
1312 watermark = efct->tgt_efct.watermark_max - in efct_scsi_del_initiator()
1314 watermark = (efct->tgt_efct.watermark_min > watermark) ? in efct_scsi_del_initiator()
1315 efct->tgt_efct.watermark_min : watermark; in efct_scsi_del_initiator()
1316 atomic_set(&efct->tgt_efct.io_high_watermark, watermark); in efct_scsi_del_initiator()
1324 struct efct_scsi_tgt_io *ocp = &io->tgt_io; in efct_scsi_recv_cmd()
1325 struct se_cmd *se_cmd = &io->tgt_io.cmd; in efct_scsi_recv_cmd()
1326 struct efct *efct = io->efct; in efct_scsi_recv_cmd()
1334 atomic_add_return(1, &efct->tgt_efct.ios_in_use); in efct_scsi_recv_cmd()
1337 io->timeout = efct->target_io_timer_sec; in efct_scsi_recv_cmd()
1340 ocp->task_attr = TCM_SIMPLE_TAG; in efct_scsi_recv_cmd()
1342 ocp->task_attr = TCM_HEAD_TAG; in efct_scsi_recv_cmd()
1344 ocp->task_attr = TCM_ORDERED_TAG; in efct_scsi_recv_cmd()
1346 ocp->task_attr = TCM_ACA_TAG; in efct_scsi_recv_cmd()
1351 ocp->ddir = DMA_TO_DEVICE; in efct_scsi_recv_cmd()
1355 ocp->ddir = DMA_FROM_DEVICE; in efct_scsi_recv_cmd()
1359 ocp->ddir = DMA_BIDIRECTIONAL; in efct_scsi_recv_cmd()
1363 ocp->ddir = DMA_NONE; in efct_scsi_recv_cmd()
1367 ocp->lun = lun; in efct_scsi_recv_cmd()
1368 efct_lio_io_printf(io, "new cmd=0x%x ddir=%s dl=%u\n", in efct_scsi_recv_cmd()
1369 cdb[0], ddir, io->exp_xfer_len); in efct_scsi_recv_cmd()
1371 tgt_node = io->node; in efct_scsi_recv_cmd()
1372 se_sess = tgt_node->session; in efct_scsi_recv_cmd()
1375 &ocp->cmd); in efct_scsi_recv_cmd()
1381 rc = target_init_cmd(se_cmd, se_sess, &io->tgt_io.sense_buffer[0], in efct_scsi_recv_cmd()
1382 ocp->lun, io->exp_xfer_len, ocp->task_attr, in efct_scsi_recv_cmd()
1383 ocp->ddir, TARGET_SCF_ACK_KREF); in efct_scsi_recv_cmd()
1385 efc_log_err(efct, "failed to init cmd se_cmd: %p\n", se_cmd); in efct_scsi_recv_cmd()
1398 efct_scsi_recv_tmf(struct efct_io *tmfio, u32 lun, enum efct_scsi_tmf_cmd cmd, in efct_scsi_recv_tmf() argument
1402 struct efct *efct = tmfio->efct; in efct_scsi_recv_tmf()
1403 struct efct_scsi_tgt_io *ocp = &tmfio->tgt_io; in efct_scsi_recv_tmf()
1410 atomic_add_return(1, &efct->tgt_efct.ios_in_use); in efct_scsi_recv_tmf()
1412 tmfio->display_name, cmd, lun); in efct_scsi_recv_tmf()
1414 switch (cmd) { in efct_scsi_recv_tmf()
1439 tmfio->tgt_io.tmf = tmr_func; in efct_scsi_recv_tmf()
1440 tmfio->tgt_io.lun = lun; in efct_scsi_recv_tmf()
1441 tmfio->tgt_io.io_to_abort = io_to_abort; in efct_scsi_recv_tmf()
1443 tgt_node = tmfio->node; in efct_scsi_recv_tmf()
1445 se_sess = tgt_node->session; in efct_scsi_recv_tmf()
1449 rc = target_submit_tmr(&ocp->cmd, se_sess, NULL, lun, ocp, tmr_func, in efct_scsi_recv_tmf()
1450 GFP_ATOMIC, tmfio->init_task_tag, TARGET_SCF_ACK_KREF); in efct_scsi_recv_tmf()
1466 #define DEF_EFCT_TPG_ATTRIB(name) \ argument
1468 static ssize_t efct_lio_tpg_attrib_##name##_show( \
1475 return sprintf(page, "%u\n", tpg->tpg_attrib.name); \
1478 static ssize_t efct_lio_tpg_attrib_##name##_store( \
1484 struct efct_lio_tpg_attrib *a = &tpg->tpg_attrib; \
1496 return -EINVAL; \
1499 a->name = val; \
1503 CONFIGFS_ATTR(efct_lio_tpg_attrib_, name)
1522 #define DEF_EFCT_NPIV_TPG_ATTRIB(name) \ argument
1524 static ssize_t efct_lio_npiv_tpg_attrib_##name##_show( \
1531 return sprintf(page, "%u\n", tpg->tpg_attrib.name); \
1534 static ssize_t efct_lio_npiv_tpg_attrib_##name##_store( \
1540 struct efct_lio_tpg_attrib *a = &tpg->tpg_attrib; \
1552 return -EINVAL; \
1555 a->name = val; \
1559 CONFIGFS_ATTR(efct_lio_npiv_tpg_attrib_, name)