ql4_os.c 46 KB

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