iscsi_target_configfs.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598
  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. static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
  702. &iscsi_tpg_attrib_attr_authentication,
  703. &iscsi_tpg_attrib_attr_login_timeout,
  704. &iscsi_tpg_attrib_attr_netif_timeout,
  705. &iscsi_tpg_attrib_attr_generate_node_acls,
  706. &iscsi_tpg_attrib_attr_default_cmdsn_depth,
  707. &iscsi_tpg_attrib_attr_cache_dynamic_acls,
  708. &iscsi_tpg_attrib_attr_demo_mode_write_protect,
  709. &iscsi_tpg_attrib_attr_prod_mode_write_protect,
  710. &iscsi_tpg_attrib_attr_demo_mode_discovery,
  711. &iscsi_tpg_attrib_attr_default_erl,
  712. &iscsi_tpg_attrib_attr_t10_pi,
  713. &iscsi_tpg_attrib_attr_fabric_prot_type,
  714. &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
  715. NULL,
  716. };
  717. /* End items for lio_target_tpg_attrib_cit */
  718. /* Start items for lio_target_tpg_auth_cit */
  719. #define __DEF_TPG_AUTH_STR(prefix, name, flags) \
  720. static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
  721. char *page) \
  722. { \
  723. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  724. struct iscsi_portal_group, tpg_se_tpg); \
  725. struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
  726. \
  727. if (!capable(CAP_SYS_ADMIN)) \
  728. return -EPERM; \
  729. \
  730. return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
  731. } \
  732. \
  733. static ssize_t __iscsi_##prefix##_##name##_store(struct se_portal_group *se_tpg,\
  734. const char *page, size_t count) \
  735. { \
  736. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  737. struct iscsi_portal_group, tpg_se_tpg); \
  738. struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
  739. \
  740. if (!capable(CAP_SYS_ADMIN)) \
  741. return -EPERM; \
  742. \
  743. snprintf(auth->name, sizeof(auth->name), "%s", page); \
  744. if (!(strncmp("NULL", auth->name, 4))) \
  745. auth->naf_flags &= ~flags; \
  746. else \
  747. auth->naf_flags |= flags; \
  748. \
  749. if ((auth->naf_flags & NAF_USERID_IN_SET) && \
  750. (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
  751. auth->authenticate_target = 1; \
  752. else \
  753. auth->authenticate_target = 0; \
  754. \
  755. return count; \
  756. }
  757. #define DEF_TPG_AUTH_STR(name, flags) \
  758. __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
  759. static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
  760. char *page) \
  761. { \
  762. return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
  763. } \
  764. \
  765. static ssize_t iscsi_tpg_auth_##name##_store(struct config_item *item, \
  766. const char *page, size_t count) \
  767. { \
  768. return __iscsi_tpg_auth_##name##_store(auth_to_tpg(item), page, count); \
  769. } \
  770. \
  771. CONFIGFS_ATTR(iscsi_tpg_auth_, name);
  772. DEF_TPG_AUTH_STR(userid, NAF_USERID_SET);
  773. DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET);
  774. DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
  775. DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
  776. #define __DEF_TPG_AUTH_INT(prefix, name) \
  777. static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
  778. char *page) \
  779. { \
  780. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  781. struct iscsi_portal_group, tpg_se_tpg); \
  782. struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
  783. \
  784. if (!capable(CAP_SYS_ADMIN)) \
  785. return -EPERM; \
  786. \
  787. return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
  788. }
  789. #define DEF_TPG_AUTH_INT(name) \
  790. __DEF_TPG_AUTH_INT(tpg_auth, name) \
  791. static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
  792. char *page) \
  793. { \
  794. return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
  795. } \
  796. CONFIGFS_ATTR_RO(iscsi_tpg_auth_, name);
  797. DEF_TPG_AUTH_INT(authenticate_target);
  798. static struct configfs_attribute *lio_target_tpg_auth_attrs[] = {
  799. &iscsi_tpg_auth_attr_userid,
  800. &iscsi_tpg_auth_attr_password,
  801. &iscsi_tpg_auth_attr_authenticate_target,
  802. &iscsi_tpg_auth_attr_userid_mutual,
  803. &iscsi_tpg_auth_attr_password_mutual,
  804. NULL,
  805. };
  806. /* End items for lio_target_tpg_auth_cit */
  807. /* Start items for lio_target_tpg_param_cit */
  808. #define DEF_TPG_PARAM(name) \
  809. static ssize_t iscsi_tpg_param_##name##_show(struct config_item *item, \
  810. char *page) \
  811. { \
  812. struct se_portal_group *se_tpg = param_to_tpg(item); \
  813. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  814. struct iscsi_portal_group, tpg_se_tpg); \
  815. struct iscsi_param *param; \
  816. ssize_t rb; \
  817. \
  818. if (iscsit_get_tpg(tpg) < 0) \
  819. return -EINVAL; \
  820. \
  821. param = iscsi_find_param_from_key(__stringify(name), \
  822. tpg->param_list); \
  823. if (!param) { \
  824. iscsit_put_tpg(tpg); \
  825. return -EINVAL; \
  826. } \
  827. rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
  828. \
  829. iscsit_put_tpg(tpg); \
  830. return rb; \
  831. } \
  832. static ssize_t iscsi_tpg_param_##name##_store(struct config_item *item, \
  833. const char *page, size_t count) \
  834. { \
  835. struct se_portal_group *se_tpg = param_to_tpg(item); \
  836. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  837. struct iscsi_portal_group, tpg_se_tpg); \
  838. char *buf; \
  839. int ret, len; \
  840. \
  841. buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
  842. if (!buf) \
  843. return -ENOMEM; \
  844. len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
  845. if (isspace(buf[len-1])) \
  846. buf[len-1] = '\0'; /* Kill newline */ \
  847. \
  848. if (iscsit_get_tpg(tpg) < 0) { \
  849. kfree(buf); \
  850. return -EINVAL; \
  851. } \
  852. \
  853. ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
  854. if (ret < 0) \
  855. goto out; \
  856. \
  857. kfree(buf); \
  858. iscsit_put_tpg(tpg); \
  859. return count; \
  860. out: \
  861. kfree(buf); \
  862. iscsit_put_tpg(tpg); \
  863. return -EINVAL; \
  864. } \
  865. CONFIGFS_ATTR(iscsi_tpg_param_, name)
  866. DEF_TPG_PARAM(AuthMethod);
  867. DEF_TPG_PARAM(HeaderDigest);
  868. DEF_TPG_PARAM(DataDigest);
  869. DEF_TPG_PARAM(MaxConnections);
  870. DEF_TPG_PARAM(TargetAlias);
  871. DEF_TPG_PARAM(InitialR2T);
  872. DEF_TPG_PARAM(ImmediateData);
  873. DEF_TPG_PARAM(MaxRecvDataSegmentLength);
  874. DEF_TPG_PARAM(MaxXmitDataSegmentLength);
  875. DEF_TPG_PARAM(MaxBurstLength);
  876. DEF_TPG_PARAM(FirstBurstLength);
  877. DEF_TPG_PARAM(DefaultTime2Wait);
  878. DEF_TPG_PARAM(DefaultTime2Retain);
  879. DEF_TPG_PARAM(MaxOutstandingR2T);
  880. DEF_TPG_PARAM(DataPDUInOrder);
  881. DEF_TPG_PARAM(DataSequenceInOrder);
  882. DEF_TPG_PARAM(ErrorRecoveryLevel);
  883. DEF_TPG_PARAM(IFMarker);
  884. DEF_TPG_PARAM(OFMarker);
  885. DEF_TPG_PARAM(IFMarkInt);
  886. DEF_TPG_PARAM(OFMarkInt);
  887. static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
  888. &iscsi_tpg_param_attr_AuthMethod,
  889. &iscsi_tpg_param_attr_HeaderDigest,
  890. &iscsi_tpg_param_attr_DataDigest,
  891. &iscsi_tpg_param_attr_MaxConnections,
  892. &iscsi_tpg_param_attr_TargetAlias,
  893. &iscsi_tpg_param_attr_InitialR2T,
  894. &iscsi_tpg_param_attr_ImmediateData,
  895. &iscsi_tpg_param_attr_MaxRecvDataSegmentLength,
  896. &iscsi_tpg_param_attr_MaxXmitDataSegmentLength,
  897. &iscsi_tpg_param_attr_MaxBurstLength,
  898. &iscsi_tpg_param_attr_FirstBurstLength,
  899. &iscsi_tpg_param_attr_DefaultTime2Wait,
  900. &iscsi_tpg_param_attr_DefaultTime2Retain,
  901. &iscsi_tpg_param_attr_MaxOutstandingR2T,
  902. &iscsi_tpg_param_attr_DataPDUInOrder,
  903. &iscsi_tpg_param_attr_DataSequenceInOrder,
  904. &iscsi_tpg_param_attr_ErrorRecoveryLevel,
  905. &iscsi_tpg_param_attr_IFMarker,
  906. &iscsi_tpg_param_attr_OFMarker,
  907. &iscsi_tpg_param_attr_IFMarkInt,
  908. &iscsi_tpg_param_attr_OFMarkInt,
  909. NULL,
  910. };
  911. /* End items for lio_target_tpg_param_cit */
  912. /* Start items for lio_target_tpg_cit */
  913. static ssize_t lio_target_tpg_enable_show(struct config_item *item, char *page)
  914. {
  915. struct se_portal_group *se_tpg = to_tpg(item);
  916. struct iscsi_portal_group *tpg = container_of(se_tpg,
  917. struct iscsi_portal_group, tpg_se_tpg);
  918. ssize_t len;
  919. spin_lock(&tpg->tpg_state_lock);
  920. len = sprintf(page, "%d\n",
  921. (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0);
  922. spin_unlock(&tpg->tpg_state_lock);
  923. return len;
  924. }
  925. static ssize_t lio_target_tpg_enable_store(struct config_item *item,
  926. const char *page, size_t count)
  927. {
  928. struct se_portal_group *se_tpg = to_tpg(item);
  929. struct iscsi_portal_group *tpg = container_of(se_tpg,
  930. struct iscsi_portal_group, tpg_se_tpg);
  931. u32 op;
  932. int ret;
  933. ret = kstrtou32(page, 0, &op);
  934. if (ret)
  935. return ret;
  936. if ((op != 1) && (op != 0)) {
  937. pr_err("Illegal value for tpg_enable: %u\n", op);
  938. return -EINVAL;
  939. }
  940. ret = iscsit_get_tpg(tpg);
  941. if (ret < 0)
  942. return -EINVAL;
  943. if (op) {
  944. ret = iscsit_tpg_enable_portal_group(tpg);
  945. if (ret < 0)
  946. goto out;
  947. } else {
  948. /*
  949. * iscsit_tpg_disable_portal_group() assumes force=1
  950. */
  951. ret = iscsit_tpg_disable_portal_group(tpg, 1);
  952. if (ret < 0)
  953. goto out;
  954. }
  955. iscsit_put_tpg(tpg);
  956. return count;
  957. out:
  958. iscsit_put_tpg(tpg);
  959. return -EINVAL;
  960. }
  961. static ssize_t lio_target_tpg_dynamic_sessions_show(struct config_item *item,
  962. char *page)
  963. {
  964. return target_show_dynamic_sessions(to_tpg(item), page);
  965. }
  966. CONFIGFS_ATTR(lio_target_tpg_, enable);
  967. CONFIGFS_ATTR_RO(lio_target_tpg_, dynamic_sessions);
  968. static struct configfs_attribute *lio_target_tpg_attrs[] = {
  969. &lio_target_tpg_attr_enable,
  970. &lio_target_tpg_attr_dynamic_sessions,
  971. NULL,
  972. };
  973. /* End items for lio_target_tpg_cit */
  974. /* Start items for lio_target_tiqn_cit */
  975. static struct se_portal_group *lio_target_tiqn_addtpg(
  976. struct se_wwn *wwn,
  977. struct config_group *group,
  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. return NULL;
  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. kfree(tpg);
  1016. return NULL;
  1017. }
  1018. static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg)
  1019. {
  1020. struct iscsi_portal_group *tpg;
  1021. struct iscsi_tiqn *tiqn;
  1022. tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
  1023. tiqn = tpg->tpg_tiqn;
  1024. /*
  1025. * iscsit_tpg_del_portal_group() assumes force=1
  1026. */
  1027. pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
  1028. iscsit_tpg_del_portal_group(tiqn, tpg, 1);
  1029. }
  1030. /* End items for lio_target_tiqn_cit */
  1031. /* Start LIO-Target TIQN struct contig_item lio_target_cit */
  1032. static ssize_t lio_target_wwn_lio_version_show(struct config_item *item,
  1033. char *page)
  1034. {
  1035. return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n");
  1036. }
  1037. CONFIGFS_ATTR_RO(lio_target_wwn_, lio_version);
  1038. static struct configfs_attribute *lio_target_wwn_attrs[] = {
  1039. &lio_target_wwn_attr_lio_version,
  1040. NULL,
  1041. };
  1042. static struct se_wwn *lio_target_call_coreaddtiqn(
  1043. struct target_fabric_configfs *tf,
  1044. struct config_group *group,
  1045. const char *name)
  1046. {
  1047. struct iscsi_tiqn *tiqn;
  1048. tiqn = iscsit_add_tiqn((unsigned char *)name);
  1049. if (IS_ERR(tiqn))
  1050. return ERR_CAST(tiqn);
  1051. pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
  1052. pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
  1053. " %s\n", name);
  1054. return &tiqn->tiqn_wwn;
  1055. }
  1056. static void lio_target_add_wwn_groups(struct se_wwn *wwn)
  1057. {
  1058. struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
  1059. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
  1060. "iscsi_instance", &iscsi_stat_instance_cit);
  1061. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_instance_group,
  1062. &tiqn->tiqn_wwn.fabric_stat_group);
  1063. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
  1064. "iscsi_sess_err", &iscsi_stat_sess_err_cit);
  1065. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
  1066. &tiqn->tiqn_wwn.fabric_stat_group);
  1067. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
  1068. "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit);
  1069. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
  1070. &tiqn->tiqn_wwn.fabric_stat_group);
  1071. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
  1072. "iscsi_login_stats", &iscsi_stat_login_cit);
  1073. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
  1074. &tiqn->tiqn_wwn.fabric_stat_group);
  1075. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
  1076. "iscsi_logout_stats", &iscsi_stat_logout_cit);
  1077. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
  1078. &tiqn->tiqn_wwn.fabric_stat_group);
  1079. }
  1080. static void lio_target_call_coredeltiqn(
  1081. struct se_wwn *wwn)
  1082. {
  1083. struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
  1084. pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
  1085. tiqn->tiqn);
  1086. iscsit_del_tiqn(tiqn);
  1087. }
  1088. /* End LIO-Target TIQN struct contig_lio_target_cit */
  1089. /* Start lio_target_discovery_auth_cit */
  1090. #define DEF_DISC_AUTH_STR(name, flags) \
  1091. __DEF_NACL_AUTH_STR(disc, name, flags) \
  1092. static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
  1093. { \
  1094. return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl,\
  1095. page); \
  1096. } \
  1097. static ssize_t iscsi_disc_##name##_store(struct config_item *item, \
  1098. const char *page, size_t count) \
  1099. { \
  1100. return __iscsi_disc_##name##_store(&iscsit_global->discovery_acl, \
  1101. page, count); \
  1102. \
  1103. } \
  1104. CONFIGFS_ATTR(iscsi_disc_, name)
  1105. DEF_DISC_AUTH_STR(userid, NAF_USERID_SET);
  1106. DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET);
  1107. DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
  1108. DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
  1109. #define DEF_DISC_AUTH_INT(name) \
  1110. __DEF_NACL_AUTH_INT(disc, name) \
  1111. static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
  1112. { \
  1113. return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl, \
  1114. page); \
  1115. } \
  1116. CONFIGFS_ATTR_RO(iscsi_disc_, name)
  1117. DEF_DISC_AUTH_INT(authenticate_target);
  1118. static ssize_t iscsi_disc_enforce_discovery_auth_show(struct config_item *item,
  1119. char *page)
  1120. {
  1121. struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth;
  1122. return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth);
  1123. }
  1124. static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
  1125. const char *page, size_t count)
  1126. {
  1127. struct iscsi_param *param;
  1128. struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg;
  1129. u32 op;
  1130. int err;
  1131. err = kstrtou32(page, 0, &op);
  1132. if (err)
  1133. return -EINVAL;
  1134. if ((op != 1) && (op != 0)) {
  1135. pr_err("Illegal value for enforce_discovery_auth:"
  1136. " %u\n", op);
  1137. return -EINVAL;
  1138. }
  1139. if (!discovery_tpg) {
  1140. pr_err("iscsit_global->discovery_tpg is NULL\n");
  1141. return -EINVAL;
  1142. }
  1143. param = iscsi_find_param_from_key(AUTHMETHOD,
  1144. discovery_tpg->param_list);
  1145. if (!param)
  1146. return -EINVAL;
  1147. if (op) {
  1148. /*
  1149. * Reset the AuthMethod key to CHAP.
  1150. */
  1151. if (iscsi_update_param_value(param, CHAP) < 0)
  1152. return -EINVAL;
  1153. discovery_tpg->tpg_attrib.authentication = 1;
  1154. iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
  1155. pr_debug("LIO-CORE[0] Successfully enabled"
  1156. " authentication enforcement for iSCSI"
  1157. " Discovery TPG\n");
  1158. } else {
  1159. /*
  1160. * Reset the AuthMethod key to CHAP,None
  1161. */
  1162. if (iscsi_update_param_value(param, "CHAP,None") < 0)
  1163. return -EINVAL;
  1164. discovery_tpg->tpg_attrib.authentication = 0;
  1165. iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
  1166. pr_debug("LIO-CORE[0] Successfully disabled"
  1167. " authentication enforcement for iSCSI"
  1168. " Discovery TPG\n");
  1169. }
  1170. return count;
  1171. }
  1172. CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
  1173. static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
  1174. &iscsi_disc_attr_userid,
  1175. &iscsi_disc_attr_password,
  1176. &iscsi_disc_attr_authenticate_target,
  1177. &iscsi_disc_attr_userid_mutual,
  1178. &iscsi_disc_attr_password_mutual,
  1179. &iscsi_disc_attr_enforce_discovery_auth,
  1180. NULL,
  1181. };
  1182. /* End lio_target_discovery_auth_cit */
  1183. /* Start functions for target_core_fabric_ops */
  1184. static char *iscsi_get_fabric_name(void)
  1185. {
  1186. return "iSCSI";
  1187. }
  1188. static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
  1189. {
  1190. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1191. return cmd->i_state;
  1192. }
  1193. static u32 lio_sess_get_index(struct se_session *se_sess)
  1194. {
  1195. struct iscsi_session *sess = se_sess->fabric_sess_ptr;
  1196. return sess->session_index;
  1197. }
  1198. static u32 lio_sess_get_initiator_sid(
  1199. struct se_session *se_sess,
  1200. unsigned char *buf,
  1201. u32 size)
  1202. {
  1203. struct iscsi_session *sess = se_sess->fabric_sess_ptr;
  1204. /*
  1205. * iSCSI Initiator Session Identifier from RFC-3720.
  1206. */
  1207. return snprintf(buf, size, "%6phN", sess->isid);
  1208. }
  1209. static int lio_queue_data_in(struct se_cmd *se_cmd)
  1210. {
  1211. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1212. struct iscsi_conn *conn = cmd->conn;
  1213. cmd->i_state = ISTATE_SEND_DATAIN;
  1214. return conn->conn_transport->iscsit_queue_data_in(conn, cmd);
  1215. }
  1216. static int lio_write_pending(struct se_cmd *se_cmd)
  1217. {
  1218. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1219. struct iscsi_conn *conn = cmd->conn;
  1220. if (!cmd->immediate_data && !cmd->unsolicited_data)
  1221. return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
  1222. return 0;
  1223. }
  1224. static int lio_write_pending_status(struct se_cmd *se_cmd)
  1225. {
  1226. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1227. int ret;
  1228. spin_lock_bh(&cmd->istate_lock);
  1229. ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT);
  1230. spin_unlock_bh(&cmd->istate_lock);
  1231. return ret;
  1232. }
  1233. static int lio_queue_status(struct se_cmd *se_cmd)
  1234. {
  1235. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1236. struct iscsi_conn *conn = cmd->conn;
  1237. cmd->i_state = ISTATE_SEND_STATUS;
  1238. if (cmd->se_cmd.scsi_status || cmd->sense_reason) {
  1239. return iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state);
  1240. }
  1241. return conn->conn_transport->iscsit_queue_status(conn, cmd);
  1242. }
  1243. static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
  1244. {
  1245. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1246. cmd->i_state = ISTATE_SEND_TASKMGTRSP;
  1247. iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
  1248. }
  1249. static void lio_aborted_task(struct se_cmd *se_cmd)
  1250. {
  1251. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1252. cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
  1253. }
  1254. static inline struct iscsi_portal_group *iscsi_tpg(struct se_portal_group *se_tpg)
  1255. {
  1256. return container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
  1257. }
  1258. static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
  1259. {
  1260. return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn;
  1261. }
  1262. static u16 lio_tpg_get_tag(struct se_portal_group *se_tpg)
  1263. {
  1264. return iscsi_tpg(se_tpg)->tpgt;
  1265. }
  1266. static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg)
  1267. {
  1268. return iscsi_tpg(se_tpg)->tpg_attrib.default_cmdsn_depth;
  1269. }
  1270. static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
  1271. {
  1272. return iscsi_tpg(se_tpg)->tpg_attrib.generate_node_acls;
  1273. }
  1274. static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
  1275. {
  1276. return iscsi_tpg(se_tpg)->tpg_attrib.cache_dynamic_acls;
  1277. }
  1278. static int lio_tpg_check_demo_mode_write_protect(
  1279. struct se_portal_group *se_tpg)
  1280. {
  1281. return iscsi_tpg(se_tpg)->tpg_attrib.demo_mode_write_protect;
  1282. }
  1283. static int lio_tpg_check_prod_mode_write_protect(
  1284. struct se_portal_group *se_tpg)
  1285. {
  1286. return iscsi_tpg(se_tpg)->tpg_attrib.prod_mode_write_protect;
  1287. }
  1288. static int lio_tpg_check_prot_fabric_only(
  1289. struct se_portal_group *se_tpg)
  1290. {
  1291. /*
  1292. * Only report fabric_prot_type if t10_pi has also been enabled
  1293. * for incoming ib_isert sessions.
  1294. */
  1295. if (!iscsi_tpg(se_tpg)->tpg_attrib.t10_pi)
  1296. return 0;
  1297. return iscsi_tpg(se_tpg)->tpg_attrib.fabric_prot_type;
  1298. }
  1299. /*
  1300. * This function calls iscsit_inc_session_usage_count() on the
  1301. * struct iscsi_session in question.
  1302. */
  1303. static void lio_tpg_close_session(struct se_session *se_sess)
  1304. {
  1305. struct iscsi_session *sess = se_sess->fabric_sess_ptr;
  1306. struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg;
  1307. spin_lock_bh(&se_tpg->session_lock);
  1308. spin_lock(&sess->conn_lock);
  1309. if (atomic_read(&sess->session_fall_back_to_erl0) ||
  1310. atomic_read(&sess->session_logout) ||
  1311. (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
  1312. spin_unlock(&sess->conn_lock);
  1313. spin_unlock_bh(&se_tpg->session_lock);
  1314. return;
  1315. }
  1316. atomic_set(&sess->session_reinstatement, 1);
  1317. atomic_set(&sess->session_fall_back_to_erl0, 1);
  1318. spin_unlock(&sess->conn_lock);
  1319. iscsit_stop_time2retain_timer(sess);
  1320. spin_unlock_bh(&se_tpg->session_lock);
  1321. iscsit_stop_session(sess, 1, 1);
  1322. iscsit_close_session(sess);
  1323. }
  1324. static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg)
  1325. {
  1326. return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn_index;
  1327. }
  1328. static void lio_set_default_node_attributes(struct se_node_acl *se_acl)
  1329. {
  1330. struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl,
  1331. se_node_acl);
  1332. struct se_portal_group *se_tpg = se_acl->se_tpg;
  1333. struct iscsi_portal_group *tpg = container_of(se_tpg,
  1334. struct iscsi_portal_group, tpg_se_tpg);
  1335. acl->node_attrib.nacl = acl;
  1336. iscsit_set_default_node_attribues(acl, tpg);
  1337. }
  1338. static int lio_check_stop_free(struct se_cmd *se_cmd)
  1339. {
  1340. return target_put_sess_cmd(se_cmd);
  1341. }
  1342. static void lio_release_cmd(struct se_cmd *se_cmd)
  1343. {
  1344. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1345. pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
  1346. iscsit_release_cmd(cmd);
  1347. }
  1348. const struct target_core_fabric_ops iscsi_ops = {
  1349. .module = THIS_MODULE,
  1350. .name = "iscsi",
  1351. .node_acl_size = sizeof(struct iscsi_node_acl),
  1352. .get_fabric_name = iscsi_get_fabric_name,
  1353. .tpg_get_wwn = lio_tpg_get_endpoint_wwn,
  1354. .tpg_get_tag = lio_tpg_get_tag,
  1355. .tpg_get_default_depth = lio_tpg_get_default_depth,
  1356. .tpg_check_demo_mode = lio_tpg_check_demo_mode,
  1357. .tpg_check_demo_mode_cache = lio_tpg_check_demo_mode_cache,
  1358. .tpg_check_demo_mode_write_protect =
  1359. lio_tpg_check_demo_mode_write_protect,
  1360. .tpg_check_prod_mode_write_protect =
  1361. lio_tpg_check_prod_mode_write_protect,
  1362. .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only,
  1363. .tpg_get_inst_index = lio_tpg_get_inst_index,
  1364. .check_stop_free = lio_check_stop_free,
  1365. .release_cmd = lio_release_cmd,
  1366. .close_session = lio_tpg_close_session,
  1367. .sess_get_index = lio_sess_get_index,
  1368. .sess_get_initiator_sid = lio_sess_get_initiator_sid,
  1369. .write_pending = lio_write_pending,
  1370. .write_pending_status = lio_write_pending_status,
  1371. .set_default_node_attributes = lio_set_default_node_attributes,
  1372. .get_cmd_state = iscsi_get_cmd_state,
  1373. .queue_data_in = lio_queue_data_in,
  1374. .queue_status = lio_queue_status,
  1375. .queue_tm_rsp = lio_queue_tm_rsp,
  1376. .aborted_task = lio_aborted_task,
  1377. .fabric_make_wwn = lio_target_call_coreaddtiqn,
  1378. .fabric_drop_wwn = lio_target_call_coredeltiqn,
  1379. .add_wwn_groups = lio_target_add_wwn_groups,
  1380. .fabric_make_tpg = lio_target_tiqn_addtpg,
  1381. .fabric_drop_tpg = lio_target_tiqn_deltpg,
  1382. .fabric_make_np = lio_target_call_addnptotpg,
  1383. .fabric_drop_np = lio_target_call_delnpfromtpg,
  1384. .fabric_init_nodeacl = lio_target_init_nodeacl,
  1385. .tfc_discovery_attrs = lio_target_discovery_auth_attrs,
  1386. .tfc_wwn_attrs = lio_target_wwn_attrs,
  1387. .tfc_tpg_base_attrs = lio_target_tpg_attrs,
  1388. .tfc_tpg_attrib_attrs = lio_target_tpg_attrib_attrs,
  1389. .tfc_tpg_auth_attrs = lio_target_tpg_auth_attrs,
  1390. .tfc_tpg_param_attrs = lio_target_tpg_param_attrs,
  1391. .tfc_tpg_np_base_attrs = lio_target_portal_attrs,
  1392. .tfc_tpg_nacl_base_attrs = lio_target_initiator_attrs,
  1393. .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs,
  1394. .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs,
  1395. .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs,
  1396. };