vsw.h revision 1ae0874509b6811fdde1dfd46f0d93fd09867a3f
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This header file contains the basic data structures which the
* virtual switch (vsw) uses to communicate with its clients and
* the outside world.
*
* The virtual switch reads the machine description (MD) to
* determine how many port_t structures to create (each port_t
* can support communications to a single network device). The
* port_t's are maintained in a linked list.
*
* Each port in turn contains a number of logical domain channels
* (ldc's) which are inter domain communications channels which
* are used for passing small messages between the domains. Their
* may be an unlimited number of channels associated with each port,
* though most devices only use a single channel.
*
* The ldc is a bi-directional channel, which is divided up into
* two directional 'lanes', one outbound from the switch to the
* virtual network device, the other inbound to the switch.
* Depending on the type of device each lane may have seperate
* communication paramaters (such as mtu etc).
*
* For those network clients which use descriptor rings the
* rings are associated with the appropriate lane. I.e. rings
* which the switch exports are associated with the outbound lanes
* while those which the network clients are exporting to the switch
* are associated with the inbound lane.
*
* In diagram form the data structures look as follows:
*
* vsw instance
* |
* +----->port_t----->port_t----->port_t----->
* |
* +--->ldc_t--->ldc_t--->ldc_t--->
* |
* +--->lane_t (inbound)
* | |
* | +--->dring--->dring--->
* |
* +--->lane_t (outbound)
* |
* +--->dring--->dring--->
*
*/
#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>
/*
* Default message type.
*/
typedef struct def_msg {
} def_msg_t;
/*
*/
#define VSW_NUM_VER 1
typedef struct ver_sup {
ver_minor:16;
} ver_sup_t;
/*
* Only support ETHER mtu at moment.
*/
/*
* Lane states.
*/
#define VSW_VER_ACK_RECV 0x4
#define VSW_VER_ACK_SENT 0x8
#define VSW_VER_NACK_RECV 0x10
#define VSW_VER_NACK_SENT 0x20
#define VSW_ATTR_ACK_SENT 0x100
#define VSW_ATTR_ACK_RECV 0x200
#define VSW_ATTR_NACK_SENT 0x400
#define VSW_ATTR_NACK_RECV 0x800
#define VSW_DRING_ACK_SENT 0x4000
#define VSW_DRING_ACK_RECV 0x8000
#define VSW_DRING_NACK_SENT 0x10000
#define VSW_DRING_NACK_RECV 0x20000
#define VSW_RDX_ACK_SENT 0x100000
#define VSW_RDX_ACK_RECV 0x200000
#define VSW_RDX_NACK_SENT 0x400000
#define VSW_RDX_NACK_RECV 0x800000
#define VSW_MCST_INFO_SENT 0x1000000
#define VSW_MCST_INFO_RECV 0x2000000
#define VSW_MCST_ACK_SENT 0x4000000
#define VSW_MCST_ACK_RECV 0x8000000
#define VSW_MCST_NACK_SENT 0x10000000
#define VSW_MCST_NACK_RECV 0x20000000
/* Handshake milestones */
/*
* Lane direction (relative to ourselves).
*/
#define INBOUND 0x1
#define OUTBOUND 0x2
/* Peer session id received */
#define VSW_PEER_SESSION 0x1
/*
* Maximum number of consecutive reads of data from channel
*/
#define VSW_MAX_CHAN_READ 50
/*
* LDC queue length
*/
#define VSW_LDC_QLEN 1024
/*
* Currently only support one ldc per port.
*/
/*
*/
#define VSW_PORT_UPDATED 0x1
#define LDC_TX_SUCCESS 0 /* ldc transmit success */
/* ID of the source of a frame being switched */
/*
* Descriptor ring info
*
* Each descriptor element has a pre-allocated data buffer
* associated with it, into which data being transmitted is
* copied. By pre-allocating we speed up the copying process.
* The buffer is re-used once the peer has indicated that it is
* finished with the descriptor.
*/
#define VSW_PRIV_SIZE sizeof (vnet_private_desc_t)
#define VSW_PUB_SIZE sizeof (vnet_public_desc_t)
/*
* Private descriptor
*/
typedef struct vsw_private_desc {
void *datap;
int bound;
/*
* Descriptor ring structure
*/
typedef struct dring_info {
uint64_t ident; /* identifier sent to peer */
/*
* base address of private and public portions of the
* ring (where appropriate), and data block.
*/
void *pub_addr; /* base of public section */
void *priv_addr; /* base of private section */
void *data_addr; /* base of data section */
} dring_info_t;
/*
* Each ldc connection is comprised of two lanes, incoming
* from a peer, and outgoing to that peer. Each lane shares
* common ldc parameters and also has private lane-specific
* parameters.
*/
typedef struct lane {
} lane_t;
/* channel drain states */
/* ldc information associated with a vsw-port */
typedef struct vsw_ldc {
int drain_state;
int hcnt; /* # handshake attempts */
} vsw_ldc_t;
/* list of ldcs per port */
typedef struct vsw_ldc_list {
int num_ldcs; /* number of ldcs in the list */
/* multicast addresses port is interested in */
typedef struct mcst_addr {
} mcst_addr_t;
/* Port detach states */
/* port information associated with a vsw */
typedef struct vsw_port {
int p_instance; /* port instance */
int state; /* port state */
int ref_cnt; /* # of active references */
/*
* mac address of the port & connected device
*/
struct ether_addr p_macaddr;
} vsw_port_t;
/* list of ports per vsw */
typedef struct vsw_port_list {
int num_ports; /* number of ports in the list */
/*
* Taskq control message
*/
typedef struct vsw_ctrl_task {
/*
* Number of hash chains in the multicast forwarding database.
*/
#define VSW_NCHAINS 8
/*
* State of interface if switch plumbed as network device.
*/
/*
* Switching modes.
*/
/*
* Bits indicating which properties we've read from MD.
*/
#define VSW_MD_PHYSNAME 0x1
#define VSW_MD_MACADDR 0x2
#define VSW_MD_SMODE 0x4
/*
* vsw instance state information.
*/
typedef struct vsw {
int instance; /* instance # */
int smode_idx; /* curr pos in smode array */
/* mac layer */
/* Initial promisc setting of interface */
/* Machine Description updates */
/* if configured as an ethernet interface */
/* multicast addresses when configured as eth interface */
} vsw_t;
/*
* Ethernet broadcast address definition.
*/
static struct ether_addr etherbroadcastaddr = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
#define IS_BROADCAST(ehp) \
#define IS_MULTICAST(ehp) \
#ifdef __cplusplus
}
#endif
#endif /* _VSW_H */