target_core_stat.c 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559
  1. /*******************************************************************************
  2. * Filename: target_core_stat.c
  3. *
  4. * Modern ConfigFS group context specific statistics based on original
  5. * target_core_mib.c code
  6. *
  7. * (c) Copyright 2006-2013 Datera, Inc.
  8. *
  9. * Nicholas A. Bellinger <nab@linux-iscsi.org>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  24. *
  25. ******************************************************************************/
  26. #include <linux/kernel.h>
  27. #include <linux/module.h>
  28. #include <linux/delay.h>
  29. #include <linux/timer.h>
  30. #include <linux/string.h>
  31. #include <linux/utsname.h>
  32. #include <linux/proc_fs.h>
  33. #include <linux/seq_file.h>
  34. #include <linux/configfs.h>
  35. #include <target/target_core_base.h>
  36. #include <target/target_core_backend.h>
  37. #include <target/target_core_fabric.h>
  38. #include <target/configfs_macros.h>
  39. #include "target_core_internal.h"
  40. #ifndef INITIAL_JIFFIES
  41. #define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
  42. #endif
  43. #define NONE "None"
  44. #define ISPRINT(a) ((a >= ' ') && (a <= '~'))
  45. #define SCSI_LU_INDEX 1
  46. #define LU_COUNT 1
  47. /*
  48. * SCSI Device Table
  49. */
  50. CONFIGFS_EATTR_STRUCT(target_stat_scsi_dev, se_dev_stat_grps);
  51. #define DEV_STAT_SCSI_DEV_ATTR(_name, _mode) \
  52. static struct target_stat_scsi_dev_attribute \
  53. target_stat_scsi_dev_##_name = \
  54. __CONFIGFS_EATTR(_name, _mode, \
  55. target_stat_scsi_dev_show_attr_##_name, \
  56. target_stat_scsi_dev_store_attr_##_name);
  57. #define DEV_STAT_SCSI_DEV_ATTR_RO(_name) \
  58. static struct target_stat_scsi_dev_attribute \
  59. target_stat_scsi_dev_##_name = \
  60. __CONFIGFS_EATTR_RO(_name, \
  61. target_stat_scsi_dev_show_attr_##_name);
  62. static ssize_t target_stat_scsi_dev_show_attr_inst(
  63. struct se_dev_stat_grps *sgrps, char *page)
  64. {
  65. struct se_device *dev =
  66. container_of(sgrps, struct se_device, dev_stat_grps);
  67. struct se_hba *hba = dev->se_hba;
  68. return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
  69. }
  70. DEV_STAT_SCSI_DEV_ATTR_RO(inst);
  71. static ssize_t target_stat_scsi_dev_show_attr_indx(
  72. struct se_dev_stat_grps *sgrps, char *page)
  73. {
  74. struct se_device *dev =
  75. container_of(sgrps, struct se_device, dev_stat_grps);
  76. return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
  77. }
  78. DEV_STAT_SCSI_DEV_ATTR_RO(indx);
  79. static ssize_t target_stat_scsi_dev_show_attr_role(
  80. struct se_dev_stat_grps *sgrps, char *page)
  81. {
  82. return snprintf(page, PAGE_SIZE, "Target\n");
  83. }
  84. DEV_STAT_SCSI_DEV_ATTR_RO(role);
  85. static ssize_t target_stat_scsi_dev_show_attr_ports(
  86. struct se_dev_stat_grps *sgrps, char *page)
  87. {
  88. struct se_device *dev =
  89. container_of(sgrps, struct se_device, dev_stat_grps);
  90. return snprintf(page, PAGE_SIZE, "%u\n", dev->export_count);
  91. }
  92. DEV_STAT_SCSI_DEV_ATTR_RO(ports);
  93. CONFIGFS_EATTR_OPS(target_stat_scsi_dev, se_dev_stat_grps, scsi_dev_group);
  94. static struct configfs_attribute *target_stat_scsi_dev_attrs[] = {
  95. &target_stat_scsi_dev_inst.attr,
  96. &target_stat_scsi_dev_indx.attr,
  97. &target_stat_scsi_dev_role.attr,
  98. &target_stat_scsi_dev_ports.attr,
  99. NULL,
  100. };
  101. static struct configfs_item_operations target_stat_scsi_dev_attrib_ops = {
  102. .show_attribute = target_stat_scsi_dev_attr_show,
  103. .store_attribute = target_stat_scsi_dev_attr_store,
  104. };
  105. static struct config_item_type target_stat_scsi_dev_cit = {
  106. .ct_item_ops = &target_stat_scsi_dev_attrib_ops,
  107. .ct_attrs = target_stat_scsi_dev_attrs,
  108. .ct_owner = THIS_MODULE,
  109. };
  110. /*
  111. * SCSI Target Device Table
  112. */
  113. CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_dev, se_dev_stat_grps);
  114. #define DEV_STAT_SCSI_TGT_DEV_ATTR(_name, _mode) \
  115. static struct target_stat_scsi_tgt_dev_attribute \
  116. target_stat_scsi_tgt_dev_##_name = \
  117. __CONFIGFS_EATTR(_name, _mode, \
  118. target_stat_scsi_tgt_dev_show_attr_##_name, \
  119. target_stat_scsi_tgt_dev_store_attr_##_name);
  120. #define DEV_STAT_SCSI_TGT_DEV_ATTR_RO(_name) \
  121. static struct target_stat_scsi_tgt_dev_attribute \
  122. target_stat_scsi_tgt_dev_##_name = \
  123. __CONFIGFS_EATTR_RO(_name, \
  124. target_stat_scsi_tgt_dev_show_attr_##_name);
  125. static ssize_t target_stat_scsi_tgt_dev_show_attr_inst(
  126. struct se_dev_stat_grps *sgrps, char *page)
  127. {
  128. struct se_device *dev =
  129. container_of(sgrps, struct se_device, dev_stat_grps);
  130. struct se_hba *hba = dev->se_hba;
  131. return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
  132. }
  133. DEV_STAT_SCSI_TGT_DEV_ATTR_RO(inst);
  134. static ssize_t target_stat_scsi_tgt_dev_show_attr_indx(
  135. struct se_dev_stat_grps *sgrps, char *page)
  136. {
  137. struct se_device *dev =
  138. container_of(sgrps, struct se_device, dev_stat_grps);
  139. return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
  140. }
  141. DEV_STAT_SCSI_TGT_DEV_ATTR_RO(indx);
  142. static ssize_t target_stat_scsi_tgt_dev_show_attr_num_lus(
  143. struct se_dev_stat_grps *sgrps, char *page)
  144. {
  145. return snprintf(page, PAGE_SIZE, "%u\n", LU_COUNT);
  146. }
  147. DEV_STAT_SCSI_TGT_DEV_ATTR_RO(num_lus);
  148. static ssize_t target_stat_scsi_tgt_dev_show_attr_status(
  149. struct se_dev_stat_grps *sgrps, char *page)
  150. {
  151. struct se_device *dev =
  152. container_of(sgrps, struct se_device, dev_stat_grps);
  153. if (dev->export_count)
  154. return snprintf(page, PAGE_SIZE, "activated");
  155. else
  156. return snprintf(page, PAGE_SIZE, "deactivated");
  157. }
  158. DEV_STAT_SCSI_TGT_DEV_ATTR_RO(status);
  159. static ssize_t target_stat_scsi_tgt_dev_show_attr_non_access_lus(
  160. struct se_dev_stat_grps *sgrps, char *page)
  161. {
  162. struct se_device *dev =
  163. container_of(sgrps, struct se_device, dev_stat_grps);
  164. int non_accessible_lus;
  165. if (dev->export_count)
  166. non_accessible_lus = 0;
  167. else
  168. non_accessible_lus = 1;
  169. return snprintf(page, PAGE_SIZE, "%u\n", non_accessible_lus);
  170. }
  171. DEV_STAT_SCSI_TGT_DEV_ATTR_RO(non_access_lus);
  172. static ssize_t target_stat_scsi_tgt_dev_show_attr_resets(
  173. struct se_dev_stat_grps *sgrps, char *page)
  174. {
  175. struct se_device *dev =
  176. container_of(sgrps, struct se_device, dev_stat_grps);
  177. return snprintf(page, PAGE_SIZE, "%lu\n",
  178. atomic_long_read(&dev->num_resets));
  179. }
  180. DEV_STAT_SCSI_TGT_DEV_ATTR_RO(resets);
  181. CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_dev, se_dev_stat_grps, scsi_tgt_dev_group);
  182. static struct configfs_attribute *target_stat_scsi_tgt_dev_attrs[] = {
  183. &target_stat_scsi_tgt_dev_inst.attr,
  184. &target_stat_scsi_tgt_dev_indx.attr,
  185. &target_stat_scsi_tgt_dev_num_lus.attr,
  186. &target_stat_scsi_tgt_dev_status.attr,
  187. &target_stat_scsi_tgt_dev_non_access_lus.attr,
  188. &target_stat_scsi_tgt_dev_resets.attr,
  189. NULL,
  190. };
  191. static struct configfs_item_operations target_stat_scsi_tgt_dev_attrib_ops = {
  192. .show_attribute = target_stat_scsi_tgt_dev_attr_show,
  193. .store_attribute = target_stat_scsi_tgt_dev_attr_store,
  194. };
  195. static struct config_item_type target_stat_scsi_tgt_dev_cit = {
  196. .ct_item_ops = &target_stat_scsi_tgt_dev_attrib_ops,
  197. .ct_attrs = target_stat_scsi_tgt_dev_attrs,
  198. .ct_owner = THIS_MODULE,
  199. };
  200. /*
  201. * SCSI Logical Unit Table
  202. */
  203. CONFIGFS_EATTR_STRUCT(target_stat_scsi_lu, se_dev_stat_grps);
  204. #define DEV_STAT_SCSI_LU_ATTR(_name, _mode) \
  205. static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \
  206. __CONFIGFS_EATTR(_name, _mode, \
  207. target_stat_scsi_lu_show_attr_##_name, \
  208. target_stat_scsi_lu_store_attr_##_name);
  209. #define DEV_STAT_SCSI_LU_ATTR_RO(_name) \
  210. static struct target_stat_scsi_lu_attribute target_stat_scsi_lu_##_name = \
  211. __CONFIGFS_EATTR_RO(_name, \
  212. target_stat_scsi_lu_show_attr_##_name);
  213. static ssize_t target_stat_scsi_lu_show_attr_inst(
  214. struct se_dev_stat_grps *sgrps, char *page)
  215. {
  216. struct se_device *dev =
  217. container_of(sgrps, struct se_device, dev_stat_grps);
  218. struct se_hba *hba = dev->se_hba;
  219. return snprintf(page, PAGE_SIZE, "%u\n", hba->hba_index);
  220. }
  221. DEV_STAT_SCSI_LU_ATTR_RO(inst);
  222. static ssize_t target_stat_scsi_lu_show_attr_dev(
  223. struct se_dev_stat_grps *sgrps, char *page)
  224. {
  225. struct se_device *dev =
  226. container_of(sgrps, struct se_device, dev_stat_grps);
  227. return snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
  228. }
  229. DEV_STAT_SCSI_LU_ATTR_RO(dev);
  230. static ssize_t target_stat_scsi_lu_show_attr_indx(
  231. struct se_dev_stat_grps *sgrps, char *page)
  232. {
  233. return snprintf(page, PAGE_SIZE, "%u\n", SCSI_LU_INDEX);
  234. }
  235. DEV_STAT_SCSI_LU_ATTR_RO(indx);
  236. static ssize_t target_stat_scsi_lu_show_attr_lun(
  237. struct se_dev_stat_grps *sgrps, char *page)
  238. {
  239. /* FIXME: scsiLuDefaultLun */
  240. return snprintf(page, PAGE_SIZE, "%llu\n", (unsigned long long)0);
  241. }
  242. DEV_STAT_SCSI_LU_ATTR_RO(lun);
  243. static ssize_t target_stat_scsi_lu_show_attr_lu_name(
  244. struct se_dev_stat_grps *sgrps, char *page)
  245. {
  246. struct se_device *dev =
  247. container_of(sgrps, struct se_device, dev_stat_grps);
  248. /* scsiLuWwnName */
  249. return snprintf(page, PAGE_SIZE, "%s\n",
  250. (strlen(dev->t10_wwn.unit_serial)) ?
  251. dev->t10_wwn.unit_serial : "None");
  252. }
  253. DEV_STAT_SCSI_LU_ATTR_RO(lu_name);
  254. static ssize_t target_stat_scsi_lu_show_attr_vend(
  255. struct se_dev_stat_grps *sgrps, char *page)
  256. {
  257. struct se_device *dev =
  258. container_of(sgrps, struct se_device, dev_stat_grps);
  259. int i;
  260. char str[sizeof(dev->t10_wwn.vendor)+1];
  261. /* scsiLuVendorId */
  262. for (i = 0; i < sizeof(dev->t10_wwn.vendor); i++)
  263. str[i] = ISPRINT(dev->t10_wwn.vendor[i]) ?
  264. dev->t10_wwn.vendor[i] : ' ';
  265. str[i] = '\0';
  266. return snprintf(page, PAGE_SIZE, "%s\n", str);
  267. }
  268. DEV_STAT_SCSI_LU_ATTR_RO(vend);
  269. static ssize_t target_stat_scsi_lu_show_attr_prod(
  270. struct se_dev_stat_grps *sgrps, char *page)
  271. {
  272. struct se_device *dev =
  273. container_of(sgrps, struct se_device, dev_stat_grps);
  274. int i;
  275. char str[sizeof(dev->t10_wwn.model)+1];
  276. /* scsiLuProductId */
  277. for (i = 0; i < sizeof(dev->t10_wwn.vendor); i++)
  278. str[i] = ISPRINT(dev->t10_wwn.model[i]) ?
  279. dev->t10_wwn.model[i] : ' ';
  280. str[i] = '\0';
  281. return snprintf(page, PAGE_SIZE, "%s\n", str);
  282. }
  283. DEV_STAT_SCSI_LU_ATTR_RO(prod);
  284. static ssize_t target_stat_scsi_lu_show_attr_rev(
  285. struct se_dev_stat_grps *sgrps, char *page)
  286. {
  287. struct se_device *dev =
  288. container_of(sgrps, struct se_device, dev_stat_grps);
  289. int i;
  290. char str[sizeof(dev->t10_wwn.revision)+1];
  291. /* scsiLuRevisionId */
  292. for (i = 0; i < sizeof(dev->t10_wwn.revision); i++)
  293. str[i] = ISPRINT(dev->t10_wwn.revision[i]) ?
  294. dev->t10_wwn.revision[i] : ' ';
  295. str[i] = '\0';
  296. return snprintf(page, PAGE_SIZE, "%s\n", str);
  297. }
  298. DEV_STAT_SCSI_LU_ATTR_RO(rev);
  299. static ssize_t target_stat_scsi_lu_show_attr_dev_type(
  300. struct se_dev_stat_grps *sgrps, char *page)
  301. {
  302. struct se_device *dev =
  303. container_of(sgrps, struct se_device, dev_stat_grps);
  304. /* scsiLuPeripheralType */
  305. return snprintf(page, PAGE_SIZE, "%u\n",
  306. dev->transport->get_device_type(dev));
  307. }
  308. DEV_STAT_SCSI_LU_ATTR_RO(dev_type);
  309. static ssize_t target_stat_scsi_lu_show_attr_status(
  310. struct se_dev_stat_grps *sgrps, char *page)
  311. {
  312. struct se_device *dev =
  313. container_of(sgrps, struct se_device, dev_stat_grps);
  314. /* scsiLuStatus */
  315. return snprintf(page, PAGE_SIZE, "%s\n",
  316. (dev->export_count) ? "available" : "notavailable");
  317. }
  318. DEV_STAT_SCSI_LU_ATTR_RO(status);
  319. static ssize_t target_stat_scsi_lu_show_attr_state_bit(
  320. struct se_dev_stat_grps *sgrps, char *page)
  321. {
  322. /* scsiLuState */
  323. return snprintf(page, PAGE_SIZE, "exposed\n");
  324. }
  325. DEV_STAT_SCSI_LU_ATTR_RO(state_bit);
  326. static ssize_t target_stat_scsi_lu_show_attr_num_cmds(
  327. struct se_dev_stat_grps *sgrps, char *page)
  328. {
  329. struct se_device *dev =
  330. container_of(sgrps, struct se_device, dev_stat_grps);
  331. /* scsiLuNumCommands */
  332. return snprintf(page, PAGE_SIZE, "%lu\n",
  333. atomic_long_read(&dev->num_cmds));
  334. }
  335. DEV_STAT_SCSI_LU_ATTR_RO(num_cmds);
  336. static ssize_t target_stat_scsi_lu_show_attr_read_mbytes(
  337. struct se_dev_stat_grps *sgrps, char *page)
  338. {
  339. struct se_device *dev =
  340. container_of(sgrps, struct se_device, dev_stat_grps);
  341. /* scsiLuReadMegaBytes */
  342. return snprintf(page, PAGE_SIZE, "%lu\n",
  343. atomic_long_read(&dev->read_bytes) >> 20);
  344. }
  345. DEV_STAT_SCSI_LU_ATTR_RO(read_mbytes);
  346. static ssize_t target_stat_scsi_lu_show_attr_write_mbytes(
  347. struct se_dev_stat_grps *sgrps, char *page)
  348. {
  349. struct se_device *dev =
  350. container_of(sgrps, struct se_device, dev_stat_grps);
  351. /* scsiLuWrittenMegaBytes */
  352. return snprintf(page, PAGE_SIZE, "%lu\n",
  353. atomic_long_read(&dev->write_bytes) >> 20);
  354. }
  355. DEV_STAT_SCSI_LU_ATTR_RO(write_mbytes);
  356. static ssize_t target_stat_scsi_lu_show_attr_resets(
  357. struct se_dev_stat_grps *sgrps, char *page)
  358. {
  359. struct se_device *dev =
  360. container_of(sgrps, struct se_device, dev_stat_grps);
  361. /* scsiLuInResets */
  362. return snprintf(page, PAGE_SIZE, "%lu\n", atomic_long_read(&dev->num_resets));
  363. }
  364. DEV_STAT_SCSI_LU_ATTR_RO(resets);
  365. static ssize_t target_stat_scsi_lu_show_attr_full_stat(
  366. struct se_dev_stat_grps *sgrps, char *page)
  367. {
  368. /* FIXME: scsiLuOutTaskSetFullStatus */
  369. return snprintf(page, PAGE_SIZE, "%u\n", 0);
  370. }
  371. DEV_STAT_SCSI_LU_ATTR_RO(full_stat);
  372. static ssize_t target_stat_scsi_lu_show_attr_hs_num_cmds(
  373. struct se_dev_stat_grps *sgrps, char *page)
  374. {
  375. /* FIXME: scsiLuHSInCommands */
  376. return snprintf(page, PAGE_SIZE, "%u\n", 0);
  377. }
  378. DEV_STAT_SCSI_LU_ATTR_RO(hs_num_cmds);
  379. static ssize_t target_stat_scsi_lu_show_attr_creation_time(
  380. struct se_dev_stat_grps *sgrps, char *page)
  381. {
  382. struct se_device *dev =
  383. container_of(sgrps, struct se_device, dev_stat_grps);
  384. /* scsiLuCreationTime */
  385. return snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)dev->creation_time -
  386. INITIAL_JIFFIES) * 100 / HZ));
  387. }
  388. DEV_STAT_SCSI_LU_ATTR_RO(creation_time);
  389. CONFIGFS_EATTR_OPS(target_stat_scsi_lu, se_dev_stat_grps, scsi_lu_group);
  390. static struct configfs_attribute *target_stat_scsi_lu_attrs[] = {
  391. &target_stat_scsi_lu_inst.attr,
  392. &target_stat_scsi_lu_dev.attr,
  393. &target_stat_scsi_lu_indx.attr,
  394. &target_stat_scsi_lu_lun.attr,
  395. &target_stat_scsi_lu_lu_name.attr,
  396. &target_stat_scsi_lu_vend.attr,
  397. &target_stat_scsi_lu_prod.attr,
  398. &target_stat_scsi_lu_rev.attr,
  399. &target_stat_scsi_lu_dev_type.attr,
  400. &target_stat_scsi_lu_status.attr,
  401. &target_stat_scsi_lu_state_bit.attr,
  402. &target_stat_scsi_lu_num_cmds.attr,
  403. &target_stat_scsi_lu_read_mbytes.attr,
  404. &target_stat_scsi_lu_write_mbytes.attr,
  405. &target_stat_scsi_lu_resets.attr,
  406. &target_stat_scsi_lu_full_stat.attr,
  407. &target_stat_scsi_lu_hs_num_cmds.attr,
  408. &target_stat_scsi_lu_creation_time.attr,
  409. NULL,
  410. };
  411. static struct configfs_item_operations target_stat_scsi_lu_attrib_ops = {
  412. .show_attribute = target_stat_scsi_lu_attr_show,
  413. .store_attribute = target_stat_scsi_lu_attr_store,
  414. };
  415. static struct config_item_type target_stat_scsi_lu_cit = {
  416. .ct_item_ops = &target_stat_scsi_lu_attrib_ops,
  417. .ct_attrs = target_stat_scsi_lu_attrs,
  418. .ct_owner = THIS_MODULE,
  419. };
  420. /*
  421. * Called from target_core_configfs.c:target_core_make_subdev() to setup
  422. * the target statistics groups + configfs CITs located in target_core_stat.c
  423. */
  424. void target_stat_setup_dev_default_groups(struct se_device *dev)
  425. {
  426. struct config_group *dev_stat_grp = &dev->dev_stat_grps.stat_group;
  427. config_group_init_type_name(&dev->dev_stat_grps.scsi_dev_group,
  428. "scsi_dev", &target_stat_scsi_dev_cit);
  429. config_group_init_type_name(&dev->dev_stat_grps.scsi_tgt_dev_group,
  430. "scsi_tgt_dev", &target_stat_scsi_tgt_dev_cit);
  431. config_group_init_type_name(&dev->dev_stat_grps.scsi_lu_group,
  432. "scsi_lu", &target_stat_scsi_lu_cit);
  433. dev_stat_grp->default_groups[0] = &dev->dev_stat_grps.scsi_dev_group;
  434. dev_stat_grp->default_groups[1] = &dev->dev_stat_grps.scsi_tgt_dev_group;
  435. dev_stat_grp->default_groups[2] = &dev->dev_stat_grps.scsi_lu_group;
  436. dev_stat_grp->default_groups[3] = NULL;
  437. }
  438. /*
  439. * SCSI Port Table
  440. */
  441. CONFIGFS_EATTR_STRUCT(target_stat_scsi_port, se_port_stat_grps);
  442. #define DEV_STAT_SCSI_PORT_ATTR(_name, _mode) \
  443. static struct target_stat_scsi_port_attribute \
  444. target_stat_scsi_port_##_name = \
  445. __CONFIGFS_EATTR(_name, _mode, \
  446. target_stat_scsi_port_show_attr_##_name, \
  447. target_stat_scsi_port_store_attr_##_name);
  448. #define DEV_STAT_SCSI_PORT_ATTR_RO(_name) \
  449. static struct target_stat_scsi_port_attribute \
  450. target_stat_scsi_port_##_name = \
  451. __CONFIGFS_EATTR_RO(_name, \
  452. target_stat_scsi_port_show_attr_##_name);
  453. static ssize_t target_stat_scsi_port_show_attr_inst(
  454. struct se_port_stat_grps *pgrps, char *page)
  455. {
  456. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  457. struct se_device *dev;
  458. ssize_t ret = -ENODEV;
  459. rcu_read_lock();
  460. dev = rcu_dereference(lun->lun_se_dev);
  461. if (dev)
  462. ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index);
  463. rcu_read_unlock();
  464. return ret;
  465. }
  466. DEV_STAT_SCSI_PORT_ATTR_RO(inst);
  467. static ssize_t target_stat_scsi_port_show_attr_dev(
  468. struct se_port_stat_grps *pgrps, char *page)
  469. {
  470. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  471. struct se_device *dev;
  472. ssize_t ret = -ENODEV;
  473. rcu_read_lock();
  474. dev = rcu_dereference(lun->lun_se_dev);
  475. if (dev)
  476. ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
  477. rcu_read_unlock();
  478. return ret;
  479. }
  480. DEV_STAT_SCSI_PORT_ATTR_RO(dev);
  481. static ssize_t target_stat_scsi_port_show_attr_indx(
  482. struct se_port_stat_grps *pgrps, char *page)
  483. {
  484. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  485. struct se_device *dev;
  486. ssize_t ret = -ENODEV;
  487. rcu_read_lock();
  488. dev = rcu_dereference(lun->lun_se_dev);
  489. if (dev)
  490. ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_rtpi);
  491. rcu_read_unlock();
  492. return ret;
  493. }
  494. DEV_STAT_SCSI_PORT_ATTR_RO(indx);
  495. static ssize_t target_stat_scsi_port_show_attr_role(
  496. struct se_port_stat_grps *pgrps, char *page)
  497. {
  498. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  499. struct se_device *dev;
  500. ssize_t ret = -ENODEV;
  501. rcu_read_lock();
  502. dev = rcu_dereference(lun->lun_se_dev);
  503. if (dev)
  504. ret = snprintf(page, PAGE_SIZE, "%s%u\n", "Device", dev->dev_index);
  505. rcu_read_unlock();
  506. return ret;
  507. }
  508. DEV_STAT_SCSI_PORT_ATTR_RO(role);
  509. static ssize_t target_stat_scsi_port_show_attr_busy_count(
  510. struct se_port_stat_grps *pgrps, char *page)
  511. {
  512. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  513. struct se_device *dev;
  514. ssize_t ret = -ENODEV;
  515. rcu_read_lock();
  516. dev = rcu_dereference(lun->lun_se_dev);
  517. if (dev) {
  518. /* FIXME: scsiPortBusyStatuses */
  519. ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
  520. }
  521. rcu_read_unlock();
  522. return ret;
  523. }
  524. DEV_STAT_SCSI_PORT_ATTR_RO(busy_count);
  525. CONFIGFS_EATTR_OPS(target_stat_scsi_port, se_port_stat_grps, scsi_port_group);
  526. static struct configfs_attribute *target_stat_scsi_port_attrs[] = {
  527. &target_stat_scsi_port_inst.attr,
  528. &target_stat_scsi_port_dev.attr,
  529. &target_stat_scsi_port_indx.attr,
  530. &target_stat_scsi_port_role.attr,
  531. &target_stat_scsi_port_busy_count.attr,
  532. NULL,
  533. };
  534. static struct configfs_item_operations target_stat_scsi_port_attrib_ops = {
  535. .show_attribute = target_stat_scsi_port_attr_show,
  536. .store_attribute = target_stat_scsi_port_attr_store,
  537. };
  538. static struct config_item_type target_stat_scsi_port_cit = {
  539. .ct_item_ops = &target_stat_scsi_port_attrib_ops,
  540. .ct_attrs = target_stat_scsi_port_attrs,
  541. .ct_owner = THIS_MODULE,
  542. };
  543. /*
  544. * SCSI Target Port Table
  545. */
  546. CONFIGFS_EATTR_STRUCT(target_stat_scsi_tgt_port, se_port_stat_grps);
  547. #define DEV_STAT_SCSI_TGT_PORT_ATTR(_name, _mode) \
  548. static struct target_stat_scsi_tgt_port_attribute \
  549. target_stat_scsi_tgt_port_##_name = \
  550. __CONFIGFS_EATTR(_name, _mode, \
  551. target_stat_scsi_tgt_port_show_attr_##_name, \
  552. target_stat_scsi_tgt_port_store_attr_##_name);
  553. #define DEV_STAT_SCSI_TGT_PORT_ATTR_RO(_name) \
  554. static struct target_stat_scsi_tgt_port_attribute \
  555. target_stat_scsi_tgt_port_##_name = \
  556. __CONFIGFS_EATTR_RO(_name, \
  557. target_stat_scsi_tgt_port_show_attr_##_name);
  558. static ssize_t target_stat_scsi_tgt_port_show_attr_inst(
  559. struct se_port_stat_grps *pgrps, char *page)
  560. {
  561. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  562. struct se_device *dev;
  563. ssize_t ret = -ENODEV;
  564. rcu_read_lock();
  565. dev = rcu_dereference(lun->lun_se_dev);
  566. if (dev)
  567. ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index);
  568. rcu_read_unlock();
  569. return ret;
  570. }
  571. DEV_STAT_SCSI_TGT_PORT_ATTR_RO(inst);
  572. static ssize_t target_stat_scsi_tgt_port_show_attr_dev(
  573. struct se_port_stat_grps *pgrps, char *page)
  574. {
  575. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  576. struct se_device *dev;
  577. ssize_t ret = -ENODEV;
  578. rcu_read_lock();
  579. dev = rcu_dereference(lun->lun_se_dev);
  580. if (dev)
  581. ret = snprintf(page, PAGE_SIZE, "%u\n", dev->dev_index);
  582. rcu_read_unlock();
  583. return ret;
  584. }
  585. DEV_STAT_SCSI_TGT_PORT_ATTR_RO(dev);
  586. static ssize_t target_stat_scsi_tgt_port_show_attr_indx(
  587. struct se_port_stat_grps *pgrps, char *page)
  588. {
  589. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  590. struct se_device *dev;
  591. ssize_t ret = -ENODEV;
  592. rcu_read_lock();
  593. dev = rcu_dereference(lun->lun_se_dev);
  594. if (dev)
  595. ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_rtpi);
  596. rcu_read_unlock();
  597. return ret;
  598. }
  599. DEV_STAT_SCSI_TGT_PORT_ATTR_RO(indx);
  600. static ssize_t target_stat_scsi_tgt_port_show_attr_name(
  601. struct se_port_stat_grps *pgrps, char *page)
  602. {
  603. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  604. struct se_portal_group *tpg = lun->lun_tpg;
  605. struct se_device *dev;
  606. ssize_t ret = -ENODEV;
  607. rcu_read_lock();
  608. dev = rcu_dereference(lun->lun_se_dev);
  609. if (dev)
  610. ret = snprintf(page, PAGE_SIZE, "%sPort#%u\n",
  611. tpg->se_tpg_tfo->get_fabric_name(),
  612. lun->lun_rtpi);
  613. rcu_read_unlock();
  614. return ret;
  615. }
  616. DEV_STAT_SCSI_TGT_PORT_ATTR_RO(name);
  617. static ssize_t target_stat_scsi_tgt_port_show_attr_port_index(
  618. struct se_port_stat_grps *pgrps, char *page)
  619. {
  620. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  621. struct se_portal_group *tpg = lun->lun_tpg;
  622. struct se_device *dev;
  623. ssize_t ret = -ENODEV;
  624. rcu_read_lock();
  625. dev = rcu_dereference(lun->lun_se_dev);
  626. if (dev)
  627. ret = snprintf(page, PAGE_SIZE, "%s%s%d\n",
  628. tpg->se_tpg_tfo->tpg_get_wwn(tpg), "+t+",
  629. tpg->se_tpg_tfo->tpg_get_tag(tpg));
  630. rcu_read_unlock();
  631. return ret;
  632. }
  633. DEV_STAT_SCSI_TGT_PORT_ATTR_RO(port_index);
  634. static ssize_t target_stat_scsi_tgt_port_show_attr_in_cmds(
  635. struct se_port_stat_grps *pgrps, char *page)
  636. {
  637. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  638. struct se_device *dev;
  639. ssize_t ret = -ENODEV;
  640. rcu_read_lock();
  641. dev = rcu_dereference(lun->lun_se_dev);
  642. if (dev)
  643. ret = snprintf(page, PAGE_SIZE, "%lu\n",
  644. atomic_long_read(&lun->lun_stats.cmd_pdus));
  645. rcu_read_unlock();
  646. return ret;
  647. }
  648. DEV_STAT_SCSI_TGT_PORT_ATTR_RO(in_cmds);
  649. static ssize_t target_stat_scsi_tgt_port_show_attr_write_mbytes(
  650. struct se_port_stat_grps *pgrps, char *page)
  651. {
  652. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  653. struct se_device *dev;
  654. ssize_t ret = -ENODEV;
  655. rcu_read_lock();
  656. dev = rcu_dereference(lun->lun_se_dev);
  657. if (dev)
  658. ret = snprintf(page, PAGE_SIZE, "%u\n",
  659. (u32)(atomic_long_read(&lun->lun_stats.rx_data_octets) >> 20));
  660. rcu_read_unlock();
  661. return ret;
  662. }
  663. DEV_STAT_SCSI_TGT_PORT_ATTR_RO(write_mbytes);
  664. static ssize_t target_stat_scsi_tgt_port_show_attr_read_mbytes(
  665. struct se_port_stat_grps *pgrps, char *page)
  666. {
  667. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  668. struct se_device *dev;
  669. ssize_t ret = -ENODEV;
  670. rcu_read_lock();
  671. dev = rcu_dereference(lun->lun_se_dev);
  672. if (dev)
  673. ret = snprintf(page, PAGE_SIZE, "%u\n",
  674. (u32)(atomic_long_read(&lun->lun_stats.tx_data_octets) >> 20));
  675. rcu_read_unlock();
  676. return ret;
  677. }
  678. DEV_STAT_SCSI_TGT_PORT_ATTR_RO(read_mbytes);
  679. static ssize_t target_stat_scsi_tgt_port_show_attr_hs_in_cmds(
  680. struct se_port_stat_grps *pgrps, char *page)
  681. {
  682. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  683. struct se_device *dev;
  684. ssize_t ret = -ENODEV;
  685. rcu_read_lock();
  686. dev = rcu_dereference(lun->lun_se_dev);
  687. if (dev) {
  688. /* FIXME: scsiTgtPortHsInCommands */
  689. ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
  690. }
  691. rcu_read_unlock();
  692. return ret;
  693. }
  694. DEV_STAT_SCSI_TGT_PORT_ATTR_RO(hs_in_cmds);
  695. CONFIGFS_EATTR_OPS(target_stat_scsi_tgt_port, se_port_stat_grps,
  696. scsi_tgt_port_group);
  697. static struct configfs_attribute *target_stat_scsi_tgt_port_attrs[] = {
  698. &target_stat_scsi_tgt_port_inst.attr,
  699. &target_stat_scsi_tgt_port_dev.attr,
  700. &target_stat_scsi_tgt_port_indx.attr,
  701. &target_stat_scsi_tgt_port_name.attr,
  702. &target_stat_scsi_tgt_port_port_index.attr,
  703. &target_stat_scsi_tgt_port_in_cmds.attr,
  704. &target_stat_scsi_tgt_port_write_mbytes.attr,
  705. &target_stat_scsi_tgt_port_read_mbytes.attr,
  706. &target_stat_scsi_tgt_port_hs_in_cmds.attr,
  707. NULL,
  708. };
  709. static struct configfs_item_operations target_stat_scsi_tgt_port_attrib_ops = {
  710. .show_attribute = target_stat_scsi_tgt_port_attr_show,
  711. .store_attribute = target_stat_scsi_tgt_port_attr_store,
  712. };
  713. static struct config_item_type target_stat_scsi_tgt_port_cit = {
  714. .ct_item_ops = &target_stat_scsi_tgt_port_attrib_ops,
  715. .ct_attrs = target_stat_scsi_tgt_port_attrs,
  716. .ct_owner = THIS_MODULE,
  717. };
  718. /*
  719. * SCSI Transport Table
  720. o */
  721. CONFIGFS_EATTR_STRUCT(target_stat_scsi_transport, se_port_stat_grps);
  722. #define DEV_STAT_SCSI_TRANSPORT_ATTR(_name, _mode) \
  723. static struct target_stat_scsi_transport_attribute \
  724. target_stat_scsi_transport_##_name = \
  725. __CONFIGFS_EATTR(_name, _mode, \
  726. target_stat_scsi_transport_show_attr_##_name, \
  727. target_stat_scsi_transport_store_attr_##_name);
  728. #define DEV_STAT_SCSI_TRANSPORT_ATTR_RO(_name) \
  729. static struct target_stat_scsi_transport_attribute \
  730. target_stat_scsi_transport_##_name = \
  731. __CONFIGFS_EATTR_RO(_name, \
  732. target_stat_scsi_transport_show_attr_##_name);
  733. static ssize_t target_stat_scsi_transport_show_attr_inst(
  734. struct se_port_stat_grps *pgrps, char *page)
  735. {
  736. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  737. struct se_device *dev;
  738. ssize_t ret = -ENODEV;
  739. rcu_read_lock();
  740. dev = rcu_dereference(lun->lun_se_dev);
  741. if (dev)
  742. ret = snprintf(page, PAGE_SIZE, "%u\n", dev->hba_index);
  743. rcu_read_unlock();
  744. return ret;
  745. }
  746. DEV_STAT_SCSI_TRANSPORT_ATTR_RO(inst);
  747. static ssize_t target_stat_scsi_transport_show_attr_device(
  748. struct se_port_stat_grps *pgrps, char *page)
  749. {
  750. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  751. struct se_device *dev;
  752. struct se_portal_group *tpg = lun->lun_tpg;
  753. ssize_t ret = -ENODEV;
  754. rcu_read_lock();
  755. dev = rcu_dereference(lun->lun_se_dev);
  756. if (dev) {
  757. /* scsiTransportType */
  758. ret = snprintf(page, PAGE_SIZE, "scsiTransport%s\n",
  759. tpg->se_tpg_tfo->get_fabric_name());
  760. }
  761. rcu_read_unlock();
  762. return ret;
  763. }
  764. DEV_STAT_SCSI_TRANSPORT_ATTR_RO(device);
  765. static ssize_t target_stat_scsi_transport_show_attr_indx(
  766. struct se_port_stat_grps *pgrps, char *page)
  767. {
  768. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  769. struct se_device *dev;
  770. struct se_portal_group *tpg = lun->lun_tpg;
  771. ssize_t ret = -ENODEV;
  772. rcu_read_lock();
  773. dev = rcu_dereference(lun->lun_se_dev);
  774. if (dev)
  775. ret = snprintf(page, PAGE_SIZE, "%u\n",
  776. tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
  777. rcu_read_unlock();
  778. return ret;
  779. }
  780. DEV_STAT_SCSI_TRANSPORT_ATTR_RO(indx);
  781. static ssize_t target_stat_scsi_transport_show_attr_dev_name(
  782. struct se_port_stat_grps *pgrps, char *page)
  783. {
  784. struct se_lun *lun = container_of(pgrps, struct se_lun, port_stat_grps);
  785. struct se_device *dev;
  786. struct se_portal_group *tpg = lun->lun_tpg;
  787. struct t10_wwn *wwn;
  788. ssize_t ret = -ENODEV;
  789. rcu_read_lock();
  790. dev = rcu_dereference(lun->lun_se_dev);
  791. if (dev) {
  792. wwn = &dev->t10_wwn;
  793. /* scsiTransportDevName */
  794. ret = snprintf(page, PAGE_SIZE, "%s+%s\n",
  795. tpg->se_tpg_tfo->tpg_get_wwn(tpg),
  796. (strlen(wwn->unit_serial)) ? wwn->unit_serial :
  797. wwn->vendor);
  798. }
  799. rcu_read_unlock();
  800. return ret;
  801. }
  802. DEV_STAT_SCSI_TRANSPORT_ATTR_RO(dev_name);
  803. CONFIGFS_EATTR_OPS(target_stat_scsi_transport, se_port_stat_grps,
  804. scsi_transport_group);
  805. static struct configfs_attribute *target_stat_scsi_transport_attrs[] = {
  806. &target_stat_scsi_transport_inst.attr,
  807. &target_stat_scsi_transport_device.attr,
  808. &target_stat_scsi_transport_indx.attr,
  809. &target_stat_scsi_transport_dev_name.attr,
  810. NULL,
  811. };
  812. static struct configfs_item_operations target_stat_scsi_transport_attrib_ops = {
  813. .show_attribute = target_stat_scsi_transport_attr_show,
  814. .store_attribute = target_stat_scsi_transport_attr_store,
  815. };
  816. static struct config_item_type target_stat_scsi_transport_cit = {
  817. .ct_item_ops = &target_stat_scsi_transport_attrib_ops,
  818. .ct_attrs = target_stat_scsi_transport_attrs,
  819. .ct_owner = THIS_MODULE,
  820. };
  821. /*
  822. * Called from target_core_fabric_configfs.c:target_fabric_make_lun() to setup
  823. * the target port statistics groups + configfs CITs located in target_core_stat.c
  824. */
  825. void target_stat_setup_port_default_groups(struct se_lun *lun)
  826. {
  827. struct config_group *port_stat_grp = &lun->port_stat_grps.stat_group;
  828. config_group_init_type_name(&lun->port_stat_grps.scsi_port_group,
  829. "scsi_port", &target_stat_scsi_port_cit);
  830. config_group_init_type_name(&lun->port_stat_grps.scsi_tgt_port_group,
  831. "scsi_tgt_port", &target_stat_scsi_tgt_port_cit);
  832. config_group_init_type_name(&lun->port_stat_grps.scsi_transport_group,
  833. "scsi_transport", &target_stat_scsi_transport_cit);
  834. port_stat_grp->default_groups[0] = &lun->port_stat_grps.scsi_port_group;
  835. port_stat_grp->default_groups[1] = &lun->port_stat_grps.scsi_tgt_port_group;
  836. port_stat_grp->default_groups[2] = &lun->port_stat_grps.scsi_transport_group;
  837. port_stat_grp->default_groups[3] = NULL;
  838. }
  839. /*
  840. * SCSI Authorized Initiator Table
  841. */
  842. CONFIGFS_EATTR_STRUCT(target_stat_scsi_auth_intr, se_ml_stat_grps);
  843. #define DEV_STAT_SCSI_AUTH_INTR_ATTR(_name, _mode) \
  844. static struct target_stat_scsi_auth_intr_attribute \
  845. target_stat_scsi_auth_intr_##_name = \
  846. __CONFIGFS_EATTR(_name, _mode, \
  847. target_stat_scsi_auth_intr_show_attr_##_name, \
  848. target_stat_scsi_auth_intr_store_attr_##_name);
  849. #define DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(_name) \
  850. static struct target_stat_scsi_auth_intr_attribute \
  851. target_stat_scsi_auth_intr_##_name = \
  852. __CONFIGFS_EATTR_RO(_name, \
  853. target_stat_scsi_auth_intr_show_attr_##_name);
  854. static ssize_t target_stat_scsi_auth_intr_show_attr_inst(
  855. struct se_ml_stat_grps *lgrps, char *page)
  856. {
  857. struct se_lun_acl *lacl = container_of(lgrps,
  858. struct se_lun_acl, ml_stat_grps);
  859. struct se_node_acl *nacl = lacl->se_lun_nacl;
  860. struct se_dev_entry *deve;
  861. struct se_portal_group *tpg;
  862. ssize_t ret;
  863. rcu_read_lock();
  864. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  865. if (!deve) {
  866. rcu_read_unlock();
  867. return -ENODEV;
  868. }
  869. tpg = nacl->se_tpg;
  870. /* scsiInstIndex */
  871. ret = snprintf(page, PAGE_SIZE, "%u\n",
  872. tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
  873. rcu_read_unlock();
  874. return ret;
  875. }
  876. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(inst);
  877. static ssize_t target_stat_scsi_auth_intr_show_attr_dev(
  878. struct se_ml_stat_grps *lgrps, char *page)
  879. {
  880. struct se_lun_acl *lacl = container_of(lgrps,
  881. struct se_lun_acl, ml_stat_grps);
  882. struct se_node_acl *nacl = lacl->se_lun_nacl;
  883. struct se_dev_entry *deve;
  884. struct se_lun *lun;
  885. ssize_t ret;
  886. rcu_read_lock();
  887. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  888. if (!deve) {
  889. rcu_read_unlock();
  890. return -ENODEV;
  891. }
  892. lun = rcu_dereference(deve->se_lun);
  893. /* scsiDeviceIndex */
  894. ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_index);
  895. rcu_read_unlock();
  896. return ret;
  897. }
  898. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev);
  899. static ssize_t target_stat_scsi_auth_intr_show_attr_port(
  900. struct se_ml_stat_grps *lgrps, char *page)
  901. {
  902. struct se_lun_acl *lacl = container_of(lgrps,
  903. struct se_lun_acl, ml_stat_grps);
  904. struct se_node_acl *nacl = lacl->se_lun_nacl;
  905. struct se_dev_entry *deve;
  906. struct se_portal_group *tpg;
  907. ssize_t ret;
  908. rcu_read_lock();
  909. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  910. if (!deve) {
  911. rcu_read_unlock();
  912. return -ENODEV;
  913. }
  914. tpg = nacl->se_tpg;
  915. /* scsiAuthIntrTgtPortIndex */
  916. ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
  917. rcu_read_unlock();
  918. return ret;
  919. }
  920. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(port);
  921. static ssize_t target_stat_scsi_auth_intr_show_attr_indx(
  922. struct se_ml_stat_grps *lgrps, char *page)
  923. {
  924. struct se_lun_acl *lacl = container_of(lgrps,
  925. struct se_lun_acl, ml_stat_grps);
  926. struct se_node_acl *nacl = lacl->se_lun_nacl;
  927. struct se_dev_entry *deve;
  928. ssize_t ret;
  929. rcu_read_lock();
  930. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  931. if (!deve) {
  932. rcu_read_unlock();
  933. return -ENODEV;
  934. }
  935. /* scsiAuthIntrIndex */
  936. ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index);
  937. rcu_read_unlock();
  938. return ret;
  939. }
  940. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(indx);
  941. static ssize_t target_stat_scsi_auth_intr_show_attr_dev_or_port(
  942. struct se_ml_stat_grps *lgrps, char *page)
  943. {
  944. struct se_lun_acl *lacl = container_of(lgrps,
  945. struct se_lun_acl, ml_stat_grps);
  946. struct se_node_acl *nacl = lacl->se_lun_nacl;
  947. struct se_dev_entry *deve;
  948. ssize_t ret;
  949. rcu_read_lock();
  950. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  951. if (!deve) {
  952. rcu_read_unlock();
  953. return -ENODEV;
  954. }
  955. /* scsiAuthIntrDevOrPort */
  956. ret = snprintf(page, PAGE_SIZE, "%u\n", 1);
  957. rcu_read_unlock();
  958. return ret;
  959. }
  960. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(dev_or_port);
  961. static ssize_t target_stat_scsi_auth_intr_show_attr_intr_name(
  962. struct se_ml_stat_grps *lgrps, char *page)
  963. {
  964. struct se_lun_acl *lacl = container_of(lgrps,
  965. struct se_lun_acl, ml_stat_grps);
  966. struct se_node_acl *nacl = lacl->se_lun_nacl;
  967. struct se_dev_entry *deve;
  968. ssize_t ret;
  969. rcu_read_lock();
  970. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  971. if (!deve) {
  972. rcu_read_unlock();
  973. return -ENODEV;
  974. }
  975. /* scsiAuthIntrName */
  976. ret = snprintf(page, PAGE_SIZE, "%s\n", nacl->initiatorname);
  977. rcu_read_unlock();
  978. return ret;
  979. }
  980. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(intr_name);
  981. static ssize_t target_stat_scsi_auth_intr_show_attr_map_indx(
  982. struct se_ml_stat_grps *lgrps, char *page)
  983. {
  984. struct se_lun_acl *lacl = container_of(lgrps,
  985. struct se_lun_acl, ml_stat_grps);
  986. struct se_node_acl *nacl = lacl->se_lun_nacl;
  987. struct se_dev_entry *deve;
  988. ssize_t ret;
  989. rcu_read_lock();
  990. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  991. if (!deve) {
  992. rcu_read_unlock();
  993. return -ENODEV;
  994. }
  995. /* FIXME: scsiAuthIntrLunMapIndex */
  996. ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
  997. rcu_read_unlock();
  998. return ret;
  999. }
  1000. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(map_indx);
  1001. static ssize_t target_stat_scsi_auth_intr_show_attr_att_count(
  1002. struct se_ml_stat_grps *lgrps, char *page)
  1003. {
  1004. struct se_lun_acl *lacl = container_of(lgrps,
  1005. struct se_lun_acl, ml_stat_grps);
  1006. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1007. struct se_dev_entry *deve;
  1008. ssize_t ret;
  1009. rcu_read_lock();
  1010. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1011. if (!deve) {
  1012. rcu_read_unlock();
  1013. return -ENODEV;
  1014. }
  1015. /* scsiAuthIntrAttachedTimes */
  1016. ret = snprintf(page, PAGE_SIZE, "%u\n", deve->attach_count);
  1017. rcu_read_unlock();
  1018. return ret;
  1019. }
  1020. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(att_count);
  1021. static ssize_t target_stat_scsi_auth_intr_show_attr_num_cmds(
  1022. struct se_ml_stat_grps *lgrps, char *page)
  1023. {
  1024. struct se_lun_acl *lacl = container_of(lgrps,
  1025. struct se_lun_acl, ml_stat_grps);
  1026. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1027. struct se_dev_entry *deve;
  1028. ssize_t ret;
  1029. rcu_read_lock();
  1030. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1031. if (!deve) {
  1032. rcu_read_unlock();
  1033. return -ENODEV;
  1034. }
  1035. /* scsiAuthIntrOutCommands */
  1036. ret = snprintf(page, PAGE_SIZE, "%lu\n",
  1037. atomic_long_read(&deve->total_cmds));
  1038. rcu_read_unlock();
  1039. return ret;
  1040. }
  1041. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(num_cmds);
  1042. static ssize_t target_stat_scsi_auth_intr_show_attr_read_mbytes(
  1043. struct se_ml_stat_grps *lgrps, char *page)
  1044. {
  1045. struct se_lun_acl *lacl = container_of(lgrps,
  1046. struct se_lun_acl, ml_stat_grps);
  1047. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1048. struct se_dev_entry *deve;
  1049. ssize_t ret;
  1050. rcu_read_lock();
  1051. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1052. if (!deve) {
  1053. rcu_read_unlock();
  1054. return -ENODEV;
  1055. }
  1056. /* scsiAuthIntrReadMegaBytes */
  1057. ret = snprintf(page, PAGE_SIZE, "%u\n",
  1058. (u32)(atomic_long_read(&deve->read_bytes) >> 20));
  1059. rcu_read_unlock();
  1060. return ret;
  1061. }
  1062. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(read_mbytes);
  1063. static ssize_t target_stat_scsi_auth_intr_show_attr_write_mbytes(
  1064. struct se_ml_stat_grps *lgrps, char *page)
  1065. {
  1066. struct se_lun_acl *lacl = container_of(lgrps,
  1067. struct se_lun_acl, ml_stat_grps);
  1068. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1069. struct se_dev_entry *deve;
  1070. ssize_t ret;
  1071. rcu_read_lock();
  1072. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1073. if (!deve) {
  1074. rcu_read_unlock();
  1075. return -ENODEV;
  1076. }
  1077. /* scsiAuthIntrWrittenMegaBytes */
  1078. ret = snprintf(page, PAGE_SIZE, "%u\n",
  1079. (u32)(atomic_long_read(&deve->write_bytes) >> 20));
  1080. rcu_read_unlock();
  1081. return ret;
  1082. }
  1083. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(write_mbytes);
  1084. static ssize_t target_stat_scsi_auth_intr_show_attr_hs_num_cmds(
  1085. struct se_ml_stat_grps *lgrps, char *page)
  1086. {
  1087. struct se_lun_acl *lacl = container_of(lgrps,
  1088. struct se_lun_acl, ml_stat_grps);
  1089. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1090. struct se_dev_entry *deve;
  1091. ssize_t ret;
  1092. rcu_read_lock();
  1093. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1094. if (!deve) {
  1095. rcu_read_unlock();
  1096. return -ENODEV;
  1097. }
  1098. /* FIXME: scsiAuthIntrHSOutCommands */
  1099. ret = snprintf(page, PAGE_SIZE, "%u\n", 0);
  1100. rcu_read_unlock();
  1101. return ret;
  1102. }
  1103. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(hs_num_cmds);
  1104. static ssize_t target_stat_scsi_auth_intr_show_attr_creation_time(
  1105. struct se_ml_stat_grps *lgrps, char *page)
  1106. {
  1107. struct se_lun_acl *lacl = container_of(lgrps,
  1108. struct se_lun_acl, ml_stat_grps);
  1109. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1110. struct se_dev_entry *deve;
  1111. ssize_t ret;
  1112. rcu_read_lock();
  1113. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1114. if (!deve) {
  1115. rcu_read_unlock();
  1116. return -ENODEV;
  1117. }
  1118. /* scsiAuthIntrLastCreation */
  1119. ret = snprintf(page, PAGE_SIZE, "%u\n", (u32)(((u32)deve->creation_time -
  1120. INITIAL_JIFFIES) * 100 / HZ));
  1121. rcu_read_unlock();
  1122. return ret;
  1123. }
  1124. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(creation_time);
  1125. static ssize_t target_stat_scsi_auth_intr_show_attr_row_status(
  1126. struct se_ml_stat_grps *lgrps, char *page)
  1127. {
  1128. struct se_lun_acl *lacl = container_of(lgrps,
  1129. struct se_lun_acl, ml_stat_grps);
  1130. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1131. struct se_dev_entry *deve;
  1132. ssize_t ret;
  1133. rcu_read_lock();
  1134. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1135. if (!deve) {
  1136. rcu_read_unlock();
  1137. return -ENODEV;
  1138. }
  1139. /* FIXME: scsiAuthIntrRowStatus */
  1140. ret = snprintf(page, PAGE_SIZE, "Ready\n");
  1141. rcu_read_unlock();
  1142. return ret;
  1143. }
  1144. DEV_STAT_SCSI_AUTH_INTR_ATTR_RO(row_status);
  1145. CONFIGFS_EATTR_OPS(target_stat_scsi_auth_intr, se_ml_stat_grps,
  1146. scsi_auth_intr_group);
  1147. static struct configfs_attribute *target_stat_scsi_auth_intr_attrs[] = {
  1148. &target_stat_scsi_auth_intr_inst.attr,
  1149. &target_stat_scsi_auth_intr_dev.attr,
  1150. &target_stat_scsi_auth_intr_port.attr,
  1151. &target_stat_scsi_auth_intr_indx.attr,
  1152. &target_stat_scsi_auth_intr_dev_or_port.attr,
  1153. &target_stat_scsi_auth_intr_intr_name.attr,
  1154. &target_stat_scsi_auth_intr_map_indx.attr,
  1155. &target_stat_scsi_auth_intr_att_count.attr,
  1156. &target_stat_scsi_auth_intr_num_cmds.attr,
  1157. &target_stat_scsi_auth_intr_read_mbytes.attr,
  1158. &target_stat_scsi_auth_intr_write_mbytes.attr,
  1159. &target_stat_scsi_auth_intr_hs_num_cmds.attr,
  1160. &target_stat_scsi_auth_intr_creation_time.attr,
  1161. &target_stat_scsi_auth_intr_row_status.attr,
  1162. NULL,
  1163. };
  1164. static struct configfs_item_operations target_stat_scsi_auth_intr_attrib_ops = {
  1165. .show_attribute = target_stat_scsi_auth_intr_attr_show,
  1166. .store_attribute = target_stat_scsi_auth_intr_attr_store,
  1167. };
  1168. static struct config_item_type target_stat_scsi_auth_intr_cit = {
  1169. .ct_item_ops = &target_stat_scsi_auth_intr_attrib_ops,
  1170. .ct_attrs = target_stat_scsi_auth_intr_attrs,
  1171. .ct_owner = THIS_MODULE,
  1172. };
  1173. /*
  1174. * SCSI Attached Initiator Port Table
  1175. */
  1176. CONFIGFS_EATTR_STRUCT(target_stat_scsi_att_intr_port, se_ml_stat_grps);
  1177. #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR(_name, _mode) \
  1178. static struct target_stat_scsi_att_intr_port_attribute \
  1179. target_stat_scsi_att_intr_port_##_name = \
  1180. __CONFIGFS_EATTR(_name, _mode, \
  1181. target_stat_scsi_att_intr_port_show_attr_##_name, \
  1182. target_stat_scsi_att_intr_port_store_attr_##_name);
  1183. #define DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(_name) \
  1184. static struct target_stat_scsi_att_intr_port_attribute \
  1185. target_stat_scsi_att_intr_port_##_name = \
  1186. __CONFIGFS_EATTR_RO(_name, \
  1187. target_stat_scsi_att_intr_port_show_attr_##_name);
  1188. static ssize_t target_stat_scsi_att_intr_port_show_attr_inst(
  1189. struct se_ml_stat_grps *lgrps, char *page)
  1190. {
  1191. struct se_lun_acl *lacl = container_of(lgrps,
  1192. struct se_lun_acl, ml_stat_grps);
  1193. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1194. struct se_dev_entry *deve;
  1195. struct se_portal_group *tpg;
  1196. ssize_t ret;
  1197. rcu_read_lock();
  1198. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1199. if (!deve) {
  1200. rcu_read_unlock();
  1201. return -ENODEV;
  1202. }
  1203. tpg = nacl->se_tpg;
  1204. /* scsiInstIndex */
  1205. ret = snprintf(page, PAGE_SIZE, "%u\n",
  1206. tpg->se_tpg_tfo->tpg_get_inst_index(tpg));
  1207. rcu_read_unlock();
  1208. return ret;
  1209. }
  1210. DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(inst);
  1211. static ssize_t target_stat_scsi_att_intr_port_show_attr_dev(
  1212. struct se_ml_stat_grps *lgrps, char *page)
  1213. {
  1214. struct se_lun_acl *lacl = container_of(lgrps,
  1215. struct se_lun_acl, ml_stat_grps);
  1216. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1217. struct se_dev_entry *deve;
  1218. struct se_lun *lun;
  1219. ssize_t ret;
  1220. rcu_read_lock();
  1221. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1222. if (!deve) {
  1223. rcu_read_unlock();
  1224. return -ENODEV;
  1225. }
  1226. lun = rcu_dereference(deve->se_lun);
  1227. /* scsiDeviceIndex */
  1228. ret = snprintf(page, PAGE_SIZE, "%u\n", lun->lun_index);
  1229. rcu_read_unlock();
  1230. return ret;
  1231. }
  1232. DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(dev);
  1233. static ssize_t target_stat_scsi_att_intr_port_show_attr_port(
  1234. struct se_ml_stat_grps *lgrps, char *page)
  1235. {
  1236. struct se_lun_acl *lacl = container_of(lgrps,
  1237. struct se_lun_acl, ml_stat_grps);
  1238. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1239. struct se_dev_entry *deve;
  1240. struct se_portal_group *tpg;
  1241. ssize_t ret;
  1242. rcu_read_lock();
  1243. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1244. if (!deve) {
  1245. rcu_read_unlock();
  1246. return -ENODEV;
  1247. }
  1248. tpg = nacl->se_tpg;
  1249. /* scsiPortIndex */
  1250. ret = snprintf(page, PAGE_SIZE, "%u\n", tpg->se_tpg_tfo->tpg_get_tag(tpg));
  1251. rcu_read_unlock();
  1252. return ret;
  1253. }
  1254. DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port);
  1255. static ssize_t target_stat_scsi_att_intr_port_show_attr_indx(
  1256. struct se_ml_stat_grps *lgrps, char *page)
  1257. {
  1258. struct se_lun_acl *lacl = container_of(lgrps,
  1259. struct se_lun_acl, ml_stat_grps);
  1260. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1261. struct se_session *se_sess;
  1262. struct se_portal_group *tpg;
  1263. ssize_t ret;
  1264. spin_lock_irq(&nacl->nacl_sess_lock);
  1265. se_sess = nacl->nacl_sess;
  1266. if (!se_sess) {
  1267. spin_unlock_irq(&nacl->nacl_sess_lock);
  1268. return -ENODEV;
  1269. }
  1270. tpg = nacl->se_tpg;
  1271. /* scsiAttIntrPortIndex */
  1272. ret = snprintf(page, PAGE_SIZE, "%u\n",
  1273. tpg->se_tpg_tfo->sess_get_index(se_sess));
  1274. spin_unlock_irq(&nacl->nacl_sess_lock);
  1275. return ret;
  1276. }
  1277. DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(indx);
  1278. static ssize_t target_stat_scsi_att_intr_port_show_attr_port_auth_indx(
  1279. struct se_ml_stat_grps *lgrps, char *page)
  1280. {
  1281. struct se_lun_acl *lacl = container_of(lgrps,
  1282. struct se_lun_acl, ml_stat_grps);
  1283. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1284. struct se_dev_entry *deve;
  1285. ssize_t ret;
  1286. rcu_read_lock();
  1287. deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
  1288. if (!deve) {
  1289. rcu_read_unlock();
  1290. return -ENODEV;
  1291. }
  1292. /* scsiAttIntrPortAuthIntrIdx */
  1293. ret = snprintf(page, PAGE_SIZE, "%u\n", nacl->acl_index);
  1294. rcu_read_unlock();
  1295. return ret;
  1296. }
  1297. DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_auth_indx);
  1298. static ssize_t target_stat_scsi_att_intr_port_show_attr_port_ident(
  1299. struct se_ml_stat_grps *lgrps, char *page)
  1300. {
  1301. struct se_lun_acl *lacl = container_of(lgrps,
  1302. struct se_lun_acl, ml_stat_grps);
  1303. struct se_node_acl *nacl = lacl->se_lun_nacl;
  1304. struct se_session *se_sess;
  1305. struct se_portal_group *tpg;
  1306. ssize_t ret;
  1307. unsigned char buf[64];
  1308. spin_lock_irq(&nacl->nacl_sess_lock);
  1309. se_sess = nacl->nacl_sess;
  1310. if (!se_sess) {
  1311. spin_unlock_irq(&nacl->nacl_sess_lock);
  1312. return -ENODEV;
  1313. }
  1314. tpg = nacl->se_tpg;
  1315. /* scsiAttIntrPortName+scsiAttIntrPortIdentifier */
  1316. memset(buf, 0, 64);
  1317. if (tpg->se_tpg_tfo->sess_get_initiator_sid != NULL)
  1318. tpg->se_tpg_tfo->sess_get_initiator_sid(se_sess, buf, 64);
  1319. ret = snprintf(page, PAGE_SIZE, "%s+i+%s\n", nacl->initiatorname, buf);
  1320. spin_unlock_irq(&nacl->nacl_sess_lock);
  1321. return ret;
  1322. }
  1323. DEV_STAT_SCSI_ATTR_INTR_PORT_ATTR_RO(port_ident);
  1324. CONFIGFS_EATTR_OPS(target_stat_scsi_att_intr_port, se_ml_stat_grps,
  1325. scsi_att_intr_port_group);
  1326. static struct configfs_attribute *target_stat_scsi_ath_intr_port_attrs[] = {
  1327. &target_stat_scsi_att_intr_port_inst.attr,
  1328. &target_stat_scsi_att_intr_port_dev.attr,
  1329. &target_stat_scsi_att_intr_port_port.attr,
  1330. &target_stat_scsi_att_intr_port_indx.attr,
  1331. &target_stat_scsi_att_intr_port_port_auth_indx.attr,
  1332. &target_stat_scsi_att_intr_port_port_ident.attr,
  1333. NULL,
  1334. };
  1335. static struct configfs_item_operations target_stat_scsi_att_intr_port_attrib_ops = {
  1336. .show_attribute = target_stat_scsi_att_intr_port_attr_show,
  1337. .store_attribute = target_stat_scsi_att_intr_port_attr_store,
  1338. };
  1339. static struct config_item_type target_stat_scsi_att_intr_port_cit = {
  1340. .ct_item_ops = &target_stat_scsi_att_intr_port_attrib_ops,
  1341. .ct_attrs = target_stat_scsi_ath_intr_port_attrs,
  1342. .ct_owner = THIS_MODULE,
  1343. };
  1344. /*
  1345. * Called from target_core_fabric_configfs.c:target_fabric_make_mappedlun() to setup
  1346. * the target MappedLUN statistics groups + configfs CITs located in target_core_stat.c
  1347. */
  1348. void target_stat_setup_mappedlun_default_groups(struct se_lun_acl *lacl)
  1349. {
  1350. struct config_group *ml_stat_grp = &lacl->ml_stat_grps.stat_group;
  1351. config_group_init_type_name(&lacl->ml_stat_grps.scsi_auth_intr_group,
  1352. "scsi_auth_intr", &target_stat_scsi_auth_intr_cit);
  1353. config_group_init_type_name(&lacl->ml_stat_grps.scsi_att_intr_port_group,
  1354. "scsi_att_intr_port", &target_stat_scsi_att_intr_port_cit);
  1355. ml_stat_grp->default_groups[0] = &lacl->ml_stat_grps.scsi_auth_intr_group;
  1356. ml_stat_grp->default_groups[1] = &lacl->ml_stat_grps.scsi_att_intr_port_group;
  1357. ml_stat_grp->default_groups[2] = NULL;
  1358. }