Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 144bc4c2 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nicholas Bellinger
Browse files

target: move node ACL allocation to core code

parent e413f472
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -313,8 +313,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
	buf += "	.tpg_check_demo_mode_cache	= " + fabric_mod_name + "_check_true,\n"
	buf += "	.tpg_check_demo_mode_write_protect = " + fabric_mod_name + "_check_true,\n"
	buf += "	.tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n"
	buf += "	.tpg_alloc_fabric_acl		= " + fabric_mod_name + "_alloc_fabric_acl,\n"
	buf += "	.tpg_release_fabric_acl		= " + fabric_mod_name + "_release_fabric_acl,\n"
	buf += "	.tpg_get_inst_index		= " + fabric_mod_name + "_tpg_get_inst_index,\n"
	buf += "	.release_cmd			= " + fabric_mod_name + "_release_cmd,\n"
	buf += "	.shutdown_session		= " + fabric_mod_name + "_shutdown_session,\n"
@@ -624,31 +622,6 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
			bufi += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(struct se_portal_group *,\n"
			bufi +=	"			const char *, u32 *, char **);\n"

		if re.search('alloc_fabric_acl\)\(', fo):
			buf += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *se_tpg)\n"
			buf += "{\n"
			buf += "	struct " + fabric_mod_name + "_nacl *nacl;\n\n"
			buf += "	nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n"
			buf += "	if (!nacl) {\n"
			buf += "		printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_nacl\\n\");\n"
			buf += "		return NULL;\n"
			buf += "	}\n\n"
			buf += "	return &nacl->se_node_acl;\n"
			buf += "}\n\n"
			bufi += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *);\n"

		if re.search('release_fabric_acl\)\(', fo):
			buf += "void " + fabric_mod_name + "_release_fabric_acl(\n"
			buf += "	struct se_portal_group *se_tpg,\n"
			buf += "	struct se_node_acl *se_nacl)\n"
			buf += "{\n"
			buf += "	struct " + fabric_mod_name + "_nacl *nacl = container_of(se_nacl,\n"
			buf += "			struct " + fabric_mod_name + "_nacl, se_node_acl);\n"
			buf += "	kfree(nacl);\n"
			buf += "}\n\n"
			bufi += "void " + fabric_mod_name + "_release_fabric_acl(struct se_portal_group *,\n"
			bufi +=	"			struct se_node_acl *);\n"

		if re.search('tpg_get_inst_index\)\(', fo):
			buf += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *se_tpg)\n"
			buf += "{\n"
+1 −24
Original line number Diff line number Diff line
@@ -3447,28 +3447,6 @@ static char *srpt_parse_pr_out_transport_id(struct se_portal_group *se_tpg,
	return (char *)tr_id->i_port_id;
}

static struct se_node_acl *srpt_alloc_fabric_acl(struct se_portal_group *se_tpg)
{
	struct srpt_node_acl *nacl;

	nacl = kzalloc(sizeof(struct srpt_node_acl), GFP_KERNEL);
	if (!nacl) {
		pr_err("Unable to allocate struct srpt_node_acl\n");
		return NULL;
	}

	return &nacl->nacl;
}

static void srpt_release_fabric_acl(struct se_portal_group *se_tpg,
				    struct se_node_acl *se_nacl)
{
	struct srpt_node_acl *nacl;

	nacl = container_of(se_nacl, struct srpt_node_acl, nacl);
	kfree(nacl);
}

static u32 srpt_tpg_get_inst_index(struct se_portal_group *se_tpg)
{
	return 1;
@@ -3883,6 +3861,7 @@ static struct configfs_attribute *srpt_wwn_attrs[] = {
static const struct target_core_fabric_ops srpt_template = {
	.module				= THIS_MODULE,
	.name				= "srpt",
	.node_acl_size			= sizeof(struct srpt_node_acl),
	.get_fabric_name		= srpt_get_fabric_name,
	.get_fabric_proto_ident		= srpt_get_fabric_proto_ident,
	.tpg_get_wwn			= srpt_get_fabric_wwn,
@@ -3894,8 +3873,6 @@ static const struct target_core_fabric_ops srpt_template = {
	.tpg_check_demo_mode_cache	= srpt_check_true,
	.tpg_check_demo_mode_write_protect = srpt_check_true,
	.tpg_check_prod_mode_write_protect = srpt_check_false,
	.tpg_alloc_fabric_acl		= srpt_alloc_fabric_acl,
	.tpg_release_fabric_acl		= srpt_release_fabric_acl,
	.tpg_get_inst_index		= srpt_tpg_get_inst_index,
	.release_cmd			= srpt_release_cmd,
	.check_stop_free		= srpt_check_stop_free,
+2 −2
Original line number Diff line number Diff line
@@ -410,15 +410,15 @@ struct srpt_device {

/**
 * struct srpt_node_acl - Per-initiator ACL data (managed via configfs).
 * @nacl:      Target core node ACL information.
 * @i_port_id: 128-bit SRP initiator port ID.
 * @sport:     port information.
 * @nacl:      Target core node ACL information.
 * @list:      Element of the per-HCA ACL list.
 */
struct srpt_node_acl {
	struct se_node_acl	nacl;
	u8			i_port_id[16];
	struct srpt_port	*sport;
	struct se_node_acl	nacl;
	struct list_head	list;
};

+2 −27
Original line number Diff line number Diff line
@@ -338,29 +338,6 @@ static int tcm_qla2xxx_check_prot_fabric_only(struct se_portal_group *se_tpg)
	return tpg->tpg_attrib.fabric_prot_type;
}

static struct se_node_acl *tcm_qla2xxx_alloc_fabric_acl(
	struct se_portal_group *se_tpg)
{
	struct tcm_qla2xxx_nacl *nacl;

	nacl = kzalloc(sizeof(struct tcm_qla2xxx_nacl), GFP_KERNEL);
	if (!nacl) {
		pr_err("Unable to allocate struct tcm_qla2xxx_nacl\n");
		return NULL;
	}

	return &nacl->se_node_acl;
}

static void tcm_qla2xxx_release_fabric_acl(
	struct se_portal_group *se_tpg,
	struct se_node_acl *se_nacl)
{
	struct tcm_qla2xxx_nacl *nacl = container_of(se_nacl,
			struct tcm_qla2xxx_nacl, se_node_acl);
	kfree(nacl);
}

static u32 tcm_qla2xxx_tpg_get_inst_index(struct se_portal_group *se_tpg)
{
	struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
@@ -1949,6 +1926,7 @@ static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = {
static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
	.module				= THIS_MODULE,
	.name				= "qla2xxx",
	.node_acl_size			= sizeof(struct tcm_qla2xxx_nacl),
	.get_fabric_name		= tcm_qla2xxx_get_fabric_name,
	.get_fabric_proto_ident		= tcm_qla2xxx_get_fabric_proto_ident,
	.tpg_get_wwn			= tcm_qla2xxx_get_fabric_wwn,
@@ -1964,8 +1942,6 @@ static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
					tcm_qla2xxx_check_prod_write_protect,
	.tpg_check_prot_fabric_only	= tcm_qla2xxx_check_prot_fabric_only,
	.tpg_check_demo_mode_login_only = tcm_qla2xxx_check_demo_mode_login_only,
	.tpg_alloc_fabric_acl		= tcm_qla2xxx_alloc_fabric_acl,
	.tpg_release_fabric_acl		= tcm_qla2xxx_release_fabric_acl,
	.tpg_get_inst_index		= tcm_qla2xxx_tpg_get_inst_index,
	.check_stop_free		= tcm_qla2xxx_check_stop_free,
	.release_cmd			= tcm_qla2xxx_release_cmd,
@@ -2001,6 +1977,7 @@ static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
	.module				= THIS_MODULE,
	.name				= "qla2xxx_npiv",
	.node_acl_size			= sizeof(struct tcm_qla2xxx_nacl),
	.get_fabric_name		= tcm_qla2xxx_npiv_get_fabric_name,
	.get_fabric_proto_ident		= tcm_qla2xxx_get_fabric_proto_ident,
	.tpg_get_wwn			= tcm_qla2xxx_get_fabric_wwn,
@@ -2014,8 +1991,6 @@ static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
	.tpg_check_prod_mode_write_protect =
	    tcm_qla2xxx_check_prod_write_protect,
	.tpg_check_demo_mode_login_only	= tcm_qla2xxx_check_demo_mode_login_only,
	.tpg_alloc_fabric_acl		= tcm_qla2xxx_alloc_fabric_acl,
	.tpg_release_fabric_acl		= tcm_qla2xxx_release_fabric_acl,
	.tpg_get_inst_index		= tcm_qla2xxx_tpg_get_inst_index,
	.check_stop_free                = tcm_qla2xxx_check_stop_free,
	.release_cmd			= tcm_qla2xxx_release_cmd,
+2 −2
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@
#include "qla_target.h"

struct tcm_qla2xxx_nacl {
	struct se_node_acl se_node_acl;

	/* From libfc struct fc_rport->port_id */
	u32 nport_id;
	/* Binary World Wide unique Node Name for remote FC Initiator Nport */
@@ -23,8 +25,6 @@ struct tcm_qla2xxx_nacl {
	struct qla_tgt_sess *qla_tgt_sess;
	/* Pointer to TCM FC nexus */
	struct se_session *nport_nexus;
	/* Returned by tcm_qla2xxx_make_nodeacl() */
	struct se_node_acl se_node_acl;
};

struct tcm_qla2xxx_tpg_attrib {
Loading