aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSwen Schillig <swen@vnet.ibm.com>2009-08-18 09:43:22 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-09-05 09:49:32 -0400
commitd5a282a1c5084ec7ebd9e6ab9723317f6b3fcd7b (patch)
treea215cde519ca65b129d35d8d435061b48ab3864c
parent5771710bd5edfafcb8656f49b93690a6fae5a4d2 (diff)
[SCSI] zfcp: introduce _setup, _destroy for qdio and FC
Extract independent data structures and introduce common _setup and _destroy routines for QDIO and Fibre Channel related data structures Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
-rw-r--r--drivers/s390/scsi/zfcp_aux.c42
-rw-r--r--drivers/s390/scsi/zfcp_ext.h7
-rw-r--r--drivers/s390/scsi/zfcp_fc.c36
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c68
4 files changed, 89 insertions, 64 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 7a50f64c36bd..c77686ed938c 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -506,30 +506,18 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
506 if (!adapter) 506 if (!adapter)
507 return -ENOMEM; 507 return -ENOMEM;
508 508
509 adapter->gs = kzalloc(sizeof(struct zfcp_wka_ports), GFP_KERNEL);
510 if (!adapter->gs) {
511 kfree(adapter);
512 return -ENOMEM;
513 }
514
515 adapter->qdio = kzalloc(sizeof(struct zfcp_qdio), GFP_KERNEL);
516 if (!adapter->qdio)
517 goto qdio_mem_failed;
518
519 adapter->qdio->adapter = adapter;
520
521 ccw_device->handler = NULL; 509 ccw_device->handler = NULL;
522 adapter->ccw_device = ccw_device; 510 adapter->ccw_device = ccw_device;
523 atomic_set(&adapter->refcount, 0); 511 atomic_set(&adapter->refcount, 0);
524 512
525 if (zfcp_qdio_allocate(adapter->qdio, ccw_device)) 513 if (zfcp_qdio_setup(adapter))
526 goto qdio_allocate_failed; 514 goto qdio_failed;
527 515
528 if (zfcp_allocate_low_mem_buffers(adapter)) 516 if (zfcp_allocate_low_mem_buffers(adapter))
529 goto failed_low_mem_buffers; 517 goto low_mem_buffers_failed;
530 518
531 if (zfcp_reqlist_alloc(adapter)) 519 if (zfcp_reqlist_alloc(adapter))
532 goto failed_low_mem_buffers; 520 goto low_mem_buffers_failed;
533 521
534 if (zfcp_dbf_adapter_register(adapter)) 522 if (zfcp_dbf_adapter_register(adapter))
535 goto debug_register_failed; 523 goto debug_register_failed;
@@ -537,6 +525,9 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
537 if (zfcp_setup_adapter_work_queue(adapter)) 525 if (zfcp_setup_adapter_work_queue(adapter))
538 goto work_queue_failed; 526 goto work_queue_failed;
539 527
528 if (zfcp_fc_gs_setup(adapter))
529 goto generic_services_failed;
530
540 init_waitqueue_head(&adapter->remove_wq); 531 init_waitqueue_head(&adapter->remove_wq);
541 init_waitqueue_head(&adapter->erp_thread_wqh); 532 init_waitqueue_head(&adapter->erp_thread_wqh);
542 init_waitqueue_head(&adapter->erp_done_wqh); 533 init_waitqueue_head(&adapter->erp_done_wqh);
@@ -547,9 +538,6 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
547 538
548 spin_lock_init(&adapter->req_list_lock); 539 spin_lock_init(&adapter->req_list_lock);
549 540
550 spin_lock_init(&adapter->qdio->req_q_lock);
551 spin_lock_init(&adapter->qdio->stat_lock);
552
553 rwlock_init(&adapter->erp_lock); 541 rwlock_init(&adapter->erp_lock);
554 rwlock_init(&adapter->abort_lock); 542 rwlock_init(&adapter->abort_lock);
555 543
@@ -570,24 +558,23 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
570 goto sysfs_failed; 558 goto sysfs_failed;
571 559
572 atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status); 560 atomic_clear_mask(ZFCP_STATUS_COMMON_REMOVE, &adapter->status);
573 zfcp_fc_wka_ports_init(adapter);
574 561
575 if (!zfcp_adapter_scsi_register(adapter)) 562 if (!zfcp_adapter_scsi_register(adapter))
576 return 0; 563 return 0;
577 564
578sysfs_failed: 565sysfs_failed:
566 zfcp_fc_gs_destroy(adapter);
567generic_services_failed:
579 zfcp_destroy_adapter_work_queue(adapter); 568 zfcp_destroy_adapter_work_queue(adapter);
580work_queue_failed: 569work_queue_failed:
581 zfcp_dbf_adapter_unregister(adapter->dbf); 570 zfcp_dbf_adapter_unregister(adapter->dbf);
582debug_register_failed: 571debug_register_failed:
583 dev_set_drvdata(&ccw_device->dev, NULL); 572 dev_set_drvdata(&ccw_device->dev, NULL);
584 kfree(adapter->req_list); 573 kfree(adapter->req_list);
585failed_low_mem_buffers: 574low_mem_buffers_failed:
586 zfcp_free_low_mem_buffers(adapter); 575 zfcp_free_low_mem_buffers(adapter);
587qdio_allocate_failed: 576qdio_failed:
588 zfcp_qdio_free(adapter->qdio); 577 zfcp_qdio_destroy(adapter->qdio);
589 kfree(adapter->qdio);
590qdio_mem_failed:
591 kfree(adapter); 578 kfree(adapter);
592 return -ENOMEM; 579 return -ENOMEM;
593} 580}
@@ -616,15 +603,14 @@ void zfcp_adapter_dequeue(struct zfcp_adapter *adapter)
616 if (!retval) 603 if (!retval)
617 return; 604 return;
618 605
606 zfcp_fc_gs_destroy(adapter);
619 zfcp_destroy_adapter_work_queue(adapter); 607 zfcp_destroy_adapter_work_queue(adapter);
620 zfcp_dbf_adapter_unregister(adapter->dbf); 608 zfcp_dbf_adapter_unregister(adapter->dbf);
621 zfcp_qdio_free(adapter->qdio);
622 zfcp_free_low_mem_buffers(adapter); 609 zfcp_free_low_mem_buffers(adapter);
610 zfcp_qdio_destroy(adapter->qdio);
623 kfree(adapter->req_list); 611 kfree(adapter->req_list);
624 kfree(adapter->fc_stats); 612 kfree(adapter->fc_stats);
625 kfree(adapter->stats_reset_data); 613 kfree(adapter->stats_reset_data);
626 kfree(adapter->gs);
627 kfree(adapter->qdio);
628 kfree(adapter); 614 kfree(adapter);
629} 615}
630 616
diff --git a/drivers/s390/scsi/zfcp_ext.h b/drivers/s390/scsi/zfcp_ext.h
index a49d00921b92..cf09b2838c50 100644
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -100,7 +100,8 @@ extern void zfcp_fc_plogi_evaluate(struct zfcp_port *, struct fsf_plogi *);
100extern void zfcp_test_link(struct zfcp_port *); 100extern void zfcp_test_link(struct zfcp_port *);
101extern void zfcp_fc_link_test_work(struct work_struct *); 101extern void zfcp_fc_link_test_work(struct work_struct *);
102extern void zfcp_fc_wka_ports_force_offline(struct zfcp_wka_ports *); 102extern void zfcp_fc_wka_ports_force_offline(struct zfcp_wka_ports *);
103extern void zfcp_fc_wka_ports_init(struct zfcp_adapter *); 103extern int zfcp_fc_gs_setup(struct zfcp_adapter *);
104extern void zfcp_fc_gs_destroy(struct zfcp_adapter *);
104extern int zfcp_fc_execute_els_fc_job(struct fc_bsg_job *); 105extern int zfcp_fc_execute_els_fc_job(struct fc_bsg_job *);
105extern int zfcp_fc_execute_ct_fc_job(struct fc_bsg_job *); 106extern int zfcp_fc_execute_ct_fc_job(struct fc_bsg_job *);
106 107
@@ -134,8 +135,8 @@ extern struct zfcp_fsf_req *zfcp_fsf_abort_fcp_command(unsigned long,
134extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int); 135extern void zfcp_fsf_reqid_check(struct zfcp_qdio *, int);
135 136
136/* zfcp_qdio.c */ 137/* zfcp_qdio.c */
137extern int zfcp_qdio_allocate(struct zfcp_qdio *, struct ccw_device *); 138extern int zfcp_qdio_setup(struct zfcp_adapter *);
138extern void zfcp_qdio_free(struct zfcp_qdio *); 139extern void zfcp_qdio_destroy(struct zfcp_qdio *);
139extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_queue_req *); 140extern int zfcp_qdio_send(struct zfcp_qdio *, struct zfcp_queue_req *);
140extern struct qdio_buffer_element 141extern struct qdio_buffer_element
141 *zfcp_qdio_sbale_req(struct zfcp_qdio *, struct zfcp_queue_req *); 142 *zfcp_qdio_sbale_req(struct zfcp_qdio *, struct zfcp_queue_req *);
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index 309f1dfad3f9..db8bb41a7794 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -141,17 +141,6 @@ void zfcp_fc_wka_ports_force_offline(struct zfcp_wka_ports *gs)
141 zfcp_fc_wka_port_force_offline(&gs->ks); 141 zfcp_fc_wka_port_force_offline(&gs->ks);
142} 142}
143 143
144void zfcp_fc_wka_ports_init(struct zfcp_adapter *adapter)
145{
146 struct zfcp_wka_ports *gs = adapter->gs;
147
148 zfcp_fc_wka_port_init(&gs->ms, FC_FID_MGMT_SERV, adapter);
149 zfcp_fc_wka_port_init(&gs->ts, FC_FID_TIME_SERV, adapter);
150 zfcp_fc_wka_port_init(&gs->ds, FC_FID_DIR_SERV, adapter);
151 zfcp_fc_wka_port_init(&gs->as, FC_FID_ALIASES, adapter);
152 zfcp_fc_wka_port_init(&gs->ks, FC_FID_SEC_KEY, adapter);
153}
154
155static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range, 144static void _zfcp_fc_incoming_rscn(struct zfcp_fsf_req *fsf_req, u32 range,
156 struct fcp_rscn_element *elem) 145 struct fcp_rscn_element *elem)
157{ 146{
@@ -870,3 +859,28 @@ int zfcp_fc_execute_ct_fc_job(struct fc_bsg_job *job)
870 } 859 }
871 return ret; 860 return ret;
872} 861}
862
863int zfcp_fc_gs_setup(struct zfcp_adapter *adapter)
864{
865 struct zfcp_wka_ports *wka_ports;
866
867 wka_ports = kzalloc(sizeof(struct zfcp_wka_ports), GFP_KERNEL);
868 if (!wka_ports)
869 return -ENOMEM;
870
871 adapter->gs = wka_ports;
872 zfcp_fc_wka_port_init(&wka_ports->ms, FC_FID_MGMT_SERV, adapter);
873 zfcp_fc_wka_port_init(&wka_ports->ts, FC_FID_TIME_SERV, adapter);
874 zfcp_fc_wka_port_init(&wka_ports->ds, FC_FID_DIR_SERV, adapter);
875 zfcp_fc_wka_port_init(&wka_ports->as, FC_FID_ALIASES, adapter);
876 zfcp_fc_wka_port_init(&wka_ports->ks, FC_FID_SEC_KEY, adapter);
877
878 return 0;
879}
880
881void zfcp_fc_gs_destroy(struct zfcp_adapter *adapter)
882{
883 kfree(adapter->gs);
884 adapter->gs = NULL;
885}
886
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index 84527ebbbe58..2b499e28ff1f 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -34,27 +34,6 @@ zfcp_qdio_sbale(struct zfcp_qdio_queue *q, int sbal_idx, int sbale_idx)
34 return &q->sbal[sbal_idx]->element[sbale_idx]; 34 return &q->sbal[sbal_idx]->element[sbale_idx];
35} 35}
36 36
37/**
38 * zfcp_qdio_free - free memory used by request- and resposne queue
39 * @qdio: pointer to the zfcp_qdio structure
40 */
41void zfcp_qdio_free(struct zfcp_qdio *qdio)
42{
43 struct qdio_buffer **sbal_req, **sbal_resp;
44 int p;
45
46 if (qdio->adapter->ccw_device)
47 qdio_free(qdio->adapter->ccw_device);
48
49 sbal_req = qdio->req_q.sbal;
50 sbal_resp = qdio->resp_q.sbal;
51
52 for (p = 0; p < QDIO_MAX_BUFFERS_PER_Q; p += QBUFF_PER_PAGE) {
53 free_page((unsigned long) sbal_req[p]);
54 free_page((unsigned long) sbal_resp[p]);
55 }
56}
57
58static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id) 37static void zfcp_qdio_handler_error(struct zfcp_qdio *qdio, char *id)
59{ 38{
60 struct zfcp_adapter *adapter = qdio->adapter; 39 struct zfcp_adapter *adapter = qdio->adapter;
@@ -383,7 +362,7 @@ static void zfcp_qdio_setup_init_data(struct qdio_initialize *id,
383 * Returns: -ENOMEM on memory allocation error or return value from 362 * Returns: -ENOMEM on memory allocation error or return value from
384 * qdio_allocate 363 * qdio_allocate
385 */ 364 */
386int zfcp_qdio_allocate(struct zfcp_qdio *qdio, struct ccw_device *ccw_dev) 365static int zfcp_qdio_allocate(struct zfcp_qdio *qdio)
387{ 366{
388 struct qdio_initialize init_data; 367 struct qdio_initialize init_data;
389 368
@@ -477,3 +456,48 @@ failed_establish:
477 "Setting up the QDIO connection to the FCP adapter failed\n"); 456 "Setting up the QDIO connection to the FCP adapter failed\n");
478 return -EIO; 457 return -EIO;
479} 458}
459
460void zfcp_qdio_destroy(struct zfcp_qdio *qdio)
461{
462 struct qdio_buffer **sbal_req, **sbal_resp;
463 int p;
464
465 if (!qdio)
466 return;
467
468 if (qdio->adapter->ccw_device)
469 qdio_free(qdio->adapter->ccw_device);
470
471 sbal_req = qdio->req_q.sbal;
472 sbal_resp = qdio->resp_q.sbal;
473
474 for (p = 0; p < QDIO_MAX_BUFFERS_PER_Q; p += QBUFF_PER_PAGE) {
475 free_page((unsigned long) sbal_req[p]);
476 free_page((unsigned long) sbal_resp[p]);
477 }
478
479 kfree(qdio);
480}
481
482int zfcp_qdio_setup(struct zfcp_adapter *adapter)
483{
484 struct zfcp_qdio *qdio;
485
486 qdio = kzalloc(sizeof(struct zfcp_qdio), GFP_KERNEL);
487 if (!qdio)
488 return -ENOMEM;
489
490 qdio->adapter = adapter;
491
492 if (zfcp_qdio_allocate(qdio)) {
493 zfcp_qdio_destroy(qdio);
494 return -ENOMEM;
495 }
496
497 spin_lock_init(&qdio->req_q_lock);
498 spin_lock_init(&qdio->stat_lock);
499
500 adapter->qdio = qdio;
501 return 0;
502}
503