vsw.h revision 678453a8ed49104d8adad58f3ba591bdc39883e8
/*
* 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.
*/
/*
* This header file contains the data structures which the
* virtual switch (vsw) uses to communicate with its clients and
* the outside world.
*/
#ifndef _VSW_H
#define _VSW_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/vio_mailbox.h>
#include <sys/vnet_common.h>
#include <sys/ethernet.h>
#include <sys/vio_util.h>
#include <sys/vgen_stats.h>
#define DRV_NAME "vsw"
/*
* Only support ETHER mtu at moment.
*/
/* ID of the source of a frame being switched */
/*
* Vsw queue -- largely modeled after squeue
*
* VSW_QUEUE_RUNNING, vqueue thread for queue is running.
* VSW_QUEUE_DRAINED, vqueue thread has drained current work and is exiting.
* VSW_QUEUE_STOP, request for the vqueue thread to stop.
* VSW_QUEUE_STOPPED, vqueue thread is not running.
*/
#define VSW_QUEUE_RUNNING 0x01
#define VSW_QUEUE_DRAINED 0x02
#define VSW_QUEUE_STOP 0x04
#define VSW_QUEUE_STOPPED 0x08
typedef struct vsw_queue_s {
} vsw_queue_t;
/*
* VSW MAC Ring Resources.
* MAC Ring resource is composed of this state structure and
* a kernel thread to perform the processing of the ring.
*/
typedef struct vsw_mac_ring_s {
void *ring_arg;
/*
* Maximum Ring Resources.
*/
#define VSW_MAC_RX_RINGS 0x40
/*
* States for entry in ring table.
*/
#define VSW_MAC_RING_FREE 1
#define VSW_MAC_RING_INUSE 2
/*
* Number of hash chains in the multicast forwarding database.
*/
#define VSW_NCHAINS 8
/* Number of transmit descriptors - must be power of 2 */
#define VSW_RING_NUM_EL 512
/*
* State of interface if switch plumbed as network device.
*/
/*
* Switching modes.
*/
/*
* vsw instance state information.
*/
typedef struct vsw {
int instance; /* instance # */
int smode_idx; /* curr pos in smode array */
int smode_num; /* # of modes specified */
int mac_open_retries; /* mac_open() retry count */
void (*vsw_switch_frame)
/* mac layer */
/*
* MAC Ring Resources.
*/
int promisc_cnt;
/* Machine Description updates */
/* if configured as an ethernet interface */
int addr_set; /* Addr set where */
/* multicast addresses when configured as eth interface */
/* HybridIO related fields */
} vsw_t;
/*
* The flags that are used by vsw_mac_rx().
*/
typedef enum {
VSW_MACRX_PROMISC = 0x01,
VSW_MACRX_COPYMSG = 0x02,
VSW_MACRX_FREEMSG = 0x04
#ifdef DEBUG
extern int vswdbg;
#define D1(...) \
if (vswdbg & 0x01) \
#define D2(...) \
if (vswdbg & 0x02) \
#define D3(...) \
if (vswdbg & 0x04) \
#define DWARN(...) \
if (vswdbg & 0x08) \
#define DERR(...) \
if (vswdbg & 0x10) \
#else
#define DERR(...) if (0) do { } while (0)
#define DWARN(...) if (0) do { } while (0)
#define D1(...) if (0) do { } while (0)
#define D2(...) if (0) do { } while (0)
#define D3(...) if (0) do { } while (0)
#endif /* DEBUG */
#ifdef __cplusplus
}
#endif
#endif /* _VSW_H */