summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io
diff options
context:
space:
mode:
authorKelly Hu <kelly.hu@Sun.COM>2009-04-08 10:38:35 +0800
committerKelly Hu <kelly.hu@Sun.COM>2009-04-08 10:38:35 +0800
commitd4401b99a36e5170ccaa7defc0d2ac65b23f08c6 (patch)
tree64b7c3709e24edccb52363542527eb5af089737e /usr/src/uts/common/io
parent45e46d060213105b5301d64e637dfdba4ddfba4e (diff)
downloadillumos-gate-d4401b99a36e5170ccaa7defc0d2ac65b23f08c6.tar.gz
6815792 fcoe need to consider link name changes on the fly
6815799 Remove mac_is_vnic() and move the check for vnic to libfcoe
Diffstat (limited to 'usr/src/uts/common/io')
-rw-r--r--usr/src/uts/common/io/comstar/port/fcoet/fcoet.c18
-rw-r--r--usr/src/uts/common/io/fcoe/fcoe.c39
-rw-r--r--usr/src/uts/common/io/fcoe/fcoe.h4
-rw-r--r--usr/src/uts/common/io/fcoe/fcoe_eth.c38
-rw-r--r--usr/src/uts/common/io/fcoe/fcoe_fc.c24
-rw-r--r--usr/src/uts/common/io/fcoe/fcoe_fc.h2
6 files changed, 55 insertions, 70 deletions
diff --git a/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c b/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c
index 2a22709bb6..def426da0b 100644
--- a/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c
+++ b/usr/src/uts/common/io/comstar/port/fcoet/fcoet.c
@@ -437,7 +437,6 @@ fcoet_attach_init(fcoet_soft_state_t *ss)
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 @@ fcoet_attach_init(fcoet_soft_state_t *ss)
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
diff --git a/usr/src/uts/common/io/fcoe/fcoe.c b/usr/src/uts/common/io/fcoe/fcoe.c
index e2dbe02921..94a23219ce 100644
--- a/usr/src/uts/common/io/fcoe/fcoe.c
+++ b/usr/src/uts/common/io/fcoe/fcoe.c
@@ -116,7 +116,7 @@ static int fcoe_initchild(dev_info_t *fcoe_dip, dev_info_t *client_dip);
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 @@ fcoe_iocmd(fcoe_soft_state_t *ss, intptr_t data, int mode)
}
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 @@ fcoe_iocmd(fcoe_soft_state_t *ss, intptr_t data, int mode)
}
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 @@ fcoe_iocmd(fcoe_soft_state_t *ss, intptr_t data, int mode)
}
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 @@ fcoe_detach_uninit(fcoe_soft_state_t *ss)
* 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 @@ fcoe_init_wwn_from_mac(uint8_t *wwn, uint8_t *mac, int is_pwwn, uint8_t idx)
* 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 @@ fcoe_cmp_wwn(fcoe_mac_t *checkedmac)
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 @@ fcoe_get_port_list(fcoe_port_instance_t *ports, int count)
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,
diff --git a/usr/src/uts/common/io/fcoe/fcoe.h b/usr/src/uts/common/io/fcoe/fcoe.h
index 222a29bf12..38a1a05cf8 100644
--- a/usr/src/uts/common/io/fcoe/fcoe.h
+++ b/usr/src/uts/common/io/fcoe/fcoe.h
@@ -123,7 +123,7 @@ typedef struct fcoe_soft_state {
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 @@ typedef struct fcoe_worker {
/*
* 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 *);
diff --git a/usr/src/uts/common/io/fcoe/fcoe_eth.c b/usr/src/uts/common/io/fcoe/fcoe_eth.c
index 91b4aa2032..7f2763c5cd 100644
--- a/usr/src/uts/common/io/fcoe/fcoe_eth.c
+++ b/usr/src/uts/common/io/fcoe/fcoe_eth.c
@@ -70,22 +70,14 @@ fcoe_open_mac(fcoe_mac_t *mac, int force_promisc, fcoeio_stat_t *err_detail)
/*
* 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 @@ fcoe_enable_callback(fcoe_mac_t *mac)
&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 @@ fcoe_mac_notify(void *arg, mac_notify_type_t type)
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 @@ fcoe_mac_set_address(fcoe_port_t *eport, uint8_t *addr, boolean_t fc_assigned)
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);
}
}
diff --git a/usr/src/uts/common/io/fcoe/fcoe_fc.c b/usr/src/uts/common/io/fcoe/fcoe_fc.c
index e1cb5e3bad..68ec016134 100644
--- a/usr/src/uts/common/io/fcoe/fcoe_fc.c
+++ b/usr/src/uts/common/io/fcoe/fcoe_fc.c
@@ -72,7 +72,7 @@ fcoe_register_client(fcoe_client_t *client)
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 @@ fcoe_register_client(fcoe_client_t *client)
*/
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_deregister_client(fcoe_port_t *eport)
{
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 @@ fcoe_create_port(dev_info_t *parent, fcoe_mac_t *mac, int is_target)
{
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 @@ fcoe_create_port(dev_info_t *parent, fcoe_mac_t *mac, int is_target)
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 @@ fcoe_create_port(dev_info_t *parent, fcoe_mac_t *mac, int is_target)
}
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);
diff --git a/usr/src/uts/common/io/fcoe/fcoe_fc.h b/usr/src/uts/common/io/fcoe/fcoe_fc.h
index 8fbbe52936..51ee375130 100644
--- a/usr/src/uts/common/io/fcoe/fcoe_fc.h
+++ b/usr/src/uts/common/io/fcoe/fcoe_fc.h
@@ -36,7 +36,7 @@ extern fcoe_frame_t *fcoe_allocate_frame(fcoe_port_t *, uint32_t, void *);
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 */