zfcp_fsf.c 154 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925
  1. /*
  2. *
  3. * linux/drivers/s390/scsi/zfcp_fsf.c
  4. *
  5. * FCP adapter driver for IBM eServer zSeries
  6. *
  7. * (C) Copyright IBM Corp. 2002, 2004
  8. *
  9. * Author(s): Martin Peschke <mpeschke@de.ibm.com>
  10. * Raimund Schroeder <raimund.schroeder@de.ibm.com>
  11. * Aron Zeh
  12. * Wolfgang Taphorn
  13. * Stefan Bader <stefan.bader@de.ibm.com>
  14. * Heiko Carstens <heiko.carstens@de.ibm.com>
  15. * Andreas Herrmann <aherrman@de.ibm.com>
  16. * Volker Sameske <sameske@de.ibm.com>
  17. *
  18. * This program is free software; you can redistribute it and/or modify
  19. * it under the terms of the GNU General Public License as published by
  20. * the Free Software Foundation; either version 2, or (at your option)
  21. * any later version.
  22. *
  23. * This program is distributed in the hope that it will be useful,
  24. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. * GNU General Public License for more details.
  27. *
  28. * You should have received a copy of the GNU General Public License
  29. * along with this program; if not, write to the Free Software
  30. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  31. */
  32. #define ZFCP_FSF_C_REVISION "$Revision: 1.92 $"
  33. #include "zfcp_ext.h"
  34. static int zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *);
  35. static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *);
  36. static int zfcp_fsf_open_port_handler(struct zfcp_fsf_req *);
  37. static int zfcp_fsf_close_port_handler(struct zfcp_fsf_req *);
  38. static int zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *);
  39. static int zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *);
  40. static int zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *);
  41. static int zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *);
  42. static int zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *);
  43. static int zfcp_fsf_send_fcp_command_task_management_handler(
  44. struct zfcp_fsf_req *);
  45. static int zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *);
  46. static int zfcp_fsf_status_read_handler(struct zfcp_fsf_req *);
  47. static int zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *);
  48. static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *);
  49. static int zfcp_fsf_control_file_handler(struct zfcp_fsf_req *);
  50. static inline int zfcp_fsf_req_sbal_check(
  51. unsigned long *, struct zfcp_qdio_queue *, int);
  52. static inline int zfcp_use_one_sbal(
  53. struct scatterlist *, int, struct scatterlist *, int);
  54. static struct zfcp_fsf_req *zfcp_fsf_req_alloc(mempool_t *, int);
  55. static int zfcp_fsf_req_send(struct zfcp_fsf_req *, struct timer_list *);
  56. static int zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *);
  57. static int zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *);
  58. static int zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *);
  59. static int zfcp_fsf_req_dispatch(struct zfcp_fsf_req *);
  60. static void zfcp_fsf_req_dismiss(struct zfcp_fsf_req *);
  61. static void zfcp_fsf_req_free(struct zfcp_fsf_req *);
  62. /* association between FSF command and FSF QTCB type */
  63. static u32 fsf_qtcb_type[] = {
  64. [FSF_QTCB_FCP_CMND] = FSF_IO_COMMAND,
  65. [FSF_QTCB_ABORT_FCP_CMND] = FSF_SUPPORT_COMMAND,
  66. [FSF_QTCB_OPEN_PORT_WITH_DID] = FSF_SUPPORT_COMMAND,
  67. [FSF_QTCB_OPEN_LUN] = FSF_SUPPORT_COMMAND,
  68. [FSF_QTCB_CLOSE_LUN] = FSF_SUPPORT_COMMAND,
  69. [FSF_QTCB_CLOSE_PORT] = FSF_SUPPORT_COMMAND,
  70. [FSF_QTCB_CLOSE_PHYSICAL_PORT] = FSF_SUPPORT_COMMAND,
  71. [FSF_QTCB_SEND_ELS] = FSF_SUPPORT_COMMAND,
  72. [FSF_QTCB_SEND_GENERIC] = FSF_SUPPORT_COMMAND,
  73. [FSF_QTCB_EXCHANGE_CONFIG_DATA] = FSF_CONFIG_COMMAND,
  74. [FSF_QTCB_EXCHANGE_PORT_DATA] = FSF_PORT_COMMAND,
  75. [FSF_QTCB_DOWNLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND,
  76. [FSF_QTCB_UPLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND
  77. };
  78. static const char zfcp_act_subtable_type[5][8] = {
  79. "unknown", "OS", "WWPN", "DID", "LUN"
  80. };
  81. /****************************************************************/
  82. /*************** FSF related Functions *************************/
  83. /****************************************************************/
  84. #define ZFCP_LOG_AREA ZFCP_LOG_AREA_FSF
  85. /*
  86. * function: zfcp_fsf_req_alloc
  87. *
  88. * purpose: Obtains an fsf_req and potentially a qtcb (for all but
  89. * unsolicited requests) via helper functions
  90. * Does some initial fsf request set-up.
  91. *
  92. * returns: pointer to allocated fsf_req if successfull
  93. * NULL otherwise
  94. *
  95. * locks: none
  96. *
  97. */
  98. static struct zfcp_fsf_req *
  99. zfcp_fsf_req_alloc(mempool_t *pool, int req_flags)
  100. {
  101. size_t size;
  102. void *ptr;
  103. struct zfcp_fsf_req *fsf_req = NULL;
  104. if (req_flags & ZFCP_REQ_NO_QTCB)
  105. size = sizeof(struct zfcp_fsf_req);
  106. else
  107. size = sizeof(struct zfcp_fsf_req_pool_element);
  108. if (likely(pool != NULL))
  109. ptr = mempool_alloc(pool, GFP_ATOMIC);
  110. else
  111. ptr = kmalloc(size, GFP_ATOMIC);
  112. if (unlikely(NULL == ptr))
  113. goto out;
  114. memset(ptr, 0, size);
  115. if (req_flags & ZFCP_REQ_NO_QTCB) {
  116. fsf_req = (struct zfcp_fsf_req *) ptr;
  117. } else {
  118. fsf_req = &((struct zfcp_fsf_req_pool_element *) ptr)->fsf_req;
  119. fsf_req->qtcb =
  120. &((struct zfcp_fsf_req_pool_element *) ptr)->qtcb;
  121. }
  122. fsf_req->pool = pool;
  123. out:
  124. return fsf_req;
  125. }
  126. /*
  127. * function: zfcp_fsf_req_free
  128. *
  129. * purpose: Frees the memory of an fsf_req (and potentially a qtcb) or
  130. * returns it into the pool via helper functions.
  131. *
  132. * returns: sod all
  133. *
  134. * locks: none
  135. */
  136. static void
  137. zfcp_fsf_req_free(struct zfcp_fsf_req *fsf_req)
  138. {
  139. if (likely(fsf_req->pool != NULL))
  140. mempool_free(fsf_req, fsf_req->pool);
  141. else
  142. kfree(fsf_req);
  143. }
  144. /*
  145. * function:
  146. *
  147. * purpose:
  148. *
  149. * returns:
  150. *
  151. * note: qdio queues shall be down (no ongoing inbound processing)
  152. */
  153. int
  154. zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
  155. {
  156. int retval = 0;
  157. struct zfcp_fsf_req *fsf_req, *tmp;
  158. list_for_each_entry_safe(fsf_req, tmp, &adapter->fsf_req_list_head,
  159. list)
  160. zfcp_fsf_req_dismiss(fsf_req);
  161. /* wait_event_timeout? */
  162. while (!list_empty(&adapter->fsf_req_list_head)) {
  163. ZFCP_LOG_DEBUG("fsf req list of adapter %s not yet empty\n",
  164. zfcp_get_busid_by_adapter(adapter));
  165. /* wait for woken intiators to clean up their requests */
  166. msleep(jiffies_to_msecs(ZFCP_FSFREQ_CLEANUP_TIMEOUT));
  167. }
  168. /* consistency check */
  169. if (atomic_read(&adapter->fsf_reqs_active)) {
  170. ZFCP_LOG_NORMAL("bug: There are still %d FSF requests pending "
  171. "on adapter %s after cleanup.\n",
  172. atomic_read(&adapter->fsf_reqs_active),
  173. zfcp_get_busid_by_adapter(adapter));
  174. atomic_set(&adapter->fsf_reqs_active, 0);
  175. }
  176. return retval;
  177. }
  178. /*
  179. * function:
  180. *
  181. * purpose:
  182. *
  183. * returns:
  184. */
  185. static void
  186. zfcp_fsf_req_dismiss(struct zfcp_fsf_req *fsf_req)
  187. {
  188. fsf_req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
  189. zfcp_fsf_req_complete(fsf_req);
  190. }
  191. /*
  192. * function: zfcp_fsf_req_complete
  193. *
  194. * purpose: Updates active counts and timers for openfcp-reqs
  195. * May cleanup request after req_eval returns
  196. *
  197. * returns: 0 - success
  198. * !0 - failure
  199. *
  200. * context:
  201. */
  202. int
  203. zfcp_fsf_req_complete(struct zfcp_fsf_req *fsf_req)
  204. {
  205. int retval = 0;
  206. int cleanup;
  207. struct zfcp_adapter *adapter = fsf_req->adapter;
  208. /* do some statistics */
  209. atomic_dec(&adapter->fsf_reqs_active);
  210. if (unlikely(fsf_req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) {
  211. ZFCP_LOG_DEBUG("Status read response received\n");
  212. /*
  213. * Note: all cleanup handling is done in the callchain of
  214. * the function call-chain below.
  215. */
  216. zfcp_fsf_status_read_handler(fsf_req);
  217. goto out;
  218. } else
  219. zfcp_fsf_protstatus_eval(fsf_req);
  220. /*
  221. * fsf_req may be deleted due to waking up functions, so
  222. * cleanup is saved here and used later
  223. */
  224. if (likely(fsf_req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
  225. cleanup = 1;
  226. else
  227. cleanup = 0;
  228. fsf_req->status |= ZFCP_STATUS_FSFREQ_COMPLETED;
  229. /* cleanup request if requested by initiator */
  230. if (likely(cleanup)) {
  231. ZFCP_LOG_TRACE("removing FSF request %p\n", fsf_req);
  232. /*
  233. * lock must not be held here since it will be
  234. * grabed by the called routine, too
  235. */
  236. zfcp_fsf_req_cleanup(fsf_req);
  237. } else {
  238. /* notify initiator waiting for the requests completion */
  239. ZFCP_LOG_TRACE("waking initiator of FSF request %p\n",fsf_req);
  240. /*
  241. * FIXME: Race! We must not access fsf_req here as it might have been
  242. * cleaned up already due to the set ZFCP_STATUS_FSFREQ_COMPLETED
  243. * flag. It's an improbable case. But, we have the same paranoia for
  244. * the cleanup flag already.
  245. * Might better be handled using complete()?
  246. * (setting the flag and doing wakeup ought to be atomic
  247. * with regard to checking the flag as long as waitqueue is
  248. * part of the to be released structure)
  249. */
  250. wake_up(&fsf_req->completion_wq);
  251. }
  252. out:
  253. return retval;
  254. }
  255. /*
  256. * function: zfcp_fsf_protstatus_eval
  257. *
  258. * purpose: evaluates the QTCB of the finished FSF request
  259. * and initiates appropriate actions
  260. * (usually calling FSF command specific handlers)
  261. *
  262. * returns:
  263. *
  264. * context:
  265. *
  266. * locks:
  267. */
  268. static int
  269. zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *fsf_req)
  270. {
  271. int retval = 0;
  272. struct zfcp_adapter *adapter = fsf_req->adapter;
  273. ZFCP_LOG_DEBUG("QTCB is at %p\n", fsf_req->qtcb);
  274. if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
  275. ZFCP_LOG_DEBUG("fsf_req 0x%lx has been dismissed\n",
  276. (unsigned long) fsf_req);
  277. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  278. ZFCP_STATUS_FSFREQ_RETRY; /* only for SCSI cmnds. */
  279. zfcp_cmd_dbf_event_fsf("dismiss", fsf_req, NULL, 0);
  280. goto skip_protstatus;
  281. }
  282. /* log additional information provided by FSF (if any) */
  283. if (unlikely(fsf_req->qtcb->header.log_length)) {
  284. /* do not trust them ;-) */
  285. if (fsf_req->qtcb->header.log_start > sizeof(struct fsf_qtcb)) {
  286. ZFCP_LOG_NORMAL
  287. ("bug: ULP (FSF logging) log data starts "
  288. "beyond end of packet header. Ignored. "
  289. "(start=%i, size=%li)\n",
  290. fsf_req->qtcb->header.log_start,
  291. sizeof(struct fsf_qtcb));
  292. goto forget_log;
  293. }
  294. if ((size_t) (fsf_req->qtcb->header.log_start +
  295. fsf_req->qtcb->header.log_length)
  296. > sizeof(struct fsf_qtcb)) {
  297. ZFCP_LOG_NORMAL("bug: ULP (FSF logging) log data ends "
  298. "beyond end of packet header. Ignored. "
  299. "(start=%i, length=%i, size=%li)\n",
  300. fsf_req->qtcb->header.log_start,
  301. fsf_req->qtcb->header.log_length,
  302. sizeof(struct fsf_qtcb));
  303. goto forget_log;
  304. }
  305. ZFCP_LOG_TRACE("ULP log data: \n");
  306. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
  307. (char *) fsf_req->qtcb +
  308. fsf_req->qtcb->header.log_start,
  309. fsf_req->qtcb->header.log_length);
  310. }
  311. forget_log:
  312. /* evaluate FSF Protocol Status */
  313. switch (fsf_req->qtcb->prefix.prot_status) {
  314. case FSF_PROT_GOOD:
  315. case FSF_PROT_FSF_STATUS_PRESENTED:
  316. break;
  317. case FSF_PROT_QTCB_VERSION_ERROR:
  318. ZFCP_LOG_NORMAL("error: The adapter %s contains "
  319. "microcode of version 0x%x, the device driver "
  320. "only supports 0x%x. Aborting.\n",
  321. zfcp_get_busid_by_adapter(adapter),
  322. fsf_req->qtcb->prefix.prot_status_qual.
  323. version_error.fsf_version, ZFCP_QTCB_VERSION);
  324. /* stop operation for this adapter */
  325. debug_text_exception(adapter->erp_dbf, 0, "prot_ver_err");
  326. zfcp_erp_adapter_shutdown(adapter, 0);
  327. zfcp_cmd_dbf_event_fsf("qverserr", fsf_req,
  328. &fsf_req->qtcb->prefix.prot_status_qual,
  329. sizeof (union fsf_prot_status_qual));
  330. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  331. break;
  332. case FSF_PROT_SEQ_NUMB_ERROR:
  333. ZFCP_LOG_NORMAL("bug: Sequence number mismatch between "
  334. "driver (0x%x) and adapter %s (0x%x). "
  335. "Restarting all operations on this adapter.\n",
  336. fsf_req->qtcb->prefix.req_seq_no,
  337. zfcp_get_busid_by_adapter(adapter),
  338. fsf_req->qtcb->prefix.prot_status_qual.
  339. sequence_error.exp_req_seq_no);
  340. debug_text_exception(adapter->erp_dbf, 0, "prot_seq_err");
  341. /* restart operation on this adapter */
  342. zfcp_erp_adapter_reopen(adapter, 0);
  343. zfcp_cmd_dbf_event_fsf("seqnoerr", fsf_req,
  344. &fsf_req->qtcb->prefix.prot_status_qual,
  345. sizeof (union fsf_prot_status_qual));
  346. fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
  347. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  348. break;
  349. case FSF_PROT_UNSUPP_QTCB_TYPE:
  350. ZFCP_LOG_NORMAL("error: Packet header type used by the "
  351. "device driver is incompatible with "
  352. "that used on adapter %s. "
  353. "Stopping all operations on this adapter.\n",
  354. zfcp_get_busid_by_adapter(adapter));
  355. debug_text_exception(adapter->erp_dbf, 0, "prot_unsup_qtcb");
  356. zfcp_erp_adapter_shutdown(adapter, 0);
  357. zfcp_cmd_dbf_event_fsf("unsqtcbt", fsf_req,
  358. &fsf_req->qtcb->prefix.prot_status_qual,
  359. sizeof (union fsf_prot_status_qual));
  360. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  361. break;
  362. case FSF_PROT_HOST_CONNECTION_INITIALIZING:
  363. zfcp_cmd_dbf_event_fsf("hconinit", fsf_req,
  364. &fsf_req->qtcb->prefix.prot_status_qual,
  365. sizeof (union fsf_prot_status_qual));
  366. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  367. atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
  368. &(adapter->status));
  369. debug_text_event(adapter->erp_dbf, 3, "prot_con_init");
  370. break;
  371. case FSF_PROT_DUPLICATE_REQUEST_ID:
  372. if (fsf_req->qtcb) {
  373. ZFCP_LOG_NORMAL("bug: The request identifier 0x%Lx "
  374. "to the adapter %s is ambiguous. "
  375. "Stopping all operations on this "
  376. "adapter.\n",
  377. *(unsigned long long *)
  378. (&fsf_req->qtcb->bottom.support.
  379. req_handle),
  380. zfcp_get_busid_by_adapter(adapter));
  381. } else {
  382. ZFCP_LOG_NORMAL("bug: The request identifier %p "
  383. "to the adapter %s is ambiguous. "
  384. "Stopping all operations on this "
  385. "adapter. "
  386. "(bug: got this for an unsolicited "
  387. "status read request)\n",
  388. fsf_req,
  389. zfcp_get_busid_by_adapter(adapter));
  390. }
  391. debug_text_exception(adapter->erp_dbf, 0, "prot_dup_id");
  392. zfcp_erp_adapter_shutdown(adapter, 0);
  393. zfcp_cmd_dbf_event_fsf("dupreqid", fsf_req,
  394. &fsf_req->qtcb->prefix.prot_status_qual,
  395. sizeof (union fsf_prot_status_qual));
  396. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  397. break;
  398. case FSF_PROT_LINK_DOWN:
  399. /*
  400. * 'test and set' is not atomic here -
  401. * it's ok as long as calls to our response queue handler
  402. * (and thus execution of this code here) are serialized
  403. * by the qdio module
  404. */
  405. if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
  406. &adapter->status)) {
  407. switch (fsf_req->qtcb->prefix.prot_status_qual.
  408. locallink_error.code) {
  409. case FSF_PSQ_LINK_NOLIGHT:
  410. ZFCP_LOG_INFO("The local link to adapter %s "
  411. "is down (no light detected).\n",
  412. zfcp_get_busid_by_adapter(
  413. adapter));
  414. break;
  415. case FSF_PSQ_LINK_WRAPPLUG:
  416. ZFCP_LOG_INFO("The local link to adapter %s "
  417. "is down (wrap plug detected).\n",
  418. zfcp_get_busid_by_adapter(
  419. adapter));
  420. break;
  421. case FSF_PSQ_LINK_NOFCP:
  422. ZFCP_LOG_INFO("The local link to adapter %s "
  423. "is down (adjacent node on "
  424. "link does not support FCP).\n",
  425. zfcp_get_busid_by_adapter(
  426. adapter));
  427. break;
  428. default:
  429. ZFCP_LOG_INFO("The local link to adapter %s "
  430. "is down "
  431. "(warning: unknown reason "
  432. "code).\n",
  433. zfcp_get_busid_by_adapter(
  434. adapter));
  435. break;
  436. }
  437. /*
  438. * Due to the 'erp failed' flag the adapter won't
  439. * be recovered but will be just set to 'blocked'
  440. * state. All subordinary devices will have state
  441. * 'blocked' and 'erp failed', too.
  442. * Thus the adapter is still able to provide
  443. * 'link up' status without being flooded with
  444. * requests.
  445. * (note: even 'close port' is not permitted)
  446. */
  447. ZFCP_LOG_INFO("Stopping all operations for adapter "
  448. "%s.\n",
  449. zfcp_get_busid_by_adapter(adapter));
  450. atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
  451. ZFCP_STATUS_COMMON_ERP_FAILED,
  452. &adapter->status);
  453. zfcp_erp_adapter_reopen(adapter, 0);
  454. }
  455. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  456. break;
  457. case FSF_PROT_REEST_QUEUE:
  458. debug_text_event(adapter->erp_dbf, 1, "prot_reest_queue");
  459. ZFCP_LOG_INFO("The local link to adapter with "
  460. "%s was re-plugged. "
  461. "Re-starting operations on this adapter.\n",
  462. zfcp_get_busid_by_adapter(adapter));
  463. /* All ports should be marked as ready to run again */
  464. zfcp_erp_modify_adapter_status(adapter,
  465. ZFCP_STATUS_COMMON_RUNNING,
  466. ZFCP_SET);
  467. zfcp_erp_adapter_reopen(adapter,
  468. ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
  469. | ZFCP_STATUS_COMMON_ERP_FAILED);
  470. zfcp_cmd_dbf_event_fsf("reestque", fsf_req,
  471. &fsf_req->qtcb->prefix.prot_status_qual,
  472. sizeof (union fsf_prot_status_qual));
  473. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  474. break;
  475. case FSF_PROT_ERROR_STATE:
  476. ZFCP_LOG_NORMAL("error: The adapter %s "
  477. "has entered the error state. "
  478. "Restarting all operations on this "
  479. "adapter.\n",
  480. zfcp_get_busid_by_adapter(adapter));
  481. debug_text_event(adapter->erp_dbf, 0, "prot_err_sta");
  482. /* restart operation on this adapter */
  483. zfcp_erp_adapter_reopen(adapter, 0);
  484. zfcp_cmd_dbf_event_fsf("proterrs", fsf_req,
  485. &fsf_req->qtcb->prefix.prot_status_qual,
  486. sizeof (union fsf_prot_status_qual));
  487. fsf_req->status |= ZFCP_STATUS_FSFREQ_RETRY;
  488. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  489. break;
  490. default:
  491. ZFCP_LOG_NORMAL("bug: Transfer protocol status information "
  492. "provided by the adapter %s "
  493. "is not compatible with the device driver. "
  494. "Stopping all operations on this adapter. "
  495. "(debug info 0x%x).\n",
  496. zfcp_get_busid_by_adapter(adapter),
  497. fsf_req->qtcb->prefix.prot_status);
  498. debug_text_event(adapter->erp_dbf, 0, "prot_inval:");
  499. debug_exception(adapter->erp_dbf, 0,
  500. &fsf_req->qtcb->prefix.prot_status,
  501. sizeof (u32));
  502. zfcp_erp_adapter_shutdown(adapter, 0);
  503. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  504. }
  505. skip_protstatus:
  506. /*
  507. * always call specific handlers to give them a chance to do
  508. * something meaningful even in error cases
  509. */
  510. zfcp_fsf_fsfstatus_eval(fsf_req);
  511. return retval;
  512. }
  513. /*
  514. * function: zfcp_fsf_fsfstatus_eval
  515. *
  516. * purpose: evaluates FSF status of completed FSF request
  517. * and acts accordingly
  518. *
  519. * returns:
  520. */
  521. static int
  522. zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *fsf_req)
  523. {
  524. int retval = 0;
  525. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
  526. goto skip_fsfstatus;
  527. }
  528. /* evaluate FSF Status */
  529. switch (fsf_req->qtcb->header.fsf_status) {
  530. case FSF_UNKNOWN_COMMAND:
  531. ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
  532. "not known by the adapter %s "
  533. "Stopping all operations on this adapter. "
  534. "(debug info 0x%x).\n",
  535. zfcp_get_busid_by_adapter(fsf_req->adapter),
  536. fsf_req->qtcb->header.fsf_command);
  537. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  538. "fsf_s_unknown");
  539. zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);
  540. zfcp_cmd_dbf_event_fsf("unknownc", fsf_req,
  541. &fsf_req->qtcb->header.fsf_status_qual,
  542. sizeof (union fsf_status_qual));
  543. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  544. break;
  545. case FSF_FCP_RSP_AVAILABLE:
  546. ZFCP_LOG_DEBUG("FCP Sense data will be presented to the "
  547. "SCSI stack.\n");
  548. debug_text_event(fsf_req->adapter->erp_dbf, 3, "fsf_s_rsp");
  549. break;
  550. case FSF_ADAPTER_STATUS_AVAILABLE:
  551. debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_astatus");
  552. zfcp_fsf_fsfstatus_qual_eval(fsf_req);
  553. break;
  554. default:
  555. break;
  556. }
  557. skip_fsfstatus:
  558. /*
  559. * always call specific handlers to give them a chance to do
  560. * something meaningful even in error cases
  561. */
  562. zfcp_fsf_req_dispatch(fsf_req);
  563. return retval;
  564. }
  565. /*
  566. * function: zfcp_fsf_fsfstatus_qual_eval
  567. *
  568. * purpose: evaluates FSF status-qualifier of completed FSF request
  569. * and acts accordingly
  570. *
  571. * returns:
  572. */
  573. static int
  574. zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *fsf_req)
  575. {
  576. int retval = 0;
  577. switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) {
  578. case FSF_SQ_FCP_RSP_AVAILABLE:
  579. debug_text_event(fsf_req->adapter->erp_dbf, 4, "fsf_sq_rsp");
  580. break;
  581. case FSF_SQ_RETRY_IF_POSSIBLE:
  582. /* The SCSI-stack may now issue retries or escalate */
  583. debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_retry");
  584. zfcp_cmd_dbf_event_fsf("sqretry", fsf_req,
  585. &fsf_req->qtcb->header.fsf_status_qual,
  586. sizeof (union fsf_status_qual));
  587. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  588. break;
  589. case FSF_SQ_COMMAND_ABORTED:
  590. /* Carry the aborted state on to upper layer */
  591. debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_sq_abort");
  592. zfcp_cmd_dbf_event_fsf("sqabort", fsf_req,
  593. &fsf_req->qtcb->header.fsf_status_qual,
  594. sizeof (union fsf_status_qual));
  595. fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTED;
  596. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  597. break;
  598. case FSF_SQ_NO_RECOM:
  599. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  600. "fsf_sq_no_rec");
  601. ZFCP_LOG_NORMAL("bug: No recommendation could be given for a"
  602. "problem on the adapter %s "
  603. "Stopping all operations on this adapter. ",
  604. zfcp_get_busid_by_adapter(fsf_req->adapter));
  605. zfcp_erp_adapter_shutdown(fsf_req->adapter, 0);
  606. zfcp_cmd_dbf_event_fsf("sqnrecom", fsf_req,
  607. &fsf_req->qtcb->header.fsf_status_qual,
  608. sizeof (union fsf_status_qual));
  609. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  610. break;
  611. case FSF_SQ_ULP_PROGRAMMING_ERROR:
  612. ZFCP_LOG_NORMAL("error: not enough SBALs for data transfer "
  613. "(adapter %s)\n",
  614. zfcp_get_busid_by_adapter(fsf_req->adapter));
  615. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  616. "fsf_sq_ulp_err");
  617. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  618. break;
  619. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  620. case FSF_SQ_NO_RETRY_POSSIBLE:
  621. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  622. /* dealt with in the respective functions */
  623. break;
  624. default:
  625. ZFCP_LOG_NORMAL("bug: Additional status info could "
  626. "not be interpreted properly.\n");
  627. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
  628. (char *) &fsf_req->qtcb->header.fsf_status_qual,
  629. sizeof (union fsf_status_qual));
  630. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval:");
  631. debug_exception(fsf_req->adapter->erp_dbf, 0,
  632. &fsf_req->qtcb->header.fsf_status_qual.word[0],
  633. sizeof (u32));
  634. zfcp_cmd_dbf_event_fsf("squndef", fsf_req,
  635. &fsf_req->qtcb->header.fsf_status_qual,
  636. sizeof (union fsf_status_qual));
  637. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  638. break;
  639. }
  640. return retval;
  641. }
  642. /*
  643. * function: zfcp_fsf_req_dispatch
  644. *
  645. * purpose: calls the appropriate command specific handler
  646. *
  647. * returns:
  648. */
  649. static int
  650. zfcp_fsf_req_dispatch(struct zfcp_fsf_req *fsf_req)
  651. {
  652. struct zfcp_erp_action *erp_action = fsf_req->erp_action;
  653. struct zfcp_adapter *adapter = fsf_req->adapter;
  654. int retval = 0;
  655. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
  656. ZFCP_LOG_TRACE("fsf_req=%p, QTCB=%p\n", fsf_req, fsf_req->qtcb);
  657. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
  658. (char *) fsf_req->qtcb, sizeof(struct fsf_qtcb));
  659. }
  660. switch (fsf_req->fsf_command) {
  661. case FSF_QTCB_FCP_CMND:
  662. zfcp_fsf_send_fcp_command_handler(fsf_req);
  663. break;
  664. case FSF_QTCB_ABORT_FCP_CMND:
  665. zfcp_fsf_abort_fcp_command_handler(fsf_req);
  666. break;
  667. case FSF_QTCB_SEND_GENERIC:
  668. zfcp_fsf_send_ct_handler(fsf_req);
  669. break;
  670. case FSF_QTCB_OPEN_PORT_WITH_DID:
  671. zfcp_fsf_open_port_handler(fsf_req);
  672. break;
  673. case FSF_QTCB_OPEN_LUN:
  674. zfcp_fsf_open_unit_handler(fsf_req);
  675. break;
  676. case FSF_QTCB_CLOSE_LUN:
  677. zfcp_fsf_close_unit_handler(fsf_req);
  678. break;
  679. case FSF_QTCB_CLOSE_PORT:
  680. zfcp_fsf_close_port_handler(fsf_req);
  681. break;
  682. case FSF_QTCB_CLOSE_PHYSICAL_PORT:
  683. zfcp_fsf_close_physical_port_handler(fsf_req);
  684. break;
  685. case FSF_QTCB_EXCHANGE_CONFIG_DATA:
  686. zfcp_fsf_exchange_config_data_handler(fsf_req);
  687. break;
  688. case FSF_QTCB_EXCHANGE_PORT_DATA:
  689. zfcp_fsf_exchange_port_data_handler(fsf_req);
  690. break;
  691. case FSF_QTCB_SEND_ELS:
  692. zfcp_fsf_send_els_handler(fsf_req);
  693. break;
  694. case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
  695. zfcp_fsf_control_file_handler(fsf_req);
  696. break;
  697. case FSF_QTCB_UPLOAD_CONTROL_FILE:
  698. zfcp_fsf_control_file_handler(fsf_req);
  699. break;
  700. default:
  701. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  702. ZFCP_LOG_NORMAL("bug: Command issued by the device driver is "
  703. "not supported by the adapter %s\n",
  704. zfcp_get_busid_by_adapter(fsf_req->adapter));
  705. if (fsf_req->fsf_command != fsf_req->qtcb->header.fsf_command)
  706. ZFCP_LOG_NORMAL
  707. ("bug: Command issued by the device driver differs "
  708. "from the command returned by the adapter %s "
  709. "(debug info 0x%x, 0x%x).\n",
  710. zfcp_get_busid_by_adapter(fsf_req->adapter),
  711. fsf_req->fsf_command,
  712. fsf_req->qtcb->header.fsf_command);
  713. }
  714. if (!erp_action)
  715. return retval;
  716. debug_text_event(adapter->erp_dbf, 3, "a_frh");
  717. debug_event(adapter->erp_dbf, 3, &erp_action->action, sizeof (int));
  718. zfcp_erp_async_handler(erp_action, 0);
  719. return retval;
  720. }
  721. /*
  722. * function: zfcp_fsf_status_read
  723. *
  724. * purpose: initiates a Status Read command at the specified adapter
  725. *
  726. * returns:
  727. */
  728. int
  729. zfcp_fsf_status_read(struct zfcp_adapter *adapter, int req_flags)
  730. {
  731. struct zfcp_fsf_req *fsf_req;
  732. struct fsf_status_read_buffer *status_buffer;
  733. unsigned long lock_flags;
  734. volatile struct qdio_buffer_element *sbale;
  735. int retval = 0;
  736. /* setup new FSF request */
  737. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_UNSOLICITED_STATUS,
  738. req_flags | ZFCP_REQ_NO_QTCB,
  739. adapter->pool.fsf_req_status_read,
  740. &lock_flags, &fsf_req);
  741. if (retval < 0) {
  742. ZFCP_LOG_INFO("error: Could not create unsolicited status "
  743. "buffer for adapter %s.\n",
  744. zfcp_get_busid_by_adapter(adapter));
  745. goto failed_req_create;
  746. }
  747. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  748. sbale[0].flags |= SBAL_FLAGS0_TYPE_STATUS;
  749. sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
  750. fsf_req->sbale_curr = 2;
  751. status_buffer =
  752. mempool_alloc(adapter->pool.data_status_read, GFP_ATOMIC);
  753. if (!status_buffer) {
  754. ZFCP_LOG_NORMAL("bug: could not get some buffer\n");
  755. goto failed_buf;
  756. }
  757. memset(status_buffer, 0, sizeof (struct fsf_status_read_buffer));
  758. fsf_req->data.status_read.buffer = status_buffer;
  759. /* insert pointer to respective buffer */
  760. sbale = zfcp_qdio_sbale_curr(fsf_req);
  761. sbale->addr = (void *) status_buffer;
  762. sbale->length = sizeof(struct fsf_status_read_buffer);
  763. /* start QDIO request for this FSF request */
  764. retval = zfcp_fsf_req_send(fsf_req, NULL);
  765. if (retval) {
  766. ZFCP_LOG_DEBUG("error: Could not set-up unsolicited status "
  767. "environment.\n");
  768. goto failed_req_send;
  769. }
  770. ZFCP_LOG_TRACE("Status Read request initiated (adapter%s)\n",
  771. zfcp_get_busid_by_adapter(adapter));
  772. goto out;
  773. failed_req_send:
  774. mempool_free(status_buffer, adapter->pool.data_status_read);
  775. failed_buf:
  776. zfcp_fsf_req_free(fsf_req);
  777. failed_req_create:
  778. out:
  779. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  780. return retval;
  781. }
  782. static int
  783. zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *fsf_req)
  784. {
  785. struct fsf_status_read_buffer *status_buffer;
  786. struct zfcp_adapter *adapter;
  787. struct zfcp_port *port;
  788. unsigned long flags;
  789. status_buffer = fsf_req->data.status_read.buffer;
  790. adapter = fsf_req->adapter;
  791. read_lock_irqsave(&zfcp_data.config_lock, flags);
  792. list_for_each_entry(port, &adapter->port_list_head, list)
  793. if (port->d_id == (status_buffer->d_id & ZFCP_DID_MASK))
  794. break;
  795. read_unlock_irqrestore(&zfcp_data.config_lock, flags);
  796. if (!port || (port->d_id != (status_buffer->d_id & ZFCP_DID_MASK))) {
  797. ZFCP_LOG_NORMAL("bug: Reopen port indication received for"
  798. "nonexisting port with d_id 0x%08x on "
  799. "adapter %s. Ignored.\n",
  800. status_buffer->d_id & ZFCP_DID_MASK,
  801. zfcp_get_busid_by_adapter(adapter));
  802. goto out;
  803. }
  804. switch (status_buffer->status_subtype) {
  805. case FSF_STATUS_READ_SUB_CLOSE_PHYS_PORT:
  806. debug_text_event(adapter->erp_dbf, 3, "unsol_pc_phys:");
  807. zfcp_erp_port_reopen(port, 0);
  808. break;
  809. case FSF_STATUS_READ_SUB_ERROR_PORT:
  810. debug_text_event(adapter->erp_dbf, 1, "unsol_pc_err:");
  811. zfcp_erp_port_shutdown(port, 0);
  812. break;
  813. default:
  814. debug_text_event(adapter->erp_dbf, 0, "unsol_unk_sub:");
  815. debug_exception(adapter->erp_dbf, 0,
  816. &status_buffer->status_subtype, sizeof (u32));
  817. ZFCP_LOG_NORMAL("bug: Undefined status subtype received "
  818. "for a reopen indication on port with "
  819. "d_id 0x%08x on the adapter %s. "
  820. "Ignored. (debug info 0x%x)\n",
  821. status_buffer->d_id,
  822. zfcp_get_busid_by_adapter(adapter),
  823. status_buffer->status_subtype);
  824. }
  825. out:
  826. return 0;
  827. }
  828. /*
  829. * function: zfcp_fsf_status_read_handler
  830. *
  831. * purpose: is called for finished Open Port command
  832. *
  833. * returns:
  834. */
  835. static int
  836. zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
  837. {
  838. int retval = 0;
  839. struct zfcp_adapter *adapter = fsf_req->adapter;
  840. struct fsf_status_read_buffer *status_buffer =
  841. fsf_req->data.status_read.buffer;
  842. if (fsf_req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
  843. mempool_free(status_buffer, adapter->pool.data_status_read);
  844. zfcp_fsf_req_cleanup(fsf_req);
  845. goto out;
  846. }
  847. switch (status_buffer->status_type) {
  848. case FSF_STATUS_READ_PORT_CLOSED:
  849. debug_text_event(adapter->erp_dbf, 3, "unsol_pclosed:");
  850. debug_event(adapter->erp_dbf, 3,
  851. &status_buffer->d_id, sizeof (u32));
  852. zfcp_fsf_status_read_port_closed(fsf_req);
  853. break;
  854. case FSF_STATUS_READ_INCOMING_ELS:
  855. debug_text_event(adapter->erp_dbf, 3, "unsol_els:");
  856. zfcp_fsf_incoming_els(fsf_req);
  857. break;
  858. case FSF_STATUS_READ_SENSE_DATA_AVAIL:
  859. debug_text_event(adapter->erp_dbf, 3, "unsol_sense:");
  860. ZFCP_LOG_INFO("unsolicited sense data received (adapter %s)\n",
  861. zfcp_get_busid_by_adapter(adapter));
  862. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL, (char *) status_buffer,
  863. sizeof(struct fsf_status_read_buffer));
  864. break;
  865. case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
  866. debug_text_event(adapter->erp_dbf, 3, "unsol_bit_err:");
  867. ZFCP_LOG_NORMAL("Bit error threshold data received:\n");
  868. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
  869. (char *) status_buffer,
  870. sizeof (struct fsf_status_read_buffer));
  871. break;
  872. case FSF_STATUS_READ_LINK_DOWN:
  873. debug_text_event(adapter->erp_dbf, 0, "unsol_link_down:");
  874. ZFCP_LOG_INFO("Local link to adapter %s is down\n",
  875. zfcp_get_busid_by_adapter(adapter));
  876. atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
  877. &adapter->status);
  878. zfcp_erp_adapter_failed(adapter);
  879. break;
  880. case FSF_STATUS_READ_LINK_UP:
  881. debug_text_event(adapter->erp_dbf, 2, "unsol_link_up:");
  882. ZFCP_LOG_INFO("Local link to adapter %s was replugged. "
  883. "Restarting operations on this adapter\n",
  884. zfcp_get_busid_by_adapter(adapter));
  885. /* All ports should be marked as ready to run again */
  886. zfcp_erp_modify_adapter_status(adapter,
  887. ZFCP_STATUS_COMMON_RUNNING,
  888. ZFCP_SET);
  889. zfcp_erp_adapter_reopen(adapter,
  890. ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED
  891. | ZFCP_STATUS_COMMON_ERP_FAILED);
  892. break;
  893. case FSF_STATUS_READ_CFDC_UPDATED:
  894. debug_text_event(adapter->erp_dbf, 2, "unsol_cfdc_update:");
  895. ZFCP_LOG_INFO("CFDC has been updated on the adapter %s\n",
  896. zfcp_get_busid_by_adapter(adapter));
  897. zfcp_erp_adapter_access_changed(adapter);
  898. break;
  899. case FSF_STATUS_READ_CFDC_HARDENED:
  900. debug_text_event(adapter->erp_dbf, 2, "unsol_cfdc_harden:");
  901. switch (status_buffer->status_subtype) {
  902. case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE:
  903. ZFCP_LOG_INFO("CFDC of adapter %s saved on SE\n",
  904. zfcp_get_busid_by_adapter(adapter));
  905. break;
  906. case FSF_STATUS_READ_SUB_CFDC_HARDENED_ON_SE2:
  907. ZFCP_LOG_INFO("CFDC of adapter %s has been copied "
  908. "to the secondary SE\n",
  909. zfcp_get_busid_by_adapter(adapter));
  910. break;
  911. default:
  912. ZFCP_LOG_INFO("CFDC of adapter %s has been hardened\n",
  913. zfcp_get_busid_by_adapter(adapter));
  914. }
  915. break;
  916. default:
  917. debug_text_event(adapter->erp_dbf, 0, "unsol_unknown:");
  918. debug_exception(adapter->erp_dbf, 0,
  919. &status_buffer->status_type, sizeof (u32));
  920. ZFCP_LOG_NORMAL("bug: An unsolicited status packet of unknown "
  921. "type was received (debug info 0x%x)\n",
  922. status_buffer->status_type);
  923. ZFCP_LOG_DEBUG("Dump of status_read_buffer %p:\n",
  924. status_buffer);
  925. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  926. (char *) status_buffer,
  927. sizeof (struct fsf_status_read_buffer));
  928. break;
  929. }
  930. mempool_free(status_buffer, adapter->pool.data_status_read);
  931. zfcp_fsf_req_cleanup(fsf_req);
  932. /*
  933. * recycle buffer and start new request repeat until outbound
  934. * queue is empty or adapter shutdown is requested
  935. */
  936. /*
  937. * FIXME(qdio):
  938. * we may wait in the req_create for 5s during shutdown, so
  939. * qdio_cleanup will have to wait at least that long before returning
  940. * with failure to allow us a proper cleanup under all circumstances
  941. */
  942. /*
  943. * FIXME:
  944. * allocation failure possible? (Is this code needed?)
  945. */
  946. retval = zfcp_fsf_status_read(adapter, 0);
  947. if (retval < 0) {
  948. ZFCP_LOG_INFO("Failed to create unsolicited status read "
  949. "request for the adapter %s.\n",
  950. zfcp_get_busid_by_adapter(adapter));
  951. /* temporary fix to avoid status read buffer shortage */
  952. adapter->status_read_failed++;
  953. if ((ZFCP_STATUS_READS_RECOM - adapter->status_read_failed)
  954. < ZFCP_STATUS_READ_FAILED_THRESHOLD) {
  955. ZFCP_LOG_INFO("restart adapter %s due to status read "
  956. "buffer shortage\n",
  957. zfcp_get_busid_by_adapter(adapter));
  958. zfcp_erp_adapter_reopen(adapter, 0);
  959. }
  960. }
  961. out:
  962. return retval;
  963. }
  964. /*
  965. * function: zfcp_fsf_abort_fcp_command
  966. *
  967. * purpose: tells FSF to abort a running SCSI command
  968. *
  969. * returns: address of initiated FSF request
  970. * NULL - request could not be initiated
  971. *
  972. * FIXME(design): should be watched by a timeout !!!
  973. * FIXME(design) shouldn't this be modified to return an int
  974. * also...don't know how though
  975. */
  976. struct zfcp_fsf_req *
  977. zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
  978. struct zfcp_adapter *adapter,
  979. struct zfcp_unit *unit, int req_flags)
  980. {
  981. volatile struct qdio_buffer_element *sbale;
  982. unsigned long lock_flags;
  983. struct zfcp_fsf_req *fsf_req = NULL;
  984. int retval = 0;
  985. /* setup new FSF request */
  986. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND,
  987. req_flags, adapter->pool.fsf_req_abort,
  988. &lock_flags, &fsf_req);
  989. if (retval < 0) {
  990. ZFCP_LOG_INFO("error: Failed to create an abort command "
  991. "request for lun 0x%016Lx on port 0x%016Lx "
  992. "on adapter %s.\n",
  993. unit->fcp_lun,
  994. unit->port->wwpn,
  995. zfcp_get_busid_by_adapter(adapter));
  996. goto out;
  997. }
  998. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  999. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1000. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1001. fsf_req->data.abort_fcp_command.unit = unit;
  1002. /* set handles of unit and its parent port in QTCB */
  1003. fsf_req->qtcb->header.lun_handle = unit->handle;
  1004. fsf_req->qtcb->header.port_handle = unit->port->handle;
  1005. /* set handle of request which should be aborted */
  1006. fsf_req->qtcb->bottom.support.req_handle = (u64) old_req_id;
  1007. /* start QDIO request for this FSF request */
  1008. zfcp_fsf_start_scsi_er_timer(adapter);
  1009. retval = zfcp_fsf_req_send(fsf_req, NULL);
  1010. if (retval) {
  1011. del_timer(&adapter->scsi_er_timer);
  1012. ZFCP_LOG_INFO("error: Failed to send abort command request "
  1013. "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
  1014. zfcp_get_busid_by_adapter(adapter),
  1015. unit->port->wwpn, unit->fcp_lun);
  1016. zfcp_fsf_req_free(fsf_req);
  1017. fsf_req = NULL;
  1018. goto out;
  1019. }
  1020. ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
  1021. "(adapter%s, port d_id=0x%08x, "
  1022. "unit x%016Lx, old_req_id=0x%lx)\n",
  1023. zfcp_get_busid_by_adapter(adapter),
  1024. unit->port->d_id,
  1025. unit->fcp_lun, old_req_id);
  1026. out:
  1027. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  1028. return fsf_req;
  1029. }
  1030. /*
  1031. * function: zfcp_fsf_abort_fcp_command_handler
  1032. *
  1033. * purpose: is called for finished Abort FCP Command request
  1034. *
  1035. * returns:
  1036. */
  1037. static int
  1038. zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
  1039. {
  1040. int retval = -EINVAL;
  1041. struct zfcp_unit *unit = new_fsf_req->data.abort_fcp_command.unit;
  1042. unsigned char status_qual =
  1043. new_fsf_req->qtcb->header.fsf_status_qual.word[0];
  1044. del_timer(&new_fsf_req->adapter->scsi_er_timer);
  1045. if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  1046. /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
  1047. goto skip_fsfstatus;
  1048. }
  1049. /* evaluate FSF status in QTCB */
  1050. switch (new_fsf_req->qtcb->header.fsf_status) {
  1051. case FSF_PORT_HANDLE_NOT_VALID:
  1052. if (status_qual >> 4 != status_qual % 0xf) {
  1053. debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
  1054. "fsf_s_phand_nv0");
  1055. /*
  1056. * In this case a command that was sent prior to a port
  1057. * reopen was aborted (handles are different). This is
  1058. * fine.
  1059. */
  1060. } else {
  1061. ZFCP_LOG_INFO("Temporary port identifier 0x%x for "
  1062. "port 0x%016Lx on adapter %s invalid. "
  1063. "This may happen occasionally.\n",
  1064. unit->port->handle,
  1065. unit->port->wwpn,
  1066. zfcp_get_busid_by_unit(unit));
  1067. ZFCP_LOG_INFO("status qualifier:\n");
  1068. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
  1069. (char *) &new_fsf_req->qtcb->header.
  1070. fsf_status_qual,
  1071. sizeof (union fsf_status_qual));
  1072. /* Let's hope this sorts out the mess */
  1073. debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
  1074. "fsf_s_phand_nv1");
  1075. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  1076. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1077. }
  1078. break;
  1079. case FSF_LUN_HANDLE_NOT_VALID:
  1080. if (status_qual >> 4 != status_qual % 0xf) {
  1081. /* 2 */
  1082. debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
  1083. "fsf_s_lhand_nv0");
  1084. /*
  1085. * In this case a command that was sent prior to a unit
  1086. * reopen was aborted (handles are different).
  1087. * This is fine.
  1088. */
  1089. } else {
  1090. ZFCP_LOG_INFO
  1091. ("Warning: Temporary LUN identifier 0x%x of LUN "
  1092. "0x%016Lx on port 0x%016Lx on adapter %s is "
  1093. "invalid. This may happen in rare cases. "
  1094. "Trying to re-establish link.\n",
  1095. unit->handle,
  1096. unit->fcp_lun,
  1097. unit->port->wwpn,
  1098. zfcp_get_busid_by_unit(unit));
  1099. ZFCP_LOG_DEBUG("Status qualifier data:\n");
  1100. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  1101. (char *) &new_fsf_req->qtcb->header.
  1102. fsf_status_qual,
  1103. sizeof (union fsf_status_qual));
  1104. /* Let's hope this sorts out the mess */
  1105. debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
  1106. "fsf_s_lhand_nv1");
  1107. zfcp_erp_port_reopen(unit->port, 0);
  1108. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1109. }
  1110. break;
  1111. case FSF_FCP_COMMAND_DOES_NOT_EXIST:
  1112. retval = 0;
  1113. debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
  1114. "fsf_s_no_exist");
  1115. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
  1116. break;
  1117. case FSF_PORT_BOXED:
  1118. ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to "
  1119. "be reopened\n", unit->port->wwpn,
  1120. zfcp_get_busid_by_unit(unit));
  1121. debug_text_event(new_fsf_req->adapter->erp_dbf, 2,
  1122. "fsf_s_pboxed");
  1123. zfcp_erp_port_reopen(unit->port, 0);
  1124. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
  1125. | ZFCP_STATUS_FSFREQ_RETRY;
  1126. break;
  1127. case FSF_LUN_BOXED:
  1128. ZFCP_LOG_INFO(
  1129. "unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
  1130. "to be reopened\n",
  1131. unit->fcp_lun, unit->port->wwpn,
  1132. zfcp_get_busid_by_unit(unit));
  1133. debug_text_event(new_fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed");
  1134. zfcp_erp_unit_reopen(unit, 0);
  1135. zfcp_cmd_dbf_event_fsf("unitbox", new_fsf_req,
  1136. &new_fsf_req->qtcb->header.fsf_status_qual,
  1137. sizeof(union fsf_status_qual));
  1138. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
  1139. | ZFCP_STATUS_FSFREQ_RETRY;
  1140. break;
  1141. case FSF_ADAPTER_STATUS_AVAILABLE:
  1142. switch (new_fsf_req->qtcb->header.fsf_status_qual.word[0]) {
  1143. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1144. debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
  1145. "fsf_sq_ltest");
  1146. zfcp_test_link(unit->port);
  1147. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1148. break;
  1149. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1150. /* SCSI stack will escalate */
  1151. debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
  1152. "fsf_sq_ulp");
  1153. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1154. break;
  1155. default:
  1156. ZFCP_LOG_NORMAL
  1157. ("bug: Wrong status qualifier 0x%x arrived.\n",
  1158. new_fsf_req->qtcb->header.fsf_status_qual.word[0]);
  1159. debug_text_event(new_fsf_req->adapter->erp_dbf, 0,
  1160. "fsf_sq_inval:");
  1161. debug_exception(new_fsf_req->adapter->erp_dbf, 0,
  1162. &new_fsf_req->qtcb->header.
  1163. fsf_status_qual.word[0], sizeof (u32));
  1164. break;
  1165. }
  1166. break;
  1167. case FSF_GOOD:
  1168. retval = 0;
  1169. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED;
  1170. break;
  1171. default:
  1172. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  1173. "(debug info 0x%x)\n",
  1174. new_fsf_req->qtcb->header.fsf_status);
  1175. debug_text_event(new_fsf_req->adapter->erp_dbf, 0,
  1176. "fsf_s_inval:");
  1177. debug_exception(new_fsf_req->adapter->erp_dbf, 0,
  1178. &new_fsf_req->qtcb->header.fsf_status,
  1179. sizeof (u32));
  1180. break;
  1181. }
  1182. skip_fsfstatus:
  1183. return retval;
  1184. }
  1185. /**
  1186. * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into
  1187. * one SBALE
  1188. * Two scatter-gather lists are passed, one for the reqeust and one for the
  1189. * response.
  1190. */
  1191. static inline int
  1192. zfcp_use_one_sbal(struct scatterlist *req, int req_count,
  1193. struct scatterlist *resp, int resp_count)
  1194. {
  1195. return ((req_count == 1) &&
  1196. (resp_count == 1) &&
  1197. (((unsigned long) zfcp_sg_to_address(&req[0]) &
  1198. PAGE_MASK) ==
  1199. ((unsigned long) (zfcp_sg_to_address(&req[0]) +
  1200. req[0].length - 1) & PAGE_MASK)) &&
  1201. (((unsigned long) zfcp_sg_to_address(&resp[0]) &
  1202. PAGE_MASK) ==
  1203. ((unsigned long) (zfcp_sg_to_address(&resp[0]) +
  1204. resp[0].length - 1) & PAGE_MASK)));
  1205. }
  1206. /**
  1207. * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
  1208. * @ct: pointer to struct zfcp_send_ct which conatins all needed data for
  1209. * the request
  1210. * @pool: pointer to memory pool, if non-null this pool is used to allocate
  1211. * a struct zfcp_fsf_req
  1212. * @erp_action: pointer to erp_action, if non-null the Generic Service request
  1213. * is sent within error recovery
  1214. */
  1215. int
  1216. zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
  1217. struct zfcp_erp_action *erp_action)
  1218. {
  1219. volatile struct qdio_buffer_element *sbale;
  1220. struct zfcp_port *port;
  1221. struct zfcp_adapter *adapter;
  1222. struct zfcp_fsf_req *fsf_req;
  1223. unsigned long lock_flags;
  1224. int bytes;
  1225. int ret = 0;
  1226. port = ct->port;
  1227. adapter = port->adapter;
  1228. ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_GENERIC,
  1229. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  1230. pool, &lock_flags, &fsf_req);
  1231. if (ret < 0) {
  1232. ZFCP_LOG_INFO("error: Could not create CT request (FC-GS) for "
  1233. "adapter: %s\n",
  1234. zfcp_get_busid_by_adapter(adapter));
  1235. goto failed_req;
  1236. }
  1237. if (erp_action != NULL) {
  1238. erp_action->fsf_req = fsf_req;
  1239. fsf_req->erp_action = erp_action;
  1240. }
  1241. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  1242. if (zfcp_use_one_sbal(ct->req, ct->req_count,
  1243. ct->resp, ct->resp_count)){
  1244. /* both request buffer and response buffer
  1245. fit into one sbale each */
  1246. sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
  1247. sbale[2].addr = zfcp_sg_to_address(&ct->req[0]);
  1248. sbale[2].length = ct->req[0].length;
  1249. sbale[3].addr = zfcp_sg_to_address(&ct->resp[0]);
  1250. sbale[3].length = ct->resp[0].length;
  1251. sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
  1252. } else if (adapter->supported_features &
  1253. FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
  1254. /* try to use chained SBALs */
  1255. bytes = zfcp_qdio_sbals_from_sg(fsf_req,
  1256. SBAL_FLAGS0_TYPE_WRITE_READ,
  1257. ct->req, ct->req_count,
  1258. ZFCP_MAX_SBALS_PER_CT_REQ);
  1259. if (bytes <= 0) {
  1260. ZFCP_LOG_INFO("error: creation of CT request failed "
  1261. "on adapter %s\n",
  1262. zfcp_get_busid_by_adapter(adapter));
  1263. if (bytes == 0)
  1264. ret = -ENOMEM;
  1265. else
  1266. ret = bytes;
  1267. goto failed_send;
  1268. }
  1269. fsf_req->qtcb->bottom.support.req_buf_length = bytes;
  1270. fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
  1271. bytes = zfcp_qdio_sbals_from_sg(fsf_req,
  1272. SBAL_FLAGS0_TYPE_WRITE_READ,
  1273. ct->resp, ct->resp_count,
  1274. ZFCP_MAX_SBALS_PER_CT_REQ);
  1275. if (bytes <= 0) {
  1276. ZFCP_LOG_INFO("error: creation of CT request failed "
  1277. "on adapter %s\n",
  1278. zfcp_get_busid_by_adapter(adapter));
  1279. if (bytes == 0)
  1280. ret = -ENOMEM;
  1281. else
  1282. ret = bytes;
  1283. goto failed_send;
  1284. }
  1285. fsf_req->qtcb->bottom.support.resp_buf_length = bytes;
  1286. } else {
  1287. /* reject send generic request */
  1288. ZFCP_LOG_INFO(
  1289. "error: microcode does not support chained SBALs,"
  1290. "CT request too big (adapter %s)\n",
  1291. zfcp_get_busid_by_adapter(adapter));
  1292. ret = -EOPNOTSUPP;
  1293. goto failed_send;
  1294. }
  1295. /* settings in QTCB */
  1296. fsf_req->qtcb->header.port_handle = port->handle;
  1297. fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class;
  1298. fsf_req->qtcb->bottom.support.timeout = ct->timeout;
  1299. fsf_req->data.send_ct = ct;
  1300. /* start QDIO request for this FSF request */
  1301. ret = zfcp_fsf_req_send(fsf_req, ct->timer);
  1302. if (ret) {
  1303. ZFCP_LOG_DEBUG("error: initiation of CT request failed "
  1304. "(adapter %s, port 0x%016Lx)\n",
  1305. zfcp_get_busid_by_adapter(adapter), port->wwpn);
  1306. goto failed_send;
  1307. }
  1308. ZFCP_LOG_DEBUG("CT request initiated (adapter %s, port 0x%016Lx)\n",
  1309. zfcp_get_busid_by_adapter(adapter), port->wwpn);
  1310. goto out;
  1311. failed_send:
  1312. zfcp_fsf_req_free(fsf_req);
  1313. if (erp_action != NULL) {
  1314. erp_action->fsf_req = NULL;
  1315. }
  1316. failed_req:
  1317. out:
  1318. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  1319. lock_flags);
  1320. return ret;
  1321. }
  1322. /**
  1323. * zfcp_fsf_send_ct_handler - handler for Generic Service requests
  1324. * @fsf_req: pointer to struct zfcp_fsf_req
  1325. *
  1326. * Data specific for the Generic Service request is passed by
  1327. * fsf_req->data.send_ct
  1328. * Usually a specific handler for the request is called via
  1329. * fsf_req->data.send_ct->handler at end of this function.
  1330. */
  1331. static int
  1332. zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
  1333. {
  1334. struct zfcp_port *port;
  1335. struct zfcp_adapter *adapter;
  1336. struct zfcp_send_ct *send_ct;
  1337. struct fsf_qtcb_header *header;
  1338. struct fsf_qtcb_bottom_support *bottom;
  1339. int retval = -EINVAL;
  1340. u16 subtable, rule, counter;
  1341. adapter = fsf_req->adapter;
  1342. send_ct = fsf_req->data.send_ct;
  1343. port = send_ct->port;
  1344. header = &fsf_req->qtcb->header;
  1345. bottom = &fsf_req->qtcb->bottom.support;
  1346. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1347. goto skip_fsfstatus;
  1348. /* evaluate FSF status in QTCB */
  1349. switch (header->fsf_status) {
  1350. case FSF_GOOD:
  1351. retval = 0;
  1352. break;
  1353. case FSF_SERVICE_CLASS_NOT_SUPPORTED:
  1354. if (adapter->fc_service_class <= 3) {
  1355. ZFCP_LOG_INFO("error: adapter %s does not support fc "
  1356. "class %d.\n",
  1357. zfcp_get_busid_by_port(port),
  1358. adapter->fc_service_class);
  1359. } else {
  1360. ZFCP_LOG_INFO("bug: The fibre channel class at the "
  1361. "adapter %s is invalid. "
  1362. "(debug info %d)\n",
  1363. zfcp_get_busid_by_port(port),
  1364. adapter->fc_service_class);
  1365. }
  1366. /* stop operation for this adapter */
  1367. debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
  1368. zfcp_erp_adapter_shutdown(adapter, 0);
  1369. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1370. break;
  1371. case FSF_ADAPTER_STATUS_AVAILABLE:
  1372. switch (header->fsf_status_qual.word[0]){
  1373. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1374. /* reopening link to port */
  1375. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
  1376. zfcp_test_link(port);
  1377. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1378. break;
  1379. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1380. /* ERP strategy will escalate */
  1381. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
  1382. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1383. break;
  1384. default:
  1385. ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x "
  1386. "arrived.\n",
  1387. header->fsf_status_qual.word[0]);
  1388. break;
  1389. }
  1390. break;
  1391. case FSF_ACCESS_DENIED:
  1392. ZFCP_LOG_NORMAL("access denied, cannot send generic service "
  1393. "command (adapter %s, port d_id=0x%08x)\n",
  1394. zfcp_get_busid_by_port(port), port->d_id);
  1395. for (counter = 0; counter < 2; counter++) {
  1396. subtable = header->fsf_status_qual.halfword[counter * 2];
  1397. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  1398. switch (subtable) {
  1399. case FSF_SQ_CFDC_SUBTABLE_OS:
  1400. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  1401. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  1402. case FSF_SQ_CFDC_SUBTABLE_LUN:
  1403. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  1404. zfcp_act_subtable_type[subtable], rule);
  1405. break;
  1406. }
  1407. }
  1408. debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
  1409. zfcp_erp_port_access_denied(port);
  1410. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1411. break;
  1412. case FSF_GENERIC_COMMAND_REJECTED:
  1413. ZFCP_LOG_INFO("generic service command rejected "
  1414. "(adapter %s, port d_id=0x%08x)\n",
  1415. zfcp_get_busid_by_port(port), port->d_id);
  1416. ZFCP_LOG_INFO("status qualifier:\n");
  1417. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
  1418. (char *) &header->fsf_status_qual,
  1419. sizeof (union fsf_status_qual));
  1420. debug_text_event(adapter->erp_dbf, 1, "fsf_s_gcom_rej");
  1421. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1422. break;
  1423. case FSF_PORT_HANDLE_NOT_VALID:
  1424. ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port "
  1425. "0x%016Lx on adapter %s invalid. This may "
  1426. "happen occasionally.\n", port->handle,
  1427. port->wwpn, zfcp_get_busid_by_port(port));
  1428. ZFCP_LOG_INFO("status qualifier:\n");
  1429. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
  1430. (char *) &header->fsf_status_qual,
  1431. sizeof (union fsf_status_qual));
  1432. debug_text_event(adapter->erp_dbf, 1, "fsf_s_phandle_nv");
  1433. zfcp_erp_adapter_reopen(adapter, 0);
  1434. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1435. break;
  1436. case FSF_PORT_BOXED:
  1437. ZFCP_LOG_INFO("port needs to be reopened "
  1438. "(adapter %s, port d_id=0x%08x)\n",
  1439. zfcp_get_busid_by_port(port), port->d_id);
  1440. debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");
  1441. zfcp_erp_port_reopen(port, 0);
  1442. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
  1443. | ZFCP_STATUS_FSFREQ_RETRY;
  1444. break;
  1445. /* following states should never occure, all cases avoided
  1446. in zfcp_fsf_send_ct - but who knows ... */
  1447. case FSF_PAYLOAD_SIZE_MISMATCH:
  1448. ZFCP_LOG_INFO("payload size mismatch (adapter: %s, "
  1449. "req_buf_length=%d, resp_buf_length=%d)\n",
  1450. zfcp_get_busid_by_adapter(adapter),
  1451. bottom->req_buf_length, bottom->resp_buf_length);
  1452. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1453. break;
  1454. case FSF_REQUEST_SIZE_TOO_LARGE:
  1455. ZFCP_LOG_INFO("request size too large (adapter: %s, "
  1456. "req_buf_length=%d)\n",
  1457. zfcp_get_busid_by_adapter(adapter),
  1458. bottom->req_buf_length);
  1459. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1460. break;
  1461. case FSF_RESPONSE_SIZE_TOO_LARGE:
  1462. ZFCP_LOG_INFO("response size too large (adapter: %s, "
  1463. "resp_buf_length=%d)\n",
  1464. zfcp_get_busid_by_adapter(adapter),
  1465. bottom->resp_buf_length);
  1466. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1467. break;
  1468. case FSF_SBAL_MISMATCH:
  1469. ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
  1470. "resp_buf_length=%d)\n",
  1471. zfcp_get_busid_by_adapter(adapter),
  1472. bottom->req_buf_length, bottom->resp_buf_length);
  1473. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1474. break;
  1475. default:
  1476. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  1477. "(debug info 0x%x)\n", header->fsf_status);
  1478. debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval:");
  1479. debug_exception(adapter->erp_dbf, 0,
  1480. &header->fsf_status_qual.word[0], sizeof (u32));
  1481. break;
  1482. }
  1483. skip_fsfstatus:
  1484. send_ct->status = retval;
  1485. if (send_ct->handler != NULL)
  1486. send_ct->handler(send_ct->handler_data);
  1487. return retval;
  1488. }
  1489. /**
  1490. * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
  1491. * @els: pointer to struct zfcp_send_els which contains all needed data for
  1492. * the command.
  1493. */
  1494. int
  1495. zfcp_fsf_send_els(struct zfcp_send_els *els)
  1496. {
  1497. volatile struct qdio_buffer_element *sbale;
  1498. struct zfcp_fsf_req *fsf_req;
  1499. fc_id_t d_id;
  1500. struct zfcp_adapter *adapter;
  1501. unsigned long lock_flags;
  1502. int bytes;
  1503. int ret = 0;
  1504. d_id = els->d_id;
  1505. adapter = els->adapter;
  1506. ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS,
  1507. ZFCP_REQ_AUTO_CLEANUP,
  1508. NULL, &lock_flags, &fsf_req);
  1509. if (ret < 0) {
  1510. ZFCP_LOG_INFO("error: creation of ELS request failed "
  1511. "(adapter %s, port d_id: 0x%08x)\n",
  1512. zfcp_get_busid_by_adapter(adapter), d_id);
  1513. goto failed_req;
  1514. }
  1515. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  1516. if (zfcp_use_one_sbal(els->req, els->req_count,
  1517. els->resp, els->resp_count)){
  1518. /* both request buffer and response buffer
  1519. fit into one sbale each */
  1520. sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
  1521. sbale[2].addr = zfcp_sg_to_address(&els->req[0]);
  1522. sbale[2].length = els->req[0].length;
  1523. sbale[3].addr = zfcp_sg_to_address(&els->resp[0]);
  1524. sbale[3].length = els->resp[0].length;
  1525. sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
  1526. } else if (adapter->supported_features &
  1527. FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
  1528. /* try to use chained SBALs */
  1529. bytes = zfcp_qdio_sbals_from_sg(fsf_req,
  1530. SBAL_FLAGS0_TYPE_WRITE_READ,
  1531. els->req, els->req_count,
  1532. ZFCP_MAX_SBALS_PER_ELS_REQ);
  1533. if (bytes <= 0) {
  1534. ZFCP_LOG_INFO("error: creation of ELS request failed "
  1535. "(adapter %s, port d_id: 0x%08x)\n",
  1536. zfcp_get_busid_by_adapter(adapter), d_id);
  1537. if (bytes == 0) {
  1538. ret = -ENOMEM;
  1539. } else {
  1540. ret = bytes;
  1541. }
  1542. goto failed_send;
  1543. }
  1544. fsf_req->qtcb->bottom.support.req_buf_length = bytes;
  1545. fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
  1546. bytes = zfcp_qdio_sbals_from_sg(fsf_req,
  1547. SBAL_FLAGS0_TYPE_WRITE_READ,
  1548. els->resp, els->resp_count,
  1549. ZFCP_MAX_SBALS_PER_ELS_REQ);
  1550. if (bytes <= 0) {
  1551. ZFCP_LOG_INFO("error: creation of ELS request failed "
  1552. "(adapter %s, port d_id: 0x%08x)\n",
  1553. zfcp_get_busid_by_adapter(adapter), d_id);
  1554. if (bytes == 0) {
  1555. ret = -ENOMEM;
  1556. } else {
  1557. ret = bytes;
  1558. }
  1559. goto failed_send;
  1560. }
  1561. fsf_req->qtcb->bottom.support.resp_buf_length = bytes;
  1562. } else {
  1563. /* reject request */
  1564. ZFCP_LOG_INFO("error: microcode does not support chained SBALs"
  1565. ", ELS request too big (adapter %s, "
  1566. "port d_id: 0x%08x)\n",
  1567. zfcp_get_busid_by_adapter(adapter), d_id);
  1568. ret = -EOPNOTSUPP;
  1569. goto failed_send;
  1570. }
  1571. /* settings in QTCB */
  1572. fsf_req->qtcb->bottom.support.d_id = d_id;
  1573. fsf_req->qtcb->bottom.support.service_class = adapter->fc_service_class;
  1574. fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT;
  1575. fsf_req->data.send_els = els;
  1576. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  1577. /* start QDIO request for this FSF request */
  1578. ret = zfcp_fsf_req_send(fsf_req, els->timer);
  1579. if (ret) {
  1580. ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
  1581. "(adapter %s, port d_id: 0x%08x)\n",
  1582. zfcp_get_busid_by_adapter(adapter), d_id);
  1583. goto failed_send;
  1584. }
  1585. ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port d_id: "
  1586. "0x%08x)\n", zfcp_get_busid_by_adapter(adapter), d_id);
  1587. goto out;
  1588. failed_send:
  1589. zfcp_fsf_req_free(fsf_req);
  1590. failed_req:
  1591. out:
  1592. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  1593. lock_flags);
  1594. return ret;
  1595. }
  1596. /**
  1597. * zfcp_fsf_send_els_handler - handler for ELS commands
  1598. * @fsf_req: pointer to struct zfcp_fsf_req
  1599. *
  1600. * Data specific for the ELS command is passed by
  1601. * fsf_req->data.send_els
  1602. * Usually a specific handler for the command is called via
  1603. * fsf_req->data.send_els->handler at end of this function.
  1604. */
  1605. static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
  1606. {
  1607. struct zfcp_adapter *adapter;
  1608. fc_id_t d_id;
  1609. struct zfcp_port *port;
  1610. struct fsf_qtcb_header *header;
  1611. struct fsf_qtcb_bottom_support *bottom;
  1612. struct zfcp_send_els *send_els;
  1613. int retval = -EINVAL;
  1614. u16 subtable, rule, counter;
  1615. send_els = fsf_req->data.send_els;
  1616. adapter = send_els->adapter;
  1617. d_id = send_els->d_id;
  1618. header = &fsf_req->qtcb->header;
  1619. bottom = &fsf_req->qtcb->bottom.support;
  1620. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1621. goto skip_fsfstatus;
  1622. switch (header->fsf_status) {
  1623. case FSF_GOOD:
  1624. retval = 0;
  1625. break;
  1626. case FSF_SERVICE_CLASS_NOT_SUPPORTED:
  1627. if (adapter->fc_service_class <= 3) {
  1628. ZFCP_LOG_INFO("error: adapter %s does "
  1629. "not support fibrechannel class %d.\n",
  1630. zfcp_get_busid_by_adapter(adapter),
  1631. adapter->fc_service_class);
  1632. } else {
  1633. ZFCP_LOG_INFO("bug: The fibrechannel class at "
  1634. "adapter %s is invalid. "
  1635. "(debug info %d)\n",
  1636. zfcp_get_busid_by_adapter(adapter),
  1637. adapter->fc_service_class);
  1638. }
  1639. /* stop operation for this adapter */
  1640. debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
  1641. zfcp_erp_adapter_shutdown(adapter, 0);
  1642. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1643. break;
  1644. case FSF_ADAPTER_STATUS_AVAILABLE:
  1645. switch (header->fsf_status_qual.word[0]){
  1646. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1647. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
  1648. if (send_els->ls_code != ZFCP_LS_ADISC) {
  1649. read_lock(&zfcp_data.config_lock);
  1650. port = zfcp_get_port_by_did(adapter, d_id);
  1651. if (port)
  1652. zfcp_test_link(port);
  1653. read_unlock(&zfcp_data.config_lock);
  1654. }
  1655. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1656. break;
  1657. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1658. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
  1659. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1660. retval =
  1661. zfcp_handle_els_rjt(header->fsf_status_qual.word[1],
  1662. (struct zfcp_ls_rjt_par *)
  1663. &header->fsf_status_qual.word[2]);
  1664. break;
  1665. case FSF_SQ_RETRY_IF_POSSIBLE:
  1666. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_retry");
  1667. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1668. break;
  1669. default:
  1670. ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x\n",
  1671. header->fsf_status_qual.word[0]);
  1672. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
  1673. (char*)header->fsf_status_qual.word, 16);
  1674. }
  1675. break;
  1676. case FSF_ELS_COMMAND_REJECTED:
  1677. ZFCP_LOG_INFO("ELS has been rejected because command filter "
  1678. "prohibited sending "
  1679. "(adapter: %s, port d_id: 0x%08x)\n",
  1680. zfcp_get_busid_by_adapter(adapter), d_id);
  1681. break;
  1682. case FSF_PAYLOAD_SIZE_MISMATCH:
  1683. ZFCP_LOG_INFO(
  1684. "ELS request size and ELS response size must be either "
  1685. "both 0, or both greater than 0 "
  1686. "(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n",
  1687. zfcp_get_busid_by_adapter(adapter),
  1688. bottom->req_buf_length,
  1689. bottom->resp_buf_length);
  1690. break;
  1691. case FSF_REQUEST_SIZE_TOO_LARGE:
  1692. ZFCP_LOG_INFO(
  1693. "Length of the ELS request buffer, "
  1694. "specified in QTCB bottom, "
  1695. "exceeds the size of the buffers "
  1696. "that have been allocated for ELS request data "
  1697. "(adapter: %s, req_buf_length=%d)\n",
  1698. zfcp_get_busid_by_adapter(adapter),
  1699. bottom->req_buf_length);
  1700. break;
  1701. case FSF_RESPONSE_SIZE_TOO_LARGE:
  1702. ZFCP_LOG_INFO(
  1703. "Length of the ELS response buffer, "
  1704. "specified in QTCB bottom, "
  1705. "exceeds the size of the buffers "
  1706. "that have been allocated for ELS response data "
  1707. "(adapter: %s, resp_buf_length=%d)\n",
  1708. zfcp_get_busid_by_adapter(adapter),
  1709. bottom->resp_buf_length);
  1710. break;
  1711. case FSF_SBAL_MISMATCH:
  1712. /* should never occure, avoided in zfcp_fsf_send_els */
  1713. ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
  1714. "resp_buf_length=%d)\n",
  1715. zfcp_get_busid_by_adapter(adapter),
  1716. bottom->req_buf_length, bottom->resp_buf_length);
  1717. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1718. break;
  1719. case FSF_ACCESS_DENIED:
  1720. ZFCP_LOG_NORMAL("access denied, cannot send ELS command "
  1721. "(adapter %s, port d_id=0x%08x)\n",
  1722. zfcp_get_busid_by_adapter(adapter), d_id);
  1723. for (counter = 0; counter < 2; counter++) {
  1724. subtable = header->fsf_status_qual.halfword[counter * 2];
  1725. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  1726. switch (subtable) {
  1727. case FSF_SQ_CFDC_SUBTABLE_OS:
  1728. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  1729. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  1730. case FSF_SQ_CFDC_SUBTABLE_LUN:
  1731. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  1732. zfcp_act_subtable_type[subtable], rule);
  1733. break;
  1734. }
  1735. }
  1736. debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
  1737. read_lock(&zfcp_data.config_lock);
  1738. port = zfcp_get_port_by_did(adapter, d_id);
  1739. if (port != NULL)
  1740. zfcp_erp_port_access_denied(port);
  1741. read_unlock(&zfcp_data.config_lock);
  1742. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1743. break;
  1744. default:
  1745. ZFCP_LOG_NORMAL(
  1746. "bug: An unknown FSF Status was presented "
  1747. "(adapter: %s, fsf_status=0x%08x)\n",
  1748. zfcp_get_busid_by_adapter(adapter),
  1749. header->fsf_status);
  1750. debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval");
  1751. debug_exception(adapter->erp_dbf, 0,
  1752. &header->fsf_status_qual.word[0], sizeof(u32));
  1753. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1754. break;
  1755. }
  1756. skip_fsfstatus:
  1757. send_els->status = retval;
  1758. if (send_els->handler != 0)
  1759. send_els->handler(send_els->handler_data);
  1760. return retval;
  1761. }
  1762. /*
  1763. * function:
  1764. *
  1765. * purpose:
  1766. *
  1767. * returns: address of initiated FSF request
  1768. * NULL - request could not be initiated
  1769. */
  1770. int
  1771. zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
  1772. {
  1773. volatile struct qdio_buffer_element *sbale;
  1774. unsigned long lock_flags;
  1775. int retval = 0;
  1776. /* setup new FSF request */
  1777. retval = zfcp_fsf_req_create(erp_action->adapter,
  1778. FSF_QTCB_EXCHANGE_CONFIG_DATA,
  1779. ZFCP_REQ_AUTO_CLEANUP,
  1780. erp_action->adapter->pool.fsf_req_erp,
  1781. &lock_flags, &(erp_action->fsf_req));
  1782. if (retval < 0) {
  1783. ZFCP_LOG_INFO("error: Could not create exchange configuration "
  1784. "data request for adapter %s.\n",
  1785. zfcp_get_busid_by_adapter(erp_action->adapter));
  1786. goto out;
  1787. }
  1788. sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
  1789. erp_action->fsf_req->sbal_curr, 0);
  1790. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1791. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1792. erp_action->fsf_req->erp_action = erp_action;
  1793. erp_action->fsf_req->qtcb->bottom.config.feature_selection =
  1794. (FSF_FEATURE_CFDC | FSF_FEATURE_LUN_SHARING);
  1795. /* start QDIO request for this FSF request */
  1796. retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
  1797. if (retval) {
  1798. ZFCP_LOG_INFO
  1799. ("error: Could not send exchange configuration data "
  1800. "command on the adapter %s\n",
  1801. zfcp_get_busid_by_adapter(erp_action->adapter));
  1802. zfcp_fsf_req_free(erp_action->fsf_req);
  1803. erp_action->fsf_req = NULL;
  1804. goto out;
  1805. }
  1806. ZFCP_LOG_DEBUG("exchange configuration data request initiated "
  1807. "(adapter %s)\n",
  1808. zfcp_get_busid_by_adapter(erp_action->adapter));
  1809. out:
  1810. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  1811. lock_flags);
  1812. return retval;
  1813. }
  1814. /**
  1815. * zfcp_fsf_exchange_config_evaluate
  1816. * @fsf_req: fsf_req which belongs to xchg config data request
  1817. * @xchg_ok: specifies if xchg config data was incomplete or complete (0/1)
  1818. *
  1819. * returns: -EIO on error, 0 otherwise
  1820. */
  1821. static int
  1822. zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
  1823. {
  1824. struct fsf_qtcb_bottom_config *bottom;
  1825. struct zfcp_adapter *adapter = fsf_req->adapter;
  1826. bottom = &fsf_req->qtcb->bottom.config;
  1827. ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n",
  1828. bottom->low_qtcb_version, bottom->high_qtcb_version);
  1829. adapter->fsf_lic_version = bottom->lic_version;
  1830. adapter->supported_features = bottom->supported_features;
  1831. adapter->peer_wwpn = 0;
  1832. adapter->peer_wwnn = 0;
  1833. adapter->peer_d_id = 0;
  1834. if (xchg_ok) {
  1835. adapter->wwnn = bottom->nport_serv_param.wwnn;
  1836. adapter->wwpn = bottom->nport_serv_param.wwpn;
  1837. adapter->s_id = bottom->s_id & ZFCP_DID_MASK;
  1838. adapter->fc_topology = bottom->fc_topology;
  1839. adapter->fc_link_speed = bottom->fc_link_speed;
  1840. adapter->hydra_version = bottom->adapter_type;
  1841. } else {
  1842. adapter->wwnn = 0;
  1843. adapter->wwpn = 0;
  1844. adapter->s_id = 0;
  1845. adapter->fc_topology = 0;
  1846. adapter->fc_link_speed = 0;
  1847. adapter->hydra_version = 0;
  1848. }
  1849. if (adapter->fc_topology == FSF_TOPO_P2P) {
  1850. adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK;
  1851. adapter->peer_wwpn = bottom->plogi_payload.wwpn;
  1852. adapter->peer_wwnn = bottom->plogi_payload.wwnn;
  1853. }
  1854. if(adapter->supported_features & FSF_FEATURE_HBAAPI_MANAGEMENT){
  1855. adapter->hardware_version = bottom->hardware_version;
  1856. memcpy(adapter->serial_number, bottom->serial_number, 17);
  1857. EBCASC(adapter->serial_number, sizeof(adapter->serial_number));
  1858. }
  1859. ZFCP_LOG_NORMAL("The adapter %s reported the following characteristics:\n"
  1860. "WWNN 0x%016Lx, "
  1861. "WWPN 0x%016Lx, "
  1862. "S_ID 0x%08x,\n"
  1863. "adapter version 0x%x, "
  1864. "LIC version 0x%x, "
  1865. "FC link speed %d Gb/s\n",
  1866. zfcp_get_busid_by_adapter(adapter),
  1867. adapter->wwnn,
  1868. adapter->wwpn,
  1869. (unsigned int) adapter->s_id,
  1870. adapter->hydra_version,
  1871. adapter->fsf_lic_version,
  1872. adapter->fc_link_speed);
  1873. if (ZFCP_QTCB_VERSION < bottom->low_qtcb_version) {
  1874. ZFCP_LOG_NORMAL("error: the adapter %s "
  1875. "only supports newer control block "
  1876. "versions in comparison to this device "
  1877. "driver (try updated device driver)\n",
  1878. zfcp_get_busid_by_adapter(adapter));
  1879. debug_text_event(adapter->erp_dbf, 0, "low_qtcb_ver");
  1880. zfcp_erp_adapter_shutdown(adapter, 0);
  1881. return -EIO;
  1882. }
  1883. if (ZFCP_QTCB_VERSION > bottom->high_qtcb_version) {
  1884. ZFCP_LOG_NORMAL("error: the adapter %s "
  1885. "only supports older control block "
  1886. "versions than this device driver uses"
  1887. "(consider a microcode upgrade)\n",
  1888. zfcp_get_busid_by_adapter(adapter));
  1889. debug_text_event(adapter->erp_dbf, 0, "high_qtcb_ver");
  1890. zfcp_erp_adapter_shutdown(adapter, 0);
  1891. return -EIO;
  1892. }
  1893. return 0;
  1894. }
  1895. /*
  1896. * function: zfcp_fsf_exchange_config_data_handler
  1897. *
  1898. * purpose: is called for finished Exchange Configuration Data command
  1899. *
  1900. * returns:
  1901. */
  1902. static int
  1903. zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
  1904. {
  1905. struct fsf_qtcb_bottom_config *bottom;
  1906. struct zfcp_adapter *adapter = fsf_req->adapter;
  1907. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1908. return -EIO;
  1909. switch (fsf_req->qtcb->header.fsf_status) {
  1910. case FSF_GOOD:
  1911. if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1))
  1912. return -EIO;
  1913. switch (adapter->fc_topology) {
  1914. case FSF_TOPO_P2P:
  1915. ZFCP_LOG_NORMAL("Point-to-Point fibrechannel "
  1916. "configuration detected at adapter %s\n"
  1917. "Peer WWNN 0x%016llx, "
  1918. "peer WWPN 0x%016llx, "
  1919. "peer d_id 0x%06x\n",
  1920. zfcp_get_busid_by_adapter(adapter),
  1921. adapter->peer_wwnn,
  1922. adapter->peer_wwpn,
  1923. adapter->peer_d_id);
  1924. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  1925. "top-p-to-p");
  1926. break;
  1927. case FSF_TOPO_AL:
  1928. ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
  1929. "topology detected at adapter %s "
  1930. "unsupported, shutting down adapter\n",
  1931. zfcp_get_busid_by_adapter(adapter));
  1932. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  1933. "top-al");
  1934. zfcp_erp_adapter_shutdown(adapter, 0);
  1935. return -EIO;
  1936. case FSF_TOPO_FABRIC:
  1937. ZFCP_LOG_INFO("Switched fabric fibrechannel "
  1938. "network detected at adapter %s.\n",
  1939. zfcp_get_busid_by_adapter(adapter));
  1940. break;
  1941. default:
  1942. ZFCP_LOG_NORMAL("bug: The fibrechannel topology "
  1943. "reported by the exchange "
  1944. "configuration command for "
  1945. "the adapter %s is not "
  1946. "of a type known to the zfcp "
  1947. "driver, shutting down adapter\n",
  1948. zfcp_get_busid_by_adapter(adapter));
  1949. adapter->fc_topology = FSF_TOPO_ERROR;
  1950. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  1951. "unknown-topo");
  1952. zfcp_erp_adapter_shutdown(adapter, 0);
  1953. return -EIO;
  1954. }
  1955. bottom = &fsf_req->qtcb->bottom.config;
  1956. if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
  1957. ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) "
  1958. "allowed by the adapter %s "
  1959. "is lower than the minimum "
  1960. "required by the driver (%ld bytes).\n",
  1961. bottom->max_qtcb_size,
  1962. zfcp_get_busid_by_adapter(adapter),
  1963. sizeof(struct fsf_qtcb));
  1964. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  1965. "qtcb-size");
  1966. debug_event(fsf_req->adapter->erp_dbf, 0,
  1967. &bottom->max_qtcb_size, sizeof (u32));
  1968. zfcp_erp_adapter_shutdown(adapter, 0);
  1969. return -EIO;
  1970. }
  1971. atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
  1972. &adapter->status);
  1973. break;
  1974. case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
  1975. debug_text_event(adapter->erp_dbf, 0, "xchg-inco");
  1976. if (zfcp_fsf_exchange_config_evaluate(fsf_req, 0))
  1977. return -EIO;
  1978. ZFCP_LOG_INFO("Local link to adapter %s is down\n",
  1979. zfcp_get_busid_by_adapter(adapter));
  1980. atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK |
  1981. ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
  1982. &adapter->status);
  1983. zfcp_erp_adapter_failed(adapter);
  1984. break;
  1985. default:
  1986. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf-stat-ng");
  1987. debug_event(fsf_req->adapter->erp_dbf, 0,
  1988. &fsf_req->qtcb->header.fsf_status, sizeof (u32));
  1989. zfcp_erp_adapter_shutdown(adapter, 0);
  1990. return -EIO;
  1991. }
  1992. return 0;
  1993. }
  1994. /**
  1995. * zfcp_fsf_exchange_port_data - request information about local port
  1996. * @adapter: for which port data is requested
  1997. * @data: response to exchange port data request
  1998. */
  1999. int
  2000. zfcp_fsf_exchange_port_data(struct zfcp_adapter *adapter,
  2001. struct fsf_qtcb_bottom_port *data)
  2002. {
  2003. volatile struct qdio_buffer_element *sbale;
  2004. int retval = 0;
  2005. unsigned long lock_flags;
  2006. struct zfcp_fsf_req *fsf_req;
  2007. struct timer_list *timer;
  2008. if(!(adapter->supported_features & FSF_FEATURE_HBAAPI_MANAGEMENT)){
  2009. ZFCP_LOG_INFO("error: exchange port data "
  2010. "command not supported by adapter %s\n",
  2011. zfcp_get_busid_by_adapter(adapter));
  2012. return -EOPNOTSUPP;
  2013. }
  2014. timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
  2015. if (!timer)
  2016. return -ENOMEM;
  2017. /* setup new FSF request */
  2018. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
  2019. 0, 0, &lock_flags, &fsf_req);
  2020. if (retval < 0) {
  2021. ZFCP_LOG_INFO("error: Out of resources. Could not create an "
  2022. "exchange port data request for"
  2023. "the adapter %s.\n",
  2024. zfcp_get_busid_by_adapter(adapter));
  2025. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  2026. lock_flags);
  2027. goto out;
  2028. }
  2029. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  2030. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2031. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2032. fsf_req->data.port_data = data;
  2033. init_timer(timer);
  2034. timer->function = zfcp_fsf_request_timeout_handler;
  2035. timer->data = (unsigned long) adapter;
  2036. timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
  2037. retval = zfcp_fsf_req_send(fsf_req, timer);
  2038. if (retval) {
  2039. ZFCP_LOG_INFO("error: Could not send an exchange port data "
  2040. "command on the adapter %s\n",
  2041. zfcp_get_busid_by_adapter(adapter));
  2042. zfcp_fsf_req_free(fsf_req);
  2043. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  2044. lock_flags);
  2045. goto out;
  2046. }
  2047. ZFCP_LOG_DEBUG("Exchange Port Data request initiated (adapter %s)\n",
  2048. zfcp_get_busid_by_adapter(adapter));
  2049. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  2050. lock_flags);
  2051. wait_event(fsf_req->completion_wq,
  2052. fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
  2053. del_timer_sync(timer);
  2054. zfcp_fsf_req_cleanup(fsf_req);
  2055. out:
  2056. kfree(timer);
  2057. return retval;
  2058. }
  2059. /**
  2060. * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request
  2061. * @fsf_req: pointer to struct zfcp_fsf_req
  2062. */
  2063. static void
  2064. zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req)
  2065. {
  2066. struct fsf_qtcb_bottom_port *bottom;
  2067. struct fsf_qtcb_bottom_port *data = fsf_req->data.port_data;
  2068. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
  2069. return;
  2070. switch (fsf_req->qtcb->header.fsf_status) {
  2071. case FSF_GOOD:
  2072. bottom = &fsf_req->qtcb->bottom.port;
  2073. memcpy(data, bottom, sizeof(*data));
  2074. break;
  2075. default:
  2076. debug_text_event(fsf_req->adapter->erp_dbf, 0, "xchg-port-ng");
  2077. debug_event(fsf_req->adapter->erp_dbf, 0,
  2078. &fsf_req->qtcb->header.fsf_status, sizeof(u32));
  2079. }
  2080. }
  2081. /*
  2082. * function: zfcp_fsf_open_port
  2083. *
  2084. * purpose:
  2085. *
  2086. * returns: address of initiated FSF request
  2087. * NULL - request could not be initiated
  2088. */
  2089. int
  2090. zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
  2091. {
  2092. volatile struct qdio_buffer_element *sbale;
  2093. unsigned long lock_flags;
  2094. int retval = 0;
  2095. /* setup new FSF request */
  2096. retval = zfcp_fsf_req_create(erp_action->adapter,
  2097. FSF_QTCB_OPEN_PORT_WITH_DID,
  2098. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  2099. erp_action->adapter->pool.fsf_req_erp,
  2100. &lock_flags, &(erp_action->fsf_req));
  2101. if (retval < 0) {
  2102. ZFCP_LOG_INFO("error: Could not create open port request "
  2103. "for port 0x%016Lx on adapter %s.\n",
  2104. erp_action->port->wwpn,
  2105. zfcp_get_busid_by_adapter(erp_action->adapter));
  2106. goto out;
  2107. }
  2108. sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
  2109. erp_action->fsf_req->sbal_curr, 0);
  2110. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2111. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2112. erp_action->fsf_req->qtcb->bottom.support.d_id = erp_action->port->d_id;
  2113. atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->port->status);
  2114. erp_action->fsf_req->data.open_port.port = erp_action->port;
  2115. erp_action->fsf_req->erp_action = erp_action;
  2116. /* start QDIO request for this FSF request */
  2117. retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
  2118. if (retval) {
  2119. ZFCP_LOG_INFO("error: Could not send open port request for "
  2120. "port 0x%016Lx on adapter %s.\n",
  2121. erp_action->port->wwpn,
  2122. zfcp_get_busid_by_adapter(erp_action->adapter));
  2123. zfcp_fsf_req_free(erp_action->fsf_req);
  2124. erp_action->fsf_req = NULL;
  2125. goto out;
  2126. }
  2127. ZFCP_LOG_DEBUG("open port request initiated "
  2128. "(adapter %s, port 0x%016Lx)\n",
  2129. zfcp_get_busid_by_adapter(erp_action->adapter),
  2130. erp_action->port->wwpn);
  2131. out:
  2132. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  2133. lock_flags);
  2134. return retval;
  2135. }
  2136. /*
  2137. * function: zfcp_fsf_open_port_handler
  2138. *
  2139. * purpose: is called for finished Open Port command
  2140. *
  2141. * returns:
  2142. */
  2143. static int
  2144. zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
  2145. {
  2146. int retval = -EINVAL;
  2147. struct zfcp_port *port;
  2148. struct fsf_plogi *plogi;
  2149. struct fsf_qtcb_header *header;
  2150. u16 subtable, rule, counter;
  2151. port = fsf_req->data.open_port.port;
  2152. header = &fsf_req->qtcb->header;
  2153. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  2154. /* don't change port status in our bookkeeping */
  2155. goto skip_fsfstatus;
  2156. }
  2157. /* evaluate FSF status in QTCB */
  2158. switch (header->fsf_status) {
  2159. case FSF_PORT_ALREADY_OPEN:
  2160. ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s "
  2161. "is already open.\n",
  2162. port->wwpn, zfcp_get_busid_by_port(port));
  2163. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  2164. "fsf_s_popen");
  2165. /*
  2166. * This is a bug, however operation should continue normally
  2167. * if it is simply ignored
  2168. */
  2169. break;
  2170. case FSF_ACCESS_DENIED:
  2171. ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx "
  2172. "on adapter %s\n",
  2173. port->wwpn, zfcp_get_busid_by_port(port));
  2174. for (counter = 0; counter < 2; counter++) {
  2175. subtable = header->fsf_status_qual.halfword[counter * 2];
  2176. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  2177. switch (subtable) {
  2178. case FSF_SQ_CFDC_SUBTABLE_OS:
  2179. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  2180. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  2181. case FSF_SQ_CFDC_SUBTABLE_LUN:
  2182. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  2183. zfcp_act_subtable_type[subtable], rule);
  2184. break;
  2185. }
  2186. }
  2187. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
  2188. zfcp_erp_port_access_denied(port);
  2189. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2190. break;
  2191. case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
  2192. ZFCP_LOG_INFO("error: The FSF adapter is out of resources. "
  2193. "The remote port 0x%016Lx on adapter %s "
  2194. "could not be opened. Disabling it.\n",
  2195. port->wwpn, zfcp_get_busid_by_port(port));
  2196. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2197. "fsf_s_max_ports");
  2198. zfcp_erp_port_failed(port);
  2199. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2200. break;
  2201. case FSF_ADAPTER_STATUS_AVAILABLE:
  2202. switch (header->fsf_status_qual.word[0]) {
  2203. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  2204. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2205. "fsf_sq_ltest");
  2206. /* ERP strategy will escalate */
  2207. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2208. break;
  2209. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  2210. /* ERP strategy will escalate */
  2211. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2212. "fsf_sq_ulp");
  2213. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2214. break;
  2215. case FSF_SQ_NO_RETRY_POSSIBLE:
  2216. ZFCP_LOG_NORMAL("The remote port 0x%016Lx on "
  2217. "adapter %s could not be opened. "
  2218. "Disabling it.\n",
  2219. port->wwpn,
  2220. zfcp_get_busid_by_port(port));
  2221. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  2222. "fsf_sq_no_retry");
  2223. zfcp_erp_port_failed(port);
  2224. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2225. break;
  2226. default:
  2227. ZFCP_LOG_NORMAL
  2228. ("bug: Wrong status qualifier 0x%x arrived.\n",
  2229. header->fsf_status_qual.word[0]);
  2230. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  2231. "fsf_sq_inval:");
  2232. debug_exception(
  2233. fsf_req->adapter->erp_dbf, 0,
  2234. &header->fsf_status_qual.word[0],
  2235. sizeof (u32));
  2236. break;
  2237. }
  2238. break;
  2239. case FSF_GOOD:
  2240. /* save port handle assigned by FSF */
  2241. port->handle = header->port_handle;
  2242. ZFCP_LOG_INFO("The remote port 0x%016Lx via adapter %s "
  2243. "was opened, it's port handle is 0x%x\n",
  2244. port->wwpn, zfcp_get_busid_by_port(port),
  2245. port->handle);
  2246. /* mark port as open */
  2247. atomic_set_mask(ZFCP_STATUS_COMMON_OPEN |
  2248. ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
  2249. retval = 0;
  2250. /* check whether D_ID has changed during open */
  2251. /*
  2252. * FIXME: This check is not airtight, as the FCP channel does
  2253. * not monitor closures of target port connections caused on
  2254. * the remote side. Thus, they might miss out on invalidating
  2255. * locally cached WWPNs (and other N_Port parameters) of gone
  2256. * target ports. So, our heroic attempt to make things safe
  2257. * could be undermined by 'open port' response data tagged with
  2258. * obsolete WWPNs. Another reason to monitor potential
  2259. * connection closures ourself at least (by interpreting
  2260. * incoming ELS' and unsolicited status). It just crosses my
  2261. * mind that one should be able to cross-check by means of
  2262. * another GID_PN straight after a port has been opened.
  2263. * Alternately, an ADISC/PDISC ELS should suffice, as well.
  2264. */
  2265. plogi = (struct fsf_plogi *) fsf_req->qtcb->bottom.support.els;
  2266. if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN, &port->status))
  2267. {
  2268. if (fsf_req->qtcb->bottom.support.els1_length <
  2269. ((((unsigned long) &plogi->serv_param.wwpn) -
  2270. ((unsigned long) plogi)) + sizeof (u64))) {
  2271. ZFCP_LOG_INFO(
  2272. "warning: insufficient length of "
  2273. "PLOGI payload (%i)\n",
  2274. fsf_req->qtcb->bottom.support.els1_length);
  2275. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  2276. "fsf_s_short_plogi:");
  2277. /* skip sanity check and assume wwpn is ok */
  2278. } else {
  2279. if (plogi->serv_param.wwpn != port->wwpn) {
  2280. ZFCP_LOG_INFO("warning: d_id of port "
  2281. "0x%016Lx changed during "
  2282. "open\n", port->wwpn);
  2283. debug_text_event(
  2284. fsf_req->adapter->erp_dbf, 0,
  2285. "fsf_s_did_change:");
  2286. atomic_clear_mask(
  2287. ZFCP_STATUS_PORT_DID_DID,
  2288. &port->status);
  2289. } else
  2290. port->wwnn = plogi->serv_param.wwnn;
  2291. }
  2292. }
  2293. break;
  2294. case FSF_UNKNOWN_OP_SUBTYPE:
  2295. /* should never occure, subtype not set in zfcp_fsf_open_port */
  2296. ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, "
  2297. "op_subtype=0x%x)\n",
  2298. zfcp_get_busid_by_port(port),
  2299. fsf_req->qtcb->bottom.support.operation_subtype);
  2300. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2301. break;
  2302. default:
  2303. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  2304. "(debug info 0x%x)\n",
  2305. header->fsf_status);
  2306. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  2307. debug_exception(fsf_req->adapter->erp_dbf, 0,
  2308. &header->fsf_status, sizeof (u32));
  2309. break;
  2310. }
  2311. skip_fsfstatus:
  2312. atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &port->status);
  2313. return retval;
  2314. }
  2315. /*
  2316. * function: zfcp_fsf_close_port
  2317. *
  2318. * purpose: submit FSF command "close port"
  2319. *
  2320. * returns: address of initiated FSF request
  2321. * NULL - request could not be initiated
  2322. */
  2323. int
  2324. zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
  2325. {
  2326. volatile struct qdio_buffer_element *sbale;
  2327. unsigned long lock_flags;
  2328. int retval = 0;
  2329. /* setup new FSF request */
  2330. retval = zfcp_fsf_req_create(erp_action->adapter,
  2331. FSF_QTCB_CLOSE_PORT,
  2332. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  2333. erp_action->adapter->pool.fsf_req_erp,
  2334. &lock_flags, &(erp_action->fsf_req));
  2335. if (retval < 0) {
  2336. ZFCP_LOG_INFO("error: Could not create a close port request "
  2337. "for port 0x%016Lx on adapter %s.\n",
  2338. erp_action->port->wwpn,
  2339. zfcp_get_busid_by_adapter(erp_action->adapter));
  2340. goto out;
  2341. }
  2342. sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
  2343. erp_action->fsf_req->sbal_curr, 0);
  2344. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2345. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2346. atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->port->status);
  2347. erp_action->fsf_req->data.close_port.port = erp_action->port;
  2348. erp_action->fsf_req->erp_action = erp_action;
  2349. erp_action->fsf_req->qtcb->header.port_handle =
  2350. erp_action->port->handle;
  2351. /* start QDIO request for this FSF request */
  2352. retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
  2353. if (retval) {
  2354. ZFCP_LOG_INFO("error: Could not send a close port request for "
  2355. "port 0x%016Lx on adapter %s.\n",
  2356. erp_action->port->wwpn,
  2357. zfcp_get_busid_by_adapter(erp_action->adapter));
  2358. zfcp_fsf_req_free(erp_action->fsf_req);
  2359. erp_action->fsf_req = NULL;
  2360. goto out;
  2361. }
  2362. ZFCP_LOG_TRACE("close port request initiated "
  2363. "(adapter %s, port 0x%016Lx)\n",
  2364. zfcp_get_busid_by_adapter(erp_action->adapter),
  2365. erp_action->port->wwpn);
  2366. out:
  2367. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  2368. lock_flags);
  2369. return retval;
  2370. }
  2371. /*
  2372. * function: zfcp_fsf_close_port_handler
  2373. *
  2374. * purpose: is called for finished Close Port FSF command
  2375. *
  2376. * returns:
  2377. */
  2378. static int
  2379. zfcp_fsf_close_port_handler(struct zfcp_fsf_req *fsf_req)
  2380. {
  2381. int retval = -EINVAL;
  2382. struct zfcp_port *port;
  2383. port = fsf_req->data.close_port.port;
  2384. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  2385. /* don't change port status in our bookkeeping */
  2386. goto skip_fsfstatus;
  2387. }
  2388. /* evaluate FSF status in QTCB */
  2389. switch (fsf_req->qtcb->header.fsf_status) {
  2390. case FSF_PORT_HANDLE_NOT_VALID:
  2391. ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
  2392. "0x%016Lx on adapter %s invalid. This may happen "
  2393. "occasionally.\n", port->handle,
  2394. port->wwpn, zfcp_get_busid_by_port(port));
  2395. ZFCP_LOG_DEBUG("status qualifier:\n");
  2396. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  2397. (char *) &fsf_req->qtcb->header.fsf_status_qual,
  2398. sizeof (union fsf_status_qual));
  2399. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2400. "fsf_s_phand_nv");
  2401. zfcp_erp_adapter_reopen(port->adapter, 0);
  2402. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2403. break;
  2404. case FSF_ADAPTER_STATUS_AVAILABLE:
  2405. /* Note: FSF has actually closed the port in this case.
  2406. * The status code is just daft. Fingers crossed for a change
  2407. */
  2408. retval = 0;
  2409. break;
  2410. case FSF_GOOD:
  2411. ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
  2412. "port handle 0x%x\n", port->wwpn,
  2413. zfcp_get_busid_by_port(port), port->handle);
  2414. zfcp_erp_modify_port_status(port,
  2415. ZFCP_STATUS_COMMON_OPEN,
  2416. ZFCP_CLEAR);
  2417. retval = 0;
  2418. break;
  2419. default:
  2420. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  2421. "(debug info 0x%x)\n",
  2422. fsf_req->qtcb->header.fsf_status);
  2423. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  2424. debug_exception(fsf_req->adapter->erp_dbf, 0,
  2425. &fsf_req->qtcb->header.fsf_status,
  2426. sizeof (u32));
  2427. break;
  2428. }
  2429. skip_fsfstatus:
  2430. atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &port->status);
  2431. return retval;
  2432. }
  2433. /*
  2434. * function: zfcp_fsf_close_physical_port
  2435. *
  2436. * purpose: submit FSF command "close physical port"
  2437. *
  2438. * returns: address of initiated FSF request
  2439. * NULL - request could not be initiated
  2440. */
  2441. int
  2442. zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
  2443. {
  2444. int retval = 0;
  2445. unsigned long lock_flags;
  2446. volatile struct qdio_buffer_element *sbale;
  2447. /* setup new FSF request */
  2448. retval = zfcp_fsf_req_create(erp_action->adapter,
  2449. FSF_QTCB_CLOSE_PHYSICAL_PORT,
  2450. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  2451. erp_action->adapter->pool.fsf_req_erp,
  2452. &lock_flags, &erp_action->fsf_req);
  2453. if (retval < 0) {
  2454. ZFCP_LOG_INFO("error: Could not create close physical port "
  2455. "request (adapter %s, port 0x%016Lx)\n",
  2456. zfcp_get_busid_by_adapter(erp_action->adapter),
  2457. erp_action->port->wwpn);
  2458. goto out;
  2459. }
  2460. sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
  2461. erp_action->fsf_req->sbal_curr, 0);
  2462. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2463. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2464. /* mark port as being closed */
  2465. atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING,
  2466. &erp_action->port->status);
  2467. /* save a pointer to this port */
  2468. erp_action->fsf_req->data.close_physical_port.port = erp_action->port;
  2469. /* port to be closeed */
  2470. erp_action->fsf_req->qtcb->header.port_handle =
  2471. erp_action->port->handle;
  2472. erp_action->fsf_req->erp_action = erp_action;
  2473. /* start QDIO request for this FSF request */
  2474. retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
  2475. if (retval) {
  2476. ZFCP_LOG_INFO("error: Could not send close physical port "
  2477. "request (adapter %s, port 0x%016Lx)\n",
  2478. zfcp_get_busid_by_adapter(erp_action->adapter),
  2479. erp_action->port->wwpn);
  2480. zfcp_fsf_req_free(erp_action->fsf_req);
  2481. erp_action->fsf_req = NULL;
  2482. goto out;
  2483. }
  2484. ZFCP_LOG_TRACE("close physical port request initiated "
  2485. "(adapter %s, port 0x%016Lx)\n",
  2486. zfcp_get_busid_by_adapter(erp_action->adapter),
  2487. erp_action->port->wwpn);
  2488. out:
  2489. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  2490. lock_flags);
  2491. return retval;
  2492. }
  2493. /*
  2494. * function: zfcp_fsf_close_physical_port_handler
  2495. *
  2496. * purpose: is called for finished Close Physical Port FSF command
  2497. *
  2498. * returns:
  2499. */
  2500. static int
  2501. zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req)
  2502. {
  2503. int retval = -EINVAL;
  2504. struct zfcp_port *port;
  2505. struct zfcp_unit *unit;
  2506. struct fsf_qtcb_header *header;
  2507. u16 subtable, rule, counter;
  2508. port = fsf_req->data.close_physical_port.port;
  2509. header = &fsf_req->qtcb->header;
  2510. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  2511. /* don't change port status in our bookkeeping */
  2512. goto skip_fsfstatus;
  2513. }
  2514. /* evaluate FSF status in QTCB */
  2515. switch (header->fsf_status) {
  2516. case FSF_PORT_HANDLE_NOT_VALID:
  2517. ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid"
  2518. "(adapter %s, port 0x%016Lx). "
  2519. "This may happen occasionally.\n",
  2520. port->handle,
  2521. zfcp_get_busid_by_port(port),
  2522. port->wwpn);
  2523. ZFCP_LOG_DEBUG("status qualifier:\n");
  2524. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  2525. (char *) &header->fsf_status_qual,
  2526. sizeof (union fsf_status_qual));
  2527. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2528. "fsf_s_phand_nv");
  2529. zfcp_erp_adapter_reopen(port->adapter, 0);
  2530. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2531. break;
  2532. case FSF_ACCESS_DENIED:
  2533. ZFCP_LOG_NORMAL("Access denied, cannot close "
  2534. "physical port 0x%016Lx on adapter %s\n",
  2535. port->wwpn, zfcp_get_busid_by_port(port));
  2536. for (counter = 0; counter < 2; counter++) {
  2537. subtable = header->fsf_status_qual.halfword[counter * 2];
  2538. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  2539. switch (subtable) {
  2540. case FSF_SQ_CFDC_SUBTABLE_OS:
  2541. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  2542. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  2543. case FSF_SQ_CFDC_SUBTABLE_LUN:
  2544. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  2545. zfcp_act_subtable_type[subtable], rule);
  2546. break;
  2547. }
  2548. }
  2549. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
  2550. zfcp_erp_port_access_denied(port);
  2551. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2552. break;
  2553. case FSF_PORT_BOXED:
  2554. ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter "
  2555. "%s needs to be reopened but it was attempted "
  2556. "to close it physically.\n",
  2557. port->wwpn,
  2558. zfcp_get_busid_by_port(port));
  2559. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_pboxed");
  2560. zfcp_erp_port_reopen(port, 0);
  2561. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  2562. ZFCP_STATUS_FSFREQ_RETRY;
  2563. break;
  2564. case FSF_ADAPTER_STATUS_AVAILABLE:
  2565. switch (header->fsf_status_qual.word[0]) {
  2566. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  2567. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2568. "fsf_sq_ltest");
  2569. /* This will now be escalated by ERP */
  2570. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2571. break;
  2572. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  2573. /* ERP strategy will escalate */
  2574. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2575. "fsf_sq_ulp");
  2576. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2577. break;
  2578. default:
  2579. ZFCP_LOG_NORMAL
  2580. ("bug: Wrong status qualifier 0x%x arrived.\n",
  2581. header->fsf_status_qual.word[0]);
  2582. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  2583. "fsf_sq_inval:");
  2584. debug_exception(
  2585. fsf_req->adapter->erp_dbf, 0,
  2586. &header->fsf_status_qual.word[0], sizeof (u32));
  2587. break;
  2588. }
  2589. break;
  2590. case FSF_GOOD:
  2591. ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s "
  2592. "physically closed, port handle 0x%x\n",
  2593. port->wwpn,
  2594. zfcp_get_busid_by_port(port), port->handle);
  2595. /* can't use generic zfcp_erp_modify_port_status because
  2596. * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
  2597. */
  2598. atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
  2599. list_for_each_entry(unit, &port->unit_list_head, list)
  2600. atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
  2601. retval = 0;
  2602. break;
  2603. default:
  2604. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  2605. "(debug info 0x%x)\n",
  2606. header->fsf_status);
  2607. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  2608. debug_exception(fsf_req->adapter->erp_dbf, 0,
  2609. &header->fsf_status, sizeof (u32));
  2610. break;
  2611. }
  2612. skip_fsfstatus:
  2613. atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING, &port->status);
  2614. return retval;
  2615. }
  2616. /*
  2617. * function: zfcp_fsf_open_unit
  2618. *
  2619. * purpose:
  2620. *
  2621. * returns:
  2622. *
  2623. * assumptions: This routine does not check whether the associated
  2624. * remote port has already been opened. This should be
  2625. * done by calling routines. Otherwise some status
  2626. * may be presented by FSF
  2627. */
  2628. int
  2629. zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
  2630. {
  2631. volatile struct qdio_buffer_element *sbale;
  2632. unsigned long lock_flags;
  2633. int retval = 0;
  2634. /* setup new FSF request */
  2635. retval = zfcp_fsf_req_create(erp_action->adapter,
  2636. FSF_QTCB_OPEN_LUN,
  2637. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  2638. erp_action->adapter->pool.fsf_req_erp,
  2639. &lock_flags, &(erp_action->fsf_req));
  2640. if (retval < 0) {
  2641. ZFCP_LOG_INFO("error: Could not create open unit request for "
  2642. "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
  2643. erp_action->unit->fcp_lun,
  2644. erp_action->unit->port->wwpn,
  2645. zfcp_get_busid_by_adapter(erp_action->adapter));
  2646. goto out;
  2647. }
  2648. sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
  2649. erp_action->fsf_req->sbal_curr, 0);
  2650. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2651. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2652. erp_action->fsf_req->qtcb->header.port_handle =
  2653. erp_action->port->handle;
  2654. erp_action->fsf_req->qtcb->bottom.support.fcp_lun =
  2655. erp_action->unit->fcp_lun;
  2656. erp_action->fsf_req->qtcb->bottom.support.option =
  2657. FSF_OPEN_LUN_SUPPRESS_BOXING;
  2658. atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status);
  2659. erp_action->fsf_req->data.open_unit.unit = erp_action->unit;
  2660. erp_action->fsf_req->erp_action = erp_action;
  2661. /* start QDIO request for this FSF request */
  2662. retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
  2663. if (retval) {
  2664. ZFCP_LOG_INFO("error: Could not send an open unit request "
  2665. "on the adapter %s, port 0x%016Lx for "
  2666. "unit 0x%016Lx\n",
  2667. zfcp_get_busid_by_adapter(erp_action->adapter),
  2668. erp_action->port->wwpn,
  2669. erp_action->unit->fcp_lun);
  2670. zfcp_fsf_req_free(erp_action->fsf_req);
  2671. erp_action->fsf_req = NULL;
  2672. goto out;
  2673. }
  2674. ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, "
  2675. "port 0x%016Lx, unit 0x%016Lx)\n",
  2676. zfcp_get_busid_by_adapter(erp_action->adapter),
  2677. erp_action->port->wwpn, erp_action->unit->fcp_lun);
  2678. out:
  2679. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  2680. lock_flags);
  2681. return retval;
  2682. }
  2683. /*
  2684. * function: zfcp_fsf_open_unit_handler
  2685. *
  2686. * purpose: is called for finished Open LUN command
  2687. *
  2688. * returns:
  2689. */
  2690. static int
  2691. zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
  2692. {
  2693. int retval = -EINVAL;
  2694. struct zfcp_adapter *adapter;
  2695. struct zfcp_unit *unit;
  2696. struct fsf_qtcb_header *header;
  2697. struct fsf_qtcb_bottom_support *bottom;
  2698. struct fsf_queue_designator *queue_designator;
  2699. u16 subtable, rule, counter;
  2700. u32 allowed, exclusive, readwrite;
  2701. unit = fsf_req->data.open_unit.unit;
  2702. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  2703. /* don't change unit status in our bookkeeping */
  2704. goto skip_fsfstatus;
  2705. }
  2706. adapter = fsf_req->adapter;
  2707. header = &fsf_req->qtcb->header;
  2708. bottom = &fsf_req->qtcb->bottom.support;
  2709. queue_designator = &header->fsf_status_qual.fsf_queue_designator;
  2710. allowed = bottom->lun_access_info & FSF_UNIT_ACCESS_OPEN_LUN_ALLOWED;
  2711. exclusive = bottom->lun_access_info & FSF_UNIT_ACCESS_EXCLUSIVE;
  2712. readwrite = bottom->lun_access_info & FSF_UNIT_ACCESS_OUTBOUND_TRANSFER;
  2713. atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
  2714. ZFCP_STATUS_UNIT_SHARED |
  2715. ZFCP_STATUS_UNIT_READONLY,
  2716. &unit->status);
  2717. /* evaluate FSF status in QTCB */
  2718. switch (header->fsf_status) {
  2719. case FSF_PORT_HANDLE_NOT_VALID:
  2720. ZFCP_LOG_INFO("Temporary port identifier 0x%x "
  2721. "for port 0x%016Lx on adapter %s invalid "
  2722. "This may happen occasionally\n",
  2723. unit->port->handle,
  2724. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  2725. ZFCP_LOG_DEBUG("status qualifier:\n");
  2726. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  2727. (char *) &header->fsf_status_qual,
  2728. sizeof (union fsf_status_qual));
  2729. debug_text_event(adapter->erp_dbf, 1, "fsf_s_ph_nv");
  2730. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  2731. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2732. break;
  2733. case FSF_LUN_ALREADY_OPEN:
  2734. ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "
  2735. "remote port 0x%016Lx on adapter %s twice.\n",
  2736. unit->fcp_lun,
  2737. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  2738. debug_text_exception(adapter->erp_dbf, 0,
  2739. "fsf_s_uopen");
  2740. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2741. break;
  2742. case FSF_ACCESS_DENIED:
  2743. ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "
  2744. "remote port 0x%016Lx on adapter %s\n",
  2745. unit->fcp_lun, unit->port->wwpn,
  2746. zfcp_get_busid_by_unit(unit));
  2747. for (counter = 0; counter < 2; counter++) {
  2748. subtable = header->fsf_status_qual.halfword[counter * 2];
  2749. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  2750. switch (subtable) {
  2751. case FSF_SQ_CFDC_SUBTABLE_OS:
  2752. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  2753. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  2754. case FSF_SQ_CFDC_SUBTABLE_LUN:
  2755. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  2756. zfcp_act_subtable_type[subtable], rule);
  2757. break;
  2758. }
  2759. }
  2760. debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
  2761. zfcp_erp_unit_access_denied(unit);
  2762. atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
  2763. atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
  2764. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2765. break;
  2766. case FSF_PORT_BOXED:
  2767. ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
  2768. "needs to be reopened\n",
  2769. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  2770. debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");
  2771. zfcp_erp_port_reopen(unit->port, 0);
  2772. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  2773. ZFCP_STATUS_FSFREQ_RETRY;
  2774. break;
  2775. case FSF_LUN_SHARING_VIOLATION:
  2776. if (header->fsf_status_qual.word[0] != 0) {
  2777. ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
  2778. "with WWPN 0x%Lx "
  2779. "connected to the adapter %s "
  2780. "is already in use in LPAR%d, CSS%d\n",
  2781. unit->fcp_lun,
  2782. unit->port->wwpn,
  2783. zfcp_get_busid_by_unit(unit),
  2784. queue_designator->hla,
  2785. queue_designator->cssid);
  2786. } else {
  2787. subtable = header->fsf_status_qual.halfword[4];
  2788. rule = header->fsf_status_qual.halfword[5];
  2789. switch (subtable) {
  2790. case FSF_SQ_CFDC_SUBTABLE_OS:
  2791. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  2792. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  2793. case FSF_SQ_CFDC_SUBTABLE_LUN:
  2794. ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "
  2795. "remote port with WWPN 0x%Lx "
  2796. "connected to the adapter %s "
  2797. "is denied (%s rule %d)\n",
  2798. unit->fcp_lun,
  2799. unit->port->wwpn,
  2800. zfcp_get_busid_by_unit(unit),
  2801. zfcp_act_subtable_type[subtable],
  2802. rule);
  2803. break;
  2804. }
  2805. }
  2806. ZFCP_LOG_DEBUG("status qualifier:\n");
  2807. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  2808. (char *) &header->fsf_status_qual,
  2809. sizeof (union fsf_status_qual));
  2810. debug_text_event(adapter->erp_dbf, 2,
  2811. "fsf_s_l_sh_vio");
  2812. zfcp_erp_unit_access_denied(unit);
  2813. atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
  2814. atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
  2815. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2816. break;
  2817. case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:
  2818. ZFCP_LOG_INFO("error: The adapter ran out of resources. "
  2819. "There is no handle (temporary port identifier) "
  2820. "available for unit 0x%016Lx on port 0x%016Lx "
  2821. "on adapter %s\n",
  2822. unit->fcp_lun,
  2823. unit->port->wwpn,
  2824. zfcp_get_busid_by_unit(unit));
  2825. debug_text_event(adapter->erp_dbf, 1,
  2826. "fsf_s_max_units");
  2827. zfcp_erp_unit_failed(unit);
  2828. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2829. break;
  2830. case FSF_ADAPTER_STATUS_AVAILABLE:
  2831. switch (header->fsf_status_qual.word[0]) {
  2832. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  2833. /* Re-establish link to port */
  2834. debug_text_event(adapter->erp_dbf, 1,
  2835. "fsf_sq_ltest");
  2836. zfcp_test_link(unit->port);
  2837. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2838. break;
  2839. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  2840. /* ERP strategy will escalate */
  2841. debug_text_event(adapter->erp_dbf, 1,
  2842. "fsf_sq_ulp");
  2843. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2844. break;
  2845. default:
  2846. ZFCP_LOG_NORMAL
  2847. ("bug: Wrong status qualifier 0x%x arrived.\n",
  2848. header->fsf_status_qual.word[0]);
  2849. debug_text_event(adapter->erp_dbf, 0,
  2850. "fsf_sq_inval:");
  2851. debug_exception(adapter->erp_dbf, 0,
  2852. &header->fsf_status_qual.word[0],
  2853. sizeof (u32));
  2854. }
  2855. break;
  2856. case FSF_INVALID_COMMAND_OPTION:
  2857. ZFCP_LOG_NORMAL(
  2858. "Invalid option 0x%x has been specified "
  2859. "in QTCB bottom sent to the adapter %s\n",
  2860. bottom->option,
  2861. zfcp_get_busid_by_adapter(adapter));
  2862. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2863. retval = -EINVAL;
  2864. break;
  2865. case FSF_GOOD:
  2866. /* save LUN handle assigned by FSF */
  2867. unit->handle = header->lun_handle;
  2868. ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "
  2869. "adapter %s opened, port handle 0x%x\n",
  2870. unit->fcp_lun,
  2871. unit->port->wwpn,
  2872. zfcp_get_busid_by_unit(unit),
  2873. unit->handle);
  2874. /* mark unit as open */
  2875. atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
  2876. if (adapter->supported_features & FSF_FEATURE_LUN_SHARING){
  2877. if (!exclusive)
  2878. atomic_set_mask(ZFCP_STATUS_UNIT_SHARED,
  2879. &unit->status);
  2880. if (!readwrite) {
  2881. atomic_set_mask(ZFCP_STATUS_UNIT_READONLY,
  2882. &unit->status);
  2883. ZFCP_LOG_NORMAL("read-only access for unit "
  2884. "(adapter %s, wwpn=0x%016Lx, "
  2885. "fcp_lun=0x%016Lx)\n",
  2886. zfcp_get_busid_by_unit(unit),
  2887. unit->port->wwpn,
  2888. unit->fcp_lun);
  2889. }
  2890. if (exclusive && !readwrite) {
  2891. ZFCP_LOG_NORMAL("exclusive access of read-only "
  2892. "unit not supported\n");
  2893. zfcp_erp_unit_failed(unit);
  2894. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2895. zfcp_erp_unit_shutdown(unit, 0);
  2896. } else if (!exclusive && readwrite) {
  2897. ZFCP_LOG_NORMAL("shared access of read-write "
  2898. "unit not supported\n");
  2899. zfcp_erp_unit_failed(unit);
  2900. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2901. zfcp_erp_unit_shutdown(unit, 0);
  2902. }
  2903. }
  2904. retval = 0;
  2905. break;
  2906. default:
  2907. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  2908. "(debug info 0x%x)\n",
  2909. header->fsf_status);
  2910. debug_text_event(adapter->erp_dbf, 0, "fsf_s_inval:");
  2911. debug_exception(adapter->erp_dbf, 0,
  2912. &header->fsf_status, sizeof (u32));
  2913. break;
  2914. }
  2915. skip_fsfstatus:
  2916. atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &unit->status);
  2917. return retval;
  2918. }
  2919. /*
  2920. * function: zfcp_fsf_close_unit
  2921. *
  2922. * purpose:
  2923. *
  2924. * returns: address of fsf_req - request successfully initiated
  2925. * NULL -
  2926. *
  2927. * assumptions: This routine does not check whether the associated
  2928. * remote port/lun has already been opened. This should be
  2929. * done by calling routines. Otherwise some status
  2930. * may be presented by FSF
  2931. */
  2932. int
  2933. zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
  2934. {
  2935. volatile struct qdio_buffer_element *sbale;
  2936. unsigned long lock_flags;
  2937. int retval = 0;
  2938. /* setup new FSF request */
  2939. retval = zfcp_fsf_req_create(erp_action->adapter,
  2940. FSF_QTCB_CLOSE_LUN,
  2941. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  2942. erp_action->adapter->pool.fsf_req_erp,
  2943. &lock_flags, &(erp_action->fsf_req));
  2944. if (retval < 0) {
  2945. ZFCP_LOG_INFO("error: Could not create close unit request for "
  2946. "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
  2947. erp_action->unit->fcp_lun,
  2948. erp_action->port->wwpn,
  2949. zfcp_get_busid_by_adapter(erp_action->adapter));
  2950. goto out;
  2951. }
  2952. sbale = zfcp_qdio_sbale_req(erp_action->fsf_req,
  2953. erp_action->fsf_req->sbal_curr, 0);
  2954. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2955. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2956. erp_action->fsf_req->qtcb->header.port_handle =
  2957. erp_action->port->handle;
  2958. erp_action->fsf_req->qtcb->header.lun_handle = erp_action->unit->handle;
  2959. atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->unit->status);
  2960. erp_action->fsf_req->data.close_unit.unit = erp_action->unit;
  2961. erp_action->fsf_req->erp_action = erp_action;
  2962. /* start QDIO request for this FSF request */
  2963. retval = zfcp_fsf_req_send(erp_action->fsf_req, &erp_action->timer);
  2964. if (retval) {
  2965. ZFCP_LOG_INFO("error: Could not send a close unit request for "
  2966. "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
  2967. erp_action->unit->fcp_lun,
  2968. erp_action->port->wwpn,
  2969. zfcp_get_busid_by_adapter(erp_action->adapter));
  2970. zfcp_fsf_req_free(erp_action->fsf_req);
  2971. erp_action->fsf_req = NULL;
  2972. goto out;
  2973. }
  2974. ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, "
  2975. "port 0x%016Lx, unit 0x%016Lx)\n",
  2976. zfcp_get_busid_by_adapter(erp_action->adapter),
  2977. erp_action->port->wwpn, erp_action->unit->fcp_lun);
  2978. out:
  2979. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  2980. lock_flags);
  2981. return retval;
  2982. }
  2983. /*
  2984. * function: zfcp_fsf_close_unit_handler
  2985. *
  2986. * purpose: is called for finished Close LUN FSF command
  2987. *
  2988. * returns:
  2989. */
  2990. static int
  2991. zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
  2992. {
  2993. int retval = -EINVAL;
  2994. struct zfcp_unit *unit;
  2995. unit = fsf_req->data.close_unit.unit; /* restore unit */
  2996. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  2997. /* don't change unit status in our bookkeeping */
  2998. goto skip_fsfstatus;
  2999. }
  3000. /* evaluate FSF status in QTCB */
  3001. switch (fsf_req->qtcb->header.fsf_status) {
  3002. case FSF_PORT_HANDLE_NOT_VALID:
  3003. ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
  3004. "0x%016Lx on adapter %s invalid. This may "
  3005. "happen in rare circumstances\n",
  3006. unit->port->handle,
  3007. unit->port->wwpn,
  3008. zfcp_get_busid_by_unit(unit));
  3009. ZFCP_LOG_DEBUG("status qualifier:\n");
  3010. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3011. (char *) &fsf_req->qtcb->header.fsf_status_qual,
  3012. sizeof (union fsf_status_qual));
  3013. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3014. "fsf_s_phand_nv");
  3015. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  3016. zfcp_cmd_dbf_event_fsf("porthinv", fsf_req,
  3017. &fsf_req->qtcb->header.fsf_status_qual,
  3018. sizeof (union fsf_status_qual));
  3019. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3020. break;
  3021. case FSF_LUN_HANDLE_NOT_VALID:
  3022. ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit "
  3023. "0x%016Lx on port 0x%016Lx on adapter %s is "
  3024. "invalid. This may happen occasionally.\n",
  3025. unit->handle,
  3026. unit->fcp_lun,
  3027. unit->port->wwpn,
  3028. zfcp_get_busid_by_unit(unit));
  3029. ZFCP_LOG_DEBUG("Status qualifier data:\n");
  3030. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3031. (char *) &fsf_req->qtcb->header.fsf_status_qual,
  3032. sizeof (union fsf_status_qual));
  3033. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3034. "fsf_s_lhand_nv");
  3035. zfcp_erp_port_reopen(unit->port, 0);
  3036. zfcp_cmd_dbf_event_fsf("lunhinv", fsf_req,
  3037. &fsf_req->qtcb->header.fsf_status_qual,
  3038. sizeof (union fsf_status_qual));
  3039. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3040. break;
  3041. case FSF_PORT_BOXED:
  3042. ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
  3043. "needs to be reopened\n",
  3044. unit->port->wwpn,
  3045. zfcp_get_busid_by_unit(unit));
  3046. debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed");
  3047. zfcp_erp_port_reopen(unit->port, 0);
  3048. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  3049. ZFCP_STATUS_FSFREQ_RETRY;
  3050. break;
  3051. case FSF_ADAPTER_STATUS_AVAILABLE:
  3052. switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) {
  3053. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  3054. /* re-establish link to port */
  3055. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3056. "fsf_sq_ltest");
  3057. zfcp_test_link(unit->port);
  3058. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3059. break;
  3060. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  3061. /* ERP strategy will escalate */
  3062. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3063. "fsf_sq_ulp");
  3064. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3065. break;
  3066. default:
  3067. ZFCP_LOG_NORMAL
  3068. ("bug: Wrong status qualifier 0x%x arrived.\n",
  3069. fsf_req->qtcb->header.fsf_status_qual.word[0]);
  3070. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  3071. "fsf_sq_inval:");
  3072. debug_exception(
  3073. fsf_req->adapter->erp_dbf, 0,
  3074. &fsf_req->qtcb->header.fsf_status_qual.word[0],
  3075. sizeof (u32));
  3076. break;
  3077. }
  3078. break;
  3079. case FSF_GOOD:
  3080. ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s "
  3081. "closed, port handle 0x%x\n",
  3082. unit->fcp_lun,
  3083. unit->port->wwpn,
  3084. zfcp_get_busid_by_unit(unit),
  3085. unit->handle);
  3086. /* mark unit as closed */
  3087. atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
  3088. retval = 0;
  3089. break;
  3090. default:
  3091. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  3092. "(debug info 0x%x)\n",
  3093. fsf_req->qtcb->header.fsf_status);
  3094. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  3095. debug_exception(fsf_req->adapter->erp_dbf, 0,
  3096. &fsf_req->qtcb->header.fsf_status,
  3097. sizeof (u32));
  3098. break;
  3099. }
  3100. skip_fsfstatus:
  3101. atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &unit->status);
  3102. return retval;
  3103. }
  3104. /**
  3105. * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
  3106. * @adapter: adapter where scsi command is issued
  3107. * @unit: unit where command is sent to
  3108. * @scsi_cmnd: scsi command to be sent
  3109. * @timer: timer to be started when request is initiated
  3110. * @req_flags: flags for fsf_request
  3111. */
  3112. int
  3113. zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
  3114. struct zfcp_unit *unit,
  3115. struct scsi_cmnd * scsi_cmnd,
  3116. struct timer_list *timer, int req_flags)
  3117. {
  3118. struct zfcp_fsf_req *fsf_req = NULL;
  3119. struct fcp_cmnd_iu *fcp_cmnd_iu;
  3120. unsigned int sbtype;
  3121. unsigned long lock_flags;
  3122. int real_bytes = 0;
  3123. int retval = 0;
  3124. int mask;
  3125. /* setup new FSF request */
  3126. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
  3127. adapter->pool.fsf_req_scsi,
  3128. &lock_flags, &fsf_req);
  3129. if (unlikely(retval < 0)) {
  3130. ZFCP_LOG_DEBUG("error: Could not create FCP command request "
  3131. "for unit 0x%016Lx on port 0x%016Lx on "
  3132. "adapter %s\n",
  3133. unit->fcp_lun,
  3134. unit->port->wwpn,
  3135. zfcp_get_busid_by_adapter(adapter));
  3136. goto failed_req_create;
  3137. }
  3138. /*
  3139. * associate FSF request with SCSI request
  3140. * (need this for look up on abort)
  3141. */
  3142. fsf_req->data.send_fcp_command_task.fsf_req = fsf_req;
  3143. scsi_cmnd->host_scribble = (char *) &(fsf_req->data);
  3144. /*
  3145. * associate SCSI command with FSF request
  3146. * (need this for look up on normal command completion)
  3147. */
  3148. fsf_req->data.send_fcp_command_task.scsi_cmnd = scsi_cmnd;
  3149. fsf_req->data.send_fcp_command_task.start_jiffies = jiffies;
  3150. fsf_req->data.send_fcp_command_task.unit = unit;
  3151. ZFCP_LOG_DEBUG("unit=%p, fcp_lun=0x%016Lx\n", unit, unit->fcp_lun);
  3152. /* set handles of unit and its parent port in QTCB */
  3153. fsf_req->qtcb->header.lun_handle = unit->handle;
  3154. fsf_req->qtcb->header.port_handle = unit->port->handle;
  3155. /* FSF does not define the structure of the FCP_CMND IU */
  3156. fcp_cmnd_iu = (struct fcp_cmnd_iu *)
  3157. &(fsf_req->qtcb->bottom.io.fcp_cmnd);
  3158. /*
  3159. * set depending on data direction:
  3160. * data direction bits in SBALE (SB Type)
  3161. * data direction bits in QTCB
  3162. * data direction bits in FCP_CMND IU
  3163. */
  3164. switch (scsi_cmnd->sc_data_direction) {
  3165. case DMA_NONE:
  3166. fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
  3167. /*
  3168. * FIXME(qdio):
  3169. * what is the correct type for commands
  3170. * without 'real' data buffers?
  3171. */
  3172. sbtype = SBAL_FLAGS0_TYPE_READ;
  3173. break;
  3174. case DMA_FROM_DEVICE:
  3175. fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_READ;
  3176. sbtype = SBAL_FLAGS0_TYPE_READ;
  3177. fcp_cmnd_iu->rddata = 1;
  3178. break;
  3179. case DMA_TO_DEVICE:
  3180. fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE;
  3181. sbtype = SBAL_FLAGS0_TYPE_WRITE;
  3182. fcp_cmnd_iu->wddata = 1;
  3183. break;
  3184. case DMA_BIDIRECTIONAL:
  3185. default:
  3186. /*
  3187. * dummy, catch this condition earlier
  3188. * in zfcp_scsi_queuecommand
  3189. */
  3190. goto failed_scsi_cmnd;
  3191. }
  3192. /* set FC service class in QTCB (3 per default) */
  3193. fsf_req->qtcb->bottom.io.service_class = adapter->fc_service_class;
  3194. /* set FCP_LUN in FCP_CMND IU in QTCB */
  3195. fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
  3196. mask = ZFCP_STATUS_UNIT_READONLY | ZFCP_STATUS_UNIT_SHARED;
  3197. /* set task attributes in FCP_CMND IU in QTCB */
  3198. if (likely((scsi_cmnd->device->simple_tags) ||
  3199. (atomic_test_mask(mask, &unit->status))))
  3200. fcp_cmnd_iu->task_attribute = SIMPLE_Q;
  3201. else
  3202. fcp_cmnd_iu->task_attribute = UNTAGGED;
  3203. /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
  3204. if (unlikely(scsi_cmnd->cmd_len > FCP_CDB_LENGTH)) {
  3205. fcp_cmnd_iu->add_fcp_cdb_length
  3206. = (scsi_cmnd->cmd_len - FCP_CDB_LENGTH) >> 2;
  3207. ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
  3208. "additional FCP_CDB length is 0x%x "
  3209. "(shifted right 2 bits)\n",
  3210. scsi_cmnd->cmd_len,
  3211. fcp_cmnd_iu->add_fcp_cdb_length);
  3212. }
  3213. /*
  3214. * copy SCSI CDB (including additional length, if any) to
  3215. * FCP_CDB in FCP_CMND IU in QTCB
  3216. */
  3217. memcpy(fcp_cmnd_iu->fcp_cdb, scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
  3218. /* FCP CMND IU length in QTCB */
  3219. fsf_req->qtcb->bottom.io.fcp_cmnd_length =
  3220. sizeof (struct fcp_cmnd_iu) +
  3221. fcp_cmnd_iu->add_fcp_cdb_length + sizeof (fcp_dl_t);
  3222. /* generate SBALEs from data buffer */
  3223. real_bytes = zfcp_qdio_sbals_from_scsicmnd(fsf_req, sbtype, scsi_cmnd);
  3224. if (unlikely(real_bytes < 0)) {
  3225. if (fsf_req->sbal_number < ZFCP_MAX_SBALS_PER_REQ) {
  3226. ZFCP_LOG_DEBUG(
  3227. "Data did not fit into available buffer(s), "
  3228. "waiting for more...\n");
  3229. retval = -EIO;
  3230. } else {
  3231. ZFCP_LOG_NORMAL("error: No truncation implemented but "
  3232. "required. Shutting down unit "
  3233. "(adapter %s, port 0x%016Lx, "
  3234. "unit 0x%016Lx)\n",
  3235. zfcp_get_busid_by_unit(unit),
  3236. unit->port->wwpn,
  3237. unit->fcp_lun);
  3238. zfcp_erp_unit_shutdown(unit, 0);
  3239. retval = -EINVAL;
  3240. }
  3241. goto no_fit;
  3242. }
  3243. /* set length of FCP data length in FCP_CMND IU in QTCB */
  3244. zfcp_set_fcp_dl(fcp_cmnd_iu, real_bytes);
  3245. ZFCP_LOG_DEBUG("Sending SCSI command:\n");
  3246. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3247. (char *) scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
  3248. /*
  3249. * start QDIO request for this FSF request
  3250. * covered by an SBALE)
  3251. */
  3252. retval = zfcp_fsf_req_send(fsf_req, timer);
  3253. if (unlikely(retval < 0)) {
  3254. ZFCP_LOG_INFO("error: Could not send FCP command request "
  3255. "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
  3256. zfcp_get_busid_by_adapter(adapter),
  3257. unit->port->wwpn,
  3258. unit->fcp_lun);
  3259. goto send_failed;
  3260. }
  3261. ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, "
  3262. "port 0x%016Lx, unit 0x%016Lx)\n",
  3263. zfcp_get_busid_by_adapter(adapter),
  3264. unit->port->wwpn,
  3265. unit->fcp_lun);
  3266. goto success;
  3267. send_failed:
  3268. no_fit:
  3269. failed_scsi_cmnd:
  3270. zfcp_fsf_req_free(fsf_req);
  3271. fsf_req = NULL;
  3272. scsi_cmnd->host_scribble = NULL;
  3273. success:
  3274. failed_req_create:
  3275. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  3276. return retval;
  3277. }
  3278. /*
  3279. * function: zfcp_fsf_send_fcp_command_task_management
  3280. *
  3281. * purpose:
  3282. *
  3283. * returns:
  3284. *
  3285. * FIXME(design): should be watched by a timeout!!!
  3286. * FIXME(design) shouldn't this be modified to return an int
  3287. * also...don't know how though
  3288. *
  3289. */
  3290. struct zfcp_fsf_req *
  3291. zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
  3292. struct zfcp_unit *unit,
  3293. u8 tm_flags, int req_flags)
  3294. {
  3295. struct zfcp_fsf_req *fsf_req = NULL;
  3296. int retval = 0;
  3297. struct fcp_cmnd_iu *fcp_cmnd_iu;
  3298. unsigned long lock_flags;
  3299. volatile struct qdio_buffer_element *sbale;
  3300. /* setup new FSF request */
  3301. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
  3302. adapter->pool.fsf_req_scsi,
  3303. &lock_flags, &fsf_req);
  3304. if (retval < 0) {
  3305. ZFCP_LOG_INFO("error: Could not create FCP command (task "
  3306. "management) request for adapter %s, port "
  3307. " 0x%016Lx, unit 0x%016Lx.\n",
  3308. zfcp_get_busid_by_adapter(adapter),
  3309. unit->port->wwpn, unit->fcp_lun);
  3310. goto out;
  3311. }
  3312. /*
  3313. * Used to decide on proper handler in the return path,
  3314. * could be either zfcp_fsf_send_fcp_command_task_handler or
  3315. * zfcp_fsf_send_fcp_command_task_management_handler */
  3316. fsf_req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT;
  3317. /*
  3318. * hold a pointer to the unit being target of this
  3319. * task management request
  3320. */
  3321. fsf_req->data.send_fcp_command_task_management.unit = unit;
  3322. /* set FSF related fields in QTCB */
  3323. fsf_req->qtcb->header.lun_handle = unit->handle;
  3324. fsf_req->qtcb->header.port_handle = unit->port->handle;
  3325. fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
  3326. fsf_req->qtcb->bottom.io.service_class = adapter->fc_service_class;
  3327. fsf_req->qtcb->bottom.io.fcp_cmnd_length =
  3328. sizeof (struct fcp_cmnd_iu) + sizeof (fcp_dl_t);
  3329. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  3330. sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
  3331. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  3332. /* set FCP related fields in FCP_CMND IU in QTCB */
  3333. fcp_cmnd_iu = (struct fcp_cmnd_iu *)
  3334. &(fsf_req->qtcb->bottom.io.fcp_cmnd);
  3335. fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
  3336. fcp_cmnd_iu->task_management_flags = tm_flags;
  3337. /* start QDIO request for this FSF request */
  3338. zfcp_fsf_start_scsi_er_timer(adapter);
  3339. retval = zfcp_fsf_req_send(fsf_req, NULL);
  3340. if (retval) {
  3341. del_timer(&adapter->scsi_er_timer);
  3342. ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
  3343. "management) on adapter %s, port 0x%016Lx for "
  3344. "unit LUN 0x%016Lx\n",
  3345. zfcp_get_busid_by_adapter(adapter),
  3346. unit->port->wwpn,
  3347. unit->fcp_lun);
  3348. zfcp_fsf_req_free(fsf_req);
  3349. fsf_req = NULL;
  3350. goto out;
  3351. }
  3352. ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
  3353. "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
  3354. "tm_flags=0x%x)\n",
  3355. zfcp_get_busid_by_adapter(adapter),
  3356. unit->port->wwpn,
  3357. unit->fcp_lun,
  3358. tm_flags);
  3359. out:
  3360. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  3361. return fsf_req;
  3362. }
  3363. /*
  3364. * function: zfcp_fsf_send_fcp_command_handler
  3365. *
  3366. * purpose: is called for finished Send FCP Command
  3367. *
  3368. * returns:
  3369. */
  3370. static int
  3371. zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
  3372. {
  3373. int retval = -EINVAL;
  3374. struct zfcp_unit *unit;
  3375. struct fsf_qtcb_header *header;
  3376. u16 subtable, rule, counter;
  3377. header = &fsf_req->qtcb->header;
  3378. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT))
  3379. unit = fsf_req->data.send_fcp_command_task_management.unit;
  3380. else
  3381. unit = fsf_req->data.send_fcp_command_task.unit;
  3382. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
  3383. /* go directly to calls of special handlers */
  3384. goto skip_fsfstatus;
  3385. }
  3386. /* evaluate FSF status in QTCB */
  3387. switch (header->fsf_status) {
  3388. case FSF_PORT_HANDLE_NOT_VALID:
  3389. ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
  3390. "0x%016Lx on adapter %s invalid\n",
  3391. unit->port->handle,
  3392. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  3393. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3394. (char *) &header->fsf_status_qual,
  3395. sizeof (union fsf_status_qual));
  3396. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3397. "fsf_s_phand_nv");
  3398. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  3399. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3400. break;
  3401. case FSF_LUN_HANDLE_NOT_VALID:
  3402. ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit "
  3403. "0x%016Lx on port 0x%016Lx on adapter %s is "
  3404. "invalid. This may happen occasionally.\n",
  3405. unit->handle,
  3406. unit->fcp_lun,
  3407. unit->port->wwpn,
  3408. zfcp_get_busid_by_unit(unit));
  3409. ZFCP_LOG_NORMAL("Status qualifier data:\n");
  3410. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
  3411. (char *) &header->fsf_status_qual,
  3412. sizeof (union fsf_status_qual));
  3413. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3414. "fsf_s_uhand_nv");
  3415. zfcp_erp_port_reopen(unit->port, 0);
  3416. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3417. break;
  3418. case FSF_HANDLE_MISMATCH:
  3419. ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed "
  3420. "unexpectedly. (adapter %s, port 0x%016Lx, "
  3421. "unit 0x%016Lx)\n",
  3422. unit->port->handle,
  3423. zfcp_get_busid_by_unit(unit),
  3424. unit->port->wwpn,
  3425. unit->fcp_lun);
  3426. ZFCP_LOG_NORMAL("status qualifier:\n");
  3427. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
  3428. (char *) &header->fsf_status_qual,
  3429. sizeof (union fsf_status_qual));
  3430. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3431. "fsf_s_hand_mis");
  3432. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  3433. zfcp_cmd_dbf_event_fsf("handmism",
  3434. fsf_req,
  3435. &header->fsf_status_qual,
  3436. sizeof (union fsf_status_qual));
  3437. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3438. break;
  3439. case FSF_SERVICE_CLASS_NOT_SUPPORTED:
  3440. if (fsf_req->adapter->fc_service_class <= 3) {
  3441. ZFCP_LOG_NORMAL("error: The adapter %s does "
  3442. "not support fibrechannel class %d.\n",
  3443. zfcp_get_busid_by_unit(unit),
  3444. fsf_req->adapter->fc_service_class);
  3445. } else {
  3446. ZFCP_LOG_NORMAL("bug: The fibrechannel class at "
  3447. "adapter %s is invalid. "
  3448. "(debug info %d)\n",
  3449. zfcp_get_busid_by_unit(unit),
  3450. fsf_req->adapter->fc_service_class);
  3451. }
  3452. /* stop operation for this adapter */
  3453. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  3454. "fsf_s_class_nsup");
  3455. zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
  3456. zfcp_cmd_dbf_event_fsf("unsclass",
  3457. fsf_req,
  3458. &header->fsf_status_qual,
  3459. sizeof (union fsf_status_qual));
  3460. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3461. break;
  3462. case FSF_FCPLUN_NOT_VALID:
  3463. ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on "
  3464. "adapter %s does not have correct unit "
  3465. "handle 0x%x\n",
  3466. unit->fcp_lun,
  3467. unit->port->wwpn,
  3468. zfcp_get_busid_by_unit(unit),
  3469. unit->handle);
  3470. ZFCP_LOG_DEBUG("status qualifier:\n");
  3471. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3472. (char *) &header->fsf_status_qual,
  3473. sizeof (union fsf_status_qual));
  3474. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3475. "fsf_s_fcp_lun_nv");
  3476. zfcp_erp_port_reopen(unit->port, 0);
  3477. zfcp_cmd_dbf_event_fsf("fluninv",
  3478. fsf_req,
  3479. &header->fsf_status_qual,
  3480. sizeof (union fsf_status_qual));
  3481. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3482. break;
  3483. case FSF_ACCESS_DENIED:
  3484. ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to "
  3485. "unit 0x%016Lx on port 0x%016Lx on "
  3486. "adapter %s\n", unit->fcp_lun, unit->port->wwpn,
  3487. zfcp_get_busid_by_unit(unit));
  3488. for (counter = 0; counter < 2; counter++) {
  3489. subtable = header->fsf_status_qual.halfword[counter * 2];
  3490. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  3491. switch (subtable) {
  3492. case FSF_SQ_CFDC_SUBTABLE_OS:
  3493. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  3494. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  3495. case FSF_SQ_CFDC_SUBTABLE_LUN:
  3496. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  3497. zfcp_act_subtable_type[subtable], rule);
  3498. break;
  3499. }
  3500. }
  3501. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
  3502. zfcp_erp_unit_access_denied(unit);
  3503. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3504. break;
  3505. case FSF_DIRECTION_INDICATOR_NOT_VALID:
  3506. ZFCP_LOG_INFO("bug: Invalid data direction given for unit "
  3507. "0x%016Lx on port 0x%016Lx on adapter %s "
  3508. "(debug info %d)\n",
  3509. unit->fcp_lun,
  3510. unit->port->wwpn,
  3511. zfcp_get_busid_by_unit(unit),
  3512. fsf_req->qtcb->bottom.io.data_direction);
  3513. /* stop operation for this adapter */
  3514. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  3515. "fsf_s_dir_ind_nv");
  3516. zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
  3517. zfcp_cmd_dbf_event_fsf("dirinv",
  3518. fsf_req,
  3519. &header->fsf_status_qual,
  3520. sizeof (union fsf_status_qual));
  3521. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3522. break;
  3523. case FSF_CMND_LENGTH_NOT_VALID:
  3524. ZFCP_LOG_NORMAL
  3525. ("bug: An invalid control-data-block length field "
  3526. "was found in a command for unit 0x%016Lx on port "
  3527. "0x%016Lx on adapter %s " "(debug info %d)\n",
  3528. unit->fcp_lun, unit->port->wwpn,
  3529. zfcp_get_busid_by_unit(unit),
  3530. fsf_req->qtcb->bottom.io.fcp_cmnd_length);
  3531. /* stop operation for this adapter */
  3532. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  3533. "fsf_s_cmd_len_nv");
  3534. zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
  3535. zfcp_cmd_dbf_event_fsf("cleninv",
  3536. fsf_req,
  3537. &header->fsf_status_qual,
  3538. sizeof (union fsf_status_qual));
  3539. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3540. break;
  3541. case FSF_PORT_BOXED:
  3542. ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
  3543. "needs to be reopened\n",
  3544. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  3545. debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed");
  3546. zfcp_erp_port_reopen(unit->port, 0);
  3547. zfcp_cmd_dbf_event_fsf("portbox", fsf_req,
  3548. &header->fsf_status_qual,
  3549. sizeof (union fsf_status_qual));
  3550. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  3551. ZFCP_STATUS_FSFREQ_RETRY;
  3552. break;
  3553. case FSF_LUN_BOXED:
  3554. ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, "
  3555. "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
  3556. zfcp_get_busid_by_unit(unit),
  3557. unit->port->wwpn, unit->fcp_lun);
  3558. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed");
  3559. zfcp_erp_unit_reopen(unit, 0);
  3560. zfcp_cmd_dbf_event_fsf("unitbox", fsf_req,
  3561. &header->fsf_status_qual,
  3562. sizeof(union fsf_status_qual));
  3563. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
  3564. | ZFCP_STATUS_FSFREQ_RETRY;
  3565. break;
  3566. case FSF_ADAPTER_STATUS_AVAILABLE:
  3567. switch (header->fsf_status_qual.word[0]) {
  3568. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  3569. /* re-establish link to port */
  3570. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3571. "fsf_sq_ltest");
  3572. zfcp_test_link(unit->port);
  3573. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3574. break;
  3575. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  3576. /* FIXME(hw) need proper specs for proper action */
  3577. /* let scsi stack deal with retries and escalation */
  3578. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3579. "fsf_sq_ulp");
  3580. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3581. break;
  3582. default:
  3583. /* FIXME: shall we consider this a successful transfer? */
  3584. ZFCP_LOG_NORMAL
  3585. ("bug: Wrong status qualifier 0x%x arrived.\n",
  3586. header->fsf_status_qual.word[0]);
  3587. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  3588. "fsf_sq_inval:");
  3589. debug_exception(fsf_req->adapter->erp_dbf, 0,
  3590. &header->fsf_status_qual.word[0],
  3591. sizeof(u32));
  3592. break;
  3593. }
  3594. break;
  3595. case FSF_GOOD:
  3596. break;
  3597. case FSF_FCP_RSP_AVAILABLE:
  3598. break;
  3599. default:
  3600. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  3601. debug_exception(fsf_req->adapter->erp_dbf, 0,
  3602. &header->fsf_status, sizeof(u32));
  3603. break;
  3604. }
  3605. skip_fsfstatus:
  3606. if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) {
  3607. retval =
  3608. zfcp_fsf_send_fcp_command_task_management_handler(fsf_req);
  3609. } else {
  3610. retval = zfcp_fsf_send_fcp_command_task_handler(fsf_req);
  3611. }
  3612. return retval;
  3613. }
  3614. /*
  3615. * function: zfcp_fsf_send_fcp_command_task_handler
  3616. *
  3617. * purpose: evaluates FCP_RSP IU
  3618. *
  3619. * returns:
  3620. */
  3621. static int
  3622. zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
  3623. {
  3624. int retval = 0;
  3625. struct scsi_cmnd *scpnt;
  3626. struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
  3627. &(fsf_req->qtcb->bottom.io.fcp_rsp);
  3628. struct fcp_cmnd_iu *fcp_cmnd_iu = (struct fcp_cmnd_iu *)
  3629. &(fsf_req->qtcb->bottom.io.fcp_cmnd);
  3630. u32 sns_len;
  3631. char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu);
  3632. unsigned long flags;
  3633. struct zfcp_unit *unit = fsf_req->data.send_fcp_command_task.unit;
  3634. read_lock_irqsave(&fsf_req->adapter->abort_lock, flags);
  3635. scpnt = fsf_req->data.send_fcp_command_task.scsi_cmnd;
  3636. if (unlikely(!scpnt)) {
  3637. ZFCP_LOG_DEBUG
  3638. ("Command with fsf_req %p is not associated to "
  3639. "a scsi command anymore. Aborted?\n", fsf_req);
  3640. goto out;
  3641. }
  3642. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTED)) {
  3643. /* FIXME: (design) mid-layer should handle DID_ABORT like
  3644. * DID_SOFT_ERROR by retrying the request for devices
  3645. * that allow retries.
  3646. */
  3647. ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n");
  3648. set_host_byte(&scpnt->result, DID_SOFT_ERROR);
  3649. set_driver_byte(&scpnt->result, SUGGEST_RETRY);
  3650. goto skip_fsfstatus;
  3651. }
  3652. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
  3653. ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
  3654. set_host_byte(&scpnt->result, DID_ERROR);
  3655. goto skip_fsfstatus;
  3656. }
  3657. /* set message byte of result in SCSI command */
  3658. scpnt->result |= COMMAND_COMPLETE << 8;
  3659. /*
  3660. * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte
  3661. * of result in SCSI command
  3662. */
  3663. scpnt->result |= fcp_rsp_iu->scsi_status;
  3664. if (unlikely(fcp_rsp_iu->scsi_status)) {
  3665. /* DEBUG */
  3666. ZFCP_LOG_DEBUG("status for SCSI Command:\n");
  3667. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3668. scpnt->cmnd, scpnt->cmd_len);
  3669. ZFCP_LOG_DEBUG("SCSI status code 0x%x\n",
  3670. fcp_rsp_iu->scsi_status);
  3671. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3672. (void *) fcp_rsp_iu, sizeof (struct fcp_rsp_iu));
  3673. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3674. zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu),
  3675. fcp_rsp_iu->fcp_sns_len);
  3676. }
  3677. /* check FCP_RSP_INFO */
  3678. if (unlikely(fcp_rsp_iu->validity.bits.fcp_rsp_len_valid)) {
  3679. ZFCP_LOG_DEBUG("rsp_len is valid\n");
  3680. switch (fcp_rsp_info[3]) {
  3681. case RSP_CODE_GOOD:
  3682. /* ok, continue */
  3683. ZFCP_LOG_TRACE("no failure or Task Management "
  3684. "Function complete\n");
  3685. set_host_byte(&scpnt->result, DID_OK);
  3686. break;
  3687. case RSP_CODE_LENGTH_MISMATCH:
  3688. /* hardware bug */
  3689. ZFCP_LOG_NORMAL("bug: FCP response code indictates "
  3690. "that the fibrechannel protocol data "
  3691. "length differs from the burst length. "
  3692. "The problem occured on unit 0x%016Lx "
  3693. "on port 0x%016Lx on adapter %s",
  3694. unit->fcp_lun,
  3695. unit->port->wwpn,
  3696. zfcp_get_busid_by_unit(unit));
  3697. /* dump SCSI CDB as prepared by zfcp */
  3698. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3699. (char *) &fsf_req->qtcb->
  3700. bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
  3701. zfcp_cmd_dbf_event_fsf("clenmis", fsf_req, NULL, 0);
  3702. set_host_byte(&scpnt->result, DID_ERROR);
  3703. goto skip_fsfstatus;
  3704. case RSP_CODE_FIELD_INVALID:
  3705. /* driver or hardware bug */
  3706. ZFCP_LOG_NORMAL("bug: FCP response code indictates "
  3707. "that the fibrechannel protocol data "
  3708. "fields were incorrectly set up. "
  3709. "The problem occured on the unit "
  3710. "0x%016Lx on port 0x%016Lx on "
  3711. "adapter %s",
  3712. unit->fcp_lun,
  3713. unit->port->wwpn,
  3714. zfcp_get_busid_by_unit(unit));
  3715. /* dump SCSI CDB as prepared by zfcp */
  3716. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3717. (char *) &fsf_req->qtcb->
  3718. bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
  3719. set_host_byte(&scpnt->result, DID_ERROR);
  3720. zfcp_cmd_dbf_event_fsf("codeinv", fsf_req, NULL, 0);
  3721. goto skip_fsfstatus;
  3722. case RSP_CODE_RO_MISMATCH:
  3723. /* hardware bug */
  3724. ZFCP_LOG_NORMAL("bug: The FCP response code indicates "
  3725. "that conflicting values for the "
  3726. "fibrechannel payload offset from the "
  3727. "header were found. "
  3728. "The problem occured on unit 0x%016Lx "
  3729. "on port 0x%016Lx on adapter %s.\n",
  3730. unit->fcp_lun,
  3731. unit->port->wwpn,
  3732. zfcp_get_busid_by_unit(unit));
  3733. /* dump SCSI CDB as prepared by zfcp */
  3734. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3735. (char *) &fsf_req->qtcb->
  3736. bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
  3737. zfcp_cmd_dbf_event_fsf("codemism", fsf_req, NULL, 0);
  3738. set_host_byte(&scpnt->result, DID_ERROR);
  3739. goto skip_fsfstatus;
  3740. default:
  3741. ZFCP_LOG_NORMAL("bug: An invalid FCP response "
  3742. "code was detected for a command. "
  3743. "The problem occured on the unit "
  3744. "0x%016Lx on port 0x%016Lx on "
  3745. "adapter %s (debug info 0x%x)\n",
  3746. unit->fcp_lun,
  3747. unit->port->wwpn,
  3748. zfcp_get_busid_by_unit(unit),
  3749. fcp_rsp_info[3]);
  3750. /* dump SCSI CDB as prepared by zfcp */
  3751. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3752. (char *) &fsf_req->qtcb->
  3753. bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
  3754. zfcp_cmd_dbf_event_fsf("undeffcp", fsf_req, NULL, 0);
  3755. set_host_byte(&scpnt->result, DID_ERROR);
  3756. goto skip_fsfstatus;
  3757. }
  3758. }
  3759. /* check for sense data */
  3760. if (unlikely(fcp_rsp_iu->validity.bits.fcp_sns_len_valid)) {
  3761. sns_len = FSF_FCP_RSP_SIZE -
  3762. sizeof (struct fcp_rsp_iu) + fcp_rsp_iu->fcp_rsp_len;
  3763. ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
  3764. sns_len);
  3765. sns_len = min(sns_len, (u32) SCSI_SENSE_BUFFERSIZE);
  3766. ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n",
  3767. SCSI_SENSE_BUFFERSIZE);
  3768. sns_len = min(sns_len, fcp_rsp_iu->fcp_sns_len);
  3769. ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n",
  3770. scpnt->result);
  3771. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
  3772. (void *) &scpnt->cmnd, scpnt->cmd_len);
  3773. ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
  3774. fcp_rsp_iu->fcp_sns_len);
  3775. memcpy(&scpnt->sense_buffer,
  3776. zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu), sns_len);
  3777. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
  3778. (void *) &scpnt->sense_buffer, sns_len);
  3779. }
  3780. /* check for overrun */
  3781. if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_over)) {
  3782. ZFCP_LOG_INFO("A data overrun was detected for a command. "
  3783. "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
  3784. "The response data length is "
  3785. "%d, the original length was %d.\n",
  3786. unit->fcp_lun,
  3787. unit->port->wwpn,
  3788. zfcp_get_busid_by_unit(unit),
  3789. fcp_rsp_iu->fcp_resid,
  3790. (int) zfcp_get_fcp_dl(fcp_cmnd_iu));
  3791. }
  3792. /* check for underrun */
  3793. if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_under)) {
  3794. ZFCP_LOG_INFO("A data underrun was detected for a command. "
  3795. "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
  3796. "The response data length is "
  3797. "%d, the original length was %d.\n",
  3798. unit->fcp_lun,
  3799. unit->port->wwpn,
  3800. zfcp_get_busid_by_unit(unit),
  3801. fcp_rsp_iu->fcp_resid,
  3802. (int) zfcp_get_fcp_dl(fcp_cmnd_iu));
  3803. scpnt->resid = fcp_rsp_iu->fcp_resid;
  3804. if (scpnt->request_bufflen - scpnt->resid < scpnt->underflow)
  3805. set_host_byte(&scpnt->result, DID_ERROR);
  3806. }
  3807. skip_fsfstatus:
  3808. ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt->result);
  3809. zfcp_cmd_dbf_event_scsi("response", scpnt);
  3810. /* cleanup pointer (need this especially for abort) */
  3811. scpnt->host_scribble = NULL;
  3812. /*
  3813. * NOTE:
  3814. * according to the outcome of a discussion on linux-scsi we
  3815. * don't need to grab the io_request_lock here since we use
  3816. * the new eh
  3817. */
  3818. /* always call back */
  3819. (scpnt->scsi_done) (scpnt);
  3820. /*
  3821. * We must hold this lock until scsi_done has been called.
  3822. * Otherwise we may call scsi_done after abort regarding this
  3823. * command has completed.
  3824. * Note: scsi_done must not block!
  3825. */
  3826. out:
  3827. read_unlock_irqrestore(&fsf_req->adapter->abort_lock, flags);
  3828. return retval;
  3829. }
  3830. /*
  3831. * function: zfcp_fsf_send_fcp_command_task_management_handler
  3832. *
  3833. * purpose: evaluates FCP_RSP IU
  3834. *
  3835. * returns:
  3836. */
  3837. static int
  3838. zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req *fsf_req)
  3839. {
  3840. int retval = 0;
  3841. struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
  3842. &(fsf_req->qtcb->bottom.io.fcp_rsp);
  3843. char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu);
  3844. struct zfcp_unit *unit =
  3845. fsf_req->data.send_fcp_command_task_management.unit;
  3846. del_timer(&fsf_req->adapter->scsi_er_timer);
  3847. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  3848. fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
  3849. goto skip_fsfstatus;
  3850. }
  3851. /* check FCP_RSP_INFO */
  3852. switch (fcp_rsp_info[3]) {
  3853. case RSP_CODE_GOOD:
  3854. /* ok, continue */
  3855. ZFCP_LOG_DEBUG("no failure or Task Management "
  3856. "Function complete\n");
  3857. break;
  3858. case RSP_CODE_TASKMAN_UNSUPP:
  3859. ZFCP_LOG_NORMAL("bug: A reuested task management function "
  3860. "is not supported on the target device "
  3861. "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ",
  3862. unit->fcp_lun,
  3863. unit->port->wwpn,
  3864. zfcp_get_busid_by_unit(unit));
  3865. fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP;
  3866. break;
  3867. case RSP_CODE_TASKMAN_FAILED:
  3868. ZFCP_LOG_NORMAL("bug: A reuested task management function "
  3869. "failed to complete successfully. "
  3870. "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n",
  3871. unit->fcp_lun,
  3872. unit->port->wwpn,
  3873. zfcp_get_busid_by_unit(unit));
  3874. fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
  3875. break;
  3876. default:
  3877. ZFCP_LOG_NORMAL("bug: An invalid FCP response "
  3878. "code was detected for a command. "
  3879. "unit 0x%016Lx, port 0x%016Lx, adapter %s "
  3880. "(debug info 0x%x)\n",
  3881. unit->fcp_lun,
  3882. unit->port->wwpn,
  3883. zfcp_get_busid_by_unit(unit),
  3884. fcp_rsp_info[3]);
  3885. fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
  3886. }
  3887. skip_fsfstatus:
  3888. return retval;
  3889. }
  3890. /*
  3891. * function: zfcp_fsf_control_file
  3892. *
  3893. * purpose: Initiator of the control file upload/download FSF requests
  3894. *
  3895. * returns: 0 - FSF request is successfuly created and queued
  3896. * -EOPNOTSUPP - The FCP adapter does not have Control File support
  3897. * -EINVAL - Invalid direction specified
  3898. * -ENOMEM - Insufficient memory
  3899. * -EPERM - Cannot create FSF request or place it in QDIO queue
  3900. */
  3901. int
  3902. zfcp_fsf_control_file(struct zfcp_adapter *adapter,
  3903. struct zfcp_fsf_req **fsf_req_ptr,
  3904. u32 fsf_command,
  3905. u32 option,
  3906. struct zfcp_sg_list *sg_list)
  3907. {
  3908. struct zfcp_fsf_req *fsf_req;
  3909. struct fsf_qtcb_bottom_support *bottom;
  3910. volatile struct qdio_buffer_element *sbale;
  3911. struct timer_list *timer;
  3912. unsigned long lock_flags;
  3913. int req_flags = 0;
  3914. int direction;
  3915. int retval = 0;
  3916. if (!(adapter->supported_features & FSF_FEATURE_CFDC)) {
  3917. ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
  3918. zfcp_get_busid_by_adapter(adapter));
  3919. retval = -EOPNOTSUPP;
  3920. goto out;
  3921. }
  3922. switch (fsf_command) {
  3923. case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
  3924. direction = SBAL_FLAGS0_TYPE_WRITE;
  3925. if ((option != FSF_CFDC_OPTION_FULL_ACCESS) &&
  3926. (option != FSF_CFDC_OPTION_RESTRICTED_ACCESS))
  3927. req_flags = ZFCP_WAIT_FOR_SBAL;
  3928. break;
  3929. case FSF_QTCB_UPLOAD_CONTROL_FILE:
  3930. direction = SBAL_FLAGS0_TYPE_READ;
  3931. break;
  3932. default:
  3933. ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command);
  3934. retval = -EINVAL;
  3935. goto out;
  3936. }
  3937. timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
  3938. if (!timer) {
  3939. retval = -ENOMEM;
  3940. goto out;
  3941. }
  3942. retval = zfcp_fsf_req_create(adapter, fsf_command, req_flags,
  3943. NULL, &lock_flags, &fsf_req);
  3944. if (retval < 0) {
  3945. ZFCP_LOG_INFO("error: Could not create FSF request for the "
  3946. "adapter %s\n",
  3947. zfcp_get_busid_by_adapter(adapter));
  3948. retval = -EPERM;
  3949. goto unlock_queue_lock;
  3950. }
  3951. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  3952. sbale[0].flags |= direction;
  3953. bottom = &fsf_req->qtcb->bottom.support;
  3954. bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE;
  3955. bottom->option = option;
  3956. if (sg_list->count > 0) {
  3957. int bytes;
  3958. bytes = zfcp_qdio_sbals_from_sg(fsf_req, direction,
  3959. sg_list->sg, sg_list->count,
  3960. ZFCP_MAX_SBALS_PER_REQ);
  3961. if (bytes != ZFCP_CFDC_MAX_CONTROL_FILE_SIZE) {
  3962. ZFCP_LOG_INFO(
  3963. "error: Could not create sufficient number of "
  3964. "SBALS for an FSF request to the adapter %s\n",
  3965. zfcp_get_busid_by_adapter(adapter));
  3966. retval = -ENOMEM;
  3967. goto free_fsf_req;
  3968. }
  3969. } else
  3970. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  3971. init_timer(timer);
  3972. timer->function = zfcp_fsf_request_timeout_handler;
  3973. timer->data = (unsigned long) adapter;
  3974. timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
  3975. retval = zfcp_fsf_req_send(fsf_req, timer);
  3976. if (retval < 0) {
  3977. ZFCP_LOG_INFO("initiation of cfdc up/download failed"
  3978. "(adapter %s)\n",
  3979. zfcp_get_busid_by_adapter(adapter));
  3980. retval = -EPERM;
  3981. goto free_fsf_req;
  3982. }
  3983. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  3984. ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the "
  3985. "adapter %s\n",
  3986. fsf_command == FSF_QTCB_DOWNLOAD_CONTROL_FILE ?
  3987. "download" : "upload",
  3988. zfcp_get_busid_by_adapter(adapter));
  3989. wait_event(fsf_req->completion_wq,
  3990. fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
  3991. *fsf_req_ptr = fsf_req;
  3992. del_timer_sync(timer);
  3993. goto free_timer;
  3994. free_fsf_req:
  3995. zfcp_fsf_req_free(fsf_req);
  3996. unlock_queue_lock:
  3997. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  3998. free_timer:
  3999. kfree(timer);
  4000. out:
  4001. return retval;
  4002. }
  4003. /*
  4004. * function: zfcp_fsf_control_file_handler
  4005. *
  4006. * purpose: Handler of the control file upload/download FSF requests
  4007. *
  4008. * returns: 0 - FSF request successfuly processed
  4009. * -EAGAIN - Operation has to be repeated because of a temporary problem
  4010. * -EACCES - There is no permission to execute an operation
  4011. * -EPERM - The control file is not in a right format
  4012. * -EIO - There is a problem with the FCP adapter
  4013. * -EINVAL - Invalid operation
  4014. * -EFAULT - User space memory I/O operation fault
  4015. */
  4016. static int
  4017. zfcp_fsf_control_file_handler(struct zfcp_fsf_req *fsf_req)
  4018. {
  4019. struct zfcp_adapter *adapter = fsf_req->adapter;
  4020. struct fsf_qtcb_header *header = &fsf_req->qtcb->header;
  4021. struct fsf_qtcb_bottom_support *bottom = &fsf_req->qtcb->bottom.support;
  4022. int retval = 0;
  4023. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  4024. retval = -EINVAL;
  4025. goto skip_fsfstatus;
  4026. }
  4027. switch (header->fsf_status) {
  4028. case FSF_GOOD:
  4029. ZFCP_LOG_NORMAL(
  4030. "The FSF request has been successfully completed "
  4031. "on the adapter %s\n",
  4032. zfcp_get_busid_by_adapter(adapter));
  4033. break;
  4034. case FSF_OPERATION_PARTIALLY_SUCCESSFUL:
  4035. if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE) {
  4036. switch (header->fsf_status_qual.word[0]) {
  4037. case FSF_SQ_CFDC_HARDENED_ON_SE:
  4038. ZFCP_LOG_NORMAL(
  4039. "CFDC on the adapter %s has being "
  4040. "hardened on primary and secondary SE\n",
  4041. zfcp_get_busid_by_adapter(adapter));
  4042. break;
  4043. case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE:
  4044. ZFCP_LOG_NORMAL(
  4045. "CFDC of the adapter %s could not "
  4046. "be saved on the SE\n",
  4047. zfcp_get_busid_by_adapter(adapter));
  4048. break;
  4049. case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2:
  4050. ZFCP_LOG_NORMAL(
  4051. "CFDC of the adapter %s could not "
  4052. "be copied to the secondary SE\n",
  4053. zfcp_get_busid_by_adapter(adapter));
  4054. break;
  4055. default:
  4056. ZFCP_LOG_NORMAL(
  4057. "CFDC could not be hardened "
  4058. "on the adapter %s\n",
  4059. zfcp_get_busid_by_adapter(adapter));
  4060. }
  4061. }
  4062. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4063. retval = -EAGAIN;
  4064. break;
  4065. case FSF_AUTHORIZATION_FAILURE:
  4066. ZFCP_LOG_NORMAL(
  4067. "Adapter %s does not accept privileged commands\n",
  4068. zfcp_get_busid_by_adapter(adapter));
  4069. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4070. retval = -EACCES;
  4071. break;
  4072. case FSF_CFDC_ERROR_DETECTED:
  4073. ZFCP_LOG_NORMAL(
  4074. "Error at position %d in the CFDC, "
  4075. "CFDC is discarded by the adapter %s\n",
  4076. header->fsf_status_qual.word[0],
  4077. zfcp_get_busid_by_adapter(adapter));
  4078. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4079. retval = -EPERM;
  4080. break;
  4081. case FSF_CONTROL_FILE_UPDATE_ERROR:
  4082. ZFCP_LOG_NORMAL(
  4083. "Adapter %s cannot harden the control file, "
  4084. "file is discarded\n",
  4085. zfcp_get_busid_by_adapter(adapter));
  4086. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4087. retval = -EIO;
  4088. break;
  4089. case FSF_CONTROL_FILE_TOO_LARGE:
  4090. ZFCP_LOG_NORMAL(
  4091. "Control file is too large, file is discarded "
  4092. "by the adapter %s\n",
  4093. zfcp_get_busid_by_adapter(adapter));
  4094. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4095. retval = -EIO;
  4096. break;
  4097. case FSF_ACCESS_CONFLICT_DETECTED:
  4098. if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE)
  4099. ZFCP_LOG_NORMAL(
  4100. "CFDC has been discarded by the adapter %s, "
  4101. "because activation would impact "
  4102. "%d active connection(s)\n",
  4103. zfcp_get_busid_by_adapter(adapter),
  4104. header->fsf_status_qual.word[0]);
  4105. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4106. retval = -EIO;
  4107. break;
  4108. case FSF_CONFLICTS_OVERRULED:
  4109. if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE)
  4110. ZFCP_LOG_NORMAL(
  4111. "CFDC has been activated on the adapter %s, "
  4112. "but activation has impacted "
  4113. "%d active connection(s)\n",
  4114. zfcp_get_busid_by_adapter(adapter),
  4115. header->fsf_status_qual.word[0]);
  4116. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4117. retval = -EIO;
  4118. break;
  4119. case FSF_UNKNOWN_OP_SUBTYPE:
  4120. ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, "
  4121. "op_subtype=0x%x)\n",
  4122. zfcp_get_busid_by_adapter(adapter),
  4123. bottom->operation_subtype);
  4124. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4125. retval = -EINVAL;
  4126. break;
  4127. case FSF_INVALID_COMMAND_OPTION:
  4128. ZFCP_LOG_NORMAL(
  4129. "Invalid option 0x%x has been specified "
  4130. "in QTCB bottom sent to the adapter %s\n",
  4131. bottom->option,
  4132. zfcp_get_busid_by_adapter(adapter));
  4133. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4134. retval = -EINVAL;
  4135. break;
  4136. default:
  4137. ZFCP_LOG_NORMAL(
  4138. "bug: An unknown/unexpected FSF status 0x%08x "
  4139. "was presented on the adapter %s\n",
  4140. header->fsf_status,
  4141. zfcp_get_busid_by_adapter(adapter));
  4142. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval");
  4143. debug_exception(fsf_req->adapter->erp_dbf, 0,
  4144. &header->fsf_status_qual.word[0], sizeof(u32));
  4145. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4146. retval = -EINVAL;
  4147. break;
  4148. }
  4149. skip_fsfstatus:
  4150. return retval;
  4151. }
  4152. /*
  4153. * function: zfcp_fsf_req_wait_and_cleanup
  4154. *
  4155. * purpose:
  4156. *
  4157. * FIXME(design): signal seems to be <0 !!!
  4158. * returns: 0 - request completed (*status is valid), cleanup succ.
  4159. * <0 - request completed (*status is valid), cleanup failed
  4160. * >0 - signal which interrupted waiting (*status invalid),
  4161. * request not completed, no cleanup
  4162. *
  4163. * *status is a copy of status of completed fsf_req
  4164. */
  4165. int
  4166. zfcp_fsf_req_wait_and_cleanup(struct zfcp_fsf_req *fsf_req,
  4167. int interruptible, u32 * status)
  4168. {
  4169. int retval = 0;
  4170. int signal = 0;
  4171. if (interruptible) {
  4172. __wait_event_interruptible(fsf_req->completion_wq,
  4173. fsf_req->status &
  4174. ZFCP_STATUS_FSFREQ_COMPLETED,
  4175. signal);
  4176. if (signal) {
  4177. ZFCP_LOG_DEBUG("Caught signal %i while waiting for the "
  4178. "completion of the request at %p\n",
  4179. signal, fsf_req);
  4180. retval = signal;
  4181. goto out;
  4182. }
  4183. } else {
  4184. __wait_event(fsf_req->completion_wq,
  4185. fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
  4186. }
  4187. *status = fsf_req->status;
  4188. /* cleanup request */
  4189. zfcp_fsf_req_cleanup(fsf_req);
  4190. out:
  4191. return retval;
  4192. }
  4193. static inline int
  4194. zfcp_fsf_req_sbal_check(unsigned long *flags,
  4195. struct zfcp_qdio_queue *queue, int needed)
  4196. {
  4197. write_lock_irqsave(&queue->queue_lock, *flags);
  4198. if (likely(atomic_read(&queue->free_count) >= needed))
  4199. return 1;
  4200. write_unlock_irqrestore(&queue->queue_lock, *flags);
  4201. return 0;
  4202. }
  4203. /*
  4204. * set qtcb pointer in fsf_req and initialize QTCB
  4205. */
  4206. static inline void
  4207. zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req *fsf_req, u32 fsf_cmd)
  4208. {
  4209. if (likely(fsf_req->qtcb != NULL)) {
  4210. fsf_req->qtcb->prefix.req_id = (unsigned long)fsf_req;
  4211. fsf_req->qtcb->prefix.ulp_info = ZFCP_ULP_INFO_VERSION;
  4212. fsf_req->qtcb->prefix.qtcb_type = fsf_qtcb_type[fsf_cmd];
  4213. fsf_req->qtcb->prefix.qtcb_version = ZFCP_QTCB_VERSION;
  4214. fsf_req->qtcb->header.req_handle = (unsigned long)fsf_req;
  4215. fsf_req->qtcb->header.fsf_command = fsf_cmd;
  4216. }
  4217. }
  4218. /**
  4219. * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue
  4220. * @adapter: adapter for which request queue is examined
  4221. * @req_flags: flags indicating whether to wait for needed SBAL or not
  4222. * @lock_flags: lock_flags if queue_lock is taken
  4223. * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
  4224. * Locks: lock adapter->request_queue->queue_lock on success
  4225. */
  4226. static int
  4227. zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter, int req_flags,
  4228. unsigned long *lock_flags)
  4229. {
  4230. long ret;
  4231. struct zfcp_qdio_queue *req_queue = &adapter->request_queue;
  4232. if (unlikely(req_flags & ZFCP_WAIT_FOR_SBAL)) {
  4233. ret = wait_event_interruptible_timeout(adapter->request_wq,
  4234. zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1),
  4235. ZFCP_SBAL_TIMEOUT);
  4236. if (ret < 0)
  4237. return ret;
  4238. if (!ret)
  4239. return -EIO;
  4240. } else if (!zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1))
  4241. return -EIO;
  4242. return 0;
  4243. }
  4244. /*
  4245. * function: zfcp_fsf_req_create
  4246. *
  4247. * purpose: create an FSF request at the specified adapter and
  4248. * setup common fields
  4249. *
  4250. * returns: -ENOMEM if there was insufficient memory for a request
  4251. * -EIO if no qdio buffers could be allocate to the request
  4252. * -EINVAL/-EPERM on bug conditions in req_dequeue
  4253. * 0 in success
  4254. *
  4255. * note: The created request is returned by reference.
  4256. *
  4257. * locks: lock of concerned request queue must not be held,
  4258. * but is held on completion (write, irqsave)
  4259. */
  4260. int
  4261. zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
  4262. mempool_t *pool, unsigned long *lock_flags,
  4263. struct zfcp_fsf_req **fsf_req_p)
  4264. {
  4265. volatile struct qdio_buffer_element *sbale;
  4266. struct zfcp_fsf_req *fsf_req = NULL;
  4267. int ret = 0;
  4268. struct zfcp_qdio_queue *req_queue = &adapter->request_queue;
  4269. /* allocate new FSF request */
  4270. fsf_req = zfcp_fsf_req_alloc(pool, req_flags);
  4271. if (unlikely(NULL == fsf_req)) {
  4272. ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
  4273. "the outbound (send) queue.\n");
  4274. ret = -ENOMEM;
  4275. goto failed_fsf_req;
  4276. }
  4277. zfcp_fsf_req_qtcb_init(fsf_req, fsf_cmd);
  4278. /* initialize waitqueue which may be used to wait on
  4279. this request completion */
  4280. init_waitqueue_head(&fsf_req->completion_wq);
  4281. ret = zfcp_fsf_req_sbal_get(adapter, req_flags, lock_flags);
  4282. if(ret < 0) {
  4283. goto failed_sbals;
  4284. }
  4285. /*
  4286. * We hold queue_lock here. Check if QDIOUP is set and let request fail
  4287. * if it is not set (see also *_open_qdio and *_close_qdio).
  4288. */
  4289. if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
  4290. write_unlock_irqrestore(&req_queue->queue_lock, *lock_flags);
  4291. ret = -EIO;
  4292. goto failed_sbals;
  4293. }
  4294. fsf_req->adapter = adapter; /* pointer to "parent" adapter */
  4295. fsf_req->fsf_command = fsf_cmd;
  4296. fsf_req->sbal_number = 1;
  4297. fsf_req->sbal_first = req_queue->free_index;
  4298. fsf_req->sbal_curr = req_queue->free_index;
  4299. fsf_req->sbale_curr = 1;
  4300. if (likely(req_flags & ZFCP_REQ_AUTO_CLEANUP)) {
  4301. fsf_req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  4302. }
  4303. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  4304. /* setup common SBALE fields */
  4305. sbale[0].addr = fsf_req;
  4306. sbale[0].flags |= SBAL_FLAGS0_COMMAND;
  4307. if (likely(fsf_req->qtcb != NULL)) {
  4308. sbale[1].addr = (void *) fsf_req->qtcb;
  4309. sbale[1].length = sizeof(struct fsf_qtcb);
  4310. }
  4311. ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n",
  4312. fsf_req->sbal_number, fsf_req->sbal_first);
  4313. goto success;
  4314. failed_sbals:
  4315. /* dequeue new FSF request previously enqueued */
  4316. zfcp_fsf_req_free(fsf_req);
  4317. fsf_req = NULL;
  4318. failed_fsf_req:
  4319. write_lock_irqsave(&req_queue->queue_lock, *lock_flags);
  4320. success:
  4321. *fsf_req_p = fsf_req;
  4322. return ret;
  4323. }
  4324. /*
  4325. * function: zfcp_fsf_req_send
  4326. *
  4327. * purpose: start transfer of FSF request via QDIO
  4328. *
  4329. * returns: 0 - request transfer succesfully started
  4330. * !0 - start of request transfer failed
  4331. */
  4332. static int
  4333. zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req, struct timer_list *timer)
  4334. {
  4335. struct zfcp_adapter *adapter;
  4336. struct zfcp_qdio_queue *req_queue;
  4337. volatile struct qdio_buffer_element *sbale;
  4338. int new_distance_from_int;
  4339. unsigned long flags;
  4340. int inc_seq_no = 1;
  4341. int retval = 0;
  4342. adapter = fsf_req->adapter;
  4343. req_queue = &adapter->request_queue,
  4344. /* FIXME(debug): remove it later */
  4345. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_first, 0);
  4346. ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale[0].flags);
  4347. ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
  4348. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, (char *) sbale[1].addr,
  4349. sbale[1].length);
  4350. /* set sequence counter in QTCB */
  4351. if (likely(fsf_req->qtcb)) {
  4352. fsf_req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
  4353. fsf_req->seq_no = adapter->fsf_req_seq_no;
  4354. ZFCP_LOG_TRACE("FSF request %p of adapter %s gets "
  4355. "FSF sequence counter value of %i\n",
  4356. fsf_req,
  4357. zfcp_get_busid_by_adapter(adapter),
  4358. fsf_req->qtcb->prefix.req_seq_no);
  4359. } else
  4360. inc_seq_no = 0;
  4361. /* put allocated FSF request at list tail */
  4362. write_lock_irqsave(&adapter->fsf_req_list_lock, flags);
  4363. list_add_tail(&fsf_req->list, &adapter->fsf_req_list_head);
  4364. write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);
  4365. /* figure out expiration time of timeout and start timeout */
  4366. if (unlikely(timer)) {
  4367. timer->expires += jiffies;
  4368. add_timer(timer);
  4369. }
  4370. ZFCP_LOG_TRACE("request queue of adapter %s: "
  4371. "next free SBAL is %i, %i free SBALs\n",
  4372. zfcp_get_busid_by_adapter(adapter),
  4373. req_queue->free_index,
  4374. atomic_read(&req_queue->free_count));
  4375. ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
  4376. "index_in_queue=%i, count=%i, buffers=%p\n",
  4377. zfcp_get_busid_by_adapter(adapter),
  4378. QDIO_FLAG_SYNC_OUTPUT,
  4379. 0, fsf_req->sbal_first, fsf_req->sbal_number,
  4380. &req_queue->buffer[fsf_req->sbal_first]);
  4381. /*
  4382. * adjust the number of free SBALs in request queue as well as
  4383. * position of first one
  4384. */
  4385. atomic_sub(fsf_req->sbal_number, &req_queue->free_count);
  4386. ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue->free_count));
  4387. req_queue->free_index += fsf_req->sbal_number; /* increase */
  4388. req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap if needed */
  4389. new_distance_from_int = zfcp_qdio_determine_pci(req_queue, fsf_req);
  4390. retval = do_QDIO(adapter->ccw_device,
  4391. QDIO_FLAG_SYNC_OUTPUT,
  4392. 0, fsf_req->sbal_first, fsf_req->sbal_number, NULL);
  4393. if (unlikely(retval)) {
  4394. /* Queues are down..... */
  4395. retval = -EIO;
  4396. /*
  4397. * FIXME(potential race):
  4398. * timer might be expired (absolutely unlikely)
  4399. */
  4400. if (timer)
  4401. del_timer(timer);
  4402. write_lock_irqsave(&adapter->fsf_req_list_lock, flags);
  4403. list_del(&fsf_req->list);
  4404. write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);
  4405. /*
  4406. * adjust the number of free SBALs in request queue as well as
  4407. * position of first one
  4408. */
  4409. zfcp_qdio_zero_sbals(req_queue->buffer,
  4410. fsf_req->sbal_first, fsf_req->sbal_number);
  4411. atomic_add(fsf_req->sbal_number, &req_queue->free_count);
  4412. req_queue->free_index -= fsf_req->sbal_number; /* increase */
  4413. req_queue->free_index += QDIO_MAX_BUFFERS_PER_Q;
  4414. req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap */
  4415. ZFCP_LOG_DEBUG
  4416. ("error: do_QDIO failed. Buffers could not be enqueued "
  4417. "to request queue.\n");
  4418. } else {
  4419. req_queue->distance_from_int = new_distance_from_int;
  4420. /*
  4421. * increase FSF sequence counter -
  4422. * this must only be done for request successfully enqueued to
  4423. * QDIO this rejected requests may be cleaned up by calling
  4424. * routines resulting in missing sequence counter values
  4425. * otherwise,
  4426. */
  4427. /* Don't increase for unsolicited status */
  4428. if (likely(inc_seq_no)) {
  4429. adapter->fsf_req_seq_no++;
  4430. ZFCP_LOG_TRACE
  4431. ("FSF sequence counter value of adapter %s "
  4432. "increased to %i\n",
  4433. zfcp_get_busid_by_adapter(adapter),
  4434. adapter->fsf_req_seq_no);
  4435. }
  4436. /* count FSF requests pending */
  4437. atomic_inc(&adapter->fsf_reqs_active);
  4438. }
  4439. return retval;
  4440. }
  4441. /*
  4442. * function: zfcp_fsf_req_cleanup
  4443. *
  4444. * purpose: cleans up an FSF request and removes it from the specified list
  4445. *
  4446. * returns:
  4447. *
  4448. * assumption: no pending SB in SBALEs other than QTCB
  4449. */
  4450. void
  4451. zfcp_fsf_req_cleanup(struct zfcp_fsf_req *fsf_req)
  4452. {
  4453. struct zfcp_adapter *adapter = fsf_req->adapter;
  4454. unsigned long flags;
  4455. write_lock_irqsave(&adapter->fsf_req_list_lock, flags);
  4456. list_del(&fsf_req->list);
  4457. write_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);
  4458. zfcp_fsf_req_free(fsf_req);
  4459. }
  4460. #undef ZFCP_LOG_AREA