Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 161138
b: refs/heads/master
c: 9fb9d32
h: refs/heads/master
v: v3
  • Loading branch information
Joe Eykholt authored and James Bottomley committed Sep 10, 2009
1 parent 4af04bd commit 890d0e5
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 280 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 922aa210bcad4b34a7bb98ec9d318b7e59e7a5ca
refs/heads/master: 9fb9d32831fd687e427ec5b147bb690f468b99a0
95 changes: 34 additions & 61 deletions trunk/drivers/scsi/libfc/fc_disc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ static void fc_disc_gpn_ft_req(struct fc_disc *);
static void fc_disc_gpn_ft_resp(struct fc_seq *, struct fc_frame *, void *);
static int fc_disc_new_target(struct fc_disc *, struct fc_rport *,
struct fc_rport_identifiers *);
static void fc_disc_del_target(struct fc_disc *, struct fc_rport *);
static void fc_disc_done(struct fc_disc *);
static void fc_disc_timeout(struct work_struct *);
static void fc_disc_single(struct fc_disc *, struct fc_disc_port *);
Expand All @@ -60,27 +59,19 @@ static void fc_disc_restart(struct fc_disc *);
* @lport: Fibre Channel host port instance
* @port_id: remote port port_id to match
*/
struct fc_rport *fc_disc_lookup_rport(const struct fc_lport *lport,
u32 port_id)
struct fc_rport_priv *fc_disc_lookup_rport(const struct fc_lport *lport,
u32 port_id)
{
const struct fc_disc *disc = &lport->disc;
struct fc_rport *rport, *found = NULL;
struct fc_rport *rport;
struct fc_rport_priv *rdata;
int disc_found = 0;

list_for_each_entry(rdata, &disc->rports, peers) {
rport = PRIV_TO_RPORT(rdata);
if (rport->port_id == port_id) {
disc_found = 1;
found = rport;
break;
}
if (rport->port_id == port_id)
return rdata;
}

if (!disc_found)
found = NULL;

return found;
return NULL;
}

/**
Expand All @@ -93,21 +84,18 @@ struct fc_rport *fc_disc_lookup_rport(const struct fc_lport *lport,
void fc_disc_stop_rports(struct fc_disc *disc)
{
struct fc_lport *lport;
struct fc_rport *rport;
struct fc_rport_priv *rdata, *next;

lport = disc->lport;

mutex_lock(&disc->disc_mutex);
list_for_each_entry_safe(rdata, next, &disc->rports, peers) {
rport = PRIV_TO_RPORT(rdata);
list_del(&rdata->peers);
lport->tt.rport_logoff(rport);
lport->tt.rport_logoff(rdata);
}

list_for_each_entry_safe(rdata, next, &disc->rogue_rports, peers) {
rport = PRIV_TO_RPORT(rdata);
lport->tt.rport_logoff(rport);
lport->tt.rport_logoff(rdata);
}

mutex_unlock(&disc->disc_mutex);
Expand All @@ -116,18 +104,18 @@ void fc_disc_stop_rports(struct fc_disc *disc)
/**
* fc_disc_rport_callback() - Event handler for rport events
* @lport: The lport which is receiving the event
* @rport: The rport which the event has occured on
* @rdata: private remote port data
* @event: The event that occured
*
* Locking Note: The rport lock should not be held when calling
* this function.
*/
static void fc_disc_rport_callback(struct fc_lport *lport,
struct fc_rport *rport,
struct fc_rport_priv *rdata,
enum fc_rport_event event)
{
struct fc_rport_priv *rdata = rport->dd_data;
struct fc_disc *disc = &lport->disc;
struct fc_rport *rport = PRIV_TO_RPORT(rdata);

FC_DISC_DBG(disc, "Received a %d event for port (%6x)\n", event,
rport->port_id);
Expand Down Expand Up @@ -169,7 +157,6 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
struct fc_disc *disc)
{
struct fc_lport *lport;
struct fc_rport *rport;
struct fc_rport_priv *rdata;
struct fc_els_rscn *rp;
struct fc_els_rscn_page *pp;
Expand Down Expand Up @@ -249,11 +236,10 @@ static void fc_disc_recv_rscn_req(struct fc_seq *sp, struct fc_frame *fp,
redisc, lport->state, disc->pending);
list_for_each_entry_safe(dp, next, &disc_ports, peers) {
list_del(&dp->peers);
rport = lport->tt.rport_lookup(lport, dp->ids.port_id);
if (rport) {
rdata = rport->dd_data;
rdata = lport->tt.rport_lookup(lport, dp->ids.port_id);
if (rdata) {
list_del(&rdata->peers);
lport->tt.rport_logoff(rport);
lport->tt.rport_logoff(rdata);
}
fc_disc_single(disc, dp);
}
Expand Down Expand Up @@ -308,16 +294,14 @@ static void fc_disc_recv_req(struct fc_seq *sp, struct fc_frame *fp,
*/
static void fc_disc_restart(struct fc_disc *disc)
{
struct fc_rport *rport;
struct fc_rport_priv *rdata, *next;
struct fc_lport *lport = disc->lport;

FC_DISC_DBG(disc, "Restarting discovery\n");

list_for_each_entry_safe(rdata, next, &disc->rports, peers) {
rport = PRIV_TO_RPORT(rdata);
list_del(&rdata->peers);
lport->tt.rport_logoff(rport);
lport->tt.rport_logoff(rdata);
}

disc->requested = 1;
Expand All @@ -335,6 +319,7 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
enum fc_disc_event),
struct fc_lport *lport)
{
struct fc_rport_priv *rdata;
struct fc_rport *rport;
struct fc_rport_identifiers ids;
struct fc_disc *disc = &lport->disc;
Expand Down Expand Up @@ -362,8 +347,9 @@ static void fc_disc_start(void (*disc_callback)(struct fc_lport *,
* Handle point-to-point mode as a simple discovery
* of the remote port. Yucky, yucky, yuck, yuck!
*/
rport = disc->lport->ptp_rp;
if (rport) {
rdata = disc->lport->ptp_rp;
if (rdata) {
rport = PRIV_TO_RPORT(rdata);
ids.port_id = rport->port_id;
ids.port_name = rport->port_name;
ids.node_name = rport->node_name;
Expand Down Expand Up @@ -418,45 +404,36 @@ static int fc_disc_new_target(struct fc_disc *disc,
* assigned the same FCID. This should be rare.
* Delete the old one and fall thru to re-create.
*/
fc_disc_del_target(disc, rport);
rdata = rport->dd_data;
list_del(&rdata->peers);
lport->tt.rport_logoff(rdata);
rport = NULL;
}
}
if (((ids->port_name != -1) || (ids->port_id != -1)) &&
ids->port_id != fc_host_port_id(lport->host) &&
ids->port_name != lport->wwpn) {
if (!rport) {
rport = lport->tt.rport_lookup(lport, ids->port_id);
rdata = lport->tt.rport_lookup(lport, ids->port_id);
if (!rport) {
rport = lport->tt.rport_create(lport, ids);
rdata = lport->tt.rport_create(lport, ids);
}
if (!rport)
if (!rdata)
error = -ENOMEM;
else
rport = PRIV_TO_RPORT(rdata);
}
if (rport) {
rdata = rport->dd_data;
rdata->ops = &fc_disc_rport_ops;
rdata->rp_state = RPORT_ST_INIT;
list_add_tail(&rdata->peers, &disc->rogue_rports);
lport->tt.rport_login(rport);
lport->tt.rport_login(rdata);
}
}
return error;
}

/**
* fc_disc_del_target() - Delete a target
* @disc: FC discovery context
* @rport: The remote port to be removed
*/
static void fc_disc_del_target(struct fc_disc *disc, struct fc_rport *rport)
{
struct fc_lport *lport = disc->lport;
struct fc_rport_priv *rdata = rport->dd_data;
list_del(&rdata->peers);
lport->tt.rport_logoff(rport);
}

/**
* fc_disc_done() - Discovery has been completed
* @disc: FC discovery context
Expand Down Expand Up @@ -573,7 +550,6 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
size_t tlen;
int error = 0;
struct fc_rport_identifiers ids;
struct fc_rport *rport;
struct fc_rport_priv *rdata;

lport = disc->lport;
Expand Down Expand Up @@ -622,14 +598,13 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)

if (ids.port_id != fc_host_port_id(lport->host) &&
ids.port_name != lport->wwpn) {
rport = lport->tt.rport_create(lport, &ids);
if (rport) {
rdata = rport->dd_data;
rdata = lport->tt.rport_create(lport, &ids);
if (rdata) {
rdata->ops = &fc_disc_rport_ops;
rdata->local_port = lport;
list_add_tail(&rdata->peers,
&disc->rogue_rports);
lport->tt.rport_login(rport);
lport->tt.rport_login(rdata);
} else
printk(KERN_WARNING "libfc: Failed to allocate "
"memory for the newly discovered port "
Expand Down Expand Up @@ -766,21 +741,19 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp,
static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp)
{
struct fc_lport *lport;
struct fc_rport *new_rport;
struct fc_rport_priv *rdata;

lport = disc->lport;

if (dp->ids.port_id == fc_host_port_id(lport->host))
goto out;

new_rport = lport->tt.rport_create(lport, &dp->ids);
if (new_rport) {
rdata = new_rport->dd_data;
rdata = lport->tt.rport_create(lport, &dp->ids);
if (rdata) {
rdata->ops = &fc_disc_rport_ops;
kfree(dp);
list_add_tail(&rdata->peers, &disc->rogue_rports);
lport->tt.rport_login(new_rport);
lport->tt.rport_login(rdata);
}
return;
out:
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/scsi/libfc/fc_elsct.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* fc_elsct_send - sends ELS/CT frame
*/
static struct fc_seq *fc_elsct_send(struct fc_lport *lport,
struct fc_rport *rport,
struct fc_rport_priv *rdata,
struct fc_frame *fp,
unsigned int op,
void (*resp)(struct fc_seq *,
Expand All @@ -47,7 +47,7 @@ static struct fc_seq *fc_elsct_send(struct fc_lport *lport,

/* ELS requests */
if ((op >= ELS_LS_RJT) && (op <= ELS_AUTH_ELS))
rc = fc_els_fill(lport, rport, fp, op, &r_ctl, &did, &fh_type);
rc = fc_els_fill(lport, rdata, fp, op, &r_ctl, &did, &fh_type);
else
/* CT requests */
rc = fc_ct_fill(lport, fp, op, &r_ctl, &did, &fh_type);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/scsi/libfc/fc_fcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ static void fc_fcp_rec(struct fc_fcp_pkt *fsp)
fc_fill_fc_hdr(fp, FC_RCTL_ELS_REQ, rport->port_id,
fc_host_port_id(rp->local_port->host), FC_TYPE_ELS,
FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
if (lp->tt.elsct_send(lp, rport, fp, ELS_REC, fc_fcp_rec_resp,
if (lp->tt.elsct_send(lp, rport->dd_data, fp, ELS_REC, fc_fcp_rec_resp,
fsp, jiffies_to_msecs(FC_SCSI_REC_TOV))) {
fc_fcp_pkt_hold(fsp); /* hold while REC outstanding */
return;
Expand Down
26 changes: 13 additions & 13 deletions trunk/drivers/scsi/libfc/fc_lport.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,18 @@ static int fc_frame_drop(struct fc_lport *lport, struct fc_frame *fp)
/**
* fc_lport_rport_callback() - Event handler for rport events
* @lport: The lport which is receiving the event
* @rport: The rport which the event has occured on
* @rdata: private remote port data
* @event: The event that occured
*
* Locking Note: The rport lock should not be held when calling
* this function.
*/
static void fc_lport_rport_callback(struct fc_lport *lport,
struct fc_rport *rport,
struct fc_rport_priv *rdata,
enum fc_rport_event event)
{
struct fc_rport *rport = PRIV_TO_RPORT(rdata);

FC_LPORT_DBG(lport, "Received a %d event for port (%6x)\n", event,
rport->port_id);

Expand All @@ -151,7 +153,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
if (rport->port_id == FC_FID_DIR_SERV) {
mutex_lock(&lport->lp_mutex);
if (lport->state == LPORT_ST_DNS) {
lport->dns_rp = rport;
lport->dns_rp = rdata;
fc_lport_enter_rpn_id(lport);
} else {
FC_LPORT_DBG(lport, "Received an CREATED event "
Expand All @@ -160,7 +162,7 @@ static void fc_lport_rport_callback(struct fc_lport *lport,
"in the DNS state, it's in the "
"%d state", rport->port_id,
lport->state);
lport->tt.rport_logoff(rport);
lport->tt.rport_logoff(rdata);
}
mutex_unlock(&lport->lp_mutex);
} else
Expand Down Expand Up @@ -832,7 +834,7 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp,
{
struct fc_frame_header *fh = fc_frame_header_get(fp);
void (*recv) (struct fc_seq *, struct fc_frame *, struct fc_lport *);
struct fc_rport *rport;
struct fc_rport_priv *rdata;
u32 s_id;
u32 d_id;
struct fc_seq_els_data rjt_data;
Expand Down Expand Up @@ -888,9 +890,9 @@ static void fc_lport_recv_req(struct fc_lport *lport, struct fc_seq *sp,
s_id = ntoh24(fh->fh_s_id);
d_id = ntoh24(fh->fh_d_id);

rport = lport->tt.rport_lookup(lport, s_id);
if (rport)
lport->tt.rport_recv_req(sp, fp, rport);
rdata = lport->tt.rport_lookup(lport, s_id);
if (rdata)
lport->tt.rport_recv_req(sp, fp, rdata);
else {
rjt_data.fp = NULL;
rjt_data.reason = ELS_RJT_UNAB;
Expand Down Expand Up @@ -1304,7 +1306,6 @@ static struct fc_rport_operations fc_lport_rport_ops = {
*/
static void fc_lport_enter_dns(struct fc_lport *lport)
{
struct fc_rport *rport;
struct fc_rport_priv *rdata;
struct fc_rport_identifiers ids;

Expand All @@ -1318,13 +1319,12 @@ static void fc_lport_enter_dns(struct fc_lport *lport)

fc_lport_state_enter(lport, LPORT_ST_DNS);

rport = lport->tt.rport_create(lport, &ids);
if (!rport)
rdata = lport->tt.rport_create(lport, &ids);
if (!rdata)
goto err;

rdata = rport->dd_data;
rdata->ops = &fc_lport_rport_ops;
lport->tt.rport_login(rport);
lport->tt.rport_login(rdata);
return;

err:
Expand Down
Loading

0 comments on commit 890d0e5

Please sign in to comment.