vsw.c revision 3c1bce15918aed7fd25ce57449e5ca2c718cbc1e
/*
* 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
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/ethernet.h>
#include <sys/machsystm.h>
#include <sys/mac_ether.h>
#include <sys/mach_descrip.h>
#include <sys/vio_mailbox.h>
#include <sys/vnet_mailbox.h>
#include <sys/vnet_common.h>
#include <sys/vio_util.h>
/*
* Function prototypes.
*/
/* 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_timeout(void *arg);
extern int vsw_setup_switching(vsw_t *);
extern void vsw_del_mcst_vsw(vsw_t *);
extern void vsw_reconfig_hw(vsw_t *);
/*
* Internal tunables.
*/
int vsw_desc_delay = 0; /* delay in us */
/* sw timeout for boot delay only, in milliseconds */
/* 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.
*/
uint64_t vsw_pri_eth_type = 0;
/*
* 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().
*/
/*
* External tunables.
*/
/*
* that is done a vsw driver attach time.
*/
int vsw_mac_rx_rings = VSW_MAC_RX_RINGS;
/* Number of transmit descriptors - must be power of 2 */
/*
* Max number of mblks received in one receive operation.
*/
/*
* Tunables for three different pools, that is, the size and
* number of mblks for each pool.
*/
/*
* 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
*/
static mac_callbacks_t vsw_m_callbacks = {
0,
NULL,
NULL,
};
static struct cb_ops vsw_cb_ops = {
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 */
vsw_getinfo, /* 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;
static struct modldrv vswmodldrv = {
"sun4v Virtual Switch",
&vsw_ops,
};
#define LDC_ENTER_LOCK(ldcp) \
#define LDC_EXIT_LOCK(ldcp) \
/* Driver soft state ptr */
static void *vsw_state;
/*
* Linked list of "vsw_t" structures - one per instance.
*/
/*
* Property names
*/
static char vdev_propname[] = "virtual-device";
static char vsw_propname[] = "virtual-network-switch";
static char physdev_propname[] = "vsw-phys-dev";
static char smode_propname[] = "vsw-switch-mode";
static char macaddr_propname[] = "local-mac-address";
static char remaddr_propname[] = "remote-mac-address";
static char ldcids_propname[] = "ldc-ids";
static char chan_propname[] = "channel-endpoint";
static char id_propname[] = "id";
static char reg_propname[] = "reg";
static char pri_types_propname[] = "priority-ether-types";
static char vsw_pvid_propname[] = "port-vlan-id";
static char vsw_vid_propname[] = "vlan-id";
static char vsw_dvid_propname[] = "default-vlan-id";
static char port_pvid_propname[] = "remote-port-vlan-id";
static char port_vid_propname[] = "remote-vlan-id";
static char hybrid_propname[] = "hybrid";
/*
* Matching criteria passed to the MDEG to register interest
* in changes to 'virtual-device-port' nodes identified by their
* 'id' property.
*/
static md_prop_match_t vport_prop_match[] = {
{ 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.
*/
static md_prop_match_t vdev_prop_match[] = {
{ 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.
*/
static mdeg_prop_spec_t vsw_prop_template[] = {
};
#ifdef DEBUG
/*
* Print debug messages - set to 0x1f to enable all msgs
* or 0x0 to turn all off.
*/
int vswdbg = 0x0;
/*
* debug levels:
* 0x02: Internal function messages
* 0x04: Verbose internal messages
* 0x08: Warning messages
* 0x10: Error messages
*/
void
{
char buf[512];
else
}
#endif /* DEBUG */
static struct modlinkage modlinkage = {
};
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;
char hashname[MAXNAMELEN];
char qname[TASKQ_NAMELEN];
enum { PROG_init = 0x00,
PROG_locks = 0x01,
PROG_readmd = 0x02,
PROG_fdb = 0x04,
PROG_mfdb = 0x08,
PROG_taskq = 0x10,
PROG_swmode = 0x20,
PROG_macreg = 0x40,
PROG_mdreg = 0x80}
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;
/* 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.
* schedule a short timeout (0.1 sec) for the first time
* setup and avoid calling mac_open() directly here,
* others are regular timeout 3 secs.
*/
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);
if (progress & PROG_mdreg) {
(void) vsw_detach_ports(vswp);
}
if (progress & PROG_macreg)
(void) vsw_mac_unregister(vswp);
if (progress & PROG_swmode) {
}
if (progress & PROG_taskq)
}
if (progress & PROG_readmd) {
if (VSW_PRI_ETH_DEFINED(vswp)) {
}
}
if (progress & PROG_locks) {
}
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);
}
/* Stop any pending timeout to setup switching mode. */
if (vsw_mac_unregister(vswp) != 0) {
return (DDI_FAILURE);
}
}
/* remove mac layer callback */
}
if (vsw_detach_ports(vswp) != 0) {
return (DDI_FAILURE);
}
/* cleanup HybridIO */
/*
* Now that the ports have been deleted, stop and close
* the physical device.
*/
/*
* Destroy any free pools that may still exist.
*/
if (vio_destroy_mblks(poolp) != 0) {
return (DDI_FAILURE);
}
}
/*
* Remove this instance from any entries it may be on in
* the hash table by using the list of addresses maintained
* in the vsw_t structure.
*/
/*
* By now any pending tasks have finished and the underlying
* ldc's have been destroyed, so its safe to delete the control
* message taskq.
*/
/*
* At this stage all the data pointers in the hash table
* should be NULL, as all the ports have been removed and will
* have deleted themselves from the port lists which the data
* pointers point to. Hence we can destroy the table using the
* default destructors.
*/
/* free pri_types table */
if (VSW_PRI_ETH_DEFINED(vswp)) {
}
break;
}
}
return (DDI_SUCCESS);
}
static int
{
int instance;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
case DDI_INFO_DEVT2INSTANCE:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/*
* 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;
char myname[MAXNAMELEN];
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 and the number of modes found in 'found',
* otherwise returns 1.
*/
static int
{
int len = 0;
int smode_num = 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;
smode_num = 0;
/*
* Unable to get switch-mode property from MD, nothing
* more we can do.
*/
*found = 0;
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.
*/
} else {
"setting to default 'switched' mode",
}
}
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);
}
+ VLAN_TAGSZ;
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
vsw_m_stop(void *arg)
{
if (vswp->recfg_reqd)
}
static int
vsw_m_start(void *arg)
{
/*
* 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. */
}
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) {
"add multicast address",
(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 rv = 1;
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
{
int i;
return (1);
}
/* mac address for vswitch device itself */
return (1);
}
"defaulting to 'switched' mode",
for (i = 0; i < NUM_SMODES; i++)
} else {
}
/* read vlan id properties of this vsw instance */
/* read priority-ether-types */
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++) {
}
}
}
/*
* 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.
*/
}
}
/*
* 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, smode_num = 0;
enum {MD_init = 0x1,
MD_physname = 0x2,
MD_macaddr = 0x4,
MD_smode = 0x8,
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 {
}
for (i = 0; i < smode_num; i++) {
break;
}
}
}
/* Read the vlan ids */
/* Determine if there are any vlan id updates */
}
/*
* Now make any changes which are needed...
*/
/*
* Stop any pending timeout to setup switching mode.
*/
/* Cleanup HybridIO */
/*
* Remove unicst, mcst addrs of vsw interface
* and ports from the physdev.
*/
/*
* Stop, detach and close the old device..
*/
/*
* Update phys name.
*/
if (updated & MD_physname) {
}
/*
* Update array with the new switch mode values.
*/
for (i = 0; i < smode_num; i++)
}
/*
* ..and attach, start the new device.
*/
/*
* Unable to setup switching mode.
* As the error is EAGAIN, schedule a timeout to retry
* and return. Programming addresses of ports and
* vsw interface will be done when the timeout handler
* completes successfully.
*/
vswp->swtmout_id =
drv_usectohz(MICROSEC)));
return;
} else if (rv) {
goto fail_update;
}
/*
* program unicst, mcst addrs of vsw interface
* and ports in the physdev.
*/
/* Start HIO for ports that have already connected */
} 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).
*/
/*
* Remove old mac address of vsw interface
* from the physdev
*/
/*
* Program new mac address of vsw interface
* in the physdev
*/
if (rv != 0) {
"!vsw%d: failed to program interface "
}
/*
* Notify the MAC layer of the changed address.
*/
}
}
/* Remove existing vlan ids from the hash table. */
/* save the new vlan ids */
}
if (nvids != 0) {
}
/* 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;
struct ether_addr ea;
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.
*/
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 */
}
if (updated_vlans == B_TRUE) {
/* Remove existing vlan ids from the hash table. */
/* save the new vlan ids */
}
if (nvids != 0) {
}
/* add these new vlan ids into hash table */
/* reset the port if it is vlan unaware (ver < 1.3) */
}
/* Check if hybrid property is present */
}
}
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;
}
}