ldc.h revision e1ebb9ec908bc2d0a8810f137ebd6566cc8a8061
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * See the License for the specific language governing permissions
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * and limitations under the License.
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 * CDDL HEADER END
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Use is subject to license terms.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#pragma ident "%Z%%M% %I% %E% SMI"
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoextern "C" {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef uint64_t ldc_mem_handle_t; /* Channel memory handle */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef uint64_t ldc_dring_handle_t; /* Descriptor ring handle */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC transport mode */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef enum {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC message payload sizes */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_PAYLOAD_SIZE_UNRELIABLE (LDC_PACKET_SIZE - LDC_ELEM_SIZE)
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_PAYLOAD_SIZE_RELIABLE (LDC_PACKET_SIZE - (LDC_ELEM_SIZE * 2))
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC Channel Status */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef enum {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* Callback return values */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC callback mode */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef enum {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* Callback events */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_EVT_DOWN 0x1 /* Channel DOWN, status = OPEN */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_EVT_RESET 0x2 /* Channel RESET, status = READY */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_EVT_READ 0x8 /* Channel has data for read */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_EVT_WRITE 0x10 /* Channel has space for write */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC device classes */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef enum {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* Channel nexus registration */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_cnex {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int (*reg_chan)(); /* interface for channel register */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int (*unreg_chan)(); /* interface for channel unregister */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int (*add_intr)(); /* interface for adding interrupts */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int (*rem_intr)(); /* interface for removing interrupts */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo int (*clr_intr)(); /* interface for clearing interrupts */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC attribute structure */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_attr {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC memory cookie */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_mem_cookie {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * LDC Memory Map Type
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * Specifies how shared memory being created is shared with its
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo * peer and/or how the peer has mapped in the exported memory.
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_SHADOW_MAP 0x1 /* share mem via shadow copy only */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_DIRECT_MAP 0x2 /* share mem direct access */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_IO_MAP 0x4 /* share mem for IOMMU/DMA access */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC Memory Access Permissions */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_MEM_W 0x2 /* Memory region is write only */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_MEM_X 0x4 /* Memory region is execute only */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC Memory Copy Direction */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_COPY_IN 0x0 /* Copy data to VA from cookie mem */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#define LDC_COPY_OUT 0x1 /* Copy data from VA to cookie mem */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC memory/dring (handle) status */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef enum {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* LDC [dring] memory info */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppotypedef struct ldc_mem_info {
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo/* API functions */
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_init(uint64_t id, ldc_attr_t *attr, ldc_handle_t *handle);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint_t(*callback)(uint64_t event, caddr_t arg), caddr_t arg);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_set_cb_mode(ldc_handle_t handle, ldc_cb_mode_t imode);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_read(ldc_handle_t handle, caddr_t buf, size_t *size);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_write(ldc_handle_t handle, caddr_t buf, size_t *size);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_status(ldc_handle_t handle, ldc_status_t *status);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_alloc_handle(ldc_handle_t handle, ldc_mem_handle_t *mhandle);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_bind_handle(ldc_mem_handle_t mhandle, caddr_t vaddr, size_t len,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t mtype, uint8_t perm, ldc_mem_cookie_t *cookie, uint32_t *ccount);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_info(ldc_mem_handle_t mhandle, ldc_mem_info_t *minfo);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_nextcookie(ldc_mem_handle_t mhandle, ldc_mem_cookie_t *cookie);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_copy(ldc_handle_t handle, caddr_t vaddr, uint64_t off, size_t *len,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo ldc_mem_cookie_t *cookies, uint32_t ccount, uint8_t direction);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_rdwr_pa(ldc_handle_t handle, caddr_t vaddr, size_t *size,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_map(ldc_mem_handle_t mhandle, ldc_mem_cookie_t *cookie,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t ccount, uint8_t mtype, caddr_t *vaddr, caddr_t *raddr);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_acquire(ldc_mem_handle_t mhandle, uint64_t offset, uint64_t size);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_release(ldc_mem_handle_t mhandle, uint64_t offset, uint64_t size);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_dring_bind(ldc_handle_t handle, ldc_dring_handle_t dhandle,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint8_t mtype, uint8_t perm, ldc_mem_cookie_t *dcookie, uint32_t *ccount);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_dring_nextcookie(ldc_dring_handle_t mhandle,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_dring_info(ldc_dring_handle_t dhandle, ldc_mem_info_t *minfo);
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_dring_map(ldc_handle_t handle, ldc_mem_cookie_t *cookie,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo uint32_t ccount, uint32_t len, uint32_t dsize, uint8_t mtype,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_dring_acquire(ldc_dring_handle_t dhandle, uint64_t start,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppoint ldc_mem_dring_release(ldc_dring_handle_t dhandle, uint64_t start,
1ae0874509b6811fdde1dfd46f0d93fd09867a3fheppo#endif /* _LDC_H */