lpfc_attr.c 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2004-2006 Emulex. All rights reserved. *
  5. * EMULEX and SLI are trademarks of Emulex. *
  6. * www.emulex.com *
  7. * Portions Copyright (C) 2004-2005 Christoph Hellwig *
  8. * *
  9. * This program is free software; you can redistribute it and/or *
  10. * modify it under the terms of version 2 of the GNU General *
  11. * Public License as published by the Free Software Foundation. *
  12. * This program is distributed in the hope that it will be useful. *
  13. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  14. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  15. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  16. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  17. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  18. * more details, a copy of which can be found in the file COPYING *
  19. * included with this package. *
  20. *******************************************************************/
  21. #include <linux/ctype.h>
  22. #include <linux/pci.h>
  23. #include <linux/interrupt.h>
  24. #include <scsi/scsi.h>
  25. #include <scsi/scsi_device.h>
  26. #include <scsi/scsi_host.h>
  27. #include <scsi/scsi_tcq.h>
  28. #include <scsi/scsi_transport_fc.h>
  29. #include "lpfc_hw.h"
  30. #include "lpfc_sli.h"
  31. #include "lpfc_disc.h"
  32. #include "lpfc_scsi.h"
  33. #include "lpfc.h"
  34. #include "lpfc_logmsg.h"
  35. #include "lpfc_version.h"
  36. #include "lpfc_compat.h"
  37. #include "lpfc_crtn.h"
  38. static void
  39. lpfc_jedec_to_ascii(int incr, char hdw[])
  40. {
  41. int i, j;
  42. for (i = 0; i < 8; i++) {
  43. j = (incr & 0xf);
  44. if (j <= 9)
  45. hdw[7 - i] = 0x30 + j;
  46. else
  47. hdw[7 - i] = 0x61 + j - 10;
  48. incr = (incr >> 4);
  49. }
  50. hdw[8] = 0;
  51. return;
  52. }
  53. static ssize_t
  54. lpfc_drvr_version_show(struct class_device *cdev, char *buf)
  55. {
  56. return snprintf(buf, PAGE_SIZE, LPFC_MODULE_DESC "\n");
  57. }
  58. static ssize_t
  59. management_version_show(struct class_device *cdev, char *buf)
  60. {
  61. return snprintf(buf, PAGE_SIZE, DFC_API_VERSION "\n");
  62. }
  63. static ssize_t
  64. lpfc_info_show(struct class_device *cdev, char *buf)
  65. {
  66. struct Scsi_Host *host = class_to_shost(cdev);
  67. return snprintf(buf, PAGE_SIZE, "%s\n",lpfc_info(host));
  68. }
  69. static ssize_t
  70. lpfc_serialnum_show(struct class_device *cdev, char *buf)
  71. {
  72. struct Scsi_Host *host = class_to_shost(cdev);
  73. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  74. return snprintf(buf, PAGE_SIZE, "%s\n",phba->SerialNumber);
  75. }
  76. static ssize_t
  77. lpfc_modeldesc_show(struct class_device *cdev, char *buf)
  78. {
  79. struct Scsi_Host *host = class_to_shost(cdev);
  80. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  81. return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelDesc);
  82. }
  83. static ssize_t
  84. lpfc_modelname_show(struct class_device *cdev, char *buf)
  85. {
  86. struct Scsi_Host *host = class_to_shost(cdev);
  87. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  88. return snprintf(buf, PAGE_SIZE, "%s\n",phba->ModelName);
  89. }
  90. static ssize_t
  91. lpfc_programtype_show(struct class_device *cdev, char *buf)
  92. {
  93. struct Scsi_Host *host = class_to_shost(cdev);
  94. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  95. return snprintf(buf, PAGE_SIZE, "%s\n",phba->ProgramType);
  96. }
  97. static ssize_t
  98. lpfc_portnum_show(struct class_device *cdev, char *buf)
  99. {
  100. struct Scsi_Host *host = class_to_shost(cdev);
  101. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  102. return snprintf(buf, PAGE_SIZE, "%s\n",phba->Port);
  103. }
  104. static ssize_t
  105. lpfc_fwrev_show(struct class_device *cdev, char *buf)
  106. {
  107. struct Scsi_Host *host = class_to_shost(cdev);
  108. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  109. char fwrev[32];
  110. lpfc_decode_firmware_rev(phba, fwrev, 1);
  111. return snprintf(buf, PAGE_SIZE, "%s\n",fwrev);
  112. }
  113. static ssize_t
  114. lpfc_hdw_show(struct class_device *cdev, char *buf)
  115. {
  116. char hdw[9];
  117. struct Scsi_Host *host = class_to_shost(cdev);
  118. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  119. lpfc_vpd_t *vp = &phba->vpd;
  120. lpfc_jedec_to_ascii(vp->rev.biuRev, hdw);
  121. return snprintf(buf, PAGE_SIZE, "%s\n", hdw);
  122. }
  123. static ssize_t
  124. lpfc_option_rom_version_show(struct class_device *cdev, char *buf)
  125. {
  126. struct Scsi_Host *host = class_to_shost(cdev);
  127. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  128. return snprintf(buf, PAGE_SIZE, "%s\n", phba->OptionROMVersion);
  129. }
  130. static ssize_t
  131. lpfc_state_show(struct class_device *cdev, char *buf)
  132. {
  133. struct Scsi_Host *host = class_to_shost(cdev);
  134. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  135. int len = 0;
  136. switch (phba->hba_state) {
  137. case LPFC_STATE_UNKNOWN:
  138. case LPFC_WARM_START:
  139. case LPFC_INIT_START:
  140. case LPFC_INIT_MBX_CMDS:
  141. case LPFC_LINK_DOWN:
  142. len += snprintf(buf + len, PAGE_SIZE-len, "Link Down\n");
  143. break;
  144. case LPFC_LINK_UP:
  145. case LPFC_LOCAL_CFG_LINK:
  146. len += snprintf(buf + len, PAGE_SIZE-len, "Link Up\n");
  147. break;
  148. case LPFC_FLOGI:
  149. case LPFC_FABRIC_CFG_LINK:
  150. case LPFC_NS_REG:
  151. case LPFC_NS_QRY:
  152. case LPFC_BUILD_DISC_LIST:
  153. case LPFC_DISC_AUTH:
  154. case LPFC_CLEAR_LA:
  155. len += snprintf(buf + len, PAGE_SIZE-len,
  156. "Link Up - Discovery\n");
  157. break;
  158. case LPFC_HBA_READY:
  159. len += snprintf(buf + len, PAGE_SIZE-len,
  160. "Link Up - Ready:\n");
  161. if (phba->fc_topology == TOPOLOGY_LOOP) {
  162. if (phba->fc_flag & FC_PUBLIC_LOOP)
  163. len += snprintf(buf + len, PAGE_SIZE-len,
  164. " Public Loop\n");
  165. else
  166. len += snprintf(buf + len, PAGE_SIZE-len,
  167. " Private Loop\n");
  168. } else {
  169. if (phba->fc_flag & FC_FABRIC)
  170. len += snprintf(buf + len, PAGE_SIZE-len,
  171. " Fabric\n");
  172. else
  173. len += snprintf(buf + len, PAGE_SIZE-len,
  174. " Point-2-Point\n");
  175. }
  176. }
  177. return len;
  178. }
  179. static ssize_t
  180. lpfc_num_discovered_ports_show(struct class_device *cdev, char *buf)
  181. {
  182. struct Scsi_Host *host = class_to_shost(cdev);
  183. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  184. return snprintf(buf, PAGE_SIZE, "%d\n", phba->fc_map_cnt +
  185. phba->fc_unmap_cnt);
  186. }
  187. static int
  188. lpfc_issue_lip(struct Scsi_Host *host)
  189. {
  190. struct lpfc_hba *phba = (struct lpfc_hba *) host->hostdata;
  191. LPFC_MBOXQ_t *pmboxq;
  192. int mbxstatus = MBXERR_ERROR;
  193. if ((phba->fc_flag & FC_OFFLINE_MODE) ||
  194. (phba->hba_state != LPFC_HBA_READY))
  195. return -EPERM;
  196. pmboxq = mempool_alloc(phba->mbox_mem_pool,GFP_KERNEL);
  197. if (!pmboxq)
  198. return -ENOMEM;
  199. memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
  200. pmboxq->mb.mbxCommand = MBX_DOWN_LINK;
  201. pmboxq->mb.mbxOwner = OWN_HOST;
  202. mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq, LPFC_MBOX_TMO * 2);
  203. if ((mbxstatus == MBX_SUCCESS) && (pmboxq->mb.mbxStatus == 0)) {
  204. memset((void *)pmboxq, 0, sizeof (LPFC_MBOXQ_t));
  205. lpfc_init_link(phba, pmboxq, phba->cfg_topology,
  206. phba->cfg_link_speed);
  207. mbxstatus = lpfc_sli_issue_mbox_wait(phba, pmboxq,
  208. phba->fc_ratov * 2);
  209. }
  210. if (mbxstatus == MBX_TIMEOUT)
  211. pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
  212. else
  213. mempool_free(pmboxq, phba->mbox_mem_pool);
  214. if (mbxstatus == MBXERR_ERROR)
  215. return -EIO;
  216. return 0;
  217. }
  218. static int
  219. lpfc_selective_reset(struct lpfc_hba *phba)
  220. {
  221. struct completion online_compl;
  222. int status = 0;
  223. init_completion(&online_compl);
  224. lpfc_workq_post_event(phba, &status, &online_compl,
  225. LPFC_EVT_OFFLINE);
  226. wait_for_completion(&online_compl);
  227. if (status != 0)
  228. return -EIO;
  229. init_completion(&online_compl);
  230. lpfc_workq_post_event(phba, &status, &online_compl,
  231. LPFC_EVT_ONLINE);
  232. wait_for_completion(&online_compl);
  233. if (status != 0)
  234. return -EIO;
  235. return 0;
  236. }
  237. static ssize_t
  238. lpfc_issue_reset(struct class_device *cdev, const char *buf, size_t count)
  239. {
  240. struct Scsi_Host *host = class_to_shost(cdev);
  241. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  242. int status = -EINVAL;
  243. if (strncmp(buf, "selective", sizeof("selective") - 1) == 0)
  244. status = lpfc_selective_reset(phba);
  245. if (status == 0)
  246. return strlen(buf);
  247. else
  248. return status;
  249. }
  250. static ssize_t
  251. lpfc_nport_evt_cnt_show(struct class_device *cdev, char *buf)
  252. {
  253. struct Scsi_Host *host = class_to_shost(cdev);
  254. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  255. return snprintf(buf, PAGE_SIZE, "%d\n", phba->nport_event_cnt);
  256. }
  257. static ssize_t
  258. lpfc_board_mode_show(struct class_device *cdev, char *buf)
  259. {
  260. struct Scsi_Host *host = class_to_shost(cdev);
  261. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  262. char * state;
  263. if (phba->hba_state == LPFC_HBA_ERROR)
  264. state = "error";
  265. else if (phba->hba_state == LPFC_WARM_START)
  266. state = "warm start";
  267. else if (phba->hba_state == LPFC_INIT_START)
  268. state = "offline";
  269. else
  270. state = "online";
  271. return snprintf(buf, PAGE_SIZE, "%s\n", state);
  272. }
  273. static ssize_t
  274. lpfc_board_mode_store(struct class_device *cdev, const char *buf, size_t count)
  275. {
  276. struct Scsi_Host *host = class_to_shost(cdev);
  277. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  278. struct completion online_compl;
  279. int status=0;
  280. init_completion(&online_compl);
  281. if(strncmp(buf, "online", sizeof("online") - 1) == 0)
  282. lpfc_workq_post_event(phba, &status, &online_compl,
  283. LPFC_EVT_ONLINE);
  284. else if (strncmp(buf, "offline", sizeof("offline") - 1) == 0)
  285. lpfc_workq_post_event(phba, &status, &online_compl,
  286. LPFC_EVT_OFFLINE);
  287. else if (strncmp(buf, "warm", sizeof("warm") - 1) == 0)
  288. lpfc_workq_post_event(phba, &status, &online_compl,
  289. LPFC_EVT_WARM_START);
  290. else if (strncmp(buf, "error", sizeof("error") - 1) == 0)
  291. lpfc_workq_post_event(phba, &status, &online_compl,
  292. LPFC_EVT_KILL);
  293. else
  294. return -EINVAL;
  295. wait_for_completion(&online_compl);
  296. if (!status)
  297. return strlen(buf);
  298. else
  299. return -EIO;
  300. }
  301. static ssize_t
  302. lpfc_poll_show(struct class_device *cdev, char *buf)
  303. {
  304. struct Scsi_Host *host = class_to_shost(cdev);
  305. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  306. return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
  307. }
  308. static ssize_t
  309. lpfc_poll_store(struct class_device *cdev, const char *buf,
  310. size_t count)
  311. {
  312. struct Scsi_Host *host = class_to_shost(cdev);
  313. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  314. uint32_t creg_val;
  315. uint32_t old_val;
  316. int val=0;
  317. if (!isdigit(buf[0]))
  318. return -EINVAL;
  319. if (sscanf(buf, "%i", &val) != 1)
  320. return -EINVAL;
  321. if ((val & 0x3) != val)
  322. return -EINVAL;
  323. spin_lock_irq(phba->host->host_lock);
  324. old_val = phba->cfg_poll;
  325. if (val & ENABLE_FCP_RING_POLLING) {
  326. if ((val & DISABLE_FCP_RING_INT) &&
  327. !(old_val & DISABLE_FCP_RING_INT)) {
  328. creg_val = readl(phba->HCregaddr);
  329. creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
  330. writel(creg_val, phba->HCregaddr);
  331. readl(phba->HCregaddr); /* flush */
  332. lpfc_poll_start_timer(phba);
  333. }
  334. } else if (val != 0x0) {
  335. spin_unlock_irq(phba->host->host_lock);
  336. return -EINVAL;
  337. }
  338. if (!(val & DISABLE_FCP_RING_INT) &&
  339. (old_val & DISABLE_FCP_RING_INT))
  340. {
  341. spin_unlock_irq(phba->host->host_lock);
  342. del_timer(&phba->fcp_poll_timer);
  343. spin_lock_irq(phba->host->host_lock);
  344. creg_val = readl(phba->HCregaddr);
  345. creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING);
  346. writel(creg_val, phba->HCregaddr);
  347. readl(phba->HCregaddr); /* flush */
  348. }
  349. phba->cfg_poll = val;
  350. spin_unlock_irq(phba->host->host_lock);
  351. return strlen(buf);
  352. }
  353. #define lpfc_param_show(attr) \
  354. static ssize_t \
  355. lpfc_##attr##_show(struct class_device *cdev, char *buf) \
  356. { \
  357. struct Scsi_Host *host = class_to_shost(cdev);\
  358. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;\
  359. int val = 0;\
  360. val = phba->cfg_##attr;\
  361. return snprintf(buf, PAGE_SIZE, "%d\n",\
  362. phba->cfg_##attr);\
  363. }
  364. #define lpfc_param_hex_show(attr) \
  365. static ssize_t \
  366. lpfc_##attr##_show(struct class_device *cdev, char *buf) \
  367. { \
  368. struct Scsi_Host *host = class_to_shost(cdev);\
  369. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;\
  370. int val = 0;\
  371. val = phba->cfg_##attr;\
  372. return snprintf(buf, PAGE_SIZE, "%#x\n",\
  373. phba->cfg_##attr);\
  374. }
  375. #define lpfc_param_init(attr, default, minval, maxval) \
  376. static int \
  377. lpfc_##attr##_init(struct lpfc_hba *phba, int val) \
  378. { \
  379. if (val >= minval && val <= maxval) {\
  380. phba->cfg_##attr = val;\
  381. return 0;\
  382. }\
  383. lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
  384. "%d:0449 lpfc_"#attr" attribute cannot be set to %d, "\
  385. "allowed range is ["#minval", "#maxval"]\n", \
  386. phba->brd_no, val); \
  387. phba->cfg_##attr = default;\
  388. return -EINVAL;\
  389. }
  390. #define lpfc_param_set(attr, default, minval, maxval) \
  391. static int \
  392. lpfc_##attr##_set(struct lpfc_hba *phba, int val) \
  393. { \
  394. if (val >= minval && val <= maxval) {\
  395. phba->cfg_##attr = val;\
  396. return 0;\
  397. }\
  398. lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
  399. "%d:0450 lpfc_"#attr" attribute cannot be set to %d, "\
  400. "allowed range is ["#minval", "#maxval"]\n", \
  401. phba->brd_no, val); \
  402. return -EINVAL;\
  403. }
  404. #define lpfc_param_store(attr) \
  405. static ssize_t \
  406. lpfc_##attr##_store(struct class_device *cdev, const char *buf, size_t count) \
  407. { \
  408. struct Scsi_Host *host = class_to_shost(cdev);\
  409. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;\
  410. int val=0;\
  411. if (!isdigit(buf[0]))\
  412. return -EINVAL;\
  413. if (sscanf(buf, "%i", &val) != 1)\
  414. return -EINVAL;\
  415. if (lpfc_##attr##_set(phba, val) == 0) \
  416. return strlen(buf);\
  417. else \
  418. return -EINVAL;\
  419. }
  420. #define LPFC_ATTR(name, defval, minval, maxval, desc) \
  421. static int lpfc_##name = defval;\
  422. module_param(lpfc_##name, int, 0);\
  423. MODULE_PARM_DESC(lpfc_##name, desc);\
  424. lpfc_param_init(name, defval, minval, maxval)
  425. #define LPFC_ATTR_R(name, defval, minval, maxval, desc) \
  426. static int lpfc_##name = defval;\
  427. module_param(lpfc_##name, int, 0);\
  428. MODULE_PARM_DESC(lpfc_##name, desc);\
  429. lpfc_param_show(name)\
  430. lpfc_param_init(name, defval, minval, maxval)\
  431. static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
  432. #define LPFC_ATTR_RW(name, defval, minval, maxval, desc) \
  433. static int lpfc_##name = defval;\
  434. module_param(lpfc_##name, int, 0);\
  435. MODULE_PARM_DESC(lpfc_##name, desc);\
  436. lpfc_param_show(name)\
  437. lpfc_param_init(name, defval, minval, maxval)\
  438. lpfc_param_set(name, defval, minval, maxval)\
  439. lpfc_param_store(name)\
  440. static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
  441. lpfc_##name##_show, lpfc_##name##_store)
  442. #define LPFC_ATTR_HEX_R(name, defval, minval, maxval, desc) \
  443. static int lpfc_##name = defval;\
  444. module_param(lpfc_##name, int, 0);\
  445. MODULE_PARM_DESC(lpfc_##name, desc);\
  446. lpfc_param_hex_show(name)\
  447. lpfc_param_init(name, defval, minval, maxval)\
  448. static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO , lpfc_##name##_show, NULL)
  449. #define LPFC_ATTR_HEX_RW(name, defval, minval, maxval, desc) \
  450. static int lpfc_##name = defval;\
  451. module_param(lpfc_##name, int, 0);\
  452. MODULE_PARM_DESC(lpfc_##name, desc);\
  453. lpfc_param_hex_show(name)\
  454. lpfc_param_init(name, defval, minval, maxval)\
  455. lpfc_param_set(name, defval, minval, maxval)\
  456. lpfc_param_store(name)\
  457. static CLASS_DEVICE_ATTR(lpfc_##name, S_IRUGO | S_IWUSR,\
  458. lpfc_##name##_show, lpfc_##name##_store)
  459. static CLASS_DEVICE_ATTR(info, S_IRUGO, lpfc_info_show, NULL);
  460. static CLASS_DEVICE_ATTR(serialnum, S_IRUGO, lpfc_serialnum_show, NULL);
  461. static CLASS_DEVICE_ATTR(modeldesc, S_IRUGO, lpfc_modeldesc_show, NULL);
  462. static CLASS_DEVICE_ATTR(modelname, S_IRUGO, lpfc_modelname_show, NULL);
  463. static CLASS_DEVICE_ATTR(programtype, S_IRUGO, lpfc_programtype_show, NULL);
  464. static CLASS_DEVICE_ATTR(portnum, S_IRUGO, lpfc_portnum_show, NULL);
  465. static CLASS_DEVICE_ATTR(fwrev, S_IRUGO, lpfc_fwrev_show, NULL);
  466. static CLASS_DEVICE_ATTR(hdw, S_IRUGO, lpfc_hdw_show, NULL);
  467. static CLASS_DEVICE_ATTR(state, S_IRUGO, lpfc_state_show, NULL);
  468. static CLASS_DEVICE_ATTR(option_rom_version, S_IRUGO,
  469. lpfc_option_rom_version_show, NULL);
  470. static CLASS_DEVICE_ATTR(num_discovered_ports, S_IRUGO,
  471. lpfc_num_discovered_ports_show, NULL);
  472. static CLASS_DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
  473. static CLASS_DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show,
  474. NULL);
  475. static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show,
  476. NULL);
  477. static CLASS_DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
  478. lpfc_board_mode_show, lpfc_board_mode_store);
  479. static CLASS_DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
  480. static int lpfc_poll = 0;
  481. module_param(lpfc_poll, int, 0);
  482. MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:"
  483. " 0 - none,"
  484. " 1 - poll with interrupts enabled"
  485. " 3 - poll and disable FCP ring interrupts");
  486. static CLASS_DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR,
  487. lpfc_poll_show, lpfc_poll_store);
  488. /*
  489. # lpfc_log_verbose: Only turn this flag on if you are willing to risk being
  490. # deluged with LOTS of information.
  491. # You can set a bit mask to record specific types of verbose messages:
  492. #
  493. # LOG_ELS 0x1 ELS events
  494. # LOG_DISCOVERY 0x2 Link discovery events
  495. # LOG_MBOX 0x4 Mailbox events
  496. # LOG_INIT 0x8 Initialization events
  497. # LOG_LINK_EVENT 0x10 Link events
  498. # LOG_IP 0x20 IP traffic history
  499. # LOG_FCP 0x40 FCP traffic history
  500. # LOG_NODE 0x80 Node table events
  501. # LOG_MISC 0x400 Miscellaneous events
  502. # LOG_SLI 0x800 SLI events
  503. # LOG_CHK_COND 0x1000 FCP Check condition flag
  504. # LOG_LIBDFC 0x2000 LIBDFC events
  505. # LOG_ALL_MSG 0xffff LOG all messages
  506. */
  507. LPFC_ATTR_HEX_RW(log_verbose, 0x0, 0x0, 0xffff, "Verbose logging bit-mask");
  508. /*
  509. # lun_queue_depth: This parameter is used to limit the number of outstanding
  510. # commands per FCP LUN. Value range is [1,128]. Default value is 30.
  511. */
  512. LPFC_ATTR_R(lun_queue_depth, 30, 1, 128,
  513. "Max number of FCP commands we can queue to a specific LUN");
  514. /*
  515. # hba_queue_depth: This parameter is used to limit the number of outstanding
  516. # commands per lpfc HBA. Value range is [32,8192]. If this parameter
  517. # value is greater than the maximum number of exchanges supported by the HBA,
  518. # then maximum number of exchanges supported by the HBA is used to determine
  519. # the hba_queue_depth.
  520. */
  521. LPFC_ATTR_R(hba_queue_depth, 8192, 32, 8192,
  522. "Max number of FCP commands we can queue to a lpfc HBA");
  523. /*
  524. # Some disk devices have a "select ID" or "select Target" capability.
  525. # From a protocol standpoint "select ID" usually means select the
  526. # Fibre channel "ALPA". In the FC-AL Profile there is an "informative
  527. # annex" which contains a table that maps a "select ID" (a number
  528. # between 0 and 7F) to an ALPA. By default, for compatibility with
  529. # older drivers, the lpfc driver scans this table from low ALPA to high
  530. # ALPA.
  531. #
  532. # Turning on the scan-down variable (on = 1, off = 0) will
  533. # cause the lpfc driver to use an inverted table, effectively
  534. # scanning ALPAs from high to low. Value range is [0,1]. Default value is 1.
  535. #
  536. # (Note: This "select ID" functionality is a LOOP ONLY characteristic
  537. # and will not work across a fabric. Also this parameter will take
  538. # effect only in the case when ALPA map is not available.)
  539. */
  540. LPFC_ATTR_R(scan_down, 1, 0, 1,
  541. "Start scanning for devices from highest ALPA to lowest");
  542. /*
  543. # lpfc_nodev_tmo: If set, it will hold all I/O errors on devices that disappear
  544. # until the timer expires. Value range is [0,255]. Default value is 30.
  545. # NOTE: this MUST be less then the SCSI Layer command timeout - 1.
  546. */
  547. LPFC_ATTR_RW(nodev_tmo, 30, 0, 255,
  548. "Seconds driver will hold I/O waiting for a device to come back");
  549. /*
  550. # lpfc_topology: link topology for init link
  551. # 0x0 = attempt loop mode then point-to-point
  552. # 0x01 = internal loopback mode
  553. # 0x02 = attempt point-to-point mode only
  554. # 0x04 = attempt loop mode only
  555. # 0x06 = attempt point-to-point mode then loop
  556. # Set point-to-point mode if you want to run as an N_Port.
  557. # Set loop mode if you want to run as an NL_Port. Value range is [0,0x6].
  558. # Default value is 0.
  559. */
  560. LPFC_ATTR_RW(topology, 0, 0, 6, "Select Fibre Channel topology");
  561. /*
  562. # lpfc_link_speed: Link speed selection for initializing the Fibre Channel
  563. # connection.
  564. # 0 = auto select (default)
  565. # 1 = 1 Gigabaud
  566. # 2 = 2 Gigabaud
  567. # 4 = 4 Gigabaud
  568. # Value range is [0,4]. Default value is 0.
  569. */
  570. LPFC_ATTR_R(link_speed, 0, 0, 4, "Select link speed");
  571. /*
  572. # lpfc_fcp_class: Determines FC class to use for the FCP protocol.
  573. # Value range is [2,3]. Default value is 3.
  574. */
  575. LPFC_ATTR_R(fcp_class, 3, 2, 3,
  576. "Select Fibre Channel class of service for FCP sequences");
  577. /*
  578. # lpfc_use_adisc: Use ADISC for FCP rediscovery instead of PLOGI. Value range
  579. # is [0,1]. Default value is 0.
  580. */
  581. LPFC_ATTR_RW(use_adisc, 0, 0, 1,
  582. "Use ADISC on rediscovery to authenticate FCP devices");
  583. /*
  584. # lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
  585. # range is [0,1]. Default value is 0.
  586. */
  587. LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support");
  588. /*
  589. # lpfc_cr_delay & lpfc_cr_count: Default values for I/O colaesing
  590. # cr_delay (msec) or cr_count outstanding commands. cr_delay can take
  591. # value [0,63]. cr_count can take value [0,255]. Default value of cr_delay
  592. # is 0. Default value of cr_count is 1. The cr_count feature is disabled if
  593. # cr_delay is set to 0.
  594. */
  595. LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an "
  596. "interrupt response is generated");
  597. LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an "
  598. "interrupt response is generated");
  599. /*
  600. # lpfc_multi_ring_support: Determines how many rings to spread available
  601. # cmd/rsp IOCB entries across.
  602. # Value range is [1,2]. Default value is 1.
  603. */
  604. LPFC_ATTR_R(multi_ring_support, 1, 1, 2, "Determines number of primary "
  605. "SLI rings to spread IOCB entries across");
  606. /*
  607. # lpfc_fdmi_on: controls FDMI support.
  608. # 0 = no FDMI support
  609. # 1 = support FDMI without attribute of hostname
  610. # 2 = support FDMI with attribute of hostname
  611. # Value range [0,2]. Default value is 0.
  612. */
  613. LPFC_ATTR_RW(fdmi_on, 0, 0, 2, "Enable FDMI support");
  614. /*
  615. # Specifies the maximum number of ELS cmds we can have outstanding (for
  616. # discovery). Value range is [1,64]. Default value = 32.
  617. */
  618. LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands "
  619. "during discovery");
  620. /*
  621. # lpfc_max_luns: maximum allowed LUN.
  622. # Value range is [0,65535]. Default value is 255.
  623. # NOTE: The SCSI layer might probe all allowed LUN on some old targets.
  624. */
  625. LPFC_ATTR_R(max_luns, 255, 0, 65535,
  626. "Maximum allowed LUN");
  627. /*
  628. # lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
  629. # Value range is [1,255], default value is 10.
  630. */
  631. LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
  632. "Milliseconds driver will wait between polling FCP ring");
  633. struct class_device_attribute *lpfc_host_attrs[] = {
  634. &class_device_attr_info,
  635. &class_device_attr_serialnum,
  636. &class_device_attr_modeldesc,
  637. &class_device_attr_modelname,
  638. &class_device_attr_programtype,
  639. &class_device_attr_portnum,
  640. &class_device_attr_fwrev,
  641. &class_device_attr_hdw,
  642. &class_device_attr_option_rom_version,
  643. &class_device_attr_state,
  644. &class_device_attr_num_discovered_ports,
  645. &class_device_attr_lpfc_drvr_version,
  646. &class_device_attr_lpfc_log_verbose,
  647. &class_device_attr_lpfc_lun_queue_depth,
  648. &class_device_attr_lpfc_hba_queue_depth,
  649. &class_device_attr_lpfc_nodev_tmo,
  650. &class_device_attr_lpfc_fcp_class,
  651. &class_device_attr_lpfc_use_adisc,
  652. &class_device_attr_lpfc_ack0,
  653. &class_device_attr_lpfc_topology,
  654. &class_device_attr_lpfc_scan_down,
  655. &class_device_attr_lpfc_link_speed,
  656. &class_device_attr_lpfc_cr_delay,
  657. &class_device_attr_lpfc_cr_count,
  658. &class_device_attr_lpfc_multi_ring_support,
  659. &class_device_attr_lpfc_fdmi_on,
  660. &class_device_attr_lpfc_max_luns,
  661. &class_device_attr_nport_evt_cnt,
  662. &class_device_attr_management_version,
  663. &class_device_attr_board_mode,
  664. &class_device_attr_issue_reset,
  665. &class_device_attr_lpfc_poll,
  666. &class_device_attr_lpfc_poll_tmo,
  667. NULL,
  668. };
  669. static ssize_t
  670. sysfs_ctlreg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
  671. {
  672. size_t buf_off;
  673. struct Scsi_Host *host = class_to_shost(container_of(kobj,
  674. struct class_device, kobj));
  675. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  676. if ((off + count) > FF_REG_AREA_SIZE)
  677. return -ERANGE;
  678. if (count == 0) return 0;
  679. if (off % 4 || count % 4 || (unsigned long)buf % 4)
  680. return -EINVAL;
  681. spin_lock_irq(phba->host->host_lock);
  682. if (!(phba->fc_flag & FC_OFFLINE_MODE)) {
  683. spin_unlock_irq(phba->host->host_lock);
  684. return -EPERM;
  685. }
  686. for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t))
  687. writel(*((uint32_t *)(buf + buf_off)),
  688. phba->ctrl_regs_memmap_p + off + buf_off);
  689. spin_unlock_irq(phba->host->host_lock);
  690. return count;
  691. }
  692. static ssize_t
  693. sysfs_ctlreg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
  694. {
  695. size_t buf_off;
  696. uint32_t * tmp_ptr;
  697. struct Scsi_Host *host = class_to_shost(container_of(kobj,
  698. struct class_device, kobj));
  699. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  700. if (off > FF_REG_AREA_SIZE)
  701. return -ERANGE;
  702. if ((off + count) > FF_REG_AREA_SIZE)
  703. count = FF_REG_AREA_SIZE - off;
  704. if (count == 0) return 0;
  705. if (off % 4 || count % 4 || (unsigned long)buf % 4)
  706. return -EINVAL;
  707. spin_lock_irq(phba->host->host_lock);
  708. for (buf_off = 0; buf_off < count; buf_off += sizeof(uint32_t)) {
  709. tmp_ptr = (uint32_t *)(buf + buf_off);
  710. *tmp_ptr = readl(phba->ctrl_regs_memmap_p + off + buf_off);
  711. }
  712. spin_unlock_irq(phba->host->host_lock);
  713. return count;
  714. }
  715. static struct bin_attribute sysfs_ctlreg_attr = {
  716. .attr = {
  717. .name = "ctlreg",
  718. .mode = S_IRUSR | S_IWUSR,
  719. .owner = THIS_MODULE,
  720. },
  721. .size = 256,
  722. .read = sysfs_ctlreg_read,
  723. .write = sysfs_ctlreg_write,
  724. };
  725. static void
  726. sysfs_mbox_idle (struct lpfc_hba * phba)
  727. {
  728. phba->sysfs_mbox.state = SMBOX_IDLE;
  729. phba->sysfs_mbox.offset = 0;
  730. if (phba->sysfs_mbox.mbox) {
  731. mempool_free(phba->sysfs_mbox.mbox,
  732. phba->mbox_mem_pool);
  733. phba->sysfs_mbox.mbox = NULL;
  734. }
  735. }
  736. static ssize_t
  737. sysfs_mbox_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
  738. {
  739. struct Scsi_Host * host =
  740. class_to_shost(container_of(kobj, struct class_device, kobj));
  741. struct lpfc_hba * phba = (struct lpfc_hba*)host->hostdata;
  742. struct lpfcMboxq * mbox = NULL;
  743. if ((count + off) > MAILBOX_CMD_SIZE)
  744. return -ERANGE;
  745. if (off % 4 || count % 4 || (unsigned long)buf % 4)
  746. return -EINVAL;
  747. if (count == 0)
  748. return 0;
  749. if (off == 0) {
  750. mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
  751. if (!mbox)
  752. return -ENOMEM;
  753. memset(mbox, 0, sizeof (LPFC_MBOXQ_t));
  754. }
  755. spin_lock_irq(host->host_lock);
  756. if (off == 0) {
  757. if (phba->sysfs_mbox.mbox)
  758. mempool_free(mbox, phba->mbox_mem_pool);
  759. else
  760. phba->sysfs_mbox.mbox = mbox;
  761. phba->sysfs_mbox.state = SMBOX_WRITING;
  762. } else {
  763. if (phba->sysfs_mbox.state != SMBOX_WRITING ||
  764. phba->sysfs_mbox.offset != off ||
  765. phba->sysfs_mbox.mbox == NULL ) {
  766. sysfs_mbox_idle(phba);
  767. spin_unlock_irq(host->host_lock);
  768. return -EAGAIN;
  769. }
  770. }
  771. memcpy((uint8_t *) & phba->sysfs_mbox.mbox->mb + off,
  772. buf, count);
  773. phba->sysfs_mbox.offset = off + count;
  774. spin_unlock_irq(host->host_lock);
  775. return count;
  776. }
  777. static ssize_t
  778. sysfs_mbox_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
  779. {
  780. struct Scsi_Host *host =
  781. class_to_shost(container_of(kobj, struct class_device,
  782. kobj));
  783. struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata;
  784. int rc;
  785. if (off > sizeof(MAILBOX_t))
  786. return -ERANGE;
  787. if ((count + off) > sizeof(MAILBOX_t))
  788. count = sizeof(MAILBOX_t) - off;
  789. if (off % 4 || count % 4 || (unsigned long)buf % 4)
  790. return -EINVAL;
  791. if (off && count == 0)
  792. return 0;
  793. spin_lock_irq(phba->host->host_lock);
  794. if (off == 0 &&
  795. phba->sysfs_mbox.state == SMBOX_WRITING &&
  796. phba->sysfs_mbox.offset >= 2 * sizeof(uint32_t)) {
  797. switch (phba->sysfs_mbox.mbox->mb.mbxCommand) {
  798. /* Offline only */
  799. case MBX_WRITE_NV:
  800. case MBX_INIT_LINK:
  801. case MBX_DOWN_LINK:
  802. case MBX_CONFIG_LINK:
  803. case MBX_CONFIG_RING:
  804. case MBX_RESET_RING:
  805. case MBX_UNREG_LOGIN:
  806. case MBX_CLEAR_LA:
  807. case MBX_DUMP_CONTEXT:
  808. case MBX_RUN_DIAGS:
  809. case MBX_RESTART:
  810. case MBX_FLASH_WR_ULA:
  811. case MBX_SET_MASK:
  812. case MBX_SET_SLIM:
  813. case MBX_SET_DEBUG:
  814. if (!(phba->fc_flag & FC_OFFLINE_MODE)) {
  815. printk(KERN_WARNING "mbox_read:Command 0x%x "
  816. "is illegal in on-line state\n",
  817. phba->sysfs_mbox.mbox->mb.mbxCommand);
  818. sysfs_mbox_idle(phba);
  819. spin_unlock_irq(phba->host->host_lock);
  820. return -EPERM;
  821. }
  822. case MBX_LOAD_SM:
  823. case MBX_READ_NV:
  824. case MBX_READ_CONFIG:
  825. case MBX_READ_RCONFIG:
  826. case MBX_READ_STATUS:
  827. case MBX_READ_XRI:
  828. case MBX_READ_REV:
  829. case MBX_READ_LNK_STAT:
  830. case MBX_DUMP_MEMORY:
  831. case MBX_DOWN_LOAD:
  832. case MBX_UPDATE_CFG:
  833. case MBX_KILL_BOARD:
  834. case MBX_LOAD_AREA:
  835. case MBX_LOAD_EXP_ROM:
  836. case MBX_BEACON:
  837. case MBX_DEL_LD_ENTRY:
  838. break;
  839. case MBX_READ_SPARM64:
  840. case MBX_READ_LA:
  841. case MBX_READ_LA64:
  842. case MBX_REG_LOGIN:
  843. case MBX_REG_LOGIN64:
  844. case MBX_CONFIG_PORT:
  845. case MBX_RUN_BIU_DIAG:
  846. printk(KERN_WARNING "mbox_read: Illegal Command 0x%x\n",
  847. phba->sysfs_mbox.mbox->mb.mbxCommand);
  848. sysfs_mbox_idle(phba);
  849. spin_unlock_irq(phba->host->host_lock);
  850. return -EPERM;
  851. default:
  852. printk(KERN_WARNING "mbox_read: Unknown Command 0x%x\n",
  853. phba->sysfs_mbox.mbox->mb.mbxCommand);
  854. sysfs_mbox_idle(phba);
  855. spin_unlock_irq(phba->host->host_lock);
  856. return -EPERM;
  857. }
  858. if ((phba->fc_flag & FC_OFFLINE_MODE) ||
  859. (!(phba->sli.sli_flag & LPFC_SLI2_ACTIVE))){
  860. spin_unlock_irq(phba->host->host_lock);
  861. rc = lpfc_sli_issue_mbox (phba,
  862. phba->sysfs_mbox.mbox,
  863. MBX_POLL);
  864. spin_lock_irq(phba->host->host_lock);
  865. } else {
  866. spin_unlock_irq(phba->host->host_lock);
  867. rc = lpfc_sli_issue_mbox_wait (phba,
  868. phba->sysfs_mbox.mbox,
  869. lpfc_mbox_tmo_val(phba,
  870. phba->sysfs_mbox.mbox->mb.mbxCommand) * HZ);
  871. spin_lock_irq(phba->host->host_lock);
  872. }
  873. if (rc != MBX_SUCCESS) {
  874. sysfs_mbox_idle(phba);
  875. spin_unlock_irq(host->host_lock);
  876. return (rc == MBX_TIMEOUT) ? -ETIME : -ENODEV;
  877. }
  878. phba->sysfs_mbox.state = SMBOX_READING;
  879. }
  880. else if (phba->sysfs_mbox.offset != off ||
  881. phba->sysfs_mbox.state != SMBOX_READING) {
  882. printk(KERN_WARNING "mbox_read: Bad State\n");
  883. sysfs_mbox_idle(phba);
  884. spin_unlock_irq(host->host_lock);
  885. return -EAGAIN;
  886. }
  887. memcpy(buf, (uint8_t *) & phba->sysfs_mbox.mbox->mb + off, count);
  888. phba->sysfs_mbox.offset = off + count;
  889. if (phba->sysfs_mbox.offset == sizeof(MAILBOX_t))
  890. sysfs_mbox_idle(phba);
  891. spin_unlock_irq(phba->host->host_lock);
  892. return count;
  893. }
  894. static struct bin_attribute sysfs_mbox_attr = {
  895. .attr = {
  896. .name = "mbox",
  897. .mode = S_IRUSR | S_IWUSR,
  898. .owner = THIS_MODULE,
  899. },
  900. .size = sizeof(MAILBOX_t),
  901. .read = sysfs_mbox_read,
  902. .write = sysfs_mbox_write,
  903. };
  904. int
  905. lpfc_alloc_sysfs_attr(struct lpfc_hba *phba)
  906. {
  907. struct Scsi_Host *host = phba->host;
  908. int error;
  909. error = sysfs_create_bin_file(&host->shost_classdev.kobj,
  910. &sysfs_ctlreg_attr);
  911. if (error)
  912. goto out;
  913. error = sysfs_create_bin_file(&host->shost_classdev.kobj,
  914. &sysfs_mbox_attr);
  915. if (error)
  916. goto out_remove_ctlreg_attr;
  917. return 0;
  918. out_remove_ctlreg_attr:
  919. sysfs_remove_bin_file(&host->shost_classdev.kobj, &sysfs_ctlreg_attr);
  920. out:
  921. return error;
  922. }
  923. void
  924. lpfc_free_sysfs_attr(struct lpfc_hba *phba)
  925. {
  926. struct Scsi_Host *host = phba->host;
  927. sysfs_remove_bin_file(&host->shost_classdev.kobj, &sysfs_mbox_attr);
  928. sysfs_remove_bin_file(&host->shost_classdev.kobj, &sysfs_ctlreg_attr);
  929. }
  930. /*
  931. * Dynamic FC Host Attributes Support
  932. */
  933. static void
  934. lpfc_get_host_port_id(struct Scsi_Host *shost)
  935. {
  936. struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
  937. /* note: fc_myDID already in cpu endianness */
  938. fc_host_port_id(shost) = phba->fc_myDID;
  939. }
  940. static void
  941. lpfc_get_host_port_type(struct Scsi_Host *shost)
  942. {
  943. struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
  944. spin_lock_irq(shost->host_lock);
  945. if (phba->hba_state == LPFC_HBA_READY) {
  946. if (phba->fc_topology == TOPOLOGY_LOOP) {
  947. if (phba->fc_flag & FC_PUBLIC_LOOP)
  948. fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
  949. else
  950. fc_host_port_type(shost) = FC_PORTTYPE_LPORT;
  951. } else {
  952. if (phba->fc_flag & FC_FABRIC)
  953. fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
  954. else
  955. fc_host_port_type(shost) = FC_PORTTYPE_PTP;
  956. }
  957. } else
  958. fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
  959. spin_unlock_irq(shost->host_lock);
  960. }
  961. static void
  962. lpfc_get_host_port_state(struct Scsi_Host *shost)
  963. {
  964. struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
  965. spin_lock_irq(shost->host_lock);
  966. if (phba->fc_flag & FC_OFFLINE_MODE)
  967. fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE;
  968. else {
  969. switch (phba->hba_state) {
  970. case LPFC_STATE_UNKNOWN:
  971. case LPFC_WARM_START:
  972. case LPFC_INIT_START:
  973. case LPFC_INIT_MBX_CMDS:
  974. case LPFC_LINK_DOWN:
  975. fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN;
  976. break;
  977. case LPFC_LINK_UP:
  978. case LPFC_LOCAL_CFG_LINK:
  979. case LPFC_FLOGI:
  980. case LPFC_FABRIC_CFG_LINK:
  981. case LPFC_NS_REG:
  982. case LPFC_NS_QRY:
  983. case LPFC_BUILD_DISC_LIST:
  984. case LPFC_DISC_AUTH:
  985. case LPFC_CLEAR_LA:
  986. case LPFC_HBA_READY:
  987. /* Links up, beyond this port_type reports state */
  988. fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
  989. break;
  990. case LPFC_HBA_ERROR:
  991. fc_host_port_state(shost) = FC_PORTSTATE_ERROR;
  992. break;
  993. default:
  994. fc_host_port_state(shost) = FC_PORTSTATE_UNKNOWN;
  995. break;
  996. }
  997. }
  998. spin_unlock_irq(shost->host_lock);
  999. }
  1000. static void
  1001. lpfc_get_host_speed(struct Scsi_Host *shost)
  1002. {
  1003. struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
  1004. spin_lock_irq(shost->host_lock);
  1005. if (phba->hba_state == LPFC_HBA_READY) {
  1006. switch(phba->fc_linkspeed) {
  1007. case LA_1GHZ_LINK:
  1008. fc_host_speed(shost) = FC_PORTSPEED_1GBIT;
  1009. break;
  1010. case LA_2GHZ_LINK:
  1011. fc_host_speed(shost) = FC_PORTSPEED_2GBIT;
  1012. break;
  1013. case LA_4GHZ_LINK:
  1014. fc_host_speed(shost) = FC_PORTSPEED_4GBIT;
  1015. break;
  1016. default:
  1017. fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
  1018. break;
  1019. }
  1020. }
  1021. spin_unlock_irq(shost->host_lock);
  1022. }
  1023. static void
  1024. lpfc_get_host_fabric_name (struct Scsi_Host *shost)
  1025. {
  1026. struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
  1027. u64 node_name;
  1028. spin_lock_irq(shost->host_lock);
  1029. if ((phba->fc_flag & FC_FABRIC) ||
  1030. ((phba->fc_topology == TOPOLOGY_LOOP) &&
  1031. (phba->fc_flag & FC_PUBLIC_LOOP)))
  1032. node_name = wwn_to_u64(phba->fc_fabparam.nodeName.u.wwn);
  1033. else
  1034. /* fabric is local port if there is no F/FL_Port */
  1035. node_name = wwn_to_u64(phba->fc_nodename.u.wwn);
  1036. spin_unlock_irq(shost->host_lock);
  1037. fc_host_fabric_name(shost) = node_name;
  1038. }
  1039. static void
  1040. lpfc_get_host_symbolic_name (struct Scsi_Host *shost)
  1041. {
  1042. struct lpfc_hba *phba = (struct lpfc_hba*)shost->hostdata;
  1043. spin_lock_irq(shost->host_lock);
  1044. lpfc_get_hba_sym_node_name(phba, fc_host_symbolic_name(shost));
  1045. spin_unlock_irq(shost->host_lock);
  1046. }
  1047. static struct fc_host_statistics *
  1048. lpfc_get_stats(struct Scsi_Host *shost)
  1049. {
  1050. struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata;
  1051. struct lpfc_sli *psli = &phba->sli;
  1052. struct fc_host_statistics *hs = &phba->link_stats;
  1053. struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets;
  1054. LPFC_MBOXQ_t *pmboxq;
  1055. MAILBOX_t *pmb;
  1056. unsigned long seconds;
  1057. int rc = 0;
  1058. pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
  1059. if (!pmboxq)
  1060. return NULL;
  1061. memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
  1062. pmb = &pmboxq->mb;
  1063. pmb->mbxCommand = MBX_READ_STATUS;
  1064. pmb->mbxOwner = OWN_HOST;
  1065. pmboxq->context1 = NULL;
  1066. if ((phba->fc_flag & FC_OFFLINE_MODE) ||
  1067. (!(psli->sli_flag & LPFC_SLI2_ACTIVE)))
  1068. rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
  1069. else
  1070. rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
  1071. if (rc != MBX_SUCCESS) {
  1072. if (rc == MBX_TIMEOUT)
  1073. pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
  1074. else
  1075. mempool_free(pmboxq, phba->mbox_mem_pool);
  1076. return NULL;
  1077. }
  1078. memset(hs, 0, sizeof (struct fc_host_statistics));
  1079. hs->tx_frames = pmb->un.varRdStatus.xmitFrameCnt;
  1080. hs->tx_words = (pmb->un.varRdStatus.xmitByteCnt * 256);
  1081. hs->rx_frames = pmb->un.varRdStatus.rcvFrameCnt;
  1082. hs->rx_words = (pmb->un.varRdStatus.rcvByteCnt * 256);
  1083. memset(pmboxq, 0, sizeof (LPFC_MBOXQ_t));
  1084. pmb->mbxCommand = MBX_READ_LNK_STAT;
  1085. pmb->mbxOwner = OWN_HOST;
  1086. pmboxq->context1 = NULL;
  1087. if ((phba->fc_flag & FC_OFFLINE_MODE) ||
  1088. (!(psli->sli_flag & LPFC_SLI2_ACTIVE)))
  1089. rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
  1090. else
  1091. rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
  1092. if (rc != MBX_SUCCESS) {
  1093. if (rc == MBX_TIMEOUT)
  1094. pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
  1095. else
  1096. mempool_free( pmboxq, phba->mbox_mem_pool);
  1097. return NULL;
  1098. }
  1099. hs->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
  1100. hs->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
  1101. hs->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
  1102. hs->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
  1103. hs->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
  1104. hs->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
  1105. hs->error_frames = pmb->un.varRdLnk.crcCnt;
  1106. hs->link_failure_count -= lso->link_failure_count;
  1107. hs->loss_of_sync_count -= lso->loss_of_sync_count;
  1108. hs->loss_of_signal_count -= lso->loss_of_signal_count;
  1109. hs->prim_seq_protocol_err_count -= lso->prim_seq_protocol_err_count;
  1110. hs->invalid_tx_word_count -= lso->invalid_tx_word_count;
  1111. hs->invalid_crc_count -= lso->invalid_crc_count;
  1112. hs->error_frames -= lso->error_frames;
  1113. if (phba->fc_topology == TOPOLOGY_LOOP) {
  1114. hs->lip_count = (phba->fc_eventTag >> 1);
  1115. hs->lip_count -= lso->link_events;
  1116. hs->nos_count = -1;
  1117. } else {
  1118. hs->lip_count = -1;
  1119. hs->nos_count = (phba->fc_eventTag >> 1);
  1120. hs->nos_count -= lso->link_events;
  1121. }
  1122. hs->dumped_frames = -1;
  1123. seconds = get_seconds();
  1124. if (seconds < psli->stats_start)
  1125. hs->seconds_since_last_reset = seconds +
  1126. ((unsigned long)-1 - psli->stats_start);
  1127. else
  1128. hs->seconds_since_last_reset = seconds - psli->stats_start;
  1129. return hs;
  1130. }
  1131. static void
  1132. lpfc_reset_stats(struct Scsi_Host *shost)
  1133. {
  1134. struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata;
  1135. struct lpfc_sli *psli = &phba->sli;
  1136. struct lpfc_lnk_stat * lso = &psli->lnk_stat_offsets;
  1137. LPFC_MBOXQ_t *pmboxq;
  1138. MAILBOX_t *pmb;
  1139. int rc = 0;
  1140. pmboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
  1141. if (!pmboxq)
  1142. return;
  1143. memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
  1144. pmb = &pmboxq->mb;
  1145. pmb->mbxCommand = MBX_READ_STATUS;
  1146. pmb->mbxOwner = OWN_HOST;
  1147. pmb->un.varWords[0] = 0x1; /* reset request */
  1148. pmboxq->context1 = NULL;
  1149. if ((phba->fc_flag & FC_OFFLINE_MODE) ||
  1150. (!(psli->sli_flag & LPFC_SLI2_ACTIVE)))
  1151. rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
  1152. else
  1153. rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
  1154. if (rc != MBX_SUCCESS) {
  1155. if (rc == MBX_TIMEOUT)
  1156. pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
  1157. else
  1158. mempool_free(pmboxq, phba->mbox_mem_pool);
  1159. return;
  1160. }
  1161. memset(pmboxq, 0, sizeof(LPFC_MBOXQ_t));
  1162. pmb->mbxCommand = MBX_READ_LNK_STAT;
  1163. pmb->mbxOwner = OWN_HOST;
  1164. pmboxq->context1 = NULL;
  1165. if ((phba->fc_flag & FC_OFFLINE_MODE) ||
  1166. (!(psli->sli_flag & LPFC_SLI2_ACTIVE)))
  1167. rc = lpfc_sli_issue_mbox(phba, pmboxq, MBX_POLL);
  1168. else
  1169. rc = lpfc_sli_issue_mbox_wait(phba, pmboxq, phba->fc_ratov * 2);
  1170. if (rc != MBX_SUCCESS) {
  1171. if (rc == MBX_TIMEOUT)
  1172. pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
  1173. else
  1174. mempool_free( pmboxq, phba->mbox_mem_pool);
  1175. return;
  1176. }
  1177. lso->link_failure_count = pmb->un.varRdLnk.linkFailureCnt;
  1178. lso->loss_of_sync_count = pmb->un.varRdLnk.lossSyncCnt;
  1179. lso->loss_of_signal_count = pmb->un.varRdLnk.lossSignalCnt;
  1180. lso->prim_seq_protocol_err_count = pmb->un.varRdLnk.primSeqErrCnt;
  1181. lso->invalid_tx_word_count = pmb->un.varRdLnk.invalidXmitWord;
  1182. lso->invalid_crc_count = pmb->un.varRdLnk.crcCnt;
  1183. lso->error_frames = pmb->un.varRdLnk.crcCnt;
  1184. lso->link_events = (phba->fc_eventTag >> 1);
  1185. psli->stats_start = get_seconds();
  1186. return;
  1187. }
  1188. /*
  1189. * The LPFC driver treats linkdown handling as target loss events so there
  1190. * are no sysfs handlers for link_down_tmo.
  1191. */
  1192. static void
  1193. lpfc_get_starget_port_id(struct scsi_target *starget)
  1194. {
  1195. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
  1196. struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
  1197. uint32_t did = -1;
  1198. struct lpfc_nodelist *ndlp = NULL;
  1199. spin_lock_irq(shost->host_lock);
  1200. /* Search the mapped list for this target ID */
  1201. list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
  1202. if (starget->id == ndlp->nlp_sid) {
  1203. did = ndlp->nlp_DID;
  1204. break;
  1205. }
  1206. }
  1207. spin_unlock_irq(shost->host_lock);
  1208. fc_starget_port_id(starget) = did;
  1209. }
  1210. static void
  1211. lpfc_get_starget_node_name(struct scsi_target *starget)
  1212. {
  1213. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
  1214. struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
  1215. u64 node_name = 0;
  1216. struct lpfc_nodelist *ndlp = NULL;
  1217. spin_lock_irq(shost->host_lock);
  1218. /* Search the mapped list for this target ID */
  1219. list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
  1220. if (starget->id == ndlp->nlp_sid) {
  1221. node_name = wwn_to_u64(ndlp->nlp_nodename.u.wwn);
  1222. break;
  1223. }
  1224. }
  1225. spin_unlock_irq(shost->host_lock);
  1226. fc_starget_node_name(starget) = node_name;
  1227. }
  1228. static void
  1229. lpfc_get_starget_port_name(struct scsi_target *starget)
  1230. {
  1231. struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
  1232. struct lpfc_hba *phba = (struct lpfc_hba *) shost->hostdata;
  1233. u64 port_name = 0;
  1234. struct lpfc_nodelist *ndlp = NULL;
  1235. spin_lock_irq(shost->host_lock);
  1236. /* Search the mapped list for this target ID */
  1237. list_for_each_entry(ndlp, &phba->fc_nlpmap_list, nlp_listp) {
  1238. if (starget->id == ndlp->nlp_sid) {
  1239. port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
  1240. break;
  1241. }
  1242. }
  1243. spin_unlock_irq(shost->host_lock);
  1244. fc_starget_port_name(starget) = port_name;
  1245. }
  1246. static void
  1247. lpfc_get_rport_loss_tmo(struct fc_rport *rport)
  1248. {
  1249. /*
  1250. * Return the driver's global value for device loss timeout plus
  1251. * five seconds to allow the driver's nodev timer to run.
  1252. */
  1253. rport->dev_loss_tmo = lpfc_nodev_tmo + 5;
  1254. }
  1255. static void
  1256. lpfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout)
  1257. {
  1258. /*
  1259. * The driver doesn't have a per-target timeout setting. Set
  1260. * this value globally. lpfc_nodev_tmo should be greater then 0.
  1261. */
  1262. if (timeout)
  1263. lpfc_nodev_tmo = timeout;
  1264. else
  1265. lpfc_nodev_tmo = 1;
  1266. rport->dev_loss_tmo = lpfc_nodev_tmo + 5;
  1267. }
  1268. #define lpfc_rport_show_function(field, format_string, sz, cast) \
  1269. static ssize_t \
  1270. lpfc_show_rport_##field (struct class_device *cdev, char *buf) \
  1271. { \
  1272. struct fc_rport *rport = transport_class_to_rport(cdev); \
  1273. struct lpfc_rport_data *rdata = rport->hostdata; \
  1274. return snprintf(buf, sz, format_string, \
  1275. (rdata->target) ? cast rdata->target->field : 0); \
  1276. }
  1277. #define lpfc_rport_rd_attr(field, format_string, sz) \
  1278. lpfc_rport_show_function(field, format_string, sz, ) \
  1279. static FC_RPORT_ATTR(field, S_IRUGO, lpfc_show_rport_##field, NULL)
  1280. struct fc_function_template lpfc_transport_functions = {
  1281. /* fixed attributes the driver supports */
  1282. .show_host_node_name = 1,
  1283. .show_host_port_name = 1,
  1284. .show_host_supported_classes = 1,
  1285. .show_host_supported_fc4s = 1,
  1286. .show_host_supported_speeds = 1,
  1287. .show_host_maxframe_size = 1,
  1288. /* dynamic attributes the driver supports */
  1289. .get_host_port_id = lpfc_get_host_port_id,
  1290. .show_host_port_id = 1,
  1291. .get_host_port_type = lpfc_get_host_port_type,
  1292. .show_host_port_type = 1,
  1293. .get_host_port_state = lpfc_get_host_port_state,
  1294. .show_host_port_state = 1,
  1295. /* active_fc4s is shown but doesn't change (thus no get function) */
  1296. .show_host_active_fc4s = 1,
  1297. .get_host_speed = lpfc_get_host_speed,
  1298. .show_host_speed = 1,
  1299. .get_host_fabric_name = lpfc_get_host_fabric_name,
  1300. .show_host_fabric_name = 1,
  1301. .get_host_symbolic_name = lpfc_get_host_symbolic_name,
  1302. .show_host_symbolic_name = 1,
  1303. /*
  1304. * The LPFC driver treats linkdown handling as target loss events
  1305. * so there are no sysfs handlers for link_down_tmo.
  1306. */
  1307. .get_fc_host_stats = lpfc_get_stats,
  1308. .reset_fc_host_stats = lpfc_reset_stats,
  1309. .dd_fcrport_size = sizeof(struct lpfc_rport_data),
  1310. .show_rport_maxframe_size = 1,
  1311. .show_rport_supported_classes = 1,
  1312. .get_rport_dev_loss_tmo = lpfc_get_rport_loss_tmo,
  1313. .set_rport_dev_loss_tmo = lpfc_set_rport_loss_tmo,
  1314. .show_rport_dev_loss_tmo = 1,
  1315. .get_starget_port_id = lpfc_get_starget_port_id,
  1316. .show_starget_port_id = 1,
  1317. .get_starget_node_name = lpfc_get_starget_node_name,
  1318. .show_starget_node_name = 1,
  1319. .get_starget_port_name = lpfc_get_starget_port_name,
  1320. .show_starget_port_name = 1,
  1321. .issue_fc_host_lip = lpfc_issue_lip,
  1322. };
  1323. void
  1324. lpfc_get_cfgparam(struct lpfc_hba *phba)
  1325. {
  1326. lpfc_log_verbose_init(phba, lpfc_log_verbose);
  1327. lpfc_cr_delay_init(phba, lpfc_cr_delay);
  1328. lpfc_cr_count_init(phba, lpfc_cr_count);
  1329. lpfc_multi_ring_support_init(phba, lpfc_multi_ring_support);
  1330. lpfc_lun_queue_depth_init(phba, lpfc_lun_queue_depth);
  1331. lpfc_fcp_class_init(phba, lpfc_fcp_class);
  1332. lpfc_use_adisc_init(phba, lpfc_use_adisc);
  1333. lpfc_ack0_init(phba, lpfc_ack0);
  1334. lpfc_topology_init(phba, lpfc_topology);
  1335. lpfc_scan_down_init(phba, lpfc_scan_down);
  1336. lpfc_nodev_tmo_init(phba, lpfc_nodev_tmo);
  1337. lpfc_link_speed_init(phba, lpfc_link_speed);
  1338. lpfc_fdmi_on_init(phba, lpfc_fdmi_on);
  1339. lpfc_discovery_threads_init(phba, lpfc_discovery_threads);
  1340. lpfc_max_luns_init(phba, lpfc_max_luns);
  1341. lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
  1342. phba->cfg_poll = lpfc_poll;
  1343. /*
  1344. * The total number of segments is the configuration value plus 2
  1345. * since the IOCB need a command and response bde.
  1346. */
  1347. phba->cfg_sg_seg_cnt = LPFC_SG_SEG_CNT + 2;
  1348. /*
  1349. * Since the sg_tablesize is module parameter, the sg_dma_buf_size
  1350. * used to create the sg_dma_buf_pool must be dynamically calculated
  1351. */
  1352. phba->cfg_sg_dma_buf_size = sizeof(struct fcp_cmnd) +
  1353. sizeof(struct fcp_rsp) +
  1354. (phba->cfg_sg_seg_cnt * sizeof(struct ulp_bde64));
  1355. switch (phba->pcidev->device) {
  1356. case PCI_DEVICE_ID_LP101:
  1357. case PCI_DEVICE_ID_BSMB:
  1358. case PCI_DEVICE_ID_ZSMB:
  1359. phba->cfg_hba_queue_depth = LPFC_LP101_HBA_Q_DEPTH;
  1360. break;
  1361. case PCI_DEVICE_ID_RFLY:
  1362. case PCI_DEVICE_ID_PFLY:
  1363. case PCI_DEVICE_ID_BMID:
  1364. case PCI_DEVICE_ID_ZMID:
  1365. case PCI_DEVICE_ID_TFLY:
  1366. phba->cfg_hba_queue_depth = LPFC_LC_HBA_Q_DEPTH;
  1367. break;
  1368. default:
  1369. phba->cfg_hba_queue_depth = LPFC_DFT_HBA_Q_DEPTH;
  1370. }
  1371. if (phba->cfg_hba_queue_depth > lpfc_hba_queue_depth)
  1372. lpfc_hba_queue_depth_init(phba, lpfc_hba_queue_depth);
  1373. return;
  1374. }