[Open-FCoE] [PATCH 3/4] fcoe: move fcoe_transport_template and fcoe_transport_function

Yi Zou yi.zou at intel.com
Wed Oct 1 21:59:25 UTC 2008


From: Chris Leech <christopher.leech at intel.com>

Add fc_get_host_port_id() and fc_get_host_port_type() and reorganized the
fcoe_transport_function.

Signed-off-by: Chris Leech <christopher.leech at intel.com>
Signed-off-by: Yi Zou <yi.zou at intel.com>
---

 drivers/scsi/fcoe/fc_transport_fcoe.c |   49 +----------------------------
 drivers/scsi/fcoe/fcoe_def.h          |    4 ++
 drivers/scsi/fcoe/fcoe_sw.c           |   56 +++++++++++++++++++++++++++++++++
 drivers/scsi/libfc/fc_lport.c         |   15 +++++++++
 include/scsi/libfc/libfc.h            |    2 +
 5 files changed, 78 insertions(+), 48 deletions(-)

diff --git a/drivers/scsi/fcoe/fc_transport_fcoe.c b/drivers/scsi/fcoe/fc_transport_fcoe.c
index fbec7f9..76888cf 100644
--- a/drivers/scsi/fcoe/fc_transport_fcoe.c
+++ b/drivers/scsi/fcoe/fc_transport_fcoe.c
@@ -49,48 +49,6 @@ static int fcoe_device_notification(struct notifier_block *, ulong, void *);
 static void fcoe_dev_setup(void);
 static void fcoe_dev_cleanup(void);
 
-struct scsi_transport_template *fcoe_transport_template;
-
-static int fcoe_reset(struct Scsi_Host *shost)
-{
-	struct fc_lport *lp = shost_priv(shost);
-	fc_lport_enter_reset(lp);
-	return 0;
-}
-
-struct fc_function_template fcoe_transport_function = {
-	.show_host_node_name = 1,
-	.show_host_port_name = 1,
-	.show_host_supported_classes = 1,
-	.show_host_supported_fc4s = 1,
-	.show_host_active_fc4s = 1,
-	.show_host_maxframe_size = 1,
-
-	.show_host_port_id = 1,
-	.show_host_supported_speeds = 1,
-	.get_host_speed = fc_get_host_speed,
-	.show_host_speed = 1,
-	.show_host_port_type = 1,
-	.get_host_port_state = fc_get_host_port_state,
-	.show_host_port_state = 1,
-	.show_host_symbolic_name = 1,
-
-	.dd_fcrport_size = sizeof(struct fc_rport_libfc_priv),
-	.show_rport_maxframe_size = 1,
-	.show_rport_supported_classes = 1,
-
-	.show_host_fabric_name = 1,
-	.show_starget_node_name = 1,
-	.show_starget_port_name = 1,
-	.show_starget_port_id = 1,
-	.set_rport_dev_loss_tmo = fc_set_rport_loss_tmo,
-	.show_rport_dev_loss_tmo = 1,
-	.get_fc_host_stats = fc_get_host_stats,
-	.issue_fc_host_lip = fcoe_reset,
-
-	.terminate_rport_io = fc_rport_terminate_io,
-};
-
 #ifdef CONFIG_HOTPLUG_CPU
 static struct notifier_block fcoe_cpu_notifier = {
 	.notifier_call = fcoe_cpu_callback,
@@ -364,10 +322,7 @@ static int __init fcoe_init(void)
 	fcoe_timer.expires = (jiffies + (10 * HZ));
 	add_timer(&fcoe_timer);
 
-	fcoe_transport_template =
-		fc_attach_transport(&fcoe_transport_function);
-
-	if (fcoe_transport_template == NULL) {
+	if (fcoe_sw_init() != 0) {
 		FC_DBG("fail to attach fc transport");
 		return -1;
 	}
@@ -427,6 +382,6 @@ static void __exit fcoe_exit(void)
 		}
 	}
 
-	fc_release_transport(fcoe_transport_template);
+	fcoe_sw_exit();
 }
 module_exit(fcoe_exit);
diff --git a/drivers/scsi/fcoe/fcoe_def.h b/drivers/scsi/fcoe/fcoe_def.h
index 1fe4db6..3d7e9e1 100644
--- a/drivers/scsi/fcoe/fcoe_def.h
+++ b/drivers/scsi/fcoe/fcoe_def.h
@@ -74,7 +74,6 @@ struct fcoe_softc {
 };
 
 extern int debug_fcoe;
-extern struct scsi_transport_template *fcoe_transport_template;
 int fcoe_percpu_receive_thread(void *arg);
 
 /*
@@ -88,4 +87,7 @@ int fcoe_xmit(struct fc_lport *, struct fc_frame *);
 int fcoe_rcv(struct sk_buff *, struct net_device *,
 	     struct packet_type *, struct net_device *);
 int fcoe_link_ok(struct fc_lport *);
+
+int __init fcoe_sw_init(void);
+void __exit fcoe_sw_exit(void);
 #endif /* _FCOE_DEF_H_ */
diff --git a/drivers/scsi/fcoe/fcoe_sw.c b/drivers/scsi/fcoe/fcoe_sw.c
index 1b77192..fcef466 100644
--- a/drivers/scsi/fcoe/fcoe_sw.c
+++ b/drivers/scsi/fcoe/fcoe_sw.c
@@ -59,6 +59,8 @@ DEFINE_RWLOCK(fcoe_hostlist_lock);
 DEFINE_TIMER(fcoe_timer, NULL, 0, 0);
 struct fcoe_percpu_s *fcoe_percpu[NR_CPUS];
 
+static struct scsi_transport_template *fcoe_transport_template;
+
 static struct fcoe_softc *fcoe_find_fc_lport(const char *name)
 {
 	struct fcoe_softc *fc;
@@ -492,3 +494,57 @@ void fcoe_clean_pending_queue(struct fc_lport *lp)
 	}
 	spin_unlock_bh(&fc->fcoe_pending_queue.lock);
 }
+
+static int fcoe_reset(struct Scsi_Host *shost)
+{
+	struct fc_lport *lp = shost_priv(shost);
+	fc_lport_enter_reset(lp);
+	return 0;
+}
+
+struct fc_function_template fcoe_transport_function = {
+	.show_host_node_name = 1,
+	.show_host_port_name = 1,
+	.show_host_supported_classes = 1,
+	.show_host_supported_fc4s = 1,
+	.show_host_active_fc4s = 1,
+	.show_host_maxframe_size = 1,
+	.show_host_supported_speeds = 1,
+	.show_host_symbolic_name = 1,
+	.show_host_fabric_name = 1,
+
+	.get_host_port_id = fc_get_host_port_id,
+	.show_host_port_id = 1,
+	.get_host_port_type = fc_get_host_port_type,
+	.show_host_port_type = 1,
+	.get_host_port_state = fc_get_host_port_state,
+	.show_host_port_state = 1,
+	.get_host_speed = fc_get_host_speed,
+	.show_host_speed = 1,
+
+	.dd_fcrport_size = sizeof(struct fc_rport_libfc_priv),
+	.show_rport_maxframe_size = 1,
+	.show_rport_supported_classes = 1,
+	.set_rport_dev_loss_tmo = fc_set_rport_loss_tmo,
+	.show_rport_dev_loss_tmo = 1,
+	.show_starget_node_name = 1,
+	.show_starget_port_name = 1,
+	.show_starget_port_id = 1,
+
+	.get_fc_host_stats = fc_get_host_stats,
+	.issue_fc_host_lip = fcoe_reset,
+
+	.terminate_rport_io = fc_rport_terminate_io,
+};
+
+int __init fcoe_sw_init(void)
+{
+	fcoe_transport_template =
+		fc_attach_transport(&fcoe_transport_function);
+	return fcoe_transport_template ? 0 : -1;
+}
+
+void __exit fcoe_sw_exit(void)
+{
+	fc_release_transport(fcoe_transport_template);
+}
diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
index afc0c76..08da0af 100644
--- a/drivers/scsi/libfc/fc_lport.c
+++ b/drivers/scsi/libfc/fc_lport.c
@@ -107,6 +107,21 @@ static void fc_lport_ptp_clear(struct fc_lport *lp)
 /*
  * Routines to support struct fc_function_template
  */
+void fc_get_host_port_id(struct Scsi_Host *shost)
+{
+	struct fc_lport *lp = shost_priv(shost);
+
+	fc_host_port_id(shost) = lp->fid;
+}
+EXPORT_SYMBOL(fc_get_host_port_id);
+
+void fc_get_host_port_type(struct Scsi_Host *shost)
+{
+	/* TODO - currently just NPORT */
+	fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
+}
+EXPORT_SYMBOL(fc_get_host_port_type);
+
 void fc_get_host_port_state(struct Scsi_Host *shost)
 {
 	struct fc_lport *lp = shost_priv(shost);
diff --git a/include/scsi/libfc/libfc.h b/include/scsi/libfc/libfc.h
index 0c39739..08f5c0a 100644
--- a/include/scsi/libfc/libfc.h
+++ b/include/scsi/libfc/libfc.h
@@ -751,6 +751,8 @@ void fc_seq_set_rec_data(struct fc_seq *sp, u32 rec_data);
  * Functions for fc_functions_template
  */
 void fc_get_host_speed(struct Scsi_Host *shost);
+void fc_get_host_port_id(struct Scsi_Host *shost);
+void fc_get_host_port_type(struct Scsi_Host *shost);
 void fc_get_host_port_state(struct Scsi_Host *shost);
 void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout);
 struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *);




More information about the devel mailing list