aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-04-13 13:51:14 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2015-05-31 01:41:51 -0400
commitc7d6a803926bae9bbf4510a18fc8dd8957cc0e01 (patch)
treeae0859fb2d4d955c4249434307e29e690bec85bd /Documentation
parente1750d20e69477c0d7b26d6e0ba24c3c9ec47530 (diff)
target: refactor init/drop_nodeacl methods
By always allocating and adding, respectively removing and freeing the se_node_acl structure in core code we can remove tons of repeated code in the init_nodeacl and drop_nodeacl routines. Additionally this now respects the get_default_queue_depth method in this code path as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'Documentation')
-rwxr-xr-xDocumentation/target/tcm_mod_builder.py77
-rw-r--r--Documentation/target/tcm_mod_builder.txt4
2 files changed, 2 insertions, 79 deletions
diff --git a/Documentation/target/tcm_mod_builder.py b/Documentation/target/tcm_mod_builder.py
index 3dab9b28f4f0..3e54809b3aa1 100755
--- a/Documentation/target/tcm_mod_builder.py
+++ b/Documentation/target/tcm_mod_builder.py
@@ -50,15 +50,6 @@ def tcm_mod_build_FC_include(fabric_mod_dir_var, fabric_mod_name):
50 buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" 50 buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
51 buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" 51 buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
52 buf += "\n" 52 buf += "\n"
53 buf += "struct " + fabric_mod_name + "_nacl {\n"
54 buf += " /* Binary World Wide unique Port Name for FC Initiator Nport */\n"
55 buf += " u64 nport_wwpn;\n"
56 buf += " /* ASCII formatted WWPN for FC Initiator Nport */\n"
57 buf += " char nport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
58 buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n"
59 buf += " struct se_node_acl se_node_acl;\n"
60 buf += "};\n"
61 buf += "\n"
62 buf += "struct " + fabric_mod_name + "_tpg {\n" 53 buf += "struct " + fabric_mod_name + "_tpg {\n"
63 buf += " /* FC lport target portal group tag for TCM */\n" 54 buf += " /* FC lport target portal group tag for TCM */\n"
64 buf += " u16 lport_tpgt;\n" 55 buf += " u16 lport_tpgt;\n"
@@ -105,14 +96,6 @@ def tcm_mod_build_SAS_include(fabric_mod_dir_var, fabric_mod_name):
105 buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" 96 buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
106 buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" 97 buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
107 buf += "\n" 98 buf += "\n"
108 buf += "struct " + fabric_mod_name + "_nacl {\n"
109 buf += " /* Binary World Wide unique Port Name for SAS Initiator port */\n"
110 buf += " u64 iport_wwpn;\n"
111 buf += " /* ASCII formatted WWPN for Sas Initiator port */\n"
112 buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
113 buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n"
114 buf += " struct se_node_acl se_node_acl;\n"
115 buf += "};\n\n"
116 buf += "struct " + fabric_mod_name + "_tpg {\n" 99 buf += "struct " + fabric_mod_name + "_tpg {\n"
117 buf += " /* SAS port target portal group tag for TCM */\n" 100 buf += " /* SAS port target portal group tag for TCM */\n"
118 buf += " u16 tport_tpgt;\n" 101 buf += " u16 tport_tpgt;\n"
@@ -158,12 +141,6 @@ def tcm_mod_build_iSCSI_include(fabric_mod_dir_var, fabric_mod_name):
158 buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n" 141 buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
159 buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n" 142 buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
160 buf += "\n" 143 buf += "\n"
161 buf += "struct " + fabric_mod_name + "_nacl {\n"
162 buf += " /* ASCII formatted InitiatorName */\n"
163 buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
164 buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n"
165 buf += " struct se_node_acl se_node_acl;\n"
166 buf += "};\n\n"
167 buf += "struct " + fabric_mod_name + "_tpg {\n" 144 buf += "struct " + fabric_mod_name + "_tpg {\n"
168 buf += " /* iSCSI target portal group tag for TCM */\n" 145 buf += " /* iSCSI target portal group tag for TCM */\n"
169 buf += " u16 tport_tpgt;\n" 146 buf += " u16 tport_tpgt;\n"
@@ -239,54 +216,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
239 216
240 buf += "static const struct target_core_fabric_ops " + fabric_mod_name + "_ops;\n\n" 217 buf += "static const struct target_core_fabric_ops " + fabric_mod_name + "_ops;\n\n"
241 218
242 buf += "static struct se_node_acl *" + fabric_mod_name + "_make_nodeacl(\n"
243 buf += " struct se_portal_group *se_tpg,\n"
244 buf += " struct config_group *group,\n"
245 buf += " const char *name)\n"
246 buf += "{\n"
247 buf += " struct se_node_acl *se_nacl, *se_nacl_new;\n"
248 buf += " struct " + fabric_mod_name + "_nacl *nacl;\n"
249
250 if proto_ident == "FC" or proto_ident == "SAS":
251 buf += " u64 wwpn = 0;\n"
252
253 buf += " u32 nexus_depth;\n\n"
254 buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n"
255 buf += " return ERR_PTR(-EINVAL); */\n"
256 buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n"
257 buf += " if (!se_nacl_new)\n"
258 buf += " return ERR_PTR(-ENOMEM);\n"
259 buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n"
260 buf += " nexus_depth = 1;\n"
261 buf += " /*\n"
262 buf += " * se_nacl_new may be released by core_tpg_add_initiator_node_acl()\n"
263 buf += " * when converting a NodeACL from demo mode -> explict\n"
264 buf += " */\n"
265 buf += " se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,\n"
266 buf += " name, nexus_depth);\n"
267 buf += " if (IS_ERR(se_nacl)) {\n"
268 buf += " " + fabric_mod_name + "_release_fabric_acl(se_tpg, se_nacl_new);\n"
269 buf += " return se_nacl;\n"
270 buf += " }\n"
271 buf += " /*\n"
272 buf += " * Locate our struct " + fabric_mod_name + "_nacl and set the FC Nport WWPN\n"
273 buf += " */\n"
274 buf += " nacl = container_of(se_nacl, struct " + fabric_mod_name + "_nacl, se_node_acl);\n"
275
276 if proto_ident == "FC" or proto_ident == "SAS":
277 buf += " nacl->" + fabric_mod_init_port + "_wwpn = wwpn;\n"
278
279 buf += " /* " + fabric_mod_name + "_format_wwn(&nacl->" + fabric_mod_init_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n"
280 buf += " return se_nacl;\n"
281 buf += "}\n\n"
282 buf += "static void " + fabric_mod_name + "_drop_nodeacl(struct se_node_acl *se_acl)\n"
283 buf += "{\n"
284 buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_acl,\n"
285 buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n"
286 buf += " core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1);\n"
287 buf += " kfree(nacl);\n"
288 buf += "}\n\n"
289
290 buf += "static struct se_portal_group *" + fabric_mod_name + "_make_tpg(\n" 219 buf += "static struct se_portal_group *" + fabric_mod_name + "_make_tpg(\n"
291 buf += " struct se_wwn *wwn,\n" 220 buf += " struct se_wwn *wwn,\n"
292 buf += " struct config_group *group,\n" 221 buf += " struct config_group *group,\n"
@@ -408,12 +337,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
408 buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n" 337 buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n"
409 buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n" 338 buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n"
410 buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n" 339 buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n"
411 buf += " .fabric_post_link = NULL,\n"
412 buf += " .fabric_pre_unlink = NULL,\n"
413 buf += " .fabric_make_np = NULL,\n"
414 buf += " .fabric_drop_np = NULL,\n"
415 buf += " .fabric_make_nodeacl = " + fabric_mod_name + "_make_nodeacl,\n"
416 buf += " .fabric_drop_nodeacl = " + fabric_mod_name + "_drop_nodeacl,\n"
417 buf += "\n" 340 buf += "\n"
418 buf += " .tfc_wwn_attrs = " + fabric_mod_name + "_wwn_attrs;\n" 341 buf += " .tfc_wwn_attrs = " + fabric_mod_name + "_wwn_attrs;\n"
419 buf += "};\n\n" 342 buf += "};\n\n"
diff --git a/Documentation/target/tcm_mod_builder.txt b/Documentation/target/tcm_mod_builder.txt
index 84533d8e747f..ae22f7005540 100644
--- a/Documentation/target/tcm_mod_builder.txt
+++ b/Documentation/target/tcm_mod_builder.txt
@@ -13,8 +13,8 @@ fabric skeleton, by simply using:
13This script will create a new drivers/target/$TCM_NEW_MOD/, and will do the following 13This script will create a new drivers/target/$TCM_NEW_MOD/, and will do the following
14 14
15 *) Generate new API callers for drivers/target/target_core_fabric_configs.c logic 15 *) Generate new API callers for drivers/target/target_core_fabric_configs.c logic
16 ->make_nodeacl(), ->drop_nodeacl(), ->make_tpg(), ->drop_tpg() 16 ->make_tpg(), ->drop_tpg(), ->make_wwn(), ->drop_wwn(). These are created
17 ->make_wwn(), ->drop_wwn(). These are created into $TCM_NEW_MOD/$TCM_NEW_MOD_configfs.c 17 into $TCM_NEW_MOD/$TCM_NEW_MOD_configfs.c
18 *) Generate basic infrastructure for loading/unloading LKMs and TCM/ConfigFS fabric module 18 *) Generate basic infrastructure for loading/unloading LKMs and TCM/ConfigFS fabric module
19 using a skeleton struct target_core_fabric_ops API template. 19 using a skeleton struct target_core_fabric_ops API template.
20 *) Based on user defined T10 Proto_Ident for the new fabric module being built, 20 *) Based on user defined T10 Proto_Ident for the new fabric module being built,