qla_os.c 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286
  1. /*
  2. * QLogic Fibre Channel HBA Driver
  3. * Copyright (c) 2003-2008 QLogic Corporation
  4. *
  5. * See LICENSE.qla2xxx for copyright and licensing details.
  6. */
  7. #include "qla_def.h"
  8. #include <linux/moduleparam.h>
  9. #include <linux/vmalloc.h>
  10. #include <linux/delay.h>
  11. #include <linux/kthread.h>
  12. #include <linux/mutex.h>
  13. #include <scsi/scsi_tcq.h>
  14. #include <scsi/scsicam.h>
  15. #include <scsi/scsi_transport.h>
  16. #include <scsi/scsi_transport_fc.h>
  17. /*
  18. * Driver version
  19. */
  20. char qla2x00_version_str[40];
  21. /*
  22. * SRB allocation cache
  23. */
  24. static struct kmem_cache *srb_cachep;
  25. int ql2xlogintimeout = 20;
  26. module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR);
  27. MODULE_PARM_DESC(ql2xlogintimeout,
  28. "Login timeout value in seconds.");
  29. int qlport_down_retry;
  30. module_param(qlport_down_retry, int, S_IRUGO|S_IRUSR);
  31. MODULE_PARM_DESC(qlport_down_retry,
  32. "Maximum number of command retries to a port that returns "
  33. "a PORT-DOWN status.");
  34. int ql2xplogiabsentdevice;
  35. module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
  36. MODULE_PARM_DESC(ql2xplogiabsentdevice,
  37. "Option to enable PLOGI to devices that are not present after "
  38. "a Fabric scan. This is needed for several broken switches. "
  39. "Default is 0 - no PLOGI. 1 - perfom PLOGI.");
  40. int ql2xloginretrycount = 0;
  41. module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
  42. MODULE_PARM_DESC(ql2xloginretrycount,
  43. "Specify an alternate value for the NVRAM login retry count.");
  44. int ql2xallocfwdump = 1;
  45. module_param(ql2xallocfwdump, int, S_IRUGO|S_IRUSR);
  46. MODULE_PARM_DESC(ql2xallocfwdump,
  47. "Option to enable allocation of memory for a firmware dump "
  48. "during HBA initialization. Memory allocation requirements "
  49. "vary by ISP type. Default is 1 - allocate memory.");
  50. int ql2xextended_error_logging;
  51. module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR);
  52. MODULE_PARM_DESC(ql2xextended_error_logging,
  53. "Option to enable extended error logging, "
  54. "Default is 0 - no logging. 1 - log errors.");
  55. static void qla2x00_free_device(scsi_qla_host_t *);
  56. int ql2xfdmienable=1;
  57. module_param(ql2xfdmienable, int, S_IRUGO|S_IRUSR);
  58. MODULE_PARM_DESC(ql2xfdmienable,
  59. "Enables FDMI registratons "
  60. "Default is 0 - no FDMI. 1 - perfom FDMI.");
  61. #define MAX_Q_DEPTH 32
  62. static int ql2xmaxqdepth = MAX_Q_DEPTH;
  63. module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
  64. MODULE_PARM_DESC(ql2xmaxqdepth,
  65. "Maximum queue depth to report for target devices.");
  66. int ql2xqfullrampup = 120;
  67. module_param(ql2xqfullrampup, int, S_IRUGO|S_IWUSR);
  68. MODULE_PARM_DESC(ql2xqfullrampup,
  69. "Number of seconds to wait to begin to ramp-up the queue "
  70. "depth for a device after a queue-full condition has been "
  71. "detected. Default is 120 seconds.");
  72. int ql2xiidmaenable=1;
  73. module_param(ql2xiidmaenable, int, S_IRUGO|S_IRUSR);
  74. MODULE_PARM_DESC(ql2xiidmaenable,
  75. "Enables iIDMA settings "
  76. "Default is 1 - perform iIDMA. 0 - no iIDMA.");
  77. int ql2xmaxqueues = 1;
  78. module_param(ql2xmaxqueues, int, S_IRUGO|S_IRUSR);
  79. MODULE_PARM_DESC(ql2xmaxqueues,
  80. "Enables MQ settings "
  81. "Default is 1 for single queue. Set it to number \
  82. of queues in MQ mode.");
  83. int ql2xmultique_tag;
  84. module_param(ql2xmultique_tag, int, S_IRUGO|S_IRUSR);
  85. MODULE_PARM_DESC(ql2xmultique_tag,
  86. "Enables CPU affinity settings for the driver "
  87. "Default is 0 for no affinity of request and response IO. "
  88. "Set it to 1 to turn on the cpu affinity.");
  89. /*
  90. * SCSI host template entry points
  91. */
  92. static int qla2xxx_slave_configure(struct scsi_device * device);
  93. static int qla2xxx_slave_alloc(struct scsi_device *);
  94. static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time);
  95. static void qla2xxx_scan_start(struct Scsi_Host *);
  96. static void qla2xxx_slave_destroy(struct scsi_device *);
  97. static int qla2xxx_queuecommand(struct scsi_cmnd *cmd,
  98. void (*fn)(struct scsi_cmnd *));
  99. static int qla2xxx_eh_abort(struct scsi_cmnd *);
  100. static int qla2xxx_eh_device_reset(struct scsi_cmnd *);
  101. static int qla2xxx_eh_target_reset(struct scsi_cmnd *);
  102. static int qla2xxx_eh_bus_reset(struct scsi_cmnd *);
  103. static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
  104. static int qla2x00_change_queue_depth(struct scsi_device *, int);
  105. static int qla2x00_change_queue_type(struct scsi_device *, int);
  106. struct scsi_host_template qla2xxx_driver_template = {
  107. .module = THIS_MODULE,
  108. .name = QLA2XXX_DRIVER_NAME,
  109. .queuecommand = qla2xxx_queuecommand,
  110. .eh_abort_handler = qla2xxx_eh_abort,
  111. .eh_device_reset_handler = qla2xxx_eh_device_reset,
  112. .eh_target_reset_handler = qla2xxx_eh_target_reset,
  113. .eh_bus_reset_handler = qla2xxx_eh_bus_reset,
  114. .eh_host_reset_handler = qla2xxx_eh_host_reset,
  115. .slave_configure = qla2xxx_slave_configure,
  116. .slave_alloc = qla2xxx_slave_alloc,
  117. .slave_destroy = qla2xxx_slave_destroy,
  118. .scan_finished = qla2xxx_scan_finished,
  119. .scan_start = qla2xxx_scan_start,
  120. .change_queue_depth = qla2x00_change_queue_depth,
  121. .change_queue_type = qla2x00_change_queue_type,
  122. .this_id = -1,
  123. .cmd_per_lun = 3,
  124. .use_clustering = ENABLE_CLUSTERING,
  125. .sg_tablesize = SG_ALL,
  126. .max_sectors = 0xFFFF,
  127. .shost_attrs = qla2x00_host_attrs,
  128. };
  129. static struct scsi_transport_template *qla2xxx_transport_template = NULL;
  130. struct scsi_transport_template *qla2xxx_transport_vport_template = NULL;
  131. /* TODO Convert to inlines
  132. *
  133. * Timer routines
  134. */
  135. __inline__ void
  136. qla2x00_start_timer(scsi_qla_host_t *vha, void *func, unsigned long interval)
  137. {
  138. init_timer(&vha->timer);
  139. vha->timer.expires = jiffies + interval * HZ;
  140. vha->timer.data = (unsigned long)vha;
  141. vha->timer.function = (void (*)(unsigned long))func;
  142. add_timer(&vha->timer);
  143. vha->timer_active = 1;
  144. }
  145. static inline void
  146. qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval)
  147. {
  148. mod_timer(&vha->timer, jiffies + interval * HZ);
  149. }
  150. static __inline__ void
  151. qla2x00_stop_timer(scsi_qla_host_t *vha)
  152. {
  153. del_timer_sync(&vha->timer);
  154. vha->timer_active = 0;
  155. }
  156. static int qla2x00_do_dpc(void *data);
  157. static void qla2x00_rst_aen(scsi_qla_host_t *);
  158. static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t,
  159. struct req_que **, struct rsp_que **);
  160. static void qla2x00_mem_free(struct qla_hw_data *);
  161. static void qla2x00_sp_free_dma(srb_t *);
  162. /* -------------------------------------------------------------------------- */
  163. static int qla2x00_alloc_queues(struct qla_hw_data *ha)
  164. {
  165. ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_req_queues,
  166. GFP_KERNEL);
  167. if (!ha->req_q_map) {
  168. qla_printk(KERN_WARNING, ha,
  169. "Unable to allocate memory for request queue ptrs\n");
  170. goto fail_req_map;
  171. }
  172. ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_rsp_queues,
  173. GFP_KERNEL);
  174. if (!ha->rsp_q_map) {
  175. qla_printk(KERN_WARNING, ha,
  176. "Unable to allocate memory for response queue ptrs\n");
  177. goto fail_rsp_map;
  178. }
  179. set_bit(0, ha->rsp_qid_map);
  180. set_bit(0, ha->req_qid_map);
  181. return 1;
  182. fail_rsp_map:
  183. kfree(ha->req_q_map);
  184. ha->req_q_map = NULL;
  185. fail_req_map:
  186. return -ENOMEM;
  187. }
  188. static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req)
  189. {
  190. if (req && req->ring)
  191. dma_free_coherent(&ha->pdev->dev,
  192. (req->length + 1) * sizeof(request_t),
  193. req->ring, req->dma);
  194. kfree(req);
  195. req = NULL;
  196. }
  197. static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
  198. {
  199. if (rsp && rsp->ring)
  200. dma_free_coherent(&ha->pdev->dev,
  201. (rsp->length + 1) * sizeof(response_t),
  202. rsp->ring, rsp->dma);
  203. kfree(rsp);
  204. rsp = NULL;
  205. }
  206. static void qla2x00_free_queues(struct qla_hw_data *ha)
  207. {
  208. struct req_que *req;
  209. struct rsp_que *rsp;
  210. int cnt;
  211. for (cnt = 0; cnt < ha->max_req_queues; cnt++) {
  212. req = ha->req_q_map[cnt];
  213. qla2x00_free_req_que(ha, req);
  214. }
  215. kfree(ha->req_q_map);
  216. ha->req_q_map = NULL;
  217. for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) {
  218. rsp = ha->rsp_q_map[cnt];
  219. qla2x00_free_rsp_que(ha, rsp);
  220. }
  221. kfree(ha->rsp_q_map);
  222. ha->rsp_q_map = NULL;
  223. }
  224. static int qla25xx_setup_mode(struct scsi_qla_host *vha)
  225. {
  226. uint16_t options = 0;
  227. int ques, req, ret;
  228. struct qla_hw_data *ha = vha->hw;
  229. if (ql2xmultique_tag) {
  230. /* CPU affinity mode */
  231. ha->wq = create_workqueue("qla2xxx_wq");
  232. /* create a request queue for IO */
  233. options |= BIT_7;
  234. req = qla25xx_create_req_que(ha, options, 0, 0, -1,
  235. QLA_DEFAULT_QUE_QOS);
  236. if (!req) {
  237. qla_printk(KERN_WARNING, ha,
  238. "Can't create request queue\n");
  239. goto fail;
  240. }
  241. vha->req = ha->req_q_map[req];
  242. options |= BIT_1;
  243. for (ques = 1; ques < ha->max_rsp_queues; ques++) {
  244. ret = qla25xx_create_rsp_que(ha, options, 0, 0, req);
  245. if (!ret) {
  246. qla_printk(KERN_WARNING, ha,
  247. "Response Queue create failed\n");
  248. goto fail2;
  249. }
  250. }
  251. DEBUG2(qla_printk(KERN_INFO, ha,
  252. "CPU affinity mode enabled, no. of response"
  253. " queues:%d, no. of request queues:%d\n",
  254. ha->max_rsp_queues, ha->max_req_queues));
  255. }
  256. return 0;
  257. fail2:
  258. qla25xx_delete_queues(vha);
  259. fail:
  260. ha->mqenable = 0;
  261. return 1;
  262. }
  263. static char *
  264. qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str)
  265. {
  266. struct qla_hw_data *ha = vha->hw;
  267. static char *pci_bus_modes[] = {
  268. "33", "66", "100", "133",
  269. };
  270. uint16_t pci_bus;
  271. strcpy(str, "PCI");
  272. pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9;
  273. if (pci_bus) {
  274. strcat(str, "-X (");
  275. strcat(str, pci_bus_modes[pci_bus]);
  276. } else {
  277. pci_bus = (ha->pci_attr & BIT_8) >> 8;
  278. strcat(str, " (");
  279. strcat(str, pci_bus_modes[pci_bus]);
  280. }
  281. strcat(str, " MHz)");
  282. return (str);
  283. }
  284. static char *
  285. qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str)
  286. {
  287. static char *pci_bus_modes[] = { "33", "66", "100", "133", };
  288. struct qla_hw_data *ha = vha->hw;
  289. uint32_t pci_bus;
  290. int pcie_reg;
  291. pcie_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP);
  292. if (pcie_reg) {
  293. char lwstr[6];
  294. uint16_t pcie_lstat, lspeed, lwidth;
  295. pcie_reg += 0x12;
  296. pci_read_config_word(ha->pdev, pcie_reg, &pcie_lstat);
  297. lspeed = pcie_lstat & (BIT_0 | BIT_1 | BIT_2 | BIT_3);
  298. lwidth = (pcie_lstat &
  299. (BIT_4 | BIT_5 | BIT_6 | BIT_7 | BIT_8 | BIT_9)) >> 4;
  300. strcpy(str, "PCIe (");
  301. if (lspeed == 1)
  302. strcat(str, "2.5GT/s ");
  303. else if (lspeed == 2)
  304. strcat(str, "5.0GT/s ");
  305. else
  306. strcat(str, "<unknown> ");
  307. snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth);
  308. strcat(str, lwstr);
  309. return str;
  310. }
  311. strcpy(str, "PCI");
  312. pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8;
  313. if (pci_bus == 0 || pci_bus == 8) {
  314. strcat(str, " (");
  315. strcat(str, pci_bus_modes[pci_bus >> 3]);
  316. } else {
  317. strcat(str, "-X ");
  318. if (pci_bus & BIT_2)
  319. strcat(str, "Mode 2");
  320. else
  321. strcat(str, "Mode 1");
  322. strcat(str, " (");
  323. strcat(str, pci_bus_modes[pci_bus & ~BIT_2]);
  324. }
  325. strcat(str, " MHz)");
  326. return str;
  327. }
  328. static char *
  329. qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str)
  330. {
  331. char un_str[10];
  332. struct qla_hw_data *ha = vha->hw;
  333. sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
  334. ha->fw_minor_version,
  335. ha->fw_subminor_version);
  336. if (ha->fw_attributes & BIT_9) {
  337. strcat(str, "FLX");
  338. return (str);
  339. }
  340. switch (ha->fw_attributes & 0xFF) {
  341. case 0x7:
  342. strcat(str, "EF");
  343. break;
  344. case 0x17:
  345. strcat(str, "TP");
  346. break;
  347. case 0x37:
  348. strcat(str, "IP");
  349. break;
  350. case 0x77:
  351. strcat(str, "VI");
  352. break;
  353. default:
  354. sprintf(un_str, "(%x)", ha->fw_attributes);
  355. strcat(str, un_str);
  356. break;
  357. }
  358. if (ha->fw_attributes & 0x100)
  359. strcat(str, "X");
  360. return (str);
  361. }
  362. static char *
  363. qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str)
  364. {
  365. struct qla_hw_data *ha = vha->hw;
  366. sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version,
  367. ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes);
  368. return str;
  369. }
  370. static inline srb_t *
  371. qla2x00_get_new_sp(scsi_qla_host_t *vha, fc_port_t *fcport,
  372. struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
  373. {
  374. srb_t *sp;
  375. struct qla_hw_data *ha = vha->hw;
  376. sp = mempool_alloc(ha->srb_mempool, GFP_ATOMIC);
  377. if (!sp)
  378. return sp;
  379. sp->fcport = fcport;
  380. sp->cmd = cmd;
  381. sp->flags = 0;
  382. CMD_SP(cmd) = (void *)sp;
  383. cmd->scsi_done = done;
  384. return sp;
  385. }
  386. static int
  387. qla2xxx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
  388. {
  389. scsi_qla_host_t *vha = shost_priv(cmd->device->host);
  390. fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
  391. struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device));
  392. struct qla_hw_data *ha = vha->hw;
  393. struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  394. srb_t *sp;
  395. int rval;
  396. if (unlikely(pci_channel_offline(ha->pdev))) {
  397. if (ha->pdev->error_state == pci_channel_io_frozen)
  398. cmd->result = DID_REQUEUE << 16;
  399. else
  400. cmd->result = DID_NO_CONNECT << 16;
  401. goto qc24_fail_command;
  402. }
  403. rval = fc_remote_port_chkready(rport);
  404. if (rval) {
  405. cmd->result = rval;
  406. goto qc24_fail_command;
  407. }
  408. /* Close window on fcport/rport state-transitioning. */
  409. if (fcport->drport)
  410. goto qc24_target_busy;
  411. if (atomic_read(&fcport->state) != FCS_ONLINE) {
  412. if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
  413. atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
  414. cmd->result = DID_NO_CONNECT << 16;
  415. goto qc24_fail_command;
  416. }
  417. goto qc24_target_busy;
  418. }
  419. spin_unlock_irq(vha->host->host_lock);
  420. sp = qla2x00_get_new_sp(base_vha, fcport, cmd, done);
  421. if (!sp)
  422. goto qc24_host_busy_lock;
  423. rval = ha->isp_ops->start_scsi(sp);
  424. if (rval != QLA_SUCCESS)
  425. goto qc24_host_busy_free_sp;
  426. spin_lock_irq(vha->host->host_lock);
  427. return 0;
  428. qc24_host_busy_free_sp:
  429. qla2x00_sp_free_dma(sp);
  430. mempool_free(sp, ha->srb_mempool);
  431. qc24_host_busy_lock:
  432. spin_lock_irq(vha->host->host_lock);
  433. return SCSI_MLQUEUE_HOST_BUSY;
  434. qc24_target_busy:
  435. return SCSI_MLQUEUE_TARGET_BUSY;
  436. qc24_fail_command:
  437. done(cmd);
  438. return 0;
  439. }
  440. /*
  441. * qla2x00_eh_wait_on_command
  442. * Waits for the command to be returned by the Firmware for some
  443. * max time.
  444. *
  445. * Input:
  446. * cmd = Scsi Command to wait on.
  447. *
  448. * Return:
  449. * Not Found : 0
  450. * Found : 1
  451. */
  452. static int
  453. qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
  454. {
  455. #define ABORT_POLLING_PERIOD 1000
  456. #define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD))
  457. unsigned long wait_iter = ABORT_WAIT_ITER;
  458. int ret = QLA_SUCCESS;
  459. while (CMD_SP(cmd)) {
  460. msleep(ABORT_POLLING_PERIOD);
  461. if (--wait_iter)
  462. break;
  463. }
  464. if (CMD_SP(cmd))
  465. ret = QLA_FUNCTION_FAILED;
  466. return ret;
  467. }
  468. /*
  469. * qla2x00_wait_for_hba_online
  470. * Wait till the HBA is online after going through
  471. * <= MAX_RETRIES_OF_ISP_ABORT or
  472. * finally HBA is disabled ie marked offline
  473. *
  474. * Input:
  475. * ha - pointer to host adapter structure
  476. *
  477. * Note:
  478. * Does context switching-Release SPIN_LOCK
  479. * (if any) before calling this routine.
  480. *
  481. * Return:
  482. * Success (Adapter is online) : 0
  483. * Failed (Adapter is offline/disabled) : 1
  484. */
  485. int
  486. qla2x00_wait_for_hba_online(scsi_qla_host_t *vha)
  487. {
  488. int return_status;
  489. unsigned long wait_online;
  490. struct qla_hw_data *ha = vha->hw;
  491. scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
  492. wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ);
  493. while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) ||
  494. test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
  495. test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
  496. ha->dpc_active) && time_before(jiffies, wait_online)) {
  497. msleep(1000);
  498. }
  499. if (base_vha->flags.online)
  500. return_status = QLA_SUCCESS;
  501. else
  502. return_status = QLA_FUNCTION_FAILED;
  503. return (return_status);
  504. }
  505. int
  506. qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha)
  507. {
  508. int return_status;
  509. unsigned long wait_reset;
  510. struct qla_hw_data *ha = vha->hw;
  511. scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
  512. wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ);
  513. while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) ||
  514. test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
  515. test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
  516. ha->dpc_active) && time_before(jiffies, wait_reset)) {
  517. msleep(1000);
  518. if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) &&
  519. ha->flags.chip_reset_done)
  520. break;
  521. }
  522. if (ha->flags.chip_reset_done)
  523. return_status = QLA_SUCCESS;
  524. else
  525. return_status = QLA_FUNCTION_FAILED;
  526. return return_status;
  527. }
  528. /*
  529. * qla2x00_wait_for_loop_ready
  530. * Wait for MAX_LOOP_TIMEOUT(5 min) value for loop
  531. * to be in LOOP_READY state.
  532. * Input:
  533. * ha - pointer to host adapter structure
  534. *
  535. * Note:
  536. * Does context switching-Release SPIN_LOCK
  537. * (if any) before calling this routine.
  538. *
  539. *
  540. * Return:
  541. * Success (LOOP_READY) : 0
  542. * Failed (LOOP_NOT_READY) : 1
  543. */
  544. static inline int
  545. qla2x00_wait_for_loop_ready(scsi_qla_host_t *vha)
  546. {
  547. int return_status = QLA_SUCCESS;
  548. unsigned long loop_timeout ;
  549. struct qla_hw_data *ha = vha->hw;
  550. scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
  551. /* wait for 5 min at the max for loop to be ready */
  552. loop_timeout = jiffies + (MAX_LOOP_TIMEOUT * HZ);
  553. while ((!atomic_read(&base_vha->loop_down_timer) &&
  554. atomic_read(&base_vha->loop_state) == LOOP_DOWN) ||
  555. atomic_read(&base_vha->loop_state) != LOOP_READY) {
  556. if (atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
  557. return_status = QLA_FUNCTION_FAILED;
  558. break;
  559. }
  560. msleep(1000);
  561. if (time_after_eq(jiffies, loop_timeout)) {
  562. return_status = QLA_FUNCTION_FAILED;
  563. break;
  564. }
  565. }
  566. return (return_status);
  567. }
  568. void
  569. qla2x00_abort_fcport_cmds(fc_port_t *fcport)
  570. {
  571. int cnt;
  572. unsigned long flags;
  573. srb_t *sp;
  574. scsi_qla_host_t *vha = fcport->vha;
  575. struct qla_hw_data *ha = vha->hw;
  576. struct req_que *req;
  577. spin_lock_irqsave(&ha->hardware_lock, flags);
  578. req = vha->req;
  579. for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
  580. sp = req->outstanding_cmds[cnt];
  581. if (!sp)
  582. continue;
  583. if (sp->fcport != fcport)
  584. continue;
  585. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  586. if (ha->isp_ops->abort_command(sp)) {
  587. DEBUG2(qla_printk(KERN_WARNING, ha,
  588. "Abort failed -- %lx\n",
  589. sp->cmd->serial_number));
  590. } else {
  591. if (qla2x00_eh_wait_on_command(sp->cmd) !=
  592. QLA_SUCCESS)
  593. DEBUG2(qla_printk(KERN_WARNING, ha,
  594. "Abort failed while waiting -- %lx\n",
  595. sp->cmd->serial_number));
  596. }
  597. spin_lock_irqsave(&ha->hardware_lock, flags);
  598. }
  599. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  600. }
  601. static void
  602. qla2x00_block_error_handler(struct scsi_cmnd *cmnd)
  603. {
  604. struct Scsi_Host *shost = cmnd->device->host;
  605. struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
  606. unsigned long flags;
  607. spin_lock_irqsave(shost->host_lock, flags);
  608. while (rport->port_state == FC_PORTSTATE_BLOCKED) {
  609. spin_unlock_irqrestore(shost->host_lock, flags);
  610. msleep(1000);
  611. spin_lock_irqsave(shost->host_lock, flags);
  612. }
  613. spin_unlock_irqrestore(shost->host_lock, flags);
  614. return;
  615. }
  616. /**************************************************************************
  617. * qla2xxx_eh_abort
  618. *
  619. * Description:
  620. * The abort function will abort the specified command.
  621. *
  622. * Input:
  623. * cmd = Linux SCSI command packet to be aborted.
  624. *
  625. * Returns:
  626. * Either SUCCESS or FAILED.
  627. *
  628. * Note:
  629. * Only return FAILED if command not returned by firmware.
  630. **************************************************************************/
  631. static int
  632. qla2xxx_eh_abort(struct scsi_cmnd *cmd)
  633. {
  634. scsi_qla_host_t *vha = shost_priv(cmd->device->host);
  635. srb_t *sp;
  636. int ret, i;
  637. unsigned int id, lun;
  638. unsigned long serial;
  639. unsigned long flags;
  640. int wait = 0;
  641. struct qla_hw_data *ha = vha->hw;
  642. struct req_que *req = vha->req;
  643. srb_t *spt;
  644. qla2x00_block_error_handler(cmd);
  645. if (!CMD_SP(cmd))
  646. return SUCCESS;
  647. ret = SUCCESS;
  648. id = cmd->device->id;
  649. lun = cmd->device->lun;
  650. serial = cmd->serial_number;
  651. spt = (srb_t *) CMD_SP(cmd);
  652. if (!spt)
  653. return SUCCESS;
  654. /* Check active list for command command. */
  655. spin_lock_irqsave(&ha->hardware_lock, flags);
  656. for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
  657. sp = req->outstanding_cmds[i];
  658. if (sp == NULL)
  659. continue;
  660. if (sp->cmd != cmd)
  661. continue;
  662. DEBUG2(printk("%s(%ld): aborting sp %p from RISC."
  663. " pid=%ld.\n", __func__, vha->host_no, sp, serial));
  664. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  665. if (ha->isp_ops->abort_command(sp)) {
  666. DEBUG2(printk("%s(%ld): abort_command "
  667. "mbx failed.\n", __func__, vha->host_no));
  668. ret = FAILED;
  669. } else {
  670. DEBUG3(printk("%s(%ld): abort_command "
  671. "mbx success.\n", __func__, vha->host_no));
  672. wait = 1;
  673. }
  674. spin_lock_irqsave(&ha->hardware_lock, flags);
  675. break;
  676. }
  677. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  678. /* Wait for the command to be returned. */
  679. if (wait) {
  680. if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) {
  681. qla_printk(KERN_ERR, ha,
  682. "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
  683. "%x.\n", vha->host_no, id, lun, serial, ret);
  684. ret = FAILED;
  685. }
  686. }
  687. qla_printk(KERN_INFO, ha,
  688. "scsi(%ld:%d:%d): Abort command issued -- %d %lx %x.\n",
  689. vha->host_no, id, lun, wait, serial, ret);
  690. return ret;
  691. }
  692. enum nexus_wait_type {
  693. WAIT_HOST = 0,
  694. WAIT_TARGET,
  695. WAIT_LUN,
  696. };
  697. static int
  698. qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
  699. unsigned int l, srb_t *sp, enum nexus_wait_type type)
  700. {
  701. int cnt, match, status;
  702. unsigned long flags;
  703. struct qla_hw_data *ha = vha->hw;
  704. struct req_que *req;
  705. status = QLA_SUCCESS;
  706. if (!sp)
  707. return status;
  708. spin_lock_irqsave(&ha->hardware_lock, flags);
  709. req = vha->req;
  710. for (cnt = 1; status == QLA_SUCCESS &&
  711. cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
  712. sp = req->outstanding_cmds[cnt];
  713. if (!sp)
  714. continue;
  715. if (vha->vp_idx != sp->fcport->vha->vp_idx)
  716. continue;
  717. match = 0;
  718. switch (type) {
  719. case WAIT_HOST:
  720. match = 1;
  721. break;
  722. case WAIT_TARGET:
  723. match = sp->cmd->device->id == t;
  724. break;
  725. case WAIT_LUN:
  726. match = (sp->cmd->device->id == t &&
  727. sp->cmd->device->lun == l);
  728. break;
  729. }
  730. if (!match)
  731. continue;
  732. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  733. status = qla2x00_eh_wait_on_command(sp->cmd);
  734. spin_lock_irqsave(&ha->hardware_lock, flags);
  735. }
  736. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  737. return status;
  738. }
  739. static char *reset_errors[] = {
  740. "HBA not online",
  741. "HBA not ready",
  742. "Task management failed",
  743. "Waiting for command completions",
  744. };
  745. static int
  746. __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type,
  747. struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int, int))
  748. {
  749. scsi_qla_host_t *vha = shost_priv(cmd->device->host);
  750. fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
  751. int err;
  752. qla2x00_block_error_handler(cmd);
  753. if (!fcport)
  754. return FAILED;
  755. qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET ISSUED.\n",
  756. vha->host_no, cmd->device->id, cmd->device->lun, name);
  757. err = 0;
  758. if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
  759. goto eh_reset_failed;
  760. err = 1;
  761. if (qla2x00_wait_for_loop_ready(vha) != QLA_SUCCESS)
  762. goto eh_reset_failed;
  763. err = 2;
  764. if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1)
  765. != QLA_SUCCESS)
  766. goto eh_reset_failed;
  767. err = 3;
  768. if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id,
  769. cmd->device->lun, (srb_t *) CMD_SP(cmd), type) != QLA_SUCCESS)
  770. goto eh_reset_failed;
  771. qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET SUCCEEDED.\n",
  772. vha->host_no, cmd->device->id, cmd->device->lun, name);
  773. return SUCCESS;
  774. eh_reset_failed:
  775. qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET FAILED: %s.\n"
  776. , vha->host_no, cmd->device->id, cmd->device->lun, name,
  777. reset_errors[err]);
  778. return FAILED;
  779. }
  780. static int
  781. qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
  782. {
  783. scsi_qla_host_t *vha = shost_priv(cmd->device->host);
  784. struct qla_hw_data *ha = vha->hw;
  785. return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd,
  786. ha->isp_ops->lun_reset);
  787. }
  788. static int
  789. qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
  790. {
  791. scsi_qla_host_t *vha = shost_priv(cmd->device->host);
  792. struct qla_hw_data *ha = vha->hw;
  793. return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd,
  794. ha->isp_ops->target_reset);
  795. }
  796. /**************************************************************************
  797. * qla2xxx_eh_bus_reset
  798. *
  799. * Description:
  800. * The bus reset function will reset the bus and abort any executing
  801. * commands.
  802. *
  803. * Input:
  804. * cmd = Linux SCSI command packet of the command that cause the
  805. * bus reset.
  806. *
  807. * Returns:
  808. * SUCCESS/FAILURE (defined as macro in scsi.h).
  809. *
  810. **************************************************************************/
  811. static int
  812. qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
  813. {
  814. scsi_qla_host_t *vha = shost_priv(cmd->device->host);
  815. fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
  816. int ret = FAILED;
  817. unsigned int id, lun;
  818. unsigned long serial;
  819. srb_t *sp = (srb_t *) CMD_SP(cmd);
  820. qla2x00_block_error_handler(cmd);
  821. id = cmd->device->id;
  822. lun = cmd->device->lun;
  823. serial = cmd->serial_number;
  824. if (!fcport)
  825. return ret;
  826. qla_printk(KERN_INFO, vha->hw,
  827. "scsi(%ld:%d:%d): BUS RESET ISSUED.\n", vha->host_no, id, lun);
  828. if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
  829. DEBUG2(printk("%s failed:board disabled\n",__func__));
  830. goto eh_bus_reset_done;
  831. }
  832. if (qla2x00_wait_for_loop_ready(vha) == QLA_SUCCESS) {
  833. if (qla2x00_loop_reset(vha) == QLA_SUCCESS)
  834. ret = SUCCESS;
  835. }
  836. if (ret == FAILED)
  837. goto eh_bus_reset_done;
  838. /* Flush outstanding commands. */
  839. if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) !=
  840. QLA_SUCCESS)
  841. ret = FAILED;
  842. eh_bus_reset_done:
  843. qla_printk(KERN_INFO, vha->hw, "%s: reset %s\n", __func__,
  844. (ret == FAILED) ? "failed" : "succeded");
  845. return ret;
  846. }
  847. /**************************************************************************
  848. * qla2xxx_eh_host_reset
  849. *
  850. * Description:
  851. * The reset function will reset the Adapter.
  852. *
  853. * Input:
  854. * cmd = Linux SCSI command packet of the command that cause the
  855. * adapter reset.
  856. *
  857. * Returns:
  858. * Either SUCCESS or FAILED.
  859. *
  860. * Note:
  861. **************************************************************************/
  862. static int
  863. qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
  864. {
  865. scsi_qla_host_t *vha = shost_priv(cmd->device->host);
  866. fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
  867. struct qla_hw_data *ha = vha->hw;
  868. int ret = FAILED;
  869. unsigned int id, lun;
  870. unsigned long serial;
  871. srb_t *sp = (srb_t *) CMD_SP(cmd);
  872. scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
  873. qla2x00_block_error_handler(cmd);
  874. id = cmd->device->id;
  875. lun = cmd->device->lun;
  876. serial = cmd->serial_number;
  877. if (!fcport)
  878. return ret;
  879. qla_printk(KERN_INFO, ha,
  880. "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", vha->host_no, id, lun);
  881. if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
  882. goto eh_host_reset_lock;
  883. /*
  884. * Fixme-may be dpc thread is active and processing
  885. * loop_resync,so wait a while for it to
  886. * be completed and then issue big hammer.Otherwise
  887. * it may cause I/O failure as big hammer marks the
  888. * devices as lost kicking of the port_down_timer
  889. * while dpc is stuck for the mailbox to complete.
  890. */
  891. qla2x00_wait_for_loop_ready(vha);
  892. if (vha != base_vha) {
  893. if (qla2x00_vp_abort_isp(vha))
  894. goto eh_host_reset_lock;
  895. } else {
  896. if (ha->wq)
  897. flush_workqueue(ha->wq);
  898. set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
  899. if (qla2x00_abort_isp(base_vha)) {
  900. clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
  901. /* failed. schedule dpc to try */
  902. set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
  903. if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
  904. goto eh_host_reset_lock;
  905. }
  906. clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
  907. }
  908. /* Waiting for command to be returned to OS.*/
  909. if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) ==
  910. QLA_SUCCESS)
  911. ret = SUCCESS;
  912. eh_host_reset_lock:
  913. qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
  914. (ret == FAILED) ? "failed" : "succeded");
  915. return ret;
  916. }
  917. /*
  918. * qla2x00_loop_reset
  919. * Issue loop reset.
  920. *
  921. * Input:
  922. * ha = adapter block pointer.
  923. *
  924. * Returns:
  925. * 0 = success
  926. */
  927. int
  928. qla2x00_loop_reset(scsi_qla_host_t *vha)
  929. {
  930. int ret;
  931. struct fc_port *fcport;
  932. struct qla_hw_data *ha = vha->hw;
  933. if (ha->flags.enable_lip_full_login && !vha->vp_idx &&
  934. !IS_QLA81XX(ha)) {
  935. ret = qla2x00_full_login_lip(vha);
  936. if (ret != QLA_SUCCESS) {
  937. DEBUG2_3(printk("%s(%ld): failed: "
  938. "full_login_lip=%d.\n", __func__, vha->host_no,
  939. ret));
  940. }
  941. atomic_set(&vha->loop_state, LOOP_DOWN);
  942. atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
  943. qla2x00_mark_all_devices_lost(vha, 0);
  944. qla2x00_wait_for_loop_ready(vha);
  945. }
  946. if (ha->flags.enable_lip_reset && !vha->vp_idx) {
  947. ret = qla2x00_lip_reset(vha);
  948. if (ret != QLA_SUCCESS) {
  949. DEBUG2_3(printk("%s(%ld): failed: "
  950. "lip_reset=%d.\n", __func__, vha->host_no, ret));
  951. } else
  952. qla2x00_wait_for_loop_ready(vha);
  953. }
  954. if (ha->flags.enable_target_reset) {
  955. list_for_each_entry(fcport, &vha->vp_fcports, list) {
  956. if (fcport->port_type != FCT_TARGET)
  957. continue;
  958. ret = ha->isp_ops->target_reset(fcport, 0, 0);
  959. if (ret != QLA_SUCCESS) {
  960. DEBUG2_3(printk("%s(%ld): bus_reset failed: "
  961. "target_reset=%d d_id=%x.\n", __func__,
  962. vha->host_no, ret, fcport->d_id.b24));
  963. }
  964. }
  965. }
  966. /* Issue marker command only when we are going to start the I/O */
  967. vha->marker_needed = 1;
  968. return QLA_SUCCESS;
  969. }
  970. void
  971. qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
  972. {
  973. int que, cnt;
  974. unsigned long flags;
  975. srb_t *sp;
  976. struct qla_hw_data *ha = vha->hw;
  977. struct req_que *req;
  978. spin_lock_irqsave(&ha->hardware_lock, flags);
  979. for (que = 0; que < ha->max_req_queues; que++) {
  980. req = ha->req_q_map[que];
  981. if (!req)
  982. continue;
  983. for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
  984. sp = req->outstanding_cmds[cnt];
  985. if (sp) {
  986. req->outstanding_cmds[cnt] = NULL;
  987. sp->cmd->result = res;
  988. qla2x00_sp_compl(ha, sp);
  989. }
  990. }
  991. }
  992. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  993. }
  994. static int
  995. qla2xxx_slave_alloc(struct scsi_device *sdev)
  996. {
  997. struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
  998. if (!rport || fc_remote_port_chkready(rport))
  999. return -ENXIO;
  1000. sdev->hostdata = *(fc_port_t **)rport->dd_data;
  1001. return 0;
  1002. }
  1003. static int
  1004. qla2xxx_slave_configure(struct scsi_device *sdev)
  1005. {
  1006. scsi_qla_host_t *vha = shost_priv(sdev->host);
  1007. struct qla_hw_data *ha = vha->hw;
  1008. struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
  1009. struct req_que *req = vha->req;
  1010. if (sdev->tagged_supported)
  1011. scsi_activate_tcq(sdev, req->max_q_depth);
  1012. else
  1013. scsi_deactivate_tcq(sdev, req->max_q_depth);
  1014. rport->dev_loss_tmo = ha->port_down_retry_count;
  1015. return 0;
  1016. }
  1017. static void
  1018. qla2xxx_slave_destroy(struct scsi_device *sdev)
  1019. {
  1020. sdev->hostdata = NULL;
  1021. }
  1022. static int
  1023. qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth)
  1024. {
  1025. scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
  1026. return sdev->queue_depth;
  1027. }
  1028. static int
  1029. qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type)
  1030. {
  1031. if (sdev->tagged_supported) {
  1032. scsi_set_tag_type(sdev, tag_type);
  1033. if (tag_type)
  1034. scsi_activate_tcq(sdev, sdev->queue_depth);
  1035. else
  1036. scsi_deactivate_tcq(sdev, sdev->queue_depth);
  1037. } else
  1038. tag_type = 0;
  1039. return tag_type;
  1040. }
  1041. /**
  1042. * qla2x00_config_dma_addressing() - Configure OS DMA addressing method.
  1043. * @ha: HA context
  1044. *
  1045. * At exit, the @ha's flags.enable_64bit_addressing set to indicated
  1046. * supported addressing method.
  1047. */
  1048. static void
  1049. qla2x00_config_dma_addressing(struct qla_hw_data *ha)
  1050. {
  1051. /* Assume a 32bit DMA mask. */
  1052. ha->flags.enable_64bit_addressing = 0;
  1053. if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) {
  1054. /* Any upper-dword bits set? */
  1055. if (MSD(dma_get_required_mask(&ha->pdev->dev)) &&
  1056. !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
  1057. /* Ok, a 64bit DMA mask is applicable. */
  1058. ha->flags.enable_64bit_addressing = 1;
  1059. ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
  1060. ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
  1061. return;
  1062. }
  1063. }
  1064. dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32));
  1065. pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32));
  1066. }
  1067. static void
  1068. qla2x00_enable_intrs(struct qla_hw_data *ha)
  1069. {
  1070. unsigned long flags = 0;
  1071. struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
  1072. spin_lock_irqsave(&ha->hardware_lock, flags);
  1073. ha->interrupts_on = 1;
  1074. /* enable risc and host interrupts */
  1075. WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
  1076. RD_REG_WORD(&reg->ictrl);
  1077. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1078. }
  1079. static void
  1080. qla2x00_disable_intrs(struct qla_hw_data *ha)
  1081. {
  1082. unsigned long flags = 0;
  1083. struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
  1084. spin_lock_irqsave(&ha->hardware_lock, flags);
  1085. ha->interrupts_on = 0;
  1086. /* disable risc and host interrupts */
  1087. WRT_REG_WORD(&reg->ictrl, 0);
  1088. RD_REG_WORD(&reg->ictrl);
  1089. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1090. }
  1091. static void
  1092. qla24xx_enable_intrs(struct qla_hw_data *ha)
  1093. {
  1094. unsigned long flags = 0;
  1095. struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
  1096. spin_lock_irqsave(&ha->hardware_lock, flags);
  1097. ha->interrupts_on = 1;
  1098. WRT_REG_DWORD(&reg->ictrl, ICRX_EN_RISC_INT);
  1099. RD_REG_DWORD(&reg->ictrl);
  1100. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1101. }
  1102. static void
  1103. qla24xx_disable_intrs(struct qla_hw_data *ha)
  1104. {
  1105. unsigned long flags = 0;
  1106. struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
  1107. if (IS_NOPOLLING_TYPE(ha))
  1108. return;
  1109. spin_lock_irqsave(&ha->hardware_lock, flags);
  1110. ha->interrupts_on = 0;
  1111. WRT_REG_DWORD(&reg->ictrl, 0);
  1112. RD_REG_DWORD(&reg->ictrl);
  1113. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1114. }
  1115. static struct isp_operations qla2100_isp_ops = {
  1116. .pci_config = qla2100_pci_config,
  1117. .reset_chip = qla2x00_reset_chip,
  1118. .chip_diag = qla2x00_chip_diag,
  1119. .config_rings = qla2x00_config_rings,
  1120. .reset_adapter = qla2x00_reset_adapter,
  1121. .nvram_config = qla2x00_nvram_config,
  1122. .update_fw_options = qla2x00_update_fw_options,
  1123. .load_risc = qla2x00_load_risc,
  1124. .pci_info_str = qla2x00_pci_info_str,
  1125. .fw_version_str = qla2x00_fw_version_str,
  1126. .intr_handler = qla2100_intr_handler,
  1127. .enable_intrs = qla2x00_enable_intrs,
  1128. .disable_intrs = qla2x00_disable_intrs,
  1129. .abort_command = qla2x00_abort_command,
  1130. .target_reset = qla2x00_abort_target,
  1131. .lun_reset = qla2x00_lun_reset,
  1132. .fabric_login = qla2x00_login_fabric,
  1133. .fabric_logout = qla2x00_fabric_logout,
  1134. .calc_req_entries = qla2x00_calc_iocbs_32,
  1135. .build_iocbs = qla2x00_build_scsi_iocbs_32,
  1136. .prep_ms_iocb = qla2x00_prep_ms_iocb,
  1137. .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
  1138. .read_nvram = qla2x00_read_nvram_data,
  1139. .write_nvram = qla2x00_write_nvram_data,
  1140. .fw_dump = qla2100_fw_dump,
  1141. .beacon_on = NULL,
  1142. .beacon_off = NULL,
  1143. .beacon_blink = NULL,
  1144. .read_optrom = qla2x00_read_optrom_data,
  1145. .write_optrom = qla2x00_write_optrom_data,
  1146. .get_flash_version = qla2x00_get_flash_version,
  1147. .start_scsi = qla2x00_start_scsi,
  1148. };
  1149. static struct isp_operations qla2300_isp_ops = {
  1150. .pci_config = qla2300_pci_config,
  1151. .reset_chip = qla2x00_reset_chip,
  1152. .chip_diag = qla2x00_chip_diag,
  1153. .config_rings = qla2x00_config_rings,
  1154. .reset_adapter = qla2x00_reset_adapter,
  1155. .nvram_config = qla2x00_nvram_config,
  1156. .update_fw_options = qla2x00_update_fw_options,
  1157. .load_risc = qla2x00_load_risc,
  1158. .pci_info_str = qla2x00_pci_info_str,
  1159. .fw_version_str = qla2x00_fw_version_str,
  1160. .intr_handler = qla2300_intr_handler,
  1161. .enable_intrs = qla2x00_enable_intrs,
  1162. .disable_intrs = qla2x00_disable_intrs,
  1163. .abort_command = qla2x00_abort_command,
  1164. .target_reset = qla2x00_abort_target,
  1165. .lun_reset = qla2x00_lun_reset,
  1166. .fabric_login = qla2x00_login_fabric,
  1167. .fabric_logout = qla2x00_fabric_logout,
  1168. .calc_req_entries = qla2x00_calc_iocbs_32,
  1169. .build_iocbs = qla2x00_build_scsi_iocbs_32,
  1170. .prep_ms_iocb = qla2x00_prep_ms_iocb,
  1171. .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
  1172. .read_nvram = qla2x00_read_nvram_data,
  1173. .write_nvram = qla2x00_write_nvram_data,
  1174. .fw_dump = qla2300_fw_dump,
  1175. .beacon_on = qla2x00_beacon_on,
  1176. .beacon_off = qla2x00_beacon_off,
  1177. .beacon_blink = qla2x00_beacon_blink,
  1178. .read_optrom = qla2x00_read_optrom_data,
  1179. .write_optrom = qla2x00_write_optrom_data,
  1180. .get_flash_version = qla2x00_get_flash_version,
  1181. .start_scsi = qla2x00_start_scsi,
  1182. };
  1183. static struct isp_operations qla24xx_isp_ops = {
  1184. .pci_config = qla24xx_pci_config,
  1185. .reset_chip = qla24xx_reset_chip,
  1186. .chip_diag = qla24xx_chip_diag,
  1187. .config_rings = qla24xx_config_rings,
  1188. .reset_adapter = qla24xx_reset_adapter,
  1189. .nvram_config = qla24xx_nvram_config,
  1190. .update_fw_options = qla24xx_update_fw_options,
  1191. .load_risc = qla24xx_load_risc,
  1192. .pci_info_str = qla24xx_pci_info_str,
  1193. .fw_version_str = qla24xx_fw_version_str,
  1194. .intr_handler = qla24xx_intr_handler,
  1195. .enable_intrs = qla24xx_enable_intrs,
  1196. .disable_intrs = qla24xx_disable_intrs,
  1197. .abort_command = qla24xx_abort_command,
  1198. .target_reset = qla24xx_abort_target,
  1199. .lun_reset = qla24xx_lun_reset,
  1200. .fabric_login = qla24xx_login_fabric,
  1201. .fabric_logout = qla24xx_fabric_logout,
  1202. .calc_req_entries = NULL,
  1203. .build_iocbs = NULL,
  1204. .prep_ms_iocb = qla24xx_prep_ms_iocb,
  1205. .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
  1206. .read_nvram = qla24xx_read_nvram_data,
  1207. .write_nvram = qla24xx_write_nvram_data,
  1208. .fw_dump = qla24xx_fw_dump,
  1209. .beacon_on = qla24xx_beacon_on,
  1210. .beacon_off = qla24xx_beacon_off,
  1211. .beacon_blink = qla24xx_beacon_blink,
  1212. .read_optrom = qla24xx_read_optrom_data,
  1213. .write_optrom = qla24xx_write_optrom_data,
  1214. .get_flash_version = qla24xx_get_flash_version,
  1215. .start_scsi = qla24xx_start_scsi,
  1216. };
  1217. static struct isp_operations qla25xx_isp_ops = {
  1218. .pci_config = qla25xx_pci_config,
  1219. .reset_chip = qla24xx_reset_chip,
  1220. .chip_diag = qla24xx_chip_diag,
  1221. .config_rings = qla24xx_config_rings,
  1222. .reset_adapter = qla24xx_reset_adapter,
  1223. .nvram_config = qla24xx_nvram_config,
  1224. .update_fw_options = qla24xx_update_fw_options,
  1225. .load_risc = qla24xx_load_risc,
  1226. .pci_info_str = qla24xx_pci_info_str,
  1227. .fw_version_str = qla24xx_fw_version_str,
  1228. .intr_handler = qla24xx_intr_handler,
  1229. .enable_intrs = qla24xx_enable_intrs,
  1230. .disable_intrs = qla24xx_disable_intrs,
  1231. .abort_command = qla24xx_abort_command,
  1232. .target_reset = qla24xx_abort_target,
  1233. .lun_reset = qla24xx_lun_reset,
  1234. .fabric_login = qla24xx_login_fabric,
  1235. .fabric_logout = qla24xx_fabric_logout,
  1236. .calc_req_entries = NULL,
  1237. .build_iocbs = NULL,
  1238. .prep_ms_iocb = qla24xx_prep_ms_iocb,
  1239. .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
  1240. .read_nvram = qla25xx_read_nvram_data,
  1241. .write_nvram = qla25xx_write_nvram_data,
  1242. .fw_dump = qla25xx_fw_dump,
  1243. .beacon_on = qla24xx_beacon_on,
  1244. .beacon_off = qla24xx_beacon_off,
  1245. .beacon_blink = qla24xx_beacon_blink,
  1246. .read_optrom = qla25xx_read_optrom_data,
  1247. .write_optrom = qla24xx_write_optrom_data,
  1248. .get_flash_version = qla24xx_get_flash_version,
  1249. .start_scsi = qla24xx_start_scsi,
  1250. };
  1251. static struct isp_operations qla81xx_isp_ops = {
  1252. .pci_config = qla25xx_pci_config,
  1253. .reset_chip = qla24xx_reset_chip,
  1254. .chip_diag = qla24xx_chip_diag,
  1255. .config_rings = qla24xx_config_rings,
  1256. .reset_adapter = qla24xx_reset_adapter,
  1257. .nvram_config = qla81xx_nvram_config,
  1258. .update_fw_options = qla81xx_update_fw_options,
  1259. .load_risc = qla81xx_load_risc,
  1260. .pci_info_str = qla24xx_pci_info_str,
  1261. .fw_version_str = qla24xx_fw_version_str,
  1262. .intr_handler = qla24xx_intr_handler,
  1263. .enable_intrs = qla24xx_enable_intrs,
  1264. .disable_intrs = qla24xx_disable_intrs,
  1265. .abort_command = qla24xx_abort_command,
  1266. .target_reset = qla24xx_abort_target,
  1267. .lun_reset = qla24xx_lun_reset,
  1268. .fabric_login = qla24xx_login_fabric,
  1269. .fabric_logout = qla24xx_fabric_logout,
  1270. .calc_req_entries = NULL,
  1271. .build_iocbs = NULL,
  1272. .prep_ms_iocb = qla24xx_prep_ms_iocb,
  1273. .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
  1274. .read_nvram = NULL,
  1275. .write_nvram = NULL,
  1276. .fw_dump = qla81xx_fw_dump,
  1277. .beacon_on = qla24xx_beacon_on,
  1278. .beacon_off = qla24xx_beacon_off,
  1279. .beacon_blink = qla24xx_beacon_blink,
  1280. .read_optrom = qla25xx_read_optrom_data,
  1281. .write_optrom = qla24xx_write_optrom_data,
  1282. .get_flash_version = qla24xx_get_flash_version,
  1283. .start_scsi = qla24xx_start_scsi,
  1284. };
  1285. static inline void
  1286. qla2x00_set_isp_flags(struct qla_hw_data *ha)
  1287. {
  1288. ha->device_type = DT_EXTENDED_IDS;
  1289. switch (ha->pdev->device) {
  1290. case PCI_DEVICE_ID_QLOGIC_ISP2100:
  1291. ha->device_type |= DT_ISP2100;
  1292. ha->device_type &= ~DT_EXTENDED_IDS;
  1293. ha->fw_srisc_address = RISC_START_ADDRESS_2100;
  1294. break;
  1295. case PCI_DEVICE_ID_QLOGIC_ISP2200:
  1296. ha->device_type |= DT_ISP2200;
  1297. ha->device_type &= ~DT_EXTENDED_IDS;
  1298. ha->fw_srisc_address = RISC_START_ADDRESS_2100;
  1299. break;
  1300. case PCI_DEVICE_ID_QLOGIC_ISP2300:
  1301. ha->device_type |= DT_ISP2300;
  1302. ha->device_type |= DT_ZIO_SUPPORTED;
  1303. ha->fw_srisc_address = RISC_START_ADDRESS_2300;
  1304. break;
  1305. case PCI_DEVICE_ID_QLOGIC_ISP2312:
  1306. ha->device_type |= DT_ISP2312;
  1307. ha->device_type |= DT_ZIO_SUPPORTED;
  1308. ha->fw_srisc_address = RISC_START_ADDRESS_2300;
  1309. break;
  1310. case PCI_DEVICE_ID_QLOGIC_ISP2322:
  1311. ha->device_type |= DT_ISP2322;
  1312. ha->device_type |= DT_ZIO_SUPPORTED;
  1313. if (ha->pdev->subsystem_vendor == 0x1028 &&
  1314. ha->pdev->subsystem_device == 0x0170)
  1315. ha->device_type |= DT_OEM_001;
  1316. ha->fw_srisc_address = RISC_START_ADDRESS_2300;
  1317. break;
  1318. case PCI_DEVICE_ID_QLOGIC_ISP6312:
  1319. ha->device_type |= DT_ISP6312;
  1320. ha->fw_srisc_address = RISC_START_ADDRESS_2300;
  1321. break;
  1322. case PCI_DEVICE_ID_QLOGIC_ISP6322:
  1323. ha->device_type |= DT_ISP6322;
  1324. ha->fw_srisc_address = RISC_START_ADDRESS_2300;
  1325. break;
  1326. case PCI_DEVICE_ID_QLOGIC_ISP2422:
  1327. ha->device_type |= DT_ISP2422;
  1328. ha->device_type |= DT_ZIO_SUPPORTED;
  1329. ha->device_type |= DT_FWI2;
  1330. ha->device_type |= DT_IIDMA;
  1331. ha->fw_srisc_address = RISC_START_ADDRESS_2400;
  1332. break;
  1333. case PCI_DEVICE_ID_QLOGIC_ISP2432:
  1334. ha->device_type |= DT_ISP2432;
  1335. ha->device_type |= DT_ZIO_SUPPORTED;
  1336. ha->device_type |= DT_FWI2;
  1337. ha->device_type |= DT_IIDMA;
  1338. ha->fw_srisc_address = RISC_START_ADDRESS_2400;
  1339. break;
  1340. case PCI_DEVICE_ID_QLOGIC_ISP8432:
  1341. ha->device_type |= DT_ISP8432;
  1342. ha->device_type |= DT_ZIO_SUPPORTED;
  1343. ha->device_type |= DT_FWI2;
  1344. ha->device_type |= DT_IIDMA;
  1345. ha->fw_srisc_address = RISC_START_ADDRESS_2400;
  1346. break;
  1347. case PCI_DEVICE_ID_QLOGIC_ISP5422:
  1348. ha->device_type |= DT_ISP5422;
  1349. ha->device_type |= DT_FWI2;
  1350. ha->fw_srisc_address = RISC_START_ADDRESS_2400;
  1351. break;
  1352. case PCI_DEVICE_ID_QLOGIC_ISP5432:
  1353. ha->device_type |= DT_ISP5432;
  1354. ha->device_type |= DT_FWI2;
  1355. ha->fw_srisc_address = RISC_START_ADDRESS_2400;
  1356. break;
  1357. case PCI_DEVICE_ID_QLOGIC_ISP2532:
  1358. ha->device_type |= DT_ISP2532;
  1359. ha->device_type |= DT_ZIO_SUPPORTED;
  1360. ha->device_type |= DT_FWI2;
  1361. ha->device_type |= DT_IIDMA;
  1362. ha->fw_srisc_address = RISC_START_ADDRESS_2400;
  1363. break;
  1364. case PCI_DEVICE_ID_QLOGIC_ISP8001:
  1365. ha->device_type |= DT_ISP8001;
  1366. ha->device_type |= DT_ZIO_SUPPORTED;
  1367. ha->device_type |= DT_FWI2;
  1368. ha->device_type |= DT_IIDMA;
  1369. ha->fw_srisc_address = RISC_START_ADDRESS_2400;
  1370. break;
  1371. }
  1372. }
  1373. static int
  1374. qla2x00_iospace_config(struct qla_hw_data *ha)
  1375. {
  1376. resource_size_t pio;
  1377. uint16_t msix;
  1378. int cpus;
  1379. if (pci_request_selected_regions(ha->pdev, ha->bars,
  1380. QLA2XXX_DRIVER_NAME)) {
  1381. qla_printk(KERN_WARNING, ha,
  1382. "Failed to reserve PIO/MMIO regions (%s)\n",
  1383. pci_name(ha->pdev));
  1384. goto iospace_error_exit;
  1385. }
  1386. if (!(ha->bars & 1))
  1387. goto skip_pio;
  1388. /* We only need PIO for Flash operations on ISP2312 v2 chips. */
  1389. pio = pci_resource_start(ha->pdev, 0);
  1390. if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) {
  1391. if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) {
  1392. qla_printk(KERN_WARNING, ha,
  1393. "Invalid PCI I/O region size (%s)...\n",
  1394. pci_name(ha->pdev));
  1395. pio = 0;
  1396. }
  1397. } else {
  1398. qla_printk(KERN_WARNING, ha,
  1399. "region #0 not a PIO resource (%s)...\n",
  1400. pci_name(ha->pdev));
  1401. pio = 0;
  1402. }
  1403. ha->pio_address = pio;
  1404. skip_pio:
  1405. /* Use MMIO operations for all accesses. */
  1406. if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) {
  1407. qla_printk(KERN_ERR, ha,
  1408. "region #1 not an MMIO resource (%s), aborting\n",
  1409. pci_name(ha->pdev));
  1410. goto iospace_error_exit;
  1411. }
  1412. if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) {
  1413. qla_printk(KERN_ERR, ha,
  1414. "Invalid PCI mem region size (%s), aborting\n",
  1415. pci_name(ha->pdev));
  1416. goto iospace_error_exit;
  1417. }
  1418. ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN);
  1419. if (!ha->iobase) {
  1420. qla_printk(KERN_ERR, ha,
  1421. "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev));
  1422. goto iospace_error_exit;
  1423. }
  1424. /* Determine queue resources */
  1425. ha->max_req_queues = ha->max_rsp_queues = 1;
  1426. if ((ql2xmaxqueues <= 1 || ql2xmultique_tag < 1) &&
  1427. (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
  1428. goto mqiobase_exit;
  1429. ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3),
  1430. pci_resource_len(ha->pdev, 3));
  1431. if (ha->mqiobase) {
  1432. /* Read MSIX vector size of the board */
  1433. pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix);
  1434. ha->msix_count = msix;
  1435. /* Max queues are bounded by available msix vectors */
  1436. /* queue 0 uses two msix vectors */
  1437. if (ql2xmultique_tag) {
  1438. cpus = num_online_cpus();
  1439. ha->max_rsp_queues = (ha->msix_count - 1 - cpus) ?
  1440. (cpus + 1) : (ha->msix_count - 1);
  1441. ha->max_req_queues = 2;
  1442. } else if (ql2xmaxqueues > 1) {
  1443. ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ?
  1444. QLA_MQ_SIZE : ql2xmaxqueues;
  1445. DEBUG2(qla_printk(KERN_INFO, ha, "QoS mode set, max no"
  1446. " of request queues:%d\n", ha->max_req_queues));
  1447. }
  1448. qla_printk(KERN_INFO, ha,
  1449. "MSI-X vector count: %d\n", msix);
  1450. } else
  1451. qla_printk(KERN_INFO, ha, "BAR 3 not enabled\n");
  1452. mqiobase_exit:
  1453. ha->msix_count = ha->max_rsp_queues + 1;
  1454. return (0);
  1455. iospace_error_exit:
  1456. return (-ENOMEM);
  1457. }
  1458. static void
  1459. qla2xxx_scan_start(struct Scsi_Host *shost)
  1460. {
  1461. scsi_qla_host_t *vha = shost_priv(shost);
  1462. set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
  1463. set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
  1464. set_bit(RSCN_UPDATE, &vha->dpc_flags);
  1465. set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags);
  1466. }
  1467. static int
  1468. qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time)
  1469. {
  1470. scsi_qla_host_t *vha = shost_priv(shost);
  1471. if (!vha->host)
  1472. return 1;
  1473. if (time > vha->hw->loop_reset_delay * HZ)
  1474. return 1;
  1475. return atomic_read(&vha->loop_state) == LOOP_READY;
  1476. }
  1477. /*
  1478. * PCI driver interface
  1479. */
  1480. static int __devinit
  1481. qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
  1482. {
  1483. int ret = -ENODEV;
  1484. struct Scsi_Host *host;
  1485. scsi_qla_host_t *base_vha = NULL;
  1486. struct qla_hw_data *ha;
  1487. char pci_info[30];
  1488. char fw_str[30];
  1489. struct scsi_host_template *sht;
  1490. int bars, max_id, mem_only = 0;
  1491. uint16_t req_length = 0, rsp_length = 0;
  1492. struct req_que *req = NULL;
  1493. struct rsp_que *rsp = NULL;
  1494. bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
  1495. sht = &qla2xxx_driver_template;
  1496. if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 ||
  1497. pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 ||
  1498. pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 ||
  1499. pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 ||
  1500. pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 ||
  1501. pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 ||
  1502. pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001) {
  1503. bars = pci_select_bars(pdev, IORESOURCE_MEM);
  1504. mem_only = 1;
  1505. }
  1506. if (mem_only) {
  1507. if (pci_enable_device_mem(pdev))
  1508. goto probe_out;
  1509. } else {
  1510. if (pci_enable_device(pdev))
  1511. goto probe_out;
  1512. }
  1513. /* This may fail but that's ok */
  1514. pci_enable_pcie_error_reporting(pdev);
  1515. ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL);
  1516. if (!ha) {
  1517. DEBUG(printk("Unable to allocate memory for ha\n"));
  1518. goto probe_out;
  1519. }
  1520. ha->pdev = pdev;
  1521. /* Clear our data area */
  1522. ha->bars = bars;
  1523. ha->mem_only = mem_only;
  1524. spin_lock_init(&ha->hardware_lock);
  1525. /* Set ISP-type information. */
  1526. qla2x00_set_isp_flags(ha);
  1527. /* Configure PCI I/O space */
  1528. ret = qla2x00_iospace_config(ha);
  1529. if (ret)
  1530. goto probe_hw_failed;
  1531. qla_printk(KERN_INFO, ha,
  1532. "Found an ISP%04X, irq %d, iobase 0x%p\n", pdev->device, pdev->irq,
  1533. ha->iobase);
  1534. ha->prev_topology = 0;
  1535. ha->init_cb_size = sizeof(init_cb_t);
  1536. ha->link_data_rate = PORT_SPEED_UNKNOWN;
  1537. ha->optrom_size = OPTROM_SIZE_2300;
  1538. /* Assign ISP specific operations. */
  1539. max_id = MAX_TARGETS_2200;
  1540. if (IS_QLA2100(ha)) {
  1541. max_id = MAX_TARGETS_2100;
  1542. ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
  1543. req_length = REQUEST_ENTRY_CNT_2100;
  1544. rsp_length = RESPONSE_ENTRY_CNT_2100;
  1545. ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
  1546. ha->gid_list_info_size = 4;
  1547. ha->flash_conf_off = ~0;
  1548. ha->flash_data_off = ~0;
  1549. ha->nvram_conf_off = ~0;
  1550. ha->nvram_data_off = ~0;
  1551. ha->isp_ops = &qla2100_isp_ops;
  1552. } else if (IS_QLA2200(ha)) {
  1553. ha->mbx_count = MAILBOX_REGISTER_COUNT;
  1554. req_length = REQUEST_ENTRY_CNT_2200;
  1555. rsp_length = RESPONSE_ENTRY_CNT_2100;
  1556. ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
  1557. ha->gid_list_info_size = 4;
  1558. ha->flash_conf_off = ~0;
  1559. ha->flash_data_off = ~0;
  1560. ha->nvram_conf_off = ~0;
  1561. ha->nvram_data_off = ~0;
  1562. ha->isp_ops = &qla2100_isp_ops;
  1563. } else if (IS_QLA23XX(ha)) {
  1564. ha->mbx_count = MAILBOX_REGISTER_COUNT;
  1565. req_length = REQUEST_ENTRY_CNT_2200;
  1566. rsp_length = RESPONSE_ENTRY_CNT_2300;
  1567. ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
  1568. ha->gid_list_info_size = 6;
  1569. if (IS_QLA2322(ha) || IS_QLA6322(ha))
  1570. ha->optrom_size = OPTROM_SIZE_2322;
  1571. ha->flash_conf_off = ~0;
  1572. ha->flash_data_off = ~0;
  1573. ha->nvram_conf_off = ~0;
  1574. ha->nvram_data_off = ~0;
  1575. ha->isp_ops = &qla2300_isp_ops;
  1576. } else if (IS_QLA24XX_TYPE(ha)) {
  1577. ha->mbx_count = MAILBOX_REGISTER_COUNT;
  1578. req_length = REQUEST_ENTRY_CNT_24XX;
  1579. rsp_length = RESPONSE_ENTRY_CNT_2300;
  1580. ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
  1581. ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
  1582. ha->gid_list_info_size = 8;
  1583. ha->optrom_size = OPTROM_SIZE_24XX;
  1584. ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX;
  1585. ha->isp_ops = &qla24xx_isp_ops;
  1586. ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
  1587. ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
  1588. ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
  1589. ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
  1590. } else if (IS_QLA25XX(ha)) {
  1591. ha->mbx_count = MAILBOX_REGISTER_COUNT;
  1592. req_length = REQUEST_ENTRY_CNT_24XX;
  1593. rsp_length = RESPONSE_ENTRY_CNT_2300;
  1594. ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
  1595. ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
  1596. ha->gid_list_info_size = 8;
  1597. ha->optrom_size = OPTROM_SIZE_25XX;
  1598. ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX;
  1599. ha->isp_ops = &qla25xx_isp_ops;
  1600. ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
  1601. ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
  1602. ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
  1603. ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
  1604. } else if (IS_QLA81XX(ha)) {
  1605. ha->mbx_count = MAILBOX_REGISTER_COUNT;
  1606. req_length = REQUEST_ENTRY_CNT_24XX;
  1607. rsp_length = RESPONSE_ENTRY_CNT_2300;
  1608. ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
  1609. ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
  1610. ha->gid_list_info_size = 8;
  1611. ha->optrom_size = OPTROM_SIZE_81XX;
  1612. ha->isp_ops = &qla81xx_isp_ops;
  1613. ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX;
  1614. ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX;
  1615. ha->nvram_conf_off = ~0;
  1616. ha->nvram_data_off = ~0;
  1617. }
  1618. mutex_init(&ha->vport_lock);
  1619. init_completion(&ha->mbx_cmd_comp);
  1620. complete(&ha->mbx_cmd_comp);
  1621. init_completion(&ha->mbx_intr_comp);
  1622. set_bit(0, (unsigned long *) ha->vp_idx_map);
  1623. qla2x00_config_dma_addressing(ha);
  1624. ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp);
  1625. if (!ret) {
  1626. qla_printk(KERN_WARNING, ha,
  1627. "[ERROR] Failed to allocate memory for adapter\n");
  1628. goto probe_hw_failed;
  1629. }
  1630. req->max_q_depth = MAX_Q_DEPTH;
  1631. if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU)
  1632. req->max_q_depth = ql2xmaxqdepth;
  1633. base_vha = qla2x00_create_host(sht, ha);
  1634. if (!base_vha) {
  1635. qla_printk(KERN_WARNING, ha,
  1636. "[ERROR] Failed to allocate memory for scsi_host\n");
  1637. ret = -ENOMEM;
  1638. qla2x00_mem_free(ha);
  1639. qla2x00_free_req_que(ha, req);
  1640. qla2x00_free_rsp_que(ha, rsp);
  1641. goto probe_hw_failed;
  1642. }
  1643. pci_set_drvdata(pdev, base_vha);
  1644. host = base_vha->host;
  1645. base_vha->req = req;
  1646. host->can_queue = req->length + 128;
  1647. if (IS_QLA2XXX_MIDTYPE(ha))
  1648. base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx;
  1649. else
  1650. base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER +
  1651. base_vha->vp_idx;
  1652. if (IS_QLA2100(ha))
  1653. host->sg_tablesize = 32;
  1654. host->max_id = max_id;
  1655. host->this_id = 255;
  1656. host->cmd_per_lun = 3;
  1657. host->unique_id = host->host_no;
  1658. host->max_cmd_len = MAX_CMDSZ;
  1659. host->max_channel = MAX_BUSES - 1;
  1660. host->max_lun = MAX_LUNS;
  1661. host->transportt = qla2xxx_transport_template;
  1662. /* Set up the irqs */
  1663. ret = qla2x00_request_irqs(ha, rsp);
  1664. if (ret)
  1665. goto probe_init_failed;
  1666. /* Alloc arrays of request and response ring ptrs */
  1667. if (!qla2x00_alloc_queues(ha)) {
  1668. qla_printk(KERN_WARNING, ha,
  1669. "[ERROR] Failed to allocate memory for queue"
  1670. " pointers\n");
  1671. goto probe_init_failed;
  1672. }
  1673. ha->rsp_q_map[0] = rsp;
  1674. ha->req_q_map[0] = req;
  1675. rsp->req = req;
  1676. req->rsp = rsp;
  1677. set_bit(0, ha->req_qid_map);
  1678. set_bit(0, ha->rsp_qid_map);
  1679. /* FWI2-capable only. */
  1680. req->req_q_in = &ha->iobase->isp24.req_q_in;
  1681. req->req_q_out = &ha->iobase->isp24.req_q_out;
  1682. rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in;
  1683. rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out;
  1684. if (ha->mqenable) {
  1685. req->req_q_in = &ha->mqiobase->isp25mq.req_q_in;
  1686. req->req_q_out = &ha->mqiobase->isp25mq.req_q_out;
  1687. rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in;
  1688. rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out;
  1689. }
  1690. if (qla2x00_initialize_adapter(base_vha)) {
  1691. qla_printk(KERN_WARNING, ha,
  1692. "Failed to initialize adapter\n");
  1693. DEBUG2(printk("scsi(%ld): Failed to initialize adapter - "
  1694. "Adapter flags %x.\n",
  1695. base_vha->host_no, base_vha->device_flags));
  1696. ret = -ENODEV;
  1697. goto probe_failed;
  1698. }
  1699. if (ha->mqenable)
  1700. if (qla25xx_setup_mode(base_vha))
  1701. qla_printk(KERN_WARNING, ha,
  1702. "Can't create queues, falling back to single"
  1703. " queue mode\n");
  1704. /*
  1705. * Startup the kernel thread for this host adapter
  1706. */
  1707. ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha,
  1708. "%s_dpc", base_vha->host_str);
  1709. if (IS_ERR(ha->dpc_thread)) {
  1710. qla_printk(KERN_WARNING, ha,
  1711. "Unable to start DPC thread!\n");
  1712. ret = PTR_ERR(ha->dpc_thread);
  1713. goto probe_failed;
  1714. }
  1715. list_add_tail(&base_vha->list, &ha->vp_list);
  1716. base_vha->host->irq = ha->pdev->irq;
  1717. /* Initialized the timer */
  1718. qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL);
  1719. DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n",
  1720. base_vha->host_no, ha));
  1721. base_vha->flags.init_done = 1;
  1722. base_vha->flags.online = 1;
  1723. ret = scsi_add_host(host, &pdev->dev);
  1724. if (ret)
  1725. goto probe_failed;
  1726. ha->isp_ops->enable_intrs(ha);
  1727. scsi_scan_host(host);
  1728. qla2x00_alloc_sysfs_attr(base_vha);
  1729. qla2x00_init_host_attr(base_vha);
  1730. qla2x00_dfs_setup(base_vha);
  1731. qla_printk(KERN_INFO, ha, "\n"
  1732. " QLogic Fibre Channel HBA Driver: %s\n"
  1733. " QLogic %s - %s\n"
  1734. " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n",
  1735. qla2x00_version_str, ha->model_number,
  1736. ha->model_desc ? ha->model_desc : "", pdev->device,
  1737. ha->isp_ops->pci_info_str(base_vha, pci_info), pci_name(pdev),
  1738. ha->flags.enable_64bit_addressing ? '+' : '-', base_vha->host_no,
  1739. ha->isp_ops->fw_version_str(base_vha, fw_str));
  1740. return 0;
  1741. probe_init_failed:
  1742. qla2x00_free_req_que(ha, req);
  1743. qla2x00_free_rsp_que(ha, rsp);
  1744. ha->max_req_queues = ha->max_rsp_queues = 0;
  1745. probe_failed:
  1746. if (base_vha->timer_active)
  1747. qla2x00_stop_timer(base_vha);
  1748. base_vha->flags.online = 0;
  1749. if (ha->dpc_thread) {
  1750. struct task_struct *t = ha->dpc_thread;
  1751. ha->dpc_thread = NULL;
  1752. kthread_stop(t);
  1753. }
  1754. qla2x00_free_device(base_vha);
  1755. scsi_host_put(base_vha->host);
  1756. probe_hw_failed:
  1757. if (ha->iobase)
  1758. iounmap(ha->iobase);
  1759. pci_release_selected_regions(ha->pdev, ha->bars);
  1760. kfree(ha);
  1761. ha = NULL;
  1762. probe_out:
  1763. pci_disable_device(pdev);
  1764. return ret;
  1765. }
  1766. static void
  1767. qla2x00_remove_one(struct pci_dev *pdev)
  1768. {
  1769. scsi_qla_host_t *base_vha, *vha, *temp;
  1770. struct qla_hw_data *ha;
  1771. base_vha = pci_get_drvdata(pdev);
  1772. ha = base_vha->hw;
  1773. list_for_each_entry_safe(vha, temp, &ha->vp_list, list) {
  1774. if (vha && vha->fc_vport)
  1775. fc_vport_terminate(vha->fc_vport);
  1776. }
  1777. set_bit(UNLOADING, &base_vha->dpc_flags);
  1778. qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16);
  1779. qla2x00_dfs_remove(base_vha);
  1780. qla84xx_put_chip(base_vha);
  1781. /* Disable timer */
  1782. if (base_vha->timer_active)
  1783. qla2x00_stop_timer(base_vha);
  1784. base_vha->flags.online = 0;
  1785. /* Flush the work queue and remove it */
  1786. if (ha->wq) {
  1787. flush_workqueue(ha->wq);
  1788. destroy_workqueue(ha->wq);
  1789. ha->wq = NULL;
  1790. }
  1791. /* Kill the kernel thread for this host */
  1792. if (ha->dpc_thread) {
  1793. struct task_struct *t = ha->dpc_thread;
  1794. /*
  1795. * qla2xxx_wake_dpc checks for ->dpc_thread
  1796. * so we need to zero it out.
  1797. */
  1798. ha->dpc_thread = NULL;
  1799. kthread_stop(t);
  1800. }
  1801. qla2x00_free_sysfs_attr(base_vha);
  1802. fc_remove_host(base_vha->host);
  1803. scsi_remove_host(base_vha->host);
  1804. qla2x00_free_device(base_vha);
  1805. scsi_host_put(base_vha->host);
  1806. if (ha->iobase)
  1807. iounmap(ha->iobase);
  1808. if (ha->mqiobase)
  1809. iounmap(ha->mqiobase);
  1810. pci_release_selected_regions(ha->pdev, ha->bars);
  1811. kfree(ha);
  1812. ha = NULL;
  1813. pci_disable_device(pdev);
  1814. pci_set_drvdata(pdev, NULL);
  1815. }
  1816. static void
  1817. qla2x00_free_device(scsi_qla_host_t *vha)
  1818. {
  1819. struct qla_hw_data *ha = vha->hw;
  1820. qla25xx_delete_queues(vha);
  1821. if (ha->flags.fce_enabled)
  1822. qla2x00_disable_fce_trace(vha, NULL, NULL);
  1823. if (ha->eft)
  1824. qla2x00_disable_eft_trace(vha);
  1825. /* Stop currently executing firmware. */
  1826. qla2x00_try_to_stop_firmware(vha);
  1827. /* turn-off interrupts on the card */
  1828. if (ha->interrupts_on)
  1829. ha->isp_ops->disable_intrs(ha);
  1830. qla2x00_free_irqs(vha);
  1831. qla2x00_mem_free(ha);
  1832. qla2x00_free_queues(ha);
  1833. }
  1834. static inline void
  1835. qla2x00_schedule_rport_del(struct scsi_qla_host *vha, fc_port_t *fcport,
  1836. int defer)
  1837. {
  1838. struct fc_rport *rport;
  1839. if (!fcport->rport)
  1840. return;
  1841. rport = fcport->rport;
  1842. if (defer) {
  1843. spin_lock_irq(vha->host->host_lock);
  1844. fcport->drport = rport;
  1845. spin_unlock_irq(vha->host->host_lock);
  1846. set_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags);
  1847. qla2xxx_wake_dpc(vha);
  1848. } else
  1849. fc_remote_port_delete(rport);
  1850. }
  1851. /*
  1852. * qla2x00_mark_device_lost Updates fcport state when device goes offline.
  1853. *
  1854. * Input: ha = adapter block pointer. fcport = port structure pointer.
  1855. *
  1856. * Return: None.
  1857. *
  1858. * Context:
  1859. */
  1860. void qla2x00_mark_device_lost(scsi_qla_host_t *vha, fc_port_t *fcport,
  1861. int do_login, int defer)
  1862. {
  1863. if (atomic_read(&fcport->state) == FCS_ONLINE &&
  1864. vha->vp_idx == fcport->vp_idx) {
  1865. atomic_set(&fcport->state, FCS_DEVICE_LOST);
  1866. qla2x00_schedule_rport_del(vha, fcport, defer);
  1867. }
  1868. /*
  1869. * We may need to retry the login, so don't change the state of the
  1870. * port but do the retries.
  1871. */
  1872. if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD)
  1873. atomic_set(&fcport->state, FCS_DEVICE_LOST);
  1874. if (!do_login)
  1875. return;
  1876. if (fcport->login_retry == 0) {
  1877. fcport->login_retry = vha->hw->login_retry_count;
  1878. set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
  1879. DEBUG(printk("scsi(%ld): Port login retry: "
  1880. "%02x%02x%02x%02x%02x%02x%02x%02x, "
  1881. "id = 0x%04x retry cnt=%d\n",
  1882. vha->host_no,
  1883. fcport->port_name[0],
  1884. fcport->port_name[1],
  1885. fcport->port_name[2],
  1886. fcport->port_name[3],
  1887. fcport->port_name[4],
  1888. fcport->port_name[5],
  1889. fcport->port_name[6],
  1890. fcport->port_name[7],
  1891. fcport->loop_id,
  1892. fcport->login_retry));
  1893. }
  1894. }
  1895. /*
  1896. * qla2x00_mark_all_devices_lost
  1897. * Updates fcport state when device goes offline.
  1898. *
  1899. * Input:
  1900. * ha = adapter block pointer.
  1901. * fcport = port structure pointer.
  1902. *
  1903. * Return:
  1904. * None.
  1905. *
  1906. * Context:
  1907. */
  1908. void
  1909. qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer)
  1910. {
  1911. fc_port_t *fcport;
  1912. list_for_each_entry(fcport, &vha->vp_fcports, list) {
  1913. if (vha->vp_idx != fcport->vp_idx)
  1914. continue;
  1915. /*
  1916. * No point in marking the device as lost, if the device is
  1917. * already DEAD.
  1918. */
  1919. if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
  1920. continue;
  1921. if (atomic_read(&fcport->state) == FCS_ONLINE) {
  1922. atomic_set(&fcport->state, FCS_DEVICE_LOST);
  1923. qla2x00_schedule_rport_del(vha, fcport, defer);
  1924. } else
  1925. atomic_set(&fcport->state, FCS_DEVICE_LOST);
  1926. }
  1927. }
  1928. /*
  1929. * qla2x00_mem_alloc
  1930. * Allocates adapter memory.
  1931. *
  1932. * Returns:
  1933. * 0 = success.
  1934. * !0 = failure.
  1935. */
  1936. static int
  1937. qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
  1938. struct req_que **req, struct rsp_que **rsp)
  1939. {
  1940. char name[16];
  1941. ha->init_cb = dma_alloc_coherent(&ha->pdev->dev, ha->init_cb_size,
  1942. &ha->init_cb_dma, GFP_KERNEL);
  1943. if (!ha->init_cb)
  1944. goto fail;
  1945. ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, GID_LIST_SIZE,
  1946. &ha->gid_list_dma, GFP_KERNEL);
  1947. if (!ha->gid_list)
  1948. goto fail_free_init_cb;
  1949. ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep);
  1950. if (!ha->srb_mempool)
  1951. goto fail_free_gid_list;
  1952. /* Get memory for cached NVRAM */
  1953. ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL);
  1954. if (!ha->nvram)
  1955. goto fail_free_srb_mempool;
  1956. snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME,
  1957. ha->pdev->device);
  1958. ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev,
  1959. DMA_POOL_SIZE, 8, 0);
  1960. if (!ha->s_dma_pool)
  1961. goto fail_free_nvram;
  1962. /* Allocate memory for SNS commands */
  1963. if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
  1964. /* Get consistent memory allocated for SNS commands */
  1965. ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev,
  1966. sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL);
  1967. if (!ha->sns_cmd)
  1968. goto fail_dma_pool;
  1969. } else {
  1970. /* Get consistent memory allocated for MS IOCB */
  1971. ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
  1972. &ha->ms_iocb_dma);
  1973. if (!ha->ms_iocb)
  1974. goto fail_dma_pool;
  1975. /* Get consistent memory allocated for CT SNS commands */
  1976. ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev,
  1977. sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL);
  1978. if (!ha->ct_sns)
  1979. goto fail_free_ms_iocb;
  1980. }
  1981. /* Allocate memory for request ring */
  1982. *req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
  1983. if (!*req) {
  1984. DEBUG(printk("Unable to allocate memory for req\n"));
  1985. goto fail_req;
  1986. }
  1987. (*req)->length = req_len;
  1988. (*req)->ring = dma_alloc_coherent(&ha->pdev->dev,
  1989. ((*req)->length + 1) * sizeof(request_t),
  1990. &(*req)->dma, GFP_KERNEL);
  1991. if (!(*req)->ring) {
  1992. DEBUG(printk("Unable to allocate memory for req_ring\n"));
  1993. goto fail_req_ring;
  1994. }
  1995. /* Allocate memory for response ring */
  1996. *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
  1997. if (!*rsp) {
  1998. qla_printk(KERN_WARNING, ha,
  1999. "Unable to allocate memory for rsp\n");
  2000. goto fail_rsp;
  2001. }
  2002. (*rsp)->hw = ha;
  2003. (*rsp)->length = rsp_len;
  2004. (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev,
  2005. ((*rsp)->length + 1) * sizeof(response_t),
  2006. &(*rsp)->dma, GFP_KERNEL);
  2007. if (!(*rsp)->ring) {
  2008. qla_printk(KERN_WARNING, ha,
  2009. "Unable to allocate memory for rsp_ring\n");
  2010. goto fail_rsp_ring;
  2011. }
  2012. (*req)->rsp = *rsp;
  2013. (*rsp)->req = *req;
  2014. /* Allocate memory for NVRAM data for vports */
  2015. if (ha->nvram_npiv_size) {
  2016. ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) *
  2017. ha->nvram_npiv_size, GFP_KERNEL);
  2018. if (!ha->npiv_info) {
  2019. qla_printk(KERN_WARNING, ha,
  2020. "Unable to allocate memory for npiv info\n");
  2021. goto fail_npiv_info;
  2022. }
  2023. } else
  2024. ha->npiv_info = NULL;
  2025. /* Get consistent memory allocated for EX-INIT-CB. */
  2026. if (IS_QLA81XX(ha)) {
  2027. ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
  2028. &ha->ex_init_cb_dma);
  2029. if (!ha->ex_init_cb)
  2030. goto fail_ex_init_cb;
  2031. }
  2032. INIT_LIST_HEAD(&ha->vp_list);
  2033. return 1;
  2034. fail_ex_init_cb:
  2035. kfree(ha->npiv_info);
  2036. fail_npiv_info:
  2037. dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) *
  2038. sizeof(response_t), (*rsp)->ring, (*rsp)->dma);
  2039. (*rsp)->ring = NULL;
  2040. (*rsp)->dma = 0;
  2041. fail_rsp_ring:
  2042. kfree(*rsp);
  2043. fail_rsp:
  2044. dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) *
  2045. sizeof(request_t), (*req)->ring, (*req)->dma);
  2046. (*req)->ring = NULL;
  2047. (*req)->dma = 0;
  2048. fail_req_ring:
  2049. kfree(*req);
  2050. fail_req:
  2051. dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
  2052. ha->ct_sns, ha->ct_sns_dma);
  2053. ha->ct_sns = NULL;
  2054. ha->ct_sns_dma = 0;
  2055. fail_free_ms_iocb:
  2056. dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
  2057. ha->ms_iocb = NULL;
  2058. ha->ms_iocb_dma = 0;
  2059. fail_dma_pool:
  2060. dma_pool_destroy(ha->s_dma_pool);
  2061. ha->s_dma_pool = NULL;
  2062. fail_free_nvram:
  2063. kfree(ha->nvram);
  2064. ha->nvram = NULL;
  2065. fail_free_srb_mempool:
  2066. mempool_destroy(ha->srb_mempool);
  2067. ha->srb_mempool = NULL;
  2068. fail_free_gid_list:
  2069. dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
  2070. ha->gid_list_dma);
  2071. ha->gid_list = NULL;
  2072. ha->gid_list_dma = 0;
  2073. fail_free_init_cb:
  2074. dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb,
  2075. ha->init_cb_dma);
  2076. ha->init_cb = NULL;
  2077. ha->init_cb_dma = 0;
  2078. fail:
  2079. DEBUG(printk("%s: Memory allocation failure\n", __func__));
  2080. return -ENOMEM;
  2081. }
  2082. /*
  2083. * qla2x00_mem_free
  2084. * Frees all adapter allocated memory.
  2085. *
  2086. * Input:
  2087. * ha = adapter block pointer.
  2088. */
  2089. static void
  2090. qla2x00_mem_free(struct qla_hw_data *ha)
  2091. {
  2092. if (ha->srb_mempool)
  2093. mempool_destroy(ha->srb_mempool);
  2094. if (ha->fce)
  2095. dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce,
  2096. ha->fce_dma);
  2097. if (ha->fw_dump) {
  2098. if (ha->eft)
  2099. dma_free_coherent(&ha->pdev->dev,
  2100. ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma);
  2101. vfree(ha->fw_dump);
  2102. }
  2103. if (ha->sns_cmd)
  2104. dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt),
  2105. ha->sns_cmd, ha->sns_cmd_dma);
  2106. if (ha->ct_sns)
  2107. dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
  2108. ha->ct_sns, ha->ct_sns_dma);
  2109. if (ha->sfp_data)
  2110. dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma);
  2111. if (ha->edc_data)
  2112. dma_pool_free(ha->s_dma_pool, ha->edc_data, ha->edc_data_dma);
  2113. if (ha->ms_iocb)
  2114. dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
  2115. if (ha->ex_init_cb)
  2116. dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma);
  2117. if (ha->s_dma_pool)
  2118. dma_pool_destroy(ha->s_dma_pool);
  2119. if (ha->gid_list)
  2120. dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
  2121. ha->gid_list_dma);
  2122. if (ha->init_cb)
  2123. dma_free_coherent(&ha->pdev->dev, ha->init_cb_size,
  2124. ha->init_cb, ha->init_cb_dma);
  2125. vfree(ha->optrom_buffer);
  2126. kfree(ha->nvram);
  2127. kfree(ha->npiv_info);
  2128. ha->srb_mempool = NULL;
  2129. ha->eft = NULL;
  2130. ha->eft_dma = 0;
  2131. ha->sns_cmd = NULL;
  2132. ha->sns_cmd_dma = 0;
  2133. ha->ct_sns = NULL;
  2134. ha->ct_sns_dma = 0;
  2135. ha->ms_iocb = NULL;
  2136. ha->ms_iocb_dma = 0;
  2137. ha->init_cb = NULL;
  2138. ha->init_cb_dma = 0;
  2139. ha->ex_init_cb = NULL;
  2140. ha->ex_init_cb_dma = 0;
  2141. ha->s_dma_pool = NULL;
  2142. ha->gid_list = NULL;
  2143. ha->gid_list_dma = 0;
  2144. ha->fw_dump = NULL;
  2145. ha->fw_dumped = 0;
  2146. ha->fw_dump_reading = 0;
  2147. }
  2148. struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht,
  2149. struct qla_hw_data *ha)
  2150. {
  2151. struct Scsi_Host *host;
  2152. struct scsi_qla_host *vha = NULL;
  2153. host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t));
  2154. if (host == NULL) {
  2155. printk(KERN_WARNING
  2156. "qla2xxx: Couldn't allocate host from scsi layer!\n");
  2157. goto fail;
  2158. }
  2159. /* Clear our data area */
  2160. vha = shost_priv(host);
  2161. memset(vha, 0, sizeof(scsi_qla_host_t));
  2162. vha->host = host;
  2163. vha->host_no = host->host_no;
  2164. vha->hw = ha;
  2165. INIT_LIST_HEAD(&vha->vp_fcports);
  2166. INIT_LIST_HEAD(&vha->work_list);
  2167. INIT_LIST_HEAD(&vha->list);
  2168. sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no);
  2169. return vha;
  2170. fail:
  2171. return vha;
  2172. }
  2173. static struct qla_work_evt *
  2174. qla2x00_alloc_work(struct scsi_qla_host *vha, enum qla_work_type type,
  2175. int locked)
  2176. {
  2177. struct qla_work_evt *e;
  2178. e = kzalloc(sizeof(struct qla_work_evt), locked ? GFP_ATOMIC:
  2179. GFP_KERNEL);
  2180. if (!e)
  2181. return NULL;
  2182. INIT_LIST_HEAD(&e->list);
  2183. e->type = type;
  2184. e->flags = QLA_EVT_FLAG_FREE;
  2185. return e;
  2186. }
  2187. static int
  2188. qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e, int locked)
  2189. {
  2190. unsigned long uninitialized_var(flags);
  2191. struct qla_hw_data *ha = vha->hw;
  2192. if (!locked)
  2193. spin_lock_irqsave(&ha->hardware_lock, flags);
  2194. list_add_tail(&e->list, &vha->work_list);
  2195. qla2xxx_wake_dpc(vha);
  2196. if (!locked)
  2197. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  2198. return QLA_SUCCESS;
  2199. }
  2200. int
  2201. qla2x00_post_aen_work(struct scsi_qla_host *vha, enum fc_host_event_code code,
  2202. u32 data)
  2203. {
  2204. struct qla_work_evt *e;
  2205. e = qla2x00_alloc_work(vha, QLA_EVT_AEN, 1);
  2206. if (!e)
  2207. return QLA_FUNCTION_FAILED;
  2208. e->u.aen.code = code;
  2209. e->u.aen.data = data;
  2210. return qla2x00_post_work(vha, e, 1);
  2211. }
  2212. int
  2213. qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb)
  2214. {
  2215. struct qla_work_evt *e;
  2216. e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK, 1);
  2217. if (!e)
  2218. return QLA_FUNCTION_FAILED;
  2219. memcpy(e->u.idc_ack.mb, mb, QLA_IDC_ACK_REGS * sizeof(uint16_t));
  2220. return qla2x00_post_work(vha, e, 1);
  2221. }
  2222. static void
  2223. qla2x00_do_work(struct scsi_qla_host *vha)
  2224. {
  2225. struct qla_work_evt *e;
  2226. struct qla_hw_data *ha = vha->hw;
  2227. spin_lock_irq(&ha->hardware_lock);
  2228. while (!list_empty(&vha->work_list)) {
  2229. e = list_entry(vha->work_list.next, struct qla_work_evt, list);
  2230. list_del_init(&e->list);
  2231. spin_unlock_irq(&ha->hardware_lock);
  2232. switch (e->type) {
  2233. case QLA_EVT_AEN:
  2234. fc_host_post_event(vha->host, fc_get_event_number(),
  2235. e->u.aen.code, e->u.aen.data);
  2236. break;
  2237. case QLA_EVT_IDC_ACK:
  2238. qla81xx_idc_ack(vha, e->u.idc_ack.mb);
  2239. break;
  2240. }
  2241. if (e->flags & QLA_EVT_FLAG_FREE)
  2242. kfree(e);
  2243. spin_lock_irq(&ha->hardware_lock);
  2244. }
  2245. spin_unlock_irq(&ha->hardware_lock);
  2246. }
  2247. /* Relogins all the fcports of a vport
  2248. * Context: dpc thread
  2249. */
  2250. void qla2x00_relogin(struct scsi_qla_host *vha)
  2251. {
  2252. fc_port_t *fcport;
  2253. int status;
  2254. uint16_t next_loopid = 0;
  2255. struct qla_hw_data *ha = vha->hw;
  2256. list_for_each_entry(fcport, &vha->vp_fcports, list) {
  2257. /*
  2258. * If the port is not ONLINE then try to login
  2259. * to it if we haven't run out of retries.
  2260. */
  2261. if (atomic_read(&fcport->state) !=
  2262. FCS_ONLINE && fcport->login_retry) {
  2263. if (fcport->flags & FCF_FABRIC_DEVICE) {
  2264. if (fcport->flags & FCF_TAPE_PRESENT)
  2265. ha->isp_ops->fabric_logout(vha,
  2266. fcport->loop_id,
  2267. fcport->d_id.b.domain,
  2268. fcport->d_id.b.area,
  2269. fcport->d_id.b.al_pa);
  2270. status = qla2x00_fabric_login(vha, fcport,
  2271. &next_loopid);
  2272. } else
  2273. status = qla2x00_local_device_login(vha,
  2274. fcport);
  2275. fcport->login_retry--;
  2276. if (status == QLA_SUCCESS) {
  2277. fcport->old_loop_id = fcport->loop_id;
  2278. DEBUG(printk("scsi(%ld): port login OK: logged "
  2279. "in ID 0x%x\n", vha->host_no, fcport->loop_id));
  2280. qla2x00_update_fcport(vha, fcport);
  2281. } else if (status == 1) {
  2282. set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
  2283. /* retry the login again */
  2284. DEBUG(printk("scsi(%ld): Retrying"
  2285. " %d login again loop_id 0x%x\n",
  2286. vha->host_no, fcport->login_retry,
  2287. fcport->loop_id));
  2288. } else {
  2289. fcport->login_retry = 0;
  2290. }
  2291. if (fcport->login_retry == 0 && status != QLA_SUCCESS)
  2292. fcport->loop_id = FC_NO_LOOP_ID;
  2293. }
  2294. if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
  2295. break;
  2296. }
  2297. }
  2298. /**************************************************************************
  2299. * qla2x00_do_dpc
  2300. * This kernel thread is a task that is schedule by the interrupt handler
  2301. * to perform the background processing for interrupts.
  2302. *
  2303. * Notes:
  2304. * This task always run in the context of a kernel thread. It
  2305. * is kick-off by the driver's detect code and starts up
  2306. * up one per adapter. It immediately goes to sleep and waits for
  2307. * some fibre event. When either the interrupt handler or
  2308. * the timer routine detects a event it will one of the task
  2309. * bits then wake us up.
  2310. **************************************************************************/
  2311. static int
  2312. qla2x00_do_dpc(void *data)
  2313. {
  2314. int rval;
  2315. scsi_qla_host_t *base_vha;
  2316. struct qla_hw_data *ha;
  2317. ha = (struct qla_hw_data *)data;
  2318. base_vha = pci_get_drvdata(ha->pdev);
  2319. set_user_nice(current, -20);
  2320. while (!kthread_should_stop()) {
  2321. DEBUG3(printk("qla2x00: DPC handler sleeping\n"));
  2322. set_current_state(TASK_INTERRUPTIBLE);
  2323. schedule();
  2324. __set_current_state(TASK_RUNNING);
  2325. DEBUG3(printk("qla2x00: DPC handler waking up\n"));
  2326. /* Initialization not yet finished. Don't do anything yet. */
  2327. if (!base_vha->flags.init_done)
  2328. continue;
  2329. DEBUG3(printk("scsi(%ld): DPC handler\n", base_vha->host_no));
  2330. ha->dpc_active = 1;
  2331. if (ha->flags.mbox_busy) {
  2332. ha->dpc_active = 0;
  2333. continue;
  2334. }
  2335. qla2x00_do_work(base_vha);
  2336. if (test_and_clear_bit(ISP_ABORT_NEEDED,
  2337. &base_vha->dpc_flags)) {
  2338. DEBUG(printk("scsi(%ld): dpc: sched "
  2339. "qla2x00_abort_isp ha = %p\n",
  2340. base_vha->host_no, ha));
  2341. if (!(test_and_set_bit(ABORT_ISP_ACTIVE,
  2342. &base_vha->dpc_flags))) {
  2343. if (qla2x00_abort_isp(base_vha)) {
  2344. /* failed. retry later */
  2345. set_bit(ISP_ABORT_NEEDED,
  2346. &base_vha->dpc_flags);
  2347. }
  2348. clear_bit(ABORT_ISP_ACTIVE,
  2349. &base_vha->dpc_flags);
  2350. }
  2351. DEBUG(printk("scsi(%ld): dpc: qla2x00_abort_isp end\n",
  2352. base_vha->host_no));
  2353. }
  2354. if (test_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags)) {
  2355. qla2x00_update_fcports(base_vha);
  2356. clear_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags);
  2357. }
  2358. if (test_and_clear_bit(RESET_MARKER_NEEDED,
  2359. &base_vha->dpc_flags) &&
  2360. (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) {
  2361. DEBUG(printk("scsi(%ld): qla2x00_reset_marker()\n",
  2362. base_vha->host_no));
  2363. qla2x00_rst_aen(base_vha);
  2364. clear_bit(RESET_ACTIVE, &base_vha->dpc_flags);
  2365. }
  2366. /* Retry each device up to login retry count */
  2367. if ((test_and_clear_bit(RELOGIN_NEEDED,
  2368. &base_vha->dpc_flags)) &&
  2369. !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) &&
  2370. atomic_read(&base_vha->loop_state) != LOOP_DOWN) {
  2371. DEBUG(printk("scsi(%ld): qla2x00_port_login()\n",
  2372. base_vha->host_no));
  2373. qla2x00_relogin(base_vha);
  2374. DEBUG(printk("scsi(%ld): qla2x00_port_login - end\n",
  2375. base_vha->host_no));
  2376. }
  2377. if (test_and_clear_bit(LOOP_RESYNC_NEEDED,
  2378. &base_vha->dpc_flags)) {
  2379. DEBUG(printk("scsi(%ld): qla2x00_loop_resync()\n",
  2380. base_vha->host_no));
  2381. if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE,
  2382. &base_vha->dpc_flags))) {
  2383. rval = qla2x00_loop_resync(base_vha);
  2384. clear_bit(LOOP_RESYNC_ACTIVE,
  2385. &base_vha->dpc_flags);
  2386. }
  2387. DEBUG(printk("scsi(%ld): qla2x00_loop_resync - end\n",
  2388. base_vha->host_no));
  2389. }
  2390. if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) &&
  2391. atomic_read(&base_vha->loop_state) == LOOP_READY) {
  2392. clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags);
  2393. qla2xxx_flash_npiv_conf(base_vha);
  2394. }
  2395. if (!ha->interrupts_on)
  2396. ha->isp_ops->enable_intrs(ha);
  2397. if (test_and_clear_bit(BEACON_BLINK_NEEDED,
  2398. &base_vha->dpc_flags))
  2399. ha->isp_ops->beacon_blink(base_vha);
  2400. qla2x00_do_dpc_all_vps(base_vha);
  2401. ha->dpc_active = 0;
  2402. } /* End of while(1) */
  2403. DEBUG(printk("scsi(%ld): DPC handler exiting\n", base_vha->host_no));
  2404. /*
  2405. * Make sure that nobody tries to wake us up again.
  2406. */
  2407. ha->dpc_active = 0;
  2408. return 0;
  2409. }
  2410. void
  2411. qla2xxx_wake_dpc(struct scsi_qla_host *vha)
  2412. {
  2413. struct qla_hw_data *ha = vha->hw;
  2414. struct task_struct *t = ha->dpc_thread;
  2415. if (!test_bit(UNLOADING, &vha->dpc_flags) && t)
  2416. wake_up_process(t);
  2417. }
  2418. /*
  2419. * qla2x00_rst_aen
  2420. * Processes asynchronous reset.
  2421. *
  2422. * Input:
  2423. * ha = adapter block pointer.
  2424. */
  2425. static void
  2426. qla2x00_rst_aen(scsi_qla_host_t *vha)
  2427. {
  2428. if (vha->flags.online && !vha->flags.reset_active &&
  2429. !atomic_read(&vha->loop_down_timer) &&
  2430. !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) {
  2431. do {
  2432. clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
  2433. /*
  2434. * Issue marker command only when we are going to start
  2435. * the I/O.
  2436. */
  2437. vha->marker_needed = 1;
  2438. } while (!atomic_read(&vha->loop_down_timer) &&
  2439. (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)));
  2440. }
  2441. }
  2442. static void
  2443. qla2x00_sp_free_dma(srb_t *sp)
  2444. {
  2445. struct scsi_cmnd *cmd = sp->cmd;
  2446. if (sp->flags & SRB_DMA_VALID) {
  2447. scsi_dma_unmap(cmd);
  2448. sp->flags &= ~SRB_DMA_VALID;
  2449. }
  2450. CMD_SP(cmd) = NULL;
  2451. }
  2452. void
  2453. qla2x00_sp_compl(struct qla_hw_data *ha, srb_t *sp)
  2454. {
  2455. struct scsi_cmnd *cmd = sp->cmd;
  2456. qla2x00_sp_free_dma(sp);
  2457. mempool_free(sp, ha->srb_mempool);
  2458. cmd->scsi_done(cmd);
  2459. }
  2460. /**************************************************************************
  2461. * qla2x00_timer
  2462. *
  2463. * Description:
  2464. * One second timer
  2465. *
  2466. * Context: Interrupt
  2467. ***************************************************************************/
  2468. void
  2469. qla2x00_timer(scsi_qla_host_t *vha)
  2470. {
  2471. unsigned long cpu_flags = 0;
  2472. fc_port_t *fcport;
  2473. int start_dpc = 0;
  2474. int index;
  2475. srb_t *sp;
  2476. int t;
  2477. struct qla_hw_data *ha = vha->hw;
  2478. struct req_que *req;
  2479. /*
  2480. * Ports - Port down timer.
  2481. *
  2482. * Whenever, a port is in the LOST state we start decrementing its port
  2483. * down timer every second until it reaches zero. Once it reaches zero
  2484. * the port it marked DEAD.
  2485. */
  2486. t = 0;
  2487. list_for_each_entry(fcport, &vha->vp_fcports, list) {
  2488. if (fcport->port_type != FCT_TARGET)
  2489. continue;
  2490. if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
  2491. if (atomic_read(&fcport->port_down_timer) == 0)
  2492. continue;
  2493. if (atomic_dec_and_test(&fcport->port_down_timer) != 0)
  2494. atomic_set(&fcport->state, FCS_DEVICE_DEAD);
  2495. DEBUG(printk("scsi(%ld): fcport-%d - port retry count: "
  2496. "%d remaining\n",
  2497. vha->host_no,
  2498. t, atomic_read(&fcport->port_down_timer)));
  2499. }
  2500. t++;
  2501. } /* End of for fcport */
  2502. /* Loop down handler. */
  2503. if (atomic_read(&vha->loop_down_timer) > 0 &&
  2504. !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
  2505. && vha->flags.online) {
  2506. if (atomic_read(&vha->loop_down_timer) ==
  2507. vha->loop_down_abort_time) {
  2508. DEBUG(printk("scsi(%ld): Loop Down - aborting the "
  2509. "queues before time expire\n",
  2510. vha->host_no));
  2511. if (!IS_QLA2100(ha) && vha->link_down_timeout)
  2512. atomic_set(&vha->loop_state, LOOP_DEAD);
  2513. /* Schedule an ISP abort to return any tape commands. */
  2514. /* NPIV - scan physical port only */
  2515. if (!vha->vp_idx) {
  2516. spin_lock_irqsave(&ha->hardware_lock,
  2517. cpu_flags);
  2518. req = ha->req_q_map[0];
  2519. for (index = 1;
  2520. index < MAX_OUTSTANDING_COMMANDS;
  2521. index++) {
  2522. fc_port_t *sfcp;
  2523. sp = req->outstanding_cmds[index];
  2524. if (!sp)
  2525. continue;
  2526. sfcp = sp->fcport;
  2527. if (!(sfcp->flags & FCF_TAPE_PRESENT))
  2528. continue;
  2529. set_bit(ISP_ABORT_NEEDED,
  2530. &vha->dpc_flags);
  2531. break;
  2532. }
  2533. spin_unlock_irqrestore(&ha->hardware_lock,
  2534. cpu_flags);
  2535. }
  2536. start_dpc++;
  2537. }
  2538. /* if the loop has been down for 4 minutes, reinit adapter */
  2539. if (atomic_dec_and_test(&vha->loop_down_timer) != 0) {
  2540. if (!(vha->device_flags & DFLG_NO_CABLE) &&
  2541. !vha->vp_idx) {
  2542. DEBUG(printk("scsi(%ld): Loop down - "
  2543. "aborting ISP.\n",
  2544. vha->host_no));
  2545. qla_printk(KERN_WARNING, ha,
  2546. "Loop down - aborting ISP.\n");
  2547. set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
  2548. }
  2549. }
  2550. DEBUG3(printk("scsi(%ld): Loop Down - seconds remaining %d\n",
  2551. vha->host_no,
  2552. atomic_read(&vha->loop_down_timer)));
  2553. }
  2554. /* Check if beacon LED needs to be blinked */
  2555. if (ha->beacon_blink_led == 1) {
  2556. set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags);
  2557. start_dpc++;
  2558. }
  2559. /* Process any deferred work. */
  2560. if (!list_empty(&vha->work_list))
  2561. start_dpc++;
  2562. /* Schedule the DPC routine if needed */
  2563. if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
  2564. test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) ||
  2565. test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) ||
  2566. start_dpc ||
  2567. test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) ||
  2568. test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) ||
  2569. test_bit(VP_DPC_NEEDED, &vha->dpc_flags) ||
  2570. test_bit(RELOGIN_NEEDED, &vha->dpc_flags)))
  2571. qla2xxx_wake_dpc(vha);
  2572. qla2x00_restart_timer(vha, WATCH_INTERVAL);
  2573. }
  2574. /* Firmware interface routines. */
  2575. #define FW_BLOBS 7
  2576. #define FW_ISP21XX 0
  2577. #define FW_ISP22XX 1
  2578. #define FW_ISP2300 2
  2579. #define FW_ISP2322 3
  2580. #define FW_ISP24XX 4
  2581. #define FW_ISP25XX 5
  2582. #define FW_ISP81XX 6
  2583. #define FW_FILE_ISP21XX "ql2100_fw.bin"
  2584. #define FW_FILE_ISP22XX "ql2200_fw.bin"
  2585. #define FW_FILE_ISP2300 "ql2300_fw.bin"
  2586. #define FW_FILE_ISP2322 "ql2322_fw.bin"
  2587. #define FW_FILE_ISP24XX "ql2400_fw.bin"
  2588. #define FW_FILE_ISP25XX "ql2500_fw.bin"
  2589. #define FW_FILE_ISP81XX "ql8100_fw.bin"
  2590. static DEFINE_MUTEX(qla_fw_lock);
  2591. static struct fw_blob qla_fw_blobs[FW_BLOBS] = {
  2592. { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, },
  2593. { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, },
  2594. { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, },
  2595. { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, },
  2596. { .name = FW_FILE_ISP24XX, },
  2597. { .name = FW_FILE_ISP25XX, },
  2598. { .name = FW_FILE_ISP81XX, },
  2599. };
  2600. struct fw_blob *
  2601. qla2x00_request_firmware(scsi_qla_host_t *vha)
  2602. {
  2603. struct qla_hw_data *ha = vha->hw;
  2604. struct fw_blob *blob;
  2605. blob = NULL;
  2606. if (IS_QLA2100(ha)) {
  2607. blob = &qla_fw_blobs[FW_ISP21XX];
  2608. } else if (IS_QLA2200(ha)) {
  2609. blob = &qla_fw_blobs[FW_ISP22XX];
  2610. } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) {
  2611. blob = &qla_fw_blobs[FW_ISP2300];
  2612. } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) {
  2613. blob = &qla_fw_blobs[FW_ISP2322];
  2614. } else if (IS_QLA24XX_TYPE(ha)) {
  2615. blob = &qla_fw_blobs[FW_ISP24XX];
  2616. } else if (IS_QLA25XX(ha)) {
  2617. blob = &qla_fw_blobs[FW_ISP25XX];
  2618. } else if (IS_QLA81XX(ha)) {
  2619. blob = &qla_fw_blobs[FW_ISP81XX];
  2620. }
  2621. mutex_lock(&qla_fw_lock);
  2622. if (blob->fw)
  2623. goto out;
  2624. if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) {
  2625. DEBUG2(printk("scsi(%ld): Failed to load firmware image "
  2626. "(%s).\n", vha->host_no, blob->name));
  2627. blob->fw = NULL;
  2628. blob = NULL;
  2629. goto out;
  2630. }
  2631. out:
  2632. mutex_unlock(&qla_fw_lock);
  2633. return blob;
  2634. }
  2635. static void
  2636. qla2x00_release_firmware(void)
  2637. {
  2638. int idx;
  2639. mutex_lock(&qla_fw_lock);
  2640. for (idx = 0; idx < FW_BLOBS; idx++)
  2641. if (qla_fw_blobs[idx].fw)
  2642. release_firmware(qla_fw_blobs[idx].fw);
  2643. mutex_unlock(&qla_fw_lock);
  2644. }
  2645. static pci_ers_result_t
  2646. qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
  2647. {
  2648. scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
  2649. switch (state) {
  2650. case pci_channel_io_normal:
  2651. return PCI_ERS_RESULT_CAN_RECOVER;
  2652. case pci_channel_io_frozen:
  2653. pci_disable_device(pdev);
  2654. return PCI_ERS_RESULT_NEED_RESET;
  2655. case pci_channel_io_perm_failure:
  2656. qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16);
  2657. return PCI_ERS_RESULT_DISCONNECT;
  2658. }
  2659. return PCI_ERS_RESULT_NEED_RESET;
  2660. }
  2661. static pci_ers_result_t
  2662. qla2xxx_pci_mmio_enabled(struct pci_dev *pdev)
  2663. {
  2664. int risc_paused = 0;
  2665. uint32_t stat;
  2666. unsigned long flags;
  2667. scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
  2668. struct qla_hw_data *ha = base_vha->hw;
  2669. struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
  2670. struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24;
  2671. spin_lock_irqsave(&ha->hardware_lock, flags);
  2672. if (IS_QLA2100(ha) || IS_QLA2200(ha)){
  2673. stat = RD_REG_DWORD(&reg->hccr);
  2674. if (stat & HCCR_RISC_PAUSE)
  2675. risc_paused = 1;
  2676. } else if (IS_QLA23XX(ha)) {
  2677. stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
  2678. if (stat & HSR_RISC_PAUSED)
  2679. risc_paused = 1;
  2680. } else if (IS_FWI2_CAPABLE(ha)) {
  2681. stat = RD_REG_DWORD(&reg24->host_status);
  2682. if (stat & HSRX_RISC_PAUSED)
  2683. risc_paused = 1;
  2684. }
  2685. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  2686. if (risc_paused) {
  2687. qla_printk(KERN_INFO, ha, "RISC paused -- mmio_enabled, "
  2688. "Dumping firmware!\n");
  2689. ha->isp_ops->fw_dump(base_vha, 0);
  2690. return PCI_ERS_RESULT_NEED_RESET;
  2691. } else
  2692. return PCI_ERS_RESULT_RECOVERED;
  2693. }
  2694. static pci_ers_result_t
  2695. qla2xxx_pci_slot_reset(struct pci_dev *pdev)
  2696. {
  2697. pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT;
  2698. scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
  2699. struct qla_hw_data *ha = base_vha->hw;
  2700. int rc;
  2701. if (ha->mem_only)
  2702. rc = pci_enable_device_mem(pdev);
  2703. else
  2704. rc = pci_enable_device(pdev);
  2705. if (rc) {
  2706. qla_printk(KERN_WARNING, ha,
  2707. "Can't re-enable PCI device after reset.\n");
  2708. return ret;
  2709. }
  2710. pci_set_master(pdev);
  2711. if (ha->isp_ops->pci_config(base_vha))
  2712. return ret;
  2713. set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
  2714. if (qla2x00_abort_isp(base_vha) == QLA_SUCCESS)
  2715. ret = PCI_ERS_RESULT_RECOVERED;
  2716. clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
  2717. return ret;
  2718. }
  2719. static void
  2720. qla2xxx_pci_resume(struct pci_dev *pdev)
  2721. {
  2722. scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
  2723. struct qla_hw_data *ha = base_vha->hw;
  2724. int ret;
  2725. ret = qla2x00_wait_for_hba_online(base_vha);
  2726. if (ret != QLA_SUCCESS) {
  2727. qla_printk(KERN_ERR, ha,
  2728. "the device failed to resume I/O "
  2729. "from slot/link_reset");
  2730. }
  2731. pci_cleanup_aer_uncorrect_error_status(pdev);
  2732. }
  2733. static struct pci_error_handlers qla2xxx_err_handler = {
  2734. .error_detected = qla2xxx_pci_error_detected,
  2735. .mmio_enabled = qla2xxx_pci_mmio_enabled,
  2736. .slot_reset = qla2xxx_pci_slot_reset,
  2737. .resume = qla2xxx_pci_resume,
  2738. };
  2739. static struct pci_device_id qla2xxx_pci_tbl[] = {
  2740. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) },
  2741. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) },
  2742. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) },
  2743. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) },
  2744. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) },
  2745. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) },
  2746. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) },
  2747. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) },
  2748. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) },
  2749. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) },
  2750. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) },
  2751. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) },
  2752. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) },
  2753. { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) },
  2754. { 0 },
  2755. };
  2756. MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
  2757. static struct pci_driver qla2xxx_pci_driver = {
  2758. .name = QLA2XXX_DRIVER_NAME,
  2759. .driver = {
  2760. .owner = THIS_MODULE,
  2761. },
  2762. .id_table = qla2xxx_pci_tbl,
  2763. .probe = qla2x00_probe_one,
  2764. .remove = qla2x00_remove_one,
  2765. .err_handler = &qla2xxx_err_handler,
  2766. };
  2767. /**
  2768. * qla2x00_module_init - Module initialization.
  2769. **/
  2770. static int __init
  2771. qla2x00_module_init(void)
  2772. {
  2773. int ret = 0;
  2774. /* Allocate cache for SRBs. */
  2775. srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
  2776. SLAB_HWCACHE_ALIGN, NULL);
  2777. if (srb_cachep == NULL) {
  2778. printk(KERN_ERR
  2779. "qla2xxx: Unable to allocate SRB cache...Failing load!\n");
  2780. return -ENOMEM;
  2781. }
  2782. /* Derive version string. */
  2783. strcpy(qla2x00_version_str, QLA2XXX_VERSION);
  2784. if (ql2xextended_error_logging)
  2785. strcat(qla2x00_version_str, "-debug");
  2786. qla2xxx_transport_template =
  2787. fc_attach_transport(&qla2xxx_transport_functions);
  2788. if (!qla2xxx_transport_template) {
  2789. kmem_cache_destroy(srb_cachep);
  2790. return -ENODEV;
  2791. }
  2792. qla2xxx_transport_vport_template =
  2793. fc_attach_transport(&qla2xxx_transport_vport_functions);
  2794. if (!qla2xxx_transport_vport_template) {
  2795. kmem_cache_destroy(srb_cachep);
  2796. fc_release_transport(qla2xxx_transport_template);
  2797. return -ENODEV;
  2798. }
  2799. printk(KERN_INFO "QLogic Fibre Channel HBA Driver: %s\n",
  2800. qla2x00_version_str);
  2801. ret = pci_register_driver(&qla2xxx_pci_driver);
  2802. if (ret) {
  2803. kmem_cache_destroy(srb_cachep);
  2804. fc_release_transport(qla2xxx_transport_template);
  2805. fc_release_transport(qla2xxx_transport_vport_template);
  2806. }
  2807. return ret;
  2808. }
  2809. /**
  2810. * qla2x00_module_exit - Module cleanup.
  2811. **/
  2812. static void __exit
  2813. qla2x00_module_exit(void)
  2814. {
  2815. pci_unregister_driver(&qla2xxx_pci_driver);
  2816. qla2x00_release_firmware();
  2817. kmem_cache_destroy(srb_cachep);
  2818. fc_release_transport(qla2xxx_transport_template);
  2819. fc_release_transport(qla2xxx_transport_vport_template);
  2820. }
  2821. module_init(qla2x00_module_init);
  2822. module_exit(qla2x00_module_exit);
  2823. MODULE_AUTHOR("QLogic Corporation");
  2824. MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver");
  2825. MODULE_LICENSE("GPL");
  2826. MODULE_VERSION(QLA2XXX_VERSION);
  2827. MODULE_FIRMWARE(FW_FILE_ISP21XX);
  2828. MODULE_FIRMWARE(FW_FILE_ISP22XX);
  2829. MODULE_FIRMWARE(FW_FILE_ISP2300);
  2830. MODULE_FIRMWARE(FW_FILE_ISP2322);
  2831. MODULE_FIRMWARE(FW_FILE_ISP24XX);
  2832. MODULE_FIRMWARE(FW_FILE_ISP25XX);
  2833. MODULE_FIRMWARE(FW_FILE_ISP81XX);