29 #include <linux/module.h>
31 #include <generated/utsrelease.h>
32 #include <linux/utsname.h>
34 #include <linux/list.h>
35 #include <linux/slab.h>
37 #include <linux/types.h>
38 #include <linux/string.h>
40 #include <linux/ctype.h>
41 #include <asm/unaligned.h>
42 #include <scsi/scsi.h>
75 static ssize_t tcm_qla2xxx_parse_wwn(
const char *
name,
u64 *wwn,
int strict)
87 if (c ==
'\n' && cp[1] ==
'\0')
89 if (strict && pos++ == 2 && byte++ < 7) {
98 if (strict && byte != 8)
106 nibble =
tolower(c) -
'a' + 10;
109 *wwn = (*wwn << 4) | nibble;
113 pr_debug(
"err %u len %zu pos %u byte %u\n",
114 err, cp - name, pos, byte);
118 static ssize_t tcm_qla2xxx_format_wwn(
char *
buf,
size_t len,
u64 wwn)
124 "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
125 b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7]);
128 static char *tcm_qla2xxx_get_fabric_name(
void)
136 static int tcm_qla2xxx_npiv_extract_wwn(
const char *
ns,
u64 *nm)
141 memset(wwn, 0,
sizeof(wwn));
144 for (i = 0, j = 0; i < 16; i++) {
149 j = (j << 4) | value;
159 *nm = wwn_to_u64(wwn);
167 static int tcm_qla2xxx_npiv_parse_wwn(
180 if (name[cnt-1] ==
'\n')
184 if ((cnt != (16+1+16)) || (name[16] !=
':'))
187 rc = tcm_qla2xxx_npiv_extract_wwn(&name[0], wwpn);
191 rc = tcm_qla2xxx_npiv_extract_wwn(&name[17], wwnn);
198 static ssize_t tcm_qla2xxx_npiv_format_wwn(
char *
buf,
size_t len,
206 "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x,"
207 "%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
208 b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7],
209 b2[0], b2[1], b2[2], b2[3], b2[4], b2[5], b2[6], b2[7]);
212 static char *tcm_qla2xxx_npiv_get_fabric_name(
void)
214 return "qla2xxx_npiv";
234 static char *tcm_qla2xxx_get_fabric_wwn(
struct se_portal_group *se_tpg)
243 static char *tcm_qla2xxx_npiv_get_fabric_wwn(
struct se_portal_group *se_tpg)
264 static u32 tcm_qla2xxx_get_pr_transport_id(
287 static u32 tcm_qla2xxx_get_pr_transport_id_len(
309 static char *tcm_qla2xxx_parse_pr_out_transport_id(
313 char **port_nexus_ptr)
339 static int tcm_qla2xxx_check_demo_mode_cache(
struct se_portal_group *se_tpg)
347 static int tcm_qla2xxx_check_demo_write_protect(
struct se_portal_group *se_tpg)
355 static int tcm_qla2xxx_check_prod_write_protect(
struct se_portal_group *se_tpg)
363 static struct se_node_acl *tcm_qla2xxx_alloc_fabric_acl(
370 pr_err(
"Unable to alocate struct tcm_qla2xxx_nacl\n");
377 static void tcm_qla2xxx_release_fabric_acl(
434 static int tcm_qla2xxx_check_stop_free(
struct se_cmd *
se_cmd)
442 static void tcm_qla2xxx_release_cmd(
struct se_cmd *
se_cmd)
457 static int tcm_qla2xxx_shutdown_session(
struct se_session *se_sess)
468 spin_unlock_irqrestore(&vha->
hw->hardware_lock, flags);
473 static void tcm_qla2xxx_close_session(
struct se_session *se_sess)
484 spin_unlock_irqrestore(&vha->
hw->hardware_lock, flags);
487 static u32 tcm_qla2xxx_sess_get_index(
struct se_session *se_sess)
517 static int tcm_qla2xxx_write_pending(
struct se_cmd *se_cmd)
535 static int tcm_qla2xxx_write_pending_status(
struct se_cmd *se_cmd)
555 static void tcm_qla2xxx_set_default_node_attrs(
struct se_node_acl *nacl)
560 static u32 tcm_qla2xxx_get_task_tag(
struct se_cmd *se_cmd)
568 static int tcm_qla2xxx_get_cmd_state(
struct se_cmd *se_cmd)
580 struct se_cmd *se_cmd = &cmd->
se_cmd;
590 pr_err(
"Unable to locate struct qla_tgt_sess from qla_tgt_cmd\n");
596 pr_err(
"Unable to locate active struct se_session\n");
634 static void tcm_qla2xxx_handle_data(
struct qla_tgt_cmd *cmd)
647 struct se_cmd *se_cmd = &mcmd->
se_cmd;
653 static int tcm_qla2xxx_queue_data_in(
struct se_cmd *se_cmd)
673 static int tcm_qla2xxx_queue_status(
struct se_cmd *se_cmd)
702 static int tcm_qla2xxx_queue_tm_rsp(
struct se_cmd *se_cmd)
708 pr_debug(
"queue_tm_rsp: mcmd: %p func: 0x%02x response: 0x%02x\n",
747 static void tcm_qla2xxx_clear_nacl_from_fcport_map(
struct qla_tgt_sess *sess)
761 WARN_ON(node && (node != se_nacl));
763 pr_debug(
"Removed from fcport_map: %p for WWNN: 0x%016LX, port_id: 0x%06x\n",
774 tcm_qla2xxx_clear_sess_lookup(lport, nacl, sess);
777 static void tcm_qla2xxx_release_session(
struct kref *
kref)
785 static void tcm_qla2xxx_put_session(
struct se_session *se_sess)
792 kref_put(&se_sess->
sess_kref, tcm_qla2xxx_release_session);
793 spin_unlock_irqrestore(&ha->hardware_lock, flags);
796 static void tcm_qla2xxx_put_sess(
struct qla_tgt_sess *sess)
798 tcm_qla2xxx_put_session(sess->
se_sess);
801 static void tcm_qla2xxx_shutdown_sess(
struct qla_tgt_sess *sess)
803 tcm_qla2xxx_shutdown_session(sess->
se_sess);
806 static struct se_node_acl *tcm_qla2xxx_make_nodeacl(
814 u32 qla2xxx_nexus_depth;
816 if (tcm_qla2xxx_parse_wwn(name, &wwnn, 1) < 0)
819 se_nacl_new = tcm_qla2xxx_alloc_fabric_acl(se_tpg);
823 qla2xxx_nexus_depth = 1;
830 name, qla2xxx_nexus_depth);
831 if (IS_ERR(se_nacl)) {
832 tcm_qla2xxx_release_fabric_acl(se_tpg, se_nacl_new);
845 static void tcm_qla2xxx_drop_nodeacl(
struct se_node_acl *se_acl)
857 #define DEF_QLA_TPG_ATTRIB(name) \
859 static ssize_t tcm_qla2xxx_tpg_attrib_show_##name( \
860 struct se_portal_group *se_tpg, \
863 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \
864 struct tcm_qla2xxx_tpg, se_tpg); \
866 return sprintf(page, "%u\n", QLA_TPG_ATTRIB(tpg)->name); \
869 static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \
870 struct se_portal_group *se_tpg, \
874 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \
875 struct tcm_qla2xxx_tpg, se_tpg); \
879 ret = kstrtoul(page, 0, &val); \
881 pr_err("kstrtoul() failed with" \
882 " ret: %d\n", ret); \
885 ret = tcm_qla2xxx_set_attrib_##name(tpg, val); \
887 return (!ret) ? count : -EINVAL; \
890 #define DEF_QLA_TPG_ATTR_BOOL(_name) \
892 static int tcm_qla2xxx_set_attrib_##_name( \
893 struct tcm_qla2xxx_tpg *tpg, \
896 struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \
898 if ((val != 0) && (val != 1)) { \
899 pr_err("Illegal boolean value %lu\n", val); \
907 #define QLA_TPG_ATTR(_name, _mode) \
908 TF_TPG_ATTRIB_ATTR(tcm_qla2xxx, _name, _mode);
939 &tcm_qla2xxx_tpg_attrib_generate_node_acls.attr,
940 &tcm_qla2xxx_tpg_attrib_cache_dynamic_acls.attr,
941 &tcm_qla2xxx_tpg_attrib_demo_mode_write_protect.attr,
942 &tcm_qla2xxx_tpg_attrib_prod_mode_write_protect.attr,
948 static ssize_t tcm_qla2xxx_tpg_show_enable(
959 static ssize_t tcm_qla2xxx_tpg_store_enable(
974 rc = kstrtoul(page, 0, &op);
976 pr_err(
"kstrtoul() returned %d\n", rc);
979 if ((op != 1) && (op != 0)) {
980 pr_err(
"Illegal value for tpg_enable: %lu\n", op);
988 if (!ha->
tgt.qla_tgt) {
989 pr_err(
"truct qla_hw_data *ha->tgt.qla_tgt is NULL\n");
1002 &tcm_qla2xxx_tpg_enable.attr,
1017 if (
strstr(name,
"tpgt_") != name)
1019 if (kstrtoul(name + 5, 10, &tpgt) || tpgt >
USHRT_MAX)
1023 pr_err(
"In non NPIV mode, a single TPG=1 is used for HW port mappings\n");
1029 pr_err(
"Unable to allocate struct tcm_qla2xxx_tpg\n");
1068 if (ha->
tgt.qla_tgt && !ha->
tgt.qla_tgt->tgt_stop)
1092 if (
strstr(name,
"tpgt_") != name)
1094 if (kstrtoul(name + 5, 10, &tpgt) || tpgt >
USHRT_MAX)
1099 pr_err(
"Unable to allocate struct tcm_qla2xxx_tpg\n");
1117 static struct qla_tgt_sess *tcm_qla2xxx_find_sess_by_s_id(
1127 lport = ha->
tgt.target_lport_ptr;
1129 pr_err(
"Unable to locate struct tcm_qla2xxx_lport\n");
1134 key = (((
unsigned long)s_id[0] << 16) |
1135 ((
unsigned long)s_id[1] << 8) |
1136 (
unsigned long)s_id[2]);
1137 pr_debug(
"find_sess_by_s_id: 0x%06x\n", key);
1141 pr_debug(
"Unable to locate s_id: 0x%06x\n", key);
1144 pr_debug(
"find_sess_by_s_id: located se_nacl: %p, initiatorname: %s\n",
1149 pr_err(
"Unable to locate struct qla_tgt_sess\n");
1159 static void tcm_qla2xxx_set_sess_by_s_id(
1171 key = (((
unsigned long)s_id[0] << 16) |
1172 ((
unsigned long)s_id[1] << 8) |
1173 (
unsigned long)s_id[2]);
1174 pr_debug(
"set_sess_by_s_id: %06x\n", key);
1179 pr_debug(
"Setting up new fc_port entry to new_se_nacl\n");
1187 pr_debug(
"Wiping nonexisting fc_port entry\n");
1190 qla_tgt_sess->
se_sess = se_sess;
1196 if (new_se_nacl ==
NULL) {
1197 pr_debug(
"Clearing existing nacl->qla_tgt_sess and fc_port entry\n");
1202 pr_debug(
"Replacing existing nacl->qla_tgt_sess and fc_port entry\n");
1204 qla_tgt_sess->
se_sess = se_sess;
1209 if (new_se_nacl ==
NULL) {
1210 pr_debug(
"Clearing existing fc_port entry\n");
1215 pr_debug(
"Replacing existing fc_port entry w/o active nacl->qla_tgt_sess\n");
1217 qla_tgt_sess->
se_sess = se_sess;
1220 pr_debug(
"Setup nacl->qla_tgt_sess %p by s_id for se_nacl: %p, initiatorname: %s\n",
1227 static struct qla_tgt_sess *tcm_qla2xxx_find_sess_by_loop_id(
1237 lport = ha->
tgt.target_lport_ptr;
1239 pr_err(
"Unable to locate struct tcm_qla2xxx_lport\n");
1244 pr_debug(
"find_sess_by_loop_id: Using loop_id: 0x%04x\n", loop_id);
1249 pr_debug(
"Unable to locate se_nacl by loop_id: 0x%04x\n",
1257 pr_err(
"Unable to locate struct qla_tgt_sess\n");
1267 static void tcm_qla2xxx_set_sess_by_loop_id(
1272 struct qla_tgt_sess *qla_tgt_sess,
1278 pr_debug(
"set_sess_by_loop_id: Using loop_id: 0x%04x\n", loop_id);
1283 saved_nacl = fc_loopid->
se_nacl;
1285 pr_debug(
"Setting up new fc_loopid->se_nacl to new_se_nacl\n");
1286 fc_loopid->
se_nacl = new_se_nacl;
1287 if (qla_tgt_sess->
se_sess != se_sess)
1288 qla_tgt_sess->
se_sess = se_sess;
1295 if (new_se_nacl ==
NULL) {
1296 pr_debug(
"Clearing nacl->qla_tgt_sess and fc_loopid->se_nacl\n");
1302 pr_debug(
"Replacing existing nacl->qla_tgt_sess and fc_loopid->se_nacl\n");
1303 fc_loopid->
se_nacl = new_se_nacl;
1304 if (qla_tgt_sess->
se_sess != se_sess)
1305 qla_tgt_sess->
se_sess = se_sess;
1311 if (new_se_nacl ==
NULL) {
1312 pr_debug(
"Clearing fc_loopid->se_nacl\n");
1317 pr_debug(
"Replacing existing fc_loopid->se_nacl w/o active nacl->qla_tgt_sess\n");
1318 fc_loopid->
se_nacl = new_se_nacl;
1319 if (qla_tgt_sess->
se_sess != se_sess)
1320 qla_tgt_sess->
se_sess = se_sess;
1324 pr_debug(
"Setup nacl->qla_tgt_sess %p by loop_id for se_nacl: %p, initiatorname: %s\n",
1335 unsigned char be_sid[3];
1337 be_sid[0] = sess->
s_id.
b.domain;
1338 be_sid[1] = sess->
s_id.
b.area;
1339 be_sid[2] = sess->
s_id.
b.al_pa;
1341 tcm_qla2xxx_set_sess_by_s_id(lport,
NULL, nacl, se_sess,
1343 tcm_qla2xxx_set_sess_by_loop_id(lport,
NULL, nacl, se_sess,
1347 static void tcm_qla2xxx_free_session(
struct qla_tgt_sess *sess)
1360 pr_err(
"struct qla_tgt_sess->se_sess is NULL\n");
1367 lport = ha->
tgt.target_lport_ptr;
1369 pr_err(
"Unable to locate struct tcm_qla2xxx_lport\n");
1383 static int tcm_qla2xxx_check_initiator_node_acl(
1385 unsigned char *fc_wwpn,
1397 struct qla_tgt_sess *sess = qla_tgt_sess;
1399 unsigned long flags;
1401 lport = ha->
tgt.target_lport_ptr;
1403 pr_err(
"Unable to locate struct tcm_qla2xxx_lport\n");
1412 pr_err(
"Unable to lcoate struct tcm_qla2xxx_lport->tpg_1\n");
1418 if (IS_ERR(se_sess)) {
1419 pr_err(
"Unable to initialize struct se_session\n");
1420 return PTR_ERR(se_sess);
1426 memset(&port_name, 0, 36);
1427 snprintf(port_name, 36,
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
1428 fc_wwpn[0], fc_wwpn[1], fc_wwpn[2], fc_wwpn[3], fc_wwpn[4],
1429 fc_wwpn[5], fc_wwpn[6], fc_wwpn[7]);
1447 tcm_qla2xxx_set_sess_by_s_id(lport, se_nacl, nacl, se_sess,
1448 qla_tgt_sess, s_id);
1449 tcm_qla2xxx_set_sess_by_loop_id(lport, se_nacl, nacl, se_sess,
1450 qla_tgt_sess, loop_id);
1451 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1460 static void tcm_qla2xxx_update_sess(
struct qla_tgt_sess *sess,
port_id_t s_id,
1473 pr_info(
"Updating session %p from port %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x loop_id %d -> %d s_id %x:%x:%x -> %x:%x:%x\n",
1481 s_id.
b.domain, s_id.
b.area, s_id.
b.al_pa);
1483 if (sess->
loop_id != loop_id) {
1501 key = (((
u32) sess->
s_id.
b.domain << 16) |
1507 "Found wrong se_nacl when updating s_id %x:%x:%x\n",
1510 WARN(1,
"No lport_fcport_map entry for s_id %x:%x:%x\n",
1513 key = (((
u32) s_id.
b.domain << 16) |
1514 ((
u32) s_id.
b.area << 8) |
1515 ((
u32) s_id.
b.al_pa));
1518 WARN(1,
"Already have lport_fcport_map entry for s_id %x:%x:%x\n",
1519 s_id.
b.domain, s_id.
b.area, s_id.
b.al_pa);
1536 .handle_cmd = tcm_qla2xxx_handle_cmd,
1537 .handle_data = tcm_qla2xxx_handle_data,
1538 .handle_tmr = tcm_qla2xxx_handle_tmr,
1539 .free_cmd = tcm_qla2xxx_free_cmd,
1540 .free_mcmd = tcm_qla2xxx_free_mcmd,
1541 .free_session = tcm_qla2xxx_free_session,
1542 .update_sess = tcm_qla2xxx_update_sess,
1543 .check_initiator_node_acl = tcm_qla2xxx_check_initiator_node_acl,
1544 .find_sess_by_s_id = tcm_qla2xxx_find_sess_by_s_id,
1545 .find_sess_by_loop_id = tcm_qla2xxx_find_sess_by_loop_id,
1546 .clear_nacl_from_fcport_map = tcm_qla2xxx_clear_nacl_from_fcport_map,
1547 .put_sess = tcm_qla2xxx_put_sess,
1548 .shutdown_sess = tcm_qla2xxx_shutdown_sess,
1557 pr_err(
"Unable to initialize lport->lport_fcport_map btree\n");
1564 pr_err(
"Unable to allocate lport->lport_loopid_map of %zu bytes\n",
1571 pr_debug(
"qla2xxx: Allocated lport_loopid_map of %zu bytes\n",
1576 static int tcm_qla2xxx_lport_register_cb(
struct scsi_qla_host *vha)
1590 static struct se_wwn *tcm_qla2xxx_make_lport(
1599 if (tcm_qla2xxx_parse_wwn(name, &wwpn, 1) < 0)
1604 pr_err(
"Unable to allocate struct tcm_qla2xxx_lport\n");
1612 ret = tcm_qla2xxx_init_lport(lport);
1617 tcm_qla2xxx_lport_register_cb, lport);
1627 return ERR_PTR(ret);
1630 static void tcm_qla2xxx_drop_lport(
struct se_wwn *wwn)
1644 if (ha->
tgt.qla_tgt && !ha->
tgt.qla_tgt->tgt_stopped)
1651 btree_remove32(&lport->lport_fcport_map, key);
1652 btree_destroy32(&lport->lport_fcport_map);
1656 static
struct se_wwn *tcm_qla2xxx_npiv_make_lport(
1662 u64 npiv_wwpn, npiv_wwnn;
1665 if (tcm_qla2xxx_npiv_parse_wwn(name,
strlen(name)+1,
1666 &npiv_wwpn, &npiv_wwnn) < 0)
1671 pr_err(
"Unable to allocate struct tcm_qla2xxx_lport for NPIV\n");
1688 return ERR_PTR(ret);
1691 static void tcm_qla2xxx_npiv_drop_lport(
struct se_wwn *wwn)
1707 static ssize_t tcm_qla2xxx_wwn_show_attr_version(
1712 "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on "
1720 &tcm_qla2xxx_wwn_version.attr,
1725 .get_fabric_name = tcm_qla2xxx_get_fabric_name,
1726 .get_fabric_proto_ident = tcm_qla2xxx_get_fabric_proto_ident,
1727 .tpg_get_wwn = tcm_qla2xxx_get_fabric_wwn,
1728 .tpg_get_tag = tcm_qla2xxx_get_tag,
1729 .tpg_get_default_depth = tcm_qla2xxx_get_default_depth,
1730 .tpg_get_pr_transport_id = tcm_qla2xxx_get_pr_transport_id,
1731 .tpg_get_pr_transport_id_len = tcm_qla2xxx_get_pr_transport_id_len,
1732 .tpg_parse_pr_out_transport_id = tcm_qla2xxx_parse_pr_out_transport_id,
1733 .tpg_check_demo_mode = tcm_qla2xxx_check_demo_mode,
1734 .tpg_check_demo_mode_cache = tcm_qla2xxx_check_demo_mode_cache,
1735 .tpg_check_demo_mode_write_protect =
1736 tcm_qla2xxx_check_demo_write_protect,
1737 .tpg_check_prod_mode_write_protect =
1738 tcm_qla2xxx_check_prod_write_protect,
1739 .tpg_check_demo_mode_login_only = tcm_qla2xxx_check_true,
1740 .tpg_alloc_fabric_acl = tcm_qla2xxx_alloc_fabric_acl,
1741 .tpg_release_fabric_acl = tcm_qla2xxx_release_fabric_acl,
1742 .tpg_get_inst_index = tcm_qla2xxx_tpg_get_inst_index,
1743 .check_stop_free = tcm_qla2xxx_check_stop_free,
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,
1762 .fabric_make_wwn = tcm_qla2xxx_make_lport,
1763 .fabric_drop_wwn = tcm_qla2xxx_drop_lport,
1764 .fabric_make_tpg = tcm_qla2xxx_make_tpg,
1765 .fabric_drop_tpg = tcm_qla2xxx_drop_tpg,
1766 .fabric_post_link =
NULL,
1767 .fabric_pre_unlink =
NULL,
1768 .fabric_make_np =
NULL,
1769 .fabric_drop_np =
NULL,
1770 .fabric_make_nodeacl = tcm_qla2xxx_make_nodeacl,
1771 .fabric_drop_nodeacl = tcm_qla2xxx_drop_nodeacl,
1775 .get_fabric_name = tcm_qla2xxx_npiv_get_fabric_name,
1776 .get_fabric_proto_ident = tcm_qla2xxx_get_fabric_proto_ident,
1777 .tpg_get_wwn = tcm_qla2xxx_npiv_get_fabric_wwn,
1778 .tpg_get_tag = tcm_qla2xxx_get_tag,
1779 .tpg_get_default_depth = tcm_qla2xxx_get_default_depth,
1780 .tpg_get_pr_transport_id = tcm_qla2xxx_get_pr_transport_id,
1781 .tpg_get_pr_transport_id_len = tcm_qla2xxx_get_pr_transport_id_len,
1782 .tpg_parse_pr_out_transport_id = tcm_qla2xxx_parse_pr_out_transport_id,
1783 .tpg_check_demo_mode = tcm_qla2xxx_check_false,
1784 .tpg_check_demo_mode_cache = tcm_qla2xxx_check_true,
1785 .tpg_check_demo_mode_write_protect = tcm_qla2xxx_check_true,
1786 .tpg_check_prod_mode_write_protect = tcm_qla2xxx_check_false,
1787 .tpg_check_demo_mode_login_only = tcm_qla2xxx_check_true,
1788 .tpg_alloc_fabric_acl = tcm_qla2xxx_alloc_fabric_acl,
1789 .tpg_release_fabric_acl = tcm_qla2xxx_release_fabric_acl,
1790 .tpg_get_inst_index = tcm_qla2xxx_tpg_get_inst_index,
1791 .release_cmd = tcm_qla2xxx_release_cmd,
1792 .put_session = tcm_qla2xxx_put_session,
1793 .shutdown_session = tcm_qla2xxx_shutdown_session,
1794 .close_session = tcm_qla2xxx_close_session,
1795 .sess_get_index = tcm_qla2xxx_sess_get_index,
1796 .sess_get_initiator_sid =
NULL,
1797 .write_pending = tcm_qla2xxx_write_pending,
1798 .write_pending_status = tcm_qla2xxx_write_pending_status,
1799 .set_default_node_attributes = tcm_qla2xxx_set_default_node_attrs,
1800 .get_task_tag = tcm_qla2xxx_get_task_tag,
1801 .get_cmd_state = tcm_qla2xxx_get_cmd_state,
1802 .queue_data_in = tcm_qla2xxx_queue_data_in,
1803 .queue_status = tcm_qla2xxx_queue_status,
1804 .queue_tm_rsp = tcm_qla2xxx_queue_tm_rsp,
1809 .fabric_make_wwn = tcm_qla2xxx_npiv_make_lport,
1810 .fabric_drop_wwn = tcm_qla2xxx_npiv_drop_lport,
1811 .fabric_make_tpg = tcm_qla2xxx_npiv_make_tpg,
1812 .fabric_drop_tpg = tcm_qla2xxx_drop_tpg,
1813 .fabric_post_link =
NULL,
1814 .fabric_pre_unlink =
NULL,
1815 .fabric_make_np =
NULL,
1816 .fabric_drop_np =
NULL,
1817 .fabric_make_nodeacl = tcm_qla2xxx_make_nodeacl,
1818 .fabric_drop_nodeacl = tcm_qla2xxx_drop_nodeacl,
1821 static int tcm_qla2xxx_register_configfs(
void)
1826 pr_debug(
"TCM QLOGIC QLA2XXX fabric module %s on %s/%s on "
1833 if (IS_ERR(fabric)) {
1834 pr_err(
"target_fabric_configfs_init() failed\n");
1835 return PTR_ERR(fabric);
1840 fabric->
tf_ops = tcm_qla2xxx_ops;
1844 TF_CIT_TMPL(fabric)->tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs;
1845 TF_CIT_TMPL(fabric)->tfc_tpg_base_cit.ct_attrs = tcm_qla2xxx_tpg_attrs;
1846 TF_CIT_TMPL(fabric)->tfc_tpg_attrib_cit.ct_attrs =
1847 tcm_qla2xxx_tpg_attrib_attrs;
1859 pr_err(
"target_fabric_configfs_register() failed for TCM_QLA2XXX\n");
1865 tcm_qla2xxx_fabric_configfs = fabric;
1866 pr_debug(
"TCM_QLA2XXX[0] - Set fabric -> tcm_qla2xxx_fabric_configfs\n");
1872 if (IS_ERR(npiv_fabric)) {
1873 pr_err(
"target_fabric_configfs_init() failed\n");
1874 ret = PTR_ERR(npiv_fabric);
1880 npiv_fabric->
tf_ops = tcm_qla2xxx_npiv_ops;
1884 TF_CIT_TMPL(npiv_fabric)->tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs;
1898 pr_err(
"target_fabric_configfs_register() failed for TCM_QLA2XXX\n");
1904 tcm_qla2xxx_npiv_fabric_configfs = npiv_fabric;
1905 pr_debug(
"TCM_QLA2XXX[0] - Set fabric -> tcm_qla2xxx_npiv_fabric_configfs\n");
1909 if (!tcm_qla2xxx_free_wq) {
1911 goto out_fabric_npiv;
1915 if (!tcm_qla2xxx_cmd_wq) {
1931 static void tcm_qla2xxx_deregister_configfs(
void)
1937 tcm_qla2xxx_fabric_configfs =
NULL;
1938 pr_debug(
"TCM_QLA2XXX[0] - Cleared tcm_qla2xxx_fabric_configfs\n");
1941 tcm_qla2xxx_npiv_fabric_configfs =
NULL;
1942 pr_debug(
"TCM_QLA2XXX[0] - Cleared tcm_qla2xxx_npiv_fabric_configfs\n");
1945 static int __init tcm_qla2xxx_init(
void)
1949 ret = tcm_qla2xxx_register_configfs();
1956 static void __exit tcm_qla2xxx_exit(
void)
1958 tcm_qla2xxx_deregister_configfs();