Mercurial > illumos > illumos-gate
changeset 8047:b817625b38dd
6769309 handling of alternative mac addresses prevents mixing of hybrid and vio vnets on a vsw
author | Michael Speer <Michael.Speer@Sun.COM> |
---|---|
date | Sat, 08 Nov 2008 21:40:49 -0800 |
parents | 9faea95046da |
children | 4b8c6e469829 |
files | usr/src/uts/common/io/nxge/nxge_hio.c usr/src/uts/common/io/nxge/nxge_mac.c usr/src/uts/common/io/nxge/nxge_main.c usr/src/uts/common/sys/nxge/nxge_hio.h |
diffstat | 4 files changed, 41 insertions(+), 78 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/uts/common/io/nxge/nxge_hio.c Sat Nov 08 16:03:01 2008 -0800 +++ b/usr/src/uts/common/io/nxge/nxge_hio.c Sat Nov 08 21:40:49 2008 -0800 @@ -1251,7 +1251,7 @@ nxge_hio_vr_t *vr; /* The Virtualization Region */ uint64_t rmap, tmap; - int rv; + int rdctbl, rv; nxge_hio_data_t *nhd = (nxge_hio_data_t *)nxge->nxge_hw_p->hio; @@ -1272,10 +1272,11 @@ /* * Get an RDC group for us to use. */ - if ((vr->rdc_tbl = nxge_hio_hostinfo_get_rdc_table(nxge)) < 0) { + if ((rdctbl = nxge_hio_hostinfo_get_rdc_table(nxge)) < 0) { nxge_hio_unshare(vr); return (EBUSY); } + vr->rdc_tbl = (uint8_t)rdctbl; /* * Add resources to the share.
--- a/usr/src/uts/common/io/nxge/nxge_mac.c Sat Nov 08 16:03:01 2008 -0800 +++ b/usr/src/uts/common/io/nxge/nxge_mac.c Sat Nov 08 21:40:49 2008 -0800 @@ -51,6 +51,8 @@ boolean_t factory); extern int nxge_m_mmac_add(void *arg, mac_multi_addr_t *maddr); extern int nxge_m_mmac_remove(void *arg, mac_addr_slot_t slot); +extern int nxge_altmac_set(p_nxge_t nxgep, uint8_t *mac_addr, + mac_addr_slot_t slot, uint8_t rdctbl); typedef enum { CHECK_LINK_RESCHEDULE, @@ -3080,23 +3082,17 @@ * */ int -nxge_hio_hostinfo_init( - nxge_t *nxge, - nxge_hio_vr_t *vr, /* Virtualization Region */ - ether_addr_t *macaddr) /* The alternate MAC address */ +nxge_hio_hostinfo_init(nxge_t *nxge, nxge_hio_vr_t *vr, ether_addr_t *macaddr) { - int rdc_tbl, slot; - - nxge_class_pt_cfg_t *class; - hostinfo_t mac_rdc; - npi_mac_addr_t altmac; + int slot, error; + uint8_t rdc_tbl; nxge_mmac_t *mmac_info; nxge_rdc_grp_t *group; uint8_t *addr = (uint8_t *)macaddr; mutex_enter(nxge->genlock); - rdc_tbl = vr->rdc_tbl; + rdc_tbl = (uint8_t)vr->rdc_tbl; /* Initialize the NXGE RDC table data structure. */ group = &nxge->pt_config.rdc_grps[rdc_tbl]; @@ -3115,8 +3111,7 @@ } /* - * The vswitch has already added this MAC address. - * Find its assigned slot. + * Find a slot for the VR to use for Hybrid I/O. */ if (mmac_info->num_factory_mmac < mmac_info->num_mmac) { for (slot = mmac_info->num_factory_mmac + 1; @@ -3138,57 +3133,15 @@ break; } } - ASSERT(slot <= mmac_info->num_mmac); vr->slot = slot; - slot = vr->slot - 1; - - /* - * Program the mac address. - */ - altmac.w2 = (((uint16_t)addr[0]) << 8) | - (((uint16_t)addr[1]) & 0x0ff); - altmac.w1 = (((uint16_t)addr[2]) << 8) | - (((uint16_t)addr[3]) & 0x0ff); - altmac.w0 = (((uint16_t)addr[4]) << 8) | - (((uint16_t)addr[5]) & 0x0ff); - - if (npi_mac_altaddr_entry(nxge->npi_handle, OP_SET, - nxge->function_num, slot, &altmac) != NPI_SUCCESS) { + + error = nxge_altmac_set(nxge, addr, slot, rdc_tbl); + if (error != 0) { mutex_exit(nxge->genlock); return (EIO); } - /* - * Associate <rdc_tbl> with this MAC address slot. - */ - class = (p_nxge_class_pt_cfg_t)&nxge->class_config; - - /* Update this variable. */ - class = (p_nxge_class_pt_cfg_t)&nxge->class_config; - class->mac_host_info[slot].rdctbl = (uint8_t)rdc_tbl; - - mac_rdc.value = 0; - mac_rdc.bits.w0.rdc_tbl_num = rdc_tbl; - mac_rdc.bits.w0.mac_pref = class->mac_host_info[slot].mpr_npr; - /* <mpr_npr> had better be 1! */ - - /* Program the RDC table. */ - if ((npi_mac_hostinfo_entry(nxge->npi_handle, OP_SET, - nxge->function_num, slot, &mac_rdc)) != NPI_SUCCESS) { - mutex_exit(nxge->genlock); - (void) nxge_m_mmac_remove(nxge, vr->slot); - return (EIO); - } - - if (nxge->mac.portnum != XMAC_PORT_0 && - nxge->mac.portnum != XMAC_PORT_1) - slot++; - - /* (Re-)enable the MAC address. */ - (void) npi_mac_altaddr_enable( - nxge->npi_handle, nxge->mac.portnum, slot); - bcopy(macaddr, vr->altmac, sizeof (vr->altmac)); /* @@ -3225,25 +3178,25 @@ * */ void -nxge_hio_hostinfo_uninit( - nxge_t *nxge, - nxge_hio_vr_t *vr) +nxge_hio_hostinfo_uninit(nxge_t *nxge, nxge_hio_vr_t *vr) { nxge_class_pt_cfg_t *class; - - (void) npi_mac_altaddr_disable( - nxge->npi_handle, nxge->mac.portnum, vr->slot); + uint8_t addrn; + + addrn = vr->slot - 1; + (void) npi_mac_altaddr_disable(nxge->npi_handle, + nxge->mac.portnum, addrn); /* Set this variable to its default. */ class = (p_nxge_class_pt_cfg_t)&nxge->class_config; - class->mac_host_info[vr->slot].rdctbl = + class->mac_host_info[addrn].rdctbl = nxge->pt_config.hw_config.def_mac_rxdma_grpid; (void) nxge_m_mmac_remove(nxge, vr->slot); vr->slot = -1; (void) nxge_fzc_rdc_tbl_unbind(nxge, vr->rdc_tbl); - vr->rdc_tbl = -1; + vr->rdc_tbl = (uint8_t)-1; } /* Initialize the RxMAC sub-block */
--- a/usr/src/uts/common/io/nxge/nxge_main.c Sat Nov 08 16:03:01 2008 -0800 +++ b/usr/src/uts/common/io/nxge/nxge_main.c Sat Nov 08 21:40:49 2008 -0800 @@ -291,8 +291,8 @@ static void nxge_m_resources(void *); mblk_t *nxge_m_tx(void *arg, mblk_t *); static nxge_status_t nxge_mac_register(p_nxge_t); -static int nxge_altmac_set(p_nxge_t nxgep, uint8_t *mac_addr, - mac_addr_slot_t slot); +int nxge_altmac_set(p_nxge_t nxgep, uint8_t *mac_addr, + mac_addr_slot_t slot, uint8_t rdctbl); void nxge_mmac_kstat_update(p_nxge_t nxgep, mac_addr_slot_t slot, boolean_t factory); static int nxge_m_mmac_reserve(void *arg, mac_multi_addr_t *maddr); @@ -4040,8 +4040,9 @@ /* * nxge_altmac_set() -- Set an alternate MAC address */ -static int -nxge_altmac_set(p_nxge_t nxgep, uint8_t *maddr, mac_addr_slot_t slot) +int +nxge_altmac_set(p_nxge_t nxgep, uint8_t *maddr, mac_addr_slot_t slot, + uint8_t rdctbl) { uint8_t addrn; uint8_t portn; @@ -4066,7 +4067,8 @@ */ clscfgp = (p_nxge_class_pt_cfg_t)&nxgep->class_config; mac_rdc.value = 0; - mac_rdc.bits.w0.rdc_tbl_num = clscfgp->mac_host_info[addrn].rdctbl; + clscfgp->mac_host_info[addrn].rdctbl = rdctbl; + mac_rdc.bits.w0.rdc_tbl_num = rdctbl; mac_rdc.bits.w0.mac_pref = clscfgp->mac_host_info[addrn].mpr_npr; if (npi_mac_hostinfo_entry(nxgep->npi_handle, OP_SET, @@ -4089,7 +4091,6 @@ if (npi_mac_altaddr_enable(nxgep->npi_handle, portn, addrn) != NPI_SUCCESS) return (EIO); - return (0); } @@ -4166,10 +4167,16 @@ } } ASSERT(slot <= mmac_info->num_mmac); - if ((err = nxge_altmac_set(nxgep, maddr->mma_addr, slot)) != 0) { + + /* + * def_mac_rxdma_grpid is the default rdc table for the port. + */ + if ((err = nxge_altmac_set(nxgep, maddr->mma_addr, slot, + nxgep->pt_config.hw_config.def_mac_rxdma_grpid)) != 0) { mutex_exit(nxgep->genlock); return (err); } + bcopy(maddr->mma_addr, mmac_info->mac_pool[slot].addr, ETHERADDRL); mmac_info->mac_pool[slot].flags |= MMAC_SLOT_USED; mmac_info->mac_pool[slot].flags &= ~MMAC_VENDOR_ADDR; @@ -4247,7 +4254,8 @@ return (EINVAL); } if (err = nxge_altmac_set(nxgep, - mmac_info->factory_mac_pool[slot], slot)) { + mmac_info->factory_mac_pool[slot], slot, + nxgep->pt_config.hw_config.def_mac_rxdma_grpid)) { mutex_exit(nxgep->genlock); return (err); } @@ -4379,8 +4387,9 @@ return (EINVAL); } if (mmac_info->mac_pool[slot].flags & MMAC_SLOT_USED) { - if ((err = nxge_altmac_set(nxgep, maddr->mma_addr, slot)) - != 0) { + if ((err = nxge_altmac_set(nxgep, + maddr->mma_addr, slot, + nxgep->pt_config.hw_config.def_mac_rxdma_grpid)) != 0) { bcopy(maddr->mma_addr, mmac_info->mac_pool[slot].addr, ETHERADDRL); /*
--- a/usr/src/uts/common/sys/nxge/nxge_hio.h Sat Nov 08 16:03:01 2008 -0800 +++ b/usr/src/uts/common/sys/nxge/nxge_hio.h Sat Nov 08 21:40:49 2008 -0800 @@ -249,7 +249,7 @@ size_t size; vr_region_t region; /* 1 of 8 regions. */ - int rdc_tbl; /* 1 of 8 RDC tables. */ + uint8_t rdc_tbl; /* 1 of 8 RDC tables. */ ether_addr_t altmac; /* The alternate MAC address. */ mac_addr_slot_t slot; /* According to nxge_m_mmac_add(). */