[Open-FCoE] [PATCH 03/28] libfc: move fc_ns_fill_dns_hdr() helper function to libfc.h

Robert Love robert.w.love at intel.com
Tue Sep 30 18:25:02 UTC 2008


In later patches for this patchset we'll be sending frames
to the NS from both the NS block as well as the lport block.
Since this fill_dns_hdr functionality is now common it should
be moved to a common place.

This also removes the duplicate fc_lport_fill_dns_hdr() function.

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

 drivers/scsi/libfc/fc_ns.c |   49 +++++++-------------------------------------
 include/scsi/libfc/libfc.h |   18 ++++++++++++++++
 2 files changed, 26 insertions(+), 41 deletions(-)

diff --git a/drivers/scsi/libfc/fc_ns.c b/drivers/scsi/libfc/fc_ns.c
index fc096ef..affd3be 100644
--- a/drivers/scsi/libfc/fc_ns.c
+++ b/drivers/scsi/libfc/fc_ns.c
@@ -65,8 +65,6 @@ static void fc_ns_gnn_id_resp(struct fc_seq *, struct fc_frame *, void *);
 static void fc_ns_gnn_id_error(struct fc_ns_port *, struct fc_frame *);
 static void fc_ns_enter_reg_pn(struct fc_lport *lp);
 static void fc_ns_error(struct fc_lport *lp, struct fc_frame *fp);
-static void fc_lport_fill_dns_hdr(struct fc_lport *lp, struct fc_ct_hdr *ct,
-				  unsigned int op, unsigned int req_size);
 static void fc_ns_resp(struct fc_seq *sp, struct fc_frame *fp,
 		       void *lp_arg);
 static void fc_ns_retry(struct fc_lport *lp);
@@ -261,10 +259,10 @@ static void fc_ns_enter_reg_ft(struct fc_lport *lp)
 		fp = fc_frame_alloc(lp, sizeof(*req));
 		if (fp) {
 			req = fc_frame_payload_get(fp, sizeof(*req));
-			fc_lport_fill_dns_hdr(lp, &req->ct,
-					      FC_NS_RFT_ID,
-					      sizeof(*req) -
-					      sizeof(struct fc_ct_hdr));
+			fc_fill_dns_hdr(lp, &req->ct,
+					FC_NS_RFT_ID,
+					sizeof(*req) -
+					sizeof(struct fc_ct_hdr));
 			hton24(req->fid.fp_fid, lp->fid);
 			req->fts = *lps;
 			fc_frame_setup(fp, FC_RCTL_DD_UNSOL_CTL, FC_TYPE_CT);
@@ -595,23 +593,6 @@ static void fc_ns_disc_done(struct fc_lport *lp)
 }
 
 /**
- * fc_ns_fill_dns_hdr - Fill in a name service request header
- * @lp: Fibre Channel host port instance
- * @ct: Common Transport (CT) header structure
- * @op: Name Service request code
- * @req_size: Full size of Name Service request
- */
-static void fc_ns_fill_dns_hdr(struct fc_lport *lp, struct fc_ct_hdr *ct,
-			       unsigned int op, unsigned int req_size)
-{
-	memset(ct, 0, sizeof(*ct) + req_size);
-	ct->ct_rev = FC_CT_REV;
-	ct->ct_fs_type = FC_FST_DIR;
-	ct->ct_fs_subtype = FC_NS_SUBTYPE;
-	ct->ct_cmd = htons((u16) op);
-}
-
-/**
  * fc_ns_gpn_ft_req - Send Get Port Names by FC-4 type (GPN_FT) request
  * @lp: Fibre Channel host port instance
  */
@@ -632,7 +613,7 @@ static void fc_ns_gpn_ft_req(struct fc_lport *lp)
 		error = ENOMEM;
 	} else {
 		rp = fc_frame_payload_get(fp, sizeof(*rp));
-		fc_ns_fill_dns_hdr(lp, &rp->ct, FC_NS_GPN_FT, sizeof(rp->gid));
+		fc_fill_dns_hdr(lp, &rp->ct, FC_NS_GPN_FT, sizeof(rp->gid));
 		rp->gid.fn_fc4_type = FC_TYPE_FCP;
 
 		WARN_ON(!fc_lport_test_ready(lp));
@@ -889,7 +870,7 @@ static int fc_ns_gpn_id_req(struct fc_lport *lp, struct fc_ns_port *dp)
 		return -ENOMEM;
 
 	cp = fc_frame_payload_get(fp, sizeof(*cp));
-	fc_ns_fill_dns_hdr(lp, &cp->ct, FC_NS_GPN_ID, sizeof(cp->fid));
+	fc_fill_dns_hdr(lp, &cp->ct, FC_NS_GPN_ID, sizeof(cp->fid));
 	hton24(cp->fid.fp_fid, dp->ids.port_id);
 
 	WARN_ON(!fc_lport_test_ready(lp));
@@ -1057,20 +1038,6 @@ static void fc_ns_enter_dns_stop(struct fc_lport *lp)
 }
 
 /*
- * Fill in dNS request header.
- */
-static void
-fc_lport_fill_dns_hdr(struct fc_lport *lp, struct fc_ct_hdr *ct,
-		      unsigned int op, unsigned int req_size)
-{
-	memset(ct, 0, sizeof(*ct) + req_size);
-	ct->ct_rev = FC_CT_REV;
-	ct->ct_fs_type = FC_FST_DIR;
-	ct->ct_fs_subtype = FC_NS_SUBTYPE;
-	ct->ct_cmd = htons(op);
-}
-
-/*
  * Register port name with name server.
  */
 static void fc_ns_enter_reg_pn(struct fc_lport *lp)
@@ -1092,7 +1059,7 @@ static void fc_ns_enter_reg_pn(struct fc_lport *lp)
 	}
 	req = fc_frame_payload_get(fp, sizeof(*req));
 	memset(req, 0, sizeof(*req));
-	fc_lport_fill_dns_hdr(lp, &req->ct, FC_NS_RPN_ID, sizeof(req->rn));
+	fc_fill_dns_hdr(lp, &req->ct, FC_NS_RPN_ID, sizeof(req->rn));
 	hton24(req->rn.fr_fid.fp_fid, lp->fid);
 	put_unaligned_be64(lp->wwpn, &req->rn.fr_wwn);
 	fc_frame_setup(fp, FC_RCTL_DD_UNSOL_CTL, FC_TYPE_CT);
@@ -1146,7 +1113,7 @@ static int fc_ns_gnn_id_req(struct fc_lport *lp, struct fc_ns_port *dp)
 		return -ENOMEM;
 
 	cp = fc_frame_payload_get(fp, sizeof(*cp));
-	fc_ns_fill_dns_hdr(lp, &cp->ct, FC_NS_GNN_ID, sizeof(cp->fid));
+	fc_fill_dns_hdr(lp, &cp->ct, FC_NS_GNN_ID, sizeof(cp->fid));
 	hton24(cp->fid.fp_fid, dp->ids.port_id);
 
 	WARN_ON(!fc_lport_test_ready(lp));
diff --git a/include/scsi/libfc/libfc.h b/include/scsi/libfc/libfc.h
index 720c607..c525d4c 100644
--- a/include/scsi/libfc/libfc.h
+++ b/include/scsi/libfc/libfc.h
@@ -29,6 +29,7 @@
 #include <scsi/fc/fc_fcp.h>
 #include <scsi/fc/fc_ns.h>
 #include <scsi/fc/fc_els.h>
+#include <scsi/fc/fc_gs.h>
 
 #include <scsi/libfc/fc_frame.h>
 
@@ -484,6 +485,23 @@ static inline int fc_lport_locked(struct fc_lport *lp)
 #endif /* CONFIG_SMP || CONFIG_DEBUG_SPINLOCK */
 }
 
+/**
+ * fc_fill_dns_hdr - Fill in a name service request header
+ * @lp: Fibre Channel host port instance
+ * @ct: Common Transport (CT) header structure
+ * @op: Name Service request code
+ * @req_size: Full size of Name Service request
+ */
+static inline void fc_fill_dns_hdr(struct fc_lport *lp, struct fc_ct_hdr *ct,
+				   unsigned int op, unsigned int req_size)
+{
+	memset(ct, 0, sizeof(*ct) + req_size);
+	ct->ct_rev = FC_CT_REV;
+	ct->ct_fs_type = FC_FST_DIR;
+	ct->ct_fs_subtype = FC_NS_SUBTYPE;
+	ct->ct_cmd = htons((u16) op);
+}
+
 /*
  * Locking code.
  */




More information about the devel mailing list