vsw_phys.c revision 06db247c678f0e3956535e8a6dec31d6c2108827
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * CDDL HEADER START
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * The contents of this file are subject to the terms of the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Common Development and Distribution License (the "License").
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * You may not use this file except in compliance with the License.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * See the License for the specific language governing permissions
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * and limitations under the License.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * When distributing Covered Code, include this CDDL HEADER in each
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If applicable, add the following below this CDDL HEADER, with the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * fields enclosed by brackets "[]" replaced with your own identifying
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * information: Portions Copyright [yyyy] [name of copyright owner]
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * CDDL HEADER END
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Use is subject to license terms.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram#pragma ident "%Z%%M% %I% %E% SMI"
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* MAC Ring table functions. */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramstatic void vsw_rx_queue_cb(void *, mac_resource_handle_t, mblk_t *);
06db247c678f0e3956535e8a6dec31d6c2108827raghuramstatic void vsw_rx_cb(void *, mac_resource_handle_t, mblk_t *);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* MAC layer routines */
06db247c678f0e3956535e8a6dec31d6c2108827raghuramstatic mac_resource_handle_t vsw_mac_ring_add_cb(void *arg,
06db247c678f0e3956535e8a6dec31d6c2108827raghuramstatic int vsw_set_hw_addr(vsw_t *, mac_multi_addr_t *);
06db247c678f0e3956535e8a6dec31d6c2108827raghuramstatic int vsw_set_hw_promisc(vsw_t *, vsw_port_t *, int);
06db247c678f0e3956535e8a6dec31d6c2108827raghuramstatic int vsw_unset_hw_promisc(vsw_t *, vsw_port_t *, int);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram/* Support functions */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Tunables used in this file.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Check to see if the card supports the setting of multiple unicst
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * addresses.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 0 if card supports the programming of multiple unicast addresses,
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * otherwise returns 1.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (!mac_capab_get(vswp->mh, MAC_CAPAB_MULTIADDRESS, &vswp->maddr)) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram cmn_err(CE_WARN, "!vsw%d: device (%s) does not support "
06db247c678f0e3956535e8a6dec31d6c2108827raghuram "setting multiple unicast addresses", vswp->instance,
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vswp->maddr.maddr_naddr, vswp->maddr.maddr_naddrfree);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Program unicast and multicast addresses of vsw interface and the ports
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * into the physical device.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* program unicst addr of vsw interface in the physdev */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (rv != 0) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram "!vsw%d: failed to program interface "
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Notify the MAC layer of the changed address.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* program mcast addrs of vsw interface in the physdev */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram for (mcap = vswp->mcap; mcap != NULL; mcap = mcap->nextp) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram rv = mac_multicst_add(vswp->mh, (uchar_t *)&mcap->mca);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (rv == 0) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* program unicast address of ports in the physical device */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram for (port = plist->head; port != NULL; port = port->p_next) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (port->addr_set != VSW_ADDR_UNSET) /* addr already set */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram "!vsw%d: port:%d failed to set unicast address\n",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* program multicast addresses of ports in the physdev */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram for (port = plist->head; port != NULL; port = port->p_next) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram for (mcap = port->mcap; mcap != NULL; mcap = mcap->nextp) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram rv = mac_multicst_add(vswp->mh, (uchar_t *)&mcap->mca);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (rv == 0) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Remove unicast and multicast addresses of vsw interface and the ports
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * from the physical device.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Remove unicast addr of vsw interfce
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * from current physdev
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Remove mcast addrs of vsw interface
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * from current physdev
06db247c678f0e3956535e8a6dec31d6c2108827raghuram for (mcap = vswp->mcap; mcap != NULL; mcap = mcap->nextp) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Remove unicast address of ports from the current physical device
06db247c678f0e3956535e8a6dec31d6c2108827raghuram for (port = plist->head; port != NULL; port = port->p_next) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* Remove address if was programmed into HW. */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* Remove multicast addresses of ports from the current physdev */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram for (port = plist->head; port != NULL; port = port->p_next) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram for (mcap = port->mcap; mcap != NULL; mcap = mcap->nextp) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Open the underlying physical device for access in layer2 mode.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * 0 on success
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * EAGAIN if mac_open() fails due to the device being not available yet.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * EIO on any other failures.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* already open */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (vswp->mac_open_retries++ >= vsw_mac_open_retries) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* exceeded max retries */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (ddi_parse(vswp->physname, drv, &ddi_instance) != DDI_SUCCESS) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram cmn_err(CE_WARN, "!vsw%d: invalid device name: %s",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Aggregation devices are special in that the device instance
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * must be set to zero when they are being mac_open()'ed.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * The only way to determine if we are being passed an aggregated
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * device is to check the device name.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram rv = mac_open(vswp->physname, ddi_instance, &vswp->mh);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (rv != 0) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If mac_open() failed and the error indicates that the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * device is not available yet, then, we return EAGAIN to
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * indicate that it needs to be retried.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * For example, this may happen during boot up, as the
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * required link aggregation groups(devices) have not been
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * created yet.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram cmn_err(CE_WARN, "vsw%d: mac_open %s failed rv:%x",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Close the underlying physical device.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Link into the MAC layer to gain access to the services provided by
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * the underlying physical device driver (which should also have
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * registered with the MAC layer).
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Only when in layer 2 mode.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram D2(vswp, "vsw_mac_attach: using device %s", vswp->physname);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Initialize the ring table.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Register our rx callback function.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Register our mac resource callback.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram mac_resource_set(vswp->mh, vsw_mac_ring_add_cb, (void *)vswp);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Get the ring resources available to us from
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * the mac below us.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Just register our rx callback function
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vswp->mrh = mac_rx_add(vswp->mh, vsw_rx_cb, (void *)vswp);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* Get the MAC tx fn */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* start the interface */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram cmn_err(CE_WARN, "!vsw%d: Could not start mac interface",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Depending on the mode specified, the capabilites and capacity
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * of the underlying device setup the physical device.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If in layer 3 mode, then do nothing.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If in layer 2 programmed mode attempt to program the unicast address
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * associated with the port into the physical device. If this is not
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * possible due to resource exhaustion or simply because the device does
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * not support multiple unicast addresses then if required fallback onto
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * putting the card into promisc mode.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If in promisc mode then simply set the card into promisc mode.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 0 success, 1 on failure.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ASSERT((type == VSW_LOCALDEV) || (type == VSW_VNETPORT));
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (vswp->smode[vswp->smode_idx] == VSW_LAYER2_PROMISC) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Attempt to program the unicast address into the HW.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Mark that attempt should be made to re-config sometime
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * in future if a port is deleted.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Only 1 mode specified, nothing more to do.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If promiscuous was next mode specified try to
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * set the card into that mode.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram "of device %s", ether_sprintf((void *)mac_addr.mma_addr),
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If in layer 3 mode do nothing.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If in layer 2 switched mode remove the address from the physical
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If in layer 2 promiscuous mode disable promisc mode.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 0 on success.
06db247c678f0e3956535e8a6dec31d6c2108827raghuramvsw_unset_hw(vsw_t *vswp, vsw_port_t *port, int type)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* should never happen */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Attempt to program a unicast address into HW.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 0 on sucess, 1 on failure.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Its okay for the add to fail because we have exhausted
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * all the resouces in the hardware device. Any other error
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * we want to flag.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram "address %s into HW err (%d)",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vswp->instance, ether_sprintf((void *)mac->mma_addr), rv);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Remove a unicast mac address which has previously been programmed
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 0 on sucess, 1 on failure.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (rv != 0) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram cmn_err(CE_WARN, "!vsw%d: unable to remove address "
06db247c678f0e3956535e8a6dec31d6c2108827raghuram "from slot %d in device %s (err %d)",
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Set network card into promisc mode.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 0 on success, 1 on failure.
06db247c678f0e3956535e8a6dec31d6c2108827raghuramvsw_set_hw_promisc(vsw_t *vswp, vsw_port_t *port, int type)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ASSERT((type == VSW_LOCALDEV) || (type == VSW_VNETPORT));
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (mac_promisc_set(vswp->mh, B_TRUE, MAC_DEVPROMISC) != 0) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram cmn_err(CE_NOTE, "!vsw%d: switching device %s into "
06db247c678f0e3956535e8a6dec31d6c2108827raghuram "promiscuous mode", vswp->instance, vswp->physname);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Turn off promiscuous mode on network card.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 0 on success, 1 on failure.
06db247c678f0e3956535e8a6dec31d6c2108827raghuramvsw_unset_hw_promisc(vsw_t *vswp, vsw_port_t *port, int type)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram ASSERT((type == VSW_LOCALDEV) || (type == VSW_VNETPORT));
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if (mac_promisc_set(vswp->mh, B_FALSE, MAC_DEVPROMISC) != 0) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * We are exiting promisc mode either because we were
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * only in promisc mode because we had failed over from
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * switched mode due to HW resource issues, or the user
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * wanted the card in promisc mode for all the ports and
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * the last port is now being deleted. Tweak the message
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * accordingly.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram cmn_err(CE_NOTE, "!vsw%d: switching device %s back to "
06db247c678f0e3956535e8a6dec31d6c2108827raghuram "programmed mode", vswp->instance, vswp->physname);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram cmn_err(CE_NOTE, "!vsw%d: switching device %s out of "
06db247c678f0e3956535e8a6dec31d6c2108827raghuram "promiscuous mode", vswp->instance, vswp->physname);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Determine whether or not we are operating in our prefered
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * mode and if not whether the physical resources now allow us
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * to operate in it.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If a port is being removed should only be invoked after port has been
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * removed from the port list.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If we are in layer 2 (i.e. switched) or would like to be
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * in layer 2 then check if any ports or the vswitch itself
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * need to be programmed into the HW.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * This can happen in two cases - switched was specified as
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * the prefered mode of operation but we exhausted the HW
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * resources and so failed over to the next specifed mode,
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * or switched was the only mode specified so after HW
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * resources were exhausted there was nothing more we
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * could do.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * First, attempt to set the vswitch mac address into HW,
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * if required.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Next, attempt to set any ports which have not yet been
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * programmed into HW.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * By now we know that have programmed all desired ports etc
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * into HW, so safe to mark reconfiguration as complete.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Check to see if vsw itself is plumbed, and if so whether or not
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * its mac address should be written into HW.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 0 if could set address, or didn't have to set it.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 1 if failed to set address.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (1);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If previously when plumbed had had to place
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * interface into promisc mode, now reverse that.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Note that interface will only actually be set into
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * non-promisc mode when last port/interface has been
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * programmed into HW.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram (void) vsw_unset_hw_promisc(vswp, NULL, VSW_LOCALDEV);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram return (0);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Scan the port list for any ports which have not yet been set
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * into HW. For those found attempt to program their mac addresses
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * into the physical device.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 0 if able to program all required ports (can be 0) into HW.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns 1 if failed to set at least one mac address.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram for (tp = plist->head; tp != NULL; tp = tp->p_next) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If when this port had first attached we had
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * had to place the interface into promisc mode,
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * then now reverse that.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Note that the interface will not actually
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * change to non-promisc mode until all ports
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * have been programmed.
06db247c678f0e3956535e8a6dec31d6c2108827raghuramvsw_mac_ring_tbl_entry_init(vsw_t *vswp, vsw_mac_ring_t *ringp)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram mutex_init(&vswp->mac_ring_lock, NULL, MUTEX_DRIVER, NULL);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram kmem_alloc(vsw_mac_rx_rings * sizeof (vsw_mac_ring_t), KM_SLEEP);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vsw_mac_ring_tbl_entry_init(vswp, &vswp->mac_ring_tbl[i]);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Destroy the queue.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Re-initialize the structure.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Handle resource add callbacks from the driver below.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Check to make sure we have the correct resource type.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Find a open entry in the ring table.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Check for an empty slot, if found, then setup queue
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * and thread.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Create the queue for this ring.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Initialize the ring data structure.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Create the worker thread.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Make sure thread get's running state for
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * this ring.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * If the thread is not running, cleanup.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * No slots in the ring table available.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram mutex_init(&vqp->vq_lock, NULL, MUTEX_DRIVER, NULL);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Set the state to running, since the thread is now active.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Wait for work to do or the state has changed
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * to not running.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Process packets that we received from the interface.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* switch the chain of packets received */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * We are drained and signal we are done.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Exit lock and drain the remaining packets.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Exit the thread
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * static void
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * vsw_rx_queue_cb() - Receive callback routine when
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * vsw_multi_ring_enable is non-zero. Queue the packets
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * to a packet queue for a worker thread to process.
06db247c678f0e3956535e8a6dec31d6c2108827raghuramvsw_rx_queue_cb(void *arg, mac_resource_handle_t mrh, mblk_t *mp)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Find the last element in the mblk chain.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* Get the queue for the packets */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Grab the lock such we can queue the packets.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Add the mblk chain to the queue. If there
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * is some mblks in the queue, then add the new
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * chain to the end.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Signal the worker thread that there is work to
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Let go of the lock and exit.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * receive callback routine. Invoked by MAC layer when there
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * are pkts being passed up from physical device.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * PERF: It may be more efficient when the card is in promisc
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * mode to check the dest address of the pkts here (against
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * the FDB) rather than checking later. Needs to be investigated.
06db247c678f0e3956535e8a6dec31d6c2108827raghuramvsw_rx_cb(void *arg, mac_resource_handle_t mrh, mblk_t *mp)
06db247c678f0e3956535e8a6dec31d6c2108827raghuram /* switch the chain of packets received */
06db247c678f0e3956535e8a6dec31d6c2108827raghuram vswp->vsw_switch_frame(vswp, mp, VSW_PHYSDEV, NULL, NULL);
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Send a message out over the physical device via the MAC layer.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram * Returns any mblks that it was unable to transmit.
06db247c678f0e3956535e8a6dec31d6c2108827raghuram if ((vswp->mh == NULL) || (vswp->mstarted == B_FALSE)) {
06db247c678f0e3956535e8a6dec31d6c2108827raghuram DERR(vswp, "vsw_tx_msg: dropping pkts: no tx routine avail");