[Open-FCoE] [PATCH] [FCoE] Simplification of the user-mode code

Steve Ma steve.ma at intel.com
Fri Apr 18 01:28:50 UTC 2008


This patch includes:
 1) Removed fcgw
 2) Removed fds
 3) Simplified the build process by only build under the architecture
    of the build machine and placing the object files next to the
    *.[ch] files, instead of generating build-i386-linux-debug,
    build-x86_64-linux-debug, build-i386-linux-prod,
    build-x86_64-linux-prod, and dist-linux.
 4) Removed the incomplete code for generating docs in the Makefiles.
 5) Limit the build to work only for `uname -s` == Linux, and
    `uname -i` == x86_64, i386, i486, i586, or i686.
 6) Simplifying the make files in usr/make.
 9) Enable "make clean" within open-fcoe/usr.

Signed-off-by: Steve Ma <steve.ma at intel.com>
---

 usr/Makefile                       |  191 +--------
 usr/common/libfc/Makefile          |    4 
 usr/common/libfc/src/Makefile      |    6 
 usr/common/libsa/Makefile          |    4 
 usr/common/libsa/src/Makefile      |    5 
 usr/common/libtps/Makefile         |    2 
 usr/common/libtps/src/Makefile     |    5 
 usr/make/Doxyfile                  |  269 -------------
 usr/make/Makefile-ARCH-i386.inc    |   12 -
 usr/make/Makefile-ARCH-x86_64.inc  |    8 
 usr/make/Makefile-OPT-debug.inc    |    5 
 usr/make/Makefile-OPT-prod.inc     |    3 
 usr/make/Makefile-OS-linux.inc     |    8 
 usr/make/Makefile-tags.inc         |   17 -
 usr/make/Makefile.inc              |  296 +++-----------
 usr/make/README                    |   21 -
 usr/make/doc_head_template.html    |   12 -
 usr/make/doc_tail_template.html    |    5 
 usr/ofc/Makefile                   |    6 
 usr/ofc/lib/Makefile               |    3 
 usr/ofc/lib/libhbaofc/Makefile     |    5 
 usr/ofc/lib/libhbaofc/src/Makefile |   11 -
 usr/ofc/tools/Makefile             |   10 
 usr/ofc/tools/common/Makefile      |    3 
 usr/ofc/tools/common/src/Makefile  |    3 
 usr/ofc/tools/fcconf/Makefile      |    3 
 usr/ofc/tools/fcconf/src/Makefile  |   13 -
 usr/ofc/tools/fcgw/Makefile        |    4 
 usr/ofc/tools/fcgw/include/fcgw.h  |   75 ----
 usr/ofc/tools/fcgw/src/Makefile    |   28 -
 usr/ofc/tools/fcgw/src/fcgw.c      |  584 ----------------------------
 usr/ofc/tools/fcgw/src/fcgw_npiv.c |  552 --------------------------
 usr/ofc/tools/fcgw/src/fcgw_port.c |  127 ------
 usr/ofc/tools/fcping/Makefile      |    3 
 usr/ofc/tools/fcping/src/Makefile  |   13 -
 usr/ofc/tools/fds/Makefile         |    6 
 usr/ofc/tools/fds/src/Makefile     |   29 -
 usr/ofc/tools/fds/src/fds.c        |  760 ------------------------------------
 38 files changed, 154 insertions(+), 2957 deletions(-)
 delete mode 100644 usr/make/Doxyfile
 delete mode 100644 usr/make/Makefile-ARCH-i386.inc
 delete mode 100644 usr/make/Makefile-ARCH-x86_64.inc
 delete mode 100644 usr/make/Makefile-OPT-debug.inc
 delete mode 100644 usr/make/Makefile-OPT-prod.inc
 delete mode 100644 usr/make/Makefile-OS-linux.inc
 delete mode 100644 usr/make/Makefile-tags.inc
 delete mode 100644 usr/make/doc_head_template.html
 delete mode 100644 usr/make/doc_tail_template.html
 delete mode 100644 usr/ofc/tools/fcgw/Makefile
 delete mode 100644 usr/ofc/tools/fcgw/include/fcgw.h
 delete mode 100644 usr/ofc/tools/fcgw/src/Makefile
 delete mode 100644 usr/ofc/tools/fcgw/src/fcgw.c
 delete mode 100644 usr/ofc/tools/fcgw/src/fcgw_npiv.c
 delete mode 100644 usr/ofc/tools/fcgw/src/fcgw_port.c
 delete mode 100644 usr/ofc/tools/fds/Makefile
 delete mode 100644 usr/ofc/tools/fds/src/Makefile
 delete mode 100644 usr/ofc/tools/fds/src/fds.c


diff --git a/usr/Makefile b/usr/Makefile
index 18cc1bd..fe6cfe3 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -1,181 +1,52 @@
 # $Id: Makefile
 
-#
-# Define version of driver release.
-#
-OFC_RELEASE_VER := 0.26
-OFC_PKG_NAME := fcoe_apps
-
-#
-# set HBAAPI to the directory containing hbaapi.h
-#
-#HBAAPI=$(HOME)/src/hbaapi_src_2.2
-
-#
-# Set FCGW=y in the command line to include FCGW in the install.
-# It'll be included in the build so errors don't creep in.
-#
-FCGW ?= n
-
-SRC = .
-
-BUILD32 = $(SRC)/../build-i386-linux-debug
-BUILD64 = $(SRC)/../build-x86_64-linux-debug
-
-BUILD_VERSION := $(OFC_RELEASE_VER)
-OFC_RPM_NAME := $(OFC_PKG_NAME)-$(OFC_RELEASE_VER)
-
-DEST_BASE := $(SRC)/../dist-linux
-DEST_BASE := $(DEST_BASE)/$(OFC_RPM_NAME)
-DEST := $(DEST_BASE)
-
-DEST_LIB32 := $(DEST)/lib
-DEST_LIB64 := $(DEST)/lib64
-DEST_BIN32 := $(DEST)/bin
-DEST_BIN64 := $(DEST)/bin64
-DEST_CONF := $(DEST)/conf
-
-LIB_FILES := \
-	libhbaofc.so \
-	$(NULL)
-
-BIN_FILES := \
-	ofc/tools/fcconf/src/fcconf \
-	ofc/tools/fcping/src/fcping \
-	ofc/tools/fds/src/fds \
-	$(NULL)
-
-ifeq "$(FCGW)" "y"
-	BIN_FILES += ofc/tools/fcgw/src/fcgw
+ifeq "$(shell uname -i)" "x86_64"
+HBA_ID := org.openfc64
+LIB_PATH=/usr/local/lib64
+else
+HBA_ID := org.openfc
+LIB_PATH=/usr/local/lib
 endif
 
-SCRIPTS := \
-	ofc/tools/fcmenu/fcmenu.sh \
-	$(NULL)
-
-TXT_FILES := \
-	$(NULL)
+SRC = .
 
 all: test_setup
-	$(MAKE) -C $(SRC)/common/libtps
-	$(MAKE) -C $(SRC)/common/libsa
-	$(MAKE) -C $(SRC)/common/libfc
-	$(MAKE) HBAAPI=$(HBAAPI) -C $(SRC)/ofc
-	make release
+	make -C $(SRC)/common/libtps
+	make -C $(SRC)/common/libsa
+	make -C $(SRC)/common/libfc
+	make HBAAPI=$(HBAAPI) -C $(SRC)/ofc
 
 test_setup:
 	@[ $(HBAAPI) ] || echo "Set HBAAPI to the directory containing hbaapi.h"
 	@[ $(HBAAPI) ] || exit 1
 
-TARGETS = release32
-ifeq "$(shell uname -i)" "x86_64"
-	TARGETS += release64
-else
-	TARGETS += no64
-endif
-
-#
-# Make release of FCoE driver source with tool binaries
-# Start by removing old build results
-#
-release: clean $(TARGETS) final
-
 clean:
-	rm -rf $(DEST)
-	rm -f $(OFC_RPM_NAME).tgz $(OFC_RPM_NAME)
-
-release32:
-	mkdir -p $(DEST_LIB32) $(DEST_BIN32)
-	cp $(SRC)/ofc/tools/fcmenu/fcmenu.sh $(DEST_BIN32)/fcmenu
-	cp $(foreach FILE, $(LIB_FILES), $(BUILD32)/lib/$(FILE)) $(DEST_LIB32)
-	cp $(foreach FILE, $(BIN_FILES), $(BUILD32)/$(FILE)) $(DEST_BIN32)
-
-release64:
-	mkdir -p $(DEST_LIB64) $(DEST_BIN64)
-	cp $(SRC)/ofc/tools/fcmenu/fcmenu.sh $(DEST_BIN64)/fcmenu
-	cp $(foreach FILE, $(LIB_FILES), $(BUILD64)/lib/$(FILE)) $(DEST_LIB64)
-	cp $(foreach FILE, $(BIN_FILES), $(BUILD64)/$(FILE)) $(DEST_BIN64)
-
-no64:
-	@echo
-	@echo "*** Note: this build will not support 64-bit user-level binaries"
-	@echo "*** This is usually not a problem."
-	@echo
-
-final:
-	mkdir -p $(DEST_CONF)
-	cp conf/openfc.sh $(DEST_CONF)
-	(svnversion $(SRC)/ofc; svnversion $(SRC)/common; \
-		date; uname -a; id; /bin/pwd) > $(DEST)/BUILD
-	cd $(DEST)/.. && tar cfz $(OFC_RPM_NAME).tgz $(OFC_RPM_NAME)
-
-INSTALL = install
-
-ARCH := $(shell uname -i)
-PREFIX := /usr/local
-HBA_ID := org.openfc
-CHKCONFIG := /sbin/chkconfig
-
-#
-# On 64-bit machines, use 64-bit binaries if provided, otherwise 32-bit.
-# Install both versions of the libraries, though, to support 32-bit apps.
-#
-BUILD := $(BUILD32)
-LIBARCH := hba_api_lib
-ifeq "$(ARCH)" "x86_64"
-	LIBARCH += hba_api_lib64
-	BUILD := $(BUILD64)
-endif
-
-
-install: udev_rules $(LIBARCH) commands
-
-commands:
-	$(INSTALL) conf/openfc.sh /etc/init.d/openfc
-	$(CHKCONFIG) --add openfc
+	make -C $(SRC)/common/libtps clean
+	make -C $(SRC)/common/libsa clean
+	make -C $(SRC)/common/libfc clean
+	make -C $(SRC)/ofc clean
+
+install:
+	/usr/bin/install conf/openfc.sh /etc/init.d/openfc
+	/sbin/chkconfig --add openfc
 	mkdir -p /etc/sysconfig/openfc
-	$(INSTALL)  $(foreach FILE, $(BIN_FILES), $(BUILD)/$(FILE)) $(PREFIX)/bin
-	$(INSTALL) $(SRC)/ofc/tools/fcmenu/fcmenu.sh $(PREFIX)/bin/fcmenu
-
-hba_api_lib: hba_conf
-	mkdir -p -m 755 $(PREFIX)/lib
-	$(INSTALL) -m 755 -o root -g root $(BUILD32)/lib/libhbaofc.so $(PREFIX)/lib
-
-hba_api_lib64: hba_conf hba_api_lib
-	mkdir -p -m 755 $(PREFIX)/lib
-	$(INSTALL) -m 755 -o root -g root $(BUILD64)/lib/libhbaofc.so $(PREFIX)/lib64
-
-hba_conf:
-	@( \
-		if [ -f /etc/hba.conf ]; then \
-			grep -v 'libhbaofc\.so' /etc/hba.conf; \
-		fi; \
-		if [ -d $(BUILD64)/lib ]; then \
-			echo $(HBA_ID)64 $(PREFIX)/lib64/libhbaofc.so; \
-		fi; \
-		echo $(HBA_ID) $(PREFIX)/lib/libhbaofc.so; \
+	/usr/bin/install $(SRC)/ofc/tools/fcconf/src/fcconf /usr/local/bin
+	/usr/bin/install $(SRC)/ofc/tools/fcping/src/fcping /usr/local/bin
+	/usr/bin/install $(SRC)/ofc/tools/fcmenu/fcmenu.sh /usr/local/bin/fcmenu
+	@( [ -f /etc/hba.conf ] && grep -v 'libhbaofc\.so' /etc/hba.conf; \
+		echo $(HBA_ID) $(LIB_PATH)/libhbaofc.so; \
 	) > hba.conf && \
 	install -m 644 -o root -g root hba.conf /etc
 	rm -f hba.conf
-
-
-udev_rules:
+	mkdir -p -m 755 $(LIB_PATH)
+	/usr/bin/install -m 755 -o root -g root $(SRC)/ofc/lib/libhbaofc/src/libhbaofc.so $(LIB_PATH)
 	cp conf/openfc.rules 91-openfc.rules
-	$(INSTALL) -m 644 -o root -g root 91-openfc.rules /etc/udev/rules.d
-	rm 91-openfc.rules
+	/usr/bin/install -m 644 -o root -g root 91-openfc.rules /etc/udev/rules.d
+	rm -f 91-openfc.rules
 	cp conf/fcoe.rules 91-fcoe.rules
-	$(INSTALL) -m 644 -o root -g root 91-fcoe.rules /etc/udev/rules.d
-	rm 91-fcoe.rules
-
+	/usr/bin/install -m 644 -o root -g root 91-fcoe.rules /etc/udev/rules.d
+	rm -f 91-fcoe.rules
 
 .PHONY: all
-.PHONY: release
-.PHONY: release32
-.PHONY: release64
-.PHONY: no64
-.PHONY: final
-.PHONY: commands
-.PHONY: hba_api_lib
-.PHONY: hba_api_lib64
+.PHONY: clean
 .PHONY: install
-.PHONY: udev_rules
diff --git a/usr/common/libfc/Makefile b/usr/common/libfc/Makefile
index b0c5fa7..4b5faf5 100644
--- a/usr/common/libfc/Makefile
+++ b/usr/common/libfc/Makefile
@@ -2,6 +2,8 @@
 
 SRC = ../..
 SUBDIRS = src
-DOCSRC = include src/encaps src/fc src/fcp src/fsw
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	make -C src clean
diff --git a/usr/common/libfc/src/Makefile b/usr/common/libfc/src/Makefile
index 0552e74..b3357ea 100644
--- a/usr/common/libfc/src/Makefile
+++ b/usr/common/libfc/src/Makefile
@@ -2,8 +2,6 @@
 
 SRC = ../../..
 LIB = libfc.a
-LBUILD_OSES = linux
-LBUILD_ARCHES = i386 x86_64
 
 #
 # Link the shared library with these static ones to resolve references
@@ -22,3 +20,7 @@ vpath %.c $(DIRS)
 include $(foreach X, $(DIRS), $(X)/Makefile.libfc)
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	rm -f *.o *.d $(LIB)
+
diff --git a/usr/common/libsa/Makefile b/usr/common/libsa/Makefile
index 82fdff2..4b5faf5 100644
--- a/usr/common/libsa/Makefile
+++ b/usr/common/libsa/Makefile
@@ -2,6 +2,8 @@
 
 SRC = ../..
 SUBDIRS = src
-DOCSRC = include src
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	make -C src clean
diff --git a/usr/common/libsa/src/Makefile b/usr/common/libsa/src/Makefile
index 070f294..2160747 100644
--- a/usr/common/libsa/src/Makefile
+++ b/usr/common/libsa/src/Makefile
@@ -3,14 +3,13 @@
 SRC = ../../..
 
 LIB = libsa.a libsa.so
-LBUILD_OSES = linux
 
 CFLAGS += -I../include -I../../libtps/include
 
 #
 # -fpic is needed if building 64-bit objects that will be used by a shared lib.
 #
-ifeq "$(BUILD_ARCH)" "x86_64"
+ifeq "$(shell uname -i)" "x86_64"
 CFLAGS += -fPIC
 endif
 
@@ -44,3 +43,5 @@ SOURCES += \
 
 include $(SRC)/make/Makefile.inc
 
+clean:
+	rm -f *.o *.d $(LIB)
diff --git a/usr/common/libtps/Makefile b/usr/common/libtps/Makefile
index 32c5982..4b5faf5 100644
--- a/usr/common/libtps/Makefile
+++ b/usr/common/libtps/Makefile
@@ -5,3 +5,5 @@ SUBDIRS = src
 
 include $(SRC)/make/Makefile.inc
 
+clean:
+	make -C src clean
diff --git a/usr/common/libtps/src/Makefile b/usr/common/libtps/src/Makefile
index 6ca9804..3276538 100644
--- a/usr/common/libtps/src/Makefile
+++ b/usr/common/libtps/src/Makefile
@@ -1,7 +1,7 @@
 # $Id: Makefile
 
 SRC = ../../..
-LBUILD_OSES = linux
+
 CFLAGS += -I../include
 
 LIB = libtps.a
@@ -14,3 +14,6 @@ SOURCES += \
 
 include $(SRC)/make/Makefile.inc
 
+clean:
+	rm -f *.o *.d $(LIB)
+
diff --git a/usr/make/Doxyfile b/usr/make/Doxyfile
deleted file mode 100644
index 63915fe..0000000
--- a/usr/make/Doxyfile
+++ /dev/null
@@ -1,269 +0,0 @@
-# Doxyfile 1.4.4
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME           = sa
-PROJECT_NUMBER         = 1.0
-OUTPUT_DIRECTORY       = ../build/doc
-CREATE_SUBDIRS         = NO
-OUTPUT_LANGUAGE        = English
-BRIEF_MEMBER_DESC      = YES
-REPEAT_BRIEF           = YES
-ABBREVIATE_BRIEF       = "The $name class" \
-                         "The $name widget" \
-                         "The $name file" \
-                         is \
-                         provides \
-                         specifies \
-                         contains \
-                         represents \
-                         a \
-                         an \
-                         the
-ALWAYS_DETAILED_SEC    = NO
-INLINE_INHERITED_MEMB  = NO
-FULL_PATH_NAMES        = YES
-STRIP_FROM_PATH        = 
-STRIP_FROM_INC_PATH    = 
-SHORT_NAMES            = NO
-JAVADOC_AUTOBRIEF      = NO
-MULTILINE_CPP_IS_BRIEF = NO
-DETAILS_AT_TOP         = NO
-INHERIT_DOCS           = YES
-DISTRIBUTE_GROUP_DOC   = NO
-SEPARATE_MEMBER_PAGES  = NO
-TAB_SIZE               = 8
-ALIASES                = 
-OPTIMIZE_OUTPUT_FOR_C  = YES
-OPTIMIZE_OUTPUT_JAVA   = NO
-SUBGROUPING            = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL            = YES
-EXTRACT_PRIVATE        = NO
-EXTRACT_STATIC         = YES
-EXTRACT_LOCAL_CLASSES  = YES
-EXTRACT_LOCAL_METHODS  = YES
-HIDE_UNDOC_MEMBERS     = YES
-HIDE_UNDOC_CLASSES     = YES
-HIDE_FRIEND_COMPOUNDS  = YES
-HIDE_IN_BODY_DOCS      = YES
-INTERNAL_DOCS          = YES
-CASE_SENSE_NAMES       = YES
-HIDE_SCOPE_NAMES       = NO
-SHOW_INCLUDE_FILES     = NO
-INLINE_INFO            = YES
-SORT_MEMBER_DOCS       = YES
-SORT_BRIEF_DOCS        = NO
-SORT_BY_SCOPE_NAME     = NO
-GENERATE_TODOLIST      = YES
-GENERATE_TESTLIST      = YES
-GENERATE_BUGLIST       = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS       = 
-MAX_INITIALIZER_LINES  = 30
-SHOW_USED_FILES        = YES
-SHOW_DIRECTORIES       = YES
-FILE_VERSION_FILTER    = 
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET                  = YES
-WARNINGS               = YES
-WARN_IF_UNDOCUMENTED   = YES
-WARN_IF_DOC_ERROR      = YES
-WARN_NO_PARAMDOC       = YES
-WARN_FORMAT            = "$file:$line: $text"
-WARN_LOGFILE           = 
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT                  = .
-FILE_PATTERNS          = *.c \
-                         *.cc \
-                         *.cxx \
-                         *.cpp \
-                         *.c++ \
-                         *.d \
-                         *.java \
-                         *.ii \
-                         *.ixx \
-                         *.ipp \
-                         *.i++ \
-                         *.inl \
-                         *.h \
-                         *.hh \
-                         *.hxx \
-                         *.hpp \
-                         *.h++ \
-                         *.idl \
-                         *.odl \
-                         *.cs \
-                         *.php \
-                         *.php3 \
-                         *.inc \
-                         *.m \
-                         *.mm \
-                         *.dox \
-                         *.C \
-                         *.CC \
-                         *.C++ \
-                         *.II \
-                         *.I++ \
-                         *.H \
-                         *.HH \
-                         *.H++ \
-                         *.CS \
-                         *.PHP \
-                         *.PHP3 \
-                         *.M \
-                         *.MM
-RECURSIVE              = YES
-EXCLUDE                = 
-EXCLUDE_SYMLINKS       = NO
-EXCLUDE_PATTERNS       = 
-EXAMPLE_PATH           = 
-EXAMPLE_PATTERNS       = *
-EXAMPLE_RECURSIVE      = NO
-IMAGE_PATH             = 
-INPUT_FILTER           = 
-FILTER_PATTERNS        = 
-FILTER_SOURCE_FILES    = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER         = YES
-INLINE_SOURCES         = YES
-STRIP_CODE_COMMENTS    = YES
-REFERENCED_BY_RELATION = YES
-REFERENCES_RELATION    = YES
-USE_HTAGS              = NO
-VERBATIM_HEADERS       = NO
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX     = YES
-COLS_IN_ALPHA_INDEX    = 5
-IGNORE_PREFIX          = 
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML          = YES
-HTML_OUTPUT            = html
-HTML_FILE_EXTENSION    = .html
-HTML_HEADER            = 
-HTML_FOOTER            = 
-HTML_STYLESHEET        = 
-HTML_ALIGN_MEMBERS     = YES
-GENERATE_HTMLHELP      = NO
-CHM_FILE               = 
-HHC_LOCATION           = 
-GENERATE_CHI           = NO
-BINARY_TOC             = NO
-TOC_EXPAND             = NO
-DISABLE_INDEX          = NO
-ENUM_VALUES_PER_LINE   = 4
-GENERATE_TREEVIEW      = YES
-TREEVIEW_WIDTH         = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX         = NO
-LATEX_OUTPUT           = latex
-LATEX_CMD_NAME         = latex
-MAKEINDEX_CMD_NAME     = makeindex
-COMPACT_LATEX          = NO
-PAPER_TYPE             = a4wide
-EXTRA_PACKAGES         = 
-LATEX_HEADER           = 
-PDF_HYPERLINKS         = NO
-USE_PDFLATEX           = NO
-LATEX_BATCHMODE        = NO
-LATEX_HIDE_INDICES     = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF           = NO
-RTF_OUTPUT             = rtf
-COMPACT_RTF            = NO
-RTF_HYPERLINKS         = NO
-RTF_STYLESHEET_FILE    = 
-RTF_EXTENSIONS_FILE    = 
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN           = NO
-MAN_OUTPUT             = man
-MAN_EXTENSION          = .3
-MAN_LINKS              = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML           = NO
-XML_OUTPUT             = xml
-XML_SCHEMA             = 
-XML_DTD                = 
-XML_PROGRAMLISTING     = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF   = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD       = NO
-PERLMOD_LATEX          = NO
-PERLMOD_PRETTY         = YES
-PERLMOD_MAKEVAR_PREFIX = 
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING   = YES
-MACRO_EXPANSION        = NO
-EXPAND_ONLY_PREDEF     = NO
-SEARCH_INCLUDES        = YES
-INCLUDE_PATH           = 
-INCLUDE_FILE_PATTERNS  = 
-PREDEFINED             = 
-EXPAND_AS_DEFINED      = 
-SKIP_FUNCTION_MACROS   = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references   
-#---------------------------------------------------------------------------
-TAGFILES               = 
-GENERATE_TAGFILE       = 
-ALLEXTERNALS           = NO
-EXTERNAL_GROUPS        = YES
-PERL_PATH              = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS         = YES
-HIDE_UNDOC_RELATIONS   = YES
-HAVE_DOT               = NO
-CLASS_GRAPH            = YES
-COLLABORATION_GRAPH    = YES
-GROUP_GRAPHS           = YES
-UML_LOOK               = NO
-TEMPLATE_RELATIONS     = NO
-INCLUDE_GRAPH          = YES
-INCLUDED_BY_GRAPH      = YES
-CALL_GRAPH             = NO
-GRAPHICAL_HIERARCHY    = YES
-DIRECTORY_GRAPH        = YES
-DOT_IMAGE_FORMAT       = png
-DOT_PATH               = 
-DOTFILE_DIRS           = 
-MAX_DOT_GRAPH_WIDTH    = 1024
-MAX_DOT_GRAPH_HEIGHT   = 1024
-MAX_DOT_GRAPH_DEPTH    = 1000
-DOT_TRANSPARENT        = NO
-DOT_MULTI_TARGETS      = NO
-GENERATE_LEGEND        = YES
-DOT_CLEANUP            = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine   
-#---------------------------------------------------------------------------
-SEARCHENGINE           = NO
diff --git a/usr/make/Makefile-ARCH-i386.inc b/usr/make/Makefile-ARCH-i386.inc
deleted file mode 100644
index 2edf94b..0000000
--- a/usr/make/Makefile-ARCH-i386.inc
+++ /dev/null
@@ -1,12 +0,0 @@
-# $Id: Makefile-ARCH-i386.inc
-
-ifeq "$(shell uname -m)" "x86_64" 
-CFLAGS += -m32
-endif
-
-#
-# Don't let make look in /usr/lib64 for libraries.
-# 
-.LIBPATTERNS = /usr/lib/lib%.so /usr/lib/lib%.a \
-		/usr/local/lib/lib%.a \
-		/usr/local/lib/lib%.so
diff --git a/usr/make/Makefile-ARCH-x86_64.inc b/usr/make/Makefile-ARCH-x86_64.inc
deleted file mode 100644
index 86adef0..0000000
--- a/usr/make/Makefile-ARCH-x86_64.inc
+++ /dev/null
@@ -1,8 +0,0 @@
-# $Id: Makefile-ARCH-x86_64.inc
-
-CFLAGS += -m64
-
-#
-# Have make look in /usr/lib64 for libraries.
-# 
-.LIBPATTERNS = /usr/lib64/lib%.so /usr/lib64/lib%.a
diff --git a/usr/make/Makefile-OPT-debug.inc b/usr/make/Makefile-OPT-debug.inc
deleted file mode 100644
index 1d3685a..0000000
--- a/usr/make/Makefile-OPT-debug.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-# $Id: Makefile-OPT-debug.inc
-
-CFLAGS += -DDEBUG_ASSERTS -O0 -g -Wall
-CFLAGS += -DFC_FRAME_DEBUG
-CFLAGS += -DSA_ERROR_INJECT_ENABLE
diff --git a/usr/make/Makefile-OPT-prod.inc b/usr/make/Makefile-OPT-prod.inc
deleted file mode 100644
index 0e6162e..0000000
--- a/usr/make/Makefile-OPT-prod.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# $Id: Makefile-OPT-prod.inc
-
-CFLAGS += -O3 -Wall
diff --git a/usr/make/Makefile-OS-linux.inc b/usr/make/Makefile-OS-linux.inc
deleted file mode 100644
index 36d1345..0000000
--- a/usr/make/Makefile-OS-linux.inc
+++ /dev/null
@@ -1,8 +0,0 @@
-# $Id: Makefile-OS-linux.inc
-
-ifeq "$(strip $(CFLAGS_NO_WERROR))" ""
-CFLAGS += -Wall -Werror
-endif
-ifeq "$(strip $(CFLAGS_NO_INCLUDE))" ""
-CFLAGS += -I $(SRC)/common/include 
-endif
diff --git a/usr/make/Makefile-tags.inc b/usr/make/Makefile-tags.inc
deleted file mode 100644
index b037239..0000000
--- a/usr/make/Makefile-tags.inc
+++ /dev/null
@@ -1,17 +0,0 @@
-# $Id: Makefile-tags.inc
-
-CLEANFILES += tags TAGS cscope.out tags.list
-
-TAGS_DIRS = .
-tags.list:
-	find $(TAGS_DIRS) -type f -name '*.[chsS]' \
-		-print > tags.list || rm -f tags.list
-
-tags: tags.list
-	rm -f tags && xargs /usr/bin/ctags --tag-relative=yes -a < tags.list
-
-TAGS: tags.list
-	rm -f TAGS && xargs /usr/bin/etags -a < tags.list
-
-cscope.out: tags.list
-	cscope -b `cat tags.list`
diff --git a/usr/make/Makefile.inc b/usr/make/Makefile.inc
index bd79ef1..b652974 100644
--- a/usr/make/Makefile.inc
+++ b/usr/make/Makefile.inc
@@ -16,47 +16,13 @@ ECHO = @echo
 #
 # List of targets to be done for releases and subdirectories.
 #
-TARGETS := all doc install clean test $(LTARGETS)
-RELEASE_TARGETS := $(TARGETS) doc_index
-SUBDIR_TARGETS := $(TARGETS)
+TARGETS := all install
 
 #
 # List of legal build component names
 #
-LEGAL_OS = linux
-LEGAL_ARCH = i386 x86_64
-LEGAL_OPT = debug prod 
-
-#
-# List of the releases we normally build by default.
-# This may be overridden in the environment.
-# 
-RELEASES = \
-	i386-linux-debug \
-	x86_64-linux-debug \
-	i386-linux-prod \
-	x86_64-linux-prod \
-	$(NULL)
-
-#
-# Local selection of options wished to be used in this section of the tree
-# These are lists that can be overridden by the including Makefile.
-# 
-ifeq "$(shell uname -i)" "i386"
-	LBUILD_ARCHES = i386		# assume only i386 is possible
-endif
-LBUILD_ARCHES ?= $(LEGAL_ARCH)
-LBUILD_OSES ?= $(LEGAL_OS)
-LBUILD_OPTS ?= $(LEGAL_OPT)
-
-#
-# Make list of all matching releases
-# This may be overridden in the environment.
-#
-LRELEASES = $(foreach B__ARCH, $(LBUILD_ARCHES), \
-		$(foreach B__OS, $(LBUILD_OSES), \
-			$(foreach B__OPT, $(LBUILD_OPTS), \
-				$(B__ARCH)-$(B__OS)-$(B__OPT))))
+LEGAL_ARCH = i386 i486 i586 i686 x86_64
+LEGAL_OS = linux Linux
 
 # Default target, *before* including sub-makefile settings
 # which might have rules of their own that would otherwise
@@ -65,134 +31,61 @@ LRELEASES = $(foreach B__ARCH, $(LBUILD_ARCHES), \
 default: all
 .PHONY:	default
 
-%/.mkdir:
-	$(ECHO) '	MKDIR $(@D)'; \
-	mkdir -p $(@D) && touch $@
-
-#
-# If BUILD_OS, BUILD_ARCH, and BUILD_OPT are not set,
-# the default is to go through the matching targets in RELEASES.
-#
-# RELEASES is broken down into BUILD_ARCH, BUILD_OS, and BUILD_OPT
-#
-# If LBUILD_ARCHES, LBUILD_OSES, and/or LBUILD_OPTS are set to a list of
-# possibly wild-carded strings, the corresponding BUILD_* must match one of
-# those strings, or we don't build anything.
-#
-ifeq "$(strip $(BUILD_OS)$(BUILD_ARCH)$(BUILD_OPT))" ""
-
-#
-# Make list of all desired releases.
-#
-RELS = $(filter $(LRELEASES), $(RELEASES))
+ifeq "$(strip $(BUILDIT))" ""
 
 #
-# Rule that targets XXX depend on rel-ARCH-OS-OPTS-XXX
+# Rule that targets XXX depend on dummy
 # 
-$(RELEASE_TARGETS): % : $(foreach REL, $(RELS), rel-$(REL)-%)
+$(TARGETS): dummy
 
 #
-# Main rule that goes through all specified releases.
-# Rule for targets of the form rel-ARCH-OS-OPTS-%
+# Rule for the dummy target
 # 
-$(foreach REL, $(RELS), $(RELEASE_TARGETS:%=rel-$(REL)-%)):
-	$(ECHO) "======================================================="; \
-	echo "	MAKE" BUILD_ARCH=$(word 2, $(subst -, , $@)) \
-		BUILD_OS=$(word 3, $(subst -, , $@)) \
-		BUILD_OPT=$(word 4, $(subst -, , $@)) \
-		$(word 5, $(subst -, , $@)); \
-	echo "======================================================="; \
-	$(MAKE) BUILD_ARCH=$(word 2, $(subst -, , $@)) \
-		BUILD_OS=$(word 3, $(subst -, , $@)) \
-		BUILD_OPT=$(word 4, $(subst -, , $@)) \
-		$(word 5, $(subst -, , $@))
-
-else	# BUILD_ARCH, BUILD_OS, and BUILD_OPT must be set 
-
-REL := $(BUILD_ARCH)-$(BUILD_OS)-$(BUILD_OPT)
-
-ifeq "$(filter $(LRELEASES), $(REL))" ""
-
-$(RELEASE_TARGETS):
-ifeq "$(BUILD_OS)" ""
-	$(error BUILD_OS not specified)
-endif
-ifeq "$(BUILD_ARCH)" ""
-	$(error BUILD_ARCH not specified)
-endif
-ifeq "$(BUILD_OPT)" ""
-	$(error BUILD_OPT not specified)
-endif
-	$(ECHO) "	no releases selected.  Check LBUILD_* variables"
+dummy:
+	make BUILDIT=yes all
 
-else	# end of releases loop code
-
-#
-# ---------------------------------------------------------------------------
-# This is where the old Makefile.inc starts.
-# 
+else
 
 # Find the current directory relative to SRC.
 # use /bin/pwd so the shell doesn't keep any symbolic links in the path
 
-CWD := $(shell /bin/pwd)
-SRCPATH := $(shell (cd $(SRC); /bin/pwd))
+#CWD := $(shell /bin/pwd)
+#SRCPATH := $(shell (cd $(SRC); /bin/pwd))
 
-ifneq "$(strip $(SRC))" "."
-        DIR := $(subst $(SRCPATH)/,,$(CWD))
-else
-        DIR := 
-endif
+# Default build directories
+BUILD_DIR := .
+
+BUILD_ARCH=$(shell uname -i)
+BUILD_OS=$(shell uname -s)
 
-#
-# Check that the supplied BUILD_* values are legal.
-#
-ifneq "$(filter-out $(LEGAL_OS), $(BUILD_OS))" ""
-        $(error bad BUILD_OS $(BUILD_OS).
-endif
 ifneq "$(filter-out $(LEGAL_ARCH), $(BUILD_ARCH))" ""
-        $(error bad BUILD_ARCH $(BUILD_ARCH))
+    $(error bad build architecture $(BUILD_ARCH))
 endif
-ifneq "$(filter-out $(LEGAL_OPT), $(BUILD_OPT))" ""
-        $(error bad BUILD_OPT $(BUILD_OPT))
-endif
-
-# set the build directory.
-
-BUILD := $(SRC)/../build-$(BUILD_ARCH)-$(BUILD_OS)-$(BUILD_OPT)
-
-# default build directories
-
-ifeq "$(strip $(INSTALL))" ""
-INSTALL := $(BUILD)/../install
+ifneq "$(filter-out $(LEGAL_OS), $(BUILD_OS))" ""
+    $(error bad build OS $(BUILD_OS))
 endif
 
-ifeq "$(strip $(BUILD_LIB))" ""
-BUILD_LIB := $(BUILD)/lib
+ifeq "$(BUILD_ARCH)" "x86_64"
+    CFLAGS += -m64
+    .LIBPATTERNS = /usr/lib64/lib%.so /usr/lib64/lib%.a
+else
+    .LIBPATTERNS = /usr/lib/lib%.so \
+                   /usr/lib/lib%.a \
+                   /usr/local/lib/lib%.a \
+                   /usr/local/lib/lib%.so
 endif
-INSTALL_LIB := $(LIB:%=$(BUILD)/lib/%)
-
-ifeq "$(strip $(INSTALL_BIN))" ""
-INSTALL_BIN := $(INSTALL)/bin
+ifeq "$(strip $(CFLAGS_NO_WERROR))" ""
+CFLAGS += -Wall -Werror
 endif
-
-ifeq "$(strip $(BUILD_DIR))" ""
-BUILD_DIR := $(BUILD)/$(DIR)
-BUILD_PICS := $(BUILD_DIR)/pics
+ifeq "$(strip $(CFLAGS_NO_INCLUDE))" ""
+CFLAGS += -I $(SRC)/common/include 
 endif
+# Debugging flags
+CFLAGS += -DDEBUG_ASSERTS -O0 -g -Wall
+CFLAGS += -DFC_FRAME_DEBUG
+CFLAGS += -DSA_ERROR_INJECT_ENABLE
 
-# Automatic CFLAGS
-# These can be overridden by the option-specific Makefiles included below
-#
-BUILD_AUTO_CFLAGS := -DBUILD_ARCH_$(BUILD_ARCH) \
-		-DBUILD_OS_$(BUILD_OS) \
-		-DBUILD_OPT_$(BUILD_OPT)
-
-include $(SRC)/make/Makefile-ARCH-$(strip $(BUILD_ARCH)).inc
-include $(SRC)/make/Makefile-OS-$(strip $(BUILD_OS)).inc
-include $(SRC)/make/Makefile-OPT-$(strip $(BUILD_OPT)).inc
-
-CFLAGS += $(BUILD_AUTO_CFLAGS)
+#CFLAGS += $(BUILD_AUTO_CFLAGS)
 CFLAGS += $(LCFLAGS)
 
 # make lists of objects
@@ -201,30 +94,10 @@ CFLAGS += $(LCFLAGS)
 OBJECTS := $(basename $(SOURCES) $(LOBJECTS))
 OBJECTS := $(OBJECTS:%=$(BUILD_DIR)/%.o)
 
-LDFLAGS += -L$(BUILD_LIB)
-LIBRARIES := $(LIBRARIES:%.a=$(BUILD_LIB)/%.a)
 LIB := $(LIB:%=$(BUILD_DIR)/%)
 PROGRAM := $(PROGRAM:%=$(BUILD_DIR)/%)
 
-all:	$(PROGRAM) $(LIB) $(LPOSTALL)
-
-test:
-	@echo cwd $(CWD)
-	@echo BUILD_ARCH $(BUILD_ARCH) BUILD_OS $(BUILD_OS)
-	@echo BUILD_OPT $(BUILD_OPT)
-	@echo LBUILD_ARCH $(LBUILD_ARCH) LBUILD_OS $(LBUILD_OS)
-	@echo LBUILD_OPT $(LBUILD_OPT)
-	@echo CFLAGS $(CFLAGS)
-	@echo subdirs $(SUBDIRS)
-	@echo lib $(LIB)
-	@echo srcpath $(SRCPATH)
-	@echo dir $(DIR)
-	@echo build_dir $(BUILD_DIR)
-	@echo build_lib $(BUILD_LIB)
-	@echo sources $(SOURCES)
-	@echo objects $(OBJECTS)
-
-$(BUILD_DIR):  $(BUILD_DIR)/.mkdir
+all: $(PROGRAM) $(LIB)
 
 # ---------------------------------------------------------------------------
 #
@@ -237,12 +110,12 @@ SUBDIR_PATTERN := $(foreach subdir, $(SUBDIRS), $(subdir)/%)
 #
 # all depends on dir/all, etc.
 #
-$(SUBDIR_TARGETS) : % : $(SUBDIR_PATTERN)
+$(TARGETS) : % : $(SUBDIR_PATTERN)
 
 #
 # Implicit rule for subdir target %/all, %/clean, etc.
 #
-$(foreach target, $(SUBDIR_TARGETS), %/$(target)):
+$(foreach target, $(TARGETS), %/$(target)):
 	@$(MAKE) -C $(@D) SRC=../$(SRC) $(@F)
 
 endif	# end of subdir rules 
@@ -257,25 +130,19 @@ LIB_A := $(filter %.a, $(LIB))
 LIB_SO := $(filter %.so, $(LIB))
 
 PICS := $(basename $(SOURCES))
-PICS := $(PICS:%=$(BUILD_DIR)/pics/%.o)
-
-$(PICS): $(BUILD_DIR)/pics/.mkdir
+PICS := $(PICS:%=$(BUILD_DIR)/%.o)
 
 $(LIB_A): $(OBJECTS)
 	$(ECHO) '	Archiving' $@; \
 	( \
 		set -e; \
-		mkdir -p $(@D) && \
-		cd $(@D) && \
 		rm -f $(@F) && \
 		$(AR) cr $(@F) $(OBJECTS); \
-	) && \
-	mkdir -p $(BUILD_LIB) && cp $(@) $(BUILD_LIB)
+	)
 
 $(LIB_SO): $(PICS)
 	$(ECHO) '	LINK' $@; \
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(LIBRARIES) && \
-	mkdir -p $(BUILD_LIB) && cp $(@) $(BUILD_LIB)
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(LIBRARIES)
 endif
 
 # ---------------------------------------------------------------------------
@@ -283,7 +150,7 @@ endif
 # Rule for programs
 #
 ifneq "$(strip $(PROGRAM))" ""
-$(PROGRAM): $(OBJECTS) $(LIBRARIES) $(BUILD_DIR)/.mkdir
+$(PROGRAM): $(OBJECTS) $(LIBRARIES)
 	$(ECHO) '	LINK' $@; \
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
 		$(OBJECTS) $(LIBRARIES) $(SYSTEM_LIBRARIES)
@@ -323,31 +190,29 @@ $(BUILD_DIR)/%.o: %.s
 		rm -f $(BUILD_DIR)/$*.d ); \
 	$(CC) -c $(CFLAGS) -o $@ $< 
 
-$(OBJECTS): $(BUILD_DIR)/.mkdir
-
 # ---------------------------------------------------------------------------
 #
 # Make C objects for shared libraries.
 #
-$(BUILD_DIR)/pics/%.o: %.c
+$(BUILD_DIR)/%.o: %.c
 	$(ECHO) '	CC PIC' $<; \
 	$(CC) -MM $(CFLAGS) -fpic $< | ( \
-		sed 's,$*\.o[ :]*,$@: ,g' > $(BUILD_DIR)/pics/$*.d || \
-		rm -f $(BUILD_DIR)/pics/$*.d ); \
+		sed 's,$*\.o[ :]*,$@: ,g' > $(BUILD_DIR)/$*.d || \
+		rm -f $(BUILD_DIR)/$*.d ); \
 	$(CC) -c $(CFLAGS) -fpic -o $@ $< 
 
-$(BUILD_DIR)/pics/%.o: %.S
+$(BUILD_DIR)/%.o: %.S
 	$(ECHO) '	CC PIC' $<; \
 	$(CC) -MM $(CFLAGS) -fpic $< | ( \
-		sed 's,$*\.o[ :]*,$@: ,g' > $(BUILD_DIR)/pics/$*.d || \
-		rm -f $(BUILD_DIR)/pics/$*.d ); \
+		sed 's,$*\.o[ :]*,$@: ,g' > $(BUILD_DIR)/$*.d || \
+		rm -f $(BUILD_DIR)/$*.d ); \
 	$(CC) -c $(CFLAGS) -fpic -o $@ $< 
 
-$(BUILD_DIR)/pics/%.o: %.s
+$(BUILD_DIR)/%.o: %.s
 	$(ECHO) '	CC PIC' $<; \
 	$(CC) -MM $(CFLAGS) -fpic $< | ( \
-		sed 's,$*\.o[ :]*,$@: ,g' > $(BUILD_DIR)/pics/$*.d || \
-		rm -f $(BUILD_DIR)/pics/$*.d ); \
+		sed 's,$*\.o[ :]*,$@: ,g' > $(BUILD_DIR)/$*.d || \
+		rm -f $(BUILD_DIR)/$*.d ); \
 	$(CC) -c $(CFLAGS) -fpic -o $@ $< 
 
 # ---------------------------------------------------------------------------
@@ -362,61 +227,6 @@ ifneq "$(strip $(PICS))" ""
 endif
 
 # ---------------------------------------------------------------------------
-#
-# Rules for documentation
-#
-DOXYGEN = doxygen
-DOCDEST = $(DIR)
-BUILD_DOC = $(BUILD)/doc/$(DOCDEST)
-DOC_ROOT = $(BUILD)/doc/html
-
-.PHONY: FORCE
 
-ifneq "$(strip $(DOCSRC))" ""
-doc $(BUILD_DOC)/html/index.html: $(BUILD_DOC)/.mkdir FORCE
-	$(ECHO) '	DOXYGEN' $(DOCSRC); \
-	( \
-		cat $(SRC)/make/Doxyfile; \
-		echo INPUT="$(DOCSRC)"; \
-		echo OUTPUT_DIRECTORY = "$(BUILD_DOC)"; \
-		echo STRIP_FROM_PATH = $(shell cd $(SRC); /bin/pwd); \
-	) | $(DOXYGEN) -
-else
-doc:
 endif
 
-#
-# Rule to make top-level documentation index for this subtree.
-#
-doc_index:  $(DOC_ROOT)/index.html
-
-$(DOC_ROOT)/index.html: $(DOC_ROOT)/.mkdir FORCE
-	$(ECHO) '	DOC_INDEX' $(DOC_ROOT);				\
-	(								\
-		cat $(SRC)/make/doc_head_template.html &&		\
-		(							\
-			cd $(DOC_ROOT) &&				\
-			find .. -type f -name index.html -print |	\
-			sed -e 's,^\.\./\(.*\),<li><a href=&>\1</a></li>,' \
-				-e 's,/html/index.html<,<,'		\
-				-e '/>html\/index.html</d'		\
-		) | sort;						\
-		cat $(SRC)/make/doc_tail_template.html			\
-	) > $(DOC_ROOT)/index.html
-
-# ---------------------------------------------------------------------------
-# remove the built objects
-
-clean:
-	rm -f $(PROGRAM) $(OBJECTS) $(LIB) $(OBJECTS:%.o=%.d) \
-		$(PICS) $(PICS:%.o=%.d) \
-		$(INSTALL_LIB) \
-		$(CLEANFILES) $(LCLEAN:%=$(BUILD_DIR)/%)
-	rm -rf $(BUILD_DOC) $(DEST)
-
-.PHONY: clean
-
-endif	# end of else old Makefile.inc
-endif	# end of else for BUILD_* specified
-
-include $(SRC)/make/Makefile-tags.inc
diff --git a/usr/make/README b/usr/make/README
index 97499e3..a153710 100644
--- a/usr/make/README
+++ b/usr/make/README
@@ -4,17 +4,6 @@
 
 To build this software, from the source directory, just type make.
 
-The following variables are understood by the make to specify build variants:
-
-	BUILD_ARCH	the processor architecture of the target, e.g.,
-			i386, x86_64, mips, etc.
-	BUILD_OS	the OS target, e.g., linux, menlofw, etc.
-	BUILD_OPT	the build variant, e.g., debug, prod, etc.
-
-To limit your build to a certain architecture, the above three variables can be set on the make command line or in the environment.
-
-A make may be performed in any directory in the source tree that has a Makefile.
-
 2. Writing Makefiles:
 
 2.1 Programs
@@ -57,13 +46,3 @@ also.  So, a Makefile may have conditional source lists, such as:
 	SOURCES += subr_mips.c
 	endif
 
-2.5 Doxygen
-
-To make documentation using Doxygen, just set DOCSRC to the list of
-subdirectories that should be included in your documentation set.
-
-Then, at the top of the source tree, a 'make doc doc_index' will build all
-documentation sets and a handy index.html page at the top of
-$(BUILD_DIR)/doc/html.
-
-The doxygen support is just a start for testing.
diff --git a/usr/make/doc_head_template.html b/usr/make/doc_head_template.html
deleted file mode 100644
index 6eee74c..0000000
--- a/usr/make/doc_head_template.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<html>
-<! $Id: doc_head_template.html 2933 2007-01-18 23:16:10Z jre $>
-<head>
-   <title>Open-FC Documentation</title>
-</head>
-
-<body>
-<h1> Open-FC Documentation </h1>
-
-<p><b> Available Documentation sets: </b></p>
-
-<ul>
diff --git a/usr/make/doc_tail_template.html b/usr/make/doc_tail_template.html
deleted file mode 100644
index 11703e2..0000000
--- a/usr/make/doc_tail_template.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<! $Id: doc_tail_template.html 2933 2007-01-18 23:16:10Z jre $>
-</ul>
-</list>
-</body>
-</html>
diff --git a/usr/ofc/Makefile b/usr/ofc/Makefile
index 4ee0828..f45c79a 100644
--- a/usr/ofc/Makefile
+++ b/usr/ofc/Makefile
@@ -2,11 +2,13 @@
 
 SRC = ..
 
-LBUILD_OSES = linux
-
 SUBDIRS = \
 	lib \
 	tools \
 	$(NULL)
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	make -C lib clean
+	make -C tools clean
diff --git a/usr/ofc/lib/Makefile b/usr/ofc/lib/Makefile
index 956afc4..a0890e9 100644
--- a/usr/ofc/lib/Makefile
+++ b/usr/ofc/lib/Makefile
@@ -4,3 +4,6 @@ SRC = ../..
 SUBDIRS = libhbaofc
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	make -C libhbaofc clean
diff --git a/usr/ofc/lib/libhbaofc/Makefile b/usr/ofc/lib/libhbaofc/Makefile
index 1b7147a..37c606d 100644
--- a/usr/ofc/lib/libhbaofc/Makefile
+++ b/usr/ofc/lib/libhbaofc/Makefile
@@ -1,7 +1,10 @@
 # $Id: Makefile
 
 SRC = ../../..
-DOCSRC = include src
+
 SUBDIRS = src
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	make -C src clean
diff --git a/usr/ofc/lib/libhbaofc/src/Makefile b/usr/ofc/lib/libhbaofc/src/Makefile
index 78ace4d..6eb5ffa 100644
--- a/usr/ofc/lib/libhbaofc/src/Makefile
+++ b/usr/ofc/lib/libhbaofc/src/Makefile
@@ -3,9 +3,6 @@
 SRC = ../../../..
 LIB = libhbaofc.so
 
-LBUILD_OSES = linux
-LBUILD_ARCHES = x86_64 i386
-
 #
 # Set OFC_TEST = y to build in a fake device for unit testing.
 #
@@ -14,7 +11,10 @@ OFC_TEST = n
 #
 # Link the shared library with these static ones to resolve references
 #
-LIBRARIES = libsa.a -lrt
+LIBRARIES = \
+	../../../../common/libsa/src/libsa.a \
+	-lrt \
+	$(NULL)
 
 CFLAGS += -I$(SRC)/common/include
 CFLAGS += -I$(SRC)/common/libtps/include
@@ -45,3 +45,6 @@ CFLAGS += -DOFC_TEST
 endif
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	rm -f *.o *.d $(LIB)
diff --git a/usr/ofc/tools/Makefile b/usr/ofc/tools/Makefile
index eef6eb7..a3decf7 100644
--- a/usr/ofc/tools/Makefile
+++ b/usr/ofc/tools/Makefile
@@ -2,11 +2,15 @@
 
 SRC = ../..
 
-SUBDIRS = common \
+SUBDIRS = \
+	common \
 	fcconf \
-	fcgw \
 	fcping \
-	fds \
 	$(NULL)
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	make -C common clean
+	make -C fcconf clean
+	make -C fcping clean
diff --git a/usr/ofc/tools/common/Makefile b/usr/ofc/tools/common/Makefile
index 3b7b38b..37c606d 100644
--- a/usr/ofc/tools/common/Makefile
+++ b/usr/ofc/tools/common/Makefile
@@ -5,3 +5,6 @@ SRC = ../../..
 SUBDIRS = src
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	make -C src clean
diff --git a/usr/ofc/tools/common/src/Makefile b/usr/ofc/tools/common/src/Makefile
index 69afb1f..f6f7e04 100644
--- a/usr/ofc/tools/common/src/Makefile
+++ b/usr/ofc/tools/common/src/Makefile
@@ -13,3 +13,6 @@ SOURCES = \
 	$(NULL)
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	rm -f *.o *.d $(LIB)
diff --git a/usr/ofc/tools/fcconf/Makefile b/usr/ofc/tools/fcconf/Makefile
index abd3857..e1a78e1 100644
--- a/usr/ofc/tools/fcconf/Makefile
+++ b/usr/ofc/tools/fcconf/Makefile
@@ -4,3 +4,6 @@ SRC = ../../..
 SUBDIRS = src
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	make -C src clean
diff --git a/usr/ofc/tools/fcconf/src/Makefile b/usr/ofc/tools/fcconf/src/Makefile
index 473e611..2ace7d1 100644
--- a/usr/ofc/tools/fcconf/src/Makefile
+++ b/usr/ofc/tools/fcconf/src/Makefile
@@ -12,9 +12,6 @@ SRC = ../../../..
 #
 FCCONF_TESTS = y
 
-LBUILD_OSES = linux
-LBUILD_ARCHES = x86_64 i386
-
 LCFLAGS += -I$(SRC)/common/libsa/include
 LCFLAGS += -I$(SRC)/common/libfc/include
 LCFLAGS += -I$(SRC)/common/libtps/include
@@ -45,9 +42,9 @@ ifeq "$(FCCONF_TESTS)" "y"
 endif
 
 LIBRARIES = \
-	libfc.a \
-	libsa.a \
-	libtps.a \
+	../../../../common/libfc/src/libfc.a \
+	../../../../common/libsa/src/libsa.a \
+	../../../../common/libtps/src/libtps.a \
 	$(NULL)
 
 SYSTEM_LIBRARIES = \
@@ -65,4 +62,8 @@ $(BUILD_DIR)/version.c: FORCE
 	rm -f $@; \
 	echo char fcc_version[] = '"'$(BUILD_VERSION) $(shell date)'";' > $@
 
+clean:
+	rm -f *.o *.d $(PROGRAM)
+	rm -f version.*
+
 .PHONY: FORCE
diff --git a/usr/ofc/tools/fcgw/Makefile b/usr/ofc/tools/fcgw/Makefile
deleted file mode 100644
index 965d4f8..0000000
--- a/usr/ofc/tools/fcgw/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-SRC = ../../..
-SUBDIRS = src
-
-include $(SRC)/make/Makefile.inc
diff --git a/usr/ofc/tools/fcgw/include/fcgw.h b/usr/ofc/tools/fcgw/include/fcgw.h
deleted file mode 100644
index e1f0f4b..0000000
--- a/usr/ofc/tools/fcgw/include/fcgw.h
+++ /dev/null
@@ -1,75 +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 _FCWB_FCGW_H_
-#define _FCWB_FCGW_H_
-
-#include <queue.h>
-
-/*
- * Statistics.
- */
-struct fcgw_stats {
-    u_int64_t       s_rx_frames;
-    u_int64_t       s_rx_bytes;
-    u_int64_t       s_tx_frames;
-    u_int64_t       s_tx_bytes;
-};
-
-enum fcgw_port_type {
-    FCGW_PORT_CLIENT,               /* client port (downstream) */
-    FCGW_PORT_LISTEN,               /* listening TCP port */
-    FCGW_PORT_FAB,                  /* fabric port (upstream) */
-};
-
-/*
- * Per-port data.
- */
-struct fcgw_port {
-    TAILQ_ENTRY(fcgw_port)  gp_list;
-    enum fcgw_port_type     gp_type;
-    const char              *gp_name;
-    u_char                  gp_logged_in;
-    struct fc_port          *gp_port;
-    struct fcgw_port        *gp_other;
-    struct fc_remote_port   *gp_rport;
-    struct fcgw_stats       gp_stats;
-};
-
-extern int fcgw_debug;
-extern int fcgw_npiv;
-extern char fcgw_xmit_test;             /* transmit test */
-extern struct fc_virt_fab *fcgw_vf;
-extern struct fcgw_port *fcgw_fab_port;
-
-struct fc_port *fcgw_rawfc_open(char *name);
-
-struct fcgw_port *fcgw_port_create(struct fc_port *, const char *);
-void fcgw_port_delete(struct fcgw_port *);
-void fcgw_port_iterate(void (*)(struct fcgw_port *, void *), void *);
-struct fcgw_port *fcgw_port_lookup(fc_fid_t);
-void fcgw_port_set_name(struct fcgw_port *, fc_wwn_t pn, fc_wwn_t nn, fc_fid_t);
-
-void fcgw_npiv_init(struct fcgw_port *eth_port, struct fcgw_port *fab_port);
-void fcgw_npiv_accept(struct fc_port *, void *);
-
-void fcgw_fc_send(struct fc_port *port, struct fc_frame *fp);
-void fcgw_frame_debug(struct fcgw_port *from, struct fcgw_port *to,
-        struct fc_frame *);
-
-#endif /* _FCWB_FCGW_H_ */
diff --git a/usr/ofc/tools/fcgw/src/Makefile b/usr/ofc/tools/fcgw/src/Makefile
deleted file mode 100644
index f3c7cbd..0000000
--- a/usr/ofc/tools/fcgw/src/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-# SRC		source root relative to this Makefile
- 
-SRC = ../../../..
-LBUILD_OSES = linux
-
-LCFLAGS += -I$(SRC)/common/libsa/include
-LCFLAGS += -I$(SRC)/common/libfc/include
-LCFLAGS += -I$(SRC)/common/libtps/include
-LCFLAGS += -I../include
-
-
-SOURCES = \
-	fcgw.c \
-	fcgw_npiv.c \
-	fcgw_port.c \
-	$(NULL)
-
-LIBRARIES = \
-	libofc.a \
-	libfc.a \
-	libsa.a \
-	libtps.a \
-	-lrt \
-	$(NULL)
-
-PROGRAM = fcgw
-
-include $(SRC)/make/Makefile.inc
diff --git a/usr/ofc/tools/fcgw/src/fcgw.c b/usr/ofc/tools/fcgw/src/fcgw.c
deleted file mode 100644
index 9a3f94b..0000000
--- a/usr/ofc/tools/fcgw/src/fcgw.c
+++ /dev/null
@@ -1,584 +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
- */
-
-/*
- * FCIP or FCoE <-> raw FC gateway
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/fcntl.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <netinet/ether.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <strings.h>
-#include <signal.h>
-
-#include "queue.h"
-
-#include "sa_assert.h"
-#include "net_types.h"
-#include "sa_select.h"
-#include "sa_tcp.h"
-#include "sa_timer.h"
-#include "sa_log.h"
-
-#include "fc_encaps.h"
-#include "fc_fcoe.h"
-#include "fc_fcip.h"
-#include "fc_fs.h"
-#include "fc_fcp.h"
-#include "fc_scsi.h"
-
-#include "fc_types.h"
-#include "fc_event.h"
-#include "fc_frame.h"
-#include "fc_fcoe_sock.h"
-#include "fc_fcip_conn.h"
-#include "fc_port.h"
-#include "fc_print.h"
-#include "fc_exch.h"
-
-#include "../../common/include/config.h"
-#include "fcgw.h"
-
-int  fcgw_debug;
-
-static u_int  fcgw_port_opts = FC_OPT_FCIP_NO_SFS;
-static int  fcgw_echo;
-int  fcgw_npiv;
-char fcgw_xmit_test;                    /* transmit test */
-static char *ifname;
-static char *fcgw_raw_if;
-
-struct fcgw_port *fcgw_fab_port;    /* port going to fabric */
-struct fcgw_port *fcgw_client_port; /* single client port if no NPIV */
-
-/*
- * XXX temporary static config for raw ethernet.
- * MAC addresses are learned from interface and from traffic.
- * VLAN number is compiled in, later will come from the command line or i/f.
- */
-static u_int vlan = 0;
-static u_char *src_mac;
-static u_char *dest_mac;
-static u_char dest_mac_buf[6];
-
-static fc_xid_t fcgw_oxid_drop;
-static fc_xid_t fcgw_rxid_drop;
-static u_long fcgw_targ_drop;
-static u_long fcgw_drop_ord;
-static u_long fcgw_drop_count = 1;
-
-static void fcgw_stats_print(int);
-
-static void
-fcgw_usage()
-{
-    fprintf(stderr, "usage: %s [-acdEnx] [-f <raw-fc-interface>]\n"
-      "\t[-i <fcoe-interface>] [-e <destination MAC address>]\n"
-      "\t[-OX <oxid-to-drop>] [-RX <rxid-to-drop>]\n"
-      "\t[-T <target>[,<exchange ordinal to drop>[,<drop-count>]]\n"
-      "\t[-l <local-fcip-listen-ip>[:<port>]]\n"
-      "\t[-g <remote-gateway-fcip-ip>[:<port>]]\n"
-      "\n"
-      "flags:\n"
-      "  -a   use fixed (non-standard) MAC addresses\n"
-      "  -c   don't check or generate FC CRCs\n"
-      "  -d   debug output (can be repeated for more detail)\n"
-      "  -E   echo FC frames verbatim back to input port\n"
-      "  -n   enable NPIV (N port virtualization) and FLOGI proxying\n"
-#ifdef FCGW_TACH
-      "  -x   FC port transmit test\n"
-#endif /* FCGW_TACH */
-      "\n"
-      "examples:"
-      "  FCoE to fabric, with standard addressing (FLOGI proxying):\n"
-      "     %s -n -f <FCoE Tachynet port name> -e <ethernet-if>\n"
-      "     %s -n -f <FC-if-name> -e <ethernet-if>\n"
-      "\n"
-      "  FCIP to fabric, pass thru from FCIP port 30000, debug\n"
-      "     %s -f <FC port number> -l :30000 -d\n"
-      "\n", cmdname, cmdname, cmdname, cmdname);
-    exit(1);
-}
-
-/*
- * Handle options.
- */
-static void
-fcgw_options(int argc, char *argv[])
-{
-    int opt;
-    extern int optind, opterr, optopt;
-    char *endptr;
-    struct ether_addr mac;
-    fc_xid_t *drop_xid = &fcgw_oxid_drop;
-
-    cmdname = argv[0];
-    while ((opt = getopt(argc, argv, "acde:f:g:i:l:nxEORT:X:")) != -1) {
-        switch (opt) {
-        case 'a':
-            fcgw_port_opts |= FC_OPT_SET_MAC;   /* use non-standard MAC addr */
-            break;
-
-        case 'c':
-            fcgw_port_opts |= FC_OPT_NO_TX_CRC | FC_OPT_NO_RX_CRC;
-            break;
-
-        case 'd':
-            if (fcgw_debug) {                   /* second -d option */
-                fcgw_port_opts |= FC_OPT_DEBUG;
-            }
-            fcgw_debug = 1;
-            break;
-
-        case 'e':
-            if (ether_aton_r(optarg, &mac) == NULL &&
-              ether_hostton(optarg, &mac) != 0) {
-                SA_LOG_EXIT("ethernet address %s not found", optarg);
-            }
-            memcpy(dest_mac_buf, mac.ether_addr_octet, sizeof (dest_mac_buf));
-            dest_mac = dest_mac_buf;
-            break;
-
-        case 'E':
-            fcgw_echo = 1;
-            break;
-
-        case 'g':
-            remote_addr = config_sockaddr_get_byname(optarg, FCIP_PORT);
-            break;
-
-        case 'i':
-            ifname = optarg;
-            break;
-
-        case 'l':
-            local_addr = config_sockaddr_get_byname(optarg, FCIP_PORT);
-            break;
-
-        case 'n':
-            fcgw_npiv = 1;
-            break;
-
-        case 'f':
-            fcgw_raw_if = optarg;
-            break;
-
-        case 'x':
-            fcgw_xmit_test = 1;
-            break;
-
-        case 'O':
-            drop_xid = &fcgw_oxid_drop;
-            break;
-
-        case 'R':
-            drop_xid = &fcgw_rxid_drop;
-            break;
-
-        case 'X':
-            *drop_xid = strtoul(optarg, &endptr, 16);
-            if (*endptr != '\0') {
-                SA_LOG_EXIT("invalid XID %s", optarg);
-            }
-            break;
-
-        case 'T':
-            fcgw_targ_drop = strtoul(optarg, &endptr, 16);
-            if (*endptr == ',') {
-                optarg = endptr + 1;
-                fcgw_drop_ord = strtoul(optarg, &endptr, 0);
-                if (*endptr != '\0' && *endptr != ',') {
-                    SA_LOG_EXIT("invalid target drop ordinal %s", optarg);
-                }
-            }
-            if (*endptr == ',') {
-                optarg = endptr + 1;
-                fcgw_drop_count = strtoul(optarg, &endptr, 0);
-                if (*endptr != '\0') {
-                    SA_LOG_EXIT("invalid target drop count %s", optarg);
-                }
-            }
-            if (*endptr != '\0' || fcgw_targ_drop >= 0x1000000) {
-                SA_LOG_EXIT("invalid target %s", optarg);
-            }
-            break;
-
-        case '?':
-        default:
-            fcgw_usage();                /* exits */
-            break;
-        }
-    }
-}
-
-void
-fcgw_frame_debug(struct fcgw_port *from, struct fcgw_port *to,
-    struct fc_frame *fp)
-{
-    char    buf[30];
-
-    if (to == NULL) {
-        ASSERT(from != NULL);
-        snprintf(buf, sizeof (buf), "%s", from->gp_name);
-    } else if (from == NULL) {
-        snprintf(buf, sizeof (buf), "%5s -> %s", "", to->gp_name);
-    } else {
-        snprintf(buf, sizeof (buf), "%s -> %s", from->gp_name, to->gp_name);
-    }
-    fc_print_frame_hdr(buf, fp);
-}
-
-/*
- * generic FC receive handler.
- */
-static void
-fcgw_recv(void *ingress_port_arg, struct fc_frame *fp)
-{
-    struct fcgw_port *gp = ingress_port_arg;
-    struct fcgw_port *op;
-    struct fc_frame_header *fh;
-
-    ASSERT(fcgw_npiv == 0);
-    ASSERT(gp != NULL);
-    ASSERT(fp != NULL);
-    op = gp->gp_other;
-    if (fcgw_debug) {
-        fcgw_frame_debug(gp, op, fp);
-    }
-    gp->gp_stats.s_rx_frames++;
-    gp->gp_stats.s_rx_bytes += fp->fr_len;
-
-    ASSERT(fp->fr_sg_len == 1);
-
-    fh = fc_frame_header_get(fp);
-    if (fcgw_oxid_drop != 0 && net16_get(&fh->fh_ox_id) == fcgw_oxid_drop &&
-      fh->fh_type != FC_TYPE_BLS) {
-        fc_frame_free(fp);
-        return;
-    }
-    if (fcgw_rxid_drop != 0 && net16_get(&fh->fh_rx_id) == fcgw_rxid_drop &&
-      fh->fh_type != FC_TYPE_BLS) {
-        fc_frame_free(fp);
-        return;
-    }
-    if (fcgw_targ_drop != 0 && net24_get(&fh->fh_d_id) == fcgw_targ_drop &&
-      fh->fh_type != FC_TYPE_BLS) {
-        if (fcgw_drop_ord == 0) {
-            if (--fcgw_drop_count == 0) {
-                fcgw_targ_drop = 0;
-            }
-            fc_frame_free(fp);
-            return;
-        } else {
-            fcgw_drop_ord--;
-        }
-    }
-    if (op != NULL && op->gp_port != NULL) {
-        op->gp_stats.s_tx_frames++;
-        op->gp_stats.s_tx_bytes += fp->fr_len;
-        fc_port_egress(op->gp_port, fp);
-    } else {
-        fc_frame_free(fp);
-    }
-}
-
-/*
- * Send a frame from the FLOGI address so that any ethernet
- * switch will learn our port.
- */
-static void
-fcgw_eth_announce(struct fc_port *port)
-{
-    struct fc_frame *fp;
-    struct fc_frame_header *fh;
-    struct ethhdr *eh;
-
-    fp = fc_frame_alloc(port, sizeof (struct ethhdr));
-    ASSERT_NOTIMPL(fp != NULL);
-    eh = fc_frame_tail_get(fp, sizeof (*eh));
-    fp->fr_eth_tx = eh;
-    ASSERT_NOTIMPL(eh != NULL);
-    net48_put((net48_t *) &eh->h_dest, 0xffffffffffffULL);
-    net48_put((net48_t *) &eh->h_source, FC_FCOE_FLOGI_MAC);
-    fp->fr_sof = FC_SOF_I3;
-    fp->fr_eof = FC_EOF_T;
-    fh = fc_frame_header_get(fp);
-    memset(fh, 0, sizeof (*fh));
-    fh->fh_r_ctl = FC_RCTL_BA_NOP;
-    fh->fh_type = FC_TYPE_BLS;
-    net24_put(&fh->fh_f_ctl, FC_FC_FIRST_SEQ | FC_FC_LAST_SEQ | FC_FC_END_SEQ);
-    net24_put(&fh->fh_d_id, FC_FID_FLOGI);
-    net24_put(&fh->fh_s_id, FC_FID_FLOGI);
-    net16_put(&fh->fh_ox_id, FC_XID_UNKNOWN);
-    net16_put(&fh->fh_rx_id, FC_XID_UNKNOWN);
-    fc_port_egress(port, fp);
-}
-
-static void
-fcgw_fcip_event(int event, void *port_arg)
-{
-    struct fcgw_port *gp = port_arg;
-
-    if (event == FC_EV_CLOSED && gp->gp_port != NULL) {
-        if (gp->gp_other != NULL) {
-            gp->gp_other->gp_other = NULL;
-        }
-        gp->gp_other = NULL;
-
-        fc_port_close_ingress(gp->gp_port);
-        gp->gp_port = NULL;
-        if (gp == fcgw_client_port) {
-            fcgw_client_port = NULL;
-        }
-        if (fcgw_fab_port != NULL) {
-            if (gp == fcgw_fab_port) {
-                fcgw_fab_port = NULL;
-                SA_LOG("fcgw_fcip_event fabric FCIP port disconnected");
-                fcgw_stats_print(0);            /* print stats and exit */
-            }
-        }
-    }
-}
-
-/*
- * Initialize FCGW.  One or two ports may have been provided.
- * If there is a raw fibre-channel port, it'll be first.
- */
-static void
-fcgw_init(struct fcgw_port *gp, struct fcgw_port *op)
-{
-    struct fc_port *port;
-
-    ASSERT(gp->gp_name != NULL);
-    port = gp->gp_port;
-    if (port != NULL) {
-        fc_port_set_ingress(port, fcgw_recv, gp);
-    }
-    if (fcgw_echo) {
-        gp->gp_other = gp;
-    } else if (op != NULL) {
-        fcgw_fab_port = gp;
-        port = op->gp_port;
-        if (fcgw_npiv) {
-            fcgw_npiv_init(gp, op);
-        } else if (port != NULL) {
-            gp->gp_other = op;
-            op->gp_other = gp;
-            fc_port_set_ingress(port, fcgw_recv, op);
-        }
-    } else if (fcgw_npiv) {
-        SA_LOG("notice: -n flag does not apply with only one interface");
-        fcgw_npiv = 0;
-    }
-}
-
-/*
- * Accept an FCIP connection.
- * Note that this not used for the NPIV case, so only one is accepted.
- */
-static void
-fcgw_accept(struct fc_port *port, void *arg)
-{
-    struct fcgw_port *gp = arg;
-
-    ASSERT(fcgw_npiv == 0);
-    if (fcgw_client_port != NULL) {
-        fc_port_close_ingress(port);
-        SA_LOG("new connection dropped - limited to single connection");
-    } else {
-        gp = fcgw_port_create(port, "fcip");
-        ASSERT_NOTIMPL(gp != NULL);
-        fcgw_client_port = gp;
-        gp->gp_port = port;
-        gp->gp_other = fcgw_fab_port;
-
-        /* fcgw_fab_port is NULL if there is no outbound port specified */
-        if (fcgw_fab_port != NULL) {
-            fcgw_fab_port->gp_other = fcgw_client_port;
-        }
-        fc_port_enq_handler(port, fcgw_fcip_event, gp);
-        fc_port_set_ingress(port, fcgw_recv, gp);
-    }
-}
-
-static void
-fcgw_stats_print_port(struct fcgw_port *gp, void *arg)
-{
-    if (gp->gp_type != FCGW_PORT_LISTEN) {
-        sa_log("%10s   %10lld %10lld  %10lld %10lld",
-          gp->gp_name, gp->gp_stats.s_rx_frames, gp->gp_stats.s_rx_bytes,
-          gp->gp_stats.s_tx_frames, gp->gp_stats.s_tx_bytes);
-    }
-}
-
-static void
-fcgw_stats_print(int sig)
-{
-    sa_log("%10s   %10s %10s   %10s %10s",
-      "net", "rx packets", "bytes", "tx packets", "bytes");
-    fcgw_port_iterate(fcgw_stats_print_port, NULL);
-    exit(0);
-}
-
-/*
- * Main.
- */
-int
-main(int argc, char *argv[])
-{
-    struct sa_tcp *tcp;
-    char *name;
-    struct fc_port *port = NULL;
-    int     rc;
-    int     port_count;
-    struct fcgw_port *fcgw_ports[3] = { NULL }; /* only two are used for now */
-    struct fcgw_port **gpp = fcgw_ports;
-    struct fcgw_port *gp;
-    struct sigaction sig;
-
-    fcgw_options(argc, argv);
-
-    port_count = (fcgw_raw_if != 0) + (local_addr != NULL) +
-      (ifname != NULL) + (remote_addr != 0);
-    if (port_count > 2 || port_count < 1) {
-        fcgw_usage();
-    }
-    if (fcgw_npiv && (local_addr == NULL && ifname == NULL)) {
-        sa_log("NPIV requires an FCIP or FCoE port to be specified");
-        fcgw_usage();
-    }
-
-    /*
-     * Open the Raw Fibre-Channel port, if specified.
-     * If the name doesn't start with a / or a digit, assume it's a network i/f.
-     * This is used to get to the Tachyon thru the tachynet driver, for example.
-     */
-    if (fcgw_raw_if != NULL) {
-        name = fcgw_raw_if;
-#ifdef FCGW_TACH
-        if (name[0] != '/' && (name[0] < '0' || name[0] > '9')) {
-#endif /* FCGW_TACH */
-            port = fc_fcoe_create(fcgw_raw_if, 0, NULL, NULL,
-              fcgw_port_opts & ~FC_OPT_NO_TX_CRC);
-            if (port == NULL) {
-                SA_LOG_EXIT("fcgw_fcoe_create failed - check permissions");
-            }
-#ifdef FCGW_TACH
-        } else {
-            port = fcgw_rawfc_open(fcgw_raw_if);
-            name = "fc";
-            if (port == NULL) {
-                SA_LOG_EXIT("fcgw_rawfc_open failed - check permissions");
-            }
-        }
-#endif /* FCGW_TACH */
-        gp = fcgw_port_create(port, name);
-        gp->gp_type = FCGW_PORT_FAB;
-        *gpp++ = gp;
-    }
-
-    /*
-     * Open the active FCIP port, if specified.
-     */
-    if (remote_addr != NULL) {
-        tcp = sa_tcp_create();
-
-        rc = sa_tcp_connect(tcp, remote_addr, sizeof (struct sockaddr_in));
-        if (rc != 0) {
-            SA_LOG_ERR_EXIT(errno, "sa_tcp_connect failed");
-        }
-        port = fc_fcip_create(tcp, fcgw_port_opts, 0, 0);
-        if (port == NULL) {
-            SA_LOG_EXIT("fc_fcip_create failed");
-        }
-        gp = fcgw_port_create(port, "fcip_a");
-        gp->gp_type = FCGW_PORT_FAB;
-        *gpp++ = gp;
-        fc_port_enq_handler(port, fcgw_fcip_event, gp);
-    }
-
-    /*
-     * Open the passive FCIP port, if specified.
-     */
-    if (local_addr != NULL) {
-        int on = 1;
-
-        tcp = sa_tcp_create();
-        setsockopt(sa_tcp_socket(tcp), SOL_SOCKET, SO_REUSEADDR,
-           &on, sizeof (on));
-
-        rc = sa_tcp_bind(tcp, local_addr, sizeof (struct sockaddr_in));
-        if (rc < 0) {
-            SA_LOG_ERR_EXIT(errno, "sa_tcp_bind failed");
-        }
-        gp = fcgw_port_create(NULL, "fcip");
-        gp->gp_type = FCGW_PORT_LISTEN;
-        ASSERT(gp != NULL);
-        gp->gp_port = NULL;
-        rc = fc_fcip_listen(tcp, fcgw_port_opts,
-          fcgw_npiv ? fcgw_npiv_accept : fcgw_accept, NULL, 0, 0);
-        if (rc != 0) {
-            SA_LOG_EXIT("fc_fcip_listen failed");
-        }
-        *gpp++ = gp;
-    }
-
-    /*
-     * Open the raw ethernet port, for FCoE, if specified.
-     */
-    if (ifname != NULL) {
-        if (local_addr != NULL) {
-            sa_log("%s: cannot support both FCoE and FCIP client ports",
-              cmdname);
-            fcgw_usage();
-        }
-        port = fc_fcoe_create(ifname, vlan, src_mac, dest_mac, fcgw_port_opts);
-        if (port == NULL) {
-            SA_LOG_EXIT("fc_fcoe_create failed");
-        }
-        gp = fcgw_port_create(port, ifname);
-        *gpp++ = gp;
-        if ((fcgw_port_opts & FC_OPT_SET_MAC) == 0) {
-            fcgw_eth_announce(port);
-        }
-    }
-    fcgw_init(fcgw_ports[0], fcgw_ports[1]);
-
-    /*
-     * Intercept ctl-C for printing statistics and exiting.
-     */
-    memset(&sig, 0, sizeof (sig));
-    sig.sa_handler = fcgw_stats_print;
-    rc = sigaction(SIGINT, &sig, NULL);
-    if (rc == -1) {
-        SA_LOG_ERR_EXIT(errno, "sigaction failed");
-    }
-    sa_log("fc gateway ready");
-    sa_select_loop();
-    return (0);
-}
diff --git a/usr/ofc/tools/fcgw/src/fcgw_npiv.c b/usr/ofc/tools/fcgw/src/fcgw_npiv.c
deleted file mode 100644
index d74c755..0000000
--- a/usr/ofc/tools/fcgw/src/fcgw_npiv.c
+++ /dev/null
@@ -1,552 +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
- */
-
-/*
- * FCIP or FCoE <-> raw FC gateway
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/fcntl.h>
-#include <sys/ioctl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <linux/if_ether.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <strings.h>
-#include <signal.h>
-
-#include "sa_assert.h"
-#include "net_types.h"
-#include "sa_select.h"
-#include "sa_tcp.h"
-#include "sa_timer.h"
-#include "sa_log.h"
-
-#include "fc_encaps.h"
-#include "fc_fs.h"
-#include "fc_els.h"
-
-#include "fc_types.h"
-#include "fc_event.h"
-#include "fc_exch.h"
-#include "fc_frame.h"
-#include "fc_port.h"
-#include "fc_print.h"
-#include "fc_remote_port.h"
-#include "fc_virt_fab.h"
-
-#include "fcgw.h"
-
-struct fcgw_proxy_info {
-    struct fcgw_port *pi_gport;
-    struct fc_remote_port *pi_rp;   /* XXX unneeded? */
-    struct fc_seq   *pi_seq;
-    struct ethhdr   pi_eth_hdr;
-    u_char          pi_op;          /* ELS opcode */
-    u_char          pi_set_fid;     /* response should set remote port fid */
-    u_char          pi_clear_fid;   /* response should clear remote port fid */
-};
-
-static unsigned int fcgw_flogi_sent; /* first FLOGI sent - XXX imprecise */
-static unsigned int fcgw_port_count; /* number of client ports attached */
-
-struct fc_virt_fab *fcgw_vf;
-static struct fc_exch_mgr *fcgw_exch_mgr;
-static struct fcgw_port *fcgw_drop_port;
-
-static void fcgw_npiv_recv_resp(struct fc_seq *, struct fc_frame *, void *);
-
-static void
-fcgw_npiv_recv_err(enum fc_event event, void *arg) 
-{
-    SA_LOG("TBD event %d", event);
-}
-
-static void
-fcgw_npiv_fix_data_size(struct fc_frame *fp)
-{
-    struct fc_els_flogi *flp;
-    u_int   mfs;
-    u_int   client_mfs;
-    u_int   i;
-    net16_t *np;
-
-    flp = fc_frame_payload_get(fp, sizeof (*flp));
-    mfs = fc_port_get_max_frame_size(fcgw_fab_port->gp_port);
-    if (fp->fr_in_port) {
-        client_mfs = fc_port_get_max_frame_size(fp->fr_in_port);
-        if (client_mfs > 0 && mfs > client_mfs) {
-            mfs = client_mfs;
-        }
-    }
-    if (flp != NULL && mfs > sizeof (struct fc_frame_header)) {
-        mfs -= sizeof (struct fc_frame_header); 
-        np = &flp->fl_csp.sp_bb_data;
-        client_mfs = net16_get(np);
-        if ((client_mfs & FC_SP_BB_DATA_MASK) > mfs) {
-            net16_put(np, (client_mfs & ~FC_SP_BB_DATA_MASK) | mfs);
-        }
-        for (i = 0; i < 4; i++) {
-            np = &flp->fl_cssp[i].cp_rdfs;
-            client_mfs = net16_get(np);
-            if ((client_mfs & FC_SP_BB_DATA_MASK) > mfs) {
-                net16_put(np, (client_mfs & ~FC_SP_BB_DATA_MASK) | mfs);
-            }
-        }
-    }
-}
-
-/*
- * Receive / proxy request from ethernet to FLOGI port.
- * The request is coming from the ethernet side and going to FC.
- * This could be FLOGI or LOGO.
- */
-static void
-fcgw_npiv_recv_req(struct fc_seq *sp, struct fc_frame *fp, void *gp_arg)
-{
-    struct fcgw_port *gp = gp_arg;
-    struct fcgw_proxy_info *pip;
-    struct fc_frame_header *fh;
-    fc_fid_t s_id;
-    u_char  *op;
-
-    ASSERT(fp != NULL);
-    fh = fc_frame_header_get(fp);
-    ASSERT(fh != NULL);
-    ASSERT(net24_get(&fh->fh_d_id) == FC_FID_FLOGI);
-    s_id = net24_get(&fh->fh_s_id);
-
-    pip = calloc(1, sizeof (*pip));
-    if (pip != NULL) {
-        pip->pi_gport = gp;
-        pip->pi_seq = sp;
-        if (fp->fr_eth_hdr != NULL) {
-            memcpy(&pip->pi_eth_hdr, fp->fr_eth_hdr, ETH_ALEN * 2);
-        }
-        fc_seq_hold(sp);                	/* hold for proxy info */
-
-        if (fh->fh_r_ctl == FC_RCTL_ELS_REQ && fh->fh_type == FC_TYPE_ELS) {
-            op = (u_char *) fc_frame_payload_get(fp, sizeof (op));
-
-            switch (*op) {
-            case ELS_FLOGI:
-#if 0 /* XXX */
-                if (fcgw_flogi_sent) {
-                    *op = ELS_FDISC;
-                }
-#endif /* XXX */
-                pip->pi_op = *op;
-                if (gp->gp_logged_in == 0) {
-                    fcgw_flogi_sent++;
-                    gp->gp_logged_in = 1;
-                }
-                pip->pi_set_fid = 1;
-                fcgw_npiv_fix_data_size(fp);
-                break;
-
-            case ELS_FDISC:                 /* XXX should this be allowed? */
-                pip->pi_op = *op;
-                if (gp->gp_logged_in == 0) {
-                    fcgw_flogi_sent++;
-                    gp->gp_logged_in = 1;
-                }
-                pip->pi_set_fid = 1;
-                fcgw_npiv_fix_data_size(fp);
-                break;
-
-            case ELS_LOGO:
-                pip->pi_set_fid = 1;
-                pip->pi_clear_fid = 1;
-                if (fcgw_flogi_sent > 0) {
-                    fcgw_flogi_sent--;
-                }
-                break;
-                
-            default:
-                break;
-            }
-        }
-
-        /*
-         * Start proxied sequence to fabric.
-         */
-        sp = fc_seq_start_exch(fcgw_exch_mgr, fcgw_npiv_recv_resp,
-          fcgw_npiv_recv_err, pip, s_id, FC_FID_FLOGI);
-        if (sp != NULL) {
-            ASSERT(fcgw_fab_port != NULL);
-            fc_exch_set_port(fc_seq_exch(sp), fcgw_fab_port->gp_port);
-            if (fcgw_debug) {
-                fcgw_frame_debug(NULL, fcgw_fab_port, fp);
-            }
-            fc_seq_send_tsi(sp, fp);
-        } else {
-            SA_LOG("couldn't allocate sequence");
-            fc_frame_free(fp);
-            free(pip);
-        }
-    } else {
-        SA_LOG("pip memory alloc failed");
-        fc_frame_free(fp);
-        fc_seq_exch_complete(sp);
-    }
-}
-
-/*
- * Handle response to a proxied request.
- */
-static void
-fcgw_npiv_recv_resp(struct fc_seq *in_sp, struct fc_frame *in_fp, void *pip_arg)
-{
-    struct fc_seq *sp;
-    struct fcgw_proxy_info *pip = pip_arg;
-    struct fc_frame_header *fh;
-    struct fc_frame *fp;
-    struct ethhdr *eh;
-    struct fc_els_flogi *flp;
-    fc_fid_t d_id;
-
-    fp = in_fp;
-    fh = fc_frame_header_get(fp);
-    ASSERT(fh != NULL);
-    ASSERT(net24_get(&fh->fh_s_id) == FC_FID_FLOGI);
-    d_id = net24_get(&fh->fh_d_id);
-
-    /*
-     * Send reply back to original requestor, using a copy of the frame.
-     * The caller will free the received frame.
-     */
-    fp = fc_frame_alloc(pip->pi_gport->gp_port,
-      fp->fr_len - sizeof (*fh) + sizeof (struct ethhdr) + 2);
-    if (fp != NULL) {
-        eh = fc_frame_tail_get(fp, sizeof (struct ethhdr) + 2);
-        if (pip->pi_op == ELS_FLOGI || pip->pi_op == ELS_FDISC) {
-            fp->fr_eth_tx = eh;
-            memcpy(eh->h_source, pip->pi_eth_hdr.h_dest, ETH_ALEN);
-            memcpy(eh->h_dest, pip->pi_eth_hdr.h_source, ETH_ALEN);
-            fcgw_npiv_fix_data_size(in_fp);
-        }
-        memcpy(fc_frame_header_get(fp), fh, fp->fr_len);
-        sp = pip->pi_seq;
-        ASSERT(sp != NULL);
-        fc_seq_set_addr(sp, d_id, FC_FID_FLOGI);
-        if (fcgw_debug) {
-            fcgw_frame_debug(NULL, pip->pi_gport, fp);
-        }
-        fc_seq_send_last(sp, fp, fh->fh_r_ctl, fh->fh_type);
-        fc_seq_release(sp);
-    }
-    fp = in_fp;
-
-    flp = fc_frame_payload_get(fp, sizeof (*flp));
-    if (pip->pi_set_fid && flp != NULL) {
-        if (pip->pi_clear_fid) {
-            d_id = 0;
-        }
-        fcgw_port_set_name(pip->pi_gport, net64_get(&flp->fl_wwpn),
-          net64_get(&flp->fl_wwnn), d_id);
-    }
-    free(pip);
-}
-
-/*
- * Handle a new exchange from the fabric.  Reject it.
- */
-static void
-fcgw_npiv_fc_req(struct fc_seq *in_sp, struct fc_frame *fp, void *gp_arg)
-{
-    struct fc_frame_header *fh;
-    int reject = 0;
-
-    fh = fc_frame_header_get(fp);
-    if (fh != NULL) {
-        if (fh->fh_type == FC_TYPE_ELS) {
-            reject = 1;
-            fc_seq_ls_rjt(in_sp, ELS_RJT_UNSUP, ELS_EXPL_NONE);
-        } else {
-            SA_LOG("unexpected request sequence - sending reject");
-        }
-    }
-    fc_frame_free(fp);
-    if (fcgw_debug) {
-        SA_LOG("unexpected request sequence%s",
-          reject ? " - sending reject" : "");
-    }
-}
-
-static void
-fcgw_npiv_fc_recv(void *gp_arg, struct fc_frame *fp)
-{
-    struct fcgw_port *in_gp = gp_arg;
-    struct fcgw_port *out_gp;
-    struct fc_frame_header *fh;
-    fc_fid_t    d_id;
-    fc_fid_t    s_id;
-
-    ASSERT(in_gp != NULL);
-
-    fp->fr_in_port = in_gp->gp_port;
-    in_gp->gp_stats.s_rx_frames++;
-    in_gp->gp_stats.s_rx_bytes += fp->fr_len;
-
-    fh = fc_frame_header_get(fp);
-    if (fh != NULL) {
-        s_id = net24_get(&fh->fh_s_id);
-        d_id = net24_get(&fh->fh_d_id);
-
-        if (s_id == FC_FID_FLOGI) {
-            if (fcgw_debug) {
-                fcgw_frame_debug(in_gp, NULL, fp);
-            }
-            if (net24_get(&fh->fh_f_ctl) & FC_FC_SEQ_CTX) {
-                fc_exch_recv_resp(fcgw_exch_mgr, fp);
-                fp = NULL;
-            } else {
-                fc_exch_recv_req(fcgw_exch_mgr, fp,
-                  in_gp->gp_port->np_max_frame - sizeof (*fh),
-                  fcgw_npiv_fc_req, in_gp);
-            }
-        } else {
-            out_gp = fcgw_port_lookup(d_id);
-            if (out_gp == NULL) {
-                out_gp = fcgw_drop_port;
-            }
-            ASSERT(out_gp != NULL);
-            if (fcgw_debug) {
-                fcgw_frame_debug(in_gp, out_gp, fp);
-            }
-            out_gp->gp_stats.s_tx_frames++;
-            out_gp->gp_stats.s_tx_bytes += fp->fr_len;
-            if (out_gp->gp_port != NULL) {
-                fc_port_egress(out_gp->gp_port, fp);
-                fp = NULL;
-            } else if (fcgw_debug) {
-                SA_LOG("no egress port for dest %x", d_id);
-            }
-        }
-    }
-    if (fp != NULL) {
-        fc_frame_free(fp);
-    }
-}
-
-/*
- * Send LOGO to client host to indicate the link is down.
- * Set remembered port FID to 0.
- */
-static void
-fcgw_send_logo(struct fcgw_port *gp, void *arg)
-{
-    struct fc_frame *fp;
-    struct fc_frame_header *fh;
-    struct fc_remote_port *rp;
-    struct fc_els_logo *pp;
-
-    gp->gp_logged_in = 0;
-    rp = gp->gp_rport;
-    if (gp != fcgw_fab_port && rp != NULL && rp->rp_fid != 0) {
-        fp = fc_frame_alloc(gp->gp_port, sizeof (*pp));
-        ASSERT(fp != NULL);
-        if (fp != NULL) {
-            fp->fr_sof = FC_SOF_I3;
-            fp->fr_eof = FC_EOF_T;
-            fh = fc_frame_header_get(fp);
-            ASSERT(fh != NULL);
-            memset(fh, 0, sizeof (*fh));
-            fh->fh_r_ctl = FC_RCTL_ELS_REQ;
-            net24_put(&fh->fh_d_id, rp->rp_fid);
-            net24_put(&fh->fh_s_id, FC_FID_FLOGI);
-            fh->fh_type = FC_TYPE_ELS;
-            net24_put(&fh->fh_f_ctl, FC_FC_FIRST_SEQ | FC_FC_LAST_SEQ |
-              FC_FC_END_SEQ | FC_FC_SEQ_INIT);
-            net16_put(&fh->fh_ox_id, FC_XID_UNKNOWN);
-            net16_put(&fh->fh_rx_id, FC_XID_UNKNOWN);
-        
-            pp = fc_frame_payload_get(fp, sizeof (*pp));
-            ASSERT(pp != NULL);
-            memset(pp, 0, sizeof (*pp));
-            pp->fl_cmd = ELS_LOGO;
-            net24_put(&pp->fl_n_port_id, rp->rp_fid);
-            net64_put(&pp->fl_n_port_wwn, rp->rp_port_wwn);
-            if (fcgw_debug) {
-                fcgw_frame_debug(NULL, gp, fp);
-            }
-            fc_port_egress(gp->gp_port, fp);
-        }
-        gp->gp_rport = NULL;
-        fc_remote_port_set_fid(rp, 0);
-        fc_remote_port_release(rp);
-    }
-}
-
-/*
- * Handle fabric link event.
- */
-static void
-fcgw_npiv_link_event(int event, void *gp_arg)
-{
-    struct fcgw_port *gp = gp_arg;
-
-    ASSERT(gp != NULL);
-    if (fcgw_debug) {
-        switch (event) {
-        case FC_EV_CLOSED:
-            SA_LOG("%s: closed", gp->gp_name);
-            break;
-        case FC_EV_DOWN:
-            SA_LOG("%s: link down", gp->gp_name);
-            break;
-        case FC_EV_READY:
-            SA_LOG("%s: link up", gp->gp_name);
-            break;
-        default:
-            SA_LOG("%s: unexpected event %d", gp->gp_name, event);
-            break;
-        }
-    }
-    if (event == FC_EV_CLOSED || event == FC_EV_DOWN) {
-        if (event == FC_EV_CLOSED) {
-            fc_port_close_ingress(gp->gp_port);
-        }
-        if (gp == fcgw_fab_port) {
-            fcgw_flogi_sent = 0;
-            fcgw_port_iterate(fcgw_send_logo, NULL);
-        } else {
-            if (gp->gp_logged_in && fcgw_flogi_sent > 0) {
-                fcgw_flogi_sent--;
-            }
-            gp->gp_logged_in = 0;
-            if (event == FC_EV_CLOSED) {
-                fcgw_port_delete(gp);
-            }
-        }
-    }
-}
-
-static void
-fcgw_npiv_eth_event(int event, void *port_arg)
-{
-    struct fcgw_port *gp = port_arg;
-
-    if (event == FC_EV_CLOSED) {
-        ASSERT(gp->gp_port != NULL);
-        ASSERT(gp->gp_other == NULL);
-        fc_port_close_ingress(gp->gp_port);
-        fcgw_port_delete(gp);
-        fcgw_port_count--;
-    } else if (event == FC_EV_DOWN) {
-        if (gp->gp_logged_in && fcgw_flogi_sent > 0) {
-            fcgw_flogi_sent--;
-        }
-        gp->gp_logged_in = 0;
-    }
-}
-
-/*
- * Handle incoming frame on FCoE / FCIP port.
- */
-static void
-fcgw_npiv_eth_recv(void *gp_arg, struct fc_frame *fp)
-{
-    struct fcgw_port *gp = gp_arg;
-    struct fc_frame_header *fh;
-
-    fp->fr_in_port = gp->gp_port;
-    gp->gp_stats.s_rx_frames++;
-    gp->gp_stats.s_rx_bytes += fp->fr_len;
-
-    fh = fc_frame_header_get(fp);
-    if (fh != NULL && net24_get(&fh->fh_d_id) == FC_FID_FLOGI) {
-        if (fcgw_debug) {
-            fcgw_frame_debug(gp, NULL, fp);
-        }
-        if ((net24_get(&fh->fh_f_ctl) & (FC_FC_SEQ_CTX | FC_FC_EX_CTX)) == 0 && 
-          fh->fh_r_ctl == FC_RCTL_ELS_REQ &&
-          fh->fh_type == FC_TYPE_ELS) {
-            fc_exch_recv_req(fcgw_exch_mgr, fp, 
-              gp->gp_port->np_max_frame - sizeof (*fh),
-	      fcgw_npiv_recv_req, gp);
-        } else {
-            SA_LOG("unexpected frame to address %x", FC_FID_FLOGI);
-            fc_print_frame_hdr(__FUNCTION__, fp);
-            fc_frame_free(fp);
-        }
-    } else {
-        if (fcgw_debug) {
-            fcgw_frame_debug(gp, fcgw_fab_port, fp);
-        }
-        ASSERT(fcgw_fab_port != NULL);
-        gp = fcgw_fab_port;
-        gp->gp_stats.s_tx_frames++;
-        gp->gp_stats.s_tx_bytes += fp->fr_len;
-        fc_port_egress(gp->gp_port, fp);
-    }
-}
-
-/*
- * Add an new incoming N port via a new FCIP connection.
- */
-void
-fcgw_npiv_accept(struct fc_port *port, void *arg)
-{
-    struct fcgw_port *gp;
-
-    ASSERT(port != NULL);
-    gp = fcgw_port_create(port, "fcip");
-    if (gp == NULL) {
-        fc_port_close_ingress(port);
-        sa_log("new connection - port allocation failed");
-    } else {
-        gp->gp_port = port;
-        fc_port_enq_handler(port, fcgw_npiv_eth_event, gp);
-        fc_port_set_ingress(port, fcgw_npiv_eth_recv, gp);
-    }
-}
-
-/*
- * Initialize setup for NPIV.
- * If the ethernet side is FCIP, eth_port will be NULL.
- */
-void
-fcgw_npiv_init(struct fcgw_port *fab_port, struct fcgw_port *eth_port)
-{
-    ASSERT_NOTIMPL(fab_port != NULL);
-    fcgw_fab_port = fab_port;
-    if (fab_port->gp_port != NULL) {
-        fc_port_enq_handler(fab_port->gp_port, fcgw_npiv_link_event, fab_port);
-        fc_port_set_ingress(fab_port->gp_port, fcgw_npiv_fc_recv, fab_port);
-    }
-
-    fcgw_drop_port = fcgw_port_create(NULL, "drop");
-
-    fcgw_vf = fc_virt_fab_alloc(0, FC_CLASS_NONE, 0, 0);
-    ASSERT_NOTIMPL(fcgw_vf != NULL);
-    fcgw_exch_mgr = fc_exch_mgr_alloc(FC_CLASS_3, 0xf000, 0xfffe);
-    ASSERT_NOTIMPL(fcgw_exch_mgr != NULL);
-
-    ASSERT(eth_port != NULL);
-    if (eth_port->gp_port != NULL) {
-        fc_port_enq_handler(eth_port->gp_port, fcgw_npiv_eth_event, eth_port);
-        fc_port_set_ingress(eth_port->gp_port, fcgw_npiv_eth_recv, eth_port);
-    }
-}
diff --git a/usr/ofc/tools/fcgw/src/fcgw_port.c b/usr/ofc/tools/fcgw/src/fcgw_port.c
deleted file mode 100644
index b69b321..0000000
--- a/usr/ofc/tools/fcgw/src/fcgw_port.c
+++ /dev/null
@@ -1,127 +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
- */
-
-/*
- * FCIP or FCoE <-> raw FC gateway
- */
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-
-#include "sa_assert.h"
-#include "sa_log.h"
-
-#include "fc_types.h"
-#include "fc_port.h"
-#include "fc_remote_port.h"
-#include "fc_virt_fab.h"
-
-#include "fcgw.h"
-
-static TAILQ_HEAD(, fcgw_port) fcgw_port_head =
-    TAILQ_HEAD_INITIALIZER(fcgw_port_head);
-
-/*
- * Allocate fcgw_port.
- */
-struct fcgw_port *
-fcgw_port_create(struct fc_port *port, const char *name)
-{
-    struct fcgw_port *gp;
-
-    gp = calloc(1, sizeof (*gp));
-    ASSERT_NOTIMPL(gp != NULL);
-    if (gp != NULL) {
-        gp->gp_name = name;
-        gp->gp_port = port;
-        gp->gp_type = FCGW_PORT_CLIENT;
-        TAILQ_INSERT_TAIL(&fcgw_port_head, gp, gp_list);
-    }
-    return (gp);
-}
-
-/*
- * Deallocate fcgw_port.
- * Performed at FCIP disconnect.
- */
-void
-fcgw_port_delete(struct fcgw_port *gp)
-{
-    struct fc_remote_port *rp;
-
-    rp = gp->gp_rport;
-    if (rp != NULL) {
-	rp->rp_client_priv = NULL;
-        fc_remote_port_release(rp);
-    }
-    TAILQ_REMOVE(&fcgw_port_head, gp, gp_list);
-    free(gp);
-}
-
-/*
- * Iterate through the list of FCGW ports.
- */
-void
-fcgw_port_iterate(void (*func)(struct fcgw_port *fgp, void *arg), void *arg)
-{
-    struct fcgw_port *gp;
-    struct fcgw_port *next;
-
-    TAILQ_FOREACH_SAFE(gp, &fcgw_port_head, gp_list, next) {
-        (*func)(gp, arg);
-    }
-}
-
-/*
- * Set a world-wide name and/or FID for the port.
- */
-void
-fcgw_port_set_name(struct fcgw_port *gp,
-    fc_wwn_t wwpn, fc_wwn_t wwnn, fc_fid_t fid)
-{
-    struct fc_remote_port *rp;
-    struct fc_remote_port *prev_rp;
-
-    prev_rp = gp->gp_rport;
-    rp = fc_remote_port_lookup_create(fcgw_vf, fid, wwpn, wwnn);    /* holds */
-    gp->gp_rport = rp;
-    if (rp != NULL) {
-        rp->rp_client_priv = gp;
-    }
-    if (prev_rp != NULL) {
-        fc_remote_port_release(prev_rp);
-    }
-}
-
-/*
- * Lookup fcgw_port by FID.
- */
-struct fcgw_port *
-fcgw_port_lookup(fc_fid_t fid)
-{
-    struct fcgw_port *gp = NULL;
-    struct fc_remote_port *rp;
-
-    rp = fc_remote_port_lookup(fcgw_vf, fid, 0);
-    if (rp != NULL) {
-        gp = rp->rp_client_priv;
-    }
-    return (gp);
-} 
diff --git a/usr/ofc/tools/fcping/Makefile b/usr/ofc/tools/fcping/Makefile
index abd3857..e1a78e1 100644
--- a/usr/ofc/tools/fcping/Makefile
+++ b/usr/ofc/tools/fcping/Makefile
@@ -4,3 +4,6 @@ SRC = ../../..
 SUBDIRS = src
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	make -C src clean
diff --git a/usr/ofc/tools/fcping/src/Makefile b/usr/ofc/tools/fcping/src/Makefile
index 778670f..3d874de 100644
--- a/usr/ofc/tools/fcping/src/Makefile
+++ b/usr/ofc/tools/fcping/src/Makefile
@@ -13,20 +13,21 @@ LCFLAGS += -I$(SRC)/common/libfc/include
 LCFLAGS += -I$(SRC)/ofc/drivers/openfc/linux
 LCFLAGS += -I../../../../kernel_include/
 
-LBUILD_ARCHES ?= i386 x86_64
-
 SOURCES = \
 	fcping.c \
 	$(NULL)
 
 LIBRARIES = \
-	libofc.a \
-	libfc.a \
-	libsa.a \
-	libtps.a \
+	../../../../ofc/tools/common/src/libofc.a \
+	../../../../common/libfc/src/libfc.a \
+	../../../../common/libsa/src/libsa.a \
+	../../../../common/libtps/src/libtps.a \
 	-lrt \
 	$(NULL)
 
 PROGRAM = fcping
 
 include $(SRC)/make/Makefile.inc
+
+clean:
+	rm -f *.o *.d $(PROGRAM)
diff --git a/usr/ofc/tools/fds/Makefile b/usr/ofc/tools/fds/Makefile
deleted file mode 100644
index abd3857..0000000
--- a/usr/ofc/tools/fds/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# $Id: Makefile
-
-SRC = ../../..
-SUBDIRS = src
-
-include $(SRC)/make/Makefile.inc
diff --git a/usr/ofc/tools/fds/src/Makefile b/usr/ofc/tools/fds/src/Makefile
deleted file mode 100644
index 23d58bf..0000000
--- a/usr/ofc/tools/fds/src/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-# $Id: Makefile
-
-#
-# Variables needed only for local makes
-#
-# SRC		source root relative to this Makefile
- 
-SRC = ../../../..
-
-LCFLAGS += -I$(SRC)/common/libsa/include
-LCFLAGS += -I$(SRC)/common/libfc/include
-LCFLAGS += -I$(SRC)/common/libtps/include
-LBUILD_ARCHES = x86_64 i386
-
-SOURCES = \
-	fds.c \
-	$(NULL)
-
-LIBRARIES = \
-	libofc.a \
-	libfc.a \
-	libsa.a \
-	libtps.a \
-	-lrt \
-	$(NULL)
-
-PROGRAM = fds
-
-include $(SRC)/make/Makefile.inc
diff --git a/usr/ofc/tools/fds/src/fds.c b/usr/ofc/tools/fds/src/fds.c
deleted file mode 100644
index a4bb6f7..0000000
--- a/usr/ofc/tools/fds/src/fds.c
+++ /dev/null
@@ -1,760 +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
- */
-
-// #define CONFIG_FDS_MTRACE               /* turn on malloc tracing */
-
-/*
- * FDS - Fabric discovery service for Fibre Channel.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/ether.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <ctype.h>
-#include <net/if.h>
-#ifdef CONFIG_FDS_MTRACE
-#include <mcheck.h>
-#endif /* CONFIG_FDS_MTRACE */
-
-#include "sa_error_inject.h"
-#include "sa_kernel.h"
-#include "sa_assert.h"
-#include "net_types.h"
-#include "sa_select.h"
-#include "sa_string.h"
-#include "sa_tcp.h"
-#include "sa_log.h"
-
-#include "fc_encaps.h"
-#include "fc_fcoe.h"
-#include "fc_fcip.h"
-#include "fc_fs.h"
-#include "fc_ns.h"
-
-#include "fc_types.h"
-#include "fc_frame.h"
-#include "fc_fcoe_sock.h"
-#include "fc_fcip_conn.h"
-#include "fc_exch.h"
-#include "fc_port.h"
-#include "fc_print.h"
-#include "fc_local_port.h"
-#include "fc_remote_port.h"
-#include "fc_sess.h"
-#include "fc_disc_targ.h"
-#include "fc_virt_fab.h"
-#include "fc_event.h"
-#include "fc_scsi_lun.h"
-
-#include "../../common/include/config.h"
-
-static int  fds_debug;
-static int  fds_debug_repeat;               /* non-zero to repeat discovery */
-static int  fds_debug_monitor;              /* non-zero to listen for RSCN */
-static char *ifname;
-static u_int vlan = 0;
-static u_int fds_quiet;
-static u_char *dest_mac;
-static u_char dest_mac_buf[6];
-static struct fc_virt_fab *fds_vf;
-static u_int fds_port_opts = FC_OPT_FCIP_NO_SFS;
-static enum fc_fh_type fds_fc4_type;        /* FC-4 type to discover */
-static u_int32_t fds_types[FC_NS_TYPES / FC_NS_BPW];
-
-static fc_wwn_t     fds_port_wwn;
-static fc_wwn_t     fds_node_wwn;
-static u_int        fds_mtu = FC_MAX_PAYLOAD + sizeof (struct fc_frame_header);
-static u_int        fds_fcp_parm = FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS;
-
-static TAILQ_HEAD(, fc_lun) fds_luns = TAILQ_HEAD_INITIALIZER(fds_luns);
-
-struct fds_state {
-    u_int           fds_sess_started;       /* sessions started */
-    u_int           fds_sess_done;          /* sessions complete */
-    u_int           fds_lun_disc_started;   /* LUN discoveries started */
-    u_int           fds_lun_disc_done;      /* LUN discoveries complete */
-    u_int           fds_lun_count;          /* LUNs counted */
-    struct fc_local_port *fds_local_port;
-};
-static struct fds_state fds_state;
-
-static void fds_local_port_event(int error, void *lp_arg);
-static void fds_disc_remote(void *lp, struct fc_remote_port *, enum fc_event);
-static void fds_lun_disc_handler(void *, struct fc_lun *);
-static void fds_sess_event(int, void *);
-static void fds_lun_report(void);
-static void fds_lun_release(struct fc_remote_port *);
-static void fds_check_done(void);
-
-static void
-fds_usage()
-{
-    fprintf(stderr, "usage: %s [-cdmqs] [-f <fcip-host>[:<port>]]\n"
-      "\t[-i <fcoe-interface>] [-e <dest-MAC-addr>]\n"
-      "\t[-l <local-ip>[:<port>]] [-t <type>[,<type>]...]\n"
-      "\t[-p <port-wwn | mac>] [-n <node-wwn | mac>]\n"
-      "\t[-M <max-payload>\n",
-      cmdname);
-    exit(1);
-}
-
-/*
- * Handle options.
- */
-static void
-fds_options(int argc, char *argv[])
-{
-    int opt;
-    u_long      type;
-    char        *endptr;
-    char        *cp;
-    extern char *optarg;
-    extern int optind, opterr, optopt;
-    struct ether_addr mac;
-    u_int64_t   oui;
-    fc_wwn_t    wwn;
-
-    cmdname = argv[0];
-
-    while ((opt = getopt(argc, argv, "cde:f:i:l:mn:p:qst:M:")) != -1) {
-        switch (opt) {
-        case 'c':
-            fds_port_opts |= FC_OPT_NO_RX_CRC | FC_OPT_NO_TX_CRC;
-            break;
-
-        case 'd':
-            if (fds_debug) {
-                fds_port_opts |= FC_OPT_DEBUG;      /* second -d flag */
-            }
-            fds_debug = 1;
-            break;
-
-        case 'e':
-            if (ether_aton_r(optarg, &mac) == NULL &&
-              ether_hostton(optarg, &mac) != 0) {
-                SA_LOG_EXIT("ethernet address %s not found", optarg);
-            }
-            memcpy(dest_mac_buf, mac.ether_addr_octet, sizeof (dest_mac_buf));
-            dest_mac = dest_mac_buf;
-            break;
-
-        case 'i':
-            ifname = optarg;
-            break;
-
-        case 'm':
-            fds_debug_monitor = 1;
-            break;
-
-        case 'M':
-            fds_mtu = strtoul(optarg, &endptr, 10);
-            if (*endptr != '\0' || fds_mtu > FC_MAX_PAYLOAD) {
-                SA_LOG("bad MTU specified.  max %d", FC_MAX_PAYLOAD);
-                fds_usage();
-            }
-            fds_mtu += sizeof (struct fc_frame_header);
-            break;
-
-        /*
-         * The -p and -n flags take a world-wide name in hex,
-         * or an ethernet addr, or an etherhost entry from /etc/ethers.
-         */
-        case 'p':
-        case 'n':
-            wwn = strtoull(optarg, &endptr, 16);
-            if (*endptr != '\0') {
-                if (ether_aton_r(optarg, &mac) == NULL &&
-                  ether_hostton(optarg, &mac) != 0) {
-                    SA_LOG_EXIT("invalid WWN or MAC addr %s", optarg);
-                }
-                oui = net48_get((net48_t *) mac.ether_addr_octet);
-                wwn = fc_wwn_from_mac(oui, opt == 'p' ? 2 : 1, 0);
-            }
-            if (opt == 'p') {
-                fds_port_wwn = wwn;
-            } else {
-                fds_node_wwn = wwn;
-            }
-            break;
-
-        case 'q':
-            fds_quiet = 1;
-            break;
-
-        case 's':
-            fds_port_opts &= ~FC_OPT_FCIP_NO_SFS;
-            break;
-
-        /*
-         * Parse a comma-separated list of types.
-         */
-        case 't':
-            for (;;) {
-                cp = strchr(optarg, ',');
-                if (cp != NULL) {
-                    *cp = '\0';
-                }
-                type = strtoul(optarg, &endptr, 10);
-                if (*endptr == '\0') {
-                    if (type >= FC_NS_TYPES) {
-                        SA_LOG_EXIT("type %s out of range", optarg);
-                    }
-                } else if (strcmp(optarg, "FCP") == 0) {
-                    type = FC_TYPE_FCP;
-                } else if (strcmp(optarg, "IP") == 0) {
-                    type = FC_TYPE_IP;
-                } else {
-                    SA_LOG_EXIT("invalid FC-4 type %s", optarg);
-                }
-                fds_types[type / FC_NS_BPW] |= 1U << (type % FC_NS_BPW);
-                if (fds_fc4_type == 0) {
-                    fds_fc4_type = type;
-                }
-                if (cp == NULL) {
-                    break;
-                }
-                *cp = ',';
-                optarg = cp + 1;
-            }
-            break;
-
-        default:
-            if (config_options_common(opt, optarg) != 0) {
-                fds_usage();                /* exits */
-            }
-            break;
-
-        case '?':
-            fds_usage();                    /* exits */
-            break;
-        }
-    }
-    config_options_common_set();
-
-    if (fds_port_wwn == 0 && fds_node_wwn != 0) {
-        fds_port_wwn = fc_wwn_from_wwn(fds_node_wwn, 2, 1);
-    } else if (fds_node_wwn == 0 && fds_port_wwn != 0) {
-        fds_node_wwn = fc_wwn_from_wwn(fds_port_wwn, 1, 0);
-    }
-}
-
-static void
-fds_recv_drop(void *arg, struct fc_frame *fp)
-{
-    fc_print_frame_hdr("fds_recv_drop - unexpected request", fp);
-    fc_frame_free(fp);
-}
-
-/*
- * Main.
- */
-int
-main(int argc, char *argv[])
-{
-    struct sa_tcp *tcp = NULL;
-    struct fc_port *port;
-    struct fc_port *inner_port;
-    struct fc_local_port *lp;
-    struct fc_virt_fab *vp;
-    int     rc;
-
-#ifdef CONFIG_FDS_MTRACE                    /* enable malloc tracing */
-    mtrace();
-#endif /* CONFIG_FDS_MTRACE */
-    fds_options(argc, argv);
-    sa_inject_init();
-
-    /*
-     * Open the port to the switch, either via FCIP or FCoE.
-     */
-    if (ifname == NULL) {
-        tcp = sa_tcp_create();
-
-        rc = sa_tcp_bind(tcp, local_addr, sizeof (struct sockaddr_in));
-        if (rc < 0) {
-            SA_LOG_ERR_EXIT(errno, "sa_tcp_bind failed");
-        }
-
-        if (fport_addr == NULL) {
-            fds_usage();
-        }
-        rc = sa_tcp_connect(tcp, fport_addr, sizeof (struct sockaddr_in));
-        if (rc < 0) {
-            SA_LOG_ERR_EXIT(errno, "sa_tcp_connect");
-        }
-
-        port = fc_fcip_create(tcp, fds_port_opts, 0, 0);
-        if (port == NULL) {
-            SA_LOG_EXIT("fc_fcip_create4 failed");
-        }
-    } else {
-        port = fc_fcoe_create(ifname, vlan, NULL, dest_mac, fds_port_opts);
-        if (port == NULL) {
-            SA_LOG_EXIT("fc_fcoe_create failed");
-        }
-    }
-
-    /*
-     * Get node and port WWNs from interface if not specified on command line.
-     */
-    if (fds_node_wwn == 0) {
-        rc = fc_port_egress_control(port, FC_PCTL_GET_WWNN,
-          &fds_node_wwn, sizeof (fds_node_wwn));
-        if (rc < 0) {
-            SA_LOG_EXIT("node WWN not specified and not provided by port");
-        }
-    }
-    if (fds_port_wwn == 0) {
-        rc = fc_port_egress_control(port, FC_PCTL_GET_WWPN,
-          &fds_port_wwn, sizeof (fds_port_wwn));
-        if (rc < 0) {
-            SA_LOG_EXIT("port WWN not specified and not provided by port");
-        }
-    }
-
-    /*
-     * Create port for incoming requests on the local port.
-     * We don't expect such requests.  Just drop anything that arrives.
-     */
-    inner_port = fc_port_alloc();
-    if (inner_port == NULL) {
-        SA_LOG_EXIT("fc_port_alloc failed");
-    }
-    if (fds_mtu > fc_port_get_max_frame_size(port)) {
-        fds_mtu = fc_port_get_max_frame_size(port);
-    }
-    fc_port_set_max_frame_size(inner_port, fds_mtu);
-    fc_port_set_ingress(inner_port, fds_recv_drop, NULL);
-    fc_port_set_egress(inner_port,
-      (int (*)(void *, struct fc_frame *)) fc_port_egress, port);
-
-    vp = fc_virt_fab_alloc(0, FC_CLASS_3, FC_VF_MIN_XID, FC_VF_MAX_XID);
-    ASSERT_NOTIMPL(vp != NULL);
-    fds_vf = vp;
-
-    /*
-     * Get the logical interface.
-     * Use the node name + a constant temporarily to make the port name.
-     * When the local port is logged into the fabric, we'll move on to creating
-     * the port_info and session structures.
-     */
-    lp = fc_local_port_create(vp, inner_port, fds_port_wwn, fds_node_wwn,
-      3000, 1);                     /* not much retry needed for display */
-    ASSERT_NOTIMPL(lp != NULL);
-
-    if (fds_fc4_type != 0) {
-        fc_local_port_set_fc4_map(lp, fds_types);
-    } else {
-        fds_fc4_type = FC_TYPE_FCP;
-    }
-    fds_state.fds_local_port = lp;
-    fc_port_set_ingress(port,
-       (void (*)(void *, struct fc_frame *)) fc_local_port_recv, lp);
-    fc_local_port_logon(lp, fds_local_port_event, lp);  /* start login */
-
-    sa_select_set_callback(fc_frame_leak_check);
-    sa_select_loop();               /* handle events */
-    fds_lun_report();               /* report on LUN discovery */
-
-    /*
-     * For debugging, repeat logon and discovery.
-     */
-    if (fds_debug_repeat) {
-        fds_debug_repeat = 0;
-        sa_log("repeating discovery as a test");
-        fc_local_port_logon(lp, fds_local_port_event, lp);  /* start login */
-        sa_select_loop();           /* handle events */
-        fds_lun_report();           /* report on LUN discovery */
-    }
-    sa_log("FDS discovery complete.  %d targets %d LUNs",
-      fds_state.fds_sess_done, fds_state.fds_lun_count);
-
-    /*
-     * Release memory.
-     * We could just exit, but we explicitly free things as a test for leaks.
-     */
-    fds_lun_release(NULL);          /* close LUNs */
-    fc_port_close_ingress(inner_port);
-    fc_port_close_egress(inner_port);
-    fc_port_close_ingress(port);
-    fc_local_port_release(lp);
-    fc_virt_fab_free(vp);
-    fc_frame_leak_check();
-    if (local_addr != NULL) {
-        free(local_addr);
-    }
-    if (fport_addr != NULL) {
-        free(fport_addr);
-    }
-    if (remote_addr != NULL) {
-        free(remote_addr);
-    }
-
-    sa_inject_stats();
-    return (0);
-}
-
-/*
- * Handle changes to the LIF state.
- * If the LIF is up, (FLOGI has completed) create sessions and start them.
- */
-static void
-fds_local_port_event(int event, void *lp_arg)
-{
-    struct fc_local_port *lp = lp_arg;
-    int     rc;
-
-    ASSERT(lp != NULL);
-    if (fds_debug) {
-        SA_LOG("event %d\n", event);
-    }
-    switch (event) {
-    case FC_EV_READY:
-        sa_log("Local port ready.   FC_ID %6.6x", fc_local_port_get_fid(lp));
-        rc = fc_disc_targ_start(lp, fds_fc4_type, fds_disc_remote, lp);
-        ASSERT(rc == 0);
-        break;
-    case FC_EV_DOWN:
-        sa_log("Local port down.");
-        break;
-    case FC_EV_CLOSED:
-        if (fds_debug_monitor == 0) {
-            sa_select_exit();
-        }
-        break;
-    }
-}
-
-/*
- * List a newly-discovered remote_port.
- * event will be either:
- *  FC_EV_START, when first added.
- *  FC_EV_READY, when a remote port is re-discovered.
- *  FC_EV_CLOSED, when a remote port is not re-discovered.
- */
-static void
-fds_list_remote(struct fc_remote_port *rp, enum fc_event event)
-{
-    static int lines;
-    char *tp;
-    char *ev;
-
-    if (fds_quiet) {
-        return;
-    }
-    switch (rp->rp_fcp_parm & (FCP_SPPF_INIT_FCN | FCP_SPPF_TARG_FCN)) {
-    case FCP_SPPF_INIT_FCN | FCP_SPPF_TARG_FCN:
-        tp = "initiator + target";
-        break;
-    case FCP_SPPF_INIT_FCN:
-        tp = "initiator";
-        break;
-    case FCP_SPPF_TARG_FCN:
-        tp = "target";
-        break;
-    default:
-        tp = "unknown";
-        break;
-    }
-    switch (event) {
-    case FC_EV_CLOSED:
-        ev = "(closed)";
-        break;
-    case FC_EV_RJT:
-        ev = "(error)";
-        break;
-    case FC_EV_READY:
-        ev = "(old)";
-        break;
-    case FC_EV_START:
-    default:
-        ev = "";
-        break;
-    }
-    if ((lines++ % 20) == 0) {
-        sa_log("%6s %18s %18s %6s %6s",
-	  "FC ID", "WWPN", "WWNN", "DL", "E_D_TOV");
-    }
-    if (rp->rp_sess != NULL) {
-        sa_log("%6.6x %18.16llx %18.16llx %6u %6u %s %s",
-          rp->rp_fid, rp->rp_port_wwn, rp->rp_node_wwn,
-          fc_sess_get_max_payload(rp->rp_sess),
-	  fc_sess_get_e_d_tov(rp->rp_sess),
-	  tp, ev);
-    } else {
-        sa_log("%10.6x %20.16llx %20.16llx %6s %s %s",
-          rp->rp_fid, rp->rp_port_wwn, rp->rp_node_wwn, "", tp, ev);
-    }
-}
-
-/*
- * Handle a newly-discovered remote_port, or the end of discovery.
- * Note that the remote port may be deallocated upon return unless
- * this routine holds it.
- *
- * event will be either:
- *  FC_EV_START, when first added.
- *  FC_EV_READY, when a remote port is re-discovered.  (not used)?
- *  FC_EV_CLOSED, when a remote port has disappeared.
- */
-static void
-fds_disc_remote(void *lp_arg, struct fc_remote_port *rp, enum fc_event event)
-{
-    struct fc_sess *sess;
-
-    if (rp == NULL) {
-        fds_check_done();
-    } else {
-        sess = rp->rp_sess;
-        switch (event) {
-        case FC_EV_READY:
-        case FC_EV_START:
-        default:
-            ASSERT(sess != NULL);
-            rp->rp_local_fcp_parm = fds_fcp_parm;
-            fc_sess_event_enq(sess, fds_sess_event, rp);
-            fc_sess_start(sess);
-            if (rp->rp_fcs_priv == NULL) {
-                rp->rp_fcs_priv = sess;     /* flag indicating sess started */
-                fds_state.fds_sess_started++;
-            }
-            break;
-        case FC_EV_RJT:
-        case FC_EV_CLOSED:
-            fds_list_remote(rp, event);
-            if (rp->rp_fcs_priv) {
-                fds_state.fds_sess_started--;
-                rp->rp_fcs_priv = NULL;
-                fds_check_done();
-            }
-            fds_lun_release(rp);            /* will release remote port */
-            break;
-        }
-    }
-}
-
-/*
- * Session event handler.
- * Note that the argument is the associated remote port for now.
- */
-static void
-fds_sess_event(int event, void *rp_arg)
-{
-    struct fc_remote_port *rp = rp_arg;
-    struct fc_sess *sess = rp->rp_sess;
-    int rc;
-
-    switch (event) {
-    case FC_EV_READY:
-        fds_list_remote(rp, FC_EV_START);
-        rp->rp_sess_ready = 1;
-        if (fds_fc4_type == FC_TYPE_FCP &&
-          (rp->rp_fcp_parm & FCP_SPPF_TARG_FCN)) {
-            rc = fc_lun_discover(sess, fds_lun_disc_handler, sess);
-            if (rc == 0) {
-                if (fds_debug) {
-                    SA_LOG("target %6x discovery started", rp->rp_fid);
-                }
-                fds_state.fds_lun_disc_started++;
-            } else {
-                sa_log_err(rc, NULL,
-                  "target %6x LUN discovery error - target skipped",
-                  rp->rp_fid);
-            }
-        }
-        fds_state.fds_sess_done++;
-        fds_check_done();
-        break;
-    case FC_EV_RJT:                     /* PLOGI, PRLI retries exhausted */
-        fds_list_remote(rp, event);
-        fds_state.fds_sess_done++;
-        fds_check_done();
-        break;
-    case FC_EV_CLOSED:                  /* finished logoff */
-        rp->rp_fcs_priv = NULL;
-        break;
-    default:
-        SA_LOG("sess to %6x event %d", fc_sess_get_did(sess), event);
-        break;
-    }
-}
-
-/*
- * LUN discovery handler.
- */
-static void
-fds_lun_disc_handler(void *sess_arg, struct fc_lun *lun)
-{
-    struct fc_sess *sess = sess_arg;
-    struct fc_lun_path *path;
-    fc_fid_t fid;
-
-    fid = fc_sess_get_did(sess);
-    if (lun != NULL) {
-        path = lun->lun_path[0];    /* XXX should match path for session */
-        ASSERT(path != NULL);
-        if (lun->lun_client_priv == NULL) {
-            lun->lun_client_priv = (void *) 1;
-            if (fds_debug) {
-                SA_LOG("target %6x lun %llx wwn %llx discovered",
-                  fid, path->lp_lun_id, lun->lun_wwlid);
-            }
-            fc_lun_hold(lun);
-            TAILQ_INSERT_TAIL(&fds_luns, lun, lun_list);
-        } else {
-            if (fds_debug) {
-                SA_LOG("target %6x lun %llx wwn %llx (old)",
-                  fid, path->lp_lun_id, lun->lun_wwlid);
-            }
-        }
-    } else {
-        if (fds_debug) {
-            SA_LOG("target %6x lun discovery complete", fid);
-        }
-        fds_state.fds_lun_disc_done++;
-        fds_check_done();
-    }
-}
-
-static void
-fds_check_done(void)
-{
-    struct fds_state *fs = &fds_state;
-
-    if (fs->fds_lun_disc_done == fs->fds_lun_disc_started &&
-      fs->fds_sess_done == fs->fds_sess_started) {
-        if (fds_debug) {
-            SA_LOG("discovery complete");
-        }
-        if (fds_debug_repeat) {
-            sa_select_exit();
-        } else if (fds_debug_monitor == 0) {
-            fc_local_port_logoff(fds_state.fds_local_port);
-        }
-    }
-}
-
-/*
- * Output report on discovery results.
- */
-static void
-fds_lun_report(void)
-{
-    struct fc_lun *lun;
-    struct fc_lun_path *path;
-    struct scsi_inquiry_std *ip;
-    int     i;
-    u_int64_t cap;
-    double  cap_abbr;
-    char    *abbr;
-    char    vendor[9];
-    char    product[17];
-    char    serial[40];
-
-    if (fds_quiet == 0) {
-        sa_log("LUN table:");
-    }
-    TAILQ_FOREACH(lun, &fds_luns, lun_list) {
-        fds_state.fds_lun_count++;
-        if (fds_quiet) {
-            continue;
-        }
-        for (i = 0; i < FC_LUN_PATHS; i++) {
-            path = lun->lun_path[i];
-            if (path != NULL) {
-                ip = &lun->lun_inq_std;
-                sa_strncpy_safe(vendor, sizeof (vendor),
-                  ip->is_vendor_id, sizeof (ip->is_vendor_id));
-                sa_strncpy_safe(product, sizeof (product),
-                  ip->is_product, sizeof (ip->is_product));
-                sa_strncpy_safe(serial, sizeof (serial),
-                  lun->lun_serial, sizeof (lun->lun_serial));
-
-                if ((path->lp_lun_id & 0xf000ffffffffffffULL) == 0) {
-                    sa_log("Target %6x LUN %lld",
-                      fc_lun_path_get_did(path), path->lp_lun_id >> 48);
-                } else {
-                    sa_log("Target %6x LUN %llx",
-                      fc_lun_path_get_did(path), path->lp_lun_id);
-                }
-                sa_log("        WWLID:   %16llx", lun->lun_wwlid);
-                sa_log("        Vendor:  %s %s %s", vendor, product, serial);
-                sa_log("        Block size:  %d", lun->lun_block_len);
-                cap = lun->lun_capacity * lun->lun_block_len;
-                cap_abbr = cap / (1024.0 * 1024.0);
-                abbr = "MB";
-                if (cap_abbr >= 1024) {
-                    cap_abbr /= 1024.0;
-                    abbr = "GB";
-                }
-                if (cap_abbr >= 1024) {
-                    cap_abbr /= 1024.0;
-                    abbr = "TB";
-                }
-                if (cap_abbr >= 1024) {
-                    cap_abbr /= 1024.0;
-                    abbr = "PB";
-                }
-                sa_log("        Capacity:  %lld blocks (%lld bytes) (%0.2f %s)",
-                  lun->lun_capacity, cap, cap_abbr, abbr);
-            }
-        }
-    }
-}
-
-/*
- * Free FC LUNs, LUN paths, and other data structures held by discovery
- * If rp is non-NULL, remove only LUN paths using the specified remote port.
- */
-static void
-fds_lun_release(struct fc_remote_port *rp)
-{
-    struct fc_lun *lun;
-    struct fc_lun *next;
-    struct fc_lun_path *path;
-    int     i;
-    int     path_count;
-
-    for (lun = TAILQ_FIRST(&fds_luns); lun != NULL; lun = next) {
-        next = TAILQ_NEXT(lun, lun_list);
-        path_count = 0;
-        for (i = 0; i < FC_LUN_PATHS; i++) {
-            path = lun->lun_path[i];
-            if (path != NULL) {
-                if (rp == NULL ||
-                  rp == fc_sess_get_remote_port(path->lp_sess)) {
-                    lun->lun_path[i] = NULL;
-                    fc_lun_path_delete(path);           /* releases LUN */
-                } else {
-                    path_count++;
-                }
-            }
-        }
-        if (path_count == 0) {
-            TAILQ_REMOVE(&fds_luns, lun, lun_list);
-            fc_lun_release(lun);
-        }
-    }
-}




More information about the devel mailing list