ldc_impl.h revision 20ae46ebaff1237662e05edf9db61538aa85d448
/*
* 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.
*/
#ifndef _LDC_IMPL_H
#define _LDC_IMPL_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/* Memory map table entries */
/* Define LDC Queue info */
#define LDC_PACKET_SHIFT 6
#define LDC_QUEUE_ENTRIES 512
#define LDC_MTU_MSGS 4
#define LDC_RXDQ_MULTIPLIER 2
/*
* LDC Reliable mode - initial packet seqid
* - If peer initiated handshake, RDX should contain init_seqid + 1
* - If this endpoint initiated handshake first data packet should
* contain the message init_seqid + 1
*/
#define LDC_INIT_SEQID 0x0
/* LDC Message types */
/* LDC Message Subtypes */
/* LDC Control Messages */
/* LDC Channel Transport State (tstate) */
/* LDC Channel Transport Handshake states */
/* LDC Interrupt State */
/* LDC MSG Envelope */
#define LDC_LEN_MASK 0x3F
#define LDC_FRAG_MASK 0xC0
/*
* LDC will retry LDC_MAX_RETRIES times when sending or
* receiving data or if the HV returns back EWOULDBLOCK.
* Between each retry it will wait LDC_DELAY usecs.
*/
#define LDC_MAX_RETRIES 1000
#define LDC_DELAY 1
/* delay(usec) between channel unregister retries in ldc_close() */
#define LDC_CLOSE_DELAY 1
/*
* LDC Version information
*/
typedef struct ldc_ver {
} ldc_ver_t;
/*
* Each guest consists of one or more LDC endpoints represented by a ldc_chan
* structure. Each ldc_chan structure points to a ldc_mtbl structure that
* contains information about the map table associated with this LDC endpoint.
* The map table contains the list of pages being shared by this guest over
* this endpoint with the guest at the other end of this endpoint. Each LDC
* endpoint also points to a list of memory handles used to bind and export
* memory segments from this guest. If a memory segment is bound, it points to
* a memory segment structure, which inturn consists of an array of ldc_page
* structure for all the pages within that segment. Each ldc_page structure
* contains information about the shared page and also points to the
* corresponding entry in the map table.
*
* Each LDC endpoint also points to a list of ldc_dring structures that refer
* to both imported and exported descriptor rings. If it is a exported
* the region of memory associated with the descriptor ring.
*
* +----------+ +----------+ +----------+
* | ldc_chan |-->| ldc_chan |-->| ldc_chan |-->....
* +----------+ +----------+ +----------+
* | | |
* | | |
* | | | +-----------+ +-----------+
* | | +----->| ldc_dring |---->| ldc_dring |---->......
* | | +-----------+ +-----------+
* | | |
* | | +----------------------------+
* | | |
* | | v
* | | +----------+ +----------+ +----------+
* | +----->| ldc_mhdl |---->| ldc_mhdl |---->| ldc_mhdl |---> ....
* | +----------+ +----------+ +----------+
* v | |
* +----------+ | +------------+ | +------------+
* | ldc_mtbl |--+ +--->| ldc_memseg |-----+ +--->| ldc_memseg |
* +----------+ | +------------+ | +------------+
* | | | | |
* v v v | v
* +--------------+ +----------+ +--------+ | +--------+
* | ldc_mte_slot |<--------| ldc_page | | cookie | | | cookie |
* +--------------+ +----------+ +--------+ | +--------+
* | ldc_mte_slot |<--------| ldc_page | | cookie | v
* +--------------+ +----------+ +--------+ +----------+
* | ldc_mte_slot |<-----------------------------------| ldc_page |
* +--------------+ +----------+
* | ldc_mte_slot |
* +--------------+
* | ...... |/ +------------+
* +--------------+ | entry |
* | ldc_mte_slot | +------------+
* +--------------+ | inv_cookie |
* \ +------------+
*
*/
/*
* Message format of each packet sent over the LDC channel.
* Each packet is 64-bytes long.
*
* Each packet that is sent over LDC can contain either data or acks.
* The type will reflect the contents. The len will contain in bytes
* the amount of data being sent. In the case of ACKs, the seqid and
* data fields will contain the SEQIDs of messages for which ACKs are
* being sent.
*
* Raw pkt format:
*
* +------------------------------------------------------+
* 0 - 7 | data payload |
* +------------------------------------------------------+
*
* Unreliable pkt format:
*
* +------------------------------------------------------+
* 0 | seqid | env | ctrl | stype | type |
* +------------------------------------------------------+
* 1 - 7 | data payload |
* +------------------------------------------------------+
*
* Reliable pkt format:
*
* +------------------------------------------------------+
* 0 | seqid | env | ctrl | stype | type |
* +------------------------------------------------------+
* 1 | ackid | unused |
* +------------------------------------------------------+
* 2 - 7 | data payload |
* +------------------------------------------------------+
*/
typedef struct ldc_msg {
union {
struct {
union {
/* Unreliable data payload */
struct {
/* Reliable data payload */
} _rl;
} _data;
} _tpkt;
} _pkt;
} ldc_msg_t;
/*
* LDC Map Table Entry (MTE)
*
* 6 6 1 1 1
* |3 0| psz| 3| 1| 0| 9| 8| 7|6|5|4| 0|
* +------+--------------------------+----+----+--+--+--+--+-+-+-+-------+
* | rsvd | PFN | 0 | 0 |CW|CR|IW|IR|X|W|R| pgszc |
* +------+--------------------------+----+----+--+--+--+--+-+-+-+-------+
* | hv invalidation cookie |
* +---------------------------------------------------------------------+
*/
typedef union {
struct {
x:1, /* <6> execute perm */
w:1, /* <5> write perm */
r:1, /* <4> read perm */
} mte_bit;
} ldc_mte_t;
/*
* LDC Map Table Slot
*/
typedef struct ldc_mte_slot {
/*
* LDC Memory Map Table
*
* Each LDC has a memory map table it uses to list all the pages
* it exporting to its peer over the channel. This structure
* contains information about the map table and is pointed to
* by the ldc_chan structure.
*/
typedef struct ldc_mtbl {
} ldc_mtbl_t;
/*
* LDC page and memory segment information
*/
typedef struct ldc_page {
} ldc_page_t;
typedef struct ldc_memseg {
} ldc_memseg_t;
/*
* LDC Cookie address format
*
* 6 6 m+n
* |3| 0| | m| 0|
* +-+-------+----------+-------------------+-------------------+
* |X| pgszc | rsvd | table_idx | page_offset |
* +-+-------+----------+-------------------+-------------------+
*/
#define LDC_COOKIE_PGSZC_MASK 0x7
#define LDC_COOKIE_PGSZC_SHIFT 60
/*
* LDC Memory handle
*/
typedef struct ldc_chan ldc_chan_t;
typedef struct ldc_mhdl {
} ldc_mhdl_t;
/*
* LDC Descriptor rings
*/
typedef struct ldc_dring {
} ldc_dring_t;
/*
* Channel specific information is kept in a separate
* structure. These are then stored on a array indexed
* by the channel number.
*/
struct ldc_chan {
/* packet buffer */
/* next read */
};
/*
* LDC module soft state structure
*/
typedef struct ldc_soft_state {
/*
* Debugging Utilities
*/
#define DBG_ALL_LDCS -1
#ifdef DEBUG
#define D1 \
if (ldcdbg & 0x01) \
#define D2 \
if (ldcdbg & 0x02) \
#define DWARN \
if (ldcdbg & 0x04) \
#else
#define D1
#define D2
#define DWARN
#endif
#ifdef __cplusplus
}
#endif
#endif /* _LDC_IMPL_H */