[Open-FCoE] [PATCH 2/5] Removed outer port use from fcs

Vasu Dev vasu.dev at intel.com
Tue Apr 1 14:12:33 UTC 2008


Removed outer port use from fcs create and fcs destroy functions.
Made fcdev available via fcs_state for previously used some of the fields
from outer port, e.g. egress handler and framesize from outer port.
Also added fcdev to fc_local_port and initialized this fcdev during
local port create, this fcdev will be used for frame alloc
and removing inner port later.

Also moved outer port event list to 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/fcs_state.h         |    4 ++
 drivers/scsi/ofc/openfc/fc_local_port.c      |    2 +
 drivers/scsi/ofc/openfc/fc_local_port_impl.h |    1 +
 drivers/scsi/ofc/openfc/fcs_state.c          |   47 ++++++++++++++------------
 drivers/scsi/ofc/openfc/fcs_state_impl.h     |    4 ++
 drivers/scsi/ofc/openfc/openfc_if.c          |    7 ++--
 drivers/scsi/ofc/openfc/openfc_ioctl.c       |   10 +++---
 8 files changed, 48 insertions(+), 29 deletions(-)

diff --git a/drivers/scsi/ofc/include/fc_local_port.h b/drivers/scsi/ofc/include/fc_local_port.h
index 37edb94..e3eae0d 100644
--- a/drivers/scsi/ofc/include/fc_local_port.h
+++ b/drivers/scsi/ofc/include/fc_local_port.h
@@ -27,6 +27,7 @@
  */
 #include "sa_event.h"
 #include "fc_fs.h"
+#include "fcdev.h"
 
 struct fc_local_port;		/* semi-opaque.  See fc_local_port_impl.h */
 struct fc_remote_port;
@@ -38,6 +39,7 @@ struct fc_frame;
 struct fc_ns_fts;
 
 struct fc_local_port *fc_local_port_create(struct fc_virt_fab *,
+					   struct fcdev *,
 					   struct fc_port *,
 					   fc_wwn_t wwpn, fc_wwn_t wwnn,
 					   u_int timeout_msec,
diff --git a/drivers/scsi/ofc/include/fcs_state.h b/drivers/scsi/ofc/include/fcs_state.h
index 1ed749f..eecc81f 100644
--- a/drivers/scsi/ofc/include/fcs_state.h
+++ b/drivers/scsi/ofc/include/fcs_state.h
@@ -20,6 +20,8 @@
 #ifndef _LIBFC_FCS_STATE_H_
 #define _LIBFC_FCS_STATE_H_
 
+#include "fcdev.h"
+
 struct fcs_state;
 struct fc_remote_port;
 struct fc_local_port;
@@ -34,6 +36,7 @@ struct fcs_create_args {
 	void		(*fca_prlo_notify)(void *arg, struct fc_remote_port *);
 	void		*fca_cb_arg;	/* arg for callbacks */
 	struct fc_port *fca_port;	/* transport interface to FC fabric */
+	struct fcdev	*dev;		/* transport driver instance */
 	u_int fca_service_params;	/* service parm flags from fc/fcp.h */
 	fc_xid_t	fca_min_xid;	/* starting exchange ID */
 	fc_xid_t	fca_max_xid;	/* maximum exchange ID */
@@ -51,6 +54,7 @@ void fcs_recv(struct fcs_state *, struct fc_frame *);
 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 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 1eecb0e..7bde7a7 100644
--- a/drivers/scsi/ofc/openfc/fc_local_port.c
+++ b/drivers/scsi/ofc/openfc/fc_local_port.c
@@ -832,6 +832,7 @@ static void fc_local_port_enter_logo(struct fc_local_port *lp)
  * Create Local Port.
  */
 struct fc_local_port *fc_local_port_create(struct fc_virt_fab *vf,
+					   struct fcdev *dev,
 					   struct fc_port *port,
 					   fc_wwn_t wwpn, fc_wwn_t wwnn,
 					   u_int timeout_msec,
@@ -845,6 +846,7 @@ struct fc_local_port *fc_local_port_create(struct fc_virt_fab *vf,
 	memset(lp, 0, sizeof(*lp));
 	lp->fl_vf = vf;
 	atomic_set(&lp->fl_refcnt, 1);
+	lp->dev = dev;
 	lp->fl_port = port;
 	lp->fl_port_wwn = wwpn;
 	lp->fl_node_wwn = wwnn;
diff --git a/drivers/scsi/ofc/openfc/fc_local_port_impl.h b/drivers/scsi/ofc/openfc/fc_local_port_impl.h
index 725402e..f85e07e 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 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 */
 	struct list_head fl_sess_list;	/* list of sessions */
diff --git a/drivers/scsi/ofc/openfc/fcs_state.c b/drivers/scsi/ofc/openfc/fcs_state.c
index b1375f3..e11fef1 100644
--- a/drivers/scsi/ofc/openfc/fcs_state.c
+++ b/drivers/scsi/ofc/openfc/fcs_state.c
@@ -52,7 +52,7 @@ static int fcs_local_port_prli_accept(struct fc_local_port *,
 				      struct fc_remote_port *, void *);
 static void fcs_add_remote(void *, struct fc_remote_port *, enum fc_event);
 static void fcs_sess_event(int, void *);
-static void fcs_port_event(int, void *);
+static void fcs_event(int, void *);
 
 void fcs_module_init(void)
 {
@@ -98,10 +98,8 @@ struct fcs_state *fcs_create(struct fcs_create_args *ap)
 {
 	struct fcs_state *sp;
 	struct fc_port *inner_port;
-	struct fc_port *outer_port;
 
 	WARN_ON(!ap->fca_disc_done);
-	WARN_ON(!ap->fca_port);
 
 	sp = sa_malloc(sizeof(*sp));
 	if (!sp)
@@ -125,15 +123,18 @@ struct fcs_state *fcs_create(struct fcs_create_args *ap)
 	if (!inner_port)
 		goto error;
 	sp->fs_inner_port = inner_port;
-	outer_port = ap->fca_port;
-	fcs_set_mfs_int(sp, fc_port_get_max_frame_size(outer_port));
+
+	if (!ap->dev)
+		goto error;
+
+	fcs_set_mfs_int(sp, ap->dev->framesize);
 	fc_port_set_ingress(inner_port, fcs_recv_req, sp);
-	fc_port_set_egress(inner_port, (int (*)(void *, struct fc_frame *))
-			   fc_port_egress, outer_port);
-	fc_port_set_frame_alloc(inner_port, outer_port->np_frame_alloc);
-	fc_port_set_ingress(outer_port,
-			    (void (*)(void *, struct fc_frame *))fcs_recv, sp);
-	if (!fc_port_enq_handler(outer_port, fcs_port_event, sp))
+
+	sp->events = sa_event_list_alloc();
+	if (!sp->events)
+		goto error;
+
+	if (!sa_event_enq(sp->events, fcs_event, (void *)sp))
 		goto error;
 	return sp;
 
@@ -142,7 +143,7 @@ error:
 	return NULL;
 }
 
-static int fcs_drop(void *arg, struct fc_frame *fp)
+static int fcs_drop(struct fcdev *hba, struct fc_frame *fp)
 {
 	fc_frame_free(fp);
 	return 0;
@@ -155,30 +156,28 @@ void fcs_destroy(struct fcs_state *sp)
 {
 	struct fc_port *port;
 
-	WARN_ON(!sp->fs_args.fca_port);
+	WARN_ON(!sp->fs_args.dev);
 
 	sp->fs_args.fca_disc_done = (void (*)(void *))fcs_nop;
 	sp->fs_args.fca_remote_port_state_change =
 	    (void (*)(void *, struct fc_remote_port *))fcs_nop;
 	fcs_ev_add(sp, OFC_EV_HBA_DEL, NULL, 0);
 
-	fc_port_set_egress(sp->fs_args.fca_port, fcs_drop, NULL);
-
-	fc_port_deq_handler(sp->fs_args.fca_port, fcs_port_event, sp);
+	sp->fs_args.dev->port_ops.send = fcs_drop;
+	sa_event_deq(sp->events, fcs_event, (void *)sp);
+	sa_event_list_free(sp->events);
 	port = sp->fs_inner_port;
 	if (port) {
 		sp->fs_inner_port = NULL;
 		fc_port_close_ingress(port);
-		fc_port_close_egress(port);
 	}
-	fc_port_close_ingress(sp->fs_args.fca_port);
+
 	if (sp->fs_local_port) {
 		fc_local_port_destroy(sp->fs_local_port);
 		fc_local_port_release(sp->fs_local_port);
 	}
 	if (sp->fs_vf)
 		fc_virt_fab_free(sp->fs_vf);
-	fc_port_close_egress(sp->fs_args.fca_port);
 	sa_free(sp);
 }
 
@@ -226,7 +225,8 @@ 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_inner_port, wwpn, wwnn,
+	lp = fc_local_port_create(sp->fs_vf, sp->fs_args.dev,
+				  sp->fs_inner_port, wwpn, wwnn,
 				  sp->fs_args.fca_e_d_tov,
 				  sp->fs_args.fca_plogi_retries);
 	if (!lp)
@@ -437,7 +437,12 @@ struct fc_sess *fcs_sess_get(struct fcs_state *sp, struct fc_remote_port *rp)
 	return sess;
 }
 
-static void fcs_port_event(int event, void *sp_arg)
+void fcs_send_event(struct fcs_state *sp, enum fc_event event)
+{
+	sa_event_call(sp->events, event);
+}
+
+static void fcs_event(int event, void *sp_arg)
 {
 	struct fcs_state *sp = sp_arg;
 
diff --git a/drivers/scsi/ofc/openfc/fcs_state_impl.h b/drivers/scsi/ofc/openfc/fcs_state_impl.h
index 9f4ecc1..d33b49c 100644
--- a/drivers/scsi/ofc/openfc/fcs_state_impl.h
+++ b/drivers/scsi/ofc/openfc/fcs_state_impl.h
@@ -20,6 +20,9 @@
 #ifndef _OPENFC_FCS_STATE_IMPL_H_
 #define _OPENFC_FCS_STATE_IMPL_H_
 
+#include "sa_event.h"
+#include "fc_event.h"
+
 /*
  * Private state structure.
  */
@@ -29,6 +32,7 @@ struct fcs_state {
 	struct fc_local_port *fs_local_port;	/* local port */
 	struct fc_port	*fs_inner_port;		/* port used by local port */
 	uint8_t		fs_disc_done;		/* discovery complete */
+	struct sa_event_list *events;		/* fcs events */
 };
 
 void fcs_ev_destroy(void);
diff --git a/drivers/scsi/ofc/openfc/openfc_if.c b/drivers/scsi/ofc/openfc/openfc_if.c
index ab26a9b..e882844 100644
--- a/drivers/scsi/ofc/openfc/openfc_if.c
+++ b/drivers/scsi/ofc/openfc/openfc_if.c
@@ -980,6 +980,7 @@ int openfc_register(struct fcdev *dev)
 		ofc_fcs_args.fca_max_xid = OPENFC_MAX_XID;
 
 	ofc_fcs_args.fca_cb_arg = (void *)openfcp;
+	ofc_fcs_args.dev = dev;
 	openfcp->fcs_state = fcs_create(&ofc_fcs_args);
 	if (openfcp->fcs_state == NULL) {
 		OFC_DBG("Could not create fcs_state structure");
@@ -1017,7 +1018,7 @@ int openfc_register(struct fcdev *dev)
 		goto out_fcs;
 	}
 	if (dev->fd_link_status == TRANS_LINK_DOWN) {
-		fc_port_send_event(openfcp->fcs_port, FC_EV_DOWN);
+		fcs_send_event(openfcp->fcs_state, FC_EV_DOWN);
 		openfcp->status &= ~OPENFC_LINK_UP;
 	}
 	if (dev->options & TRANS_O_FCS_AUTO) {
@@ -1119,7 +1120,7 @@ void openfc_linkup(struct fcdev *dev)
 	struct openfc_softc *openfcp = openfc_get_softc(dev);
 
 	if (!(openfcp->status & OPENFC_LINK_UP)) {
-		fc_port_send_event(openfcp->fcs_port, FC_EV_READY);
+		fcs_send_event(openfcp->fcs_state, FC_EV_READY);
 		openfcp->status |= OPENFC_LINK_UP;
 	}
 }
@@ -1135,7 +1136,7 @@ void openfc_linkdown(struct fcdev *dev)
 	struct fc_scsi_pkt *fsp;
 
 	if (openfcp->status & OPENFC_LINK_UP) {
-		fc_port_send_event(openfcp->fcs_port, FC_EV_DOWN);
+		fcs_send_event(openfcp->fcs_state, FC_EV_DOWN);
 		openfcp->status &= ~(OPENFC_LINK_UP);
 		fsp = openfc_alloc_scsi_pkt(openfcp);
 		openfc_scsi_cleanup(fsp);
diff --git a/drivers/scsi/ofc/openfc/openfc_ioctl.c b/drivers/scsi/ofc/openfc/openfc_ioctl.c
index a421f09..b0d270d 100644
--- a/drivers/scsi/ofc/openfc/openfc_ioctl.c
+++ b/drivers/scsi/ofc/openfc/openfc_ioctl.c
@@ -189,14 +189,14 @@ static int openfc_ioctl(struct inode *inode, struct file *file,
 			port->pi_max_frame_size = FC_MAX_PAYLOAD;
 
 		port->pi_class = FC_COS_CLASS3;
-		if (fc_port_ready(openfcp->fcs_port) == 0) {
+		if (openfcp->fcs_state == NULL)
 			port->pi_port_state = OFC_PSTATE_NOLINK;
-		} else if (atomic_read(&openfcp->fcs_status) ==
-			   OPENFC_FCS_ONLINE) {
+		else if (atomic_read(&openfcp->fcs_status) ==
+			   OPENFC_FCS_ONLINE)
 			port->pi_port_state = OFC_PSTATE_ONLINE;
-		} else {
+		else
 			port->pi_port_state = OFC_PSTATE_OFFLINE;
-		}
+
 		lp = fcs_get_local_port(openfcp->fcs_state);
 		fm = fc_local_port_get_fc4_map(lp);
 		memcpy(port->pi_fc4_support, fm, sizeof(*fm));




More information about the devel mailing list