diff options
author | Christof Schmitt <christof.schmitt@de.ibm.com> | 2009-11-24 10:54:10 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2009-12-04 13:02:13 -0500 |
commit | dbf5dfe9dbcecf159139eec25ad256738cbc3715 (patch) | |
tree | 1f1703cf4a270beb3e7046244123e62188de53f4 /drivers/s390/scsi/zfcp_fc.c | |
parent | 9d05ce2c0a6704ff84df02cbb3baef94fcac4f5d (diff) |
[SCSI] zfcp: Use common code definitions for FC CT structs
Use common code definitions for FC GPN_FT and GID_PN
instead of inventing private ones. Move the private structs still
required inside zfcp to zfcp_fc header file.
Reviewed-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>
Diffstat (limited to 'drivers/s390/scsi/zfcp_fc.c')
-rw-r--r-- | drivers/s390/scsi/zfcp_fc.c | 138 |
1 files changed, 55 insertions, 83 deletions
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c index e03410043cd7..7c306a5ef4dd 100644 --- a/drivers/s390/scsi/zfcp_fc.c +++ b/drivers/s390/scsi/zfcp_fc.c | |||
@@ -22,32 +22,6 @@ static u32 zfcp_fc_rscn_range_mask[] = { | |||
22 | [ELS_ADDR_FMT_FAB] = 0x000000, | 22 | [ELS_ADDR_FMT_FAB] = 0x000000, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | struct gpn_ft_resp_acc { | ||
26 | u8 control; | ||
27 | u8 port_id[3]; | ||
28 | u8 reserved[4]; | ||
29 | u64 wwpn; | ||
30 | } __attribute__ ((packed)); | ||
31 | |||
32 | #define ZFCP_CT_SIZE_ONE_PAGE (PAGE_SIZE - sizeof(struct ct_hdr)) | ||
33 | #define ZFCP_GPN_FT_ENTRIES (ZFCP_CT_SIZE_ONE_PAGE \ | ||
34 | / sizeof(struct gpn_ft_resp_acc)) | ||
35 | #define ZFCP_GPN_FT_BUFFERS 4 | ||
36 | #define ZFCP_GPN_FT_MAX_SIZE (ZFCP_GPN_FT_BUFFERS * PAGE_SIZE \ | ||
37 | - sizeof(struct ct_hdr)) | ||
38 | #define ZFCP_GPN_FT_MAX_ENTRIES ZFCP_GPN_FT_BUFFERS * (ZFCP_GPN_FT_ENTRIES + 1) | ||
39 | |||
40 | struct ct_iu_gpn_ft_resp { | ||
41 | struct ct_hdr header; | ||
42 | struct gpn_ft_resp_acc accept[ZFCP_GPN_FT_ENTRIES]; | ||
43 | } __attribute__ ((packed)); | ||
44 | |||
45 | struct zfcp_gpn_ft { | ||
46 | struct zfcp_send_ct ct; | ||
47 | struct scatterlist sg_req; | ||
48 | struct scatterlist sg_resp[ZFCP_GPN_FT_BUFFERS]; | ||
49 | }; | ||
50 | |||
51 | struct zfcp_fc_ns_handler_data { | 25 | struct zfcp_fc_ns_handler_data { |
52 | struct completion done; | 26 | struct completion done; |
53 | void (*handler)(unsigned long); | 27 | void (*handler)(unsigned long); |
@@ -251,26 +225,26 @@ static void zfcp_fc_ns_handler(unsigned long data) | |||
251 | 225 | ||
252 | static void zfcp_fc_ns_gid_pn_eval(unsigned long data) | 226 | static void zfcp_fc_ns_gid_pn_eval(unsigned long data) |
253 | { | 227 | { |
254 | struct zfcp_gid_pn_data *gid_pn = (struct zfcp_gid_pn_data *) data; | 228 | struct zfcp_fc_gid_pn *gid_pn = (struct zfcp_fc_gid_pn *) data; |
255 | struct zfcp_send_ct *ct = &gid_pn->ct; | 229 | struct zfcp_send_ct *ct = &gid_pn->ct; |
256 | struct ct_iu_gid_pn_req *ct_iu_req = sg_virt(ct->req); | 230 | struct zfcp_fc_gid_pn_req *gid_pn_req = sg_virt(ct->req); |
257 | struct ct_iu_gid_pn_resp *ct_iu_resp = sg_virt(ct->resp); | 231 | struct zfcp_fc_gid_pn_resp *gid_pn_resp = sg_virt(ct->resp); |
258 | struct zfcp_port *port = gid_pn->port; | 232 | struct zfcp_port *port = gid_pn->port; |
259 | 233 | ||
260 | if (ct->status) | 234 | if (ct->status) |
261 | return; | 235 | return; |
262 | if (ct_iu_resp->header.cmd_rsp_code != ZFCP_CT_ACCEPT) | 236 | if (gid_pn_resp->ct_hdr.ct_cmd != FC_FS_ACC) |
263 | return; | 237 | return; |
264 | 238 | ||
265 | /* paranoia */ | 239 | /* paranoia */ |
266 | if (ct_iu_req->wwpn != port->wwpn) | 240 | if (gid_pn_req->gid_pn.fn_wwpn != port->wwpn) |
267 | return; | 241 | return; |
268 | /* looks like a valid d_id */ | 242 | /* looks like a valid d_id */ |
269 | port->d_id = ct_iu_resp->d_id & ZFCP_DID_MASK; | 243 | port->d_id = ntoh24(gid_pn_resp->gid_pn.fp_fid); |
270 | } | 244 | } |
271 | 245 | ||
272 | static int zfcp_fc_ns_gid_pn_request(struct zfcp_port *port, | 246 | static int zfcp_fc_ns_gid_pn_request(struct zfcp_port *port, |
273 | struct zfcp_gid_pn_data *gid_pn) | 247 | struct zfcp_fc_gid_pn *gid_pn) |
274 | { | 248 | { |
275 | struct zfcp_adapter *adapter = port->adapter; | 249 | struct zfcp_adapter *adapter = port->adapter; |
276 | struct zfcp_fc_ns_handler_data compl_rec; | 250 | struct zfcp_fc_ns_handler_data compl_rec; |
@@ -281,21 +255,21 @@ static int zfcp_fc_ns_gid_pn_request(struct zfcp_port *port, | |||
281 | gid_pn->ct.wka_port = &adapter->gs->ds; | 255 | gid_pn->ct.wka_port = &adapter->gs->ds; |
282 | gid_pn->ct.handler = zfcp_fc_ns_handler; | 256 | gid_pn->ct.handler = zfcp_fc_ns_handler; |
283 | gid_pn->ct.handler_data = (unsigned long) &compl_rec; | 257 | gid_pn->ct.handler_data = (unsigned long) &compl_rec; |
284 | gid_pn->ct.req = &gid_pn->req; | 258 | gid_pn->ct.req = &gid_pn->sg_req; |
285 | gid_pn->ct.resp = &gid_pn->resp; | 259 | gid_pn->ct.resp = &gid_pn->sg_resp; |
286 | sg_init_one(&gid_pn->req, &gid_pn->ct_iu_req, | 260 | sg_init_one(&gid_pn->sg_req, &gid_pn->gid_pn_req, |
287 | sizeof(struct ct_iu_gid_pn_req)); | 261 | sizeof(struct zfcp_fc_gid_pn_req)); |
288 | sg_init_one(&gid_pn->resp, &gid_pn->ct_iu_resp, | 262 | sg_init_one(&gid_pn->sg_resp, &gid_pn->gid_pn_resp, |
289 | sizeof(struct ct_iu_gid_pn_resp)); | 263 | sizeof(struct zfcp_fc_gid_pn_resp)); |
290 | 264 | ||
291 | /* setup nameserver request */ | 265 | /* setup nameserver request */ |
292 | gid_pn->ct_iu_req.header.revision = ZFCP_CT_REVISION; | 266 | gid_pn->gid_pn_req.ct_hdr.ct_rev = FC_CT_REV; |
293 | gid_pn->ct_iu_req.header.gs_type = ZFCP_CT_DIRECTORY_SERVICE; | 267 | gid_pn->gid_pn_req.ct_hdr.ct_fs_type = FC_FST_DIR; |
294 | gid_pn->ct_iu_req.header.gs_subtype = ZFCP_CT_NAME_SERVER; | 268 | gid_pn->gid_pn_req.ct_hdr.ct_fs_subtype = FC_NS_SUBTYPE; |
295 | gid_pn->ct_iu_req.header.options = ZFCP_CT_SYNCHRONOUS; | 269 | gid_pn->gid_pn_req.ct_hdr.ct_options = 0; |
296 | gid_pn->ct_iu_req.header.cmd_rsp_code = ZFCP_CT_GID_PN; | 270 | gid_pn->gid_pn_req.ct_hdr.ct_cmd = FC_NS_GID_PN; |
297 | gid_pn->ct_iu_req.header.max_res_size = ZFCP_CT_SIZE_ONE_PAGE / 4; | 271 | gid_pn->gid_pn_req.ct_hdr.ct_mr_size = ZFCP_FC_CT_SIZE_PAGE / 4; |
298 | gid_pn->ct_iu_req.wwpn = port->wwpn; | 272 | gid_pn->gid_pn_req.gid_pn.fn_wwpn = port->wwpn; |
299 | 273 | ||
300 | init_completion(&compl_rec.done); | 274 | init_completion(&compl_rec.done); |
301 | compl_rec.handler = zfcp_fc_ns_gid_pn_eval; | 275 | compl_rec.handler = zfcp_fc_ns_gid_pn_eval; |
@@ -314,10 +288,10 @@ static int zfcp_fc_ns_gid_pn_request(struct zfcp_port *port, | |||
314 | static int zfcp_fc_ns_gid_pn(struct zfcp_port *port) | 288 | static int zfcp_fc_ns_gid_pn(struct zfcp_port *port) |
315 | { | 289 | { |
316 | int ret; | 290 | int ret; |
317 | struct zfcp_gid_pn_data *gid_pn; | 291 | struct zfcp_fc_gid_pn *gid_pn; |
318 | struct zfcp_adapter *adapter = port->adapter; | 292 | struct zfcp_adapter *adapter = port->adapter; |
319 | 293 | ||
320 | gid_pn = mempool_alloc(adapter->pool.gid_pn_data, GFP_ATOMIC); | 294 | gid_pn = mempool_alloc(adapter->pool.gid_pn, GFP_ATOMIC); |
321 | if (!gid_pn) | 295 | if (!gid_pn) |
322 | return -ENOMEM; | 296 | return -ENOMEM; |
323 | 297 | ||
@@ -331,7 +305,7 @@ static int zfcp_fc_ns_gid_pn(struct zfcp_port *port) | |||
331 | 305 | ||
332 | zfcp_fc_wka_port_put(&adapter->gs->ds); | 306 | zfcp_fc_wka_port_put(&adapter->gs->ds); |
333 | out: | 307 | out: |
334 | mempool_free(gid_pn, adapter->pool.gid_pn_data); | 308 | mempool_free(gid_pn, adapter->pool.gid_pn); |
335 | return ret; | 309 | return ret; |
336 | } | 310 | } |
337 | 311 | ||
@@ -508,7 +482,7 @@ void zfcp_fc_test_link(struct zfcp_port *port) | |||
508 | put_device(&port->sysfs_device); | 482 | put_device(&port->sysfs_device); |
509 | } | 483 | } |
510 | 484 | ||
511 | static void zfcp_free_sg_env(struct zfcp_gpn_ft *gpn_ft, int buf_num) | 485 | static void zfcp_free_sg_env(struct zfcp_fc_gpn_ft *gpn_ft, int buf_num) |
512 | { | 486 | { |
513 | struct scatterlist *sg = &gpn_ft->sg_req; | 487 | struct scatterlist *sg = &gpn_ft->sg_req; |
514 | 488 | ||
@@ -518,10 +492,10 @@ static void zfcp_free_sg_env(struct zfcp_gpn_ft *gpn_ft, int buf_num) | |||
518 | kfree(gpn_ft); | 492 | kfree(gpn_ft); |
519 | } | 493 | } |
520 | 494 | ||
521 | static struct zfcp_gpn_ft *zfcp_alloc_sg_env(int buf_num) | 495 | static struct zfcp_fc_gpn_ft *zfcp_alloc_sg_env(int buf_num) |
522 | { | 496 | { |
523 | struct zfcp_gpn_ft *gpn_ft; | 497 | struct zfcp_fc_gpn_ft *gpn_ft; |
524 | struct ct_iu_gpn_ft_req *req; | 498 | struct zfcp_fc_gpn_ft_req *req; |
525 | 499 | ||
526 | gpn_ft = kzalloc(sizeof(*gpn_ft), GFP_KERNEL); | 500 | gpn_ft = kzalloc(sizeof(*gpn_ft), GFP_KERNEL); |
527 | if (!gpn_ft) | 501 | if (!gpn_ft) |
@@ -544,25 +518,24 @@ out: | |||
544 | } | 518 | } |
545 | 519 | ||
546 | 520 | ||
547 | static int zfcp_fc_send_gpn_ft(struct zfcp_gpn_ft *gpn_ft, | 521 | static int zfcp_fc_send_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, |
548 | struct zfcp_adapter *adapter, int max_bytes) | 522 | struct zfcp_adapter *adapter, int max_bytes) |
549 | { | 523 | { |
550 | struct zfcp_send_ct *ct = &gpn_ft->ct; | 524 | struct zfcp_send_ct *ct = &gpn_ft->ct; |
551 | struct ct_iu_gpn_ft_req *req = sg_virt(&gpn_ft->sg_req); | 525 | struct zfcp_fc_gpn_ft_req *req = sg_virt(&gpn_ft->sg_req); |
552 | struct zfcp_fc_ns_handler_data compl_rec; | 526 | struct zfcp_fc_ns_handler_data compl_rec; |
553 | int ret; | 527 | int ret; |
554 | 528 | ||
555 | /* prepare CT IU for GPN_FT */ | 529 | /* prepare CT IU for GPN_FT */ |
556 | req->header.revision = ZFCP_CT_REVISION; | 530 | req->ct_hdr.ct_rev = FC_CT_REV; |
557 | req->header.gs_type = ZFCP_CT_DIRECTORY_SERVICE; | 531 | req->ct_hdr.ct_fs_type = FC_FST_DIR; |
558 | req->header.gs_subtype = ZFCP_CT_NAME_SERVER; | 532 | req->ct_hdr.ct_fs_subtype = FC_NS_SUBTYPE; |
559 | req->header.options = ZFCP_CT_SYNCHRONOUS; | 533 | req->ct_hdr.ct_options = 0; |
560 | req->header.cmd_rsp_code = ZFCP_CT_GPN_FT; | 534 | req->ct_hdr.ct_cmd = FC_NS_GPN_FT; |
561 | req->header.max_res_size = max_bytes / 4; | 535 | req->ct_hdr.ct_mr_size = max_bytes / 4; |
562 | req->flags = 0; | 536 | req->gpn_ft.fn_domain_id_scope = 0; |
563 | req->domain_id_scope = 0; | 537 | req->gpn_ft.fn_area_id_scope = 0; |
564 | req->area_id_scope = 0; | 538 | req->gpn_ft.fn_fc4_type = FC_TYPE_FCP; |
565 | req->fc4_type = ZFCP_CT_SCSI_FCP; | ||
566 | 539 | ||
567 | /* prepare zfcp_send_ct */ | 540 | /* prepare zfcp_send_ct */ |
568 | ct->wka_port = &adapter->gs->ds; | 541 | ct->wka_port = &adapter->gs->ds; |
@@ -593,12 +566,12 @@ static void zfcp_fc_validate_port(struct zfcp_port *port, struct list_head *lh) | |||
593 | list_move_tail(&port->list, lh); | 566 | list_move_tail(&port->list, lh); |
594 | } | 567 | } |
595 | 568 | ||
596 | static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries) | 569 | static int zfcp_fc_eval_gpn_ft(struct zfcp_fc_gpn_ft *gpn_ft, int max_entries) |
597 | { | 570 | { |
598 | struct zfcp_send_ct *ct = &gpn_ft->ct; | 571 | struct zfcp_send_ct *ct = &gpn_ft->ct; |
599 | struct scatterlist *sg = gpn_ft->sg_resp; | 572 | struct scatterlist *sg = gpn_ft->sg_resp; |
600 | struct ct_hdr *hdr = sg_virt(sg); | 573 | struct fc_ct_hdr *hdr = sg_virt(sg); |
601 | struct gpn_ft_resp_acc *acc = sg_virt(sg); | 574 | struct fc_gpn_ft_resp *acc = sg_virt(sg); |
602 | struct zfcp_adapter *adapter = ct->wka_port->adapter; | 575 | struct zfcp_adapter *adapter = ct->wka_port->adapter; |
603 | struct zfcp_port *port, *tmp; | 576 | struct zfcp_port *port, *tmp; |
604 | unsigned long flags; | 577 | unsigned long flags; |
@@ -609,38 +582,37 @@ static int zfcp_fc_eval_gpn_ft(struct zfcp_gpn_ft *gpn_ft, int max_entries) | |||
609 | if (ct->status) | 582 | if (ct->status) |
610 | return -EIO; | 583 | return -EIO; |
611 | 584 | ||
612 | if (hdr->cmd_rsp_code != ZFCP_CT_ACCEPT) { | 585 | if (hdr->ct_cmd != FC_FS_ACC) { |
613 | if (hdr->reason_code == ZFCP_CT_UNABLE_TO_PERFORM_CMD) | 586 | if (hdr->ct_reason == FC_BA_RJT_UNABLE) |
614 | return -EAGAIN; /* might be a temporary condition */ | 587 | return -EAGAIN; /* might be a temporary condition */ |
615 | return -EIO; | 588 | return -EIO; |
616 | } | 589 | } |
617 | 590 | ||
618 | if (hdr->max_res_size) { | 591 | if (hdr->ct_mr_size) { |
619 | dev_warn(&adapter->ccw_device->dev, | 592 | dev_warn(&adapter->ccw_device->dev, |
620 | "The name server reported %d words residual data\n", | 593 | "The name server reported %d words residual data\n", |
621 | hdr->max_res_size); | 594 | hdr->ct_mr_size); |
622 | return -E2BIG; | 595 | return -E2BIG; |
623 | } | 596 | } |
624 | 597 | ||
625 | /* first entry is the header */ | 598 | /* first entry is the header */ |
626 | for (x = 1; x < max_entries && !last; x++) { | 599 | for (x = 1; x < max_entries && !last; x++) { |
627 | if (x % (ZFCP_GPN_FT_ENTRIES + 1)) | 600 | if (x % (ZFCP_FC_GPN_FT_ENT_PAGE + 1)) |
628 | acc++; | 601 | acc++; |
629 | else | 602 | else |
630 | acc = sg_virt(++sg); | 603 | acc = sg_virt(++sg); |
631 | 604 | ||
632 | last = acc->control & 0x80; | 605 | last = acc->fp_flags & FC_NS_FID_LAST; |
633 | d_id = acc->port_id[0] << 16 | acc->port_id[1] << 8 | | 606 | d_id = ntoh24(acc->fp_fid); |
634 | acc->port_id[2]; | ||
635 | 607 | ||
636 | /* don't attach ports with a well known address */ | 608 | /* don't attach ports with a well known address */ |
637 | if ((d_id & ZFCP_DID_WKA) == ZFCP_DID_WKA) | 609 | if (d_id >= FC_FID_WELL_KNOWN_BASE) |
638 | continue; | 610 | continue; |
639 | /* skip the adapter's port and known remote ports */ | 611 | /* skip the adapter's port and known remote ports */ |
640 | if (acc->wwpn == fc_host_port_name(adapter->scsi_host)) | 612 | if (acc->fp_wwpn == fc_host_port_name(adapter->scsi_host)) |
641 | continue; | 613 | continue; |
642 | 614 | ||
643 | port = zfcp_port_enqueue(adapter, acc->wwpn, | 615 | port = zfcp_port_enqueue(adapter, acc->fp_wwpn, |
644 | ZFCP_STATUS_COMMON_NOESC, d_id); | 616 | ZFCP_STATUS_COMMON_NOESC, d_id); |
645 | if (!IS_ERR(port)) | 617 | if (!IS_ERR(port)) |
646 | zfcp_erp_port_reopen(port, 0, "fcegpf1", NULL); | 618 | zfcp_erp_port_reopen(port, 0, "fcegpf1", NULL); |
@@ -672,13 +644,13 @@ void zfcp_fc_scan_ports(struct work_struct *work) | |||
672 | struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter, | 644 | struct zfcp_adapter *adapter = container_of(work, struct zfcp_adapter, |
673 | scan_work); | 645 | scan_work); |
674 | int ret, i; | 646 | int ret, i; |
675 | struct zfcp_gpn_ft *gpn_ft; | 647 | struct zfcp_fc_gpn_ft *gpn_ft; |
676 | int chain, max_entries, buf_num, max_bytes; | 648 | int chain, max_entries, buf_num, max_bytes; |
677 | 649 | ||
678 | chain = adapter->adapter_features & FSF_FEATURE_ELS_CT_CHAINED_SBALS; | 650 | chain = adapter->adapter_features & FSF_FEATURE_ELS_CT_CHAINED_SBALS; |
679 | buf_num = chain ? ZFCP_GPN_FT_BUFFERS : 1; | 651 | buf_num = chain ? ZFCP_FC_GPN_FT_NUM_BUFS : 1; |
680 | max_entries = chain ? ZFCP_GPN_FT_MAX_ENTRIES : ZFCP_GPN_FT_ENTRIES; | 652 | max_entries = chain ? ZFCP_FC_GPN_FT_MAX_ENT : ZFCP_FC_GPN_FT_ENT_PAGE; |
681 | max_bytes = chain ? ZFCP_GPN_FT_MAX_SIZE : ZFCP_CT_SIZE_ONE_PAGE; | 653 | max_bytes = chain ? ZFCP_FC_GPN_FT_MAX_SIZE : ZFCP_FC_CT_SIZE_PAGE; |
682 | 654 | ||
683 | if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT && | 655 | if (fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPORT && |
684 | fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV) | 656 | fc_host_port_type(adapter->scsi_host) != FC_PORTTYPE_NPIV) |