ldc_impl.h revision 20ae46ebaff1237662e05edf9db61538aa85d448
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER START
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The contents of this file are subject to the terms of the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Common Development and Distribution License (the "License").
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You may not use this file except in compliance with the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * or http://www.opensolaris.org/os/licensing.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * See the License for the specific language governing permissions
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * and limitations under the License.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * When distributing Covered Code, include this CDDL HEADER in each
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * If applicable, add the following below this CDDL HEADER, with the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * fields enclosed by brackets "[]" replaced with your own identifying
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * information: Portions Copyright [yyyy] [name of copyright owner]
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER END
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
582832867ac00db0b1619c1bb890285984d338c9ha * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Use is subject to license terms.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#ifndef _LDC_IMPL_H
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define _LDC_IMPL_H
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#pragma ident "%Z%%M% %I% %E% SMI"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#ifdef __cplusplus
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoextern "C" {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#endif
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/types.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/ddi.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/sunddi.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#include <sys/ioctl.h>
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
e1ebb9ec908bc2d0a8810f137ebd6566cc8a8061lm/* Memory map table entries */
e1ebb9ec908bc2d0a8810f137ebd6566cc8a8061lm#define LDC_MTBL_ENTRIES 8192 /* 8 K */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* Define LDC Queue info */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_PACKET_SHIFT 6
e1ebb9ec908bc2d0a8810f137ebd6566cc8a8061lm#define LDC_QUEUE_ENTRIES 512
e1ebb9ec908bc2d0a8810f137ebd6566cc8a8061lm#define LDC_MTU_MSGS 4
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_QUEUE_SIZE (LDC_QUEUE_ENTRIES << LDC_PACKET_SHIFT)
e1ebb9ec908bc2d0a8810f137ebd6566cc8a8061lm#define LDC_DEFAULT_MTU (LDC_QUEUE_SIZE / LDC_MTU_MSGS)
582832867ac00db0b1619c1bb890285984d338c9ha#define LDC_RXDQ_MULTIPLIER 2
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC Reliable mode - initial packet seqid
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * - If peer initiated handshake, RDX should contain init_seqid + 1
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * - If this endpoint initiated handshake first data packet should
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * contain the message init_seqid + 1
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_INIT_SEQID 0x0
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC Message types */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_CTRL 0x01 /* Control Pkt */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_DATA 0x02 /* Data Pkt */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_ERR 0x10 /* Error Pkt */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC Message Subtypes */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_INFO 0x01 /* Control/Data/Error info pkt */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_ACK 0x02 /* Control/Data ACK */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_NACK 0x04 /* Control/Data NACK */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC Control Messages */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_VER 0x01 /* Version message */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_RTS 0x02 /* Request to Send */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_RTR 0x03 /* Ready To Receive */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_RDX 0x04 /* Ready for data exchange */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_CTRL_MASK 0x0f /* Mask to read control bits */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC Channel Transport State (tstate) */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_TXQ_RDY 0x01 /* allocated TX queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_RXQ_RDY 0x02 /* allocated RX queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_INIT (TS_TXQ_RDY | TS_RXQ_RDY)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_QCONF_RDY 0x04 /* registered queues with HV */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_CNEX_RDY 0x08 /* registered channel with cnex */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_OPEN (TS_INIT | TS_QCONF_RDY | TS_CNEX_RDY)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_LINK_READY 0x10 /* both endpts registered Rx queues */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_READY (TS_OPEN | TS_LINK_READY)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_VER_DONE 0x20 /* negotiated version */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_VREADY (TS_READY | TS_VER_DONE)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_HSHAKE_DONE 0x40 /* completed handshake */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define TS_UP (TS_READY | TS_VER_DONE | TS_HSHAKE_DONE)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
3af08d828975d7e2581b6829e0eecff14d87a483lm#define TS_IN_RESET 0x100 /* channel is in reset state */
3af08d828975d7e2581b6829e0eecff14d87a483lm
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC Channel Transport Handshake states */
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define TS_SENT_VER 0x01 /* Sent version */
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define TS_SENT_RTS 0x02 /* Sent RTS */
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define TS_RCVD_RTR 0x04 /* Received RTR */
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define TS_SENT_RDX 0x08 /* Sent RDX */
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define TS_RCVD_VER 0x10 /* Received version */
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define TS_RCVD_RTS 0x20 /* Received RTS */
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define TS_SENT_RTR 0x40 /* Sent RTR */
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define TS_RCVD_RDX 0x80 /* Received RDX */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
3af08d828975d7e2581b6829e0eecff14d87a483lm/* LDC Interrupt State */
3af08d828975d7e2581b6829e0eecff14d87a483lm#define LDC_INTR_NONE 0x00 /* No interrupts */
3af08d828975d7e2581b6829e0eecff14d87a483lm#define LDC_INTR_ACTIVE 0x01 /* Interrupt being processed */
3af08d828975d7e2581b6829e0eecff14d87a483lm#define LDC_INTR_PEND 0x02 /* Interrupt pending */
3af08d828975d7e2581b6829e0eecff14d87a483lm
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC MSG Envelope */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_LEN_MASK 0x3F
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_FRAG_MASK 0xC0
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_FRAG_START 0x40 /* frag_info = 0x01 */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_FRAG_STOP 0x80 /* frag_info = 0x02 */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_FRAG_CONT 0x00 /* frag_info = 0x00 */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm * LDC will retry LDC_MAX_RETRIES times when sending or
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm * receiving data or if the HV returns back EWOULDBLOCK.
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm * Between each retry it will wait LDC_DELAY usecs.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define LDC_MAX_RETRIES 1000
0a55fbb79ee31ed09f84a9ae28e9747bc23f4a08lm#define LDC_DELAY 1
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
4d39be2b45b5ac811d28452e6eb629ac64aebfc4sg/* delay(usec) between channel unregister retries in ldc_close() */
4d39be2b45b5ac811d28452e6eb629ac64aebfc4sg#define LDC_CLOSE_DELAY 1
4d39be2b45b5ac811d28452e6eb629ac64aebfc4sg
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC Version information
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_PAYLOAD_VER_OFF 8 /* offset of version in payload */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_ver {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint16_t major;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint16_t minor;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_ver_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Each guest consists of one or more LDC endpoints represented by a ldc_chan
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * structure. Each ldc_chan structure points to a ldc_mtbl structure that
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * contains information about the map table associated with this LDC endpoint.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The map table contains the list of pages being shared by this guest over
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * this endpoint with the guest at the other end of this endpoint. Each LDC
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * endpoint also points to a list of memory handles used to bind and export
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * memory segments from this guest. If a memory segment is bound, it points to
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * a memory segment structure, which inturn consists of an array of ldc_page
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * structure for all the pages within that segment. Each ldc_page structure
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * contains information about the shared page and also points to the
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * corresponding entry in the map table.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Each LDC endpoint also points to a list of ldc_dring structures that refer
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * to both imported and exported descriptor rings. If it is a exported
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * descriptor ring, it then points to memory handle/memseg corresponding to
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * the region of memory associated with the descriptor ring.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +----------+ +----------+ +----------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | ldc_chan |-->| ldc_chan |-->| ldc_chan |-->....
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +----------+ +----------+ +----------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | | +-----------+ +-----------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | +----->| ldc_dring |---->| ldc_dring |---->......
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | +-----------+ +-----------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | +----------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | v
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | +----------+ +----------+ +----------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | +----->| ldc_mhdl |---->| ldc_mhdl |---->| ldc_mhdl |---> ....
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | +----------+ +----------+ +----------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * v | |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +----------+ | +------------+ | +------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | ldc_mtbl |--+ +--->| ldc_memseg |-----+ +--->| ldc_memseg |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +----------+ | +------------+ | +------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | | | | |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * v v v | v
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +--------------+ +----------+ +--------+ | +--------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | ldc_mte_slot |<--------| ldc_page | | cookie | | | cookie |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +--------------+ +----------+ +--------+ | +--------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | ldc_mte_slot |<--------| ldc_page | | cookie | v
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +--------------+ +----------+ +--------+ +----------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | ldc_mte_slot |<-----------------------------------| ldc_page |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +--------------+ +----------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | ldc_mte_slot |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +--------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | ...... |/ +------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +--------------+ | entry |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | ldc_mte_slot | +------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +--------------+ | inv_cookie |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * \ +------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Message format of each packet sent over the LDC channel.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Each packet is 64-bytes long.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Each packet that is sent over LDC can contain either data or acks.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * The type will reflect the contents. The len will contain in bytes
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * the amount of data being sent. In the case of ACKs, the seqid and
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * data fields will contain the SEQIDs of messages for which ACKs are
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * being sent.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Raw pkt format:
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * 0 - 7 | data payload |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Unreliable pkt format:
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * 0 | seqid | env | ctrl | stype | type |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * 1 - 7 | data payload |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Reliable pkt format:
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * 0 | seqid | env | ctrl | stype | type |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * 1 | ackid | unused |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * 2 - 7 | data payload |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_msg {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo union {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo struct {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t _type; /* Message type */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t _stype; /* Message subtype */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t _ctrl; /* Control/Error Message */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t _env; /* Message Envelope */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t _seqid; /* Sequence ID */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo union {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t _ud[LDC_PAYLOAD_SIZE_UNRELIABLE];
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* Unreliable data payload */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo struct {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t _unused; /* unused */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t _ackid; /* ACK ID */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t _rd[LDC_PAYLOAD_SIZE_RELIABLE];
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* Reliable data payload */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo } _rl;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo } _data;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo } _tpkt;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t _raw[LDC_PAYLOAD_SIZE_RAW];
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo } _pkt;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_msg_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define raw _pkt._raw
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define type _pkt._tpkt._type
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define stype _pkt._tpkt._stype
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define ctrl _pkt._tpkt._ctrl
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define env _pkt._tpkt._env
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define seqid _pkt._tpkt._seqid
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define udata _pkt._tpkt._data._ud
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define ackid _pkt._tpkt._data._rl._ackid
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define rdata _pkt._tpkt._data._rl._rd
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC Map Table Entry (MTE)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * 6 6 1 1 1
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * |3 0| psz| 3| 1| 0| 9| 8| 7|6|5|4| 0|
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------+--------------------------+----+----+--+--+--+--+-+-+-+-------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | rsvd | PFN | 0 | 0 |CW|CR|IW|IR|X|W|R| pgszc |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +------+--------------------------+----+----+--+--+--+--+-+-+-+-------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * | hv invalidation cookie |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +---------------------------------------------------------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef union {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo struct {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t _rsvd2:8, /* <63:56> reserved */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo rpfn:43, /* <55:13> real pfn */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo _rsvd1:2, /* <12:11> reserved */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cw:1, /* <10> copy write access */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo cr:1, /* <9> copy read perm */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo iw:1, /* <8> iommu write perm */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ir:1, /* <7> iommu read perm */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo x:1, /* <6> execute perm */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo w:1, /* <5> write perm */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo r:1, /* <4> read perm */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo pgszc:4; /* <3:0> pgsz code */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo } mte_bit;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t ll;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_mte_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define mte_rpfn mte_bit.rpfn
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define mte_cw mte_bit.cw
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define mte_cr mte_bit.cr
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define mte_iw mte_bit.iw
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define mte_ir mte_bit.ir
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define mte_x mte_bit.x
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define mte_w mte_bit.w
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define mte_r mte_bit.r
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define mte_pgszc mte_bit.pgszc
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define MTE_BSZS_SHIFT(sz) ((sz) * 3)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define MTEBYTES(sz) (MMU_PAGESIZE << MTE_BSZS_SHIFT(sz))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define MTEPAGES(sz) (1 << MTE_BSZS_SHIFT(sz))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define MTE_PAGE_SHIFT(sz) (MMU_PAGESHIFT + MTE_BSZS_SHIFT(sz))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define MTE_PAGE_OFFSET(sz) (MTEBYTES(sz) - 1)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define MTE_PAGEMASK(sz) (~MTE_PAGE_OFFSET(sz))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define MTE_PFNMASK(sz) (~(MTE_PAGE_OFFSET(sz) >> MMU_PAGESHIFT))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC Map Table Slot
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_mte_slot {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mte_t entry;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t cookie;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_mte_slot_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC Memory Map Table
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Each LDC has a memory map table it uses to list all the pages
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * it exporting to its peer over the channel. This structure
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * contains information about the map table and is pointed to
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * by the ldc_chan structure.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_mtbl {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmutex_t lock; /* Table lock */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo size_t size; /* Table size (in bytes) */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t next_entry; /* Next entry to use */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t num_entries; /* Num entries in table */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t num_avail; /* Num of available entries */
3af08d828975d7e2581b6829e0eecff14d87a483lm boolean_t contigmem; /* TRUE=Contig mem alloc'd */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mte_slot_t *table; /* The table itself */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_mtbl_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC page and memory segment information
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_page {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uintptr_t raddr; /* Exported page RA */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t offset; /* Exported page offset */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo size_t size; /* Exported page size */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t index; /* Index in map table */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mte_slot_t *mte; /* Map table entry */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_page_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_memseg {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t vaddr; /* Exported segment VA */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uintptr_t raddr; /* Exported segment VA */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo size_t size; /* Exported segment size */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t npages; /* Number of pages */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_page_t *pages; /* Array of exported pages */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t ncookies; /* Number of cookies */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mem_cookie_t *cookies;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t next_cookie; /* Index to next cookie */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_memseg_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC Cookie address format
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo *
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * 6 6 m+n
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * |3| 0| | m| 0|
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +-+-------+----------+-------------------+-------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * |X| pgszc | rsvd | table_idx | page_offset |
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * +-+-------+----------+-------------------+-------------------+
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_COOKIE_PGSZC_MASK 0x7
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_COOKIE_PGSZC_SHIFT 60
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC Memory handle
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_chan ldc_chan_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_mhdl {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmutex_t lock; /* Mutex for memory handle */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mstatus_t status; /* Memory map status */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t mtype; /* Type of sharing */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t perm; /* Access permissions */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo boolean_t myshadow; /* TRUE=alloc'd shadow mem */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_chan_t *ldcp; /* Pointer to channel struct */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_memseg_t *memseg; /* Bound memory segment */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo struct ldc_mhdl *next; /* Next memory handle */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_mhdl_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC Descriptor rings
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_dring {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmutex_t lock; /* Desc ring lock */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mstatus_t status; /* Desc ring status */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t dsize; /* Descriptor size */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t length; /* Descriptor ring length */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t size; /* Desc ring size (in bytes) */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t base; /* Descriptor ring base addr */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_chan_t *ldcp; /* Pointer to bound channel */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mem_handle_t mhdl; /* Mem handle to desc ring */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo struct ldc_dring *ch_next; /* Next dring in channel */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo struct ldc_dring *next; /* Next dring overall */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_dring_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Channel specific information is kept in a separate
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * structure. These are then stored on a array indexed
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * by the channel number.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppostruct ldc_chan {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_chan_t *next; /* Next channel */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmutex_t lock; /* Channel lock */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t id; /* Channel ID */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_status_t status; /* Channel status */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t tstate; /* Channel transport state */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t hstate; /* Channel transport handshake state */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_dev_t devclass; /* Associated device class */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t devinst; /* Associated device instance */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mode_t mode; /* Channel mode */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
3af08d828975d7e2581b6829e0eecff14d87a483lm uint64_t mtu; /* Max TU size */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_ver_t version; /* Channel version */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t next_vidx; /* Next version to match */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint_t (*cb)(uint64_t event, caddr_t arg);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo caddr_t cb_arg; /* Channel callback and arg */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo boolean_t cb_inprogress; /* Channel callback in progress */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo boolean_t cb_enabled; /* Channel callbacks are enabled */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
3af08d828975d7e2581b6829e0eecff14d87a483lm uint8_t tx_intr_state; /* Tx interrupt state */
3af08d828975d7e2581b6829e0eecff14d87a483lm uint8_t rx_intr_state; /* Rx interrupt state */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
d10e4ef2fabf16c3237c6d6592496df3eac6a1efnarayan kmutex_t tx_lock; /* Transmit lock */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t tx_q_entries; /* Num entries in transmit queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t tx_q_va; /* Virtual addr of transmit queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t tx_q_ra; /* Real addr of transmit queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t tx_head; /* Tx queue head */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t tx_ackd_head; /* Tx queue ACKd head (Reliable) */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t tx_tail; /* Tx queue tail */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t rx_q_entries; /* Num entries in receive queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t rx_q_va; /* Virtual addr of receive queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t rx_q_ra; /* Real addr of receive queue */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
582832867ac00db0b1619c1bb890285984d338c9ha uint64_t rx_dq_entries; /* Num entries in the data queue */
582832867ac00db0b1619c1bb890285984d338c9ha uint64_t rx_dq_va; /* Virtual addr of the data queue */
582832867ac00db0b1619c1bb890285984d338c9ha uint64_t rx_dq_head; /* Receive data queue head */
582832867ac00db0b1619c1bb890285984d338c9ha uint64_t rx_dq_tail; /* Receive data queue tail */
582832867ac00db0b1619c1bb890285984d338c9ha uint64_t rx_ack_head; /* Receive data ACK peek head ptr */
582832867ac00db0b1619c1bb890285984d338c9ha
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t link_state; /* Underlying HV channel state */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mtbl_t *mtbl; /* Memory table used by channel */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mhdl_t *mhdl_list; /* List of memory handles */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmutex_t mlist_lock; /* Mem handle list lock */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_dring_t *exp_dring_list; /* Exported desc ring list */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmutex_t exp_dlist_lock; /* Lock for exported desc ring list */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_dring_t *imp_dring_list; /* Imported desc ring list */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmutex_t imp_dlist_lock; /* Lock for imported desc ring list */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t pkt_payload; /* Size of packet payload */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t last_msg_snt; /* Seqid of last packet sent */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t last_ack_rcd; /* Seqid of last ACK recd */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t last_msg_rcd; /* Seqid of last packet received */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t stream_remains; /* Number of bytes in stream */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* packet buffer */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t stream_offset; /* Offset into packet buffer for */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo /* next read */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t *stream_bufferp; /* Stream packet buffer */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int (*read_p)(ldc_chan_t *ldcp, caddr_t bufferp,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo size_t *sizep);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int (*write_p)(ldc_chan_t *ldcp, caddr_t bufferp,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo size_t *sizep);
582832867ac00db0b1619c1bb890285984d338c9ha
582832867ac00db0b1619c1bb890285984d338c9ha uint64_t (*readq_get_state)(ldc_chan_t *ldcp, uint64_t *head,
582832867ac00db0b1619c1bb890285984d338c9ha uint64_t *tail, uint64_t *link_state);
582832867ac00db0b1619c1bb890285984d338c9ha
582832867ac00db0b1619c1bb890285984d338c9ha int (*readq_set_head)(ldc_chan_t *ldcp, uint64_t head);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo};
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/*
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC module soft state structure
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_soft_state {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo kmutex_t lock; /* Protects ldc_soft_state_t */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_cnex_t cinfo; /* channel nexus info */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t channel_count; /* Number of channels */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint64_t channels_open; /* Number of open channels */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_chan_t *chan_list; /* List of LDC endpoints */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_dring_t *dring_list; /* Descriptor rings (for export) */
4bac220845f606f60663ed6f3a2b88caa00ae87enarayan
4bac220845f606f60663ed6f3a2b88caa00ae87enarayan kmem_cache_t *memhdl_cache; /* Memory handle cache */
4bac220845f606f60663ed6f3a2b88caa00ae87enarayan kmem_cache_t *memseg_cache; /* Memory segment cache */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo} ldc_soft_state_t;
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
20ae46ebaff1237662e05edf9db61538aa85d448ha
20ae46ebaff1237662e05edf9db61538aa85d448ha/*
20ae46ebaff1237662e05edf9db61538aa85d448ha * Debugging Utilities
20ae46ebaff1237662e05edf9db61538aa85d448ha */
20ae46ebaff1237662e05edf9db61538aa85d448ha#define DBG_ALL_LDCS -1
20ae46ebaff1237662e05edf9db61538aa85d448ha#ifdef DEBUG
20ae46ebaff1237662e05edf9db61538aa85d448ha#define D1 \
20ae46ebaff1237662e05edf9db61538aa85d448haif (ldcdbg & 0x01) \
20ae46ebaff1237662e05edf9db61538aa85d448ha ldcdebug
20ae46ebaff1237662e05edf9db61538aa85d448ha#define D2 \
20ae46ebaff1237662e05edf9db61538aa85d448haif (ldcdbg & 0x02) \
20ae46ebaff1237662e05edf9db61538aa85d448ha ldcdebug
20ae46ebaff1237662e05edf9db61538aa85d448ha#define DWARN \
20ae46ebaff1237662e05edf9db61538aa85d448haif (ldcdbg & 0x04) \
20ae46ebaff1237662e05edf9db61538aa85d448ha ldcdebug
20ae46ebaff1237662e05edf9db61538aa85d448ha#else
20ae46ebaff1237662e05edf9db61538aa85d448ha#define D1
20ae46ebaff1237662e05edf9db61538aa85d448ha#define D2
20ae46ebaff1237662e05edf9db61538aa85d448ha#define DWARN
20ae46ebaff1237662e05edf9db61538aa85d448ha#endif
20ae46ebaff1237662e05edf9db61538aa85d448ha
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#ifdef __cplusplus
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo}
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#endif
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#endif /* _LDC_IMPL_H */