target: change core_tpg_register prototype
authorChristoph Hellwig <hch@lst.de>
Fri, 1 May 2015 15:47:56 +0000 (17:47 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Sun, 31 May 2015 05:42:27 +0000 (22:42 -0700)
Remove the unneeded fabric_ptr argument, and change the type argument
to pass in a SPC protocol identifier.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
14 files changed:
Documentation/target/tcm_mod_builder.py
drivers/infiniband/ulp/srpt/ib_srpt.c
drivers/scsi/qla2xxx/tcm_qla2xxx.c
drivers/target/iscsi/iscsi_target_configfs.c
drivers/target/iscsi/iscsi_target_tpg.c
drivers/target/loopback/tcm_loop.c
drivers/target/sbp/sbp_target.c
drivers/target/target_core_tpg.c
drivers/target/tcm_fc/tfc_conf.c
drivers/usb/gadget/legacy/tcm_usb_gadget.c
drivers/vhost/scsi.c
drivers/xen/xen-scsiback.c
include/target/target_core_base.h
include/target/target_core_fabric.h

index 07e7ef3d742999f345bf7e1b32efd4c06e9e5484..b04846e985d4f5ca08025a5f79636cd2b3137ba1 100755 (executable)
@@ -238,8 +238,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
        buf += "        tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n"
        buf += "        tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n"
        buf += "        ret = core_tpg_register(&" + fabric_mod_name + "_ops, wwn,\n"
-       buf += "                                &tpg->se_tpg, tpg,\n"
-       buf += "                                TRANSPORT_TPG_TYPE_NORMAL);\n"
+       buf += "                                &tpg->se_tpg, SCSI_PROTOCOL_SAS);\n"
        buf += "        if (ret < 0) {\n"
        buf += "                kfree(tpg);\n"
        buf += "                return NULL;\n"
index 38e51f4a17de7c72508a10b36eeac9d34e241f9e..8eed6089c5d7e69a223739806e0656d9c35275a6 100644 (file)
@@ -3791,7 +3791,7 @@ static struct se_portal_group *srpt_make_tpg(struct se_wwn *wwn,
 
        /* Initialize sport->port_wwn and sport->port_tpg_1 */
        res = core_tpg_register(&srpt_template, &sport->port_wwn,
-                       &sport->port_tpg_1, sport, TRANSPORT_TPG_TYPE_NORMAL);
+                       &sport->port_tpg_1, SCSI_PROTOCOL_SRP);
        if (res)
                return ERR_PTR(res);
 
index cb376e5198d0ca418ef792b934b3fc61239510e3..30cbfa6dc3e6a3bdef385ddf0fe1ffaeab3be6dd 100644 (file)
@@ -1113,8 +1113,8 @@ static struct se_portal_group *tcm_qla2xxx_make_tpg(
        tpg->tpg_attrib.cache_dynamic_acls = 1;
        tpg->tpg_attrib.demo_mode_login_only = 1;
 
-       ret = core_tpg_register(&tcm_qla2xxx_ops, wwn,
-                               &tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);
+       ret = core_tpg_register(&tcm_qla2xxx_ops, wwn, &tpg->se_tpg,
+                               SCSI_PROTOCOL_FCP);
        if (ret < 0) {
                kfree(tpg);
                return NULL;
@@ -1233,8 +1233,8 @@ static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg(
        tpg->tpg_attrib.cache_dynamic_acls = 1;
        tpg->tpg_attrib.demo_mode_login_only = 1;
 
-       ret = core_tpg_register(&tcm_qla2xxx_npiv_ops, wwn,
-                               &tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);
+       ret = core_tpg_register(&tcm_qla2xxx_npiv_ops, wwn, &tpg->se_tpg,
+                               SCSI_PROTOCOL_FCP);
        if (ret < 0) {
                kfree(tpg);
                return NULL;
index 03b2e15c1b6c7d6644fdaa01b1d657013608c6b3..0d5d88817a478b41e1bbed750c9602383991d13c 100644 (file)
@@ -1421,7 +1421,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg(
                return NULL;
 
        ret = core_tpg_register(&iscsi_ops, wwn, &tpg->tpg_se_tpg,
-                               tpg, TRANSPORT_TPG_TYPE_NORMAL);
+                               SCSI_PROTOCOL_ISCSI);
        if (ret < 0)
                return NULL;
 
index 5e3295fe404d7cc93aae6354f2578bcbca55ee23..dcb7ede1d4aa5b07d6af79d37db20692de065fd6 100644 (file)
@@ -68,8 +68,7 @@ int iscsit_load_discovery_tpg(void)
                return -1;
        }
 
-       ret = core_tpg_register(&iscsi_ops, NULL, &tpg->tpg_se_tpg,
-                               tpg, TRANSPORT_TPG_TYPE_DISCOVERY);
+       ret = core_tpg_register(&iscsi_ops, NULL, &tpg->tpg_se_tpg, -1);
        if (ret < 0) {
                kfree(tpg);
                return -1;
index 9436bdfef091a0b75191b30a25f2417345c0a85e..3f264d436737df066abedb20b5b696f6cb13b42b 100644 (file)
@@ -1204,8 +1204,8 @@ static struct se_portal_group *tcm_loop_make_naa_tpg(
        /*
         * Register the tl_tpg as a emulated SAS TCM Target Endpoint
         */
-       ret = core_tpg_register(&loop_ops, wwn, &tl_tpg->tl_se_tpg, tl_tpg,
-                       TRANSPORT_TPG_TYPE_NORMAL);
+       ret = core_tpg_register(&loop_ops, wwn, &tl_tpg->tl_se_tpg,
+                               tl_hba->tl_proto_id);
        if (ret < 0)
                return ERR_PTR(-ENOMEM);
 
index 5df2a61714fb196cc4d0bc78d05a4edce0ae148d..40b9f516cf9b16de76ae44665e81d63c14107c7e 100644 (file)
@@ -2152,8 +2152,7 @@ static struct se_portal_group *sbp_make_tpg(
                goto out_free_tpg;
        }
 
-       ret = core_tpg_register(&sbp_ops, wwn, &tpg->se_tpg, tpg,
-                       TRANSPORT_TPG_TYPE_NORMAL);
+       ret = core_tpg_register(&sbp_ops, wwn, &tpg->se_tpg, SCSI_PROTOCOL_SBP);
        if (ret < 0)
                goto out_unreg_mgt_agt;
 
index 42f3bd9561c8c96864de5786a888283051d96e3b..c0c1f67facb56c1504c36dfdd0a4b235d86ffb4e 100644 (file)
@@ -634,8 +634,7 @@ int core_tpg_register(
        const struct target_core_fabric_ops *tfo,
        struct se_wwn *se_wwn,
        struct se_portal_group *se_tpg,
-       void *tpg_fabric_ptr,
-       int se_tpg_type)
+       int proto_id)
 {
        struct se_lun *lun;
        u32 i;
@@ -661,8 +660,7 @@ int core_tpg_register(
                init_completion(&lun->lun_ref_comp);
        }
 
-       se_tpg->se_tpg_type = se_tpg_type;
-       se_tpg->se_tpg_fabric_ptr = tpg_fabric_ptr;
+       se_tpg->proto_id = proto_id;
        se_tpg->se_tpg_tfo = tfo;
        se_tpg->se_tpg_wwn = se_wwn;
        atomic_set(&se_tpg->tpg_pr_ref_count, 0);
@@ -673,7 +671,7 @@ int core_tpg_register(
        spin_lock_init(&se_tpg->session_lock);
        spin_lock_init(&se_tpg->tpg_lun_lock);
 
-       if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) {
+       if (se_tpg->proto_id >= 0) {
                if (core_tpg_setup_virtual_lun0(se_tpg) < 0) {
                        array_free(se_tpg->tpg_lun_list,
                                   TRANSPORT_MAX_LUNS_PER_TPG);
@@ -685,11 +683,10 @@ int core_tpg_register(
        list_add_tail(&se_tpg->se_tpg_node, &tpg_list);
        spin_unlock_bh(&tpg_lock);
 
-       pr_debug("TARGET_CORE[%s]: Allocated %s struct se_portal_group for"
-               " endpoint: %s, Portal Tag: %u\n", tfo->get_fabric_name(),
-               (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) ?
-               "Normal" : "Discovery", (tfo->tpg_get_wwn(se_tpg) == NULL) ?
-               "None" : tfo->tpg_get_wwn(se_tpg), tfo->tpg_get_tag(se_tpg));
+       pr_debug("TARGET_CORE[%s]: Allocated portal_group for endpoint: %s, "
+                "Proto: %d, Portal Tag: %u\n", tfo->get_fabric_name(),
+               tfo->tpg_get_wwn(se_tpg) ? tfo->tpg_get_wwn(se_tpg) : NULL,
+               se_tpg->proto_id, tfo->tpg_get_tag(se_tpg));
 
        return 0;
 }
@@ -697,14 +694,13 @@ EXPORT_SYMBOL(core_tpg_register);
 
 int core_tpg_deregister(struct se_portal_group *se_tpg)
 {
+       const struct target_core_fabric_ops *tfo = se_tpg->se_tpg_tfo;
        struct se_node_acl *nacl, *nacl_tmp;
 
-       pr_debug("TARGET_CORE[%s]: Deallocating %s struct se_portal_group"
-               " for endpoint: %s Portal Tag %u\n",
-               (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) ?
-               "Normal" : "Discovery", se_tpg->se_tpg_tfo->get_fabric_name(),
-               se_tpg->se_tpg_tfo->tpg_get_wwn(se_tpg),
-               se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg));
+       pr_debug("TARGET_CORE[%s]: Deallocating portal_group for endpoint: %s, "
+                "Proto: %d, Portal Tag: %u\n", tfo->get_fabric_name(),
+               tfo->tpg_get_wwn(se_tpg) ? tfo->tpg_get_wwn(se_tpg) : NULL,
+               se_tpg->proto_id, tfo->tpg_get_tag(se_tpg));
 
        spin_lock_bh(&tpg_lock);
        list_del(&se_tpg->se_tpg_node);
@@ -732,10 +728,9 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
        }
        spin_unlock_irq(&se_tpg->acl_node_lock);
 
-       if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL)
+       if (se_tpg->proto_id >= 0)
                core_tpg_remove_lun(se_tpg, &se_tpg->tpg_virt_lun0);
 
-       se_tpg->se_tpg_fabric_ptr = NULL;
        array_free(se_tpg->tpg_lun_list, TRANSPORT_MAX_LUNS_PER_TPG);
        return 0;
 }
index 4bdf7a25ae67886e9c6e7acbd86ad170fcd0f3d7..8309c3d91387f8494fb0e580de39d3c8930f6bfe 100644 (file)
@@ -284,7 +284,7 @@ static struct se_portal_group *ft_add_tpg(
        }
 
        ret = core_tpg_register(&ft_fabric_ops, wwn, &tpg->se_tpg,
-                               tpg, TRANSPORT_TPG_TYPE_NORMAL);
+                               SCSI_PROTOCOL_FCP);
        if (ret < 0) {
                destroy_workqueue(wq);
                kfree(tpg);
index 82f4da8bfe416419bf0a5ec171ebc12848684a2b..08b4f48aa49e40e04065c6dcd7b8865dc364c3cd 100644 (file)
@@ -1508,8 +1508,8 @@ static struct se_portal_group *usbg_make_tpg(
        tpg->tport = tport;
        tpg->tport_tpgt = tpgt;
 
-       ret = core_tpg_register(&usbg_ops, wwn, &tpg->se_tpg, tpg,
-                               TRANSPORT_TPG_TYPE_NORMAL);
+       ret = core_tpg_register(&usbg_ops, wwn, &tpg->se_tpg,
+                               tport->tport_proto_id);
        if (ret < 0) {
                destroy_workqueue(tpg->workqueue);
                kfree(tpg);
index b93c03935964df9f9968ef8efe430232c0219b41..8295e7be0fcba9af4a9fdd8eecedaa08f3c2c6d3 100644 (file)
@@ -2119,8 +2119,8 @@ vhost_scsi_make_tpg(struct se_wwn *wwn,
        tpg->tport = tport;
        tpg->tport_tpgt = tpgt;
 
-       ret = core_tpg_register(&vhost_scsi_ops, wwn,
-                               &tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);
+       ret = core_tpg_register(&vhost_scsi_ops, wwn, &tpg->se_tpg,
+                               tport->tport_proto_id);
        if (ret < 0) {
                kfree(tpg);
                return NULL;
index 3756953b385bc0408ff92bce62cc56240ae01c23..223d493878eb64a2455de42a4f89ea6edf170b22 100644 (file)
@@ -1883,8 +1883,8 @@ scsiback_make_tpg(struct se_wwn *wwn,
        tpg->tport = tport;
        tpg->tport_tpgt = tpgt;
 
-       ret = core_tpg_register(&scsiback_ops, wwn,
-                               &tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);
+       ret = core_tpg_register(&scsiback_ops, wwn, &tpg->se_tpg,
+                               tport->tport_proto_id);
        if (ret < 0) {
                kfree(tpg);
                return NULL;
index 9f8f5a1b527d1bb8e7f829e1e4ea66a851f31277..c462fb0a47f48e56ceb9aef472bbd4499ddc2740 100644 (file)
@@ -125,12 +125,6 @@ enum transport_lun_status_table {
        TRANSPORT_LUN_STATUS_ACTIVE = 1,
 };
 
-/* struct se_portal_group->se_tpg_type */
-enum transport_tpg_type_table {
-       TRANSPORT_TPG_TYPE_NORMAL = 0,
-       TRANSPORT_TPG_TYPE_DISCOVERY = 1,
-};
-
 /* Special transport agnostic struct se_cmd->t_states */
 enum transport_state_table {
        TRANSPORT_NO_STATE      = 0,
@@ -864,8 +858,12 @@ struct se_tpg_np {
 };
 
 struct se_portal_group {
-       /* Type of target portal group, see transport_tpg_type_table */
-       enum transport_tpg_type_table se_tpg_type;
+       /*
+        * PROTOCOL IDENTIFIER value per SPC4, 7.5.1.
+        *
+        * Negative values can be used by fabric drivers for internal use TPGs.
+        */
+       int                     proto_id;
        /* Number of ACLed Initiator Nodes for this TPG */
        u32                     num_node_acls;
        /* Used for PR SPEC_I_PT=1 and REGISTER_AND_MOVE */
@@ -875,8 +873,6 @@ struct se_portal_group {
        /* Spinlock for adding/removing sessions */
        spinlock_t              session_lock;
        spinlock_t              tpg_lun_lock;
-       /* Pointer to $FABRIC_MOD portal group */
-       void                    *se_tpg_fabric_ptr;
        struct list_head        se_tpg_node;
        /* linked list for initiator ACL list */
        struct list_head        acl_node_list;
index e5414744bf2d18e0c7eccbb34a30b1ca9731ccf2..e0adc141de078d093f5d2479e6375d582f026a29 100644 (file)
@@ -175,7 +175,7 @@ int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *,
 int    core_tpg_set_initiator_node_tag(struct se_portal_group *,
                struct se_node_acl *, const char *);
 int    core_tpg_register(const struct target_core_fabric_ops *,
-               struct se_wwn *, struct se_portal_group *, void *, int);
+               struct se_wwn *, struct se_portal_group *, int);
 int    core_tpg_deregister(struct se_portal_group *);
 
 /* SAS helpers */