zfcp_fsf.c 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563
  1. /*
  2. * zfcp device driver
  3. *
  4. * Implementation of FSF commands.
  5. *
  6. * Copyright IBM Corporation 2002, 2009
  7. */
  8. #define KMSG_COMPONENT "zfcp"
  9. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  10. #include <linux/blktrace_api.h>
  11. #include <scsi/fc/fc_els.h>
  12. #include "zfcp_ext.h"
  13. #include "zfcp_fc.h"
  14. #include "zfcp_dbf.h"
  15. static void zfcp_fsf_request_timeout_handler(unsigned long data)
  16. {
  17. struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
  18. zfcp_erp_adapter_reopen(adapter, ZFCP_STATUS_COMMON_ERP_FAILED,
  19. "fsrth_1", NULL);
  20. }
  21. static void zfcp_fsf_start_timer(struct zfcp_fsf_req *fsf_req,
  22. unsigned long timeout)
  23. {
  24. fsf_req->timer.function = zfcp_fsf_request_timeout_handler;
  25. fsf_req->timer.data = (unsigned long) fsf_req->adapter;
  26. fsf_req->timer.expires = jiffies + timeout;
  27. add_timer(&fsf_req->timer);
  28. }
  29. static void zfcp_fsf_start_erp_timer(struct zfcp_fsf_req *fsf_req)
  30. {
  31. BUG_ON(!fsf_req->erp_action);
  32. fsf_req->timer.function = zfcp_erp_timeout_handler;
  33. fsf_req->timer.data = (unsigned long) fsf_req->erp_action;
  34. fsf_req->timer.expires = jiffies + 30 * HZ;
  35. add_timer(&fsf_req->timer);
  36. }
  37. /* association between FSF command and FSF QTCB type */
  38. static u32 fsf_qtcb_type[] = {
  39. [FSF_QTCB_FCP_CMND] = FSF_IO_COMMAND,
  40. [FSF_QTCB_ABORT_FCP_CMND] = FSF_SUPPORT_COMMAND,
  41. [FSF_QTCB_OPEN_PORT_WITH_DID] = FSF_SUPPORT_COMMAND,
  42. [FSF_QTCB_OPEN_LUN] = FSF_SUPPORT_COMMAND,
  43. [FSF_QTCB_CLOSE_LUN] = FSF_SUPPORT_COMMAND,
  44. [FSF_QTCB_CLOSE_PORT] = FSF_SUPPORT_COMMAND,
  45. [FSF_QTCB_CLOSE_PHYSICAL_PORT] = FSF_SUPPORT_COMMAND,
  46. [FSF_QTCB_SEND_ELS] = FSF_SUPPORT_COMMAND,
  47. [FSF_QTCB_SEND_GENERIC] = FSF_SUPPORT_COMMAND,
  48. [FSF_QTCB_EXCHANGE_CONFIG_DATA] = FSF_CONFIG_COMMAND,
  49. [FSF_QTCB_EXCHANGE_PORT_DATA] = FSF_PORT_COMMAND,
  50. [FSF_QTCB_DOWNLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND,
  51. [FSF_QTCB_UPLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND
  52. };
  53. static void zfcp_act_eval_err(struct zfcp_adapter *adapter, u32 table)
  54. {
  55. u16 subtable = table >> 16;
  56. u16 rule = table & 0xffff;
  57. const char *act_type[] = { "unknown", "OS", "WWPN", "DID", "LUN" };
  58. if (subtable && subtable < ARRAY_SIZE(act_type))
  59. dev_warn(&adapter->ccw_device->dev,
  60. "Access denied according to ACT rule type %s, "
  61. "rule %d\n", act_type[subtable], rule);
  62. }
  63. static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req,
  64. struct zfcp_port *port)
  65. {
  66. struct fsf_qtcb_header *header = &req->qtcb->header;
  67. dev_warn(&req->adapter->ccw_device->dev,
  68. "Access denied to port 0x%016Lx\n",
  69. (unsigned long long)port->wwpn);
  70. zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
  71. zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
  72. zfcp_erp_port_access_denied(port, "fspad_1", req);
  73. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  74. }
  75. static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req,
  76. struct zfcp_unit *unit)
  77. {
  78. struct fsf_qtcb_header *header = &req->qtcb->header;
  79. dev_warn(&req->adapter->ccw_device->dev,
  80. "Access denied to unit 0x%016Lx on port 0x%016Lx\n",
  81. (unsigned long long)unit->fcp_lun,
  82. (unsigned long long)unit->port->wwpn);
  83. zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
  84. zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
  85. zfcp_erp_unit_access_denied(unit, "fsuad_1", req);
  86. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  87. }
  88. static void zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req)
  89. {
  90. dev_err(&req->adapter->ccw_device->dev, "FCP device not "
  91. "operational because of an unsupported FC class\n");
  92. zfcp_erp_adapter_shutdown(req->adapter, 0, "fscns_1", req);
  93. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  94. }
  95. /**
  96. * zfcp_fsf_req_free - free memory used by fsf request
  97. * @fsf_req: pointer to struct zfcp_fsf_req
  98. */
  99. void zfcp_fsf_req_free(struct zfcp_fsf_req *req)
  100. {
  101. if (likely(req->pool)) {
  102. if (likely(req->qtcb))
  103. mempool_free(req->qtcb, req->adapter->pool.qtcb_pool);
  104. mempool_free(req, req->pool);
  105. return;
  106. }
  107. if (likely(req->qtcb))
  108. kmem_cache_free(zfcp_data.qtcb_cache, req->qtcb);
  109. kfree(req);
  110. }
  111. static void zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *req)
  112. {
  113. unsigned long flags;
  114. struct fsf_status_read_buffer *sr_buf = req->data;
  115. struct zfcp_adapter *adapter = req->adapter;
  116. struct zfcp_port *port;
  117. int d_id = sr_buf->d_id & ZFCP_DID_MASK;
  118. read_lock_irqsave(&adapter->port_list_lock, flags);
  119. list_for_each_entry(port, &adapter->port_list, list)
  120. if (port->d_id == d_id) {
  121. zfcp_erp_port_reopen(port, 0, "fssrpc1", req);
  122. break;
  123. }
  124. read_unlock_irqrestore(&adapter->port_list_lock, flags);
  125. }
  126. static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req, char *id,
  127. struct fsf_link_down_info *link_down)
  128. {
  129. struct zfcp_adapter *adapter = req->adapter;
  130. if (atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED)
  131. return;
  132. atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
  133. zfcp_scsi_schedule_rports_block(adapter);
  134. if (!link_down)
  135. goto out;
  136. switch (link_down->error_code) {
  137. case FSF_PSQ_LINK_NO_LIGHT:
  138. dev_warn(&req->adapter->ccw_device->dev,
  139. "There is no light signal from the local "
  140. "fibre channel cable\n");
  141. break;
  142. case FSF_PSQ_LINK_WRAP_PLUG:
  143. dev_warn(&req->adapter->ccw_device->dev,
  144. "There is a wrap plug instead of a fibre "
  145. "channel cable\n");
  146. break;
  147. case FSF_PSQ_LINK_NO_FCP:
  148. dev_warn(&req->adapter->ccw_device->dev,
  149. "The adjacent fibre channel node does not "
  150. "support FCP\n");
  151. break;
  152. case FSF_PSQ_LINK_FIRMWARE_UPDATE:
  153. dev_warn(&req->adapter->ccw_device->dev,
  154. "The FCP device is suspended because of a "
  155. "firmware update\n");
  156. break;
  157. case FSF_PSQ_LINK_INVALID_WWPN:
  158. dev_warn(&req->adapter->ccw_device->dev,
  159. "The FCP device detected a WWPN that is "
  160. "duplicate or not valid\n");
  161. break;
  162. case FSF_PSQ_LINK_NO_NPIV_SUPPORT:
  163. dev_warn(&req->adapter->ccw_device->dev,
  164. "The fibre channel fabric does not support NPIV\n");
  165. break;
  166. case FSF_PSQ_LINK_NO_FCP_RESOURCES:
  167. dev_warn(&req->adapter->ccw_device->dev,
  168. "The FCP adapter cannot support more NPIV ports\n");
  169. break;
  170. case FSF_PSQ_LINK_NO_FABRIC_RESOURCES:
  171. dev_warn(&req->adapter->ccw_device->dev,
  172. "The adjacent switch cannot support "
  173. "more NPIV ports\n");
  174. break;
  175. case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE:
  176. dev_warn(&req->adapter->ccw_device->dev,
  177. "The FCP adapter could not log in to the "
  178. "fibre channel fabric\n");
  179. break;
  180. case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED:
  181. dev_warn(&req->adapter->ccw_device->dev,
  182. "The WWPN assignment file on the FCP adapter "
  183. "has been damaged\n");
  184. break;
  185. case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED:
  186. dev_warn(&req->adapter->ccw_device->dev,
  187. "The mode table on the FCP adapter "
  188. "has been damaged\n");
  189. break;
  190. case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT:
  191. dev_warn(&req->adapter->ccw_device->dev,
  192. "All NPIV ports on the FCP adapter have "
  193. "been assigned\n");
  194. break;
  195. default:
  196. dev_warn(&req->adapter->ccw_device->dev,
  197. "The link between the FCP adapter and "
  198. "the FC fabric is down\n");
  199. }
  200. out:
  201. zfcp_erp_adapter_failed(adapter, id, req);
  202. }
  203. static void zfcp_fsf_status_read_link_down(struct zfcp_fsf_req *req)
  204. {
  205. struct fsf_status_read_buffer *sr_buf = req->data;
  206. struct fsf_link_down_info *ldi =
  207. (struct fsf_link_down_info *) &sr_buf->payload;
  208. switch (sr_buf->status_subtype) {
  209. case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
  210. zfcp_fsf_link_down_info_eval(req, "fssrld1", ldi);
  211. break;
  212. case FSF_STATUS_READ_SUB_FDISC_FAILED:
  213. zfcp_fsf_link_down_info_eval(req, "fssrld2", ldi);
  214. break;
  215. case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE:
  216. zfcp_fsf_link_down_info_eval(req, "fssrld3", NULL);
  217. };
  218. }
  219. static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req)
  220. {
  221. struct zfcp_adapter *adapter = req->adapter;
  222. struct fsf_status_read_buffer *sr_buf = req->data;
  223. if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
  224. zfcp_dbf_hba_fsf_unsol("dism", adapter->dbf, sr_buf);
  225. mempool_free(sr_buf, adapter->pool.status_read_data);
  226. zfcp_fsf_req_free(req);
  227. return;
  228. }
  229. zfcp_dbf_hba_fsf_unsol("read", adapter->dbf, sr_buf);
  230. switch (sr_buf->status_type) {
  231. case FSF_STATUS_READ_PORT_CLOSED:
  232. zfcp_fsf_status_read_port_closed(req);
  233. break;
  234. case FSF_STATUS_READ_INCOMING_ELS:
  235. zfcp_fc_incoming_els(req);
  236. break;
  237. case FSF_STATUS_READ_SENSE_DATA_AVAIL:
  238. break;
  239. case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
  240. dev_warn(&adapter->ccw_device->dev,
  241. "The error threshold for checksum statistics "
  242. "has been exceeded\n");
  243. zfcp_dbf_hba_berr(adapter->dbf, req);
  244. break;
  245. case FSF_STATUS_READ_LINK_DOWN:
  246. zfcp_fsf_status_read_link_down(req);
  247. break;
  248. case FSF_STATUS_READ_LINK_UP:
  249. dev_info(&adapter->ccw_device->dev,
  250. "The local link has been restored\n");
  251. /* All ports should be marked as ready to run again */
  252. zfcp_erp_modify_adapter_status(adapter, "fssrh_1", NULL,
  253. ZFCP_STATUS_COMMON_RUNNING,
  254. ZFCP_SET);
  255. zfcp_erp_adapter_reopen(adapter,
  256. ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
  257. ZFCP_STATUS_COMMON_ERP_FAILED,
  258. "fssrh_2", req);
  259. break;
  260. case FSF_STATUS_READ_NOTIFICATION_LOST:
  261. if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_ACT_UPDATED)
  262. zfcp_erp_adapter_access_changed(adapter, "fssrh_3",
  263. req);
  264. if (sr_buf->status_subtype & FSF_STATUS_READ_SUB_INCOMING_ELS)
  265. queue_work(adapter->work_queue, &adapter->scan_work);
  266. break;
  267. case FSF_STATUS_READ_CFDC_UPDATED:
  268. zfcp_erp_adapter_access_changed(adapter, "fssrh_4", req);
  269. break;
  270. case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
  271. adapter->adapter_features = sr_buf->payload.word[0];
  272. break;
  273. }
  274. mempool_free(sr_buf, adapter->pool.status_read_data);
  275. zfcp_fsf_req_free(req);
  276. atomic_inc(&adapter->stat_miss);
  277. queue_work(adapter->work_queue, &adapter->stat_work);
  278. }
  279. static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req)
  280. {
  281. switch (req->qtcb->header.fsf_status_qual.word[0]) {
  282. case FSF_SQ_FCP_RSP_AVAILABLE:
  283. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  284. case FSF_SQ_NO_RETRY_POSSIBLE:
  285. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  286. return;
  287. case FSF_SQ_COMMAND_ABORTED:
  288. req->status |= ZFCP_STATUS_FSFREQ_ABORTED;
  289. break;
  290. case FSF_SQ_NO_RECOM:
  291. dev_err(&req->adapter->ccw_device->dev,
  292. "The FCP adapter reported a problem "
  293. "that cannot be recovered\n");
  294. zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfsqe1", req);
  295. break;
  296. }
  297. /* all non-return stats set FSFREQ_ERROR*/
  298. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  299. }
  300. static void zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *req)
  301. {
  302. if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
  303. return;
  304. switch (req->qtcb->header.fsf_status) {
  305. case FSF_UNKNOWN_COMMAND:
  306. dev_err(&req->adapter->ccw_device->dev,
  307. "The FCP adapter does not recognize the command 0x%x\n",
  308. req->qtcb->header.fsf_command);
  309. zfcp_erp_adapter_shutdown(req->adapter, 0, "fsfse_1", req);
  310. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  311. break;
  312. case FSF_ADAPTER_STATUS_AVAILABLE:
  313. zfcp_fsf_fsfstatus_qual_eval(req);
  314. break;
  315. }
  316. }
  317. static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
  318. {
  319. struct zfcp_adapter *adapter = req->adapter;
  320. struct fsf_qtcb *qtcb = req->qtcb;
  321. union fsf_prot_status_qual *psq = &qtcb->prefix.prot_status_qual;
  322. zfcp_dbf_hba_fsf_response(req);
  323. if (req->status & ZFCP_STATUS_FSFREQ_DISMISSED) {
  324. req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  325. ZFCP_STATUS_FSFREQ_RETRY; /* only for SCSI cmnds. */
  326. return;
  327. }
  328. switch (qtcb->prefix.prot_status) {
  329. case FSF_PROT_GOOD:
  330. case FSF_PROT_FSF_STATUS_PRESENTED:
  331. return;
  332. case FSF_PROT_QTCB_VERSION_ERROR:
  333. dev_err(&adapter->ccw_device->dev,
  334. "QTCB version 0x%x not supported by FCP adapter "
  335. "(0x%x to 0x%x)\n", FSF_QTCB_CURRENT_VERSION,
  336. psq->word[0], psq->word[1]);
  337. zfcp_erp_adapter_shutdown(adapter, 0, "fspse_1", req);
  338. break;
  339. case FSF_PROT_ERROR_STATE:
  340. case FSF_PROT_SEQ_NUMB_ERROR:
  341. zfcp_erp_adapter_reopen(adapter, 0, "fspse_2", req);
  342. req->status |= ZFCP_STATUS_FSFREQ_RETRY;
  343. break;
  344. case FSF_PROT_UNSUPP_QTCB_TYPE:
  345. dev_err(&adapter->ccw_device->dev,
  346. "The QTCB type is not supported by the FCP adapter\n");
  347. zfcp_erp_adapter_shutdown(adapter, 0, "fspse_3", req);
  348. break;
  349. case FSF_PROT_HOST_CONNECTION_INITIALIZING:
  350. atomic_set_mask(ZFCP_STATUS_ADAPTER_HOST_CON_INIT,
  351. &adapter->status);
  352. break;
  353. case FSF_PROT_DUPLICATE_REQUEST_ID:
  354. dev_err(&adapter->ccw_device->dev,
  355. "0x%Lx is an ambiguous request identifier\n",
  356. (unsigned long long)qtcb->bottom.support.req_handle);
  357. zfcp_erp_adapter_shutdown(adapter, 0, "fspse_4", req);
  358. break;
  359. case FSF_PROT_LINK_DOWN:
  360. zfcp_fsf_link_down_info_eval(req, "fspse_5",
  361. &psq->link_down_info);
  362. /* FIXME: reopening adapter now? better wait for link up */
  363. zfcp_erp_adapter_reopen(adapter, 0, "fspse_6", req);
  364. break;
  365. case FSF_PROT_REEST_QUEUE:
  366. /* All ports should be marked as ready to run again */
  367. zfcp_erp_modify_adapter_status(adapter, "fspse_7", NULL,
  368. ZFCP_STATUS_COMMON_RUNNING,
  369. ZFCP_SET);
  370. zfcp_erp_adapter_reopen(adapter,
  371. ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED |
  372. ZFCP_STATUS_COMMON_ERP_FAILED,
  373. "fspse_8", req);
  374. break;
  375. default:
  376. dev_err(&adapter->ccw_device->dev,
  377. "0x%x is not a valid transfer protocol status\n",
  378. qtcb->prefix.prot_status);
  379. zfcp_erp_adapter_shutdown(adapter, 0, "fspse_9", req);
  380. }
  381. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  382. }
  383. /**
  384. * zfcp_fsf_req_complete - process completion of a FSF request
  385. * @fsf_req: The FSF request that has been completed.
  386. *
  387. * When a request has been completed either from the FCP adapter,
  388. * or it has been dismissed due to a queue shutdown, this function
  389. * is called to process the completion status and trigger further
  390. * events related to the FSF request.
  391. */
  392. static void zfcp_fsf_req_complete(struct zfcp_fsf_req *req)
  393. {
  394. if (unlikely(req->fsf_command == FSF_QTCB_UNSOLICITED_STATUS)) {
  395. zfcp_fsf_status_read_handler(req);
  396. return;
  397. }
  398. del_timer(&req->timer);
  399. zfcp_fsf_protstatus_eval(req);
  400. zfcp_fsf_fsfstatus_eval(req);
  401. req->handler(req);
  402. if (req->erp_action)
  403. zfcp_erp_notify(req->erp_action, 0);
  404. if (likely(req->status & ZFCP_STATUS_FSFREQ_CLEANUP))
  405. zfcp_fsf_req_free(req);
  406. else
  407. complete(&req->completion);
  408. }
  409. /**
  410. * zfcp_fsf_req_dismiss_all - dismiss all fsf requests
  411. * @adapter: pointer to struct zfcp_adapter
  412. *
  413. * Never ever call this without shutting down the adapter first.
  414. * Otherwise the adapter would continue using and corrupting s390 storage.
  415. * Included BUG_ON() call to ensure this is done.
  416. * ERP is supposed to be the only user of this function.
  417. */
  418. void zfcp_fsf_req_dismiss_all(struct zfcp_adapter *adapter)
  419. {
  420. struct zfcp_fsf_req *req, *tmp;
  421. unsigned long flags;
  422. LIST_HEAD(remove_queue);
  423. unsigned int i;
  424. BUG_ON(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP);
  425. spin_lock_irqsave(&adapter->req_list_lock, flags);
  426. for (i = 0; i < REQUEST_LIST_SIZE; i++)
  427. list_splice_init(&adapter->req_list[i], &remove_queue);
  428. spin_unlock_irqrestore(&adapter->req_list_lock, flags);
  429. list_for_each_entry_safe(req, tmp, &remove_queue, list) {
  430. list_del(&req->list);
  431. req->status |= ZFCP_STATUS_FSFREQ_DISMISSED;
  432. zfcp_fsf_req_complete(req);
  433. }
  434. }
  435. static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
  436. {
  437. struct fsf_qtcb_bottom_config *bottom = &req->qtcb->bottom.config;
  438. struct zfcp_adapter *adapter = req->adapter;
  439. struct Scsi_Host *shost = adapter->scsi_host;
  440. struct fc_els_flogi *nsp, *plogi;
  441. /* adjust pointers for missing command code */
  442. nsp = (struct fc_els_flogi *) ((u8 *)&bottom->nport_serv_param
  443. - sizeof(u32));
  444. plogi = (struct fc_els_flogi *) ((u8 *)&bottom->plogi_payload
  445. - sizeof(u32));
  446. if (req->data)
  447. memcpy(req->data, bottom, sizeof(*bottom));
  448. fc_host_port_name(shost) = nsp->fl_wwpn;
  449. fc_host_node_name(shost) = nsp->fl_wwnn;
  450. fc_host_port_id(shost) = bottom->s_id & ZFCP_DID_MASK;
  451. fc_host_speed(shost) = bottom->fc_link_speed;
  452. fc_host_supported_classes(shost) = FC_COS_CLASS2 | FC_COS_CLASS3;
  453. adapter->hydra_version = bottom->adapter_type;
  454. adapter->timer_ticks = bottom->timer_interval;
  455. if (fc_host_permanent_port_name(shost) == -1)
  456. fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
  457. switch (bottom->fc_topology) {
  458. case FSF_TOPO_P2P:
  459. adapter->peer_d_id = bottom->peer_d_id & ZFCP_DID_MASK;
  460. adapter->peer_wwpn = plogi->fl_wwpn;
  461. adapter->peer_wwnn = plogi->fl_wwnn;
  462. fc_host_port_type(shost) = FC_PORTTYPE_PTP;
  463. break;
  464. case FSF_TOPO_FABRIC:
  465. fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
  466. break;
  467. case FSF_TOPO_AL:
  468. fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
  469. /* fall through */
  470. default:
  471. dev_err(&adapter->ccw_device->dev,
  472. "Unknown or unsupported arbitrated loop "
  473. "fibre channel topology detected\n");
  474. zfcp_erp_adapter_shutdown(adapter, 0, "fsece_1", req);
  475. return -EIO;
  476. }
  477. return 0;
  478. }
  479. static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
  480. {
  481. struct zfcp_adapter *adapter = req->adapter;
  482. struct fsf_qtcb *qtcb = req->qtcb;
  483. struct fsf_qtcb_bottom_config *bottom = &qtcb->bottom.config;
  484. struct Scsi_Host *shost = adapter->scsi_host;
  485. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  486. return;
  487. adapter->fsf_lic_version = bottom->lic_version;
  488. adapter->adapter_features = bottom->adapter_features;
  489. adapter->connection_features = bottom->connection_features;
  490. adapter->peer_wwpn = 0;
  491. adapter->peer_wwnn = 0;
  492. adapter->peer_d_id = 0;
  493. switch (qtcb->header.fsf_status) {
  494. case FSF_GOOD:
  495. if (zfcp_fsf_exchange_config_evaluate(req))
  496. return;
  497. if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
  498. dev_err(&adapter->ccw_device->dev,
  499. "FCP adapter maximum QTCB size (%d bytes) "
  500. "is too small\n",
  501. bottom->max_qtcb_size);
  502. zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh1", req);
  503. return;
  504. }
  505. atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
  506. &adapter->status);
  507. break;
  508. case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
  509. fc_host_node_name(shost) = 0;
  510. fc_host_port_name(shost) = 0;
  511. fc_host_port_id(shost) = 0;
  512. fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN;
  513. fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
  514. adapter->hydra_version = 0;
  515. atomic_set_mask(ZFCP_STATUS_ADAPTER_XCONFIG_OK,
  516. &adapter->status);
  517. zfcp_fsf_link_down_info_eval(req, "fsecdh2",
  518. &qtcb->header.fsf_status_qual.link_down_info);
  519. break;
  520. default:
  521. zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh3", req);
  522. return;
  523. }
  524. if (adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT) {
  525. adapter->hardware_version = bottom->hardware_version;
  526. memcpy(fc_host_serial_number(shost), bottom->serial_number,
  527. min(FC_SERIAL_NUMBER_SIZE, 17));
  528. EBCASC(fc_host_serial_number(shost),
  529. min(FC_SERIAL_NUMBER_SIZE, 17));
  530. }
  531. if (FSF_QTCB_CURRENT_VERSION < bottom->low_qtcb_version) {
  532. dev_err(&adapter->ccw_device->dev,
  533. "The FCP adapter only supports newer "
  534. "control block versions\n");
  535. zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh4", req);
  536. return;
  537. }
  538. if (FSF_QTCB_CURRENT_VERSION > bottom->high_qtcb_version) {
  539. dev_err(&adapter->ccw_device->dev,
  540. "The FCP adapter only supports older "
  541. "control block versions\n");
  542. zfcp_erp_adapter_shutdown(adapter, 0, "fsecdh5", req);
  543. }
  544. }
  545. static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req)
  546. {
  547. struct zfcp_adapter *adapter = req->adapter;
  548. struct fsf_qtcb_bottom_port *bottom = &req->qtcb->bottom.port;
  549. struct Scsi_Host *shost = adapter->scsi_host;
  550. if (req->data)
  551. memcpy(req->data, bottom, sizeof(*bottom));
  552. if (adapter->connection_features & FSF_FEATURE_NPIV_MODE) {
  553. fc_host_permanent_port_name(shost) = bottom->wwpn;
  554. fc_host_port_type(shost) = FC_PORTTYPE_NPIV;
  555. } else
  556. fc_host_permanent_port_name(shost) = fc_host_port_name(shost);
  557. fc_host_maxframe_size(shost) = bottom->maximum_frame_size;
  558. fc_host_supported_speeds(shost) = bottom->supported_speed;
  559. }
  560. static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
  561. {
  562. struct fsf_qtcb *qtcb = req->qtcb;
  563. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  564. return;
  565. switch (qtcb->header.fsf_status) {
  566. case FSF_GOOD:
  567. zfcp_fsf_exchange_port_evaluate(req);
  568. break;
  569. case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
  570. zfcp_fsf_exchange_port_evaluate(req);
  571. zfcp_fsf_link_down_info_eval(req, "fsepdh1",
  572. &qtcb->header.fsf_status_qual.link_down_info);
  573. break;
  574. }
  575. }
  576. static int zfcp_fsf_sbal_check(struct zfcp_qdio *qdio)
  577. {
  578. struct zfcp_qdio_queue *req_q = &qdio->req_q;
  579. spin_lock_bh(&qdio->req_q_lock);
  580. if (atomic_read(&req_q->count))
  581. return 1;
  582. spin_unlock_bh(&qdio->req_q_lock);
  583. return 0;
  584. }
  585. static int zfcp_fsf_req_sbal_get(struct zfcp_qdio *qdio)
  586. {
  587. struct zfcp_adapter *adapter = qdio->adapter;
  588. long ret;
  589. spin_unlock_bh(&qdio->req_q_lock);
  590. ret = wait_event_interruptible_timeout(qdio->req_q_wq,
  591. zfcp_fsf_sbal_check(qdio), 5 * HZ);
  592. if (ret > 0)
  593. return 0;
  594. if (!ret) {
  595. atomic_inc(&qdio->req_q_full);
  596. /* assume hanging outbound queue, try queue recovery */
  597. zfcp_erp_adapter_reopen(adapter, 0, "fsrsg_1", NULL);
  598. }
  599. spin_lock_bh(&qdio->req_q_lock);
  600. return -EIO;
  601. }
  602. static struct zfcp_fsf_req *zfcp_fsf_alloc(mempool_t *pool)
  603. {
  604. struct zfcp_fsf_req *req;
  605. if (likely(pool))
  606. req = mempool_alloc(pool, GFP_ATOMIC);
  607. else
  608. req = kmalloc(sizeof(*req), GFP_ATOMIC);
  609. if (unlikely(!req))
  610. return NULL;
  611. memset(req, 0, sizeof(*req));
  612. req->pool = pool;
  613. return req;
  614. }
  615. static struct fsf_qtcb *zfcp_qtcb_alloc(mempool_t *pool)
  616. {
  617. struct fsf_qtcb *qtcb;
  618. if (likely(pool))
  619. qtcb = mempool_alloc(pool, GFP_ATOMIC);
  620. else
  621. qtcb = kmem_cache_alloc(zfcp_data.qtcb_cache, GFP_ATOMIC);
  622. if (unlikely(!qtcb))
  623. return NULL;
  624. memset(qtcb, 0, sizeof(*qtcb));
  625. return qtcb;
  626. }
  627. static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_qdio *qdio,
  628. u32 fsf_cmd, mempool_t *pool)
  629. {
  630. struct qdio_buffer_element *sbale;
  631. struct zfcp_qdio_queue *req_q = &qdio->req_q;
  632. struct zfcp_adapter *adapter = qdio->adapter;
  633. struct zfcp_fsf_req *req = zfcp_fsf_alloc(pool);
  634. if (unlikely(!req))
  635. return ERR_PTR(-ENOMEM);
  636. if (adapter->req_no == 0)
  637. adapter->req_no++;
  638. INIT_LIST_HEAD(&req->list);
  639. init_timer(&req->timer);
  640. init_completion(&req->completion);
  641. req->adapter = adapter;
  642. req->fsf_command = fsf_cmd;
  643. req->req_id = adapter->req_no;
  644. req->queue_req.sbal_number = 1;
  645. req->queue_req.sbal_first = req_q->first;
  646. req->queue_req.sbal_last = req_q->first;
  647. req->queue_req.sbale_curr = 1;
  648. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  649. sbale[0].addr = (void *) req->req_id;
  650. sbale[0].flags |= SBAL_FLAGS0_COMMAND;
  651. if (likely(fsf_cmd != FSF_QTCB_UNSOLICITED_STATUS)) {
  652. if (likely(pool))
  653. req->qtcb = zfcp_qtcb_alloc(adapter->pool.qtcb_pool);
  654. else
  655. req->qtcb = zfcp_qtcb_alloc(NULL);
  656. if (unlikely(!req->qtcb)) {
  657. zfcp_fsf_req_free(req);
  658. return ERR_PTR(-ENOMEM);
  659. }
  660. req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
  661. req->qtcb->prefix.req_id = req->req_id;
  662. req->qtcb->prefix.ulp_info = 26;
  663. req->qtcb->prefix.qtcb_type = fsf_qtcb_type[req->fsf_command];
  664. req->qtcb->prefix.qtcb_version = FSF_QTCB_CURRENT_VERSION;
  665. req->qtcb->header.req_handle = req->req_id;
  666. req->qtcb->header.fsf_command = req->fsf_command;
  667. req->seq_no = adapter->fsf_req_seq_no;
  668. req->qtcb->prefix.req_seq_no = adapter->fsf_req_seq_no;
  669. sbale[1].addr = (void *) req->qtcb;
  670. sbale[1].length = sizeof(struct fsf_qtcb);
  671. }
  672. if (!(atomic_read(&adapter->status) & ZFCP_STATUS_ADAPTER_QDIOUP)) {
  673. zfcp_fsf_req_free(req);
  674. return ERR_PTR(-EIO);
  675. }
  676. return req;
  677. }
  678. static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
  679. {
  680. struct zfcp_adapter *adapter = req->adapter;
  681. struct zfcp_qdio *qdio = adapter->qdio;
  682. unsigned long flags;
  683. int idx;
  684. int with_qtcb = (req->qtcb != NULL);
  685. /* put allocated FSF request into hash table */
  686. spin_lock_irqsave(&adapter->req_list_lock, flags);
  687. idx = zfcp_reqlist_hash(req->req_id);
  688. list_add_tail(&req->list, &adapter->req_list[idx]);
  689. spin_unlock_irqrestore(&adapter->req_list_lock, flags);
  690. req->queue_req.qdio_outb_usage = atomic_read(&qdio->req_q.count);
  691. req->issued = get_clock();
  692. if (zfcp_qdio_send(qdio, &req->queue_req)) {
  693. del_timer(&req->timer);
  694. spin_lock_irqsave(&adapter->req_list_lock, flags);
  695. /* lookup request again, list might have changed */
  696. if (zfcp_reqlist_find_safe(adapter, req))
  697. zfcp_reqlist_remove(adapter, req);
  698. spin_unlock_irqrestore(&adapter->req_list_lock, flags);
  699. zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1", req);
  700. return -EIO;
  701. }
  702. /* Don't increase for unsolicited status */
  703. if (with_qtcb)
  704. adapter->fsf_req_seq_no++;
  705. adapter->req_no++;
  706. return 0;
  707. }
  708. /**
  709. * zfcp_fsf_status_read - send status read request
  710. * @adapter: pointer to struct zfcp_adapter
  711. * @req_flags: request flags
  712. * Returns: 0 on success, ERROR otherwise
  713. */
  714. int zfcp_fsf_status_read(struct zfcp_qdio *qdio)
  715. {
  716. struct zfcp_adapter *adapter = qdio->adapter;
  717. struct zfcp_fsf_req *req;
  718. struct fsf_status_read_buffer *sr_buf;
  719. struct qdio_buffer_element *sbale;
  720. int retval = -EIO;
  721. spin_lock_bh(&qdio->req_q_lock);
  722. if (zfcp_fsf_req_sbal_get(qdio))
  723. goto out;
  724. req = zfcp_fsf_req_create(qdio, FSF_QTCB_UNSOLICITED_STATUS,
  725. adapter->pool.status_read_req);
  726. if (IS_ERR(req)) {
  727. retval = PTR_ERR(req);
  728. goto out;
  729. }
  730. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  731. sbale[2].flags |= SBAL_FLAGS_LAST_ENTRY;
  732. req->queue_req.sbale_curr = 2;
  733. sr_buf = mempool_alloc(adapter->pool.status_read_data, GFP_ATOMIC);
  734. if (!sr_buf) {
  735. retval = -ENOMEM;
  736. goto failed_buf;
  737. }
  738. memset(sr_buf, 0, sizeof(*sr_buf));
  739. req->data = sr_buf;
  740. sbale = zfcp_qdio_sbale_curr(qdio, &req->queue_req);
  741. sbale->addr = (void *) sr_buf;
  742. sbale->length = sizeof(*sr_buf);
  743. retval = zfcp_fsf_req_send(req);
  744. if (retval)
  745. goto failed_req_send;
  746. goto out;
  747. failed_req_send:
  748. mempool_free(sr_buf, adapter->pool.status_read_data);
  749. failed_buf:
  750. zfcp_fsf_req_free(req);
  751. zfcp_dbf_hba_fsf_unsol("fail", adapter->dbf, NULL);
  752. out:
  753. spin_unlock_bh(&qdio->req_q_lock);
  754. return retval;
  755. }
  756. static void zfcp_fsf_abort_fcp_command_handler(struct zfcp_fsf_req *req)
  757. {
  758. struct zfcp_unit *unit = req->data;
  759. union fsf_status_qual *fsq = &req->qtcb->header.fsf_status_qual;
  760. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  761. return;
  762. switch (req->qtcb->header.fsf_status) {
  763. case FSF_PORT_HANDLE_NOT_VALID:
  764. if (fsq->word[0] == fsq->word[1]) {
  765. zfcp_erp_adapter_reopen(unit->port->adapter, 0,
  766. "fsafch1", req);
  767. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  768. }
  769. break;
  770. case FSF_LUN_HANDLE_NOT_VALID:
  771. if (fsq->word[0] == fsq->word[1]) {
  772. zfcp_erp_port_reopen(unit->port, 0, "fsafch2", req);
  773. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  774. }
  775. break;
  776. case FSF_FCP_COMMAND_DOES_NOT_EXIST:
  777. req->status |= ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED;
  778. break;
  779. case FSF_PORT_BOXED:
  780. zfcp_erp_port_boxed(unit->port, "fsafch3", req);
  781. req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  782. ZFCP_STATUS_FSFREQ_RETRY;
  783. break;
  784. case FSF_LUN_BOXED:
  785. zfcp_erp_unit_boxed(unit, "fsafch4", req);
  786. req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  787. ZFCP_STATUS_FSFREQ_RETRY;
  788. break;
  789. case FSF_ADAPTER_STATUS_AVAILABLE:
  790. switch (fsq->word[0]) {
  791. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  792. zfcp_fc_test_link(unit->port);
  793. /* fall through */
  794. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  795. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  796. break;
  797. }
  798. break;
  799. case FSF_GOOD:
  800. req->status |= ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED;
  801. break;
  802. }
  803. }
  804. /**
  805. * zfcp_fsf_abort_fcp_command - abort running SCSI command
  806. * @old_req_id: unsigned long
  807. * @unit: pointer to struct zfcp_unit
  808. * Returns: pointer to struct zfcp_fsf_req
  809. */
  810. struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
  811. struct zfcp_unit *unit)
  812. {
  813. struct qdio_buffer_element *sbale;
  814. struct zfcp_fsf_req *req = NULL;
  815. struct zfcp_qdio *qdio = unit->port->adapter->qdio;
  816. spin_lock_bh(&qdio->req_q_lock);
  817. if (zfcp_fsf_req_sbal_get(qdio))
  818. goto out;
  819. req = zfcp_fsf_req_create(qdio, FSF_QTCB_ABORT_FCP_CMND,
  820. qdio->adapter->pool.scsi_abort);
  821. if (IS_ERR(req)) {
  822. req = NULL;
  823. goto out;
  824. }
  825. if (unlikely(!(atomic_read(&unit->status) &
  826. ZFCP_STATUS_COMMON_UNBLOCKED)))
  827. goto out_error_free;
  828. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  829. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  830. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  831. req->data = unit;
  832. req->handler = zfcp_fsf_abort_fcp_command_handler;
  833. req->qtcb->header.lun_handle = unit->handle;
  834. req->qtcb->header.port_handle = unit->port->handle;
  835. req->qtcb->bottom.support.req_handle = (u64) old_req_id;
  836. zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT);
  837. if (!zfcp_fsf_req_send(req))
  838. goto out;
  839. out_error_free:
  840. zfcp_fsf_req_free(req);
  841. req = NULL;
  842. out:
  843. spin_unlock_bh(&qdio->req_q_lock);
  844. return req;
  845. }
  846. static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
  847. {
  848. struct zfcp_adapter *adapter = req->adapter;
  849. struct zfcp_send_ct *send_ct = req->data;
  850. struct fsf_qtcb_header *header = &req->qtcb->header;
  851. send_ct->status = -EINVAL;
  852. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  853. goto skip_fsfstatus;
  854. switch (header->fsf_status) {
  855. case FSF_GOOD:
  856. zfcp_dbf_san_ct_response(req);
  857. send_ct->status = 0;
  858. break;
  859. case FSF_SERVICE_CLASS_NOT_SUPPORTED:
  860. zfcp_fsf_class_not_supp(req);
  861. break;
  862. case FSF_ADAPTER_STATUS_AVAILABLE:
  863. switch (header->fsf_status_qual.word[0]){
  864. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  865. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  866. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  867. break;
  868. }
  869. break;
  870. case FSF_ACCESS_DENIED:
  871. break;
  872. case FSF_PORT_BOXED:
  873. req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  874. ZFCP_STATUS_FSFREQ_RETRY;
  875. break;
  876. case FSF_PORT_HANDLE_NOT_VALID:
  877. zfcp_erp_adapter_reopen(adapter, 0, "fsscth1", req);
  878. /* fall through */
  879. case FSF_GENERIC_COMMAND_REJECTED:
  880. case FSF_PAYLOAD_SIZE_MISMATCH:
  881. case FSF_REQUEST_SIZE_TOO_LARGE:
  882. case FSF_RESPONSE_SIZE_TOO_LARGE:
  883. case FSF_SBAL_MISMATCH:
  884. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  885. break;
  886. }
  887. skip_fsfstatus:
  888. if (send_ct->handler)
  889. send_ct->handler(send_ct->handler_data);
  890. }
  891. static void zfcp_fsf_setup_ct_els_unchained(struct qdio_buffer_element *sbale,
  892. struct scatterlist *sg_req,
  893. struct scatterlist *sg_resp)
  894. {
  895. sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
  896. sbale[2].addr = sg_virt(sg_req);
  897. sbale[2].length = sg_req->length;
  898. sbale[3].addr = sg_virt(sg_resp);
  899. sbale[3].length = sg_resp->length;
  900. sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
  901. }
  902. static int zfcp_fsf_one_sbal(struct scatterlist *sg)
  903. {
  904. return sg_is_last(sg) && sg->length <= PAGE_SIZE;
  905. }
  906. static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
  907. struct scatterlist *sg_req,
  908. struct scatterlist *sg_resp,
  909. int max_sbals)
  910. {
  911. struct zfcp_adapter *adapter = req->adapter;
  912. struct qdio_buffer_element *sbale = zfcp_qdio_sbale_req(adapter->qdio,
  913. &req->queue_req);
  914. u32 feat = adapter->adapter_features;
  915. int bytes;
  916. if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) {
  917. if (!zfcp_fsf_one_sbal(sg_req) || !zfcp_fsf_one_sbal(sg_resp))
  918. return -EOPNOTSUPP;
  919. zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp);
  920. return 0;
  921. }
  922. /* use single, unchained SBAL if it can hold the request */
  923. if (zfcp_fsf_one_sbal(sg_req) && zfcp_fsf_one_sbal(sg_resp)) {
  924. zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp);
  925. return 0;
  926. }
  927. bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->queue_req,
  928. SBAL_FLAGS0_TYPE_WRITE_READ,
  929. sg_req, max_sbals);
  930. if (bytes <= 0)
  931. return -EIO;
  932. req->qtcb->bottom.support.req_buf_length = bytes;
  933. req->queue_req.sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
  934. bytes = zfcp_qdio_sbals_from_sg(adapter->qdio, &req->queue_req,
  935. SBAL_FLAGS0_TYPE_WRITE_READ,
  936. sg_resp, max_sbals);
  937. req->qtcb->bottom.support.resp_buf_length = bytes;
  938. if (bytes <= 0)
  939. return -EIO;
  940. return 0;
  941. }
  942. static int zfcp_fsf_setup_ct_els(struct zfcp_fsf_req *req,
  943. struct scatterlist *sg_req,
  944. struct scatterlist *sg_resp,
  945. int max_sbals)
  946. {
  947. int ret;
  948. unsigned int fcp_chan_timeout;
  949. ret = zfcp_fsf_setup_ct_els_sbals(req, sg_req, sg_resp, max_sbals);
  950. if (ret)
  951. return ret;
  952. /* common settings for ct/gs and els requests */
  953. fcp_chan_timeout = 2 * FC_DEF_R_A_TOV / 1000;
  954. req->qtcb->bottom.support.service_class = FSF_CLASS_3;
  955. req->qtcb->bottom.support.timeout = fcp_chan_timeout;
  956. zfcp_fsf_start_timer(req, (fcp_chan_timeout + 10) * HZ);
  957. return 0;
  958. }
  959. /**
  960. * zfcp_fsf_send_ct - initiate a Generic Service request (FC-GS)
  961. * @ct: pointer to struct zfcp_send_ct with data for request
  962. * @pool: if non-null this mempool is used to allocate struct zfcp_fsf_req
  963. */
  964. int zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool)
  965. {
  966. struct zfcp_wka_port *wka_port = ct->wka_port;
  967. struct zfcp_qdio *qdio = wka_port->adapter->qdio;
  968. struct zfcp_fsf_req *req;
  969. int ret = -EIO;
  970. spin_lock_bh(&qdio->req_q_lock);
  971. if (zfcp_fsf_req_sbal_get(qdio))
  972. goto out;
  973. req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_GENERIC, pool);
  974. if (IS_ERR(req)) {
  975. ret = PTR_ERR(req);
  976. goto out;
  977. }
  978. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  979. ret = zfcp_fsf_setup_ct_els(req, ct->req, ct->resp,
  980. FSF_MAX_SBALS_PER_REQ);
  981. if (ret)
  982. goto failed_send;
  983. req->handler = zfcp_fsf_send_ct_handler;
  984. req->qtcb->header.port_handle = wka_port->handle;
  985. req->data = ct;
  986. zfcp_dbf_san_ct_request(req);
  987. ret = zfcp_fsf_req_send(req);
  988. if (ret)
  989. goto failed_send;
  990. goto out;
  991. failed_send:
  992. zfcp_fsf_req_free(req);
  993. out:
  994. spin_unlock_bh(&qdio->req_q_lock);
  995. return ret;
  996. }
  997. static void zfcp_fsf_send_els_handler(struct zfcp_fsf_req *req)
  998. {
  999. struct zfcp_send_els *send_els = req->data;
  1000. struct zfcp_port *port = send_els->port;
  1001. struct fsf_qtcb_header *header = &req->qtcb->header;
  1002. send_els->status = -EINVAL;
  1003. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1004. goto skip_fsfstatus;
  1005. switch (header->fsf_status) {
  1006. case FSF_GOOD:
  1007. zfcp_dbf_san_els_response(req);
  1008. send_els->status = 0;
  1009. break;
  1010. case FSF_SERVICE_CLASS_NOT_SUPPORTED:
  1011. zfcp_fsf_class_not_supp(req);
  1012. break;
  1013. case FSF_ADAPTER_STATUS_AVAILABLE:
  1014. switch (header->fsf_status_qual.word[0]){
  1015. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1016. if (port && (send_els->ls_code != ELS_ADISC))
  1017. zfcp_fc_test_link(port);
  1018. /*fall through */
  1019. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1020. case FSF_SQ_RETRY_IF_POSSIBLE:
  1021. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1022. break;
  1023. }
  1024. break;
  1025. case FSF_ELS_COMMAND_REJECTED:
  1026. case FSF_PAYLOAD_SIZE_MISMATCH:
  1027. case FSF_REQUEST_SIZE_TOO_LARGE:
  1028. case FSF_RESPONSE_SIZE_TOO_LARGE:
  1029. break;
  1030. case FSF_ACCESS_DENIED:
  1031. if (port)
  1032. zfcp_fsf_access_denied_port(req, port);
  1033. break;
  1034. case FSF_SBAL_MISMATCH:
  1035. /* should never occure, avoided in zfcp_fsf_send_els */
  1036. /* fall through */
  1037. default:
  1038. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1039. break;
  1040. }
  1041. skip_fsfstatus:
  1042. if (send_els->handler)
  1043. send_els->handler(send_els->handler_data);
  1044. }
  1045. /**
  1046. * zfcp_fsf_send_els - initiate an ELS command (FC-FS)
  1047. * @els: pointer to struct zfcp_send_els with data for the command
  1048. */
  1049. int zfcp_fsf_send_els(struct zfcp_send_els *els)
  1050. {
  1051. struct zfcp_fsf_req *req;
  1052. struct zfcp_qdio *qdio = els->adapter->qdio;
  1053. int ret = -EIO;
  1054. spin_lock_bh(&qdio->req_q_lock);
  1055. if (zfcp_fsf_req_sbal_get(qdio))
  1056. goto out;
  1057. req = zfcp_fsf_req_create(qdio, FSF_QTCB_SEND_ELS, NULL);
  1058. if (IS_ERR(req)) {
  1059. ret = PTR_ERR(req);
  1060. goto out;
  1061. }
  1062. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1063. ret = zfcp_fsf_setup_ct_els(req, els->req, els->resp, 2);
  1064. if (ret)
  1065. goto failed_send;
  1066. req->qtcb->bottom.support.d_id = els->d_id;
  1067. req->handler = zfcp_fsf_send_els_handler;
  1068. req->data = els;
  1069. zfcp_dbf_san_els_request(req);
  1070. ret = zfcp_fsf_req_send(req);
  1071. if (ret)
  1072. goto failed_send;
  1073. goto out;
  1074. failed_send:
  1075. zfcp_fsf_req_free(req);
  1076. out:
  1077. spin_unlock_bh(&qdio->req_q_lock);
  1078. return ret;
  1079. }
  1080. int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
  1081. {
  1082. struct qdio_buffer_element *sbale;
  1083. struct zfcp_fsf_req *req;
  1084. struct zfcp_qdio *qdio = erp_action->adapter->qdio;
  1085. int retval = -EIO;
  1086. spin_lock_bh(&qdio->req_q_lock);
  1087. if (zfcp_fsf_req_sbal_get(qdio))
  1088. goto out;
  1089. req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA,
  1090. qdio->adapter->pool.erp_req);
  1091. if (IS_ERR(req)) {
  1092. retval = PTR_ERR(req);
  1093. goto out;
  1094. }
  1095. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1096. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1097. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1098. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1099. req->qtcb->bottom.config.feature_selection =
  1100. FSF_FEATURE_CFDC |
  1101. FSF_FEATURE_LUN_SHARING |
  1102. FSF_FEATURE_NOTIFICATION_LOST |
  1103. FSF_FEATURE_UPDATE_ALERT;
  1104. req->erp_action = erp_action;
  1105. req->handler = zfcp_fsf_exchange_config_data_handler;
  1106. erp_action->fsf_req = req;
  1107. zfcp_fsf_start_erp_timer(req);
  1108. retval = zfcp_fsf_req_send(req);
  1109. if (retval) {
  1110. zfcp_fsf_req_free(req);
  1111. erp_action->fsf_req = NULL;
  1112. }
  1113. out:
  1114. spin_unlock_bh(&qdio->req_q_lock);
  1115. return retval;
  1116. }
  1117. int zfcp_fsf_exchange_config_data_sync(struct zfcp_qdio *qdio,
  1118. struct fsf_qtcb_bottom_config *data)
  1119. {
  1120. struct qdio_buffer_element *sbale;
  1121. struct zfcp_fsf_req *req = NULL;
  1122. int retval = -EIO;
  1123. spin_lock_bh(&qdio->req_q_lock);
  1124. if (zfcp_fsf_req_sbal_get(qdio))
  1125. goto out_unlock;
  1126. req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_CONFIG_DATA, NULL);
  1127. if (IS_ERR(req)) {
  1128. retval = PTR_ERR(req);
  1129. goto out_unlock;
  1130. }
  1131. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1132. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1133. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1134. req->handler = zfcp_fsf_exchange_config_data_handler;
  1135. req->qtcb->bottom.config.feature_selection =
  1136. FSF_FEATURE_CFDC |
  1137. FSF_FEATURE_LUN_SHARING |
  1138. FSF_FEATURE_NOTIFICATION_LOST |
  1139. FSF_FEATURE_UPDATE_ALERT;
  1140. if (data)
  1141. req->data = data;
  1142. zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
  1143. retval = zfcp_fsf_req_send(req);
  1144. spin_unlock_bh(&qdio->req_q_lock);
  1145. if (!retval)
  1146. wait_for_completion(&req->completion);
  1147. zfcp_fsf_req_free(req);
  1148. return retval;
  1149. out_unlock:
  1150. spin_unlock_bh(&qdio->req_q_lock);
  1151. return retval;
  1152. }
  1153. /**
  1154. * zfcp_fsf_exchange_port_data - request information about local port
  1155. * @erp_action: ERP action for the adapter for which port data is requested
  1156. * Returns: 0 on success, error otherwise
  1157. */
  1158. int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
  1159. {
  1160. struct zfcp_qdio *qdio = erp_action->adapter->qdio;
  1161. struct qdio_buffer_element *sbale;
  1162. struct zfcp_fsf_req *req;
  1163. int retval = -EIO;
  1164. if (!(qdio->adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT))
  1165. return -EOPNOTSUPP;
  1166. spin_lock_bh(&qdio->req_q_lock);
  1167. if (zfcp_fsf_req_sbal_get(qdio))
  1168. goto out;
  1169. req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA,
  1170. qdio->adapter->pool.erp_req);
  1171. if (IS_ERR(req)) {
  1172. retval = PTR_ERR(req);
  1173. goto out;
  1174. }
  1175. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1176. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1177. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1178. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1179. req->handler = zfcp_fsf_exchange_port_data_handler;
  1180. req->erp_action = erp_action;
  1181. erp_action->fsf_req = req;
  1182. zfcp_fsf_start_erp_timer(req);
  1183. retval = zfcp_fsf_req_send(req);
  1184. if (retval) {
  1185. zfcp_fsf_req_free(req);
  1186. erp_action->fsf_req = NULL;
  1187. }
  1188. out:
  1189. spin_unlock_bh(&qdio->req_q_lock);
  1190. return retval;
  1191. }
  1192. /**
  1193. * zfcp_fsf_exchange_port_data_sync - request information about local port
  1194. * @qdio: pointer to struct zfcp_qdio
  1195. * @data: pointer to struct fsf_qtcb_bottom_port
  1196. * Returns: 0 on success, error otherwise
  1197. */
  1198. int zfcp_fsf_exchange_port_data_sync(struct zfcp_qdio *qdio,
  1199. struct fsf_qtcb_bottom_port *data)
  1200. {
  1201. struct qdio_buffer_element *sbale;
  1202. struct zfcp_fsf_req *req = NULL;
  1203. int retval = -EIO;
  1204. if (!(qdio->adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT))
  1205. return -EOPNOTSUPP;
  1206. spin_lock_bh(&qdio->req_q_lock);
  1207. if (zfcp_fsf_req_sbal_get(qdio))
  1208. goto out_unlock;
  1209. req = zfcp_fsf_req_create(qdio, FSF_QTCB_EXCHANGE_PORT_DATA, NULL);
  1210. if (IS_ERR(req)) {
  1211. retval = PTR_ERR(req);
  1212. goto out_unlock;
  1213. }
  1214. if (data)
  1215. req->data = data;
  1216. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1217. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1218. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1219. req->handler = zfcp_fsf_exchange_port_data_handler;
  1220. zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
  1221. retval = zfcp_fsf_req_send(req);
  1222. spin_unlock_bh(&qdio->req_q_lock);
  1223. if (!retval)
  1224. wait_for_completion(&req->completion);
  1225. zfcp_fsf_req_free(req);
  1226. return retval;
  1227. out_unlock:
  1228. spin_unlock_bh(&qdio->req_q_lock);
  1229. return retval;
  1230. }
  1231. static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
  1232. {
  1233. struct zfcp_port *port = req->data;
  1234. struct fsf_qtcb_header *header = &req->qtcb->header;
  1235. struct fc_els_flogi *plogi;
  1236. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1237. goto out;
  1238. switch (header->fsf_status) {
  1239. case FSF_PORT_ALREADY_OPEN:
  1240. break;
  1241. case FSF_ACCESS_DENIED:
  1242. zfcp_fsf_access_denied_port(req, port);
  1243. break;
  1244. case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
  1245. dev_warn(&req->adapter->ccw_device->dev,
  1246. "Not enough FCP adapter resources to open "
  1247. "remote port 0x%016Lx\n",
  1248. (unsigned long long)port->wwpn);
  1249. zfcp_erp_port_failed(port, "fsoph_1", req);
  1250. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1251. break;
  1252. case FSF_ADAPTER_STATUS_AVAILABLE:
  1253. switch (header->fsf_status_qual.word[0]) {
  1254. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1255. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1256. case FSF_SQ_NO_RETRY_POSSIBLE:
  1257. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1258. break;
  1259. }
  1260. break;
  1261. case FSF_GOOD:
  1262. port->handle = header->port_handle;
  1263. atomic_set_mask(ZFCP_STATUS_COMMON_OPEN |
  1264. ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
  1265. atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
  1266. ZFCP_STATUS_COMMON_ACCESS_BOXED,
  1267. &port->status);
  1268. /* check whether D_ID has changed during open */
  1269. /*
  1270. * FIXME: This check is not airtight, as the FCP channel does
  1271. * not monitor closures of target port connections caused on
  1272. * the remote side. Thus, they might miss out on invalidating
  1273. * locally cached WWPNs (and other N_Port parameters) of gone
  1274. * target ports. So, our heroic attempt to make things safe
  1275. * could be undermined by 'open port' response data tagged with
  1276. * obsolete WWPNs. Another reason to monitor potential
  1277. * connection closures ourself at least (by interpreting
  1278. * incoming ELS' and unsolicited status). It just crosses my
  1279. * mind that one should be able to cross-check by means of
  1280. * another GID_PN straight after a port has been opened.
  1281. * Alternately, an ADISC/PDISC ELS should suffice, as well.
  1282. */
  1283. plogi = (struct fc_els_flogi *) req->qtcb->bottom.support.els;
  1284. if (req->qtcb->bottom.support.els1_length >=
  1285. FSF_PLOGI_MIN_LEN)
  1286. zfcp_fc_plogi_evaluate(port, plogi);
  1287. break;
  1288. case FSF_UNKNOWN_OP_SUBTYPE:
  1289. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1290. break;
  1291. }
  1292. out:
  1293. put_device(&port->sysfs_device);
  1294. }
  1295. /**
  1296. * zfcp_fsf_open_port - create and send open port request
  1297. * @erp_action: pointer to struct zfcp_erp_action
  1298. * Returns: 0 on success, error otherwise
  1299. */
  1300. int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
  1301. {
  1302. struct qdio_buffer_element *sbale;
  1303. struct zfcp_qdio *qdio = erp_action->adapter->qdio;
  1304. struct zfcp_port *port = erp_action->port;
  1305. struct zfcp_fsf_req *req;
  1306. int retval = -EIO;
  1307. spin_lock_bh(&qdio->req_q_lock);
  1308. if (zfcp_fsf_req_sbal_get(qdio))
  1309. goto out;
  1310. req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
  1311. qdio->adapter->pool.erp_req);
  1312. if (IS_ERR(req)) {
  1313. retval = PTR_ERR(req);
  1314. goto out;
  1315. }
  1316. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1317. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1318. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1319. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1320. req->handler = zfcp_fsf_open_port_handler;
  1321. req->qtcb->bottom.support.d_id = port->d_id;
  1322. req->data = port;
  1323. req->erp_action = erp_action;
  1324. erp_action->fsf_req = req;
  1325. get_device(&port->sysfs_device);
  1326. zfcp_fsf_start_erp_timer(req);
  1327. retval = zfcp_fsf_req_send(req);
  1328. if (retval) {
  1329. zfcp_fsf_req_free(req);
  1330. erp_action->fsf_req = NULL;
  1331. put_device(&port->sysfs_device);
  1332. }
  1333. out:
  1334. spin_unlock_bh(&qdio->req_q_lock);
  1335. return retval;
  1336. }
  1337. static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req)
  1338. {
  1339. struct zfcp_port *port = req->data;
  1340. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1341. return;
  1342. switch (req->qtcb->header.fsf_status) {
  1343. case FSF_PORT_HANDLE_NOT_VALID:
  1344. zfcp_erp_adapter_reopen(port->adapter, 0, "fscph_1", req);
  1345. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1346. break;
  1347. case FSF_ADAPTER_STATUS_AVAILABLE:
  1348. break;
  1349. case FSF_GOOD:
  1350. zfcp_erp_modify_port_status(port, "fscph_2", req,
  1351. ZFCP_STATUS_COMMON_OPEN,
  1352. ZFCP_CLEAR);
  1353. break;
  1354. }
  1355. }
  1356. /**
  1357. * zfcp_fsf_close_port - create and send close port request
  1358. * @erp_action: pointer to struct zfcp_erp_action
  1359. * Returns: 0 on success, error otherwise
  1360. */
  1361. int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
  1362. {
  1363. struct qdio_buffer_element *sbale;
  1364. struct zfcp_qdio *qdio = erp_action->adapter->qdio;
  1365. struct zfcp_fsf_req *req;
  1366. int retval = -EIO;
  1367. spin_lock_bh(&qdio->req_q_lock);
  1368. if (zfcp_fsf_req_sbal_get(qdio))
  1369. goto out;
  1370. req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
  1371. qdio->adapter->pool.erp_req);
  1372. if (IS_ERR(req)) {
  1373. retval = PTR_ERR(req);
  1374. goto out;
  1375. }
  1376. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1377. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1378. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1379. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1380. req->handler = zfcp_fsf_close_port_handler;
  1381. req->data = erp_action->port;
  1382. req->erp_action = erp_action;
  1383. req->qtcb->header.port_handle = erp_action->port->handle;
  1384. erp_action->fsf_req = req;
  1385. zfcp_fsf_start_erp_timer(req);
  1386. retval = zfcp_fsf_req_send(req);
  1387. if (retval) {
  1388. zfcp_fsf_req_free(req);
  1389. erp_action->fsf_req = NULL;
  1390. }
  1391. out:
  1392. spin_unlock_bh(&qdio->req_q_lock);
  1393. return retval;
  1394. }
  1395. static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
  1396. {
  1397. struct zfcp_wka_port *wka_port = req->data;
  1398. struct fsf_qtcb_header *header = &req->qtcb->header;
  1399. if (req->status & ZFCP_STATUS_FSFREQ_ERROR) {
  1400. wka_port->status = ZFCP_WKA_PORT_OFFLINE;
  1401. goto out;
  1402. }
  1403. switch (header->fsf_status) {
  1404. case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
  1405. dev_warn(&req->adapter->ccw_device->dev,
  1406. "Opening WKA port 0x%x failed\n", wka_port->d_id);
  1407. /* fall through */
  1408. case FSF_ADAPTER_STATUS_AVAILABLE:
  1409. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1410. /* fall through */
  1411. case FSF_ACCESS_DENIED:
  1412. wka_port->status = ZFCP_WKA_PORT_OFFLINE;
  1413. break;
  1414. case FSF_GOOD:
  1415. wka_port->handle = header->port_handle;
  1416. /* fall through */
  1417. case FSF_PORT_ALREADY_OPEN:
  1418. wka_port->status = ZFCP_WKA_PORT_ONLINE;
  1419. }
  1420. out:
  1421. wake_up(&wka_port->completion_wq);
  1422. }
  1423. /**
  1424. * zfcp_fsf_open_wka_port - create and send open wka-port request
  1425. * @wka_port: pointer to struct zfcp_wka_port
  1426. * Returns: 0 on success, error otherwise
  1427. */
  1428. int zfcp_fsf_open_wka_port(struct zfcp_wka_port *wka_port)
  1429. {
  1430. struct qdio_buffer_element *sbale;
  1431. struct zfcp_qdio *qdio = wka_port->adapter->qdio;
  1432. struct zfcp_fsf_req *req;
  1433. int retval = -EIO;
  1434. spin_lock_bh(&qdio->req_q_lock);
  1435. if (zfcp_fsf_req_sbal_get(qdio))
  1436. goto out;
  1437. req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_PORT_WITH_DID,
  1438. qdio->adapter->pool.erp_req);
  1439. if (unlikely(IS_ERR(req))) {
  1440. retval = PTR_ERR(req);
  1441. goto out;
  1442. }
  1443. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1444. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1445. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1446. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1447. req->handler = zfcp_fsf_open_wka_port_handler;
  1448. req->qtcb->bottom.support.d_id = wka_port->d_id;
  1449. req->data = wka_port;
  1450. zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
  1451. retval = zfcp_fsf_req_send(req);
  1452. if (retval)
  1453. zfcp_fsf_req_free(req);
  1454. out:
  1455. spin_unlock_bh(&qdio->req_q_lock);
  1456. return retval;
  1457. }
  1458. static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
  1459. {
  1460. struct zfcp_wka_port *wka_port = req->data;
  1461. if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) {
  1462. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1463. zfcp_erp_adapter_reopen(wka_port->adapter, 0, "fscwph1", req);
  1464. }
  1465. wka_port->status = ZFCP_WKA_PORT_OFFLINE;
  1466. wake_up(&wka_port->completion_wq);
  1467. }
  1468. /**
  1469. * zfcp_fsf_close_wka_port - create and send close wka port request
  1470. * @erp_action: pointer to struct zfcp_erp_action
  1471. * Returns: 0 on success, error otherwise
  1472. */
  1473. int zfcp_fsf_close_wka_port(struct zfcp_wka_port *wka_port)
  1474. {
  1475. struct qdio_buffer_element *sbale;
  1476. struct zfcp_qdio *qdio = wka_port->adapter->qdio;
  1477. struct zfcp_fsf_req *req;
  1478. int retval = -EIO;
  1479. spin_lock_bh(&qdio->req_q_lock);
  1480. if (zfcp_fsf_req_sbal_get(qdio))
  1481. goto out;
  1482. req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PORT,
  1483. qdio->adapter->pool.erp_req);
  1484. if (unlikely(IS_ERR(req))) {
  1485. retval = PTR_ERR(req);
  1486. goto out;
  1487. }
  1488. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1489. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1490. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1491. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1492. req->handler = zfcp_fsf_close_wka_port_handler;
  1493. req->data = wka_port;
  1494. req->qtcb->header.port_handle = wka_port->handle;
  1495. zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
  1496. retval = zfcp_fsf_req_send(req);
  1497. if (retval)
  1498. zfcp_fsf_req_free(req);
  1499. out:
  1500. spin_unlock_bh(&qdio->req_q_lock);
  1501. return retval;
  1502. }
  1503. static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
  1504. {
  1505. struct zfcp_port *port = req->data;
  1506. struct fsf_qtcb_header *header = &req->qtcb->header;
  1507. struct zfcp_unit *unit;
  1508. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1509. return;
  1510. switch (header->fsf_status) {
  1511. case FSF_PORT_HANDLE_NOT_VALID:
  1512. zfcp_erp_adapter_reopen(port->adapter, 0, "fscpph1", req);
  1513. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1514. break;
  1515. case FSF_ACCESS_DENIED:
  1516. zfcp_fsf_access_denied_port(req, port);
  1517. break;
  1518. case FSF_PORT_BOXED:
  1519. /* can't use generic zfcp_erp_modify_port_status because
  1520. * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */
  1521. atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
  1522. read_lock(&port->unit_list_lock);
  1523. list_for_each_entry(unit, &port->unit_list, list)
  1524. atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
  1525. &unit->status);
  1526. read_unlock(&port->unit_list_lock);
  1527. zfcp_erp_port_boxed(port, "fscpph2", req);
  1528. req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  1529. ZFCP_STATUS_FSFREQ_RETRY;
  1530. break;
  1531. case FSF_ADAPTER_STATUS_AVAILABLE:
  1532. switch (header->fsf_status_qual.word[0]) {
  1533. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1534. /* fall through */
  1535. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1536. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1537. break;
  1538. }
  1539. break;
  1540. case FSF_GOOD:
  1541. /* can't use generic zfcp_erp_modify_port_status because
  1542. * ZFCP_STATUS_COMMON_OPEN must not be reset for the port
  1543. */
  1544. atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
  1545. read_lock(&port->unit_list_lock);
  1546. list_for_each_entry(unit, &port->unit_list, list)
  1547. atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
  1548. &unit->status);
  1549. read_unlock(&port->unit_list_lock);
  1550. break;
  1551. }
  1552. }
  1553. /**
  1554. * zfcp_fsf_close_physical_port - close physical port
  1555. * @erp_action: pointer to struct zfcp_erp_action
  1556. * Returns: 0 on success
  1557. */
  1558. int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
  1559. {
  1560. struct qdio_buffer_element *sbale;
  1561. struct zfcp_qdio *qdio = erp_action->adapter->qdio;
  1562. struct zfcp_fsf_req *req;
  1563. int retval = -EIO;
  1564. spin_lock_bh(&qdio->req_q_lock);
  1565. if (zfcp_fsf_req_sbal_get(qdio))
  1566. goto out;
  1567. req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_PHYSICAL_PORT,
  1568. qdio->adapter->pool.erp_req);
  1569. if (IS_ERR(req)) {
  1570. retval = PTR_ERR(req);
  1571. goto out;
  1572. }
  1573. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1574. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1575. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1576. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1577. req->data = erp_action->port;
  1578. req->qtcb->header.port_handle = erp_action->port->handle;
  1579. req->erp_action = erp_action;
  1580. req->handler = zfcp_fsf_close_physical_port_handler;
  1581. erp_action->fsf_req = req;
  1582. zfcp_fsf_start_erp_timer(req);
  1583. retval = zfcp_fsf_req_send(req);
  1584. if (retval) {
  1585. zfcp_fsf_req_free(req);
  1586. erp_action->fsf_req = NULL;
  1587. }
  1588. out:
  1589. spin_unlock_bh(&qdio->req_q_lock);
  1590. return retval;
  1591. }
  1592. static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
  1593. {
  1594. struct zfcp_adapter *adapter = req->adapter;
  1595. struct zfcp_unit *unit = req->data;
  1596. struct fsf_qtcb_header *header = &req->qtcb->header;
  1597. struct fsf_qtcb_bottom_support *bottom = &req->qtcb->bottom.support;
  1598. struct fsf_queue_designator *queue_designator =
  1599. &header->fsf_status_qual.fsf_queue_designator;
  1600. int exclusive, readwrite;
  1601. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1602. return;
  1603. atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
  1604. ZFCP_STATUS_COMMON_ACCESS_BOXED |
  1605. ZFCP_STATUS_UNIT_SHARED |
  1606. ZFCP_STATUS_UNIT_READONLY,
  1607. &unit->status);
  1608. switch (header->fsf_status) {
  1609. case FSF_PORT_HANDLE_NOT_VALID:
  1610. zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fsouh_1", req);
  1611. /* fall through */
  1612. case FSF_LUN_ALREADY_OPEN:
  1613. break;
  1614. case FSF_ACCESS_DENIED:
  1615. zfcp_fsf_access_denied_unit(req, unit);
  1616. atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
  1617. atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
  1618. break;
  1619. case FSF_PORT_BOXED:
  1620. zfcp_erp_port_boxed(unit->port, "fsouh_2", req);
  1621. req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  1622. ZFCP_STATUS_FSFREQ_RETRY;
  1623. break;
  1624. case FSF_LUN_SHARING_VIOLATION:
  1625. if (header->fsf_status_qual.word[0])
  1626. dev_warn(&adapter->ccw_device->dev,
  1627. "LUN 0x%Lx on port 0x%Lx is already in "
  1628. "use by CSS%d, MIF Image ID %x\n",
  1629. (unsigned long long)unit->fcp_lun,
  1630. (unsigned long long)unit->port->wwpn,
  1631. queue_designator->cssid,
  1632. queue_designator->hla);
  1633. else
  1634. zfcp_act_eval_err(adapter,
  1635. header->fsf_status_qual.word[2]);
  1636. zfcp_erp_unit_access_denied(unit, "fsouh_3", req);
  1637. atomic_clear_mask(ZFCP_STATUS_UNIT_SHARED, &unit->status);
  1638. atomic_clear_mask(ZFCP_STATUS_UNIT_READONLY, &unit->status);
  1639. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1640. break;
  1641. case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:
  1642. dev_warn(&adapter->ccw_device->dev,
  1643. "No handle is available for LUN "
  1644. "0x%016Lx on port 0x%016Lx\n",
  1645. (unsigned long long)unit->fcp_lun,
  1646. (unsigned long long)unit->port->wwpn);
  1647. zfcp_erp_unit_failed(unit, "fsouh_4", req);
  1648. /* fall through */
  1649. case FSF_INVALID_COMMAND_OPTION:
  1650. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1651. break;
  1652. case FSF_ADAPTER_STATUS_AVAILABLE:
  1653. switch (header->fsf_status_qual.word[0]) {
  1654. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1655. zfcp_fc_test_link(unit->port);
  1656. /* fall through */
  1657. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1658. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1659. break;
  1660. }
  1661. break;
  1662. case FSF_GOOD:
  1663. unit->handle = header->lun_handle;
  1664. atomic_set_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
  1665. if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE) &&
  1666. (adapter->adapter_features & FSF_FEATURE_LUN_SHARING) &&
  1667. !zfcp_ccw_priv_sch(adapter)) {
  1668. exclusive = (bottom->lun_access_info &
  1669. FSF_UNIT_ACCESS_EXCLUSIVE);
  1670. readwrite = (bottom->lun_access_info &
  1671. FSF_UNIT_ACCESS_OUTBOUND_TRANSFER);
  1672. if (!exclusive)
  1673. atomic_set_mask(ZFCP_STATUS_UNIT_SHARED,
  1674. &unit->status);
  1675. if (!readwrite) {
  1676. atomic_set_mask(ZFCP_STATUS_UNIT_READONLY,
  1677. &unit->status);
  1678. dev_info(&adapter->ccw_device->dev,
  1679. "SCSI device at LUN 0x%016Lx on port "
  1680. "0x%016Lx opened read-only\n",
  1681. (unsigned long long)unit->fcp_lun,
  1682. (unsigned long long)unit->port->wwpn);
  1683. }
  1684. if (exclusive && !readwrite) {
  1685. dev_err(&adapter->ccw_device->dev,
  1686. "Exclusive read-only access not "
  1687. "supported (unit 0x%016Lx, "
  1688. "port 0x%016Lx)\n",
  1689. (unsigned long long)unit->fcp_lun,
  1690. (unsigned long long)unit->port->wwpn);
  1691. zfcp_erp_unit_failed(unit, "fsouh_5", req);
  1692. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1693. zfcp_erp_unit_shutdown(unit, 0, "fsouh_6", req);
  1694. } else if (!exclusive && readwrite) {
  1695. dev_err(&adapter->ccw_device->dev,
  1696. "Shared read-write access not "
  1697. "supported (unit 0x%016Lx, port "
  1698. "0x%016Lx)\n",
  1699. (unsigned long long)unit->fcp_lun,
  1700. (unsigned long long)unit->port->wwpn);
  1701. zfcp_erp_unit_failed(unit, "fsouh_7", req);
  1702. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1703. zfcp_erp_unit_shutdown(unit, 0, "fsouh_8", req);
  1704. }
  1705. }
  1706. break;
  1707. }
  1708. }
  1709. /**
  1710. * zfcp_fsf_open_unit - open unit
  1711. * @erp_action: pointer to struct zfcp_erp_action
  1712. * Returns: 0 on success, error otherwise
  1713. */
  1714. int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
  1715. {
  1716. struct qdio_buffer_element *sbale;
  1717. struct zfcp_adapter *adapter = erp_action->adapter;
  1718. struct zfcp_qdio *qdio = adapter->qdio;
  1719. struct zfcp_fsf_req *req;
  1720. int retval = -EIO;
  1721. spin_lock_bh(&qdio->req_q_lock);
  1722. if (zfcp_fsf_req_sbal_get(qdio))
  1723. goto out;
  1724. req = zfcp_fsf_req_create(qdio, FSF_QTCB_OPEN_LUN,
  1725. adapter->pool.erp_req);
  1726. if (IS_ERR(req)) {
  1727. retval = PTR_ERR(req);
  1728. goto out;
  1729. }
  1730. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1731. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1732. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1733. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1734. req->qtcb->header.port_handle = erp_action->port->handle;
  1735. req->qtcb->bottom.support.fcp_lun = erp_action->unit->fcp_lun;
  1736. req->handler = zfcp_fsf_open_unit_handler;
  1737. req->data = erp_action->unit;
  1738. req->erp_action = erp_action;
  1739. erp_action->fsf_req = req;
  1740. if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE))
  1741. req->qtcb->bottom.support.option = FSF_OPEN_LUN_SUPPRESS_BOXING;
  1742. zfcp_fsf_start_erp_timer(req);
  1743. retval = zfcp_fsf_req_send(req);
  1744. if (retval) {
  1745. zfcp_fsf_req_free(req);
  1746. erp_action->fsf_req = NULL;
  1747. }
  1748. out:
  1749. spin_unlock_bh(&qdio->req_q_lock);
  1750. return retval;
  1751. }
  1752. static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req)
  1753. {
  1754. struct zfcp_unit *unit = req->data;
  1755. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1756. return;
  1757. switch (req->qtcb->header.fsf_status) {
  1758. case FSF_PORT_HANDLE_NOT_VALID:
  1759. zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fscuh_1", req);
  1760. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1761. break;
  1762. case FSF_LUN_HANDLE_NOT_VALID:
  1763. zfcp_erp_port_reopen(unit->port, 0, "fscuh_2", req);
  1764. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1765. break;
  1766. case FSF_PORT_BOXED:
  1767. zfcp_erp_port_boxed(unit->port, "fscuh_3", req);
  1768. req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  1769. ZFCP_STATUS_FSFREQ_RETRY;
  1770. break;
  1771. case FSF_ADAPTER_STATUS_AVAILABLE:
  1772. switch (req->qtcb->header.fsf_status_qual.word[0]) {
  1773. case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
  1774. zfcp_fc_test_link(unit->port);
  1775. /* fall through */
  1776. case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
  1777. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1778. break;
  1779. }
  1780. break;
  1781. case FSF_GOOD:
  1782. atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
  1783. break;
  1784. }
  1785. }
  1786. /**
  1787. * zfcp_fsf_close_unit - close zfcp unit
  1788. * @erp_action: pointer to struct zfcp_unit
  1789. * Returns: 0 on success, error otherwise
  1790. */
  1791. int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
  1792. {
  1793. struct qdio_buffer_element *sbale;
  1794. struct zfcp_qdio *qdio = erp_action->adapter->qdio;
  1795. struct zfcp_fsf_req *req;
  1796. int retval = -EIO;
  1797. spin_lock_bh(&qdio->req_q_lock);
  1798. if (zfcp_fsf_req_sbal_get(qdio))
  1799. goto out;
  1800. req = zfcp_fsf_req_create(qdio, FSF_QTCB_CLOSE_LUN,
  1801. qdio->adapter->pool.erp_req);
  1802. if (IS_ERR(req)) {
  1803. retval = PTR_ERR(req);
  1804. goto out;
  1805. }
  1806. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  1807. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  1808. sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
  1809. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  1810. req->qtcb->header.port_handle = erp_action->port->handle;
  1811. req->qtcb->header.lun_handle = erp_action->unit->handle;
  1812. req->handler = zfcp_fsf_close_unit_handler;
  1813. req->data = erp_action->unit;
  1814. req->erp_action = erp_action;
  1815. erp_action->fsf_req = req;
  1816. zfcp_fsf_start_erp_timer(req);
  1817. retval = zfcp_fsf_req_send(req);
  1818. if (retval) {
  1819. zfcp_fsf_req_free(req);
  1820. erp_action->fsf_req = NULL;
  1821. }
  1822. out:
  1823. spin_unlock_bh(&qdio->req_q_lock);
  1824. return retval;
  1825. }
  1826. static void zfcp_fsf_update_lat(struct fsf_latency_record *lat_rec, u32 lat)
  1827. {
  1828. lat_rec->sum += lat;
  1829. lat_rec->min = min(lat_rec->min, lat);
  1830. lat_rec->max = max(lat_rec->max, lat);
  1831. }
  1832. static void zfcp_fsf_req_trace(struct zfcp_fsf_req *req, struct scsi_cmnd *scsi)
  1833. {
  1834. struct fsf_qual_latency_info *lat_in;
  1835. struct latency_cont *lat = NULL;
  1836. struct zfcp_unit *unit = req->unit;
  1837. struct zfcp_blk_drv_data blktrc;
  1838. int ticks = req->adapter->timer_ticks;
  1839. lat_in = &req->qtcb->prefix.prot_status_qual.latency_info;
  1840. blktrc.flags = 0;
  1841. blktrc.magic = ZFCP_BLK_DRV_DATA_MAGIC;
  1842. if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
  1843. blktrc.flags |= ZFCP_BLK_REQ_ERROR;
  1844. blktrc.inb_usage = req->queue_req.qdio_inb_usage;
  1845. blktrc.outb_usage = req->queue_req.qdio_outb_usage;
  1846. if (req->adapter->adapter_features & FSF_FEATURE_MEASUREMENT_DATA) {
  1847. blktrc.flags |= ZFCP_BLK_LAT_VALID;
  1848. blktrc.channel_lat = lat_in->channel_lat * ticks;
  1849. blktrc.fabric_lat = lat_in->fabric_lat * ticks;
  1850. switch (req->qtcb->bottom.io.data_direction) {
  1851. case FSF_DATADIR_READ:
  1852. lat = &unit->latencies.read;
  1853. break;
  1854. case FSF_DATADIR_WRITE:
  1855. lat = &unit->latencies.write;
  1856. break;
  1857. case FSF_DATADIR_CMND:
  1858. lat = &unit->latencies.cmd;
  1859. break;
  1860. }
  1861. if (lat) {
  1862. spin_lock(&unit->latencies.lock);
  1863. zfcp_fsf_update_lat(&lat->channel, lat_in->channel_lat);
  1864. zfcp_fsf_update_lat(&lat->fabric, lat_in->fabric_lat);
  1865. lat->counter++;
  1866. spin_unlock(&unit->latencies.lock);
  1867. }
  1868. }
  1869. blk_add_driver_data(scsi->request->q, scsi->request, &blktrc,
  1870. sizeof(blktrc));
  1871. }
  1872. static void zfcp_fsf_send_fcp_command_task_handler(struct zfcp_fsf_req *req)
  1873. {
  1874. struct scsi_cmnd *scpnt;
  1875. struct fcp_resp_with_ext *fcp_rsp;
  1876. unsigned long flags;
  1877. read_lock_irqsave(&req->adapter->abort_lock, flags);
  1878. scpnt = req->data;
  1879. if (unlikely(!scpnt)) {
  1880. read_unlock_irqrestore(&req->adapter->abort_lock, flags);
  1881. return;
  1882. }
  1883. if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ABORTED)) {
  1884. set_host_byte(scpnt, DID_SOFT_ERROR);
  1885. goto skip_fsfstatus;
  1886. }
  1887. if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR)) {
  1888. set_host_byte(scpnt, DID_ERROR);
  1889. goto skip_fsfstatus;
  1890. }
  1891. fcp_rsp = (struct fcp_resp_with_ext *) &req->qtcb->bottom.io.fcp_rsp;
  1892. zfcp_fc_eval_fcp_rsp(fcp_rsp, scpnt);
  1893. zfcp_fsf_req_trace(req, scpnt);
  1894. skip_fsfstatus:
  1895. if (scpnt->result != 0)
  1896. zfcp_dbf_scsi_result("erro", 3, req->adapter->dbf, scpnt, req);
  1897. else if (scpnt->retries > 0)
  1898. zfcp_dbf_scsi_result("retr", 4, req->adapter->dbf, scpnt, req);
  1899. else
  1900. zfcp_dbf_scsi_result("norm", 6, req->adapter->dbf, scpnt, req);
  1901. scpnt->host_scribble = NULL;
  1902. (scpnt->scsi_done) (scpnt);
  1903. /*
  1904. * We must hold this lock until scsi_done has been called.
  1905. * Otherwise we may call scsi_done after abort regarding this
  1906. * command has completed.
  1907. * Note: scsi_done must not block!
  1908. */
  1909. read_unlock_irqrestore(&req->adapter->abort_lock, flags);
  1910. }
  1911. static void zfcp_fsf_send_fcp_ctm_handler(struct zfcp_fsf_req *req)
  1912. {
  1913. struct fcp_resp_with_ext *fcp_rsp;
  1914. struct fcp_resp_rsp_info *rsp_info;
  1915. fcp_rsp = (struct fcp_resp_with_ext *) &req->qtcb->bottom.io.fcp_rsp;
  1916. rsp_info = (struct fcp_resp_rsp_info *) &fcp_rsp[1];
  1917. if ((rsp_info->rsp_code != FCP_TMF_CMPL) ||
  1918. (req->status & ZFCP_STATUS_FSFREQ_ERROR))
  1919. req->status |= ZFCP_STATUS_FSFREQ_TMFUNCFAILED;
  1920. }
  1921. static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req)
  1922. {
  1923. struct zfcp_unit *unit;
  1924. struct fsf_qtcb_header *header = &req->qtcb->header;
  1925. if (unlikely(req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT))
  1926. unit = req->data;
  1927. else
  1928. unit = req->unit;
  1929. if (unlikely(req->status & ZFCP_STATUS_FSFREQ_ERROR))
  1930. goto skip_fsfstatus;
  1931. switch (header->fsf_status) {
  1932. case FSF_HANDLE_MISMATCH:
  1933. case FSF_PORT_HANDLE_NOT_VALID:
  1934. zfcp_erp_adapter_reopen(unit->port->adapter, 0, "fssfch1", req);
  1935. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1936. break;
  1937. case FSF_FCPLUN_NOT_VALID:
  1938. case FSF_LUN_HANDLE_NOT_VALID:
  1939. zfcp_erp_port_reopen(unit->port, 0, "fssfch2", req);
  1940. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1941. break;
  1942. case FSF_SERVICE_CLASS_NOT_SUPPORTED:
  1943. zfcp_fsf_class_not_supp(req);
  1944. break;
  1945. case FSF_ACCESS_DENIED:
  1946. zfcp_fsf_access_denied_unit(req, unit);
  1947. break;
  1948. case FSF_DIRECTION_INDICATOR_NOT_VALID:
  1949. dev_err(&req->adapter->ccw_device->dev,
  1950. "Incorrect direction %d, unit 0x%016Lx on port "
  1951. "0x%016Lx closed\n",
  1952. req->qtcb->bottom.io.data_direction,
  1953. (unsigned long long)unit->fcp_lun,
  1954. (unsigned long long)unit->port->wwpn);
  1955. zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch3",
  1956. req);
  1957. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1958. break;
  1959. case FSF_CMND_LENGTH_NOT_VALID:
  1960. dev_err(&req->adapter->ccw_device->dev,
  1961. "Incorrect CDB length %d, unit 0x%016Lx on "
  1962. "port 0x%016Lx closed\n",
  1963. req->qtcb->bottom.io.fcp_cmnd_length,
  1964. (unsigned long long)unit->fcp_lun,
  1965. (unsigned long long)unit->port->wwpn);
  1966. zfcp_erp_adapter_shutdown(unit->port->adapter, 0, "fssfch4",
  1967. req);
  1968. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1969. break;
  1970. case FSF_PORT_BOXED:
  1971. zfcp_erp_port_boxed(unit->port, "fssfch5", req);
  1972. req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  1973. ZFCP_STATUS_FSFREQ_RETRY;
  1974. break;
  1975. case FSF_LUN_BOXED:
  1976. zfcp_erp_unit_boxed(unit, "fssfch6", req);
  1977. req->status |= ZFCP_STATUS_FSFREQ_ERROR |
  1978. ZFCP_STATUS_FSFREQ_RETRY;
  1979. break;
  1980. case FSF_ADAPTER_STATUS_AVAILABLE:
  1981. if (header->fsf_status_qual.word[0] ==
  1982. FSF_SQ_INVOKE_LINK_TEST_PROCEDURE)
  1983. zfcp_fc_test_link(unit->port);
  1984. req->status |= ZFCP_STATUS_FSFREQ_ERROR;
  1985. break;
  1986. }
  1987. skip_fsfstatus:
  1988. if (req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
  1989. zfcp_fsf_send_fcp_ctm_handler(req);
  1990. else {
  1991. zfcp_fsf_send_fcp_command_task_handler(req);
  1992. req->unit = NULL;
  1993. put_device(&unit->sysfs_device);
  1994. }
  1995. }
  1996. /**
  1997. * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
  1998. * @unit: unit where command is sent to
  1999. * @scsi_cmnd: scsi command to be sent
  2000. */
  2001. int zfcp_fsf_send_fcp_command_task(struct zfcp_unit *unit,
  2002. struct scsi_cmnd *scsi_cmnd)
  2003. {
  2004. struct zfcp_fsf_req *req;
  2005. struct fcp_cmnd *fcp_cmnd;
  2006. unsigned int sbtype = SBAL_FLAGS0_TYPE_READ;
  2007. int real_bytes, retval = -EIO;
  2008. struct zfcp_adapter *adapter = unit->port->adapter;
  2009. struct zfcp_qdio *qdio = adapter->qdio;
  2010. if (unlikely(!(atomic_read(&unit->status) &
  2011. ZFCP_STATUS_COMMON_UNBLOCKED)))
  2012. return -EBUSY;
  2013. spin_lock(&qdio->req_q_lock);
  2014. if (atomic_read(&qdio->req_q.count) <= 0) {
  2015. atomic_inc(&qdio->req_q_full);
  2016. goto out;
  2017. }
  2018. req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
  2019. adapter->pool.scsi_req);
  2020. if (IS_ERR(req)) {
  2021. retval = PTR_ERR(req);
  2022. goto out;
  2023. }
  2024. req->status |= ZFCP_STATUS_FSFREQ_CLEANUP;
  2025. get_device(&unit->sysfs_device);
  2026. req->unit = unit;
  2027. req->data = scsi_cmnd;
  2028. req->handler = zfcp_fsf_send_fcp_command_handler;
  2029. req->qtcb->header.lun_handle = unit->handle;
  2030. req->qtcb->header.port_handle = unit->port->handle;
  2031. req->qtcb->bottom.io.service_class = FSF_CLASS_3;
  2032. req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN;
  2033. scsi_cmnd->host_scribble = (unsigned char *) req->req_id;
  2034. /*
  2035. * set depending on data direction:
  2036. * data direction bits in SBALE (SB Type)
  2037. * data direction bits in QTCB
  2038. */
  2039. switch (scsi_cmnd->sc_data_direction) {
  2040. case DMA_NONE:
  2041. req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
  2042. break;
  2043. case DMA_FROM_DEVICE:
  2044. req->qtcb->bottom.io.data_direction = FSF_DATADIR_READ;
  2045. break;
  2046. case DMA_TO_DEVICE:
  2047. req->qtcb->bottom.io.data_direction = FSF_DATADIR_WRITE;
  2048. sbtype = SBAL_FLAGS0_TYPE_WRITE;
  2049. break;
  2050. case DMA_BIDIRECTIONAL:
  2051. goto failed_scsi_cmnd;
  2052. }
  2053. fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
  2054. zfcp_fc_scsi_to_fcp(fcp_cmnd, scsi_cmnd);
  2055. real_bytes = zfcp_qdio_sbals_from_sg(qdio, &req->queue_req, sbtype,
  2056. scsi_sglist(scsi_cmnd),
  2057. FSF_MAX_SBALS_PER_REQ);
  2058. if (unlikely(real_bytes < 0)) {
  2059. if (req->queue_req.sbal_number >= FSF_MAX_SBALS_PER_REQ) {
  2060. dev_err(&adapter->ccw_device->dev,
  2061. "Oversize data package, unit 0x%016Lx "
  2062. "on port 0x%016Lx closed\n",
  2063. (unsigned long long)unit->fcp_lun,
  2064. (unsigned long long)unit->port->wwpn);
  2065. zfcp_erp_unit_shutdown(unit, 0, "fssfct1", req);
  2066. retval = -EINVAL;
  2067. }
  2068. goto failed_scsi_cmnd;
  2069. }
  2070. retval = zfcp_fsf_req_send(req);
  2071. if (unlikely(retval))
  2072. goto failed_scsi_cmnd;
  2073. goto out;
  2074. failed_scsi_cmnd:
  2075. put_device(&unit->sysfs_device);
  2076. zfcp_fsf_req_free(req);
  2077. scsi_cmnd->host_scribble = NULL;
  2078. out:
  2079. spin_unlock(&qdio->req_q_lock);
  2080. return retval;
  2081. }
  2082. /**
  2083. * zfcp_fsf_send_fcp_ctm - send SCSI task management command
  2084. * @unit: pointer to struct zfcp_unit
  2085. * @tm_flags: unsigned byte for task management flags
  2086. * Returns: on success pointer to struct fsf_req, NULL otherwise
  2087. */
  2088. struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_unit *unit, u8 tm_flags)
  2089. {
  2090. struct qdio_buffer_element *sbale;
  2091. struct zfcp_fsf_req *req = NULL;
  2092. struct fcp_cmnd *fcp_cmnd;
  2093. struct zfcp_qdio *qdio = unit->port->adapter->qdio;
  2094. if (unlikely(!(atomic_read(&unit->status) &
  2095. ZFCP_STATUS_COMMON_UNBLOCKED)))
  2096. return NULL;
  2097. spin_lock_bh(&qdio->req_q_lock);
  2098. if (zfcp_fsf_req_sbal_get(qdio))
  2099. goto out;
  2100. req = zfcp_fsf_req_create(qdio, FSF_QTCB_FCP_CMND,
  2101. qdio->adapter->pool.scsi_req);
  2102. if (IS_ERR(req)) {
  2103. req = NULL;
  2104. goto out;
  2105. }
  2106. req->status |= ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT;
  2107. req->data = unit;
  2108. req->handler = zfcp_fsf_send_fcp_command_handler;
  2109. req->qtcb->header.lun_handle = unit->handle;
  2110. req->qtcb->header.port_handle = unit->port->handle;
  2111. req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
  2112. req->qtcb->bottom.io.service_class = FSF_CLASS_3;
  2113. req->qtcb->bottom.io.fcp_cmnd_length = FCP_CMND_LEN;
  2114. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  2115. sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
  2116. sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
  2117. fcp_cmnd = (struct fcp_cmnd *) &req->qtcb->bottom.io.fcp_cmnd;
  2118. zfcp_fc_fcp_tm(fcp_cmnd, unit->device, tm_flags);
  2119. zfcp_fsf_start_timer(req, ZFCP_SCSI_ER_TIMEOUT);
  2120. if (!zfcp_fsf_req_send(req))
  2121. goto out;
  2122. zfcp_fsf_req_free(req);
  2123. req = NULL;
  2124. out:
  2125. spin_unlock_bh(&qdio->req_q_lock);
  2126. return req;
  2127. }
  2128. static void zfcp_fsf_control_file_handler(struct zfcp_fsf_req *req)
  2129. {
  2130. }
  2131. /**
  2132. * zfcp_fsf_control_file - control file upload/download
  2133. * @adapter: pointer to struct zfcp_adapter
  2134. * @fsf_cfdc: pointer to struct zfcp_fsf_cfdc
  2135. * Returns: on success pointer to struct zfcp_fsf_req, NULL otherwise
  2136. */
  2137. struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
  2138. struct zfcp_fsf_cfdc *fsf_cfdc)
  2139. {
  2140. struct qdio_buffer_element *sbale;
  2141. struct zfcp_qdio *qdio = adapter->qdio;
  2142. struct zfcp_fsf_req *req = NULL;
  2143. struct fsf_qtcb_bottom_support *bottom;
  2144. int direction, retval = -EIO, bytes;
  2145. if (!(adapter->adapter_features & FSF_FEATURE_CFDC))
  2146. return ERR_PTR(-EOPNOTSUPP);
  2147. switch (fsf_cfdc->command) {
  2148. case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
  2149. direction = SBAL_FLAGS0_TYPE_WRITE;
  2150. break;
  2151. case FSF_QTCB_UPLOAD_CONTROL_FILE:
  2152. direction = SBAL_FLAGS0_TYPE_READ;
  2153. break;
  2154. default:
  2155. return ERR_PTR(-EINVAL);
  2156. }
  2157. spin_lock_bh(&qdio->req_q_lock);
  2158. if (zfcp_fsf_req_sbal_get(qdio))
  2159. goto out;
  2160. req = zfcp_fsf_req_create(qdio, fsf_cfdc->command, NULL);
  2161. if (IS_ERR(req)) {
  2162. retval = -EPERM;
  2163. goto out;
  2164. }
  2165. req->handler = zfcp_fsf_control_file_handler;
  2166. sbale = zfcp_qdio_sbale_req(qdio, &req->queue_req);
  2167. sbale[0].flags |= direction;
  2168. bottom = &req->qtcb->bottom.support;
  2169. bottom->operation_subtype = FSF_CFDC_OPERATION_SUBTYPE;
  2170. bottom->option = fsf_cfdc->option;
  2171. bytes = zfcp_qdio_sbals_from_sg(qdio, &req->queue_req,
  2172. direction, fsf_cfdc->sg,
  2173. FSF_MAX_SBALS_PER_REQ);
  2174. if (bytes != ZFCP_CFDC_MAX_SIZE) {
  2175. zfcp_fsf_req_free(req);
  2176. goto out;
  2177. }
  2178. zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
  2179. retval = zfcp_fsf_req_send(req);
  2180. out:
  2181. spin_unlock_bh(&qdio->req_q_lock);
  2182. if (!retval) {
  2183. wait_for_completion(&req->completion);
  2184. return req;
  2185. }
  2186. return ERR_PTR(retval);
  2187. }
  2188. /**
  2189. * zfcp_fsf_reqid_check - validate req_id contained in SBAL returned by QDIO
  2190. * @adapter: pointer to struct zfcp_adapter
  2191. * @sbal_idx: response queue index of SBAL to be processed
  2192. */
  2193. void zfcp_fsf_reqid_check(struct zfcp_qdio *qdio, int sbal_idx)
  2194. {
  2195. struct zfcp_adapter *adapter = qdio->adapter;
  2196. struct qdio_buffer *sbal = qdio->resp_q.sbal[sbal_idx];
  2197. struct qdio_buffer_element *sbale;
  2198. struct zfcp_fsf_req *fsf_req;
  2199. unsigned long flags, req_id;
  2200. int idx;
  2201. for (idx = 0; idx < QDIO_MAX_ELEMENTS_PER_BUFFER; idx++) {
  2202. sbale = &sbal->element[idx];
  2203. req_id = (unsigned long) sbale->addr;
  2204. spin_lock_irqsave(&adapter->req_list_lock, flags);
  2205. fsf_req = zfcp_reqlist_find(adapter, req_id);
  2206. if (!fsf_req)
  2207. /*
  2208. * Unknown request means that we have potentially memory
  2209. * corruption and must stop the machine immediately.
  2210. */
  2211. panic("error: unknown req_id (%lx) on adapter %s.\n",
  2212. req_id, dev_name(&adapter->ccw_device->dev));
  2213. list_del(&fsf_req->list);
  2214. spin_unlock_irqrestore(&adapter->req_list_lock, flags);
  2215. fsf_req->queue_req.sbal_response = sbal_idx;
  2216. fsf_req->queue_req.qdio_inb_usage =
  2217. atomic_read(&qdio->resp_q.count);
  2218. zfcp_fsf_req_complete(fsf_req);
  2219. if (likely(sbale->flags & SBAL_FLAGS_LAST_ENTRY))
  2220. break;
  2221. }
  2222. }