* ========== Copyright Header Begin ==========================================
* Hypervisor Software File: cwq.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* - Do no alter or remove copyright notices
* - Redistribution and use of this software in source and binary forms, with
* or without modification, are permitted provided that the following
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* You acknowledge that this software is not designed, licensed or
* intended for use in the design, construction, operation or maintenance of
* ========== Copyright Header End ============================================
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
#pragma ident "@(#)cwq.h 1.1 07/05/03 SMI"
* Niagara2 CWQ definitions
uint64_t cpuset
; /* cpus ref CWQ */
typedef struct cwq_queue
{
uint64_t cq_cpu_pid
; /* HV intr target */
uint64_t cq_dr_hv_offset
;
* space allocated for "shadow queue" elements
* allocate one more entry than necessary to make room
* for alignment of array to 64-byte boundary
cwq_cw_t cq_hv_cws
[NCS_MAX_CWQ_NENTRIES
+ 1];
uint64_t pid
; /* physical CWQ id */
uint64_t state
; /* error/running/unconfig */
uint64_t handle
; /* handle for CWQ */
uint64_t ino
; /* ino property */
uint64_t cpuset
; /* cpus ref CWQ */
uint8_t cpu_active
[NSTRANDS_PER_CORE
];
crypto_intr_t ihdlr
; /* intr_handler info */
* Configuration and running status
cwq_queue_t queue
; /* queue for CWQ */
* Niagara2 CWQ definitions
* CWQ Initial Control Word
#define CW_STRAND_ID_SHIFT 37
#define CW_STRAND_ID_MASK 0x7
#define CW_HMAC_KEYLEN_SHIFT 16
#define CW_HMAC_KEYLEN_MASK 0xff
#define CW_LENGTH_MASK 0xffff
#define MAX_AUTHSTATE_LENGTH 32
#define CWQ_CSR_ENABLED 1
#define CWQ_CSR_PROTOERR 4
#define CWQ_CSR_ERROR_SHIFT 2
#define CWQ_CSR_ERROR (CWQ_CSR_PROTOERR | \
#define HANDLE_SIGMASK 0xfff
#define HANDLE_IDMASK 0xfff
#define HANDLE_IDSHIFT 16
#define HANDLE2ID(hdl, idx) \
srlx hdl, HANDLE_IDSHIFT, idx ; \
and idx, HANDLE_IDMASK, idx
#define ID2HANDLE(idx, sig, hdl) \
and idx, HANDLE_IDMASK, hdl ; \
sllx hdl, HANDLE_IDSHIFT, hdl ; \
#endif /* NCS_HANDLE_DEFS */
#define CWQ_HANDLE_SIG 0x0a72
#define HANDLE_IS_CWQ(hdl, scr) \
and hdl, HANDLE_SIGMASK, scr ; \
#define HANDLE_IS_CWQ_BRANCH(hdl, scr, label) \
and hdl, HANDLE_SIGMASK, scr ; \
cmp scr, CWQ_HANDLE_SIG ;\
* Translates and verifies a CWQ specific handle
* for a valid signature and ID.
#define CWQ_HANDLE2ID_VERIFY(hdl, lbl, id) \
HANDLE_IS_CWQ(hdl, id) ; \
#define CWQ_CLEAR_QSTATE(cwq) \
stx %g0, [cwq + CWQ_QUEUE + CQ_LOCK] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_DR_BASE_RA] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_DR_BASE] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_DR_LAST] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_DR_HEAD] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_DR_TAIL] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_BASE] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_LAST] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_HEAD] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_HEAD_MARKER] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_NENTRIES] ; \
stx %g0, [cwq + CWQ_QUEUE + CQ_DR_HV_OFFSET] ; \
st %g0, [cwq + CWQ_QUEUE + CQ_BUSY]
#define GUEST_CID_GETCWQ(guest, id, cwq) \
sllx id, GUEST_CWQS_SHIFT, cwq ; \
add cwq, GUEST_CWQS, cwq ; \
#define CWQ_LOCK_ENTER(cwq, lck, scr1, scr2) \
add cwq, CWQ_QUEUE, lck ; \
add lck, CQ_LOCK, lck ; \
SPINLOCK_ENTER(lck, scr1, scr2)
#define CWQ_LOCK_EXIT(cwq, lck) \
add cwq, CWQ_QUEUE, lck ; \
add lck, CQ_LOCK, lck ; \
#define CWQ_LOCK_EXIT_L(lck) \
#define HCALL_NCS_QINFO_CWQ() \
HANDLE_IS_CWQ(%o0, %g2) ;\
bne,pn %xcc, herr_inval ;\
CWQ_HANDLE2ID_VERIFY(%o0, herr_inval, %g2) ;\
GUEST_CID_GETCWQ(%g1, %g2, %g3) ;\
brz,pn %g3, herr_inval ;\
CWQ_LOCK_ENTER(%g3, %g2, %g5, %g6) ;\
mov NCS_QTYPE_CWQ, %o1 ;\
ldx [%g3 + CWQ_QUEUE + CQ_DR_BASE_RA], %o2 ;\
ldx [%g3 + CWQ_QUEUE + CQ_NENTRIES], %o3 ;\
#define HCALL_NCS_GETHEAD_CWQ() \
HANDLE_IS_CWQ(%o0, %g2) ;\
bne,pn %xcc, herr_inval ;\
CWQ_HANDLE2ID_VERIFY(%o0, herr_inval, %g2) ;\
GUEST_CID_GETCWQ(%g1, %g2, %g3) ;\
brz,pn %g3, herr_inval ;\
CWQ_LOCK_ENTER(%g3, %g5, %g2, %g6) ;\
ldx [%g3 + CWQ_QUEUE + CQ_BASE], %g1 ;\
ldx [%g3 + CWQ_QUEUE + CQ_HEAD], %g2 ;\
#define HCALL_NCS_GETTAIL_CWQ() \
HANDLE_IS_CWQ(%o0, %g2) ;\
bne,pn %xcc, herr_inval ;\
CWQ_HANDLE2ID_VERIFY(%o0, herr_inval, %g2) ;\
GUEST_CID_GETCWQ(%g1, %g2, %g3) ;\
brz,pn %g3, herr_inval ;\
CWQ_LOCK_ENTER(%g3, %g5, %g2, %g6) ;\
ldx [%g3 + CWQ_QUEUE + CQ_BASE], %g1 ;\
ldx [%g3 + CWQ_QUEUE + CQ_TAIL], %g2 ;\
#define HCALL_NCS_QHANDLE_TO_DEVINO_CWQ() \
HANDLE_IS_CWQ(%o0, %g2) ;\
bne,pn %xcc, herr_inval ;\
CWQ_HANDLE2ID_VERIFY(%o0, herr_inval, %g2) ;\
GUEST_CID_GETCWQ(%g1, %g2, %g3) ;\
brz,pn %g3, herr_inval ;\
ldx [%g3 + CWQ_INO], %o1 ;\
#define HCALL_NCS_SETHEAD_MARKER_CWQ() \
HANDLE_IS_CWQ(%o0, %g2) ;\
bne,pn %xcc, herr_inval ;\
CWQ_HANDLE2ID_VERIFY(%o0, herr_inval, %g2) ;\
GUEST_CID_GETCWQ(%g1, %g2, %g3) ;\
brz,pn %g3, herr_inval ;\
btst CWQ_CW_SIZE - 1, %o1 ;\
bnz,a,pn %xcc, herr_inval ;\
CWQ_LOCK_ENTER(%g3, %g5, %g2, %g6) ;\
ldx [%g3 + CWQ_QUEUE + CQ_BASE], %g1 ;\
ldx [%g3 + CWQ_QUEUE + CQ_LAST], %g2 ;\
stx %g1, [%g3 + CWQ_QUEUE + CQ_HEAD_MARKER] ;\
#define IS_NCS_QTYPE_CWQ(q, qtype, qlabel) \
#endif /* _PLATFORM_CWQ_H */