vsw_ldc.h revision bce0a86e5d4d65341c5aca6da2595c848297b2aa
/*
* 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 2009 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 vnet clients.
*
* 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_LDC_H
#define _VSW_LDC_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* Default message type.
*/
typedef struct def_msg {
} def_msg_t;
/*
*/
#define VSW_NUM_VER 1
typedef struct ver_sup {
} ver_sup_t;
/*
* 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
/*
* Currently only support one ldc per port.
*/
/*
*/
#define VSW_PORT_UPDATED 0x1
#define LDC_TX_SUCCESS 0 /* ldc transmit success */
/*
* 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)
/*
* LDC pkt tranfer MTU
*/
#define VSW_LDC_MTU sizeof (def_msg_t)
/*
* Size of the mblk in each mblk pool.
*/
#define VSW_MBLK_SZ_128 128
#define VSW_MBLK_SZ_256 256
#define VSW_MBLK_SZ_2048 2048
/*
* Number of mblks in each mblk pool.
*/
#define VSW_NUM_MBLKS 1024
/*
* Private descriptor
*/
typedef struct vsw_private_desc {
/*
* Below lock must be held when accessing the state of
* a descriptor on either the private or public sections
* of the ring.
*/
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 */
/*
* vnet-protocol-version dependent function prototypes.
*/
typedef void (*vsw_ldcrx_pktdata_t) (void *, void *, uint32_t);
/* ldc information associated with a vsw-port */
typedef struct vsw_ldc {
int drain_state;
int hcnt; /* # handshake attempts */
/* tx thread fields */
/* receive thread fields */
/* channel statistics */
} vsw_ldc_t;
/* worker thread flags */
/* list of ldcs per port */
typedef struct vsw_ldc_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 num_ldcs; /* # of ldcs in the port */
int state; /* port state */
/*
* mac address of the port & connected device
*/
struct ether_addr p_macaddr;
/* HybridIO related info */
/* bandwidth limit */
} 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 {
/*
* State of connection to peer. Some of these states
* can be mapped to LDC events as follows:
*
* VSW_CONN_RESET -> LDC_RESET_EVT
* VSW_CONN_UP -> LDC_UP_EVT
*/
typedef struct vsw_conn_evt {
/*
* 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_LDC_H */