[Open-FCoE] [RFC PATCH 3/5] libfc: use RPORT_TO_PRIV not rport->dd_data

Robert Love robert.w.love at intel.com
Wed Jan 28 20:49:10 UTC 2009


Signed-off-by: Robert Love <robert.w.love at intel.com>
---

 drivers/scsi/libfc/fc_disc.c  |   10 ++--
 drivers/scsi/libfc/fc_fcp.c   |   14 ++---
 drivers/scsi/libfc/fc_lport.c |    2 -
 drivers/scsi/libfc/fc_rport.c |  117 ++++++++++++++++++++++++++++-------------
 4 files changed, 95 insertions(+), 48 deletions(-)

diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 875d77a..aa3cb03 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -129,10 +129,12 @@ static void fc_disc_rport_callback(struct fc_lport *lport,
 				   struct fc_rport *rport,
 				   enum fc_rport_event event)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
 	struct fc_disc *disc = &lport->disc;
 	int found = 0;
 
+	rdata = RPORT_TO_PRIV(rport);
+
 	FC_DEBUG_DISC("Received a %d event for port (%6x)\n", event,
 		      rport->port_id);
 
@@ -436,7 +438,7 @@ static int fc_disc_new_target(struct fc_disc *disc,
 				error = -ENOMEM;
 		}
 		if (rport) {
-			rdata = rport->dd_data;
+			rdata = RPORT_TO_PRIV(rport);
 			rdata->ops = &fc_disc_rport_ops;
 			rdata->rp_state = RPORT_ST_INIT;
 			lport->tt.rport_login(rport);
@@ -619,7 +621,7 @@ static int fc_disc_gpn_ft_parse(struct fc_disc *disc, void *buf, size_t len)
 		    (dp.ids.port_name != lport->wwpn)) {
 			rport = lport->tt.rport_create(&dp);
 			if (rport) {
-				rdata = rport->dd_data;
+				rdata = RPORT_TO_PRIV(rport);
 				rdata->ops = &fc_disc_rport_ops;
 				rdata->local_port = lport;
 				lport->tt.rport_login(rport);
@@ -771,7 +773,7 @@ static void fc_disc_single(struct fc_disc *disc, struct fc_disc_port *dp)
 
 	new_rport = lport->tt.rport_create(dp);
 	if (new_rport) {
-		rdata = new_rport->dd_data;
+		rdata = RPORT_TO_PRIV(new_rport);
 		rdata->ops = &fc_disc_rport_ops;
 		kfree(dp);
 		lport->tt.rport_login(new_rport);
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index ecc7261..ad0454c 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -1010,7 +1010,7 @@ static int fc_fcp_cmd_send(struct fc_lport *lp, struct fc_fcp_pkt *fsp,
 	fr_cmd(fp) = fsp->cmd;
 	rport = fsp->rport;
 	fsp->max_payload = rport->maxframe_size;
-	rp = rport->dd_data;
+	rp = RPORT_TO_PRIV(rport);
 
 	fc_fill_fc_hdr(fp, FC_RCTL_DD_UNSOL_CMD, rport->port_id,
 		       fc_host_port_id(rp->local_port->host), FC_TYPE_FCP,
@@ -1229,7 +1229,7 @@ static void fc_fcp_timeout(unsigned long data)
 {
 	struct fc_fcp_pkt *fsp = (struct fc_fcp_pkt *)data;
 	struct fc_rport *rport = fsp->rport;
-	struct fc_rport_libfc_priv *rp = rport->dd_data;
+	struct fc_rport_libfc_priv *rp = RPORT_TO_PRIV(rport);
 
 	if (fc_fcp_lock_pkt(fsp))
 		return;
@@ -1265,7 +1265,7 @@ static void fc_fcp_rec(struct fc_fcp_pkt *fsp)
 
 	lp = fsp->lp;
 	rport = fsp->rport;
-	rp = rport->dd_data;
+	rp = RPORT_TO_PRIV(rport);
 	if (!fsp->seq_ptr || rp->rp_state != RPORT_ST_READY) {
 		fsp->status_code = FC_HRD_ERROR;
 		fsp->io_status = SUGGEST_RETRY << 24;
@@ -1333,7 +1333,7 @@ static void fc_fcp_rec_resp(struct fc_seq *seq, struct fc_frame *fp, void *arg)
 			/* fall through */
 		case ELS_RJT_UNSUP:
 			FC_DEBUG_FCP("device does not support REC\n");
-			rp = fsp->rport->dd_data;
+			rp = RPORT_TO_PRIV(fsp->rport);
 			/*
 			 * if we do not spport RECs or got some bogus
 			 * reason then resetup timer so we check for
@@ -1510,7 +1510,7 @@ static void fc_fcp_srr(struct fc_fcp_pkt *fsp, enum fc_rctl r_ctl, u32 offset)
 	u8 cdb_op;
 
 	rport = fsp->rport;
-	rp = rport->dd_data;
+	rp = RPORT_TO_PRIV(rport);
 	cdb_op = fsp->cdb_cmd.fc_cdb[0];
 
 	if (!(rp->flags & FC_RP_FLAGS_RETRY) || rp->rp_state != RPORT_ST_READY)
@@ -1661,7 +1661,7 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd, void (*done)(struct scsi_cmnd *))
 		goto out;
 	}
 
-	rp = rport->dd_data;
+	rp = RPORT_TO_PRIV(rport);
 
 	if (!fc_fcp_lport_queue_ready(lp)) {
 		rc = SCSI_MLQUEUE_HOST_BUSY;
@@ -1939,7 +1939,7 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd)
 	if (rval)
 		goto out;
 
-	rp = rport->dd_data;
+	rp = RPORT_TO_PRIV(rport);
 	lp = shost_priv(sc_cmd->device->host);
 
 	if (lp->state != LPORT_ST_READY)
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index 27858ed..5bc8511 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -1284,7 +1284,7 @@ static void fc_lport_enter_dns(struct fc_lport *lport)
 	if (!rport)
 		goto err;
 
-	rdata = rport->dd_data;
+	rdata = RPORT_TO_PRIV(rport);
 	rdata->ops = &fc_lport_rport_ops;
 	lport->tt.rport_login(rport);
 	return;
diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 81b3ca1..918ce9b 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -152,7 +152,8 @@ struct fc_rport *fc_rport_rogue_create(struct fc_disc_port *dp)
 static const char *fc_rport_state(struct fc_rport *rport)
 {
 	const char *cp;
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
+	rdata = RPORT_TO_PRIV(rport);
 
 	cp = fc_rport_state_names[rdata->rp_state];
 	if (!cp)
@@ -207,7 +208,8 @@ fc_plogi_get_maxframe(struct fc_els_flogi *flp, unsigned int maxval)
 static void fc_rport_state_enter(struct fc_rport *rport,
 				 enum fc_rport_state new)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
+	rdata = RPORT_TO_PRIV(rport);
 	if (rdata->rp_state != new)
 		rdata->retries = 0;
 	rdata->rp_state = new;
@@ -248,7 +250,7 @@ static void fc_rport_work(struct work_struct *work)
 			 */
 			new_rport->maxframe_size = rport->maxframe_size;
 
-			new_rdata = new_rport->dd_data;
+			new_rdata = RPORT_TO_PRIV(new_rport);
 			new_rdata->e_d_tov = rdata->e_d_tov;
 			new_rdata->r_a_tov = rdata->r_a_tov;
 			new_rdata->ops = rdata->ops;
@@ -269,7 +271,7 @@ static void fc_rport_work(struct work_struct *work)
 		}
 		put_device(&rport->dev);
 		rport = new_rport;
-		rdata = new_rport->dd_data;
+		rdata = RPORT_TO_PRIV(new_rport);
 		if (rport_ops->event_callback)
 			rport_ops->event_callback(lport, rport, event);
 	} else if ((event == RPORT_EV_FAILED) ||
@@ -301,7 +303,8 @@ static void fc_rport_work(struct work_struct *work)
  */
 int fc_rport_login(struct fc_rport *rport)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
+	rdata = RPORT_TO_PRIV(rport);
 
 	mutex_lock(&rdata->rp_mutex);
 
@@ -324,7 +327,8 @@ int fc_rport_login(struct fc_rport *rport)
  */
 int fc_rport_logoff(struct fc_rport *rport)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
+	rdata = RPORT_TO_PRIV(rport);
 
 	mutex_lock(&rdata->rp_mutex);
 
@@ -361,7 +365,8 @@ int fc_rport_logoff(struct fc_rport *rport)
  */
 static void fc_rport_enter_ready(struct fc_rport *rport)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
+	rdata = RPORT_TO_PRIV(rport);
 
 	fc_rport_state_enter(rport, RPORT_ST_READY);
 
@@ -420,7 +425,8 @@ static void fc_rport_timeout(struct work_struct *work)
  */
 static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
+	rdata = RPORT_TO_PRIV(rport);
 
 	FC_DEBUG_RPORT("Error %ld in state %s, retries %d\n",
 		       PTR_ERR(fp), fc_rport_state(rport), rdata->retries);
@@ -456,9 +462,11 @@ static void fc_rport_error(struct fc_rport *rport, struct fc_frame *fp)
  */
 static void fc_rport_error_retry(struct fc_rport *rport, struct fc_frame *fp)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
 	unsigned long delay = FC_DEF_E_D_TOV;
 
+	rdata = RPORT_TO_PRIV(rport);
+
 	/* make sure this isn't an FC_EX_CLOSED error, never retry those */
 	if (PTR_ERR(fp) == -FC_EX_CLOSED)
 		return fc_rport_error(rport, fp);
@@ -492,14 +500,17 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct fc_frame *fp,
 				void *rp_arg)
 {
 	struct fc_rport *rport = rp_arg;
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
 	struct fc_els_flogi *plp;
 	unsigned int tov;
 	u16 csp_seq;
 	u16 cssp_seq;
 	u8 op;
 
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
+
 	mutex_lock(&rdata->rp_mutex);
 
 	FC_DEBUG_RPORT("Received a PLOGI response from port (%6x)\n",
@@ -562,10 +573,13 @@ err:
  */
 static void fc_rport_enter_plogi(struct fc_rport *rport)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
 	struct fc_frame *fp;
 
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
+
 	FC_DEBUG_RPORT("Port (%6x) entered PLOGI state from %s state\n",
 		       rport->port_id, fc_rport_state(rport));
 
@@ -600,7 +614,7 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp,
 			       void *rp_arg)
 {
 	struct fc_rport *rport = rp_arg;
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
 	struct {
 		struct fc_els_prli prli;
 		struct fc_els_spp spp;
@@ -609,6 +623,8 @@ static void fc_rport_prli_resp(struct fc_seq *sp, struct fc_frame *fp,
 	u32 fcp_parm = 0;
 	u8 op;
 
+	rdata = RPORT_TO_PRIV(rport);
+
 	mutex_lock(&rdata->rp_mutex);
 
 	FC_DEBUG_RPORT("Received a PRLI response from port (%6x)\n",
@@ -670,9 +686,11 @@ static void fc_rport_logo_resp(struct fc_seq *sp, struct fc_frame *fp,
 			       void *rp_arg)
 {
 	struct fc_rport *rport = rp_arg;
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
 	u8 op;
 
+	rdata = RPORT_TO_PRIV(rport);
+
 	mutex_lock(&rdata->rp_mutex);
 
 	FC_DEBUG_RPORT("Received a LOGO response from port (%6x)\n",
@@ -714,14 +732,17 @@ err:
  */
 static void fc_rport_enter_prli(struct fc_rport *rport)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
 	struct {
 		struct fc_els_prli prli;
 		struct fc_els_spp spp;
 	} *pp;
 	struct fc_frame *fp;
 
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
+
 	FC_DEBUG_RPORT("Port (%6x) entered PRLI state from %s state\n",
 		       rport->port_id, fc_rport_state(rport));
 
@@ -756,9 +777,11 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct fc_frame *fp,
 			      void *rp_arg)
 {
 	struct fc_rport *rport = rp_arg;
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
+	struct fc_rport_libfc_priv *rdata;
 	u8 op;
 
+	rdata = RPORT_TO_PRIV(rport);
+
 	mutex_lock(&rdata->rp_mutex);
 
 	FC_DEBUG_RPORT("Received a RTV response from port (%6x)\n",
@@ -816,8 +839,11 @@ err:
 static void fc_rport_enter_rtv(struct fc_rport *rport)
 {
 	struct fc_frame *fp;
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
+
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
 
 	FC_DEBUG_RPORT("Port (%6x) entered RTV state from %s state\n",
 		       rport->port_id, fc_rport_state(rport));
@@ -846,10 +872,13 @@ static void fc_rport_enter_rtv(struct fc_rport *rport)
  */
 static void fc_rport_enter_logo(struct fc_rport *rport)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
 	struct fc_frame *fp;
 
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
+
 	FC_DEBUG_RPORT("Port (%6x) entered LOGO state from %s state\n",
 		       rport->port_id, fc_rport_state(rport));
 
@@ -882,13 +911,15 @@ static void fc_rport_enter_logo(struct fc_rport *rport)
 void fc_rport_recv_req(struct fc_seq *sp, struct fc_frame *fp,
 		       struct fc_rport *rport)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
-
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
 	struct fc_frame_header *fh;
 	struct fc_seq_els_data els_data;
 	u8 op;
 
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
+
 	mutex_lock(&rdata->rp_mutex);
 
 	els_data.fp = NULL;
@@ -942,8 +973,8 @@ void fc_rport_recv_req(struct fc_seq *sp, struct fc_frame *fp,
 static void fc_rport_recv_plogi_req(struct fc_rport *rport,
 				    struct fc_seq *sp, struct fc_frame *rx_fp)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
 	struct fc_frame *fp = rx_fp;
 	struct fc_exch *ep;
 	struct fc_frame_header *fh;
@@ -956,6 +987,9 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
 	u32 f_ctl;
 	rjt_data.fp = NULL;
 
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
+
 	fh = fc_frame_header_get(fp);
 
 	FC_DEBUG_RPORT("Received PLOGI request from port (%6x) "
@@ -1064,8 +1098,8 @@ static void fc_rport_recv_plogi_req(struct fc_rport *rport,
 static void fc_rport_recv_prli_req(struct fc_rport *rport,
 				   struct fc_seq *sp, struct fc_frame *rx_fp)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
 	struct fc_exch *ep;
 	struct fc_frame *fp;
 	struct fc_frame_header *fh;
@@ -1086,6 +1120,9 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport,
 	u32 roles = FC_RPORT_ROLE_UNKNOWN;
 	rjt_data.fp = NULL;
 
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
+
 	fh = fc_frame_header_get(rx_fp);
 
 	FC_DEBUG_RPORT("Received PRLI request from port (%6x) "
@@ -1215,12 +1252,14 @@ static void fc_rport_recv_prli_req(struct fc_rport *rport,
 static void fc_rport_recv_prlo_req(struct fc_rport *rport, struct fc_seq *sp,
 				   struct fc_frame *fp)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
-
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
 	struct fc_frame_header *fh;
 	struct fc_seq_els_data rjt_data;
 
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
+
 	fh = fc_frame_header_get(fp);
 
 	FC_DEBUG_RPORT("Received PRLO request from port (%6x) "
@@ -1247,8 +1286,11 @@ static void fc_rport_recv_logo_req(struct fc_rport *rport, struct fc_seq *sp,
 				   struct fc_frame *fp)
 {
 	struct fc_frame_header *fh;
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
+
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
 
 	fh = fc_frame_header_get(fp);
 
@@ -1307,8 +1349,11 @@ EXPORT_SYMBOL(fc_destroy_rport);
 
 void fc_rport_terminate_io(struct fc_rport *rport)
 {
-	struct fc_rport_libfc_priv *rdata = rport->dd_data;
-	struct fc_lport *lport = rdata->local_port;
+	struct fc_rport_libfc_priv *rdata;
+	struct fc_lport *lport;
+
+	rdata = RPORT_TO_PRIV(rport);
+	lport = rdata->local_port;
 
 	lport->tt.exch_mgr_reset(lport, 0, rport->port_id);
 	lport->tt.exch_mgr_reset(lport, rport->port_id, 0);




More information about the devel mailing list