Skip to content

Commit

Permalink
libfcoe: Fix fcoe_sysfs VN2VN mode
Browse files Browse the repository at this point in the history
The libfc discovery layer is being initialized in the
'create' paths for both legacy libfcoe module parameters
and fcoe_sysfs control interfaces. The problem is that
for VN2VN mode the discovery layer is initialized as if
it were in 'fabric' mode and it is not re-configured when
the mode is changed to 'vn2vn'.

This patch splits out code that needs to be initialized
once and code that can, and should be, re-configured when
the mode changes. Additionally this patch makes that change
so that the discovery layer can be reconfigured to the
libfcoe implementation when in 'vn2vn' mode.

Signed-off-by: Robert Love <robert.w.love@intel.com>
Tested-by: Jack Morgan <jack.morgan@intel.com>
Reviewed-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
  • Loading branch information
Robert Love committed Mar 25, 2013
1 parent 0807619 commit 0db0e37
Showing 1 changed file with 45 additions and 15 deletions.
60 changes: 45 additions & 15 deletions drivers/scsi/fcoe/fcoe_ctlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2814,6 +2814,47 @@ static void fcoe_ctlr_vn_timeout(struct fcoe_ctlr *fip)
fc_lport_set_local_id(fip->lp, new_port_id);
}

/**
* fcoe_ctlr_mode_set() - Set or reset the ctlr's mode
* @lport: The local port to be (re)configured
* @fip: The FCoE controller whose mode is changing
* @fip_mode: The new fip mode
*
* Note that the we shouldn't be changing the libfc discovery settings
* (fc_disc_config) while an lport is going through the libfc state
* machine. The mode can only be changed when a fcoe_ctlr device is
* disabled, so that should ensure that this routine is only called
* when nothing is happening.
*/
void fcoe_ctlr_mode_set(struct fc_lport *lport, struct fcoe_ctlr *fip,
enum fip_state fip_mode)
{
void *priv;

WARN_ON(lport->state != LPORT_ST_RESET &&
lport->state != LPORT_ST_DISABLED);

if (fip_mode == FIP_MODE_VN2VN) {
lport->rport_priv_size = sizeof(struct fcoe_rport);
lport->point_to_multipoint = 1;
lport->tt.disc_recv_req = fcoe_ctlr_disc_recv;
lport->tt.disc_start = fcoe_ctlr_disc_start;
lport->tt.disc_stop = fcoe_ctlr_disc_stop;
lport->tt.disc_stop_final = fcoe_ctlr_disc_stop_final;
priv = fip;
} else {
lport->rport_priv_size = 0;
lport->point_to_multipoint = 0;
lport->tt.disc_recv_req = NULL;
lport->tt.disc_start = NULL;
lport->tt.disc_stop = NULL;
lport->tt.disc_stop_final = NULL;
priv = lport;
}

fc_disc_config(lport, priv);
}

/**
* fcoe_libfc_config() - Sets up libfc related properties for local port
* @lport: The local port to configure libfc for
Expand All @@ -2826,30 +2867,16 @@ static void fcoe_ctlr_vn_timeout(struct fcoe_ctlr *fip)
int fcoe_libfc_config(struct fc_lport *lport, struct fcoe_ctlr *fip,
const struct libfc_function_template *tt, int init_fcp)
{
void *priv = lport;

/* Set the function pointers set by the LLDD */
memcpy(&lport->tt, tt, sizeof(*tt));
if (init_fcp && fc_fcp_init(lport))
return -ENOMEM;
fc_exch_init(lport);
fc_elsct_init(lport);
fc_lport_init(lport);
if (fip->mode == FIP_MODE_VN2VN)
lport->rport_priv_size = sizeof(struct fcoe_rport);
fc_rport_init(lport);
if (fip->mode == FIP_MODE_VN2VN) {
lport->point_to_multipoint = 1;
lport->tt.disc_recv_req = fcoe_ctlr_disc_recv;
lport->tt.disc_start = fcoe_ctlr_disc_start;
lport->tt.disc_stop = fcoe_ctlr_disc_stop;
lport->tt.disc_stop_final = fcoe_ctlr_disc_stop_final;
priv = fip;
}

fc_disc_init(lport);
fc_disc_config(lport, priv);

fcoe_ctlr_mode_set(lport, fip, fip->mode);
return 0;
}
EXPORT_SYMBOL_GPL(fcoe_libfc_config);
Expand Down Expand Up @@ -2877,6 +2904,7 @@ EXPORT_SYMBOL(fcoe_fcf_get_selected);
void fcoe_ctlr_set_fip_mode(struct fcoe_ctlr_device *ctlr_dev)
{
struct fcoe_ctlr *ctlr = fcoe_ctlr_device_priv(ctlr_dev);
struct fc_lport *lport = ctlr->lp;

mutex_lock(&ctlr->ctlr_mutex);
switch (ctlr_dev->mode) {
Expand All @@ -2890,5 +2918,7 @@ void fcoe_ctlr_set_fip_mode(struct fcoe_ctlr_device *ctlr_dev)
}

mutex_unlock(&ctlr->ctlr_mutex);

fcoe_ctlr_mode_set(lport, ctlr, ctlr->mode);
}
EXPORT_SYMBOL(fcoe_ctlr_set_fip_mode);

0 comments on commit 0db0e37

Please sign in to comment.