qla_attr.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268
  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. static 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. qla2x00_loop_reset(ha);
  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. struct link_statistics *stats;
  818. dma_addr_t stats_dma;
  819. struct fc_host_statistics *pfc_host_stat;
  820. pfc_host_stat = &ha->fc_host_stat;
  821. memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics));
  822. stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma);
  823. if (stats == NULL) {
  824. DEBUG2_3_11(printk("%s(%ld): Failed to allocate memory.\n",
  825. __func__, ha->host_no));
  826. goto done;
  827. }
  828. memset(stats, 0, DMA_POOL_SIZE);
  829. rval = QLA_FUNCTION_FAILED;
  830. if (IS_FWI2_CAPABLE(ha)) {
  831. rval = qla24xx_get_isp_stats(ha, stats, stats_dma);
  832. } else if (atomic_read(&ha->loop_state) == LOOP_READY &&
  833. !test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) &&
  834. !test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) &&
  835. !ha->dpc_active) {
  836. /* Must be in a 'READY' state for statistics retrieval. */
  837. rval = qla2x00_get_link_status(ha, ha->loop_id, stats,
  838. stats_dma);
  839. }
  840. if (rval != QLA_SUCCESS)
  841. goto done_free;
  842. pfc_host_stat->link_failure_count = stats->link_fail_cnt;
  843. pfc_host_stat->loss_of_sync_count = stats->loss_sync_cnt;
  844. pfc_host_stat->loss_of_signal_count = stats->loss_sig_cnt;
  845. pfc_host_stat->prim_seq_protocol_err_count = stats->prim_seq_err_cnt;
  846. pfc_host_stat->invalid_tx_word_count = stats->inval_xmit_word_cnt;
  847. pfc_host_stat->invalid_crc_count = stats->inval_crc_cnt;
  848. if (IS_FWI2_CAPABLE(ha)) {
  849. pfc_host_stat->tx_frames = stats->tx_frames;
  850. pfc_host_stat->rx_frames = stats->rx_frames;
  851. pfc_host_stat->dumped_frames = stats->dumped_frames;
  852. pfc_host_stat->nos_count = stats->nos_rcvd;
  853. }
  854. done_free:
  855. dma_pool_free(ha->s_dma_pool, stats, stats_dma);
  856. done:
  857. return pfc_host_stat;
  858. }
  859. static void
  860. qla2x00_get_host_symbolic_name(struct Scsi_Host *shost)
  861. {
  862. scsi_qla_host_t *ha = shost_priv(shost);
  863. qla2x00_get_sym_node_name(ha, fc_host_symbolic_name(shost));
  864. }
  865. static void
  866. qla2x00_set_host_system_hostname(struct Scsi_Host *shost)
  867. {
  868. scsi_qla_host_t *ha = shost_priv(shost);
  869. set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags);
  870. }
  871. static void
  872. qla2x00_get_host_fabric_name(struct Scsi_Host *shost)
  873. {
  874. scsi_qla_host_t *ha = shost_priv(shost);
  875. u64 node_name;
  876. if (ha->device_flags & SWITCH_FOUND)
  877. node_name = wwn_to_u64(ha->fabric_node_name);
  878. else
  879. node_name = wwn_to_u64(ha->node_name);
  880. fc_host_fabric_name(shost) = node_name;
  881. }
  882. static void
  883. qla2x00_get_host_port_state(struct Scsi_Host *shost)
  884. {
  885. scsi_qla_host_t *ha = shost_priv(shost);
  886. if (!ha->flags.online)
  887. fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
  888. else if (atomic_read(&ha->loop_state) == LOOP_TIMEOUT)
  889. fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
  890. else
  891. fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
  892. }
  893. static int
  894. qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
  895. {
  896. int ret = 0;
  897. scsi_qla_host_t *ha = shost_priv(fc_vport->shost);
  898. scsi_qla_host_t *vha;
  899. ret = qla24xx_vport_create_req_sanity_check(fc_vport);
  900. if (ret) {
  901. DEBUG15(printk("qla24xx_vport_create_req_sanity_check failed, "
  902. "status %x\n", ret));
  903. return (ret);
  904. }
  905. vha = qla24xx_create_vhost(fc_vport);
  906. if (vha == NULL) {
  907. DEBUG15(printk ("qla24xx_create_vhost failed, vha = %p\n",
  908. vha));
  909. return FC_VPORT_FAILED;
  910. }
  911. if (disable) {
  912. atomic_set(&vha->vp_state, VP_OFFLINE);
  913. fc_vport_set_state(fc_vport, FC_VPORT_DISABLED);
  914. } else
  915. atomic_set(&vha->vp_state, VP_FAILED);
  916. /* ready to create vport */
  917. qla_printk(KERN_INFO, vha, "VP entry id %d assigned.\n", vha->vp_idx);
  918. /* initialized vport states */
  919. atomic_set(&vha->loop_state, LOOP_DOWN);
  920. vha->vp_err_state= VP_ERR_PORTDWN;
  921. vha->vp_prev_err_state= VP_ERR_UNKWN;
  922. /* Check if physical ha port is Up */
  923. if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
  924. atomic_read(&ha->loop_state) == LOOP_DEAD) {
  925. /* Don't retry or attempt login of this virtual port */
  926. DEBUG15(printk ("scsi(%ld): pport loop_state is not UP.\n",
  927. vha->host_no));
  928. atomic_set(&vha->loop_state, LOOP_DEAD);
  929. if (!disable)
  930. fc_vport_set_state(fc_vport, FC_VPORT_LINKDOWN);
  931. }
  932. if (scsi_add_host(vha->host, &fc_vport->dev)) {
  933. DEBUG15(printk("scsi(%ld): scsi_add_host failure for VP[%d].\n",
  934. vha->host_no, vha->vp_idx));
  935. goto vport_create_failed_2;
  936. }
  937. /* initialize attributes */
  938. fc_host_node_name(vha->host) = wwn_to_u64(vha->node_name);
  939. fc_host_port_name(vha->host) = wwn_to_u64(vha->port_name);
  940. fc_host_supported_classes(vha->host) =
  941. fc_host_supported_classes(ha->host);
  942. fc_host_supported_speeds(vha->host) =
  943. fc_host_supported_speeds(ha->host);
  944. qla24xx_vport_disable(fc_vport, disable);
  945. return 0;
  946. vport_create_failed_2:
  947. qla24xx_disable_vp(vha);
  948. qla24xx_deallocate_vp_id(vha);
  949. kfree(vha->port_name);
  950. kfree(vha->node_name);
  951. scsi_host_put(vha->host);
  952. return FC_VPORT_FAILED;
  953. }
  954. static int
  955. qla24xx_vport_delete(struct fc_vport *fc_vport)
  956. {
  957. scsi_qla_host_t *ha = shost_priv(fc_vport->shost);
  958. scsi_qla_host_t *vha = fc_vport->dd_data;
  959. qla24xx_disable_vp(vha);
  960. qla24xx_deallocate_vp_id(vha);
  961. down(&ha->vport_sem);
  962. ha->cur_vport_count--;
  963. clear_bit(vha->vp_idx, ha->vp_idx_map);
  964. up(&ha->vport_sem);
  965. kfree(vha->node_name);
  966. kfree(vha->port_name);
  967. if (vha->timer_active) {
  968. qla2x00_vp_stop_timer(vha);
  969. DEBUG15(printk ("scsi(%ld): timer for the vport[%d] = %p "
  970. "has stopped\n",
  971. vha->host_no, vha->vp_idx, vha));
  972. }
  973. fc_remove_host(vha->host);
  974. scsi_remove_host(vha->host);
  975. scsi_host_put(vha->host);
  976. return 0;
  977. }
  978. static int
  979. qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
  980. {
  981. scsi_qla_host_t *vha = fc_vport->dd_data;
  982. if (disable)
  983. qla24xx_disable_vp(vha);
  984. else
  985. qla24xx_enable_vp(vha);
  986. return 0;
  987. }
  988. struct fc_function_template qla2xxx_transport_functions = {
  989. .show_host_node_name = 1,
  990. .show_host_port_name = 1,
  991. .show_host_supported_classes = 1,
  992. .get_host_port_id = qla2x00_get_host_port_id,
  993. .show_host_port_id = 1,
  994. .get_host_speed = qla2x00_get_host_speed,
  995. .show_host_speed = 1,
  996. .get_host_port_type = qla2x00_get_host_port_type,
  997. .show_host_port_type = 1,
  998. .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
  999. .show_host_symbolic_name = 1,
  1000. .set_host_system_hostname = qla2x00_set_host_system_hostname,
  1001. .show_host_system_hostname = 1,
  1002. .get_host_fabric_name = qla2x00_get_host_fabric_name,
  1003. .show_host_fabric_name = 1,
  1004. .get_host_port_state = qla2x00_get_host_port_state,
  1005. .show_host_port_state = 1,
  1006. .dd_fcrport_size = sizeof(struct fc_port *),
  1007. .show_rport_supported_classes = 1,
  1008. .get_starget_node_name = qla2x00_get_starget_node_name,
  1009. .show_starget_node_name = 1,
  1010. .get_starget_port_name = qla2x00_get_starget_port_name,
  1011. .show_starget_port_name = 1,
  1012. .get_starget_port_id = qla2x00_get_starget_port_id,
  1013. .show_starget_port_id = 1,
  1014. .get_rport_dev_loss_tmo = qla2x00_get_rport_loss_tmo,
  1015. .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
  1016. .show_rport_dev_loss_tmo = 1,
  1017. .issue_fc_host_lip = qla2x00_issue_lip,
  1018. .get_fc_host_stats = qla2x00_get_fc_host_stats,
  1019. .vport_create = qla24xx_vport_create,
  1020. .vport_disable = qla24xx_vport_disable,
  1021. .vport_delete = qla24xx_vport_delete,
  1022. };
  1023. struct fc_function_template qla2xxx_transport_vport_functions = {
  1024. .show_host_node_name = 1,
  1025. .show_host_port_name = 1,
  1026. .show_host_supported_classes = 1,
  1027. .get_host_port_id = qla2x00_get_host_port_id,
  1028. .show_host_port_id = 1,
  1029. .get_host_speed = qla2x00_get_host_speed,
  1030. .show_host_speed = 1,
  1031. .get_host_port_type = qla2x00_get_host_port_type,
  1032. .show_host_port_type = 1,
  1033. .get_host_symbolic_name = qla2x00_get_host_symbolic_name,
  1034. .show_host_symbolic_name = 1,
  1035. .set_host_system_hostname = qla2x00_set_host_system_hostname,
  1036. .show_host_system_hostname = 1,
  1037. .get_host_fabric_name = qla2x00_get_host_fabric_name,
  1038. .show_host_fabric_name = 1,
  1039. .get_host_port_state = qla2x00_get_host_port_state,
  1040. .show_host_port_state = 1,
  1041. .dd_fcrport_size = sizeof(struct fc_port *),
  1042. .show_rport_supported_classes = 1,
  1043. .get_starget_node_name = qla2x00_get_starget_node_name,
  1044. .show_starget_node_name = 1,
  1045. .get_starget_port_name = qla2x00_get_starget_port_name,
  1046. .show_starget_port_name = 1,
  1047. .get_starget_port_id = qla2x00_get_starget_port_id,
  1048. .show_starget_port_id = 1,
  1049. .get_rport_dev_loss_tmo = qla2x00_get_rport_loss_tmo,
  1050. .set_rport_dev_loss_tmo = qla2x00_set_rport_loss_tmo,
  1051. .show_rport_dev_loss_tmo = 1,
  1052. .issue_fc_host_lip = qla2x00_issue_lip,
  1053. .get_fc_host_stats = qla2x00_get_fc_host_stats,
  1054. };
  1055. void
  1056. qla2x00_init_host_attr(scsi_qla_host_t *ha)
  1057. {
  1058. fc_host_node_name(ha->host) = wwn_to_u64(ha->node_name);
  1059. fc_host_port_name(ha->host) = wwn_to_u64(ha->port_name);
  1060. fc_host_supported_classes(ha->host) = FC_COS_CLASS3;
  1061. fc_host_max_npiv_vports(ha->host) = ha->max_npiv_vports;;
  1062. fc_host_npiv_vports_inuse(ha->host) = ha->cur_vport_count;
  1063. }