Skip to content

Commit 093bb6a

Browse files
Joe EykholtJames Bottomley
authored andcommitted
[SCSI] libfc: add set_fid function to libfc template
This is to notify the LLD when an FC_ID is assigned to the local port. The fnic driver needs to push the assigned FC_ID to firmware. It currently does this by intercepting the FLOGI responses, and in order to make that code more common with FIP and NPIV, it makes more sense to wait until the local port has completely handled the FLOGI or FDISC response. Also, when we fix point-to-point FC_ID assignment, we'll need this callback as well. Add a call to the libfc template, which is called whenever the local port FC_ID is being assigned. It defaults to fc_lport_set_fid(), supplied by libfc. As additional benefit of this function, the LLD may determine the MAC address that caused the change by looking at the received frame. We also print the assigned port ID as long as it isn't 0. Setting port ID to 0 happens often in reset while retrying FLOGI, and would be uninteresting. This replaces the previous message which didn't identify the host adapter instance. patch v2 note: changed one word in a comment. "intercepted" -> "provided". Signed-off-by: Joe Eykholt <jeykholt@cisco.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 52a6690 commit 093bb6a

2 files changed

Lines changed: 47 additions & 7 deletions

File tree

‎drivers/scsi/libfc/fc_lport.c‎

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,27 @@ static void fc_lport_enter_ready(struct fc_lport *lport)
732732
lport->tt.disc_start(fc_lport_disc_callback, lport);
733733
}
734734

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+
735756
/**
736757
* fc_lport_recv_flogi_req() - Receive a FLOGI request
737758
* @sp_in: The sequence the FLOGI is on
@@ -790,7 +811,7 @@ static void fc_lport_recv_flogi_req(struct fc_seq *sp_in,
790811
remote_fid = FC_LOCAL_PTP_FID_HI;
791812
}
792813

793-
fc_host_port_id(lport->host) = local_fid;
814+
fc_lport_set_port_id(lport, local_fid, rx_fp);
794815

795816
fp = fc_frame_alloc(lport, sizeof(*flp));
796817
if (fp) {
@@ -926,7 +947,9 @@ static void fc_lport_reset_locked(struct fc_lport *lport)
926947

927948
lport->tt.exch_mgr_reset(lport, 0, 0);
928949
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);
930953
}
931954

932955
/**
@@ -1428,11 +1451,6 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
14281451
fh = fc_frame_header_get(fp);
14291452
did = ntoh24(fh->fh_d_id);
14301453
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-
14361454
flp = fc_frame_payload_get(fp, sizeof(*flp));
14371455
if (flp) {
14381456
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,
14521470
if (e_d_tov > lport->e_d_tov)
14531471
lport->e_d_tov = e_d_tov;
14541472
lport->r_a_tov = 2 * e_d_tov;
1473+
fc_lport_set_port_id(lport, did, fp);
14551474
printk(KERN_INFO "libfc: Port (%6x) entered "
14561475
"point to point mode\n", did);
14571476
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,
14641483
lport->r_a_tov = r_a_tov;
14651484
fc_host_fabric_name(lport->host) =
14661485
get_unaligned_be64(&flp->fl_wwnn);
1486+
fc_lport_set_port_id(lport, did, fp);
14671487
fc_lport_enter_dns(lport);
14681488
}
14691489
}

‎include/scsi/libfc.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,26 @@ struct libfc_function_template {
580580
*/
581581
int (*lport_reset)(struct fc_lport *);
582582

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+
583603
/*
584604
* Create a remote port with a given port ID
585605
*

0 commit comments

Comments
 (0)