1 /*******************************************************************************
2 * This file contains tcm implementation using v4 configfs fabric infrastructure
3 * for QLogic target mode HBAs
5 * ?? Copyright 2010-2011 RisingTide Systems LLC.
7 * Licensed to the Linux Foundation under the General Public License (GPL)
10 * Author: Nicholas A. Bellinger <nab@risingtidesystems.com>
12 * tcm_qla2xxx_parse_wwn() and tcm_qla2xxx_format_wwn() contains code from
13 * the TCM_FC / Open-FCoE.org fabric module.
15 * Copyright (c) 2010 Cisco Systems, Inc
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 ****************************************************************************/
29 #include <linux/module.h>
30 #include <linux/moduleparam.h>
31 #include <generated/utsrelease.h>
32 #include <linux/utsname.h>
33 #include <linux/init.h>
34 #include <linux/list.h>
35 #include <linux/slab.h>
36 #include <linux/kthread.h>
37 #include <linux/types.h>
38 #include <linux/string.h>
39 #include <linux/configfs.h>
40 #include <linux/ctype.h>
41 #include <linux/string.h>
42 #include <linux/ctype.h>
43 #include <asm/unaligned.h>
44 #include <scsi/scsi.h>
45 #include <scsi/scsi_host.h>
46 #include <scsi/scsi_device.h>
47 #include <scsi/scsi_cmnd.h>
48 #include <target/target_core_base.h>
49 #include <target/target_core_fabric.h>
50 #include <target/target_core_fabric_configfs.h>
51 #include <target/target_core_configfs.h>
52 #include <target/configfs_macros.h>
55 #include "qla_target.h"
56 #include "tcm_qla2xxx.h"
58 struct workqueue_struct
*tcm_qla2xxx_free_wq
;
59 struct workqueue_struct
*tcm_qla2xxx_cmd_wq
;
61 static int tcm_qla2xxx_check_true(struct se_portal_group
*se_tpg
)
66 static int tcm_qla2xxx_check_false(struct se_portal_group
*se_tpg
)
73 * If strict, we require lower-case hex and colon separators to be sure
74 * the name is the same as what would be generated by ft_format_wwn()
75 * so the name and wwn are mapped one-to-one.
77 static ssize_t
tcm_qla2xxx_parse_wwn(const char *name
, u64
*wwn
, int strict
)
87 for (cp
= name
; cp
< &name
[TCM_QLA2XXX_NAMELEN
- 1]; cp
++) {
89 if (c
== '\n' && cp
[1] == '\0')
91 if (strict
&& pos
++ == 2 && byte
++ < 7) {
100 if (strict
&& byte
!= 8)
107 else if (isxdigit(c
) && (islower(c
) || !strict
))
108 nibble
= tolower(c
) - 'a' + 10;
111 *wwn
= (*wwn
<< 4) | nibble
;
115 pr_debug("err %u len %zu pos %u byte %u\n",
116 err
, cp
- name
, pos
, byte
);
120 static ssize_t
tcm_qla2xxx_format_wwn(char *buf
, size_t len
, u64 wwn
)
124 put_unaligned_be64(wwn
, b
);
125 return snprintf(buf
, len
,
126 "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
127 b
[0], b
[1], b
[2], b
[3], b
[4], b
[5], b
[6], b
[7]);
130 static char *tcm_qla2xxx_get_fabric_name(void)
136 * From drivers/scsi/scsi_transport_fc.c:fc_parse_wwn
138 static int tcm_qla2xxx_npiv_extract_wwn(const char *ns
, u64
*nm
)
143 memset(wwn
, 0, sizeof(wwn
));
145 /* Validate and store the new name */
146 for (i
= 0, j
= 0; i
< 16; i
++) {
149 value
= hex_to_bin(*ns
++);
151 j
= (j
<< 4) | value
;
161 *nm
= wwn_to_u64(wwn
);
166 * This parsing logic follows drivers/scsi/scsi_transport_fc.c:
167 * store_fc_host_vport_create()
169 static int tcm_qla2xxx_npiv_parse_wwn(
175 unsigned int cnt
= count
;
181 /* count may include a LF at end of string */
182 if (name
[cnt
-1] == '\n')
185 /* validate we have enough characters for WWPN */
186 if ((cnt
!= (16+1+16)) || (name
[16] != ':'))
189 rc
= tcm_qla2xxx_npiv_extract_wwn(&name
[0], wwpn
);
193 rc
= tcm_qla2xxx_npiv_extract_wwn(&name
[17], wwnn
);
200 static ssize_t
tcm_qla2xxx_npiv_format_wwn(char *buf
, size_t len
,
205 put_unaligned_be64(wwpn
, b
);
206 put_unaligned_be64(wwnn
, b2
);
207 return snprintf(buf
, len
,
208 "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x,"
209 "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
210 b
[0], b
[1], b
[2], b
[3], b
[4], b
[5], b
[6], b
[7],
211 b2
[0], b2
[1], b2
[2], b2
[3], b2
[4], b2
[5], b2
[6], b2
[7]);
214 static char *tcm_qla2xxx_npiv_get_fabric_name(void)
216 return "qla2xxx_npiv";
219 static u8
tcm_qla2xxx_get_fabric_proto_ident(struct se_portal_group
*se_tpg
)
221 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
222 struct tcm_qla2xxx_tpg
, se_tpg
);
223 struct tcm_qla2xxx_lport
*lport
= tpg
->lport
;
226 switch (lport
->lport_proto_id
) {
227 case SCSI_PROTOCOL_FCP
:
229 proto_id
= fc_get_fabric_proto_ident(se_tpg
);
236 static char *tcm_qla2xxx_get_fabric_wwn(struct se_portal_group
*se_tpg
)
238 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
239 struct tcm_qla2xxx_tpg
, se_tpg
);
240 struct tcm_qla2xxx_lport
*lport
= tpg
->lport
;
242 return &lport
->lport_name
[0];
245 static char *tcm_qla2xxx_npiv_get_fabric_wwn(struct se_portal_group
*se_tpg
)
247 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
248 struct tcm_qla2xxx_tpg
, se_tpg
);
249 struct tcm_qla2xxx_lport
*lport
= tpg
->lport
;
251 return &lport
->lport_npiv_name
[0];
254 static u16
tcm_qla2xxx_get_tag(struct se_portal_group
*se_tpg
)
256 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
257 struct tcm_qla2xxx_tpg
, se_tpg
);
258 return tpg
->lport_tpgt
;
261 static u32
tcm_qla2xxx_get_default_depth(struct se_portal_group
*se_tpg
)
266 static u32
tcm_qla2xxx_get_pr_transport_id(
267 struct se_portal_group
*se_tpg
,
268 struct se_node_acl
*se_nacl
,
269 struct t10_pr_registration
*pr_reg
,
273 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
274 struct tcm_qla2xxx_tpg
, se_tpg
);
275 struct tcm_qla2xxx_lport
*lport
= tpg
->lport
;
278 switch (lport
->lport_proto_id
) {
279 case SCSI_PROTOCOL_FCP
:
281 ret
= fc_get_pr_transport_id(se_tpg
, se_nacl
, pr_reg
,
289 static u32
tcm_qla2xxx_get_pr_transport_id_len(
290 struct se_portal_group
*se_tpg
,
291 struct se_node_acl
*se_nacl
,
292 struct t10_pr_registration
*pr_reg
,
295 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
296 struct tcm_qla2xxx_tpg
, se_tpg
);
297 struct tcm_qla2xxx_lport
*lport
= tpg
->lport
;
300 switch (lport
->lport_proto_id
) {
301 case SCSI_PROTOCOL_FCP
:
303 ret
= fc_get_pr_transport_id_len(se_tpg
, se_nacl
, pr_reg
,
311 static char *tcm_qla2xxx_parse_pr_out_transport_id(
312 struct se_portal_group
*se_tpg
,
315 char **port_nexus_ptr
)
317 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
318 struct tcm_qla2xxx_tpg
, se_tpg
);
319 struct tcm_qla2xxx_lport
*lport
= tpg
->lport
;
322 switch (lport
->lport_proto_id
) {
323 case SCSI_PROTOCOL_FCP
:
325 tid
= fc_parse_pr_out_transport_id(se_tpg
, buf
, out_tid_len
,
333 static int tcm_qla2xxx_check_demo_mode(struct se_portal_group
*se_tpg
)
335 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
336 struct tcm_qla2xxx_tpg
, se_tpg
);
338 return QLA_TPG_ATTRIB(tpg
)->generate_node_acls
;
341 static int tcm_qla2xxx_check_demo_mode_cache(struct se_portal_group
*se_tpg
)
343 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
344 struct tcm_qla2xxx_tpg
, se_tpg
);
346 return QLA_TPG_ATTRIB(tpg
)->cache_dynamic_acls
;
349 static int tcm_qla2xxx_check_demo_write_protect(struct se_portal_group
*se_tpg
)
351 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
352 struct tcm_qla2xxx_tpg
, se_tpg
);
354 return QLA_TPG_ATTRIB(tpg
)->demo_mode_write_protect
;
357 static int tcm_qla2xxx_check_prod_write_protect(struct se_portal_group
*se_tpg
)
359 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
360 struct tcm_qla2xxx_tpg
, se_tpg
);
362 return QLA_TPG_ATTRIB(tpg
)->prod_mode_write_protect
;
365 static struct se_node_acl
*tcm_qla2xxx_alloc_fabric_acl(
366 struct se_portal_group
*se_tpg
)
368 struct tcm_qla2xxx_nacl
*nacl
;
370 nacl
= kzalloc(sizeof(struct tcm_qla2xxx_nacl
), GFP_KERNEL
);
372 pr_err("Unable to alocate struct tcm_qla2xxx_nacl\n");
376 return &nacl
->se_node_acl
;
379 static void tcm_qla2xxx_release_fabric_acl(
380 struct se_portal_group
*se_tpg
,
381 struct se_node_acl
*se_nacl
)
383 struct tcm_qla2xxx_nacl
*nacl
= container_of(se_nacl
,
384 struct tcm_qla2xxx_nacl
, se_node_acl
);
388 static u32
tcm_qla2xxx_tpg_get_inst_index(struct se_portal_group
*se_tpg
)
390 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
391 struct tcm_qla2xxx_tpg
, se_tpg
);
393 return tpg
->lport_tpgt
;
396 static void tcm_qla2xxx_complete_mcmd(struct work_struct
*work
)
398 struct qla_tgt_mgmt_cmd
*mcmd
= container_of(work
,
399 struct qla_tgt_mgmt_cmd
, free_work
);
401 transport_generic_free_cmd(&mcmd
->se_cmd
, 0);
405 * Called from qla_target_template->free_mcmd(), and will call
406 * tcm_qla2xxx_release_cmd() via normal struct target_core_fabric_ops
407 * release callback. qla_hw_data->hardware_lock is expected to be held
409 static void tcm_qla2xxx_free_mcmd(struct qla_tgt_mgmt_cmd
*mcmd
)
411 INIT_WORK(&mcmd
->free_work
, tcm_qla2xxx_complete_mcmd
);
412 queue_work(tcm_qla2xxx_free_wq
, &mcmd
->free_work
);
415 static void tcm_qla2xxx_complete_free(struct work_struct
*work
)
417 struct qla_tgt_cmd
*cmd
= container_of(work
, struct qla_tgt_cmd
, work
);
419 transport_generic_free_cmd(&cmd
->se_cmd
, 0);
423 * Called from qla_target_template->free_cmd(), and will call
424 * tcm_qla2xxx_release_cmd via normal struct target_core_fabric_ops
425 * release callback. qla_hw_data->hardware_lock is expected to be held
427 static void tcm_qla2xxx_free_cmd(struct qla_tgt_cmd
*cmd
)
429 INIT_WORK(&cmd
->work
, tcm_qla2xxx_complete_free
);
430 queue_work(tcm_qla2xxx_free_wq
, &cmd
->work
);
434 * Called from struct target_core_fabric_ops->check_stop_free() context
436 static int tcm_qla2xxx_check_stop_free(struct se_cmd
*se_cmd
)
438 return target_put_sess_cmd(se_cmd
->se_sess
, se_cmd
);
441 /* tcm_qla2xxx_release_cmd - Callback from TCM Core to release underlying
442 * fabric descriptor @se_cmd command to release
444 static void tcm_qla2xxx_release_cmd(struct se_cmd
*se_cmd
)
446 struct qla_tgt_cmd
*cmd
;
448 if (se_cmd
->se_cmd_flags
& SCF_SCSI_TMR_CDB
) {
449 struct qla_tgt_mgmt_cmd
*mcmd
= container_of(se_cmd
,
450 struct qla_tgt_mgmt_cmd
, se_cmd
);
455 cmd
= container_of(se_cmd
, struct qla_tgt_cmd
, se_cmd
);
459 static int tcm_qla2xxx_shutdown_session(struct se_session
*se_sess
)
461 struct qla_tgt_sess
*sess
= se_sess
->fabric_sess_ptr
;
462 struct scsi_qla_host
*vha
;
468 spin_lock_irqsave(&vha
->hw
->hardware_lock
, flags
);
469 sess
->tearing_down
= 1;
470 target_splice_sess_cmd_list(se_sess
);
471 spin_unlock_irqrestore(&vha
->hw
->hardware_lock
, flags
);
476 static void tcm_qla2xxx_close_session(struct se_session
*se_sess
)
478 struct qla_tgt_sess
*sess
= se_sess
->fabric_sess_ptr
;
479 struct scsi_qla_host
*vha
;
485 spin_lock_irqsave(&vha
->hw
->hardware_lock
, flags
);
486 qlt_unreg_sess(sess
);
487 spin_unlock_irqrestore(&vha
->hw
->hardware_lock
, flags
);
490 static u32
tcm_qla2xxx_sess_get_index(struct se_session
*se_sess
)
496 * The LIO target core uses DMA_TO_DEVICE to mean that data is going
497 * to the target (eg handling a WRITE) and DMA_FROM_DEVICE to mean
498 * that data is coming from the target (eg handling a READ). However,
499 * this is just the opposite of what we have to tell the DMA mapping
500 * layer -- eg when handling a READ, the HBA will have to DMA the data
501 * out of memory so it can send it to the initiator, which means we
502 * need to use DMA_TO_DEVICE when we map the data.
504 static enum dma_data_direction
tcm_qla2xxx_mapping_dir(struct se_cmd
*se_cmd
)
506 if (se_cmd
->se_cmd_flags
& SCF_BIDI
)
507 return DMA_BIDIRECTIONAL
;
509 switch (se_cmd
->data_direction
) {
511 return DMA_FROM_DEVICE
;
512 case DMA_FROM_DEVICE
:
513 return DMA_TO_DEVICE
;
520 static int tcm_qla2xxx_write_pending(struct se_cmd
*se_cmd
)
522 struct qla_tgt_cmd
*cmd
= container_of(se_cmd
,
523 struct qla_tgt_cmd
, se_cmd
);
525 cmd
->bufflen
= se_cmd
->data_length
;
526 cmd
->dma_data_direction
= tcm_qla2xxx_mapping_dir(se_cmd
);
528 cmd
->sg_cnt
= se_cmd
->t_data_nents
;
529 cmd
->sg
= se_cmd
->t_data_sg
;
532 * qla_target.c:qlt_rdy_to_xfer() will call pci_map_sg() to setup
533 * the SGL mappings into PCIe memory for incoming FCP WRITE data.
535 return qlt_rdy_to_xfer(cmd
);
538 static int tcm_qla2xxx_write_pending_status(struct se_cmd
*se_cmd
)
542 * Check for WRITE_PENDING status to determine if we need to wait for
543 * CTIO aborts to be posted via hardware in tcm_qla2xxx_handle_data().
545 spin_lock_irqsave(&se_cmd
->t_state_lock
, flags
);
546 if (se_cmd
->t_state
== TRANSPORT_WRITE_PENDING
||
547 se_cmd
->t_state
== TRANSPORT_COMPLETE_QF_WP
) {
548 spin_unlock_irqrestore(&se_cmd
->t_state_lock
, flags
);
549 wait_for_completion_timeout(&se_cmd
->t_transport_stop_comp
,
553 spin_unlock_irqrestore(&se_cmd
->t_state_lock
, flags
);
558 static void tcm_qla2xxx_set_default_node_attrs(struct se_node_acl
*nacl
)
563 static u32
tcm_qla2xxx_get_task_tag(struct se_cmd
*se_cmd
)
565 struct qla_tgt_cmd
*cmd
= container_of(se_cmd
,
566 struct qla_tgt_cmd
, se_cmd
);
571 static int tcm_qla2xxx_get_cmd_state(struct se_cmd
*se_cmd
)
577 * Called from process context in qla_target.c:qlt_do_work() code
579 static int tcm_qla2xxx_handle_cmd(scsi_qla_host_t
*vha
, struct qla_tgt_cmd
*cmd
,
580 unsigned char *cdb
, uint32_t data_length
, int fcp_task_attr
,
581 int data_dir
, int bidi
)
583 struct se_cmd
*se_cmd
= &cmd
->se_cmd
;
584 struct se_session
*se_sess
;
585 struct qla_tgt_sess
*sess
;
586 int flags
= TARGET_SCF_ACK_KREF
;
589 flags
|= TARGET_SCF_BIDI_OP
;
593 pr_err("Unable to locate struct qla_tgt_sess from qla_tgt_cmd\n");
597 se_sess
= sess
->se_sess
;
599 pr_err("Unable to locate active struct se_session\n");
603 target_submit_cmd(se_cmd
, se_sess
, cdb
, &cmd
->sense_buffer
[0],
604 cmd
->unpacked_lun
, data_length
, fcp_task_attr
,
609 static void tcm_qla2xxx_do_rsp(struct work_struct
*work
)
611 struct qla_tgt_cmd
*cmd
= container_of(work
, struct qla_tgt_cmd
, work
);
613 * Dispatch ->queue_status from workqueue process context
615 transport_generic_request_failure(&cmd
->se_cmd
);
619 * Called from qla_target.c:qlt_do_ctio_completion()
621 static int tcm_qla2xxx_handle_data(struct qla_tgt_cmd
*cmd
)
623 struct se_cmd
*se_cmd
= &cmd
->se_cmd
;
626 * Ensure that the complete FCP WRITE payload has been received.
627 * Otherwise return an exception via CHECK_CONDITION status.
629 if (!cmd
->write_data_transferred
) {
631 * Check if se_cmd has already been aborted via LUN_RESET, and
632 * waiting upon completion in tcm_qla2xxx_write_pending_status()
634 spin_lock_irqsave(&se_cmd
->t_state_lock
, flags
);
635 if (se_cmd
->transport_state
& CMD_T_ABORTED
) {
636 spin_unlock_irqrestore(&se_cmd
->t_state_lock
, flags
);
637 complete(&se_cmd
->t_transport_stop_comp
);
640 spin_unlock_irqrestore(&se_cmd
->t_state_lock
, flags
);
642 se_cmd
->scsi_sense_reason
= TCM_CHECK_CONDITION_ABORT_CMD
;
643 INIT_WORK(&cmd
->work
, tcm_qla2xxx_do_rsp
);
644 queue_work(tcm_qla2xxx_free_wq
, &cmd
->work
);
648 * We now tell TCM to queue this WRITE CDB with TRANSPORT_PROCESS_WRITE
649 * status to the backstore processing thread.
651 return transport_generic_handle_data(&cmd
->se_cmd
);
655 * Called from qla_target.c:qlt_issue_task_mgmt()
657 static int tcm_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd
*mcmd
, uint32_t lun
,
658 uint8_t tmr_func
, uint32_t tag
)
660 struct qla_tgt_sess
*sess
= mcmd
->sess
;
661 struct se_cmd
*se_cmd
= &mcmd
->se_cmd
;
663 return target_submit_tmr(se_cmd
, sess
->se_sess
, NULL
, lun
, mcmd
,
664 tmr_func
, GFP_ATOMIC
, tag
, TARGET_SCF_ACK_KREF
);
667 static int tcm_qla2xxx_queue_data_in(struct se_cmd
*se_cmd
)
669 struct qla_tgt_cmd
*cmd
= container_of(se_cmd
,
670 struct qla_tgt_cmd
, se_cmd
);
672 cmd
->bufflen
= se_cmd
->data_length
;
673 cmd
->dma_data_direction
= tcm_qla2xxx_mapping_dir(se_cmd
);
674 cmd
->aborted
= (se_cmd
->transport_state
& CMD_T_ABORTED
);
676 cmd
->sg_cnt
= se_cmd
->t_data_nents
;
677 cmd
->sg
= se_cmd
->t_data_sg
;
681 * Now queue completed DATA_IN the qla2xxx LLD and response ring
683 return qlt_xmit_response(cmd
, QLA_TGT_XMIT_DATA
|QLA_TGT_XMIT_STATUS
,
684 se_cmd
->scsi_status
);
687 static int tcm_qla2xxx_queue_status(struct se_cmd
*se_cmd
)
689 struct qla_tgt_cmd
*cmd
= container_of(se_cmd
,
690 struct qla_tgt_cmd
, se_cmd
);
691 int xmit_type
= QLA_TGT_XMIT_STATUS
;
693 cmd
->bufflen
= se_cmd
->data_length
;
697 cmd
->dma_data_direction
= tcm_qla2xxx_mapping_dir(se_cmd
);
698 cmd
->aborted
= (se_cmd
->transport_state
& CMD_T_ABORTED
);
700 if (se_cmd
->data_direction
== DMA_FROM_DEVICE
) {
702 * For FCP_READ with CHECK_CONDITION status, clear cmd->bufflen
703 * for qla_tgt_xmit_response LLD code
705 se_cmd
->se_cmd_flags
|= SCF_UNDERFLOW_BIT
;
706 se_cmd
->residual_count
= se_cmd
->data_length
;
711 * Now queue status response to qla2xxx LLD code and response ring
713 return qlt_xmit_response(cmd
, xmit_type
, se_cmd
->scsi_status
);
716 static int tcm_qla2xxx_queue_tm_rsp(struct se_cmd
*se_cmd
)
718 struct se_tmr_req
*se_tmr
= se_cmd
->se_tmr_req
;
719 struct qla_tgt_mgmt_cmd
*mcmd
= container_of(se_cmd
,
720 struct qla_tgt_mgmt_cmd
, se_cmd
);
722 pr_debug("queue_tm_rsp: mcmd: %p func: 0x%02x response: 0x%02x\n",
723 mcmd
, se_tmr
->function
, se_tmr
->response
);
725 * Do translation between TCM TM response codes and
726 * QLA2xxx FC TM response codes.
728 switch (se_tmr
->response
) {
729 case TMR_FUNCTION_COMPLETE
:
730 mcmd
->fc_tm_rsp
= FC_TM_SUCCESS
;
732 case TMR_TASK_DOES_NOT_EXIST
:
733 mcmd
->fc_tm_rsp
= FC_TM_BAD_CMD
;
735 case TMR_FUNCTION_REJECTED
:
736 mcmd
->fc_tm_rsp
= FC_TM_REJECT
;
738 case TMR_LUN_DOES_NOT_EXIST
:
740 mcmd
->fc_tm_rsp
= FC_TM_FAILED
;
744 * Queue the TM response to QLA2xxx LLD to build a
745 * CTIO response packet.
747 qlt_xmit_tm_rsp(mcmd
);
752 static u16
tcm_qla2xxx_get_fabric_sense_len(void)
757 static u16
tcm_qla2xxx_set_fabric_sense_len(struct se_cmd
*se_cmd
,
763 /* Local pointer to allocated TCM configfs fabric module */
764 struct target_fabric_configfs
*tcm_qla2xxx_fabric_configfs
;
765 struct target_fabric_configfs
*tcm_qla2xxx_npiv_fabric_configfs
;
767 static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport
*,
768 struct tcm_qla2xxx_nacl
*, struct qla_tgt_sess
*);
770 * Expected to be called with struct qla_hw_data->hardware_lock held
772 static void tcm_qla2xxx_clear_nacl_from_fcport_map(struct qla_tgt_sess
*sess
)
774 struct se_node_acl
*se_nacl
= sess
->se_sess
->se_node_acl
;
775 struct se_portal_group
*se_tpg
= se_nacl
->se_tpg
;
776 struct se_wwn
*se_wwn
= se_tpg
->se_tpg_wwn
;
777 struct tcm_qla2xxx_lport
*lport
= container_of(se_wwn
,
778 struct tcm_qla2xxx_lport
, lport_wwn
);
779 struct tcm_qla2xxx_nacl
*nacl
= container_of(se_nacl
,
780 struct tcm_qla2xxx_nacl
, se_node_acl
);
783 pr_debug("fc_rport domain: port_id 0x%06x\n", nacl
->nport_id
);
785 node
= btree_remove32(&lport
->lport_fcport_map
, nacl
->nport_id
);
786 WARN_ON(node
&& (node
!= se_nacl
));
788 pr_debug("Removed from fcport_map: %p for WWNN: 0x%016LX, port_id: 0x%06x\n",
789 se_nacl
, nacl
->nport_wwnn
, nacl
->nport_id
);
791 * Now clear the se_nacl and session pointers from our HW lport lookup
792 * table mapping for this initiator's fabric S_ID and LOOP_ID entries.
794 * This is done ahead of callbacks into tcm_qla2xxx_free_session() ->
795 * target_wait_for_sess_cmds() before the session waits for outstanding
796 * I/O to complete, to avoid a race between session shutdown execution
797 * and incoming ATIOs or TMRs picking up a stale se_node_act reference.
799 tcm_qla2xxx_clear_sess_lookup(lport
, nacl
, sess
);
802 static void tcm_qla2xxx_release_session(struct kref
*kref
)
804 struct se_session
*se_sess
= container_of(kref
,
805 struct se_session
, sess_kref
);
807 qlt_unreg_sess(se_sess
->fabric_sess_ptr
);
810 static void tcm_qla2xxx_put_session(struct se_session
*se_sess
)
812 struct qla_tgt_sess
*sess
= se_sess
->fabric_sess_ptr
;
813 struct qla_hw_data
*ha
= sess
->vha
->hw
;
816 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
817 kref_put(&se_sess
->sess_kref
, tcm_qla2xxx_release_session
);
818 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
821 static void tcm_qla2xxx_put_sess(struct qla_tgt_sess
*sess
)
823 tcm_qla2xxx_put_session(sess
->se_sess
);
826 static void tcm_qla2xxx_shutdown_sess(struct qla_tgt_sess
*sess
)
828 tcm_qla2xxx_shutdown_session(sess
->se_sess
);
831 static struct se_node_acl
*tcm_qla2xxx_make_nodeacl(
832 struct se_portal_group
*se_tpg
,
833 struct config_group
*group
,
836 struct se_node_acl
*se_nacl
, *se_nacl_new
;
837 struct tcm_qla2xxx_nacl
*nacl
;
839 u32 qla2xxx_nexus_depth
;
841 if (tcm_qla2xxx_parse_wwn(name
, &wwnn
, 1) < 0)
842 return ERR_PTR(-EINVAL
);
844 se_nacl_new
= tcm_qla2xxx_alloc_fabric_acl(se_tpg
);
846 return ERR_PTR(-ENOMEM
);
847 /* #warning FIXME: Hardcoded qla2xxx_nexus depth in tcm_qla2xxx_make_nodeacl */
848 qla2xxx_nexus_depth
= 1;
851 * se_nacl_new may be released by core_tpg_add_initiator_node_acl()
852 * when converting a NodeACL from demo mode -> explict
854 se_nacl
= core_tpg_add_initiator_node_acl(se_tpg
, se_nacl_new
,
855 name
, qla2xxx_nexus_depth
);
856 if (IS_ERR(se_nacl
)) {
857 tcm_qla2xxx_release_fabric_acl(se_tpg
, se_nacl_new
);
861 * Locate our struct tcm_qla2xxx_nacl and set the FC Nport WWPN
863 nacl
= container_of(se_nacl
, struct tcm_qla2xxx_nacl
, se_node_acl
);
864 nacl
->nport_wwnn
= wwnn
;
865 tcm_qla2xxx_format_wwn(&nacl
->nport_name
[0], TCM_QLA2XXX_NAMELEN
, wwnn
);
870 static void tcm_qla2xxx_drop_nodeacl(struct se_node_acl
*se_acl
)
872 struct se_portal_group
*se_tpg
= se_acl
->se_tpg
;
873 struct tcm_qla2xxx_nacl
*nacl
= container_of(se_acl
,
874 struct tcm_qla2xxx_nacl
, se_node_acl
);
876 core_tpg_del_initiator_node_acl(se_tpg
, se_acl
, 1);
880 /* Start items for tcm_qla2xxx_tpg_attrib_cit */
882 #define DEF_QLA_TPG_ATTRIB(name) \
884 static ssize_t tcm_qla2xxx_tpg_attrib_show_##name( \
885 struct se_portal_group *se_tpg, \
888 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \
889 struct tcm_qla2xxx_tpg, se_tpg); \
891 return sprintf(page, "%u\n", QLA_TPG_ATTRIB(tpg)->name); \
894 static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \
895 struct se_portal_group *se_tpg, \
899 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \
900 struct tcm_qla2xxx_tpg, se_tpg); \
904 ret = kstrtoul(page, 0, &val); \
906 pr_err("kstrtoul() failed with" \
907 " ret: %d\n", ret); \
910 ret = tcm_qla2xxx_set_attrib_##name(tpg, val); \
912 return (!ret) ? count : -EINVAL; \
915 #define DEF_QLA_TPG_ATTR_BOOL(_name) \
917 static int tcm_qla2xxx_set_attrib_##_name( \
918 struct tcm_qla2xxx_tpg *tpg, \
921 struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \
923 if ((val != 0) && (val != 1)) { \
924 pr_err("Illegal boolean value %lu\n", val); \
932 #define QLA_TPG_ATTR(_name, _mode) \
933 TF_TPG_ATTRIB_ATTR(tcm_qla2xxx, _name, _mode);
936 * Define tcm_qla2xxx_tpg_attrib_s_generate_node_acls
938 DEF_QLA_TPG_ATTR_BOOL(generate_node_acls
);
939 DEF_QLA_TPG_ATTRIB(generate_node_acls
);
940 QLA_TPG_ATTR(generate_node_acls
, S_IRUGO
| S_IWUSR
);
943 Define tcm_qla2xxx_attrib_s_cache_dynamic_acls
945 DEF_QLA_TPG_ATTR_BOOL(cache_dynamic_acls
);
946 DEF_QLA_TPG_ATTRIB(cache_dynamic_acls
);
947 QLA_TPG_ATTR(cache_dynamic_acls
, S_IRUGO
| S_IWUSR
);
950 * Define tcm_qla2xxx_tpg_attrib_s_demo_mode_write_protect
952 DEF_QLA_TPG_ATTR_BOOL(demo_mode_write_protect
);
953 DEF_QLA_TPG_ATTRIB(demo_mode_write_protect
);
954 QLA_TPG_ATTR(demo_mode_write_protect
, S_IRUGO
| S_IWUSR
);
957 * Define tcm_qla2xxx_tpg_attrib_s_prod_mode_write_protect
959 DEF_QLA_TPG_ATTR_BOOL(prod_mode_write_protect
);
960 DEF_QLA_TPG_ATTRIB(prod_mode_write_protect
);
961 QLA_TPG_ATTR(prod_mode_write_protect
, S_IRUGO
| S_IWUSR
);
963 static struct configfs_attribute
*tcm_qla2xxx_tpg_attrib_attrs
[] = {
964 &tcm_qla2xxx_tpg_attrib_generate_node_acls
.attr
,
965 &tcm_qla2xxx_tpg_attrib_cache_dynamic_acls
.attr
,
966 &tcm_qla2xxx_tpg_attrib_demo_mode_write_protect
.attr
,
967 &tcm_qla2xxx_tpg_attrib_prod_mode_write_protect
.attr
,
971 /* End items for tcm_qla2xxx_tpg_attrib_cit */
973 static ssize_t
tcm_qla2xxx_tpg_show_enable(
974 struct se_portal_group
*se_tpg
,
977 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
978 struct tcm_qla2xxx_tpg
, se_tpg
);
980 return snprintf(page
, PAGE_SIZE
, "%d\n",
981 atomic_read(&tpg
->lport_tpg_enabled
));
984 static ssize_t
tcm_qla2xxx_tpg_store_enable(
985 struct se_portal_group
*se_tpg
,
989 struct se_wwn
*se_wwn
= se_tpg
->se_tpg_wwn
;
990 struct tcm_qla2xxx_lport
*lport
= container_of(se_wwn
,
991 struct tcm_qla2xxx_lport
, lport_wwn
);
992 struct scsi_qla_host
*vha
= lport
->qla_vha
;
993 struct qla_hw_data
*ha
= vha
->hw
;
994 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
995 struct tcm_qla2xxx_tpg
, se_tpg
);
999 rc
= kstrtoul(page
, 0, &op
);
1001 pr_err("kstrtoul() returned %d\n", rc
);
1004 if ((op
!= 1) && (op
!= 0)) {
1005 pr_err("Illegal value for tpg_enable: %lu\n", op
);
1010 atomic_set(&tpg
->lport_tpg_enabled
, 1);
1011 qlt_enable_vha(vha
);
1013 if (!ha
->tgt
.qla_tgt
) {
1014 pr_err("truct qla_hw_data *ha->tgt.qla_tgt is NULL\n");
1017 atomic_set(&tpg
->lport_tpg_enabled
, 0);
1018 qlt_stop_phase1(ha
->tgt
.qla_tgt
);
1024 TF_TPG_BASE_ATTR(tcm_qla2xxx
, enable
, S_IRUGO
| S_IWUSR
);
1026 static struct configfs_attribute
*tcm_qla2xxx_tpg_attrs
[] = {
1027 &tcm_qla2xxx_tpg_enable
.attr
,
1031 static struct se_portal_group
*tcm_qla2xxx_make_tpg(
1033 struct config_group
*group
,
1036 struct tcm_qla2xxx_lport
*lport
= container_of(wwn
,
1037 struct tcm_qla2xxx_lport
, lport_wwn
);
1038 struct tcm_qla2xxx_tpg
*tpg
;
1042 if (strstr(name
, "tpgt_") != name
)
1043 return ERR_PTR(-EINVAL
);
1044 if (kstrtoul(name
+ 5, 10, &tpgt
) || tpgt
> USHRT_MAX
)
1045 return ERR_PTR(-EINVAL
);
1047 if (!lport
->qla_npiv_vp
&& (tpgt
!= 1)) {
1048 pr_err("In non NPIV mode, a single TPG=1 is used for HW port mappings\n");
1049 return ERR_PTR(-ENOSYS
);
1052 tpg
= kzalloc(sizeof(struct tcm_qla2xxx_tpg
), GFP_KERNEL
);
1054 pr_err("Unable to allocate struct tcm_qla2xxx_tpg\n");
1055 return ERR_PTR(-ENOMEM
);
1058 tpg
->lport_tpgt
= tpgt
;
1060 * By default allow READ-ONLY TPG demo-mode access w/ cached dynamic
1063 QLA_TPG_ATTRIB(tpg
)->generate_node_acls
= 1;
1064 QLA_TPG_ATTRIB(tpg
)->demo_mode_write_protect
= 1;
1065 QLA_TPG_ATTRIB(tpg
)->cache_dynamic_acls
= 1;
1067 ret
= core_tpg_register(&tcm_qla2xxx_fabric_configfs
->tf_ops
, wwn
,
1068 &tpg
->se_tpg
, tpg
, TRANSPORT_TPG_TYPE_NORMAL
);
1074 * Setup local TPG=1 pointer for non NPIV mode.
1076 if (lport
->qla_npiv_vp
== NULL
)
1079 return &tpg
->se_tpg
;
1082 static void tcm_qla2xxx_drop_tpg(struct se_portal_group
*se_tpg
)
1084 struct tcm_qla2xxx_tpg
*tpg
= container_of(se_tpg
,
1085 struct tcm_qla2xxx_tpg
, se_tpg
);
1086 struct tcm_qla2xxx_lport
*lport
= tpg
->lport
;
1087 struct scsi_qla_host
*vha
= lport
->qla_vha
;
1088 struct qla_hw_data
*ha
= vha
->hw
;
1090 * Call into qla2x_target.c LLD logic to shutdown the active
1091 * FC Nexuses and disable target mode operation for this qla_hw_data
1093 if (ha
->tgt
.qla_tgt
&& !ha
->tgt
.qla_tgt
->tgt_stop
)
1094 qlt_stop_phase1(ha
->tgt
.qla_tgt
);
1096 core_tpg_deregister(se_tpg
);
1098 * Clear local TPG=1 pointer for non NPIV mode.
1100 if (lport
->qla_npiv_vp
== NULL
)
1101 lport
->tpg_1
= NULL
;
1106 static struct se_portal_group
*tcm_qla2xxx_npiv_make_tpg(
1108 struct config_group
*group
,
1111 struct tcm_qla2xxx_lport
*lport
= container_of(wwn
,
1112 struct tcm_qla2xxx_lport
, lport_wwn
);
1113 struct tcm_qla2xxx_tpg
*tpg
;
1117 if (strstr(name
, "tpgt_") != name
)
1118 return ERR_PTR(-EINVAL
);
1119 if (kstrtoul(name
+ 5, 10, &tpgt
) || tpgt
> USHRT_MAX
)
1120 return ERR_PTR(-EINVAL
);
1122 tpg
= kzalloc(sizeof(struct tcm_qla2xxx_tpg
), GFP_KERNEL
);
1124 pr_err("Unable to allocate struct tcm_qla2xxx_tpg\n");
1125 return ERR_PTR(-ENOMEM
);
1128 tpg
->lport_tpgt
= tpgt
;
1130 ret
= core_tpg_register(&tcm_qla2xxx_npiv_fabric_configfs
->tf_ops
, wwn
,
1131 &tpg
->se_tpg
, tpg
, TRANSPORT_TPG_TYPE_NORMAL
);
1136 return &tpg
->se_tpg
;
1140 * Expected to be called with struct qla_hw_data->hardware_lock held
1142 static struct qla_tgt_sess
*tcm_qla2xxx_find_sess_by_s_id(
1143 scsi_qla_host_t
*vha
,
1144 const uint8_t *s_id
)
1146 struct qla_hw_data
*ha
= vha
->hw
;
1147 struct tcm_qla2xxx_lport
*lport
;
1148 struct se_node_acl
*se_nacl
;
1149 struct tcm_qla2xxx_nacl
*nacl
;
1152 lport
= ha
->tgt
.target_lport_ptr
;
1154 pr_err("Unable to locate struct tcm_qla2xxx_lport\n");
1159 key
= (((unsigned long)s_id
[0] << 16) |
1160 ((unsigned long)s_id
[1] << 8) |
1161 (unsigned long)s_id
[2]);
1162 pr_debug("find_sess_by_s_id: 0x%06x\n", key
);
1164 se_nacl
= btree_lookup32(&lport
->lport_fcport_map
, key
);
1166 pr_debug("Unable to locate s_id: 0x%06x\n", key
);
1169 pr_debug("find_sess_by_s_id: located se_nacl: %p, initiatorname: %s\n",
1170 se_nacl
, se_nacl
->initiatorname
);
1172 nacl
= container_of(se_nacl
, struct tcm_qla2xxx_nacl
, se_node_acl
);
1173 if (!nacl
->qla_tgt_sess
) {
1174 pr_err("Unable to locate struct qla_tgt_sess\n");
1178 return nacl
->qla_tgt_sess
;
1182 * Expected to be called with struct qla_hw_data->hardware_lock held
1184 static void tcm_qla2xxx_set_sess_by_s_id(
1185 struct tcm_qla2xxx_lport
*lport
,
1186 struct se_node_acl
*new_se_nacl
,
1187 struct tcm_qla2xxx_nacl
*nacl
,
1188 struct se_session
*se_sess
,
1189 struct qla_tgt_sess
*qla_tgt_sess
,
1196 key
= (((unsigned long)s_id
[0] << 16) |
1197 ((unsigned long)s_id
[1] << 8) |
1198 (unsigned long)s_id
[2]);
1199 pr_debug("set_sess_by_s_id: %06x\n", key
);
1201 slot
= btree_lookup32(&lport
->lport_fcport_map
, key
);
1204 pr_debug("Setting up new fc_port entry to new_se_nacl\n");
1205 nacl
->nport_id
= key
;
1206 rc
= btree_insert32(&lport
->lport_fcport_map
, key
,
1207 new_se_nacl
, GFP_ATOMIC
);
1209 printk(KERN_ERR
"Unable to insert s_id into fcport_map: %06x\n",
1212 pr_debug("Wiping nonexisting fc_port entry\n");
1215 qla_tgt_sess
->se_sess
= se_sess
;
1216 nacl
->qla_tgt_sess
= qla_tgt_sess
;
1220 if (nacl
->qla_tgt_sess
) {
1221 if (new_se_nacl
== NULL
) {
1222 pr_debug("Clearing existing nacl->qla_tgt_sess and fc_port entry\n");
1223 btree_remove32(&lport
->lport_fcport_map
, key
);
1224 nacl
->qla_tgt_sess
= NULL
;
1227 pr_debug("Replacing existing nacl->qla_tgt_sess and fc_port entry\n");
1228 btree_update32(&lport
->lport_fcport_map
, key
, new_se_nacl
);
1229 qla_tgt_sess
->se_sess
= se_sess
;
1230 nacl
->qla_tgt_sess
= qla_tgt_sess
;
1234 if (new_se_nacl
== NULL
) {
1235 pr_debug("Clearing existing fc_port entry\n");
1236 btree_remove32(&lport
->lport_fcport_map
, key
);
1240 pr_debug("Replacing existing fc_port entry w/o active nacl->qla_tgt_sess\n");
1241 btree_update32(&lport
->lport_fcport_map
, key
, new_se_nacl
);
1242 qla_tgt_sess
->se_sess
= se_sess
;
1243 nacl
->qla_tgt_sess
= qla_tgt_sess
;
1245 pr_debug("Setup nacl->qla_tgt_sess %p by s_id for se_nacl: %p, initiatorname: %s\n",
1246 nacl
->qla_tgt_sess
, new_se_nacl
, new_se_nacl
->initiatorname
);
1250 * Expected to be called with struct qla_hw_data->hardware_lock held
1252 static struct qla_tgt_sess
*tcm_qla2xxx_find_sess_by_loop_id(
1253 scsi_qla_host_t
*vha
,
1254 const uint16_t loop_id
)
1256 struct qla_hw_data
*ha
= vha
->hw
;
1257 struct tcm_qla2xxx_lport
*lport
;
1258 struct se_node_acl
*se_nacl
;
1259 struct tcm_qla2xxx_nacl
*nacl
;
1260 struct tcm_qla2xxx_fc_loopid
*fc_loopid
;
1262 lport
= ha
->tgt
.target_lport_ptr
;
1264 pr_err("Unable to locate struct tcm_qla2xxx_lport\n");
1269 pr_debug("find_sess_by_loop_id: Using loop_id: 0x%04x\n", loop_id
);
1271 fc_loopid
= lport
->lport_loopid_map
+ loop_id
;
1272 se_nacl
= fc_loopid
->se_nacl
;
1274 pr_debug("Unable to locate se_nacl by loop_id: 0x%04x\n",
1279 nacl
= container_of(se_nacl
, struct tcm_qla2xxx_nacl
, se_node_acl
);
1281 if (!nacl
->qla_tgt_sess
) {
1282 pr_err("Unable to locate struct qla_tgt_sess\n");
1286 return nacl
->qla_tgt_sess
;
1290 * Expected to be called with struct qla_hw_data->hardware_lock held
1292 static void tcm_qla2xxx_set_sess_by_loop_id(
1293 struct tcm_qla2xxx_lport
*lport
,
1294 struct se_node_acl
*new_se_nacl
,
1295 struct tcm_qla2xxx_nacl
*nacl
,
1296 struct se_session
*se_sess
,
1297 struct qla_tgt_sess
*qla_tgt_sess
,
1300 struct se_node_acl
*saved_nacl
;
1301 struct tcm_qla2xxx_fc_loopid
*fc_loopid
;
1303 pr_debug("set_sess_by_loop_id: Using loop_id: 0x%04x\n", loop_id
);
1305 fc_loopid
= &((struct tcm_qla2xxx_fc_loopid
*)
1306 lport
->lport_loopid_map
)[loop_id
];
1308 saved_nacl
= fc_loopid
->se_nacl
;
1310 pr_debug("Setting up new fc_loopid->se_nacl to new_se_nacl\n");
1311 fc_loopid
->se_nacl
= new_se_nacl
;
1312 if (qla_tgt_sess
->se_sess
!= se_sess
)
1313 qla_tgt_sess
->se_sess
= se_sess
;
1314 if (nacl
->qla_tgt_sess
!= qla_tgt_sess
)
1315 nacl
->qla_tgt_sess
= qla_tgt_sess
;
1319 if (nacl
->qla_tgt_sess
) {
1320 if (new_se_nacl
== NULL
) {
1321 pr_debug("Clearing nacl->qla_tgt_sess and fc_loopid->se_nacl\n");
1322 fc_loopid
->se_nacl
= NULL
;
1323 nacl
->qla_tgt_sess
= NULL
;
1327 pr_debug("Replacing existing nacl->qla_tgt_sess and fc_loopid->se_nacl\n");
1328 fc_loopid
->se_nacl
= new_se_nacl
;
1329 if (qla_tgt_sess
->se_sess
!= se_sess
)
1330 qla_tgt_sess
->se_sess
= se_sess
;
1331 if (nacl
->qla_tgt_sess
!= qla_tgt_sess
)
1332 nacl
->qla_tgt_sess
= qla_tgt_sess
;
1336 if (new_se_nacl
== NULL
) {
1337 pr_debug("Clearing fc_loopid->se_nacl\n");
1338 fc_loopid
->se_nacl
= NULL
;
1342 pr_debug("Replacing existing fc_loopid->se_nacl w/o active nacl->qla_tgt_sess\n");
1343 fc_loopid
->se_nacl
= new_se_nacl
;
1344 if (qla_tgt_sess
->se_sess
!= se_sess
)
1345 qla_tgt_sess
->se_sess
= se_sess
;
1346 if (nacl
->qla_tgt_sess
!= qla_tgt_sess
)
1347 nacl
->qla_tgt_sess
= qla_tgt_sess
;
1349 pr_debug("Setup nacl->qla_tgt_sess %p by loop_id for se_nacl: %p, initiatorname: %s\n",
1350 nacl
->qla_tgt_sess
, new_se_nacl
, new_se_nacl
->initiatorname
);
1354 * Should always be called with qla_hw_data->hardware_lock held.
1356 static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport
*lport
,
1357 struct tcm_qla2xxx_nacl
*nacl
, struct qla_tgt_sess
*sess
)
1359 struct se_session
*se_sess
= sess
->se_sess
;
1360 unsigned char be_sid
[3];
1362 be_sid
[0] = sess
->s_id
.b
.domain
;
1363 be_sid
[1] = sess
->s_id
.b
.area
;
1364 be_sid
[2] = sess
->s_id
.b
.al_pa
;
1366 tcm_qla2xxx_set_sess_by_s_id(lport
, NULL
, nacl
, se_sess
,
1368 tcm_qla2xxx_set_sess_by_loop_id(lport
, NULL
, nacl
, se_sess
,
1369 sess
, sess
->loop_id
);
1372 static void tcm_qla2xxx_free_session(struct qla_tgt_sess
*sess
)
1374 struct qla_tgt
*tgt
= sess
->tgt
;
1375 struct qla_hw_data
*ha
= tgt
->ha
;
1376 struct se_session
*se_sess
;
1377 struct se_node_acl
*se_nacl
;
1378 struct tcm_qla2xxx_lport
*lport
;
1379 struct tcm_qla2xxx_nacl
*nacl
;
1381 BUG_ON(in_interrupt());
1383 se_sess
= sess
->se_sess
;
1385 pr_err("struct qla_tgt_sess->se_sess is NULL\n");
1389 se_nacl
= se_sess
->se_node_acl
;
1390 nacl
= container_of(se_nacl
, struct tcm_qla2xxx_nacl
, se_node_acl
);
1392 lport
= ha
->tgt
.target_lport_ptr
;
1394 pr_err("Unable to locate struct tcm_qla2xxx_lport\n");
1398 target_wait_for_sess_cmds(se_sess
, 0);
1400 transport_deregister_session_configfs(sess
->se_sess
);
1401 transport_deregister_session(sess
->se_sess
);
1405 * Called via qlt_create_sess():ha->qla2x_tmpl->check_initiator_node_acl()
1406 * to locate struct se_node_acl
1408 static int tcm_qla2xxx_check_initiator_node_acl(
1409 scsi_qla_host_t
*vha
,
1410 unsigned char *fc_wwpn
,
1415 struct qla_hw_data
*ha
= vha
->hw
;
1416 struct tcm_qla2xxx_lport
*lport
;
1417 struct tcm_qla2xxx_tpg
*tpg
;
1418 struct tcm_qla2xxx_nacl
*nacl
;
1419 struct se_portal_group
*se_tpg
;
1420 struct se_node_acl
*se_nacl
;
1421 struct se_session
*se_sess
;
1422 struct qla_tgt_sess
*sess
= qla_tgt_sess
;
1423 unsigned char port_name
[36];
1424 unsigned long flags
;
1426 lport
= ha
->tgt
.target_lport_ptr
;
1428 pr_err("Unable to locate struct tcm_qla2xxx_lport\n");
1433 * Locate the TPG=1 reference..
1437 pr_err("Unable to lcoate struct tcm_qla2xxx_lport->tpg_1\n");
1440 se_tpg
= &tpg
->se_tpg
;
1442 se_sess
= transport_init_session();
1443 if (IS_ERR(se_sess
)) {
1444 pr_err("Unable to initialize struct se_session\n");
1445 return PTR_ERR(se_sess
);
1448 * Format the FCP Initiator port_name into colon seperated values to
1449 * match the format by tcm_qla2xxx explict ConfigFS NodeACLs.
1451 memset(&port_name
, 0, 36);
1452 snprintf(port_name
, 36, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
1453 fc_wwpn
[0], fc_wwpn
[1], fc_wwpn
[2], fc_wwpn
[3], fc_wwpn
[4],
1454 fc_wwpn
[5], fc_wwpn
[6], fc_wwpn
[7]);
1456 * Locate our struct se_node_acl either from an explict NodeACL created
1457 * via ConfigFS, or via running in TPG demo mode.
1459 se_sess
->se_node_acl
= core_tpg_check_initiator_node_acl(se_tpg
,
1461 if (!se_sess
->se_node_acl
) {
1462 transport_free_session(se_sess
);
1465 se_nacl
= se_sess
->se_node_acl
;
1466 nacl
= container_of(se_nacl
, struct tcm_qla2xxx_nacl
, se_node_acl
);
1468 * And now setup the new se_nacl and session pointers into our HW lport
1469 * mappings for fabric S_ID and LOOP_ID.
1471 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1472 tcm_qla2xxx_set_sess_by_s_id(lport
, se_nacl
, nacl
, se_sess
,
1473 qla_tgt_sess
, s_id
);
1474 tcm_qla2xxx_set_sess_by_loop_id(lport
, se_nacl
, nacl
, se_sess
,
1475 qla_tgt_sess
, loop_id
);
1476 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1478 * Finally register the new FC Nexus with TCM
1480 __transport_register_session(se_nacl
->se_tpg
, se_nacl
, se_sess
, sess
);
1486 * Calls into tcm_qla2xxx used by qla2xxx LLD I/O path.
1488 static struct qla_tgt_func_tmpl tcm_qla2xxx_template
= {
1489 .handle_cmd
= tcm_qla2xxx_handle_cmd
,
1490 .handle_data
= tcm_qla2xxx_handle_data
,
1491 .handle_tmr
= tcm_qla2xxx_handle_tmr
,
1492 .free_cmd
= tcm_qla2xxx_free_cmd
,
1493 .free_mcmd
= tcm_qla2xxx_free_mcmd
,
1494 .free_session
= tcm_qla2xxx_free_session
,
1495 .check_initiator_node_acl
= tcm_qla2xxx_check_initiator_node_acl
,
1496 .find_sess_by_s_id
= tcm_qla2xxx_find_sess_by_s_id
,
1497 .find_sess_by_loop_id
= tcm_qla2xxx_find_sess_by_loop_id
,
1498 .clear_nacl_from_fcport_map
= tcm_qla2xxx_clear_nacl_from_fcport_map
,
1499 .put_sess
= tcm_qla2xxx_put_sess
,
1500 .shutdown_sess
= tcm_qla2xxx_shutdown_sess
,
1503 static int tcm_qla2xxx_init_lport(struct tcm_qla2xxx_lport
*lport
)
1507 rc
= btree_init32(&lport
->lport_fcport_map
);
1509 pr_err("Unable to initialize lport->lport_fcport_map btree\n");
1513 lport
->lport_loopid_map
= vmalloc(sizeof(struct tcm_qla2xxx_fc_loopid
) *
1515 if (!lport
->lport_loopid_map
) {
1516 pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n",
1517 sizeof(struct tcm_qla2xxx_fc_loopid
) * 65536);
1518 btree_destroy32(&lport
->lport_fcport_map
);
1521 memset(lport
->lport_loopid_map
, 0, sizeof(struct tcm_qla2xxx_fc_loopid
)
1523 pr_debug("qla2xxx: Allocated lport_loopid_map of %zu bytes\n",
1524 sizeof(struct tcm_qla2xxx_fc_loopid
) * 65536);
1528 static int tcm_qla2xxx_lport_register_cb(struct scsi_qla_host
*vha
)
1530 struct qla_hw_data
*ha
= vha
->hw
;
1531 struct tcm_qla2xxx_lport
*lport
;
1533 * Setup local pointer to vha, NPIV VP pointer (if present) and
1534 * vha->tcm_lport pointer
1536 lport
= (struct tcm_qla2xxx_lport
*)ha
->tgt
.target_lport_ptr
;
1537 lport
->qla_vha
= vha
;
1542 static struct se_wwn
*tcm_qla2xxx_make_lport(
1543 struct target_fabric_configfs
*tf
,
1544 struct config_group
*group
,
1547 struct tcm_qla2xxx_lport
*lport
;
1551 if (tcm_qla2xxx_parse_wwn(name
, &wwpn
, 1) < 0)
1552 return ERR_PTR(-EINVAL
);
1554 lport
= kzalloc(sizeof(struct tcm_qla2xxx_lport
), GFP_KERNEL
);
1556 pr_err("Unable to allocate struct tcm_qla2xxx_lport\n");
1557 return ERR_PTR(-ENOMEM
);
1559 lport
->lport_wwpn
= wwpn
;
1560 tcm_qla2xxx_format_wwn(&lport
->lport_name
[0], TCM_QLA2XXX_NAMELEN
,
1563 ret
= tcm_qla2xxx_init_lport(lport
);
1567 ret
= qlt_lport_register(&tcm_qla2xxx_template
, wwpn
,
1568 tcm_qla2xxx_lport_register_cb
, lport
);
1572 return &lport
->lport_wwn
;
1574 vfree(lport
->lport_loopid_map
);
1575 btree_destroy32(&lport
->lport_fcport_map
);
1578 return ERR_PTR(ret
);
1581 static void tcm_qla2xxx_drop_lport(struct se_wwn
*wwn
)
1583 struct tcm_qla2xxx_lport
*lport
= container_of(wwn
,
1584 struct tcm_qla2xxx_lport
, lport_wwn
);
1585 struct scsi_qla_host
*vha
= lport
->qla_vha
;
1586 struct qla_hw_data
*ha
= vha
->hw
;
1587 struct se_node_acl
*node
;
1591 * Call into qla2x_target.c LLD logic to complete the
1592 * shutdown of struct qla_tgt after the call to
1593 * qlt_stop_phase1() from tcm_qla2xxx_drop_tpg() above..
1595 if (ha
->tgt
.qla_tgt
&& !ha
->tgt
.qla_tgt
->tgt_stopped
)
1596 qlt_stop_phase2(ha
->tgt
.qla_tgt
);
1598 qlt_lport_deregister(vha
);
1600 vfree(lport
->lport_loopid_map
);
1601 btree_for_each_safe32(&lport
->lport_fcport_map
, key
, node
)
1602 btree_remove32(&lport
->lport_fcport_map
, key
);
1603 btree_destroy32(&lport
->lport_fcport_map
);
1607 static struct se_wwn
*tcm_qla2xxx_npiv_make_lport(
1608 struct target_fabric_configfs
*tf
,
1609 struct config_group
*group
,
1612 struct tcm_qla2xxx_lport
*lport
;
1613 u64 npiv_wwpn
, npiv_wwnn
;
1616 if (tcm_qla2xxx_npiv_parse_wwn(name
, strlen(name
)+1,
1617 &npiv_wwpn
, &npiv_wwnn
) < 0)
1618 return ERR_PTR(-EINVAL
);
1620 lport
= kzalloc(sizeof(struct tcm_qla2xxx_lport
), GFP_KERNEL
);
1622 pr_err("Unable to allocate struct tcm_qla2xxx_lport for NPIV\n");
1623 return ERR_PTR(-ENOMEM
);
1625 lport
->lport_npiv_wwpn
= npiv_wwpn
;
1626 lport
->lport_npiv_wwnn
= npiv_wwnn
;
1627 tcm_qla2xxx_npiv_format_wwn(&lport
->lport_npiv_name
[0],
1628 TCM_QLA2XXX_NAMELEN
, npiv_wwpn
, npiv_wwnn
);
1630 /* FIXME: tcm_qla2xxx_npiv_make_lport */
1635 return &lport
->lport_wwn
;
1638 return ERR_PTR(ret
);
1641 static void tcm_qla2xxx_npiv_drop_lport(struct se_wwn
*wwn
)
1643 struct tcm_qla2xxx_lport
*lport
= container_of(wwn
,
1644 struct tcm_qla2xxx_lport
, lport_wwn
);
1645 struct scsi_qla_host
*vha
= lport
->qla_vha
;
1646 struct Scsi_Host
*sh
= vha
->host
;
1648 * Notify libfc that we want to release the lport->npiv_vport
1650 fc_vport_terminate(lport
->npiv_vport
);
1657 static ssize_t
tcm_qla2xxx_wwn_show_attr_version(
1658 struct target_fabric_configfs
*tf
,
1661 return sprintf(page
,
1662 "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on "
1663 UTS_RELEASE
"\n", TCM_QLA2XXX_VERSION
, utsname()->sysname
,
1664 utsname()->machine
);
1667 TF_WWN_ATTR_RO(tcm_qla2xxx
, version
);
1669 static struct configfs_attribute
*tcm_qla2xxx_wwn_attrs
[] = {
1670 &tcm_qla2xxx_wwn_version
.attr
,
1674 static struct target_core_fabric_ops tcm_qla2xxx_ops
= {
1675 .get_fabric_name
= tcm_qla2xxx_get_fabric_name
,
1676 .get_fabric_proto_ident
= tcm_qla2xxx_get_fabric_proto_ident
,
1677 .tpg_get_wwn
= tcm_qla2xxx_get_fabric_wwn
,
1678 .tpg_get_tag
= tcm_qla2xxx_get_tag
,
1679 .tpg_get_default_depth
= tcm_qla2xxx_get_default_depth
,
1680 .tpg_get_pr_transport_id
= tcm_qla2xxx_get_pr_transport_id
,
1681 .tpg_get_pr_transport_id_len
= tcm_qla2xxx_get_pr_transport_id_len
,
1682 .tpg_parse_pr_out_transport_id
= tcm_qla2xxx_parse_pr_out_transport_id
,
1683 .tpg_check_demo_mode
= tcm_qla2xxx_check_demo_mode
,
1684 .tpg_check_demo_mode_cache
= tcm_qla2xxx_check_demo_mode_cache
,
1685 .tpg_check_demo_mode_write_protect
=
1686 tcm_qla2xxx_check_demo_write_protect
,
1687 .tpg_check_prod_mode_write_protect
=
1688 tcm_qla2xxx_check_prod_write_protect
,
1689 .tpg_check_demo_mode_login_only
= tcm_qla2xxx_check_true
,
1690 .tpg_alloc_fabric_acl
= tcm_qla2xxx_alloc_fabric_acl
,
1691 .tpg_release_fabric_acl
= tcm_qla2xxx_release_fabric_acl
,
1692 .tpg_get_inst_index
= tcm_qla2xxx_tpg_get_inst_index
,
1693 .new_cmd_map
= NULL
,
1694 .check_stop_free
= tcm_qla2xxx_check_stop_free
,
1695 .release_cmd
= tcm_qla2xxx_release_cmd
,
1696 .put_session
= tcm_qla2xxx_put_session
,
1697 .shutdown_session
= tcm_qla2xxx_shutdown_session
,
1698 .close_session
= tcm_qla2xxx_close_session
,
1699 .sess_get_index
= tcm_qla2xxx_sess_get_index
,
1700 .sess_get_initiator_sid
= NULL
,
1701 .write_pending
= tcm_qla2xxx_write_pending
,
1702 .write_pending_status
= tcm_qla2xxx_write_pending_status
,
1703 .set_default_node_attributes
= tcm_qla2xxx_set_default_node_attrs
,
1704 .get_task_tag
= tcm_qla2xxx_get_task_tag
,
1705 .get_cmd_state
= tcm_qla2xxx_get_cmd_state
,
1706 .queue_data_in
= tcm_qla2xxx_queue_data_in
,
1707 .queue_status
= tcm_qla2xxx_queue_status
,
1708 .queue_tm_rsp
= tcm_qla2xxx_queue_tm_rsp
,
1709 .get_fabric_sense_len
= tcm_qla2xxx_get_fabric_sense_len
,
1710 .set_fabric_sense_len
= tcm_qla2xxx_set_fabric_sense_len
,
1712 * Setup function pointers for generic logic in
1713 * target_core_fabric_configfs.c
1715 .fabric_make_wwn
= tcm_qla2xxx_make_lport
,
1716 .fabric_drop_wwn
= tcm_qla2xxx_drop_lport
,
1717 .fabric_make_tpg
= tcm_qla2xxx_make_tpg
,
1718 .fabric_drop_tpg
= tcm_qla2xxx_drop_tpg
,
1719 .fabric_post_link
= NULL
,
1720 .fabric_pre_unlink
= NULL
,
1721 .fabric_make_np
= NULL
,
1722 .fabric_drop_np
= NULL
,
1723 .fabric_make_nodeacl
= tcm_qla2xxx_make_nodeacl
,
1724 .fabric_drop_nodeacl
= tcm_qla2xxx_drop_nodeacl
,
1727 static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops
= {
1728 .get_fabric_name
= tcm_qla2xxx_npiv_get_fabric_name
,
1729 .get_fabric_proto_ident
= tcm_qla2xxx_get_fabric_proto_ident
,
1730 .tpg_get_wwn
= tcm_qla2xxx_npiv_get_fabric_wwn
,
1731 .tpg_get_tag
= tcm_qla2xxx_get_tag
,
1732 .tpg_get_default_depth
= tcm_qla2xxx_get_default_depth
,
1733 .tpg_get_pr_transport_id
= tcm_qla2xxx_get_pr_transport_id
,
1734 .tpg_get_pr_transport_id_len
= tcm_qla2xxx_get_pr_transport_id_len
,
1735 .tpg_parse_pr_out_transport_id
= tcm_qla2xxx_parse_pr_out_transport_id
,
1736 .tpg_check_demo_mode
= tcm_qla2xxx_check_false
,
1737 .tpg_check_demo_mode_cache
= tcm_qla2xxx_check_true
,
1738 .tpg_check_demo_mode_write_protect
= tcm_qla2xxx_check_true
,
1739 .tpg_check_prod_mode_write_protect
= tcm_qla2xxx_check_false
,
1740 .tpg_check_demo_mode_login_only
= tcm_qla2xxx_check_true
,
1741 .tpg_alloc_fabric_acl
= tcm_qla2xxx_alloc_fabric_acl
,
1742 .tpg_release_fabric_acl
= tcm_qla2xxx_release_fabric_acl
,
1743 .tpg_get_inst_index
= tcm_qla2xxx_tpg_get_inst_index
,
1744 .release_cmd
= tcm_qla2xxx_release_cmd
,
1745 .put_session
= tcm_qla2xxx_put_session
,
1746 .shutdown_session
= tcm_qla2xxx_shutdown_session
,
1747 .close_session
= tcm_qla2xxx_close_session
,
1748 .sess_get_index
= tcm_qla2xxx_sess_get_index
,
1749 .sess_get_initiator_sid
= NULL
,
1750 .write_pending
= tcm_qla2xxx_write_pending
,
1751 .write_pending_status
= tcm_qla2xxx_write_pending_status
,
1752 .set_default_node_attributes
= tcm_qla2xxx_set_default_node_attrs
,
1753 .get_task_tag
= tcm_qla2xxx_get_task_tag
,
1754 .get_cmd_state
= tcm_qla2xxx_get_cmd_state
,
1755 .queue_data_in
= tcm_qla2xxx_queue_data_in
,
1756 .queue_status
= tcm_qla2xxx_queue_status
,
1757 .queue_tm_rsp
= tcm_qla2xxx_queue_tm_rsp
,
1758 .get_fabric_sense_len
= tcm_qla2xxx_get_fabric_sense_len
,
1759 .set_fabric_sense_len
= tcm_qla2xxx_set_fabric_sense_len
,
1761 * Setup function pointers for generic logic in
1762 * target_core_fabric_configfs.c
1764 .fabric_make_wwn
= tcm_qla2xxx_npiv_make_lport
,
1765 .fabric_drop_wwn
= tcm_qla2xxx_npiv_drop_lport
,
1766 .fabric_make_tpg
= tcm_qla2xxx_npiv_make_tpg
,
1767 .fabric_drop_tpg
= tcm_qla2xxx_drop_tpg
,
1768 .fabric_post_link
= NULL
,
1769 .fabric_pre_unlink
= NULL
,
1770 .fabric_make_np
= NULL
,
1771 .fabric_drop_np
= NULL
,
1772 .fabric_make_nodeacl
= tcm_qla2xxx_make_nodeacl
,
1773 .fabric_drop_nodeacl
= tcm_qla2xxx_drop_nodeacl
,
1776 static int tcm_qla2xxx_register_configfs(void)
1778 struct target_fabric_configfs
*fabric
, *npiv_fabric
;
1781 pr_debug("TCM QLOGIC QLA2XXX fabric module %s on %s/%s on "
1782 UTS_RELEASE
"\n", TCM_QLA2XXX_VERSION
, utsname()->sysname
,
1783 utsname()->machine
);
1785 * Register the top level struct config_item_type with TCM core
1787 fabric
= target_fabric_configfs_init(THIS_MODULE
, "qla2xxx");
1788 if (IS_ERR(fabric
)) {
1789 pr_err("target_fabric_configfs_init() failed\n");
1790 return PTR_ERR(fabric
);
1793 * Setup fabric->tf_ops from our local tcm_qla2xxx_ops
1795 fabric
->tf_ops
= tcm_qla2xxx_ops
;
1797 * Setup default attribute lists for various fabric->tf_cit_tmpl
1799 TF_CIT_TMPL(fabric
)->tfc_wwn_cit
.ct_attrs
= tcm_qla2xxx_wwn_attrs
;
1800 TF_CIT_TMPL(fabric
)->tfc_tpg_base_cit
.ct_attrs
= tcm_qla2xxx_tpg_attrs
;
1801 TF_CIT_TMPL(fabric
)->tfc_tpg_attrib_cit
.ct_attrs
=
1802 tcm_qla2xxx_tpg_attrib_attrs
;
1803 TF_CIT_TMPL(fabric
)->tfc_tpg_param_cit
.ct_attrs
= NULL
;
1804 TF_CIT_TMPL(fabric
)->tfc_tpg_np_base_cit
.ct_attrs
= NULL
;
1805 TF_CIT_TMPL(fabric
)->tfc_tpg_nacl_base_cit
.ct_attrs
= NULL
;
1806 TF_CIT_TMPL(fabric
)->tfc_tpg_nacl_attrib_cit
.ct_attrs
= NULL
;
1807 TF_CIT_TMPL(fabric
)->tfc_tpg_nacl_auth_cit
.ct_attrs
= NULL
;
1808 TF_CIT_TMPL(fabric
)->tfc_tpg_nacl_param_cit
.ct_attrs
= NULL
;
1810 * Register the fabric for use within TCM
1812 ret
= target_fabric_configfs_register(fabric
);
1814 pr_err("target_fabric_configfs_register() failed for TCM_QLA2XXX\n");
1818 * Setup our local pointer to *fabric
1820 tcm_qla2xxx_fabric_configfs
= fabric
;
1821 pr_debug("TCM_QLA2XXX[0] - Set fabric -> tcm_qla2xxx_fabric_configfs\n");
1824 * Register the top level struct config_item_type for NPIV with TCM core
1826 npiv_fabric
= target_fabric_configfs_init(THIS_MODULE
, "qla2xxx_npiv");
1827 if (IS_ERR(npiv_fabric
)) {
1828 pr_err("target_fabric_configfs_init() failed\n");
1829 ret
= PTR_ERR(npiv_fabric
);
1833 * Setup fabric->tf_ops from our local tcm_qla2xxx_npiv_ops
1835 npiv_fabric
->tf_ops
= tcm_qla2xxx_npiv_ops
;
1837 * Setup default attribute lists for various npiv_fabric->tf_cit_tmpl
1839 TF_CIT_TMPL(npiv_fabric
)->tfc_wwn_cit
.ct_attrs
= tcm_qla2xxx_wwn_attrs
;
1840 TF_CIT_TMPL(npiv_fabric
)->tfc_tpg_base_cit
.ct_attrs
= NULL
;
1841 TF_CIT_TMPL(npiv_fabric
)->tfc_tpg_attrib_cit
.ct_attrs
= NULL
;
1842 TF_CIT_TMPL(npiv_fabric
)->tfc_tpg_param_cit
.ct_attrs
= NULL
;
1843 TF_CIT_TMPL(npiv_fabric
)->tfc_tpg_np_base_cit
.ct_attrs
= NULL
;
1844 TF_CIT_TMPL(npiv_fabric
)->tfc_tpg_nacl_base_cit
.ct_attrs
= NULL
;
1845 TF_CIT_TMPL(npiv_fabric
)->tfc_tpg_nacl_attrib_cit
.ct_attrs
= NULL
;
1846 TF_CIT_TMPL(npiv_fabric
)->tfc_tpg_nacl_auth_cit
.ct_attrs
= NULL
;
1847 TF_CIT_TMPL(npiv_fabric
)->tfc_tpg_nacl_param_cit
.ct_attrs
= NULL
;
1849 * Register the npiv_fabric for use within TCM
1851 ret
= target_fabric_configfs_register(npiv_fabric
);
1853 pr_err("target_fabric_configfs_register() failed for TCM_QLA2XXX\n");
1857 * Setup our local pointer to *npiv_fabric
1859 tcm_qla2xxx_npiv_fabric_configfs
= npiv_fabric
;
1860 pr_debug("TCM_QLA2XXX[0] - Set fabric -> tcm_qla2xxx_npiv_fabric_configfs\n");
1862 tcm_qla2xxx_free_wq
= alloc_workqueue("tcm_qla2xxx_free",
1864 if (!tcm_qla2xxx_free_wq
) {
1866 goto out_fabric_npiv
;
1869 tcm_qla2xxx_cmd_wq
= alloc_workqueue("tcm_qla2xxx_cmd", 0, 0);
1870 if (!tcm_qla2xxx_cmd_wq
) {
1878 destroy_workqueue(tcm_qla2xxx_free_wq
);
1880 target_fabric_configfs_deregister(tcm_qla2xxx_npiv_fabric_configfs
);
1882 target_fabric_configfs_deregister(tcm_qla2xxx_fabric_configfs
);
1886 static void tcm_qla2xxx_deregister_configfs(void)
1888 destroy_workqueue(tcm_qla2xxx_cmd_wq
);
1889 destroy_workqueue(tcm_qla2xxx_free_wq
);
1891 target_fabric_configfs_deregister(tcm_qla2xxx_fabric_configfs
);
1892 tcm_qla2xxx_fabric_configfs
= NULL
;
1893 pr_debug("TCM_QLA2XXX[0] - Cleared tcm_qla2xxx_fabric_configfs\n");
1895 target_fabric_configfs_deregister(tcm_qla2xxx_npiv_fabric_configfs
);
1896 tcm_qla2xxx_npiv_fabric_configfs
= NULL
;
1897 pr_debug("TCM_QLA2XXX[0] - Cleared tcm_qla2xxx_npiv_fabric_configfs\n");
1900 static int __init
tcm_qla2xxx_init(void)
1904 ret
= tcm_qla2xxx_register_configfs();
1911 static void __exit
tcm_qla2xxx_exit(void)
1913 tcm_qla2xxx_deregister_configfs();
1916 MODULE_DESCRIPTION("TCM QLA2XXX series NPIV enabled fabric driver");
1917 MODULE_LICENSE("GPL");
1918 module_init(tcm_qla2xxx_init
);
1919 module_exit(tcm_qla2xxx_exit
);