iscsi_target_configfs.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600
  1. /*******************************************************************************
  2. * This file contains the configfs implementation for iSCSI Target mode
  3. * from the LIO-Target Project.
  4. *
  5. * (c) Copyright 2007-2013 Datera, Inc.
  6. *
  7. * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. ****************************************************************************/
  19. #include <linux/configfs.h>
  20. #include <linux/ctype.h>
  21. #include <linux/export.h>
  22. #include <linux/inet.h>
  23. #include <linux/module.h>
  24. #include <net/ipv6.h>
  25. #include <target/target_core_base.h>
  26. #include <target/target_core_fabric.h>
  27. #include <target/iscsi/iscsi_transport.h>
  28. #include <target/iscsi/iscsi_target_core.h>
  29. #include "iscsi_target_parameters.h"
  30. #include "iscsi_target_device.h"
  31. #include "iscsi_target_erl0.h"
  32. #include "iscsi_target_nodeattrib.h"
  33. #include "iscsi_target_tpg.h"
  34. #include "iscsi_target_util.h"
  35. #include "iscsi_target.h"
  36. #include <target/iscsi/iscsi_target_stat.h>
  37. /* Start items for lio_target_portal_cit */
  38. static inline struct iscsi_tpg_np *to_iscsi_tpg_np(struct config_item *item)
  39. {
  40. return container_of(to_tpg_np(item), struct iscsi_tpg_np, se_tpg_np);
  41. }
  42. static ssize_t lio_target_np_driver_show(struct config_item *item, char *page,
  43. enum iscsit_transport_type type)
  44. {
  45. struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item);
  46. struct iscsi_tpg_np *tpg_np_new;
  47. ssize_t rb;
  48. tpg_np_new = iscsit_tpg_locate_child_np(tpg_np, type);
  49. if (tpg_np_new)
  50. rb = sprintf(page, "1\n");
  51. else
  52. rb = sprintf(page, "0\n");
  53. return rb;
  54. }
  55. static ssize_t lio_target_np_driver_store(struct config_item *item,
  56. const char *page, size_t count, enum iscsit_transport_type type,
  57. const char *mod_name)
  58. {
  59. struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item);
  60. struct iscsi_np *np;
  61. struct iscsi_portal_group *tpg;
  62. struct iscsi_tpg_np *tpg_np_new = NULL;
  63. u32 op;
  64. int rc;
  65. rc = kstrtou32(page, 0, &op);
  66. if (rc)
  67. return rc;
  68. if ((op != 1) && (op != 0)) {
  69. pr_err("Illegal value for tpg_enable: %u\n", op);
  70. return -EINVAL;
  71. }
  72. np = tpg_np->tpg_np;
  73. if (!np) {
  74. pr_err("Unable to locate struct iscsi_np from"
  75. " struct iscsi_tpg_np\n");
  76. return -EINVAL;
  77. }
  78. tpg = tpg_np->tpg;
  79. if (iscsit_get_tpg(tpg) < 0)
  80. return -EINVAL;
  81. if (op) {
  82. if (strlen(mod_name)) {
  83. rc = request_module(mod_name);
  84. if (rc != 0) {
  85. pr_warn("Unable to request_module for %s\n",
  86. mod_name);
  87. rc = 0;
  88. }
  89. }
  90. tpg_np_new = iscsit_tpg_add_network_portal(tpg,
  91. &np->np_sockaddr, tpg_np, type);
  92. if (IS_ERR(tpg_np_new)) {
  93. rc = PTR_ERR(tpg_np_new);
  94. goto out;
  95. }
  96. } else {
  97. tpg_np_new = iscsit_tpg_locate_child_np(tpg_np, type);
  98. if (tpg_np_new) {
  99. rc = iscsit_tpg_del_network_portal(tpg, tpg_np_new);
  100. if (rc < 0)
  101. goto out;
  102. }
  103. }
  104. iscsit_put_tpg(tpg);
  105. return count;
  106. out:
  107. iscsit_put_tpg(tpg);
  108. return rc;
  109. }
  110. static ssize_t lio_target_np_iser_show(struct config_item *item, char *page)
  111. {
  112. return lio_target_np_driver_show(item, page, ISCSI_INFINIBAND);
  113. }
  114. static ssize_t lio_target_np_iser_store(struct config_item *item,
  115. const char *page, size_t count)
  116. {
  117. return lio_target_np_driver_store(item, page, count,
  118. ISCSI_INFINIBAND, "ib_isert");
  119. }
  120. CONFIGFS_ATTR(lio_target_np_, iser);
  121. static ssize_t lio_target_np_cxgbit_show(struct config_item *item, char *page)
  122. {
  123. return lio_target_np_driver_show(item, page, ISCSI_CXGBIT);
  124. }
  125. static ssize_t lio_target_np_cxgbit_store(struct config_item *item,
  126. const char *page, size_t count)
  127. {
  128. return lio_target_np_driver_store(item, page, count,
  129. ISCSI_CXGBIT, "cxgbit");
  130. }
  131. CONFIGFS_ATTR(lio_target_np_, cxgbit);
  132. static struct configfs_attribute *lio_target_portal_attrs[] = {
  133. &lio_target_np_attr_iser,
  134. &lio_target_np_attr_cxgbit,
  135. NULL,
  136. };
  137. /* Stop items for lio_target_portal_cit */
  138. /* Start items for lio_target_np_cit */
  139. #define MAX_PORTAL_LEN 256
  140. static struct se_tpg_np *lio_target_call_addnptotpg(
  141. struct se_portal_group *se_tpg,
  142. struct config_group *group,
  143. const char *name)
  144. {
  145. struct iscsi_portal_group *tpg;
  146. struct iscsi_tpg_np *tpg_np;
  147. char *str, *str2, *ip_str, *port_str;
  148. struct sockaddr_storage sockaddr = { };
  149. int ret;
  150. char buf[MAX_PORTAL_LEN + 1];
  151. if (strlen(name) > MAX_PORTAL_LEN) {
  152. pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n",
  153. (int)strlen(name), MAX_PORTAL_LEN);
  154. return ERR_PTR(-EOVERFLOW);
  155. }
  156. memset(buf, 0, MAX_PORTAL_LEN + 1);
  157. snprintf(buf, MAX_PORTAL_LEN + 1, "%s", name);
  158. str = strstr(buf, "[");
  159. if (str) {
  160. str2 = strstr(str, "]");
  161. if (!str2) {
  162. pr_err("Unable to locate trailing \"]\""
  163. " in IPv6 iSCSI network portal address\n");
  164. return ERR_PTR(-EINVAL);
  165. }
  166. ip_str = str + 1; /* Skip over leading "[" */
  167. *str2 = '\0'; /* Terminate the unbracketed IPv6 address */
  168. str2++; /* Skip over the \0 */
  169. port_str = strstr(str2, ":");
  170. if (!port_str) {
  171. pr_err("Unable to locate \":port\""
  172. " in IPv6 iSCSI network portal address\n");
  173. return ERR_PTR(-EINVAL);
  174. }
  175. *port_str = '\0'; /* Terminate string for IP */
  176. port_str++; /* Skip over ":" */
  177. } else {
  178. ip_str = &buf[0];
  179. port_str = strstr(ip_str, ":");
  180. if (!port_str) {
  181. pr_err("Unable to locate \":port\""
  182. " in IPv4 iSCSI network portal address\n");
  183. return ERR_PTR(-EINVAL);
  184. }
  185. *port_str = '\0'; /* Terminate string for IP */
  186. port_str++; /* Skip over ":" */
  187. }
  188. ret = inet_pton_with_scope(&init_net, AF_UNSPEC, ip_str,
  189. port_str, &sockaddr);
  190. if (ret) {
  191. pr_err("malformed ip/port passed: %s\n", name);
  192. return ERR_PTR(ret);
  193. }
  194. tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
  195. ret = iscsit_get_tpg(tpg);
  196. if (ret < 0)
  197. return ERR_PTR(-EINVAL);
  198. pr_debug("LIO_Target_ConfigFS: REGISTER -> %s TPGT: %hu"
  199. " PORTAL: %s\n",
  200. config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
  201. tpg->tpgt, name);
  202. /*
  203. * Assume ISCSI_TCP by default. Other network portals for other
  204. * iSCSI fabrics:
  205. *
  206. * Traditional iSCSI over SCTP (initial support)
  207. * iSER/TCP (TODO, hardware available)
  208. * iSER/SCTP (TODO, software emulation with osc-iwarp)
  209. * iSER/IB (TODO, hardware available)
  210. *
  211. * can be enabled with attributes under
  212. * sys/kernel/config/iscsi/$IQN/$TPG/np/$IP:$PORT/
  213. *
  214. */
  215. tpg_np = iscsit_tpg_add_network_portal(tpg, &sockaddr, NULL,
  216. ISCSI_TCP);
  217. if (IS_ERR(tpg_np)) {
  218. iscsit_put_tpg(tpg);
  219. return ERR_CAST(tpg_np);
  220. }
  221. pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n");
  222. iscsit_put_tpg(tpg);
  223. return &tpg_np->se_tpg_np;
  224. }
  225. static void lio_target_call_delnpfromtpg(
  226. struct se_tpg_np *se_tpg_np)
  227. {
  228. struct iscsi_portal_group *tpg;
  229. struct iscsi_tpg_np *tpg_np;
  230. struct se_portal_group *se_tpg;
  231. int ret;
  232. tpg_np = container_of(se_tpg_np, struct iscsi_tpg_np, se_tpg_np);
  233. tpg = tpg_np->tpg;
  234. ret = iscsit_get_tpg(tpg);
  235. if (ret < 0)
  236. return;
  237. se_tpg = &tpg->tpg_se_tpg;
  238. pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s TPGT: %hu"
  239. " PORTAL: %pISpc\n", config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
  240. tpg->tpgt, &tpg_np->tpg_np->np_sockaddr);
  241. ret = iscsit_tpg_del_network_portal(tpg, tpg_np);
  242. if (ret < 0)
  243. goto out;
  244. pr_debug("LIO_Target_ConfigFS: delnpfromtpg done!\n");
  245. out:
  246. iscsit_put_tpg(tpg);
  247. }
  248. /* End items for lio_target_np_cit */
  249. /* Start items for lio_target_nacl_attrib_cit */
  250. #define ISCSI_NACL_ATTR(name) \
  251. static ssize_t iscsi_nacl_attrib_##name##_show(struct config_item *item,\
  252. char *page) \
  253. { \
  254. struct se_node_acl *se_nacl = attrib_to_nacl(item); \
  255. struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
  256. se_node_acl); \
  257. \
  258. return sprintf(page, "%u\n", nacl->node_attrib.name); \
  259. } \
  260. \
  261. static ssize_t iscsi_nacl_attrib_##name##_store(struct config_item *item,\
  262. const char *page, size_t count) \
  263. { \
  264. struct se_node_acl *se_nacl = attrib_to_nacl(item); \
  265. struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
  266. se_node_acl); \
  267. u32 val; \
  268. int ret; \
  269. \
  270. ret = kstrtou32(page, 0, &val); \
  271. if (ret) \
  272. return ret; \
  273. ret = iscsit_na_##name(nacl, val); \
  274. if (ret < 0) \
  275. return ret; \
  276. \
  277. return count; \
  278. } \
  279. \
  280. CONFIGFS_ATTR(iscsi_nacl_attrib_, name)
  281. ISCSI_NACL_ATTR(dataout_timeout);
  282. ISCSI_NACL_ATTR(dataout_timeout_retries);
  283. ISCSI_NACL_ATTR(default_erl);
  284. ISCSI_NACL_ATTR(nopin_timeout);
  285. ISCSI_NACL_ATTR(nopin_response_timeout);
  286. ISCSI_NACL_ATTR(random_datain_pdu_offsets);
  287. ISCSI_NACL_ATTR(random_datain_seq_offsets);
  288. ISCSI_NACL_ATTR(random_r2t_offsets);
  289. static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = {
  290. &iscsi_nacl_attrib_attr_dataout_timeout,
  291. &iscsi_nacl_attrib_attr_dataout_timeout_retries,
  292. &iscsi_nacl_attrib_attr_default_erl,
  293. &iscsi_nacl_attrib_attr_nopin_timeout,
  294. &iscsi_nacl_attrib_attr_nopin_response_timeout,
  295. &iscsi_nacl_attrib_attr_random_datain_pdu_offsets,
  296. &iscsi_nacl_attrib_attr_random_datain_seq_offsets,
  297. &iscsi_nacl_attrib_attr_random_r2t_offsets,
  298. NULL,
  299. };
  300. /* End items for lio_target_nacl_attrib_cit */
  301. /* Start items for lio_target_nacl_auth_cit */
  302. #define __DEF_NACL_AUTH_STR(prefix, name, flags) \
  303. static ssize_t __iscsi_##prefix##_##name##_show( \
  304. struct iscsi_node_acl *nacl, \
  305. char *page) \
  306. { \
  307. struct iscsi_node_auth *auth = &nacl->node_auth; \
  308. \
  309. if (!capable(CAP_SYS_ADMIN)) \
  310. return -EPERM; \
  311. return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
  312. } \
  313. \
  314. static ssize_t __iscsi_##prefix##_##name##_store( \
  315. struct iscsi_node_acl *nacl, \
  316. const char *page, \
  317. size_t count) \
  318. { \
  319. struct iscsi_node_auth *auth = &nacl->node_auth; \
  320. \
  321. if (!capable(CAP_SYS_ADMIN)) \
  322. return -EPERM; \
  323. if (count >= sizeof(auth->name)) \
  324. return -EINVAL; \
  325. snprintf(auth->name, sizeof(auth->name), "%s", page); \
  326. if (!strncmp("NULL", auth->name, 4)) \
  327. auth->naf_flags &= ~flags; \
  328. else \
  329. auth->naf_flags |= flags; \
  330. \
  331. if ((auth->naf_flags & NAF_USERID_IN_SET) && \
  332. (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
  333. auth->authenticate_target = 1; \
  334. else \
  335. auth->authenticate_target = 0; \
  336. \
  337. return count; \
  338. }
  339. #define DEF_NACL_AUTH_STR(name, flags) \
  340. __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \
  341. static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
  342. char *page) \
  343. { \
  344. struct se_node_acl *nacl = auth_to_nacl(item); \
  345. return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
  346. struct iscsi_node_acl, se_node_acl), page); \
  347. } \
  348. static ssize_t iscsi_nacl_auth_##name##_store(struct config_item *item, \
  349. const char *page, size_t count) \
  350. { \
  351. struct se_node_acl *nacl = auth_to_nacl(item); \
  352. return __iscsi_nacl_auth_##name##_store(container_of(nacl, \
  353. struct iscsi_node_acl, se_node_acl), page, count); \
  354. } \
  355. \
  356. CONFIGFS_ATTR(iscsi_nacl_auth_, name)
  357. /*
  358. * One-way authentication userid
  359. */
  360. DEF_NACL_AUTH_STR(userid, NAF_USERID_SET);
  361. DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET);
  362. DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
  363. DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
  364. #define __DEF_NACL_AUTH_INT(prefix, name) \
  365. static ssize_t __iscsi_##prefix##_##name##_show( \
  366. struct iscsi_node_acl *nacl, \
  367. char *page) \
  368. { \
  369. struct iscsi_node_auth *auth = &nacl->node_auth; \
  370. \
  371. if (!capable(CAP_SYS_ADMIN)) \
  372. return -EPERM; \
  373. \
  374. return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
  375. }
  376. #define DEF_NACL_AUTH_INT(name) \
  377. __DEF_NACL_AUTH_INT(nacl_auth, name) \
  378. static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
  379. char *page) \
  380. { \
  381. struct se_node_acl *nacl = auth_to_nacl(item); \
  382. return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
  383. struct iscsi_node_acl, se_node_acl), page); \
  384. } \
  385. \
  386. CONFIGFS_ATTR_RO(iscsi_nacl_auth_, name)
  387. DEF_NACL_AUTH_INT(authenticate_target);
  388. static struct configfs_attribute *lio_target_nacl_auth_attrs[] = {
  389. &iscsi_nacl_auth_attr_userid,
  390. &iscsi_nacl_auth_attr_password,
  391. &iscsi_nacl_auth_attr_authenticate_target,
  392. &iscsi_nacl_auth_attr_userid_mutual,
  393. &iscsi_nacl_auth_attr_password_mutual,
  394. NULL,
  395. };
  396. /* End items for lio_target_nacl_auth_cit */
  397. /* Start items for lio_target_nacl_param_cit */
  398. #define ISCSI_NACL_PARAM(name) \
  399. static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \
  400. char *page) \
  401. { \
  402. struct se_node_acl *se_nacl = param_to_nacl(item); \
  403. struct iscsi_session *sess; \
  404. struct se_session *se_sess; \
  405. ssize_t rb; \
  406. \
  407. spin_lock_bh(&se_nacl->nacl_sess_lock); \
  408. se_sess = se_nacl->nacl_sess; \
  409. if (!se_sess) { \
  410. rb = snprintf(page, PAGE_SIZE, \
  411. "No Active iSCSI Session\n"); \
  412. } else { \
  413. sess = se_sess->fabric_sess_ptr; \
  414. rb = snprintf(page, PAGE_SIZE, "%u\n", \
  415. (u32)sess->sess_ops->name); \
  416. } \
  417. spin_unlock_bh(&se_nacl->nacl_sess_lock); \
  418. \
  419. return rb; \
  420. } \
  421. \
  422. CONFIGFS_ATTR_RO(iscsi_nacl_param_, name)
  423. ISCSI_NACL_PARAM(MaxConnections);
  424. ISCSI_NACL_PARAM(InitialR2T);
  425. ISCSI_NACL_PARAM(ImmediateData);
  426. ISCSI_NACL_PARAM(MaxBurstLength);
  427. ISCSI_NACL_PARAM(FirstBurstLength);
  428. ISCSI_NACL_PARAM(DefaultTime2Wait);
  429. ISCSI_NACL_PARAM(DefaultTime2Retain);
  430. ISCSI_NACL_PARAM(MaxOutstandingR2T);
  431. ISCSI_NACL_PARAM(DataPDUInOrder);
  432. ISCSI_NACL_PARAM(DataSequenceInOrder);
  433. ISCSI_NACL_PARAM(ErrorRecoveryLevel);
  434. static struct configfs_attribute *lio_target_nacl_param_attrs[] = {
  435. &iscsi_nacl_param_attr_MaxConnections,
  436. &iscsi_nacl_param_attr_InitialR2T,
  437. &iscsi_nacl_param_attr_ImmediateData,
  438. &iscsi_nacl_param_attr_MaxBurstLength,
  439. &iscsi_nacl_param_attr_FirstBurstLength,
  440. &iscsi_nacl_param_attr_DefaultTime2Wait,
  441. &iscsi_nacl_param_attr_DefaultTime2Retain,
  442. &iscsi_nacl_param_attr_MaxOutstandingR2T,
  443. &iscsi_nacl_param_attr_DataPDUInOrder,
  444. &iscsi_nacl_param_attr_DataSequenceInOrder,
  445. &iscsi_nacl_param_attr_ErrorRecoveryLevel,
  446. NULL,
  447. };
  448. /* End items for lio_target_nacl_param_cit */
  449. /* Start items for lio_target_acl_cit */
  450. static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)
  451. {
  452. struct se_node_acl *se_nacl = acl_to_nacl(item);
  453. struct iscsi_session *sess;
  454. struct iscsi_conn *conn;
  455. struct se_session *se_sess;
  456. ssize_t rb = 0;
  457. u32 max_cmd_sn;
  458. spin_lock_bh(&se_nacl->nacl_sess_lock);
  459. se_sess = se_nacl->nacl_sess;
  460. if (!se_sess) {
  461. rb += sprintf(page+rb, "No active iSCSI Session for Initiator"
  462. " Endpoint: %s\n", se_nacl->initiatorname);
  463. } else {
  464. sess = se_sess->fabric_sess_ptr;
  465. rb += sprintf(page+rb, "InitiatorName: %s\n",
  466. sess->sess_ops->InitiatorName);
  467. rb += sprintf(page+rb, "InitiatorAlias: %s\n",
  468. sess->sess_ops->InitiatorAlias);
  469. rb += sprintf(page+rb,
  470. "LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ",
  471. sess->sid, sess->isid, sess->tsih);
  472. rb += sprintf(page+rb, "SessionType: %s\n",
  473. (sess->sess_ops->SessionType) ?
  474. "Discovery" : "Normal");
  475. rb += sprintf(page+rb, "Session State: ");
  476. switch (sess->session_state) {
  477. case TARG_SESS_STATE_FREE:
  478. rb += sprintf(page+rb, "TARG_SESS_FREE\n");
  479. break;
  480. case TARG_SESS_STATE_ACTIVE:
  481. rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n");
  482. break;
  483. case TARG_SESS_STATE_LOGGED_IN:
  484. rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n");
  485. break;
  486. case TARG_SESS_STATE_FAILED:
  487. rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n");
  488. break;
  489. case TARG_SESS_STATE_IN_CONTINUE:
  490. rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n");
  491. break;
  492. default:
  493. rb += sprintf(page+rb, "ERROR: Unknown Session"
  494. " State!\n");
  495. break;
  496. }
  497. rb += sprintf(page+rb, "---------------------[iSCSI Session"
  498. " Values]-----------------------\n");
  499. rb += sprintf(page+rb, " CmdSN/WR : CmdSN/WC : ExpCmdSN"
  500. " : MaxCmdSN : ITT : TTT\n");
  501. max_cmd_sn = (u32) atomic_read(&sess->max_cmd_sn);
  502. rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x"
  503. " 0x%08x 0x%08x\n",
  504. sess->cmdsn_window,
  505. (max_cmd_sn - sess->exp_cmd_sn) + 1,
  506. sess->exp_cmd_sn, max_cmd_sn,
  507. sess->init_task_tag, sess->targ_xfer_tag);
  508. rb += sprintf(page+rb, "----------------------[iSCSI"
  509. " Connections]-------------------------\n");
  510. spin_lock(&sess->conn_lock);
  511. list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
  512. rb += sprintf(page+rb, "CID: %hu Connection"
  513. " State: ", conn->cid);
  514. switch (conn->conn_state) {
  515. case TARG_CONN_STATE_FREE:
  516. rb += sprintf(page+rb,
  517. "TARG_CONN_STATE_FREE\n");
  518. break;
  519. case TARG_CONN_STATE_XPT_UP:
  520. rb += sprintf(page+rb,
  521. "TARG_CONN_STATE_XPT_UP\n");
  522. break;
  523. case TARG_CONN_STATE_IN_LOGIN:
  524. rb += sprintf(page+rb,
  525. "TARG_CONN_STATE_IN_LOGIN\n");
  526. break;
  527. case TARG_CONN_STATE_LOGGED_IN:
  528. rb += sprintf(page+rb,
  529. "TARG_CONN_STATE_LOGGED_IN\n");
  530. break;
  531. case TARG_CONN_STATE_IN_LOGOUT:
  532. rb += sprintf(page+rb,
  533. "TARG_CONN_STATE_IN_LOGOUT\n");
  534. break;
  535. case TARG_CONN_STATE_LOGOUT_REQUESTED:
  536. rb += sprintf(page+rb,
  537. "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
  538. break;
  539. case TARG_CONN_STATE_CLEANUP_WAIT:
  540. rb += sprintf(page+rb,
  541. "TARG_CONN_STATE_CLEANUP_WAIT\n");
  542. break;
  543. default:
  544. rb += sprintf(page+rb,
  545. "ERROR: Unknown Connection State!\n");
  546. break;
  547. }
  548. rb += sprintf(page+rb, " Address %pISc %s", &conn->login_sockaddr,
  549. (conn->network_transport == ISCSI_TCP) ?
  550. "TCP" : "SCTP");
  551. rb += sprintf(page+rb, " StatSN: 0x%08x\n",
  552. conn->stat_sn);
  553. }
  554. spin_unlock(&sess->conn_lock);
  555. }
  556. spin_unlock_bh(&se_nacl->nacl_sess_lock);
  557. return rb;
  558. }
  559. static ssize_t lio_target_nacl_cmdsn_depth_show(struct config_item *item,
  560. char *page)
  561. {
  562. return sprintf(page, "%u\n", acl_to_nacl(item)->queue_depth);
  563. }
  564. static ssize_t lio_target_nacl_cmdsn_depth_store(struct config_item *item,
  565. const char *page, size_t count)
  566. {
  567. struct se_node_acl *se_nacl = acl_to_nacl(item);
  568. struct se_portal_group *se_tpg = se_nacl->se_tpg;
  569. struct iscsi_portal_group *tpg = container_of(se_tpg,
  570. struct iscsi_portal_group, tpg_se_tpg);
  571. struct config_item *acl_ci, *tpg_ci, *wwn_ci;
  572. u32 cmdsn_depth = 0;
  573. int ret;
  574. ret = kstrtou32(page, 0, &cmdsn_depth);
  575. if (ret)
  576. return ret;
  577. if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
  578. pr_err("Passed cmdsn_depth: %u exceeds"
  579. " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth,
  580. TA_DEFAULT_CMDSN_DEPTH_MAX);
  581. return -EINVAL;
  582. }
  583. acl_ci = &se_nacl->acl_group.cg_item;
  584. if (!acl_ci) {
  585. pr_err("Unable to locatel acl_ci\n");
  586. return -EINVAL;
  587. }
  588. tpg_ci = &acl_ci->ci_parent->ci_group->cg_item;
  589. if (!tpg_ci) {
  590. pr_err("Unable to locate tpg_ci\n");
  591. return -EINVAL;
  592. }
  593. wwn_ci = &tpg_ci->ci_group->cg_item;
  594. if (!wwn_ci) {
  595. pr_err("Unable to locate config_item wwn_ci\n");
  596. return -EINVAL;
  597. }
  598. if (iscsit_get_tpg(tpg) < 0)
  599. return -EINVAL;
  600. ret = core_tpg_set_initiator_node_queue_depth(se_nacl, cmdsn_depth);
  601. pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for"
  602. "InitiatorName: %s\n", config_item_name(wwn_ci),
  603. config_item_name(tpg_ci), cmdsn_depth,
  604. config_item_name(acl_ci));
  605. iscsit_put_tpg(tpg);
  606. return (!ret) ? count : (ssize_t)ret;
  607. }
  608. static ssize_t lio_target_nacl_tag_show(struct config_item *item, char *page)
  609. {
  610. return snprintf(page, PAGE_SIZE, "%s", acl_to_nacl(item)->acl_tag);
  611. }
  612. static ssize_t lio_target_nacl_tag_store(struct config_item *item,
  613. const char *page, size_t count)
  614. {
  615. struct se_node_acl *se_nacl = acl_to_nacl(item);
  616. int ret;
  617. ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page);
  618. if (ret < 0)
  619. return ret;
  620. return count;
  621. }
  622. CONFIGFS_ATTR_RO(lio_target_nacl_, info);
  623. CONFIGFS_ATTR(lio_target_nacl_, cmdsn_depth);
  624. CONFIGFS_ATTR(lio_target_nacl_, tag);
  625. static struct configfs_attribute *lio_target_initiator_attrs[] = {
  626. &lio_target_nacl_attr_info,
  627. &lio_target_nacl_attr_cmdsn_depth,
  628. &lio_target_nacl_attr_tag,
  629. NULL,
  630. };
  631. static int lio_target_init_nodeacl(struct se_node_acl *se_nacl,
  632. const char *name)
  633. {
  634. struct iscsi_node_acl *acl =
  635. container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
  636. config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group,
  637. "iscsi_sess_stats", &iscsi_stat_sess_cit);
  638. configfs_add_default_group(&acl->node_stat_grps.iscsi_sess_stats_group,
  639. &se_nacl->acl_fabric_stat_group);
  640. return 0;
  641. }
  642. /* End items for lio_target_acl_cit */
  643. /* Start items for lio_target_tpg_attrib_cit */
  644. #define DEF_TPG_ATTRIB(name) \
  645. \
  646. static ssize_t iscsi_tpg_attrib_##name##_show(struct config_item *item, \
  647. char *page) \
  648. { \
  649. struct se_portal_group *se_tpg = attrib_to_tpg(item); \
  650. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  651. struct iscsi_portal_group, tpg_se_tpg); \
  652. ssize_t rb; \
  653. \
  654. if (iscsit_get_tpg(tpg) < 0) \
  655. return -EINVAL; \
  656. \
  657. rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \
  658. iscsit_put_tpg(tpg); \
  659. return rb; \
  660. } \
  661. \
  662. static ssize_t iscsi_tpg_attrib_##name##_store(struct config_item *item,\
  663. const char *page, size_t count) \
  664. { \
  665. struct se_portal_group *se_tpg = attrib_to_tpg(item); \
  666. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  667. struct iscsi_portal_group, tpg_se_tpg); \
  668. u32 val; \
  669. int ret; \
  670. \
  671. if (iscsit_get_tpg(tpg) < 0) \
  672. return -EINVAL; \
  673. \
  674. ret = kstrtou32(page, 0, &val); \
  675. if (ret) \
  676. goto out; \
  677. ret = iscsit_ta_##name(tpg, val); \
  678. if (ret < 0) \
  679. goto out; \
  680. \
  681. iscsit_put_tpg(tpg); \
  682. return count; \
  683. out: \
  684. iscsit_put_tpg(tpg); \
  685. return ret; \
  686. } \
  687. CONFIGFS_ATTR(iscsi_tpg_attrib_, name)
  688. DEF_TPG_ATTRIB(authentication);
  689. DEF_TPG_ATTRIB(login_timeout);
  690. DEF_TPG_ATTRIB(netif_timeout);
  691. DEF_TPG_ATTRIB(generate_node_acls);
  692. DEF_TPG_ATTRIB(default_cmdsn_depth);
  693. DEF_TPG_ATTRIB(cache_dynamic_acls);
  694. DEF_TPG_ATTRIB(demo_mode_write_protect);
  695. DEF_TPG_ATTRIB(prod_mode_write_protect);
  696. DEF_TPG_ATTRIB(demo_mode_discovery);
  697. DEF_TPG_ATTRIB(default_erl);
  698. DEF_TPG_ATTRIB(t10_pi);
  699. DEF_TPG_ATTRIB(fabric_prot_type);
  700. DEF_TPG_ATTRIB(tpg_enabled_sendtargets);
  701. DEF_TPG_ATTRIB(login_keys_workaround);
  702. static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
  703. &iscsi_tpg_attrib_attr_authentication,
  704. &iscsi_tpg_attrib_attr_login_timeout,
  705. &iscsi_tpg_attrib_attr_netif_timeout,
  706. &iscsi_tpg_attrib_attr_generate_node_acls,
  707. &iscsi_tpg_attrib_attr_default_cmdsn_depth,
  708. &iscsi_tpg_attrib_attr_cache_dynamic_acls,
  709. &iscsi_tpg_attrib_attr_demo_mode_write_protect,
  710. &iscsi_tpg_attrib_attr_prod_mode_write_protect,
  711. &iscsi_tpg_attrib_attr_demo_mode_discovery,
  712. &iscsi_tpg_attrib_attr_default_erl,
  713. &iscsi_tpg_attrib_attr_t10_pi,
  714. &iscsi_tpg_attrib_attr_fabric_prot_type,
  715. &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
  716. &iscsi_tpg_attrib_attr_login_keys_workaround,
  717. NULL,
  718. };
  719. /* End items for lio_target_tpg_attrib_cit */
  720. /* Start items for lio_target_tpg_auth_cit */
  721. #define __DEF_TPG_AUTH_STR(prefix, name, flags) \
  722. static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
  723. char *page) \
  724. { \
  725. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  726. struct iscsi_portal_group, tpg_se_tpg); \
  727. struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
  728. \
  729. if (!capable(CAP_SYS_ADMIN)) \
  730. return -EPERM; \
  731. \
  732. return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
  733. } \
  734. \
  735. static ssize_t __iscsi_##prefix##_##name##_store(struct se_portal_group *se_tpg,\
  736. const char *page, size_t count) \
  737. { \
  738. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  739. struct iscsi_portal_group, tpg_se_tpg); \
  740. struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
  741. \
  742. if (!capable(CAP_SYS_ADMIN)) \
  743. return -EPERM; \
  744. \
  745. snprintf(auth->name, sizeof(auth->name), "%s", page); \
  746. if (!(strncmp("NULL", auth->name, 4))) \
  747. auth->naf_flags &= ~flags; \
  748. else \
  749. auth->naf_flags |= flags; \
  750. \
  751. if ((auth->naf_flags & NAF_USERID_IN_SET) && \
  752. (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
  753. auth->authenticate_target = 1; \
  754. else \
  755. auth->authenticate_target = 0; \
  756. \
  757. return count; \
  758. }
  759. #define DEF_TPG_AUTH_STR(name, flags) \
  760. __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
  761. static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
  762. char *page) \
  763. { \
  764. return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
  765. } \
  766. \
  767. static ssize_t iscsi_tpg_auth_##name##_store(struct config_item *item, \
  768. const char *page, size_t count) \
  769. { \
  770. return __iscsi_tpg_auth_##name##_store(auth_to_tpg(item), page, count); \
  771. } \
  772. \
  773. CONFIGFS_ATTR(iscsi_tpg_auth_, name);
  774. DEF_TPG_AUTH_STR(userid, NAF_USERID_SET);
  775. DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET);
  776. DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
  777. DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
  778. #define __DEF_TPG_AUTH_INT(prefix, name) \
  779. static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
  780. char *page) \
  781. { \
  782. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  783. struct iscsi_portal_group, tpg_se_tpg); \
  784. struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
  785. \
  786. if (!capable(CAP_SYS_ADMIN)) \
  787. return -EPERM; \
  788. \
  789. return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
  790. }
  791. #define DEF_TPG_AUTH_INT(name) \
  792. __DEF_TPG_AUTH_INT(tpg_auth, name) \
  793. static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
  794. char *page) \
  795. { \
  796. return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
  797. } \
  798. CONFIGFS_ATTR_RO(iscsi_tpg_auth_, name);
  799. DEF_TPG_AUTH_INT(authenticate_target);
  800. static struct configfs_attribute *lio_target_tpg_auth_attrs[] = {
  801. &iscsi_tpg_auth_attr_userid,
  802. &iscsi_tpg_auth_attr_password,
  803. &iscsi_tpg_auth_attr_authenticate_target,
  804. &iscsi_tpg_auth_attr_userid_mutual,
  805. &iscsi_tpg_auth_attr_password_mutual,
  806. NULL,
  807. };
  808. /* End items for lio_target_tpg_auth_cit */
  809. /* Start items for lio_target_tpg_param_cit */
  810. #define DEF_TPG_PARAM(name) \
  811. static ssize_t iscsi_tpg_param_##name##_show(struct config_item *item, \
  812. char *page) \
  813. { \
  814. struct se_portal_group *se_tpg = param_to_tpg(item); \
  815. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  816. struct iscsi_portal_group, tpg_se_tpg); \
  817. struct iscsi_param *param; \
  818. ssize_t rb; \
  819. \
  820. if (iscsit_get_tpg(tpg) < 0) \
  821. return -EINVAL; \
  822. \
  823. param = iscsi_find_param_from_key(__stringify(name), \
  824. tpg->param_list); \
  825. if (!param) { \
  826. iscsit_put_tpg(tpg); \
  827. return -EINVAL; \
  828. } \
  829. rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
  830. \
  831. iscsit_put_tpg(tpg); \
  832. return rb; \
  833. } \
  834. static ssize_t iscsi_tpg_param_##name##_store(struct config_item *item, \
  835. const char *page, size_t count) \
  836. { \
  837. struct se_portal_group *se_tpg = param_to_tpg(item); \
  838. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  839. struct iscsi_portal_group, tpg_se_tpg); \
  840. char *buf; \
  841. int ret, len; \
  842. \
  843. buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
  844. if (!buf) \
  845. return -ENOMEM; \
  846. len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
  847. if (isspace(buf[len-1])) \
  848. buf[len-1] = '\0'; /* Kill newline */ \
  849. \
  850. if (iscsit_get_tpg(tpg) < 0) { \
  851. kfree(buf); \
  852. return -EINVAL; \
  853. } \
  854. \
  855. ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
  856. if (ret < 0) \
  857. goto out; \
  858. \
  859. kfree(buf); \
  860. iscsit_put_tpg(tpg); \
  861. return count; \
  862. out: \
  863. kfree(buf); \
  864. iscsit_put_tpg(tpg); \
  865. return -EINVAL; \
  866. } \
  867. CONFIGFS_ATTR(iscsi_tpg_param_, name)
  868. DEF_TPG_PARAM(AuthMethod);
  869. DEF_TPG_PARAM(HeaderDigest);
  870. DEF_TPG_PARAM(DataDigest);
  871. DEF_TPG_PARAM(MaxConnections);
  872. DEF_TPG_PARAM(TargetAlias);
  873. DEF_TPG_PARAM(InitialR2T);
  874. DEF_TPG_PARAM(ImmediateData);
  875. DEF_TPG_PARAM(MaxRecvDataSegmentLength);
  876. DEF_TPG_PARAM(MaxXmitDataSegmentLength);
  877. DEF_TPG_PARAM(MaxBurstLength);
  878. DEF_TPG_PARAM(FirstBurstLength);
  879. DEF_TPG_PARAM(DefaultTime2Wait);
  880. DEF_TPG_PARAM(DefaultTime2Retain);
  881. DEF_TPG_PARAM(MaxOutstandingR2T);
  882. DEF_TPG_PARAM(DataPDUInOrder);
  883. DEF_TPG_PARAM(DataSequenceInOrder);
  884. DEF_TPG_PARAM(ErrorRecoveryLevel);
  885. DEF_TPG_PARAM(IFMarker);
  886. DEF_TPG_PARAM(OFMarker);
  887. DEF_TPG_PARAM(IFMarkInt);
  888. DEF_TPG_PARAM(OFMarkInt);
  889. static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
  890. &iscsi_tpg_param_attr_AuthMethod,
  891. &iscsi_tpg_param_attr_HeaderDigest,
  892. &iscsi_tpg_param_attr_DataDigest,
  893. &iscsi_tpg_param_attr_MaxConnections,
  894. &iscsi_tpg_param_attr_TargetAlias,
  895. &iscsi_tpg_param_attr_InitialR2T,
  896. &iscsi_tpg_param_attr_ImmediateData,
  897. &iscsi_tpg_param_attr_MaxRecvDataSegmentLength,
  898. &iscsi_tpg_param_attr_MaxXmitDataSegmentLength,
  899. &iscsi_tpg_param_attr_MaxBurstLength,
  900. &iscsi_tpg_param_attr_FirstBurstLength,
  901. &iscsi_tpg_param_attr_DefaultTime2Wait,
  902. &iscsi_tpg_param_attr_DefaultTime2Retain,
  903. &iscsi_tpg_param_attr_MaxOutstandingR2T,
  904. &iscsi_tpg_param_attr_DataPDUInOrder,
  905. &iscsi_tpg_param_attr_DataSequenceInOrder,
  906. &iscsi_tpg_param_attr_ErrorRecoveryLevel,
  907. &iscsi_tpg_param_attr_IFMarker,
  908. &iscsi_tpg_param_attr_OFMarker,
  909. &iscsi_tpg_param_attr_IFMarkInt,
  910. &iscsi_tpg_param_attr_OFMarkInt,
  911. NULL,
  912. };
  913. /* End items for lio_target_tpg_param_cit */
  914. /* Start items for lio_target_tpg_cit */
  915. static ssize_t lio_target_tpg_enable_show(struct config_item *item, char *page)
  916. {
  917. struct se_portal_group *se_tpg = to_tpg(item);
  918. struct iscsi_portal_group *tpg = container_of(se_tpg,
  919. struct iscsi_portal_group, tpg_se_tpg);
  920. ssize_t len;
  921. spin_lock(&tpg->tpg_state_lock);
  922. len = sprintf(page, "%d\n",
  923. (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0);
  924. spin_unlock(&tpg->tpg_state_lock);
  925. return len;
  926. }
  927. static ssize_t lio_target_tpg_enable_store(struct config_item *item,
  928. const char *page, size_t count)
  929. {
  930. struct se_portal_group *se_tpg = to_tpg(item);
  931. struct iscsi_portal_group *tpg = container_of(se_tpg,
  932. struct iscsi_portal_group, tpg_se_tpg);
  933. u32 op;
  934. int ret;
  935. ret = kstrtou32(page, 0, &op);
  936. if (ret)
  937. return ret;
  938. if ((op != 1) && (op != 0)) {
  939. pr_err("Illegal value for tpg_enable: %u\n", op);
  940. return -EINVAL;
  941. }
  942. ret = iscsit_get_tpg(tpg);
  943. if (ret < 0)
  944. return -EINVAL;
  945. if (op) {
  946. ret = iscsit_tpg_enable_portal_group(tpg);
  947. if (ret < 0)
  948. goto out;
  949. } else {
  950. /*
  951. * iscsit_tpg_disable_portal_group() assumes force=1
  952. */
  953. ret = iscsit_tpg_disable_portal_group(tpg, 1);
  954. if (ret < 0)
  955. goto out;
  956. }
  957. iscsit_put_tpg(tpg);
  958. return count;
  959. out:
  960. iscsit_put_tpg(tpg);
  961. return -EINVAL;
  962. }
  963. static ssize_t lio_target_tpg_dynamic_sessions_show(struct config_item *item,
  964. char *page)
  965. {
  966. return target_show_dynamic_sessions(to_tpg(item), page);
  967. }
  968. CONFIGFS_ATTR(lio_target_tpg_, enable);
  969. CONFIGFS_ATTR_RO(lio_target_tpg_, dynamic_sessions);
  970. static struct configfs_attribute *lio_target_tpg_attrs[] = {
  971. &lio_target_tpg_attr_enable,
  972. &lio_target_tpg_attr_dynamic_sessions,
  973. NULL,
  974. };
  975. /* End items for lio_target_tpg_cit */
  976. /* Start items for lio_target_tiqn_cit */
  977. static struct se_portal_group *lio_target_tiqn_addtpg(struct se_wwn *wwn,
  978. const char *name)
  979. {
  980. struct iscsi_portal_group *tpg;
  981. struct iscsi_tiqn *tiqn;
  982. char *tpgt_str;
  983. int ret;
  984. u16 tpgt;
  985. tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
  986. /*
  987. * Only tpgt_# directory groups can be created below
  988. * target/iscsi/iqn.superturodiskarry/
  989. */
  990. tpgt_str = strstr(name, "tpgt_");
  991. if (!tpgt_str) {
  992. pr_err("Unable to locate \"tpgt_#\" directory"
  993. " group\n");
  994. return NULL;
  995. }
  996. tpgt_str += 5; /* Skip ahead of "tpgt_" */
  997. ret = kstrtou16(tpgt_str, 0, &tpgt);
  998. if (ret)
  999. return NULL;
  1000. tpg = iscsit_alloc_portal_group(tiqn, tpgt);
  1001. if (!tpg)
  1002. return NULL;
  1003. ret = core_tpg_register(wwn, &tpg->tpg_se_tpg, SCSI_PROTOCOL_ISCSI);
  1004. if (ret < 0)
  1005. goto free_out;
  1006. ret = iscsit_tpg_add_portal_group(tiqn, tpg);
  1007. if (ret != 0)
  1008. goto out;
  1009. pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
  1010. pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n",
  1011. name);
  1012. return &tpg->tpg_se_tpg;
  1013. out:
  1014. core_tpg_deregister(&tpg->tpg_se_tpg);
  1015. free_out:
  1016. kfree(tpg);
  1017. return NULL;
  1018. }
  1019. static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg)
  1020. {
  1021. struct iscsi_portal_group *tpg;
  1022. struct iscsi_tiqn *tiqn;
  1023. tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
  1024. tiqn = tpg->tpg_tiqn;
  1025. /*
  1026. * iscsit_tpg_del_portal_group() assumes force=1
  1027. */
  1028. pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
  1029. iscsit_tpg_del_portal_group(tiqn, tpg, 1);
  1030. }
  1031. /* End items for lio_target_tiqn_cit */
  1032. /* Start LIO-Target TIQN struct contig_item lio_target_cit */
  1033. static ssize_t lio_target_wwn_lio_version_show(struct config_item *item,
  1034. char *page)
  1035. {
  1036. return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n");
  1037. }
  1038. CONFIGFS_ATTR_RO(lio_target_wwn_, lio_version);
  1039. static struct configfs_attribute *lio_target_wwn_attrs[] = {
  1040. &lio_target_wwn_attr_lio_version,
  1041. NULL,
  1042. };
  1043. static struct se_wwn *lio_target_call_coreaddtiqn(
  1044. struct target_fabric_configfs *tf,
  1045. struct config_group *group,
  1046. const char *name)
  1047. {
  1048. struct iscsi_tiqn *tiqn;
  1049. tiqn = iscsit_add_tiqn((unsigned char *)name);
  1050. if (IS_ERR(tiqn))
  1051. return ERR_CAST(tiqn);
  1052. pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
  1053. pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
  1054. " %s\n", name);
  1055. return &tiqn->tiqn_wwn;
  1056. }
  1057. static void lio_target_add_wwn_groups(struct se_wwn *wwn)
  1058. {
  1059. struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
  1060. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
  1061. "iscsi_instance", &iscsi_stat_instance_cit);
  1062. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_instance_group,
  1063. &tiqn->tiqn_wwn.fabric_stat_group);
  1064. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
  1065. "iscsi_sess_err", &iscsi_stat_sess_err_cit);
  1066. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
  1067. &tiqn->tiqn_wwn.fabric_stat_group);
  1068. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
  1069. "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit);
  1070. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
  1071. &tiqn->tiqn_wwn.fabric_stat_group);
  1072. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
  1073. "iscsi_login_stats", &iscsi_stat_login_cit);
  1074. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
  1075. &tiqn->tiqn_wwn.fabric_stat_group);
  1076. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
  1077. "iscsi_logout_stats", &iscsi_stat_logout_cit);
  1078. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
  1079. &tiqn->tiqn_wwn.fabric_stat_group);
  1080. }
  1081. static void lio_target_call_coredeltiqn(
  1082. struct se_wwn *wwn)
  1083. {
  1084. struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
  1085. pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
  1086. tiqn->tiqn);
  1087. iscsit_del_tiqn(tiqn);
  1088. }
  1089. /* End LIO-Target TIQN struct contig_lio_target_cit */
  1090. /* Start lio_target_discovery_auth_cit */
  1091. #define DEF_DISC_AUTH_STR(name, flags) \
  1092. __DEF_NACL_AUTH_STR(disc, name, flags) \
  1093. static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
  1094. { \
  1095. return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl,\
  1096. page); \
  1097. } \
  1098. static ssize_t iscsi_disc_##name##_store(struct config_item *item, \
  1099. const char *page, size_t count) \
  1100. { \
  1101. return __iscsi_disc_##name##_store(&iscsit_global->discovery_acl, \
  1102. page, count); \
  1103. \
  1104. } \
  1105. CONFIGFS_ATTR(iscsi_disc_, name)
  1106. DEF_DISC_AUTH_STR(userid, NAF_USERID_SET);
  1107. DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET);
  1108. DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
  1109. DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
  1110. #define DEF_DISC_AUTH_INT(name) \
  1111. __DEF_NACL_AUTH_INT(disc, name) \
  1112. static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
  1113. { \
  1114. return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl, \
  1115. page); \
  1116. } \
  1117. CONFIGFS_ATTR_RO(iscsi_disc_, name)
  1118. DEF_DISC_AUTH_INT(authenticate_target);
  1119. static ssize_t iscsi_disc_enforce_discovery_auth_show(struct config_item *item,
  1120. char *page)
  1121. {
  1122. struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth;
  1123. return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth);
  1124. }
  1125. static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
  1126. const char *page, size_t count)
  1127. {
  1128. struct iscsi_param *param;
  1129. struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg;
  1130. u32 op;
  1131. int err;
  1132. err = kstrtou32(page, 0, &op);
  1133. if (err)
  1134. return -EINVAL;
  1135. if ((op != 1) && (op != 0)) {
  1136. pr_err("Illegal value for enforce_discovery_auth:"
  1137. " %u\n", op);
  1138. return -EINVAL;
  1139. }
  1140. if (!discovery_tpg) {
  1141. pr_err("iscsit_global->discovery_tpg is NULL\n");
  1142. return -EINVAL;
  1143. }
  1144. param = iscsi_find_param_from_key(AUTHMETHOD,
  1145. discovery_tpg->param_list);
  1146. if (!param)
  1147. return -EINVAL;
  1148. if (op) {
  1149. /*
  1150. * Reset the AuthMethod key to CHAP.
  1151. */
  1152. if (iscsi_update_param_value(param, CHAP) < 0)
  1153. return -EINVAL;
  1154. discovery_tpg->tpg_attrib.authentication = 1;
  1155. iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
  1156. pr_debug("LIO-CORE[0] Successfully enabled"
  1157. " authentication enforcement for iSCSI"
  1158. " Discovery TPG\n");
  1159. } else {
  1160. /*
  1161. * Reset the AuthMethod key to CHAP,None
  1162. */
  1163. if (iscsi_update_param_value(param, "CHAP,None") < 0)
  1164. return -EINVAL;
  1165. discovery_tpg->tpg_attrib.authentication = 0;
  1166. iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
  1167. pr_debug("LIO-CORE[0] Successfully disabled"
  1168. " authentication enforcement for iSCSI"
  1169. " Discovery TPG\n");
  1170. }
  1171. return count;
  1172. }
  1173. CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
  1174. static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
  1175. &iscsi_disc_attr_userid,
  1176. &iscsi_disc_attr_password,
  1177. &iscsi_disc_attr_authenticate_target,
  1178. &iscsi_disc_attr_userid_mutual,
  1179. &iscsi_disc_attr_password_mutual,
  1180. &iscsi_disc_attr_enforce_discovery_auth,
  1181. NULL,
  1182. };
  1183. /* End lio_target_discovery_auth_cit */
  1184. /* Start functions for target_core_fabric_ops */
  1185. static char *iscsi_get_fabric_name(void)
  1186. {
  1187. return "iSCSI";
  1188. }
  1189. static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
  1190. {
  1191. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1192. return cmd->i_state;
  1193. }
  1194. static u32 lio_sess_get_index(struct se_session *se_sess)
  1195. {
  1196. struct iscsi_session *sess = se_sess->fabric_sess_ptr;
  1197. return sess->session_index;
  1198. }
  1199. static u32 lio_sess_get_initiator_sid(
  1200. struct se_session *se_sess,
  1201. unsigned char *buf,
  1202. u32 size)
  1203. {
  1204. struct iscsi_session *sess = se_sess->fabric_sess_ptr;
  1205. /*
  1206. * iSCSI Initiator Session Identifier from RFC-3720.
  1207. */
  1208. return snprintf(buf, size, "%6phN", sess->isid);
  1209. }
  1210. static int lio_queue_data_in(struct se_cmd *se_cmd)
  1211. {
  1212. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1213. struct iscsi_conn *conn = cmd->conn;
  1214. cmd->i_state = ISTATE_SEND_DATAIN;
  1215. return conn->conn_transport->iscsit_queue_data_in(conn, cmd);
  1216. }
  1217. static int lio_write_pending(struct se_cmd *se_cmd)
  1218. {
  1219. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1220. struct iscsi_conn *conn = cmd->conn;
  1221. if (!cmd->immediate_data && !cmd->unsolicited_data)
  1222. return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
  1223. return 0;
  1224. }
  1225. static int lio_write_pending_status(struct se_cmd *se_cmd)
  1226. {
  1227. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1228. int ret;
  1229. spin_lock_bh(&cmd->istate_lock);
  1230. ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT);
  1231. spin_unlock_bh(&cmd->istate_lock);
  1232. return ret;
  1233. }
  1234. static int lio_queue_status(struct se_cmd *se_cmd)
  1235. {
  1236. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1237. struct iscsi_conn *conn = cmd->conn;
  1238. cmd->i_state = ISTATE_SEND_STATUS;
  1239. if (cmd->se_cmd.scsi_status || cmd->sense_reason) {
  1240. return iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state);
  1241. }
  1242. return conn->conn_transport->iscsit_queue_status(conn, cmd);
  1243. }
  1244. static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
  1245. {
  1246. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1247. cmd->i_state = ISTATE_SEND_TASKMGTRSP;
  1248. iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
  1249. }
  1250. static void lio_aborted_task(struct se_cmd *se_cmd)
  1251. {
  1252. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1253. cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
  1254. }
  1255. static inline struct iscsi_portal_group *iscsi_tpg(struct se_portal_group *se_tpg)
  1256. {
  1257. return container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
  1258. }
  1259. static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
  1260. {
  1261. return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn;
  1262. }
  1263. static u16 lio_tpg_get_tag(struct se_portal_group *se_tpg)
  1264. {
  1265. return iscsi_tpg(se_tpg)->tpgt;
  1266. }
  1267. static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg)
  1268. {
  1269. return iscsi_tpg(se_tpg)->tpg_attrib.default_cmdsn_depth;
  1270. }
  1271. static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
  1272. {
  1273. return iscsi_tpg(se_tpg)->tpg_attrib.generate_node_acls;
  1274. }
  1275. static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
  1276. {
  1277. return iscsi_tpg(se_tpg)->tpg_attrib.cache_dynamic_acls;
  1278. }
  1279. static int lio_tpg_check_demo_mode_write_protect(
  1280. struct se_portal_group *se_tpg)
  1281. {
  1282. return iscsi_tpg(se_tpg)->tpg_attrib.demo_mode_write_protect;
  1283. }
  1284. static int lio_tpg_check_prod_mode_write_protect(
  1285. struct se_portal_group *se_tpg)
  1286. {
  1287. return iscsi_tpg(se_tpg)->tpg_attrib.prod_mode_write_protect;
  1288. }
  1289. static int lio_tpg_check_prot_fabric_only(
  1290. struct se_portal_group *se_tpg)
  1291. {
  1292. /*
  1293. * Only report fabric_prot_type if t10_pi has also been enabled
  1294. * for incoming ib_isert sessions.
  1295. */
  1296. if (!iscsi_tpg(se_tpg)->tpg_attrib.t10_pi)
  1297. return 0;
  1298. return iscsi_tpg(se_tpg)->tpg_attrib.fabric_prot_type;
  1299. }
  1300. /*
  1301. * This function calls iscsit_inc_session_usage_count() on the
  1302. * struct iscsi_session in question.
  1303. */
  1304. static void lio_tpg_close_session(struct se_session *se_sess)
  1305. {
  1306. struct iscsi_session *sess = se_sess->fabric_sess_ptr;
  1307. struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg;
  1308. spin_lock_bh(&se_tpg->session_lock);
  1309. spin_lock(&sess->conn_lock);
  1310. if (atomic_read(&sess->session_fall_back_to_erl0) ||
  1311. atomic_read(&sess->session_logout) ||
  1312. (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
  1313. spin_unlock(&sess->conn_lock);
  1314. spin_unlock_bh(&se_tpg->session_lock);
  1315. return;
  1316. }
  1317. atomic_set(&sess->session_reinstatement, 1);
  1318. atomic_set(&sess->session_fall_back_to_erl0, 1);
  1319. spin_unlock(&sess->conn_lock);
  1320. iscsit_stop_time2retain_timer(sess);
  1321. spin_unlock_bh(&se_tpg->session_lock);
  1322. iscsit_stop_session(sess, 1, 1);
  1323. iscsit_close_session(sess);
  1324. }
  1325. static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg)
  1326. {
  1327. return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn_index;
  1328. }
  1329. static void lio_set_default_node_attributes(struct se_node_acl *se_acl)
  1330. {
  1331. struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl,
  1332. se_node_acl);
  1333. struct se_portal_group *se_tpg = se_acl->se_tpg;
  1334. struct iscsi_portal_group *tpg = container_of(se_tpg,
  1335. struct iscsi_portal_group, tpg_se_tpg);
  1336. acl->node_attrib.nacl = acl;
  1337. iscsit_set_default_node_attribues(acl, tpg);
  1338. }
  1339. static int lio_check_stop_free(struct se_cmd *se_cmd)
  1340. {
  1341. return target_put_sess_cmd(se_cmd);
  1342. }
  1343. static void lio_release_cmd(struct se_cmd *se_cmd)
  1344. {
  1345. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1346. pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
  1347. iscsit_release_cmd(cmd);
  1348. }
  1349. const struct target_core_fabric_ops iscsi_ops = {
  1350. .module = THIS_MODULE,
  1351. .name = "iscsi",
  1352. .node_acl_size = sizeof(struct iscsi_node_acl),
  1353. .get_fabric_name = iscsi_get_fabric_name,
  1354. .tpg_get_wwn = lio_tpg_get_endpoint_wwn,
  1355. .tpg_get_tag = lio_tpg_get_tag,
  1356. .tpg_get_default_depth = lio_tpg_get_default_depth,
  1357. .tpg_check_demo_mode = lio_tpg_check_demo_mode,
  1358. .tpg_check_demo_mode_cache = lio_tpg_check_demo_mode_cache,
  1359. .tpg_check_demo_mode_write_protect =
  1360. lio_tpg_check_demo_mode_write_protect,
  1361. .tpg_check_prod_mode_write_protect =
  1362. lio_tpg_check_prod_mode_write_protect,
  1363. .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only,
  1364. .tpg_get_inst_index = lio_tpg_get_inst_index,
  1365. .check_stop_free = lio_check_stop_free,
  1366. .release_cmd = lio_release_cmd,
  1367. .close_session = lio_tpg_close_session,
  1368. .sess_get_index = lio_sess_get_index,
  1369. .sess_get_initiator_sid = lio_sess_get_initiator_sid,
  1370. .write_pending = lio_write_pending,
  1371. .write_pending_status = lio_write_pending_status,
  1372. .set_default_node_attributes = lio_set_default_node_attributes,
  1373. .get_cmd_state = iscsi_get_cmd_state,
  1374. .queue_data_in = lio_queue_data_in,
  1375. .queue_status = lio_queue_status,
  1376. .queue_tm_rsp = lio_queue_tm_rsp,
  1377. .aborted_task = lio_aborted_task,
  1378. .fabric_make_wwn = lio_target_call_coreaddtiqn,
  1379. .fabric_drop_wwn = lio_target_call_coredeltiqn,
  1380. .add_wwn_groups = lio_target_add_wwn_groups,
  1381. .fabric_make_tpg = lio_target_tiqn_addtpg,
  1382. .fabric_drop_tpg = lio_target_tiqn_deltpg,
  1383. .fabric_make_np = lio_target_call_addnptotpg,
  1384. .fabric_drop_np = lio_target_call_delnpfromtpg,
  1385. .fabric_init_nodeacl = lio_target_init_nodeacl,
  1386. .tfc_discovery_attrs = lio_target_discovery_auth_attrs,
  1387. .tfc_wwn_attrs = lio_target_wwn_attrs,
  1388. .tfc_tpg_base_attrs = lio_target_tpg_attrs,
  1389. .tfc_tpg_attrib_attrs = lio_target_tpg_attrib_attrs,
  1390. .tfc_tpg_auth_attrs = lio_target_tpg_auth_attrs,
  1391. .tfc_tpg_param_attrs = lio_target_tpg_param_attrs,
  1392. .tfc_tpg_np_base_attrs = lio_target_portal_attrs,
  1393. .tfc_tpg_nacl_base_attrs = lio_target_initiator_attrs,
  1394. .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs,
  1395. .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs,
  1396. .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs,
  1397. };