diff options
-rw-r--r-- | drivers/scsi/libfc/fc_lport.c | 34 | ||||
-rw-r--r-- | include/scsi/libfc.h | 20 |
2 files changed, 47 insertions, 7 deletions
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index 90930c435455..653b52dd2ff7 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c | |||
@@ -733,6 +733,27 @@ static void fc_lport_enter_ready(struct fc_lport *lport) | |||
733 | } | 733 | } |
734 | 734 | ||
735 | /** | 735 | /** |
736 | * fc_lport_set_port_id() - set the local port Port ID | ||
737 | * @lport: The local port which will have its Port ID set. | ||
738 | * @port_id: The new port ID. | ||
739 | * @fp: The frame containing the incoming request, or NULL. | ||
740 | * | ||
741 | * Locking Note: The lport lock is expected to be held before calling | ||
742 | * this function. | ||
743 | */ | ||
744 | static void fc_lport_set_port_id(struct fc_lport *lport, u32 port_id, | ||
745 | struct fc_frame *fp) | ||
746 | { | ||
747 | if (port_id) | ||
748 | printk(KERN_INFO "host%d: Assigned Port ID %6x\n", | ||
749 | lport->host->host_no, port_id); | ||
750 | |||
751 | fc_host_port_id(lport->host) = port_id; | ||
752 | if (lport->tt.lport_set_port_id) | ||
753 | lport->tt.lport_set_port_id(lport, port_id, fp); | ||
754 | } | ||
755 | |||
756 | /** | ||
736 | * fc_lport_recv_flogi_req() - Receive a FLOGI request | 757 | * fc_lport_recv_flogi_req() - Receive a FLOGI request |
737 | * @sp_in: The sequence the FLOGI is on | 758 | * @sp_in: The sequence the FLOGI is on |
738 | * @rx_fp: The FLOGI frame | 759 | * @rx_fp: The FLOGI frame |
@@ -790,7 +811,7 @@ static void fc_lport_recv_flogi_req(struct fc_seq *sp_in, | |||
790 | remote_fid = FC_LOCAL_PTP_FID_HI; | 811 | remote_fid = FC_LOCAL_PTP_FID_HI; |
791 | } | 812 | } |
792 | 813 | ||
793 | fc_host_port_id(lport->host) = local_fid; | 814 | fc_lport_set_port_id(lport, local_fid, rx_fp); |
794 | 815 | ||
795 | fp = fc_frame_alloc(lport, sizeof(*flp)); | 816 | fp = fc_frame_alloc(lport, sizeof(*flp)); |
796 | if (fp) { | 817 | if (fp) { |
@@ -926,7 +947,9 @@ static void fc_lport_reset_locked(struct fc_lport *lport) | |||
926 | 947 | ||
927 | lport->tt.exch_mgr_reset(lport, 0, 0); | 948 | lport->tt.exch_mgr_reset(lport, 0, 0); |
928 | fc_host_fabric_name(lport->host) = 0; | 949 | fc_host_fabric_name(lport->host) = 0; |
929 | fc_host_port_id(lport->host) = 0; | 950 | |
951 | if (fc_host_port_id(lport->host)) | ||
952 | fc_lport_set_port_id(lport, 0, NULL); | ||
930 | } | 953 | } |
931 | 954 | ||
932 | /** | 955 | /** |
@@ -1428,11 +1451,6 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1428 | fh = fc_frame_header_get(fp); | 1451 | fh = fc_frame_header_get(fp); |
1429 | did = ntoh24(fh->fh_d_id); | 1452 | did = ntoh24(fh->fh_d_id); |
1430 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { | 1453 | if (fc_frame_payload_op(fp) == ELS_LS_ACC && did != 0) { |
1431 | |||
1432 | printk(KERN_INFO "libfc: Assigned FID (%6x) in FLOGI response\n", | ||
1433 | did); | ||
1434 | fc_host_port_id(lport->host) = did; | ||
1435 | |||
1436 | flp = fc_frame_payload_get(fp, sizeof(*flp)); | 1454 | flp = fc_frame_payload_get(fp, sizeof(*flp)); |
1437 | if (flp) { | 1455 | if (flp) { |
1438 | mfs = ntohs(flp->fl_csp.sp_bb_data) & | 1456 | mfs = ntohs(flp->fl_csp.sp_bb_data) & |
@@ -1452,6 +1470,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1452 | if (e_d_tov > lport->e_d_tov) | 1470 | if (e_d_tov > lport->e_d_tov) |
1453 | lport->e_d_tov = e_d_tov; | 1471 | lport->e_d_tov = e_d_tov; |
1454 | lport->r_a_tov = 2 * e_d_tov; | 1472 | lport->r_a_tov = 2 * e_d_tov; |
1473 | fc_lport_set_port_id(lport, did, fp); | ||
1455 | printk(KERN_INFO "libfc: Port (%6x) entered " | 1474 | printk(KERN_INFO "libfc: Port (%6x) entered " |
1456 | "point to point mode\n", did); | 1475 | "point to point mode\n", did); |
1457 | fc_lport_ptp_setup(lport, ntoh24(fh->fh_s_id), | 1476 | fc_lport_ptp_setup(lport, ntoh24(fh->fh_s_id), |
@@ -1464,6 +1483,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
1464 | lport->r_a_tov = r_a_tov; | 1483 | lport->r_a_tov = r_a_tov; |
1465 | fc_host_fabric_name(lport->host) = | 1484 | fc_host_fabric_name(lport->host) = |
1466 | get_unaligned_be64(&flp->fl_wwnn); | 1485 | get_unaligned_be64(&flp->fl_wwnn); |
1486 | fc_lport_set_port_id(lport, did, fp); | ||
1467 | fc_lport_enter_dns(lport); | 1487 | fc_lport_enter_dns(lport); |
1468 | } | 1488 | } |
1469 | } | 1489 | } |
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 310d8a22b726..67ce9fa1fee4 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h | |||
@@ -581,6 +581,26 @@ struct libfc_function_template { | |||
581 | int (*lport_reset)(struct fc_lport *); | 581 | int (*lport_reset)(struct fc_lport *); |
582 | 582 | ||
583 | /* | 583 | /* |
584 | * Set the local port FC_ID. | ||
585 | * | ||
586 | * This may be provided by the LLD to allow it to be | ||
587 | * notified when the local port is assigned a FC-ID. | ||
588 | * | ||
589 | * The frame, if non-NULL, is the incoming frame with the | ||
590 | * FLOGI LS_ACC or FLOGI, and may contain the granted MAC | ||
591 | * address for the LLD. The frame pointer may be NULL if | ||
592 | * no MAC is associated with this assignment (LOGO or PLOGI). | ||
593 | * | ||
594 | * If FC_ID is non-zero, r_a_tov and e_d_tov must be valid. | ||
595 | * | ||
596 | * Note: this is called with the local port mutex held. | ||
597 | * | ||
598 | * STATUS: OPTIONAL | ||
599 | */ | ||
600 | void (*lport_set_port_id)(struct fc_lport *, u32 port_id, | ||
601 | struct fc_frame *); | ||
602 | |||
603 | /* | ||
584 | * Create a remote port with a given port ID | 604 | * Create a remote port with a given port ID |
585 | * | 605 | * |
586 | * STATUS: OPTIONAL | 606 | * STATUS: OPTIONAL |