zfcp_fsf.c 152 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909
  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. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  1006. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1007. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1008. fsf_req->data = (unsigned long) unit;
  1009. /* set handles of unit and its parent port in QTCB */
  1010. fsf_req->qtcb->header.lun_handle = unit->handle;
  1011. fsf_req->qtcb->header.port_handle = unit->port->handle;
  1012. /* set handle of request which should be aborted */
  1013. fsf_req->qtcb->bottom.support.req_handle = (u64) old_req_id;
  1014. zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
  1015. retval = zfcp_fsf_req_send(fsf_req);
  1016. if (retval) {
  1017. ZFCP_LOG_INFO("error: Failed to send abort command request "
  1018. "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
  1019. zfcp_get_busid_by_adapter(adapter),
  1020. unit->port->wwpn, unit->fcp_lun);
  1021. zfcp_fsf_req_free(fsf_req);
  1022. fsf_req = NULL;
  1023. goto out;
  1024. }
  1025. ZFCP_LOG_DEBUG("Abort FCP Command request initiated "
  1026. "(adapter%s, port d_id=0x%06x, "
  1027. "unit x%016Lx, old_req_id=0x%lx)\n",
  1028. zfcp_get_busid_by_adapter(adapter),
  1029. unit->port->d_id,
  1030. unit->fcp_lun, old_req_id);
  1031. out:
  1032. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  1033. return fsf_req;
  1034. }
  1035. /*
  1036. * function: zfcp_fsf_abort_fcp_command_handler
  1037. *
  1038. * purpose: is called for finished Abort FCP Command request
  1039. *
  1040. * returns:
  1041. */
  1042. static int
  1043. zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *new_fsf_req)
  1044. {
  1045. int retval = -EINVAL;
  1046. struct zfcp_unit *unit;
  1047. unsigned char status_qual =
  1048. new_fsf_req->qtcb->header.fsf_status_qual.word[0];
  1049. if (new_fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  1050. /* do not set ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED */
  1051. goto skip_fsfstatus;
  1052. }
  1053. unit = (struct zfcp_unit *) new_fsf_req->data;
  1054. /* evaluate FSF status in QTCB */
  1055. switch (new_fsf_req->qtcb->header.fsf_status) {
  1056. case FSF_PORT_HANDLE_NOT_VALID:
  1057. if (status_qual >> 4 != status_qual % 0xf) {
  1058. debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
  1059. "fsf_s_phand_nv0");
  1060. /*
  1061. * In this case a command that was sent prior to a port
  1062. * reopen was aborted (handles are different). This is
  1063. * fine.
  1064. */
  1065. } else {
  1066. ZFCP_LOG_INFO("Temporary port identifier 0x%x for "
  1067. "port 0x%016Lx on adapter %s invalid. "
  1068. "This may happen occasionally.\n",
  1069. unit->port->handle,
  1070. unit->port->wwpn,
  1071. zfcp_get_busid_by_unit(unit));
  1072. ZFCP_LOG_INFO("status qualifier:\n");
  1073. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
  1074. (char *) &new_fsf_req->qtcb->header.
  1075. fsf_status_qual,
  1076. sizeof (union fsf_status_qual));
  1077. /* Let's hope this sorts out the mess */
  1078. debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
  1079. "fsf_s_phand_nv1");
  1080. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  1081. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1082. }
  1083. break;
  1084. case FSF_LUN_HANDLE_NOT_VALID:
  1085. if (status_qual >> 4 != status_qual % 0xf) {
  1086. /* 2 */
  1087. debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
  1088. "fsf_s_lhand_nv0");
  1089. /*
  1090. * In this case a command that was sent prior to a unit
  1091. * reopen was aborted (handles are different).
  1092. * This is fine.
  1093. */
  1094. } else {
  1095. ZFCP_LOG_INFO
  1096. ("Warning: Temporary LUN identifier 0x%x of LUN "
  1097. "0x%016Lx on port 0x%016Lx on adapter %s is "
  1098. "invalid. This may happen in rare cases. "
  1099. "Trying to re-establish link.\n",
  1100. unit->handle,
  1101. unit->fcp_lun,
  1102. unit->port->wwpn,
  1103. zfcp_get_busid_by_unit(unit));
  1104. ZFCP_LOG_DEBUG("Status qualifier data:\n");
  1105. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  1106. (char *) &new_fsf_req->qtcb->header.
  1107. fsf_status_qual,
  1108. sizeof (union fsf_status_qual));
  1109. /* Let's hope this sorts out the mess */
  1110. debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
  1111. "fsf_s_lhand_nv1");
  1112. zfcp_erp_port_reopen(unit->port, 0);
  1113. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1114. }
  1115. break;
  1116. case FSF_FCP_COMMAND_DOES_NOT_EXIST:
  1117. retval = 0;
  1118. debug_text_event(new_fsf_req->adapter->erp_dbf, 3,
  1119. "fsf_s_no_exist");
  1120. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
  1121. break;
  1122. case FSF_PORT_BOXED:
  1123. ZFCP_LOG_INFO("Remote port 0x%016Lx on adapter %s needs to "
  1124. "be reopened\n", unit->port->wwpn,
  1125. zfcp_get_busid_by_unit(unit));
  1126. debug_text_event(new_fsf_req->adapter->erp_dbf, 2,
  1127. "fsf_s_pboxed");
  1128. zfcp_erp_port_boxed(unit->port);
  1129. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
  1130. | ZFCP_STATUS_FSFREQ_RETRY;
  1131. break;
  1132. case FSF_LUN_BOXED:
  1133. ZFCP_LOG_INFO(
  1134. "unit 0x%016Lx on port 0x%016Lx on adapter %s needs "
  1135. "to be reopened\n",
  1136. unit->fcp_lun, unit->port->wwpn,
  1137. zfcp_get_busid_by_unit(unit));
  1138. debug_text_event(new_fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed");
  1139. zfcp_erp_unit_boxed(unit);
  1140. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
  1141. | ZFCP_STATUS_FSFREQ_RETRY;
  1142. break;
  1143. case FSF_ADAPTER_STATUS_AVAILABLE:
  1144. switch (new_fsf_req->qtcb->header.fsf_status_qual.word[0]) {
  1145. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1146. debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
  1147. "fsf_sq_ltest");
  1148. zfcp_test_link(unit->port);
  1149. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1150. break;
  1151. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1152. /* SCSI stack will escalate */
  1153. debug_text_event(new_fsf_req->adapter->erp_dbf, 1,
  1154. "fsf_sq_ulp");
  1155. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1156. break;
  1157. default:
  1158. ZFCP_LOG_NORMAL
  1159. ("bug: Wrong status qualifier 0x%x arrived.\n",
  1160. new_fsf_req->qtcb->header.fsf_status_qual.word[0]);
  1161. debug_text_event(new_fsf_req->adapter->erp_dbf, 0,
  1162. "fsf_sq_inval:");
  1163. debug_exception(new_fsf_req->adapter->erp_dbf, 0,
  1164. &new_fsf_req->qtcb->header.
  1165. fsf_status_qual.word[0], sizeof (u32));
  1166. break;
  1167. }
  1168. break;
  1169. case FSF_GOOD:
  1170. retval = 0;
  1171. new_fsf_req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED;
  1172. break;
  1173. default:
  1174. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  1175. "(debug info 0x%x)\n",
  1176. new_fsf_req->qtcb->header.fsf_status);
  1177. debug_text_event(new_fsf_req->adapter->erp_dbf, 0,
  1178. "fsf_s_inval:");
  1179. debug_exception(new_fsf_req->adapter->erp_dbf, 0,
  1180. &new_fsf_req->qtcb->header.fsf_status,
  1181. sizeof (u32));
  1182. break;
  1183. }
  1184. skip_fsfstatus:
  1185. return retval;
  1186. }
  1187. /**
  1188. * zfcp_use_one_sbal - checks whether req buffer and resp bother each fit into
  1189. * one SBALE
  1190. * Two scatter-gather lists are passed, one for the reqeust and one for the
  1191. * response.
  1192. */
  1193. static inline int
  1194. zfcp_use_one_sbal(struct scatterlist *req, int req_count,
  1195. struct scatterlist *resp, int resp_count)
  1196. {
  1197. return ((req_count == 1) &&
  1198. (resp_count == 1) &&
  1199. (((unsigned long) zfcp_sg_to_address(&req[0]) &
  1200. PAGE_MASK) ==
  1201. ((unsigned long) (zfcp_sg_to_address(&req[0]) +
  1202. req[0].length - 1) & PAGE_MASK)) &&
  1203. (((unsigned long) zfcp_sg_to_address(&resp[0]) &
  1204. PAGE_MASK) ==
  1205. ((unsigned long) (zfcp_sg_to_address(&resp[0]) +
  1206. resp[0].length - 1) & PAGE_MASK)));
  1207. }
  1208. /**
  1209. * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
  1210. * @ct: pointer to struct zfcp_send_ct which conatins all needed data for
  1211. * the request
  1212. * @pool: pointer to memory pool, if non-null this pool is used to allocate
  1213. * a struct zfcp_fsf_req
  1214. * @erp_action: pointer to erp_action, if non-null the Generic Service request
  1215. * is sent within error recovery
  1216. */
  1217. int
  1218. zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
  1219. struct zfcp_erp_action *erp_action)
  1220. {
  1221. volatile struct qdio_buffer_element *sbale;
  1222. struct zfcp_port *port;
  1223. struct zfcp_adapter *adapter;
  1224. struct zfcp_fsf_req *fsf_req;
  1225. unsigned long lock_flags;
  1226. int bytes;
  1227. int ret = 0;
  1228. port = ct->port;
  1229. adapter = port->adapter;
  1230. ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_GENERIC,
  1231. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  1232. pool, &lock_flags, &fsf_req);
  1233. if (ret < 0) {
  1234. ZFCP_LOG_INFO("error: Could not create CT request (FC-GS) for "
  1235. "adapter: %s\n",
  1236. zfcp_get_busid_by_adapter(adapter));
  1237. goto failed_req;
  1238. }
  1239. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  1240. if (zfcp_use_one_sbal(ct->req, ct->req_count,
  1241. ct->resp, ct->resp_count)){
  1242. /* both request buffer and response buffer
  1243. fit into one sbale each */
  1244. sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
  1245. sbale[2].addr = zfcp_sg_to_address(&ct->req[0]);
  1246. sbale[2].length = ct->req[0].length;
  1247. sbale[3].addr = zfcp_sg_to_address(&ct->resp[0]);
  1248. sbale[3].length = ct->resp[0].length;
  1249. sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
  1250. } else if (adapter->adapter_features &
  1251. FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
  1252. /* try to use chained SBALs */
  1253. bytes = zfcp_qdio_sbals_from_sg(fsf_req,
  1254. SBAL_FLAGS0_TYPE_WRITE_READ,
  1255. ct->req, ct->req_count,
  1256. ZFCP_MAX_SBALS_PER_CT_REQ);
  1257. if (bytes <= 0) {
  1258. ZFCP_LOG_INFO("error: creation of CT request failed "
  1259. "on adapter %s\n",
  1260. zfcp_get_busid_by_adapter(adapter));
  1261. if (bytes == 0)
  1262. ret = -ENOMEM;
  1263. else
  1264. ret = bytes;
  1265. goto failed_send;
  1266. }
  1267. fsf_req->qtcb->bottom.support.req_buf_length = bytes;
  1268. fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
  1269. bytes = zfcp_qdio_sbals_from_sg(fsf_req,
  1270. SBAL_FLAGS0_TYPE_WRITE_READ,
  1271. ct->resp, ct->resp_count,
  1272. ZFCP_MAX_SBALS_PER_CT_REQ);
  1273. if (bytes <= 0) {
  1274. ZFCP_LOG_INFO("error: creation of CT request failed "
  1275. "on adapter %s\n",
  1276. zfcp_get_busid_by_adapter(adapter));
  1277. if (bytes == 0)
  1278. ret = -ENOMEM;
  1279. else
  1280. ret = bytes;
  1281. goto failed_send;
  1282. }
  1283. fsf_req->qtcb->bottom.support.resp_buf_length = bytes;
  1284. } else {
  1285. /* reject send generic request */
  1286. ZFCP_LOG_INFO(
  1287. "error: microcode does not support chained SBALs,"
  1288. "CT request too big (adapter %s)\n",
  1289. zfcp_get_busid_by_adapter(adapter));
  1290. ret = -EOPNOTSUPP;
  1291. goto failed_send;
  1292. }
  1293. /* settings in QTCB */
  1294. fsf_req->qtcb->header.port_handle = port->handle;
  1295. fsf_req->qtcb->bottom.support.service_class =
  1296. ZFCP_FC_SERVICE_CLASS_DEFAULT;
  1297. fsf_req->qtcb->bottom.support.timeout = ct->timeout;
  1298. fsf_req->data = (unsigned long) ct;
  1299. zfcp_san_dbf_event_ct_request(fsf_req);
  1300. if (erp_action) {
  1301. erp_action->fsf_req = fsf_req;
  1302. fsf_req->erp_action = erp_action;
  1303. zfcp_erp_start_timer(fsf_req);
  1304. } else
  1305. zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
  1306. ret = zfcp_fsf_req_send(fsf_req);
  1307. if (ret) {
  1308. ZFCP_LOG_DEBUG("error: initiation of CT request failed "
  1309. "(adapter %s, port 0x%016Lx)\n",
  1310. zfcp_get_busid_by_adapter(adapter), port->wwpn);
  1311. goto failed_send;
  1312. }
  1313. ZFCP_LOG_DEBUG("CT request initiated (adapter %s, port 0x%016Lx)\n",
  1314. zfcp_get_busid_by_adapter(adapter), port->wwpn);
  1315. goto out;
  1316. failed_send:
  1317. zfcp_fsf_req_free(fsf_req);
  1318. if (erp_action != NULL) {
  1319. erp_action->fsf_req = NULL;
  1320. }
  1321. failed_req:
  1322. out:
  1323. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  1324. lock_flags);
  1325. return ret;
  1326. }
  1327. /**
  1328. * zfcp_fsf_send_ct_handler - handler for Generic Service requests
  1329. * @fsf_req: pointer to struct zfcp_fsf_req
  1330. *
  1331. * Data specific for the Generic Service request is passed using
  1332. * fsf_req->data. There we find the pointer to struct zfcp_send_ct.
  1333. * Usually a specific handler for the CT request is called which is
  1334. * found in this structure.
  1335. */
  1336. static int
  1337. zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *fsf_req)
  1338. {
  1339. struct zfcp_port *port;
  1340. struct zfcp_adapter *adapter;
  1341. struct zfcp_send_ct *send_ct;
  1342. struct fsf_qtcb_header *header;
  1343. struct fsf_qtcb_bottom_support *bottom;
  1344. int retval = -EINVAL;
  1345. u16 subtable, rule, counter;
  1346. adapter = fsf_req->adapter;
  1347. send_ct = (struct zfcp_send_ct *) fsf_req->data;
  1348. port = send_ct->port;
  1349. header = &fsf_req->qtcb->header;
  1350. bottom = &fsf_req->qtcb->bottom.support;
  1351. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1352. goto skip_fsfstatus;
  1353. /* evaluate FSF status in QTCB */
  1354. switch (header->fsf_status) {
  1355. case FSF_GOOD:
  1356. zfcp_san_dbf_event_ct_response(fsf_req);
  1357. retval = 0;
  1358. break;
  1359. case FSF_SERVICE_CLASS_NOT_SUPPORTED:
  1360. ZFCP_LOG_INFO("error: adapter %s does not support fc "
  1361. "class %d.\n",
  1362. zfcp_get_busid_by_port(port),
  1363. ZFCP_FC_SERVICE_CLASS_DEFAULT);
  1364. /* stop operation for this adapter */
  1365. debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
  1366. zfcp_erp_adapter_shutdown(adapter, 0);
  1367. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1368. break;
  1369. case FSF_ADAPTER_STATUS_AVAILABLE:
  1370. switch (header->fsf_status_qual.word[0]){
  1371. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1372. /* reopening link to port */
  1373. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
  1374. zfcp_test_link(port);
  1375. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1376. break;
  1377. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1378. /* ERP strategy will escalate */
  1379. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
  1380. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1381. break;
  1382. default:
  1383. ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x "
  1384. "arrived.\n",
  1385. header->fsf_status_qual.word[0]);
  1386. break;
  1387. }
  1388. break;
  1389. case FSF_ACCESS_DENIED:
  1390. ZFCP_LOG_NORMAL("access denied, cannot send generic service "
  1391. "command (adapter %s, port d_id=0x%06x)\n",
  1392. zfcp_get_busid_by_port(port), port->d_id);
  1393. for (counter = 0; counter < 2; counter++) {
  1394. subtable = header->fsf_status_qual.halfword[counter * 2];
  1395. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  1396. switch (subtable) {
  1397. case FSF_SQ_CFDC_SUBTABLE_OS:
  1398. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  1399. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  1400. case FSF_SQ_CFDC_SUBTABLE_LUN:
  1401. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  1402. zfcp_act_subtable_type[subtable], rule);
  1403. break;
  1404. }
  1405. }
  1406. debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
  1407. zfcp_erp_port_access_denied(port);
  1408. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1409. break;
  1410. case FSF_GENERIC_COMMAND_REJECTED:
  1411. ZFCP_LOG_INFO("generic service command rejected "
  1412. "(adapter %s, port d_id=0x%06x)\n",
  1413. zfcp_get_busid_by_port(port), port->d_id);
  1414. ZFCP_LOG_INFO("status qualifier:\n");
  1415. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
  1416. (char *) &header->fsf_status_qual,
  1417. sizeof (union fsf_status_qual));
  1418. debug_text_event(adapter->erp_dbf, 1, "fsf_s_gcom_rej");
  1419. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1420. break;
  1421. case FSF_PORT_HANDLE_NOT_VALID:
  1422. ZFCP_LOG_DEBUG("Temporary port identifier 0x%x for port "
  1423. "0x%016Lx on adapter %s invalid. This may "
  1424. "happen occasionally.\n", port->handle,
  1425. port->wwpn, zfcp_get_busid_by_port(port));
  1426. ZFCP_LOG_INFO("status qualifier:\n");
  1427. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
  1428. (char *) &header->fsf_status_qual,
  1429. sizeof (union fsf_status_qual));
  1430. debug_text_event(adapter->erp_dbf, 1, "fsf_s_phandle_nv");
  1431. zfcp_erp_adapter_reopen(adapter, 0);
  1432. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1433. break;
  1434. case FSF_PORT_BOXED:
  1435. ZFCP_LOG_INFO("port needs to be reopened "
  1436. "(adapter %s, port d_id=0x%06x)\n",
  1437. zfcp_get_busid_by_port(port), port->d_id);
  1438. debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");
  1439. zfcp_erp_port_boxed(port);
  1440. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
  1441. | ZFCP_STATUS_FSFREQ_RETRY;
  1442. break;
  1443. /* following states should never occure, all cases avoided
  1444. in zfcp_fsf_send_ct - but who knows ... */
  1445. case FSF_PAYLOAD_SIZE_MISMATCH:
  1446. ZFCP_LOG_INFO("payload size mismatch (adapter: %s, "
  1447. "req_buf_length=%d, resp_buf_length=%d)\n",
  1448. zfcp_get_busid_by_adapter(adapter),
  1449. bottom->req_buf_length, bottom->resp_buf_length);
  1450. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1451. break;
  1452. case FSF_REQUEST_SIZE_TOO_LARGE:
  1453. ZFCP_LOG_INFO("request size too large (adapter: %s, "
  1454. "req_buf_length=%d)\n",
  1455. zfcp_get_busid_by_adapter(adapter),
  1456. bottom->req_buf_length);
  1457. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1458. break;
  1459. case FSF_RESPONSE_SIZE_TOO_LARGE:
  1460. ZFCP_LOG_INFO("response size too large (adapter: %s, "
  1461. "resp_buf_length=%d)\n",
  1462. zfcp_get_busid_by_adapter(adapter),
  1463. bottom->resp_buf_length);
  1464. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1465. break;
  1466. case FSF_SBAL_MISMATCH:
  1467. ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
  1468. "resp_buf_length=%d)\n",
  1469. zfcp_get_busid_by_adapter(adapter),
  1470. bottom->req_buf_length, bottom->resp_buf_length);
  1471. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1472. break;
  1473. default:
  1474. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  1475. "(debug info 0x%x)\n", header->fsf_status);
  1476. debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval:");
  1477. debug_exception(adapter->erp_dbf, 0,
  1478. &header->fsf_status_qual.word[0], sizeof (u32));
  1479. break;
  1480. }
  1481. skip_fsfstatus:
  1482. send_ct->status = retval;
  1483. if (send_ct->handler != NULL)
  1484. send_ct->handler(send_ct->handler_data);
  1485. return retval;
  1486. }
  1487. /**
  1488. * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
  1489. * @els: pointer to struct zfcp_send_els which contains all needed data for
  1490. * the command.
  1491. */
  1492. int
  1493. zfcp_fsf_send_els(struct zfcp_send_els *els)
  1494. {
  1495. volatile struct qdio_buffer_element *sbale;
  1496. struct zfcp_fsf_req *fsf_req;
  1497. u32 d_id;
  1498. struct zfcp_adapter *adapter;
  1499. unsigned long lock_flags;
  1500. int bytes;
  1501. int ret = 0;
  1502. d_id = els->d_id;
  1503. adapter = els->adapter;
  1504. ret = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS,
  1505. ZFCP_REQ_AUTO_CLEANUP,
  1506. NULL, &lock_flags, &fsf_req);
  1507. if (ret < 0) {
  1508. ZFCP_LOG_INFO("error: creation of ELS request failed "
  1509. "(adapter %s, port d_id: 0x%06x)\n",
  1510. zfcp_get_busid_by_adapter(adapter), d_id);
  1511. goto failed_req;
  1512. }
  1513. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  1514. if (zfcp_use_one_sbal(els->req, els->req_count,
  1515. els->resp, els->resp_count)){
  1516. /* both request buffer and response buffer
  1517. fit into one sbale each */
  1518. sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
  1519. sbale[2].addr = zfcp_sg_to_address(&els->req[0]);
  1520. sbale[2].length = els->req[0].length;
  1521. sbale[3].addr = zfcp_sg_to_address(&els->resp[0]);
  1522. sbale[3].length = els->resp[0].length;
  1523. sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
  1524. } else if (adapter->adapter_features &
  1525. FSF_FEATURE_ELS_CT_CHAINED_SBALS) {
  1526. /* try to use chained SBALs */
  1527. bytes = zfcp_qdio_sbals_from_sg(fsf_req,
  1528. SBAL_FLAGS0_TYPE_WRITE_READ,
  1529. els->req, els->req_count,
  1530. ZFCP_MAX_SBALS_PER_ELS_REQ);
  1531. if (bytes <= 0) {
  1532. ZFCP_LOG_INFO("error: creation of ELS request failed "
  1533. "(adapter %s, port d_id: 0x%06x)\n",
  1534. zfcp_get_busid_by_adapter(adapter), d_id);
  1535. if (bytes == 0) {
  1536. ret = -ENOMEM;
  1537. } else {
  1538. ret = bytes;
  1539. }
  1540. goto failed_send;
  1541. }
  1542. fsf_req->qtcb->bottom.support.req_buf_length = bytes;
  1543. fsf_req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
  1544. bytes = zfcp_qdio_sbals_from_sg(fsf_req,
  1545. SBAL_FLAGS0_TYPE_WRITE_READ,
  1546. els->resp, els->resp_count,
  1547. ZFCP_MAX_SBALS_PER_ELS_REQ);
  1548. if (bytes <= 0) {
  1549. ZFCP_LOG_INFO("error: creation of ELS request failed "
  1550. "(adapter %s, port d_id: 0x%06x)\n",
  1551. zfcp_get_busid_by_adapter(adapter), d_id);
  1552. if (bytes == 0) {
  1553. ret = -ENOMEM;
  1554. } else {
  1555. ret = bytes;
  1556. }
  1557. goto failed_send;
  1558. }
  1559. fsf_req->qtcb->bottom.support.resp_buf_length = bytes;
  1560. } else {
  1561. /* reject request */
  1562. ZFCP_LOG_INFO("error: microcode does not support chained SBALs"
  1563. ", ELS request too big (adapter %s, "
  1564. "port d_id: 0x%06x)\n",
  1565. zfcp_get_busid_by_adapter(adapter), d_id);
  1566. ret = -EOPNOTSUPP;
  1567. goto failed_send;
  1568. }
  1569. /* settings in QTCB */
  1570. fsf_req->qtcb->bottom.support.d_id = d_id;
  1571. fsf_req->qtcb->bottom.support.service_class =
  1572. ZFCP_FC_SERVICE_CLASS_DEFAULT;
  1573. fsf_req->qtcb->bottom.support.timeout = ZFCP_ELS_TIMEOUT;
  1574. fsf_req->data = (unsigned long) els;
  1575. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  1576. zfcp_san_dbf_event_els_request(fsf_req);
  1577. zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
  1578. ret = zfcp_fsf_req_send(fsf_req);
  1579. if (ret) {
  1580. ZFCP_LOG_DEBUG("error: initiation of ELS request failed "
  1581. "(adapter %s, port d_id: 0x%06x)\n",
  1582. zfcp_get_busid_by_adapter(adapter), d_id);
  1583. goto failed_send;
  1584. }
  1585. ZFCP_LOG_DEBUG("ELS request initiated (adapter %s, port d_id: "
  1586. "0x%06x)\n", zfcp_get_busid_by_adapter(adapter), d_id);
  1587. goto out;
  1588. failed_send:
  1589. zfcp_fsf_req_free(fsf_req);
  1590. failed_req:
  1591. out:
  1592. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  1593. lock_flags);
  1594. return ret;
  1595. }
  1596. /**
  1597. * zfcp_fsf_send_els_handler - handler for ELS commands
  1598. * @fsf_req: pointer to struct zfcp_fsf_req
  1599. *
  1600. * Data specific for the ELS command is passed using
  1601. * fsf_req->data. There we find the pointer to struct zfcp_send_els.
  1602. * Usually a specific handler for the ELS command is called which is
  1603. * found in this structure.
  1604. */
  1605. static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
  1606. {
  1607. struct zfcp_adapter *adapter;
  1608. struct zfcp_port *port;
  1609. u32 d_id;
  1610. struct fsf_qtcb_header *header;
  1611. struct fsf_qtcb_bottom_support *bottom;
  1612. struct zfcp_send_els *send_els;
  1613. int retval = -EINVAL;
  1614. u16 subtable, rule, counter;
  1615. send_els = (struct zfcp_send_els *) fsf_req->data;
  1616. adapter = send_els->adapter;
  1617. port = send_els->port;
  1618. d_id = send_els->d_id;
  1619. header = &fsf_req->qtcb->header;
  1620. bottom = &fsf_req->qtcb->bottom.support;
  1621. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1622. goto skip_fsfstatus;
  1623. switch (header->fsf_status) {
  1624. case FSF_GOOD:
  1625. zfcp_san_dbf_event_els_response(fsf_req);
  1626. retval = 0;
  1627. break;
  1628. case FSF_SERVICE_CLASS_NOT_SUPPORTED:
  1629. ZFCP_LOG_INFO("error: adapter %s does not support fc "
  1630. "class %d.\n",
  1631. zfcp_get_busid_by_adapter(adapter),
  1632. ZFCP_FC_SERVICE_CLASS_DEFAULT);
  1633. /* stop operation for this adapter */
  1634. debug_text_exception(adapter->erp_dbf, 0, "fsf_s_class_nsup");
  1635. zfcp_erp_adapter_shutdown(adapter, 0);
  1636. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1637. break;
  1638. case FSF_ADAPTER_STATUS_AVAILABLE:
  1639. switch (header->fsf_status_qual.word[0]){
  1640. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1641. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ltest");
  1642. if (port && (send_els->ls_code != ZFCP_LS_ADISC))
  1643. zfcp_test_link(port);
  1644. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1645. break;
  1646. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1647. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_ulp");
  1648. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1649. retval =
  1650. zfcp_handle_els_rjt(header->fsf_status_qual.word[1],
  1651. (struct zfcp_ls_rjt_par *)
  1652. &header->fsf_status_qual.word[2]);
  1653. break;
  1654. case FSF_SQ_RETRY_IF_POSSIBLE:
  1655. debug_text_event(adapter->erp_dbf, 1, "fsf_sq_retry");
  1656. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1657. break;
  1658. default:
  1659. ZFCP_LOG_INFO("bug: Wrong status qualifier 0x%x\n",
  1660. header->fsf_status_qual.word[0]);
  1661. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_INFO,
  1662. (char*)header->fsf_status_qual.word, 16);
  1663. }
  1664. break;
  1665. case FSF_ELS_COMMAND_REJECTED:
  1666. ZFCP_LOG_INFO("ELS has been rejected because command filter "
  1667. "prohibited sending "
  1668. "(adapter: %s, port d_id: 0x%06x)\n",
  1669. zfcp_get_busid_by_adapter(adapter), d_id);
  1670. break;
  1671. case FSF_PAYLOAD_SIZE_MISMATCH:
  1672. ZFCP_LOG_INFO(
  1673. "ELS request size and ELS response size must be either "
  1674. "both 0, or both greater than 0 "
  1675. "(adapter: %s, req_buf_length=%d resp_buf_length=%d)\n",
  1676. zfcp_get_busid_by_adapter(adapter),
  1677. bottom->req_buf_length,
  1678. bottom->resp_buf_length);
  1679. break;
  1680. case FSF_REQUEST_SIZE_TOO_LARGE:
  1681. ZFCP_LOG_INFO(
  1682. "Length of the ELS request buffer, "
  1683. "specified in QTCB bottom, "
  1684. "exceeds the size of the buffers "
  1685. "that have been allocated for ELS request data "
  1686. "(adapter: %s, req_buf_length=%d)\n",
  1687. zfcp_get_busid_by_adapter(adapter),
  1688. bottom->req_buf_length);
  1689. break;
  1690. case FSF_RESPONSE_SIZE_TOO_LARGE:
  1691. ZFCP_LOG_INFO(
  1692. "Length of the ELS response buffer, "
  1693. "specified in QTCB bottom, "
  1694. "exceeds the size of the buffers "
  1695. "that have been allocated for ELS response data "
  1696. "(adapter: %s, resp_buf_length=%d)\n",
  1697. zfcp_get_busid_by_adapter(adapter),
  1698. bottom->resp_buf_length);
  1699. break;
  1700. case FSF_SBAL_MISMATCH:
  1701. /* should never occure, avoided in zfcp_fsf_send_els */
  1702. ZFCP_LOG_INFO("SBAL mismatch (adapter: %s, req_buf_length=%d, "
  1703. "resp_buf_length=%d)\n",
  1704. zfcp_get_busid_by_adapter(adapter),
  1705. bottom->req_buf_length, bottom->resp_buf_length);
  1706. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1707. break;
  1708. case FSF_ACCESS_DENIED:
  1709. ZFCP_LOG_NORMAL("access denied, cannot send ELS command "
  1710. "(adapter %s, port d_id=0x%06x)\n",
  1711. zfcp_get_busid_by_adapter(adapter), d_id);
  1712. for (counter = 0; counter < 2; counter++) {
  1713. subtable = header->fsf_status_qual.halfword[counter * 2];
  1714. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  1715. switch (subtable) {
  1716. case FSF_SQ_CFDC_SUBTABLE_OS:
  1717. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  1718. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  1719. case FSF_SQ_CFDC_SUBTABLE_LUN:
  1720. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  1721. zfcp_act_subtable_type[subtable], rule);
  1722. break;
  1723. }
  1724. }
  1725. debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
  1726. if (port != NULL)
  1727. zfcp_erp_port_access_denied(port);
  1728. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1729. break;
  1730. default:
  1731. ZFCP_LOG_NORMAL(
  1732. "bug: An unknown FSF Status was presented "
  1733. "(adapter: %s, fsf_status=0x%08x)\n",
  1734. zfcp_get_busid_by_adapter(adapter),
  1735. header->fsf_status);
  1736. debug_text_event(adapter->erp_dbf, 0, "fsf_sq_inval");
  1737. debug_exception(adapter->erp_dbf, 0,
  1738. &header->fsf_status_qual.word[0], sizeof(u32));
  1739. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1740. break;
  1741. }
  1742. skip_fsfstatus:
  1743. send_els->status = retval;
  1744. if (send_els->handler)
  1745. send_els->handler(send_els->handler_data);
  1746. return retval;
  1747. }
  1748. int
  1749. zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
  1750. {
  1751. volatile struct qdio_buffer_element *sbale;
  1752. struct zfcp_fsf_req *fsf_req;
  1753. struct zfcp_adapter *adapter = erp_action->adapter;
  1754. unsigned long lock_flags;
  1755. int retval;
  1756. /* setup new FSF request */
  1757. retval = zfcp_fsf_req_create(adapter,
  1758. FSF_QTCB_EXCHANGE_CONFIG_DATA,
  1759. ZFCP_REQ_AUTO_CLEANUP,
  1760. adapter->pool.fsf_req_erp,
  1761. &lock_flags, &fsf_req);
  1762. if (retval) {
  1763. ZFCP_LOG_INFO("error: Could not create exchange configuration "
  1764. "data request for adapter %s.\n",
  1765. zfcp_get_busid_by_adapter(adapter));
  1766. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  1767. lock_flags);
  1768. return retval;
  1769. }
  1770. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  1771. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1772. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1773. fsf_req->qtcb->bottom.config.feature_selection =
  1774. FSF_FEATURE_CFDC |
  1775. FSF_FEATURE_LUN_SHARING |
  1776. FSF_FEATURE_NOTIFICATION_LOST |
  1777. FSF_FEATURE_UPDATE_ALERT;
  1778. fsf_req->erp_action = erp_action;
  1779. erp_action->fsf_req = fsf_req;
  1780. zfcp_erp_start_timer(fsf_req);
  1781. retval = zfcp_fsf_req_send(fsf_req);
  1782. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  1783. lock_flags);
  1784. if (retval) {
  1785. ZFCP_LOG_INFO("error: Could not send exchange configuration "
  1786. "data command on the adapter %s\n",
  1787. zfcp_get_busid_by_adapter(adapter));
  1788. zfcp_fsf_req_free(fsf_req);
  1789. erp_action->fsf_req = NULL;
  1790. }
  1791. else
  1792. ZFCP_LOG_DEBUG("exchange configuration data request initiated "
  1793. "(adapter %s)\n",
  1794. zfcp_get_busid_by_adapter(adapter));
  1795. return retval;
  1796. }
  1797. int
  1798. zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter,
  1799. struct fsf_qtcb_bottom_config *data)
  1800. {
  1801. volatile struct qdio_buffer_element *sbale;
  1802. struct zfcp_fsf_req *fsf_req;
  1803. unsigned long lock_flags;
  1804. int retval;
  1805. /* setup new FSF request */
  1806. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_CONFIG_DATA,
  1807. 0, NULL, &lock_flags, &fsf_req);
  1808. if (retval) {
  1809. ZFCP_LOG_INFO("error: Could not create exchange configuration "
  1810. "data request for adapter %s.\n",
  1811. zfcp_get_busid_by_adapter(adapter));
  1812. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  1813. lock_flags);
  1814. return retval;
  1815. }
  1816. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  1817. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1818. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1819. fsf_req->qtcb->bottom.config.feature_selection =
  1820. FSF_FEATURE_CFDC |
  1821. FSF_FEATURE_LUN_SHARING |
  1822. FSF_FEATURE_NOTIFICATION_LOST |
  1823. FSF_FEATURE_UPDATE_ALERT;
  1824. if (data)
  1825. fsf_req->data = (unsigned long) data;
  1826. zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
  1827. retval = zfcp_fsf_req_send(fsf_req);
  1828. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  1829. lock_flags);
  1830. if (retval)
  1831. ZFCP_LOG_INFO("error: Could not send exchange configuration "
  1832. "data command on the adapter %s\n",
  1833. zfcp_get_busid_by_adapter(adapter));
  1834. else
  1835. wait_event(fsf_req->completion_wq,
  1836. fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
  1837. zfcp_fsf_req_free(fsf_req);
  1838. return retval;
  1839. }
  1840. /**
  1841. * zfcp_fsf_exchange_config_evaluate
  1842. * @fsf_req: fsf_req which belongs to xchg config data request
  1843. * @xchg_ok: specifies if xchg config data was incomplete or complete (0/1)
  1844. *
  1845. * returns: -EIO on error, 0 otherwise
  1846. */
  1847. static int
  1848. zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
  1849. {
  1850. struct fsf_qtcb_bottom_config *bottom;
  1851. struct zfcp_adapter *adapter = fsf_req->adapter;
  1852. struct Scsi_Host *shost = adapter->scsi_host;
  1853. bottom = &fsf_req->qtcb->bottom.config;
  1854. ZFCP_LOG_DEBUG("low/high QTCB version 0x%x/0x%x of FSF\n",
  1855. bottom->low_qtcb_version, bottom->high_qtcb_version);
  1856. adapter->fsf_lic_version = bottom->lic_version;
  1857. adapter->adapter_features = bottom->adapter_features;
  1858. adapter->connection_features = bottom->connection_features;
  1859. adapter->peer_wwpn = 0;
  1860. adapter->peer_wwnn = 0;
  1861. adapter->peer_d_id = 0;
  1862. if (xchg_ok) {
  1863. if (fsf_req->data)
  1864. memcpy((struct fsf_qtcb_bottom_config *) fsf_req->data,
  1865. bottom, sizeof (struct fsf_qtcb_bottom_config));
  1866. fc_host_node_name(shost) = bottom->nport_serv_param.wwnn;
  1867. fc_host_port_name(shost) = bottom->nport_serv_param.wwpn;
  1868. fc_host_port_id(shost) = bottom->s_id & ZFCP_DID_MASK;
  1869. fc_host_speed(shost) = bottom->fc_link_speed;
  1870. fc_host_supported_classes(shost) =
  1871. FC_COS_CLASS2 | FC_COS_CLASS3;
  1872. adapter->hydra_version = bottom->adapter_type;
  1873. if (fc_host_permanent_port_name(shost) == -1)
  1874. fc_host_permanent_port_name(shost) =
  1875. fc_host_port_name(shost);
  1876. if (bottom->fc_topology == FSF_TOPO_P2P) {
  1877. adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK;
  1878. adapter->peer_wwpn = bottom->plogi_payload.wwpn;
  1879. adapter->peer_wwnn = bottom->plogi_payload.wwnn;
  1880. fc_host_port_type(shost) = FC_PORTTYPE_PTP;
  1881. } else if (bottom->fc_topology == FSF_TOPO_FABRIC)
  1882. fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
  1883. else if (bottom->fc_topology == FSF_TOPO_AL)
  1884. fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
  1885. else
  1886. fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
  1887. } else {
  1888. fc_host_node_name(shost) = 0;
  1889. fc_host_port_name(shost) = 0;
  1890. fc_host_port_id(shost) = 0;
  1891. fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
  1892. fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
  1893. adapter->hydra_version = 0;
  1894. }
  1895. if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) {
  1896. adapter->hardware_version = bottom->hardware_version;
  1897. memcpy(fc_host_serial_number(shost), bottom->serial_number,
  1898. min(FC_SERIAL_NUMBER_SIZE, 17));
  1899. EBCASC(fc_host_serial_number(shost),
  1900. min(FC_SERIAL_NUMBER_SIZE, 17));
  1901. }
  1902. ZFCP_LOG_NORMAL("The adapter %s reported the following "
  1903. "characteristics:\n"
  1904. "WWNN 0x%016Lx, "
  1905. "WWPN 0x%016Lx, "
  1906. "S_ID 0x%06x,\n"
  1907. "adapter version 0x%x, "
  1908. "LIC version 0x%x, "
  1909. "FC link speed %d Gb/s\n",
  1910. zfcp_get_busid_by_adapter(adapter),
  1911. (wwn_t) fc_host_node_name(shost),
  1912. (wwn_t) fc_host_port_name(shost),
  1913. fc_host_port_id(shost),
  1914. adapter->hydra_version,
  1915. adapter->fsf_lic_version,
  1916. fc_host_speed(shost));
  1917. if (ZFCP_QTCB_VERSION < bottom->low_qtcb_version) {
  1918. ZFCP_LOG_NORMAL("error: the adapter %s "
  1919. "only supports newer control block "
  1920. "versions in comparison to this device "
  1921. "driver (try updated device driver)\n",
  1922. zfcp_get_busid_by_adapter(adapter));
  1923. debug_text_event(adapter->erp_dbf, 0, "low_qtcb_ver");
  1924. zfcp_erp_adapter_shutdown(adapter, 0);
  1925. return -EIO;
  1926. }
  1927. if (ZFCP_QTCB_VERSION > bottom->high_qtcb_version) {
  1928. ZFCP_LOG_NORMAL("error: the adapter %s "
  1929. "only supports older control block "
  1930. "versions than this device driver uses"
  1931. "(consider a microcode upgrade)\n",
  1932. zfcp_get_busid_by_adapter(adapter));
  1933. debug_text_event(adapter->erp_dbf, 0, "high_qtcb_ver");
  1934. zfcp_erp_adapter_shutdown(adapter, 0);
  1935. return -EIO;
  1936. }
  1937. return 0;
  1938. }
  1939. /**
  1940. * function: zfcp_fsf_exchange_config_data_handler
  1941. *
  1942. * purpose: is called for finished Exchange Configuration Data command
  1943. *
  1944. * returns:
  1945. */
  1946. static int
  1947. zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *fsf_req)
  1948. {
  1949. struct fsf_qtcb_bottom_config *bottom;
  1950. struct zfcp_adapter *adapter = fsf_req->adapter;
  1951. struct fsf_qtcb *qtcb = fsf_req->qtcb;
  1952. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1953. return -EIO;
  1954. switch (qtcb->header.fsf_status) {
  1955. case FSF_GOOD:
  1956. if (zfcp_fsf_exchange_config_evaluate(fsf_req, 1))
  1957. return -EIO;
  1958. switch (fc_host_port_type(adapter->scsi_host)) {
  1959. case FC_PORTTYPE_PTP:
  1960. ZFCP_LOG_NORMAL("Point-to-Point fibrechannel "
  1961. "configuration detected at adapter %s\n"
  1962. "Peer WWNN 0x%016llx, "
  1963. "peer WWPN 0x%016llx, "
  1964. "peer d_id 0x%06x\n",
  1965. zfcp_get_busid_by_adapter(adapter),
  1966. adapter->peer_wwnn,
  1967. adapter->peer_wwpn,
  1968. adapter->peer_d_id);
  1969. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  1970. "top-p-to-p");
  1971. break;
  1972. case FC_PORTTYPE_NLPORT:
  1973. ZFCP_LOG_NORMAL("error: Arbitrated loop fibrechannel "
  1974. "topology detected at adapter %s "
  1975. "unsupported, shutting down adapter\n",
  1976. zfcp_get_busid_by_adapter(adapter));
  1977. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  1978. "top-al");
  1979. zfcp_erp_adapter_shutdown(adapter, 0);
  1980. return -EIO;
  1981. case FC_PORTTYPE_NPORT:
  1982. ZFCP_LOG_NORMAL("Switched fabric fibrechannel "
  1983. "network detected at adapter %s.\n",
  1984. zfcp_get_busid_by_adapter(adapter));
  1985. break;
  1986. default:
  1987. ZFCP_LOG_NORMAL("bug: The fibrechannel topology "
  1988. "reported by the exchange "
  1989. "configuration command for "
  1990. "the adapter %s is not "
  1991. "of a type known to the zfcp "
  1992. "driver, shutting down adapter\n",
  1993. zfcp_get_busid_by_adapter(adapter));
  1994. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  1995. "unknown-topo");
  1996. zfcp_erp_adapter_shutdown(adapter, 0);
  1997. return -EIO;
  1998. }
  1999. bottom = &qtcb->bottom.config;
  2000. if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
  2001. ZFCP_LOG_NORMAL("bug: Maximum QTCB size (%d bytes) "
  2002. "allowed by the adapter %s "
  2003. "is lower than the minimum "
  2004. "required by the driver (%ld bytes).\n",
  2005. bottom->max_qtcb_size,
  2006. zfcp_get_busid_by_adapter(adapter),
  2007. sizeof(struct fsf_qtcb));
  2008. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  2009. "qtcb-size");
  2010. debug_event(fsf_req->adapter->erp_dbf, 0,
  2011. &bottom->max_qtcb_size, sizeof (u32));
  2012. zfcp_erp_adapter_shutdown(adapter, 0);
  2013. return -EIO;
  2014. }
  2015. atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
  2016. &adapter->status);
  2017. break;
  2018. case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
  2019. debug_text_event(adapter->erp_dbf, 0, "xchg-inco");
  2020. if (zfcp_fsf_exchange_config_evaluate(fsf_req, 0))
  2021. return -EIO;
  2022. atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
  2023. &adapter->status);
  2024. zfcp_fsf_link_down_info_eval(adapter,
  2025. &qtcb->header.fsf_status_qual.link_down_info);
  2026. break;
  2027. default:
  2028. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf-stat-ng");
  2029. debug_event(fsf_req->adapter->erp_dbf, 0,
  2030. &fsf_req->qtcb->header.fsf_status, sizeof(u32));
  2031. zfcp_erp_adapter_shutdown(adapter, 0);
  2032. return -EIO;
  2033. }
  2034. return 0;
  2035. }
  2036. /**
  2037. * zfcp_fsf_exchange_port_data - request information about local port
  2038. * @erp_action: ERP action for the adapter for which port data is requested
  2039. */
  2040. int
  2041. zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
  2042. {
  2043. volatile struct qdio_buffer_element *sbale;
  2044. struct zfcp_fsf_req *fsf_req;
  2045. struct zfcp_adapter *adapter = erp_action->adapter;
  2046. unsigned long lock_flags;
  2047. int retval;
  2048. if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) {
  2049. ZFCP_LOG_INFO("error: exchange port data "
  2050. "command not supported by adapter %s\n",
  2051. zfcp_get_busid_by_adapter(adapter));
  2052. return -EOPNOTSUPP;
  2053. }
  2054. /* setup new FSF request */
  2055. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
  2056. ZFCP_REQ_AUTO_CLEANUP,
  2057. adapter->pool.fsf_req_erp,
  2058. &lock_flags, &fsf_req);
  2059. if (retval) {
  2060. ZFCP_LOG_INFO("error: Out of resources. Could not create an "
  2061. "exchange port data request for"
  2062. "the adapter %s.\n",
  2063. zfcp_get_busid_by_adapter(adapter));
  2064. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  2065. lock_flags);
  2066. return retval;
  2067. }
  2068. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  2069. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2070. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2071. erp_action->fsf_req = fsf_req;
  2072. fsf_req->erp_action = erp_action;
  2073. zfcp_erp_start_timer(fsf_req);
  2074. retval = zfcp_fsf_req_send(fsf_req);
  2075. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  2076. if (retval) {
  2077. ZFCP_LOG_INFO("error: Could not send an exchange port data "
  2078. "command on the adapter %s\n",
  2079. zfcp_get_busid_by_adapter(adapter));
  2080. zfcp_fsf_req_free(fsf_req);
  2081. erp_action->fsf_req = NULL;
  2082. }
  2083. else
  2084. ZFCP_LOG_DEBUG("exchange port data request initiated "
  2085. "(adapter %s)\n",
  2086. zfcp_get_busid_by_adapter(adapter));
  2087. return retval;
  2088. }
  2089. /**
  2090. * zfcp_fsf_exchange_port_data_sync - request information about local port
  2091. * and wait until information is ready
  2092. */
  2093. int
  2094. zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter,
  2095. struct fsf_qtcb_bottom_port *data)
  2096. {
  2097. volatile struct qdio_buffer_element *sbale;
  2098. struct zfcp_fsf_req *fsf_req;
  2099. unsigned long lock_flags;
  2100. int retval;
  2101. if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) {
  2102. ZFCP_LOG_INFO("error: exchange port data "
  2103. "command not supported by adapter %s\n",
  2104. zfcp_get_busid_by_adapter(adapter));
  2105. return -EOPNOTSUPP;
  2106. }
  2107. /* setup new FSF request */
  2108. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
  2109. 0, NULL, &lock_flags, &fsf_req);
  2110. if (retval) {
  2111. ZFCP_LOG_INFO("error: Out of resources. Could not create an "
  2112. "exchange port data request for"
  2113. "the adapter %s.\n",
  2114. zfcp_get_busid_by_adapter(adapter));
  2115. write_unlock_irqrestore(&adapter->request_queue.queue_lock,
  2116. lock_flags);
  2117. return retval;
  2118. }
  2119. if (data)
  2120. fsf_req->data = (unsigned long) data;
  2121. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  2122. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2123. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2124. zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
  2125. retval = zfcp_fsf_req_send(fsf_req);
  2126. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  2127. if (retval)
  2128. ZFCP_LOG_INFO("error: Could not send an exchange port data "
  2129. "command on the adapter %s\n",
  2130. zfcp_get_busid_by_adapter(adapter));
  2131. else
  2132. wait_event(fsf_req->completion_wq,
  2133. fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
  2134. zfcp_fsf_req_free(fsf_req);
  2135. return retval;
  2136. }
  2137. /**
  2138. * zfcp_fsf_exchange_port_evaluate
  2139. * @fsf_req: fsf_req which belongs to xchg port data request
  2140. * @xchg_ok: specifies if xchg port data was incomplete or complete (0/1)
  2141. */
  2142. static void
  2143. zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *fsf_req, int xchg_ok)
  2144. {
  2145. struct zfcp_adapter *adapter;
  2146. struct fsf_qtcb_bottom_port *bottom;
  2147. struct Scsi_Host *shost;
  2148. adapter = fsf_req->adapter;
  2149. bottom = &fsf_req->qtcb->bottom.port;
  2150. shost = adapter->scsi_host;
  2151. if (fsf_req->data)
  2152. memcpy((struct fsf_qtcb_bottom_port*) fsf_req->data, bottom,
  2153. sizeof(struct fsf_qtcb_bottom_port));
  2154. if (adapter->connection_features & FSF_FEATURE_NPIV_MODE)
  2155. fc_host_permanent_port_name(shost) = bottom->wwpn;
  2156. else
  2157. fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
  2158. fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
  2159. fc_host_supported_speeds(shost) = bottom->supported_speed;
  2160. }
  2161. /**
  2162. * zfcp_fsf_exchange_port_data_handler - handler for exchange_port_data request
  2163. * @fsf_req: pointer to struct zfcp_fsf_req
  2164. */
  2165. static void
  2166. zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *fsf_req)
  2167. {
  2168. struct zfcp_adapter *adapter;
  2169. struct fsf_qtcb *qtcb;
  2170. adapter = fsf_req->adapter;
  2171. qtcb = fsf_req->qtcb;
  2172. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)
  2173. return;
  2174. switch (qtcb->header.fsf_status) {
  2175. case FSF_GOOD:
  2176. zfcp_fsf_exchange_port_evaluate(fsf_req, 1);
  2177. atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
  2178. break;
  2179. case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
  2180. zfcp_fsf_exchange_port_evaluate(fsf_req, 0);
  2181. atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
  2182. zfcp_fsf_link_down_info_eval(adapter,
  2183. &qtcb->header.fsf_status_qual.link_down_info);
  2184. break;
  2185. default:
  2186. debug_text_event(adapter->erp_dbf, 0, "xchg-port-ng");
  2187. debug_event(adapter->erp_dbf, 0,
  2188. &fsf_req->qtcb->header.fsf_status, sizeof(u32));
  2189. }
  2190. }
  2191. /*
  2192. * function: zfcp_fsf_open_port
  2193. *
  2194. * purpose:
  2195. *
  2196. * returns: address of initiated FSF request
  2197. * NULL - request could not be initiated
  2198. */
  2199. int
  2200. zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
  2201. {
  2202. volatile struct qdio_buffer_element *sbale;
  2203. struct zfcp_fsf_req *fsf_req;
  2204. unsigned long lock_flags;
  2205. int retval = 0;
  2206. /* setup new FSF request */
  2207. retval = zfcp_fsf_req_create(erp_action->adapter,
  2208. FSF_QTCB_OPEN_PORT_WITH_DID,
  2209. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  2210. erp_action->adapter->pool.fsf_req_erp,
  2211. &lock_flags, &fsf_req);
  2212. if (retval < 0) {
  2213. ZFCP_LOG_INFO("error: Could not create open port request "
  2214. "for port 0x%016Lx on adapter %s.\n",
  2215. erp_action->port->wwpn,
  2216. zfcp_get_busid_by_adapter(erp_action->adapter));
  2217. goto out;
  2218. }
  2219. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  2220. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2221. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2222. fsf_req->qtcb->bottom.support.d_id = erp_action->port->d_id;
  2223. atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->port->status);
  2224. fsf_req->data = (unsigned long) erp_action->port;
  2225. fsf_req->erp_action = erp_action;
  2226. erp_action->fsf_req = fsf_req;
  2227. zfcp_erp_start_timer(fsf_req);
  2228. retval = zfcp_fsf_req_send(fsf_req);
  2229. if (retval) {
  2230. ZFCP_LOG_INFO("error: Could not send open port request for "
  2231. "port 0x%016Lx on adapter %s.\n",
  2232. erp_action->port->wwpn,
  2233. zfcp_get_busid_by_adapter(erp_action->adapter));
  2234. zfcp_fsf_req_free(fsf_req);
  2235. erp_action->fsf_req = NULL;
  2236. goto out;
  2237. }
  2238. ZFCP_LOG_DEBUG("open port request initiated "
  2239. "(adapter %s, port 0x%016Lx)\n",
  2240. zfcp_get_busid_by_adapter(erp_action->adapter),
  2241. erp_action->port->wwpn);
  2242. out:
  2243. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  2244. lock_flags);
  2245. return retval;
  2246. }
  2247. /*
  2248. * function: zfcp_fsf_open_port_handler
  2249. *
  2250. * purpose: is called for finished Open Port command
  2251. *
  2252. * returns:
  2253. */
  2254. static int
  2255. zfcp_fsf_open_port_handler(struct zfcp_fsf_req *fsf_req)
  2256. {
  2257. int retval = -EINVAL;
  2258. struct zfcp_port *port;
  2259. struct fsf_plogi *plogi;
  2260. struct fsf_qtcb_header *header;
  2261. u16 subtable, rule, counter;
  2262. port = (struct zfcp_port *) fsf_req->data;
  2263. header = &fsf_req->qtcb->header;
  2264. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  2265. /* don't change port status in our bookkeeping */
  2266. goto skip_fsfstatus;
  2267. }
  2268. /* evaluate FSF status in QTCB */
  2269. switch (header->fsf_status) {
  2270. case FSF_PORT_ALREADY_OPEN:
  2271. ZFCP_LOG_NORMAL("bug: remote port 0x%016Lx on adapter %s "
  2272. "is already open.\n",
  2273. port->wwpn, zfcp_get_busid_by_port(port));
  2274. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  2275. "fsf_s_popen");
  2276. /*
  2277. * This is a bug, however operation should continue normally
  2278. * if it is simply ignored
  2279. */
  2280. break;
  2281. case FSF_ACCESS_DENIED:
  2282. ZFCP_LOG_NORMAL("Access denied, cannot open port 0x%016Lx "
  2283. "on adapter %s\n",
  2284. port->wwpn, zfcp_get_busid_by_port(port));
  2285. for (counter = 0; counter < 2; counter++) {
  2286. subtable = header->fsf_status_qual.halfword[counter * 2];
  2287. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  2288. switch (subtable) {
  2289. case FSF_SQ_CFDC_SUBTABLE_OS:
  2290. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  2291. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  2292. case FSF_SQ_CFDC_SUBTABLE_LUN:
  2293. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  2294. zfcp_act_subtable_type[subtable], rule);
  2295. break;
  2296. }
  2297. }
  2298. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
  2299. zfcp_erp_port_access_denied(port);
  2300. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2301. break;
  2302. case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
  2303. ZFCP_LOG_INFO("error: The FSF adapter is out of resources. "
  2304. "The remote port 0x%016Lx on adapter %s "
  2305. "could not be opened. Disabling it.\n",
  2306. port->wwpn, zfcp_get_busid_by_port(port));
  2307. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2308. "fsf_s_max_ports");
  2309. zfcp_erp_port_failed(port);
  2310. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2311. break;
  2312. case FSF_ADAPTER_STATUS_AVAILABLE:
  2313. switch (header->fsf_status_qual.word[0]) {
  2314. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  2315. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2316. "fsf_sq_ltest");
  2317. /* ERP strategy will escalate */
  2318. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2319. break;
  2320. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  2321. /* ERP strategy will escalate */
  2322. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2323. "fsf_sq_ulp");
  2324. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2325. break;
  2326. case FSF_SQ_NO_RETRY_POSSIBLE:
  2327. ZFCP_LOG_NORMAL("The remote port 0x%016Lx on "
  2328. "adapter %s could not be opened. "
  2329. "Disabling it.\n",
  2330. port->wwpn,
  2331. zfcp_get_busid_by_port(port));
  2332. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  2333. "fsf_sq_no_retry");
  2334. zfcp_erp_port_failed(port);
  2335. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2336. break;
  2337. default:
  2338. ZFCP_LOG_NORMAL
  2339. ("bug: Wrong status qualifier 0x%x arrived.\n",
  2340. header->fsf_status_qual.word[0]);
  2341. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  2342. "fsf_sq_inval:");
  2343. debug_exception(
  2344. fsf_req->adapter->erp_dbf, 0,
  2345. &header->fsf_status_qual.word[0],
  2346. sizeof (u32));
  2347. break;
  2348. }
  2349. break;
  2350. case FSF_GOOD:
  2351. /* save port handle assigned by FSF */
  2352. port->handle = header->port_handle;
  2353. ZFCP_LOG_INFO("The remote port 0x%016Lx via adapter %s "
  2354. "was opened, it's port handle is 0x%x\n",
  2355. port->wwpn, zfcp_get_busid_by_port(port),
  2356. port->handle);
  2357. /* mark port as open */
  2358. atomic_set_mask(ZFCP_STATUS_COMMON_OPEN |
  2359. ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
  2360. atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
  2361. ZFCP_STATUS_COMMON_ACCESS_BOXED,
  2362. &port->status);
  2363. retval = 0;
  2364. /* check whether D_ID has changed during open */
  2365. /*
  2366. * FIXME: This check is not airtight, as the FCP channel does
  2367. * not monitor closures of target port connections caused on
  2368. * the remote side. Thus, they might miss out on invalidating
  2369. * locally cached WWPNs (and other N_Port parameters) of gone
  2370. * target ports. So, our heroic attempt to make things safe
  2371. * could be undermined by 'open port' response data tagged with
  2372. * obsolete WWPNs. Another reason to monitor potential
  2373. * connection closures ourself at least (by interpreting
  2374. * incoming ELS' and unsolicited status). It just crosses my
  2375. * mind that one should be able to cross-check by means of
  2376. * another GID_PN straight after a port has been opened.
  2377. * Alternately, an ADISC/PDISC ELS should suffice, as well.
  2378. */
  2379. plogi = (struct fsf_plogi *) fsf_req->qtcb->bottom.support.els;
  2380. if (!atomic_test_mask(ZFCP_STATUS_PORT_NO_WWPN, &port->status))
  2381. {
  2382. if (fsf_req->qtcb->bottom.support.els1_length <
  2383. sizeof (struct fsf_plogi)) {
  2384. ZFCP_LOG_INFO(
  2385. "warning: insufficient length of "
  2386. "PLOGI payload (%i)\n",
  2387. fsf_req->qtcb->bottom.support.els1_length);
  2388. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  2389. "fsf_s_short_plogi:");
  2390. /* skip sanity check and assume wwpn is ok */
  2391. } else {
  2392. if (plogi->serv_param.wwpn != port->wwpn) {
  2393. ZFCP_LOG_INFO("warning: d_id of port "
  2394. "0x%016Lx changed during "
  2395. "open\n", port->wwpn);
  2396. debug_text_event(
  2397. fsf_req->adapter->erp_dbf, 0,
  2398. "fsf_s_did_change:");
  2399. atomic_clear_mask(
  2400. ZFCP_STATUS_PORT_DID_DID,
  2401. &port->status);
  2402. } else {
  2403. port->wwnn = plogi->serv_param.wwnn;
  2404. zfcp_plogi_evaluate(port, plogi);
  2405. }
  2406. }
  2407. }
  2408. break;
  2409. case FSF_UNKNOWN_OP_SUBTYPE:
  2410. /* should never occure, subtype not set in zfcp_fsf_open_port */
  2411. ZFCP_LOG_INFO("unknown operation subtype (adapter: %s, "
  2412. "op_subtype=0x%x)\n",
  2413. zfcp_get_busid_by_port(port),
  2414. fsf_req->qtcb->bottom.support.operation_subtype);
  2415. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2416. break;
  2417. default:
  2418. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  2419. "(debug info 0x%x)\n",
  2420. header->fsf_status);
  2421. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  2422. debug_exception(fsf_req->adapter->erp_dbf, 0,
  2423. &header->fsf_status, sizeof (u32));
  2424. break;
  2425. }
  2426. skip_fsfstatus:
  2427. atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &port->status);
  2428. return retval;
  2429. }
  2430. /*
  2431. * function: zfcp_fsf_close_port
  2432. *
  2433. * purpose: submit FSF command "close port"
  2434. *
  2435. * returns: address of initiated FSF request
  2436. * NULL - request could not be initiated
  2437. */
  2438. int
  2439. zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
  2440. {
  2441. volatile struct qdio_buffer_element *sbale;
  2442. struct zfcp_fsf_req *fsf_req;
  2443. unsigned long lock_flags;
  2444. int retval = 0;
  2445. /* setup new FSF request */
  2446. retval = zfcp_fsf_req_create(erp_action->adapter,
  2447. FSF_QTCB_CLOSE_PORT,
  2448. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  2449. erp_action->adapter->pool.fsf_req_erp,
  2450. &lock_flags, &fsf_req);
  2451. if (retval < 0) {
  2452. ZFCP_LOG_INFO("error: Could not create a close port request "
  2453. "for port 0x%016Lx on adapter %s.\n",
  2454. erp_action->port->wwpn,
  2455. zfcp_get_busid_by_adapter(erp_action->adapter));
  2456. goto out;
  2457. }
  2458. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  2459. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2460. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2461. atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->port->status);
  2462. fsf_req->data = (unsigned long) erp_action->port;
  2463. fsf_req->erp_action = erp_action;
  2464. fsf_req->qtcb->header.port_handle = erp_action->port->handle;
  2465. fsf_req->erp_action = erp_action;
  2466. erp_action->fsf_req = fsf_req;
  2467. zfcp_erp_start_timer(fsf_req);
  2468. retval = zfcp_fsf_req_send(fsf_req);
  2469. if (retval) {
  2470. ZFCP_LOG_INFO("error: Could not send a close port request for "
  2471. "port 0x%016Lx on adapter %s.\n",
  2472. erp_action->port->wwpn,
  2473. zfcp_get_busid_by_adapter(erp_action->adapter));
  2474. zfcp_fsf_req_free(fsf_req);
  2475. erp_action->fsf_req = NULL;
  2476. goto out;
  2477. }
  2478. ZFCP_LOG_TRACE("close port request initiated "
  2479. "(adapter %s, port 0x%016Lx)\n",
  2480. zfcp_get_busid_by_adapter(erp_action->adapter),
  2481. erp_action->port->wwpn);
  2482. out:
  2483. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  2484. lock_flags);
  2485. return retval;
  2486. }
  2487. /*
  2488. * function: zfcp_fsf_close_port_handler
  2489. *
  2490. * purpose: is called for finished Close Port FSF command
  2491. *
  2492. * returns:
  2493. */
  2494. static int
  2495. zfcp_fsf_close_port_handler(struct zfcp_fsf_req *fsf_req)
  2496. {
  2497. int retval = -EINVAL;
  2498. struct zfcp_port *port;
  2499. port = (struct zfcp_port *) fsf_req->data;
  2500. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  2501. /* don't change port status in our bookkeeping */
  2502. goto skip_fsfstatus;
  2503. }
  2504. /* evaluate FSF status in QTCB */
  2505. switch (fsf_req->qtcb->header.fsf_status) {
  2506. case FSF_PORT_HANDLE_NOT_VALID:
  2507. ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
  2508. "0x%016Lx on adapter %s invalid. This may happen "
  2509. "occasionally.\n", port->handle,
  2510. port->wwpn, zfcp_get_busid_by_port(port));
  2511. ZFCP_LOG_DEBUG("status qualifier:\n");
  2512. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  2513. (char *) &fsf_req->qtcb->header.fsf_status_qual,
  2514. sizeof (union fsf_status_qual));
  2515. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2516. "fsf_s_phand_nv");
  2517. zfcp_erp_adapter_reopen(port->adapter, 0);
  2518. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2519. break;
  2520. case FSF_ADAPTER_STATUS_AVAILABLE:
  2521. /* Note: FSF has actually closed the port in this case.
  2522. * The status code is just daft. Fingers crossed for a change
  2523. */
  2524. retval = 0;
  2525. break;
  2526. case FSF_GOOD:
  2527. ZFCP_LOG_TRACE("remote port 0x016%Lx on adapter %s closed, "
  2528. "port handle 0x%x\n", port->wwpn,
  2529. zfcp_get_busid_by_port(port), port->handle);
  2530. zfcp_erp_modify_port_status(port,
  2531. ZFCP_STATUS_COMMON_OPEN,
  2532. ZFCP_CLEAR);
  2533. retval = 0;
  2534. break;
  2535. default:
  2536. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  2537. "(debug info 0x%x)\n",
  2538. fsf_req->qtcb->header.fsf_status);
  2539. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  2540. debug_exception(fsf_req->adapter->erp_dbf, 0,
  2541. &fsf_req->qtcb->header.fsf_status,
  2542. sizeof (u32));
  2543. break;
  2544. }
  2545. skip_fsfstatus:
  2546. atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &port->status);
  2547. return retval;
  2548. }
  2549. /*
  2550. * function: zfcp_fsf_close_physical_port
  2551. *
  2552. * purpose: submit FSF command "close physical port"
  2553. *
  2554. * returns: address of initiated FSF request
  2555. * NULL - request could not be initiated
  2556. */
  2557. int
  2558. zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
  2559. {
  2560. volatile struct qdio_buffer_element *sbale;
  2561. struct zfcp_fsf_req *fsf_req;
  2562. unsigned long lock_flags;
  2563. int retval = 0;
  2564. /* setup new FSF request */
  2565. retval = zfcp_fsf_req_create(erp_action->adapter,
  2566. FSF_QTCB_CLOSE_PHYSICAL_PORT,
  2567. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  2568. erp_action->adapter->pool.fsf_req_erp,
  2569. &lock_flags, &fsf_req);
  2570. if (retval < 0) {
  2571. ZFCP_LOG_INFO("error: Could not create close physical port "
  2572. "request (adapter %s, port 0x%016Lx)\n",
  2573. zfcp_get_busid_by_adapter(erp_action->adapter),
  2574. erp_action->port->wwpn);
  2575. goto out;
  2576. }
  2577. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  2578. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2579. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2580. /* mark port as being closed */
  2581. atomic_set_mask(ZFCP_STATUS_PORT_PHYS_CLOSING,
  2582. &erp_action->port->status);
  2583. /* save a pointer to this port */
  2584. fsf_req->data = (unsigned long) erp_action->port;
  2585. fsf_req->qtcb->header.port_handle = erp_action->port->handle;
  2586. fsf_req->erp_action = erp_action;
  2587. erp_action->fsf_req = fsf_req;
  2588. zfcp_erp_start_timer(fsf_req);
  2589. retval = zfcp_fsf_req_send(fsf_req);
  2590. if (retval) {
  2591. ZFCP_LOG_INFO("error: Could not send close physical port "
  2592. "request (adapter %s, port 0x%016Lx)\n",
  2593. zfcp_get_busid_by_adapter(erp_action->adapter),
  2594. erp_action->port->wwpn);
  2595. zfcp_fsf_req_free(fsf_req);
  2596. erp_action->fsf_req = NULL;
  2597. goto out;
  2598. }
  2599. ZFCP_LOG_TRACE("close physical port request initiated "
  2600. "(adapter %s, port 0x%016Lx)\n",
  2601. zfcp_get_busid_by_adapter(erp_action->adapter),
  2602. erp_action->port->wwpn);
  2603. out:
  2604. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  2605. lock_flags);
  2606. return retval;
  2607. }
  2608. /*
  2609. * function: zfcp_fsf_close_physical_port_handler
  2610. *
  2611. * purpose: is called for finished Close Physical Port FSF command
  2612. *
  2613. * returns:
  2614. */
  2615. static int
  2616. zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *fsf_req)
  2617. {
  2618. int retval = -EINVAL;
  2619. struct zfcp_port *port;
  2620. struct zfcp_unit *unit;
  2621. struct fsf_qtcb_header *header;
  2622. u16 subtable, rule, counter;
  2623. port = (struct zfcp_port *) fsf_req->data;
  2624. header = &fsf_req->qtcb->header;
  2625. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  2626. /* don't change port status in our bookkeeping */
  2627. goto skip_fsfstatus;
  2628. }
  2629. /* evaluate FSF status in QTCB */
  2630. switch (header->fsf_status) {
  2631. case FSF_PORT_HANDLE_NOT_VALID:
  2632. ZFCP_LOG_INFO("Temporary port identifier 0x%x invalid"
  2633. "(adapter %s, port 0x%016Lx). "
  2634. "This may happen occasionally.\n",
  2635. port->handle,
  2636. zfcp_get_busid_by_port(port),
  2637. port->wwpn);
  2638. ZFCP_LOG_DEBUG("status qualifier:\n");
  2639. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  2640. (char *) &header->fsf_status_qual,
  2641. sizeof (union fsf_status_qual));
  2642. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2643. "fsf_s_phand_nv");
  2644. zfcp_erp_adapter_reopen(port->adapter, 0);
  2645. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2646. break;
  2647. case FSF_ACCESS_DENIED:
  2648. ZFCP_LOG_NORMAL("Access denied, cannot close "
  2649. "physical port 0x%016Lx on adapter %s\n",
  2650. port->wwpn, zfcp_get_busid_by_port(port));
  2651. for (counter = 0; counter < 2; counter++) {
  2652. subtable = header->fsf_status_qual.halfword[counter * 2];
  2653. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  2654. switch (subtable) {
  2655. case FSF_SQ_CFDC_SUBTABLE_OS:
  2656. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  2657. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  2658. case FSF_SQ_CFDC_SUBTABLE_LUN:
  2659. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  2660. zfcp_act_subtable_type[subtable], rule);
  2661. break;
  2662. }
  2663. }
  2664. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
  2665. zfcp_erp_port_access_denied(port);
  2666. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2667. break;
  2668. case FSF_PORT_BOXED:
  2669. ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter "
  2670. "%s needs to be reopened but it was attempted "
  2671. "to close it physically.\n",
  2672. port->wwpn,
  2673. zfcp_get_busid_by_port(port));
  2674. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_pboxed");
  2675. zfcp_erp_port_boxed(port);
  2676. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  2677. ZFCP_STATUS_FSFREQ_RETRY;
  2678. break;
  2679. case FSF_ADAPTER_STATUS_AVAILABLE:
  2680. switch (header->fsf_status_qual.word[0]) {
  2681. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  2682. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2683. "fsf_sq_ltest");
  2684. /* This will now be escalated by ERP */
  2685. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2686. break;
  2687. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  2688. /* ERP strategy will escalate */
  2689. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  2690. "fsf_sq_ulp");
  2691. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2692. break;
  2693. default:
  2694. ZFCP_LOG_NORMAL
  2695. ("bug: Wrong status qualifier 0x%x arrived.\n",
  2696. header->fsf_status_qual.word[0]);
  2697. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  2698. "fsf_sq_inval:");
  2699. debug_exception(
  2700. fsf_req->adapter->erp_dbf, 0,
  2701. &header->fsf_status_qual.word[0], sizeof (u32));
  2702. break;
  2703. }
  2704. break;
  2705. case FSF_GOOD:
  2706. ZFCP_LOG_DEBUG("Remote port 0x%016Lx via adapter %s "
  2707. "physically closed, port handle 0x%x\n",
  2708. port->wwpn,
  2709. zfcp_get_busid_by_port(port), port->handle);
  2710. /* can't use generic zfcp_erp_modify_port_status because
  2711. * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
  2712. */
  2713. atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
  2714. list_for_each_entry(unit, &port->unit_list_head, list)
  2715. atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
  2716. retval = 0;
  2717. break;
  2718. default:
  2719. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  2720. "(debug info 0x%x)\n",
  2721. header->fsf_status);
  2722. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  2723. debug_exception(fsf_req->adapter->erp_dbf, 0,
  2724. &header->fsf_status, sizeof (u32));
  2725. break;
  2726. }
  2727. skip_fsfstatus:
  2728. atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_CLOSING, &port->status);
  2729. return retval;
  2730. }
  2731. /*
  2732. * function: zfcp_fsf_open_unit
  2733. *
  2734. * purpose:
  2735. *
  2736. * returns:
  2737. *
  2738. * assumptions: This routine does not check whether the associated
  2739. * remote port has already been opened. This should be
  2740. * done by calling routines. Otherwise some status
  2741. * may be presented by FSF
  2742. */
  2743. int
  2744. zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
  2745. {
  2746. volatile struct qdio_buffer_element *sbale;
  2747. struct zfcp_fsf_req *fsf_req;
  2748. unsigned long lock_flags;
  2749. int retval = 0;
  2750. /* setup new FSF request */
  2751. retval = zfcp_fsf_req_create(erp_action->adapter,
  2752. FSF_QTCB_OPEN_LUN,
  2753. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  2754. erp_action->adapter->pool.fsf_req_erp,
  2755. &lock_flags, &fsf_req);
  2756. if (retval < 0) {
  2757. ZFCP_LOG_INFO("error: Could not create open unit request for "
  2758. "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
  2759. erp_action->unit->fcp_lun,
  2760. erp_action->unit->port->wwpn,
  2761. zfcp_get_busid_by_adapter(erp_action->adapter));
  2762. goto out;
  2763. }
  2764. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  2765. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  2766. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2767. fsf_req->qtcb->header.port_handle = erp_action->port->handle;
  2768. fsf_req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun;
  2769. if (!(erp_action->adapter->connection_features & FSF_FEATURE_NPIV_MODE))
  2770. fsf_req->qtcb->bottom.support.option =
  2771. FSF_OPEN_LUN_SUPPRESS_BOXING;
  2772. atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status);
  2773. fsf_req->data = (unsigned long) erp_action->unit;
  2774. fsf_req->erp_action = erp_action;
  2775. erp_action->fsf_req = fsf_req;
  2776. zfcp_erp_start_timer(fsf_req);
  2777. retval = zfcp_fsf_req_send(erp_action->fsf_req);
  2778. if (retval) {
  2779. ZFCP_LOG_INFO("error: Could not send an open unit request "
  2780. "on the adapter %s, port 0x%016Lx for "
  2781. "unit 0x%016Lx\n",
  2782. zfcp_get_busid_by_adapter(erp_action->adapter),
  2783. erp_action->port->wwpn,
  2784. erp_action->unit->fcp_lun);
  2785. zfcp_fsf_req_free(fsf_req);
  2786. erp_action->fsf_req = NULL;
  2787. goto out;
  2788. }
  2789. ZFCP_LOG_TRACE("Open LUN request initiated (adapter %s, "
  2790. "port 0x%016Lx, unit 0x%016Lx)\n",
  2791. zfcp_get_busid_by_adapter(erp_action->adapter),
  2792. erp_action->port->wwpn, erp_action->unit->fcp_lun);
  2793. out:
  2794. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  2795. lock_flags);
  2796. return retval;
  2797. }
  2798. /*
  2799. * function: zfcp_fsf_open_unit_handler
  2800. *
  2801. * purpose: is called for finished Open LUN command
  2802. *
  2803. * returns:
  2804. */
  2805. static int
  2806. zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *fsf_req)
  2807. {
  2808. int retval = -EINVAL;
  2809. struct zfcp_adapter *adapter;
  2810. struct zfcp_unit *unit;
  2811. struct fsf_qtcb_header *header;
  2812. struct fsf_qtcb_bottom_support *bottom;
  2813. struct fsf_queue_designator *queue_designator;
  2814. u16 subtable, rule, counter;
  2815. int exclusive, readwrite;
  2816. unit = (struct zfcp_unit *) fsf_req->data;
  2817. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  2818. /* don't change unit status in our bookkeeping */
  2819. goto skip_fsfstatus;
  2820. }
  2821. adapter = fsf_req->adapter;
  2822. header = &fsf_req->qtcb->header;
  2823. bottom = &fsf_req->qtcb->bottom.support;
  2824. queue_designator = &header->fsf_status_qual.fsf_queue_designator;
  2825. atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
  2826. ZFCP_STATUS_COMMON_ACCESS_BOXED |
  2827. ZFCP_STATUS_UNIT_SHARED |
  2828. ZFCP_STATUS_UNIT_READONLY,
  2829. &unit->status);
  2830. /* evaluate FSF status in QTCB */
  2831. switch (header->fsf_status) {
  2832. case FSF_PORT_HANDLE_NOT_VALID:
  2833. ZFCP_LOG_INFO("Temporary port identifier 0x%x "
  2834. "for port 0x%016Lx on adapter %s invalid "
  2835. "This may happen occasionally\n",
  2836. unit->port->handle,
  2837. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  2838. ZFCP_LOG_DEBUG("status qualifier:\n");
  2839. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  2840. (char *) &header->fsf_status_qual,
  2841. sizeof (union fsf_status_qual));
  2842. debug_text_event(adapter->erp_dbf, 1, "fsf_s_ph_nv");
  2843. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  2844. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2845. break;
  2846. case FSF_LUN_ALREADY_OPEN:
  2847. ZFCP_LOG_NORMAL("bug: Attempted to open unit 0x%016Lx on "
  2848. "remote port 0x%016Lx on adapter %s twice.\n",
  2849. unit->fcp_lun,
  2850. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  2851. debug_text_exception(adapter->erp_dbf, 0,
  2852. "fsf_s_uopen");
  2853. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2854. break;
  2855. case FSF_ACCESS_DENIED:
  2856. ZFCP_LOG_NORMAL("Access denied, cannot open unit 0x%016Lx on "
  2857. "remote port 0x%016Lx on adapter %s\n",
  2858. unit->fcp_lun, unit->port->wwpn,
  2859. zfcp_get_busid_by_unit(unit));
  2860. for (counter = 0; counter < 2; counter++) {
  2861. subtable = header->fsf_status_qual.halfword[counter * 2];
  2862. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  2863. switch (subtable) {
  2864. case FSF_SQ_CFDC_SUBTABLE_OS:
  2865. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  2866. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  2867. case FSF_SQ_CFDC_SUBTABLE_LUN:
  2868. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  2869. zfcp_act_subtable_type[subtable], rule);
  2870. break;
  2871. }
  2872. }
  2873. debug_text_event(adapter->erp_dbf, 1, "fsf_s_access");
  2874. zfcp_erp_unit_access_denied(unit);
  2875. atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
  2876. atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
  2877. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2878. break;
  2879. case FSF_PORT_BOXED:
  2880. ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
  2881. "needs to be reopened\n",
  2882. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  2883. debug_text_event(adapter->erp_dbf, 2, "fsf_s_pboxed");
  2884. zfcp_erp_port_boxed(unit->port);
  2885. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  2886. ZFCP_STATUS_FSFREQ_RETRY;
  2887. break;
  2888. case FSF_LUN_SHARING_VIOLATION:
  2889. if (header->fsf_status_qual.word[0] != 0) {
  2890. ZFCP_LOG_NORMAL("FCP-LUN 0x%Lx at the remote port "
  2891. "with WWPN 0x%Lx "
  2892. "connected to the adapter %s "
  2893. "is already in use in LPAR%d, CSS%d\n",
  2894. unit->fcp_lun,
  2895. unit->port->wwpn,
  2896. zfcp_get_busid_by_unit(unit),
  2897. queue_designator->hla,
  2898. queue_designator->cssid);
  2899. } else {
  2900. subtable = header->fsf_status_qual.halfword[4];
  2901. rule = header->fsf_status_qual.halfword[5];
  2902. switch (subtable) {
  2903. case FSF_SQ_CFDC_SUBTABLE_OS:
  2904. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  2905. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  2906. case FSF_SQ_CFDC_SUBTABLE_LUN:
  2907. ZFCP_LOG_NORMAL("Access to FCP-LUN 0x%Lx at the "
  2908. "remote port with WWPN 0x%Lx "
  2909. "connected to the adapter %s "
  2910. "is denied (%s rule %d)\n",
  2911. unit->fcp_lun,
  2912. unit->port->wwpn,
  2913. zfcp_get_busid_by_unit(unit),
  2914. zfcp_act_subtable_type[subtable],
  2915. rule);
  2916. break;
  2917. }
  2918. }
  2919. ZFCP_LOG_DEBUG("status qualifier:\n");
  2920. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  2921. (char *) &header->fsf_status_qual,
  2922. sizeof (union fsf_status_qual));
  2923. debug_text_event(adapter->erp_dbf, 2,
  2924. "fsf_s_l_sh_vio");
  2925. zfcp_erp_unit_access_denied(unit);
  2926. atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
  2927. atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
  2928. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2929. break;
  2930. case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:
  2931. ZFCP_LOG_INFO("error: The adapter ran out of resources. "
  2932. "There is no handle (temporary port identifier) "
  2933. "available for unit 0x%016Lx on port 0x%016Lx "
  2934. "on adapter %s\n",
  2935. unit->fcp_lun,
  2936. unit->port->wwpn,
  2937. zfcp_get_busid_by_unit(unit));
  2938. debug_text_event(adapter->erp_dbf, 1,
  2939. "fsf_s_max_units");
  2940. zfcp_erp_unit_failed(unit);
  2941. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2942. break;
  2943. case FSF_ADAPTER_STATUS_AVAILABLE:
  2944. switch (header->fsf_status_qual.word[0]) {
  2945. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  2946. /* Re-establish link to port */
  2947. debug_text_event(adapter->erp_dbf, 1,
  2948. "fsf_sq_ltest");
  2949. zfcp_test_link(unit->port);
  2950. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2951. break;
  2952. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  2953. /* ERP strategy will escalate */
  2954. debug_text_event(adapter->erp_dbf, 1,
  2955. "fsf_sq_ulp");
  2956. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2957. break;
  2958. default:
  2959. ZFCP_LOG_NORMAL
  2960. ("bug: Wrong status qualifier 0x%x arrived.\n",
  2961. header->fsf_status_qual.word[0]);
  2962. debug_text_event(adapter->erp_dbf, 0,
  2963. "fsf_sq_inval:");
  2964. debug_exception(adapter->erp_dbf, 0,
  2965. &header->fsf_status_qual.word[0],
  2966. sizeof (u32));
  2967. }
  2968. break;
  2969. case FSF_INVALID_COMMAND_OPTION:
  2970. ZFCP_LOG_NORMAL(
  2971. "Invalid option 0x%x has been specified "
  2972. "in QTCB bottom sent to the adapter %s\n",
  2973. bottom->option,
  2974. zfcp_get_busid_by_adapter(adapter));
  2975. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  2976. retval = -EINVAL;
  2977. break;
  2978. case FSF_GOOD:
  2979. /* save LUN handle assigned by FSF */
  2980. unit->handle = header->lun_handle;
  2981. ZFCP_LOG_TRACE("unit 0x%016Lx on remote port 0x%016Lx on "
  2982. "adapter %s opened, port handle 0x%x\n",
  2983. unit->fcp_lun,
  2984. unit->port->wwpn,
  2985. zfcp_get_busid_by_unit(unit),
  2986. unit->handle);
  2987. /* mark unit as open */
  2988. atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
  2989. if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) &&
  2990. (adapter->adapter_features & FSF_FEATURE_LUN_SHARING) &&
  2991. (adapter->ccw_device->id.dev_model != ZFCP_DEVICE_MODEL_PRIV)) {
  2992. exclusive = (bottom->lun_access_info &
  2993. FSF_UNIT_ACCESS_EXCLUSIVE);
  2994. readwrite = (bottom->lun_access_info &
  2995. FSF_UNIT_ACCESS_OUTBOUND_TRANSFER);
  2996. if (!exclusive)
  2997. atomic_set_mask(ZFCP_STATUS_UNIT_SHARED,
  2998. &unit->status);
  2999. if (!readwrite) {
  3000. atomic_set_mask(ZFCP_STATUS_UNIT_READONLY,
  3001. &unit->status);
  3002. ZFCP_LOG_NORMAL("read-only access for unit "
  3003. "(adapter %s, wwpn=0x%016Lx, "
  3004. "fcp_lun=0x%016Lx)\n",
  3005. zfcp_get_busid_by_unit(unit),
  3006. unit->port->wwpn,
  3007. unit->fcp_lun);
  3008. }
  3009. if (exclusive && !readwrite) {
  3010. ZFCP_LOG_NORMAL("exclusive access of read-only "
  3011. "unit not supported\n");
  3012. zfcp_erp_unit_failed(unit);
  3013. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3014. zfcp_erp_unit_shutdown(unit, 0);
  3015. } else if (!exclusive && readwrite) {
  3016. ZFCP_LOG_NORMAL("shared access of read-write "
  3017. "unit not supported\n");
  3018. zfcp_erp_unit_failed(unit);
  3019. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3020. zfcp_erp_unit_shutdown(unit, 0);
  3021. }
  3022. }
  3023. retval = 0;
  3024. break;
  3025. default:
  3026. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  3027. "(debug info 0x%x)\n",
  3028. header->fsf_status);
  3029. debug_text_event(adapter->erp_dbf, 0, "fsf_s_inval:");
  3030. debug_exception(adapter->erp_dbf, 0,
  3031. &header->fsf_status, sizeof (u32));
  3032. break;
  3033. }
  3034. skip_fsfstatus:
  3035. atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &unit->status);
  3036. return retval;
  3037. }
  3038. /*
  3039. * function: zfcp_fsf_close_unit
  3040. *
  3041. * purpose:
  3042. *
  3043. * returns: address of fsf_req - request successfully initiated
  3044. * NULL -
  3045. *
  3046. * assumptions: This routine does not check whether the associated
  3047. * remote port/lun has already been opened. This should be
  3048. * done by calling routines. Otherwise some status
  3049. * may be presented by FSF
  3050. */
  3051. int
  3052. zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
  3053. {
  3054. volatile struct qdio_buffer_element *sbale;
  3055. struct zfcp_fsf_req *fsf_req;
  3056. unsigned long lock_flags;
  3057. int retval = 0;
  3058. /* setup new FSF request */
  3059. retval = zfcp_fsf_req_create(erp_action->adapter,
  3060. FSF_QTCB_CLOSE_LUN,
  3061. ZFCP_WAIT_FOR_SBAL | ZFCP_REQ_AUTO_CLEANUP,
  3062. erp_action->adapter->pool.fsf_req_erp,
  3063. &lock_flags, &fsf_req);
  3064. if (retval < 0) {
  3065. ZFCP_LOG_INFO("error: Could not create close unit request for "
  3066. "unit 0x%016Lx on port 0x%016Lx on adapter %s.\n",
  3067. erp_action->unit->fcp_lun,
  3068. erp_action->port->wwpn,
  3069. zfcp_get_busid_by_adapter(erp_action->adapter));
  3070. goto out;
  3071. }
  3072. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  3073. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  3074. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  3075. fsf_req->qtcb->header.port_handle = erp_action->port->handle;
  3076. fsf_req->qtcb->header.lun_handle = erp_action->unit->handle;
  3077. atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->unit->status);
  3078. fsf_req->data = (unsigned long) erp_action->unit;
  3079. fsf_req->erp_action = erp_action;
  3080. erp_action->fsf_req = fsf_req;
  3081. zfcp_erp_start_timer(fsf_req);
  3082. retval = zfcp_fsf_req_send(erp_action->fsf_req);
  3083. if (retval) {
  3084. ZFCP_LOG_INFO("error: Could not send a close unit request for "
  3085. "unit 0x%016Lx on port 0x%016Lx onadapter %s.\n",
  3086. erp_action->unit->fcp_lun,
  3087. erp_action->port->wwpn,
  3088. zfcp_get_busid_by_adapter(erp_action->adapter));
  3089. zfcp_fsf_req_free(fsf_req);
  3090. erp_action->fsf_req = NULL;
  3091. goto out;
  3092. }
  3093. ZFCP_LOG_TRACE("Close LUN request initiated (adapter %s, "
  3094. "port 0x%016Lx, unit 0x%016Lx)\n",
  3095. zfcp_get_busid_by_adapter(erp_action->adapter),
  3096. erp_action->port->wwpn, erp_action->unit->fcp_lun);
  3097. out:
  3098. write_unlock_irqrestore(&erp_action->adapter->request_queue.queue_lock,
  3099. lock_flags);
  3100. return retval;
  3101. }
  3102. /*
  3103. * function: zfcp_fsf_close_unit_handler
  3104. *
  3105. * purpose: is called for finished Close LUN FSF command
  3106. *
  3107. * returns:
  3108. */
  3109. static int
  3110. zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *fsf_req)
  3111. {
  3112. int retval = -EINVAL;
  3113. struct zfcp_unit *unit;
  3114. unit = (struct zfcp_unit *) fsf_req->data;
  3115. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  3116. /* don't change unit status in our bookkeeping */
  3117. goto skip_fsfstatus;
  3118. }
  3119. /* evaluate FSF status in QTCB */
  3120. switch (fsf_req->qtcb->header.fsf_status) {
  3121. case FSF_PORT_HANDLE_NOT_VALID:
  3122. ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
  3123. "0x%016Lx on adapter %s invalid. This may "
  3124. "happen in rare circumstances\n",
  3125. unit->port->handle,
  3126. unit->port->wwpn,
  3127. zfcp_get_busid_by_unit(unit));
  3128. ZFCP_LOG_DEBUG("status qualifier:\n");
  3129. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3130. (char *) &fsf_req->qtcb->header.fsf_status_qual,
  3131. sizeof (union fsf_status_qual));
  3132. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3133. "fsf_s_phand_nv");
  3134. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  3135. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3136. break;
  3137. case FSF_LUN_HANDLE_NOT_VALID:
  3138. ZFCP_LOG_INFO("Temporary LUN identifier 0x%x of unit "
  3139. "0x%016Lx on port 0x%016Lx on adapter %s is "
  3140. "invalid. This may happen occasionally.\n",
  3141. unit->handle,
  3142. unit->fcp_lun,
  3143. unit->port->wwpn,
  3144. zfcp_get_busid_by_unit(unit));
  3145. ZFCP_LOG_DEBUG("Status qualifier data:\n");
  3146. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3147. (char *) &fsf_req->qtcb->header.fsf_status_qual,
  3148. sizeof (union fsf_status_qual));
  3149. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3150. "fsf_s_lhand_nv");
  3151. zfcp_erp_port_reopen(unit->port, 0);
  3152. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3153. break;
  3154. case FSF_PORT_BOXED:
  3155. ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
  3156. "needs to be reopened\n",
  3157. unit->port->wwpn,
  3158. zfcp_get_busid_by_unit(unit));
  3159. debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed");
  3160. zfcp_erp_port_boxed(unit->port);
  3161. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  3162. ZFCP_STATUS_FSFREQ_RETRY;
  3163. break;
  3164. case FSF_ADAPTER_STATUS_AVAILABLE:
  3165. switch (fsf_req->qtcb->header.fsf_status_qual.word[0]) {
  3166. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  3167. /* re-establish link to port */
  3168. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3169. "fsf_sq_ltest");
  3170. zfcp_test_link(unit->port);
  3171. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3172. break;
  3173. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  3174. /* ERP strategy will escalate */
  3175. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3176. "fsf_sq_ulp");
  3177. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3178. break;
  3179. default:
  3180. ZFCP_LOG_NORMAL
  3181. ("bug: Wrong status qualifier 0x%x arrived.\n",
  3182. fsf_req->qtcb->header.fsf_status_qual.word[0]);
  3183. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  3184. "fsf_sq_inval:");
  3185. debug_exception(
  3186. fsf_req->adapter->erp_dbf, 0,
  3187. &fsf_req->qtcb->header.fsf_status_qual.word[0],
  3188. sizeof (u32));
  3189. break;
  3190. }
  3191. break;
  3192. case FSF_GOOD:
  3193. ZFCP_LOG_TRACE("unit 0x%016Lx on port 0x%016Lx on adapter %s "
  3194. "closed, port handle 0x%x\n",
  3195. unit->fcp_lun,
  3196. unit->port->wwpn,
  3197. zfcp_get_busid_by_unit(unit),
  3198. unit->handle);
  3199. /* mark unit as closed */
  3200. atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
  3201. retval = 0;
  3202. break;
  3203. default:
  3204. ZFCP_LOG_NORMAL("bug: An unknown FSF Status was presented "
  3205. "(debug info 0x%x)\n",
  3206. fsf_req->qtcb->header.fsf_status);
  3207. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  3208. debug_exception(fsf_req->adapter->erp_dbf, 0,
  3209. &fsf_req->qtcb->header.fsf_status,
  3210. sizeof (u32));
  3211. break;
  3212. }
  3213. skip_fsfstatus:
  3214. atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &unit->status);
  3215. return retval;
  3216. }
  3217. /**
  3218. * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
  3219. * @adapter: adapter where scsi command is issued
  3220. * @unit: unit where command is sent to
  3221. * @scsi_cmnd: scsi command to be sent
  3222. * @timer: timer to be started when request is initiated
  3223. * @req_flags: flags for fsf_request
  3224. */
  3225. int
  3226. zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
  3227. struct zfcp_unit *unit,
  3228. struct scsi_cmnd * scsi_cmnd,
  3229. int use_timer, int req_flags)
  3230. {
  3231. struct zfcp_fsf_req *fsf_req = NULL;
  3232. struct fcp_cmnd_iu *fcp_cmnd_iu;
  3233. unsigned int sbtype;
  3234. unsigned long lock_flags;
  3235. int real_bytes = 0;
  3236. int retval = 0;
  3237. int mask;
  3238. /* setup new FSF request */
  3239. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
  3240. adapter->pool.fsf_req_scsi,
  3241. &lock_flags, &fsf_req);
  3242. if (unlikely(retval < 0)) {
  3243. ZFCP_LOG_DEBUG("error: Could not create FCP command request "
  3244. "for unit 0x%016Lx on port 0x%016Lx on "
  3245. "adapter %s\n",
  3246. unit->fcp_lun,
  3247. unit->port->wwpn,
  3248. zfcp_get_busid_by_adapter(adapter));
  3249. goto failed_req_create;
  3250. }
  3251. zfcp_unit_get(unit);
  3252. fsf_req->unit = unit;
  3253. /* associate FSF request with SCSI request (for look up on abort) */
  3254. scsi_cmnd->host_scribble = (unsigned char *) fsf_req->req_id;
  3255. /* associate SCSI command with FSF request */
  3256. fsf_req->data = (unsigned long) scsi_cmnd;
  3257. /* set handles of unit and its parent port in QTCB */
  3258. fsf_req->qtcb->header.lun_handle = unit->handle;
  3259. fsf_req->qtcb->header.port_handle = unit->port->handle;
  3260. /* FSF does not define the structure of the FCP_CMND IU */
  3261. fcp_cmnd_iu = (struct fcp_cmnd_iu *)
  3262. &(fsf_req->qtcb->bottom.io.fcp_cmnd);
  3263. /*
  3264. * set depending on data direction:
  3265. * data direction bits in SBALE (SB Type)
  3266. * data direction bits in QTCB
  3267. * data direction bits in FCP_CMND IU
  3268. */
  3269. switch (scsi_cmnd->sc_data_direction) {
  3270. case DMA_NONE:
  3271. fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
  3272. /*
  3273. * FIXME(qdio):
  3274. * what is the correct type for commands
  3275. * without 'real' data buffers?
  3276. */
  3277. sbtype = SBAL_FLAGS0_TYPE_READ;
  3278. break;
  3279. case DMA_FROM_DEVICE:
  3280. fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_READ;
  3281. sbtype = SBAL_FLAGS0_TYPE_READ;
  3282. fcp_cmnd_iu->rddata = 1;
  3283. break;
  3284. case DMA_TO_DEVICE:
  3285. fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE;
  3286. sbtype = SBAL_FLAGS0_TYPE_WRITE;
  3287. fcp_cmnd_iu->wddata = 1;
  3288. break;
  3289. case DMA_BIDIRECTIONAL:
  3290. default:
  3291. /*
  3292. * dummy, catch this condition earlier
  3293. * in zfcp_scsi_queuecommand
  3294. */
  3295. goto failed_scsi_cmnd;
  3296. }
  3297. /* set FC service class in QTCB (3 per default) */
  3298. fsf_req->qtcb->bottom.io.service_class = ZFCP_FC_SERVICE_CLASS_DEFAULT;
  3299. /* set FCP_LUN in FCP_CMND IU in QTCB */
  3300. fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
  3301. mask = ZFCP_STATUS_UNIT_READONLY | ZFCP_STATUS_UNIT_SHARED;
  3302. /* set task attributes in FCP_CMND IU in QTCB */
  3303. if (likely((scsi_cmnd->device->simple_tags) ||
  3304. (atomic_test_mask(mask, &unit->status))))
  3305. fcp_cmnd_iu->task_attribute = SIMPLE_Q;
  3306. else
  3307. fcp_cmnd_iu->task_attribute = UNTAGGED;
  3308. /* set additional length of FCP_CDB in FCP_CMND IU in QTCB, if needed */
  3309. if (unlikely(scsi_cmnd->cmd_len > FCP_CDB_LENGTH)) {
  3310. fcp_cmnd_iu->add_fcp_cdb_length
  3311. = (scsi_cmnd->cmd_len - FCP_CDB_LENGTH) >> 2;
  3312. ZFCP_LOG_TRACE("SCSI CDB length is 0x%x, "
  3313. "additional FCP_CDB length is 0x%x "
  3314. "(shifted right 2 bits)\n",
  3315. scsi_cmnd->cmd_len,
  3316. fcp_cmnd_iu->add_fcp_cdb_length);
  3317. }
  3318. /*
  3319. * copy SCSI CDB (including additional length, if any) to
  3320. * FCP_CDB in FCP_CMND IU in QTCB
  3321. */
  3322. memcpy(fcp_cmnd_iu->fcp_cdb, scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
  3323. /* FCP CMND IU length in QTCB */
  3324. fsf_req->qtcb->bottom.io.fcp_cmnd_length =
  3325. sizeof (struct fcp_cmnd_iu) +
  3326. fcp_cmnd_iu->add_fcp_cdb_length + sizeof (fcp_dl_t);
  3327. /* generate SBALEs from data buffer */
  3328. real_bytes = zfcp_qdio_sbals_from_scsicmnd(fsf_req, sbtype, scsi_cmnd);
  3329. if (unlikely(real_bytes < 0)) {
  3330. if (fsf_req->sbal_number < ZFCP_MAX_SBALS_PER_REQ) {
  3331. ZFCP_LOG_DEBUG(
  3332. "Data did not fit into available buffer(s), "
  3333. "waiting for more...\n");
  3334. retval = -EIO;
  3335. } else {
  3336. ZFCP_LOG_NORMAL("error: No truncation implemented but "
  3337. "required. Shutting down unit "
  3338. "(adapter %s, port 0x%016Lx, "
  3339. "unit 0x%016Lx)\n",
  3340. zfcp_get_busid_by_unit(unit),
  3341. unit->port->wwpn,
  3342. unit->fcp_lun);
  3343. zfcp_erp_unit_shutdown(unit, 0);
  3344. retval = -EINVAL;
  3345. }
  3346. goto no_fit;
  3347. }
  3348. /* set length of FCP data length in FCP_CMND IU in QTCB */
  3349. zfcp_set_fcp_dl(fcp_cmnd_iu, real_bytes);
  3350. ZFCP_LOG_DEBUG("Sending SCSI command:\n");
  3351. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3352. (char *) scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
  3353. if (use_timer)
  3354. zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
  3355. retval = zfcp_fsf_req_send(fsf_req);
  3356. if (unlikely(retval < 0)) {
  3357. ZFCP_LOG_INFO("error: Could not send FCP command request "
  3358. "on adapter %s, port 0x%016Lx, unit 0x%016Lx\n",
  3359. zfcp_get_busid_by_adapter(adapter),
  3360. unit->port->wwpn,
  3361. unit->fcp_lun);
  3362. goto send_failed;
  3363. }
  3364. ZFCP_LOG_TRACE("Send FCP Command initiated (adapter %s, "
  3365. "port 0x%016Lx, unit 0x%016Lx)\n",
  3366. zfcp_get_busid_by_adapter(adapter),
  3367. unit->port->wwpn,
  3368. unit->fcp_lun);
  3369. goto success;
  3370. send_failed:
  3371. no_fit:
  3372. failed_scsi_cmnd:
  3373. zfcp_unit_put(unit);
  3374. zfcp_fsf_req_free(fsf_req);
  3375. fsf_req = NULL;
  3376. scsi_cmnd->host_scribble = NULL;
  3377. success:
  3378. failed_req_create:
  3379. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  3380. return retval;
  3381. }
  3382. struct zfcp_fsf_req *
  3383. zfcp_fsf_send_fcp_command_task_management(struct zfcp_adapter *adapter,
  3384. struct zfcp_unit *unit,
  3385. u8 tm_flags, int req_flags)
  3386. {
  3387. struct zfcp_fsf_req *fsf_req = NULL;
  3388. int retval = 0;
  3389. struct fcp_cmnd_iu *fcp_cmnd_iu;
  3390. unsigned long lock_flags;
  3391. volatile struct qdio_buffer_element *sbale;
  3392. /* setup new FSF request */
  3393. retval = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
  3394. adapter->pool.fsf_req_scsi,
  3395. &lock_flags, &fsf_req);
  3396. if (retval < 0) {
  3397. ZFCP_LOG_INFO("error: Could not create FCP command (task "
  3398. "management) request for adapter %s, port "
  3399. " 0x%016Lx, unit 0x%016Lx.\n",
  3400. zfcp_get_busid_by_adapter(adapter),
  3401. unit->port->wwpn, unit->fcp_lun);
  3402. goto out;
  3403. }
  3404. /*
  3405. * Used to decide on proper handler in the return path,
  3406. * could be either zfcp_fsf_send_fcp_command_task_handler or
  3407. * zfcp_fsf_send_fcp_command_task_management_handler */
  3408. fsf_req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT;
  3409. /*
  3410. * hold a pointer to the unit being target of this
  3411. * task management request
  3412. */
  3413. fsf_req->data = (unsigned long) unit;
  3414. /* set FSF related fields in QTCB */
  3415. fsf_req->qtcb->header.lun_handle = unit->handle;
  3416. fsf_req->qtcb->header.port_handle = unit->port->handle;
  3417. fsf_req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
  3418. fsf_req->qtcb->bottom.io.service_class = ZFCP_FC_SERVICE_CLASS_DEFAULT;
  3419. fsf_req->qtcb->bottom.io.fcp_cmnd_length =
  3420. sizeof (struct fcp_cmnd_iu) + sizeof (fcp_dl_t);
  3421. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  3422. sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
  3423. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  3424. /* set FCP related fields in FCP_CMND IU in QTCB */
  3425. fcp_cmnd_iu = (struct fcp_cmnd_iu *)
  3426. &(fsf_req->qtcb->bottom.io.fcp_cmnd);
  3427. fcp_cmnd_iu->fcp_lun = unit->fcp_lun;
  3428. fcp_cmnd_iu->task_management_flags = tm_flags;
  3429. zfcp_fsf_start_timer(fsf_req, ZFCP_SCSI_ER_TIMEOUT);
  3430. retval = zfcp_fsf_req_send(fsf_req);
  3431. if (retval) {
  3432. ZFCP_LOG_INFO("error: Could not send an FCP-command (task "
  3433. "management) on adapter %s, port 0x%016Lx for "
  3434. "unit LUN 0x%016Lx\n",
  3435. zfcp_get_busid_by_adapter(adapter),
  3436. unit->port->wwpn,
  3437. unit->fcp_lun);
  3438. zfcp_fsf_req_free(fsf_req);
  3439. fsf_req = NULL;
  3440. goto out;
  3441. }
  3442. ZFCP_LOG_TRACE("Send FCP Command (task management function) initiated "
  3443. "(adapter %s, port 0x%016Lx, unit 0x%016Lx, "
  3444. "tm_flags=0x%x)\n",
  3445. zfcp_get_busid_by_adapter(adapter),
  3446. unit->port->wwpn,
  3447. unit->fcp_lun,
  3448. tm_flags);
  3449. out:
  3450. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  3451. return fsf_req;
  3452. }
  3453. /*
  3454. * function: zfcp_fsf_send_fcp_command_handler
  3455. *
  3456. * purpose: is called for finished Send FCP Command
  3457. *
  3458. * returns:
  3459. */
  3460. static int
  3461. zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *fsf_req)
  3462. {
  3463. int retval = -EINVAL;
  3464. struct zfcp_unit *unit;
  3465. struct fsf_qtcb_header *header;
  3466. u16 subtable, rule, counter;
  3467. header = &fsf_req->qtcb->header;
  3468. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT))
  3469. unit = (struct zfcp_unit *) fsf_req->data;
  3470. else
  3471. unit = fsf_req->unit;
  3472. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
  3473. /* go directly to calls of special handlers */
  3474. goto skip_fsfstatus;
  3475. }
  3476. /* evaluate FSF status in QTCB */
  3477. switch (header->fsf_status) {
  3478. case FSF_PORT_HANDLE_NOT_VALID:
  3479. ZFCP_LOG_INFO("Temporary port identifier 0x%x for port "
  3480. "0x%016Lx on adapter %s invalid\n",
  3481. unit->port->handle,
  3482. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  3483. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3484. (char *) &header->fsf_status_qual,
  3485. sizeof (union fsf_status_qual));
  3486. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3487. "fsf_s_phand_nv");
  3488. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  3489. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3490. break;
  3491. case FSF_LUN_HANDLE_NOT_VALID:
  3492. ZFCP_LOG_INFO("Temporary LUN identifier 0x%x for unit "
  3493. "0x%016Lx on port 0x%016Lx on adapter %s is "
  3494. "invalid. This may happen occasionally.\n",
  3495. unit->handle,
  3496. unit->fcp_lun,
  3497. unit->port->wwpn,
  3498. zfcp_get_busid_by_unit(unit));
  3499. ZFCP_LOG_NORMAL("Status qualifier data:\n");
  3500. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
  3501. (char *) &header->fsf_status_qual,
  3502. sizeof (union fsf_status_qual));
  3503. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3504. "fsf_s_uhand_nv");
  3505. zfcp_erp_port_reopen(unit->port, 0);
  3506. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3507. break;
  3508. case FSF_HANDLE_MISMATCH:
  3509. ZFCP_LOG_NORMAL("bug: The port handle 0x%x has changed "
  3510. "unexpectedly. (adapter %s, port 0x%016Lx, "
  3511. "unit 0x%016Lx)\n",
  3512. unit->port->handle,
  3513. zfcp_get_busid_by_unit(unit),
  3514. unit->port->wwpn,
  3515. unit->fcp_lun);
  3516. ZFCP_LOG_NORMAL("status qualifier:\n");
  3517. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_NORMAL,
  3518. (char *) &header->fsf_status_qual,
  3519. sizeof (union fsf_status_qual));
  3520. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3521. "fsf_s_hand_mis");
  3522. zfcp_erp_adapter_reopen(unit->port->adapter, 0);
  3523. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3524. break;
  3525. case FSF_SERVICE_CLASS_NOT_SUPPORTED:
  3526. ZFCP_LOG_INFO("error: adapter %s does not support fc "
  3527. "class %d.\n",
  3528. zfcp_get_busid_by_unit(unit),
  3529. ZFCP_FC_SERVICE_CLASS_DEFAULT);
  3530. /* stop operation for this adapter */
  3531. debug_text_exception(fsf_req->adapter->erp_dbf, 0,
  3532. "fsf_s_class_nsup");
  3533. zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
  3534. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3535. break;
  3536. case FSF_FCPLUN_NOT_VALID:
  3537. ZFCP_LOG_NORMAL("bug: unit 0x%016Lx on port 0x%016Lx on "
  3538. "adapter %s does not have correct unit "
  3539. "handle 0x%x\n",
  3540. unit->fcp_lun,
  3541. unit->port->wwpn,
  3542. zfcp_get_busid_by_unit(unit),
  3543. unit->handle);
  3544. ZFCP_LOG_DEBUG("status qualifier:\n");
  3545. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3546. (char *) &header->fsf_status_qual,
  3547. sizeof (union fsf_status_qual));
  3548. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3549. "fsf_s_fcp_lun_nv");
  3550. zfcp_erp_port_reopen(unit->port, 0);
  3551. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3552. break;
  3553. case FSF_ACCESS_DENIED:
  3554. ZFCP_LOG_NORMAL("Access denied, cannot send FCP command to "
  3555. "unit 0x%016Lx on port 0x%016Lx on "
  3556. "adapter %s\n", unit->fcp_lun, unit->port->wwpn,
  3557. zfcp_get_busid_by_unit(unit));
  3558. for (counter = 0; counter < 2; counter++) {
  3559. subtable = header->fsf_status_qual.halfword[counter * 2];
  3560. rule = header->fsf_status_qual.halfword[counter * 2 + 1];
  3561. switch (subtable) {
  3562. case FSF_SQ_CFDC_SUBTABLE_OS:
  3563. case FSF_SQ_CFDC_SUBTABLE_PORT_WWPN:
  3564. case FSF_SQ_CFDC_SUBTABLE_PORT_DID:
  3565. case FSF_SQ_CFDC_SUBTABLE_LUN:
  3566. ZFCP_LOG_INFO("Access denied (%s rule %d)\n",
  3567. zfcp_act_subtable_type[subtable], rule);
  3568. break;
  3569. }
  3570. }
  3571. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_access");
  3572. zfcp_erp_unit_access_denied(unit);
  3573. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3574. break;
  3575. case FSF_DIRECTION_INDICATOR_NOT_VALID:
  3576. ZFCP_LOG_INFO("bug: Invalid data direction given for unit "
  3577. "0x%016Lx on port 0x%016Lx on adapter %s "
  3578. "(debug info %d)\n",
  3579. unit->fcp_lun,
  3580. unit->port->wwpn,
  3581. zfcp_get_busid_by_unit(unit),
  3582. fsf_req->qtcb->bottom.io.data_direction);
  3583. /* stop operation for this adapter */
  3584. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  3585. "fsf_s_dir_ind_nv");
  3586. zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
  3587. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3588. break;
  3589. case FSF_CMND_LENGTH_NOT_VALID:
  3590. ZFCP_LOG_NORMAL
  3591. ("bug: An invalid control-data-block length field "
  3592. "was found in a command for unit 0x%016Lx on port "
  3593. "0x%016Lx on adapter %s " "(debug info %d)\n",
  3594. unit->fcp_lun, unit->port->wwpn,
  3595. zfcp_get_busid_by_unit(unit),
  3596. fsf_req->qtcb->bottom.io.fcp_cmnd_length);
  3597. /* stop operation for this adapter */
  3598. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  3599. "fsf_s_cmd_len_nv");
  3600. zfcp_erp_adapter_shutdown(unit->port->adapter, 0);
  3601. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3602. break;
  3603. case FSF_PORT_BOXED:
  3604. ZFCP_LOG_DEBUG("The remote port 0x%016Lx on adapter %s "
  3605. "needs to be reopened\n",
  3606. unit->port->wwpn, zfcp_get_busid_by_unit(unit));
  3607. debug_text_event(fsf_req->adapter->erp_dbf, 2, "fsf_s_pboxed");
  3608. zfcp_erp_port_boxed(unit->port);
  3609. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  3610. ZFCP_STATUS_FSFREQ_RETRY;
  3611. break;
  3612. case FSF_LUN_BOXED:
  3613. ZFCP_LOG_NORMAL("unit needs to be reopened (adapter %s, "
  3614. "wwpn=0x%016Lx, fcp_lun=0x%016Lx)\n",
  3615. zfcp_get_busid_by_unit(unit),
  3616. unit->port->wwpn, unit->fcp_lun);
  3617. debug_text_event(fsf_req->adapter->erp_dbf, 1, "fsf_s_lboxed");
  3618. zfcp_erp_unit_boxed(unit);
  3619. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR
  3620. | ZFCP_STATUS_FSFREQ_RETRY;
  3621. break;
  3622. case FSF_ADAPTER_STATUS_AVAILABLE:
  3623. switch (header->fsf_status_qual.word[0]) {
  3624. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  3625. /* re-establish link to port */
  3626. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3627. "fsf_sq_ltest");
  3628. zfcp_test_link(unit->port);
  3629. break;
  3630. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  3631. /* FIXME(hw) need proper specs for proper action */
  3632. /* let scsi stack deal with retries and escalation */
  3633. debug_text_event(fsf_req->adapter->erp_dbf, 1,
  3634. "fsf_sq_ulp");
  3635. break;
  3636. default:
  3637. ZFCP_LOG_NORMAL
  3638. ("Unknown status qualifier 0x%x arrived.\n",
  3639. header->fsf_status_qual.word[0]);
  3640. debug_text_event(fsf_req->adapter->erp_dbf, 0,
  3641. "fsf_sq_inval:");
  3642. debug_exception(fsf_req->adapter->erp_dbf, 0,
  3643. &header->fsf_status_qual.word[0],
  3644. sizeof(u32));
  3645. break;
  3646. }
  3647. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  3648. break;
  3649. case FSF_GOOD:
  3650. break;
  3651. case FSF_FCP_RSP_AVAILABLE:
  3652. break;
  3653. default:
  3654. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_s_inval:");
  3655. debug_exception(fsf_req->adapter->erp_dbf, 0,
  3656. &header->fsf_status, sizeof(u32));
  3657. break;
  3658. }
  3659. skip_fsfstatus:
  3660. if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT) {
  3661. retval =
  3662. zfcp_fsf_send_fcp_command_task_management_handler(fsf_req);
  3663. } else {
  3664. retval = zfcp_fsf_send_fcp_command_task_handler(fsf_req);
  3665. fsf_req->unit = NULL;
  3666. zfcp_unit_put(unit);
  3667. }
  3668. return retval;
  3669. }
  3670. /*
  3671. * function: zfcp_fsf_send_fcp_command_task_handler
  3672. *
  3673. * purpose: evaluates FCP_RSP IU
  3674. *
  3675. * returns:
  3676. */
  3677. static int
  3678. zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *fsf_req)
  3679. {
  3680. int retval = 0;
  3681. struct scsi_cmnd *scpnt;
  3682. struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
  3683. &(fsf_req->qtcb->bottom.io.fcp_rsp);
  3684. struct fcp_cmnd_iu *fcp_cmnd_iu = (struct fcp_cmnd_iu *)
  3685. &(fsf_req->qtcb->bottom.io.fcp_cmnd);
  3686. u32 sns_len;
  3687. char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu);
  3688. unsigned long flags;
  3689. struct zfcp_unit *unit = fsf_req->unit;
  3690. read_lock_irqsave(&fsf_req->adapter->abort_lock, flags);
  3691. scpnt = (struct scsi_cmnd *) fsf_req->data;
  3692. if (unlikely(!scpnt)) {
  3693. ZFCP_LOG_DEBUG
  3694. ("Command with fsf_req %p is not associated to "
  3695. "a scsi command anymore. Aborted?\n", fsf_req);
  3696. goto out;
  3697. }
  3698. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ABORTED)) {
  3699. /* FIXME: (design) mid-layer should handle DID_ABORT like
  3700. * DID_SOFT_ERROR by retrying the request for devices
  3701. * that allow retries.
  3702. */
  3703. ZFCP_LOG_DEBUG("Setting DID_SOFT_ERROR and SUGGEST_RETRY\n");
  3704. set_host_byte(&scpnt->result, DID_SOFT_ERROR);
  3705. set_driver_byte(&scpnt->result, SUGGEST_RETRY);
  3706. goto skip_fsfstatus;
  3707. }
  3708. if (unlikely(fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
  3709. ZFCP_LOG_DEBUG("Setting DID_ERROR\n");
  3710. set_host_byte(&scpnt->result, DID_ERROR);
  3711. goto skip_fsfstatus;
  3712. }
  3713. /* set message byte of result in SCSI command */
  3714. scpnt->result |= COMMAND_COMPLETE << 8;
  3715. /*
  3716. * copy SCSI status code of FCP_STATUS of FCP_RSP IU to status byte
  3717. * of result in SCSI command
  3718. */
  3719. scpnt->result |= fcp_rsp_iu->scsi_status;
  3720. if (unlikely(fcp_rsp_iu->scsi_status)) {
  3721. /* DEBUG */
  3722. ZFCP_LOG_DEBUG("status for SCSI Command:\n");
  3723. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3724. scpnt->cmnd, scpnt->cmd_len);
  3725. ZFCP_LOG_DEBUG("SCSI status code 0x%x\n",
  3726. fcp_rsp_iu->scsi_status);
  3727. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3728. (void *) fcp_rsp_iu, sizeof (struct fcp_rsp_iu));
  3729. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3730. zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu),
  3731. fcp_rsp_iu->fcp_sns_len);
  3732. }
  3733. /* check FCP_RSP_INFO */
  3734. if (unlikely(fcp_rsp_iu->validity.bits.fcp_rsp_len_valid)) {
  3735. ZFCP_LOG_DEBUG("rsp_len is valid\n");
  3736. switch (fcp_rsp_info[3]) {
  3737. case RSP_CODE_GOOD:
  3738. /* ok, continue */
  3739. ZFCP_LOG_TRACE("no failure or Task Management "
  3740. "Function complete\n");
  3741. set_host_byte(&scpnt->result, DID_OK);
  3742. break;
  3743. case RSP_CODE_LENGTH_MISMATCH:
  3744. /* hardware bug */
  3745. ZFCP_LOG_NORMAL("bug: FCP response code indictates "
  3746. "that the fibrechannel protocol data "
  3747. "length differs from the burst length. "
  3748. "The problem occured on unit 0x%016Lx "
  3749. "on port 0x%016Lx on adapter %s",
  3750. unit->fcp_lun,
  3751. unit->port->wwpn,
  3752. zfcp_get_busid_by_unit(unit));
  3753. /* dump SCSI CDB as prepared by zfcp */
  3754. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3755. (char *) &fsf_req->qtcb->
  3756. bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
  3757. set_host_byte(&scpnt->result, DID_ERROR);
  3758. goto skip_fsfstatus;
  3759. case RSP_CODE_FIELD_INVALID:
  3760. /* driver or hardware bug */
  3761. ZFCP_LOG_NORMAL("bug: FCP response code indictates "
  3762. "that the fibrechannel protocol data "
  3763. "fields were incorrectly set up. "
  3764. "The problem occured on the unit "
  3765. "0x%016Lx on port 0x%016Lx on "
  3766. "adapter %s",
  3767. unit->fcp_lun,
  3768. unit->port->wwpn,
  3769. zfcp_get_busid_by_unit(unit));
  3770. /* dump SCSI CDB as prepared by zfcp */
  3771. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3772. (char *) &fsf_req->qtcb->
  3773. bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
  3774. set_host_byte(&scpnt->result, DID_ERROR);
  3775. goto skip_fsfstatus;
  3776. case RSP_CODE_RO_MISMATCH:
  3777. /* hardware bug */
  3778. ZFCP_LOG_NORMAL("bug: The FCP response code indicates "
  3779. "that conflicting values for the "
  3780. "fibrechannel payload offset from the "
  3781. "header were found. "
  3782. "The problem occured on unit 0x%016Lx "
  3783. "on port 0x%016Lx on adapter %s.\n",
  3784. unit->fcp_lun,
  3785. unit->port->wwpn,
  3786. zfcp_get_busid_by_unit(unit));
  3787. /* dump SCSI CDB as prepared by zfcp */
  3788. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3789. (char *) &fsf_req->qtcb->
  3790. bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
  3791. set_host_byte(&scpnt->result, DID_ERROR);
  3792. goto skip_fsfstatus;
  3793. default:
  3794. ZFCP_LOG_NORMAL("bug: An invalid FCP response "
  3795. "code was detected for a command. "
  3796. "The problem occured on the unit "
  3797. "0x%016Lx on port 0x%016Lx on "
  3798. "adapter %s (debug info 0x%x)\n",
  3799. unit->fcp_lun,
  3800. unit->port->wwpn,
  3801. zfcp_get_busid_by_unit(unit),
  3802. fcp_rsp_info[3]);
  3803. /* dump SCSI CDB as prepared by zfcp */
  3804. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_DEBUG,
  3805. (char *) &fsf_req->qtcb->
  3806. bottom.io.fcp_cmnd, FSF_FCP_CMND_SIZE);
  3807. set_host_byte(&scpnt->result, DID_ERROR);
  3808. goto skip_fsfstatus;
  3809. }
  3810. }
  3811. /* check for sense data */
  3812. if (unlikely(fcp_rsp_iu->validity.bits.fcp_sns_len_valid)) {
  3813. sns_len = FSF_FCP_RSP_SIZE -
  3814. sizeof (struct fcp_rsp_iu) + fcp_rsp_iu->fcp_rsp_len;
  3815. ZFCP_LOG_TRACE("room for %i bytes sense data in QTCB\n",
  3816. sns_len);
  3817. sns_len = min(sns_len, (u32) SCSI_SENSE_BUFFERSIZE);
  3818. ZFCP_LOG_TRACE("room for %i bytes sense data in SCSI command\n",
  3819. SCSI_SENSE_BUFFERSIZE);
  3820. sns_len = min(sns_len, fcp_rsp_iu->fcp_sns_len);
  3821. ZFCP_LOG_TRACE("scpnt->result =0x%x, command was:\n",
  3822. scpnt->result);
  3823. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
  3824. (void *) &scpnt->cmnd, scpnt->cmd_len);
  3825. ZFCP_LOG_TRACE("%i bytes sense data provided by FCP\n",
  3826. fcp_rsp_iu->fcp_sns_len);
  3827. memcpy(&scpnt->sense_buffer,
  3828. zfcp_get_fcp_sns_info_ptr(fcp_rsp_iu), sns_len);
  3829. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE,
  3830. (void *) &scpnt->sense_buffer, sns_len);
  3831. }
  3832. /* check for overrun */
  3833. if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_over)) {
  3834. ZFCP_LOG_INFO("A data overrun was detected for a command. "
  3835. "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
  3836. "The response data length is "
  3837. "%d, the original length was %d.\n",
  3838. unit->fcp_lun,
  3839. unit->port->wwpn,
  3840. zfcp_get_busid_by_unit(unit),
  3841. fcp_rsp_iu->fcp_resid,
  3842. (int) zfcp_get_fcp_dl(fcp_cmnd_iu));
  3843. }
  3844. /* check for underrun */
  3845. if (unlikely(fcp_rsp_iu->validity.bits.fcp_resid_under)) {
  3846. ZFCP_LOG_INFO("A data underrun was detected for a command. "
  3847. "unit 0x%016Lx, port 0x%016Lx, adapter %s. "
  3848. "The response data length is "
  3849. "%d, the original length was %d.\n",
  3850. unit->fcp_lun,
  3851. unit->port->wwpn,
  3852. zfcp_get_busid_by_unit(unit),
  3853. fcp_rsp_iu->fcp_resid,
  3854. (int) zfcp_get_fcp_dl(fcp_cmnd_iu));
  3855. scsi_set_resid(scpnt, fcp_rsp_iu->fcp_resid);
  3856. if (scsi_bufflen(scpnt) - scsi_get_resid(scpnt) <
  3857. scpnt->underflow)
  3858. set_host_byte(&scpnt->result, DID_ERROR);
  3859. }
  3860. skip_fsfstatus:
  3861. ZFCP_LOG_DEBUG("scpnt->result =0x%x\n", scpnt->result);
  3862. if (scpnt->result != 0)
  3863. zfcp_scsi_dbf_event_result("erro", 3, fsf_req->adapter, scpnt, fsf_req);
  3864. else if (scpnt->retries > 0)
  3865. zfcp_scsi_dbf_event_result("retr", 4, fsf_req->adapter, scpnt, fsf_req);
  3866. else
  3867. zfcp_scsi_dbf_event_result("norm", 6, fsf_req->adapter, scpnt, fsf_req);
  3868. /* cleanup pointer (need this especially for abort) */
  3869. scpnt->host_scribble = NULL;
  3870. /* always call back */
  3871. (scpnt->scsi_done) (scpnt);
  3872. /*
  3873. * We must hold this lock until scsi_done has been called.
  3874. * Otherwise we may call scsi_done after abort regarding this
  3875. * command has completed.
  3876. * Note: scsi_done must not block!
  3877. */
  3878. out:
  3879. read_unlock_irqrestore(&fsf_req->adapter->abort_lock, flags);
  3880. return retval;
  3881. }
  3882. /*
  3883. * function: zfcp_fsf_send_fcp_command_task_management_handler
  3884. *
  3885. * purpose: evaluates FCP_RSP IU
  3886. *
  3887. * returns:
  3888. */
  3889. static int
  3890. zfcp_fsf_send_fcp_command_task_management_handler(struct zfcp_fsf_req *fsf_req)
  3891. {
  3892. int retval = 0;
  3893. struct fcp_rsp_iu *fcp_rsp_iu = (struct fcp_rsp_iu *)
  3894. &(fsf_req->qtcb->bottom.io.fcp_rsp);
  3895. char *fcp_rsp_info = zfcp_get_fcp_rsp_info_ptr(fcp_rsp_iu);
  3896. struct zfcp_unit *unit = (struct zfcp_unit *) fsf_req->data;
  3897. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  3898. fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
  3899. goto skip_fsfstatus;
  3900. }
  3901. /* check FCP_RSP_INFO */
  3902. switch (fcp_rsp_info[3]) {
  3903. case RSP_CODE_GOOD:
  3904. /* ok, continue */
  3905. ZFCP_LOG_DEBUG("no failure or Task Management "
  3906. "Function complete\n");
  3907. break;
  3908. case RSP_CODE_TASKMAN_UNSUPP:
  3909. ZFCP_LOG_NORMAL("bug: A reuested task management function "
  3910. "is not supported on the target device "
  3911. "unit 0x%016Lx, port 0x%016Lx, adapter %s\n ",
  3912. unit->fcp_lun,
  3913. unit->port->wwpn,
  3914. zfcp_get_busid_by_unit(unit));
  3915. fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCNOTSUPP;
  3916. break;
  3917. case RSP_CODE_TASKMAN_FAILED:
  3918. ZFCP_LOG_NORMAL("bug: A reuested task management function "
  3919. "failed to complete successfully. "
  3920. "unit 0x%016Lx, port 0x%016Lx, adapter %s.\n",
  3921. unit->fcp_lun,
  3922. unit->port->wwpn,
  3923. zfcp_get_busid_by_unit(unit));
  3924. fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
  3925. break;
  3926. default:
  3927. ZFCP_LOG_NORMAL("bug: An invalid FCP response "
  3928. "code was detected for a command. "
  3929. "unit 0x%016Lx, port 0x%016Lx, adapter %s "
  3930. "(debug info 0x%x)\n",
  3931. unit->fcp_lun,
  3932. unit->port->wwpn,
  3933. zfcp_get_busid_by_unit(unit),
  3934. fcp_rsp_info[3]);
  3935. fsf_req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
  3936. }
  3937. skip_fsfstatus:
  3938. return retval;
  3939. }
  3940. /*
  3941. * function: zfcp_fsf_control_file
  3942. *
  3943. * purpose: Initiator of the control file upload/download FSF requests
  3944. *
  3945. * returns: 0 - FSF request is successfuly created and queued
  3946. * -EOPNOTSUPP - The FCP adapter does not have Control File support
  3947. * -EINVAL - Invalid direction specified
  3948. * -ENOMEM - Insufficient memory
  3949. * -EPERM - Cannot create FSF request or place it in QDIO queue
  3950. */
  3951. int
  3952. zfcp_fsf_control_file(struct zfcp_adapter *adapter,
  3953. struct zfcp_fsf_req **fsf_req_ptr,
  3954. u32 fsf_command,
  3955. u32 option,
  3956. struct zfcp_sg_list *sg_list)
  3957. {
  3958. struct zfcp_fsf_req *fsf_req;
  3959. struct fsf_qtcb_bottom_support *bottom;
  3960. volatile struct qdio_buffer_element *sbale;
  3961. unsigned long lock_flags;
  3962. int req_flags = 0;
  3963. int direction;
  3964. int retval = 0;
  3965. if (!(adapter->adapter_features & FSF_FEATURE_CFDC)) {
  3966. ZFCP_LOG_INFO("cfdc not supported (adapter %s)\n",
  3967. zfcp_get_busid_by_adapter(adapter));
  3968. retval = -EOPNOTSUPP;
  3969. goto out;
  3970. }
  3971. switch (fsf_command) {
  3972. case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
  3973. direction = SBAL_FLAGS0_TYPE_WRITE;
  3974. if ((option != FSF_CFDC_OPTION_FULL_ACCESS) &&
  3975. (option != FSF_CFDC_OPTION_RESTRICTED_ACCESS))
  3976. req_flags = ZFCP_WAIT_FOR_SBAL;
  3977. break;
  3978. case FSF_QTCB_UPLOAD_CONTROL_FILE:
  3979. direction = SBAL_FLAGS0_TYPE_READ;
  3980. break;
  3981. default:
  3982. ZFCP_LOG_INFO("Invalid FSF command code 0x%08x\n", fsf_command);
  3983. retval = -EINVAL;
  3984. goto out;
  3985. }
  3986. retval = zfcp_fsf_req_create(adapter, fsf_command, req_flags,
  3987. NULL, &lock_flags, &fsf_req);
  3988. if (retval < 0) {
  3989. ZFCP_LOG_INFO("error: Could not create FSF request for the "
  3990. "adapter %s\n",
  3991. zfcp_get_busid_by_adapter(adapter));
  3992. retval = -EPERM;
  3993. goto unlock_queue_lock;
  3994. }
  3995. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  3996. sbale[0].flags |= direction;
  3997. bottom = &fsf_req->qtcb->bottom.support;
  3998. bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE;
  3999. bottom->option = option;
  4000. if (sg_list->count > 0) {
  4001. int bytes;
  4002. bytes = zfcp_qdio_sbals_from_sg(fsf_req, direction,
  4003. sg_list->sg, sg_list->count,
  4004. ZFCP_MAX_SBALS_PER_REQ);
  4005. if (bytes != ZFCP_CFDC_MAX_CONTROL_FILE_SIZE) {
  4006. ZFCP_LOG_INFO(
  4007. "error: Could not create sufficient number of "
  4008. "SBALS for an FSF request to the adapter %s\n",
  4009. zfcp_get_busid_by_adapter(adapter));
  4010. retval = -ENOMEM;
  4011. goto free_fsf_req;
  4012. }
  4013. } else
  4014. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  4015. zfcp_fsf_start_timer(fsf_req, ZFCP_FSF_REQUEST_TIMEOUT);
  4016. retval = zfcp_fsf_req_send(fsf_req);
  4017. if (retval < 0) {
  4018. ZFCP_LOG_INFO("initiation of cfdc up/download failed"
  4019. "(adapter %s)\n",
  4020. zfcp_get_busid_by_adapter(adapter));
  4021. retval = -EPERM;
  4022. goto free_fsf_req;
  4023. }
  4024. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  4025. ZFCP_LOG_NORMAL("Control file %s FSF request has been sent to the "
  4026. "adapter %s\n",
  4027. fsf_command == FSF_QTCB_DOWNLOAD_CONTROL_FILE ?
  4028. "download" : "upload",
  4029. zfcp_get_busid_by_adapter(adapter));
  4030. wait_event(fsf_req->completion_wq,
  4031. fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
  4032. *fsf_req_ptr = fsf_req;
  4033. goto out;
  4034. free_fsf_req:
  4035. zfcp_fsf_req_free(fsf_req);
  4036. unlock_queue_lock:
  4037. write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
  4038. out:
  4039. return retval;
  4040. }
  4041. /*
  4042. * function: zfcp_fsf_control_file_handler
  4043. *
  4044. * purpose: Handler of the control file upload/download FSF requests
  4045. *
  4046. * returns: 0 - FSF request successfuly processed
  4047. * -EAGAIN - Operation has to be repeated because of a temporary problem
  4048. * -EACCES - There is no permission to execute an operation
  4049. * -EPERM - The control file is not in a right format
  4050. * -EIO - There is a problem with the FCP adapter
  4051. * -EINVAL - Invalid operation
  4052. * -EFAULT - User space memory I/O operation fault
  4053. */
  4054. static int
  4055. zfcp_fsf_control_file_handler(struct zfcp_fsf_req *fsf_req)
  4056. {
  4057. struct zfcp_adapter *adapter = fsf_req->adapter;
  4058. struct fsf_qtcb_header *header = &fsf_req->qtcb->header;
  4059. struct fsf_qtcb_bottom_support *bottom = &fsf_req->qtcb->bottom.support;
  4060. int retval = 0;
  4061. if (fsf_req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  4062. retval = -EINVAL;
  4063. goto skip_fsfstatus;
  4064. }
  4065. switch (header->fsf_status) {
  4066. case FSF_GOOD:
  4067. ZFCP_LOG_NORMAL(
  4068. "The FSF request has been successfully completed "
  4069. "on the adapter %s\n",
  4070. zfcp_get_busid_by_adapter(adapter));
  4071. break;
  4072. case FSF_OPERATION_PARTIALLY_SUCCESSFUL:
  4073. if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE) {
  4074. switch (header->fsf_status_qual.word[0]) {
  4075. case FSF_SQ_CFDC_HARDENED_ON_SE:
  4076. ZFCP_LOG_NORMAL(
  4077. "CFDC on the adapter %s has being "
  4078. "hardened on primary and secondary SE\n",
  4079. zfcp_get_busid_by_adapter(adapter));
  4080. break;
  4081. case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE:
  4082. ZFCP_LOG_NORMAL(
  4083. "CFDC of the adapter %s could not "
  4084. "be saved on the SE\n",
  4085. zfcp_get_busid_by_adapter(adapter));
  4086. break;
  4087. case FSF_SQ_CFDC_COULD_NOT_HARDEN_ON_SE2:
  4088. ZFCP_LOG_NORMAL(
  4089. "CFDC of the adapter %s could not "
  4090. "be copied to the secondary SE\n",
  4091. zfcp_get_busid_by_adapter(adapter));
  4092. break;
  4093. default:
  4094. ZFCP_LOG_NORMAL(
  4095. "CFDC could not be hardened "
  4096. "on the adapter %s\n",
  4097. zfcp_get_busid_by_adapter(adapter));
  4098. }
  4099. }
  4100. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4101. retval = -EAGAIN;
  4102. break;
  4103. case FSF_AUTHORIZATION_FAILURE:
  4104. ZFCP_LOG_NORMAL(
  4105. "Adapter %s does not accept privileged commands\n",
  4106. zfcp_get_busid_by_adapter(adapter));
  4107. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4108. retval = -EACCES;
  4109. break;
  4110. case FSF_CFDC_ERROR_DETECTED:
  4111. ZFCP_LOG_NORMAL(
  4112. "Error at position %d in the CFDC, "
  4113. "CFDC is discarded by the adapter %s\n",
  4114. header->fsf_status_qual.word[0],
  4115. zfcp_get_busid_by_adapter(adapter));
  4116. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4117. retval = -EPERM;
  4118. break;
  4119. case FSF_CONTROL_FILE_UPDATE_ERROR:
  4120. ZFCP_LOG_NORMAL(
  4121. "Adapter %s cannot harden the control file, "
  4122. "file is discarded\n",
  4123. zfcp_get_busid_by_adapter(adapter));
  4124. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4125. retval = -EIO;
  4126. break;
  4127. case FSF_CONTROL_FILE_TOO_LARGE:
  4128. ZFCP_LOG_NORMAL(
  4129. "Control file is too large, file is discarded "
  4130. "by the adapter %s\n",
  4131. zfcp_get_busid_by_adapter(adapter));
  4132. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4133. retval = -EIO;
  4134. break;
  4135. case FSF_ACCESS_CONFLICT_DETECTED:
  4136. if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE)
  4137. ZFCP_LOG_NORMAL(
  4138. "CFDC has been discarded by the adapter %s, "
  4139. "because activation would impact "
  4140. "%d active connection(s)\n",
  4141. zfcp_get_busid_by_adapter(adapter),
  4142. header->fsf_status_qual.word[0]);
  4143. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4144. retval = -EIO;
  4145. break;
  4146. case FSF_CONFLICTS_OVERRULED:
  4147. if (bottom->operation_subtype == FSF_CFDC_OPERATION_SUBTYPE)
  4148. ZFCP_LOG_NORMAL(
  4149. "CFDC has been activated on the adapter %s, "
  4150. "but activation has impacted "
  4151. "%d active connection(s)\n",
  4152. zfcp_get_busid_by_adapter(adapter),
  4153. header->fsf_status_qual.word[0]);
  4154. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4155. retval = -EIO;
  4156. break;
  4157. case FSF_UNKNOWN_OP_SUBTYPE:
  4158. ZFCP_LOG_NORMAL("unknown operation subtype (adapter: %s, "
  4159. "op_subtype=0x%x)\n",
  4160. zfcp_get_busid_by_adapter(adapter),
  4161. bottom->operation_subtype);
  4162. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4163. retval = -EINVAL;
  4164. break;
  4165. case FSF_INVALID_COMMAND_OPTION:
  4166. ZFCP_LOG_NORMAL(
  4167. "Invalid option 0x%x has been specified "
  4168. "in QTCB bottom sent to the adapter %s\n",
  4169. bottom->option,
  4170. zfcp_get_busid_by_adapter(adapter));
  4171. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4172. retval = -EINVAL;
  4173. break;
  4174. default:
  4175. ZFCP_LOG_NORMAL(
  4176. "bug: An unknown/unexpected FSF status 0x%08x "
  4177. "was presented on the adapter %s\n",
  4178. header->fsf_status,
  4179. zfcp_get_busid_by_adapter(adapter));
  4180. debug_text_event(fsf_req->adapter->erp_dbf, 0, "fsf_sq_inval");
  4181. debug_exception(fsf_req->adapter->erp_dbf, 0,
  4182. &header->fsf_status_qual.word[0], sizeof(u32));
  4183. fsf_req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  4184. retval = -EINVAL;
  4185. break;
  4186. }
  4187. skip_fsfstatus:
  4188. return retval;
  4189. }
  4190. static inline int
  4191. zfcp_fsf_req_sbal_check(unsigned long *flags,
  4192. struct zfcp_qdio_queue *queue, int needed)
  4193. {
  4194. write_lock_irqsave(&queue->queue_lock, *flags);
  4195. if (likely(atomic_read(&queue->free_count) >= needed))
  4196. return 1;
  4197. write_unlock_irqrestore(&queue->queue_lock, *flags);
  4198. return 0;
  4199. }
  4200. /*
  4201. * set qtcb pointer in fsf_req and initialize QTCB
  4202. */
  4203. static void
  4204. zfcp_fsf_req_qtcb_init(struct zfcp_fsf_req *fsf_req)
  4205. {
  4206. if (likely(fsf_req->qtcb != NULL)) {
  4207. fsf_req->qtcb->prefix.req_seq_no =
  4208. fsf_req->adapter->fsf_req_seq_no;
  4209. fsf_req->qtcb->prefix.req_id = fsf_req->req_id;
  4210. fsf_req->qtcb->prefix.ulp_info = ZFCP_ULP_INFO_VERSION;
  4211. fsf_req->qtcb->prefix.qtcb_type =
  4212. fsf_qtcb_type[fsf_req->fsf_command];
  4213. fsf_req->qtcb->prefix.qtcb_version = ZFCP_QTCB_VERSION;
  4214. fsf_req->qtcb->header.req_handle = fsf_req->req_id;
  4215. fsf_req->qtcb->header.fsf_command = fsf_req->fsf_command;
  4216. }
  4217. }
  4218. /**
  4219. * zfcp_fsf_req_sbal_get - try to get one SBAL in the request queue
  4220. * @adapter: adapter for which request queue is examined
  4221. * @req_flags: flags indicating whether to wait for needed SBAL or not
  4222. * @lock_flags: lock_flags if queue_lock is taken
  4223. * Return: 0 on success, otherwise -EIO, or -ERESTARTSYS
  4224. * Locks: lock adapter->request_queue->queue_lock on success
  4225. */
  4226. static int
  4227. zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter, int req_flags,
  4228. unsigned long *lock_flags)
  4229. {
  4230. long ret;
  4231. struct zfcp_qdio_queue *req_queue = &adapter->request_queue;
  4232. if (unlikely(req_flags & ZFCP_WAIT_FOR_SBAL)) {
  4233. ret = wait_event_interruptible_timeout(adapter->request_wq,
  4234. zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1),
  4235. ZFCP_SBAL_TIMEOUT);
  4236. if (ret < 0)
  4237. return ret;
  4238. if (!ret)
  4239. return -EIO;
  4240. } else if (!zfcp_fsf_req_sbal_check(lock_flags, req_queue, 1))
  4241. return -EIO;
  4242. return 0;
  4243. }
  4244. /*
  4245. * function: zfcp_fsf_req_create
  4246. *
  4247. * purpose: create an FSF request at the specified adapter and
  4248. * setup common fields
  4249. *
  4250. * returns: -ENOMEM if there was insufficient memory for a request
  4251. * -EIO if no qdio buffers could be allocate to the request
  4252. * -EINVAL/-EPERM on bug conditions in req_dequeue
  4253. * 0 in success
  4254. *
  4255. * note: The created request is returned by reference.
  4256. *
  4257. * locks: lock of concerned request queue must not be held,
  4258. * but is held on completion (write, irqsave)
  4259. */
  4260. int
  4261. zfcp_fsf_req_create(struct zfcp_adapter *adapter, u32 fsf_cmd, int req_flags,
  4262. mempool_t *pool, unsigned long *lock_flags,
  4263. struct zfcp_fsf_req **fsf_req_p)
  4264. {
  4265. volatile struct qdio_buffer_element *sbale;
  4266. struct zfcp_fsf_req *fsf_req = NULL;
  4267. int ret = 0;
  4268. struct zfcp_qdio_queue *req_queue = &adapter->request_queue;
  4269. /* allocate new FSF request */
  4270. fsf_req = zfcp_fsf_req_alloc(pool, req_flags);
  4271. if (unlikely(NULL == fsf_req)) {
  4272. ZFCP_LOG_DEBUG("error: Could not put an FSF request into"
  4273. "the outbound (send) queue.\n");
  4274. ret = -ENOMEM;
  4275. goto failed_fsf_req;
  4276. }
  4277. fsf_req->adapter = adapter;
  4278. fsf_req->fsf_command = fsf_cmd;
  4279. INIT_LIST_HEAD(&fsf_req->list);
  4280. init_timer(&fsf_req->timer);
  4281. /* initialize waitqueue which may be used to wait on
  4282. this request completion */
  4283. init_waitqueue_head(&fsf_req->completion_wq);
  4284. ret = zfcp_fsf_req_sbal_get(adapter, req_flags, lock_flags);
  4285. if (ret < 0)
  4286. goto failed_sbals;
  4287. /* this is serialized (we are holding req_queue-lock of adapter) */
  4288. if (adapter->req_no == 0)
  4289. adapter->req_no++;
  4290. fsf_req->req_id = adapter->req_no++;
  4291. zfcp_fsf_req_qtcb_init(fsf_req);
  4292. /*
  4293. * We hold queue_lock here. Check if QDIOUP is set and let request fail
  4294. * if it is not set (see also *_open_qdio and *_close_qdio).
  4295. */
  4296. if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status)) {
  4297. write_unlock_irqrestore(&req_queue->queue_lock, *lock_flags);
  4298. ret = -EIO;
  4299. goto failed_sbals;
  4300. }
  4301. if (fsf_req->qtcb) {
  4302. fsf_req->seq_no = adapter->fsf_req_seq_no;
  4303. fsf_req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
  4304. }
  4305. fsf_req->sbal_number = 1;
  4306. fsf_req->sbal_first = req_queue->free_index;
  4307. fsf_req->sbal_curr = req_queue->free_index;
  4308. fsf_req->sbale_curr = 1;
  4309. if (likely(req_flags & ZFCP_REQ_AUTO_CLEANUP)) {
  4310. fsf_req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  4311. }
  4312. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
  4313. /* setup common SBALE fields */
  4314. sbale[0].addr = (void *) fsf_req->req_id;
  4315. sbale[0].flags |= SBAL_FLAGS0_COMMAND;
  4316. if (likely(fsf_req->qtcb != NULL)) {
  4317. sbale[1].addr = (void *) fsf_req->qtcb;
  4318. sbale[1].length = sizeof(struct fsf_qtcb);
  4319. }
  4320. ZFCP_LOG_TRACE("got %i free BUFFERs starting at index %i\n",
  4321. fsf_req->sbal_number, fsf_req->sbal_first);
  4322. goto success;
  4323. failed_sbals:
  4324. /* dequeue new FSF request previously enqueued */
  4325. zfcp_fsf_req_free(fsf_req);
  4326. fsf_req = NULL;
  4327. failed_fsf_req:
  4328. write_lock_irqsave(&req_queue->queue_lock, *lock_flags);
  4329. success:
  4330. *fsf_req_p = fsf_req;
  4331. return ret;
  4332. }
  4333. /*
  4334. * function: zfcp_fsf_req_send
  4335. *
  4336. * purpose: start transfer of FSF request via QDIO
  4337. *
  4338. * returns: 0 - request transfer succesfully started
  4339. * !0 - start of request transfer failed
  4340. */
  4341. static int zfcp_fsf_req_send(struct zfcp_fsf_req *fsf_req)
  4342. {
  4343. struct zfcp_adapter *adapter;
  4344. struct zfcp_qdio_queue *req_queue;
  4345. volatile struct qdio_buffer_element *sbale;
  4346. int inc_seq_no;
  4347. int new_distance_from_int;
  4348. u64 dbg_tmp[2];
  4349. int retval = 0;
  4350. adapter = fsf_req->adapter;
  4351. req_queue = &adapter->request_queue,
  4352. /* FIXME(debug): remove it later */
  4353. sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_first, 0);
  4354. ZFCP_LOG_DEBUG("SBALE0 flags=0x%x\n", sbale[0].flags);
  4355. ZFCP_LOG_TRACE("HEX DUMP OF SBALE1 PAYLOAD:\n");
  4356. ZFCP_HEX_DUMP(ZFCP_LOG_LEVEL_TRACE, (char *) sbale[1].addr,
  4357. sbale[1].length);
  4358. /* put allocated FSF request into hash table */
  4359. spin_lock(&adapter->req_list_lock);
  4360. zfcp_reqlist_add(adapter, fsf_req);
  4361. spin_unlock(&adapter->req_list_lock);
  4362. inc_seq_no = (fsf_req->qtcb != NULL);
  4363. ZFCP_LOG_TRACE("request queue of adapter %s: "
  4364. "next free SBAL is %i, %i free SBALs\n",
  4365. zfcp_get_busid_by_adapter(adapter),
  4366. req_queue->free_index,
  4367. atomic_read(&req_queue->free_count));
  4368. ZFCP_LOG_DEBUG("calling do_QDIO adapter %s, flags=0x%x, queue_no=%i, "
  4369. "index_in_queue=%i, count=%i, buffers=%p\n",
  4370. zfcp_get_busid_by_adapter(adapter),
  4371. QDIO_FLAG_SYNC_OUTPUT,
  4372. 0, fsf_req->sbal_first, fsf_req->sbal_number,
  4373. &req_queue->buffer[fsf_req->sbal_first]);
  4374. /*
  4375. * adjust the number of free SBALs in request queue as well as
  4376. * position of first one
  4377. */
  4378. atomic_sub(fsf_req->sbal_number, &req_queue->free_count);
  4379. ZFCP_LOG_TRACE("free_count=%d\n", atomic_read(&req_queue->free_count));
  4380. req_queue->free_index += fsf_req->sbal_number; /* increase */
  4381. req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap if needed */
  4382. new_distance_from_int = zfcp_qdio_determine_pci(req_queue, fsf_req);
  4383. fsf_req->issued = get_clock();
  4384. retval = do_QDIO(adapter->ccw_device,
  4385. QDIO_FLAG_SYNC_OUTPUT,
  4386. 0, fsf_req->sbal_first, fsf_req->sbal_number, NULL);
  4387. dbg_tmp[0] = (unsigned long) sbale[0].addr;
  4388. dbg_tmp[1] = (u64) retval;
  4389. debug_event(adapter->erp_dbf, 4, (void *) dbg_tmp, 16);
  4390. if (unlikely(retval)) {
  4391. /* Queues are down..... */
  4392. retval = -EIO;
  4393. del_timer(&fsf_req->timer);
  4394. spin_lock(&adapter->req_list_lock);
  4395. zfcp_reqlist_remove(adapter, fsf_req);
  4396. spin_unlock(&adapter->req_list_lock);
  4397. /* undo changes in request queue made for this request */
  4398. zfcp_qdio_zero_sbals(req_queue->buffer,
  4399. fsf_req->sbal_first, fsf_req->sbal_number);
  4400. atomic_add(fsf_req->sbal_number, &req_queue->free_count);
  4401. req_queue->free_index -= fsf_req->sbal_number;
  4402. req_queue->free_index += QDIO_MAX_BUFFERS_PER_Q;
  4403. req_queue->free_index %= QDIO_MAX_BUFFERS_PER_Q; /* wrap */
  4404. zfcp_erp_adapter_reopen(adapter, 0);
  4405. } else {
  4406. req_queue->distance_from_int = new_distance_from_int;
  4407. /*
  4408. * increase FSF sequence counter -
  4409. * this must only be done for request successfully enqueued to
  4410. * QDIO this rejected requests may be cleaned up by calling
  4411. * routines resulting in missing sequence counter values
  4412. * otherwise,
  4413. */
  4414. /* Don't increase for unsolicited status */
  4415. if (inc_seq_no)
  4416. adapter->fsf_req_seq_no++;
  4417. /* count FSF requests pending */
  4418. atomic_inc(&adapter->reqs_active);
  4419. }
  4420. return retval;
  4421. }
  4422. #undef ZFCP_LOG_AREA