[Open-FCoE] [PATCH 2/7] Moved lp event handler from inner port to fcs_state

Vasu Dev vasu.dev at intel.com
Tue Apr 1 15:25:47 UTC 2008


Moved lp event handler from inner port to fcs_state and
also added fcs_state pointer to lp to replace inner port use
between lp and FCS. Added new fcs_enq_handler() API in fcs
to add an event handler to sa_event list in fcs_state.

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

 drivers/scsi/ofc/include/fc_local_port.h     |    2 ++
 drivers/scsi/ofc/include/fc_sess.h           |    1 +
 drivers/scsi/ofc/include/fcs_state.h         |    4 ++++
 drivers/scsi/ofc/openfc/fc_local_port.c      |    8 +++++---
 drivers/scsi/ofc/openfc/fc_local_port_impl.h |    1 +
 drivers/scsi/ofc/openfc/fcs_state.c          |   23 +++++++++++++----------
 6 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/ofc/include/fc_local_port.h b/drivers/scsi/ofc/include/fc_local_port.h
index e3eae0d..3626f54 100644
--- a/drivers/scsi/ofc/include/fc_local_port.h
+++ b/drivers/scsi/ofc/include/fc_local_port.h
@@ -28,6 +28,7 @@
 #include "sa_event.h"
 #include "fc_fs.h"
 #include "fcdev.h"
+#include "fcs_state.h"
 
 struct fc_local_port;		/* semi-opaque.  See fc_local_port_impl.h */
 struct fc_remote_port;
@@ -41,6 +42,7 @@ struct fc_ns_fts;
 struct fc_local_port *fc_local_port_create(struct fc_virt_fab *,
 					   struct fcdev *,
 					   struct fc_port *,
+					   struct fcs_state *,
 					   fc_wwn_t wwpn, fc_wwn_t wwnn,
 					   u_int timeout_msec,
 					   u_int retry_limit);
diff --git a/drivers/scsi/ofc/include/fc_sess.h b/drivers/scsi/ofc/include/fc_sess.h
index eb79d20..9ea7a1a 100644
--- a/drivers/scsi/ofc/include/fc_sess.h
+++ b/drivers/scsi/ofc/include/fc_sess.h
@@ -19,6 +19,7 @@
 
 #ifndef _LIBFC_SESS_H_
 #define _LIBFC_SESS_H_
+#include "sa_event.h"
 
 /*
  * Fibre Channel Sessions.
diff --git a/drivers/scsi/ofc/include/fcs_state.h b/drivers/scsi/ofc/include/fcs_state.h
index eecc81f..151c1da 100644
--- a/drivers/scsi/ofc/include/fcs_state.h
+++ b/drivers/scsi/ofc/include/fcs_state.h
@@ -21,6 +21,8 @@
 #define _LIBFC_FCS_STATE_H_
 
 #include "fcdev.h"
+#include "fc_exch.h"
+#include "sa_event.h"
 
 struct fcs_state;
 struct fc_remote_port;
@@ -55,6 +57,8 @@ int fcs_local_port_set(struct fcs_state *, fc_wwn_t node, fc_wwn_t port);
 int fcs_cmd_send(struct fcs_state *, struct fc_frame *,
 			struct fc_frame *, u_int, u_int);
 void fcs_send_event(struct fcs_state *sp, enum fc_event event);
+struct sa_event *fcs_enq_handler(struct fcs_state *sp,
+				     sa_event_handler_t *handler, void *arg);
 struct fc_local_port *fcs_get_local_port(struct fcs_state *);
 
 /*
diff --git a/drivers/scsi/ofc/openfc/fc_local_port.c b/drivers/scsi/ofc/openfc/fc_local_port.c
index edbb910..dcfc54e 100644
--- a/drivers/scsi/ofc/openfc/fc_local_port.c
+++ b/drivers/scsi/ofc/openfc/fc_local_port.c
@@ -88,7 +88,7 @@ static void fc_local_port_enter_logo(struct fc_local_port *);
 static void fc_local_port_ns_resp(struct fc_seq *, struct fc_frame *, void *);
 static void fc_local_port_error(enum fc_event, void *);
 static void fc_local_port_scr_resp(struct fc_seq *, struct fc_frame *, void *);
-static void fc_local_port_port_event(int, void *);
+static void fc_local_port_fcs_event(int, void *);
 static void fc_local_port_set_fid_int(struct fc_local_port *, fc_fid_t);
 static void fc_local_port_gid_pn_error(enum fc_event, void *arg);
 
@@ -834,6 +834,7 @@ static void fc_local_port_enter_logo(struct fc_local_port *lp)
 struct fc_local_port *fc_local_port_create(struct fc_virt_fab *vf,
 					   struct fcdev *dev,
 					   struct fc_port *port,
+					   struct fcs_state *sp,
 					   fc_wwn_t wwpn, fc_wwn_t wwnn,
 					   u_int timeout_msec,
 					   u_int retry_limit)
@@ -848,6 +849,7 @@ struct fc_local_port *fc_local_port_create(struct fc_virt_fab *vf,
 	atomic_set(&lp->fl_refcnt, 1);
 	lp->dev = dev;
 	lp->fl_port = port;
+	lp->sp = sp;
 	lp->fl_port_wwn = wwpn;
 	lp->fl_node_wwn = wwnn;
 	lp->fl_state = LOCAL_PORT_ST_INIT;
@@ -868,7 +870,7 @@ struct fc_local_port *fc_local_port_create(struct fc_virt_fab *vf,
 	spin_lock_init(&lp->fl_lock);
 	sa_spin_lock_debug_set_hier(&lp->fl_lock, 0);
 
-	if (!fc_port_enq_handler(port, fc_local_port_port_event, lp)) {
+	if (!fcs_enq_handler(sp, fc_local_port_fcs_event, lp)) {
 		sa_event_list_free(lp->fl_events);
 		goto err;
 	}
@@ -1545,7 +1547,7 @@ static void fc_local_port_error(enum fc_event event, void *lp_arg)
 /*
  * Handle state change from the ingress/egress port.
  */
-static void fc_local_port_port_event(int event, void *lp_arg)
+static void fc_local_port_fcs_event(int event, void *lp_arg)
 {
 	struct fc_local_port *lp = lp_arg;
 
diff --git a/drivers/scsi/ofc/openfc/fc_local_port_impl.h b/drivers/scsi/ofc/openfc/fc_local_port_impl.h
index f85e07e..06d6f35 100644
--- a/drivers/scsi/ofc/openfc/fc_local_port_impl.h
+++ b/drivers/scsi/ofc/openfc/fc_local_port_impl.h
@@ -54,6 +54,7 @@ struct fc_local_port {
 	struct fc_virt_fab *fl_vf;		/* virtual fabric */
 	struct list_head fl_list;		/* list headed in virt_fab */
 	struct fc_port	*fl_port;		/* port to use when sending */
+	struct fcs_state *sp;			/* fcs for this local port */
 	struct fcdev	*dev;			/* fc device instance */
 	struct fc_sess	*fl_dns_sess;		/* session for dNS queries */
 	struct fc_remote_port *fl_ptp_rp;	/* point-to-point remote port */
diff --git a/drivers/scsi/ofc/openfc/fcs_state.c b/drivers/scsi/ofc/openfc/fcs_state.c
index 4c4b07a..78d96df 100644
--- a/drivers/scsi/ofc/openfc/fcs_state.c
+++ b/drivers/scsi/ofc/openfc/fcs_state.c
@@ -127,7 +127,7 @@ struct fcs_state *fcs_create(struct fcs_create_args *ap)
 	if (!sp->events)
 		goto error;
 
-	if (!sa_event_enq(sp->events, fcs_event, (void *)sp))
+	if (!fcs_enq_handler(sp, fcs_event, (void *)sp))
 		goto error;
 	return sp;
 
@@ -147,8 +147,6 @@ static int fcs_drop(struct fcdev *hba, struct fc_frame *fp)
  */
 void fcs_destroy(struct fcs_state *sp)
 {
-	struct fc_port *port;
-
 	WARN_ON(!sp->fs_args.dev);
 
 	sp->fs_args.fca_disc_done = (void (*)(void *))fcs_nop;
@@ -158,12 +156,8 @@ void fcs_destroy(struct fcs_state *sp)
 
 	sp->fs_args.dev->port_ops.send = fcs_drop;
 	sa_event_deq(sp->events, fcs_event, (void *)sp);
+	fcs_send_event(sp, FC_EV_CLOSED);
 	sa_event_list_free(sp->events);
-	port = sp->fs_inner_port;
-	if (port) {
-		sp->fs_inner_port = NULL;
-		fc_port_close_ingress(port);
-	}
 
 	if (sp->fs_local_port) {
 		fc_local_port_destroy(sp->fs_local_port);
@@ -220,7 +214,7 @@ int fcs_local_port_set(struct fcs_state *sp, fc_wwn_t wwnn, fc_wwn_t wwpn)
 	WARN_ON(!sp->fs_inner_port);
 	WARN_ON(sp->fs_local_port);
 	lp = fc_local_port_create(sp->fs_vf, sp->fs_args.dev,
-				  sp->fs_inner_port, wwpn, wwnn,
+				  sp->fs_inner_port, sp, wwpn, wwnn,
 				  sp->fs_args.fca_e_d_tov,
 				  sp->fs_args.fca_plogi_retries);
 	if (!lp)
@@ -436,6 +430,16 @@ void fcs_send_event(struct fcs_state *sp, enum fc_event event)
 	sa_event_call(sp->events, event);
 }
 
+/*
+ * Set fcs event handler.
+ */
+struct sa_event *fcs_enq_handler(struct fcs_state *sp,
+				     sa_event_handler_t *handler, void *arg)
+{
+	return sa_event_enq(sp->events, handler, arg);
+}
+
+
 static void fcs_event(int event, void *sp_arg)
 {
 	struct fcs_state *sp = sp_arg;
@@ -449,7 +453,6 @@ static void fcs_event(int event, void *sp_arg)
 		break;
 	}
 	WARN_ON(!sp->fs_inner_port);
-	fc_port_send_event(sp->fs_inner_port, event);
 }
 
 struct fc_local_port *fcs_get_local_port(struct fcs_state *sp)




More information about the devel mailing list