diff options
author | Christof Schmitt <christof.schmitt@de.ibm.com> | 2011-02-22 13:54:43 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2011-02-25 12:02:09 -0500 |
commit | f9773229be6d8a3caa4c9dfc2961a63ab51a4e2a (patch) | |
tree | 4970f351a9b82ed9487f8f23933b7008e650cc25 /drivers/s390/scsi/zfcp_fc.c | |
parent | fcf7e6144df60cd5082e5bc52f1ca5d1ca99a2d6 (diff) |
[SCSI] zfcp: Use common FC kmem_cache for GPN_FT request
Switch the allocation of the GPN_FT request data to the FC kmem_cache
and remove the zfcp_gpn kmem_cache.
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390/scsi/zfcp_fc.c')
-rw-r--r-- | drivers/s390/scsi/zfcp_fc.c | 87 |
1 files changed, 31 insertions, 56 deletions
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c index 982455603349..c839a3b6879d 100644 --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c | |||
@@ -528,68 +528,42 @@ void zfcp_fc_test_link(struct zfcp_port *port) | |||
528 | put_device(&port->dev); | 528 | put_device(&port->dev); |
529 | } | 529 | } |
530 | 530 | ||
531 | static void zfcp_free_sg_env(struct zfcp_fc_gpn_ft *gpn_ft, int buf_num) | 531 | static struct zfcp_fc_req *zfcp_alloc_sg_env(int buf_num) |
532 | { | 532 | { |
533 | struct scatterlist *sg = &gpn_ft->sg_req; | 533 | struct zfcp_fc_req *fc_req; |
534 | |||
535 | kmem_cache_free(zfcp_data.gpn_ft_cache, sg_virt(sg)); | ||
536 | zfcp_sg_free_table(gpn_ft->sg_resp, buf_num); | ||
537 | |||
538 | kfree(gpn_ft); | ||
539 | } | ||
540 | |||
541 | static struct zfcp_fc_gpn_ft *zfcp_alloc_sg_env(int buf_num) | ||
542 | { | ||
543 | struct zfcp_fc_gpn_ft *gpn_ft; | ||
544 | struct zfcp_fc_gpn_ft_req *req; | ||
545 | 534 | ||
546 | gpn_ft = kzalloc(sizeof(*gpn_ft), GFP_KERNEL); | 535 | fc_req = kmem_cache_zalloc(zfcp_fc_req_cache, GFP_KERNEL); |
547 | if (!gpn_ft) | 536 | if (!fc_req) |
548 | return NULL; | 537 | return NULL; |
549 | 538 | ||
550 | req = kmem_cache_zalloc(zfcp_data.gpn_ft_cache, GFP_KERNEL); | 539 | if (zfcp_sg_setup_table(&fc_req->sg_rsp, buf_num)) { |
551 | if (!req) { | 540 | kmem_cache_free(zfcp_fc_req_cache, fc_req); |
552 | kfree(gpn_ft); | 541 | return NULL; |
553 | gpn_ft = NULL; | ||
554 | goto out; | ||
555 | } | 542 | } |
556 | sg_init_one(&gpn_ft->sg_req, req, sizeof(*req)); | ||
557 | 543 | ||
558 | if (zfcp_sg_setup_table(gpn_ft->sg_resp, buf_num)) { | 544 | sg_init_one(&fc_req->sg_req, &fc_req->u.gpn_ft.req, |
559 | zfcp_free_sg_env(gpn_ft, buf_num); | 545 | sizeof(struct zfcp_fc_gpn_ft_req)); |
560 | gpn_ft = NULL; | ||
561 | } | ||
562 | out: | ||
563 | return gpn_ft; | ||
564 | } | ||
565 | 546 | ||
547 | return fc_req; | ||
548 | } | ||
566 | 549 | ||
567 | static int zfcp_fc_send_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, | 550 | static int zfcp_fc_send_gpn_ft(struct zfcp_fc_req *fc_req, |
568 | struct zfcp_adapter *adapter, int max_bytes) | 551 | struct zfcp_adapter *adapter, int max_bytes) |
569 | { | 552 | { |
570 | struct zfcp_fsf_ct_els *ct = &gpn_ft->ct; | 553 | struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; |
571 | struct zfcp_fc_gpn_ft_req *req = sg_virt(&gpn_ft->sg_req); | 554 | struct zfcp_fc_gpn_ft_req *req = &fc_req->u.gpn_ft.req; |
572 | DECLARE_COMPLETION_ONSTACK(completion); | 555 | DECLARE_COMPLETION_ONSTACK(completion); |
573 | int ret; | 556 | int ret; |
574 | 557 | ||
575 | /* prepare CT IU for GPN_FT */ | 558 | zfcp_fc_ct_ns_init(&req->ct_hdr, FC_NS_GPN_FT, max_bytes); |
576 | req->ct_hdr.ct_rev = FC_CT_REV; | ||
577 | req->ct_hdr.ct_fs_type = FC_FST_DIR; | ||
578 | req->ct_hdr.ct_fs_subtype = FC_NS_SUBTYPE; | ||
579 | req->ct_hdr.ct_options = 0; | ||
580 | req->ct_hdr.ct_cmd = FC_NS_GPN_FT; | ||
581 | req->ct_hdr.ct_mr_size = max_bytes / 4; | ||
582 | req->gpn_ft.fn_domain_id_scope = 0; | ||
583 | req->gpn_ft.fn_area_id_scope = 0; | ||
584 | req->gpn_ft.fn_fc4_type = FC_TYPE_FCP; | 559 | req->gpn_ft.fn_fc4_type = FC_TYPE_FCP; |
585 | 560 | ||
586 | /* prepare zfcp_send_ct */ | 561 | ct_els->handler = zfcp_fc_complete; |
587 | ct->handler = zfcp_fc_complete; | 562 | ct_els->handler_data = &completion; |
588 | ct->handler_data = &completion; | 563 | ct_els->req = &fc_req->sg_req; |
589 | ct->req = &gpn_ft->sg_req; | 564 | ct_els->resp = &fc_req->sg_rsp; |
590 | ct->resp = gpn_ft->sg_resp; | ||
591 | 565 | ||
592 | ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct, NULL, | 566 | ret = zfcp_fsf_send_ct(&adapter->gs->ds, ct_els, NULL, |
593 | ZFCP_FC_CTELS_TMO); | 567 | ZFCP_FC_CTELS_TMO); |
594 | if (!ret) | 568 | if (!ret) |
595 | wait_for_completion(&completion); | 569 | wait_for_completion(&completion); |
@@ -610,11 +584,11 @@ static void zfcp_fc_validate_port(struct zfcp_port *port, struct list_head *lh) | |||
610 | list_move_tail(&port->list, lh); | 584 | list_move_tail(&port->list, lh); |
611 | } | 585 | } |
612 | 586 | ||
613 | static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, | 587 | static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_req *fc_req, |
614 | struct zfcp_adapter *adapter, int max_entries) | 588 | struct zfcp_adapter *adapter, int max_entries) |
615 | { | 589 | { |
616 | struct zfcp_fsf_ct_els *ct = &gpn_ft->ct; | 590 | struct zfcp_fsf_ct_els *ct_els = &fc_req->ct_els; |
617 | struct scatterlist *sg = gpn_ft->sg_resp; | 591 | struct scatterlist *sg = &fc_req->sg_rsp; |
618 | struct fc_ct_hdr *hdr = sg_virt(sg); | 592 | struct fc_ct_hdr *hdr = sg_virt(sg); |
619 | struct fc_gpn_ft_resp *acc = sg_virt(sg); | 593 | struct fc_gpn_ft_resp *acc = sg_virt(sg); |
620 | struct zfcp_port *port, *tmp; | 594 | struct zfcp_port *port, *tmp; |
@@ -623,7 +597,7 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, | |||
623 | u32 d_id; | 597 | u32 d_id; |
624 | int ret = 0, x, last = 0; | 598 | int ret = 0, x, last = 0; |
625 | 599 | ||
626 | if (ct->status) | 600 | if (ct_els->status) |
627 | return -EIO; | 601 | return -EIO; |
628 | 602 | ||
629 | if (hdr->ct_cmd != FC_FS_ACC) { | 603 | if (hdr->ct_cmd != FC_FS_ACC) { |
@@ -687,7 +661,7 @@ void zfcp_fc_scan_ports(struct work_struct *work) | |||
687 | struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter, | 661 | struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter, |
688 | scan_work); | 662 | scan_work); |
689 | int ret, i; | 663 | int ret, i; |
690 | struct zfcp_fc_gpn_ft *gpn_ft; | 664 | struct zfcp_fc_req *fc_req; |
691 | int chain, max_entries, buf_num, max_bytes; | 665 | int chain, max_entries, buf_num, max_bytes; |
692 | 666 | ||
693 | chain = adapter->adapter_features & FSF_FEATURE_ELS_CT_CHAINED_SBALS; | 667 | chain = adapter->adapter_features & FSF_FEATURE_ELS_CT_CHAINED_SBALS; |
@@ -702,21 +676,22 @@ void zfcp_fc_scan_ports(struct work_struct *work) | |||
702 | if (zfcp_fc_wka_port_get(&adapter->gs->ds)) | 676 | if (zfcp_fc_wka_port_get(&adapter->gs->ds)) |
703 | return; | 677 | return; |
704 | 678 | ||
705 | gpn_ft = zfcp_alloc_sg_env(buf_num); | 679 | fc_req = zfcp_alloc_sg_env(buf_num); |
706 | if (!gpn_ft) | 680 | if (!fc_req) |
707 | goto out; | 681 | goto out; |
708 | 682 | ||
709 | for (i = 0; i < 3; i++) { | 683 | for (i = 0; i < 3; i++) { |
710 | ret = zfcp_fc_send_gpn_ft(gpn_ft, adapter, max_bytes); | 684 | ret = zfcp_fc_send_gpn_ft(fc_req, adapter, max_bytes); |
711 | if (!ret) { | 685 | if (!ret) { |
712 | ret = zfcp_fc_eval_gpn_ft(gpn_ft, adapter, max_entries); | 686 | ret = zfcp_fc_eval_gpn_ft(fc_req, adapter, max_entries); |
713 | if (ret == -EAGAIN) | 687 | if (ret == -EAGAIN) |
714 | ssleep(1); | 688 | ssleep(1); |
715 | else | 689 | else |
716 | break; | 690 | break; |
717 | } | 691 | } |
718 | } | 692 | } |
719 | zfcp_free_sg_env(gpn_ft, buf_num); | 693 | zfcp_sg_free_table(&fc_req->sg_rsp, buf_num); |
694 | kmem_cache_free(zfcp_fc_req_cache, fc_req); | ||
720 | out: | 695 | out: |
721 | zfcp_fc_wka_port_put(&adapter->gs->ds); | 696 | zfcp_fc_wka_port_put(&adapter->gs->ds); |
722 | } | 697 | } |