Skip to contentSkip to conversation

Removal of state machine transition abstraction layer.

PATCH New Robert Love 1 participant 1 message Jan 12, 2008 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Removal of state machine transition abstraction layer.

Part of effort to remove libsa.

---

 drivers/scsi/ofc/include/sa_state.h    |  164 -------------
 drivers/scsi/ofc/libfc/fc_local_port.c |  402 ++++++++++++++------------------
 drivers/scsi/ofc/libfc/fc_sess.c       |  398 ++++++++++----------------------
 drivers/scsi/ofc/libfc/fc_sess_impl.h  |    1 
 drivers/scsi/ofc/libfc/fcs_state.c     |    4 
 drivers/scsi/ofc/libsa/Makefile        |    1 
 drivers/scsi/ofc/libsa/sa_state.c      |  371 ------------------------------
 7 files changed, 308 insertions(+), 1033 deletions(-)
 delete mode 100644 drivers/scsi/ofc/include/sa_state.h
 delete mode 100644 drivers/scsi/ofc/libsa/sa_state.c
drivers/scsi/ofc/include/sa_state.h deleted +0 -164
deleted file mode 100644
index 8a7ee8d..0000000
@@ -1,164 +0,0 @@
-/*
- * Copyright(c) 2007 Intel Corporation. All rights reserved.
- * 
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- * 
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- * 
- * Maintained at www.Open-FCoE.org
- */
-
-#ifndef _LIBSA_SA_STATE_H_
-#define _LIBSA_SA_STATE_H_
-
-/*
- * State transition table handling.
- */
-struct sa_state_table;
-
-/*
- * State transition description.
- * There are the following entry types:
- * - END simply indicates the end of the table.
- * - STATE gives the number and name of a state.
- * - EVENT gives the number and name of an event
- * - HANDLER gives the number and function pointer to a handler.
- * - FROM sets the current state.
- * - NEXT gives a state transition from the current state on.
- * a given event; the next state and/or a handler to call are given.
- *
- * A handler can also be associated with a particular state, in which
- * case the handler will be called on every entry to the state.
- */
-struct sa_state_desc {
-	enum {
-		SST_END,	/* end of table */
-		SST_STATE,	/* state definition */
-		SST_EVENT,	/* event definition */
-		SST_HANDLER,	/* handler */
-		SST_FROM,	/* old state definition */
-		SST_NEXT,	/* state transition definition */
-	} sd_type;
-	u_char	sd_in;		/* event or state number */
-	u_char	sd_next;	/* next state number */
-	const char *sd_ptr;	/* name of state or event or function or NULL */
-};
-
-typedef void (sa_state_handler_t)(void *arg, u_int next_state, u_int event);
-
-/*
- * Convenience macros for filling in descriptors.
- */
-
-/**
- * SA_STATE_LABEL(state, name) - declare a state name and number.
- *
- * @param state symbol with value of state.
- * @param name human-readable name for state.
- *
- * This sets the current state for the following state event initializations.
- */
-#define SA_STATE_LABEL(state, name) { \
-        .sd_type = SST_STATE, .sd_ptr = name, .sd_in = state }
-
-/**
- * SA_STATE_NAME(state) - declare a state name and number.
- *
- * @param state symbol with value of state, also used for state name
- *
- * This sets the current state for the following state event initializations.
- */
-#define SA_STATE_NAME(state) SA_STATE_LABEL(state, #state)
-
-/**
- * SA_STATE_HANDLER(state, handler) - declare function to handle entry to state.
- *
- * @param state the state number.
- * @param handler the handler function pointer.
- */
-#define SA_STATE_HANDLER(state, handler) { \
-        .sd_type = SST_HANDLER, .sd_ptr = (void *) handler, .sd_in = state }
-
-/*
- * SA_STATE_EVENT(event)
- *
- * @param event symbol with value of event, also used for the event name.
- *
- * This declares an event which can be used in the state transition table.
- */
-#define SA_STATE_EVENT(event) { \
-        .sd_type = SST_EVENT, .sd_ptr = #event, .sd_in = event }
-
-/**
- * SA_STATE_FROM(val) - set the state number for subsequent SA_STATE_NEXT*()s.
- */
-#define SA_STATE_FROM(val) {            /* not really needed */ \
-        .sd_type = SST_STATE, .sd_in = val }
-
-/**
- * SA_STATE_NEXT_FUNC(event, next, handler) - declare transition entry.
- *
- * @param event the event number.
- * @param next the state to which to transition.
- * @param handler a pointer to a function to call before the transition.
- */
-#define SA_STATE_NEXT_FUNC(event, next, handler) { \
-        .sd_type = SST_NEXT, .sd_in = event, .sd_next = next, \
-        .sd_ptr = (void *) handler }
-
-/**
- * SA_STATE_NEXT(event, next) - declare transition entry.
- *
- * @param event the event number.
- * @param next the state to which to transition.
- */
-#define SA_STATE_NEXT(event, next)  SA_STATE_NEXT_FUNC(event, next, NULL)
-
-/**
- * SA_STATE_END - declare end of state table description.
- */
-#define SA_STATE_END    { .sd_type = SST_END }
-
-/*
- * State transition table initialization.
- */
-struct sa_state_table *sa_state_table_alloc(const char *name,
-					    const struct sa_state_desc
-					    *state_desc);
-
-/*
- * Free state table.
- */
-void sa_state_table_free(struct sa_state_table *);
-
-/*
- * Handle event for a state transition table.
- */
-void sa_state_table_step(struct sa_state_table *tp, void *statep,
-			 u_int event, void *arg);
-
-/*
- * Transition to the specified state.  Run the handler if any.
- */
-void sa_state_table_enter(struct sa_state_table *, void *statep,
-			  u_int new_state, u_int event, void *arg);
-
-/**
- * sa_state_table_log() - set function to log state table transitions.
- */
-void sa_state_table_log(struct sa_state_table *tp,
-			void (*log_func) (void *arg, const char *msg));
-
-const char *sa_state_event_name(struct sa_state_table *, u_int);
-const char *sa_state_name(struct sa_state_table *, u_int);
-
-#endif /* _LIBSA_SA_STATE_H_ */
drivers/scsi/ofc/libfc/fc_local_port.c +178 -224

659 lines not on this page · raw message

drivers/scsi/ofc/libfc/fc_sess.c +128 -270

619 lines not on this page · raw message

drivers/scsi/ofc/libfc/fc_sess_impl.h +0 -1
index 2660f1a..37166fb 100644
@@ -37,7 +37,6 @@ enum fc_sess_state {
 	SESS_ST_ERROR,		/* error */
 	SESS_ST_READY,		/* ready for use */
 	SESS_ST_LOGO,		/* port logout sent */
-	SESS_ST_RESTART,	/* restarting */
 };
 
 /*
drivers/scsi/ofc/libfc/fcs_state.c +2 -2
index d970ac9..794f440 100644
@@ -108,11 +108,11 @@ struct fcs_state *fcs_create(struct fcs_create_args *ap)
 	outer_port = ap->fca_port;
 	mfs = fc_port_get_max_frame_size(outer_port);
 	if (mfs < FC_MIN_MAX_PAYLOAD) {
-		OFC_DBG("port max frame size only %d (0x%x) bytes - "
+		OFC_DBG("port max frame size only %zx (0x%zx) bytes - "
 		       "setting to %d", mfs, mfs, FC_MIN_MAX_PAYLOAD);
 		mfs = 1024;
 	} else if (mfs > FC_MAX_PAYLOAD + sizeof(struct fc_frame_header)) {
-		OFC_DBG("port max frame size too large: %d (0x%x) bytes\n",
+		OFC_DBG("port max frame size too large: %zx (0x%zx) bytes\n",
 		       mfs, mfs);
 		mfs = FC_MAX_PAYLOAD + sizeof(struct fc_frame_header);
 	}
drivers/scsi/ofc/libsa/Makefile +0 -1
index 7f13291..42b8733 100644
@@ -8,5 +8,4 @@ libsa-y := \
 	sa_assert.o \
 	sa_event.o \
 	sa_hash_kern.o \
-	sa_state.o \
 	sa_timer.o
drivers/scsi/ofc/libsa/sa_state.c deleted +0 -371

371 lines not on this page · raw message