aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_fsf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/s390/scsi/zfcp_fsf.c')
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c584
1 files changed, 322 insertions, 262 deletions
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 49dbeb754e5f..739356a5c123 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -50,19 +50,16 @@ static u32 fsf_qtcb_type[] = {
50 [FSF_QTCB_UPLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND 50 [FSF_QTCB_UPLOAD_CONTROL_FILE] = FSF_SUPPORT_COMMAND
51}; 51};
52 52
53static const char *zfcp_act_subtable_type[] = {
54 "unknown", "OS", "WWPN", "DID", "LUN"
55};
56
57static void zfcp_act_eval_err(struct zfcp_adapter *adapter, u32 table) 53static void zfcp_act_eval_err(struct zfcp_adapter *adapter, u32 table)
58{ 54{
59 u16 subtable = table >> 16; 55 u16 subtable = table >> 16;
60 u16 rule = table & 0xffff; 56 u16 rule = table & 0xffff;
57 const char *act_type[] = { "unknown", "OS", "WWPN", "DID", "LUN" };
61 58
62 if (subtable && subtable < ARRAY_SIZE(zfcp_act_subtable_type)) 59 if (subtable && subtable < ARRAY_SIZE(act_type))
63 dev_warn(&adapter->ccw_device->dev, 60 dev_warn(&adapter->ccw_device->dev,
64 "Access denied in subtable %s, rule %d.\n", 61 "Access denied according to ACT rule type %s, "
65 zfcp_act_subtable_type[subtable], rule); 62 "rule %d\n", act_type[subtable], rule);
66} 63}
67 64
68static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req, 65static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req,
@@ -70,8 +67,8 @@ static void zfcp_fsf_access_denied_port(struct zfcp_fsf_req *req,
70{ 67{
71 struct fsf_qtcb_header *header = &req->qtcb->header; 68 struct fsf_qtcb_header *header = &req->qtcb->header;
72 dev_warn(&req->adapter->ccw_device->dev, 69 dev_warn(&req->adapter->ccw_device->dev,
73 "Access denied, cannot send command to port 0x%016Lx.\n", 70 "Access denied to port 0x%016Lx\n",
74 port->wwpn); 71 (unsigned long long)port->wwpn);
75 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); 72 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
76 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); 73 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
77 zfcp_erp_port_access_denied(port, 55, req); 74 zfcp_erp_port_access_denied(port, 55, req);
@@ -83,8 +80,9 @@ static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req,
83{ 80{
84 struct fsf_qtcb_header *header = &req->qtcb->header; 81 struct fsf_qtcb_header *header = &req->qtcb->header;
85 dev_warn(&req->adapter->ccw_device->dev, 82 dev_warn(&req->adapter->ccw_device->dev,
86 "Access denied for unit 0x%016Lx on port 0x%016Lx.\n", 83 "Access denied to unit 0x%016Lx on port 0x%016Lx\n",
87 unit->fcp_lun, unit->port->wwpn); 84 (unsigned long long)unit->fcp_lun,
85 (unsigned long long)unit->port->wwpn);
88 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]); 86 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[0]);
89 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]); 87 zfcp_act_eval_err(req->adapter, header->fsf_status_qual.halfword[1]);
90 zfcp_erp_unit_access_denied(unit, 59, req); 88 zfcp_erp_unit_access_denied(unit, 59, req);
@@ -93,9 +91,8 @@ static void zfcp_fsf_access_denied_unit(struct zfcp_fsf_req *req,
93 91
94static void zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req) 92static void zfcp_fsf_class_not_supp(struct zfcp_fsf_req *req)
95{ 93{
96 dev_err(&req->adapter->ccw_device->dev, 94 dev_err(&req->adapter->ccw_device->dev, "FCP device not "
97 "Required FC class not supported by adapter, " 95 "operational because of an unsupported FC class\n");
98 "shutting down adapter.\n");
99 zfcp_erp_adapter_shutdown(req->adapter, 0, 123, req); 96 zfcp_erp_adapter_shutdown(req->adapter, 0, 123, req);
100 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 97 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
101} 98}
@@ -171,42 +168,6 @@ static void zfcp_fsf_status_read_port_closed(struct zfcp_fsf_req *req)
171 read_unlock_irqrestore(&zfcp_data.config_lock, flags); 168 read_unlock_irqrestore(&zfcp_data.config_lock, flags);
172} 169}
173 170
174static void zfcp_fsf_bit_error_threshold(struct zfcp_fsf_req *req)
175{
176 struct zfcp_adapter *adapter = req->adapter;
177 struct fsf_status_read_buffer *sr_buf = req->data;
178 struct fsf_bit_error_payload *err = &sr_buf->payload.bit_error;
179
180 dev_warn(&adapter->ccw_device->dev,
181 "Warning: bit error threshold data "
182 "received for the adapter: "
183 "link failures = %i, loss of sync errors = %i, "
184 "loss of signal errors = %i, "
185 "primitive sequence errors = %i, "
186 "invalid transmission word errors = %i, "
187 "CRC errors = %i).\n",
188 err->link_failure_error_count,
189 err->loss_of_sync_error_count,
190 err->loss_of_signal_error_count,
191 err->primitive_sequence_error_count,
192 err->invalid_transmission_word_error_count,
193 err->crc_error_count);
194 dev_warn(&adapter->ccw_device->dev,
195 "Additional bit error threshold data of the adapter: "
196 "primitive sequence event time-outs = %i, "
197 "elastic buffer overrun errors = %i, "
198 "advertised receive buffer-to-buffer credit = %i, "
199 "current receice buffer-to-buffer credit = %i, "
200 "advertised transmit buffer-to-buffer credit = %i, "
201 "current transmit buffer-to-buffer credit = %i).\n",
202 err->primitive_sequence_event_timeout_count,
203 err->elastic_buffer_overrun_error_count,
204 err->advertised_receive_b2b_credit,
205 err->current_receive_b2b_credit,
206 err->advertised_transmit_b2b_credit,
207 err->current_transmit_b2b_credit);
208}
209
210static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req, u8 id, 171static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req, u8 id,
211 struct fsf_link_down_info *link_down) 172 struct fsf_link_down_info *link_down)
212{ 173{
@@ -223,62 +184,66 @@ static void zfcp_fsf_link_down_info_eval(struct zfcp_fsf_req *req, u8 id,
223 switch (link_down->error_code) { 184 switch (link_down->error_code) {
224 case FSF_PSQ_LINK_NO_LIGHT: 185 case FSF_PSQ_LINK_NO_LIGHT:
225 dev_warn(&req->adapter->ccw_device->dev, 186 dev_warn(&req->adapter->ccw_device->dev,
226 "The local link is down: no light detected.\n"); 187 "There is no light signal from the local "
188 "fibre channel cable\n");
227 break; 189 break;
228 case FSF_PSQ_LINK_WRAP_PLUG: 190 case FSF_PSQ_LINK_WRAP_PLUG:
229 dev_warn(&req->adapter->ccw_device->dev, 191 dev_warn(&req->adapter->ccw_device->dev,
230 "The local link is down: wrap plug detected.\n"); 192 "There is a wrap plug instead of a fibre "
193 "channel cable\n");
231 break; 194 break;
232 case FSF_PSQ_LINK_NO_FCP: 195 case FSF_PSQ_LINK_NO_FCP:
233 dev_warn(&req->adapter->ccw_device->dev, 196 dev_warn(&req->adapter->ccw_device->dev,
234 "The local link is down: " 197 "The adjacent fibre channel node does not "
235 "adjacent node on link does not support FCP.\n"); 198 "support FCP\n");
236 break; 199 break;
237 case FSF_PSQ_LINK_FIRMWARE_UPDATE: 200 case FSF_PSQ_LINK_FIRMWARE_UPDATE:
238 dev_warn(&req->adapter->ccw_device->dev, 201 dev_warn(&req->adapter->ccw_device->dev,
239 "The local link is down: " 202 "The FCP device is suspended because of a "
240 "firmware update in progress.\n"); 203 "firmware update\n");
241 break; 204 break;
242 case FSF_PSQ_LINK_INVALID_WWPN: 205 case FSF_PSQ_LINK_INVALID_WWPN:
243 dev_warn(&req->adapter->ccw_device->dev, 206 dev_warn(&req->adapter->ccw_device->dev,
244 "The local link is down: " 207 "The FCP device detected a WWPN that is "
245 "duplicate or invalid WWPN detected.\n"); 208 "duplicate or not valid\n");
246 break; 209 break;
247 case FSF_PSQ_LINK_NO_NPIV_SUPPORT: 210 case FSF_PSQ_LINK_NO_NPIV_SUPPORT:
248 dev_warn(&req->adapter->ccw_device->dev, 211 dev_warn(&req->adapter->ccw_device->dev,
249 "The local link is down: " 212 "The fibre channel fabric does not support NPIV\n");
250 "no support for NPIV by Fabric.\n");
251 break; 213 break;
252 case FSF_PSQ_LINK_NO_FCP_RESOURCES: 214 case FSF_PSQ_LINK_NO_FCP_RESOURCES:
253 dev_warn(&req->adapter->ccw_device->dev, 215 dev_warn(&req->adapter->ccw_device->dev,
254 "The local link is down: " 216 "The FCP adapter cannot support more NPIV ports\n");
255 "out of resource in FCP daughtercard.\n");
256 break; 217 break;
257 case FSF_PSQ_LINK_NO_FABRIC_RESOURCES: 218 case FSF_PSQ_LINK_NO_FABRIC_RESOURCES:
258 dev_warn(&req->adapter->ccw_device->dev, 219 dev_warn(&req->adapter->ccw_device->dev,
259 "The local link is down: " 220 "The adjacent switch cannot support "
260 "out of resource in Fabric.\n"); 221 "more NPIV ports\n");
261 break; 222 break;
262 case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE: 223 case FSF_PSQ_LINK_FABRIC_LOGIN_UNABLE:
263 dev_warn(&req->adapter->ccw_device->dev, 224 dev_warn(&req->adapter->ccw_device->dev,
264 "The local link is down: " 225 "The FCP adapter could not log in to the "
265 "unable to login to Fabric.\n"); 226 "fibre channel fabric\n");
266 break; 227 break;
267 case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED: 228 case FSF_PSQ_LINK_WWPN_ASSIGNMENT_CORRUPTED:
268 dev_warn(&req->adapter->ccw_device->dev, 229 dev_warn(&req->adapter->ccw_device->dev,
269 "WWPN assignment file corrupted on adapter.\n"); 230 "The WWPN assignment file on the FCP adapter "
231 "has been damaged\n");
270 break; 232 break;
271 case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED: 233 case FSF_PSQ_LINK_MODE_TABLE_CURRUPTED:
272 dev_warn(&req->adapter->ccw_device->dev, 234 dev_warn(&req->adapter->ccw_device->dev,
273 "Mode table corrupted on adapter.\n"); 235 "The mode table on the FCP adapter "
236 "has been damaged\n");
274 break; 237 break;
275 case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT: 238 case FSF_PSQ_LINK_NO_WWPN_ASSIGNMENT:
276 dev_warn(&req->adapter->ccw_device->dev, 239 dev_warn(&req->adapter->ccw_device->dev,
277 "No WWPN for assignment table on adapter.\n"); 240 "All NPIV ports on the FCP adapter have "
241 "been assigned\n");
278 break; 242 break;
279 default: 243 default:
280 dev_warn(&req->adapter->ccw_device->dev, 244 dev_warn(&req->adapter->ccw_device->dev,
281 "The local link to adapter is down.\n"); 245 "The link between the FCP adapter and "
246 "the FC fabric is down\n");
282 } 247 }
283out: 248out:
284 zfcp_erp_adapter_failed(adapter, id, req); 249 zfcp_erp_adapter_failed(adapter, id, req);
@@ -286,27 +251,18 @@ out:
286 251
287static void zfcp_fsf_status_read_link_down(struct zfcp_fsf_req *req) 252static void zfcp_fsf_status_read_link_down(struct zfcp_fsf_req *req)
288{ 253{
289 struct zfcp_adapter *adapter = req->adapter;
290 struct fsf_status_read_buffer *sr_buf = req->data; 254 struct fsf_status_read_buffer *sr_buf = req->data;
291 struct fsf_link_down_info *ldi = 255 struct fsf_link_down_info *ldi =
292 (struct fsf_link_down_info *) &sr_buf->payload; 256 (struct fsf_link_down_info *) &sr_buf->payload;
293 257
294 switch (sr_buf->status_subtype) { 258 switch (sr_buf->status_subtype) {
295 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK: 259 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
296 dev_warn(&adapter->ccw_device->dev,
297 "Physical link is down.\n");
298 zfcp_fsf_link_down_info_eval(req, 38, ldi); 260 zfcp_fsf_link_down_info_eval(req, 38, ldi);
299 break; 261 break;
300 case FSF_STATUS_READ_SUB_FDISC_FAILED: 262 case FSF_STATUS_READ_SUB_FDISC_FAILED:
301 dev_warn(&adapter->ccw_device->dev,
302 "Local link is down "
303 "due to failed FDISC login.\n");
304 zfcp_fsf_link_down_info_eval(req, 39, ldi); 263 zfcp_fsf_link_down_info_eval(req, 39, ldi);
305 break; 264 break;
306 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE: 265 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE:
307 dev_warn(&adapter->ccw_device->dev,
308 "Local link is down "
309 "due to firmware update on adapter.\n");
310 zfcp_fsf_link_down_info_eval(req, 40, NULL); 266 zfcp_fsf_link_down_info_eval(req, 40, NULL);
311 }; 267 };
312} 268}
@@ -335,14 +291,17 @@ static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req)
335 case FSF_STATUS_READ_SENSE_DATA_AVAIL: 291 case FSF_STATUS_READ_SENSE_DATA_AVAIL:
336 break; 292 break;
337 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD: 293 case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
338 zfcp_fsf_bit_error_threshold(req); 294 dev_warn(&adapter->ccw_device->dev,
295 "The error threshold for checksum statistics "
296 "has been exceeded\n");
297 zfcp_hba_dbf_event_berr(adapter, req);
339 break; 298 break;
340 case FSF_STATUS_READ_LINK_DOWN: 299 case FSF_STATUS_READ_LINK_DOWN:
341 zfcp_fsf_status_read_link_down(req); 300 zfcp_fsf_status_read_link_down(req);
342 break; 301 break;
343 case FSF_STATUS_READ_LINK_UP: 302 case FSF_STATUS_READ_LINK_UP:
344 dev_info(&adapter->ccw_device->dev, 303 dev_info(&adapter->ccw_device->dev,
345 "Local link was replugged.\n"); 304 "The local link has been restored\n");
346 /* All ports should be marked as ready to run again */ 305 /* All ports should be marked as ready to run again */
347 zfcp_erp_modify_adapter_status(adapter, 30, NULL, 306 zfcp_erp_modify_adapter_status(adapter, 30, NULL,
348 ZFCP_STATUS_COMMON_RUNNING, 307 ZFCP_STATUS_COMMON_RUNNING,
@@ -370,7 +329,7 @@ static void zfcp_fsf_status_read_handler(struct zfcp_fsf_req *req)
370 zfcp_fsf_req_free(req); 329 zfcp_fsf_req_free(req);
371 330
372 atomic_inc(&adapter->stat_miss); 331 atomic_inc(&adapter->stat_miss);
373 schedule_work(&adapter->stat_work); 332 queue_work(zfcp_data.work_queue, &adapter->stat_work);
374} 333}
375 334
376static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req) 335static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req)
@@ -386,8 +345,8 @@ static void zfcp_fsf_fsfstatus_qual_eval(struct zfcp_fsf_req *req)
386 break; 345 break;
387 case FSF_SQ_NO_RECOM: 346 case FSF_SQ_NO_RECOM:
388 dev_err(&req->adapter->ccw_device->dev, 347 dev_err(&req->adapter->ccw_device->dev,
389 "No recommendation could be given for a " 348 "The FCP adapter reported a problem "
390 "problem on the adapter.\n"); 349 "that cannot be recovered\n");
391 zfcp_erp_adapter_shutdown(req->adapter, 0, 121, req); 350 zfcp_erp_adapter_shutdown(req->adapter, 0, 121, req);
392 break; 351 break;
393 } 352 }
@@ -403,8 +362,7 @@ static void zfcp_fsf_fsfstatus_eval(struct zfcp_fsf_req *req)
403 switch (req->qtcb->header.fsf_status) { 362 switch (req->qtcb->header.fsf_status) {
404 case FSF_UNKNOWN_COMMAND: 363 case FSF_UNKNOWN_COMMAND:
405 dev_err(&req->adapter->ccw_device->dev, 364 dev_err(&req->adapter->ccw_device->dev,
406 "Command issued by the device driver (0x%x) is " 365 "The FCP adapter does not recognize the command 0x%x\n",
407 "not known by the adapter.\n",
408 req->qtcb->header.fsf_command); 366 req->qtcb->header.fsf_command);
409 zfcp_erp_adapter_shutdown(req->adapter, 0, 120, req); 367 zfcp_erp_adapter_shutdown(req->adapter, 0, 120, req);
410 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 368 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
@@ -435,11 +393,9 @@ static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
435 return; 393 return;
436 case FSF_PROT_QTCB_VERSION_ERROR: 394 case FSF_PROT_QTCB_VERSION_ERROR:
437 dev_err(&adapter->ccw_device->dev, 395 dev_err(&adapter->ccw_device->dev,
438 "The QTCB version requested by zfcp (0x%x) is not " 396 "QTCB version 0x%x not supported by FCP adapter "
439 "supported by the FCP adapter (lowest supported " 397 "(0x%x to 0x%x)\n", FSF_QTCB_CURRENT_VERSION,
440 "0x%x, highest supported 0x%x).\n", 398 psq->word[0], psq->word[1]);
441 FSF_QTCB_CURRENT_VERSION, psq->word[0],
442 psq->word[1]);
443 zfcp_erp_adapter_shutdown(adapter, 0, 117, req); 399 zfcp_erp_adapter_shutdown(adapter, 0, 117, req);
444 break; 400 break;
445 case FSF_PROT_ERROR_STATE: 401 case FSF_PROT_ERROR_STATE:
@@ -449,8 +405,7 @@ static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
449 break; 405 break;
450 case FSF_PROT_UNSUPP_QTCB_TYPE: 406 case FSF_PROT_UNSUPP_QTCB_TYPE:
451 dev_err(&adapter->ccw_device->dev, 407 dev_err(&adapter->ccw_device->dev,
452 "Packet header type used by the device driver is " 408 "The QTCB type is not supported by the FCP adapter\n");
453 "incompatible with that used on the adapter.\n");
454 zfcp_erp_adapter_shutdown(adapter, 0, 118, req); 409 zfcp_erp_adapter_shutdown(adapter, 0, 118, req);
455 break; 410 break;
456 case FSF_PROT_HOST_CONNECTION_INITIALIZING: 411 case FSF_PROT_HOST_CONNECTION_INITIALIZING:
@@ -459,7 +414,7 @@ static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
459 break; 414 break;
460 case FSF_PROT_DUPLICATE_REQUEST_ID: 415 case FSF_PROT_DUPLICATE_REQUEST_ID:
461 dev_err(&adapter->ccw_device->dev, 416 dev_err(&adapter->ccw_device->dev,
462 "The request identifier 0x%Lx is ambiguous.\n", 417 "0x%Lx is an ambiguous request identifier\n",
463 (unsigned long long)qtcb->bottom.support.req_handle); 418 (unsigned long long)qtcb->bottom.support.req_handle);
464 zfcp_erp_adapter_shutdown(adapter, 0, 78, req); 419 zfcp_erp_adapter_shutdown(adapter, 0, 78, req);
465 break; 420 break;
@@ -479,9 +434,7 @@ static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)
479 break; 434 break;
480 default: 435 default:
481 dev_err(&adapter->ccw_device->dev, 436 dev_err(&adapter->ccw_device->dev,
482 "Transfer protocol status information" 437 "0x%x is not a valid transfer protocol status\n",
483 "provided by the adapter (0x%x) "
484 "is not compatible with the device driver.\n",
485 qtcb->prefix.prot_status); 438 qtcb->prefix.prot_status);
486 zfcp_erp_adapter_shutdown(adapter, 0, 119, req); 439 zfcp_erp_adapter_shutdown(adapter, 0, 119, req);
487 } 440 }
@@ -559,33 +512,17 @@ static int zfcp_fsf_exchange_config_evaluate(struct zfcp_fsf_req *req)
559 adapter->peer_wwpn = bottom->plogi_payload.wwpn; 512 adapter->peer_wwpn = bottom->plogi_payload.wwpn;
560 adapter->peer_wwnn = bottom->plogi_payload.wwnn; 513 adapter->peer_wwnn = bottom->plogi_payload.wwnn;
561 fc_host_port_type(shost) = FC_PORTTYPE_PTP; 514 fc_host_port_type(shost) = FC_PORTTYPE_PTP;
562 if (req->erp_action)
563 dev_info(&adapter->ccw_device->dev,
564 "Point-to-Point fibrechannel "
565 "configuration detected.\n");
566 break; 515 break;
567 case FSF_TOPO_FABRIC: 516 case FSF_TOPO_FABRIC:
568 fc_host_port_type(shost) = FC_PORTTYPE_NPORT; 517 fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
569 if (req->erp_action)
570 dev_info(&adapter->ccw_device->dev,
571 "Switched fabric fibrechannel "
572 "network detected.\n");
573 break; 518 break;
574 case FSF_TOPO_AL: 519 case FSF_TOPO_AL:
575 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT; 520 fc_host_port_type(shost) = FC_PORTTYPE_NLPORT;
576 dev_err(&adapter->ccw_device->dev,
577 "Unsupported arbitrated loop fibrechannel "
578 "topology detected, shutting down "
579 "adapter.\n");
580 zfcp_erp_adapter_shutdown(adapter, 0, 127, req);
581 return -EIO;
582 default: 521 default:
583 fc_host_port_type(shost) = FC_PORTTYPE_UNKNOWN;
584 dev_err(&adapter->ccw_device->dev, 522 dev_err(&adapter->ccw_device->dev,
585 "The fibrechannel topology reported by the" 523 "Unknown or unsupported arbitrated loop "
586 " adapter is not known by the zfcp driver," 524 "fibre channel topology detected\n");
587 " shutting down adapter.\n"); 525 zfcp_erp_adapter_shutdown(adapter, 0, 127, req);
588 zfcp_erp_adapter_shutdown(adapter, 0, 128, req);
589 return -EIO; 526 return -EIO;
590 } 527 }
591 528
@@ -616,11 +553,9 @@ static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
616 553
617 if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) { 554 if (bottom->max_qtcb_size < sizeof(struct fsf_qtcb)) {
618 dev_err(&adapter->ccw_device->dev, 555 dev_err(&adapter->ccw_device->dev,
619 "Maximum QTCB size (%d bytes) allowed by " 556 "FCP adapter maximum QTCB size (%d bytes) "
620 "the adapter is lower than the minimum " 557 "is too small\n",
621 "required by the driver (%ld bytes).\n", 558 bottom->max_qtcb_size);
622 bottom->max_qtcb_size,
623 sizeof(struct fsf_qtcb));
624 zfcp_erp_adapter_shutdown(adapter, 0, 129, req); 559 zfcp_erp_adapter_shutdown(adapter, 0, 129, req);
625 return; 560 return;
626 } 561 }
@@ -656,15 +591,15 @@ static void zfcp_fsf_exchange_config_data_handler(struct zfcp_fsf_req *req)
656 591
657 if (FSF_QTCB_CURRENT_VERSION < bottom->low_qtcb_version) { 592 if (FSF_QTCB_CURRENT_VERSION < bottom->low_qtcb_version) {
658 dev_err(&adapter->ccw_device->dev, 593 dev_err(&adapter->ccw_device->dev,
659 "The adapter only supports newer control block " 594 "The FCP adapter only supports newer "
660 "versions, try updated device driver.\n"); 595 "control block versions\n");
661 zfcp_erp_adapter_shutdown(adapter, 0, 125, req); 596 zfcp_erp_adapter_shutdown(adapter, 0, 125, req);
662 return; 597 return;
663 } 598 }
664 if (FSF_QTCB_CURRENT_VERSION > bottom->high_qtcb_version) { 599 if (FSF_QTCB_CURRENT_VERSION > bottom->high_qtcb_version) {
665 dev_err(&adapter->ccw_device->dev, 600 dev_err(&adapter->ccw_device->dev,
666 "The adapter only supports older control block " 601 "The FCP adapter only supports older "
667 "versions, consider a microcode upgrade.\n"); 602 "control block versions\n");
668 zfcp_erp_adapter_shutdown(adapter, 0, 126, req); 603 zfcp_erp_adapter_shutdown(adapter, 0, 126, req);
669 } 604 }
670} 605}
@@ -688,7 +623,6 @@ static void zfcp_fsf_exchange_port_evaluate(struct zfcp_fsf_req *req)
688 623
689static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req) 624static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
690{ 625{
691 struct zfcp_adapter *adapter = req->adapter;
692 struct fsf_qtcb *qtcb = req->qtcb; 626 struct fsf_qtcb *qtcb = req->qtcb;
693 627
694 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 628 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
@@ -697,38 +631,47 @@ static void zfcp_fsf_exchange_port_data_handler(struct zfcp_fsf_req *req)
697 switch (qtcb->header.fsf_status) { 631 switch (qtcb->header.fsf_status) {
698 case FSF_GOOD: 632 case FSF_GOOD:
699 zfcp_fsf_exchange_port_evaluate(req); 633 zfcp_fsf_exchange_port_evaluate(req);
700 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
701 break; 634 break;
702 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE: 635 case FSF_EXCHANGE_CONFIG_DATA_INCOMPLETE:
703 zfcp_fsf_exchange_port_evaluate(req); 636 zfcp_fsf_exchange_port_evaluate(req);
704 atomic_set_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
705 zfcp_fsf_link_down_info_eval(req, 43, 637 zfcp_fsf_link_down_info_eval(req, 43,
706 &qtcb->header.fsf_status_qual.link_down_info); 638 &qtcb->header.fsf_status_qual.link_down_info);
707 break; 639 break;
708 } 640 }
709} 641}
710 642
711static int zfcp_fsf_sbal_check(struct zfcp_qdio_queue *queue) 643static int zfcp_fsf_sbal_check(struct zfcp_adapter *adapter)
712{ 644{
713 spin_lock_bh(&queue->lock); 645 struct zfcp_qdio_queue *req_q = &adapter->req_q;
714 if (atomic_read(&queue->count)) 646
647 spin_lock_bh(&adapter->req_q_lock);
648 if (atomic_read(&req_q->count))
715 return 1; 649 return 1;
716 spin_unlock_bh(&queue->lock); 650 spin_unlock_bh(&adapter->req_q_lock);
717 return 0; 651 return 0;
718} 652}
719 653
654static int zfcp_fsf_sbal_available(struct zfcp_adapter *adapter)
655{
656 unsigned int count = atomic_read(&adapter->req_q.count);
657 if (!count)
658 atomic_inc(&adapter->qdio_outb_full);
659 return count > 0;
660}
661
720static int zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter) 662static int zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter)
721{ 663{
722 long ret; 664 long ret;
723 struct zfcp_qdio_queue *req_q = &adapter->req_q;
724 665
725 spin_unlock_bh(&req_q->lock); 666 spin_unlock_bh(&adapter->req_q_lock);
726 ret = wait_event_interruptible_timeout(adapter->request_wq, 667 ret = wait_event_interruptible_timeout(adapter->request_wq,
727 zfcp_fsf_sbal_check(req_q), 5 * HZ); 668 zfcp_fsf_sbal_check(adapter), 5 * HZ);
728 if (ret > 0) 669 if (ret > 0)
729 return 0; 670 return 0;
671 if (!ret)
672 atomic_inc(&adapter->qdio_outb_full);
730 673
731 spin_lock_bh(&req_q->lock); 674 spin_lock_bh(&adapter->req_q_lock);
732 return -EIO; 675 return -EIO;
733} 676}
734 677
@@ -765,7 +708,7 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_adapter *adapter,
765 u32 fsf_cmd, int req_flags, 708 u32 fsf_cmd, int req_flags,
766 mempool_t *pool) 709 mempool_t *pool)
767{ 710{
768 volatile struct qdio_buffer_element *sbale; 711 struct qdio_buffer_element *sbale;
769 712
770 struct zfcp_fsf_req *req; 713 struct zfcp_fsf_req *req;
771 struct zfcp_qdio_queue *req_q = &adapter->req_q; 714 struct zfcp_qdio_queue *req_q = &adapter->req_q;
@@ -867,10 +810,10 @@ int zfcp_fsf_status_read(struct zfcp_adapter *adapter)
867{ 810{
868 struct zfcp_fsf_req *req; 811 struct zfcp_fsf_req *req;
869 struct fsf_status_read_buffer *sr_buf; 812 struct fsf_status_read_buffer *sr_buf;
870 volatile struct qdio_buffer_element *sbale; 813 struct qdio_buffer_element *sbale;
871 int retval = -EIO; 814 int retval = -EIO;
872 815
873 spin_lock_bh(&adapter->req_q.lock); 816 spin_lock_bh(&adapter->req_q_lock);
874 if (zfcp_fsf_req_sbal_get(adapter)) 817 if (zfcp_fsf_req_sbal_get(adapter))
875 goto out; 818 goto out;
876 819
@@ -910,7 +853,7 @@ failed_buf:
910 zfcp_fsf_req_free(req); 853 zfcp_fsf_req_free(req);
911 zfcp_hba_dbf_event_fsf_unsol("fail", adapter, NULL); 854 zfcp_hba_dbf_event_fsf_unsol("fail", adapter, NULL);
912out: 855out:
913 spin_unlock_bh(&adapter->req_q.lock); 856 spin_unlock_bh(&adapter->req_q_lock);
914 return retval; 857 return retval;
915} 858}
916 859
@@ -980,11 +923,11 @@ struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long old_req_id,
980 struct zfcp_unit *unit, 923 struct zfcp_unit *unit,
981 int req_flags) 924 int req_flags)
982{ 925{
983 volatile struct qdio_buffer_element *sbale; 926 struct qdio_buffer_element *sbale;
984 struct zfcp_fsf_req *req = NULL; 927 struct zfcp_fsf_req *req = NULL;
985 928
986 spin_lock(&adapter->req_q.lock); 929 spin_lock(&adapter->req_q_lock);
987 if (!atomic_read(&adapter->req_q.count)) 930 if (!zfcp_fsf_sbal_available(adapter))
988 goto out; 931 goto out;
989 req = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND, 932 req = zfcp_fsf_req_create(adapter, FSF_QTCB_ABORT_FCP_CMND,
990 req_flags, adapter->pool.fsf_req_abort); 933 req_flags, adapter->pool.fsf_req_abort);
@@ -1013,7 +956,7 @@ out_error_free:
1013 zfcp_fsf_req_free(req); 956 zfcp_fsf_req_free(req);
1014 req = NULL; 957 req = NULL;
1015out: 958out:
1016 spin_unlock(&adapter->req_q.lock); 959 spin_unlock(&adapter->req_q_lock);
1017 return req; 960 return req;
1018} 961}
1019 962
@@ -1021,7 +964,6 @@ static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
1021{ 964{
1022 struct zfcp_adapter *adapter = req->adapter; 965 struct zfcp_adapter *adapter = req->adapter;
1023 struct zfcp_send_ct *send_ct = req->data; 966 struct zfcp_send_ct *send_ct = req->data;
1024 struct zfcp_port *port = send_ct->port;
1025 struct fsf_qtcb_header *header = &req->qtcb->header; 967 struct fsf_qtcb_header *header = &req->qtcb->header;
1026 968
1027 send_ct->status = -EINVAL; 969 send_ct->status = -EINVAL;
@@ -1040,17 +982,14 @@ static void zfcp_fsf_send_ct_handler(struct zfcp_fsf_req *req)
1040 case FSF_ADAPTER_STATUS_AVAILABLE: 982 case FSF_ADAPTER_STATUS_AVAILABLE:
1041 switch (header->fsf_status_qual.word[0]){ 983 switch (header->fsf_status_qual.word[0]){
1042 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE: 984 case FSF_SQ_INVOKE_LINK_TEST_PROCEDURE:
1043 zfcp_test_link(port);
1044 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED: 985 case FSF_SQ_ULP_DEPENDENT_ERP_REQUIRED:
1045 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 986 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1046 break; 987 break;
1047 } 988 }
1048 break; 989 break;
1049 case FSF_ACCESS_DENIED: 990 case FSF_ACCESS_DENIED:
1050 zfcp_fsf_access_denied_port(req, port);
1051 break; 991 break;
1052 case FSF_PORT_BOXED: 992 case FSF_PORT_BOXED:
1053 zfcp_erp_port_boxed(port, 49, req);
1054 req->status |= ZFCP_STATUS_FSFREQ_ERROR | 993 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
1055 ZFCP_STATUS_FSFREQ_RETRY; 994 ZFCP_STATUS_FSFREQ_RETRY;
1056 break; 995 break;
@@ -1101,12 +1040,12 @@ static int zfcp_fsf_setup_sbals(struct zfcp_fsf_req *req,
1101int zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool, 1040int zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1102 struct zfcp_erp_action *erp_action) 1041 struct zfcp_erp_action *erp_action)
1103{ 1042{
1104 struct zfcp_port *port = ct->port; 1043 struct zfcp_wka_port *wka_port = ct->wka_port;
1105 struct zfcp_adapter *adapter = port->adapter; 1044 struct zfcp_adapter *adapter = wka_port->adapter;
1106 struct zfcp_fsf_req *req; 1045 struct zfcp_fsf_req *req;
1107 int ret = -EIO; 1046 int ret = -EIO;
1108 1047
1109 spin_lock_bh(&adapter->req_q.lock); 1048 spin_lock_bh(&adapter->req_q_lock);
1110 if (zfcp_fsf_req_sbal_get(adapter)) 1049 if (zfcp_fsf_req_sbal_get(adapter))
1111 goto out; 1050 goto out;
1112 1051
@@ -1123,7 +1062,7 @@ int zfcp_fsf_send_ct(struct zfcp_send_ct *ct, mempool_t *pool,
1123 goto failed_send; 1062 goto failed_send;
1124 1063
1125 req->handler = zfcp_fsf_send_ct_handler; 1064 req->handler = zfcp_fsf_send_ct_handler;
1126 req->qtcb->header.port_handle = port->handle; 1065 req->qtcb->header.port_handle = wka_port->handle;
1127 req->qtcb->bottom.support.service_class = FSF_CLASS_3; 1066 req->qtcb->bottom.support.service_class = FSF_CLASS_3;
1128 req->qtcb->bottom.support.timeout = ct->timeout; 1067 req->qtcb->bottom.support.timeout = ct->timeout;
1129 req->data = ct; 1068 req->data = ct;
@@ -1148,7 +1087,7 @@ failed_send:
1148 if (erp_action) 1087 if (erp_action)
1149 erp_action->fsf_req = NULL; 1088 erp_action->fsf_req = NULL;
1150out: 1089out:
1151 spin_unlock_bh(&adapter->req_q.lock); 1090 spin_unlock_bh(&adapter->req_q_lock);
1152 return ret; 1091 return ret;
1153} 1092}
1154 1093
@@ -1218,8 +1157,8 @@ int zfcp_fsf_send_els(struct zfcp_send_els *els)
1218 ZFCP_STATUS_COMMON_UNBLOCKED))) 1157 ZFCP_STATUS_COMMON_UNBLOCKED)))
1219 return -EBUSY; 1158 return -EBUSY;
1220 1159
1221 spin_lock(&adapter->req_q.lock); 1160 spin_lock(&adapter->req_q_lock);
1222 if (!atomic_read(&adapter->req_q.count)) 1161 if (!zfcp_fsf_sbal_available(adapter))
1223 goto out; 1162 goto out;
1224 req = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS, 1163 req = zfcp_fsf_req_create(adapter, FSF_QTCB_SEND_ELS,
1225 ZFCP_REQ_AUTO_CLEANUP, NULL); 1164 ZFCP_REQ_AUTO_CLEANUP, NULL);
@@ -1228,8 +1167,8 @@ int zfcp_fsf_send_els(struct zfcp_send_els *els)
1228 goto out; 1167 goto out;
1229 } 1168 }
1230 1169
1231 ret = zfcp_fsf_setup_sbals(req, els->req, els->resp, 1170 ret = zfcp_fsf_setup_sbals(req, els->req, els->resp, 2);
1232 FSF_MAX_SBALS_PER_ELS_REQ); 1171
1233 if (ret) 1172 if (ret)
1234 goto failed_send; 1173 goto failed_send;
1235 1174
@@ -1252,19 +1191,19 @@ int zfcp_fsf_send_els(struct zfcp_send_els *els)
1252failed_send: 1191failed_send:
1253 zfcp_fsf_req_free(req); 1192 zfcp_fsf_req_free(req);
1254out: 1193out:
1255 spin_unlock(&adapter->req_q.lock); 1194 spin_unlock(&adapter->req_q_lock);
1256 return ret; 1195 return ret;
1257} 1196}
1258 1197
1259int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action) 1198int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1260{ 1199{
1261 volatile struct qdio_buffer_element *sbale; 1200 struct qdio_buffer_element *sbale;
1262 struct zfcp_fsf_req *req; 1201 struct zfcp_fsf_req *req;
1263 struct zfcp_adapter *adapter = erp_action->adapter; 1202 struct zfcp_adapter *adapter = erp_action->adapter;
1264 int retval = -EIO; 1203 int retval = -EIO;
1265 1204
1266 spin_lock_bh(&adapter->req_q.lock); 1205 spin_lock_bh(&adapter->req_q_lock);
1267 if (!atomic_read(&adapter->req_q.count)) 1206 if (!zfcp_fsf_sbal_available(adapter))
1268 goto out; 1207 goto out;
1269 req = zfcp_fsf_req_create(adapter, 1208 req = zfcp_fsf_req_create(adapter,
1270 FSF_QTCB_EXCHANGE_CONFIG_DATA, 1209 FSF_QTCB_EXCHANGE_CONFIG_DATA,
@@ -1295,18 +1234,18 @@ int zfcp_fsf_exchange_config_data(struct zfcp_erp_action *erp_action)
1295 erp_action->fsf_req = NULL; 1234 erp_action->fsf_req = NULL;
1296 } 1235 }
1297out: 1236out:
1298 spin_unlock_bh(&adapter->req_q.lock); 1237 spin_unlock_bh(&adapter->req_q_lock);
1299 return retval; 1238 return retval;
1300} 1239}
1301 1240
1302int zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter, 1241int zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter,
1303 struct fsf_qtcb_bottom_config *data) 1242 struct fsf_qtcb_bottom_config *data)
1304{ 1243{
1305 volatile struct qdio_buffer_element *sbale; 1244 struct qdio_buffer_element *sbale;
1306 struct zfcp_fsf_req *req = NULL; 1245 struct zfcp_fsf_req *req = NULL;
1307 int retval = -EIO; 1246 int retval = -EIO;
1308 1247
1309 spin_lock_bh(&adapter->req_q.lock); 1248 spin_lock_bh(&adapter->req_q_lock);
1310 if (zfcp_fsf_req_sbal_get(adapter)) 1249 if (zfcp_fsf_req_sbal_get(adapter))
1311 goto out; 1250 goto out;
1312 1251
@@ -1334,7 +1273,7 @@ int zfcp_fsf_exchange_config_data_sync(struct zfcp_adapter *adapter,
1334 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); 1273 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1335 retval = zfcp_fsf_req_send(req); 1274 retval = zfcp_fsf_req_send(req);
1336out: 1275out:
1337 spin_unlock_bh(&adapter->req_q.lock); 1276 spin_unlock_bh(&adapter->req_q_lock);
1338 if (!retval) 1277 if (!retval)
1339 wait_event(req->completion_wq, 1278 wait_event(req->completion_wq,
1340 req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 1279 req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
@@ -1351,7 +1290,7 @@ out:
1351 */ 1290 */
1352int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action) 1291int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1353{ 1292{
1354 volatile struct qdio_buffer_element *sbale; 1293 struct qdio_buffer_element *sbale;
1355 struct zfcp_fsf_req *req; 1294 struct zfcp_fsf_req *req;
1356 struct zfcp_adapter *adapter = erp_action->adapter; 1295 struct zfcp_adapter *adapter = erp_action->adapter;
1357 int retval = -EIO; 1296 int retval = -EIO;
@@ -1359,8 +1298,8 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1359 if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) 1298 if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT))
1360 return -EOPNOTSUPP; 1299 return -EOPNOTSUPP;
1361 1300
1362 spin_lock_bh(&adapter->req_q.lock); 1301 spin_lock_bh(&adapter->req_q_lock);
1363 if (!atomic_read(&adapter->req_q.count)) 1302 if (!zfcp_fsf_sbal_available(adapter))
1364 goto out; 1303 goto out;
1365 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 1304 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
1366 ZFCP_REQ_AUTO_CLEANUP, 1305 ZFCP_REQ_AUTO_CLEANUP,
@@ -1385,7 +1324,7 @@ int zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action)
1385 erp_action->fsf_req = NULL; 1324 erp_action->fsf_req = NULL;
1386 } 1325 }
1387out: 1326out:
1388 spin_unlock_bh(&adapter->req_q.lock); 1327 spin_unlock_bh(&adapter->req_q_lock);
1389 return retval; 1328 return retval;
1390} 1329}
1391 1330
@@ -1398,15 +1337,15 @@ out:
1398int zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter, 1337int zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter,
1399 struct fsf_qtcb_bottom_port *data) 1338 struct fsf_qtcb_bottom_port *data)
1400{ 1339{
1401 volatile struct qdio_buffer_element *sbale; 1340 struct qdio_buffer_element *sbale;
1402 struct zfcp_fsf_req *req = NULL; 1341 struct zfcp_fsf_req *req = NULL;
1403 int retval = -EIO; 1342 int retval = -EIO;
1404 1343
1405 if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT)) 1344 if (!(adapter->adapter_features & FSF_FEATURE_HBAAPI_MANAGEMENT))
1406 return -EOPNOTSUPP; 1345 return -EOPNOTSUPP;
1407 1346
1408 spin_lock_bh(&adapter->req_q.lock); 1347 spin_lock_bh(&adapter->req_q_lock);
1409 if (!atomic_read(&adapter->req_q.count)) 1348 if (!zfcp_fsf_sbal_available(adapter))
1410 goto out; 1349 goto out;
1411 1350
1412 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 0, 1351 req = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 0,
@@ -1427,7 +1366,7 @@ int zfcp_fsf_exchange_port_data_sync(struct zfcp_adapter *adapter,
1427 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); 1366 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1428 retval = zfcp_fsf_req_send(req); 1367 retval = zfcp_fsf_req_send(req);
1429out: 1368out:
1430 spin_unlock_bh(&adapter->req_q.lock); 1369 spin_unlock_bh(&adapter->req_q_lock);
1431 if (!retval) 1370 if (!retval)
1432 wait_event(req->completion_wq, 1371 wait_event(req->completion_wq,
1433 req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 1372 req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
@@ -1443,7 +1382,7 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
1443 struct fsf_plogi *plogi; 1382 struct fsf_plogi *plogi;
1444 1383
1445 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 1384 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1446 goto skip_fsfstatus; 1385 return;
1447 1386
1448 switch (header->fsf_status) { 1387 switch (header->fsf_status) {
1449 case FSF_PORT_ALREADY_OPEN: 1388 case FSF_PORT_ALREADY_OPEN:
@@ -1453,9 +1392,9 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
1453 break; 1392 break;
1454 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED: 1393 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
1455 dev_warn(&req->adapter->ccw_device->dev, 1394 dev_warn(&req->adapter->ccw_device->dev,
1456 "The adapter is out of resources. The remote port " 1395 "Not enough FCP adapter resources to open "
1457 "0x%016Lx could not be opened, disabling it.\n", 1396 "remote port 0x%016Lx\n",
1458 port->wwpn); 1397 (unsigned long long)port->wwpn);
1459 zfcp_erp_port_failed(port, 31, req); 1398 zfcp_erp_port_failed(port, 31, req);
1460 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1399 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1461 break; 1400 break;
@@ -1467,8 +1406,8 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
1467 break; 1406 break;
1468 case FSF_SQ_NO_RETRY_POSSIBLE: 1407 case FSF_SQ_NO_RETRY_POSSIBLE:
1469 dev_warn(&req->adapter->ccw_device->dev, 1408 dev_warn(&req->adapter->ccw_device->dev,
1470 "The remote port 0x%016Lx could not be " 1409 "Remote port 0x%016Lx could not be opened\n",
1471 "opened. Disabling it.\n", port->wwpn); 1410 (unsigned long long)port->wwpn);
1472 zfcp_erp_port_failed(port, 32, req); 1411 zfcp_erp_port_failed(port, 32, req);
1473 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1412 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1474 break; 1413 break;
@@ -1496,9 +1435,6 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
1496 * another GID_PN straight after a port has been opened. 1435 * another GID_PN straight after a port has been opened.
1497 * Alternately, an ADISC/PDISC ELS should suffice, as well. 1436 * Alternately, an ADISC/PDISC ELS should suffice, as well.
1498 */ 1437 */
1499 if (atomic_read(&port->status) & ZFCP_STATUS_PORT_NO_WWPN)
1500 break;
1501
1502 plogi = (struct fsf_plogi *) req->qtcb->bottom.support.els; 1438 plogi = (struct fsf_plogi *) req->qtcb->bottom.support.els;
1503 if (req->qtcb->bottom.support.els1_length >= sizeof(*plogi)) { 1439 if (req->qtcb->bottom.support.els1_length >= sizeof(*plogi)) {
1504 if (plogi->serv_param.wwpn != port->wwpn) 1440 if (plogi->serv_param.wwpn != port->wwpn)
@@ -1514,9 +1450,6 @@ static void zfcp_fsf_open_port_handler(struct zfcp_fsf_req *req)
1514 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1450 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1515 break; 1451 break;
1516 } 1452 }
1517
1518skip_fsfstatus:
1519 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &port->status);
1520} 1453}
1521 1454
1522/** 1455/**
@@ -1526,12 +1459,12 @@ skip_fsfstatus:
1526 */ 1459 */
1527int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action) 1460int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1528{ 1461{
1529 volatile struct qdio_buffer_element *sbale; 1462 struct qdio_buffer_element *sbale;
1530 struct zfcp_adapter *adapter = erp_action->adapter; 1463 struct zfcp_adapter *adapter = erp_action->adapter;
1531 struct zfcp_fsf_req *req; 1464 struct zfcp_fsf_req *req;
1532 int retval = -EIO; 1465 int retval = -EIO;
1533 1466
1534 spin_lock_bh(&adapter->req_q.lock); 1467 spin_lock_bh(&adapter->req_q_lock);
1535 if (zfcp_fsf_req_sbal_get(adapter)) 1468 if (zfcp_fsf_req_sbal_get(adapter))
1536 goto out; 1469 goto out;
1537 1470
@@ -1553,7 +1486,6 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1553 req->data = erp_action->port; 1486 req->data = erp_action->port;
1554 req->erp_action = erp_action; 1487 req->erp_action = erp_action;
1555 erp_action->fsf_req = req; 1488 erp_action->fsf_req = req;
1556 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->port->status);
1557 1489
1558 zfcp_fsf_start_erp_timer(req); 1490 zfcp_fsf_start_erp_timer(req);
1559 retval = zfcp_fsf_req_send(req); 1491 retval = zfcp_fsf_req_send(req);
@@ -1562,7 +1494,7 @@ int zfcp_fsf_open_port(struct zfcp_erp_action *erp_action)
1562 erp_action->fsf_req = NULL; 1494 erp_action->fsf_req = NULL;
1563 } 1495 }
1564out: 1496out:
1565 spin_unlock_bh(&adapter->req_q.lock); 1497 spin_unlock_bh(&adapter->req_q_lock);
1566 return retval; 1498 return retval;
1567} 1499}
1568 1500
@@ -1571,7 +1503,7 @@ static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req)
1571 struct zfcp_port *port = req->data; 1503 struct zfcp_port *port = req->data;
1572 1504
1573 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 1505 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1574 goto skip_fsfstatus; 1506 return;
1575 1507
1576 switch (req->qtcb->header.fsf_status) { 1508 switch (req->qtcb->header.fsf_status) {
1577 case FSF_PORT_HANDLE_NOT_VALID: 1509 case FSF_PORT_HANDLE_NOT_VALID:
@@ -1586,9 +1518,6 @@ static void zfcp_fsf_close_port_handler(struct zfcp_fsf_req *req)
1586 ZFCP_CLEAR); 1518 ZFCP_CLEAR);
1587 break; 1519 break;
1588 } 1520 }
1589
1590skip_fsfstatus:
1591 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &port->status);
1592} 1521}
1593 1522
1594/** 1523/**
@@ -1598,12 +1527,12 @@ skip_fsfstatus:
1598 */ 1527 */
1599int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action) 1528int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1600{ 1529{
1601 volatile struct qdio_buffer_element *sbale; 1530 struct qdio_buffer_element *sbale;
1602 struct zfcp_adapter *adapter = erp_action->adapter; 1531 struct zfcp_adapter *adapter = erp_action->adapter;
1603 struct zfcp_fsf_req *req; 1532 struct zfcp_fsf_req *req;
1604 int retval = -EIO; 1533 int retval = -EIO;
1605 1534
1606 spin_lock_bh(&adapter->req_q.lock); 1535 spin_lock_bh(&adapter->req_q_lock);
1607 if (zfcp_fsf_req_sbal_get(adapter)) 1536 if (zfcp_fsf_req_sbal_get(adapter))
1608 goto out; 1537 goto out;
1609 1538
@@ -1624,7 +1553,6 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1624 req->erp_action = erp_action; 1553 req->erp_action = erp_action;
1625 req->qtcb->header.port_handle = erp_action->port->handle; 1554 req->qtcb->header.port_handle = erp_action->port->handle;
1626 erp_action->fsf_req = req; 1555 erp_action->fsf_req = req;
1627 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->port->status);
1628 1556
1629 zfcp_fsf_start_erp_timer(req); 1557 zfcp_fsf_start_erp_timer(req);
1630 retval = zfcp_fsf_req_send(req); 1558 retval = zfcp_fsf_req_send(req);
@@ -1633,7 +1561,131 @@ int zfcp_fsf_close_port(struct zfcp_erp_action *erp_action)
1633 erp_action->fsf_req = NULL; 1561 erp_action->fsf_req = NULL;
1634 } 1562 }
1635out: 1563out:
1636 spin_unlock_bh(&adapter->req_q.lock); 1564 spin_unlock_bh(&adapter->req_q_lock);
1565 return retval;
1566}
1567
1568static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
1569{
1570 struct zfcp_wka_port *wka_port = req->data;
1571 struct fsf_qtcb_header *header = &req->qtcb->header;
1572
1573 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) {
1574 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1575 goto out;
1576 }
1577
1578 switch (header->fsf_status) {
1579 case FSF_MAXIMUM_NUMBER_OF_PORTS_EXCEEDED:
1580 dev_warn(&req->adapter->ccw_device->dev,
1581 "Opening WKA port 0x%x failed\n", wka_port->d_id);
1582 case FSF_ADAPTER_STATUS_AVAILABLE:
1583 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1584 case FSF_ACCESS_DENIED:
1585 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1586 break;
1587 case FSF_PORT_ALREADY_OPEN:
1588 case FSF_GOOD:
1589 wka_port->handle = header->port_handle;
1590 wka_port->status = ZFCP_WKA_PORT_ONLINE;
1591 }
1592out:
1593 wake_up(&wka_port->completion_wq);
1594}
1595
1596/**
1597 * zfcp_fsf_open_wka_port - create and send open wka-port request
1598 * @wka_port: pointer to struct zfcp_wka_port
1599 * Returns: 0 on success, error otherwise
1600 */
1601int zfcp_fsf_open_wka_port(struct zfcp_wka_port *wka_port)
1602{
1603 struct qdio_buffer_element *sbale;
1604 struct zfcp_adapter *adapter = wka_port->adapter;
1605 struct zfcp_fsf_req *req;
1606 int retval = -EIO;
1607
1608 spin_lock_bh(&adapter->req_q_lock);
1609 if (zfcp_fsf_req_sbal_get(adapter))
1610 goto out;
1611
1612 req = zfcp_fsf_req_create(adapter,
1613 FSF_QTCB_OPEN_PORT_WITH_DID,
1614 ZFCP_REQ_AUTO_CLEANUP,
1615 adapter->pool.fsf_req_erp);
1616 if (unlikely(IS_ERR(req))) {
1617 retval = PTR_ERR(req);
1618 goto out;
1619 }
1620
1621 sbale = zfcp_qdio_sbale_req(req);
1622 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1623 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1624
1625 req->handler = zfcp_fsf_open_wka_port_handler;
1626 req->qtcb->bottom.support.d_id = wka_port->d_id;
1627 req->data = wka_port;
1628
1629 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1630 retval = zfcp_fsf_req_send(req);
1631 if (retval)
1632 zfcp_fsf_req_free(req);
1633out:
1634 spin_unlock_bh(&adapter->req_q_lock);
1635 return retval;
1636}
1637
1638static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
1639{
1640 struct zfcp_wka_port *wka_port = req->data;
1641
1642 if (req->qtcb->header.fsf_status == FSF_PORT_HANDLE_NOT_VALID) {
1643 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1644 zfcp_erp_adapter_reopen(wka_port->adapter, 0, 84, req);
1645 }
1646
1647 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1648 wake_up(&wka_port->completion_wq);
1649}
1650
1651/**
1652 * zfcp_fsf_close_wka_port - create and send close wka port request
1653 * @erp_action: pointer to struct zfcp_erp_action
1654 * Returns: 0 on success, error otherwise
1655 */
1656int zfcp_fsf_close_wka_port(struct zfcp_wka_port *wka_port)
1657{
1658 struct qdio_buffer_element *sbale;
1659 struct zfcp_adapter *adapter = wka_port->adapter;
1660 struct zfcp_fsf_req *req;
1661 int retval = -EIO;
1662
1663 spin_lock_bh(&adapter->req_q_lock);
1664 if (zfcp_fsf_req_sbal_get(adapter))
1665 goto out;
1666
1667 req = zfcp_fsf_req_create(adapter, FSF_QTCB_CLOSE_PORT,
1668 ZFCP_REQ_AUTO_CLEANUP,
1669 adapter->pool.fsf_req_erp);
1670 if (unlikely(IS_ERR(req))) {
1671 retval = PTR_ERR(req);
1672 goto out;
1673 }
1674
1675 sbale = zfcp_qdio_sbale_req(req);
1676 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
1677 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
1678
1679 req->handler = zfcp_fsf_close_wka_port_handler;
1680 req->data = wka_port;
1681 req->qtcb->header.port_handle = wka_port->handle;
1682
1683 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
1684 retval = zfcp_fsf_req_send(req);
1685 if (retval)
1686 zfcp_fsf_req_free(req);
1687out:
1688 spin_unlock_bh(&adapter->req_q_lock);
1637 return retval; 1689 return retval;
1638} 1690}
1639 1691
@@ -1695,12 +1747,12 @@ skip_fsfstatus:
1695 */ 1747 */
1696int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action) 1748int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1697{ 1749{
1698 volatile struct qdio_buffer_element *sbale; 1750 struct qdio_buffer_element *sbale;
1699 struct zfcp_adapter *adapter = erp_action->adapter; 1751 struct zfcp_adapter *adapter = erp_action->adapter;
1700 struct zfcp_fsf_req *req; 1752 struct zfcp_fsf_req *req;
1701 int retval = -EIO; 1753 int retval = -EIO;
1702 1754
1703 spin_lock_bh(&adapter->req_q.lock); 1755 spin_lock_bh(&adapter->req_q_lock);
1704 if (zfcp_fsf_req_sbal_get(adapter)) 1756 if (zfcp_fsf_req_sbal_get(adapter))
1705 goto out; 1757 goto out;
1706 1758
@@ -1731,7 +1783,7 @@ int zfcp_fsf_close_physical_port(struct zfcp_erp_action *erp_action)
1731 erp_action->fsf_req = NULL; 1783 erp_action->fsf_req = NULL;
1732 } 1784 }
1733out: 1785out:
1734 spin_unlock_bh(&adapter->req_q.lock); 1786 spin_unlock_bh(&adapter->req_q_lock);
1735 return retval; 1787 return retval;
1736} 1788}
1737 1789
@@ -1746,7 +1798,7 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1746 int exclusive, readwrite; 1798 int exclusive, readwrite;
1747 1799
1748 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 1800 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1749 goto skip_fsfstatus; 1801 return;
1750 1802
1751 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED | 1803 atomic_clear_mask(ZFCP_STATUS_COMMON_ACCESS_DENIED |
1752 ZFCP_STATUS_COMMON_ACCESS_BOXED | 1804 ZFCP_STATUS_COMMON_ACCESS_BOXED |
@@ -1774,14 +1826,12 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1774 case FSF_LUN_SHARING_VIOLATION: 1826 case FSF_LUN_SHARING_VIOLATION:
1775 if (header->fsf_status_qual.word[0]) 1827 if (header->fsf_status_qual.word[0])
1776 dev_warn(&adapter->ccw_device->dev, 1828 dev_warn(&adapter->ccw_device->dev,
1777 "FCP-LUN 0x%Lx at the remote port " 1829 "LUN 0x%Lx on port 0x%Lx is already in "
1778 "with WWPN 0x%Lx " 1830 "use by CSS%d, MIF Image ID %x\n",
1779 "connected to the adapter " 1831 (unsigned long long)unit->fcp_lun,
1780 "is already in use in LPAR%d, CSS%d.\n", 1832 (unsigned long long)unit->port->wwpn,
1781 unit->fcp_lun, 1833 queue_designator->cssid,
1782 unit->port->wwpn, 1834 queue_designator->hla);
1783 queue_designator->hla,
1784 queue_designator->cssid);
1785 else 1835 else
1786 zfcp_act_eval_err(adapter, 1836 zfcp_act_eval_err(adapter,
1787 header->fsf_status_qual.word[2]); 1837 header->fsf_status_qual.word[2]);
@@ -1792,9 +1842,10 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1792 break; 1842 break;
1793 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED: 1843 case FSF_MAXIMUM_NUMBER_OF_LUNS_EXCEEDED:
1794 dev_warn(&adapter->ccw_device->dev, 1844 dev_warn(&adapter->ccw_device->dev,
1795 "The adapter ran out of resources. There is no " 1845 "No handle is available for LUN "
1796 "handle available for unit 0x%016Lx on port 0x%016Lx.", 1846 "0x%016Lx on port 0x%016Lx\n",
1797 unit->fcp_lun, unit->port->wwpn); 1847 (unsigned long long)unit->fcp_lun,
1848 (unsigned long long)unit->port->wwpn);
1798 zfcp_erp_unit_failed(unit, 34, req); 1849 zfcp_erp_unit_failed(unit, 34, req);
1799 /* fall through */ 1850 /* fall through */
1800 case FSF_INVALID_COMMAND_OPTION: 1851 case FSF_INVALID_COMMAND_OPTION:
@@ -1831,26 +1882,29 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1831 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY, 1882 atomic_set_mask(ZFCP_STATUS_UNIT_READONLY,
1832 &unit->status); 1883 &unit->status);
1833 dev_info(&adapter->ccw_device->dev, 1884 dev_info(&adapter->ccw_device->dev,
1834 "Read-only access for unit 0x%016Lx " 1885 "SCSI device at LUN 0x%016Lx on port "
1835 "on port 0x%016Lx.\n", 1886 "0x%016Lx opened read-only\n",
1836 unit->fcp_lun, unit->port->wwpn); 1887 (unsigned long long)unit->fcp_lun,
1888 (unsigned long long)unit->port->wwpn);
1837 } 1889 }
1838 1890
1839 if (exclusive && !readwrite) { 1891 if (exclusive && !readwrite) {
1840 dev_err(&adapter->ccw_device->dev, 1892 dev_err(&adapter->ccw_device->dev,
1841 "Exclusive access of read-only unit " 1893 "Exclusive read-only access not "
1842 "0x%016Lx on port 0x%016Lx not " 1894 "supported (unit 0x%016Lx, "
1843 "supported, disabling unit.\n", 1895 "port 0x%016Lx)\n",
1844 unit->fcp_lun, unit->port->wwpn); 1896 (unsigned long long)unit->fcp_lun,
1897 (unsigned long long)unit->port->wwpn);
1845 zfcp_erp_unit_failed(unit, 35, req); 1898 zfcp_erp_unit_failed(unit, 35, req);
1846 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1899 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1847 zfcp_erp_unit_shutdown(unit, 0, 80, req); 1900 zfcp_erp_unit_shutdown(unit, 0, 80, req);
1848 } else if (!exclusive && readwrite) { 1901 } else if (!exclusive && readwrite) {
1849 dev_err(&adapter->ccw_device->dev, 1902 dev_err(&adapter->ccw_device->dev,
1850 "Shared access of read-write unit " 1903 "Shared read-write access not "
1851 "0x%016Lx on port 0x%016Lx not " 1904 "supported (unit 0x%016Lx, port "
1852 "supported, disabling unit.\n", 1905 "0x%016Lx\n)",
1853 unit->fcp_lun, unit->port->wwpn); 1906 (unsigned long long)unit->fcp_lun,
1907 (unsigned long long)unit->port->wwpn);
1854 zfcp_erp_unit_failed(unit, 36, req); 1908 zfcp_erp_unit_failed(unit, 36, req);
1855 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 1909 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
1856 zfcp_erp_unit_shutdown(unit, 0, 81, req); 1910 zfcp_erp_unit_shutdown(unit, 0, 81, req);
@@ -1858,9 +1912,6 @@ static void zfcp_fsf_open_unit_handler(struct zfcp_fsf_req *req)
1858 } 1912 }
1859 break; 1913 break;
1860 } 1914 }
1861
1862skip_fsfstatus:
1863 atomic_clear_mask(ZFCP_STATUS_COMMON_OPENING, &unit->status);
1864} 1915}
1865 1916
1866/** 1917/**
@@ -1870,12 +1921,12 @@ skip_fsfstatus:
1870 */ 1921 */
1871int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action) 1922int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1872{ 1923{
1873 volatile struct qdio_buffer_element *sbale; 1924 struct qdio_buffer_element *sbale;
1874 struct zfcp_adapter *adapter = erp_action->adapter; 1925 struct zfcp_adapter *adapter = erp_action->adapter;
1875 struct zfcp_fsf_req *req; 1926 struct zfcp_fsf_req *req;
1876 int retval = -EIO; 1927 int retval = -EIO;
1877 1928
1878 spin_lock_bh(&adapter->req_q.lock); 1929 spin_lock_bh(&adapter->req_q_lock);
1879 if (zfcp_fsf_req_sbal_get(adapter)) 1930 if (zfcp_fsf_req_sbal_get(adapter))
1880 goto out; 1931 goto out;
1881 1932
@@ -1901,8 +1952,6 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1901 if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE)) 1952 if (!(adapter->connection_features & FSF_FEATURE_NPIV_MODE))
1902 req->qtcb->bottom.support.option = FSF_OPEN_LUN_SUPPRESS_BOXING; 1953 req->qtcb->bottom.support.option = FSF_OPEN_LUN_SUPPRESS_BOXING;
1903 1954
1904 atomic_set_mask(ZFCP_STATUS_COMMON_OPENING, &erp_action->unit->status);
1905
1906 zfcp_fsf_start_erp_timer(req); 1955 zfcp_fsf_start_erp_timer(req);
1907 retval = zfcp_fsf_req_send(req); 1956 retval = zfcp_fsf_req_send(req);
1908 if (retval) { 1957 if (retval) {
@@ -1910,7 +1959,7 @@ int zfcp_fsf_open_unit(struct zfcp_erp_action *erp_action)
1910 erp_action->fsf_req = NULL; 1959 erp_action->fsf_req = NULL;
1911 } 1960 }
1912out: 1961out:
1913 spin_unlock_bh(&adapter->req_q.lock); 1962 spin_unlock_bh(&adapter->req_q_lock);
1914 return retval; 1963 return retval;
1915} 1964}
1916 1965
@@ -1919,7 +1968,7 @@ static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req)
1919 struct zfcp_unit *unit = req->data; 1968 struct zfcp_unit *unit = req->data;
1920 1969
1921 if (req->status & ZFCP_STATUS_FSFREQ_ERROR) 1970 if (req->status & ZFCP_STATUS_FSFREQ_ERROR)
1922 goto skip_fsfstatus; 1971 return;
1923 1972
1924 switch (req->qtcb->header.fsf_status) { 1973 switch (req->qtcb->header.fsf_status) {
1925 case FSF_PORT_HANDLE_NOT_VALID: 1974 case FSF_PORT_HANDLE_NOT_VALID:
@@ -1949,8 +1998,6 @@ static void zfcp_fsf_close_unit_handler(struct zfcp_fsf_req *req)
1949 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status); 1998 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, &unit->status);
1950 break; 1999 break;
1951 } 2000 }
1952skip_fsfstatus:
1953 atomic_clear_mask(ZFCP_STATUS_COMMON_CLOSING, &unit->status);
1954} 2001}
1955 2002
1956/** 2003/**
@@ -1960,12 +2007,12 @@ skip_fsfstatus:
1960 */ 2007 */
1961int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action) 2008int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
1962{ 2009{
1963 volatile struct qdio_buffer_element *sbale; 2010 struct qdio_buffer_element *sbale;
1964 struct zfcp_adapter *adapter = erp_action->adapter; 2011 struct zfcp_adapter *adapter = erp_action->adapter;
1965 struct zfcp_fsf_req *req; 2012 struct zfcp_fsf_req *req;
1966 int retval = -EIO; 2013 int retval = -EIO;
1967 2014
1968 spin_lock_bh(&adapter->req_q.lock); 2015 spin_lock_bh(&adapter->req_q_lock);
1969 if (zfcp_fsf_req_sbal_get(adapter)) 2016 if (zfcp_fsf_req_sbal_get(adapter))
1970 goto out; 2017 goto out;
1971 req = zfcp_fsf_req_create(adapter, FSF_QTCB_CLOSE_LUN, 2018 req = zfcp_fsf_req_create(adapter, FSF_QTCB_CLOSE_LUN,
@@ -1986,7 +2033,6 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
1986 req->data = erp_action->unit; 2033 req->data = erp_action->unit;
1987 req->erp_action = erp_action; 2034 req->erp_action = erp_action;
1988 erp_action->fsf_req = req; 2035 erp_action->fsf_req = req;
1989 atomic_set_mask(ZFCP_STATUS_COMMON_CLOSING, &erp_action->unit->status);
1990 2036
1991 zfcp_fsf_start_erp_timer(req); 2037 zfcp_fsf_start_erp_timer(req);
1992 retval = zfcp_fsf_req_send(req); 2038 retval = zfcp_fsf_req_send(req);
@@ -1995,7 +2041,7 @@ int zfcp_fsf_close_unit(struct zfcp_erp_action *erp_action)
1995 erp_action->fsf_req = NULL; 2041 erp_action->fsf_req = NULL;
1996 } 2042 }
1997out: 2043out:
1998 spin_unlock_bh(&adapter->req_q.lock); 2044 spin_unlock_bh(&adapter->req_q_lock);
1999 return retval; 2045 return retval;
2000} 2046}
2001 2047
@@ -2156,21 +2202,21 @@ static void zfcp_fsf_send_fcp_command_handler(struct zfcp_fsf_req *req)
2156 break; 2202 break;
2157 case FSF_DIRECTION_INDICATOR_NOT_VALID: 2203 case FSF_DIRECTION_INDICATOR_NOT_VALID:
2158 dev_err(&req->adapter->ccw_device->dev, 2204 dev_err(&req->adapter->ccw_device->dev,
2159 "Invalid data direction (%d) given for unit " 2205 "Incorrect direction %d, unit 0x%016Lx on port "
2160 "0x%016Lx on port 0x%016Lx, shutting down " 2206 "0x%016Lx closed\n",
2161 "adapter.\n",
2162 req->qtcb->bottom.io.data_direction, 2207 req->qtcb->bottom.io.data_direction,
2163 unit->fcp_lun, unit->port->wwpn); 2208 (unsigned long long)unit->fcp_lun,
2209 (unsigned long long)unit->port->wwpn);
2164 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 133, req); 2210 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 133, req);
2165 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2211 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2166 break; 2212 break;
2167 case FSF_CMND_LENGTH_NOT_VALID: 2213 case FSF_CMND_LENGTH_NOT_VALID:
2168 dev_err(&req->adapter->ccw_device->dev, 2214 dev_err(&req->adapter->ccw_device->dev,
2169 "An invalid control-data-block length field (%d) " 2215 "Incorrect CDB length %d, unit 0x%016Lx on "
2170 "was found in a command for unit 0x%016Lx on port " 2216 "port 0x%016Lx closed\n",
2171 "0x%016Lx. Shutting down adapter.\n",
2172 req->qtcb->bottom.io.fcp_cmnd_length, 2217 req->qtcb->bottom.io.fcp_cmnd_length,
2173 unit->fcp_lun, unit->port->wwpn); 2218 (unsigned long long)unit->fcp_lun,
2219 (unsigned long long)unit->port->wwpn);
2174 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 134, req); 2220 zfcp_erp_adapter_shutdown(unit->port->adapter, 0, 134, req);
2175 req->status |= ZFCP_STATUS_FSFREQ_ERROR; 2221 req->status |= ZFCP_STATUS_FSFREQ_ERROR;
2176 break; 2222 break;
@@ -2201,6 +2247,20 @@ skip_fsfstatus:
2201 } 2247 }
2202} 2248}
2203 2249
2250static void zfcp_set_fcp_dl(struct fcp_cmnd_iu *fcp_cmd, u32 fcp_dl)
2251{
2252 u32 *fcp_dl_ptr;
2253
2254 /*
2255 * fcp_dl_addr = start address of fcp_cmnd structure +
2256 * size of fixed part + size of dynamically sized add_dcp_cdb field
2257 * SEE FCP-2 documentation
2258 */
2259 fcp_dl_ptr = (u32 *) ((unsigned char *) &fcp_cmd[1] +
2260 (fcp_cmd->add_fcp_cdb_length << 2));
2261 *fcp_dl_ptr = fcp_dl;
2262}
2263
2204/** 2264/**
2205 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command) 2265 * zfcp_fsf_send_fcp_command_task - initiate an FCP command (for a SCSI command)
2206 * @adapter: adapter where scsi command is issued 2266 * @adapter: adapter where scsi command is issued
@@ -2223,8 +2283,8 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
2223 ZFCP_STATUS_COMMON_UNBLOCKED))) 2283 ZFCP_STATUS_COMMON_UNBLOCKED)))
2224 return -EBUSY; 2284 return -EBUSY;
2225 2285
2226 spin_lock(&adapter->req_q.lock); 2286 spin_lock(&adapter->req_q_lock);
2227 if (!atomic_read(&adapter->req_q.count)) 2287 if (!zfcp_fsf_sbal_available(adapter))
2228 goto out; 2288 goto out;
2229 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags, 2289 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
2230 adapter->pool.fsf_req_scsi); 2290 adapter->pool.fsf_req_scsi);
@@ -2286,7 +2346,7 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
2286 memcpy(fcp_cmnd_iu->fcp_cdb, scsi_cmnd->cmnd, scsi_cmnd->cmd_len); 2346 memcpy(fcp_cmnd_iu->fcp_cdb, scsi_cmnd->cmnd, scsi_cmnd->cmd_len);
2287 2347
2288 req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) + 2348 req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) +
2289 fcp_cmnd_iu->add_fcp_cdb_length + sizeof(fcp_dl_t); 2349 fcp_cmnd_iu->add_fcp_cdb_length + sizeof(u32);
2290 2350
2291 real_bytes = zfcp_qdio_sbals_from_sg(req, sbtype, 2351 real_bytes = zfcp_qdio_sbals_from_sg(req, sbtype,
2292 scsi_sglist(scsi_cmnd), 2352 scsi_sglist(scsi_cmnd),
@@ -2296,10 +2356,10 @@ int zfcp_fsf_send_fcp_command_task(struct zfcp_adapter *adapter,
2296 retval = -EIO; 2356 retval = -EIO;
2297 else { 2357 else {
2298 dev_err(&adapter->ccw_device->dev, 2358 dev_err(&adapter->ccw_device->dev,
2299 "SCSI request too large. " 2359 "Oversize data package, unit 0x%016Lx "
2300 "Shutting down unit 0x%016Lx on port " 2360 "on port 0x%016Lx closed\n",
2301 "0x%016Lx.\n", unit->fcp_lun, 2361 (unsigned long long)unit->fcp_lun,
2302 unit->port->wwpn); 2362 (unsigned long long)unit->port->wwpn);
2303 zfcp_erp_unit_shutdown(unit, 0, 131, req); 2363 zfcp_erp_unit_shutdown(unit, 0, 131, req);
2304 retval = -EINVAL; 2364 retval = -EINVAL;
2305 } 2365 }
@@ -2322,7 +2382,7 @@ failed_scsi_cmnd:
2322 zfcp_fsf_req_free(req); 2382 zfcp_fsf_req_free(req);
2323 scsi_cmnd->host_scribble = NULL; 2383 scsi_cmnd->host_scribble = NULL;
2324out: 2384out:
2325 spin_unlock(&adapter->req_q.lock); 2385 spin_unlock(&adapter->req_q_lock);
2326 return retval; 2386 return retval;
2327} 2387}
2328 2388
@@ -2338,7 +2398,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter,
2338 struct zfcp_unit *unit, 2398 struct zfcp_unit *unit,
2339 u8 tm_flags, int req_flags) 2399 u8 tm_flags, int req_flags)
2340{ 2400{
2341 volatile struct qdio_buffer_element *sbale; 2401 struct qdio_buffer_element *sbale;
2342 struct zfcp_fsf_req *req = NULL; 2402 struct zfcp_fsf_req *req = NULL;
2343 struct fcp_cmnd_iu *fcp_cmnd_iu; 2403 struct fcp_cmnd_iu *fcp_cmnd_iu;
2344 2404
@@ -2346,8 +2406,8 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter,
2346 ZFCP_STATUS_COMMON_UNBLOCKED))) 2406 ZFCP_STATUS_COMMON_UNBLOCKED)))
2347 return NULL; 2407 return NULL;
2348 2408
2349 spin_lock(&adapter->req_q.lock); 2409 spin_lock(&adapter->req_q_lock);
2350 if (!atomic_read(&adapter->req_q.count)) 2410 if (!zfcp_fsf_sbal_available(adapter))
2351 goto out; 2411 goto out;
2352 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags, 2412 req = zfcp_fsf_req_create(adapter, FSF_QTCB_FCP_CMND, req_flags,
2353 adapter->pool.fsf_req_scsi); 2413 adapter->pool.fsf_req_scsi);
@@ -2362,7 +2422,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter,
2362 req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND; 2422 req->qtcb->bottom.io.data_direction = FSF_DATADIR_CMND;
2363 req->qtcb->bottom.io.service_class = FSF_CLASS_3; 2423 req->qtcb->bottom.io.service_class = FSF_CLASS_3;
2364 req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) + 2424 req->qtcb->bottom.io.fcp_cmnd_length = sizeof(struct fcp_cmnd_iu) +
2365 sizeof(fcp_dl_t); 2425 sizeof(u32);
2366 2426
2367 sbale = zfcp_qdio_sbale_req(req); 2427 sbale = zfcp_qdio_sbale_req(req);
2368 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE; 2428 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE;
@@ -2379,7 +2439,7 @@ struct zfcp_fsf_req *zfcp_fsf_send_fcp_ctm(struct zfcp_adapter *adapter,
2379 zfcp_fsf_req_free(req); 2439 zfcp_fsf_req_free(req);
2380 req = NULL; 2440 req = NULL;
2381out: 2441out:
2382 spin_unlock(&adapter->req_q.lock); 2442 spin_unlock(&adapter->req_q_lock);
2383 return req; 2443 return req;
2384} 2444}
2385 2445
@@ -2398,7 +2458,7 @@ static void zfcp_fsf_control_file_handler(struct zfcp_fsf_req *req)
2398struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter, 2458struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2399 struct zfcp_fsf_cfdc *fsf_cfdc) 2459 struct zfcp_fsf_cfdc *fsf_cfdc)
2400{ 2460{
2401 volatile struct qdio_buffer_element *sbale; 2461 struct qdio_buffer_element *sbale;
2402 struct zfcp_fsf_req *req = NULL; 2462 struct zfcp_fsf_req *req = NULL;
2403 struct fsf_qtcb_bottom_support *bottom; 2463 struct fsf_qtcb_bottom_support *bottom;
2404 int direction, retval = -EIO, bytes; 2464 int direction, retval = -EIO, bytes;
@@ -2417,7 +2477,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2417 return ERR_PTR(-EINVAL); 2477 return ERR_PTR(-EINVAL);
2418 } 2478 }
2419 2479
2420 spin_lock_bh(&adapter->req_q.lock); 2480 spin_lock_bh(&adapter->req_q_lock);
2421 if (zfcp_fsf_req_sbal_get(adapter)) 2481 if (zfcp_fsf_req_sbal_get(adapter))
2422 goto out; 2482 goto out;
2423 2483
@@ -2447,7 +2507,7 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2447 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT); 2507 zfcp_fsf_start_timer(req, ZFCP_FSF_REQUEST_TIMEOUT);
2448 retval = zfcp_fsf_req_send(req); 2508 retval = zfcp_fsf_req_send(req);
2449out: 2509out:
2450 spin_unlock_bh(&adapter->req_q.lock); 2510 spin_unlock_bh(&adapter->req_q_lock);
2451 2511
2452 if (!retval) { 2512 if (!retval) {
2453 wait_event(req->completion_wq, 2513 wait_event(req->completion_wq,