File fcoe-utils-beta1-update of Package open-fcoe

From c3777607d9721d439d23fa51547744f3eb8a275b Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 4 Dec 2009 11:49:10 +0100
Subject: [PATCH] Update fcoe userspace programs

This patchset is an update for the fcoe userspace programs.
Should be avialable from the main git repository shortly.

References: bnc#557495,FATE306854

Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/etc/initd/initd.fedora b/etc/initd/initd.fedora
index 629fc76..7107566 100755
--- a/etc/initd/initd.fedora
+++ b/etc/initd/initd.fedora
@@ -148,42 +148,7 @@ service_start()
 	modprobe -q libfc
 	modprobe -q fcoe
 
-	HAS_DCB_IF="false"
-	for ifcfg_file in `ls $CONFIG_DIR/cfg-eth*`
-	do
-		ifname=`basename $ifcfg_file | cut -d"-" -f2`
-		. $ifcfg_file
-		[ "$FCOE_ENABLE" != "yes" ] &&
-		[ "$FCOE_ENABLE" != "YES" ] && continue
-
-		if [ "$DCB_REQUIRED" != "yes" ] &&
-		   [ "$DCB_REQUIRED" != "YES" ]; then
-			#
-			# DCB is not required, we nee to validate the
-			# link flow control of the Ethernet port
-			#
-			validate_link_flow_control $ifname
-			[ $? -ne 0 ] && continue
-			#
-			# Create the FCoE interface
-			#
-			$FCOEADM -c $ifname
-		else
-			#
-			# Configure the DCB for the Ethernet
-			# port if DCB is required
-			#
-			HAS_DCB_IF="true"
-		fi
-	done
-
-	#
-	# If DCB-required Ethernet port exists, then start the fcoemon
-	# daemon to create the FCoE interfaces for these ports.
-	#
-	if [ "$HAS_DCB_IF" = "true" ]; then
-	    daemon --pidfile ${PID_FILE} ${FCOEMON} ${FCOEMON_OPTS}
-	fi
+	daemon --pidfile ${PID_FILE} ${FCOEMON} ${FCOEMON_OPTS}
 
 	return
 }
diff --git a/fcoemon.c b/fcoemon.c
index 96c59e6..8e3980b 100644
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -38,12 +38,14 @@
 #include <sys/queue.h>
 #include <sys/un.h>
 #include <sys/wait.h>
+#include <sys/ioctl.h>
 #include <linux/sockios.h>
 #include <linux/if.h>
 #include <linux/if_arp.h>
 #include <linux/netlink.h>
 #include <linux/rtnetlink.h>
 #include <linux/ethtool.h>
+#include <linux/if_vlan.h>
 
 #include <dcbd/dcb_types.h>
 #include <dcbd/dcbtool.h>	/* for typedef cmd_status */
@@ -74,32 +76,40 @@
 #define CLIF_NAME_PATH          _PATH_VARRUN "dcbd/clif"
 #define CLIF_PID_FILE           _PATH_VARRUN "fcoemon.pid"
 #define CLIF_LOCAL_SUN_PATH     _PATH_TMP "fcoemon.dcbd.%d"
-#define FCM_DCBD_TIMEOUT_USEC   (10 * 1000 * 1000)	/* 10 seconds */
-#define FCM_EVENT_TIMEOUT_USEC  (500 * 1000)		/* half a second */
+#define DCBD_CONNECT_TIMEOUT    (10 * 1000 * 1000)	/* 10 seconds */
+#define DCBD_CONNECT_RETRY_TIMEOUT   (1 * 1000 * 1000)	/* 1 seconds */
+#define DCBD_REQ_RETRY_TIMEOUT  (200 * 1000)            /* 0.2 seconds */
+#define DCBD_MAX_REQ_RETRIES    10
 #define FCM_PING_REQ_LEN	1 /* byte-length of dcbd PING request */
 #define FCM_PING_RSP_LEN	8 /* byte-length of dcbd PING response */
 
 static char *fcoemon_version =						\
-	"fcoemon v1.0.7\n Copyright (c) 2009, Intel Corporation.\n";
+	"fcoemon v1.0.8\n Copyright (c) 2009, Intel Corporation.\n";
 
 /*
  * fcoe service configuration data
  * Note: These information are read in from the fcoe service
  *       files in CONFIG_DIR
  */
-struct fcoe_port_config {
-	struct fcoe_port_config *next;
-	char ifname[IFNAMSIZ];
+struct fcoe_port {
+	struct fcoe_port *next;
+
+	/* information from fcoe configuration files in CONFIG_DIR */
+	char ifname[IFNAMSIZ];       /* netif on which fcoe i/f is created */
+	char real_ifname[IFNAMSIZ];  /* underlying net ifname - e.g. if ifname
+					is a VLAN */
 	int fcoe_enable;
 	int dcb_required;
-	int dcb_app_0_enable;
-	int dcb_app_0_willing;
+
+	/* following track data required to manage FCoE interface state */
+	u_int32_t action;      /* current state */
+	u_int32_t last_action; /* last action */
+	int last_msg_type;     /* last rtnetlink msg type received on if name */
 };
 
-enum fcoeadm_action {
-	ADM_DESTROY = 0,
-	ADM_CREATE,
-	ADM_RESET
+enum fcoeport_ifname {
+	FCP_CFG_IFNAME = 0,
+	FCP_REAL_IFNAME
 };
 
 static u_int8_t fcm_def_qos_mask = FCM_DEFAULT_QOS_MASK;
@@ -109,17 +119,15 @@ struct clif;			/* for dcbtool.h only */
 /*
  * Interact with DCB daemon.
  */
-static void fcm_event_timeout(void *);
 static void fcm_dcbd_timeout(void *);
+static void fcm_dcbd_retry_timeout(void *);
 static void fcm_dcbd_disconnect(void);
-static void fcm_dcbd_request(char *);
+static int fcm_dcbd_request(char *);
 static void fcm_dcbd_rx(void *);
-static void fcm_dcbd_ex(void *);
-static void fcm_dcbd_next(void);
 static void fcm_dcbd_event(char *, size_t);
 static void fcm_dcbd_cmd_resp(char *, cmd_status);
-static void fcm_dcbd_port_advance(struct fcm_fcoe *);
-static void fcm_dcbd_setup(struct fcm_fcoe *, enum fcoeadm_action);
+static void fcm_netif_advance(struct fcm_netif *);
+static void fcm_fcoe_action(struct fcm_netif *, struct fcoe_port *);
 
 struct fcm_clif {
 	int cl_fd;
@@ -137,13 +145,14 @@ char *fcm_dcbd_cmd = CONFIG_DIR "/scripts/fcoeplumb";
 /* Debugging routine */
 static void print_errors(char *buf, int errors);
 
-struct fcm_fcoe_head fcm_fcoe_head = TAILQ_HEAD_INITIALIZER(fcm_fcoe_head);
+struct fcm_netif_head fcm_netif_head = TAILQ_HEAD_INITIALIZER(fcm_netif_head);
 
 static int fcm_link_socket;
 static int fcm_link_seq;
 static void fcm_link_recv(void *);
 static void fcm_link_getlink(void);
 static int fcm_link_buf_check(size_t);
+static void clear_dcbd_info(struct fcm_netif *ff);
 
 /*
  * Table for getopt_long(3).
@@ -260,8 +269,8 @@ static int fcm_read_config_files(void)
 	char val[CONFIG_MAX_VAL_LEN + 1];
 	DIR *dir;
 	struct dirent *dp;
-	struct fcoe_port_config *curr;
-	struct fcoe_port_config *next;
+	struct fcoe_port *curr;
+	struct fcoe_port *next;
 	int rc;
 
 	dir = opendir(CONFIG_DIR);
@@ -280,63 +289,110 @@ static int fcm_read_config_files(void)
 		rc = strncmp(dp->d_name, "cfg-", strlen("cfg-"));
 		if (rc)
 			continue;
-		next = (struct fcoe_port_config *)
-			calloc(1, sizeof(struct fcoe_port_config));
-		if (!fcoe_config.port) {
-			fcoe_config.port = next;
-			curr = next;
-		} else {
-			curr->next = next;
-			curr = next;
+		next = (struct fcoe_port *)
+			calloc(1, sizeof(struct fcoe_port));
+
+		if (!next) {
+			FCM_LOG_ERR(errno, "failed to allocate fcoe_port %s",
+				dp->d_name);
+			continue;
 		}
-		strncpy(curr->ifname, dp->d_name + 4, sizeof(curr->ifname));
+		strncpy(next->ifname, dp->d_name + 4, sizeof(next->ifname));
 		strncpy(file, CONFIG_DIR "/", sizeof(file));
 		strncat(file, dp->d_name, sizeof(file) - strlen(file));
 		fp = fopen(file, "r");
 		if (!fp) {
-			FCM_LOG_ERR(errno, "Failed reading %s\n", file);
-			exit(1);
+			FCM_LOG_ERR(errno, "Failed to read %s\n", file);
+			free(next);
+			continue;
 		}
 
+		next->action = FCP_WAIT;
+
 		/* FCOE_ENABLE */
 		rc = fcm_read_config_variable(file, val, sizeof(val),
 					      fp, "FCOE_ENABLE");
 		if (rc < 0) {
 			fclose(fp);
-			return -1;
+			free(next);
+			continue;
 		}
 		/* if not found, default to "no" */
 		if (!strncasecmp(val, "yes", 3) && rc == 1)
-			curr->fcoe_enable = 1;
+			next->fcoe_enable = 1;
 
 		/* DCB_REQUIRED */
 		rc = fcm_read_config_variable(file, val, sizeof(val),
 					      fp, "DCB_REQUIRED");
 		if (rc < 0) {
 			fclose(fp);
-			return -1;
+			free(next);
+			continue;
 		}
 		/* if not found, default to "no" */
 		if (!strncasecmp(val, "yes", 3) && rc == 1) {
-			curr->dcb_required = 1;
-			curr->dcb_app_0_enable = DCB_APP_0_DEFAULT_ENABLE;
-			curr->dcb_app_0_willing = DCB_APP_0_DEFAULT_WILLING;
+			next->dcb_required = 1;
 		}
 
 		fclose(fp);
+
+		if (!fcoe_config.port) {
+			fcoe_config.port = next;
+			curr = next;
+		} else {
+			curr->next = next;
+			curr = next;
+		}
 	}
 	closedir(dir);
 	return 0;
 }
 
-static struct fcoe_port_config *fcm_find_port_config(char *ifname)
+/*
+ * Given an fcoe_port pointer and an ifname, find the next fcoe_port
+ * in the list with a real ifname of 'ifname'.
+ *
+ * Returns:  fcoe_port pointer to fcoe port entry
+ *           NULL - if not found
+ */
+static struct fcoe_port *fcm_find_next_fcoe_port(struct fcoe_port *p,
+						char *ifname)
 {
-	struct fcoe_port_config *p;
+	struct fcoe_port *np;
+
+	np = fcoe_config.port;
+	while (np) {
+		if (np == p)
+			break;
+		np = np->next;
+	}
+
+	if (np)
+		np = np->next;
+
+	while (np) {
+		if (!strncmp(ifname, np->real_ifname, IFNAMSIZ))
+			return np;
+		np = np->next;
+	}
+
+	return NULL;
+}
+
+static struct fcoe_port *fcm_find_fcoe_port(char *ifname,
+						enum fcoeport_ifname t)
+{
+	struct fcoe_port *p;
+	char *fp_ifname;
 
 	p = fcoe_config.port;
 	while (p) {
-		if (!strncmp(ifname, p->ifname, IFNAMSIZ) &&
-		    p->fcoe_enable && p->dcb_required)
+		if (t == FCP_CFG_IFNAME)
+			fp_ifname = p->ifname;
+		else
+			fp_ifname = p->real_ifname;
+
+		if (!strncmp(ifname, fp_ifname, IFNAMSIZ))
 			return p;
 		p = p->next;
 	}
@@ -377,73 +433,33 @@ static int fcm_link_init(void)
 }
 
 
-/* fcm_read_vlan - parse file for "Device" string
- * @val_buf - copy string to val_buf
- * @len - length of val_buf buffer
- * @fp - file pointer to parse
- */
-static void read_vlan(char *val_buf, size_t len,  FILE *fp)
-{
-	char *s;
-	char buf[FILE_NAME_LEN];
-
-	val_buf[0] = '\0';
-	buf[sizeof(buf) - 1] = '\0';
-	while ((s = fgets(buf, sizeof(buf) - 1, fp)) != NULL) {
-		while (isspace(*s))
-			s++;
-
-		if (*s == '\0' || *s == '#')
-			continue;
-
-		s = strstr(s, "Device:");
-		if (s == NULL)
-			continue;
-
-		while (!isspace(*s))
-			s++;
-
-		while (isspace(*s))
-			s++;
-
-		s = strncpy(val_buf, s, len);
-		while (isalnum(*s))
-			s++;
-
-		*s = '\0';
-		return;
-	}
-}
-
-
-
-
-/* fcm_vlan_dev_real_dev - parse vlan real_dev from /proc
- * @vlan_dev - vlan_dev to find real interface name for
- * @real_dev - pointer to copy real_dev to
+/* fcm_vlan_dev_real_dev - query vlan real_dev
+ * @vlan_ifname - vlan device ifname to find real interface name for
+ * @real_ifname - pointer to copy real ifname to
  *
- * This parses the /proc/net/vlan/ directory for the vlan_dev.
- * If the file exists it will parse for the real device and
- * copy it to real_dev parameter.
+ * Make an ioctl call to find the real device for vlan_ifname.
+ * Copy to real_ifname if found.
  */
 static void fcm_vlan_dev_real_dev(char *vlan_ifname, char *real_ifname)
 {
-	FILE *fp;
-	char  file[80];
+	int fd;
+	struct vlan_ioctl_args ifv;
 
-	if (opendir(VLAN_DIR)) {
-		strncpy(file, VLAN_DIR "/", sizeof(file));
-		strncat(file, vlan_ifname, sizeof(file) - strlen(file));
+	real_ifname[0] = '\0';
 
-		fp = fopen(file, "r");
-		if (fp) {
-			read_vlan(real_ifname, sizeof(real_ifname), fp);
-			fclose(fp);
-			return;
-		}
+	fd = socket(PF_INET, SOCK_DGRAM, 0);
+
+	if (fd <= 0) {
+		FCM_LOG_ERR(errno, "open vlan query socket error");
+		return;
 	}
 
-	strncpy(real_ifname, vlan_ifname, sizeof(real_ifname));
+	memset(&ifv, 0, sizeof(ifv));
+	ifv.cmd = GET_VLAN_REALDEV_NAME_CMD;
+	strncpy(ifv.device1, vlan_ifname, strlen(vlan_ifname)+1);
+	if (ioctl(fd, SIOCGIFVLAN, &ifv) == 0)
+		strncpy(real_ifname, ifv.u.device2, strlen(ifv.u.device2)+1);
+	close(fd);
 }
 
 /* fcm_is_linkinfo_vlan - parse nlmsg linkinfo rtattr for vlan kind
@@ -472,11 +488,27 @@ int fcm_is_linkinfo_vlan(struct rtattr *ap)
 	return 0;
 }
 
+static void fcp_action_set(char *ifname, enum fcp_action action)
+{
+	struct fcoe_port *p;
+
+	p = fcm_find_fcoe_port(ifname, FCP_REAL_IFNAME);
+	while (p) {
+		p->action = action;
+		p = fcm_find_next_fcoe_port(p, ifname);
+	}
+}
+
 static struct sa_nameval fcm_dcbd_states[] = FCM_DCBD_STATES;
 
-static void fcm_dcbd_state_set(struct fcm_fcoe *ff,
+static void fcm_dcbd_state_set(struct fcm_netif *ff,
 			       enum fcm_dcbd_state new_state)
 {
+	if (ff->ff_operstate != IF_OPER_UP) {
+		ff->ff_dcbd_state = FCD_INIT;
+		return;
+	}
+
 	if (fcoe_config.debug) {
 		char old[32];
 		char new[32];
@@ -488,19 +520,39 @@ static void fcm_dcbd_state_set(struct fcm_fcoe *ff,
 				sa_enum_decode(new, sizeof(new),
 					       fcm_dcbd_states, new_state));
 	}
+
+	if (new_state == FCD_GET_DCB_STATE)
+		clear_dcbd_info(ff);
+
+	if (new_state == FCD_INIT) {
+		ff->dcbd_retry_cnt = 0;
+		sa_timer_cancel(&ff->dcbd_retry_timer);
+	}
+
+	if (new_state == FCD_ERROR) {
+		ff->dcbd_retry_cnt++;
+		FCM_LOG_DEV_DBG(ff, "%s: SETTING dcbd RETRY TIMER  = %d\n",
+			ff->ifname,
+			ff->dcbd_retry_cnt * DCBD_REQ_RETRY_TIMEOUT);
+		sa_timer_set(&ff->dcbd_retry_timer,
+			ff->dcbd_retry_cnt * DCBD_REQ_RETRY_TIMEOUT);
+	}
+
 	ff->ff_dcbd_state = new_state;
+	ff->response_pending = 0;
 }
 
-void fcm_parse_link_msg(struct ifinfomsg *ip, int len)
+void fcm_process_link_msg(struct ifinfomsg *ip, int len, unsigned type)
 {
-	struct fcm_fcoe *ff;
-	struct fcm_vfcoe *fv;
+	struct fcoe_port *p;
+	struct fcm_netif *ff = NULL;
 	struct rtattr *ap;
 	char ifname[IFNAMSIZ];
 	char real_dev[IFNAMSIZ];
 	u_int8_t operstate;
 	u_int64_t mac;
 	int is_vlan;
+	int dcb_required_cnt;
 
 	mac = is_vlan = 0;
 	operstate = IF_OPER_UNKNOWN;
@@ -529,11 +581,8 @@ void fcm_parse_link_msg(struct ifinfomsg *ip, int len)
 			break;
 
 		case IFLA_LINKINFO:
-			if (!fcm_is_linkinfo_vlan(ap))
-				break;
-			fcm_vlan_dev_real_dev(ifname, real_dev);
-			is_vlan = 1;
-			FCM_LOG_DBG("vlan ifname %s:%s", real_dev, ifname);
+			if (fcm_is_linkinfo_vlan(ap))
+				is_vlan = 1;
 			break;
 
 		default:
@@ -541,30 +590,113 @@ void fcm_parse_link_msg(struct ifinfomsg *ip, int len)
 		}
 	}
 
+	p = fcm_find_fcoe_port(ifname, FCP_CFG_IFNAME);
 	if (is_vlan) {
-		fv = fcm_vfcoe_lookup_create_ifname(ifname, real_dev);
-		if (!fv)
-			return;
-		ff = fcm_fcoe_lookup_name(real_dev);
-		fv->fv_active = 1;
-	} else {
-		ff = fcm_fcoe_lookup_create_ifname(ifname);
-		if (!ff)
+		/* if not in fcoe port list, then ignore this ifname */
+		if (!p)
 			return;
-		ff->ff_active = 1;
-	}
 
-	/* Set FCD_INIT when netif is enabled */
-	if (!(ff->ff_flags & IFF_LOWER_UP) && (ip->ifi_flags & IFF_LOWER_UP))
-		fcm_dcbd_state_set(ff, FCD_INIT);
+		/* try to find the real device name */
+		real_dev[0] = '\0';
+		if (type != RTM_DELLINK) {
+			fcm_vlan_dev_real_dev(ifname, real_dev);
+			if (strlen(real_dev)) {
+				strncpy(p->real_ifname, real_dev,
+					strlen(real_dev)+1);
+				ff = fcm_netif_lookup_create(real_dev);
+				if (!ff)
+					return;
+			}
 
-	/* Set FCD_ERROR when netif is disabled */
-	if ((ff->ff_flags & IFF_LOWER_UP) && !(ip->ifi_flags & IFF_LOWER_UP))
-		fcm_dcbd_state_set(ff, FCD_ERROR);
+			if (operstate == IF_OPER_UP) {
+				/* if ff was just created, initialize
+				 * operstate to the value of the VLAN
+				 * interface.  Since the VLAN interface
+				 * is up, the underlying real interface
+				 * should be up too.
+				*/
+				if (ff->ff_operstate == IF_OPER_UNKNOWN)
+					ff->ff_operstate = operstate;
+
+				if (p->fcoe_enable) {
+					if (p->dcb_required)
+						fcm_dcbd_state_set(ff,
+							FCD_GET_DCB_STATE);
+					else
+						p->action = FCP_CREATE_IF;
+				}
+
+			}
+			if (!p->fcoe_enable)
+				p->action = FCP_DESTROY_IF;
+		} else {
+			p->action = FCP_DESTROY_IF;
+		}
+		p->last_msg_type = type;
+	} else {
+		/* there is an fcoe port configured to use this real netif.
+		 * make sure structures are up to date.
+		*/
+		if (p && type != RTM_DELLINK) {
+			strncpy(p->real_ifname, ifname, strlen(ifname)+1);
+			ff = fcm_netif_lookup_create(ifname);
+			if (!ff)
+				return;
+			ff->ff_operstate = operstate;
+			if (p->fcoe_enable) {
+				if (!p->dcb_required && operstate == IF_OPER_UP)
+					p->action = FCP_CREATE_IF;
+				if (p->dcb_required && operstate != IF_OPER_UP)
+					fcm_dcbd_state_set(ff, FCD_INIT);
+			} else {
+				p->action = FCP_DESTROY_IF;
+			}
+		} else if (p && type == RTM_DELLINK) {
+			p->action = FCP_DESTROY_IF;
+		} else if (p && !p->fcoe_enable) {
+			p->action = FCP_DESTROY_IF;
+		}
 
-	ff->ff_flags = ip->ifi_flags;
-	ff->ff_mac = mac;
-	ff->ff_operstate = operstate;
+		if (!ff)
+			ff = fcm_netif_lookup(ifname);
+		if (ff)
+			ff->ff_operstate = operstate;
+
+		/* scan for all fcoe port's which use this netif as a
+		 * real netif.
+		*/
+		p = fcm_find_fcoe_port(ifname, FCP_REAL_IFNAME);
+		dcb_required_cnt = 0;
+		while (p) {
+			ff = fcm_netif_lookup_create(ifname);
+			if (!ff)
+				break;
+			ff->ff_operstate = operstate;
+
+			if (p->fcoe_enable && p->last_msg_type != RTM_DELLINK) {
+				if (operstate == IF_OPER_UP) {
+					if (p->dcb_required) {
+						fcm_dcbd_state_set(ff,
+							FCD_GET_DCB_STATE);
+						dcb_required_cnt++;
+					} else if (!dcb_required_cnt) {
+						fcm_dcbd_state_set(ff,
+							FCD_INIT);
+					}
+				} else {
+					if (p->dcb_required)
+						fcm_dcbd_state_set(ff,
+							FCD_INIT);
+					if (type == RTM_DELLINK)
+						p->action = FCP_DESTROY_IF;
+				}
+			} else {
+				p->action = FCP_DESTROY_IF;
+			}
+
+			p = fcm_find_next_fcoe_port(p, ifname);
+		}
+	}
 }
 
 static void fcm_link_recv(void *arg)
@@ -615,10 +747,10 @@ static void fcm_link_recv(void *arg)
 		case RTM_NEWLINK:
 		case RTM_DELLINK:
 		case RTM_GETLINK:
-			FCM_LOG_DBG("Link event: %d flags %05X index %d\n",
+			FCM_LOG_DBG("Link event: %d flags %05X index %d ",
 				    type, ip->ifi_flags, ip->ifi_index);
 
-			fcm_parse_link_msg(ip, plen);
+			fcm_process_link_msg(ip, plen, type);
 			break;
 
 		default:
@@ -671,11 +803,14 @@ static int fcm_link_buf_check(size_t read_len)
 			fcm_link_buf = buf;
 			fcm_link_buf_size = len;
 			return 1;
+		} else {
+			FCM_LOG_ERR(errno, "failed to allocate link buffer");
 		}
 	}
 	return 0;
 }
 
+
 static void fcm_fcoe_init(void)
 {
 	if (fcm_read_config_files())
@@ -683,139 +818,61 @@ static void fcm_fcoe_init(void)
 }
 
 /*
- * Allocate a virtual FCoE interface state structure.
- */
-static struct fcm_vfcoe *fcm_vfcoe_alloc(struct fcm_fcoe *ff)
-{
-	struct fcm_vfcoe *fv;
-
-	fv = calloc(1, sizeof(*fv));
-	if (fv)
-		TAILQ_INSERT_TAIL(&ff->ff_vfcoe_head, fv, fv_list);
-	return fv;
-}
-/*
  * Allocate an FCoE interface state structure.
  */
-static struct fcm_fcoe *fcm_fcoe_alloc(void)
+static struct fcm_netif *fcm_netif_alloc(void)
 {
-	struct fcm_fcoe *ff;
+	struct fcm_netif *ff;
 
 	ff = calloc(1, sizeof(*ff));
 	if (ff) {
 		ff->ff_qos_mask = fcm_def_qos_mask;
-		ff->ff_ifindex = ~0;
 		ff->ff_operstate = IF_OPER_UNKNOWN;
-		TAILQ_INSERT_TAIL(&fcm_fcoe_head, ff, ff_list);
-		TAILQ_INIT(&(ff->ff_vfcoe_head));
+		TAILQ_INSERT_TAIL(&fcm_netif_head, ff, ff_list);
+	} else {
+		FCM_LOG_ERR(errno, "failed to allocate fcm_netif");
 	}
 	return ff;
 }
 
 /*
- * Find a virtual FCoE interface by ifname
- */
-static struct fcm_vfcoe *fcm_vfcoe_lookup_create_ifname(char *ifname,
-							char *real_name)
-{
-	struct fcm_fcoe *ff;
-	struct fcm_vfcoe *fv;
-	struct fcoe_port_config *p;
-
-	p = fcm_find_port_config(ifname);
-	if (!p)
-		return NULL;
-
-	ff = fcm_fcoe_lookup_name(real_name);
-	if (!ff) {
-		ff = fcm_fcoe_alloc();
-		if (!ff)
-			return NULL;
-		fcm_fcoe_set_name(ff, real_name);
-		ff->ff_app_info.enable = DCB_APP_0_DEFAULT_ENABLE;
-		ff->ff_app_info.willing = DCB_APP_0_DEFAULT_WILLING;
-		ff->ff_pfc_saved.u.pfcup = 0xffff;
-		sa_timer_init(&ff->ff_event_timer, fcm_event_timeout, ff);
-	}
-
-	fv = fcm_vfcoe_lookup_name(ff, ifname);
-	if (fv)
-		return fv;
-
-	fv = fcm_vfcoe_alloc(ff);
-	if (!fv) {
-		TAILQ_REMOVE(&fcm_fcoe_head, ff, ff_list);
-		free(ff);
-		return NULL;
-	}
-
-	snprintf(fv->fv_name, sizeof(fv->fv_name), "%s", ifname);
-	return fv;
-}
-
-/*
- * Find an FCoE interface by ifindex.
+ * Find or create an FCoE network interface by ifname.
  * @ifname - interface name to create
- * @check - check for port config file before creating
  *
- * This create a fcoe interface structure with interface name,
- * or if one already exists returns the existing one.  If check
- * is set it verifies the ifname has a valid config file before
- * creating interface
+ * This creates a netif interface structure with interface name,
+ * or if one already exists returns the existing one.
  */
-static struct fcm_fcoe *fcm_fcoe_lookup_create_ifname(char *ifname)
+static struct fcm_netif *fcm_netif_lookup_create(char *ifname)
 {
-	struct fcm_fcoe *ff;
-	struct fcoe_port_config *p;
-
-	p = fcm_find_port_config(ifname);
-	if (!p)
-		return NULL;
+	struct fcm_netif *ff;
 
-	TAILQ_FOREACH(ff, &fcm_fcoe_head, ff_list) {
-		if (!strncmp(ifname, ff->ff_name, IFNAMSIZ))
+	TAILQ_FOREACH(ff, &fcm_netif_head, ff_list) {
+		if (!strncmp(ifname, ff->ifname, IFNAMSIZ))
 			return ff;
 	}
 
-	ff = fcm_fcoe_alloc();
+	ff = fcm_netif_alloc();
 	if (ff != NULL) {
-		fcm_fcoe_set_name(ff, ifname);
-		ff->ff_pfc_saved.u.pfcup = 0xffff;
-		sa_timer_init(&ff->ff_event_timer, fcm_event_timeout, ff);
+		snprintf(ff->ifname, sizeof(ff->ifname), "%s", ifname);
+		sa_timer_init(&ff->dcbd_retry_timer, fcm_dcbd_retry_timeout,
+			(void *)ff);
+		FCM_LOG_DEV_DBG(ff, "Monitoring port %s\n", ifname);
 	}
 
-	FCM_LOG_DEV_DBG(ff, "Monitoring port %s\n", ifname);
 	return ff;
 }
 
 /*
- * Find an virtual FCoE interface by name.
- */
-static struct fcm_vfcoe *fcm_vfcoe_lookup_name(struct fcm_fcoe *ff, char *name)
-{
-	struct fcm_vfcoe *fv, *curr;
-
-	TAILQ_FOREACH(curr, &(ff->ff_vfcoe_head), fv_list) {
-		if (!strncmp(curr->fv_name, name, sizeof(name))) {
-			fv = curr;
-			break;
-		}
-	}
-
-	return fv;
-}
-
-/*
  * Find an FCoE interface by name.
  */
-static struct fcm_fcoe *fcm_fcoe_lookup_name(char *name)
+static struct fcm_netif *fcm_netif_lookup(char *ifname)
 {
-	struct fcm_fcoe *ff, *curr;
+	struct fcm_netif *ff, *curr;
 
 	ff = NULL;
 
-	TAILQ_FOREACH(curr, &fcm_fcoe_head, ff_list) {
-		if (strcmp(curr->ff_name, name) == 0) {
+	TAILQ_FOREACH(curr, &fcm_netif_head, ff_list) {
+		if (strcmp(curr->ifname, ifname) == 0) {
 			ff = curr;
 			break;
 		}
@@ -824,53 +881,6 @@ static struct fcm_fcoe *fcm_fcoe_lookup_name(char *name)
 	return ff;
 }
 
-static void fcm_fcoe_get_dcb_settings(struct fcm_fcoe *ff)
-{
-	struct fcoe_port_config *p;
-	struct fcm_vfcoe *fv;
-
-	if (ff->ff_mac == 0)
-		return;		/* loopback or other non-eligible interface */
-
-	/*
-	 * Get DCB config from file if possible.
-	 */
-	p = fcoe_config.port;
-	while (p) {
-		if (!strncmp(ff->ff_name, p->ifname, IFNAMSIZ)) {
-			ff->ff_app_info.enable = p->dcb_app_0_enable;
-			ff->ff_app_info.willing = p->dcb_app_0_willing;
-			break;
-		}
-
-		TAILQ_FOREACH(fv, &(ff->ff_vfcoe_head), fv_list) {
-			if (!strncmp(fv->fv_name, p->ifname, IFNAMSIZ)) {
-				ff->ff_app_info.enable = p->dcb_app_0_enable;
-				ff->ff_app_info.willing = p->dcb_app_0_willing;
-				break;
-			}
-		}
-
-		p = p->next;
-	}
-}
-
-static void fcm_fcoe_set_name(struct fcm_fcoe *ff, char *ifname)
-{
-	char *cp;
-	int vlan;
-
-	snprintf(ff->ff_name, sizeof(ff->ff_name), "%s", ifname);
-	vlan = -1;
-	cp = strchr(ff->ff_name, '.');
-	if (cp != NULL) {
-		vlan = atoi(cp + 1);
-		if (vlan < 0 || vlan > 4095)
-			vlan = 0;
-	}
-	ff->ff_vlan = vlan;
-}
-
 static void fcm_dcbd_init()
 {
 	fcm_clif->cl_fd = -1;	/* not connected */
@@ -916,35 +926,11 @@ static int fcm_dcbd_connect(void)
 		return 0;
 	}
 	fcm_clif->cl_fd = fd;
-	sa_select_add_fd(fd, fcm_dcbd_rx, NULL, fcm_dcbd_ex, fcm_clif);
+	sa_select_add_fd(fd, fcm_dcbd_rx, NULL, NULL, fcm_clif);
 	FCM_LOG_DBG("connected to dcbd");
 	return 1;
 }
 
-static int is_query_in_progress(void)
-{
-	struct fcm_fcoe *ff;
-
-	TAILQ_FOREACH(ff, &fcm_fcoe_head, ff_list) {
-		if (ff->ff_dcbd_state >= FCD_GET_DCB_STATE &&
-		    ff->ff_dcbd_state < FCD_DONE)
-			return 1;
-	}
-	return 0;
-}
-
-static void fcm_fcoe_config_reset(void)
-{
-	struct fcm_fcoe *ff;
-
-	TAILQ_FOREACH(ff, &fcm_fcoe_head, ff_list) {
-		fcm_dcbd_setup(ff, ADM_DESTROY);
-		ff->ff_qos_mask = fcm_def_qos_mask;
-		ff->ff_pfc_saved.u.pfcup = 0xffff;
-		FCM_LOG_DEV_DBG(ff, "Port config reset\n");
-	}
-}
-
 static void fcm_dcbd_timeout(void *arg)
 {
 	if (fcm_clif->cl_ping_pending > 0) {
@@ -954,13 +940,24 @@ static void fcm_dcbd_timeout(void *arg)
 	if (fcm_clif->cl_fd < 0) {
 		if (fcm_dcbd_connect())
 			fcm_dcbd_request("A");	/* ATTACH_CMD: for events */
+		else
+			sa_timer_set(&fcm_dcbd_timer, DCBD_CONNECT_TIMEOUT);
 	} else {
-		if (!is_query_in_progress()) {
-			fcm_clif->cl_ping_pending++;
-			fcm_dcbd_request("P");	/* ping to verify connection */
-		}
+		fcm_clif->cl_ping_pending++;
+		fcm_dcbd_request("P");	/* ping to verify connection */
 	}
-	sa_timer_set(&fcm_dcbd_timer, FCM_DCBD_TIMEOUT_USEC);
+}
+
+static void fcm_dcbd_retry_timeout(void *arg)
+{
+	struct fcm_netif *ff = (struct fcm_netif *)arg;
+
+	ASSERT(ff);
+	FCM_LOG_DBG("%s: dcbd retry TIMEOUT occurred [%d]",
+		ff->ifname, ff->dcbd_retry_cnt);
+
+	fcm_dcbd_state_set(ff, FCD_GET_DCB_STATE);
+	fcm_netif_advance(ff);
 }
 
 static void fcm_dcbd_disconnect(void)
@@ -973,7 +970,6 @@ static void fcm_dcbd_disconnect(void)
 		fcm_clif->cl_fd = -1;	/* mark as disconnected */
 		fcm_clif->cl_busy = 0;
 		fcm_clif->cl_ping_pending = 0;
-		fcm_fcoe_config_reset();
 		FCM_LOG_DBG("Disconnected from dcbd");
 	}
 }
@@ -987,34 +983,19 @@ static void fcm_dcbd_shutdown(void)
 	closelog();
 }
 
-static void fcm_vfcoe_cleanup(struct fcm_fcoe *ff)
-{
-	struct fcm_vfcoe *fv, *head;
-	struct fcm_vfcoe_head *list;
-
-	list = &(ff->ff_vfcoe_head);
-
-	for (head = TAILQ_FIRST(list); head; head = fv) {
-		fv = TAILQ_NEXT(head, fv_list);
-		TAILQ_REMOVE(list, head, fv_list);
-		free(head);
-	}
-}
-
 static void fcm_cleanup(void)
 {
-	struct fcoe_port_config *curr, *next;
-	struct fcm_fcoe *ff, *head;
+	struct fcoe_port *curr, *next;
+	struct fcm_netif *ff, *head;
 
 	for (curr = fcoe_config.port; curr; curr = next) {
 		next = curr->next;
 		free(curr);
 	}
 
-	for (head = TAILQ_FIRST(&fcm_fcoe_head); head; head = ff) {
+	for (head = TAILQ_FIRST(&fcm_netif_head); head; head = ff) {
 		ff = TAILQ_NEXT(head, ff_list);
-		TAILQ_REMOVE(&fcm_fcoe_head, head, ff_list);
-		fcm_vfcoe_cleanup(head);
+		TAILQ_REMOVE(&fcm_netif_head, head, ff_list);
 		free(head);
 	}
 
@@ -1055,7 +1036,6 @@ static void fcm_dcbd_rx(void *arg)
 	if (rc < 0)
 		FCM_LOG_ERR(errno, "read");
 	else if ((rc > 0) && (rc < sizeof(buf))) {
-		ASSERT(rc < sizeof(buf));
 		buf[rc] = '\0';
 		len = strlen(buf);
 		ASSERT(len <= rc);
@@ -1097,7 +1077,6 @@ static void fcm_dcbd_rx(void *arg)
 					len, buf);
 				break;
 			}
-			fcm_dcbd_next();	/* advance ports if possible */
 			break;
 
 		case EVENT_MSG:
@@ -1111,33 +1090,33 @@ static void fcm_dcbd_rx(void *arg)
 	}
 }
 
-static void fcm_dcbd_ex(void *arg)
-{
-	FCM_LOG_DBG("called");
-}
-
-static void fcm_dcbd_request(char *req)
+/*
+ * returns:  1 if request was successfully written
+ *           0 if the write failed
+*/
+static int fcm_dcbd_request(char *req)
 {
 	size_t len;
 	int rc;
 
 	if (fcm_clif->cl_fd < 0)
-		return;
+		return 0;
 	len = strlen(req);
 	ASSERT(fcm_clif->cl_busy == 0);
+	sa_timer_set(&fcm_dcbd_timer, DCBD_CONNECT_TIMEOUT);
 	fcm_clif->cl_busy = 1;
 	rc = write(fcm_clif->cl_fd, req, len);
 	if (rc < 0) {
 		FCM_LOG_ERR(errno, "Failed write req %s len %d", req, len);
 		fcm_clif->cl_busy = 0;
 		fcm_dcbd_disconnect();
-		fcm_dcbd_connect();
-		return;
+		sa_timer_set(&fcm_dcbd_timer, DCBD_CONNECT_RETRY_TIMEOUT);
+		return 0;
 	}
 
 	if (rc > FCM_PING_REQ_LEN)
 		FCM_LOG_DBG("sent '%s', rc=%d bytes succeeded", req, rc);
-	return;
+	return 1;
 }
 
 /*
@@ -1147,10 +1126,10 @@ static void fcm_dcbd_request(char *req)
  * The pointer to the message pointer is passed in, and updated to point
  * past the interface name.
  */
-static struct fcm_fcoe *fcm_dcbd_get_port(char **msgp, size_t len_off,
+static struct fcm_netif *fcm_dcbd_get_port(char **msgp, size_t len_off,
 					  size_t len_len, size_t len)
 {
-	struct fcm_fcoe *ff;
+	struct fcm_netif *ff;
 	u_int32_t if_len;
 	char *ep;
 	char *msg;
@@ -1173,10 +1152,9 @@ static struct fcm_fcoe *fcm_dcbd_get_port(char **msgp, size_t len_off,
 	msg += len_off + len_len;
 	sa_strncpy_safe(ifname, sizeof(ifname), msg, if_len);
 	*msgp = msg + if_len;
-	ff = fcm_fcoe_lookup_name(ifname);
+	ff = fcm_netif_lookup(ifname);
 	if (ff == NULL) {
 		FCM_LOG("ifname '%s' not found", ifname);
-		exit(1);	/* XXX */
 	}
 	return ff;
 }
@@ -1184,10 +1162,11 @@ static struct fcm_fcoe *fcm_dcbd_get_port(char **msgp, size_t len_off,
 /*
  * (XXX) Notes:
  * This routine is here to help fcm_dcbd_cmd_resp() to pick up
- * information of the response packet from the DCBD. In the
- * future, it should be merged into fcm_dcbd_cmd_resp().
+ * information of the response packet from the DCBD.
+ * Returns:  0 on success
+ *          -1 on failure
  */
-static int dcb_rsp_parser(struct fcm_fcoe *ff, char *rsp, cmd_status st)
+static int dcb_rsp_parser(struct fcm_netif *ff, char *rsp)
 {
 	int version;
 	int dcb_cmd;
@@ -1200,25 +1179,9 @@ static int dcb_rsp_parser(struct fcm_fcoe *ff, char *rsp, cmd_status st)
 	struct feature_info *f_info = NULL;
 	char buf[20];
 
-	if (st != cmd_success)	/* log msg already issued */
-		return -1;
-
 	feature = hex2int(rsp+DCB_FEATURE_OFF);
-	if (feature != FEATURE_DCB &&
-	    feature != FEATURE_PFC &&
-	    feature != FEATURE_APP) {
-		FCM_LOG_DEV(ff, "WARNING: Unexpected DCB feature %d\n",
-			    feature);
-		return -1;
-	}
 
 	dcb_cmd = hex2int(rsp+DCB_CMD_OFF);
-	if (dcb_cmd != CMD_GET_CONFIG &&
-	    dcb_cmd != CMD_GET_OPER &&
-	    dcb_cmd != CMD_GET_PEER) {
-		FCM_LOG_DEV(ff, "WARNING: Unexpected DCB cmd %d\n", dcb_cmd);
-		return -1;
-	}
 
 	version = rsp[DCB_VER_OFF] & 0x0f;
 	if (version != CLIF_MSG_VERSION) {
@@ -1234,10 +1197,6 @@ static int dcb_rsp_parser(struct fcm_fcoe *ff, char *rsp, cmd_status st)
 	switch (feature) {
 	case FEATURE_DCB:
 		ff->ff_dcb_state = (*(rsp+doff+CFG_ENABLE) == '1');
-		if (!ff->ff_dcb_state) {
-			FCM_LOG_DEV(ff, "WARNING: DCB state is off\n");
-			return -1;
-		}
 		return 0;
 	case FEATURE_PFC:
 		f_info = &ff->ff_pfc_info;
@@ -1246,6 +1205,8 @@ static int dcb_rsp_parser(struct fcm_fcoe *ff, char *rsp, cmd_status st)
 		f_info = &ff->ff_app_info;
 		f_info->subtype = subtype;
 		break;
+	default:
+		return -1;
 	}
 
 	switch (dcb_cmd) {
@@ -1281,123 +1242,138 @@ static int dcb_rsp_parser(struct fcm_fcoe *ff, char *rsp, cmd_status st)
 	return 0;
 }
 
+
 /*
- * validating_dcb_app_pfc - Validating App:FCoE and PFC requirements
- *
- * DCB is configured correctly when
- * 1) The local configuration of the App:FCoE feature is
- *    configured to Enable=TRUE, Advertise=TRUE, Willing=TRUE.
- * 2) App:FCoE feature is in Opertional Mode = TRUE,
- * 3) PFC feasture is in Opertional Mode = TRUE,
- * 4) The priority indicated by the App:FCoE Operational Configuration
- *    is also enabled in the PFC Operational Configuration.
- * 5) DCB State is on.
+ * validate_dcbd_info - Validating DCBD configuration and status
  *
- * Returns:  1 if succeeded
- *           0 if failed
+ * Returns:  FCP_CREATE_IF - if the dcb netif qualifies for an fcoe interface
+ *           FCP_DESTROY_IF - if the dcb netif should not support fcoe interface
+ *           FCP_WAIT - if dcb criteria is inconclusive
  */
-static int validating_dcb_app_pfc(struct fcm_fcoe *ff)
+static int validate_dcbd_info(struct fcm_netif *ff)
 {
-	int error = 0;
+	int errors = 0;
+	int dcbon;
+
+	dcbon = ff->ff_dcb_state;
+
+	/* check if dcb state qualifies to create the fcoe interface */
+	if (dcbon &&
+	    ff->ff_app_info.enable &&
+	    ff->ff_pfc_info.enable &&
+	    ff->ff_app_info.op_mode &&
+	    ff->ff_pfc_info.op_mode &&
+	    ff->ff_pfc_info.u.pfcup & ff->ff_app_info.u.appcfg) {
+
+		if (dcbon && !ff->ff_app_info.willing) {
+			FCM_LOG_DEV(ff,
+				"WARNING: FCoE willing mode is false\n");
+			errors++;
+		}
+		if (dcbon && !ff->ff_app_info.advertise) {
+			FCM_LOG_DEV(ff,
+				"WARNING: FCoE advertise mode is false\n");
+			errors++;
+		}
+		if (dcbon && !ff->ff_pfc_info.willing) {
+			FCM_LOG_DEV(ff,
+				"WARNING: PFC willing mode is false\n");
+			errors++;
+		}
+		if (dcbon && !ff->ff_pfc_info.advertise) {
+			FCM_LOG_DEV(ff,
+				"WARNING: PFC advertise mode is false\n");
+			errors++;
+		}
 
-	if (!ff->ff_dcb_state) {
-		FCM_LOG_DEV(ff, "WARNING: DCB state is off\n");
-		error++;
+		if (errors)
+			FCM_LOG_DEV_DBG(ff,
+			    "WARNING: DCB may not be configured correctly\n");
+		else
+			FCM_LOG_DEV_DBG(ff, "DCB is configured correctly\n");
+
+		ff->ff_qos_mask =
+			ff->ff_pfc_info.u.pfcup & ff->ff_app_info.u.appcfg;
+
+		return FCP_CREATE_IF;
 	}
-	if (!ff->ff_app_info.willing) {
-		FCM_LOG_DEV(ff, "WARNING: APP:0 willing mode is false\n");
-		error++;
+
+	/* check if dcb state qualifies to destroy the fcoe interface */
+	if (!dcbon ||
+	    !ff->ff_app_info.enable ||
+	    (ff->ff_app_info.op_mode && ff->ff_pfc_info.op_mode &&
+	    !(ff->ff_pfc_info.u.pfcup & ff->ff_app_info.u.appcfg))) {
+
+		if (dcbon && !ff->ff_dcb_state)
+			FCM_LOG_DEV(ff, "WARNING: DCB is disabled\n");
+
+		if (dcbon && !ff->ff_app_info.enable)
+			FCM_LOG_DEV(ff, "WARNING: FCoE enable is off\n");
+
+		if (dcbon &&
+			!(ff->ff_pfc_info.u.pfcup & ff->ff_app_info.u.appcfg))
+			FCM_LOG_DEV(ff,
+				"WARNING: FCoE priority (0x%02x) doesn't "
+				"intersect with PFC priority (0x%02x)\n",
+				ff->ff_app_info.u.appcfg,
+				ff->ff_pfc_info.u.pfcup);
+
+		return FCP_DESTROY_IF;
+	}
+
+	/* The dcbd state does not match the create or destroy criteria.
+	 * Log possible problems.
+	*/
+	if (dcbon && !ff->ff_app_info.willing) {
+		FCM_LOG_DEV(ff, "WARNING: FCoE willing mode is false\n");
+		errors++;
+	}
+	if (dcbon && !ff->ff_app_info.advertise) {
+		FCM_LOG_DEV(ff, "WARNING: FCoE advertise mode is false\n");
+		errors++;
 	}
-	if (!ff->ff_app_info.advertise) {
-		FCM_LOG_DEV(ff, "WARNING: APP:0 advertise mode is false\n");
-		error++;
+	if (dcbon && !ff->ff_app_info.op_mode) {
+		FCM_LOG_DEV(ff, "WARNING: FCoE operational mode is false\n");
+		print_errors("", ff->ff_app_info.op_error);
+		errors++;
 	}
-	if (!ff->ff_app_info.enable) {
-		FCM_LOG_DEV(ff, "WARNING: APP:0 enable mode is false\n");
-		error++;
+	if (dcbon && !ff->ff_pfc_info.enable) {
+		FCM_LOG_DEV(ff, "WARNING: PFC enable is off\n");
+		errors++;
 	}
-	if (!ff->ff_app_info.op_mode) {
-		FCM_LOG_DEV(ff, "WARNING: APP:0 operational mode is false\n");
-		error++;
+	if (dcbon && !ff->ff_pfc_info.advertise) {
+		FCM_LOG_DEV(ff, "WARNING: PFC advertise mode is false\n");
+		errors++;
 	}
-	if (!ff->ff_pfc_info.op_mode) {
+	if (dcbon && !ff->ff_pfc_info.op_mode) {
 		FCM_LOG_DEV(ff, "WARNING: PFC operational mode is false\n");
-		error++;
+		print_errors("", ff->ff_pfc_info.op_error);
+		errors++;
 	}
-	if ((ff->ff_pfc_info.u.pfcup & ff->ff_app_info.u.appcfg) \
-	    != ff->ff_app_info.u.appcfg) {
+	if (dcbon && !(ff->ff_pfc_info.u.pfcup & ff->ff_app_info.u.appcfg)) {
 		FCM_LOG_DEV(ff, "WARNING: APP:0 priority (0x%02x) doesn't "
-			    "match PFC priority (0x%02x)\n",
+			    "intersect with PFC priority (0x%02x)\n",
 			    ff->ff_app_info.u.appcfg,
 			    ff->ff_pfc_info.u.pfcup);
-		error++;
+		errors++;
 	}
-	if (error) {
-		FCM_LOG_DEV(ff, "WARNING: DCB is configured incorrectly\n");
-		return 0;
+	if (errors) {
+		FCM_LOG_DEV(ff, "WARNING: DCB may be configured incorrectly\n");
+		return FCP_ERROR;
 	}
-	FCM_LOG_DEV_DBG(ff, "DCB is configured correctly\n");
 
-	return 1;
+	return FCP_WAIT;
 }
 
-/*
- * validating_dcbd_info - Validating DCBD configuration and status
- *
- * Returns:  1 if succeeded
- *           0 if failed
- */
-static int validating_dcbd_info(struct fcm_fcoe *ff)
-{
-	int rc;
-
-	rc = validating_dcb_app_pfc(ff);
-	return rc;
-}
-
-/*
- * is_pfcup_changed - Check to see if PFC priority is changed
- *
- * Returns:  0 if no
- *           1 if yes, but it is the first time, or was destroyed.
- *           2 if yes
- */
-static int is_pfcup_changed(struct fcm_fcoe *ff)
-{
-	if (ff->ff_pfc_info.u.pfcup != ff->ff_pfc_saved.u.pfcup) {
-		if (ff->ff_pfc_saved.u.pfcup == 0xffff)
-			return 1;	/* first time */
-		else
-			return 2;
-	}
-	return 0;
-}
-
-/*
- * update_saved_pfcup - Update the saved PFC priority with
- *                      the current priority.
- *
- * Returns:  None
- */
-static void update_saved_pfcup(struct fcm_fcoe *ff)
-{
-	ff->ff_pfc_saved.u.pfcup = ff->ff_pfc_info.u.pfcup;
-}
 
 /*
  * clear_dcbd_info - clear dcbd info to unknown values
  *
  */
-static void clear_dcbd_info(struct fcm_fcoe *ff)
+static void clear_dcbd_info(struct fcm_netif *ff)
 {
-	ff->ff_dcb_state = 0;
-	ff->ff_app_info.advertise = 0;
-	ff->ff_app_info.enable = 0;
-	ff->ff_app_info.op_mode = 0;
-	ff->ff_app_info.u.appcfg = 0;
-	ff->ff_app_info.willing = 0;
-	ff->ff_pfc_info.op_mode = 0;
-	ff->ff_pfc_info.u.pfcup = 0xffff;
+	memset(&ff->ff_pfc_info, 0, sizeof(struct feature_info));
+	memset(&ff->ff_app_info, 0, sizeof(struct feature_info));
 }
 
 
@@ -1406,13 +1382,10 @@ static void clear_dcbd_info(struct fcm_fcoe *ff)
  * @ff: fcoe port structure
  * @st: status
  */
-static void fcm_dcbd_set_config(struct fcm_fcoe *ff, cmd_status st)
+static void fcm_dcbd_set_config(struct fcm_netif *ff)
 {
 	if (ff->ff_dcbd_state == FCD_SEND_CONF) {
-		if (st != cmd_success)
-			fcm_dcbd_state_set(ff, FCD_ERROR);
-		else
-			fcm_dcbd_state_set(ff, FCD_GET_PFC_CONFIG);
+		fcm_dcbd_state_set(ff, FCD_GET_PFC_CONFIG);
 	}
 }
 
@@ -1422,47 +1395,31 @@ static void fcm_dcbd_set_config(struct fcm_fcoe *ff, cmd_status st)
  * @resp: response buffer
  * @st:   status
  */
-static void fcm_dcbd_get_config(struct fcm_fcoe *ff, char *resp,
-				const cmd_status st)
+static void fcm_dcbd_get_config(struct fcm_netif *ff, char *resp)
 {
-	int rc;
-
 	switch (ff->ff_dcbd_state) {
 	case FCD_GET_DCB_STATE:
-		if (st != cmd_success) {
-			fcm_dcbd_state_set(ff, FCD_ERROR);
-			break;
-		}
-		rc = dcb_rsp_parser(ff, resp, st);
-		if (!rc)
-			fcm_dcbd_state_set(ff, FCD_SEND_CONF);
-		else
+		if (!dcb_rsp_parser(ff, resp)) {
+			if (ff->ff_dcb_state)
+				fcm_dcbd_state_set(ff, FCD_GET_PFC_CONFIG);
+			else
+				fcm_dcbd_state_set(ff, FCD_DONE);
+		} else
 			fcm_dcbd_state_set(ff, FCD_ERROR);
 		break;
 	case FCD_GET_PFC_CONFIG:
-		if (st != cmd_success) {
-			fcm_dcbd_state_set(ff, FCD_ERROR);
-			break;
-		}
-		rc = dcb_rsp_parser(ff, resp, st);
-		if (!rc)
+		if (!dcb_rsp_parser(ff, resp))
 			fcm_dcbd_state_set(ff, FCD_GET_APP_CONFIG);
 		else
 			fcm_dcbd_state_set(ff, FCD_ERROR);
 		break;
 	case FCD_GET_APP_CONFIG:
-		if (st != cmd_success) {
-			fcm_dcbd_state_set(ff, FCD_ERROR);
-			break;
-		}
-		rc = dcb_rsp_parser(ff, resp, st);
-		if (!rc)
+		if (!dcb_rsp_parser(ff, resp))
 			fcm_dcbd_state_set(ff, FCD_GET_PFC_OPER);
 		else
 			fcm_dcbd_state_set(ff, FCD_ERROR);
 		break;
 	default:
-		fcm_dcbd_state_set(ff, FCD_ERROR);
 		break;
 	}
 }
@@ -1478,128 +1435,47 @@ static void fcm_dcbd_get_config(struct fcm_fcoe *ff, char *resp,
  * Sample msg: R00C103050004eth8010100100208
  *                  opppssll    vvmmeemsllpp
  */
-static void fcm_dcbd_get_oper(struct fcm_fcoe *ff, char *resp,
-			      char *cp, const cmd_status st)
+static void fcm_dcbd_get_oper(struct fcm_netif *ff, char *resp, char *cp)
 {
-	u_int32_t enable;
 	u_int32_t val;
-	u_int32_t parm_len;
-	u_int32_t parm;
 	char *ep = NULL;
-	int rc;
 
 	val = fcm_get_hex(cp + OPER_ERROR, 2, &ep);
 
 	if (ep) {
 		FCM_LOG_DEV(ff, "Invalid get oper response "
-			    "parse error byte %d, resp %s",
-			    ep - cp, cp);
+			    "parse error byte %d, resp %s", ep - cp, cp);
 		fcm_dcbd_state_set(ff, FCD_ERROR);
 	} else {
-		if (val != 0) {
-			FCM_LOG_DEV_DBG(ff, "val=0x%x resp:%s\n", val,
-					resp);
-			if (fcoe_config.debug)
-				print_errors("", val);
-
-			fcm_dcbd_setup(ff, ADM_DESTROY);
-			fcm_dcbd_state_set(ff, FCD_DONE);
-			return;
-		}
-
-		if (st != cmd_success) {
-			fcm_dcbd_state_set(ff, FCD_ERROR);
-			return;
-		}
-
-		enable = (cp[OPER_OPER_MODE] == '1');
+		if (val && fcoe_config.debug)
+			print_errors("", val);
 
 		switch (ff->ff_dcbd_state) {
 		case FCD_GET_PFC_OPER:
-			FCM_LOG_DEV_DBG(ff, "PFC feature is %ssynced",
-					cp[OPER_SYNCD] == '1' ? "" : "not ");
+			if (dcb_rsp_parser(ff, resp) || !ff->ff_pfc_info.syncd)
+				fcm_dcbd_state_set(ff, FCD_ERROR);
+			else
+				fcm_dcbd_state_set(ff, FCD_GET_APP_OPER);
 
+			FCM_LOG_DEV_DBG(ff, "PFC feature is %ssynced",
+				ff->ff_pfc_info.syncd ? "" : "not ");
 			FCM_LOG_DEV_DBG(ff, "PFC operating mode is %s",
-					cp[OPER_OPER_MODE] == '1'
-					? "on" : "off ");
-			ff->ff_pfc_info.enable = enable;
-			rc = dcb_rsp_parser(ff, resp, st);
-			if (!rc)
-				fcm_dcbd_state_set(ff, FCD_GET_APP_OPER);
-			else
-				fcm_dcbd_state_set(ff, FCD_ERROR);
+				ff->ff_pfc_info.op_mode ? "on" : "off ");
 			break;
 
 		case FCD_GET_APP_OPER:
-			FCM_LOG_DEV_DBG(ff, "FCoE feature is %ssynced",
-					cp[OPER_SYNCD] == '1' ? "" : "not ");
-			FCM_LOG_DEV_DBG(ff, "FCoE operating mode is %s",
-					cp[OPER_OPER_MODE] == '1'
-					? "on" : "off ");
-			rc = dcb_rsp_parser(ff, resp, st);
-			if (rc) {
+			if (dcb_rsp_parser(ff, resp) || !ff->ff_app_info.syncd)
 				fcm_dcbd_state_set(ff, FCD_ERROR);
-				break;
-			}
-
-			parm_len = fcm_get_hex(cp + OPER_LEN, 2, &ep);
-			cp += OPER_LEN + 2;
-			if (ep != NULL || parm_len > strlen(cp)) {
-				FCM_LOG_DEV_DBG(ff, "Invalid peer parm_len %d",
-						parm_len);
-				fcm_dcbd_state_set(ff, FCD_ERROR);
-				break;
-			}
-			parm = 0;
-			if (parm_len > 0) {
-				parm = fcm_get_hex(cp, parm_len, &ep);
-				if (ep != NULL) {
-					FCM_LOG_DEV_DBG(ff, "Invalid parameter "
-							"%s", cp);
-					fcm_dcbd_state_set(ff, FCD_ERROR);
-					break;
-				}
-			}
-			ff->ff_qos_mask = parm;
-			if (validating_dcbd_info(ff)) {
-				FCM_LOG_DEV_DBG(ff, "DCB settings "
-						"qualified for creating "
-						"FCoE interface\n");
-
-				rc = is_pfcup_changed(ff);
-				if (rc == 1) {
-					FCM_LOG_DEV_DBG(ff, "Initial "
-							"QOS = 0x%x\n",
-							ff->ff_qos_mask);
-					fcm_dcbd_setup(ff, ADM_CREATE);
-				} else if (rc == 2) {
-					FCM_LOG_DEV_DBG(ff, "QOS changed"
-							" to 0x%x\n",
-							ff->ff_qos_mask);
-					fcm_dcbd_setup(ff, ADM_RESET);
-				} else if (!ff->ff_enabled) {
-					FCM_LOG_DEV_DBG(ff, "Re-create "
-							"QOS = 0x%x\n",
-							ff->ff_qos_mask);
-					fcm_dcbd_setup(ff, ADM_CREATE);
-				} else {
-					FCM_LOG_DEV_DBG(ff, "No action will "
-							"be taken\n");
-				}
-			} else {
-				FCM_LOG_DEV_DBG(ff, "DCB settings of %s not "
-						"qualified for FCoE "
-						"operations.");
-				fcm_dcbd_setup(ff, ADM_DESTROY);
-				clear_dcbd_info(ff);
-			}
+			else
+				fcm_dcbd_state_set(ff, FCD_DONE);
 
-			update_saved_pfcup(ff);
-			fcm_dcbd_state_set(ff, FCD_DONE);
-			return;
+			FCM_LOG_DEV_DBG(ff, "FCoE feature is %ssynced",
+				ff->ff_app_info.syncd ? "" : "not ");
+			FCM_LOG_DEV_DBG(ff, "FCoE operating mode is %s",
+				ff->ff_app_info.op_mode ? "on" : "off ");
+			break;
 
 		default:
-			fcm_dcbd_state_set(ff, FCD_ERROR);
 			break;
 		}
 	}
@@ -1612,36 +1488,9 @@ static void fcm_dcbd_get_oper(struct fcm_fcoe *ff, char *resp,
  * @cp:   response buffer pointer, points past the interface name
  * @st:   status
  */
-static void fcm_dcbd_get_peer(struct fcm_fcoe *ff, char *resp,
-			      char *cp, const cmd_status st)
+static void fcm_dcbd_get_peer(struct fcm_netif *ff, char *resp, char *cp)
 {
-	char *ep = NULL;
-	u_int32_t val;
-
-	val = fcm_get_hex(cp + OPER_ERROR, 2, &ep);
-	if (ep) {
-		FCM_LOG_DEV_DBG(ff, "Invalid get oper response "
-				"parse error byte %d. resp %s",
-				ep - cp, cp);
-		fcm_dcbd_state_set(ff, FCD_ERROR);
-		return;
-	}
-
-	if (val != 0) {
-		FCM_LOG_DEV_DBG(ff, "val=0x%x resp:%s\n", val, resp);
-		if (fcoe_config.debug)
-			print_errors("", val);
-		fcm_dcbd_setup(ff, ADM_DESTROY);
-		fcm_dcbd_state_set(ff, FCD_DONE);
-		return;
-	}
-
-	if (st != cmd_success) {
-		fcm_dcbd_state_set(ff, FCD_ERROR);
-		return;
-	}
-
-	fcm_dcbd_state_set(ff, FCD_ERROR);
+	return;
 }
 
 /*
@@ -1650,11 +1499,12 @@ static void fcm_dcbd_get_peer(struct fcm_fcoe *ff, char *resp,
  */
 static void fcm_dcbd_cmd_resp(char *resp, cmd_status st)
 {
-	struct fcm_fcoe *ff;
+	struct fcm_netif *ff;
 	u_int32_t ver;
 	u_int32_t cmd;
 	u_int32_t feature;
 	u_int32_t subtype;
+	u_int32_t state;
 	char *ep;
 	char *cp;
 	size_t len;
@@ -1691,26 +1541,42 @@ static void fcm_dcbd_cmd_resp(char *resp, cmd_status st)
 		return;
 	}
 
-	if (!(ff->ff_flags & IFF_LOWER_UP)) {
-		FCM_LOG_DEV_DBG(ff, "Port state netif carrier down\n");
-		return;
+	/*
+	 * check that dcbd response matches the current dcbd state.
+	*/
+	state = ff->ff_dcbd_state;
+	if (((cmd == CMD_GET_CONFIG) &&
+		((state == FCD_GET_DCB_STATE && feature == FEATURE_DCB) ||
+		(state == FCD_GET_PFC_CONFIG && feature == FEATURE_PFC) ||
+		(state == FCD_GET_APP_CONFIG && feature == FEATURE_APP)))
+		||
+	    ((cmd == CMD_GET_OPER) &&
+		((state == FCD_GET_PFC_OPER && feature == FEATURE_PFC) ||
+		(state == FCD_GET_APP_OPER && feature == FEATURE_APP)))) {
+
+		/* the response matches the current pending query */
+		ff->response_pending = 0;
+		if (st != cmd_success) {
+			fcm_dcbd_state_set(ff, FCD_ERROR);
+			return;
+		}
 	}
 
 	switch (cmd) {
 	case CMD_SET_CONFIG:
-		fcm_dcbd_set_config(ff, st);
+		fcm_dcbd_set_config(ff);
 		break;
 
 	case CMD_GET_CONFIG:
-		fcm_dcbd_get_config(ff, resp, st);
+		fcm_dcbd_get_config(ff, resp);
 		break;
 
 	case CMD_GET_OPER:
-		fcm_dcbd_get_oper(ff, resp, cp, st);
+		fcm_dcbd_get_oper(ff, resp, cp);
 		break;
 
 	case CMD_GET_PEER:
-		fcm_dcbd_get_peer(ff, resp, cp, st);
+		fcm_dcbd_get_peer(ff, resp, cp);
 		break;
 
 	default:
@@ -1720,27 +1586,14 @@ static void fcm_dcbd_cmd_resp(char *resp, cmd_status st)
 	}
 }
 
-static void fcm_event_timeout(void *arg)
-{
-	struct fcm_fcoe *ff = (struct fcm_fcoe *)arg;
-
-	FCM_LOG_DEV_DBG(ff, "%d milliseconds timeout!\n",
-			FCM_EVENT_TIMEOUT_USEC/1000);
-
-	if (!is_query_in_progress()) {
-		fcm_clif->cl_ping_pending++;
-		fcm_dcbd_request("P");
-	}
-	fcm_dcbd_state_set(ff, FCD_GET_DCB_STATE);
-}
-
 /*
  * Handle incoming DCB event message.
  * Example message: E5104eth8050001
  */
 static void fcm_dcbd_event(char *msg, size_t len)
 {
-	struct fcm_fcoe *ff;
+	struct fcm_netif *ff;
+	struct fcoe_port *p;
 	u_int32_t feature;
 	u_int32_t subtype;
 	char *cp;
@@ -1757,11 +1610,6 @@ static void fcm_dcbd_event(char *msg, size_t len)
 	if (ff == NULL)
 		return;
 
-	if (!(ff->ff_flags & IFF_LOWER_UP)) {
-		FCM_LOG_DEV_DBG(ff, "Port state netif carrier down\n");
-		return;
-	}
-
 	feature = fcm_get_hex(cp + EV_FEATURE_OFF, 2, &ep);
 	if (ep != NULL) {
 		FCM_LOG_DEV_DBG(ff, "Invalid feature code in event msg %s",
@@ -1769,38 +1617,51 @@ static void fcm_dcbd_event(char *msg, size_t len)
 		return;
 	}
 
+	/*
+	 * Check if the FCoE ports which use the interface on which the
+	 * dcbd event arrived are configured to require dcb.
+	*/
+
+	p = fcm_find_fcoe_port(ff->ifname, FCP_REAL_IFNAME);
+	while (p) {
+		if (p->dcb_required && p->last_msg_type != RTM_DELLINK)
+			break;
+		p = fcm_find_next_fcoe_port(p, ff->ifname);
+	}
+
+	/*
+	 * dcb is not required or link was removed, ignore dcbd event
+	*/
+	if (!p)
+		return;
+
+	if (ff->ff_operstate != IF_OPER_UP)
+		return;
+
 	switch (feature) {
-	case FEATURE_DCB:
-		FCM_LOG_DEV_DBG(ff, "<%s: Got DCB Event>\n");
-		goto ignore_event;
 	case FEATURE_PG:     /* 'E5204eth2020001' */
-		FCM_LOG_DEV_DBG(ff, "<%s: Got PG Event>\n");
-		goto ignore_event;
-	case FEATURE_BCN:    /* 'E5204eth2040001' */
-		FCM_LOG_DEV_DBG(ff, "<%s: Got BCN Event>\n");
-		goto ignore_event;
-	case FEATURE_PG_DESC:
-		FCM_LOG_DEV_DBG(ff, "<%s: Got PG_DESC Event>\n");
-		goto ignore_event;
+		FCM_LOG_DEV_DBG(ff, "<Got PG Event>\n");
+		break;
 	case FEATURE_PFC:    /* 'E5204eth2030011' */
-		FCM_LOG_DEV_DBG(ff, "<%s: Got PFC Event>\n");
-		goto handle_event;
+		FCM_LOG_DEV_DBG(ff, "<Got PFC Event>\n");
+		fcm_dcbd_state_set(ff, FCD_GET_DCB_STATE);
+		break;
 	case FEATURE_APP:    /* 'E5204eth2050011' */
-		FCM_LOG_DEV_DBG(ff, "<%s: Got APP Event>\n");
-		goto handle_event;
+		FCM_LOG_DEV_DBG(ff, "<Got APP Event>\n");
+		subtype = fcm_get_hex(cp + EV_SUBTYPE_OFF, 2, &ep);
+		if (subtype != APP_FCOE_STYPE) {
+			FCM_LOG_DEV_DBG(ff, "Unknown application subtype "
+					"in msg %s", msg);
+			break;
+		}
+		fcm_dcbd_state_set(ff, FCD_GET_DCB_STATE);
+		break;
 	default:
 		FCM_LOG_DEV_DBG(ff, "Unknown feature 0x%x in msg %s",
 				feature, msg);
-		goto ignore_event;
+		break;
 	}
 
-handle_event:
-	subtype = fcm_get_hex(cp + EV_SUBTYPE_OFF, 2, &ep);
-	if (subtype != APP_FCOE_STYPE) {
-		FCM_LOG_DEV_DBG(ff, "Unknown application subtype "
-				"in msg %s", msg);
-		return;
-	}
 	if (fcoe_config.debug) {
 		if (cp[EV_OP_MODE_CHG_OFF] == '1')
 			FCM_LOG_DEV_DBG(ff,
@@ -1809,21 +1670,6 @@ handle_event:
 			FCM_LOG_DEV_DBG(ff,
 					"Operational config changed");
 	}
-
-	if (ff->ff_dcbd_state == FCD_DONE ||
-	    ff->ff_dcbd_state == FCD_ERROR) {
-		if (cp[EV_OP_MODE_CHG_OFF] == '1' ||
-		    cp[EV_OP_CFG_CHG_OFF] == '1') {
-			/* Cancel timer if it is active */
-			sa_timer_cancel(&ff->ff_event_timer);
-			/* Reset the timer */
-			sa_timer_set(&ff->ff_event_timer,
-				     FCM_EVENT_TIMEOUT_USEC);
-		}
-		if (fcm_clif->cl_busy == 0)
-			fcm_dcbd_port_advance(ff);
-	}
-ignore_event:
 	return;
 }
 
@@ -1834,9 +1680,8 @@ ignore_event:
  *         enable = 1      Create the FCoE interface
  *         enable = 2      Reset the interface
  */
-static void fcm_dcbd_setup(struct fcm_fcoe *ff, enum fcoeadm_action action)
+static void fcm_fcoe_action(struct fcm_netif *ff, struct fcoe_port *p)
 {
-	struct fcm_vfcoe *fv;
 	char *op, *debug, *syslog = NULL;
 	char *qos_arg;
 	char qos[64];
@@ -1844,13 +1689,29 @@ static void fcm_dcbd_setup(struct fcm_fcoe *ff, enum fcoeadm_action action)
 	int rc;
 	int fd;
 
-	if (action == 0)
-		op = "--destroy";
-	else if (action == 1)
+	qos_arg = "--qos-enable";
+	switch (p->action) {
+	case FCP_CREATE_IF:
+		if (p->last_action == FCP_CREATE_IF)
+			return;
 		op = "--create";
-	else
+		break;
+	case FCP_DESTROY_IF:
+		if (p->last_action == FCP_DESTROY_IF)
+			return;
+		op = "--destroy";
+		qos_arg = "--qos-disable";
+		break;
+	case FCP_RESET_IF:
 		op = "--reset";
-	if (action && !ff->ff_qos_mask)
+		break;
+	default:
+		return;
+		break;
+	}
+	p->last_action = p->action;
+
+	if (p->action && !ff->ff_qos_mask)
 		return;
 	if (fcm_dcbd_cmd == NULL) {
 		FCM_LOG_DEV_DBG(ff, "Should %s per op state", op);
@@ -1860,34 +1721,28 @@ static void fcm_dcbd_setup(struct fcm_fcoe *ff, enum fcoeadm_action action)
 	/*
 	 * XXX should wait for child status
 	 */
-	ff->ff_enabled = action;
-
 	rc = fork();
 	if (rc < 0) {
 		FCM_LOG_ERR(errno, "fork error");
 	} else if (rc == 0) {	/* child process */
 		for (fd = ulimit(4 /* __UL_GETOPENMAX */ , 0); fd > 2; fd--)
 			close(fd);
-		qos_arg = "--qos-disable";
 		snprintf(qos, sizeof(qos), "%s", "0");
-		if (action) {
-			mask = ff->ff_qos_mask;
-			if (mask) {
-				int off = 0;
-				char *sep = "";
-				u_int32_t bit;
-
-				while (mask != 0 && off < sizeof(qos) - 1) {
-					bit = ffs(mask) - 1;
-					off +=
-						snprintf(qos + off,
-							 sizeof(qos) - off,
-							 "%s%u",
-							 sep, bit);
-					mask &= ~(1 << bit);
-					sep = ",";
-				}
-				qos_arg = "--qos-enable";
+		mask = ff->ff_qos_mask;
+		if (mask) {
+			int off = 0;
+			char *sep = "";
+			u_int32_t bit;
+
+			while (mask != 0 && off < sizeof(qos) - 1) {
+				bit = ffs(mask) - 1;
+				off +=
+					snprintf(qos + off,
+						 sizeof(qos) - off,
+						 "%s%u",
+						 sep, bit);
+				mask &= ~(1 << bit);
+				sep = ",";
 			}
 		}
 
@@ -1897,7 +1752,7 @@ static void fcm_dcbd_setup(struct fcm_fcoe *ff, enum fcoeadm_action action)
 		if (fcoe_config.debug) {
 			debug = "--debug";
 
-			if (!action)
+			if (!p->action)
 				FCM_LOG_DEV_DBG(ff, "%s %s %s\n", fcm_dcbd_cmd,
 						op, syslog);
 			else
@@ -1910,31 +1765,9 @@ static void fcm_dcbd_setup(struct fcm_fcoe *ff, enum fcoeadm_action action)
 		if (rc < 0)
 			FCM_LOG_ERR(errno, "fork error");
 		else if (rc == 0) {     /* child process */
-			if (ff->ff_active)
-				execlp(fcm_dcbd_cmd, fcm_dcbd_cmd, ff->ff_name,
-				       op, qos_arg, qos, debug, syslog,
-				       (char *)NULL);
-			else
-				execlp(fcm_dcbd_cmd, fcm_dcbd_cmd, ff->ff_name,
-				       qos_arg, qos, debug, syslog,
-				       (char *)NULL);
-		}
-
-		/* VLAN interfaces only enable and disable */
-		if (action < 0  || action > 1)
-			exit(1);
-
-		TAILQ_FOREACH(fv, &(ff->ff_vfcoe_head), fv_list) {
-			if (!fv->fv_active)
-				continue;
-			FCM_LOG_DEV_DBG(ff, "%s %s %s %s\n", fcm_dcbd_cmd,
-					fv->fv_name, op, syslog);
-			rc = fork();
-			if (rc < 0)
-				FCM_LOG_ERR(errno, "fork error");
-			else if (rc == 0)       /* child process */
-				execlp(fcm_dcbd_cmd, fcm_dcbd_cmd, fv->fv_name,
-				       op, debug, syslog, (char *)NULL);
+			execlp(fcm_dcbd_cmd, fcm_dcbd_cmd, p->ifname,
+			       p->real_ifname, op, qos_arg, qos, debug, syslog,
+			       (char *)NULL);
 		}
 
 		exit(1);
@@ -1946,9 +1779,10 @@ static void fcm_dcbd_setup(struct fcm_fcoe *ff, enum fcoeadm_action action)
  * Called for all ports.  For FCoE ports and candidates,
  * get information and send to dcbd.
  */
-static void fcm_dcbd_port_advance(struct fcm_fcoe *ff)
+static void fcm_netif_advance(struct fcm_netif *ff)
 {
 	char buf[80], params[30];
+	int old_qos_mask;
 
 	ASSERT(ff);
 	ASSERT(fcm_clif);
@@ -1956,17 +1790,22 @@ static void fcm_dcbd_port_advance(struct fcm_fcoe *ff)
 	if (fcm_clif->cl_busy)
 		return;
 
+	if (ff->response_pending)
+		return;
+
+	if (sa_timer_active(&ff->dcbd_retry_timer))
+		return;
+
 	switch (ff->ff_dcbd_state) {
 	case FCD_INIT:
-		fcm_dcbd_state_set(ff, FCD_GET_DCB_STATE);
-		/* Fall through */
+	case FCD_ERROR:
+		break;
 	case FCD_GET_DCB_STATE:
-		fcm_fcoe_get_dcb_settings(ff);
 		snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s",
 			 DCB_CMD, CLIF_RSP_VERSION,
 			 CMD_GET_CONFIG, FEATURE_DCB, 0,
-			 (u_int) strlen(ff->ff_name), ff->ff_name);
-		fcm_dcbd_request(buf);
+			 (u_int) strlen(ff->ifname), ff->ifname);
+		ff->response_pending = fcm_dcbd_request(buf);
 		break;
 	case FCD_SEND_CONF:
 		snprintf(params, sizeof(params), "%x1%x02%2.2x",
@@ -1976,63 +1815,121 @@ static void fcm_dcbd_port_advance(struct fcm_fcoe *ff)
 		snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s",
 			 DCB_CMD, CLIF_RSP_VERSION,
 			 CMD_SET_CONFIG, FEATURE_APP, APP_FCOE_STYPE,
-			 (u_int) strlen(ff->ff_name), ff->ff_name, params);
-		fcm_dcbd_request(buf);
+			 (u_int) strlen(ff->ifname), ff->ifname, params);
+		ff->response_pending = fcm_dcbd_request(buf);
 		break;
 	case FCD_GET_PFC_CONFIG:
 		snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s",
 			 DCB_CMD, CLIF_RSP_VERSION,
 			 CMD_GET_CONFIG, FEATURE_PFC, 0,
-			 (u_int) strlen(ff->ff_name), ff->ff_name, "");
-		fcm_dcbd_request(buf);
+			 (u_int) strlen(ff->ifname), ff->ifname, "");
+		ff->response_pending = fcm_dcbd_request(buf);
 		break;
 	case FCD_GET_APP_CONFIG:
 		snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s",
 			 DCB_CMD, CLIF_RSP_VERSION,
 			 CMD_GET_CONFIG, FEATURE_APP, APP_FCOE_STYPE,
-			 (u_int) strlen(ff->ff_name), ff->ff_name, "");
-		fcm_dcbd_request(buf);
+			 (u_int) strlen(ff->ifname), ff->ifname, "");
+		ff->response_pending = fcm_dcbd_request(buf);
 		break;
 	case FCD_GET_PFC_OPER:
 		snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s",
 			 DCB_CMD, CLIF_RSP_VERSION,
 			 CMD_GET_OPER, FEATURE_PFC, 0,
-			 (u_int) strlen(ff->ff_name), ff->ff_name, "");
-		fcm_dcbd_request(buf);
+			 (u_int) strlen(ff->ifname), ff->ifname, "");
+		ff->response_pending = fcm_dcbd_request(buf);
 		break;
 	case FCD_GET_APP_OPER:
 		snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s",
 			 DCB_CMD, CLIF_RSP_VERSION,
 			 CMD_GET_OPER, FEATURE_APP, APP_FCOE_STYPE,
-			 (u_int) strlen(ff->ff_name), ff->ff_name, "");
-		fcm_dcbd_request(buf);
+			 (u_int) strlen(ff->ifname), ff->ifname, "");
+		ff->response_pending = fcm_dcbd_request(buf);
 		break;
 	case FCD_GET_PEER:
 		snprintf(buf, sizeof(buf), "%c%x%2.2x%2.2x%2.2x%2.2x%s%s",
 			 DCB_CMD, CLIF_RSP_VERSION,
 			 CMD_GET_PEER, FEATURE_APP, APP_FCOE_STYPE,
-			 (u_int) strlen(ff->ff_name), ff->ff_name, "");
-		fcm_dcbd_request(buf);
+			 (u_int) strlen(ff->ifname), ff->ifname, "");
+		ff->response_pending = fcm_dcbd_request(buf);
 		break;
 	case FCD_DONE:
-		break;
-	case FCD_ERROR:
+		/* keep qos_mask and see if it changed */
+		old_qos_mask = ff->ff_qos_mask;
+		switch (validate_dcbd_info(ff)) {
+		case FCP_DESTROY_IF:
+			fcp_action_set(ff->ifname, FCP_DESTROY_IF);
+			fcm_dcbd_state_set(ff, FCD_INIT);
+			break;
+		case FCP_CREATE_IF:
+			if (!old_qos_mask) {
+				FCM_LOG_DEV_DBG(ff, "Initial QOS = 0x%x\n",
+						ff->ff_qos_mask);
+				fcp_action_set(ff->ifname, FCP_CREATE_IF);
+			} else if (old_qos_mask == ff->ff_qos_mask) {
+				fcp_action_set(ff->ifname, FCP_CREATE_IF);
+			} else {
+				FCM_LOG_DEV_DBG(ff, "QOS changed to 0x%x\n",
+						ff->ff_qos_mask);
+				fcp_action_set(ff->ifname, FCP_RESET_IF);
+			}
+			fcm_dcbd_state_set(ff, FCD_INIT);
+			break;
+		case FCP_ERROR:
+			if (ff->dcbd_retry_cnt < DCBD_MAX_REQ_RETRIES) {
+				fcm_dcbd_state_set(ff, FCD_ERROR);
+			} else {
+				fcp_action_set(ff->ifname, FCP_DESTROY_IF);
+				fcm_dcbd_state_set(ff, FCD_INIT);
+			}
+			break;
+		case FCP_WAIT:
+		default:
+			break;
+		}
+
 		break;
 	default:
 		break;
 	}
 }
 
-static void fcm_dcbd_next(void)
+
+/*
+ * Run through these steps at the end of each select loop.
+ * 1.  Process list of network interfaces
+ *     - issue next dcbd query action
+ *     - if query sequence is complete - update FCoE port objects
+ *       as necessary with a CREATE or DESTROY next action.
+ * 2.  Process FCoE port list - handle next actions, update states, clean up
+*/
+static void fcm_handle_changes()
 {
-	struct fcm_fcoe *ff;
+	struct fcm_netif *ff;
+	struct fcoe_port *p;
+	int i;
 
-	TAILQ_FOREACH(ff, &fcm_fcoe_head, ff_list) {
-		if (fcm_clif->cl_busy)
-			break;
+	/*
+	 * Perform pending actions (dcbd queries) on network interfaces.
+	*/
+	TAILQ_FOREACH(ff, &fcm_netif_head, ff_list)
+		fcm_netif_advance(ff);
+
+	/*
+	 * Perform actions on FCoE ports
+	*/
+	i = 0;
+	p = fcoe_config.port;
+	while (p) {
+		ff = fcm_netif_lookup(p->real_ifname);
+		if (!ff)
+			goto next_port;
+
+		fcm_fcoe_action(ff, p);
 
-		if (ff->ff_flags & IFF_LOWER_UP)
-			fcm_dcbd_port_advance(ff);
+		p->action = FCP_WAIT;
+next_port:
+		p = p->next;
 	}
 }
 
@@ -2170,6 +2067,7 @@ int main(int argc, char **argv)
 	fcm_fcoe_init();
 	fcm_link_init();	/* NETLINK_ROUTE protocol */
 	fcm_dcbd_init();
+	sa_select_set_callback(fcm_handle_changes);
 
 	rc = sa_select_loop();
 	if (rc < 0) {
@@ -2203,41 +2101,53 @@ static void print_errors(char *buf, int errors)
 	if (errors & 0x01) {
 		flag++;
 		j = sprintf(msg + len, "mismatch with peer");
+		len += j;
 	}
 
 	if (errors & 0x02) {
-		j = len;
-		if (flag++)
+		if (flag++) {
 			j = sprintf(msg + len, ", ");
-		sprintf(msg + j, "local configuration error");
+			len += j;
+		}
+		j = sprintf(msg + len, "local configuration error");
+		len += j;
 	}
 
 	if (errors & 0x04) {
-		j = len;
-		if (flag++)
+		if (flag++) {
 			j = sprintf(msg + len, ", ");
-		sprintf(msg + j, "multiple TLV's received");
+			len += j;
+		}
+		j = sprintf(msg + len, "multiple TLV's received");
+		len += j;
 	}
 
 	if (errors & 0x08) {
-		j = len;
-		if (flag++)
+		if (flag++) {
 			j = sprintf(msg + len, ", ");
-		sprintf(msg + j, "peer error");
+			len += j;
+		}
+		j = sprintf(msg + len, "peer error");
+		len += j;
 	}
 
 	if (errors & 0x10) {
-		j = len;
-		if (flag++)
+		if (flag++) {
 			j = sprintf(msg + len, ", ");
-		sprintf(msg + j, "multiple LLDP neighbors");
+			len += j;
+		}
+		j = sprintf(msg + len, "multiple LLDP neighbors");
+		len += j;
 	}
 
 	if (errors & 0x20) {
 		j = len;
-		if (flag++)
+		if (flag++) {
 			j = sprintf(msg + len, ", ");
-		sprintf(msg + j, "peer feature not present");
+			len += j;
+		}
+		j = sprintf(msg + len, "peer feature not present");
+		len += j;
 	}
 
 	FCM_LOG("%s %s\n", buf, msg);
diff --git a/fcoemon.h b/fcoemon.h
index 11cb4fb..ad71838 100644
--- a/fcoemon.h
+++ b/fcoemon.h
@@ -23,7 +23,7 @@
 struct fcoe_config {
 	int debug;
 	int use_syslog;
-	struct fcoe_port_config *port;
+	struct fcoe_port *port;
 } fcoe_config;
 
 /*
@@ -48,12 +48,12 @@ struct fcoe_config {
 #define FCM_LOG_DEV_DBG(fcm, fmt, args...)				\
 	do {								\
 		if (fcoe_config.debug)					\
-			sa_log("%s, " fmt, fcm->ff_name, ##args);	\
+			sa_log("%s, " fmt, fcm->ifname, ##args);	\
 	} while (0)
 
 #define FCM_LOG_DEV(fcm, fmt, args...)				\
 	do {							\
-		sa_log("%s, " fmt, fcm->ff_name, ##args);	\
+		sa_log("%s, " fmt, fcm->ifname, ##args);	\
 	} while (0)
 
 /*
@@ -73,6 +73,17 @@ enum fcm_dcbd_state {
    FCD_ERROR,           /* DCB error or port unknown by DCB */
 };
 
+/*
+ * Action codes for FCoE ports
+*/
+enum fcp_action {
+   FCP_WAIT = 0,        /* waiting for something to happen */
+   FCP_CREATE_IF,       /* create FCoE interface */
+   FCP_DESTROY_IF,      /* destroy FCoE interface */
+   FCP_RESET_IF,        /* reset FCoE interface */
+   FCP_ERROR,           /* error condition */
+};
+
 #define FCM_DCBD_STATES {                         \
     { "INIT",             FCD_INIT },             \
     { "GET_DCB_STATE",    FCD_GET_DCB_STATE },    \
@@ -103,60 +114,34 @@ struct feature_info {
 };
 
 /*
- * Description of FCoE VLAN interfaces
- */
-struct fcm_vfcoe {
-   TAILQ_ENTRY(fcm_vfcoe) fv_list;
-   char			  fv_name[IFNAMSIZ];
-   int			  fv_active;
-};
-
-TAILQ_HEAD(fcm_vfcoe_head, fcm_vfcoe);
-
-/*
- * Description of potential FCoE interface.
+ * Description of potential FCoE network interface.
  */
-struct fcm_fcoe {
-   TAILQ_ENTRY(fcm_fcoe) ff_list;          /* list linkage */
-   struct fcm_vfcoe_head ff_vfcoe_head;    /* list of fcm_vfcoe */
-   u_int32_t             ff_ifindex;       /* kernel interface index */
-   u_int32_t             ff_flags;         /* kernel interface flags */
-   u_int32_t             ff_last_flags;    /* previously known flags */
+struct fcm_netif {
+   TAILQ_ENTRY(fcm_netif) ff_list;          /* list linkage */
    u_int32_t             ff_enabled:1;     /* operational status */
    u_int32_t             ff_dcb_state;     /* DCB feature state */
    struct feature_info   ff_pfc_info;      /* PFC feature info */
-   struct feature_info   ff_pfc_saved;     /* saved PFC feature info */
    struct feature_info   ff_app_info;      /* App feature info */
-   struct feature_info   ff_llink_info;    /* LLink feature info */
-   u_int32_t             ff_llink_status;  /* LLink status */
-   u_int64_t             ff_mac;           /* MAC address */
-   int                   ff_vlan;          /* VLAN ID or -1 if none */
-   int                   ff_active;	   /* active device */
    u_int8_t              ff_operstate;     /* RFC 2863 operational status */
    u_int8_t              ff_qos_mask;      /* 801.p priority mask */
    enum fcm_dcbd_state   ff_dcbd_state;    /* DCB daemon state */
-   struct sa_timer       ff_event_timer;   /* Event timer */
-   char                  ff_name[IFNAMSIZ];/* Ethernet interface name */
+   char                  ifname[IFNAMSIZ]; /* Ethernet interface name */
+   int                   response_pending; /* dcbd query in progress */
+   int                   dcbd_retry_cnt;   /* Number of query attempts */
+   struct sa_timer       dcbd_retry_timer; /* dcbd retry timer */
 };
 
-TAILQ_HEAD(fcm_fcoe_head, fcm_fcoe);
+TAILQ_HEAD(fcm_netif_head, fcm_netif);
 
-struct fcm_fcoe_head fcm_fcoe_head;
+struct fcm_netif_head fcm_netif_head;
 extern char build_date[];
 
 static void fcm_dcbd_init(void);
 static void fcm_dcbd_shutdown(void);
 static void fcm_fcoe_init(void);
-#ifdef NOT_YET
-static struct fcm_fcoe *fcm_fcoe_lookup_mac(u_int64_t ff_mac, int vlan);
-static struct fcm_fcoe *fcm_fcoe_lookup_create_mac(u_int64_t ff_mac, int vlan);
-#endif
-static struct fcm_fcoe *fcm_fcoe_lookup_name(char *name);
-static struct fcm_vfcoe *fcm_vfcoe_lookup_name(struct fcm_fcoe *, char *);
-static struct fcm_fcoe *fcm_fcoe_lookup_create_ifname(char *);
-static struct fcm_vfcoe *fcm_vfcoe_lookup_create_ifname(char *, char *);
-static void fcm_fcoe_set_name(struct fcm_fcoe *, char *);
-static void fcm_fcoe_get_dcb_settings(struct fcm_fcoe *);
+static struct fcm_netif *fcm_netif_lookup(char *);
+static struct fcm_netif *fcm_netif_lookup_create(char *);
 static int fcm_link_init(void);
+static void fcm_dcbd_state_set(struct fcm_netif *, enum fcm_dcbd_state);
 
 #endif /* _FCOEMON_H_ */
diff --git a/fcoeplumb.in b/fcoeplumb.in
index 0445999..1721b60 100755
--- a/fcoeplumb.in
+++ b/fcoeplumb.in
@@ -22,7 +22,7 @@ cmdname=`basename $0`
 usage()
 {
 	echo usage: $cmdname \
-		'<ethX> [--reset | --create | --destroy] [--debug] [--syslog]' \
+		'<ifname real_ifname> [--reset | --create | --destroy] [--debug] [--syslog]' \
 		'[--qos-disable | --qos-enable  <pri>[,<pri>]...]' >&2
 	exit 1
 }
@@ -235,12 +235,14 @@ config_logging()
     fi
 }
 
-[ "$#" -lt 1 ] && usage
+[ "$#" -lt 2 ] && usage
 
 [ ${DEBUG_LOGGING} ] && $LOGGER "fcoeplumb arguments: ($*)"
 
 ifname=$1
 shift
+real_ifname=$1
+shift
 
 while [ "$#" -ge 1 ]
 do
@@ -282,8 +284,8 @@ done
 # This must be the first to do after parsing the command arguments!
 # Notice that the filter ID is used in find_skbedit_filter(),
 # add_skbedit_filter(), replace_skbedit_filter().
-fcoe_filter_id=`get_filter_id $ifname $FCOE_FILTER_KEY`
-fip_filter_id=`get_filter_id $ifname $FIP_FILTER_KEY`
+fcoe_filter_id=`get_filter_id $real_ifname $FCOE_FILTER_KEY`
+fip_filter_id=`get_filter_id $real_ifname $FIP_FILTER_KEY`
 
 if [ "$cmd" == "destroy" ]; then
 	remove_fcoe_interface $ifname
@@ -294,14 +296,14 @@ fi
 
 if [ "$qos_list" == "disable" ]; then
 	# Remove the FCoE filters
-	find_skbedit_filter $ifname $FCOE_ETHERTYPE $fcoe_filter_id
+	find_skbedit_filter $real_ifname $FCOE_ETHERTYPE $fcoe_filter_id
 	found_filter=$?
-	[ $found_filter -le 7 ] && delete_skbedit_filter $ifname $found_filter $FCOE_ETHERTYPE $fcoe_filter_id
+	[ $found_filter -le 7 ] && delete_skbedit_filter $real_ifname $found_filter $FCOE_ETHERTYPE $fcoe_filter_id
 
 	# Remove the FIP filters
-	find_skbedit_filter $ifname $FIP_ETHERTYPE $fip_filter_id
+	find_skbedit_filter $real_ifname $FIP_ETHERTYPE $fip_filter_id
 	found_filter=$?
-	[ $found_filter -le 7 ] && delete_skbedit_filter $ifname $found_filter $FIP_ETHERTYPE $fip_filter_id
+	[ $found_filter -le 7 ] && delete_skbedit_filter $real_ifname $found_filter $FIP_ETHERTYPE $fip_filter_id
 
 elif [ -n $qos_list ]; then
 	#
@@ -324,6 +326,7 @@ elif [ -n $qos_list ]; then
 			*)
 				echo "$cmdname: bad QOS value '$1'" >&2
 				usage
+
 				;;
 			esac
 			if [ -z "$QOS_BEST" ]; then
@@ -338,7 +341,7 @@ elif [ -n $qos_list ]; then
 	# If the best QOS is not found, do nothing.
 	[ -z "$QOS_BEST" ] && exit 0
 
-	[ ${DEBUG_LOGGING} ] && $LOGGER "$ifname - Choosing QOS '$QOS_BEST'"
+	[ ${DEBUG_LOGGING} ] && $LOGGER "$real_ifname - Choosing QOS '$QOS_BEST'"
 
 	#
 	# Setup the traffic classifier for FCoE
@@ -346,45 +349,45 @@ elif [ -n $qos_list ]; then
 	#
 	qos_queue=`expr $QOS_BEST`
 
-	find_multiq_qdisc $ifname
+	find_multiq_qdisc $real_ifname
 	found_qdisc=$?
 
 	if [ $found_qdisc -eq 1 ]; then
 	        # Adjust the FCoE filter
-		[ ${DEBUG_LOGGING} ] && $LOGGER "$ifname: Qdisc is found"
-		find_skbedit_filter $ifname $FCOE_ETHERTYPE $fcoe_filter_id
+		[ ${DEBUG_LOGGING} ] && $LOGGER "$real_ifname: Qdisc is found"
+		find_skbedit_filter $real_ifname $FCOE_ETHERTYPE $fcoe_filter_id
 		found_filter=$?
 		if [ $found_filter -gt 7 ]; then
-			add_skbedit_filter $ifname $qdisc_id $qos_queue \
+			add_skbedit_filter $real_ifname $qdisc_id $qos_queue \
 			    $FCOE_ETHERTYPE $fcoe_filter_id
 		elif [ $found_filter -ne $qos_queue ]; then
 			[ ${DEBUG_LOGGING} ] && $LOGGER \
-				"$ifname: Filter is found and QOS is different"
-			replace_skbedit_filter $ifname $qos_queue $FCOE_ETHERTYPE $fcoe_filter_id
+				"$real_ifname: Filter is found and QOS is different"
+			replace_skbedit_filter $real_ifname $qos_queue $FCOE_ETHERTYPE $fcoe_filter_id
 		else
 			[ ${DEBUG_LOGGING} ] && $LOGGER \
-				"$ifname: Filter is found and is identical"
+				"$real_ifname: Filter is found and is identical"
 		fi
 
 		# Adjust the FIP filter
-		[ ${DEBUG_LOGGING} ] && $LOGGER "$ifname: Qdisc is found"
-		find_skbedit_filter $ifname $FIP_ETHERTYPE $fip_filter_id
+		[ ${DEBUG_LOGGING} ] && $LOGGER "$real_ifname: Qdisc is found"
+		find_skbedit_filter $real_ifname $FIP_ETHERTYPE $fip_filter_id
 		found_filter=$?
 		if [ $found_filter -gt 7 ]; then
-			add_skbedit_filter $ifname $qdisc_id $qos_queue \
+			add_skbedit_filter $real_ifname $qdisc_id $qos_queue \
 			    $FIP_ETHERTYPE $fip_filter_id
 		elif [ $found_filter -ne $qos_queue ]; then
 			[ ${DEBUG_LOGGING} ] && $LOGGER \
 				"$ifname: Filter is found and QOS is different"
-			replace_skbedit_filter $ifname $qos_queue $FIP_ETHERTYPE $fip_filter_id
+			replace_skbedit_filter $real_ifname $qos_queue $FIP_ETHERTYPE $fip_filter_id
 		else
 			[ ${DEBUG_LOGGING} ] && $LOGGER \
-				"$ifname: Filter is found and is identical"
+				"$real_ifname: Filter is found and is identical"
 		fi
 	else
-		add_multiq_qdisc $ifname $qdisc_id
-		add_skbedit_filter $ifname $qdisc_id $qos_queue $FCOE_ETHERTYPE $fcoe_filter_id
-		add_skbedit_filter $ifname $qdisc_id $qos_queue $FIP_ETHERTYPE $fip_filter_id
+		add_multiq_qdisc $real_ifname $qdisc_id
+		add_skbedit_filter $real_ifname $qdisc_id $qos_queue $FCOE_ETHERTYPE $fcoe_filter_id
+		add_skbedit_filter $real_ifname $qdisc_id $qos_queue $FIP_ETHERTYPE $fip_filter_id
 	fi
 fi
 
diff --git a/include/scsi/fc/fc_els.h b/include/scsi/fc/fc_els.h
new file mode 100644
index 0000000..f943281
--- /dev/null
+++ b/include/scsi/fc/fc_els.h
@@ -0,0 +1,820 @@
+/*
+ * 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 _FC_ELS_H_
+#define	_FC_ELS_H_
+
+#include <linux/types.h>
+
+/*
+ * Fibre Channel Switch - Enhanced Link Services definitions.
+ * From T11 FC-LS Rev 1.2 June 7, 2005.
+ */
+
+/*
+ * ELS Command codes - byte 0 of the frame payload
+ */
+enum fc_els_cmd {
+	ELS_LS_RJT =	0x01,	/* ESL reject */
+	ELS_LS_ACC =	0x02,	/* ESL Accept */
+	ELS_PLOGI =	0x03,	/* N_Port login */
+	ELS_FLOGI =	0x04,	/* F_Port login */
+	ELS_LOGO =	0x05,	/* Logout */
+	ELS_ABTX =	0x06,	/* Abort exchange - obsolete */
+	ELS_RCS =	0x07,	/* read connection status */
+	ELS_RES =	0x08,	/* read exchange status block */
+	ELS_RSS =	0x09,	/* read sequence status block */
+	ELS_RSI =	0x0a,	/* read sequence initiative */
+	ELS_ESTS =	0x0b,	/* establish streaming */
+	ELS_ESTC =	0x0c,	/* estimate credit */
+	ELS_ADVC =	0x0d,	/* advise credit */
+	ELS_RTV =	0x0e,	/* read timeout value */
+	ELS_RLS =	0x0f,	/* read link error status block */
+	ELS_ECHO =	0x10,	/* echo */
+	ELS_TEST =	0x11,	/* test */
+	ELS_RRQ =	0x12,	/* reinstate recovery qualifier */
+	ELS_REC =	0x13,	/* read exchange concise */
+	ELS_SRR =	0x14,	/* sequence retransmission request */
+	ELS_PRLI =	0x20,	/* process login */
+	ELS_PRLO =	0x21,	/* process logout */
+	ELS_SCN =	0x22,	/* state change notification */
+	ELS_TPLS =	0x23,	/* test process login state */
+	ELS_TPRLO =	0x24,	/* third party process logout */
+	ELS_LCLM =	0x25,	/* login control list mgmt (obs) */
+	ELS_GAID =	0x30,	/* get alias_ID */
+	ELS_FACT =	0x31,	/* fabric activate alias_id */
+	ELS_FDACDT =	0x32,	/* fabric deactivate alias_id */
+	ELS_NACT =	0x33,	/* N-port activate alias_id */
+	ELS_NDACT =	0x34,	/* N-port deactivate alias_id */
+	ELS_QOSR =	0x40,	/* quality of service request */
+	ELS_RVCS =	0x41,	/* read virtual circuit status */
+	ELS_PDISC =	0x50,	/* discover N_port service params */
+	ELS_FDISC =	0x51,	/* discover F_port service params */
+	ELS_ADISC =	0x52,	/* discover address */
+	ELS_RNC =	0x53,	/* report node cap (obs) */
+	ELS_FARP_REQ =	0x54,	/* FC ARP request */
+	ELS_FARP_REPL =	0x55,	/* FC ARP reply */
+	ELS_RPS =	0x56,	/* read port status block */
+	ELS_RPL =	0x57,	/* read port list */
+	ELS_RPBC =	0x58,	/* read port buffer condition */
+	ELS_FAN =	0x60,	/* fabric address notification */
+	ELS_RSCN =	0x61,	/* registered state change notification */
+	ELS_SCR =	0x62,	/* state change registration */
+	ELS_RNFT =	0x63,	/* report node FC-4 types */
+	ELS_CSR =	0x68,	/* clock synch. request */
+	ELS_CSU =	0x69,	/* clock synch. update */
+	ELS_LINIT =	0x70,	/* loop initialize */
+	ELS_LSTS =	0x72,	/* loop status */
+	ELS_RNID =	0x78,	/* request node ID data */
+	ELS_RLIR =	0x79,	/* registered link incident report */
+	ELS_LIRR =	0x7a,	/* link incident record registration */
+	ELS_SRL =	0x7b,	/* scan remote loop */
+	ELS_SBRP =	0x7c,	/* set bit-error reporting params */
+	ELS_RPSC =	0x7d,	/* report speed capabilities */
+	ELS_QSA =	0x7e,	/* query security attributes */
+	ELS_EVFP =	0x7f,	/* exchange virt. fabrics params */
+	ELS_LKA =	0x80,	/* link keep-alive */
+	ELS_AUTH_ELS =	0x90,	/* authentication ELS */
+};
+
+/*
+ * Initializer useful for decoding table.
+ * Please keep this in sync with the above definitions.
+ */
+#define	FC_ELS_CMDS_INIT {			\
+	[ELS_LS_RJT] =	"LS_RJT",		\
+	[ELS_LS_ACC] =	"LS_ACC",		\
+	[ELS_PLOGI] =	"PLOGI",		\
+	[ELS_FLOGI] =	"FLOGI",		\
+	[ELS_LOGO] =	"LOGO",			\
+	[ELS_ABTX] =	"ABTX",			\
+	[ELS_RCS] =	"RCS",			\
+	[ELS_RES] =	"RES",			\
+	[ELS_RSS] =	"RSS",			\
+	[ELS_RSI] =	"RSI",			\
+	[ELS_ESTS] =	"ESTS",			\
+	[ELS_ESTC] =	"ESTC",			\
+	[ELS_ADVC] =	"ADVC",			\
+	[ELS_RTV] =	"RTV",			\
+	[ELS_RLS] =	"RLS",			\
+	[ELS_ECHO] =	"ECHO",			\
+	[ELS_TEST] =	"TEST",			\
+	[ELS_RRQ] =	"RRQ",			\
+	[ELS_REC] =	"REC",			\
+	[ELS_SRR] =	"SRR",			\
+	[ELS_PRLI] =	"PRLI",			\
+	[ELS_PRLO] =	"PRLO",			\
+	[ELS_SCN] =	"SCN",			\
+	[ELS_TPLS] =	"TPLS",			\
+	[ELS_TPRLO] =	"TPRLO",		\
+	[ELS_LCLM] =	"LCLM",			\
+	[ELS_GAID] =	"GAID",			\
+	[ELS_FACT] =	"FACT",			\
+	[ELS_FDACDT] =	"FDACDT",		\
+	[ELS_NACT] =	"NACT",			\
+	[ELS_NDACT] =	"NDACT",		\
+	[ELS_QOSR] =	"QOSR",			\
+	[ELS_RVCS] =	"RVCS",			\
+	[ELS_PDISC] =	"PDISC",		\
+	[ELS_FDISC] =	"FDISC",		\
+	[ELS_ADISC] =	"ADISC",		\
+	[ELS_RNC] =	"RNC",			\
+	[ELS_FARP_REQ] = "FARP_REQ",		\
+	[ELS_FARP_REPL] =  "FARP_REPL",		\
+	[ELS_RPS] =	"RPS",			\
+	[ELS_RPL] =	"RPL",			\
+	[ELS_RPBC] =	"RPBC",			\
+	[ELS_FAN] =	"FAN",			\
+	[ELS_RSCN] =	"RSCN",			\
+	[ELS_SCR] =	"SCR",			\
+	[ELS_RNFT] =	"RNFT",			\
+	[ELS_CSR] =	"CSR",			\
+	[ELS_CSU] =	"CSU",			\
+	[ELS_LINIT] =	"LINIT",		\
+	[ELS_LSTS] =	"LSTS",			\
+	[ELS_RNID] =	"RNID",			\
+	[ELS_RLIR] =	"RLIR",			\
+	[ELS_LIRR] =	"LIRR",			\
+	[ELS_SRL] =	"SRL",			\
+	[ELS_SBRP] =	"SBRP",			\
+	[ELS_RPSC] =	"RPSC",			\
+	[ELS_QSA] =	"QSA",			\
+	[ELS_EVFP] =	"EVFP",			\
+	[ELS_LKA] =	"LKA",			\
+	[ELS_AUTH_ELS] = "AUTH_ELS",		\
+}
+
+/*
+ * LS_ACC payload.
+ */
+struct fc_els_ls_acc {
+	__u8          la_cmd;		/* command code ELS_LS_ACC */
+	__u8          la_resv[3];	/* reserved */
+};
+
+/*
+ * ELS reject payload.
+ */
+struct fc_els_ls_rjt {
+	__u8	er_cmd;		/* command code ELS_LS_RJT */
+	__u8	er_resv[4];	/* reserved must be zero */
+	__u8	er_reason;	/* reason (enum fc_els_rjt_reason below) */
+	__u8	er_explan;	/* explanation (enum fc_els_rjt_explan below) */
+	__u8	er_vendor;	/* vendor specific code */
+};
+
+/*
+ * ELS reject reason codes (er_reason).
+ */
+enum fc_els_rjt_reason {
+	ELS_RJT_NONE =		0,	/* no reject - not to be sent */
+	ELS_RJT_INVAL =		0x01,	/* invalid ELS command code */
+	ELS_RJT_LOGIC =		0x03,	/* logical error */
+	ELS_RJT_BUSY =		0x05,	/* logical busy */
+	ELS_RJT_PROT =		0x07,	/* protocol error */
+	ELS_RJT_UNAB =		0x09,	/* unable to perform command request */
+	ELS_RJT_UNSUP =		0x0b,	/* command not supported */
+	ELS_RJT_INPROG =	0x0e,	/* command already in progress */
+	ELS_RJT_VENDOR =	0xff,	/* vendor specific error */
+};
+
+
+/*
+ * reason code explanation (er_explan).
+ */
+enum fc_els_rjt_explan {
+	ELS_EXPL_NONE =		0x00,	/* No additional explanation */
+	ELS_EXPL_SPP_OPT_ERR =	0x01,	/* service parameter error - options */
+	ELS_EXPL_SPP_ICTL_ERR =	0x03,	/* service parm error - initiator ctl */
+	ELS_EXPL_AH =		0x11,	/* invalid association header */
+	ELS_EXPL_AH_REQ =	0x13,	/* association_header required */
+	ELS_EXPL_SID =		0x15,	/* invalid originator S_ID */
+	ELS_EXPL_OXID_RXID =	0x17,	/* invalid OX_ID-RX_ID combination */
+	ELS_EXPL_INPROG =	0x19,	/* Request already in progress */
+	ELS_EXPL_PLOGI_REQD =	0x1e,	/* N_Port login required */
+	ELS_EXPL_INSUF_RES =	0x29,	/* insufficient resources */
+	ELS_EXPL_UNAB_DATA =	0x2a,	/* unable to supply requested data */
+	ELS_EXPL_UNSUPR =	0x2c,	/* Request not supported */
+	ELS_EXPL_INV_LEN =	0x2d,	/* Invalid payload length */
+	/* TBD - above definitions incomplete */
+};
+
+/*
+ * Common service parameters (N ports).
+ */
+struct fc_els_csp {
+	__u8		sp_hi_ver;	/* highest version supported (obs.) */
+	__u8		sp_lo_ver;	/* highest version supported (obs.) */
+	__be16		sp_bb_cred;	/* buffer-to-buffer credits */
+	__be16		sp_features;	/* common feature flags */
+	__be16		sp_bb_data;	/* b-b state number and data field sz */
+	union {
+		struct {
+			__be16	_sp_tot_seq; /* total concurrent sequences */
+			__be16	_sp_rel_off; /* rel. offset by info cat */
+		} sp_plogi;
+		struct {
+			__be32	_sp_r_a_tov; /* resource alloc. timeout msec */
+		} sp_flogi_acc;
+	} sp_u;
+	__be32		sp_e_d_tov;	/* error detect timeout value */
+};
+#define	sp_tot_seq	sp_u.sp_plogi._sp_tot_seq
+#define	sp_rel_off	sp_u.sp_plogi._sp_rel_off
+#define	sp_r_a_tov	sp_u.sp_flogi_acc._sp_r_a_tov
+
+#define	FC_SP_BB_DATA_MASK 0xfff /* mask for data field size in sp_bb_data */
+
+/*
+ * Minimum and maximum values for max data field size in service parameters.
+ */
+#define	FC_SP_MIN_MAX_PAYLOAD	FC_MIN_MAX_PAYLOAD
+#define	FC_SP_MAX_MAX_PAYLOAD	FC_MAX_PAYLOAD
+
+/*
+ * sp_features
+ */
+#define	FC_SP_FT_NPIV	0x8000	/* multiple N_Port_ID support (FLOGI) */
+#define	FC_SP_FT_CIRO	0x8000	/* continuously increasing rel off (PLOGI) */
+#define	FC_SP_FT_CLAD	0x8000	/* clean address (in FLOGI LS_ACC) */
+#define	FC_SP_FT_RAND	0x4000	/* random relative offset */
+#define	FC_SP_FT_VAL	0x2000	/* valid vendor version level */
+#define	FC_SP_FT_NPIV_ACC	0x2000	/* NPIV assignment (FLOGI LS_ACC) */
+#define	FC_SP_FT_FPORT	0x1000	/* F port (1) vs. N port (0) */
+#define	FC_SP_FT_ABB	0x0800	/* alternate BB_credit management */
+#define	FC_SP_FT_EDTR	0x0400	/* E_D_TOV Resolution is nanoseconds */
+#define	FC_SP_FT_MCAST	0x0200	/* multicast */
+#define	FC_SP_FT_BCAST	0x0100	/* broadcast */
+#define	FC_SP_FT_HUNT	0x0080	/* hunt group */
+#define	FC_SP_FT_SIMP	0x0040	/* dedicated simplex */
+#define	FC_SP_FT_SEC	0x0020	/* reserved for security */
+#define	FC_SP_FT_CSYN	0x0010	/* clock synch. supported */
+#define	FC_SP_FT_RTTOV	0x0008	/* R_T_TOV value 100 uS, else 100 mS */
+#define	FC_SP_FT_HALF	0x0004	/* dynamic half duplex */
+#define	FC_SP_FT_SEQC	0x0002	/* SEQ_CNT */
+#define	FC_SP_FT_PAYL	0x0001	/* FLOGI payload length 256, else 116 */
+
+/*
+ * Class-specific service parameters.
+ */
+struct fc_els_cssp {
+	__be16		cp_class;	/* class flags */
+	__be16		cp_init;	/* initiator flags */
+	__be16		cp_recip;	/* recipient flags */
+	__be16		cp_rdfs;	/* receive data field size */
+	__be16		cp_con_seq;	/* concurrent sequences */
+	__be16		cp_ee_cred;	/* N-port end-to-end credit */
+	__u8		cp_resv1;	/* reserved */
+	__u8		cp_open_seq;	/* open sequences per exchange */
+	__u8		_cp_resv2[2];	/* reserved */
+};
+
+/*
+ * cp_class flags.
+ */
+#define	FC_CPC_VALID	0x8000		/* class valid */
+#define	FC_CPC_IMIX	0x4000		/* intermix mode */
+#define	FC_CPC_SEQ	0x0800		/* sequential delivery */
+#define	FC_CPC_CAMP	0x0200		/* camp-on */
+#define	FC_CPC_PRI	0x0080		/* priority */
+
+/*
+ * cp_init flags.
+ * (TBD: not all flags defined here).
+ */
+#define	FC_CPI_CSYN	0x0010		/* clock synch. capable */
+
+/*
+ * cp_recip flags.
+ */
+#define	FC_CPR_CSYN	0x0008		/* clock synch. capable */
+
+/*
+ * NFC_ELS_FLOGI: Fabric login request.
+ * NFC_ELS_PLOGI: Port login request (same format).
+ */
+struct fc_els_flogi {
+	__u8		fl_cmd;		/* command */
+	__u8		_fl_resvd[3];	/* must be zero */
+	struct fc_els_csp fl_csp;	/* common service parameters */
+	__be64		fl_wwpn;	/* port name */
+	__be64		fl_wwnn;	/* node name */
+	struct fc_els_cssp fl_cssp[4];	/* class 1-4 service parameters */
+	__u8		fl_vend[16];	/* vendor version level */
+} __attribute__((__packed__));
+
+/*
+ * Process login service parameter page.
+ */
+struct fc_els_spp {
+	__u8		spp_type;	/* type code or common service params */
+	__u8		spp_type_ext;	/* type code extension */
+	__u8		spp_flags;
+	__u8		_spp_resvd;
+	__be32		spp_orig_pa;	/* originator process associator */
+	__be32		spp_resp_pa;	/* responder process associator */
+	__be32		spp_params;	/* service parameters */
+};
+
+/*
+ * spp_flags.
+ */
+#define	FC_SPP_OPA_VAL	    0x80	/* originator proc. assoc. valid */
+#define	FC_SPP_RPA_VAL	    0x40	/* responder proc. assoc. valid */
+#define	FC_SPP_EST_IMG_PAIR 0x20	/* establish image pair */
+#define	FC_SPP_RESP_MASK    0x0f	/* mask for response code (below) */
+
+/*
+ * SPP response code in spp_flags - lower 4 bits.
+ */
+enum fc_els_spp_resp {
+	FC_SPP_RESP_ACK	=	1,	/* request executed */
+	FC_SPP_RESP_RES =	2,	/* unable due to lack of resources */
+	FC_SPP_RESP_INIT =	3,	/* initialization not complete */
+	FC_SPP_RESP_NO_PA = 	4,	/* unknown process associator */
+	FC_SPP_RESP_CONF = 	5,	/* configuration precludes image pair */
+	FC_SPP_RESP_COND = 	6,	/* request completed conditionally */
+	FC_SPP_RESP_MULT = 	7,	/* unable to handle multiple SPPs */
+	FC_SPP_RESP_INVL = 	8,	/* SPP is invalid */
+};
+
+/*
+ * ELS_RRQ - Reinstate Recovery Qualifier
+ */
+struct fc_els_rrq {
+	__u8		rrq_cmd;	/* command (0x12) */
+	__u8		rrq_zero[3];	/* specified as zero - part of cmd */
+	__u8		rrq_resvd;	/* reserved */
+	__u8		rrq_s_id[3];	/* originator FID */
+	__be16		rrq_ox_id;	/* originator exchange ID */
+	__be16		rrq_rx_id;	/* responders exchange ID */
+};
+
+/*
+ * ELS_REC - Read exchange concise.
+ */
+struct fc_els_rec {
+	__u8		rec_cmd;	/* command (0x13) */
+	__u8		rec_zero[3];	/* specified as zero - part of cmd */
+	__u8		rec_resvd;	/* reserved */
+	__u8		rec_s_id[3];	/* originator FID */
+	__be16		rec_ox_id;	/* originator exchange ID */
+	__be16		rec_rx_id;	/* responders exchange ID */
+};
+
+/*
+ * ELS_REC LS_ACC payload.
+ */
+struct fc_els_rec_acc {
+	__u8		reca_cmd;	/* accept (0x02) */
+	__u8		reca_zero[3];	/* specified as zero - part of cmd */
+	__be16		reca_ox_id;	/* originator exchange ID */
+	__be16		reca_rx_id;	/* responders exchange ID */
+	__u8		reca_resvd1;	/* reserved */
+	__u8		reca_ofid[3];	/* originator FID */
+	__u8		reca_resvd2;	/* reserved */
+	__u8		reca_rfid[3];	/* responder FID */
+	__be32		reca_fc4value;	/* FC4 value */
+	__be32		reca_e_stat;	/* ESB (exchange status block) status */
+};
+
+/*
+ * ELS_PRLI - Process login request and response.
+ */
+struct fc_els_prli {
+	__u8		prli_cmd;	/* command */
+	__u8		prli_spp_len;	/* length of each serv. parm. page */
+	__be16		prli_len;	/* length of entire payload */
+	/* service parameter pages follow */
+};
+
+/*
+ * ELS_ADISC payload
+ */
+struct fc_els_adisc {
+	__u8		adisc_cmd;
+	__u8		adisc_resv[3];
+	__u8            adisc_resv1;
+	__u8            adisc_hard_addr[3];
+	__be64          adisc_wwpn;
+	__be64          adisc_wwnn;
+	__u8            adisc_resv2;
+	__u8            adisc_port_id[3];
+} __attribute__((__packed__));
+
+/*
+ * ELS_LOGO - process or fabric logout.
+ */
+struct fc_els_logo {
+	__u8		fl_cmd;		/* command code */
+	__u8		fl_zero[3];	/* specified as zero - part of cmd */
+	__u8		fl_resvd;	/* reserved */
+	__u8		fl_n_port_id[3];/* N port ID */
+	__be64		fl_n_port_wwn;	/* port name */
+};
+
+/*
+ * ELS_RTV - read timeout value.
+ */
+struct fc_els_rtv {
+	__u8		rtv_cmd;	/* command code 0x0e */
+	__u8		rtv_zero[3];	/* specified as zero - part of cmd */
+};
+
+/*
+ * LS_ACC for ELS_RTV - read timeout value.
+ */
+struct fc_els_rtv_acc {
+	__u8		rtv_cmd;	/* command code 0x02 */
+	__u8		rtv_zero[3];	/* specified as zero - part of cmd */
+	__be32		rtv_r_a_tov;	/* resource allocation timeout value */
+	__be32		rtv_e_d_tov;	/* error detection timeout value */
+	__be32		rtv_toq;	/* timeout qualifier (see below) */
+};
+
+/*
+ * rtv_toq bits.
+ */
+#define	FC_ELS_RTV_EDRES (1 << 26)	/* E_D_TOV resolution is nS else mS */
+#define	FC_ELS_RTV_RTTOV (1 << 19)	/* R_T_TOV is 100 uS else 100 mS */
+
+/*
+ * ELS_SCR - state change registration payload.
+ */
+struct fc_els_scr {
+	__u8		scr_cmd;	/* command code */
+	__u8		scr_resv[6];	/* reserved */
+	__u8		scr_reg_func;	/* registration function (see below) */
+};
+
+enum fc_els_scr_func {
+	ELS_SCRF_FAB =	1,	/* fabric-detected registration */
+	ELS_SCRF_NPORT = 2,	/* Nx_Port-detected registration */
+	ELS_SCRF_FULL =	3,	/* full registration */
+	ELS_SCRF_CLEAR = 255,	/* remove any current registrations */
+};
+
+/*
+ * ELS_RSCN - registered state change notification payload.
+ */
+struct fc_els_rscn {
+	__u8		rscn_cmd;	/* RSCN opcode (0x61) */
+	__u8		rscn_page_len;	/* page length (4) */
+	__be16		rscn_plen;	/* payload length including this word */
+
+	/* followed by 4-byte generic affected Port_ID pages */
+};
+
+struct fc_els_rscn_page {
+	__u8		rscn_page_flags; /* event and address format */
+	__u8		rscn_fid[3];	/* fabric ID */
+};
+
+#define	ELS_RSCN_EV_QUAL_BIT	2	/* shift count for event qualifier */
+#define	ELS_RSCN_EV_QUAL_MASK	0xf	/* mask for event qualifier */
+#define	ELS_RSCN_ADDR_FMT_BIT	0	/* shift count for address format */
+#define	ELS_RSCN_ADDR_FMT_MASK	0x3	/* mask for address format */
+
+enum fc_els_rscn_ev_qual {
+	ELS_EV_QUAL_NONE = 0,		/* unspecified */
+	ELS_EV_QUAL_NS_OBJ = 1,		/* changed name server object */
+	ELS_EV_QUAL_PORT_ATTR = 2,	/* changed port attribute */
+	ELS_EV_QUAL_SERV_OBJ = 3,	/* changed service object */
+	ELS_EV_QUAL_SW_CONFIG = 4,	/* changed switch configuration */
+	ELS_EV_QUAL_REM_OBJ = 5,	/* removed object */
+};
+
+enum fc_els_rscn_addr_fmt {
+	ELS_ADDR_FMT_PORT = 0,	/* rscn_fid is a port address */
+	ELS_ADDR_FMT_AREA = 1,	/* rscn_fid is a area address */
+	ELS_ADDR_FMT_DOM = 2,	/* rscn_fid is a domain address */
+	ELS_ADDR_FMT_FAB = 3,	/* anything on fabric may have changed */
+};
+
+/*
+ * ELS_RNID - request Node ID.
+ */
+struct fc_els_rnid {
+	__u8		rnid_cmd;	/* RNID opcode (0x78) */
+	__u8		rnid_resv[3];	/* reserved */
+	__u8		rnid_fmt;	/* data format */
+	__u8		rnid_resv2[3];	/* reserved */
+};
+
+/*
+ * Node Identification Data formats (rnid_fmt)
+ */
+enum fc_els_rnid_fmt {
+	ELS_RNIDF_NONE = 0,		/* no specific identification data */
+	ELS_RNIDF_GEN = 0xdf,		/* general topology discovery format */
+};
+
+/*
+ * ELS_RNID response.
+ */
+struct fc_els_rnid_resp {
+	__u8		rnid_cmd;	/* response code (LS_ACC) */
+	__u8		rnid_resv[3];	/* reserved */
+	__u8		rnid_fmt;	/* data format */
+	__u8		rnid_cid_len;	/* common ID data length */
+	__u8		rnid_resv2;	/* reserved */
+	__u8		rnid_sid_len;	/* specific ID data length */
+};
+
+struct fc_els_rnid_cid {
+	__be64		rnid_wwpn;	/* N port name */
+	__be64		rnid_wwnn;	/* node name */
+};
+
+struct fc_els_rnid_gen {
+	__u8		rnid_vend_id[16]; /* vendor-unique ID */
+	__be32		rnid_atype;	/* associated type (see below) */
+	__be32		rnid_phys_port;	/* physical port number */
+	__be32		rnid_att_nodes;	/* number of attached nodes */
+	__u8		rnid_node_mgmt;	/* node management (see below) */
+	__u8		rnid_ip_ver;	/* IP version (see below) */
+	__be16		rnid_prot_port;	/* UDP / TCP port number */
+	__be32		rnid_ip_addr[4]; /* IP address */
+	__u8		rnid_resvd[2];	/* reserved */
+	__be16		rnid_vend_spec;	/* vendor-specific field */
+};
+
+enum fc_els_rnid_atype {
+	ELS_RNIDA_UNK =		0x01,	/* unknown */
+	ELS_RNIDA_OTHER =	0x02,	/* none of the following */
+	ELS_RNIDA_HUB =		0x03,
+	ELS_RNIDA_SWITCH =	0x04,
+	ELS_RNIDA_GATEWAY =	0x05,
+	ELS_RNIDA_CONV =	0x06,   /* Obsolete, do not use this value */
+	ELS_RNIDA_HBA =	        0x07,   /* Obsolete, do not use this value */
+	ELS_RNIDA_PROXY =       0x08,   /* Obsolete, do not use this value */
+	ELS_RNIDA_STORAGE =	0x09,
+	ELS_RNIDA_HOST =	0x0a,
+	ELS_RNIDA_SUBSYS =	0x0b,	/* storage subsystem (e.g., RAID) */
+	ELS_RNIDA_ACCESS =	0x0e,	/* access device (e.g. media changer) */
+	ELS_RNIDA_NAS =		0x11,	/* NAS server */
+	ELS_RNIDA_BRIDGE =	0x12,	/* bridge */
+	ELS_RNIDA_VIRT =	0x13,	/* virtualization device */
+	ELS_RNIDA_MF =		0xff,	/* multifunction device (bits below) */
+	ELS_RNIDA_MF_HUB =	1UL << 31, 	/* hub */
+	ELS_RNIDA_MF_SW =	1UL << 30, 	/* switch */
+	ELS_RNIDA_MF_GW =	1UL << 29,	/* gateway */
+	ELS_RNIDA_MF_ST =	1UL << 28,	/* storage */
+	ELS_RNIDA_MF_HOST =	1UL << 27,	/* host */
+	ELS_RNIDA_MF_SUB =	1UL << 26,	/* storage subsystem */
+	ELS_RNIDA_MF_ACC =	1UL << 25,	/* storage access dev */
+	ELS_RNIDA_MF_WDM =	1UL << 24,	/* wavelength division mux */
+	ELS_RNIDA_MF_NAS =	1UL << 23,	/* NAS server */
+	ELS_RNIDA_MF_BR =	1UL << 22,	/* bridge */
+	ELS_RNIDA_MF_VIRT =	1UL << 21,	/* virtualization device */
+};
+
+enum fc_els_rnid_mgmt {
+	ELS_RNIDM_SNMP =	0,
+	ELS_RNIDM_TELNET =	1,
+	ELS_RNIDM_HTTP =	2,
+	ELS_RNIDM_HTTPS =	3,
+	ELS_RNIDM_XML =		4,	/* HTTP + XML */
+};
+
+enum fc_els_rnid_ipver {
+	ELS_RNIDIP_NONE =	0,	/* no IP support or node mgmt. */
+	ELS_RNIDIP_V4 =		1,	/* IPv4 */
+	ELS_RNIDIP_V6 =		2,	/* IPv6 */
+};
+
+/*
+ * ELS RPL - Read Port List.
+ */
+struct fc_els_rpl {
+	__u8		rpl_cmd;	/* command */
+	__u8		rpl_resv[5];	/* reserved - must be zero */
+	__be16		rpl_max_size;	/* maximum response size or zero */
+	__u8		rpl_resv1;	/* reserved - must be zero */
+	__u8		rpl_index[3];	/* starting index */
+};
+
+/*
+ * Port number block in RPL response.
+ */
+struct fc_els_pnb {
+	__be32		pnb_phys_pn;	/* physical port number */
+	__u8		pnb_resv;	/* reserved */
+	__u8		pnb_port_id[3];	/* port ID */
+	__be64		pnb_wwpn;	/* port name */
+};
+
+/*
+ * RPL LS_ACC response.
+ */
+struct fc_els_rpl_resp {
+	__u8		rpl_cmd;	/* ELS_LS_ACC */
+	__u8		rpl_resv1;	/* reserved - must be zero */
+	__be16		rpl_plen;	/* payload length */
+	__u8		rpl_resv2;	/* reserved - must be zero */
+	__u8		rpl_llen[3];	/* list length */
+	__u8		rpl_resv3;	/* reserved - must be zero */
+	__u8		rpl_index[3];	/* starting index */
+	struct fc_els_pnb rpl_pnb[1];	/* variable number of PNBs */
+};
+
+/*
+ * Link Error Status Block.
+ */
+struct fc_els_lesb {
+	__be32		lesb_link_fail;	/* link failure count */
+	__be32		lesb_sync_loss;	/* loss of synchronization count */
+	__be32		lesb_sig_loss;	/* loss of signal count */
+	__be32		lesb_prim_err;	/* primitive sequence error count */
+	__be32		lesb_inv_word;	/* invalid transmission word count */
+	__be32		lesb_inv_crc;	/* invalid CRC count */
+};
+
+/*
+ * ELS RPS - Read Port Status Block request.
+ */
+struct fc_els_rps {
+	__u8		rps_cmd;	/* command */
+	__u8		rps_resv[2];	/* reserved - must be zero */
+	__u8		rps_flag;	/* flag - see below */
+	__be64		rps_port_spec;	/* port selection */
+};
+
+enum fc_els_rps_flag {
+	FC_ELS_RPS_DID =	0x00,	/* port identified by D_ID of req. */
+	FC_ELS_RPS_PPN =	0x01,	/* port_spec is physical port number */
+	FC_ELS_RPS_WWPN =	0x02,	/* port_spec is port WWN */
+};
+
+/*
+ * ELS RPS LS_ACC response.
+ */
+struct fc_els_rps_resp {
+	__u8		rps_cmd;	/* command - LS_ACC */
+	__u8		rps_resv[2];	/* reserved - must be zero */
+	__u8		rps_flag;	/* flag - see below */
+	__u8		rps_resv2[2];	/* reserved */
+	__be16		rps_status;	/* port status - see below */
+	struct fc_els_lesb rps_lesb;	/* link error status block */
+};
+
+enum fc_els_rps_resp_flag {
+	FC_ELS_RPS_LPEV =	0x01,	/* L_port extension valid */
+};
+
+enum fc_els_rps_resp_status {
+	FC_ELS_RPS_PTP =	1 << 5,	/* point-to-point connection */
+	FC_ELS_RPS_LOOP =	1 << 4,	/* loop mode */
+	FC_ELS_RPS_FAB =	1 << 3,	/* fabric present */
+	FC_ELS_RPS_NO_SIG =	1 << 2,	/* loss of signal */
+	FC_ELS_RPS_NO_SYNC =	1 << 1,	/* loss of synchronization */
+	FC_ELS_RPS_RESET =	1 << 0,	/* in link reset protocol */
+};
+
+/*
+ * ELS LIRR - Link Incident Record Registration request.
+ */
+struct fc_els_lirr {
+	__u8		lirr_cmd;	/* command */
+	__u8		lirr_resv[3];	/* reserved - must be zero */
+	__u8		lirr_func;	/* registration function */
+	__u8		lirr_fmt;	/* FC-4 type of RLIR requested */
+	__u8		lirr_resv2[2];	/* reserved - must be zero */
+};
+
+enum fc_els_lirr_func {
+	ELS_LIRR_SET_COND = 	0x01,	/* set - conditionally receive */
+	ELS_LIRR_SET_UNCOND = 	0x02,	/* set - unconditionally receive */
+	ELS_LIRR_CLEAR = 	0xff	/* clear registration */
+};
+
+/*
+ * ELS SRL - Scan Remote Loop request.
+ */
+struct fc_els_srl {
+	__u8		srl_cmd;	/* command */
+	__u8		srl_resv[3];	/* reserved - must be zero */
+	__u8		srl_flag;	/* flag - see below */
+	__u8		srl_flag_param[3];	/* flag parameter */
+};
+
+enum fc_els_srl_flag {
+	FC_ELS_SRL_ALL =	0x00,	/* scan all FL ports */
+	FC_ELS_SRL_ONE =	0x01,	/* scan specified loop */
+	FC_ELS_SRL_EN_PER =	0x02,	/* enable periodic scanning (param) */
+	FC_ELS_SRL_DIS_PER =	0x03,	/* disable periodic scanning */
+};
+
+/*
+ * ELS RLS - Read Link Error Status Block request.
+ */
+struct fc_els_rls {
+	__u8		rls_cmd;	/* command */
+	__u8		rls_resv[4];	/* reserved - must be zero */
+	__u8		rls_port_id[3];	/* port ID */
+};
+
+/*
+ * ELS RLS LS_ACC Response.
+ */
+struct fc_els_rls_resp {
+	__u8		rls_cmd;	/* ELS_LS_ACC */
+	__u8		rls_resv[3];	/* reserved - must be zero */
+	struct fc_els_lesb rls_lesb;	/* link error status block */
+};
+
+/*
+ * ELS RLIR - Registered Link Incident Report.
+ * This is followed by the CLIR and the CLID, described below.
+ */
+struct fc_els_rlir {
+	__u8		rlir_cmd;	/* command */
+	__u8		rlir_resv[3];	/* reserved - must be zero */
+	__u8		rlir_fmt;	/* format (FC4-type if type specific) */
+	__u8		rlir_clr_len;	/* common link incident record length */
+	__u8		rlir_cld_len;	/* common link incident desc. length */
+	__u8		rlir_slr_len;	/* spec. link incident record length */
+};
+
+/*
+ * CLIR - Common Link Incident Record Data. - Sent via RLIR.
+ */
+struct fc_els_clir {
+	__be64		clir_wwpn;	/* incident port name */
+	__be64		clir_wwnn;	/* incident port node name */
+	__u8		clir_port_type;	/* incident port type */
+	__u8		clir_port_id[3];	/* incident port ID */
+
+	__be64		clir_conn_wwpn;	/* connected port name */
+	__be64		clir_conn_wwnn;	/* connected node name */
+	__be64		clir_fab_name;	/* fabric name */
+	__be32		clir_phys_port;	/* physical port number */
+	__be32		clir_trans_id;	/* transaction ID */
+	__u8		clir_resv[3];	/* reserved */
+	__u8		clir_ts_fmt;	/* time stamp format */
+	__be64		clir_timestamp;	/* time stamp */
+};
+
+/*
+ * CLIR clir_ts_fmt - time stamp format values.
+ */
+enum fc_els_clir_ts_fmt {
+	ELS_CLIR_TS_UNKNOWN = 	0,	/* time stamp field unknown */
+	ELS_CLIR_TS_SEC_FRAC = 	1,	/* time in seconds and fractions */
+	ELS_CLIR_TS_CSU =	2,	/* time in clock synch update format */
+};
+
+/*
+ * Common Link Incident Descriptor - sent via RLIR.
+ */
+struct fc_els_clid {
+	__u8		clid_iq;	/* incident qualifier flags */
+	__u8		clid_ic;	/* incident code */
+	__be16		clid_epai;	/* domain/area of ISL */
+};
+
+/*
+ * CLID incident qualifier flags.
+ */
+enum fc_els_clid_iq {
+	ELS_CLID_SWITCH =	0x20,	/* incident port is a switch node */
+	ELS_CLID_E_PORT =	0x10,	/* incident is an ISL (E) port */
+	ELS_CLID_SEV_MASK =	0x0c,	/* severity 2-bit field mask */
+	ELS_CLID_SEV_INFO =	0x00,	/* report is informational */
+	ELS_CLID_SEV_INOP =	0x08,	/* link not operational */
+	ELS_CLID_SEV_DEG =	0x04,	/* link degraded but operational */
+	ELS_CLID_LASER =	0x02,	/* subassembly is a laser */
+	ELS_CLID_FRU =		0x01,	/* format can identify a FRU */
+};
+
+/*
+ * CLID incident code.
+ */
+enum fc_els_clid_ic {
+	ELS_CLID_IC_IMPL =	1,	/* implicit incident */
+	ELS_CLID_IC_BER =	2,	/* bit-error-rate threshold exceeded */
+	ELS_CLID_IC_LOS =	3,	/* loss of synch or signal */
+	ELS_CLID_IC_NOS =	4,	/* non-operational primitive sequence */
+	ELS_CLID_IC_PST =	5,	/* primitive sequence timeout */
+	ELS_CLID_IC_INVAL =	6,	/* invalid primitive sequence */
+	ELS_CLID_IC_LOOP_TO =	7,	/* loop initialization time out */
+	ELS_CLID_IC_LIP =	8,	/* receiving LIP */
+};
+
+#endif /* _FC_ELS_H_ */
diff --git a/include/scsi/fc/fc_encaps.h b/include/scsi/fc/fc_encaps.h
new file mode 100644
index 0000000..f180c3e
--- /dev/null
+++ b/include/scsi/fc/fc_encaps.h
@@ -0,0 +1,138 @@
+/*
+ * 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 _FC_ENCAPS_H_
+#define _FC_ENCAPS_H_
+
+/*
+ * Protocol definitions from RFC 3643 - Fibre Channel Frame Encapsulation.
+ *
+ * Note:  The frame length field is the number of 32-bit words in
+ * the encapsulation including the fcip_encaps_header, CRC and EOF words.
+ * The minimum frame length value in bytes is (32 + 24 + 4 + 4) * 4 = 64.
+ * The maximum frame length value in bytes is (32 + 24 + 2112 + 4 + 4) = 2172.
+ */
+#define FC_ENCAPS_MIN_FRAME_LEN 64	/* min frame len (bytes) (see above) */
+#define FC_ENCAPS_MAX_FRAME_LEN (FC_ENCAPS_MIN_FRAME_LEN + FC_MAX_PAYLOAD)
+
+#define FC_ENCAPS_VER       1           /* current version number */
+
+struct fc_encaps_hdr {
+	__u8	fc_proto;	/* protocol number */
+	__u8	fc_ver;		/* version of encapsulation */
+	__u8	fc_proto_n;	/* ones complement of protocol */
+	__u8	fc_ver_n;	/* ones complement of version */
+
+	unsigned char fc_proto_data[8]; /* protocol specific data */
+
+	__be16	fc_len_flags;	/* 10-bit length/4 w/ 6 flag bits */
+	__be16	fc_len_flags_n;	/* ones complement of length / flags */
+
+	/*
+	 * Offset 0x10
+	 */
+	__be32	fc_time[2];	/* time stamp: seconds and fraction */
+	__be32	fc_crc;		/* CRC */
+	__be32	fc_sof;		/* start of frame (see FC_SOF below) */
+
+	/* 0x20 - FC frame content followed by EOF word */
+};
+
+#define FCIP_ENCAPS_HDR_LEN 0x20	/* expected length for asserts */
+
+/*
+ * Macro's for making redundant copies of EOF and SOF.
+ */
+#define FC_XY(x, y)		((((x) & 0xff) << 8) | ((y) & 0xff))
+#define FC_XYXY(x, y)		((FCIP_XY(x, y) << 16) | FCIP_XY(x, y))
+#define FC_XYNN(x, y)		(FCIP_XYXY(x, y) ^ 0xffff)
+
+#define FC_SOF_ENCODE(n)	FC_XYNN(n, n)
+#define FC_EOF_ENCODE(n)	FC_XYNN(n, n)
+
+/*
+ * SOF / EOF bytes.
+ */
+enum fc_sof {
+	FC_SOF_F =	0x28,	/* fabric */
+	FC_SOF_I4 =	0x29,	/* initiate class 4 */
+	FC_SOF_I2 =	0x2d,	/* initiate class 2 */
+	FC_SOF_I3 =	0x2e,	/* initiate class 3 */
+	FC_SOF_N4 =	0x31,	/* normal class 4 */
+	FC_SOF_N2 =	0x35,	/* normal class 2 */
+	FC_SOF_N3 =	0x36,	/* normal class 3 */
+	FC_SOF_C4 =	0x39,	/* activate class 4 */
+} __attribute__((packed));
+
+enum fc_eof {
+	FC_EOF_N =	0x41,	/* normal (not last frame of seq) */
+	FC_EOF_T =	0x42,	/* terminate (last frame of sequence) */
+	FC_EOF_RT =	0x44,
+	FC_EOF_DT =	0x46,	/* disconnect-terminate class-1 */
+	FC_EOF_NI =	0x49,	/* normal-invalid */
+	FC_EOF_DTI =	0x4e,	/* disconnect-terminate-invalid */
+	FC_EOF_RTI =	0x4f,
+	FC_EOF_A =	0x50,	/* abort */
+} __attribute__((packed));
+
+#define FC_SOF_CLASS_MASK 0x06	/* mask for class of service in SOF */
+
+/*
+ * Define classes in terms of the SOF code (initial).
+ */
+enum fc_class {
+	FC_CLASS_NONE = 0,	/* software value indicating no class */
+	FC_CLASS_2 =	FC_SOF_I2,
+	FC_CLASS_3 =	FC_SOF_I3,
+	FC_CLASS_4 =	FC_SOF_I4,
+	FC_CLASS_F =	FC_SOF_F,
+};
+
+/*
+ * Determine whether SOF code indicates the need for a BLS ACK.
+ */
+static inline int fc_sof_needs_ack(enum fc_sof sof)
+{
+	return (~sof) & 0x02;	/* true for class 1, 2, 4, 6, or F */
+}
+
+/*
+ * Given an fc_class, return the normal (non-initial) SOF value.
+ */
+static inline enum fc_sof fc_sof_normal(enum fc_class class)
+{
+	return class + FC_SOF_N3 - FC_SOF_I3;	/* diff is always 8 */
+}
+
+/*
+ * Compute class from SOF value.
+ */
+static inline enum fc_class fc_sof_class(enum fc_sof sof)
+{
+	return (sof & 0x7) | FC_SOF_F;
+}
+
+/*
+ * Determine whether SOF is for the initial frame of a sequence.
+ */
+static inline int fc_sof_is_init(enum fc_sof sof)
+{
+	return sof < 0x30;
+}
+
+#endif /* _FC_ENCAPS_H_ */
diff --git a/include/scsi/fc/fc_fc2.h b/include/scsi/fc/fc_fc2.h
new file mode 100644
index 0000000..f87777d
--- /dev/null
+++ b/include/scsi/fc/fc_fc2.h
@@ -0,0 +1,123 @@
+/*
+ * 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 _FC_FC2_H_
+#define _FC_FC2_H_
+
+/*
+ * Fibre Channel Exchanges and Sequences.
+ */
+#ifndef PACKED
+#define PACKED  __attribute__ ((__packed__))
+#endif /* PACKED */
+
+
+/*
+ * Sequence Status Block.
+ * This format is set by the FC-FS standard and is sent over the wire.
+ * Note that the fields aren't all naturally aligned.
+ */
+struct fc_ssb {
+	__u8	ssb_seq_id;		/* sequence ID */
+	__u8	_ssb_resvd;
+	__be16	ssb_low_seq_cnt;	/* lowest SEQ_CNT */
+
+	__be16	ssb_high_seq_cnt;	/* highest SEQ_CNT */
+	__be16	ssb_s_stat;		/* sequence status flags */
+
+	__be16	ssb_err_seq_cnt;	/* error SEQ_CNT */
+	__u8	ssb_fh_cs_ctl;		/* frame header CS_CTL */
+	__be16	ssb_fh_ox_id;		/* frame header OX_ID */
+	__be16	ssb_rx_id;		/* responder's exchange ID */
+	__u8	_ssb_resvd2[2];
+} PACKED;
+
+/*
+ * The SSB should be 17 bytes.  Since it's layout is somewhat strange,
+ * we define the size here so that code can ASSERT that the size comes out
+ * correct.
+ */
+#define FC_SSB_SIZE         17          /* length of fc_ssb for assert */
+
+/*
+ * ssb_s_stat - flags from FC-FS-2 T11/1619-D Rev 0.90.
+ */
+#define SSB_ST_RESP         (1 << 15)   /* sequence responder */
+#define SSB_ST_ACTIVE       (1 << 14)   /* sequence is active */
+#define SSB_ST_ABNORMAL     (1 << 12)   /* abnormal ending condition */
+
+#define SSB_ST_REQ_MASK     (3 << 10)   /* ACK, abort sequence condition */
+#define SSB_ST_REQ_CONT     (0 << 10)
+#define SSB_ST_REQ_ABORT    (1 << 10)
+#define SSB_ST_REQ_STOP     (2 << 10)
+#define SSB_ST_REQ_RETRANS  (3 << 10)
+
+#define SSB_ST_ABTS         (1 << 9)    /* ABTS protocol completed */
+#define SSB_ST_RETRANS      (1 << 8)    /* retransmission completed */
+#define SSB_ST_TIMEOUT      (1 << 7)    /* sequence timed out by recipient */
+#define SSB_ST_P_RJT        (1 << 6)    /* P_RJT transmitted */
+
+#define SSB_ST_CLASS_BIT    4           /* class of service field LSB */
+#define SSB_ST_CLASS_MASK   3           /* class of service mask */
+#define SSB_ST_ACK          (1 << 3)    /* ACK (EOFt or EOFdt) transmitted */
+
+/*
+ * Exchange Status Block.
+ * This format is set by the FC-FS standard and is sent over the wire.
+ * Note that the fields aren't all naturally aligned.
+ */
+struct fc_esb {
+	__u8	esb_cs_ctl;		/* CS_CTL for frame header */
+	__be16	esb_ox_id;		/* originator exchange ID */
+	__be16	esb_rx_id;		/* responder exchange ID */
+	__be32	esb_orig_fid;		/* fabric ID of originator */
+	__be32	esb_resp_fid;		/* fabric ID of responder */
+	__be32	esb_e_stat;		/* status */
+	__u8	_esb_resvd[4];
+	__u8	esb_service_params[112]; /* TBD */
+	__u8	esb_seq_status[8];	/* sequence statuses, 8 bytes each */
+} __attribute__((packed));
+
+/*
+ * Define expected size for ASSERTs.
+ * See comments on FC_SSB_SIZE.
+ */
+#define FC_ESB_SIZE         (1 + 5*4 + 112 + 8)     /* expected size */
+
+/*
+ * esb_e_stat - flags from FC-FS-2 T11/1619-D Rev 0.90.
+ */
+#define ESB_ST_RESP         (1 << 31)   /* responder to exchange */
+#define ESB_ST_SEQ_INIT     (1 << 30)   /* port holds sequence initiaive */
+#define ESB_ST_COMPLETE     (1 << 29)   /* exchange is complete */
+#define ESB_ST_ABNORMAL     (1 << 28)   /* abnormal ending condition */
+#define ESB_ST_REC_QUAL     (1 << 26)   /* recovery qualifier active */
+
+#define ESB_ST_ERRP_BIT     24          /* LSB for error policy */
+#define ESB_ST_ERRP_MASK    (3 << 24)   /* mask for error policy */
+#define ESB_ST_ERRP_MULT    (0 << 24)   /* abort, discard multiple sequences */
+#define ESB_ST_ERRP_SING    (1 << 24)   /* abort, discard single sequence */
+#define ESB_ST_ERRP_INF     (2 << 24)   /* process with infinite buffers */
+#define ESB_ST_ERRP_IMM     (3 << 24)   /* discard mult. with immed. retran. */
+
+#define ESB_ST_OX_ID_INVL   (1 << 23)   /* originator XID invalid */
+#define ESB_ST_RX_ID_INVL   (1 << 22)   /* responder XID invalid */
+#define ESB_ST_PRI_INUSE    (1 << 21)   /* priority / preemption in use */
+
+#endif /* _FC_FC2_H_ */
diff --git a/include/scsi/fc/fc_fcoe.h b/include/scsi/fc/fc_fcoe.h
new file mode 100644
index 0000000..ccb3dbe
--- /dev/null
+++ b/include/scsi/fc/fc_fcoe.h
@@ -0,0 +1,103 @@
+/*
+ * 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 _FC_FCOE_H_
+#define	_FC_FCOE_H_
+
+/*
+ * FCoE - Fibre Channel over Ethernet.
+ */
+
+/*
+ * FC_FCOE_OUI hasn't been standardized yet.   XXX TBD.
+ */
+#ifndef FC_FCOE_OUI
+#define	FC_FCOE_OUI	0x0efc00	/* upper 24 bits of FCOE dest MAC TBD */
+#endif
+
+/*
+ * The destination MAC address for the fabric login may get a different OUI.
+ * This isn't standardized yet.
+ */
+#ifndef FC_FCOE_FLOGI_MAC
+/* gateway MAC - TBD */
+#define	FC_FCOE_FLOGI_MAC { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }
+#endif
+
+#define	FC_FCOE_VER	0			/* version */
+
+/*
+ * Ethernet Addresses based on FC S_ID and D_ID.
+ * Generated by FC_FCOE_OUI | S_ID/D_ID
+ */
+#define	FC_FCOE_ENCAPS_ID(n)	(((u64) FC_FCOE_OUI << 24) | (n))
+#define	FC_FCOE_DECAPS_ID(n)	((n) >> 24)
+
+/*
+ * FCoE frame header - 14 bytes
+ *
+ * This is the August 2007 version of the FCoE header as defined by T11.
+ * This follows the VLAN header, which includes the ethertype.
+ */
+struct fcoe_hdr {
+	__u8		fcoe_ver;	/* version field - upper 4 bits */
+	__u8		fcoe_resvd[12];	/* reserved - send zero and ignore */
+	__u8		fcoe_sof;	/* start of frame per RFC 3643 */
+};
+
+#define FC_FCOE_DECAPS_VER(hp)	    ((hp)->fcoe_ver >> 4)
+#define FC_FCOE_ENCAPS_VER(hp, ver) ((hp)->fcoe_ver = (ver) << 4)
+
+/*
+ * FCoE CRC & EOF - 8 bytes.
+ */
+struct fcoe_crc_eof {
+	__le32		fcoe_crc32;	/* CRC for FC packet */
+	__u8		fcoe_eof;	/* EOF from RFC 3643 */
+	__u8		fcoe_resvd[3];	/* reserved - send zero and ignore */
+} __attribute__((packed));
+
+/*
+ * Minimum FCoE + FC header length
+ * 14 bytes FCoE header + 24 byte FC header = 38 bytes
+ */
+#define FCOE_HEADER_LEN 38
+
+/*
+ * Minimum FCoE frame size
+ * 14 bytes FCoE header + 24 byte FC header + 8 byte FCoE trailer = 46 bytes
+ */
+#define FCOE_MIN_FRAME 46
+
+/*
+ * fc_fcoe_set_mac - Store OUI + DID into MAC address field.
+ * @mac: mac address to be set
+ * @did: fc dest id to use
+ */
+static inline void fc_fcoe_set_mac(u8 *mac, u8 *did)
+{
+	mac[0] = (u8) (FC_FCOE_OUI >> 16);
+	mac[1] = (u8) (FC_FCOE_OUI >> 8);
+	mac[2] = (u8) FC_FCOE_OUI;
+	mac[3] = did[0];
+	mac[4] = did[1];
+	mac[5] = did[2];
+}
+
+#endif /* _FC_FCOE_H_ */
diff --git a/include/scsi/fc/fc_fcp.h b/include/scsi/fc/fc_fcp.h
new file mode 100644
index 0000000..29ecb0b
--- /dev/null
+++ b/include/scsi/fc/fc_fcp.h
@@ -0,0 +1,205 @@
+/*
+ * 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 _FC_FCP_H_
+#define	_FC_FCP_H_
+
+/*
+ * Fibre Channel Protocol for SCSI.
+ * From T10 FCP-3, T10 project 1560-D Rev 4, Sept. 13, 2005.
+ */
+
+/*
+ * fc/fs.h defines FC_TYPE_FCP.
+ */
+
+/*
+ * Service parameter page parameters (word 3 bits) for Process Login.
+ */
+#define	FCP_SPPF_TASK_RETRY_ID	0x0200	/* task retry ID requested */
+#define	FCP_SPPF_RETRY		0x0100	/* retry supported */
+#define	FCP_SPPF_CONF_COMPL	0x0080	/* confirmed completion allowed */
+#define	FCP_SPPF_OVLY_ALLOW	0x0040	/* data overlay allowed */
+#define	FCP_SPPF_INIT_FCN	0x0020	/* initiator function */
+#define	FCP_SPPF_TARG_FCN	0x0010	/* target function */
+#define	FCP_SPPF_RD_XRDY_DIS	0x0002	/* disable XFER_RDY for reads */
+#define	FCP_SPPF_WR_XRDY_DIS	0x0001	/* disable XFER_RDY for writes */
+
+/*
+ * FCP_CMND IU Payload.
+ */
+struct fcp_cmnd {
+	__u8		fc_lun[8];	/* logical unit number */
+	__u8		fc_cmdref;	/* commmand reference number */
+	__u8		fc_pri_ta;	/* priority and task attribute */
+	__u8		fc_tm_flags;	/* task management flags */
+	__u8		fc_flags;	/* additional len & flags */
+	__u8		fc_cdb[16];	/* base CDB */
+	__be32		fc_dl;		/* data length (must follow fc_cdb) */
+};
+
+#define	FCP_CMND_LEN	32	/* expected length of structure */
+
+struct fcp_cmnd32 {
+	__u8		fc_lun[8];	/* logical unit number */
+	__u8		fc_cmdref;	/* commmand reference number */
+	__u8		fc_pri_ta;	/* priority and task attribute */
+	__u8		fc_tm_flags;	/* task management flags */
+	__u8		fc_flags;	/* additional len & flags */
+	__u8		fc_cdb[32];	/* base CDB */
+	__be32		fc_dl;		/* data length (must follow fc_cdb) */
+};
+
+#define	FCP_CMND32_LEN	    48	/* expected length of structure */
+#define	FCP_CMND32_ADD_LEN  (16 / 4)	/* Additional cdb length */
+
+/*
+ * fc_pri_ta.
+ */
+#define	FCP_PTA_SIMPLE	    0	/* simple task attribute */
+#define	FCP_PTA_HEADQ	    1	/* head of queue task attribute */
+#define	FCP_PTA_ORDERED     2	/* ordered task attribute */
+#define	FCP_PTA_ACA	    4	/* auto. contigent allegiance */
+#define	FCP_PRI_SHIFT	    3	/* priority field starts in bit 3 */
+#define	FCP_PRI_RESVD_MASK  0x80	/* reserved bits in priority field */
+
+/*
+ * fc_tm_flags - task management flags field.
+ */
+#define	FCP_TMF_CLR_ACA		0x40	/* clear ACA condition */
+#define	FCP_TMF_LUN_RESET	0x10	/* logical unit reset task management */
+#define	FCP_TMF_CLR_TASK_SET	0x04	/* clear task set */
+#define	FCP_TMF_ABT_TASK_SET	0x02	/* abort task set */
+
+/*
+ * fc_flags.
+ *  Bits 7:2 are the additional FCP_CDB length / 4.
+ */
+#define	FCP_CFL_LEN_MASK	0xfc	/* mask for additional length */
+#define	FCP_CFL_LEN_SHIFT	2	/* shift bits for additional length */
+#define	FCP_CFL_RDDATA		0x02	/* read data */
+#define	FCP_CFL_WRDATA		0x01	/* write data */
+
+/*
+ * FCP_TXRDY IU - transfer ready payload.
+ */
+struct fcp_txrdy {
+	__be32		ft_data_ro;	/* data relative offset */
+	__be32		ft_burst_len;	/* burst length */
+	__u8		_ft_resvd[4];	/* reserved */
+};
+
+#define	FCP_TXRDY_LEN	12	/* expected length of structure */
+
+/*
+ * FCP_RESP IU - response payload.
+ *
+ * The response payload comes in three parts: the flags/status, the
+ * sense/response lengths and the sense data/response info section.
+ *
+ * From FCP3r04, note 6 of section 9.5.13:
+ *
+ * Some early implementations presented the FCP_RSP IU without the FCP_RESID,
+ * FCP_SNS_LEN, and FCP_RSP_LEN fields if the FCP_RESID_UNDER, FCP_RESID_OVER,
+ * FCP_SNS_LEN_VALID, and FCP_RSP_LEN_VALID bits were all set to zero. This
+ * non-standard behavior should be tolerated.
+ *
+ * All response frames will always contain the fcp_resp template.  Some
+ * will also include the fcp_resp_len template.
+ */
+struct fcp_resp {
+	__u8		_fr_resvd[8];	/* reserved */
+	__be16		fr_retry_delay;	/* retry delay timer */
+	__u8		fr_flags;	/* flags */
+	__u8		fr_status;	/* SCSI status code */
+};
+
+#define	FCP_RESP_LEN	12	/* expected length of structure */
+
+struct fcp_resp_ext {
+	__be32		fr_resid;	/* Residual value */
+	__be32		fr_sns_len;	/* SCSI Sense length */
+	__be32		fr_rsp_len;	/* Response Info length */
+
+	/*
+	 * Optionally followed by RSP info and/or SNS info and/or
+	 * bidirectional read residual length, if any.
+	 */
+};
+
+#define FCP_RESP_EXT_LEN    12  /* expected length of the structure */
+
+struct fcp_resp_rsp_info {
+    __u8      _fr_resvd[3];       /* reserved */
+    __u8      rsp_code;           /* Response Info Code */
+    __u8      _fr_resvd2[4];      /* reserved */
+};
+
+struct fcp_resp_with_ext {
+	struct fcp_resp resp;
+	struct fcp_resp_ext ext;
+};
+
+#define	FCP_RESP_WITH_EXT   (FCP_RESP_LEN + FCP_RESP_EXT_LEN)
+
+/*
+ * fr_flags.
+ */
+#define	FCP_BIDI_RSP	    0x80	/* bidirectional read response */
+#define	FCP_BIDI_READ_UNDER 0x40	/* bidir. read less than requested */
+#define	FCP_BIDI_READ_OVER  0x20	/* DL insufficient for full transfer */
+#define	FCP_CONF_REQ	    0x10	/* confirmation requested */
+#define	FCP_RESID_UNDER     0x08	/* transfer shorter than expected */
+#define	FCP_RESID_OVER	    0x04	/* DL insufficient for full transfer */
+#define	FCP_SNS_LEN_VAL     0x02	/* SNS_LEN field is valid */
+#define	FCP_RSP_LEN_VAL     0x01	/* RSP_LEN field is valid */
+
+/*
+ * rsp_codes
+ */
+enum fcp_resp_rsp_codes {
+	FCP_TMF_CMPL = 0,
+	FCP_DATA_LEN_INVALID = 1,
+	FCP_CMND_FIELDS_INVALID = 2,
+	FCP_DATA_PARAM_MISMATCH = 3,
+	FCP_TMF_REJECTED = 4,
+	FCP_TMF_FAILED = 5,
+	FCP_TMF_INVALID_LUN = 9,
+};
+
+/*
+ * FCP SRR Link Service request - Sequence Retransmission Request.
+ */
+struct fcp_srr {
+	__u8		srr_op;		/* opcode ELS_SRR */
+	__u8		srr_resvd[3];	/* opcode / reserved - must be zero */
+	__be16		srr_ox_id;	/* OX_ID of failed command */
+	__be16		srr_rx_id;	/* RX_ID of failed command */
+	__be32		srr_rel_off;	/* relative offset */
+	__u8		srr_r_ctl;	/* r_ctl for the information unit */
+	__u8		srr_resvd2[3];	/* reserved */
+};
+
+/*
+ * Feature bits in name server FC-4 Features object.
+ */
+#define	FCP_FEAT_TARG	(1 << 0)	/* target function supported */
+#define	FCP_FEAT_INIT	(1 << 1)	/* initiator function supported */
+
+#endif /* _FC_FCP_H_ */
diff --git a/include/scsi/fc/fc_fip.h b/include/scsi/fc/fc_fip.h
new file mode 100644
index 0000000..3d138c1
--- /dev/null
+++ b/include/scsi/fc/fc_fip.h
@@ -0,0 +1,230 @@
+/*
+ * Copyright 2008 Cisco Systems, Inc.  All rights reserved.
+ *
+ * This program is free software; you may redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef _FC_FIP_H_
+#define _FC_FIP_H_
+
+/*
+ * This version is based on:
+ * http://www.t11.org/ftp/t11/pub/fc/bb-5/08-543v1.pdf
+ */
+
+#define FIP_DEF_PRI	128	/* default selection priority */
+#define FIP_DEF_FC_MAP	0x0efc00 /* default FCoE MAP (MAC OUI) value */
+#define FIP_DEF_FKA	8000	/* default FCF keep-alive/advert period (mS) */
+#define FIP_VN_KA_PERIOD 90000	/* required VN_port keep-alive period (mS) */
+#define FIP_FCF_FUZZ	100	/* random time added by FCF (mS) */
+
+/*
+ * Multicast MAC addresses.  T11-adopted.
+ */
+#define FIP_ALL_FCOE_MACS	((u8[6]) { 1, 0x10, 0x18, 1, 0, 0 })
+#define FIP_ALL_ENODE_MACS	((u8[6]) { 1, 0x10, 0x18, 1, 0, 1 })
+#define FIP_ALL_FCF_MACS	((u8[6]) { 1, 0x10, 0x18, 1, 0, 2 })
+
+#define FIP_VER		1		/* version for fip_header */
+
+struct fip_header {
+	__u8	fip_ver;		/* upper 4 bits are the version */
+	__u8	fip_resv1;		/* reserved */
+	__be16	fip_op;			/* operation code */
+	__u8	fip_resv2;		/* reserved */
+	__u8	fip_subcode;		/* lower 4 bits are sub-code */
+	__be16	fip_dl_len;		/* length of descriptors in words */
+	__be16	fip_flags;		/* header flags */
+} __attribute__((packed));
+
+#define FIP_VER_SHIFT	4
+#define FIP_VER_ENCAPS(v) ((v) << FIP_VER_SHIFT)
+#define FIP_VER_DECAPS(v) ((v) >> FIP_VER_SHIFT)
+#define FIP_BPW		4		/* bytes per word for lengths */
+
+/*
+ * fip_op.
+ */
+enum fip_opcode {
+	FIP_OP_DISC =	1,		/* discovery, advertisement, etc. */
+	FIP_OP_LS =	2,		/* Link Service request or reply */
+	FIP_OP_CTRL =	3,		/* Keep Alive / Link Reset */
+	FIP_OP_VLAN =	4,		/* VLAN discovery */
+	FIP_OP_VENDOR_MIN = 0xfff8,	/* min vendor-specific opcode */
+	FIP_OP_VENDOR_MAX = 0xfffe,	/* max vendor-specific opcode */
+};
+
+/*
+ * Subcodes for FIP_OP_DISC.
+ */
+enum fip_disc_subcode {
+	FIP_SC_SOL =	1,		/* solicitation */
+	FIP_SC_ADV =	2,		/* advertisement */
+};
+
+/*
+ * Subcodes for FIP_OP_LS.
+ */
+enum fip_trans_subcode {
+	FIP_SC_REQ =	1,		/* request */
+	FIP_SC_REP =	2,		/* reply */
+};
+
+/*
+ * Subcodes for FIP_OP_RESET.
+ */
+enum fip_reset_subcode {
+	FIP_SC_KEEP_ALIVE = 1,		/* keep-alive from VN_Port */
+	FIP_SC_CLR_VLINK = 2,		/* clear virtual link from VF_Port */
+};
+
+/*
+ * Subcodes for FIP_OP_VLAN.
+ */
+enum fip_vlan_subcode {
+	FIP_SC_VL_REQ =	1,		/* request */
+	FIP_SC_VL_REP =	2,		/* reply */
+};
+
+/*
+ * flags in header fip_flags.
+ */
+enum fip_flag {
+	FIP_FL_FPMA =	0x8000,		/* supports FPMA fabric-provided MACs */
+	FIP_FL_SPMA =	0x4000,		/* supports SPMA server-provided MACs */
+	FIP_FL_AVAIL =	0x0004,		/* available for FLOGI/ELP */
+	FIP_FL_SOL =	0x0002,		/* this is a solicited message */
+	FIP_FL_FPORT =	0x0001,		/* sent from an F port */
+};
+
+/*
+ * Common descriptor header format.
+ */
+struct fip_desc {
+	__u8	fip_dtype;		/* type - see below */
+	__u8	fip_dlen;		/* length - in 32-bit words */
+};
+
+enum fip_desc_type {
+	FIP_DT_PRI =	1,		/* priority for forwarder selection */
+	FIP_DT_MAC =	2,		/* MAC address */
+	FIP_DT_MAP_OUI = 3,		/* FC-MAP OUI */
+	FIP_DT_NAME =	4,		/* switch name or node name */
+	FIP_DT_FAB =	5,		/* fabric descriptor */
+	FIP_DT_FCOE_SIZE = 6,		/* max FCoE frame size */
+	FIP_DT_FLOGI =	7,		/* FLOGI request or response */
+	FIP_DT_FDISC =	8,		/* FDISC request or response */
+	FIP_DT_LOGO =	9,		/* LOGO request or response */
+	FIP_DT_ELP =	10,		/* ELP request or response */
+	FIP_DT_VN_ID =	11,		/* VN_Node Identifier */
+	FIP_DT_FKA =	12,		/* advertisement keep-alive period */
+	FIP_DT_VENDOR =	13,		/* vendor ID */
+	FIP_DT_VLAN =	14,		/* vlan number */
+	FIP_DT_LIMIT,			/* max defined desc_type + 1 */
+	FIP_DT_VENDOR_BASE = 128,	/* first vendor-specific desc_type */
+};
+
+/*
+ * FIP_DT_PRI - priority descriptor.
+ */
+struct fip_pri_desc {
+	struct fip_desc fd_desc;
+	__u8		fd_resvd;
+	__u8		fd_pri;		/* FCF priority:  higher is better */
+} __attribute__((packed));
+
+/*
+ * FIP_DT_MAC - MAC address descriptor.
+ */
+struct fip_mac_desc {
+	struct fip_desc fd_desc;
+	__u8		fd_mac[ETH_ALEN];
+} __attribute__((packed));
+
+/*
+ * FIP_DT_MAP - descriptor.
+ */
+struct fip_map_desc {
+	struct fip_desc fd_desc;
+	__u8		fd_resvd[3];
+	__u8		fd_map[3];
+} __attribute__((packed));
+
+/*
+ * FIP_DT_NAME descriptor.
+ */
+struct fip_wwn_desc {
+	struct fip_desc fd_desc;
+	__u8		fd_resvd[2];
+	__be64		fd_wwn;		/* 64-bit WWN, unaligned */
+} __attribute__((packed));
+
+/*
+ * FIP_DT_FAB descriptor.
+ */
+struct fip_fab_desc {
+	struct fip_desc fd_desc;
+	__be16		fd_vfid;	/* virtual fabric ID */
+	__u8		fd_resvd;
+	__u8		fd_map[3];	/* FC-MAP value */
+	__be64		fd_wwn;		/* fabric name, unaligned */
+} __attribute__((packed));
+
+/*
+ * FIP_DT_FCOE_SIZE descriptor.
+ */
+struct fip_size_desc {
+	struct fip_desc fd_desc;
+	__be16		fd_size;
+} __attribute__((packed));
+
+/*
+ * Descriptor that encapsulates an ELS or ILS frame.
+ * The encapsulated frame immediately follows this header, without
+ * SOF, EOF, or CRC.
+ */
+struct fip_encaps {
+	struct fip_desc fd_desc;
+	__u8		fd_resvd[2];
+} __attribute__((packed));
+
+/*
+ * FIP_DT_VN_ID - VN_Node Identifier descriptor.
+ */
+struct fip_vn_desc {
+	struct fip_desc fd_desc;
+	__u8		fd_mac[ETH_ALEN];
+	__u8		fd_resvd;
+	__u8		fd_fc_id[3];
+	__be64		fd_wwpn;	/* port name, unaligned */
+} __attribute__((packed));
+
+/*
+ * FIP_DT_FKA - Advertisement keep-alive period.
+ */
+struct fip_fka_desc {
+	struct fip_desc fd_desc;
+	__u8		fd_resvd[2];
+	__be32		fd_fka_period;	/* adv./keep-alive period in mS */
+} __attribute__((packed));
+
+/*
+ * FIP_DT_VENDOR descriptor.
+ */
+struct fip_vendor_desc {
+	struct fip_desc fd_desc;
+	__u8		fd_resvd[2];
+	__u8		fd_vendor_id[8];
+} __attribute__((packed));
+
+#endif /* _FC_FIP_H_ */
diff --git a/include/scsi/fc/fc_fs.h b/include/scsi/fc/fc_fs.h
new file mode 100644
index 0000000..50f28b1
--- /dev/null
+++ b/include/scsi/fc/fc_fs.h
@@ -0,0 +1,348 @@
+/*
+ * 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 _FC_FS_H_
+#define _FC_FS_H_
+
+#include <linux/types.h>
+
+/*
+ * Fibre Channel Framing and Signalling definitions.
+ * From T11 FC-FS-2 Rev 0.90 - 9 August 2005.
+ */
+
+/*
+ * Frame header
+ */
+struct fc_frame_header {
+	__u8          fh_r_ctl;	/* routing control */
+	__u8          fh_d_id[3];	/* Destination ID */
+
+	__u8          fh_cs_ctl;	/* class of service control / pri */
+	__u8          fh_s_id[3];	/* Source ID */
+
+	__u8          fh_type;		/* see enum fc_fh_type below */
+	__u8          fh_f_ctl[3];	/* frame control */
+
+	__u8          fh_seq_id;	/* sequence ID */
+	__u8          fh_df_ctl;	/* data field control */
+	__be16        fh_seq_cnt;	/* sequence count */
+
+	__be16        fh_ox_id;		/* originator exchange ID */
+	__be16        fh_rx_id;		/* responder exchange ID */
+	__be32        fh_parm_offset;	/* parameter or relative offset */
+};
+
+#define FC_FRAME_HEADER_LEN 24	/* expected length of structure */
+
+#define FC_MAX_PAYLOAD  2112U		/* max payload length in bytes */
+#define FC_MIN_MAX_PAYLOAD  256U 	/* lower limit on max payload */
+
+#define FC_MAX_FRAME	(FC_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
+#define FC_MIN_MAX_FRAME (FC_MIN_MAX_PAYLOAD + FC_FRAME_HEADER_LEN)
+
+/*
+ * fh_r_ctl - Routing control definitions.
+ */
+    /*
+     * FC-4 device_data.
+     */
+enum fc_rctl {
+	FC_RCTL_DD_UNCAT = 0x00,	/* uncategorized information */
+	FC_RCTL_DD_SOL_DATA = 0x01,	/* solicited data */
+	FC_RCTL_DD_UNSOL_CTL = 0x02,	/* unsolicited control */
+	FC_RCTL_DD_SOL_CTL = 0x03,	/* solicited control or reply */
+	FC_RCTL_DD_UNSOL_DATA = 0x04,	/* unsolicited data */
+	FC_RCTL_DD_DATA_DESC = 0x05,	/* data descriptor */
+	FC_RCTL_DD_UNSOL_CMD = 0x06,	/* unsolicited command */
+	FC_RCTL_DD_CMD_STATUS = 0x07,	/* command status */
+
+#define FC_RCTL_ILS_REQ FC_RCTL_DD_UNSOL_CTL	/* ILS request */
+#define FC_RCTL_ILS_REP FC_RCTL_DD_SOL_CTL	/* ILS reply */
+
+	/*
+	 * Extended Link_Data
+	 */
+	FC_RCTL_ELS_REQ = 0x22,	/* extended link services request */
+	FC_RCTL_ELS_REP = 0x23,	/* extended link services reply */
+	FC_RCTL_ELS4_REQ = 0x32, /* FC-4 ELS request */
+	FC_RCTL_ELS4_REP = 0x33, /* FC-4 ELS reply */
+	/*
+	 * Optional Extended Headers
+	 */
+	FC_RCTL_VFTH = 0x50,	/* virtual fabric tagging header */
+	FC_RCTL_IFRH = 0x51,	/* inter-fabric routing header */
+	FC_RCTL_ENCH = 0x52,	/* encapsulation header */
+	/*
+	 * Basic Link Services fh_r_ctl values.
+	 */
+	FC_RCTL_BA_NOP = 0x80,	/* basic link service NOP */
+	FC_RCTL_BA_ABTS = 0x81,	/* basic link service abort */
+	FC_RCTL_BA_RMC = 0x82,	/* remove connection */
+	FC_RCTL_BA_ACC = 0x84,	/* basic accept */
+	FC_RCTL_BA_RJT = 0x85,	/* basic reject */
+	FC_RCTL_BA_PRMT = 0x86,	/* dedicated connection preempted */
+	/*
+	 * Link Control Information.
+	 */
+	FC_RCTL_ACK_1 = 0xc0,	/* acknowledge_1 */
+	FC_RCTL_ACK_0 = 0xc1,	/* acknowledge_0 */
+	FC_RCTL_P_RJT = 0xc2,	/* port reject */
+	FC_RCTL_F_RJT = 0xc3,	/* fabric reject */
+	FC_RCTL_P_BSY = 0xc4,	/* port busy */
+	FC_RCTL_F_BSY = 0xc5,	/* fabric busy to data frame */
+	FC_RCTL_F_BSYL = 0xc6,	/* fabric busy to link control frame */
+	FC_RCTL_LCR = 0xc7,	/* link credit reset */
+	FC_RCTL_END = 0xc9,	/* end */
+};
+				    /* incomplete list of definitions */
+
+/*
+ * R_CTL names initializer.
+ * Please keep this matching the above definitions.
+ */
+#define FC_RCTL_NAMES_INIT { \
+	[FC_RCTL_DD_UNCAT] =		"uncat",			\
+	[FC_RCTL_DD_SOL_DATA] =		"sol data",			\
+	[FC_RCTL_DD_UNSOL_CTL] =	"unsol ctl",			\
+	[FC_RCTL_DD_SOL_CTL] =		"sol ctl/reply",		\
+	[FC_RCTL_DD_UNSOL_DATA] =	"unsol data",			\
+	[FC_RCTL_DD_DATA_DESC] =	"data desc",			\
+	[FC_RCTL_DD_UNSOL_CMD] =	"unsol cmd",			\
+	[FC_RCTL_DD_CMD_STATUS] =	"cmd status",			\
+	[FC_RCTL_ELS_REQ] =		"ELS req",			\
+	[FC_RCTL_ELS_REP] =		"ELS rep",			\
+	[FC_RCTL_ELS4_REQ] =		"FC-4 ELS req",			\
+	[FC_RCTL_ELS4_REP] =		"FC-4 ELS rep",			\
+	[FC_RCTL_BA_NOP] =		"BLS NOP",			\
+	[FC_RCTL_BA_ABTS] =		"BLS abort",			\
+	[FC_RCTL_BA_RMC] =		"BLS remove connection",	\
+	[FC_RCTL_BA_ACC] =		"BLS accept",			\
+	[FC_RCTL_BA_RJT] =		"BLS reject",			\
+	[FC_RCTL_BA_PRMT] =		"BLS dedicated connection preempted", \
+	[FC_RCTL_ACK_1] =		"LC ACK_1",			\
+	[FC_RCTL_ACK_0] =		"LC ACK_0",			\
+	[FC_RCTL_P_RJT] =		"LC port reject",		\
+	[FC_RCTL_F_RJT] =		"LC fabric reject",		\
+	[FC_RCTL_P_BSY] =		"LC port busy",			\
+	[FC_RCTL_F_BSY] =		"LC fabric busy to data frame",	\
+	[FC_RCTL_F_BSYL] =		"LC fabric busy to link control frame",\
+	[FC_RCTL_LCR] =			"LC link credit reset",		\
+	[FC_RCTL_END] =			"LC end",			\
+}
+
+/*
+ * Well-known fabric addresses.
+ */
+enum fc_well_known_fid {
+	FC_FID_NONE =           0x000000,       /* No destination */
+	FC_FID_BCAST =		0xffffff,	/* broadcast */
+	FC_FID_FLOGI =		0xfffffe,	/* fabric login */
+	FC_FID_FCTRL =		0xfffffd,	/* fabric controller */
+	FC_FID_DIR_SERV =	0xfffffc,	/* directory server */
+	FC_FID_TIME_SERV =	0xfffffb,	/* time server */
+	FC_FID_MGMT_SERV =	0xfffffa,	/* management server */
+	FC_FID_QOS =		0xfffff9,	/* QoS Facilitator */
+	FC_FID_ALIASES =	0xfffff8,	/* alias server (FC-PH2) */
+	FC_FID_SEC_KEY =	0xfffff7,	/* Security key dist. server */
+	FC_FID_CLOCK =		0xfffff6,	/* clock synch server */
+	FC_FID_MCAST_SERV =	0xfffff5,	/* multicast server */
+};
+
+#define	FC_FID_WELL_KNOWN_MAX	0xffffff /* highest well-known fabric ID */
+#define	FC_FID_WELL_KNOWN_BASE	0xfffff5 /* start of well-known fabric ID */
+
+/*
+ * Other well-known addresses, outside the above contiguous range.
+ */
+#define	FC_FID_DOM_MGR		0xfffc00	/* domain manager base */
+
+/*
+ * Fabric ID bytes.
+ */
+#define	FC_FID_DOMAIN		0
+#define	FC_FID_PORT		1
+#define	FC_FID_LINK		2
+
+/*
+ * fh_type codes
+ */
+enum fc_fh_type {
+	FC_TYPE_BLS =	0x00,	/* basic link service */
+	FC_TYPE_ELS =	0x01,	/* extended link service */
+	FC_TYPE_IP =	0x05,	/* IP over FC, RFC 4338 */
+	FC_TYPE_FCP =	0x08,	/* SCSI FCP */
+	FC_TYPE_CT =	0x20,	/* Fibre Channel Services (FC-CT) */
+	FC_TYPE_ILS =	0x22,	/* internal link service */
+};
+
+/*
+ * FC_TYPE names initializer.
+ * Please keep this matching the above definitions.
+ */
+#define FC_TYPE_NAMES_INIT {				\
+	[FC_TYPE_BLS] =		"BLS",			\
+	[FC_TYPE_ELS] =		"ELS",			\
+	[FC_TYPE_IP] =		"IP",			\
+	[FC_TYPE_FCP] =		"FCP",			\
+	[FC_TYPE_CT] =		"CT",			\
+	[FC_TYPE_ILS] =		"ILS",			\
+}
+
+/*
+ * Exchange IDs.
+ */
+#define FC_XID_UNKNOWN  0xffff	/* unknown exchange ID */
+#define FC_XID_MIN	0x0	/* supported min exchange ID */
+#define FC_XID_MAX	0xfffe	/* supported max exchange ID */
+
+/*
+ * fh_f_ctl - Frame control flags.
+ */
+#define	FC_FC_EX_CTX	(1 << 23)	/* sent by responder to exchange */
+#define	FC_FC_SEQ_CTX	(1 << 22)	/* sent by responder to sequence */
+#define	FC_FC_FIRST_SEQ (1 << 21)	/* first sequence of this exchange */
+#define	FC_FC_LAST_SEQ	(1 << 20)	/* last sequence of this exchange */
+#define	FC_FC_END_SEQ	(1 << 19)	/* last frame of sequence */
+#define	FC_FC_END_CONN	(1 << 18)	/* end of class 1 connection pending */
+#define	FC_FC_RES_B17	(1 << 17)	/* reserved */
+#define	FC_FC_SEQ_INIT	(1 << 16)	/* transfer of sequence initiative */
+#define	FC_FC_X_ID_REASS (1 << 15)	/* exchange ID has been changed */
+#define	FC_FC_X_ID_INVAL (1 << 14)	/* exchange ID invalidated */
+
+#define	FC_FC_ACK_1	(1 << 12)	/* 13:12 = 1: ACK_1 expected */
+#define	FC_FC_ACK_N	(2 << 12)	/* 13:12 = 2: ACK_N expected */
+#define	FC_FC_ACK_0	(3 << 12)	/* 13:12 = 3: ACK_0 expected */
+
+#define	FC_FC_RES_B11	(1 << 11)	/* reserved */
+#define	FC_FC_RES_B10	(1 << 10)	/* reserved */
+#define	FC_FC_RETX_SEQ	(1 << 9)	/* retransmitted sequence */
+#define	FC_FC_UNI_TX	(1 << 8)	/* unidirectional transmit (class 1) */
+#define	FC_FC_CONT_SEQ(i) ((i) << 6)
+#define	FC_FC_ABT_SEQ(i) ((i) << 4)
+#define	FC_FC_REL_OFF	(1 << 3)	/* parameter is relative offset */
+#define	FC_FC_RES2	(1 << 2)	/* reserved */
+#define	FC_FC_FILL(i)	((i) & 3)	/* 1:0: bytes of trailing fill */
+
+/*
+ * BA_ACC payload.
+ */
+struct fc_ba_acc {
+	__u8		ba_seq_id_val;	/* SEQ_ID validity */
+#define FC_BA_SEQ_ID_VAL 0x80
+	__u8		ba_seq_id;	/* SEQ_ID of seq last deliverable */
+	__u8		ba_resvd[2];	/* reserved */
+	__be16		ba_ox_id;	/* OX_ID for aborted seq or exch */
+	__be16		ba_rx_id;	/* RX_ID for aborted seq or exch */
+	__be16		ba_low_seq_cnt;	/* low SEQ_CNT of aborted seq */
+	__be16		ba_high_seq_cnt; /* high SEQ_CNT of aborted seq */
+};
+
+/*
+ * BA_RJT: Basic Reject payload.
+ */
+struct fc_ba_rjt {
+	__u8		br_resvd;	/* reserved */
+	__u8		br_reason;	/* reason code */
+	__u8		br_explan;	/* reason explanation */
+	__u8		br_vendor;	/* vendor unique code */
+};
+
+/*
+ * BA_RJT reason codes.
+ * From FS-2.
+ */
+enum fc_ba_rjt_reason {
+	FC_BA_RJT_NONE =	0,	/* in software this means no reject */
+	FC_BA_RJT_INVL_CMD =	0x01,	/* invalid command code */
+	FC_BA_RJT_LOG_ERR =	0x03,	/* logical error */
+	FC_BA_RJT_LOG_BUSY =	0x05,	/* logical busy */
+	FC_BA_RJT_PROTO_ERR =	0x07,	/* protocol error */
+	FC_BA_RJT_UNABLE =	0x09,	/* unable to perform request */
+	FC_BA_RJT_VENDOR =	0xff,	/* vendor-specific (see br_vendor) */
+};
+
+/*
+ * BA_RJT reason code explanations.
+ */
+enum fc_ba_rjt_explan {
+	FC_BA_RJT_EXP_NONE =	0x00,	/* no additional expanation */
+	FC_BA_RJT_INV_XID =	0x03,	/* invalid OX_ID-RX_ID combination */
+	FC_BA_RJT_ABT =		0x05,	/* sequence aborted, no seq info */
+};
+
+/*
+ * P_RJT or F_RJT: Port Reject or Fabric Reject parameter field.
+ */
+struct fc_pf_rjt {
+	__u8		rj_action;	/* reserved */
+	__u8		rj_reason;	/* reason code */
+	__u8		rj_resvd;	/* reserved */
+	__u8		rj_vendor;	/* vendor unique code */
+};
+
+/*
+ * P_RJT and F_RJT reject reason codes.
+ */
+enum fc_pf_rjt_reason {
+	FC_RJT_NONE =		0,	/* non-reject (reserved by standard) */
+	FC_RJT_INVL_DID =	0x01,	/* invalid destination ID */
+	FC_RJT_INVL_SID =	0x02,	/* invalid source ID */
+	FC_RJT_P_UNAV_T =	0x03,	/* port unavailable, temporary */
+	FC_RJT_P_UNAV =		0x04,	/* port unavailable, permanent */
+	FC_RJT_CLS_UNSUP =	0x05,	/* class not supported */
+	FC_RJT_DEL_USAGE =	0x06,	/* delimiter usage error */
+	FC_RJT_TYPE_UNSUP =	0x07,	/* type not supported */
+	FC_RJT_LINK_CTL =	0x08,	/* invalid link control */
+	FC_RJT_R_CTL =		0x09,	/* invalid R_CTL field */
+	FC_RJT_F_CTL =		0x0a,	/* invalid F_CTL field */
+	FC_RJT_OX_ID =		0x0b,	/* invalid originator exchange ID */
+	FC_RJT_RX_ID =		0x0c,	/* invalid responder exchange ID */
+	FC_RJT_SEQ_ID =		0x0d,	/* invalid sequence ID */
+	FC_RJT_DF_CTL =		0x0e,	/* invalid DF_CTL field */
+	FC_RJT_SEQ_CNT =	0x0f,	/* invalid SEQ_CNT field */
+	FC_RJT_PARAM =		0x10,	/* invalid parameter field */
+	FC_RJT_EXCH_ERR =	0x11,	/* exchange error */
+	FC_RJT_PROTO =		0x12,	/* protocol error */
+	FC_RJT_LEN =		0x13,	/* incorrect length */
+	FC_RJT_UNEXP_ACK =	0x14,	/* unexpected ACK */
+	FC_RJT_FAB_CLASS =	0x15,	/* class unsupported by fabric entity */
+	FC_RJT_LOGI_REQ =	0x16,	/* login required */
+	FC_RJT_SEQ_XS =		0x17,	/* excessive sequences attempted */
+	FC_RJT_EXCH_EST =	0x18,	/* unable to establish exchange */
+	FC_RJT_FAB_UNAV =	0x1a,	/* fabric unavailable */
+	FC_RJT_VC_ID =		0x1b,	/* invalid VC_ID (class 4) */
+	FC_RJT_CS_CTL =		0x1c,	/* invalid CS_CTL field */
+	FC_RJT_INSUF_RES =	0x1d,	/* insuff. resources for VC (Class 4) */
+	FC_RJT_INVL_CLS =	0x1f,	/* invalid class of service */
+	FC_RJT_PREEMT_RJT =	0x20,	/* preemption request rejected */
+	FC_RJT_PREEMT_DIS =	0x21,	/* preemption not enabled */
+	FC_RJT_MCAST_ERR =	0x22,	/* multicast error */
+	FC_RJT_MCAST_ET =	0x23,	/* multicast error terminate */
+	FC_RJT_PRLI_REQ =	0x24,	/* process login required */
+	FC_RJT_INVL_ATT =	0x25,	/* invalid attachment */
+	FC_RJT_VENDOR =		0xff,	/* vendor specific reject */
+};
+
+/* default timeout values */
+
+#define FC_DEF_E_D_TOV	2000UL
+#define FC_DEF_R_A_TOV	10000UL
+
+#endif /* _FC_FS_H_ */
diff --git a/include/scsi/fc/fc_gs.h b/include/scsi/fc/fc_gs.h
new file mode 100644
index 0000000..a37346d
--- /dev/null
+++ b/include/scsi/fc/fc_gs.h
@@ -0,0 +1,96 @@
+/*
+ * 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 _FC_GS_H_
+#define	_FC_GS_H_
+
+#include <linux/types.h>
+
+/*
+ * Fibre Channel Services - Common Transport.
+ * From T11.org FC-GS-2 Rev 5.3 November 1998.
+ */
+
+struct fc_ct_hdr {
+	__u8		ct_rev;		/* revision */
+	__u8		ct_in_id[3];	/* N_Port ID of original requestor */
+	__u8		ct_fs_type;	/* type of fibre channel service */
+	__u8		ct_fs_subtype;	/* subtype */
+	__u8		ct_options;
+	__u8		_ct_resvd1;
+	__be16		ct_cmd;		/* command / response code */
+	__be16		ct_mr_size;	/* maximum / residual size */
+	__u8		_ct_resvd2;
+	__u8		ct_reason;	/* reject reason */
+	__u8		ct_explan;	/* reason code explanation */
+	__u8		ct_vendor;	/* vendor unique data */
+};
+
+#define	FC_CT_HDR_LEN	16	/* expected sizeof (struct fc_ct_hdr) */
+
+enum fc_ct_rev {
+	FC_CT_REV = 1		/* common transport revision */
+};
+
+/*
+ * ct_fs_type values.
+ */
+enum fc_ct_fs_type {
+	FC_FST_ALIAS =	0xf8,	/* alias service */
+	FC_FST_MGMT =	0xfa,	/* management service */
+	FC_FST_TIME =	0xfb,	/* time service */
+	FC_FST_DIR =	0xfc,	/* directory service */
+};
+
+/*
+ * ct_cmd: Command / response codes
+ */
+enum fc_ct_cmd {
+	FC_FS_RJT =	0x8001,	/* reject */
+	FC_FS_ACC =	0x8002,	/* accept */
+};
+
+/*
+ * FS_RJT reason codes.
+ */
+enum fc_ct_reason {
+	FC_FS_RJT_CMD =		0x01,	/* invalid command code */
+	FC_FS_RJT_VER =		0x02,	/* invalid version level */
+	FC_FS_RJT_LOG =		0x03,	/* logical error */
+	FC_FS_RJT_IUSIZ =	0x04,	/* invalid IU size */
+	FC_FS_RJT_BSY =		0x05,	/* logical busy */
+	FC_FS_RJT_PROTO =	0x07,	/* protocol error */
+	FC_FS_RJT_UNABL =	0x09,	/* unable to perform command request */
+	FC_FS_RJT_UNSUP =	0x0b,	/* command not supported */
+};
+
+/*
+ * FS_RJT reason code explanations.
+ */
+enum fc_ct_explan {
+	FC_FS_EXP_NONE =	0x00,	/* no additional explanation */
+	FC_FS_EXP_PID =		0x01,	/* port ID not registered */
+	FC_FS_EXP_PNAM =	0x02,	/* port name not registered */
+	FC_FS_EXP_NNAM =	0x03,	/* node name not registered */
+	FC_FS_EXP_COS =		0x04,	/* class of service not registered */
+	FC_FS_EXP_FTNR =	0x07,	/* FC-4 types not registered */
+	/* definitions not complete */
+};
+
+#endif /* _FC_GS_H_ */
diff --git a/include/scsi/fc/fc_ns.h b/include/scsi/fc/fc_ns.h
new file mode 100644
index 0000000..e7d3ac4
--- /dev/null
+++ b/include/scsi/fc/fc_ns.h
@@ -0,0 +1,192 @@
+/*
+ * 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 _FC_NS_H_
+#define	_FC_NS_H_
+
+#include <linux/types.h>
+
+/*
+ * Fibre Channel Services - Name Service (dNS)
+ * From T11.org FC-GS-2 Rev 5.3 November 1998.
+ */
+
+/*
+ * Common-transport sub-type for Name Server.
+ */
+#define	FC_NS_SUBTYPE	    2	/* fs_ct_hdr.ct_fs_subtype */
+
+/*
+ * Name server Requests.
+ * Note:  this is an incomplete list, some unused requests are omitted.
+ */
+enum fc_ns_req {
+	FC_NS_GA_NXT =	0x0100,		/* get all next */
+	FC_NS_GI_A =	0x0101,		/* get identifiers - scope */
+	FC_NS_GPN_ID =	0x0112,		/* get port name by ID */
+	FC_NS_GNN_ID =	0x0113,		/* get node name by ID */
+	FC_NS_GID_PN =	0x0121,		/* get ID for port name */
+	FC_NS_GID_NN =	0x0131,		/* get IDs for node name */
+	FC_NS_GID_FT =	0x0171,		/* get IDs by FC4 type */
+	FC_NS_GPN_FT =	0x0172,		/* get port names by FC4 type */
+	FC_NS_GID_PT =	0x01a1,		/* get IDs by port type */
+	FC_NS_RPN_ID =	0x0212,		/* reg port name for ID */
+	FC_NS_RNN_ID =	0x0213,		/* reg node name for ID */
+	FC_NS_RFT_ID =	0x0217,		/* reg FC4 type for ID */
+	FC_NS_RSPN_ID =	0x0218,		/* reg symbolic port name */
+	FC_NS_RFF_ID =	0x021f,		/* reg FC4 Features for ID */
+	FC_NS_RSNN_NN =	0x0239,		/* reg symbolic node name */
+};
+
+/*
+ * Port type values.
+ */
+enum fc_ns_pt {
+	FC_NS_UNID_PORT = 0x00,	/* unidentified */
+	FC_NS_N_PORT =	0x01,	/* N port */
+	FC_NS_NL_PORT =	0x02,	/* NL port */
+	FC_NS_FNL_PORT = 0x03,	/* F/NL port */
+	FC_NS_NX_PORT =	0x7f,	/* Nx port */
+	FC_NS_F_PORT =	0x81,	/* F port */
+	FC_NS_FL_PORT =	0x82,	/* FL port */
+	FC_NS_E_PORT =	0x84,	/* E port */
+	FC_NS_B_PORT =	0x85,	/* B port */
+};
+
+/*
+ * Port type object.
+ */
+struct fc_ns_pt_obj {
+	__u8		pt_type;
+};
+
+/*
+ * Port ID object
+ */
+struct fc_ns_fid {
+	__u8		fp_flags;	/* flags for responses only */
+	__u8		fp_fid[3];
+};
+
+/*
+ * fp_flags in port ID object, for responses only.
+ */
+#define	FC_NS_FID_LAST	0x80		/* last object */
+
+/*
+ * FC4-types object.
+ */
+#define	FC_NS_TYPES	256	/* number of possible FC-4 types */
+#define	FC_NS_BPW	32	/* bits per word in bitmap */
+
+struct fc_ns_fts {
+	__be32	ff_type_map[FC_NS_TYPES / FC_NS_BPW]; /* bitmap of FC-4 types */
+};
+
+/*
+ * GID_PT request.
+ */
+struct fc_ns_gid_pt {
+	__u8		fn_pt_type;
+	__u8		fn_domain_id_scope;
+	__u8		fn_area_id_scope;
+	__u8		fn_resvd;
+};
+
+/*
+ * GID_FT or GPN_FT request.
+ */
+struct fc_ns_gid_ft {
+	__u8		fn_resvd;
+	__u8		fn_domain_id_scope;
+	__u8		fn_area_id_scope;
+	__u8		fn_fc4_type;
+};
+
+/*
+ * GPN_FT response.
+ */
+struct fc_gpn_ft_resp {
+	__u8		fp_flags;	/* see fp_flags definitions above */
+	__u8		fp_fid[3];	/* port ID */
+	__be32		fp_resvd;
+	__be64		fp_wwpn;	/* port name */
+};
+
+/*
+ * GID_PN request
+ */
+struct fc_ns_gid_pn {
+	__be64     fn_wwpn;    /* port name */
+};
+
+/*
+ * GID_PN response
+ */
+struct fc_gid_pn_resp {
+	__u8      fp_resvd;
+	__u8      fp_fid[3];     /* port ID */
+};
+
+/*
+ * RFT_ID request - register FC-4 types for ID.
+ */
+struct fc_ns_rft_id {
+	struct fc_ns_fid fr_fid;	/* port ID object */
+	struct fc_ns_fts fr_fts;	/* FC-4 types object */
+};
+
+/*
+ * RPN_ID request - register port name for ID.
+ * RNN_ID request - register node name for ID.
+ */
+struct fc_ns_rn_id {
+	struct fc_ns_fid fr_fid;	/* port ID object */
+	__be64		fr_wwn;		/* node name or port name */
+} __attribute__((__packed__));
+
+/*
+ * RSNN_NN request - register symbolic node name
+ */
+struct fc_ns_rsnn {
+	__be64		fr_wwn;		/* node name */
+	__u8		fr_name_len;
+	char		fr_name[];
+} __attribute__((__packed__));
+
+/*
+ * RSPN_ID request - register symbolic port name
+ */
+struct fc_ns_rspn {
+	struct fc_ns_fid fr_fid;	/* port ID object */
+	__u8		fr_name_len;
+	char		fr_name[];
+} __attribute__((__packed__));
+
+/*
+ * RFF_ID request - register FC-4 Features for ID.
+ */
+struct fc_ns_rff_id {
+	struct fc_ns_fid fr_fid;	/* port ID object */
+	__u8		fr_resvd[2];
+	__u8		fr_feat;	/* FC-4 Feature bits */
+	__u8		fr_type;	/* FC-4 type */
+} __attribute__((__packed__));
+
+#endif /* _FC_NS_H_ */
diff --git a/include/scsi/scsi_bsg_fc.h b/include/scsi/scsi_bsg_fc.h
new file mode 100644
index 0000000..a4b2333
--- /dev/null
+++ b/include/scsi/scsi_bsg_fc.h
@@ -0,0 +1,322 @@
+/*
+ *  FC Transport BSG Interface
+ *
+ *  Copyright (C) 2008   James Smart, Emulex Corporation
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef SCSI_BSG_FC_H
+#define SCSI_BSG_FC_H
+
+/*
+ * This file intended to be included by both kernel and user space
+ */
+
+#include <scsi/scsi.h>
+
+/*
+ * FC Transport SGIO v4 BSG Message Support
+ */
+
+/* Default BSG request timeout (in seconds) */
+#define FC_DEFAULT_BSG_TIMEOUT		(10 * HZ)
+
+
+/*
+ * Request Message Codes supported by the FC Transport
+ */
+
+/* define the class masks for the message codes */
+#define FC_BSG_CLS_MASK		0xF0000000	/* find object class */
+#define FC_BSG_HST_MASK		0x80000000	/* fc host class */
+#define FC_BSG_RPT_MASK		0x40000000	/* fc rport class */
+
+	/* fc_host Message Codes */
+#define FC_BSG_HST_ADD_RPORT		(FC_BSG_HST_MASK | 0x00000001)
+#define FC_BSG_HST_DEL_RPORT		(FC_BSG_HST_MASK | 0x00000002)
+#define FC_BSG_HST_ELS_NOLOGIN		(FC_BSG_HST_MASK | 0x00000003)
+#define FC_BSG_HST_CT			(FC_BSG_HST_MASK | 0x00000004)
+#define FC_BSG_HST_VENDOR		(FC_BSG_HST_MASK | 0x000000FF)
+
+	/* fc_rport Message Codes */
+#define FC_BSG_RPT_ELS			(FC_BSG_RPT_MASK | 0x00000001)
+#define FC_BSG_RPT_CT			(FC_BSG_RPT_MASK | 0x00000002)
+
+
+
+/*
+ * FC Address Identifiers in Message Structures :
+ *
+ *   Whenever a command payload contains a FC Address Identifier
+ *   (aka port_id), the value is effectively in big-endian
+ *   order, thus the array elements are decoded as follows:
+ *     element [0] is bits 23:16 of the FC Address Identifier
+ *     element [1] is bits 15:8 of the FC Address Identifier
+ *     element [2] is bits 7:0 of the FC Address Identifier
+ */
+
+
+/*
+ * FC Host Messages
+ */
+
+/* FC_BSG_HST_ADDR_PORT : */
+
+/* Request:
+ * This message requests the FC host to login to the remote port
+ * at the specified N_Port_Id.  The remote port is to be enumerated
+ * with the transport upon completion of the login.
+ */
+struct fc_bsg_host_add_rport {
+	uint8_t		reserved;
+
+	/* FC Address Identier of the remote port to login to */
+	uint8_t		port_id[3];
+};
+
+/* Response:
+ * There is no additional response data - fc_bsg_reply->result is sufficient
+ */
+
+
+/* FC_BSG_HST_DEL_RPORT : */
+
+/* Request:
+ * This message requests the FC host to remove an enumerated
+ * remote port and to terminate the login to it.
+ *
+ * Note: The driver is free to reject this request if it desires to
+ * remain logged in with the remote port.
+ */
+struct fc_bsg_host_del_rport {
+	uint8_t		reserved;
+
+	/* FC Address Identier of the remote port to logout of */
+	uint8_t		port_id[3];
+};
+
+/* Response:
+ * There is no additional response data - fc_bsg_reply->result is sufficient
+ */
+
+
+/* FC_BSG_HST_ELS_NOLOGIN : */
+
+/* Request:
+ * This message requests the FC_Host to send an ELS to a specific
+ * N_Port_ID. The host does not need to log into the remote port,
+ * nor does it need to enumerate the rport for further traffic
+ * (although, the FC host is free to do so if it desires).
+ */
+struct fc_bsg_host_els {
+	/*
+	 * ELS Command Code being sent (must be the same as byte 0
+	 * of the payload)
+	 */
+	uint8_t 	command_code;
+
+	/* FC Address Identier of the remote port to send the ELS to */
+	uint8_t		port_id[3];
+};
+
+/* Response:
+ */
+/* fc_bsg_ctels_reply->status values */
+#define FC_CTELS_STATUS_OK	0x00000000
+#define FC_CTELS_STATUS_REJECT	0x00000001
+#define FC_CTELS_STATUS_P_RJT	0x00000002
+#define FC_CTELS_STATUS_F_RJT	0x00000003
+#define FC_CTELS_STATUS_P_BSY	0x00000004
+#define FC_CTELS_STATUS_F_BSY	0x00000006
+struct fc_bsg_ctels_reply {
+	/*
+	 * Note: An ELS LS_RJT may be reported in 2 ways:
+	 *  a) A status of FC_CTELS_STATUS_OK is returned. The caller
+	 *     is to look into the ELS receive payload to determine
+	 *     LS_ACC or LS_RJT (by contents of word 0). The reject
+	 *     data will be in word 1.
+	 *  b) A status of FC_CTELS_STATUS_REJECT is returned, The
+	 *     rjt_data field will contain valid data.
+	 *
+	 * Note: ELS LS_ACC is determined by an FC_CTELS_STATUS_OK, and
+	 *   the receive payload word 0 indicates LS_ACC
+	 *   (e.g. value is 0x02xxxxxx).
+	 *
+	 * Note: Similarly, a CT Reject may be reported in 2 ways:
+	 *  a) A status of FC_CTELS_STATUS_OK is returned. The caller
+	 *     is to look into the CT receive payload to determine
+	 *     Accept or Reject (by contents of word 2). The reject
+	 *     data will be in word 3.
+	 *  b) A status of FC_CTELS_STATUS_REJECT is returned, The
+	 *     rjt_data field will contain valid data.
+	 *
+	 * Note: x_RJT/BSY status will indicae that the rjt_data field
+	 *   is valid and contains the reason/explanation values.
+	 */
+	uint32_t	status;		/* See FC_CTELS_STATUS_xxx */
+
+	/* valid if status is not FC_CTELS_STATUS_OK */
+	struct	{
+		uint8_t	action;		/* fragment_id for CT REJECT */
+		uint8_t	reason_code;
+		uint8_t	reason_explanation;
+		uint8_t	vendor_unique;
+	} rjt_data;
+};
+
+
+/* FC_BSG_HST_CT : */
+
+/* Request:
+ * This message requests that a CT Request be performed with the
+ * indicated N_Port_ID. The driver is responsible for logging in with
+ * the fabric and/or N_Port_ID, etc as per FC rules. This request does
+ * not mandate that the driver must enumerate the destination in the
+ * transport. The driver is allowed to decide whether to enumerate it,
+ * and whether to tear it down after the request.
+ */
+struct fc_bsg_host_ct {
+	uint8_t		reserved;
+
+	/* FC Address Identier of the remote port to send the ELS to */
+	uint8_t		port_id[3];
+
+	/*
+	 * We need words 0-2 of the generic preamble for the LLD's
+	 */
+	uint32_t	preamble_word0;	/* revision & IN_ID */
+	uint32_t	preamble_word1;	/* GS_Type, GS_SubType, Options, Rsvd */
+	uint32_t	preamble_word2;	/* Cmd Code, Max Size */
+
+};
+/* Response:
+ *
+ * The reply structure is an fc_bsg_ctels_reply structure
+ */
+
+
+/* FC_BSG_HST_VENDOR : */
+
+/* Request:
+ * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
+ *   formatting requirements specified in scsi_netlink.h
+ */
+struct fc_bsg_host_vendor {
+	/*
+	 * Identifies the vendor that the message is formatted for. This
+	 * should be the recipient of the message.
+	 */
+	uint64_t vendor_id;
+
+	/* start of vendor command area */
+	uint32_t vendor_cmd[0];
+};
+
+/* Response:
+ */
+struct fc_bsg_host_vendor_reply {
+	/* start of vendor response area */
+	uint32_t vendor_rsp[0];
+};
+
+
+
+/*
+ * FC Remote Port Messages
+ */
+
+/* FC_BSG_RPT_ELS : */
+
+/* Request:
+ * This message requests that an ELS be performed with the rport.
+ */
+struct fc_bsg_rport_els {
+	/*
+	 * ELS Command Code being sent (must be the same as
+	 * byte 0 of the payload)
+	 */
+	uint8_t els_code;
+};
+
+/* Response:
+ *
+ * The reply structure is an fc_bsg_ctels_reply structure
+ */
+
+
+/* FC_BSG_RPT_CT : */
+
+/* Request:
+ * This message requests that a CT Request be performed with the rport.
+ */
+struct fc_bsg_rport_ct {
+	/*
+	 * We need words 0-2 of the generic preamble for the LLD's
+	 */
+	uint32_t	preamble_word0;	/* revision & IN_ID */
+	uint32_t	preamble_word1;	/* GS_Type, GS_SubType, Options, Rsvd */
+	uint32_t	preamble_word2;	/* Cmd Code, Max Size */
+};
+/* Response:
+ *
+ * The reply structure is an fc_bsg_ctels_reply structure
+ */
+
+
+
+
+/* request (CDB) structure of the sg_io_v4 */
+struct fc_bsg_request {
+	uint32_t msgcode;
+	union {
+		struct fc_bsg_host_add_rport	h_addrport;
+		struct fc_bsg_host_del_rport	h_delrport;
+		struct fc_bsg_host_els		h_els;
+		struct fc_bsg_host_ct		h_ct;
+		struct fc_bsg_host_vendor	h_vendor;
+
+		struct fc_bsg_rport_els		r_els;
+		struct fc_bsg_rport_ct		r_ct;
+	} rqst_data;
+};
+
+
+/* response (request sense data) structure of the sg_io_v4 */
+struct fc_bsg_reply {
+	/*
+	 * The completion result. Result exists in two forms:
+	 *  if negative, it is an -Exxx system errno value. There will
+	 *    be no further reply information supplied.
+	 *  else, it's the 4-byte scsi error result, with driver, host,
+	 *    msg and status fields. The per-msgcode reply structure
+	 *    will contain valid data.
+	 */
+	uint32_t result;
+
+	/* If there was reply_payload, how much was recevied ? */
+	uint32_t reply_payload_rcv_len;
+
+	union {
+		struct fc_bsg_host_vendor_reply		vendor_reply;
+
+		struct fc_bsg_ctels_reply		ctels_reply;
+	} reply_data;
+};
+
+
+#endif /* SCSI_BSG_FC_H */
+
openSUSE Build Service is sponsored by