aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_erp.c
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@de.ibm.com>2008-06-10 12:20:54 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-07-12 09:22:25 -0400
commit24073b475d6d2bad8880434a16343ee1da816ea5 (patch)
tree27cf64817f5aa9020692b88366a46743b11db6d3 /drivers/s390/scsi/zfcp_erp.c
parent6362abd3e00d3161affad996fa53cc69a01fc6d1 (diff)
[SCSI] zfcp: Move FC code to new file
Move all Fibre Channel related code to new file and cleanup the code while doing so. Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/s390/scsi/zfcp_erp.c')
-rw-r--r--drivers/s390/scsi/zfcp_erp.c188
1 files changed, 1 insertions, 187 deletions
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index d05b37054897..ee19be13e708 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -23,9 +23,6 @@
23 23
24#include "zfcp_ext.h" 24#include "zfcp_ext.h"
25 25
26static int zfcp_erp_adisc(struct zfcp_port *);
27static void zfcp_erp_adisc_handler(unsigned long);
28
29static int zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *, int, u8, 26static int zfcp_erp_adapter_reopen_internal(struct zfcp_adapter *, int, u8,
30 void *); 27 void *);
31static int zfcp_erp_port_forced_reopen_internal(struct zfcp_port *, int, u8, 28static int zfcp_erp_port_forced_reopen_internal(struct zfcp_port *, int, u8,
@@ -292,189 +289,6 @@ int zfcp_erp_unit_shutdown(struct zfcp_unit *unit, int clear_mask, u8 id,
292 return retval; 289 return retval;
293} 290}
294 291
295
296/**
297 * zfcp_erp_adisc - send ADISC ELS command
298 * @port: port structure
299 */
300static int
301zfcp_erp_adisc(struct zfcp_port *port)
302{
303 struct zfcp_adapter *adapter = port->adapter;
304 struct zfcp_send_els *send_els;
305 struct zfcp_ls_adisc *adisc;
306 void *address = NULL;
307 int retval = 0;
308
309 send_els = kzalloc(sizeof(struct zfcp_send_els), GFP_ATOMIC);
310 if (send_els == NULL)
311 goto nomem;
312
313 send_els->req = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
314 if (send_els->req == NULL)
315 goto nomem;
316 sg_init_table(send_els->req, 1);
317
318 send_els->resp = kmalloc(sizeof(struct scatterlist), GFP_ATOMIC);
319 if (send_els->resp == NULL)
320 goto nomem;
321 sg_init_table(send_els->resp, 1);
322
323 address = (void *) get_zeroed_page(GFP_ATOMIC);
324 if (address == NULL)
325 goto nomem;
326
327 zfcp_address_to_sg(address, send_els->req, sizeof(struct zfcp_ls_adisc));
328 address += PAGE_SIZE >> 1;
329 zfcp_address_to_sg(address, send_els->resp, sizeof(struct zfcp_ls_adisc_acc));
330 send_els->req_count = send_els->resp_count = 1;
331
332 send_els->adapter = adapter;
333 send_els->port = port;
334 send_els->d_id = port->d_id;
335 send_els->handler = zfcp_erp_adisc_handler;
336 send_els->handler_data = (unsigned long) send_els;
337
338 adisc = zfcp_sg_to_address(send_els->req);
339 send_els->ls_code = adisc->code = ZFCP_LS_ADISC;
340
341 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
342 without FC-AL-2 capability, so we don't set it */
343 adisc->wwpn = fc_host_port_name(adapter->scsi_host);
344 adisc->wwnn = fc_host_node_name(adapter->scsi_host);
345 adisc->nport_id = fc_host_port_id(adapter->scsi_host);
346 ZFCP_LOG_INFO("ADISC request from s_id 0x%06x to d_id 0x%06x "
347 "(wwpn=0x%016Lx, wwnn=0x%016Lx, "
348 "hard_nport_id=0x%06x, nport_id=0x%06x)\n",
349 adisc->nport_id, send_els->d_id, (wwn_t) adisc->wwpn,
350 (wwn_t) adisc->wwnn, adisc->hard_nport_id,
351 adisc->nport_id);
352
353 retval = zfcp_fsf_send_els(send_els);
354 if (retval != 0) {
355 ZFCP_LOG_NORMAL("error: initiation of Send ELS failed for port "
356 "0x%06x on adapter %s\n", send_els->d_id,
357 zfcp_get_busid_by_adapter(adapter));
358 goto freemem;
359 }
360
361 goto out;
362
363 nomem:
364 retval = -ENOMEM;
365 freemem:
366 if (address != NULL)
367 __free_pages(sg_page(send_els->req), 0);
368 if (send_els != NULL) {
369 kfree(send_els->req);
370 kfree(send_els->resp);
371 kfree(send_els);
372 }
373 out:
374 return retval;
375}
376
377
378/**
379 * zfcp_erp_adisc_handler - handler for ADISC ELS command
380 * @data: pointer to struct zfcp_send_els
381 *
382 * If ADISC failed (LS_RJT or timed out) forced reopen of the port is triggered.
383 */
384static void
385zfcp_erp_adisc_handler(unsigned long data)
386{
387 struct zfcp_send_els *send_els;
388 struct zfcp_port *port;
389 struct zfcp_adapter *adapter;
390 u32 d_id;
391 struct zfcp_ls_adisc_acc *adisc;
392
393 send_els = (struct zfcp_send_els *) data;
394 adapter = send_els->adapter;
395 port = send_els->port;
396 d_id = send_els->d_id;
397
398 /* request rejected or timed out */
399 if (send_els->status != 0) {
400 ZFCP_LOG_NORMAL("ELS request rejected/timed out, "
401 "force physical port reopen "
402 "(adapter %s, port d_id=0x%06x)\n",
403 zfcp_get_busid_by_adapter(adapter), d_id);
404 if (zfcp_erp_port_forced_reopen(port, 0, 63, NULL))
405 ZFCP_LOG_NORMAL("failed reopen of port "
406 "(adapter %s, wwpn=0x%016Lx)\n",
407 zfcp_get_busid_by_port(port),
408 port->wwpn);
409 goto out;
410 }
411
412 adisc = zfcp_sg_to_address(send_els->resp);
413
414 ZFCP_LOG_INFO("ADISC response from d_id 0x%06x to s_id "
415 "0x%06x (wwpn=0x%016Lx, wwnn=0x%016Lx, "
416 "hard_nport_id=0x%06x, nport_id=0x%06x)\n",
417 d_id, fc_host_port_id(adapter->scsi_host),
418 (wwn_t) adisc->wwpn, (wwn_t) adisc->wwnn,
419 adisc->hard_nport_id, adisc->nport_id);
420
421 /* set wwnn for port */
422 if (port->wwnn == 0)
423 port->wwnn = adisc->wwnn;
424
425 if (port->wwpn != adisc->wwpn) {
426 ZFCP_LOG_NORMAL("d_id assignment changed, reopening "
427 "port (adapter %s, wwpn=0x%016Lx, "
428 "adisc_resp_wwpn=0x%016Lx)\n",
429 zfcp_get_busid_by_port(port),
430 port->wwpn, (wwn_t) adisc->wwpn);
431 if (zfcp_erp_port_reopen(port, 0, 64, NULL))
432 ZFCP_LOG_NORMAL("failed reopen of port "
433 "(adapter %s, wwpn=0x%016Lx)\n",
434 zfcp_get_busid_by_port(port),
435 port->wwpn);
436 }
437
438 out:
439 zfcp_port_put(port);
440 __free_pages(sg_page(send_els->req), 0);
441 kfree(send_els->req);
442 kfree(send_els->resp);
443 kfree(send_els);
444}
445
446
447/**
448 * zfcp_test_link - lightweight link test procedure
449 * @port: port to be tested
450 *
451 * Test status of a link to a remote port using the ELS command ADISC.
452 */
453int
454zfcp_test_link(struct zfcp_port *port)
455{
456 int retval;
457
458 zfcp_port_get(port);
459 retval = zfcp_erp_adisc(port);
460 if (retval != 0 && retval != -EBUSY) {
461 zfcp_port_put(port);
462 ZFCP_LOG_NORMAL("reopen needed for port 0x%016Lx "
463 "on adapter %s\n ", port->wwpn,
464 zfcp_get_busid_by_port(port));
465 retval = zfcp_erp_port_forced_reopen(port, 0, 65, NULL);
466 if (retval != 0) {
467 ZFCP_LOG_NORMAL("reopen of remote port 0x%016Lx "
468 "on adapter %s failed\n", port->wwpn,
469 zfcp_get_busid_by_port(port));
470 retval = -EPERM;
471 }
472 }
473
474 return retval;
475}
476
477
478/* 292/*
479 * function: 293 * function:
480 * 294 *
@@ -2564,7 +2378,7 @@ zfcp_erp_port_strategy_open_common_lookup(struct zfcp_erp_action *erp_action)
2564{ 2378{
2565 int retval; 2379 int retval;
2566 2380
2567 retval = zfcp_ns_gid_pn_request(erp_action); 2381 retval = zfcp_fc_ns_gid_pn_request(erp_action);
2568 if (retval == -ENOMEM) { 2382 if (retval == -ENOMEM) {
2569 retval = ZFCP_ERP_NOMEM; 2383 retval = ZFCP_ERP_NOMEM;
2570 goto out; 2384 goto out;