ql4_os.c 46 KB

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