bfad_attr.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*
  2. * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. /**
  18. * bfa_attr.c Linux driver configuration interface module.
  19. */
  20. #include "bfad_drv.h"
  21. #include "bfad_im.h"
  22. #include "bfad_trcmod.h"
  23. #include "bfad_attr.h"
  24. /**
  25. * FC_transport_template FC transport template
  26. */
  27. /**
  28. * FC transport template entry, get SCSI target port ID.
  29. */
  30. void
  31. bfad_im_get_starget_port_id(struct scsi_target *starget)
  32. {
  33. struct Scsi_Host *shost;
  34. struct bfad_im_port_s *im_port;
  35. struct bfad_s *bfad;
  36. struct bfad_itnim_s *itnim = NULL;
  37. u32 fc_id = -1;
  38. unsigned long flags;
  39. shost = bfad_os_starget_to_shost(starget);
  40. im_port = (struct bfad_im_port_s *) shost->hostdata[0];
  41. bfad = im_port->bfad;
  42. spin_lock_irqsave(&bfad->bfad_lock, flags);
  43. itnim = bfad_os_get_itnim(im_port, starget->id);
  44. if (itnim)
  45. fc_id = bfa_fcs_itnim_get_fcid(&itnim->fcs_itnim);
  46. fc_starget_port_id(starget) = fc_id;
  47. spin_unlock_irqrestore(&bfad->bfad_lock, flags);
  48. }
  49. /**
  50. * FC transport template entry, get SCSI target nwwn.
  51. */
  52. void
  53. bfad_im_get_starget_node_name(struct scsi_target *starget)
  54. {
  55. struct Scsi_Host *shost;
  56. struct bfad_im_port_s *im_port;
  57. struct bfad_s *bfad;
  58. struct bfad_itnim_s *itnim = NULL;
  59. u64 node_name = 0;
  60. unsigned long flags;
  61. shost = bfad_os_starget_to_shost(starget);
  62. im_port = (struct bfad_im_port_s *) shost->hostdata[0];
  63. bfad = im_port->bfad;
  64. spin_lock_irqsave(&bfad->bfad_lock, flags);
  65. itnim = bfad_os_get_itnim(im_port, starget->id);
  66. if (itnim)
  67. node_name = bfa_fcs_itnim_get_nwwn(&itnim->fcs_itnim);
  68. fc_starget_node_name(starget) = bfa_os_htonll(node_name);
  69. spin_unlock_irqrestore(&bfad->bfad_lock, flags);
  70. }
  71. /**
  72. * FC transport template entry, get SCSI target pwwn.
  73. */
  74. void
  75. bfad_im_get_starget_port_name(struct scsi_target *starget)
  76. {
  77. struct Scsi_Host *shost;
  78. struct bfad_im_port_s *im_port;
  79. struct bfad_s *bfad;
  80. struct bfad_itnim_s *itnim = NULL;
  81. u64 port_name = 0;
  82. unsigned long flags;
  83. shost = bfad_os_starget_to_shost(starget);
  84. im_port = (struct bfad_im_port_s *) shost->hostdata[0];
  85. bfad = im_port->bfad;
  86. spin_lock_irqsave(&bfad->bfad_lock, flags);
  87. itnim = bfad_os_get_itnim(im_port, starget->id);
  88. if (itnim)
  89. port_name = bfa_fcs_itnim_get_pwwn(&itnim->fcs_itnim);
  90. fc_starget_port_name(starget) = bfa_os_htonll(port_name);
  91. spin_unlock_irqrestore(&bfad->bfad_lock, flags);
  92. }
  93. /**
  94. * FC transport template entry, get SCSI host port ID.
  95. */
  96. void
  97. bfad_im_get_host_port_id(struct Scsi_Host *shost)
  98. {
  99. struct bfad_im_port_s *im_port =
  100. (struct bfad_im_port_s *) shost->hostdata[0];
  101. struct bfad_port_s *port = im_port->port;
  102. fc_host_port_id(shost) =
  103. bfa_os_hton3b(bfa_fcs_port_get_fcid(port->fcs_port));
  104. }
  105. struct Scsi_Host *
  106. bfad_os_starget_to_shost(struct scsi_target *starget)
  107. {
  108. return dev_to_shost(starget->dev.parent);
  109. }
  110. /**
  111. * FC transport template entry, get SCSI host port type.
  112. */
  113. static void
  114. bfad_im_get_host_port_type(struct Scsi_Host *shost)
  115. {
  116. struct bfad_im_port_s *im_port =
  117. (struct bfad_im_port_s *) shost->hostdata[0];
  118. struct bfad_s *bfad = im_port->bfad;
  119. struct bfa_pport_attr_s attr;
  120. bfa_pport_get_attr(&bfad->bfa, &attr);
  121. switch (attr.port_type) {
  122. case BFA_PPORT_TYPE_NPORT:
  123. fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
  124. break;
  125. case BFA_PPORT_TYPE_NLPORT:
  126. fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
  127. break;
  128. case BFA_PPORT_TYPE_P2P:
  129. fc_host_port_type(shost) = FC_PORTTYPE_PTP;
  130. break;
  131. case BFA_PPORT_TYPE_LPORT:
  132. fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
  133. break;
  134. default:
  135. fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
  136. break;
  137. }
  138. }
  139. /**
  140. * FC transport template entry, get SCSI host port state.
  141. */
  142. static void
  143. bfad_im_get_host_port_state(struct Scsi_Host *shost)
  144. {
  145. struct bfad_im_port_s *im_port =
  146. (struct bfad_im_port_s *) shost->hostdata[0];
  147. struct bfad_s *bfad = im_port->bfad;
  148. struct bfa_pport_attr_s attr;
  149. bfa_pport_get_attr(&bfad->bfa, &attr);
  150. switch (attr.port_state) {
  151. case BFA_PPORT_ST_LINKDOWN:
  152. fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
  153. break;
  154. case BFA_PPORT_ST_LINKUP:
  155. fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
  156. break;
  157. case BFA_PPORT_ST_UNINIT:
  158. case BFA_PPORT_ST_ENABLING_QWAIT:
  159. case BFA_PPORT_ST_ENABLING:
  160. case BFA_PPORT_ST_DISABLING_QWAIT:
  161. case BFA_PPORT_ST_DISABLING:
  162. case BFA_PPORT_ST_DISABLED:
  163. case BFA_PPORT_ST_STOPPED:
  164. case BFA_PPORT_ST_IOCDOWN:
  165. default:
  166. fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
  167. break;
  168. }
  169. }
  170. /**
  171. * FC transport template entry, get SCSI host active fc4s.
  172. */
  173. static void
  174. bfad_im_get_host_active_fc4s(struct Scsi_Host *shost)
  175. {
  176. struct bfad_im_port_s *im_port =
  177. (struct bfad_im_port_s *) shost->hostdata[0];
  178. struct bfad_port_s *port = im_port->port;
  179. memset(fc_host_active_fc4s(shost), 0,
  180. sizeof(fc_host_active_fc4s(shost)));
  181. if (port->supported_fc4s &
  182. (BFA_PORT_ROLE_FCP_IM | BFA_PORT_ROLE_FCP_TM))
  183. fc_host_active_fc4s(shost)[2] = 1;
  184. if (port->supported_fc4s & BFA_PORT_ROLE_FCP_IPFC)
  185. fc_host_active_fc4s(shost)[3] = 0x20;
  186. fc_host_active_fc4s(shost)[7] = 1;
  187. }
  188. /**
  189. * FC transport template entry, get SCSI host link speed.
  190. */
  191. static void
  192. bfad_im_get_host_speed(struct Scsi_Host *shost)
  193. {
  194. struct bfad_im_port_s *im_port =
  195. (struct bfad_im_port_s *) shost->hostdata[0];
  196. struct bfad_s *bfad = im_port->bfad;
  197. struct bfa_pport_attr_s attr;
  198. bfa_pport_get_attr(&bfad->bfa, &attr);
  199. switch (attr.speed) {
  200. case BFA_PPORT_SPEED_8GBPS:
  201. fc_host_speed(shost) = FC_PORTSPEED_8GBIT;
  202. break;
  203. case BFA_PPORT_SPEED_4GBPS:
  204. fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
  205. break;
  206. case BFA_PPORT_SPEED_2GBPS:
  207. fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
  208. break;
  209. case BFA_PPORT_SPEED_1GBPS:
  210. fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
  211. break;
  212. default:
  213. fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
  214. break;
  215. }
  216. }
  217. /**
  218. * FC transport template entry, get SCSI host port type.
  219. */
  220. static void
  221. bfad_im_get_host_fabric_name(struct Scsi_Host *shost)
  222. {
  223. struct bfad_im_port_s *im_port =
  224. (struct bfad_im_port_s *) shost->hostdata[0];
  225. struct bfad_port_s *port = im_port->port;
  226. wwn_t fabric_nwwn = 0;
  227. fabric_nwwn = bfa_fcs_port_get_fabric_name(port->fcs_port);
  228. fc_host_fabric_name(shost) = bfa_os_htonll(fabric_nwwn);
  229. }
  230. /**
  231. * FC transport template entry, get BFAD statistics.
  232. */
  233. static struct fc_host_statistics *
  234. bfad_im_get_stats(struct Scsi_Host *shost)
  235. {
  236. struct bfad_im_port_s *im_port =
  237. (struct bfad_im_port_s *) shost->hostdata[0];
  238. struct bfad_s *bfad = im_port->bfad;
  239. struct bfad_hal_comp fcomp;
  240. struct fc_host_statistics *hstats;
  241. bfa_status_t rc;
  242. unsigned long flags;
  243. hstats = &bfad->link_stats;
  244. init_completion(&fcomp.comp);
  245. spin_lock_irqsave(&bfad->bfad_lock, flags);
  246. memset(hstats, 0, sizeof(struct fc_host_statistics));
  247. rc = bfa_pport_get_stats(&bfad->bfa,
  248. (union bfa_pport_stats_u *) hstats,
  249. bfad_hcb_comp, &fcomp);
  250. spin_unlock_irqrestore(&bfad->bfad_lock, flags);
  251. if (rc != BFA_STATUS_OK)
  252. return NULL;
  253. wait_for_completion(&fcomp.comp);
  254. return hstats;
  255. }
  256. /**
  257. * FC transport template entry, reset BFAD statistics.
  258. */
  259. static void
  260. bfad_im_reset_stats(struct Scsi_Host *shost)
  261. {
  262. struct bfad_im_port_s *im_port =
  263. (struct bfad_im_port_s *) shost->hostdata[0];
  264. struct bfad_s *bfad = im_port->bfad;
  265. struct bfad_hal_comp fcomp;
  266. unsigned long flags;
  267. bfa_status_t rc;
  268. init_completion(&fcomp.comp);
  269. spin_lock_irqsave(&bfad->bfad_lock, flags);
  270. rc = bfa_pport_clear_stats(&bfad->bfa, bfad_hcb_comp, &fcomp);
  271. spin_unlock_irqrestore(&bfad->bfad_lock, flags);
  272. if (rc != BFA_STATUS_OK)
  273. return;
  274. wait_for_completion(&fcomp.comp);
  275. return;
  276. }
  277. /**
  278. * FC transport template entry, get rport loss timeout.
  279. */
  280. static void
  281. bfad_im_get_rport_loss_tmo(struct fc_rport *rport)
  282. {
  283. struct bfad_itnim_data_s *itnim_data = rport->dd_data;
  284. struct bfad_itnim_s *itnim = itnim_data->itnim;
  285. struct bfad_s *bfad = itnim->im->bfad;
  286. unsigned long flags;
  287. spin_lock_irqsave(&bfad->bfad_lock, flags);
  288. rport->dev_loss_tmo = bfa_fcpim_path_tov_get(&bfad->bfa);
  289. spin_unlock_irqrestore(&bfad->bfad_lock, flags);
  290. }
  291. /**
  292. * FC transport template entry, set rport loss timeout.
  293. */
  294. static void
  295. bfad_im_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout)
  296. {
  297. struct bfad_itnim_data_s *itnim_data = rport->dd_data;
  298. struct bfad_itnim_s *itnim = itnim_data->itnim;
  299. struct bfad_s *bfad = itnim->im->bfad;
  300. unsigned long flags;
  301. if (timeout > 0) {
  302. spin_lock_irqsave(&bfad->bfad_lock, flags);
  303. bfa_fcpim_path_tov_set(&bfad->bfa, timeout);
  304. rport->dev_loss_tmo = bfa_fcpim_path_tov_get(&bfad->bfa);
  305. spin_unlock_irqrestore(&bfad->bfad_lock, flags);
  306. }
  307. }
  308. struct fc_function_template bfad_im_fc_function_template = {
  309. /* Target dynamic attributes */
  310. .get_starget_port_id = bfad_im_get_starget_port_id,
  311. .show_starget_port_id = 1,
  312. .get_starget_node_name = bfad_im_get_starget_node_name,
  313. .show_starget_node_name = 1,
  314. .get_starget_port_name = bfad_im_get_starget_port_name,
  315. .show_starget_port_name = 1,
  316. /* Host dynamic attribute */
  317. .get_host_port_id = bfad_im_get_host_port_id,
  318. .show_host_port_id = 1,
  319. /* Host fixed attributes */
  320. .show_host_node_name = 1,
  321. .show_host_port_name = 1,
  322. .show_host_supported_classes = 1,
  323. .show_host_supported_fc4s = 1,
  324. .show_host_supported_speeds = 1,
  325. .show_host_maxframe_size = 1,
  326. /* More host dynamic attributes */
  327. .show_host_port_type = 1,
  328. .get_host_port_type = bfad_im_get_host_port_type,
  329. .show_host_port_state = 1,
  330. .get_host_port_state = bfad_im_get_host_port_state,
  331. .show_host_active_fc4s = 1,
  332. .get_host_active_fc4s = bfad_im_get_host_active_fc4s,
  333. .show_host_speed = 1,
  334. .get_host_speed = bfad_im_get_host_speed,
  335. .show_host_fabric_name = 1,
  336. .get_host_fabric_name = bfad_im_get_host_fabric_name,
  337. .show_host_symbolic_name = 1,
  338. /* Statistics */
  339. .get_fc_host_stats = bfad_im_get_stats,
  340. .reset_fc_host_stats = bfad_im_reset_stats,
  341. /* Allocation length for host specific data */
  342. .dd_fcrport_size = sizeof(struct bfad_itnim_data_s *),
  343. /* Remote port fixed attributes */
  344. .show_rport_maxframe_size = 1,
  345. .show_rport_supported_classes = 1,
  346. .show_rport_dev_loss_tmo = 1,
  347. .get_rport_dev_loss_tmo = bfad_im_get_rport_loss_tmo,
  348. .set_rport_dev_loss_tmo = bfad_im_set_rport_loss_tmo,
  349. };
  350. /**
  351. * Scsi_Host_attrs SCSI host attributes
  352. */
  353. static ssize_t
  354. bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr,
  355. char *buf)
  356. {
  357. struct Scsi_Host *shost = class_to_shost(dev);
  358. struct bfad_im_port_s *im_port =
  359. (struct bfad_im_port_s *) shost->hostdata[0];
  360. struct bfad_s *bfad = im_port->bfad;
  361. struct bfa_ioc_attr_s ioc_attr;
  362. memset(&ioc_attr, 0, sizeof(ioc_attr));
  363. bfa_get_attr(&bfad->bfa, &ioc_attr);
  364. return snprintf(buf, PAGE_SIZE, "%s\n",
  365. ioc_attr.adapter_attr.serial_num);
  366. }
  367. static ssize_t
  368. bfad_im_model_show(struct device *dev, struct device_attribute *attr,
  369. char *buf)
  370. {
  371. struct Scsi_Host *shost = class_to_shost(dev);
  372. struct bfad_im_port_s *im_port =
  373. (struct bfad_im_port_s *) shost->hostdata[0];
  374. struct bfad_s *bfad = im_port->bfad;
  375. struct bfa_ioc_attr_s ioc_attr;
  376. memset(&ioc_attr, 0, sizeof(ioc_attr));
  377. bfa_get_attr(&bfad->bfa, &ioc_attr);
  378. return snprintf(buf, PAGE_SIZE, "%s\n", ioc_attr.adapter_attr.model);
  379. }
  380. static ssize_t
  381. bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr,
  382. char *buf)
  383. {
  384. struct Scsi_Host *shost = class_to_shost(dev);
  385. struct bfad_im_port_s *im_port =
  386. (struct bfad_im_port_s *) shost->hostdata[0];
  387. struct bfad_s *bfad = im_port->bfad;
  388. struct bfa_ioc_attr_s ioc_attr;
  389. memset(&ioc_attr, 0, sizeof(ioc_attr));
  390. bfa_get_attr(&bfad->bfa, &ioc_attr);
  391. return snprintf(buf, PAGE_SIZE, "%s\n",
  392. ioc_attr.adapter_attr.model_descr);
  393. }
  394. static ssize_t
  395. bfad_im_node_name_show(struct device *dev, struct device_attribute *attr,
  396. char *buf)
  397. {
  398. struct Scsi_Host *shost = class_to_shost(dev);
  399. struct bfad_im_port_s *im_port =
  400. (struct bfad_im_port_s *) shost->hostdata[0];
  401. struct bfad_port_s *port = im_port->port;
  402. u64 nwwn;
  403. nwwn = bfa_fcs_port_get_nwwn(port->fcs_port);
  404. return snprintf(buf, PAGE_SIZE, "0x%llx\n", bfa_os_htonll(nwwn));
  405. }
  406. static ssize_t
  407. bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,
  408. char *buf)
  409. {
  410. struct Scsi_Host *shost = class_to_shost(dev);
  411. struct bfad_im_port_s *im_port =
  412. (struct bfad_im_port_s *) shost->hostdata[0];
  413. struct bfad_s *bfad = im_port->bfad;
  414. struct bfa_ioc_attr_s ioc_attr;
  415. memset(&ioc_attr, 0, sizeof(ioc_attr));
  416. bfa_get_attr(&bfad->bfa, &ioc_attr);
  417. return snprintf(buf, PAGE_SIZE, "Brocade %s FV%s DV%s\n",
  418. ioc_attr.adapter_attr.model,
  419. ioc_attr.adapter_attr.fw_ver, BFAD_DRIVER_VERSION);
  420. }
  421. static ssize_t
  422. bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,
  423. char *buf)
  424. {
  425. struct Scsi_Host *shost = class_to_shost(dev);
  426. struct bfad_im_port_s *im_port =
  427. (struct bfad_im_port_s *) shost->hostdata[0];
  428. struct bfad_s *bfad = im_port->bfad;
  429. struct bfa_ioc_attr_s ioc_attr;
  430. memset(&ioc_attr, 0, sizeof(ioc_attr));
  431. bfa_get_attr(&bfad->bfa, &ioc_attr);
  432. return snprintf(buf, PAGE_SIZE, "%s\n", ioc_attr.adapter_attr.hw_ver);
  433. }
  434. static ssize_t
  435. bfad_im_drv_version_show(struct device *dev, struct device_attribute *attr,
  436. char *buf)
  437. {
  438. return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_VERSION);
  439. }
  440. static ssize_t
  441. bfad_im_optionrom_version_show(struct device *dev,
  442. struct device_attribute *attr, char *buf)
  443. {
  444. struct Scsi_Host *shost = class_to_shost(dev);
  445. struct bfad_im_port_s *im_port =
  446. (struct bfad_im_port_s *) shost->hostdata[0];
  447. struct bfad_s *bfad = im_port->bfad;
  448. struct bfa_ioc_attr_s ioc_attr;
  449. memset(&ioc_attr, 0, sizeof(ioc_attr));
  450. bfa_get_attr(&bfad->bfa, &ioc_attr);
  451. return snprintf(buf, PAGE_SIZE, "%s\n",
  452. ioc_attr.adapter_attr.optrom_ver);
  453. }
  454. static ssize_t
  455. bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr,
  456. char *buf)
  457. {
  458. struct Scsi_Host *shost = class_to_shost(dev);
  459. struct bfad_im_port_s *im_port =
  460. (struct bfad_im_port_s *) shost->hostdata[0];
  461. struct bfad_s *bfad = im_port->bfad;
  462. struct bfa_ioc_attr_s ioc_attr;
  463. memset(&ioc_attr, 0, sizeof(ioc_attr));
  464. bfa_get_attr(&bfad->bfa, &ioc_attr);
  465. return snprintf(buf, PAGE_SIZE, "%s\n", ioc_attr.adapter_attr.fw_ver);
  466. }
  467. static ssize_t
  468. bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr,
  469. char *buf)
  470. {
  471. struct Scsi_Host *shost = class_to_shost(dev);
  472. struct bfad_im_port_s *im_port =
  473. (struct bfad_im_port_s *) shost->hostdata[0];
  474. struct bfad_s *bfad = im_port->bfad;
  475. struct bfa_ioc_attr_s ioc_attr;
  476. memset(&ioc_attr, 0, sizeof(ioc_attr));
  477. bfa_get_attr(&bfad->bfa, &ioc_attr);
  478. return snprintf(buf, PAGE_SIZE, "%d\n", ioc_attr.adapter_attr.nports);
  479. }
  480. static ssize_t
  481. bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr,
  482. char *buf)
  483. {
  484. return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_NAME);
  485. }
  486. static ssize_t
  487. bfad_im_num_of_discovered_ports_show(struct device *dev,
  488. struct device_attribute *attr, char *buf)
  489. {
  490. struct Scsi_Host *shost = class_to_shost(dev);
  491. struct bfad_im_port_s *im_port =
  492. (struct bfad_im_port_s *) shost->hostdata[0];
  493. struct bfad_port_s *port = im_port->port;
  494. struct bfad_s *bfad = im_port->bfad;
  495. int nrports = 2048;
  496. wwn_t *rports = NULL;
  497. unsigned long flags;
  498. rports = kzalloc(sizeof(wwn_t) * nrports , GFP_ATOMIC);
  499. if (rports == NULL)
  500. return -ENOMEM;
  501. spin_lock_irqsave(&bfad->bfad_lock, flags);
  502. bfa_fcs_port_get_rports(port->fcs_port, rports, &nrports);
  503. spin_unlock_irqrestore(&bfad->bfad_lock, flags);
  504. kfree(rports);
  505. return snprintf(buf, PAGE_SIZE, "%d\n", nrports);
  506. }
  507. static DEVICE_ATTR(serial_number, S_IRUGO,
  508. bfad_im_serial_num_show, NULL);
  509. static DEVICE_ATTR(model, S_IRUGO, bfad_im_model_show, NULL);
  510. static DEVICE_ATTR(model_description, S_IRUGO,
  511. bfad_im_model_desc_show, NULL);
  512. static DEVICE_ATTR(node_name, S_IRUGO, bfad_im_node_name_show, NULL);
  513. static DEVICE_ATTR(symbolic_name, S_IRUGO,
  514. bfad_im_symbolic_name_show, NULL);
  515. static DEVICE_ATTR(hardware_version, S_IRUGO,
  516. bfad_im_hw_version_show, NULL);
  517. static DEVICE_ATTR(driver_version, S_IRUGO,
  518. bfad_im_drv_version_show, NULL);
  519. static DEVICE_ATTR(option_rom_version, S_IRUGO,
  520. bfad_im_optionrom_version_show, NULL);
  521. static DEVICE_ATTR(firmware_version, S_IRUGO,
  522. bfad_im_fw_version_show, NULL);
  523. static DEVICE_ATTR(number_of_ports, S_IRUGO,
  524. bfad_im_num_of_ports_show, NULL);
  525. static DEVICE_ATTR(driver_name, S_IRUGO, bfad_im_drv_name_show, NULL);
  526. static DEVICE_ATTR(number_of_discovered_ports, S_IRUGO,
  527. bfad_im_num_of_discovered_ports_show, NULL);
  528. struct device_attribute *bfad_im_host_attrs[] = {
  529. &dev_attr_serial_number,
  530. &dev_attr_model,
  531. &dev_attr_model_description,
  532. &dev_attr_node_name,
  533. &dev_attr_symbolic_name,
  534. &dev_attr_hardware_version,
  535. &dev_attr_driver_version,
  536. &dev_attr_option_rom_version,
  537. &dev_attr_firmware_version,
  538. &dev_attr_number_of_ports,
  539. &dev_attr_driver_name,
  540. &dev_attr_number_of_discovered_ports,
  541. NULL,
  542. };
  543. struct device_attribute *bfad_im_vport_attrs[] = {
  544. &dev_attr_serial_number,
  545. &dev_attr_model,
  546. &dev_attr_model_description,
  547. &dev_attr_node_name,
  548. &dev_attr_symbolic_name,
  549. &dev_attr_hardware_version,
  550. &dev_attr_driver_version,
  551. &dev_attr_option_rom_version,
  552. &dev_attr_firmware_version,
  553. &dev_attr_number_of_ports,
  554. &dev_attr_driver_name,
  555. &dev_attr_number_of_discovered_ports,
  556. NULL,
  557. };