ql4_os.c 46 KB

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