qla_attr.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2005 QLogic Corporation
  4. *
  5. * See LICENSE.qla2xxx for copyright and licensing details.
  6. */
  7. #include "qla_def.h"
  8. #include <linux/kthread.h>
  9. #include <linux/vmalloc.h>
  10. int qla24xx_vport_disable(struct fc_vport *, bool);
  11. /* SYSFS attributes --------------------------------------------------------- */
  12. static ssize_t
  13. qla2x00_sysfs_read_fw_dump(struct kobject *kobj,
  14. struct bin_attribute *bin_attr,
  15. char *buf, loff_t off, size_t count)
  16. {
  17. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  18. struct device, kobj)));
  19. char *rbuf = (char *)ha->fw_dump;
  20. if (ha->fw_dump_reading == 0)
  21. return 0;
  22. if (off > ha->fw_dump_len)
  23. return 0;
  24. if (off + count > ha->fw_dump_len)
  25. count = ha->fw_dump_len - off;
  26. memcpy(buf, &rbuf[off], count);
  27. return (count);
  28. }
  29. static ssize_t
  30. qla2x00_sysfs_write_fw_dump(struct kobject *kobj,
  31. struct bin_attribute *bin_attr,
  32. char *buf, loff_t off, size_t count)
  33. {
  34. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  35. struct device, kobj)));
  36. int reading;
  37. if (off != 0)
  38. return (0);
  39. reading = simple_strtol(buf, NULL, 10);
  40. switch (reading) {
  41. case 0:
  42. if (!ha->fw_dump_reading)
  43. break;
  44. qla_printk(KERN_INFO, ha,
  45. "Firmware dump cleared on (%ld).\n", ha->host_no);
  46. ha->fw_dump_reading = 0;
  47. ha->fw_dumped = 0;
  48. break;
  49. case 1:
  50. if (ha->fw_dumped && !ha->fw_dump_reading) {
  51. ha->fw_dump_reading = 1;
  52. qla_printk(KERN_INFO, ha,
  53. "Raw firmware dump ready for read on (%ld).\n",
  54. ha->host_no);
  55. }
  56. break;
  57. case 2:
  58. qla2x00_alloc_fw_dump(ha);
  59. break;
  60. }
  61. return (count);
  62. }
  63. static struct bin_attribute sysfs_fw_dump_attr = {
  64. .attr = {
  65. .name = "fw_dump",
  66. .mode = S_IRUSR | S_IWUSR,
  67. },
  68. .size = 0,
  69. .read = qla2x00_sysfs_read_fw_dump,
  70. .write = qla2x00_sysfs_write_fw_dump,
  71. };
  72. static ssize_t
  73. qla2x00_sysfs_read_nvram(struct kobject *kobj,
  74. struct bin_attribute *bin_attr,
  75. char *buf, loff_t off, size_t count)
  76. {
  77. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  78. struct device, kobj)));
  79. int size = ha->nvram_size;
  80. char *nvram_cache = ha->nvram;
  81. if (!capable(CAP_SYS_ADMIN) || off > size || count == 0)
  82. return 0;
  83. if (off + count > size) {
  84. size -= off;
  85. count = size;
  86. }
  87. /* Read NVRAM data from cache. */
  88. memcpy(buf, &nvram_cache[off], count);
  89. return count;
  90. }
  91. static ssize_t
  92. qla2x00_sysfs_write_nvram(struct kobject *kobj,
  93. struct bin_attribute *bin_attr,
  94. char *buf, loff_t off, size_t count)
  95. {
  96. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  97. struct device, kobj)));
  98. uint16_t cnt;
  99. if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->nvram_size)
  100. return 0;
  101. /* Checksum NVRAM. */
  102. if (IS_FWI2_CAPABLE(ha)) {
  103. uint32_t *iter;
  104. uint32_t chksum;
  105. iter = (uint32_t *)buf;
  106. chksum = 0;
  107. for (cnt = 0; cnt < ((count >> 2) - 1); cnt++)
  108. chksum += le32_to_cpu(*iter++);
  109. chksum = ~chksum + 1;
  110. *iter = cpu_to_le32(chksum);
  111. } else {
  112. uint8_t *iter;
  113. uint8_t chksum;
  114. iter = (uint8_t *)buf;
  115. chksum = 0;
  116. for (cnt = 0; cnt < count - 1; cnt++)
  117. chksum += *iter++;
  118. chksum = ~chksum + 1;
  119. *iter = chksum;
  120. }
  121. /* Write NVRAM. */
  122. ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count);
  123. ha->isp_ops->read_nvram(ha, (uint8_t *)ha->nvram, ha->nvram_base,
  124. count);
  125. set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
  126. return (count);
  127. }
  128. static struct bin_attribute sysfs_nvram_attr = {
  129. .attr = {
  130. .name = "nvram",
  131. .mode = S_IRUSR | S_IWUSR,
  132. },
  133. .size = 512,
  134. .read = qla2x00_sysfs_read_nvram,
  135. .write = qla2x00_sysfs_write_nvram,
  136. };
  137. static ssize_t
  138. qla2x00_sysfs_read_optrom(struct kobject *kobj,
  139. struct bin_attribute *bin_attr,
  140. char *buf, loff_t off, size_t count)
  141. {
  142. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  143. struct device, kobj)));
  144. if (ha->optrom_state != QLA_SREADING)
  145. return 0;
  146. if (off > ha->optrom_region_size)
  147. return 0;
  148. if (off + count > ha->optrom_region_size)
  149. count = ha->optrom_region_size - off;
  150. memcpy(buf, &ha->optrom_buffer[off], count);
  151. return count;
  152. }
  153. static ssize_t
  154. qla2x00_sysfs_write_optrom(struct kobject *kobj,
  155. struct bin_attribute *bin_attr,
  156. char *buf, loff_t off, size_t count)
  157. {
  158. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  159. struct device, kobj)));
  160. if (ha->optrom_state != QLA_SWRITING)
  161. return -EINVAL;
  162. if (off > ha->optrom_region_size)
  163. return -ERANGE;
  164. if (off + count > ha->optrom_region_size)
  165. count = ha->optrom_region_size - off;
  166. memcpy(&ha->optrom_buffer[off], buf, count);
  167. return count;
  168. }
  169. static struct bin_attribute sysfs_optrom_attr = {
  170. .attr = {
  171. .name = "optrom",
  172. .mode = S_IRUSR | S_IWUSR,
  173. },
  174. .size = 0,
  175. .read = qla2x00_sysfs_read_optrom,
  176. .write = qla2x00_sysfs_write_optrom,
  177. };
  178. static ssize_t
  179. qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
  180. struct bin_attribute *bin_attr,
  181. char *buf, loff_t off, size_t count)
  182. {
  183. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  184. struct device, kobj)));
  185. uint32_t start = 0;
  186. uint32_t size = ha->optrom_size;
  187. int val, valid;
  188. if (off)
  189. return 0;
  190. if (sscanf(buf, "%d:%x:%x", &val, &start, &size) < 1)
  191. return -EINVAL;
  192. if (start > ha->optrom_size)
  193. return -EINVAL;
  194. switch (val) {
  195. case 0:
  196. if (ha->optrom_state != QLA_SREADING &&
  197. ha->optrom_state != QLA_SWRITING)
  198. break;
  199. ha->optrom_state = QLA_SWAITING;
  200. DEBUG2(qla_printk(KERN_INFO, ha,
  201. "Freeing flash region allocation -- 0x%x bytes.\n",
  202. ha->optrom_region_size));
  203. vfree(ha->optrom_buffer);
  204. ha->optrom_buffer = NULL;
  205. break;
  206. case 1:
  207. if (ha->optrom_state != QLA_SWAITING)
  208. break;
  209. if (start & 0xfff) {
  210. qla_printk(KERN_WARNING, ha,
  211. "Invalid start region 0x%x/0x%x.\n", start, size);
  212. return -EINVAL;
  213. }
  214. ha->optrom_region_start = start;
  215. ha->optrom_region_size = start + size > ha->optrom_size ?
  216. ha->optrom_size - start : size;
  217. ha->optrom_state = QLA_SREADING;
  218. ha->optrom_buffer = vmalloc(ha->optrom_region_size);
  219. if (ha->optrom_buffer == NULL) {
  220. qla_printk(KERN_WARNING, ha,
  221. "Unable to allocate memory for optrom retrieval "
  222. "(%x).\n", ha->optrom_region_size);
  223. ha->optrom_state = QLA_SWAITING;
  224. return count;
  225. }
  226. DEBUG2(qla_printk(KERN_INFO, ha,
  227. "Reading flash region -- 0x%x/0x%x.\n",
  228. ha->optrom_region_start, ha->optrom_region_size));
  229. memset(ha->optrom_buffer, 0, ha->optrom_region_size);
  230. ha->isp_ops->read_optrom(ha, ha->optrom_buffer,
  231. ha->optrom_region_start, ha->optrom_region_size);
  232. break;
  233. case 2:
  234. if (ha->optrom_state != QLA_SWAITING)
  235. break;
  236. /*
  237. * We need to be more restrictive on which FLASH regions are
  238. * allowed to be updated via user-space. Regions accessible
  239. * via this method include:
  240. *
  241. * ISP21xx/ISP22xx/ISP23xx type boards:
  242. *
  243. * 0x000000 -> 0x020000 -- Boot code.
  244. *
  245. * ISP2322/ISP24xx type boards:
  246. *
  247. * 0x000000 -> 0x07ffff -- Boot code.
  248. * 0x080000 -> 0x0fffff -- Firmware.
  249. *
  250. * ISP25xx type boards:
  251. *
  252. * 0x000000 -> 0x07ffff -- Boot code.
  253. * 0x080000 -> 0x0fffff -- Firmware.
  254. * 0x120000 -> 0x12ffff -- VPD and HBA parameters.
  255. */
  256. valid = 0;
  257. if (ha->optrom_size == OPTROM_SIZE_2300 && start == 0)
  258. valid = 1;
  259. else if (start == (FA_BOOT_CODE_ADDR*4) ||
  260. start == (FA_RISC_CODE_ADDR*4))
  261. valid = 1;
  262. else if (IS_QLA25XX(ha) && start == (FA_VPD_NVRAM_ADDR*4))
  263. valid = 1;
  264. if (!valid) {
  265. qla_printk(KERN_WARNING, ha,
  266. "Invalid start region 0x%x/0x%x.\n", start, size);
  267. return -EINVAL;
  268. }
  269. ha->optrom_region_start = start;
  270. ha->optrom_region_size = start + size > ha->optrom_size ?
  271. ha->optrom_size - start : size;
  272. ha->optrom_state = QLA_SWRITING;
  273. ha->optrom_buffer = vmalloc(ha->optrom_region_size);
  274. if (ha->optrom_buffer == NULL) {
  275. qla_printk(KERN_WARNING, ha,
  276. "Unable to allocate memory for optrom update "
  277. "(%x).\n", ha->optrom_region_size);
  278. ha->optrom_state = QLA_SWAITING;
  279. return count;
  280. }
  281. DEBUG2(qla_printk(KERN_INFO, ha,
  282. "Staging flash region write -- 0x%x/0x%x.\n",
  283. ha->optrom_region_start, ha->optrom_region_size));
  284. memset(ha->optrom_buffer, 0, ha->optrom_region_size);
  285. break;
  286. case 3:
  287. if (ha->optrom_state != QLA_SWRITING)
  288. break;
  289. DEBUG2(qla_printk(KERN_INFO, ha,
  290. "Writing flash region -- 0x%x/0x%x.\n",
  291. ha->optrom_region_start, ha->optrom_region_size));
  292. ha->isp_ops->write_optrom(ha, ha->optrom_buffer,
  293. ha->optrom_region_start, ha->optrom_region_size);
  294. break;
  295. default:
  296. count = -EINVAL;
  297. }
  298. return count;
  299. }
  300. static struct bin_attribute sysfs_optrom_ctl_attr = {
  301. .attr = {
  302. .name = "optrom_ctl",
  303. .mode = S_IWUSR,
  304. },
  305. .size = 0,
  306. .write = qla2x00_sysfs_write_optrom_ctl,
  307. };
  308. static ssize_t
  309. qla2x00_sysfs_read_vpd(struct kobject *kobj,
  310. struct bin_attribute *bin_attr,
  311. char *buf, loff_t off, size_t count)
  312. {
  313. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  314. struct device, kobj)));
  315. int size = ha->vpd_size;
  316. char *vpd_cache = ha->vpd;
  317. if (!capable(CAP_SYS_ADMIN) || off > size || count == 0)
  318. return 0;
  319. if (off + count > size) {
  320. size -= off;
  321. count = size;
  322. }
  323. /* Read NVRAM data from cache. */
  324. memcpy(buf, &vpd_cache[off], count);
  325. return count;
  326. }
  327. static ssize_t
  328. qla2x00_sysfs_write_vpd(struct kobject *kobj,
  329. struct bin_attribute *bin_attr,
  330. char *buf, loff_t off, size_t count)
  331. {
  332. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  333. struct device, kobj)));
  334. if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size)
  335. return 0;
  336. /* Write NVRAM. */
  337. ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count);
  338. ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd, ha->vpd_base, count);
  339. return count;
  340. }
  341. static struct bin_attribute sysfs_vpd_attr = {
  342. .attr = {
  343. .name = "vpd",
  344. .mode = S_IRUSR | S_IWUSR,
  345. },
  346. .size = 0,
  347. .read = qla2x00_sysfs_read_vpd,
  348. .write = qla2x00_sysfs_write_vpd,
  349. };
  350. static ssize_t
  351. qla2x00_sysfs_read_sfp(struct kobject *kobj,
  352. struct bin_attribute *bin_attr,
  353. char *buf, loff_t off, size_t count)
  354. {
  355. struct scsi_qla_host *ha = shost_priv(dev_to_shost(container_of(kobj,
  356. struct device, kobj)));
  357. uint16_t iter, addr, offset;
  358. int rval;
  359. if (!capable(CAP_SYS_ADMIN) || off != 0 || count != SFP_DEV_SIZE * 2)
  360. return 0;
  361. addr = 0xa0;
  362. for (iter = 0, offset = 0; iter < (SFP_DEV_SIZE * 2) / SFP_BLOCK_SIZE;
  363. iter++, offset += SFP_BLOCK_SIZE) {
  364. if (iter == 4) {
  365. /* Skip to next device address. */
  366. addr = 0xa2;
  367. offset = 0;
  368. }
  369. rval = qla2x00_read_sfp(ha, ha->sfp_data_dma, addr, offset,
  370. SFP_BLOCK_SIZE);
  371. if (rval != QLA_SUCCESS) {
  372. qla_printk(KERN_WARNING, ha,
  373. "Unable to read SFP data (%x/%x/%x).\n", rval,
  374. addr, offset);
  375. count = 0;
  376. break;
  377. }
  378. memcpy(buf, ha->sfp_data, SFP_BLOCK_SIZE);
  379. buf += SFP_BLOCK_SIZE;
  380. }
  381. return count;
  382. }
  383. static struct bin_attribute sysfs_sfp_attr = {
  384. .attr = {
  385. .name = "sfp",
  386. .mode = S_IRUSR | S_IWUSR,
  387. },
  388. .size = SFP_DEV_SIZE * 2,
  389. .read = qla2x00_sysfs_read_sfp,
  390. };
  391. static struct sysfs_entry {
  392. char *name;
  393. struct bin_attribute *attr;
  394. int is4GBp_only;
  395. } bin_file_entries[] = {
  396. { "fw_dump", &sysfs_fw_dump_attr, },
  397. { "nvram", &sysfs_nvram_attr, },
  398. { "optrom", &sysfs_optrom_attr, },
  399. { "optrom_ctl", &sysfs_optrom_ctl_attr, },
  400. { "vpd", &sysfs_vpd_attr, 1 },
  401. { "sfp", &sysfs_sfp_attr, 1 },
  402. { NULL },
  403. };
  404. void
  405. qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha)
  406. {
  407. struct Scsi_Host *host = ha->host;
  408. struct sysfs_entry *iter;
  409. int ret;
  410. for (iter = bin_file_entries; iter->name; iter++) {
  411. if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
  412. continue;
  413. ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
  414. iter->attr);
  415. if (ret)
  416. qla_printk(KERN_INFO, ha,
  417. "Unable to create sysfs %s binary attribute "
  418. "(%d).\n", iter->name, ret);
  419. }
  420. }
  421. void
  422. qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
  423. {
  424. struct Scsi_Host *host = ha->host;
  425. struct sysfs_entry *iter;
  426. for (iter = bin_file_entries; iter->name; iter++) {
  427. if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
  428. continue;
  429. sysfs_remove_bin_file(&host->shost_gendev.kobj,
  430. iter->attr);
  431. }
  432. if (ha->beacon_blink_led == 1)
  433. ha->isp_ops->beacon_off(ha);
  434. }
  435. /* Scsi_Host attributes. */
  436. static ssize_t
  437. qla2x00_drvr_version_show(struct class_device *cdev, char *buf)
  438. {
  439. return snprintf(buf, PAGE_SIZE, "%s\n", qla2x00_version_str);
  440. }
  441. static ssize_t
  442. qla2x00_fw_version_show(struct class_device *cdev, char *buf)
  443. {
  444. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  445. char fw_str[30];
  446. return snprintf(buf, PAGE_SIZE, "%s\n",
  447. ha->isp_ops->fw_version_str(ha, fw_str));
  448. }
  449. static ssize_t
  450. qla2x00_serial_num_show(struct class_device *cdev, char *buf)
  451. {
  452. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  453. uint32_t sn;
  454. if (IS_FWI2_CAPABLE(ha))
  455. return snprintf(buf, PAGE_SIZE, "\n");
  456. sn = ((ha->serial0 & 0x1f) << 16) | (ha->serial2 << 8) | ha->serial1;
  457. return snprintf(buf, PAGE_SIZE, "%c%05d\n", 'A' + sn / 100000,
  458. sn % 100000);
  459. }
  460. static ssize_t
  461. qla2x00_isp_name_show(struct class_device *cdev, char *buf)
  462. {
  463. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  464. return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device);
  465. }
  466. static ssize_t
  467. qla2x00_isp_id_show(struct class_device *cdev, char *buf)
  468. {
  469. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  470. return snprintf(buf, PAGE_SIZE, "%04x %04x %04x %04x\n",
  471. ha->product_id[0], ha->product_id[1], ha->product_id[2],
  472. ha->product_id[3]);
  473. }
  474. static ssize_t
  475. qla2x00_model_name_show(struct class_device *cdev, char *buf)
  476. {
  477. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  478. return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_number);
  479. }
  480. static ssize_t
  481. qla2x00_model_desc_show(struct class_device *cdev, char *buf)
  482. {
  483. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  484. return snprintf(buf, PAGE_SIZE, "%s\n",
  485. ha->model_desc ? ha->model_desc: "");
  486. }
  487. static ssize_t
  488. qla2x00_pci_info_show(struct class_device *cdev, char *buf)
  489. {
  490. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  491. char pci_info[30];
  492. return snprintf(buf, PAGE_SIZE, "%s\n",
  493. ha->isp_ops->pci_info_str(ha, pci_info));
  494. }
  495. static ssize_t
  496. qla2x00_state_show(struct class_device *cdev, char *buf)
  497. {
  498. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  499. int len = 0;
  500. if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
  501. atomic_read(&ha->loop_state) == LOOP_DEAD)
  502. len = snprintf(buf, PAGE_SIZE, "Link Down\n");
  503. else if (atomic_read(&ha->loop_state) != LOOP_READY ||
  504. test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) ||
  505. test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags))
  506. len = snprintf(buf, PAGE_SIZE, "Unknown Link State\n");
  507. else {
  508. len = snprintf(buf, PAGE_SIZE, "Link Up - ");
  509. switch (ha->current_topology) {
  510. case ISP_CFG_NL:
  511. len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n");
  512. break;
  513. case ISP_CFG_FL:
  514. len += snprintf(buf + len, PAGE_SIZE-len, "FL_Port\n");
  515. break;
  516. case ISP_CFG_N:
  517. len += snprintf(buf + len, PAGE_SIZE-len,
  518. "N_Port to N_Port\n");
  519. break;
  520. case ISP_CFG_F:
  521. len += snprintf(buf + len, PAGE_SIZE-len, "F_Port\n");
  522. break;
  523. default:
  524. len += snprintf(buf + len, PAGE_SIZE-len, "Loop\n");
  525. break;
  526. }
  527. }
  528. return len;
  529. }
  530. static ssize_t
  531. qla2x00_zio_show(struct class_device *cdev, char *buf)
  532. {
  533. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  534. int len = 0;
  535. switch (ha->zio_mode) {
  536. case QLA_ZIO_MODE_6:
  537. len += snprintf(buf + len, PAGE_SIZE-len, "Mode 6\n");
  538. break;
  539. case QLA_ZIO_DISABLED:
  540. len += snprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
  541. break;
  542. }
  543. return len;
  544. }
  545. static ssize_t
  546. qla2x00_zio_store(struct class_device *cdev, const char *buf, size_t count)
  547. {
  548. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  549. int val = 0;
  550. uint16_t zio_mode;
  551. if (!IS_ZIO_SUPPORTED(ha))
  552. return -ENOTSUPP;
  553. if (sscanf(buf, "%d", &val) != 1)
  554. return -EINVAL;
  555. if (val)
  556. zio_mode = QLA_ZIO_MODE_6;
  557. else
  558. zio_mode = QLA_ZIO_DISABLED;
  559. /* Update per-hba values and queue a reset. */
  560. if (zio_mode != QLA_ZIO_DISABLED || ha->zio_mode != QLA_ZIO_DISABLED) {
  561. ha->zio_mode = zio_mode;
  562. set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
  563. }
  564. return strlen(buf);
  565. }
  566. static ssize_t
  567. qla2x00_zio_timer_show(struct class_device *cdev, char *buf)
  568. {
  569. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  570. return snprintf(buf, PAGE_SIZE, "%d us\n", ha->zio_timer * 100);
  571. }
  572. static ssize_t
  573. qla2x00_zio_timer_store(struct class_device *cdev, const char *buf,
  574. size_t count)
  575. {
  576. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  577. int val = 0;
  578. uint16_t zio_timer;
  579. if (sscanf(buf, "%d", &val) != 1)
  580. return -EINVAL;
  581. if (val > 25500 || val < 100)
  582. return -ERANGE;
  583. zio_timer = (uint16_t)(val / 100);
  584. ha->zio_timer = zio_timer;
  585. return strlen(buf);
  586. }
  587. static ssize_t
  588. qla2x00_beacon_show(struct class_device *cdev, char *buf)
  589. {
  590. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  591. int len = 0;
  592. if (ha->beacon_blink_led)
  593. len += snprintf(buf + len, PAGE_SIZE-len, "Enabled\n");
  594. else
  595. len += snprintf(buf + len, PAGE_SIZE-len, "Disabled\n");
  596. return len;
  597. }
  598. static ssize_t
  599. qla2x00_beacon_store(struct class_device *cdev, const char *buf,
  600. size_t count)
  601. {
  602. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  603. int val = 0;
  604. int rval;
  605. if (IS_QLA2100(ha) || IS_QLA2200(ha))
  606. return -EPERM;
  607. if (test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags)) {
  608. qla_printk(KERN_WARNING, ha,
  609. "Abort ISP active -- ignoring beacon request.\n");
  610. return -EBUSY;
  611. }
  612. if (sscanf(buf, "%d", &val) != 1)
  613. return -EINVAL;
  614. if (val)
  615. rval = ha->isp_ops->beacon_on(ha);
  616. else
  617. rval = ha->isp_ops->beacon_off(ha);
  618. if (rval != QLA_SUCCESS)
  619. count = 0;
  620. return count;
  621. }
  622. static ssize_t
  623. qla2x00_optrom_bios_version_show(struct class_device *cdev, char *buf)
  624. {
  625. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  626. return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->bios_revision[1],
  627. ha->bios_revision[0]);
  628. }
  629. static ssize_t
  630. qla2x00_optrom_efi_version_show(struct class_device *cdev, char *buf)
  631. {
  632. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  633. return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->efi_revision[1],
  634. ha->efi_revision[0]);
  635. }
  636. static ssize_t
  637. qla2x00_optrom_fcode_version_show(struct class_device *cdev, char *buf)
  638. {
  639. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  640. return snprintf(buf, PAGE_SIZE, "%d.%02d\n", ha->fcode_revision[1],
  641. ha->fcode_revision[0]);
  642. }
  643. static ssize_t
  644. qla2x00_optrom_fw_version_show(struct class_device *cdev, char *buf)
  645. {
  646. scsi_qla_host_t *ha = shost_priv(class_to_shost(cdev));
  647. return snprintf(buf, PAGE_SIZE, "%d.%02d.%02d %d\n",
  648. ha->fw_revision[0], ha->fw_revision[1], ha->fw_revision[2],
  649. ha->fw_revision[3]);
  650. }
  651. static CLASS_DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show,
  652. NULL);
  653. static CLASS_DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
  654. static CLASS_DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
  655. static CLASS_DEVICE_ATTR(isp_name, S_IRUGO, qla2x00_isp_name_show, NULL);
  656. static CLASS_DEVICE_ATTR(isp_id, S_IRUGO, qla2x00_isp_id_show, NULL);
  657. static CLASS_DEVICE_ATTR(model_name, S_IRUGO, qla2x00_model_name_show, NULL);
  658. static CLASS_DEVICE_ATTR(model_desc, S_IRUGO, qla2x00_model_desc_show, NULL);
  659. static CLASS_DEVICE_ATTR(pci_info, S_IRUGO, qla2x00_pci_info_show, NULL);
  660. static CLASS_DEVICE_ATTR(state, S_IRUGO, qla2x00_state_show, NULL);
  661. static CLASS_DEVICE_ATTR(zio, S_IRUGO | S_IWUSR, qla2x00_zio_show,
  662. qla2x00_zio_store);
  663. static CLASS_DEVICE_ATTR(zio_timer, S_IRUGO | S_IWUSR, qla2x00_zio_timer_show,
  664. qla2x00_zio_timer_store);
  665. static CLASS_DEVICE_ATTR(beacon, S_IRUGO | S_IWUSR, qla2x00_beacon_show,
  666. qla2x00_beacon_store);
  667. static CLASS_DEVICE_ATTR(optrom_bios_version, S_IRUGO,
  668. qla2x00_optrom_bios_version_show, NULL);
  669. static CLASS_DEVICE_ATTR(optrom_efi_version, S_IRUGO,
  670. qla2x00_optrom_efi_version_show, NULL);
  671. static CLASS_DEVICE_ATTR(optrom_fcode_version, S_IRUGO,
  672. qla2x00_optrom_fcode_version_show, NULL);
  673. static CLASS_DEVICE_ATTR(optrom_fw_version, S_IRUGO,
  674. qla2x00_optrom_fw_version_show, NULL);
  675. struct class_device_attribute *qla2x00_host_attrs[] = {
  676. &class_device_attr_driver_version,
  677. &class_device_attr_fw_version,
  678. &class_device_attr_serial_num,
  679. &class_device_attr_isp_name,
  680. &class_device_attr_isp_id,
  681. &class_device_attr_model_name,
  682. &class_device_attr_model_desc,
  683. &class_device_attr_pci_info,
  684. &class_device_attr_state,
  685. &class_device_attr_zio,
  686. &class_device_attr_zio_timer,
  687. &class_device_attr_beacon,
  688. &class_device_attr_optrom_bios_version,
  689. &class_device_attr_optrom_efi_version,
  690. &class_device_attr_optrom_fcode_version,
  691. &class_device_attr_optrom_fw_version,
  692. NULL,
  693. };
  694. /* Host attributes. */
  695. static void
  696. qla2x00_get_host_port_id(struct Scsi_Host *shost)
  697. {
  698. scsi_qla_host_t *ha = shost_priv(shost);
  699. fc_host_port_id(shost) = ha->d_id.b.domain << 16 |
  700. ha->d_id.b.area << 8 | ha->d_id.b.al_pa;
  701. }
  702. static void
  703. qla2x00_get_host_speed(struct Scsi_Host *shost)
  704. {
  705. scsi_qla_host_t *ha = shost_priv(shost);
  706. uint32_t speed = 0;
  707. switch (ha->link_data_rate) {
  708. case PORT_SPEED_1GB:
  709. speed = 1;
  710. break;
  711. case PORT_SPEED_2GB:
  712. speed = 2;
  713. break;
  714. case PORT_SPEED_4GB:
  715. speed = 4;
  716. break;
  717. }
  718. fc_host_speed(shost) = speed;
  719. }
  720. static void
  721. qla2x00_get_host_port_type(struct Scsi_Host *shost)
  722. {
  723. scsi_qla_host_t *ha = shost_priv(shost);
  724. uint32_t port_type = FC_PORTTYPE_UNKNOWN;
  725. switch (ha->current_topology) {
  726. case ISP_CFG_NL:
  727. port_type = FC_PORTTYPE_LPORT;
  728. break;
  729. case ISP_CFG_FL:
  730. port_type = FC_PORTTYPE_NLPORT;
  731. break;
  732. case ISP_CFG_N:
  733. port_type = FC_PORTTYPE_PTP;
  734. break;
  735. case ISP_CFG_F:
  736. port_type = FC_PORTTYPE_NPORT;
  737. break;
  738. }
  739. fc_host_port_type(shost) = port_type;
  740. }
  741. static void
  742. qla2x00_get_starget_node_name(struct scsi_target *starget)
  743. {
  744. struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
  745. scsi_qla_host_t *ha = shost_priv(host);
  746. fc_port_t *fcport;
  747. u64 node_name = 0;
  748. list_for_each_entry(fcport, &ha->fcports, list) {
  749. if (starget->id == fcport->os_target_id) {
  750. node_name = wwn_to_u64(fcport->node_name);
  751. break;
  752. }
  753. }
  754. fc_starget_node_name(starget) = node_name;
  755. }
  756. static void
  757. qla2x00_get_starget_port_name(struct scsi_target *starget)
  758. {
  759. struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
  760. scsi_qla_host_t *ha = shost_priv(host);
  761. fc_port_t *fcport;
  762. u64 port_name = 0;
  763. list_for_each_entry(fcport, &ha->fcports, list) {
  764. if (starget->id == fcport->os_target_id) {
  765. port_name = wwn_to_u64(fcport->port_name);
  766. break;
  767. }
  768. }
  769. fc_starget_port_name(starget) = port_name;
  770. }
  771. static void
  772. qla2x00_get_starget_port_id(struct scsi_target *starget)
  773. {
  774. struct Scsi_Host *host = dev_to_shost(starget->dev.parent);
  775. scsi_qla_host_t *ha = shost_priv(host);
  776. fc_port_t *fcport;
  777. uint32_t port_id = ~0U;
  778. list_for_each_entry(fcport, &ha->fcports, list) {
  779. if (starget->id == fcport->os_target_id) {
  780. port_id = fcport->d_id.b.domain << 16 |
  781. fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa;
  782. break;
  783. }
  784. }
  785. fc_starget_port_id(starget) = port_id;
  786. }
  787. static void
  788. qla2x00_get_rport_loss_tmo(struct fc_rport *rport)
  789. {
  790. struct Scsi_Host *host = rport_to_shost(rport);
  791. scsi_qla_host_t *ha = shost_priv(host);
  792. rport->dev_loss_tmo = ha->port_down_retry_count + 5;
  793. }
  794. static void
  795. qla2x00_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
  796. {
  797. struct Scsi_Host *host = rport_to_shost(rport);
  798. scsi_qla_host_t *ha = shost_priv(host);
  799. if (timeout)
  800. ha->port_down_retry_count = timeout;
  801. else
  802. ha->port_down_retry_count = 1;
  803. rport->dev_loss_tmo = ha->port_down_retry_count + 5;
  804. }
  805. static int
  806. qla2x00_issue_lip(struct Scsi_Host *shost)
  807. {
  808. scsi_qla_host_t *ha = shost_priv(shost);
  809. set_bit(LOOP_RESET_NEEDED, &ha->dpc_flags);
  810. return 0;
  811. }
  812. static struct fc_host_statistics *
  813. qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
  814. {
  815. scsi_qla_host_t *ha = shost_priv(shost);
  816. int rval;
  817. uint16_t mb_stat[1];
  818. link_stat_t stat_buf;
  819. struct fc_host_statistics *pfc_host_stat;
  820. rval = QLA_FUNCTION_FAILED;
  821. pfc_host_stat = &ha->fc_host_stat;
  822. memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics));
  823. if (IS_FWI2_CAPABLE(ha)) {
  824. rval = qla24xx_get_isp_stats(ha, (uint32_t *)&stat_buf,
  825. sizeof(stat_buf) / 4, mb_stat);
  826. } else if (atomic_read(&ha->loop_state) == LOOP_READY &&
  827. !test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) &&
  828. !test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) &&
  829. !ha->dpc_active) {
  830. /* Must be in a 'READY' state for statistics retrieval. */
  831. rval = qla2x00_get_link_status(ha, ha->loop_id, &stat_buf,
  832. mb_stat);
  833. }
  834. if (rval != QLA_SUCCESS)
  835. goto done;
  836. pfc_host_stat->link_failure_count = stat_buf.link_fail_cnt;
  837. pfc_host_stat->loss_of_sync_count = stat_buf.loss_sync_cnt;
  838. pfc_host_stat->loss_of_signal_count = stat_buf.loss_sig_cnt;
  839. pfc_host_stat->prim_seq_protocol_err_count = stat_buf.prim_seq_err_cnt;
  840. pfc_host_stat->invalid_tx_word_count = stat_buf.inval_xmit_word_cnt;
  841. pfc_host_stat->invalid_crc_count = stat_buf.inval_crc_cnt;
  842. done:
  843. return pfc_host_stat;
  844. }
  845. static void
  846. qla2x00_get_host_symbolic_name(struct Scsi_Host *shost)
  847. {
  848. scsi_qla_host_t *ha = shost_priv(shost);
  849. qla2x00_get_sym_node_name(ha, fc_host_symbolic_name(shost));
  850. }
  851. static void
  852. qla2x00_set_host_system_hostname(struct Scsi_Host *shost)
  853. {
  854. scsi_qla_host_t *ha = shost_priv(shost);
  855. set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags);
  856. }
  857. static void
  858. qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
  859. {
  860. scsi_qla_host_t *ha = shost_priv(shost);
  861. u64 node_name;
  862. if (ha->device_flags & SWITCH_FOUND)
  863. node_name = wwn_to_u64(ha->fabric_node_name);
  864. else
  865. node_name = wwn_to_u64(ha->node_name);
  866. fc_host_fabric_name(shost) = node_name;
  867. }
  868. static void
  869. qla2x00_get_host_port_state(struct Scsi_Host *shost)
  870. {
  871. scsi_qla_host_t *ha = shost_priv(shost);
  872. if (!ha->flags.online)
  873. fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
  874. else if (atomic_read(&ha->loop_state) == LOOP_TIMEOUT)
  875. fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
  876. else
  877. fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
  878. }
  879. static int
  880. qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
  881. {
  882. int ret = 0;
  883. scsi_qla_host_t *ha = shost_priv(fc_vport->shost);
  884. scsi_qla_host_t *vha;
  885. ret = qla24xx_vport_create_req_sanity_check(fc_vport);
  886. if (ret) {
  887. DEBUG15(printk("qla24xx_vport_create_req_sanity_check failed, "
  888. "status %x\n", ret));
  889. return (ret);
  890. }
  891. vha = qla24xx_create_vhost(fc_vport);
  892. if (vha == NULL) {
  893. DEBUG15(printk ("qla24xx_create_vhost failed, vha = %p\n",
  894. vha));
  895. return FC_VPORT_FAILED;
  896. }
  897. if (disable) {
  898. atomic_set(&vha->vp_state, VP_OFFLINE);
  899. fc_vport_set_state(fc_vport, FC_VPORT_DISABLED);
  900. } else
  901. atomic_set(&vha->vp_state, VP_FAILED);
  902. /* ready to create vport */
  903. qla_printk(KERN_INFO, vha, "VP entry id %d assigned.\n", vha->vp_idx);
  904. /* initialized vport states */
  905. atomic_set(&vha->loop_state, LOOP_DOWN);
  906. vha->vp_err_state= VP_ERR_PORTDWN;
  907. vha->vp_prev_err_state= VP_ERR_UNKWN;
  908. /* Check if physical ha port is Up */
  909. if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
  910. atomic_read(&ha->loop_state) == LOOP_DEAD) {
  911. /* Don't retry or attempt login of this virtual port */
  912. DEBUG15(printk ("scsi(%ld): pport loop_state is not UP.\n",
  913. vha->host_no));
  914. atomic_set(&vha->loop_state, LOOP_DEAD);
  915. if (!disable)
  916. fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN);
  917. }
  918. if (scsi_add_host(vha->host, &fc_vport->dev)) {
  919. DEBUG15(printk("scsi(%ld): scsi_add_host failure for VP[%d].\n",
  920. vha->host_no, vha->vp_idx));
  921. goto vport_create_failed_2;
  922. }
  923. /* initialize attributes */
  924. fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
  925. fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
  926. fc_host_supported_classes(vha->host) =
  927. fc_host_supported_classes(ha->host);
  928. fc_host_supported_speeds(vha->host) =
  929. fc_host_supported_speeds(ha->host);
  930. qla24xx_vport_disable(fc_vport, disable);
  931. return 0;
  932. vport_create_failed_2:
  933. qla24xx_disable_vp(vha);
  934. qla24xx_deallocate_vp_id(vha);
  935. kfree(vha->port_name);
  936. kfree(vha->node_name);
  937. scsi_host_put(vha->host);
  938. return FC_VPORT_FAILED;
  939. }
  940. int
  941. qla24xx_vport_delete(struct fc_vport *fc_vport)
  942. {
  943. scsi_qla_host_t *ha = shost_priv(fc_vport->shost);
  944. scsi_qla_host_t *vha = fc_vport->dd_data;
  945. qla24xx_disable_vp(vha);
  946. qla24xx_deallocate_vp_id(vha);
  947. down(&ha->vport_sem);
  948. ha->cur_vport_count--;
  949. clear_bit(vha->vp_idx, ha->vp_idx_map);
  950. up(&ha->vport_sem);
  951. kfree(vha->node_name);
  952. kfree(vha->port_name);
  953. if (vha->timer_active) {
  954. qla2x00_vp_stop_timer(vha);
  955. DEBUG15(printk ("scsi(%ld): timer for the vport[%d] = %p "
  956. "has stopped\n",
  957. vha->host_no, vha->vp_idx, vha));
  958. }
  959. fc_remove_host(vha->host);
  960. scsi_remove_host(vha->host);
  961. scsi_host_put(vha->host);
  962. return 0;
  963. }
  964. int
  965. qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
  966. {
  967. scsi_qla_host_t *vha = fc_vport->dd_data;
  968. if (disable)
  969. qla24xx_disable_vp(vha);
  970. else
  971. qla24xx_enable_vp(vha);
  972. return 0;
  973. }
  974. struct fc_function_template qla2xxx_transport_functions = {
  975. .show_host_node_name = 1,
  976. .show_host_port_name = 1,
  977. .show_host_supported_classes = 1,
  978. .get_host_port_id = qla2x00_get_host_port_id,
  979. .show_host_port_id = 1,
  980. .get_host_speed = qla2x00_get_host_speed,
  981. .show_host_speed = 1,
  982. .get_host_port_type = qla2x00_get_host_port_type,
  983. .show_host_port_type = 1,
  984. .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
  985. .show_host_symbolic_name = 1,
  986. .set_host_system_hostname = qla2x00_set_host_system_hostname,
  987. .show_host_system_hostname = 1,
  988. .get_host_fabric_name = qla2x00_get_host_fabric_name,
  989. .show_host_fabric_name = 1,
  990. .get_host_port_state = qla2x00_get_host_port_state,
  991. .show_host_port_state = 1,
  992. .dd_fcrport_size = sizeof(struct fc_port *),
  993. .show_rport_supported_classes = 1,
  994. .get_starget_node_name = qla2x00_get_starget_node_name,
  995. .show_starget_node_name = 1,
  996. .get_starget_port_name = qla2x00_get_starget_port_name,
  997. .show_starget_port_name = 1,
  998. .get_starget_port_id = qla2x00_get_starget_port_id,
  999. .show_starget_port_id = 1,
  1000. .get_rport_dev_loss_tmo = qla2x00_get_rport_loss_tmo,
  1001. .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
  1002. .show_rport_dev_loss_tmo = 1,
  1003. .issue_fc_host_lip = qla2x00_issue_lip,
  1004. .get_fc_host_stats = qla2x00_get_fc_host_stats,
  1005. .vport_create = qla24xx_vport_create,
  1006. .vport_disable = qla24xx_vport_disable,
  1007. .vport_delete = qla24xx_vport_delete,
  1008. };
  1009. struct fc_function_template qla2xxx_transport_vport_functions = {
  1010. .show_host_node_name = 1,
  1011. .show_host_port_name = 1,
  1012. .show_host_supported_classes = 1,
  1013. .get_host_port_id = qla2x00_get_host_port_id,
  1014. .show_host_port_id = 1,
  1015. .get_host_speed = qla2x00_get_host_speed,
  1016. .show_host_speed = 1,
  1017. .get_host_port_type = qla2x00_get_host_port_type,
  1018. .show_host_port_type = 1,
  1019. .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
  1020. .show_host_symbolic_name = 1,
  1021. .set_host_system_hostname = qla2x00_set_host_system_hostname,
  1022. .show_host_system_hostname = 1,
  1023. .get_host_fabric_name = qla2x00_get_host_fabric_name,
  1024. .show_host_fabric_name = 1,
  1025. .get_host_port_state = qla2x00_get_host_port_state,
  1026. .show_host_port_state = 1,
  1027. .dd_fcrport_size = sizeof(struct fc_port *),
  1028. .show_rport_supported_classes = 1,
  1029. .get_starget_node_name = qla2x00_get_starget_node_name,
  1030. .show_starget_node_name = 1,
  1031. .get_starget_port_name = qla2x00_get_starget_port_name,
  1032. .show_starget_port_name = 1,
  1033. .get_starget_port_id = qla2x00_get_starget_port_id,
  1034. .show_starget_port_id = 1,
  1035. .get_rport_dev_loss_tmo = qla2x00_get_rport_loss_tmo,
  1036. .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
  1037. .show_rport_dev_loss_tmo = 1,
  1038. .issue_fc_host_lip = qla2x00_issue_lip,
  1039. .get_fc_host_stats = qla2x00_get_fc_host_stats,
  1040. };
  1041. void
  1042. qla2x00_init_host_attr(scsi_qla_host_t *ha)
  1043. {
  1044. fc_host_node_name(ha->host) = wwn_to_u64(ha->node_name);
  1045. fc_host_port_name(ha->host) = wwn_to_u64(ha->port_name);
  1046. fc_host_supported_classes(ha->host) = FC_COS_CLASS3;
  1047. fc_host_max_npiv_vports(ha->host) = ha->max_npiv_vports;;
  1048. fc_host_npiv_vports_inuse(ha->host) = ha->cur_vport_count;
  1049. }