ql4_os.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725
  1. /*
  2. * QLogic iSCSI HBA Driver
  3. * Copyright (c) 2003-2006 QLogic Corporation
  4. *
  5. * See LICENSE.qla4xxx for copyright and licensing details.
  6. */
  7. #include <linux/moduleparam.h>
  8. #include <scsi/scsi_tcq.h>
  9. #include <scsi/scsicam.h>
  10. #include "ql4_def.h"
  11. #include "ql4_version.h"
  12. #include "ql4_glbl.h"
  13. #include "ql4_dbg.h"
  14. #include "ql4_inline.h"
  15. /*
  16. * Driver version
  17. */
  18. static char qla4xxx_version_str[40];
  19. /*
  20. * SRB allocation cache
  21. */
  22. static struct kmem_cache *srb_cachep;
  23. /*
  24. * Module parameter information and variables
  25. */
  26. int ql4xdiscoverywait = 60;
  27. module_param(ql4xdiscoverywait, int, S_IRUGO | S_IRUSR);
  28. MODULE_PARM_DESC(ql4xdiscoverywait, "Discovery wait time");
  29. int ql4xdontresethba = 0;
  30. module_param(ql4xdontresethba, int, S_IRUGO | S_IRUSR);
  31. MODULE_PARM_DESC(ql4xdontresethba,
  32. "Dont reset the HBA when the driver gets 0x8002 AEN "
  33. " default it will reset hba :0"
  34. " set to 1 to avoid resetting HBA");
  35. int ql4xextended_error_logging = 0; /* 0 = off, 1 = log errors */
  36. module_param(ql4xextended_error_logging, int, S_IRUGO | S_IRUSR);
  37. MODULE_PARM_DESC(ql4xextended_error_logging,
  38. "Option to enable extended error logging, "
  39. "Default is 0 - no logging, 1 - debug logging");
  40. int ql4_mod_unload = 0;
  41. /*
  42. * SCSI host template entry points
  43. */
  44. static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha);
  45. /*
  46. * iSCSI template entry points
  47. */
  48. static int qla4xxx_tgt_dscvr(enum iscsi_tgt_dscvr type, uint32_t host_no,
  49. uint32_t enable, struct sockaddr *dst_addr);
  50. static int qla4xxx_conn_get_param(struct iscsi_cls_conn *conn,
  51. enum iscsi_param param, char *buf);
  52. static int qla4xxx_sess_get_param(struct iscsi_cls_session *sess,
  53. enum iscsi_param param, char *buf);
  54. static int qla4xxx_host_get_param(struct Scsi_Host *shost,
  55. enum iscsi_host_param param, char *buf);
  56. static void qla4xxx_conn_stop(struct iscsi_cls_conn *conn, int flag);
  57. static int qla4xxx_conn_start(struct iscsi_cls_conn *conn);
  58. static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session);
  59. /*
  60. * SCSI host template entry points
  61. */
  62. static int qla4xxx_queuecommand(struct scsi_cmnd *cmd,
  63. void (*done) (struct scsi_cmnd *));
  64. static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd);
  65. static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd);
  66. static int qla4xxx_slave_alloc(struct scsi_device *device);
  67. static int qla4xxx_slave_configure(struct scsi_device *device);
  68. static void qla4xxx_slave_destroy(struct scsi_device *sdev);
  69. static struct scsi_host_template qla4xxx_driver_template = {
  70. .module = THIS_MODULE,
  71. .name = DRIVER_NAME,
  72. .proc_name = DRIVER_NAME,
  73. .queuecommand = qla4xxx_queuecommand,
  74. .eh_device_reset_handler = qla4xxx_eh_device_reset,
  75. .eh_host_reset_handler = qla4xxx_eh_host_reset,
  76. .slave_configure = qla4xxx_slave_configure,
  77. .slave_alloc = qla4xxx_slave_alloc,
  78. .slave_destroy = qla4xxx_slave_destroy,
  79. .this_id = -1,
  80. .cmd_per_lun = 3,
  81. .use_clustering = ENABLE_CLUSTERING,
  82. .sg_tablesize = SG_ALL,
  83. .max_sectors = 0xFFFF,
  84. };
  85. static struct iscsi_transport qla4xxx_iscsi_transport = {
  86. .owner = THIS_MODULE,
  87. .name = DRIVER_NAME,
  88. .param_mask = ISCSI_CONN_PORT | ISCSI_CONN_ADDRESS |
  89. ISCSI_TARGET_NAME | ISCSI_TPGT,
  90. .host_param_mask = ISCSI_HOST_HWADDRESS,
  91. .sessiondata_size = sizeof(struct ddb_entry),
  92. .host_template = &qla4xxx_driver_template,
  93. .tgt_dscvr = qla4xxx_tgt_dscvr,
  94. .get_conn_param = qla4xxx_conn_get_param,
  95. .get_session_param = qla4xxx_sess_get_param,
  96. .get_host_param = qla4xxx_host_get_param,
  97. .start_conn = qla4xxx_conn_start,
  98. .stop_conn = qla4xxx_conn_stop,
  99. .session_recovery_timedout = qla4xxx_recovery_timedout,
  100. };
  101. static struct scsi_transport_template *qla4xxx_scsi_transport;
  102. static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session)
  103. {
  104. struct ddb_entry *ddb_entry = session->dd_data;
  105. struct scsi_qla_host *ha = ddb_entry->ha;
  106. DEBUG2(printk("scsi%ld: %s: index [%d] port down retry count of (%d) "
  107. "secs exhausted, marking device DEAD.\n", ha->host_no,
  108. __func__, ddb_entry->fw_ddb_index,
  109. ha->port_down_retry_count));
  110. atomic_set(&ddb_entry->state, DDB_STATE_DEAD);
  111. DEBUG2(printk("scsi%ld: %s: scheduling dpc routine - dpc flags = "
  112. "0x%lx\n", ha->host_no, __func__, ha->dpc_flags));
  113. queue_work(ha->dpc_thread, &ha->dpc_work);
  114. }
  115. static int qla4xxx_conn_start(struct iscsi_cls_conn *conn)
  116. {
  117. struct iscsi_cls_session *session;
  118. struct ddb_entry *ddb_entry;
  119. session = iscsi_dev_to_session(conn->dev.parent);
  120. ddb_entry = session->dd_data;
  121. DEBUG2(printk("scsi%ld: %s: index [%d] starting conn\n",
  122. ddb_entry->ha->host_no, __func__,
  123. ddb_entry->fw_ddb_index));
  124. iscsi_unblock_session(session);
  125. return 0;
  126. }
  127. static void qla4xxx_conn_stop(struct iscsi_cls_conn *conn, int flag)
  128. {
  129. struct iscsi_cls_session *session;
  130. struct ddb_entry *ddb_entry;
  131. session = iscsi_dev_to_session(conn->dev.parent);
  132. ddb_entry = session->dd_data;
  133. DEBUG2(printk("scsi%ld: %s: index [%d] stopping conn\n",
  134. ddb_entry->ha->host_no, __func__,
  135. ddb_entry->fw_ddb_index));
  136. if (flag == STOP_CONN_RECOVER)
  137. iscsi_block_session(session);
  138. else
  139. printk(KERN_ERR "iscsi: invalid stop flag %d\n", flag);
  140. }
  141. static ssize_t format_addr(char *buf, const unsigned char *addr, int len)
  142. {
  143. int i;
  144. char *cp = buf;
  145. for (i = 0; i < len; i++)
  146. cp += sprintf(cp, "%02x%c", addr[i],
  147. i == (len - 1) ? '\n' : ':');
  148. return cp - buf;
  149. }
  150. static int qla4xxx_host_get_param(struct Scsi_Host *shost,
  151. enum iscsi_host_param param, char *buf)
  152. {
  153. struct scsi_qla_host *ha = to_qla_host(shost);
  154. int len;
  155. switch (param) {
  156. case ISCSI_HOST_PARAM_HWADDRESS:
  157. len = format_addr(buf, ha->my_mac, MAC_ADDR_LEN);
  158. break;
  159. default:
  160. return -ENOSYS;
  161. }
  162. return len;
  163. }
  164. static int qla4xxx_sess_get_param(struct iscsi_cls_session *sess,
  165. enum iscsi_param param, char *buf)
  166. {
  167. struct ddb_entry *ddb_entry = sess->dd_data;
  168. int len;
  169. switch (param) {
  170. case ISCSI_PARAM_TARGET_NAME:
  171. len = snprintf(buf, PAGE_SIZE - 1, "%s\n",
  172. ddb_entry->iscsi_name);
  173. break;
  174. case ISCSI_PARAM_TPGT:
  175. len = sprintf(buf, "%u\n", ddb_entry->tpgt);
  176. break;
  177. default:
  178. return -ENOSYS;
  179. }
  180. return len;
  181. }
  182. static int qla4xxx_conn_get_param(struct iscsi_cls_conn *conn,
  183. enum iscsi_param param, char *buf)
  184. {
  185. struct iscsi_cls_session *session;
  186. struct ddb_entry *ddb_entry;
  187. int len;
  188. session = iscsi_dev_to_session(conn->dev.parent);
  189. ddb_entry = session->dd_data;
  190. switch (param) {
  191. case ISCSI_PARAM_CONN_PORT:
  192. len = sprintf(buf, "%hu\n", ddb_entry->port);
  193. break;
  194. case ISCSI_PARAM_CONN_ADDRESS:
  195. /* TODO: what are the ipv6 bits */
  196. len = sprintf(buf, "%u.%u.%u.%u\n",
  197. NIPQUAD(ddb_entry->ip_addr));
  198. break;
  199. default:
  200. return -ENOSYS;
  201. }
  202. return len;
  203. }
  204. static int qla4xxx_tgt_dscvr(enum iscsi_tgt_dscvr type, uint32_t host_no,
  205. uint32_t enable, struct sockaddr *dst_addr)
  206. {
  207. struct scsi_qla_host *ha;
  208. struct Scsi_Host *shost;
  209. struct sockaddr_in *addr;
  210. struct sockaddr_in6 *addr6;
  211. int ret = 0;
  212. shost = scsi_host_lookup(host_no);
  213. if (IS_ERR(shost)) {
  214. printk(KERN_ERR "Could not find host no %u\n", host_no);
  215. return -ENODEV;
  216. }
  217. ha = (struct scsi_qla_host *) shost->hostdata;
  218. switch (type) {
  219. case ISCSI_TGT_DSCVR_SEND_TARGETS:
  220. if (dst_addr->sa_family == AF_INET) {
  221. addr = (struct sockaddr_in *)dst_addr;
  222. if (qla4xxx_send_tgts(ha, (char *)&addr->sin_addr,
  223. addr->sin_port) != QLA_SUCCESS)
  224. ret = -EIO;
  225. } else if (dst_addr->sa_family == AF_INET6) {
  226. /*
  227. * TODO: fix qla4xxx_send_tgts
  228. */
  229. addr6 = (struct sockaddr_in6 *)dst_addr;
  230. if (qla4xxx_send_tgts(ha, (char *)&addr6->sin6_addr,
  231. addr6->sin6_port) != QLA_SUCCESS)
  232. ret = -EIO;
  233. } else
  234. ret = -ENOSYS;
  235. break;
  236. default:
  237. ret = -ENOSYS;
  238. }
  239. scsi_host_put(shost);
  240. return ret;
  241. }
  242. void qla4xxx_destroy_sess(struct ddb_entry *ddb_entry)
  243. {
  244. if (!ddb_entry->sess)
  245. return;
  246. if (ddb_entry->conn) {
  247. iscsi_if_destroy_session_done(ddb_entry->conn);
  248. iscsi_destroy_conn(ddb_entry->conn);
  249. iscsi_remove_session(ddb_entry->sess);
  250. }
  251. iscsi_free_session(ddb_entry->sess);
  252. }
  253. int qla4xxx_add_sess(struct ddb_entry *ddb_entry)
  254. {
  255. int err;
  256. err = iscsi_add_session(ddb_entry->sess, ddb_entry->fw_ddb_index);
  257. if (err) {
  258. DEBUG2(printk(KERN_ERR "Could not add session.\n"));
  259. return err;
  260. }
  261. ddb_entry->conn = iscsi_create_conn(ddb_entry->sess, 0);
  262. if (!ddb_entry->conn) {
  263. iscsi_remove_session(ddb_entry->sess);
  264. DEBUG2(printk(KERN_ERR "Could not add connection.\n"));
  265. return -ENOMEM;
  266. }
  267. ddb_entry->sess->recovery_tmo = ddb_entry->ha->port_down_retry_count;
  268. iscsi_if_create_session_done(ddb_entry->conn);
  269. return 0;
  270. }
  271. struct ddb_entry *qla4xxx_alloc_sess(struct scsi_qla_host *ha)
  272. {
  273. struct ddb_entry *ddb_entry;
  274. struct iscsi_cls_session *sess;
  275. sess = iscsi_alloc_session(ha->host, &qla4xxx_iscsi_transport);
  276. if (!sess)
  277. return NULL;
  278. ddb_entry = sess->dd_data;
  279. memset(ddb_entry, 0, sizeof(*ddb_entry));
  280. ddb_entry->ha = ha;
  281. ddb_entry->sess = sess;
  282. return ddb_entry;
  283. }
  284. /*
  285. * Timer routines
  286. */
  287. static void qla4xxx_start_timer(struct scsi_qla_host *ha, void *func,
  288. unsigned long interval)
  289. {
  290. DEBUG(printk("scsi: %s: Starting timer thread for adapter %d\n",
  291. __func__, ha->host->host_no));
  292. init_timer(&ha->timer);
  293. ha->timer.expires = jiffies + interval * HZ;
  294. ha->timer.data = (unsigned long)ha;
  295. ha->timer.function = (void (*)(unsigned long))func;
  296. add_timer(&ha->timer);
  297. ha->timer_active = 1;
  298. }
  299. static void qla4xxx_stop_timer(struct scsi_qla_host *ha)
  300. {
  301. del_timer_sync(&ha->timer);
  302. ha->timer_active = 0;
  303. }
  304. /***
  305. * qla4xxx_mark_device_missing - mark a device as missing.
  306. * @ha: Pointer to host adapter structure.
  307. * @ddb_entry: Pointer to device database entry
  308. *
  309. * This routine marks a device missing and resets the relogin retry count.
  310. **/
  311. void qla4xxx_mark_device_missing(struct scsi_qla_host *ha,
  312. struct ddb_entry *ddb_entry)
  313. {
  314. atomic_set(&ddb_entry->state, DDB_STATE_MISSING);
  315. DEBUG3(printk("scsi%d:%d:%d: index [%d] marked MISSING\n",
  316. ha->host_no, ddb_entry->bus, ddb_entry->target,
  317. ddb_entry->fw_ddb_index));
  318. iscsi_conn_error(ddb_entry->conn, ISCSI_ERR_CONN_FAILED);
  319. }
  320. static struct srb* qla4xxx_get_new_srb(struct scsi_qla_host *ha,
  321. struct ddb_entry *ddb_entry,
  322. struct scsi_cmnd *cmd,
  323. void (*done)(struct scsi_cmnd *))
  324. {
  325. struct srb *srb;
  326. srb = mempool_alloc(ha->srb_mempool, GFP_ATOMIC);
  327. if (!srb)
  328. return srb;
  329. atomic_set(&srb->ref_count, 1);
  330. srb->ha = ha;
  331. srb->ddb = ddb_entry;
  332. srb->cmd = cmd;
  333. srb->flags = 0;
  334. cmd->SCp.ptr = (void *)srb;
  335. cmd->scsi_done = done;
  336. return srb;
  337. }
  338. static void qla4xxx_srb_free_dma(struct scsi_qla_host *ha, struct srb *srb)
  339. {
  340. struct scsi_cmnd *cmd = srb->cmd;
  341. if (srb->flags & SRB_DMA_VALID) {
  342. scsi_dma_unmap(cmd);
  343. srb->flags &= ~SRB_DMA_VALID;
  344. }
  345. cmd->SCp.ptr = NULL;
  346. }
  347. void qla4xxx_srb_compl(struct scsi_qla_host *ha, struct srb *srb)
  348. {
  349. struct scsi_cmnd *cmd = srb->cmd;
  350. qla4xxx_srb_free_dma(ha, srb);
  351. mempool_free(srb, ha->srb_mempool);
  352. cmd->scsi_done(cmd);
  353. }
  354. /**
  355. * qla4xxx_queuecommand - scsi layer issues scsi command to driver.
  356. * @cmd: Pointer to Linux's SCSI command structure
  357. * @done_fn: Function that the driver calls to notify the SCSI mid-layer
  358. * that the command has been processed.
  359. *
  360. * Remarks:
  361. * This routine is invoked by Linux to send a SCSI command to the driver.
  362. * The mid-level driver tries to ensure that queuecommand never gets
  363. * invoked concurrently with itself or the interrupt handler (although
  364. * the interrupt handler may call this routine as part of request-
  365. * completion handling). Unfortunely, it sometimes calls the scheduler
  366. * in interrupt context which is a big NO! NO!.
  367. **/
  368. static int qla4xxx_queuecommand(struct scsi_cmnd *cmd,
  369. void (*done)(struct scsi_cmnd *))
  370. {
  371. struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
  372. struct ddb_entry *ddb_entry = cmd->device->hostdata;
  373. struct srb *srb;
  374. int rval;
  375. if (atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE) {
  376. if (atomic_read(&ddb_entry->state) == DDB_STATE_DEAD) {
  377. cmd->result = DID_NO_CONNECT << 16;
  378. goto qc_fail_command;
  379. }
  380. goto qc_host_busy;
  381. }
  382. if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags))
  383. goto qc_host_busy;
  384. spin_unlock_irq(ha->host->host_lock);
  385. srb = qla4xxx_get_new_srb(ha, ddb_entry, cmd, done);
  386. if (!srb)
  387. goto qc_host_busy_lock;
  388. rval = qla4xxx_send_command_to_isp(ha, srb);
  389. if (rval != QLA_SUCCESS)
  390. goto qc_host_busy_free_sp;
  391. spin_lock_irq(ha->host->host_lock);
  392. return 0;
  393. qc_host_busy_free_sp:
  394. qla4xxx_srb_free_dma(ha, srb);
  395. mempool_free(srb, ha->srb_mempool);
  396. qc_host_busy_lock:
  397. spin_lock_irq(ha->host->host_lock);
  398. qc_host_busy:
  399. return SCSI_MLQUEUE_HOST_BUSY;
  400. qc_fail_command:
  401. done(cmd);
  402. return 0;
  403. }
  404. /**
  405. * qla4xxx_mem_free - frees memory allocated to adapter
  406. * @ha: Pointer to host adapter structure.
  407. *
  408. * Frees memory previously allocated by qla4xxx_mem_alloc
  409. **/
  410. static void qla4xxx_mem_free(struct scsi_qla_host *ha)
  411. {
  412. if (ha->queues)
  413. dma_free_coherent(&ha->pdev->dev, ha->queues_len, ha->queues,
  414. ha->queues_dma);
  415. ha->queues_len = 0;
  416. ha->queues = NULL;
  417. ha->queues_dma = 0;
  418. ha->request_ring = NULL;
  419. ha->request_dma = 0;
  420. ha->response_ring = NULL;
  421. ha->response_dma = 0;
  422. ha->shadow_regs = NULL;
  423. ha->shadow_regs_dma = 0;
  424. /* Free srb pool. */
  425. if (ha->srb_mempool)
  426. mempool_destroy(ha->srb_mempool);
  427. ha->srb_mempool = NULL;
  428. /* release io space registers */
  429. if (ha->reg)
  430. iounmap(ha->reg);
  431. pci_release_regions(ha->pdev);
  432. }
  433. /**
  434. * qla4xxx_mem_alloc - allocates memory for use by adapter.
  435. * @ha: Pointer to host adapter structure
  436. *
  437. * Allocates DMA memory for request and response queues. Also allocates memory
  438. * for srbs.
  439. **/
  440. static int qla4xxx_mem_alloc(struct scsi_qla_host *ha)
  441. {
  442. unsigned long align;
  443. /* Allocate contiguous block of DMA memory for queues. */
  444. ha->queues_len = ((REQUEST_QUEUE_DEPTH * QUEUE_SIZE) +
  445. (RESPONSE_QUEUE_DEPTH * QUEUE_SIZE) +
  446. sizeof(struct shadow_regs) +
  447. MEM_ALIGN_VALUE +
  448. (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
  449. ha->queues = dma_alloc_coherent(&ha->pdev->dev, ha->queues_len,
  450. &ha->queues_dma, GFP_KERNEL);
  451. if (ha->queues == NULL) {
  452. dev_warn(&ha->pdev->dev,
  453. "Memory Allocation failed - queues.\n");
  454. goto mem_alloc_error_exit;
  455. }
  456. memset(ha->queues, 0, ha->queues_len);
  457. /*
  458. * As per RISC alignment requirements -- the bus-address must be a
  459. * multiple of the request-ring size (in bytes).
  460. */
  461. align = 0;
  462. if ((unsigned long)ha->queues_dma & (MEM_ALIGN_VALUE - 1))
  463. align = MEM_ALIGN_VALUE - ((unsigned long)ha->queues_dma &
  464. (MEM_ALIGN_VALUE - 1));
  465. /* Update request and response queue pointers. */
  466. ha->request_dma = ha->queues_dma + align;
  467. ha->request_ring = (struct queue_entry *) (ha->queues + align);
  468. ha->response_dma = ha->queues_dma + align +
  469. (REQUEST_QUEUE_DEPTH * QUEUE_SIZE);
  470. ha->response_ring = (struct queue_entry *) (ha->queues + align +
  471. (REQUEST_QUEUE_DEPTH *
  472. QUEUE_SIZE));
  473. ha->shadow_regs_dma = ha->queues_dma + align +
  474. (REQUEST_QUEUE_DEPTH * QUEUE_SIZE) +
  475. (RESPONSE_QUEUE_DEPTH * QUEUE_SIZE);
  476. ha->shadow_regs = (struct shadow_regs *) (ha->queues + align +
  477. (REQUEST_QUEUE_DEPTH *
  478. QUEUE_SIZE) +
  479. (RESPONSE_QUEUE_DEPTH *
  480. QUEUE_SIZE));
  481. /* Allocate memory for srb pool. */
  482. ha->srb_mempool = mempool_create(SRB_MIN_REQ, mempool_alloc_slab,
  483. mempool_free_slab, srb_cachep);
  484. if (ha->srb_mempool == NULL) {
  485. dev_warn(&ha->pdev->dev,
  486. "Memory Allocation failed - SRB Pool.\n");
  487. goto mem_alloc_error_exit;
  488. }
  489. return QLA_SUCCESS;
  490. mem_alloc_error_exit:
  491. qla4xxx_mem_free(ha);
  492. return QLA_ERROR;
  493. }
  494. /**
  495. * qla4xxx_timer - checks every second for work to do.
  496. * @ha: Pointer to host adapter structure.
  497. **/
  498. static void qla4xxx_timer(struct scsi_qla_host *ha)
  499. {
  500. struct ddb_entry *ddb_entry, *dtemp;
  501. int start_dpc = 0;
  502. /* Search for relogin's to time-out and port down retry. */
  503. list_for_each_entry_safe(ddb_entry, dtemp, &ha->ddb_list, list) {
  504. /* Count down time between sending relogins */
  505. if (adapter_up(ha) &&
  506. !test_bit(DF_RELOGIN, &ddb_entry->flags) &&
  507. atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE) {
  508. if (atomic_read(&ddb_entry->retry_relogin_timer) !=
  509. INVALID_ENTRY) {
  510. if (atomic_read(&ddb_entry->retry_relogin_timer)
  511. == 0) {
  512. atomic_set(&ddb_entry->
  513. retry_relogin_timer,
  514. INVALID_ENTRY);
  515. set_bit(DPC_RELOGIN_DEVICE,
  516. &ha->dpc_flags);
  517. set_bit(DF_RELOGIN, &ddb_entry->flags);
  518. DEBUG2(printk("scsi%ld: %s: index [%d]"
  519. " login device\n",
  520. ha->host_no, __func__,
  521. ddb_entry->fw_ddb_index));
  522. } else
  523. atomic_dec(&ddb_entry->
  524. retry_relogin_timer);
  525. }
  526. }
  527. /* Wait for relogin to timeout */
  528. if (atomic_read(&ddb_entry->relogin_timer) &&
  529. (atomic_dec_and_test(&ddb_entry->relogin_timer) != 0)) {
  530. /*
  531. * If the relogin times out and the device is
  532. * still NOT ONLINE then try and relogin again.
  533. */
  534. if (atomic_read(&ddb_entry->state) !=
  535. DDB_STATE_ONLINE &&
  536. ddb_entry->fw_ddb_device_state ==
  537. DDB_DS_SESSION_FAILED) {
  538. /* Reset retry relogin timer */
  539. atomic_inc(&ddb_entry->relogin_retry_count);
  540. DEBUG2(printk("scsi%ld: index[%d] relogin"
  541. " timed out-retrying"
  542. " relogin (%d)\n",
  543. ha->host_no,
  544. ddb_entry->fw_ddb_index,
  545. atomic_read(&ddb_entry->
  546. relogin_retry_count))
  547. );
  548. start_dpc++;
  549. DEBUG(printk("scsi%ld:%d:%d: index [%d] "
  550. "initate relogin after"
  551. " %d seconds\n",
  552. ha->host_no, ddb_entry->bus,
  553. ddb_entry->target,
  554. ddb_entry->fw_ddb_index,
  555. ddb_entry->default_time2wait + 4)
  556. );
  557. atomic_set(&ddb_entry->retry_relogin_timer,
  558. ddb_entry->default_time2wait + 4);
  559. }
  560. }
  561. }
  562. /* Check for heartbeat interval. */
  563. if (ha->firmware_options & FWOPT_HEARTBEAT_ENABLE &&
  564. ha->heartbeat_interval != 0) {
  565. ha->seconds_since_last_heartbeat++;
  566. if (ha->seconds_since_last_heartbeat >
  567. ha->heartbeat_interval + 2)
  568. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  569. }
  570. /* Wakeup the dpc routine for this adapter, if needed. */
  571. if ((start_dpc ||
  572. test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
  573. test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags) ||
  574. test_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags) ||
  575. test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags) ||
  576. test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
  577. test_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags) ||
  578. test_bit(DPC_AEN, &ha->dpc_flags)) &&
  579. ha->dpc_thread) {
  580. DEBUG2(printk("scsi%ld: %s: scheduling dpc routine"
  581. " - dpc flags = 0x%lx\n",
  582. ha->host_no, __func__, ha->dpc_flags));
  583. queue_work(ha->dpc_thread, &ha->dpc_work);
  584. }
  585. /* Reschedule timer thread to call us back in one second */
  586. mod_timer(&ha->timer, jiffies + HZ);
  587. DEBUG2(ha->seconds_since_last_intr++);
  588. }
  589. /**
  590. * qla4xxx_cmd_wait - waits for all outstanding commands to complete
  591. * @ha: Pointer to host adapter structure.
  592. *
  593. * This routine stalls the driver until all outstanding commands are returned.
  594. * Caller must release the Hardware Lock prior to calling this routine.
  595. **/
  596. static int qla4xxx_cmd_wait(struct scsi_qla_host *ha)
  597. {
  598. uint32_t index = 0;
  599. int stat = QLA_SUCCESS;
  600. unsigned long flags;
  601. struct scsi_cmnd *cmd;
  602. int wait_cnt = WAIT_CMD_TOV; /*
  603. * Initialized for 30 seconds as we
  604. * expect all commands to retuned
  605. * ASAP.
  606. */
  607. while (wait_cnt) {
  608. spin_lock_irqsave(&ha->hardware_lock, flags);
  609. /* Find a command that hasn't completed. */
  610. for (index = 0; index < ha->host->can_queue; index++) {
  611. cmd = scsi_host_find_tag(ha->host, index);
  612. if (cmd != NULL)
  613. break;
  614. }
  615. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  616. /* If No Commands are pending, wait is complete */
  617. if (index == ha->host->can_queue) {
  618. break;
  619. }
  620. /* If we timed out on waiting for commands to come back
  621. * return ERROR.
  622. */
  623. wait_cnt--;
  624. if (wait_cnt == 0)
  625. stat = QLA_ERROR;
  626. else {
  627. msleep(1000);
  628. }
  629. } /* End of While (wait_cnt) */
  630. return stat;
  631. }
  632. void qla4xxx_hw_reset(struct scsi_qla_host *ha)
  633. {
  634. uint32_t ctrl_status;
  635. unsigned long flags = 0;
  636. DEBUG2(printk(KERN_ERR "scsi%ld: %s\n", ha->host_no, __func__));
  637. spin_lock_irqsave(&ha->hardware_lock, flags);
  638. /*
  639. * If the SCSI Reset Interrupt bit is set, clear it.
  640. * Otherwise, the Soft Reset won't work.
  641. */
  642. ctrl_status = readw(&ha->reg->ctrl_status);
  643. if ((ctrl_status & CSR_SCSI_RESET_INTR) != 0)
  644. writel(set_rmask(CSR_SCSI_RESET_INTR), &ha->reg->ctrl_status);
  645. /* Issue Soft Reset */
  646. writel(set_rmask(CSR_SOFT_RESET), &ha->reg->ctrl_status);
  647. readl(&ha->reg->ctrl_status);
  648. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  649. }
  650. /**
  651. * qla4xxx_soft_reset - performs soft reset.
  652. * @ha: Pointer to host adapter structure.
  653. **/
  654. int qla4xxx_soft_reset(struct scsi_qla_host *ha)
  655. {
  656. uint32_t max_wait_time;
  657. unsigned long flags = 0;
  658. int status = QLA_ERROR;
  659. uint32_t ctrl_status;
  660. qla4xxx_hw_reset(ha);
  661. /* Wait until the Network Reset Intr bit is cleared */
  662. max_wait_time = RESET_INTR_TOV;
  663. do {
  664. spin_lock_irqsave(&ha->hardware_lock, flags);
  665. ctrl_status = readw(&ha->reg->ctrl_status);
  666. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  667. if ((ctrl_status & CSR_NET_RESET_INTR) == 0)
  668. break;
  669. msleep(1000);
  670. } while ((--max_wait_time));
  671. if ((ctrl_status & CSR_NET_RESET_INTR) != 0) {
  672. DEBUG2(printk(KERN_WARNING
  673. "scsi%ld: Network Reset Intr not cleared by "
  674. "Network function, clearing it now!\n",
  675. ha->host_no));
  676. spin_lock_irqsave(&ha->hardware_lock, flags);
  677. writel(set_rmask(CSR_NET_RESET_INTR), &ha->reg->ctrl_status);
  678. readl(&ha->reg->ctrl_status);
  679. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  680. }
  681. /* Wait until the firmware tells us the Soft Reset is done */
  682. max_wait_time = SOFT_RESET_TOV;
  683. do {
  684. spin_lock_irqsave(&ha->hardware_lock, flags);
  685. ctrl_status = readw(&ha->reg->ctrl_status);
  686. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  687. if ((ctrl_status & CSR_SOFT_RESET) == 0) {
  688. status = QLA_SUCCESS;
  689. break;
  690. }
  691. msleep(1000);
  692. } while ((--max_wait_time));
  693. /*
  694. * Also, make sure that the SCSI Reset Interrupt bit has been cleared
  695. * after the soft reset has taken place.
  696. */
  697. spin_lock_irqsave(&ha->hardware_lock, flags);
  698. ctrl_status = readw(&ha->reg->ctrl_status);
  699. if ((ctrl_status & CSR_SCSI_RESET_INTR) != 0) {
  700. writel(set_rmask(CSR_SCSI_RESET_INTR), &ha->reg->ctrl_status);
  701. readl(&ha->reg->ctrl_status);
  702. }
  703. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  704. /* If soft reset fails then most probably the bios on other
  705. * function is also enabled.
  706. * Since the initialization is sequential the other fn
  707. * wont be able to acknowledge the soft reset.
  708. * Issue a force soft reset to workaround this scenario.
  709. */
  710. if (max_wait_time == 0) {
  711. /* Issue Force Soft Reset */
  712. spin_lock_irqsave(&ha->hardware_lock, flags);
  713. writel(set_rmask(CSR_FORCE_SOFT_RESET), &ha->reg->ctrl_status);
  714. readl(&ha->reg->ctrl_status);
  715. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  716. /* Wait until the firmware tells us the Soft Reset is done */
  717. max_wait_time = SOFT_RESET_TOV;
  718. do {
  719. spin_lock_irqsave(&ha->hardware_lock, flags);
  720. ctrl_status = readw(&ha->reg->ctrl_status);
  721. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  722. if ((ctrl_status & CSR_FORCE_SOFT_RESET) == 0) {
  723. status = QLA_SUCCESS;
  724. break;
  725. }
  726. msleep(1000);
  727. } while ((--max_wait_time));
  728. }
  729. return status;
  730. }
  731. /**
  732. * qla4xxx_flush_active_srbs - returns all outstanding i/o requests to O.S.
  733. * @ha: Pointer to host adapter structure.
  734. *
  735. * This routine is called just prior to a HARD RESET to return all
  736. * outstanding commands back to the Operating System.
  737. * Caller should make sure that the following locks are released
  738. * before this calling routine: Hardware lock, and io_request_lock.
  739. **/
  740. static void qla4xxx_flush_active_srbs(struct scsi_qla_host *ha)
  741. {
  742. struct srb *srb;
  743. int i;
  744. unsigned long flags;
  745. spin_lock_irqsave(&ha->hardware_lock, flags);
  746. for (i = 0; i < ha->host->can_queue; i++) {
  747. srb = qla4xxx_del_from_active_array(ha, i);
  748. if (srb != NULL) {
  749. srb->cmd->result = DID_RESET << 16;
  750. qla4xxx_srb_compl(ha, srb);
  751. }
  752. }
  753. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  754. }
  755. /**
  756. * qla4xxx_recover_adapter - recovers adapter after a fatal error
  757. * @ha: Pointer to host adapter structure.
  758. * @renew_ddb_list: Indicates what to do with the adapter's ddb list
  759. * after adapter recovery has completed.
  760. * 0=preserve ddb list, 1=destroy and rebuild ddb list
  761. **/
  762. static int qla4xxx_recover_adapter(struct scsi_qla_host *ha,
  763. uint8_t renew_ddb_list)
  764. {
  765. int status;
  766. /* Stall incoming I/O until we are done */
  767. clear_bit(AF_ONLINE, &ha->flags);
  768. DEBUG2(printk("scsi%ld: %s calling qla4xxx_cmd_wait\n", ha->host_no,
  769. __func__));
  770. /* Wait for outstanding commands to complete.
  771. * Stalls the driver for max 30 secs
  772. */
  773. status = qla4xxx_cmd_wait(ha);
  774. qla4xxx_disable_intrs(ha);
  775. /* Flush any pending ddb changed AENs */
  776. qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
  777. /* Reset the firmware. If successful, function
  778. * returns with ISP interrupts enabled.
  779. */
  780. if (status == QLA_SUCCESS) {
  781. DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n",
  782. ha->host_no, __func__));
  783. qla4xxx_flush_active_srbs(ha);
  784. if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
  785. status = qla4xxx_soft_reset(ha);
  786. else
  787. status = QLA_ERROR;
  788. }
  789. /* Flush any pending ddb changed AENs */
  790. qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
  791. /* Re-initialize firmware. If successful, function returns
  792. * with ISP interrupts enabled */
  793. if (status == QLA_SUCCESS) {
  794. DEBUG2(printk("scsi%ld: %s - Initializing adapter..\n",
  795. ha->host_no, __func__));
  796. /* If successful, AF_ONLINE flag set in
  797. * qla4xxx_initialize_adapter */
  798. status = qla4xxx_initialize_adapter(ha, renew_ddb_list);
  799. }
  800. /* Failed adapter initialization?
  801. * Retry reset_ha only if invoked via DPC (DPC_RESET_HA) */
  802. if ((test_bit(AF_ONLINE, &ha->flags) == 0) &&
  803. (test_bit(DPC_RESET_HA, &ha->dpc_flags))) {
  804. /* Adapter initialization failed, see if we can retry
  805. * resetting the ha */
  806. if (!test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags)) {
  807. ha->retry_reset_ha_cnt = MAX_RESET_HA_RETRIES;
  808. DEBUG2(printk("scsi%ld: recover adapter - retrying "
  809. "(%d) more times\n", ha->host_no,
  810. ha->retry_reset_ha_cnt));
  811. set_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
  812. status = QLA_ERROR;
  813. } else {
  814. if (ha->retry_reset_ha_cnt > 0) {
  815. /* Schedule another Reset HA--DPC will retry */
  816. ha->retry_reset_ha_cnt--;
  817. DEBUG2(printk("scsi%ld: recover adapter - "
  818. "retry remaining %d\n",
  819. ha->host_no,
  820. ha->retry_reset_ha_cnt));
  821. status = QLA_ERROR;
  822. }
  823. if (ha->retry_reset_ha_cnt == 0) {
  824. /* Recover adapter retries have been exhausted.
  825. * Adapter DEAD */
  826. DEBUG2(printk("scsi%ld: recover adapter "
  827. "failed - board disabled\n",
  828. ha->host_no));
  829. qla4xxx_flush_active_srbs(ha);
  830. clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
  831. clear_bit(DPC_RESET_HA, &ha->dpc_flags);
  832. clear_bit(DPC_RESET_HA_DESTROY_DDB_LIST,
  833. &ha->dpc_flags);
  834. status = QLA_ERROR;
  835. }
  836. }
  837. } else {
  838. clear_bit(DPC_RESET_HA, &ha->dpc_flags);
  839. clear_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags);
  840. clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags);
  841. }
  842. ha->adapter_error_count++;
  843. if (status == QLA_SUCCESS)
  844. qla4xxx_enable_intrs(ha);
  845. DEBUG2(printk("scsi%ld: recover adapter .. DONE\n", ha->host_no));
  846. return status;
  847. }
  848. /**
  849. * qla4xxx_do_dpc - dpc routine
  850. * @data: in our case pointer to adapter structure
  851. *
  852. * This routine is a task that is schedule by the interrupt handler
  853. * to perform the background processing for interrupts. We put it
  854. * on a task queue that is consumed whenever the scheduler runs; that's
  855. * so you can do anything (i.e. put the process to sleep etc). In fact,
  856. * the mid-level tries to sleep when it reaches the driver threshold
  857. * "host->can_queue". This can cause a panic if we were in our interrupt code.
  858. **/
  859. static void qla4xxx_do_dpc(struct work_struct *work)
  860. {
  861. struct scsi_qla_host *ha =
  862. container_of(work, struct scsi_qla_host, dpc_work);
  863. struct ddb_entry *ddb_entry, *dtemp;
  864. int status = QLA_ERROR;
  865. DEBUG2(printk("scsi%ld: %s: DPC handler waking up."
  866. "flags = 0x%08lx, dpc_flags = 0x%08lx ctrl_stat = 0x%08x\n",
  867. ha->host_no, __func__, ha->flags, ha->dpc_flags,
  868. readw(&ha->reg->ctrl_status)));
  869. /* Initialization not yet finished. Don't do anything yet. */
  870. if (!test_bit(AF_INIT_DONE, &ha->flags))
  871. return;
  872. if (adapter_up(ha) ||
  873. test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
  874. test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
  875. test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags)) {
  876. if (test_bit(DPC_RESET_HA_DESTROY_DDB_LIST, &ha->dpc_flags) ||
  877. test_bit(DPC_RESET_HA, &ha->dpc_flags))
  878. qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST);
  879. if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) {
  880. uint8_t wait_time = RESET_INTR_TOV;
  881. while ((readw(&ha->reg->ctrl_status) &
  882. (CSR_SOFT_RESET | CSR_FORCE_SOFT_RESET)) != 0) {
  883. if (--wait_time == 0)
  884. break;
  885. msleep(1000);
  886. }
  887. if (wait_time == 0)
  888. DEBUG2(printk("scsi%ld: %s: SR|FSR "
  889. "bit not cleared-- resetting\n",
  890. ha->host_no, __func__));
  891. qla4xxx_flush_active_srbs(ha);
  892. if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) {
  893. qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
  894. status = qla4xxx_initialize_adapter(ha,
  895. PRESERVE_DDB_LIST);
  896. }
  897. clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
  898. if (status == QLA_SUCCESS)
  899. qla4xxx_enable_intrs(ha);
  900. }
  901. }
  902. /* ---- process AEN? --- */
  903. if (test_and_clear_bit(DPC_AEN, &ha->dpc_flags))
  904. qla4xxx_process_aen(ha, PROCESS_ALL_AENS);
  905. /* ---- Get DHCP IP Address? --- */
  906. if (test_and_clear_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags))
  907. qla4xxx_get_dhcp_ip_address(ha);
  908. /* ---- relogin device? --- */
  909. if (adapter_up(ha) &&
  910. test_and_clear_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags)) {
  911. list_for_each_entry_safe(ddb_entry, dtemp,
  912. &ha->ddb_list, list) {
  913. if (test_and_clear_bit(DF_RELOGIN, &ddb_entry->flags) &&
  914. atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE)
  915. qla4xxx_relogin_device(ha, ddb_entry);
  916. /*
  917. * If mbx cmd times out there is no point
  918. * in continuing further.
  919. * With large no of targets this can hang
  920. * the system.
  921. */
  922. if (test_bit(DPC_RESET_HA, &ha->dpc_flags)) {
  923. printk(KERN_WARNING "scsi%ld: %s: "
  924. "need to reset hba\n",
  925. ha->host_no, __func__);
  926. break;
  927. }
  928. }
  929. }
  930. }
  931. /**
  932. * qla4xxx_free_adapter - release the adapter
  933. * @ha: pointer to adapter structure
  934. **/
  935. static void qla4xxx_free_adapter(struct scsi_qla_host *ha)
  936. {
  937. if (test_bit(AF_INTERRUPTS_ON, &ha->flags)) {
  938. /* Turn-off interrupts on the card. */
  939. qla4xxx_disable_intrs(ha);
  940. }
  941. /* Kill the kernel thread for this host */
  942. if (ha->dpc_thread)
  943. destroy_workqueue(ha->dpc_thread);
  944. /* Issue Soft Reset to put firmware in unknown state */
  945. if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
  946. qla4xxx_hw_reset(ha);
  947. /* Remove timer thread, if present */
  948. if (ha->timer_active)
  949. qla4xxx_stop_timer(ha);
  950. /* Detach interrupts */
  951. if (test_and_clear_bit(AF_IRQ_ATTACHED, &ha->flags))
  952. free_irq(ha->pdev->irq, ha);
  953. /* free extra memory */
  954. qla4xxx_mem_free(ha);
  955. pci_disable_device(ha->pdev);
  956. }
  957. /***
  958. * qla4xxx_iospace_config - maps registers
  959. * @ha: pointer to adapter structure
  960. *
  961. * This routines maps HBA's registers from the pci address space
  962. * into the kernel virtual address space for memory mapped i/o.
  963. **/
  964. static int qla4xxx_iospace_config(struct scsi_qla_host *ha)
  965. {
  966. unsigned long pio, pio_len, pio_flags;
  967. unsigned long mmio, mmio_len, mmio_flags;
  968. pio = pci_resource_start(ha->pdev, 0);
  969. pio_len = pci_resource_len(ha->pdev, 0);
  970. pio_flags = pci_resource_flags(ha->pdev, 0);
  971. if (pio_flags & IORESOURCE_IO) {
  972. if (pio_len < MIN_IOBASE_LEN) {
  973. dev_warn(&ha->pdev->dev,
  974. "Invalid PCI I/O region size\n");
  975. pio = 0;
  976. }
  977. } else {
  978. dev_warn(&ha->pdev->dev, "region #0 not a PIO resource\n");
  979. pio = 0;
  980. }
  981. /* Use MMIO operations for all accesses. */
  982. mmio = pci_resource_start(ha->pdev, 1);
  983. mmio_len = pci_resource_len(ha->pdev, 1);
  984. mmio_flags = pci_resource_flags(ha->pdev, 1);
  985. if (!(mmio_flags & IORESOURCE_MEM)) {
  986. dev_err(&ha->pdev->dev,
  987. "region #0 not an MMIO resource, aborting\n");
  988. goto iospace_error_exit;
  989. }
  990. if (mmio_len < MIN_IOBASE_LEN) {
  991. dev_err(&ha->pdev->dev,
  992. "Invalid PCI mem region size, aborting\n");
  993. goto iospace_error_exit;
  994. }
  995. if (pci_request_regions(ha->pdev, DRIVER_NAME)) {
  996. dev_warn(&ha->pdev->dev,
  997. "Failed to reserve PIO/MMIO regions\n");
  998. goto iospace_error_exit;
  999. }
  1000. ha->pio_address = pio;
  1001. ha->pio_length = pio_len;
  1002. ha->reg = ioremap(mmio, MIN_IOBASE_LEN);
  1003. if (!ha->reg) {
  1004. dev_err(&ha->pdev->dev,
  1005. "cannot remap MMIO, aborting\n");
  1006. goto iospace_error_exit;
  1007. }
  1008. return 0;
  1009. iospace_error_exit:
  1010. return -ENOMEM;
  1011. }
  1012. /**
  1013. * qla4xxx_probe_adapter - callback function to probe HBA
  1014. * @pdev: pointer to pci_dev structure
  1015. * @pci_device_id: pointer to pci_device entry
  1016. *
  1017. * This routine will probe for Qlogic 4xxx iSCSI host adapters.
  1018. * It returns zero if successful. It also initializes all data necessary for
  1019. * the driver.
  1020. **/
  1021. static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
  1022. const struct pci_device_id *ent)
  1023. {
  1024. int ret = -ENODEV, status;
  1025. struct Scsi_Host *host;
  1026. struct scsi_qla_host *ha;
  1027. struct ddb_entry *ddb_entry, *ddbtemp;
  1028. uint8_t init_retry_count = 0;
  1029. char buf[34];
  1030. if (pci_enable_device(pdev))
  1031. return -1;
  1032. host = scsi_host_alloc(&qla4xxx_driver_template, sizeof(*ha));
  1033. if (host == NULL) {
  1034. printk(KERN_WARNING
  1035. "qla4xxx: Couldn't allocate host from scsi layer!\n");
  1036. goto probe_disable_device;
  1037. }
  1038. /* Clear our data area */
  1039. ha = (struct scsi_qla_host *) host->hostdata;
  1040. memset(ha, 0, sizeof(*ha));
  1041. /* Save the information from PCI BIOS. */
  1042. ha->pdev = pdev;
  1043. ha->host = host;
  1044. ha->host_no = host->host_no;
  1045. /* Configure PCI I/O space. */
  1046. ret = qla4xxx_iospace_config(ha);
  1047. if (ret)
  1048. goto probe_failed;
  1049. dev_info(&ha->pdev->dev, "Found an ISP%04x, irq %d, iobase 0x%p\n",
  1050. pdev->device, pdev->irq, ha->reg);
  1051. qla4xxx_config_dma_addressing(ha);
  1052. /* Initialize lists and spinlocks. */
  1053. INIT_LIST_HEAD(&ha->ddb_list);
  1054. INIT_LIST_HEAD(&ha->free_srb_q);
  1055. mutex_init(&ha->mbox_sem);
  1056. spin_lock_init(&ha->hardware_lock);
  1057. /* Allocate dma buffers */
  1058. if (qla4xxx_mem_alloc(ha)) {
  1059. dev_warn(&ha->pdev->dev,
  1060. "[ERROR] Failed to allocate memory for adapter\n");
  1061. ret = -ENOMEM;
  1062. goto probe_failed;
  1063. }
  1064. /*
  1065. * Initialize the Host adapter request/response queues and
  1066. * firmware
  1067. * NOTE: interrupts enabled upon successful completion
  1068. */
  1069. status = qla4xxx_initialize_adapter(ha, REBUILD_DDB_LIST);
  1070. while (status == QLA_ERROR && init_retry_count++ < MAX_INIT_RETRIES) {
  1071. DEBUG2(printk("scsi: %s: retrying adapter initialization "
  1072. "(%d)\n", __func__, init_retry_count));
  1073. qla4xxx_soft_reset(ha);
  1074. status = qla4xxx_initialize_adapter(ha, REBUILD_DDB_LIST);
  1075. }
  1076. if (status == QLA_ERROR) {
  1077. dev_warn(&ha->pdev->dev, "Failed to initialize adapter\n");
  1078. ret = -ENODEV;
  1079. goto probe_failed;
  1080. }
  1081. host->cmd_per_lun = 3;
  1082. host->max_channel = 0;
  1083. host->max_lun = MAX_LUNS - 1;
  1084. host->max_id = MAX_TARGETS;
  1085. host->max_cmd_len = IOCB_MAX_CDB_LEN;
  1086. host->can_queue = MAX_SRBS ;
  1087. host->transportt = qla4xxx_scsi_transport;
  1088. ret = scsi_init_shared_tag_map(host, MAX_SRBS);
  1089. if (ret) {
  1090. dev_warn(&ha->pdev->dev, "scsi_init_shared_tag_map failed");
  1091. goto probe_failed;
  1092. }
  1093. /* Startup the kernel thread for this host adapter. */
  1094. DEBUG2(printk("scsi: %s: Starting kernel thread for "
  1095. "qla4xxx_dpc\n", __func__));
  1096. sprintf(buf, "qla4xxx_%lu_dpc", ha->host_no);
  1097. ha->dpc_thread = create_singlethread_workqueue(buf);
  1098. if (!ha->dpc_thread) {
  1099. dev_warn(&ha->pdev->dev, "Unable to start DPC thread!\n");
  1100. ret = -ENODEV;
  1101. goto probe_failed;
  1102. }
  1103. INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc);
  1104. ret = request_irq(pdev->irq, qla4xxx_intr_handler,
  1105. IRQF_DISABLED | IRQF_SHARED, "qla4xxx", ha);
  1106. if (ret) {
  1107. dev_warn(&ha->pdev->dev, "Failed to reserve interrupt %d"
  1108. " already in use.\n", pdev->irq);
  1109. goto probe_failed;
  1110. }
  1111. set_bit(AF_IRQ_ATTACHED, &ha->flags);
  1112. host->irq = pdev->irq;
  1113. DEBUG(printk("scsi%d: irq %d attached\n", ha->host_no, ha->pdev->irq));
  1114. qla4xxx_enable_intrs(ha);
  1115. /* Start timer thread. */
  1116. qla4xxx_start_timer(ha, qla4xxx_timer, 1);
  1117. set_bit(AF_INIT_DONE, &ha->flags);
  1118. pci_set_drvdata(pdev, ha);
  1119. ret = scsi_add_host(host, &pdev->dev);
  1120. if (ret)
  1121. goto probe_failed;
  1122. /* Update transport device information for all devices. */
  1123. list_for_each_entry_safe(ddb_entry, ddbtemp, &ha->ddb_list, list) {
  1124. if (ddb_entry->fw_ddb_device_state == DDB_DS_SESSION_ACTIVE)
  1125. if (qla4xxx_add_sess(ddb_entry))
  1126. goto remove_host;
  1127. }
  1128. printk(KERN_INFO
  1129. " QLogic iSCSI HBA Driver version: %s\n"
  1130. " QLogic ISP%04x @ %s, host#=%ld, fw=%02d.%02d.%02d.%02d\n",
  1131. qla4xxx_version_str, ha->pdev->device, pci_name(ha->pdev),
  1132. ha->host_no, ha->firmware_version[0], ha->firmware_version[1],
  1133. ha->patch_number, ha->build_number);
  1134. return 0;
  1135. remove_host:
  1136. qla4xxx_free_ddb_list(ha);
  1137. scsi_remove_host(host);
  1138. probe_failed:
  1139. qla4xxx_free_adapter(ha);
  1140. scsi_host_put(ha->host);
  1141. probe_disable_device:
  1142. pci_disable_device(pdev);
  1143. return ret;
  1144. }
  1145. /**
  1146. * qla4xxx_remove_adapter - calback function to remove adapter.
  1147. * @pci_dev: PCI device pointer
  1148. **/
  1149. static void __devexit qla4xxx_remove_adapter(struct pci_dev *pdev)
  1150. {
  1151. struct scsi_qla_host *ha;
  1152. ha = pci_get_drvdata(pdev);
  1153. qla4xxx_disable_intrs(ha);
  1154. while (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags))
  1155. ssleep(1);
  1156. /* remove devs from iscsi_sessions to scsi_devices */
  1157. qla4xxx_free_ddb_list(ha);
  1158. scsi_remove_host(ha->host);
  1159. qla4xxx_free_adapter(ha);
  1160. scsi_host_put(ha->host);
  1161. pci_set_drvdata(pdev, NULL);
  1162. }
  1163. /**
  1164. * qla4xxx_config_dma_addressing() - Configure OS DMA addressing method.
  1165. * @ha: HA context
  1166. *
  1167. * At exit, the @ha's flags.enable_64bit_addressing set to indicated
  1168. * supported addressing method.
  1169. */
  1170. static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha)
  1171. {
  1172. int retval;
  1173. /* Update our PCI device dma_mask for full 64 bit mask */
  1174. if (pci_set_dma_mask(ha->pdev, DMA_64BIT_MASK) == 0) {
  1175. if (pci_set_consistent_dma_mask(ha->pdev, DMA_64BIT_MASK)) {
  1176. dev_dbg(&ha->pdev->dev,
  1177. "Failed to set 64 bit PCI consistent mask; "
  1178. "using 32 bit.\n");
  1179. retval = pci_set_consistent_dma_mask(ha->pdev,
  1180. DMA_32BIT_MASK);
  1181. }
  1182. } else
  1183. retval = pci_set_dma_mask(ha->pdev, DMA_32BIT_MASK);
  1184. }
  1185. static int qla4xxx_slave_alloc(struct scsi_device *sdev)
  1186. {
  1187. struct iscsi_cls_session *sess = starget_to_session(sdev->sdev_target);
  1188. struct ddb_entry *ddb = sess->dd_data;
  1189. sdev->hostdata = ddb;
  1190. sdev->tagged_supported = 1;
  1191. scsi_activate_tcq(sdev, sdev->host->can_queue);
  1192. return 0;
  1193. }
  1194. static int qla4xxx_slave_configure(struct scsi_device *sdev)
  1195. {
  1196. sdev->tagged_supported = 1;
  1197. return 0;
  1198. }
  1199. static void qla4xxx_slave_destroy(struct scsi_device *sdev)
  1200. {
  1201. scsi_deactivate_tcq(sdev, 1);
  1202. }
  1203. /**
  1204. * qla4xxx_del_from_active_array - returns an active srb
  1205. * @ha: Pointer to host adapter structure.
  1206. * @index: index into to the active_array
  1207. *
  1208. * This routine removes and returns the srb at the specified index
  1209. **/
  1210. struct srb * qla4xxx_del_from_active_array(struct scsi_qla_host *ha, uint32_t index)
  1211. {
  1212. struct srb *srb = NULL;
  1213. struct scsi_cmnd *cmd;
  1214. if (!(cmd = scsi_host_find_tag(ha->host, index)))
  1215. return srb;
  1216. if (!(srb = (struct srb *)cmd->host_scribble))
  1217. return srb;
  1218. /* update counters */
  1219. if (srb->flags & SRB_DMA_VALID) {
  1220. ha->req_q_count += srb->iocb_cnt;
  1221. ha->iocb_cnt -= srb->iocb_cnt;
  1222. if (srb->cmd)
  1223. srb->cmd->host_scribble = NULL;
  1224. }
  1225. return srb;
  1226. }
  1227. /**
  1228. * qla4xxx_eh_wait_on_command - waits for command to be returned by firmware
  1229. * @ha: actual ha whose done queue will contain the comd returned by firmware.
  1230. * @cmd: Scsi Command to wait on.
  1231. *
  1232. * This routine waits for the command to be returned by the Firmware
  1233. * for some max time.
  1234. **/
  1235. static int qla4xxx_eh_wait_on_command(struct scsi_qla_host *ha,
  1236. struct scsi_cmnd *cmd)
  1237. {
  1238. int done = 0;
  1239. struct srb *rp;
  1240. uint32_t max_wait_time = EH_WAIT_CMD_TOV;
  1241. do {
  1242. /* Checking to see if its returned to OS */
  1243. rp = (struct srb *) cmd->SCp.ptr;
  1244. if (rp == NULL) {
  1245. done++;
  1246. break;
  1247. }
  1248. msleep(2000);
  1249. } while (max_wait_time--);
  1250. return done;
  1251. }
  1252. /**
  1253. * qla4xxx_wait_for_hba_online - waits for HBA to come online
  1254. * @ha: Pointer to host adapter structure
  1255. **/
  1256. static int qla4xxx_wait_for_hba_online(struct scsi_qla_host *ha)
  1257. {
  1258. unsigned long wait_online;
  1259. wait_online = jiffies + (30 * HZ);
  1260. while (time_before(jiffies, wait_online)) {
  1261. if (adapter_up(ha))
  1262. return QLA_SUCCESS;
  1263. else if (ha->retry_reset_ha_cnt == 0)
  1264. return QLA_ERROR;
  1265. msleep(2000);
  1266. }
  1267. return QLA_ERROR;
  1268. }
  1269. /**
  1270. * qla4xxx_eh_wait_for_active_target_commands - wait for active cmds to finish.
  1271. * @ha: pointer to to HBA
  1272. * @t: target id
  1273. * @l: lun id
  1274. *
  1275. * This function waits for all outstanding commands to a lun to complete. It
  1276. * returns 0 if all pending commands are returned and 1 otherwise.
  1277. **/
  1278. static int qla4xxx_eh_wait_for_active_target_commands(struct scsi_qla_host *ha,
  1279. int t, int l)
  1280. {
  1281. int cnt;
  1282. int status = 0;
  1283. struct scsi_cmnd *cmd;
  1284. /*
  1285. * Waiting for all commands for the designated target in the active
  1286. * array
  1287. */
  1288. for (cnt = 0; cnt < ha->host->can_queue; cnt++) {
  1289. cmd = scsi_host_find_tag(ha->host, cnt);
  1290. if (cmd && cmd->device->id == t && cmd->device->lun == l) {
  1291. if (!qla4xxx_eh_wait_on_command(ha, cmd)) {
  1292. status++;
  1293. break;
  1294. }
  1295. }
  1296. }
  1297. return status;
  1298. }
  1299. /**
  1300. * qla4xxx_eh_device_reset - callback for target reset.
  1301. * @cmd: Pointer to Linux's SCSI command structure
  1302. *
  1303. * This routine is called by the Linux OS to reset all luns on the
  1304. * specified target.
  1305. **/
  1306. static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
  1307. {
  1308. struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
  1309. struct ddb_entry *ddb_entry = cmd->device->hostdata;
  1310. struct srb *sp;
  1311. int ret = FAILED, stat;
  1312. sp = (struct srb *) cmd->SCp.ptr;
  1313. if (!sp || !ddb_entry)
  1314. return ret;
  1315. dev_info(&ha->pdev->dev,
  1316. "scsi%ld:%d:%d:%d: DEVICE RESET ISSUED.\n", ha->host_no,
  1317. cmd->device->channel, cmd->device->id, cmd->device->lun);
  1318. DEBUG2(printk(KERN_INFO
  1319. "scsi%ld: DEVICE_RESET cmd=%p jiffies = 0x%lx, to=%x,"
  1320. "dpc_flags=%lx, status=%x allowed=%d\n", ha->host_no,
  1321. cmd, jiffies, cmd->timeout_per_command / HZ,
  1322. ha->dpc_flags, cmd->result, cmd->allowed));
  1323. /* FIXME: wait for hba to go online */
  1324. stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun);
  1325. if (stat != QLA_SUCCESS) {
  1326. dev_info(&ha->pdev->dev, "DEVICE RESET FAILED. %d\n", stat);
  1327. goto eh_dev_reset_done;
  1328. }
  1329. /* Send marker. */
  1330. ha->marker_needed = 1;
  1331. /*
  1332. * If we are coming down the EH path, wait for all commands to complete
  1333. * for the device.
  1334. */
  1335. if (cmd->device->host->shost_state == SHOST_RECOVERY) {
  1336. if (qla4xxx_eh_wait_for_active_target_commands(ha,
  1337. cmd->device->id,
  1338. cmd->device->lun)){
  1339. dev_info(&ha->pdev->dev,
  1340. "DEVICE RESET FAILED - waiting for "
  1341. "commands.\n");
  1342. goto eh_dev_reset_done;
  1343. }
  1344. }
  1345. dev_info(&ha->pdev->dev,
  1346. "scsi(%ld:%d:%d:%d): DEVICE RESET SUCCEEDED.\n",
  1347. ha->host_no, cmd->device->channel, cmd->device->id,
  1348. cmd->device->lun);
  1349. ret = SUCCESS;
  1350. eh_dev_reset_done:
  1351. return ret;
  1352. }
  1353. /**
  1354. * qla4xxx_eh_host_reset - kernel callback
  1355. * @cmd: Pointer to Linux's SCSI command structure
  1356. *
  1357. * This routine is invoked by the Linux kernel to perform fatal error
  1358. * recovery on the specified adapter.
  1359. **/
  1360. static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd)
  1361. {
  1362. int return_status = FAILED;
  1363. struct scsi_qla_host *ha;
  1364. ha = (struct scsi_qla_host *) cmd->device->host->hostdata;
  1365. dev_info(&ha->pdev->dev,
  1366. "scsi(%ld:%d:%d:%d): ADAPTER RESET ISSUED.\n", ha->host_no,
  1367. cmd->device->channel, cmd->device->id, cmd->device->lun);
  1368. if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) {
  1369. DEBUG2(printk("scsi%ld:%d: %s: Unable to reset host. Adapter "
  1370. "DEAD.\n", ha->host_no, cmd->device->channel,
  1371. __func__));
  1372. return FAILED;
  1373. }
  1374. if (qla4xxx_recover_adapter(ha, PRESERVE_DDB_LIST) == QLA_SUCCESS) {
  1375. return_status = SUCCESS;
  1376. }
  1377. dev_info(&ha->pdev->dev, "HOST RESET %s.\n",
  1378. return_status == FAILED ? "FAILED" : "SUCCEDED");
  1379. return return_status;
  1380. }
  1381. static struct pci_device_id qla4xxx_pci_tbl[] = {
  1382. {
  1383. .vendor = PCI_VENDOR_ID_QLOGIC,
  1384. .device = PCI_DEVICE_ID_QLOGIC_ISP4010,
  1385. .subvendor = PCI_ANY_ID,
  1386. .subdevice = PCI_ANY_ID,
  1387. },
  1388. {
  1389. .vendor = PCI_VENDOR_ID_QLOGIC,
  1390. .device = PCI_DEVICE_ID_QLOGIC_ISP4022,
  1391. .subvendor = PCI_ANY_ID,
  1392. .subdevice = PCI_ANY_ID,
  1393. },
  1394. {
  1395. .vendor = PCI_VENDOR_ID_QLOGIC,
  1396. .device = PCI_DEVICE_ID_QLOGIC_ISP4032,
  1397. .subvendor = PCI_ANY_ID,
  1398. .subdevice = PCI_ANY_ID,
  1399. },
  1400. {0, 0},
  1401. };
  1402. MODULE_DEVICE_TABLE(pci, qla4xxx_pci_tbl);
  1403. static struct pci_driver qla4xxx_pci_driver = {
  1404. .name = DRIVER_NAME,
  1405. .id_table = qla4xxx_pci_tbl,
  1406. .probe = qla4xxx_probe_adapter,
  1407. .remove = qla4xxx_remove_adapter,
  1408. };
  1409. static int __init qla4xxx_module_init(void)
  1410. {
  1411. int ret;
  1412. /* Allocate cache for SRBs. */
  1413. srb_cachep = kmem_cache_create("qla4xxx_srbs", sizeof(struct srb), 0,
  1414. SLAB_HWCACHE_ALIGN, NULL, NULL);
  1415. if (srb_cachep == NULL) {
  1416. printk(KERN_ERR
  1417. "%s: Unable to allocate SRB cache..."
  1418. "Failing load!\n", DRIVER_NAME);
  1419. ret = -ENOMEM;
  1420. goto no_srp_cache;
  1421. }
  1422. /* Derive version string. */
  1423. strcpy(qla4xxx_version_str, QLA4XXX_DRIVER_VERSION);
  1424. if (ql4xextended_error_logging)
  1425. strcat(qla4xxx_version_str, "-debug");
  1426. qla4xxx_scsi_transport =
  1427. iscsi_register_transport(&qla4xxx_iscsi_transport);
  1428. if (!qla4xxx_scsi_transport){
  1429. ret = -ENODEV;
  1430. goto release_srb_cache;
  1431. }
  1432. ret = pci_register_driver(&qla4xxx_pci_driver);
  1433. if (ret)
  1434. goto unregister_transport;
  1435. printk(KERN_INFO "QLogic iSCSI HBA Driver\n");
  1436. return 0;
  1437. unregister_transport:
  1438. iscsi_unregister_transport(&qla4xxx_iscsi_transport);
  1439. release_srb_cache:
  1440. kmem_cache_destroy(srb_cachep);
  1441. no_srp_cache:
  1442. return ret;
  1443. }
  1444. static void __exit qla4xxx_module_exit(void)
  1445. {
  1446. ql4_mod_unload = 1;
  1447. pci_unregister_driver(&qla4xxx_pci_driver);
  1448. iscsi_unregister_transport(&qla4xxx_iscsi_transport);
  1449. kmem_cache_destroy(srb_cachep);
  1450. }
  1451. module_init(qla4xxx_module_init);
  1452. module_exit(qla4xxx_module_exit);
  1453. MODULE_AUTHOR("QLogic Corporation");
  1454. MODULE_DESCRIPTION("QLogic iSCSI HBA Driver");
  1455. MODULE_LICENSE("GPL");
  1456. MODULE_VERSION(QLA4XXX_DRIVER_VERSION);