diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2016-01-09 09:47:58 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2016-03-11 00:45:31 -0500 |
commit | 1b655b19e28b70a45db2e30b5a864af503afff89 (patch) | |
tree | 90529ef2b5b788a9cfd3b72b3cdda43b344be5d2 | |
parent | 65ea789869a519b63382418bb38ba61b62ec4b4c (diff) |
tcm_qla2xxx: Convert to target_alloc_session usage
This patch converts existing qla2xxx target mode assignment
of struct qla_tgt_sess related sid + loop_id values to use
a callback via the new target_alloc_session API caller.
Cc: Himanshu Madhani <himanshu.madhani@qlogic.com>
Cc: Quinn Tran <quinn.tran@qlogic.com>
Cc: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r-- | drivers/scsi/qla2xxx/qla_target.c | 8 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/qla_target.h | 2 | ||||
-rw-r--r-- | drivers/scsi/qla2xxx/tcm_qla2xxx.c | 79 |
3 files changed, 43 insertions, 46 deletions
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index ee967becd257..98d313668644 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c | |||
@@ -879,7 +879,6 @@ static struct qla_tgt_sess *qlt_create_sess( | |||
879 | struct qla_hw_data *ha = vha->hw; | 879 | struct qla_hw_data *ha = vha->hw; |
880 | struct qla_tgt_sess *sess; | 880 | struct qla_tgt_sess *sess; |
881 | unsigned long flags; | 881 | unsigned long flags; |
882 | unsigned char be_sid[3]; | ||
883 | 882 | ||
884 | /* Check to avoid double sessions */ | 883 | /* Check to avoid double sessions */ |
885 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); | 884 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); |
@@ -948,17 +947,14 @@ static struct qla_tgt_sess *qlt_create_sess( | |||
948 | "Adding sess %p to tgt %p via ->check_initiator_node_acl()\n", | 947 | "Adding sess %p to tgt %p via ->check_initiator_node_acl()\n", |
949 | sess, vha->vha_tgt.qla_tgt); | 948 | sess, vha->vha_tgt.qla_tgt); |
950 | 949 | ||
951 | be_sid[0] = sess->s_id.b.domain; | ||
952 | be_sid[1] = sess->s_id.b.area; | ||
953 | be_sid[2] = sess->s_id.b.al_pa; | ||
954 | /* | 950 | /* |
955 | * Determine if this fc_port->port_name is allowed to access | 951 | * Determine if this fc_port->port_name is allowed to access |
956 | * target mode using explict NodeACLs+MappedLUNs, or using | 952 | * target mode using explict NodeACLs+MappedLUNs, or using |
957 | * TPG demo mode. If this is successful a target mode FC nexus | 953 | * TPG demo mode. If this is successful a target mode FC nexus |
958 | * is created. | 954 | * is created. |
959 | */ | 955 | */ |
960 | if (ha->tgt.tgt_ops->check_initiator_node_acl(vha, | 956 | if (ha->tgt.tgt_ops->check_initiator_node_acl(vha, &fcport->port_name[0], |
961 | &fcport->port_name[0], sess, &be_sid[0], fcport->loop_id) < 0) { | 957 | sess)) { |
962 | kfree(sess); | 958 | kfree(sess); |
963 | return NULL; | 959 | return NULL; |
964 | } | 960 | } |
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index 22a6a767fe07..d857feeb6514 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h | |||
@@ -731,7 +731,7 @@ struct qla_tgt_func_tmpl { | |||
731 | void (*free_session)(struct qla_tgt_sess *); | 731 | void (*free_session)(struct qla_tgt_sess *); |
732 | 732 | ||
733 | int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *, | 733 | int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *, |
734 | void *, uint8_t *, uint16_t); | 734 | struct qla_tgt_sess *); |
735 | void (*update_sess)(struct qla_tgt_sess *, port_id_t, uint16_t, bool); | 735 | void (*update_sess)(struct qla_tgt_sess *, port_id_t, uint16_t, bool); |
736 | struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *, | 736 | struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *, |
737 | const uint16_t); | 737 | const uint16_t); |
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 1808a01cfb7e..c1461d225f08 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c | |||
@@ -1406,6 +1406,39 @@ static void tcm_qla2xxx_free_session(struct qla_tgt_sess *sess) | |||
1406 | transport_deregister_session(sess->se_sess); | 1406 | transport_deregister_session(sess->se_sess); |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | static int tcm_qla2xxx_session_cb(struct se_portal_group *se_tpg, | ||
1410 | struct se_session *se_sess, void *p) | ||
1411 | { | ||
1412 | struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, | ||
1413 | struct tcm_qla2xxx_tpg, se_tpg); | ||
1414 | struct tcm_qla2xxx_lport *lport = tpg->lport; | ||
1415 | struct qla_hw_data *ha = lport->qla_vha->hw; | ||
1416 | struct se_node_acl *se_nacl = se_sess->se_node_acl; | ||
1417 | struct tcm_qla2xxx_nacl *nacl = container_of(se_nacl, | ||
1418 | struct tcm_qla2xxx_nacl, se_node_acl); | ||
1419 | struct qla_tgt_sess *qlat_sess = p; | ||
1420 | uint16_t loop_id = qlat_sess->loop_id; | ||
1421 | unsigned long flags; | ||
1422 | unsigned char be_sid[3]; | ||
1423 | |||
1424 | be_sid[0] = qlat_sess->s_id.b.domain; | ||
1425 | be_sid[1] = qlat_sess->s_id.b.area; | ||
1426 | be_sid[2] = qlat_sess->s_id.b.al_pa; | ||
1427 | |||
1428 | /* | ||
1429 | * And now setup se_nacl and session pointers into HW lport internal | ||
1430 | * mappings for fabric S_ID and LOOP_ID. | ||
1431 | */ | ||
1432 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); | ||
1433 | tcm_qla2xxx_set_sess_by_s_id(lport, se_nacl, nacl, | ||
1434 | se_sess, qlat_sess, be_sid); | ||
1435 | tcm_qla2xxx_set_sess_by_loop_id(lport, se_nacl, nacl, | ||
1436 | se_sess, qlat_sess, loop_id); | ||
1437 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); | ||
1438 | |||
1439 | return 0; | ||
1440 | } | ||
1441 | |||
1409 | /* | 1442 | /* |
1410 | * Called via qlt_create_sess():ha->qla2x_tmpl->check_initiator_node_acl() | 1443 | * Called via qlt_create_sess():ha->qla2x_tmpl->check_initiator_node_acl() |
1411 | * to locate struct se_node_acl | 1444 | * to locate struct se_node_acl |
@@ -1413,20 +1446,13 @@ static void tcm_qla2xxx_free_session(struct qla_tgt_sess *sess) | |||
1413 | static int tcm_qla2xxx_check_initiator_node_acl( | 1446 | static int tcm_qla2xxx_check_initiator_node_acl( |
1414 | scsi_qla_host_t *vha, | 1447 | scsi_qla_host_t *vha, |
1415 | unsigned char *fc_wwpn, | 1448 | unsigned char *fc_wwpn, |
1416 | void *qla_tgt_sess, | 1449 | struct qla_tgt_sess *qlat_sess) |
1417 | uint8_t *s_id, | ||
1418 | uint16_t loop_id) | ||
1419 | { | 1450 | { |
1420 | struct qla_hw_data *ha = vha->hw; | 1451 | struct qla_hw_data *ha = vha->hw; |
1421 | struct tcm_qla2xxx_lport *lport; | 1452 | struct tcm_qla2xxx_lport *lport; |
1422 | struct tcm_qla2xxx_tpg *tpg; | 1453 | struct tcm_qla2xxx_tpg *tpg; |
1423 | struct tcm_qla2xxx_nacl *nacl; | ||
1424 | struct se_portal_group *se_tpg; | ||
1425 | struct se_node_acl *se_nacl; | ||
1426 | struct se_session *se_sess; | 1454 | struct se_session *se_sess; |
1427 | struct qla_tgt_sess *sess = qla_tgt_sess; | ||
1428 | unsigned char port_name[36]; | 1455 | unsigned char port_name[36]; |
1429 | unsigned long flags; | ||
1430 | int num_tags = (ha->cur_fw_xcb_count) ? ha->cur_fw_xcb_count : | 1456 | int num_tags = (ha->cur_fw_xcb_count) ? ha->cur_fw_xcb_count : |
1431 | TCM_QLA2XXX_DEFAULT_TAGS; | 1457 | TCM_QLA2XXX_DEFAULT_TAGS; |
1432 | 1458 | ||
@@ -1444,15 +1470,6 @@ static int tcm_qla2xxx_check_initiator_node_acl( | |||
1444 | pr_err("Unable to lcoate struct tcm_qla2xxx_lport->tpg_1\n"); | 1470 | pr_err("Unable to lcoate struct tcm_qla2xxx_lport->tpg_1\n"); |
1445 | return -EINVAL; | 1471 | return -EINVAL; |
1446 | } | 1472 | } |
1447 | se_tpg = &tpg->se_tpg; | ||
1448 | |||
1449 | se_sess = transport_init_session_tags(num_tags, | ||
1450 | sizeof(struct qla_tgt_cmd), | ||
1451 | TARGET_PROT_ALL); | ||
1452 | if (IS_ERR(se_sess)) { | ||
1453 | pr_err("Unable to initialize struct se_session\n"); | ||
1454 | return PTR_ERR(se_sess); | ||
1455 | } | ||
1456 | /* | 1473 | /* |
1457 | * Format the FCP Initiator port_name into colon seperated values to | 1474 | * Format the FCP Initiator port_name into colon seperated values to |
1458 | * match the format by tcm_qla2xxx explict ConfigFS NodeACLs. | 1475 | * match the format by tcm_qla2xxx explict ConfigFS NodeACLs. |
@@ -1463,28 +1480,12 @@ static int tcm_qla2xxx_check_initiator_node_acl( | |||
1463 | * Locate our struct se_node_acl either from an explict NodeACL created | 1480 | * Locate our struct se_node_acl either from an explict NodeACL created |
1464 | * via ConfigFS, or via running in TPG demo mode. | 1481 | * via ConfigFS, or via running in TPG demo mode. |
1465 | */ | 1482 | */ |
1466 | se_sess->se_node_acl = core_tpg_check_initiator_node_acl(se_tpg, | 1483 | se_sess = target_alloc_session(&tpg->se_tpg, num_tags, |
1467 | port_name); | 1484 | sizeof(struct qla_tgt_cmd), |
1468 | if (!se_sess->se_node_acl) { | 1485 | TARGET_PROT_ALL, port_name, |
1469 | transport_free_session(se_sess); | 1486 | qlat_sess, tcm_qla2xxx_session_cb); |
1470 | return -EINVAL; | 1487 | if (IS_ERR(se_sess)) |
1471 | } | 1488 | return PTR_ERR(se_sess); |
1472 | se_nacl = se_sess->se_node_acl; | ||
1473 | nacl = container_of(se_nacl, struct tcm_qla2xxx_nacl, se_node_acl); | ||
1474 | /* | ||
1475 | * And now setup the new se_nacl and session pointers into our HW lport | ||
1476 | * mappings for fabric S_ID and LOOP_ID. | ||
1477 | */ | ||
1478 | spin_lock_irqsave(&ha->tgt.sess_lock, flags); | ||
1479 | tcm_qla2xxx_set_sess_by_s_id(lport, se_nacl, nacl, se_sess, | ||
1480 | qla_tgt_sess, s_id); | ||
1481 | tcm_qla2xxx_set_sess_by_loop_id(lport, se_nacl, nacl, se_sess, | ||
1482 | qla_tgt_sess, loop_id); | ||
1483 | spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); | ||
1484 | /* | ||
1485 | * Finally register the new FC Nexus with TCM | ||
1486 | */ | ||
1487 | transport_register_session(se_nacl->se_tpg, se_nacl, se_sess, sess); | ||
1488 | 1489 | ||
1489 | return 0; | 1490 | return 0; |
1490 | } | 1491 | } |