xref: /onnv-gate/usr/src/uts/sun4v/sys/vio_common.h (revision 12011:2377022c7a2d)
11991Sheppo /*
21991Sheppo  * CDDL HEADER START
31991Sheppo  *
41991Sheppo  * The contents of this file are subject to the terms of the
51991Sheppo  * Common Development and Distribution License (the "License").
61991Sheppo  * You may not use this file except in compliance with the License.
71991Sheppo  *
81991Sheppo  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91991Sheppo  * or http://www.opensolaris.org/os/licensing.
101991Sheppo  * See the License for the specific language governing permissions
111991Sheppo  * and limitations under the License.
121991Sheppo  *
131991Sheppo  * When distributing Covered Code, include this CDDL HEADER in each
141991Sheppo  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151991Sheppo  * If applicable, add the following below this CDDL HEADER, with the
161991Sheppo  * fields enclosed by brackets "[]" replaced with your own identifying
171991Sheppo  * information: Portions Copyright [yyyy] [name of copyright owner]
181991Sheppo  *
191991Sheppo  * CDDL HEADER END
201991Sheppo  */
211991Sheppo 
221991Sheppo /*
23*12011SSriharsha.Basavapatna@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
241991Sheppo  * Use is subject to license terms.
251991Sheppo  */
261991Sheppo 
271991Sheppo #ifndef _SYS_VIO_COMMON_H
281991Sheppo #define	_SYS_VIO_COMMON_H
291991Sheppo 
301991Sheppo #ifdef __cplusplus
311991Sheppo extern "C" {
321991Sheppo #endif
331991Sheppo 
346845Sha137994 #include <sys/ldc.h>
351991Sheppo 
361991Sheppo /*
376845Sha137994  * Common header for VIO descriptor ring entries
381991Sheppo  */
391991Sheppo typedef struct vio_dring_entry_hdr {
401991Sheppo 	uint8_t		dstate;		/* Current state of Dring entry */
411991Sheppo 	uint8_t		ack:1;		/* 1 => receiver must ACK when DONE */
421991Sheppo 
431991Sheppo 	/*
441991Sheppo 	 * Padding.
451991Sheppo 	 */
461991Sheppo 	uint16_t	resv[3];
471991Sheppo } vio_dring_entry_hdr_t;
481991Sheppo 
496845Sha137994 /*
506845Sha137994  * Common macros for acquiring and releasing VIO descriptor ring entries
516845Sha137994  */
526845Sha137994 #define	VIO_DRING_ACQUIRE(otd, mtype, handle, start, stop)		\
536845Sha137994 	((mtype) == LDC_DIRECT_MAP ?					\
54*12011SSriharsha.Basavapatna@Sun.COM 	LDC_ON_TRAP((otd)) :						\
556845Sha137994 	ldc_mem_dring_acquire((handle), (start), (stop)))
566845Sha137994 
576845Sha137994 #define	VIO_DRING_ACQUIRE_NOCOPYIN(otd, mtype)				\
586845Sha137994 	((mtype) == LDC_DIRECT_MAP ?					\
59*12011SSriharsha.Basavapatna@Sun.COM 	LDC_ON_TRAP((otd)) : 0)
606845Sha137994 
616845Sha137994 #define	VIO_DRING_RELEASE(mtype, handle, start, stop)			\
626845Sha137994 	((mtype) == LDC_DIRECT_MAP ?					\
63*12011SSriharsha.Basavapatna@Sun.COM 	LDC_NO_TRAP() :							\
646845Sha137994 	ldc_mem_dring_release((handle), (start), (stop)))
656845Sha137994 
666845Sha137994 #define	VIO_DRING_RELEASE_NOCOPYOUT(mtype)				\
676845Sha137994 	((mtype) == LDC_DIRECT_MAP ?					\
68*12011SSriharsha.Basavapatna@Sun.COM 	LDC_NO_TRAP() : 0)
691991Sheppo 
701991Sheppo #ifdef __cplusplus
711991Sheppo }
721991Sheppo #endif
731991Sheppo 
741991Sheppo #endif	/* _SYS_VIO_COMMON_H */
75