aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Eykholt <jeykholt@cisco.com>2009-08-25 17:00:39 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-09-10 13:07:40 -0400
commit795d86f55ec3bf6280dda368f208943f1fb7d366 (patch)
tree8d123acf1e7d9d07495d702b88ef2d75dfe696b1
parentab28f1fd3b0d14c1bd693e640decd711d5e6642a (diff)
[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>
-rw-r--r--drivers/scsi/libfc/fc_disc.c31
-rw-r--r--drivers/scsi/libfc/fc_lport.c26
-rw-r--r--drivers/scsi/libfc/fc_rport.c17
-rw-r--r--include/scsi/libfc.h5
4 files changed, 35 insertions, 44 deletions
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 4c8d893af7bd..ecc625c20520 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -428,13 +428,7 @@ static int fc_disc_new_target(struct fc_disc *disc,
428 if (!rport) { 428 if (!rport) {
429 rport = lport->tt.rport_lookup(lport, ids->port_id); 429 rport = lport->tt.rport_lookup(lport, ids->port_id);
430 if (!rport) { 430 if (!rport) {
431 struct fc_disc_port dp; 431 rport = lport->tt.rport_create(lport, ids);
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);
438 } 432 }
439 if (!rport) 433 if (!rport)
440 error = -ENOMEM; 434 error = -ENOMEM;
@@ -578,7 +572,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
578 size_t plen; 572 size_t plen;
579 size_t tlen; 573 size_t tlen;
580 int error = 0; 574 int error = 0;
581 struct fc_disc_port dp; 575 struct fc_rport_identifiers ids;
582 struct fc_rport *rport; 576 struct fc_rport *rport;
583 struct fc_rport_priv *rdata; 577 struct fc_rport_priv *rdata;
584 578
@@ -621,15 +615,14 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
621 * After the first time through the loop, things return to "normal". 615 * After the first time through the loop, things return to "normal".
622 */ 616 */
623 while (plen >= sizeof(*np)) { 617 while (plen >= sizeof(*np)) {
624 dp.lp = lport; 618 ids.port_id = ntoh24(np->fp_fid);
625 dp.ids.port_id = ntoh24(np->fp_fid); 619 ids.port_name = ntohll(np->fp_wwpn);
626 dp.ids.port_name = ntohll(np->fp_wwpn); 620 ids.node_name = -1;
627 dp.ids.node_name = -1; 621 ids.roles = FC_RPORT_ROLE_UNKNOWN;
628 dp.ids.roles = FC_RPORT_ROLE_UNKNOWN; 622
629 623 if (ids.port_id != fc_host_port_id(lport->host) &&
630 if ((dp.ids.port_id != fc_host_port_id(lport->host)) && 624 ids.port_name != lport->wwpn) {
631 (dp.ids.port_name != lport->wwpn)) { 625 rport = lport->tt.rport_create(lport, &ids);
632 rport = lport->tt.rport_create(&dp);
633 if (rport) { 626 if (rport) {
634 rdata = rport->dd_data; 627 rdata = rport->dd_data;
635 rdata->ops = &fc_disc_rport_ops; 628 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)
640 } else 633 } else
641 printk(KERN_WARNING "libfc: Failed to allocate " 634 printk(KERN_WARNING "libfc: Failed to allocate "
642 "memory for the newly discovered port " 635 "memory for the newly discovered port "
643 "(%6x)\n", dp.ids.port_id); 636 "(%6x)\n", ids.port_id);
644 } 637 }
645 638
646 if (np->fp_flags & FC_NS_FID_LAST) { 639 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)
781 if (dp->ids.port_id == fc_host_port_id(lport->host)) 774 if (dp->ids.port_id == fc_host_port_id(lport->host))
782 goto out; 775 goto out;
783 776
784 new_rport = lport->tt.rport_create(dp); 777 new_rport = lport->tt.rport_create(lport, &dp->ids);
785 if (new_rport) { 778 if (new_rport) {
786 rdata = new_rport->dd_data; 779 rdata = new_rport->dd_data;
787 rdata->ops = &fc_disc_rport_ops; 780 rdata->ops = &fc_disc_rport_ops;
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index f7f328f952a5..a78161cf1811 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -211,20 +211,19 @@ static void fc_lport_ptp_setup(struct fc_lport *lport,
211 u32 remote_fid, u64 remote_wwpn, 211 u32 remote_fid, u64 remote_wwpn,
212 u64 remote_wwnn) 212 u64 remote_wwnn)
213{ 213{
214 struct fc_disc_port dp; 214 struct fc_rport_identifiers ids;
215 215
216 dp.lp = lport; 216 ids.port_id = remote_fid;
217 dp.ids.port_id = remote_fid; 217 ids.port_name = remote_wwpn;
218 dp.ids.port_name = remote_wwpn; 218 ids.node_name = remote_wwnn;
219 dp.ids.node_name = remote_wwnn; 219 ids.roles = FC_RPORT_ROLE_UNKNOWN;
220 dp.ids.roles = FC_RPORT_ROLE_UNKNOWN;
221 220
222 if (lport->ptp_rp) { 221 if (lport->ptp_rp) {
223 lport->tt.rport_logoff(lport->ptp_rp); 222 lport->tt.rport_logoff(lport->ptp_rp);
224 lport->ptp_rp = NULL; 223 lport->ptp_rp = NULL;
225 } 224 }
226 225
227 lport->ptp_rp = lport->tt.rport_create(&dp); 226 lport->ptp_rp = lport->tt.rport_create(lport, &ids);
228 227
229 lport->tt.rport_login(lport->ptp_rp); 228 lport->tt.rport_login(lport->ptp_rp);
230 229
@@ -1307,20 +1306,19 @@ static void fc_lport_enter_dns(struct fc_lport *lport)
1307{ 1306{
1308 struct fc_rport *rport; 1307 struct fc_rport *rport;
1309 struct fc_rport_priv *rdata; 1308 struct fc_rport_priv *rdata;
1310 struct fc_disc_port dp; 1309 struct fc_rport_identifiers ids;
1311 1310
1312 dp.ids.port_id = FC_FID_DIR_SERV; 1311 ids.port_id = FC_FID_DIR_SERV;
1313 dp.ids.port_name = -1; 1312 ids.port_name = -1;
1314 dp.ids.node_name = -1; 1313 ids.node_name = -1;
1315 dp.ids.roles = FC_RPORT_ROLE_UNKNOWN; 1314 ids.roles = FC_RPORT_ROLE_UNKNOWN;
1316 dp.lp = lport;
1317 1315
1318 FC_LPORT_DBG(lport, "Entered DNS state from %s state\n", 1316 FC_LPORT_DBG(lport, "Entered DNS state from %s state\n",
1319 fc_lport_state(lport)); 1317 fc_lport_state(lport));
1320 1318
1321 fc_lport_state_enter(lport, LPORT_ST_DNS); 1319 fc_lport_state_enter(lport, LPORT_ST_DNS);
1322 1320
1323 rport = lport->tt.rport_create(&dp); 1321 rport = lport->tt.rport_create(lport, &ids);
1324 if (!rport) 1322 if (!rport)
1325 goto err; 1323 goto err;
1326 1324
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 5f8f437e76b3..2fbc94aaf343 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -93,7 +93,8 @@ static void fc_rport_rogue_destroy(struct device *dev)
93 kfree(rport); 93 kfree(rport);
94} 94}
95 95
96struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp) 96struct fc_rport *fc_rport_rogue_create(struct fc_lport *lport,
97 struct fc_rport_identifiers *ids)
97{ 98{
98 struct fc_rport *rport; 99 struct fc_rport *rport;
99 struct fc_rport_priv *rdata; 100 struct fc_rport_priv *rdata;
@@ -105,10 +106,10 @@ struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
105 rdata = RPORT_TO_PRIV(rport); 106 rdata = RPORT_TO_PRIV(rport);
106 107
107 rport->dd_data = rdata; 108 rport->dd_data = rdata;
108 rport->port_id = dp->ids.port_id; 109 rport->port_id = ids->port_id;
109 rport->port_name = dp->ids.port_name; 110 rport->port_name = ids->port_name;
110 rport->node_name = dp->ids.node_name; 111 rport->node_name = ids->node_name;
111 rport->roles = dp->ids.roles; 112 rport->roles = ids->roles;
112 rport->maxframe_size = FC_MIN_MAX_PAYLOAD; 113 rport->maxframe_size = FC_MIN_MAX_PAYLOAD;
113 /* 114 /*
114 * Note: all this libfc rogue rport code will be removed for 115 * 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)
118 rport->dev.release = fc_rport_rogue_destroy; 119 rport->dev.release = fc_rport_rogue_destroy;
119 120
120 mutex_init(&rdata->rp_mutex); 121 mutex_init(&rdata->rp_mutex);
121 rdata->local_port = dp->lp; 122 rdata->local_port = lport;
122 rdata->trans_state = FC_PORTSTATE_ROGUE; 123 rdata->trans_state = FC_PORTSTATE_ROGUE;
123 rdata->rp_state = RPORT_ST_INIT; 124 rdata->rp_state = RPORT_ST_INIT;
124 rdata->event = RPORT_EV_NONE; 125 rdata->event = RPORT_EV_NONE;
125 rdata->flags = FC_RP_FLAGS_REC_SUPPORTED; 126 rdata->flags = FC_RP_FLAGS_REC_SUPPORTED;
126 rdata->ops = NULL; 127 rdata->ops = NULL;
127 rdata->e_d_tov = dp->lp->e_d_tov; 128 rdata->e_d_tov = lport->e_d_tov;
128 rdata->r_a_tov = dp->lp->r_a_tov; 129 rdata->r_a_tov = lport->r_a_tov;
129 INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout); 130 INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout);
130 INIT_WORK(&rdata->event_work, fc_rport_work); 131 INIT_WORK(&rdata->event_work, fc_rport_work);
131 /* 132 /*
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index aa219514c96b..d888cbecd72e 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -227,8 +227,6 @@ struct fc_rport_libfc_priv {
227#define RPORT_TO_PRIV(x) \ 227#define RPORT_TO_PRIV(x) \
228 (struct fc_rport_libfc_priv *)((void *)x + sizeof(struct fc_rport)); 228 (struct fc_rport_libfc_priv *)((void *)x + sizeof(struct fc_rport));
229 229
230struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *);
231
232static inline void fc_rport_set_name(struct fc_rport *rport, u64 wwpn, u64 wwnn) 230static inline void fc_rport_set_name(struct fc_rport *rport, u64 wwpn, u64 wwnn)
233{ 231{
234 rport->node_name = wwnn; 232 rport->node_name = wwnn;
@@ -569,7 +567,8 @@ struct libfc_function_template {
569 /* 567 /*
570 * Create a remote port 568 * Create a remote port
571 */ 569 */
572 struct fc_rport *(*rport_create)(struct fc_disc_port *); 570 struct fc_rport *(*rport_create)(struct fc_lport *,
571 struct fc_rport_identifiers *);
573 572
574 /* 573 /*
575 * Initiates the RP state machine. It is called from the LP module. 574 * Initiates the RP state machine. It is called from the LP module.