zfcp_fsf.c 152 KB

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