dcopy.h revision c6c65e5445ba6bc005f3da488bddd36494d26e65
/*
* 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 _SYS_DCOPY_H
#define _SYS_DCOPY_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* *** This interface is for private use by the IP stack only ***
*/
/* Function return status */
#define DCOPY_FAILURE (-1)
#define DCOPY_SUCCESS (0)
/* dq_version */
#define DCOPY_QUERY_V0 0
typedef struct dcopy_query_s {
int dq_version; /* DCOPY_QUERY_V0 */
/*
* dcopy_query()
* query for the number of DMA engines usable in the system.
*/
typedef struct dcopy_channel_s *dcopy_handle_t;
/* dcopy_alloc() and dcopy_cmd_alloc() common flags */
#define DCOPY_SLEEP (0)
#define DCOPY_NOSLEEP (1 << 0)
/*
* dcopy_alloc()
* Allocate a DMA channel which is used for posting DMA requests. Note: this
* does not give the caller exclusive access to the DMA engine. Commands
* posted to a channel will complete in order.
* flags - (DCOPY_SLEEP, DCOPY_NOSLEEP)
* returns => DCOPY_FAILURE, DCOPY_SUCCESS, DCOPY_NORESOURCES
*/
/*
* dcopy_free()
* Free the DMA channel. The client can no longer use the handle to post or
* poll for status on posts which were previously done on this channel.
*/
/* dq_version */
#define DCOPY_QUERY_CHANNEL_V0 0
/* Per DMA channel info */
typedef struct dcopy_query_channel_s {
int qc_version; /* DCOPY_QUERY_CHANNEL_V0 */
/* Does DMA channel support DCA */
/* device id and device specific capabilities */
/*
* DMA channel size. This may not be the same as the number of posts
* that the DMA channel can handle since a post may consume 1 or more
* entries.
*/
/* DMA channel number within the device. Not unique across devices */
/*
* dcopy_query_channel()
* query DMA engines capabilities
*/
/* dp_version */
#define DCOPY_CMD_V0 0
/* dp_cmd */
#define DCOPY_CMD_COPY 0x1
/* dp_flags */
/*
* DCOPY_CMD_QUEUE
* Hint to queue up the post but don't notify the DMA engine. This can be
* used as an optimization when multiple posts are going to be queued up and
* you only want notify the DMA engine after the last post. Note, this does
* not mean the DMA engine won't process the request since it could notice
* it anyway.
* DCOPY_CMD_NOSTAT
* Don't generate a status. If this flag is used, You cannot poll for
* completion status on this command. This can be a useful performance
* optimization if your posting multiple commands and just want to poll on
* the last command.
* DCOPY_CMD_DCA
* If DCA is supported, direct this and all future command data (until the
* next command with DCOPY_POST_DCA set) to the processor specified in
* dp_dca_id. This flag is ignored if DCA is not supported.
* DCOPY_CMD_INTR
* Generate an interrupt when command completes. This flag is required if
* the caller is going to call dcopy_cmd_poll(() with DCOPY_POLL_BLOCK set
* for this command.
*/
#define DCOPY_CMD_NOFLAGS (0)
#define DCOPY_CMD_QUEUE (1 << 0)
typedef struct dcopy_cmd_copy_s {
typedef union dcopy_cmd_u {
typedef struct dcopy_cmd_priv_s *dcopy_cmd_priv_t;
struct dcopy_cmd_s {
};
typedef struct dcopy_cmd_s *dcopy_cmd_t;
/*
* dcopy_cmd_alloc() specific flags
* DCOPY_ALLOC_LINK - when set, the caller passes in a previously alloced
* command in cmd. dcopy_cmd_alloc() will allocate a new command and
* link it to the old command. The caller can use this to build a
* chain of commands, keeping only the last cmd alloced. calling
* dcopy_cmd_free() with the last cmd alloced in the chain will free all of
* the commands in the chain. dcopy_cmd_post() and dcopy_cmd_poll() have
*/
/*
* dcopy_cmd_alloc()
* allocate a command. A command can be re-used after it completes.
* flags - (DCOPY_SLEEP || DCOPY_NOSLEEP), DCOPY_ALLOC_LINK
* returns => DCOPY_FAILURE, DCOPY_SUCCESS, DCOPY_NORESOURCES
*/
/*
* dcopy_cmd_free()
* free the command. This call cannot be called after dcopy_free().
*/
/*
* dcopy_cmd_post()
* post a command (allocated from dcopy_cmd_alloc()) to the DMA channel
* returns => DCOPY_FAILURE, DCOPY_SUCCESS, DCOPY_NORESOURCES
*/
/* dcopy_cmd_poll() flags */
#define DCOPY_POLL_NOFLAGS (0)
#define DCOPY_POLL_BLOCK (1 << 0)
/*
* dcopy_cmd_poll()
* poll on completion status of a previous post. This call cannot be called
* after dcopy_free().
*
* if flags == DCOPY_POLL_NOFLAGS, return status can be DCOPY_FAILURE,
* DCOPY_PENDING, or DCOPY_COMPLETED.
*
* if flags & DCOPY_POLL_BLOCK, return status can be DCOPY_FAILURE or
* DCOPY_COMPLETED. DCOPY_POLL_BLOCK can only be set in base context.
*
* The command cannot be re-used or freed until the command has completed
* (e.g. DCOPY_FAILURE or DCOPY_COMPLETED).
*/
#ifdef __cplusplus
}
#endif
#endif /* _SYS_DCOPY_H */