6815792 fcoe need to consider link name changes on the fly
authorKelly Hu <kelly.hu@Sun.COM>
Wed, 08 Apr 2009 10:38:35 +0800
changeset 9307 7d2e1e823986
parent 9306 b4e1026791dd
child 9308 dd8dc970f04a
6815792 fcoe need to consider link name changes on the fly 6815799 Remove mac_is_vnic() and move the check for vnic to libfcoe
usr/src/cmd/fcinfo/fcinfo.h
usr/src/cmd/fcinfo/fcoeadm.c
usr/src/lib/libfcoe/Makefile.com
usr/src/lib/libfcoe/common/libfcoe.c
usr/src/lib/libfcoe/common/libfcoe.h
usr/src/uts/common/io/comstar/port/fcoet/fcoet.c
usr/src/uts/common/io/fcoe/fcoe.c
usr/src/uts/common/io/fcoe/fcoe.h
usr/src/uts/common/io/fcoe/fcoe_eth.c
usr/src/uts/common/io/fcoe/fcoe_fc.c
usr/src/uts/common/io/fcoe/fcoe_fc.h
usr/src/uts/common/sys/fcoe/fcoe_common.h
usr/src/uts/common/sys/fcoe/fcoeio.h
--- a/usr/src/cmd/fcinfo/fcinfo.h	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/cmd/fcinfo/fcinfo.h	Wed Apr 08 10:38:35 2009 +0800
@@ -119,7 +119,6 @@
 #define	TARGET_MODE	    0x00000010
 
 /* FCOE */
-#define	FCOE_MAX_MAC_NAME_LEN		32
 #define	FCOE_USER_RAW_FRAME_SIZE	224
 
 typedef struct _tgtPortWWNList {
--- a/usr/src/cmd/fcinfo/fcoeadm.c	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/cmd/fcinfo/fcoeadm.c	Wed Apr 08 10:38:35 2009 +0800
@@ -621,9 +621,16 @@
 			    "port on the specified MAC link\n"));
 			break;
 
-		case  FCOE_STATUS_ERROR_VNIC_UNSUPPORT:
+		case  FCOE_STATUS_ERROR_CLASS_UNSUPPORT:
 			fprintf(stderr,
-			    gettext("Error: VNIC is not supported\n"));
+			    gettext("Error: Link class other than physical "
+			    "link is not supported\n"));
+			break;
+
+		case FCOE_STATUS_ERROR_GET_LINKINFO:
+			fprintf(stderr,
+			    gettext("Error: Failed to get link infomation "
+			    "for %s\n"), macLinkName);
 			break;
 
 		case FCOE_STATUS_ERROR:
@@ -702,6 +709,12 @@
 			    "the FCoE target first\n"));
 			break;
 
+		case FCOE_STATUS_ERROR_GET_LINKINFO:
+			fprintf(stderr,
+			    gettext("Error: Failed to get link information "
+			    "for %s\n"), macLinkName);
+			break;
+
 		case FCOE_STATUS_ERROR:
 		default:
 			fprintf(stderr,
--- a/usr/src/lib/libfcoe/Makefile.com	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/lib/libfcoe/Makefile.com	Wed Apr 08 10:38:35 2009 +0800
@@ -37,7 +37,7 @@
 INCS +=		-I$(SRCDIR)
 INCS +=		-I$(SRC)/uts/common/sys/fcoe
 
-LDLIBS +=	-lc
+LDLIBS +=	-lc -ldladm
 C99MODE=	-xc99=%all
 C99LMODE=	-Xc99=%all
 CPPFLAGS +=	$(INCS) -D_REENTRANT
--- a/usr/src/lib/libfcoe/common/libfcoe.c	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/lib/libfcoe/common/libfcoe.c	Wed Apr 08 10:38:35 2009 +0800
@@ -37,6 +37,7 @@
 #include <assert.h>
 #include <syslog.h>
 #include <libfcoe.h>
+#include <libdllink.h>
 #include <fcoeio.h>
 
 #define	FCOE_DEV_PATH	 "/devices/fcoe:admin"
@@ -92,10 +93,13 @@
 	FCOE_PORT_WWN		nwwn,
 	FCOE_UINT8		promiscuous)
 {
-	FCOE_STATUS status = FCOE_STATUS_OK;
-	int fcoe_fd;
-	fcoeio_t	fcoeio;
+	FCOE_STATUS		status = FCOE_STATUS_OK;
+	int			fcoe_fd;
+	fcoeio_t		fcoeio;
 	fcoeio_create_port_param_t	param;
+	dladm_handle_t		handle;
+	datalink_id_t		linkid;
+	datalink_class_t	class;
 
 	bzero(&param, sizeof (fcoeio_create_port_param_t));
 
@@ -103,6 +107,25 @@
 		return (FCOE_STATUS_ERROR_INVAL_ARG);
 	}
 
+	if (strlen((char *)macLinkName) > MAXLINKNAMELEN-1) {
+		return (FCOE_STATUS_ERROR_MAC_LEN);
+	}
+
+	if (dladm_open(&handle) != DLADM_STATUS_OK) {
+		return (FCOE_STATUS_ERROR);
+	}
+
+	if (dladm_name2info(handle, (const char *)macLinkName,
+	    &linkid, NULL, &class, NULL) != DLADM_STATUS_OK) {
+		dladm_close(handle);
+		return (FCOE_STATUS_ERROR_GET_LINKINFO);
+	}
+	dladm_close(handle);
+
+	if (class != DATALINK_CLASS_PHYS) {
+		return (FCOE_STATUS_ERROR_CLASS_UNSUPPORT);
+	}
+
 	if (portType != FCOE_PORTTYPE_INITIATOR &&
 	    portType != FCOE_PORTTYPE_TARGET) {
 		return (FCOE_STATUS_ERROR_INVAL_ARG);
@@ -124,12 +147,8 @@
 		return (FCOE_STATUS_ERROR_WWN_SAME);
 	}
 
-	if (strlen((char *)macLinkName) > FCOE_MAX_MAC_NAME_LEN-1) {
-		return (FCOE_STATUS_ERROR_MAC_LEN);
-	}
-
 	param.fcp_force_promisc = promiscuous;
-	(void) strcpy((char *)param.fcp_mac_name, (char *)macLinkName);
+	param.fcp_mac_linkid = linkid;
 	param.fcp_port_type = (fcoe_cli_type_t)portType;
 
 	if ((status = openFcoe(OPEN_FCOE, &fcoe_fd)) != FCOE_STATUS_OK) {
@@ -181,10 +200,6 @@
 			status = FCOE_STATUS_ERROR_NEED_JUMBO_FRAME;
 			break;
 
-		case FCOEIOE_VNIC_UNSUPPORT:
-			status = FCOE_STATUS_ERROR_VNIC_UNSUPPORT;
-			break;
-
 		default:
 			status = FCOE_STATUS_ERROR;
 		}
@@ -201,25 +216,41 @@
 	FCOE_STATUS status = FCOE_STATUS_OK;
 	int fcoe_fd;
 	fcoeio_t	fcoeio;
+	dladm_handle_t		handle;
+	datalink_id_t		linkid;
+	fcoeio_delete_port_param_t fc_del_port;
 
 	if (macLinkName == NULL) {
 		return (FCOE_STATUS_ERROR_INVAL_ARG);
 	}
 
-	if (strlen((char *)macLinkName) > FCOE_MAX_MAC_NAME_LEN-1) {
+	if (strlen((char *)macLinkName) > MAXLINKNAMELEN-1) {
 		return (FCOE_STATUS_ERROR_MAC_LEN);
 	}
+	if (dladm_open(&handle) != DLADM_STATUS_OK) {
+		return (FCOE_STATUS_ERROR);
+	}
+
+	if (dladm_name2info(handle, (const char *)macLinkName,
+	    &linkid, NULL, NULL, NULL) != DLADM_STATUS_OK) {
+		dladm_close(handle);
+		return (FCOE_STATUS_ERROR_GET_LINKINFO);
+	}
+	dladm_close(handle);
 
 	if ((status = openFcoe(OPEN_FCOE, &fcoe_fd)) != FCOE_STATUS_OK) {
 		return (status);
 	}
 
+	fc_del_port.fdp_mac_linkid = linkid;
+
 	(void) memset(&fcoeio, 0, sizeof (fcoeio));
 	fcoeio.fcoeio_cmd = FCOEIO_DELETE_FCOE_PORT;
 
-	fcoeio.fcoeio_ilen = strlen((char *)macLinkName)+1;
+	/* only 4 bytes here, need to change */
+	fcoeio.fcoeio_ilen = sizeof (fcoeio_delete_port_param_t);
 	fcoeio.fcoeio_xfer = FCOEIO_XFER_WRITE;
-	fcoeio.fcoeio_ibuf = (uintptr_t)macLinkName;
+	fcoeio.fcoeio_ibuf = (uintptr_t)&fc_del_port;
 
 	if (ioctl(fcoe_fd, FCOEIO_CMD, &fcoeio) != 0) {
 		switch (fcoeio.fcoeio_status) {
@@ -259,14 +290,16 @@
 	FCOE_PORT_ATTRIBUTE	**portlist)
 {
 	FCOE_STATUS	status = FCOE_STATUS_OK;
-	int	fcoe_fd;
+	int		fcoe_fd;
 	fcoeio_t	fcoeio;
-	fcoe_port_list_t		*inportlist = NULL;
+	fcoe_port_list_t	*inportlist = NULL;
 	FCOE_PORT_ATTRIBUTE	*outportlist = NULL;
-	int	i;
-	int	size = 64; /* default first attempt */
-	int	retry = 0;
-	int	bufsize;
+	int		i;
+	int		size = 64; /* default first attempt */
+	int		retry = 0;
+	int		bufsize;
+	dladm_handle_t	handle;
+	char		mac_name[MAXLINKNAMELEN];
 
 	if (port_num == NULL || portlist == NULL) {
 		return (FCOE_STATUS_ERROR_INVAL_ARG);
@@ -318,7 +351,11 @@
 		}
 	} while (retry <= 3 && status != FCOE_STATUS_OK);
 
-	if (status == FCOE_STATUS_OK) {
+	if (status == FCOE_STATUS_OK && inportlist->numPorts > 0) {
+		if (dladm_open(&handle) != DLADM_STATUS_OK) {
+			handle = NULL;
+		}
+
 		outportlist = (PFCOE_PORT_ATTRIBUTE)
 		    malloc(sizeof (FCOE_PORT_ATTRIBUTE) * inportlist->numPorts);
 
@@ -326,7 +363,17 @@
 			fcoe_port_instance_t *pi = &inportlist->ports[i];
 			FCOE_PORT_ATTRIBUTE *po = &outportlist[i];
 			bcopy(pi->fpi_pwwn, &po->port_wwn, 8);
-			bcopy(pi->fpi_mac_link_name, po->mac_link_name, 32);
+
+			if (handle == NULL ||
+			    dladm_datalink_id2info(handle, pi->fpi_mac_linkid,
+			    NULL, NULL, NULL, mac_name, sizeof (mac_name))
+			    != DLADM_STATUS_OK) {
+				(void) strcpy((char *)po->mac_link_name,
+				    "<unknown>");
+			} else {
+				(void) strcpy((char *)po->mac_link_name,
+				    mac_name);
+			}
 			bcopy(pi->fpi_mac_factory_addr,
 			    po->mac_factory_addr, 6);
 			bcopy(pi->fpi_mac_current_addr,
@@ -335,6 +382,10 @@
 			po->mtu_size = pi->fpi_mtu_size;
 			po->mac_promisc = pi->fpi_mac_promisc;
 		}
+
+		if (handle != NULL) {
+			dladm_close(handle);
+		}
 		*port_num = inportlist->numPorts;
 		*portlist = outportlist;
 		free(inportlist);
--- a/usr/src/lib/libfcoe/common/libfcoe.h	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/lib/libfcoe/common/libfcoe.h	Wed Apr 08 10:38:35 2009 +0800
@@ -70,7 +70,8 @@
 #define	FCOE_STATUS_ERROR_MAC_NOT_FOUND		15
 #define	FCOE_STATUS_ERROR_OFFLINE_DEV		16
 #define	FCOE_STATUS_ERROR_MORE_DATA		17
-#define	FCOE_STATUS_ERROR_VNIC_UNSUPPORT	18
+#define	FCOE_STATUS_ERROR_CLASS_UNSUPPORT	18
+#define	FCOE_STATUS_ERROR_GET_LINKINFO		19
 
 typedef struct fcoe_port_wwn {
 	uchar_t	wwn[8];
--- a/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c	Wed Apr 08 10:38:35 2009 +0800
@@ -437,7 +437,6 @@
 	fcoe_port_t		*eport;
 	fct_local_port_t	*port;
 	fct_dbuf_store_t	*fds;
-	char			 *mac_name;
 	char			 taskq_name[32];
 	int			 ret;
 
@@ -453,19 +452,16 @@
 	client_fcoet.ect_port_event = fcoet_port_event;
 	client_fcoet.ect_release_sol_frame = fcoet_release_sol_frame;
 	client_fcoet.ect_client_port_struct = ss;
-	ret = ddi_prop_lookup_string(DDI_DEV_T_ANY, ss->ss_dip,
-	    DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "mac_name", &mac_name);
-	if (ret != DDI_PROP_SUCCESS) {
-		FCOET_LOG("fcoet_attach_init", "lookup_string failed");
+	ret = ddi_prop_get_int(DDI_DEV_T_ANY, ss->ss_dip,
+	    DDI_PROP_DONTPASS | DDI_PROP_NOTPROM, "mac_id", -1);
+	if (ret == -1) {
+		FCOET_LOG("fcoet_attach_init", "get mac_id failed");
 		return (DDI_FAILURE);
 	} else {
-		bcopy(mac_name, client_fcoet.ect_channel_name,
-		    strlen(mac_name));
-		client_fcoet.ect_channel_name[strlen(mac_name)] = 0;
-		ddi_prop_free(mac_name);
+		client_fcoet.ect_channelid = ret;
 	}
-	FCOET_LOG("fcoet_attach_init", "channel_name is %s",
-	    client_fcoet.ect_channel_name);
+	FCOET_LOG("fcoet_attach_init", "channel_id is %d",
+	    client_fcoet.ect_channelid);
 
 	/*
 	 * It's FCoE's responsiblity to initialize eport's all elements
--- a/usr/src/uts/common/io/fcoe/fcoe.c	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/uts/common/io/fcoe/fcoe.c	Wed Apr 08 10:38:35 2009 +0800
@@ -116,7 +116,7 @@
 static int fcoe_uninitchild(dev_info_t *fcoe_dip, dev_info_t *client_dip);
 static void fcoe_init_wwn_from_mac(uint8_t *wwn, uint8_t *mac,
     int is_pwwn, uint8_t idx);
-static fcoe_mac_t *fcoe_create_mac_by_name(uint8_t *name);
+static fcoe_mac_t *fcoe_create_mac_by_id(datalink_id_t linkid);
 static int fcoe_cmp_wwn(fcoe_mac_t *checkedmac);
 static void fcoe_watchdog(void *arg);
 static void fcoe_worker_init();
@@ -682,7 +682,7 @@
 		}
 
 		mutex_enter(&ss->ss_ioctl_mutex);
-		fcoe_mac = fcoe_create_mac_by_name(param->fcp_mac_name);
+		fcoe_mac = fcoe_create_mac_by_id(param->fcp_mac_linkid);
 		if (fcoe_mac == NULL) {
 			mutex_exit(&ss->ss_ioctl_mutex);
 			fcoeio->fcoeio_status = FCOEIOE_CREATE_MAC;
@@ -762,9 +762,10 @@
 	}
 
 	case FCOEIO_DELETE_FCOE_PORT: {
-		uint8_t *mac_name = (uint8_t *)ibuf;
+		fcoeio_delete_port_param_t *del_port_param =
+		    (fcoeio_delete_port_param_t *)ibuf;
 
-		if (fcoeio->fcoeio_ilen > FCOE_MAX_MAC_NAME_LEN ||
+		if (fcoeio->fcoeio_ilen < sizeof (fcoeio_delete_port_param_t) ||
 		    fcoeio->fcoeio_xfer != FCOEIO_XFER_WRITE) {
 			fcoeio->fcoeio_status = FCOEIOE_INVAL_ARG;
 			ret = EINVAL;
@@ -772,7 +773,8 @@
 		}
 
 		mutex_enter(&ss->ss_ioctl_mutex);
-		ret = fcoe_delete_port(ss->ss_dip, fcoeio, mac_name);
+		ret = fcoe_delete_port(ss->ss_dip, fcoeio,
+		    del_port_param->fdp_mac_linkid);
 		if (ret != 0) {
 			FCOE_LOG("fcoe",
 			    "fcoe_delete_port failed: %d", ret);
@@ -935,14 +937,14 @@
  * Return mac instance if it exist, or else return NULL.
  */
 fcoe_mac_t *
-fcoe_lookup_mac_by_name(uint8_t *name)
+fcoe_lookup_mac_by_id(datalink_id_t linkid)
 {
 	fcoe_mac_t	*mac = NULL;
 
-	ASSERT(mutex_owned(&fcoe_global_ss->ss_ioctl_mutex));
+	ASSERT(MUTEX_HELD(&fcoe_global_ss->ss_ioctl_mutex));
 	for (mac = list_head(&fcoe_global_ss->ss_mac_list); mac;
 	    mac = list_next(&fcoe_global_ss->ss_mac_list, mac)) {
-		if (strcmp((char *)name, mac->fm_link_name)) {
+		if (linkid != mac->fm_linkid) {
 			continue;
 		}
 		return (mac);
@@ -967,24 +969,24 @@
  * Return fcoe_mac if it exists, otherwise create a new one
  */
 static fcoe_mac_t *
-fcoe_create_mac_by_name(uint8_t *name)
+fcoe_create_mac_by_id(datalink_id_t linkid)
 {
 	fcoe_mac_t	*mac = NULL;
-	ASSERT(mutex_owned(&fcoe_global_ss->ss_ioctl_mutex));
+	ASSERT(MUTEX_HELD(&fcoe_global_ss->ss_ioctl_mutex));
 
-	mac = fcoe_lookup_mac_by_name(name);
+	mac = fcoe_lookup_mac_by_id(linkid);
 	if (mac != NULL) {
-		FCOE_LOG("fcoe", "fcoe_create_mac_by_name found one mac %s",
-		    name);
+		FCOE_LOG("fcoe", "fcoe_create_mac_by_id found one mac %d",
+		    linkid);
 		return (mac);
 	}
 
 	mac = kmem_zalloc(sizeof (fcoe_mac_t), KM_SLEEP);
-	bcopy(name, mac->fm_link_name, strlen((char *)name) + 1);
+	mac->fm_linkid = linkid;
 	mac->fm_flags = 0;
 	mac->fm_ss = fcoe_global_ss;
 	list_insert_tail(&mac->fm_ss->ss_mac_list, mac);
-	FCOE_LOG("fcoe", "fcoe_create_mac_by_name created one mac %s", name);
+	FCOE_LOG("fcoe", "fcoe_create_mac_by_id created one mac %d", linkid);
 	return (mac);
 }
 
@@ -1232,7 +1234,7 @@
 
 	cnwwn = checkedmac->fm_eport.eport_nodewwn;
 	cpwwn = checkedmac->fm_eport.eport_portwwn;
-	ASSERT(mutex_owned(&fcoe_global_ss->ss_ioctl_mutex));
+	ASSERT(MUTEX_HELD(&fcoe_global_ss->ss_ioctl_mutex));
 
 	for (mac = list_head(&fcoe_global_ss->ss_mac_list); mac;
 	    mac = list_next(&fcoe_global_ss->ss_mac_list, mac)) {
@@ -1260,15 +1262,14 @@
 	int		i = 0;
 
 	ASSERT(ports != NULL);
-	ASSERT(mutex_owned(&fcoe_global_ss->ss_ioctl_mutex));
+	ASSERT(MUTEX_HELD(&fcoe_global_ss->ss_ioctl_mutex));
 
 	for (mac = list_head(&fcoe_global_ss->ss_mac_list); mac;
 	    mac = list_next(&fcoe_global_ss->ss_mac_list, mac)) {
 		if (i < count) {
 			bcopy(mac->fm_eport.eport_portwwn,
 			    ports[i].fpi_pwwn, 8);
-			bcopy(mac->fm_link_name,
-			    ports[i].fpi_mac_link_name, MAXLINKNAMELEN);
+			ports[i].fpi_mac_linkid = mac->fm_linkid;
 			bcopy(mac->fm_current_addr,
 			    ports[i].fpi_mac_current_addr, ETHERADDRL);
 			bcopy(mac->fm_primary_addr,
--- a/usr/src/uts/common/io/fcoe/fcoe.h	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/uts/common/io/fcoe/fcoe.h	Wed Apr 08 10:38:35 2009 +0800
@@ -123,7 +123,7 @@
 typedef struct fcoe_mac
 {
 	list_node_t		fm_ss_node;
-	char			fm_link_name[MAXLINKNAMELEN];
+	datalink_id_t		fm_linkid;
 	uint32_t		fm_flags;
 
 	fcoe_soft_state_t	*fm_ss;
@@ -235,7 +235,7 @@
 /*
  * fcoe driver common functions
  */
-extern fcoe_mac_t *fcoe_lookup_mac_by_name(uint8_t *);
+extern fcoe_mac_t *fcoe_lookup_mac_by_id(datalink_id_t);
 extern void fcoe_destroy_mac(fcoe_mac_t *);
 extern mblk_t *fcoe_get_mblk(fcoe_mac_t *, uint32_t);
 extern void fcoe_post_frame(fcoe_frame_t *);
--- a/usr/src/uts/common/io/fcoe/fcoe_eth.c	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/uts/common/io/fcoe/fcoe_eth.c	Wed Apr 08 10:38:35 2009 +0800
@@ -70,22 +70,14 @@
 	/*
 	 * Open MAC interface
 	 */
-	ret = mac_open_by_linkname(mac->fm_link_name, &mac->fm_handle);
+	ret = mac_open_by_linkid(mac->fm_linkid, &mac->fm_handle);
 	if (ret != 0) {
-		cmn_err(CE_WARN, "Open network interface %s failed",
-		    mac->fm_link_name);
-		FCOE_LOG("fcoe", "mac_open_by_linkname %s failed %x",
-		    mac->fm_link_name, ret);
+		FCOE_LOG("fcoe", "mac_open_by_linkname %d failed %x",
+		    mac->fm_linkid, ret);
 		return (FCOE_FAILURE);
 	}
 
-	if (mac_is_vnic(mac->fm_handle)) {
-		(void) mac_close(mac->fm_handle);
-		*err_detail = FCOEIOE_VNIC_UNSUPPORT;
-		return (FCOE_FAILURE);
-	}
-
-	(void) sprintf(cli_name, "%s-%s", mac->fm_link_name, "fcoe");
+	(void) sprintf(cli_name, "%s-%d", "fcoe", mac->fm_linkid);
 
 	ret = mac_client_open(mac->fm_handle,
 	    &mac->fm_cli_handle, cli_name, fm_open_flag);
@@ -194,10 +186,8 @@
 		    &mac->fm_promisc_handle,
 		    MAC_PROMISC_FLAGS_NO_TX_LOOP);
 		if (ret != 0) {
-			cmn_err(CE_WARN, "Enable promisc mode on %s failed",
-			    mac->fm_link_name);
-			FCOE_LOG("foce", "mac_promisc_add on %s failed %x",
-			    mac->fm_link_name, ret);
+			FCOE_LOG("foce", "mac_promisc_add on %d failed %x",
+			    mac->fm_linkid, ret);
 			return (FCOE_FAILURE);
 		}
 	} else {
@@ -308,16 +298,18 @@
 			    mac->fm_eport.eport_efh_dst);
 
 			mac->fm_link_state = FCOE_MAC_LINK_STATE_UP;
-			FCOE_LOG(mac->fm_link_name,
-			    "fcoe_mac_notify: arg/%p LINK up", arg, type);
+			FCOE_LOG(NULL,
+			    "fcoe_mac_notify: link/%d arg/%p LINK up",
+			    mac->fm_linkid, arg, type);
 			fcoe_mac_notify_link_up(mac);
 		} else {
 			if (mac->fm_link_state == FCOE_MAC_LINK_STATE_DOWN) {
 				break;
 			}
 			mac->fm_link_state = FCOE_MAC_LINK_STATE_DOWN;
-			FCOE_LOG(mac->fm_link_name,
-			    "fcoe_mac_notify: arg/%p LINK down", arg, type);
+			FCOE_LOG(NULL,
+			    "fcoe_mac_notify: link/%d arg/%p LINK down",
+			    mac->fm_linkid, arg, type);
 			fcoe_mac_notify_link_down(mac);
 		}
 		break;
@@ -355,10 +347,8 @@
 		ret = mac_unicast_primary_set(mac->fm_handle, addr);
 		if (ret != 0) {
 			mutex_exit(&mac->fm_mutex);
-			cmn_err(CE_WARN, "Set primary unicast address on %s "
-			    "failed", mac->fm_link_name);
-			FCOE_LOG("fcoe", "mac_unicast_primary_set on %s "
-			    "failed %x", mac->fm_link_name, ret);
+			FCOE_LOG("fcoe", "mac_unicast_primary_set on %d "
+			    "failed %x", mac->fm_linkid, ret);
 			return (FCOE_FAILURE);
 		}
 	}
--- a/usr/src/uts/common/io/fcoe/fcoe_fc.c	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/uts/common/io/fcoe/fcoe_fc.c	Wed Apr 08 10:38:35 2009 +0800
@@ -72,7 +72,7 @@
 	fcoe_mac_t	*mac;
 	fcoe_port_t	*eport;
 
-	ASSERT(mutex_owned(&fcoe_global_ss->ss_ioctl_mutex));
+	ASSERT(MUTEX_HELD(&fcoe_global_ss->ss_ioctl_mutex));
 
 	/*
 	 * We will not come here, when someone is changing ss_mac_list,
@@ -80,8 +80,7 @@
 	 */
 	for (mac = list_head(&fcoe_global_ss->ss_mac_list); mac;
 	    mac = list_next(&fcoe_global_ss->ss_mac_list, mac)) {
-		if (strcmp(client->ect_channel_name, mac->fm_link_name)
-		    == 0) {
+		if (client->ect_channelid == mac->fm_linkid) {
 			break;
 		}
 	}
@@ -132,7 +131,7 @@
 {
 	fcoe_mac_t	*mac = EPORT2MAC(eport);
 
-	ASSERT(mutex_owned(&fcoe_global_ss->ss_ioctl_mutex));
+	ASSERT(MUTEX_HELD(&fcoe_global_ss->ss_ioctl_mutex));
 
 	/*
 	 * Wait for all the related frame to be freed, this should be fast
@@ -425,7 +424,6 @@
 {
 	int		 rval	  = 0;
 	dev_info_t	*child	  = NULL;
-	char		*mac_name = mac->fm_link_name;
 	char *devname = is_target ? FCOET_DRIVER_NAME : FCOEI_DRIVER_NAME;
 
 	ndi_devi_alloc_sleep(parent, devname, DEVI_PSEUDO_NODEID, &child);
@@ -434,19 +432,19 @@
 		return (NDI_FAILURE);
 	}
 
-	if (ddi_prop_update_string(DDI_DEV_T_NONE, child,
-	    "mac_name", mac_name) != DDI_PROP_SUCCESS) {
+	if (ddi_prop_update_int(DDI_DEV_T_NONE, child,
+	    "mac_id", mac->fm_linkid) != DDI_PROP_SUCCESS) {
 		FCOE_LOG("fcoe",
-		    "fcoe%d: prop_update port mac name failed for mac %s",
-		    ddi_get_instance(parent), mac_name);
+		    "fcoe%d: prop_update port mac id failed for mac %d",
+		    ddi_get_instance(parent), mac->fm_linkid);
 		(void) ndi_devi_free(child);
 		return (NDI_FAILURE);
 	}
 
 	rval = ndi_devi_online(child, NDI_ONLINE_ATTACH);
 	if (rval != NDI_SUCCESS) {
-		FCOE_LOG("fcoe", "fcoe%d: online_driver failed for mac %s",
-		    ddi_get_instance(parent), mac->fm_link_name);
+		FCOE_LOG("fcoe", "fcoe%d: online_driver failed for mac %d",
+		    ddi_get_instance(parent), mac->fm_linkid);
 		return (NDI_FAILURE);
 	}
 	mac->fm_client_dev = child;
@@ -455,12 +453,12 @@
 }
 
 int
-fcoe_delete_port(dev_info_t *parent, fcoeio_t *fcoeio, uint8_t *mac_name)
+fcoe_delete_port(dev_info_t *parent, fcoeio_t *fcoeio, datalink_id_t linkid)
 {
 	int		 rval = 0;
 	fcoe_mac_t	*mac;
 
-	mac = fcoe_lookup_mac_by_name(mac_name);
+	mac = fcoe_lookup_mac_by_id(linkid);
 	if (mac == NULL) {
 		fcoeio->fcoeio_status = FCOEIOE_MAC_NOT_FOUND;
 		return (EINVAL);
--- a/usr/src/uts/common/io/fcoe/fcoe_fc.h	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/uts/common/io/fcoe/fcoe_fc.h	Wed Apr 08 10:38:35 2009 +0800
@@ -36,7 +36,7 @@
 extern void fcoe_mac_notify_link_up(void *);
 extern void fcoe_mac_notify_link_down(void *);
 extern int fcoe_create_port(dev_info_t *, fcoe_mac_t *, int);
-extern int fcoe_delete_port(dev_info_t *, fcoeio_t *, uint8_t *);
+extern int fcoe_delete_port(dev_info_t *, fcoeio_t *, datalink_id_t);
 
 #endif	/* _KERNEL */
 
--- a/usr/src/uts/common/sys/fcoe/fcoe_common.h	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/uts/common/sys/fcoe/fcoe_common.h	Wed Apr 08 10:38:35 2009 +0800
@@ -156,7 +156,7 @@
 	uint32_t	 ect_eport_flags;
 	uint32_t	 ect_max_fc_frame_size;
 	uint32_t	 ect_private_frame_struct_size;
-	char		 ect_channel_name[32];
+	uint32_t	 ect_channelid;
 	void		*ect_client_port_struct;
 	void		 (*ect_rx_frame)(fcoe_frame_t *frame);
 	void		 (*ect_port_event)(fcoe_port_t *eport, uint32_t event);
--- a/usr/src/uts/common/sys/fcoe/fcoeio.h	Wed Apr 08 10:42:55 2009 +0800
+++ b/usr/src/uts/common/sys/fcoe/fcoeio.h	Wed Apr 08 10:38:35 2009 +0800
@@ -26,6 +26,7 @@
 #define	_FCOEIO_H_
 
 #include <sys/ethernet.h>
+#include <sys/types.h>
 
 #ifdef	__cplusplus
 extern "C" {
@@ -72,8 +73,7 @@
 	FCOEIOE_NEED_JUMBO_FRAME,
 	FCOEIOE_MAC_NOT_FOUND,
 	FCOEIOE_OFFLINE_FAILURE,
-	FCOEIOE_MORE_DATA,
-	FCOEIOE_VNIC_UNSUPPORT
+	FCOEIOE_MORE_DATA
 } fcoeio_stat_t;
 
 /* Biggest buffer length, can hold up to 1024 port instances */
@@ -112,15 +112,22 @@
 	uint32_t	fcp_pwwn_provided;
 	uint32_t	fcp_force_promisc;
 	fcoe_cli_type_t	fcp_port_type;
-	uchar_t		fcp_mac_name[MAXLINKNAMELEN];
+	datalink_id_t	fcp_mac_linkid;
+	uint32_t	fcp_rsvd0;
 } fcoeio_create_port_param_t;
 
+typedef struct fcoeio_delete_port_param {
+	datalink_id_t	fdp_mac_linkid;
+	uint32_t	fdp_rsvd0;
+} fcoeio_delete_port_param_t;
+
 /*
  * FCOE port instance
  */
 typedef struct fcoe_port_instance {
 	uchar_t			fpi_pwwn[FCOE_WWN_SIZE];
-	uchar_t			fpi_mac_link_name[MAXLINKNAMELEN];
+	datalink_id_t		fpi_mac_linkid;
+	uint32_t		fpi_rsvd0;
 	uint8_t			fpi_mac_factory_addr[ETHERADDRL];
 	uint16_t		fpi_mac_promisc;
 	uint8_t			fpi_mac_current_addr[ETHERADDRL];