Skip to content

Commit 795d86f

Browse files
Joe EykholtJames Bottomley
authored andcommitted
[SCSI] libfc: change interface for rport_create
The interface for lport->tt.rport_create() takes a fc_disc_port arg, which is unnatural for most calls. The only reason for this was to avoid passing in the local port as an argument, but otherwise added to complexity. Simplify by just using lport and fc_rport_identifiers. 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 ab28f1f commit 795d86f

4 files changed

Lines changed: 35 additions & 44 deletions

File tree

‎drivers/scsi/libfc/fc_disc.c‎

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -428,13 +428,7 @@ static int fc_disc_new_target(struct fc_disc *disc,
428428
if (!rport) {
429429
rport = lport->tt.rport_lookup(lport, ids->port_id);
430430
if (!rport) {
431-
struct fc_disc_port dp;
432-
dp.lp = lport;
433-
dp.ids.port_id = ids->port_id;
434-
dp.ids.port_name = ids->port_name;
435-
dp.ids.node_name = ids->node_name;
436-
dp.ids.roles = ids->roles;
437-
rport = lport->tt.rport_create(&dp);
431+
rport = lport->tt.rport_create(lport, ids);
438432
}
439433
if (!rport)
440434
error = -ENOMEM;
@@ -578,7 +572,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
578572
size_t plen;
579573
size_t tlen;
580574
int error = 0;
581-
struct fc_disc_port dp;
575+
struct fc_rport_identifiers ids;
582576
struct fc_rport *rport;
583577
struct fc_rport_priv *rdata;
584578

@@ -621,15 +615,14 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
621615
* After the first time through the loop, things return to "normal".
622616
*/
623617
while (plen >= sizeof(*np)) {
624-
dp.lp = lport;
625-
dp.ids.port_id = ntoh24(np->fp_fid);
626-
dp.ids.port_name = ntohll(np->fp_wwpn);
627-
dp.ids.node_name = -1;
628-
dp.ids.roles = FC_RPORT_ROLE_UNKNOWN;
629-
630-
if ((dp.ids.port_id != fc_host_port_id(lport->host)) &&
631-
(dp.ids.port_name != lport->wwpn)) {
632-
rport = lport->tt.rport_create(&dp);
618+
ids.port_id = ntoh24(np->fp_fid);
619+
ids.port_name = ntohll(np->fp_wwpn);
620+
ids.node_name = -1;
621+
ids.roles = FC_RPORT_ROLE_UNKNOWN;
622+
623+
if (ids.port_id != fc_host_port_id(lport->host) &&
624+
ids.port_name != lport->wwpn) {
625+
rport = lport->tt.rport_create(lport, &ids);
633626
if (rport) {
634627
rdata = rport->dd_data;
635628
rdata->ops = &fc_disc_rport_ops;
@@ -640,7 +633,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
640633
} else
641634
printk(KERN_WARNING "libfc: Failed to allocate "
642635
"memory for the newly discovered port "
643-
"(%6x)\n", dp.ids.port_id);
636+
"(%6x)\n", ids.port_id);
644637
}
645638

646639
if (np->fp_flags & FC_NS_FID_LAST) {
@@ -781,7 +774,7 @@ static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp)
781774
if (dp->ids.port_id == fc_host_port_id(lport->host))
782775
goto out;
783776

784-
new_rport = lport->tt.rport_create(dp);
777+
new_rport = lport->tt.rport_create(lport, &dp->ids);
785778
if (new_rport) {
786779
rdata = new_rport->dd_data;
787780
rdata->ops = &fc_disc_rport_ops;

‎drivers/scsi/libfc/fc_lport.c‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,19 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
211211
u32 remote_fid, u64 remote_wwpn,
212212
u64 remote_wwnn)
213213
{
214-
struct fc_disc_port dp;
214+
struct fc_rport_identifiers ids;
215215

216-
dp.lp = lport;
217-
dp.ids.port_id = remote_fid;
218-
dp.ids.port_name = remote_wwpn;
219-
dp.ids.node_name = remote_wwnn;
220-
dp.ids.roles = FC_RPORT_ROLE_UNKNOWN;
216+
ids.port_id = remote_fid;
217+
ids.port_name = remote_wwpn;
218+
ids.node_name = remote_wwnn;
219+
ids.roles = FC_RPORT_ROLE_UNKNOWN;
221220

222221
if (lport->ptp_rp) {
223222
lport->tt.rport_logoff(lport->ptp_rp);
224223
lport->ptp_rp = NULL;
225224
}
226225

227-
lport->ptp_rp = lport->tt.rport_create(&dp);
226+
lport->ptp_rp = lport->tt.rport_create(lport, &ids);
228227

229228
lport->tt.rport_login(lport->ptp_rp);
230229

@@ -1307,20 +1306,19 @@ static void fc_lport_enter_dns(struct fc_lport *lport)
13071306
{
13081307
struct fc_rport *rport;
13091308
struct fc_rport_priv *rdata;
1310-
struct fc_disc_port dp;
1309+
struct fc_rport_identifiers ids;
13111310

1312-
dp.ids.port_id = FC_FID_DIR_SERV;
1313-
dp.ids.port_name = -1;
1314-
dp.ids.node_name = -1;
1315-
dp.ids.roles = FC_RPORT_ROLE_UNKNOWN;
1316-
dp.lp = lport;
1311+
ids.port_id = FC_FID_DIR_SERV;
1312+
ids.port_name = -1;
1313+
ids.node_name = -1;
1314+
ids.roles = FC_RPORT_ROLE_UNKNOWN;
13171315

13181316
FC_LPORT_DBG(lport, "Entered DNS state from %s state\n",
13191317
fc_lport_state(lport));
13201318

13211319
fc_lport_state_enter(lport, LPORT_ST_DNS);
13221320

1323-
rport = lport->tt.rport_create(&dp);
1321+
rport = lport->tt.rport_create(lport, &ids);
13241322
if (!rport)
13251323
goto err;
13261324

‎drivers/scsi/libfc/fc_rport.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ static void fc_rport_rogue_destroy(struct device *dev)
9393
kfree(rport);
9494
}
9595

96-
struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
96+
struct fc_rport *fc_rport_rogue_create(struct fc_lport *lport,
97+
struct fc_rport_identifiers *ids)
9798
{
9899
struct fc_rport *rport;
99100
struct fc_rport_priv *rdata;
@@ -105,10 +106,10 @@ struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
105106
rdata = RPORT_TO_PRIV(rport);
106107

107108
rport->dd_data = rdata;
108-
rport->port_id = dp->ids.port_id;
109-
rport->port_name = dp->ids.port_name;
110-
rport->node_name = dp->ids.node_name;
111-
rport->roles = dp->ids.roles;
109+
rport->port_id = ids->port_id;
110+
rport->port_name = ids->port_name;
111+
rport->node_name = ids->node_name;
112+
rport->roles = ids->roles;
112113
rport->maxframe_size = FC_MIN_MAX_PAYLOAD;
113114
/*
114115
* Note: all this libfc rogue rport code will be removed for
@@ -118,14 +119,14 @@ struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
118119
rport->dev.release = fc_rport_rogue_destroy;
119120

120121
mutex_init(&rdata->rp_mutex);
121-
rdata->local_port = dp->lp;
122+
rdata->local_port = lport;
122123
rdata->trans_state = FC_PORTSTATE_ROGUE;
123124
rdata->rp_state = RPORT_ST_INIT;
124125
rdata->event = RPORT_EV_NONE;
125126
rdata->flags = FC_RP_FLAGS_REC_SUPPORTED;
126127
rdata->ops = NULL;
127-
rdata->e_d_tov = dp->lp->e_d_tov;
128-
rdata->r_a_tov = dp->lp->r_a_tov;
128+
rdata->e_d_tov = lport->e_d_tov;
129+
rdata->r_a_tov = lport->r_a_tov;
129130
INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout);
130131
INIT_WORK(&rdata->event_work, fc_rport_work);
131132
/*

‎include/scsi/libfc.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ struct fc_rport_libfc_priv {
227227
#define RPORT_TO_PRIV(x) \
228228
(struct fc_rport_libfc_priv *)((void *)x + sizeof(struct fc_rport));
229229

230-
struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *);
231-
232230
static inline void fc_rport_set_name(struct fc_rport *rport, u64 wwpn, u64 wwnn)
233231
{
234232
rport->node_name = wwnn;
@@ -569,7 +567,8 @@ struct libfc_function_template {
569567
/*
570568
* Create a remote port
571569
*/
572-
struct fc_rport *(*rport_create)(struct fc_disc_port *);
570+
struct fc_rport *(*rport_create)(struct fc_lport *,
571+
struct fc_rport_identifiers *);
573572

574573
/*
575574
* Initiates the RP state machine. It is called from the LP module.

0 commit comments

Comments
 (0)