[Open-FCoE] [PATCH 2/6] libfc: Added fc_fcp_complete API

Vasu Dev vasu.dev at intel.com
Tue Oct 21 15:49:17 UTC 2008


The LLD could use this API to complete fc_fcp_pkt after FCP_RSP processing.

Signed-off-by: Vasu Dev <vasu.dev at intel.com>
---

 drivers/scsi/libfc/fc_fcp.c |   41 +++++++++++++++++++++++++++++------------
 include/scsi/libfc/libfc.h  |    8 ++++++++
 2 files changed, 37 insertions(+), 12 deletions(-)


diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index 9f2a2e5..96887c1 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -90,7 +90,7 @@ struct fc_fcp_internal {
 static void fc_fcp_recv_data(struct fc_fcp_pkt *, struct fc_frame *);
 static void fc_fcp_recv(struct fc_seq *, struct fc_frame *, void *);
 static void fc_fcp_resp(struct fc_fcp_pkt *, struct fc_frame *);
-static void fc_fcp_complete(struct fc_fcp_pkt *);
+static void fc_fcp_complete_locked(struct fc_fcp_pkt *);
 static void fc_tm_done(struct fc_seq *, struct fc_frame *, void *);
 static void fc_fcp_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp);
 static void fc_timeout_error(struct fc_fcp_pkt *);
@@ -261,7 +261,7 @@ static void fc_fcp_retry_cmd(struct fc_fcp_pkt *fsp)
 	fsp->state &= ~FC_SRB_ABORT_PENDING;
 	fsp->io_status = SUGGEST_RETRY << 24;
 	fsp->status_code = FC_ERROR;
-	fc_fcp_complete(fsp);
+	fc_fcp_complete_locked(fsp);
 }
 
 /*
@@ -383,7 +383,7 @@ crc_err:
 	 */
 	if (unlikely(fsp->state & FC_SRB_RCV_STATUS) &&
 	    fsp->xfer_len == fsp->data_len - fsp->scsi_resid)
-		fc_fcp_complete(fsp);
+		fc_fcp_complete_locked(fsp);
 }
 
 /*
@@ -596,7 +596,7 @@ static void fc_fcp_abts_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
 		if (fsp->wait_for_comp)
 			complete(&fsp->tm_done);
 		else
-			fc_fcp_complete(fsp);
+			fc_fcp_complete_locked(fsp);
 	}
 }
 
@@ -810,7 +810,7 @@ static void fc_fcp_resp(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
 		       fsp->rport->port_id,
 		       fsp->xfer_len, expected_len, fsp->data_len);
 	}
-	fc_fcp_complete(fsp);
+	fc_fcp_complete_locked(fsp);
 	return;
 
 len_err:
@@ -818,17 +818,17 @@ len_err:
 	       flags, fr_len(fp), respl, snsl);
 err:
 	fsp->status_code = FC_ERROR;
-	fc_fcp_complete(fsp);
+	fc_fcp_complete_locked(fsp);
 }
 
 /**
- * fc_fcp_complete - complete processing of a fcp packet
+ * fc_fcp_complete_locked - complete processing of a fcp packet
  * @fsp:	fcp packet
  *
  * This function may sleep if a timer is pending. The packet lock must be
  * held, and the host lock must not be held.
  */
-static void fc_fcp_complete(struct fc_fcp_pkt *fsp)
+static void fc_fcp_complete_locked(struct fc_fcp_pkt *fsp)
 {
 	struct fc_lport *lp = fsp->lp;
 	struct fc_seq *sp;
@@ -1047,7 +1047,7 @@ static void fc_fcp_error(struct fc_fcp_pkt *fsp, struct fc_frame *fp)
 	 */
 	fsp->state &= ~FC_SRB_ABORT_PENDING;
 	fsp->status_code = FC_CMD_PLOGO;
-	fc_fcp_complete(fsp);
+	fc_fcp_complete_locked(fsp);
 unlock:
 	fc_fcp_unlock_pkt(fsp);
 }
@@ -1077,7 +1077,7 @@ static int fc_fcp_pkt_abort(struct fc_lport *lp, struct fc_fcp_pkt *fsp)
 	} else if (fsp->state & FC_SRB_ABORTED) {
 		FC_DBG("target abort cmd  passed\n");
 		rc = SUCCESS;
-		fc_fcp_complete(fsp);
+		fc_fcp_complete_locked(fsp);
 	}
 
 	return rc;
@@ -1264,7 +1264,7 @@ static void fc_fcp_timeout(unsigned long data)
 			       jiffies))
 		fc_fcp_timer_set(fsp, FC_SCSI_ER_TIMEOUT);
 	else if (fsp->state & FC_SRB_RCV_STATUS)
-		fc_fcp_complete(fsp);
+		fc_fcp_complete_locked(fsp);
 	else
 		fc_timeout_error(fsp);
 	fsp->state &= ~FC_SRB_FCP_PROCESSING_TMO;
@@ -1293,7 +1293,7 @@ static void fc_fcp_rec(struct fc_fcp_pkt *fsp)
 	if (!sp || rp->rp_state != RPORT_ST_READY) {
 		fsp->status_code = FC_HRD_ERROR;
 		fsp->io_status = SUGGEST_RETRY << 24;
-		fc_fcp_complete(fsp);
+		fc_fcp_complete_locked(fsp);
 		return;
 	}
 	lp->tt.seq_get_xids(sp, &ox_id, &rx_id);
@@ -1904,6 +1904,23 @@ static void fc_io_compl(struct fc_fcp_pkt *sp)
 }
 
 /**
+ * fc_fcp_complete - complete processing of a fcp packet
+ * @fsp:	fcp packet
+ *
+ * This function may sleep if a fsp timer is pending.
+ * The host lock must not be held by caller.
+ */
+void fc_fcp_complete(struct fc_fcp_pkt *fsp)
+{
+	if (fc_fcp_lock_pkt(fsp))
+		return;
+
+	fc_fcp_complete_locked(fsp);
+	fc_fcp_unlock_pkt(fsp);
+}
+EXPORT_SYMBOL(fc_fcp_complete);
+
+/**
  * fc_eh_abort - Abort a command...from scsi host template
  * @sc_cmd:	scsi command to abort
  *
diff --git a/include/scsi/libfc/libfc.h b/include/scsi/libfc/libfc.h
index 774c08c..72266e2 100644
--- a/include/scsi/libfc/libfc.h
+++ b/include/scsi/libfc/libfc.h
@@ -668,6 +668,14 @@ int fc_queuecommand(struct scsi_cmnd *sc_cmd,
 		    void (*done)(struct scsi_cmnd *));
 
 /*
+ * complete processing of a fcp packet
+ *
+ * This function may sleep if a fsp timer is pending.
+ * The host lock must not be held by caller.
+ */
+void fc_fcp_complete(struct fc_fcp_pkt *fsp);
+
+/*
  * Send an ABTS frame to the target device. The sc_cmd argument
  * is a pointer to the SCSI command to be aborted.
  */




More information about the devel mailing list