aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@de.ibm.com>2011-02-22 13:54:43 -0500
committerJames Bottomley <James.Bottomley@suse.de>2011-02-25 12:02:09 -0500
commitf9773229be6d8a3caa4c9dfc2961a63ab51a4e2a (patch)
tree4970f351a9b82ed9487f8f23933b7008e650cc25 /drivers
parentfcf7e6144df60cd5082e5bc52f1ca5d1ca99a2d6 (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')
-rw-r--r--drivers/s390/scsi/zfcp_aux.c8
-rw-r--r--drivers/s390/scsi/zfcp_def.h1
-rw-r--r--drivers/s390/scsi/zfcp_fc.c87
-rw-r--r--drivers/s390/scsi/zfcp_fc.h26
4 files changed, 35 insertions, 87 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 6d2beb6ad9ee..324fb1aab6f5 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -122,11 +122,6 @@ static int __init zfcp_module_init(void)
122{ 122{
123 int retval = -ENOMEM; 123 int retval = -ENOMEM;
124 124
125 zfcp_data.gpn_ft_cache = zfcp_cache_hw_align("zfcp_gpn",
126 sizeof(struct zfcp_fc_gpn_ft_req));
127 if (!zfcp_data.gpn_ft_cache)
128 goto out;
129
130 zfcp_data.qtcb_cache = zfcp_cache_hw_align("zfcp_qtcb", 125 zfcp_data.qtcb_cache = zfcp_cache_hw_align("zfcp_qtcb",
131 sizeof(struct fsf_qtcb)); 126 sizeof(struct fsf_qtcb));
132 if (!zfcp_data.qtcb_cache) 127 if (!zfcp_data.qtcb_cache)
@@ -171,8 +166,6 @@ out_transport:
171out_fc_cache: 166out_fc_cache:
172 kmem_cache_destroy(zfcp_data.qtcb_cache); 167 kmem_cache_destroy(zfcp_data.qtcb_cache);
173out_qtcb_cache: 168out_qtcb_cache:
174 kmem_cache_destroy(zfcp_data.gpn_ft_cache);
175out:
176 return retval; 169 return retval;
177} 170}
178 171
@@ -185,7 +178,6 @@ static void __exit zfcp_module_exit(void)
185 fc_release_transport(zfcp_data.scsi_transport_template); 178 fc_release_transport(zfcp_data.scsi_transport_template);
186 kmem_cache_destroy(zfcp_fc_req_cache); 179 kmem_cache_destroy(zfcp_fc_req_cache);
187 kmem_cache_destroy(zfcp_data.qtcb_cache); 180 kmem_cache_destroy(zfcp_data.qtcb_cache);
188 kmem_cache_destroy(zfcp_data.gpn_ft_cache);
189} 181}
190 182
191module_exit(zfcp_module_exit); 183module_exit(zfcp_module_exit);
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index dbf59108e1f4..d7e2534ed66e 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -317,7 +317,6 @@ struct zfcp_fsf_req {
317struct zfcp_data { 317struct zfcp_data {
318 struct scsi_host_template scsi_host_template; 318 struct scsi_host_template scsi_host_template;
319 struct scsi_transport_template *scsi_transport_template; 319 struct scsi_transport_template *scsi_transport_template;
320 struct kmem_cache *gpn_ft_cache;
321 struct kmem_cache *qtcb_cache; 320 struct kmem_cache *qtcb_cache;
322}; 321};
323 322
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
531static void zfcp_free_sg_env(struct zfcp_fc_gpn_ft *gpn_ft, int buf_num) 531static 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
541static 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 }
562out:
563 return gpn_ft;
564}
565 546
547 return fc_req;
548}
566 549
567static int zfcp_fc_send_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, 550static 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
613static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, 587static 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);
720out: 695out:
721 zfcp_fc_wka_port_put(&adapter->gs->ds); 696 zfcp_fc_wka_port_put(&adapter->gs->ds);
722} 697}
diff --git a/drivers/s390/scsi/zfcp_fc.h b/drivers/s390/scsi/zfcp_fc.h
index 200fe2501332..2066f9d9ceb5 100644
--- a/drivers/s390/scsi/zfcp_fc.h
+++ b/drivers/s390/scsi/zfcp_fc.h
@@ -84,28 +84,6 @@ struct zfcp_fc_gpn_ft_req {
84} __packed; 84} __packed;
85 85
86/** 86/**
87 * struct zfcp_fc_gpn_ft_resp - container for ct header plus gpn_ft response
88 * @ct_hdr: FC GS common transport header
89 * @gpn_ft: Array of gpn_ft response data to fill one memory page
90 */
91struct zfcp_fc_gpn_ft_resp {
92 struct fc_ct_hdr ct_hdr;
93 struct fc_gpn_ft_resp gpn_ft[ZFCP_FC_GPN_FT_ENT_PAGE];
94} __packed;
95
96/**
97 * struct zfcp_fc_gpn_ft - zfcp data for gpn_ft request
98 * @ct: data passed to zfcp_fsf for issuing fsf request
99 * @sg_req: scatter list entry for gpn_ft request
100 * @sg_resp: scatter list entries for gpn_ft responses (per memory page)
101 */
102struct zfcp_fc_gpn_ft {
103 struct zfcp_fsf_ct_els ct;
104 struct scatterlist sg_req;
105 struct scatterlist sg_resp[ZFCP_FC_GPN_FT_NUM_BUFS];
106};
107
108/**
109 * struct zfcp_fc_req - Container for FC ELS and CT requests sent from zfcp 87 * struct zfcp_fc_req - Container for FC ELS and CT requests sent from zfcp
110 * @ct_els: data required for issuing fsf command 88 * @ct_els: data required for issuing fsf command
111 * @sg_req: scatterlist entry for request data 89 * @sg_req: scatterlist entry for request data
@@ -125,6 +103,10 @@ struct zfcp_fc_req {
125 struct zfcp_fc_gid_pn_req req; 103 struct zfcp_fc_gid_pn_req req;
126 struct zfcp_fc_gid_pn_rsp rsp; 104 struct zfcp_fc_gid_pn_rsp rsp;
127 } gid_pn; 105 } gid_pn;
106 struct {
107 struct scatterlist sg_rsp2[ZFCP_FC_GPN_FT_NUM_BUFS - 1];
108 struct zfcp_fc_gpn_ft_req req;
109 } gpn_ft;
128 } u; 110 } u;
129}; 111};
130 112