/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <sys/sysmacros.h>
#include <sys/ethernet.h>
#include <sys/machsystm.h>
#include <sys/mac_provider.h>
#include <sys/mac_ether.h>
#include <sys/mach_descrip.h>
#include <sys/mac_provider.h>
#include <sys/vio_mailbox.h>
#include <sys/vnet_mailbox.h>
#include <sys/vnet_common.h>
#include <sys/vio_util.h>
/*
* Function prototypes.
*/
void vsw_destroy_rxpools(void *);
/* MDEG routines */
/* Mac driver related routines */
static int vsw_mac_register(vsw_t *);
static int vsw_mac_unregister(vsw_t *);
static void vsw_m_stop(void *arg);
static int vsw_m_start(void *arg);
/*
* Functions imported from other files.
*/
extern void vsw_setup_switching_thread(void *arg);
extern int vsw_setup_switching(vsw_t *);
extern void vsw_del_mcst_vsw(vsw_t *);
/*
* Internal tunables.
*/
/* 300*3 = 900sec(15min) of max tmout */
/* delay in usec to wait for all references on a fdb entry to be dropped */
/*
* Default vlan id. This is only used internally when the "default-vlan-id"
* property is not present in the MD device node. Therefore, this should not be
* used as a tunable; if this value is changed, the corresponding variable
* should be updated to the same value in all vnets connected to this vsw.
*/
/*
* Workaround for a version handshake bug in obp's vnet.
* If vsw initiates version negotiation starting from the highest version,
* obp sends a nack and terminates version handshake. To workaround
* this, we do not initiate version handshake when the channel comes up.
* Instead, we wait for the peer to send its version info msg and go through
* the version protocol exchange. If we successfully negotiate a version,
* before sending the ack, we send our version info msg to the peer
* using the <major,minor> version that we are about to ack.
*/
/*
* In the absence of "priority-ether-types" property in MD, the following
* internal tunable can be set to specify a single priority ethertype.
*/
/*
* Number of transmit priority buffers that are preallocated per device.
* This number is chosen to be a small value to throttle transmission
* of priority packets. Note: Must be a power of 2 for vio_create_mblks().
*/
/*
* Number of RARP packets sent to announce macaddr to the physical switch,
* after vsw's physical device is changed dynamically or after a guest (client
* vnet) is live migrated in.
*/
/*
*/
/*
* Max retries for HybridIO cleanup
*/
/*
* 10ms delay for HybridIO cleanup
*/
/*
* Descriptor ring modes of LDC data transfer:
*
* 1) TxDring mode:
* In versions < v1.6 of VIO Protocol, we support only TxDring mode. In this
* mode, we create a transmit descriptor ring and export it to the peer through
* dring registration process of handshake. The descriptor ring is exported
* using LDC shared memory. Each descriptor is associated with a data buffer.
* The data buffer is also exported over LDC and the cookies for this data
* buffer are provided in the descriptor. The peer maps this ring as its
* receive ring. Similarly, the peer exports a transmit descriptor ring which
* is mapped by this device as its receive ring. In this mode, in a given data
* transfer direction, the transmitter copies the data to the exported data
* buffer (owned by itself), bound to the descriptor. The receiver uses the LDC
* cookies specified in the descriptor to copy the data into the receiving
* guest through the hypervisor (ldc_mem_copy()).
*
* 2) RxDringData mode:
* In versions >= v1.6 of VIO Protocol, we also support RxDringData mode. In
* this mode, we create a receive descriptor ring and export it to the peer
* through dring registration process of handshake. In addition, we export a
* receive buffer area and provide that information also in the dring
* registration message. The descriptor ring and the data buffer area are
* exported using LDC shared memory. Each descriptor is associated with a data
* buffer in the data buffer area and the offset of the specific data buffer
* within this area is specified in the descriptor. The peer maps this ring
* along with the data buffer area as its transmit ring. Similarly, the peer
* exports a receive ring which is mapped by this device as its transmit ring,
* along with its buffer area. In this mode, in a given data transfer
* direction, the transmitter copies the data to the data buffer offset
* specified in the descriptor. The receiver simply picks up the data buffer
* (owned by itself) without any copy operation into the receiving guest.
*
* We enable RxDringData mode during handshake negotiations if LDC supports
* mapping in large areas of shared memory(see ldc_is_viotsb_configured() API),
* which is required to support RxDringData mode.
*/
/*
* Number of descriptors; must be power of 2.
*/
/*
* In RxDringData mode, # of buffers is determined by multiplying the # of
* descriptors with the factor below. Note that the factor must be > 1; i.e,
* the # of buffers must always be > # of descriptors. This is needed because,
* while the shared memory buffers are sent up the stack on the receiver, the
* sender needs additional buffers that can be used for further transmits.
* See vsw_setup_rx_dring() for details.
*/
/*
* Delay when rx descr not ready; used in both dring modes.
*/
int vsw_recv_delay = 0;
/*
* Retry when rx descr not ready; used in both dring modes.
*/
/*
* Max number of mblks received in one receive operation.
*/
/*
* Internal tunables for receive buffer pools, that is, the size and number of
* mblks for each pool. At least 3 sizes must be specified if these are used.
* The sizes must be specified in increasing order. Non-zero value of the first
* size will be used as a hint to use these values instead of the algorithm
* that determines the sizes based on MTU. Used in TxDring mode only.
*/
/*
* Set this to non-zero to enable additional internal receive buffer pools
* based on the MTU of the device for better performance at the cost of more
* memory consumption. This is turned off by default, to use allocb(9F) for
* receive buffer allocations of sizes > 2K.
*/
/*
* vsw_max_tx_qcount is the maximum # of packets that can be queued
* before the tx worker thread begins processing the queue. Its value
* is chosen to be 4x the default length of tx descriptor ring.
*/
/*
* MAC callbacks
*/
0,
};
nulldev, /* cb_open */
nulldev, /* cb_close */
nodev, /* cb_strategy */
nodev, /* cb_print */
nodev, /* cb_dump */
nodev, /* cb_read */
nodev, /* cb_write */
nodev, /* cb_ioctl */
nodev, /* cb_devmap */
nodev, /* cb_mmap */
nodev, /* cb_segmap */
nochpoll, /* cb_chpoll */
ddi_prop_op, /* cb_prop_op */
NULL, /* cb_stream */
D_MP, /* cb_flag */
CB_REV, /* rev */
nodev, /* int (*cb_aread)() */
nodev /* int (*cb_awrite)() */
};
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
NULL, /* devo_getinfo */
nulldev, /* devo_identify */
nulldev, /* devo_probe */
vsw_attach, /* devo_attach */
vsw_detach, /* devo_detach */
nodev, /* devo_reset */
&vsw_cb_ops, /* devo_cb_ops */
ddi_power /* devo_power */
};
extern struct mod_ops mod_driverops;
"sun4v Virtual Switch",
&vsw_ops,
};
/* Driver soft state ptr */
static void *vsw_state;
/*
* Linked list of "vsw_t" structures - one per instance.
*/
/*
* Property names
*/
/*
* Matching criteria passed to the MDEG to register interest
* in changes to 'virtual-device-port' nodes identified by their
* 'id' property.
*/
{ MDET_PROP_VAL, "id" },
{ MDET_LIST_END, NULL }
};
/*
* Matching criteria passed to the MDEG to register interest
* in changes to 'virtual-device' nodes (i.e. vsw nodes) identified
* by their 'name' and 'cfg-handle' properties.
*/
{ MDET_PROP_STR, "name" },
{ MDET_PROP_VAL, "cfg-handle" },
{ MDET_LIST_END, NULL }
};
/*
* Specification of an MD node passed to the MDEG to filter any
* 'vport' nodes that do not belong to the specified node. This
* template is copied for each vsw instance and filled in with
* the appropriate 'cfg-handle' value before being passed to the MDEG.
*/
};
#ifdef DEBUG
/*
* Print debug messages - set to 0x1f to enable all msgs
* or 0x0 to turn all off.
*/
/*
* debug levels:
* 0x02: Internal function messages
* 0x04: Verbose internal messages
* 0x08: Warning messages
* 0x10: Error messages
*/
void
{
else
}
#endif /* DEBUG */
};
int
_init(void)
{
int status;
if (status != 0) {
return (status);
}
if (status != 0) {
}
return (status);
}
int
_fini(void)
{
int status;
if (status != 0)
return (status);
rw_destroy(&vsw_rw);
return (status);
}
int
{
}
static int
{
int instance;
int rv;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
/* nothing to do for this non-device */
return (DDI_SUCCESS);
case DDI_PM_RESUME:
default:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
goto vsw_attach_fail;
}
progress |= PROG_locks;
if (rv != 0)
goto vsw_attach_fail;
progress |= PROG_readmd;
/* setup the unicast forwarding database */
mod_hash_null_valdtor, sizeof (void *));
/* setup the multicast fowarding database */
mod_hash_null_valdtor, sizeof (void *));
/*
* Create the taskq which will process all the VIO
* control messages.
*/
TASKQ_DEFAULTPRI, 0)) == NULL) {
goto vsw_attach_fail;
}
progress |= PROG_taskq;
TASKQ_DEFAULTPRI, 0)) == NULL) {
goto vsw_attach_fail;
}
/* prevent auto-detaching */
}
/*
* The null switching function is set to avoid panic until
* switch mode is setup.
*/
/*
* Setup the required switching mode, based on the mdprops that we read
* earlier. We start a thread to do this, to avoid calling mac_open()
* directly from attach().
*/
if (rv != 0) {
goto vsw_attach_fail;
}
progress |= PROG_swmode;
/* Register with mac layer as a provider */
if (rv != 0)
goto vsw_attach_fail;
progress |= PROG_macreg;
/*
* Now we have everything setup, register an interest in
* specific MD nodes.
*
* The callback is invoked in 2 cases, firstly if upon mdeg
* registration there are existing nodes which match our specified
* criteria, and secondly if the MD is changed (and again, there
* are nodes which we are interested in present within it. Note
* that our callback will be invoked even if our specified nodes
* have not actually changed).
*
*/
if (rv != 0)
goto vsw_attach_fail;
progress |= PROG_mdreg;
return (DDI_SUCCESS);
(void) vsw_unattach(vswp);
return (DDI_FAILURE);
}
static int
{
int instance;
return (DDI_FAILURE);
}
switch (cmd) {
case DDI_DETACH:
break;
case DDI_SUSPEND:
case DDI_PM_SUSPEND:
default:
return (DDI_FAILURE);
}
if (vsw_unattach(vswp) != 0) {
return (DDI_FAILURE);
}
break;
}
}
return (DDI_SUCCESS);
}
/*
* Common routine to handle vsw_attach() failure and vsw_detach(). Note that
* the only reason this function could fail is if mac_unregister() fails.
* Otherwise, this function must ensure that all resources are freed and return
* success.
*/
static int
{
/*
* Unregister from the gldv3 subsystem. This can fail, in particular
* if there are still any open references to this mac device; in which
* case we just return failure without continuing to detach further.
*/
if (progress & PROG_macreg) {
if (vsw_mac_unregister(vswp) != 0) {
return (1);
}
progress &= ~PROG_macreg;
}
/*
* Now that we have unregistered from gldv3, we must finish all other
* steps and successfully return from this function; otherwise we will
*
* If we have registered with mdeg, unregister now to stop further
* existing ports.
*/
if (progress & PROG_mdreg) {
progress &= ~PROG_mdreg;
}
/*
* If we have started a thread to setup the switching mode, stop it, if
* it is still running. If it has finished setting up the switching
* mode, then we need to clean up some additional things if we are
* running in L2 mode: first free up any hybrid resources; then stop
* and close the underlying physical device. Note that we would have
* already released all per mac_client resources (ucast, mcast addrs,
* hio-shares etc) as all the ports are detached and if the vsw device
* itself was in use as an interface, it has been unplumbed (otherwise
* mac_unregister() above would fail).
*/
if (progress & PROG_swmode) {
}
progress &= ~PROG_swmode;
}
/*
* We now destroy the taskq used to clean up rx mblk pools that
* We implicitly wait for those tasks to complete in
* ddi_taskq_destroy().
*/
if (progress & PROG_rxp_taskq) {
progress &= ~PROG_rxp_taskq;
}
/*
* By now any pending tasks have finished and the underlying
* ldc's have been destroyed, so its safe to delete the control
* message taskq.
*/
if (progress & PROG_taskq) {
progress &= ~PROG_taskq;
}
/* Destroy the multicast hash table */
}
/* Destroy the vlan hash table and fdb */
}
if (progress & PROG_readmd) {
if (VSW_PRI_ETH_DEFINED(vswp)) {
}
progress &= ~PROG_readmd;
}
if (progress & PROG_locks) {
progress &= ~PROG_locks;
}
return (0);
}
void
{
while (vio_destroy_mblks(poolp) != 0) {
}
}
}
/*
* Get the value of the "vsw-phys-dev" property in the specified
* node. This property is the name of the physical device that
* the virtual switch will use to talk to the outside world.
*
* Note it is valid for this property to be NULL (but the property
* itself must exist). Callers of this routine should verify that
* the value returned is what they expected (i.e. either NULL or non NULL).
*
* On success returns value of the property in region pointed to by
* the 'name' argument, and with return value of 0. Otherwise returns 1.
*/
static int
{
int len = 0;
int instance;
char *dev;
const char *dev_name;
return (1);
return (1);
/*
* Prevent the vswitch from opening itself as the
* network device.
*/
return (1);
} else {
}
#ifdef DEBUG
/*
* As a temporary measure to aid testing we check to see if there
* is a vsw.conf file present. If there is we use the value of the
* vsw_physname property in the file as the name of the physical
* device, overriding the value from the MD.
*
* There may be multiple devices listed, but for the moment
* we just use the first one.
*/
return (1);
} else {
}
}
#endif
return (0);
}
/*
* Read the 'vsw-switch-mode' property from the specified MD node.
*
* Returns 0 on success, otherwise returns 1.
*/
static int
{
int len = 0;
/*
* Get the switch-mode property. The modes are listed in
* decreasing order of preference, i.e. prefered mode is
* first item in list.
*/
len = 0;
/*
* Unable to get switch-mode property from MD, nothing
* more we can do.
*/
return (1);
}
/*
* Modes of operation:
* 'switched' - layer 2 switching, underlying HW in
* programmed mode.
* 'promiscuous' - layer 2 switching, underlying HW in
* promiscuous mode.
* 'routed' - layer 3 (i.e. IP) routing, underlying HW
* in non-promiscuous mode.
*/
*mode = VSW_LAYER2;
*mode = VSW_LAYER3;
} else {
"setting to default switched mode",
*mode = VSW_LAYER2;
}
}
return (0);
}
/*
* Register with the MAC layer as a network device, so we
* can be plumbed if necessary.
*/
static int
{
int rv;
return (EINVAL);
if (rv != 0) {
/*
* Treat this as a non-fatal error as we may be
* able to operate in some other mode.
*/
return (rv);
}
return (rv);
}
static int
{
int rv = 0;
if (rv != 0) {
"framework", __func__);
return (rv);
}
/* mark i/f as down and unregistered */
}
return (rv);
}
static int
{
return (EINVAL);
}
/* return stats from underlying device */
return (0);
}
static void
{
/* Cleanup and close the mac client */
}
static int
{
int rv;
/*
* If the switching mode has not been setup yet, just
* return. The unicast address will be programmed
* after the physical device is successfully setup by the
* timeout handler.
*/
return (0);
}
/* if in layer2 mode, program unicast address. */
/* Init a mac client and program addresses */
if (rv != 0) {
"!vsw%d: failed to program interface "
}
}
return (0);
}
/*
* Change the local interface address.
*
* Note: we don't support this entry point. The local
* mac address of the switch can only be changed via its
* MD node properties.
*/
static int
{
return (DDI_FAILURE);
}
static int
{
int i, ret = 0;
/*
* Convert address into form that can be used
* as hash table key.
*/
for (i = 0; i < ETHERADDRL; i++) {
}
if (add) {
/*
* Update the list of multicast addresses
* contained within the vsw_t structure to
* include this new one.
*/
(void) vsw_del_mcst(vswp,
return (1);
}
/*
* Call into the underlying driver to program the
* address into HW.
*/
if (ret != 0) {
(void) vsw_del_mcst(vswp,
return (ret);
}
} else {
}
return (ret);
}
/*
* Remove the address from the hash table..
*/
/*
* ..and then from the list maintained in the
* vsw_t structure.
*/
}
return (0);
}
static int
{
if (on)
else
return (0);
}
static mblk_t *
{
return (NULL);
}
return (NULL);
}
/*
* Register for machine description (MD) updates.
*
* Returns 0 on success, 1 on failure.
*/
static int
{
int rv;
/*
* Allocate and initialize a per-instance copy
* of the global property spec array that will
* uniquely identify this vsw instance.
*/
templatesz = sizeof (vsw_prop_template);
/* initialize the complete prop spec structure */
/*
* Register an interest in 'virtual-device' nodes with a
* 'name' property of 'virtual-network-switch'
*/
if (rv != MDEG_SUCCESS) {
goto mdeg_reg_fail;
}
/*
* Register an interest in 'vsw-port' nodes.
*/
(void *)vswp, &mdeg_port_hdl);
if (rv != MDEG_SUCCESS) {
(void) mdeg_unregister(mdeg_hdl);
goto mdeg_reg_fail;
}
/* save off data that will be needed later */
return (0);
return (1);
}
static void
{
sizeof (vsw_prop_template));
}
}
}
/*
* Mdeg callback invoked for the vsw node itself.
*/
static int
{
return (MDEG_FAILURE);
/*
* We get an initial callback for this node as 'added'
* after registering with mdeg. Note that we would have
* already gathered information about this vsw node by
* walking MD earlier during attach (in vsw_read_mdprops()).
* So, there is a window where the properties of this
* node might have changed when we get this initial 'added'
* callback. We handle this as if an update occured
* and invoke the same function which handles updates to
* the properties of this vsw-node if any.
*
* A non-zero 'match' value indicates that the MD has been
* updated and that a virtual-network-switch node is
* present which may or may not have been updated. It is
* up to the clients to examine their own nodes and
* determine if they have changed.
*/
return (MDEG_FAILURE);
}
return (MDEG_FAILURE);
}
} else {
return (MDEG_FAILURE);
}
/* Validate name and instance */
return (MDEG_FAILURE);
}
/* is this a virtual-network-switch? */
return (MDEG_FAILURE);
}
__func__);
return (MDEG_FAILURE);
}
/* is this the right instance of vsw? */
return (MDEG_FAILURE);
}
return (MDEG_SUCCESS);
}
/*
* Mdeg callback invoked for changes to the vsw-port nodes
* under the vsw node.
*/
static int
{
int idx;
int rv;
return (MDEG_FAILURE);
/* process added ports */
}
}
/* process removed ports */
continue;
}
}
}
}
return (MDEG_SUCCESS);
}
/*
* Scan the machine description for this instance of vsw
* and read its properties. Called only from vsw_attach().
* Returns: 0 on success, 1 on failure.
*/
static int
{
char *name;
int num_nodes = 0;
int num_devs = 0;
int listsz = 0;
int i;
/*
* In each 'virtual-device' node in the MD there is a
* 'cfg-handle' property which is the MD's concept of
* an instance number (this may be completely different from
* the device drivers instance #). OBP reads that value and
* stores it in the 'reg' property of the appropriate node in
* the device tree. We first read this reg property and use this
* to compare against the 'cfg-handle' property of vsw nodes
* in MD to get to this specific vsw instance and then read
* other properties that we are interested in.
* We also cache the value of 'reg' property and use it later
* to register callbacks with mdeg (see vsw_mdeg_register())
*/
if (inst == -1) {
return (rv);
}
return (rv);
}
/* search for all "virtual_device" nodes */
if (num_devs <= 0) {
goto vsw_readmd_exit;
}
/*
* Now loop through the list of virtual-devices looking for
* devices with name "virtual-network-switch" and for each
* such device compare its instance with what we have from
* the 'reg' property to find the right node in MD and then
* read all its properties.
*/
for (i = 0; i < num_devs; i++) {
__func__);
goto vsw_readmd_exit;
}
/* is this a virtual-network-switch? */
continue;
__func__);
goto vsw_readmd_exit;
}
/* is this the required instance of vsw? */
continue;
/* now read all properties of this vsw instance */
break;
}
(void) md_fini_handle(mdp);
return (rv);
}
/*
* Read the initial start-of-day values from the specified MD node.
*/
static int
{
return (1);
}
/* mac address for vswitch device itself */
return (1);
}
"defaulting to 'switched' mode",
}
/*
* Read the 'linkprop' property to know if this
* vsw device wants to get physical link updates.
*/
/* read mtu */
}
/* read vlan id properties of this vsw instance */
/* read priority-ether-types */
/* read bandwidth property of this vsw instance */
return (0);
}
/*
* Read vlan id properties of the given MD node.
* Arguments:
* arg: device argument(vsw device or a port)
* type: type of arg; VSW_LOCALDEV(vsw device) or VSW_VNETPORT(port)
* mdp: machine description
* node: md node cookie
*
* Returns:
* pvidp: port-vlan-id of the node
* vidspp: list of vlan-ids of the node
* nvidsp: # of vlan-ids in the list
* default_idp: default-vlan-id of the node(if node is vsw device)
*/
static void
{
char *pvid_propname;
char *vid_propname;
int rv;
int i;
int size;
int inst;
if (type == VSW_LOCALDEV) {
} else if (type == VSW_VNETPORT) {
} else {
return;
}
if (rv != 0) {
} else {
}
}
if (rv != 0) {
} else {
}
&size);
if (rv != 0) {
size = 0;
} else {
}
if (nvids != 0) {
for (i = 0; i < nvids; i++) {
}
}
}
static void
{
int rv;
if (rv != 0) {
*bw = 0;
} else {
}
}
/*
* This function reads "priority-ether-types" property from md. This property
* is used to enable support for priority frames. Applications which need
* a vnet or vsw within ldoms, should configure this property by providing
* the ether type(s) for which the priority facility is needed.
* Normal data frames are delivered over a ldc channel using the descriptor
* ring mechanism which is constrained by factors such as descriptor ring size,
* the rate at which the ring is processed at the peer ldc end point, etc.
* as raw pkt data (VIO_PKT_DATA) messages over the channel, avoiding the
* descriptor ring path and enables a more reliable and timely delivery of
* frames to the peer.
*/
static void
{
int rv;
int size;
int i;
if (rv != 0) {
/*
* Property may not exist if we are running pre-ldoms1.1 f/w.
* Check if 'vsw_pri_eth_type' has been set in that case.
*/
if (vsw_pri_eth_type != 0) {
size = sizeof (vsw_pri_eth_type);
data = &vsw_pri_eth_type;
} else {
size = 0;
}
}
if (size == 0) {
vswp->pri_num_types = 0;
return;
}
/*
* we have some priority-ether-types defined;
* allocate a table of these types and also
* allocate a pool of mblks to transmit these
* priority packets.
*/
}
&vswp->pri_tx_vmp);
}
static void
{
int rv;
int inst;
char *mtu_propname;
if (rv != 0) {
*mtu = vsw_ethermtu;
} else {
}
}
/*
* Update the mtu of the vsw device. We first check if the device has been
* plumbed and if so fail the mtu update. Otherwise, we continue to update the
* new mtu and reset all ports to initiate handshake re-negotiation with peers
* using the new mtu.
*/
static int
{
int rv;
return (EBUSY);
} else {
sizeof (struct ether_header) + VLAN_TAGSZ;
if (rv != 0) {
"!vsw%d: Unable to update mtu with mac"
}
/* Reset ports to renegotiate with the new mtu */
}
return (0);
}
static void
{
int rv;
char *linkpropname;
if (rv != 0) {
} else {
}
}
void
{
}
}
void
{
}
}
static void
{
/* read the vsw bandwidth from md */
int rv;
if (rv != 0) {
*bw = 0;
} else {
}
}
/*
* Check to see if the relevant properties in the specified node have
* changed, and if so take the appropriate action.
*
* If any of the properties are missing or invalid we don't take
* any action, as this function should only be invoked when modifications
* have been made to what we assume is a working configuration, which
* we leave active.
*
* Note it is legal for this routine to be invoked even if none of the
* properties in the port node within the MD have actually changed.
*/
static void
{
int i;
int rv;
/*
* Check if name of physical device in MD has changed.
*/
/*
* if its non NULL. It is valid for the device name to
* have changed from a non NULL to a NULL value, i.e.
* the vsw is being changed to 'routed' mode.
*/
&ddi_instance) != DDI_SUCCESS)) {
goto fail_reconf;
}
updated |= MD_physname;
} else {
}
} else {
goto fail_reconf;
}
/*
* Check if MAC address has changed.
*/
goto fail_reconf;
} else {
for (i = ETHERADDRL - 1; i >= 0; i--) {
!= (macaddr & 0xFF)) {
__func__, i,
(macaddr & 0xFF));
updated |= MD_macaddr;
break;
}
macaddr >>= 8;
}
if (updated & MD_macaddr) {
}
}
/*
* Check if switching modes have changed.
*/
goto fail_reconf;
} else {
}
}
/* Read the vlan ids */
/* Determine if there are any vlan id updates */
}
/* Read mtu */
} else {
" as the specified value:%d is invalid\n",
}
}
/*
* Read the 'linkprop' property.
*/
}
/* Read bandwidth */
} else {
" update as the specified value:%ld is invalid\n",
}
}
/*
* Now make any changes which are needed...
*/
/* save the updated property. */
if (pls_update == B_FALSE) {
/*
* Phys link state update is now disabled for this vsw
* interface. If we had previously reported a link-down
* to the stack, undo that by sending a link-up.
*/
}
} else {
/*
* Phys link state update is now enabled. Send up an
* update based on the current phys link state.
*/
}
}
}
/*
* Stop any pending thread to setup switching mode.
*/
/* Cleanup HybridIO */
/*
* Remove unicst, mcst addrs of vsw interface
* and ports from the physdev. This also closes
* the corresponding mac clients.
*/
/*
* Stop, detach and close the old device..
*/
/*
* Update phys name.
*/
if (updated & MD_physname) {
}
/*
* Update array with the new switch mode values.
*/
}
/* Update mtu */
if (rv != 0) {
goto fail_update;
}
}
/*
* ..and attach, start the new device.
*/
/*
* Unable to setup switching mode.
* As the error is EAGAIN, schedule a thread to retry
* and return. Programming addresses of ports and
* vsw interface will be done by the thread when the
* switching setup completes successfully.
*/
if (vsw_setup_switching_start(vswp) != 0) {
goto fail_update;
}
return;
} else if (rv) {
goto fail_update;
}
} else if (updated & MD_macaddr) {
/*
* We enter here if only MD_macaddr is exclusively updated.
* as part of that, we would have implicitly processed
* MD_macaddr update (above).
*/
/* reconfigure with new address */
/*
* Notify the MAC layer of the changed address.
*/
}
}
/* Remove existing vlan ids from the hash table. */
} else {
}
}
/* add these new vlan ids into hash table */
} else {
if (nvids != 0) {
}
}
}
return;
return;
}
/*
* Read the port's md properties.
*/
static int
{
int i, addrsz;
int listsz = 0;
return (1);
}
/*
* Find the channel endpoint node(s) (which should be under this
* port node) which contain the channel id(s).
*/
return (1);
}
/* allocate enough space for node list */
if (nchan <= 0) {
return (1);
}
/* use property from first node found */
return (1);
}
/* don't need list any more */
/* read mac-address property */
return (1);
}
if (addrsz < ETHERADDRL) {
return (1);
}
for (i = ETHERADDRL - 1; i >= 0; i--) {
macaddr >>= 8;
}
/* now update all properties into the port */
if (nchan > VSW_PORT_MAX_LDCS) {
}
/* read vlan id properties of this port node */
/* Check if hybrid property is present */
} else {
}
/*
* Port hio capability determined after version
* negotiation, i.e., when we know the peer is HybridIO capable.
*/
/* Read bandwidth of this port */
return (0);
}
/*
* Add a new port to the system.
*
* Returns 0 on success, 1 on failure.
*/
int
{
int rv;
if (rv != 0) {
return (1);
}
if (rv != 0) {
return (1);
}
return (0);
}
static int
{
/*
* For now, we get port updates only if vlan ids changed.
* We read the port num and do some sanity check.
*/
return (1);
}
return (1);
}
return (1);
return (1);
}
/* Read the vlan ids */
/* Determine if there are any vlan id updates */
updated |= P_MD_vlans;
}
/* Check if hybrid property is present */
}
}
/* Check if maxbw property is present */
updated |= P_MD_maxbw;
} else {
" update for port %d as the specified value:%ld"
" is invalid\n",
}
}
if (updated & P_MD_vlans) {
/* Remove existing vlan ids from the hash table. */
/* Reconfigure vlans with network device */
/* add these new vlan ids into hash table */
/* reset the port if it is vlan unaware (ver < 1.3) */
}
}
if (updated & P_MD_maxbw) {
}
return (0);
}
/*
* vsw_mac_rx -- A common function to send packets to the interface.
* By default this function check if the interface is UP or not, the
* rest of the behaviour depends on the flags as below:
*
* VSW_MACRX_PROMISC -- Check if the promisc mode set or not.
* VSW_MACRX_COPYMSG -- Make a copy of the message(s).
* VSW_MACRX_FREEMSG -- Free if the messages cannot be sent up the stack.
*/
void
{
/* Check if the interface is up */
/* Free messages only if FREEMSG flag specified */
if (flags & VSW_MACRX_FREEMSG) {
}
return;
}
/*
* If PROMISC flag is passed, then check if
* the interface is in the PROMISC mode.
* If not, drop the messages.
*/
if (flags & VSW_MACRX_PROMISC) {
/* Free messages only if FREEMSG flag specified */
if (flags & VSW_MACRX_FREEMSG) {
}
return;
}
}
/*
* If COPYMSG flag is passed, then make a copy
* of the message chain and send up the copy.
*/
if (flags & VSW_MACRX_COPYMSG) {
return;
}
}
}
}
/* copy mac address of vsw into soft state structure */
static void
{
int i;
for (i = ETHERADDRL - 1; i >= 0; i--) {
macaddr >>= 8;
}
}
/* Compare VLAN ids, array size expected to be same. */
static boolean_t
{
int i, j;
for (i = 0; i < nvids; i++) {
for (j = 0; j < nvids; j++) {
break;
}
if (j == nvids) {
return (B_FALSE);
}
}
return (B_TRUE);
}