qla_attr.c 32 KB

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