1221167Sgnn/*-
2221167Sgnn * Copyright(c) 2002-2011 Exar Corp.
3221167Sgnn * All rights reserved.
4221167Sgnn *
5221167Sgnn * Redistribution and use in source and binary forms, with or without
6221167Sgnn * modification are permitted provided the following conditions are met:
7221167Sgnn *
8221167Sgnn *    1. Redistributions of source code must retain the above copyright notice,
9221167Sgnn *       this list of conditions and the following disclaimer.
10221167Sgnn *
11221167Sgnn *    2. Redistributions in binary form must reproduce the above copyright
12221167Sgnn *       notice, this list of conditions and the following disclaimer in the
13221167Sgnn *       documentation and/or other materials provided with the distribution.
14221167Sgnn *
15221167Sgnn *    3. Neither the name of the Exar Corporation nor the names of its
16221167Sgnn *       contributors may be used to endorse or promote products derived from
17221167Sgnn *       this software without specific prior written permission.
18221167Sgnn *
19221167Sgnn * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20221167Sgnn * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21221167Sgnn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22221167Sgnn * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23221167Sgnn * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24221167Sgnn * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25221167Sgnn * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26221167Sgnn * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27221167Sgnn * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28221167Sgnn * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29221167Sgnn * POSSIBILITY OF SUCH DAMAGE.
30221167Sgnn */
31221167Sgnn/*$FreeBSD$*/
32221167Sgnn
33221167Sgnn#ifndef	VXGE_HAL_DOOR_BELLS_H
34221167Sgnn#define	VXGE_HAL_DOOR_BELLS_H
35221167Sgnn
36221167Sgnn__EXTERN_BEGIN_DECLS
37221167Sgnn
38221167Sgnn/*
39221167Sgnn * struct __hal_non_offload_db_wrapper_t - Non-offload Doorbell Wrapper
40221167Sgnn * @control_0:	Bits 0 to 7 - Doorbell type.
41221167Sgnn *		Bits 8 to 31 - Reserved.
42221167Sgnn *		Bits 32 to 39 - The highest TxD in this TxDL.
43221167Sgnn *		Bits 40 to 47 - Reserved.
44221167Sgnn *		Bits 48 to 55 - Reserved.
45221167Sgnn *		Bits 56 to 63 - No snoop flags.
46221167Sgnn * @txdl_ptr:	The starting location of the TxDL in host memory.
47221167Sgnn *
48221167Sgnn * Created by the host and written to the adapter via PIO to a Kernel Doorbell
49221167Sgnn * FIFO. All non-offload doorbell wrapper fields must be written by the host as
50221167Sgnn * part of a doorbell write. Consumed by the adapter but is not written by the
51221167Sgnn * adapter.
52221167Sgnn */
53221167Sgnntypedef __vxge_os_attr_cacheline_aligned struct __hal_non_offload_db_wrapper_t {
54221167Sgnn	u64		control_0;
55221167Sgnn#define	VXGE_HAL_NODBW_GET_TYPE(ctrl0)				bVAL8(ctrl0, 0)
56221167Sgnn#define	VXGE_HAL_NODBW_TYPE(val)				vBIT(val, 0, 8)
57221167Sgnn#define	VXGE_HAL_NODBW_TYPE_NODBW				0
58221167Sgnn
59221167Sgnn#define	VXGE_HAL_NODBW_GET_LAST_TXD_NUMBER(ctrl0)		bVAL8(ctrl0, 32)
60221167Sgnn#define	VXGE_HAL_NODBW_LAST_TXD_NUMBER(val)			vBIT(val, 32, 8)
61221167Sgnn
62221167Sgnn#define	VXGE_HAL_NODBW_GET_NO_SNOOP(ctrl0)			bVAL8(ctrl0, 56)
63221167Sgnn#define	VXGE_HAL_NODBW_LIST_NO_SNOOP(val)			vBIT(val, 56, 8)
64221167Sgnn#define	VXGE_HAL_NODBW_LIST_NO_SNOOP_TXD_READ_TXD0_WRITE	0x2
65221167Sgnn#define	VXGE_HAL_NODBW_LIST_NO_SNOOP_TX_FRAME_DATA_READ		0x1
66221167Sgnn
67221167Sgnn	u64		txdl_ptr;
68221167Sgnn} __hal_non_offload_db_wrapper_t;
69221167Sgnn
70221167Sgnn/*
71221167Sgnn * struct __hal_offload_db_wrapper_t - Tx-Offload Doorbell Wrapper
72221167Sgnn * @control_0:	Bits 0 to 7 - Doorbell type.
73221167Sgnn *		Bits 8 to 31 - Identifies the session to which this Tx
74221167Sgnn *		offload doorbell applies.
75221167Sgnn *		Bits 32 to 40 - Identifies the incarnation of this Session
76221167Sgnn *		Number. The adapter assigns a Session Instance
77221167Sgnn *		Number of 0 to a session when that Session Number
78221167Sgnn *		is first used. Each subsequent assignment of that
79221167Sgnn *		Session Number from the free pool causes this
80221167Sgnn *		number to be incremented, with wrap eventually
81221167Sgnn *		occurring from 255 back to 0.
82221167Sgnn *		Bits 40 to 63 - Identifies the end of the TOWI list for
83221167Sgnn *		this session to the adapter.
84221167Sgnn * @control_1:	Bits 0 to 7 - Identifies what is included in this doorbell
85221167Sgnn *		Bits 8 to 15 - The number of Immediate data bytes included in
86221167Sgnn *		this doorbell.
87221167Sgnn *		Bits 16 to 63 - Reserved.
88221167Sgnn *
89221167Sgnn * Created by the host and written to the adapter via PIO to a Kernel Doorbell
90221167Sgnn * FIFO. All Tx Offload doorbell wrapper fields must be written by the host as
91221167Sgnn * part of a doorbell write. Consumed by the adapter but is never written by the
92221167Sgnn * adapter.
93221167Sgnn */
94221167Sgnntypedef __vxge_os_attr_cacheline_aligned struct __hal_offload_db_wrapper_t {
95221167Sgnn	u64		control_0;
96221167Sgnn#define	VXGE_HAL_ODBW_GET_TYPE(ctrl0)			bVAL8(ctrl0, 0)
97221167Sgnn#define	VXGE_HAL_ODBW_TYPE(val)				vBIT(val, 0, 8)
98221167Sgnn#define	VXGE_HAL_ODBW_TYPE_ODBW				1
99221167Sgnn
100221167Sgnn#define	VXGE_HAL_ODBW_GET_SESSION_NUMBER(ctrl0)		bVAL24(ctrl0, 8)
101221167Sgnn#define	VXGE_HAL_ODBW_SESSION_NUMBER(val)		vBIT(val, 8, 24)
102221167Sgnn
103221167Sgnn#define	VXGE_HAL_ODBW_GET_SESSION_INST_NUMBER(ctrl0)	bVAL8(ctrl0, 32)
104221167Sgnn#define	VXGE_HAL_ODBW_SESSION_INST_NUMBER(val)		vBIT(val, 32, 8)
105221167Sgnn
106221167Sgnn#define	VXGE_HAL_ODBW_GET_HIGH_TOWI_NUMBER(ctrl0)	bVAL24(ctrl0, 40)
107221167Sgnn#define	VXGE_HAL_ODBW_HIGH_TOWI_NUMBER(val)		vBIT(val, 40, 24)
108221167Sgnn
109221167Sgnn	u64		control_1;
110221167Sgnn#define	VXGE_HAL_ODBW_GET_ENTRY_TYPE(ctrl1)		bVAL8(ctrl1, 0)
111221167Sgnn#define	VXGE_HAL_ODBW_ENTRY_TYPE(val)			vBIT(val, 0, 8)
112221167Sgnn#define	VXGE_HAL_ODBW_ENTRY_TYPE_WRAPPER_ONLY		0x0
113221167Sgnn#define	VXGE_HAL_ODBW_ENTRY_TYPE_WRAPPER_TOWI		0x1
114221167Sgnn#define	VXGE_HAL_ODBW_ENTRY_TYPE_WRAPPER_TOWI_DATA	0x2
115221167Sgnn
116221167Sgnn#define	VXGE_HAL_ODBW_GET_IMMEDIATE_BYTE_COUNT(ctrl1)	bVAL8(ctrl1, 8)
117221167Sgnn#define	VXGE_HAL_ODBW_IMMEDIATE_BYTE_COUNT(val)		vBIT(val, 8, 8)
118221167Sgnn
119221167Sgnn} __hal_offload_db_wrapper_t;
120221167Sgnn
121221167Sgnn/*
122221167Sgnn * struct __hal_offload_atomic_db_wrapper_t - Atomic Tx-Offload Doorbell
123221167Sgnn *						 Wrapper
124221167Sgnn * @control_0:	Bits 0 to 7 - Doorbell type.
125221167Sgnn *		Bits 8 to 31 - Identifies the session to which this Tx
126221167Sgnn *		offload doorbell applies.
127221167Sgnn *		Bits 32 to 40 - Identifies the incarnation of this Session
128221167Sgnn *		Number. The adapter assigns a Session Instance
129221167Sgnn *		Number of 0 to a session when that Session Number
130221167Sgnn *		is first used. Each subsequent assignment of that
131221167Sgnn *		Session Number from the free pool causes this
132221167Sgnn *		number to be incremented, with wrap eventually
133221167Sgnn *		occurring from 255 back to 0.
134221167Sgnn *		Bits 40 to 63 - Identifies the end of the TOWI list for
135221167Sgnn *		this session to the adapter.
136221167Sgnn *
137221167Sgnn * Created by the host and written to the adapter via PIO to a Kernel Doorbell
138221167Sgnn * FIFO.  All Tx Offload doorbell wrapper fields must be written by the host as
139221167Sgnn * part of a doorbell write. Consumed by the adapter but is never written by the
140221167Sgnn * adapter.
141221167Sgnn */
142221167Sgnntypedef	__vxge_os_attr_cacheline_aligned
143221167Sgnnstruct __hal_offload_atomic_db_wrapper_t {
144221167Sgnn	u64		control_0;
145221167Sgnn#define	VXGE_HAL_ODBW_GET_TYPE(ctrl0)			bVAL8(ctrl0, 0)
146221167Sgnn#define	VXGE_HAL_ODBW_TYPE(val)				vBIT(val, 0, 8)
147221167Sgnn#define	VXGE_HAL_ODBW_TYPE_ATOMIC			2
148221167Sgnn
149221167Sgnn#define	VXGE_HAL_ODBW_GET_SESSION_NUMBER(ctrl0)		bVAL24(ctrl0, 8)
150221167Sgnn#define	VXGE_HAL_ODBW_SESSION_NUMBER(val)		vBIT(val, 8, 24)
151221167Sgnn
152221167Sgnn#define	VXGE_HAL_ODBW_GET_SESSION_INST_NUMBER(ctrl0)	bVAL8(ctrl0, 32)
153221167Sgnn#define	VXGE_HAL_ODBW_SESSION_INST_NUMBER(val)		vBIT(val, 32, 8)
154221167Sgnn
155221167Sgnn#define	VXGE_HAL_ODBW_GET_HIGH_TOWI_NUMBER(ctrl0)	bVAL24(ctrl0, 40)
156221167Sgnn#define	VXGE_HAL_ODBW_HIGH_TOWI_NUMBER(val)		vBIT(val, 40, 24)
157221167Sgnn
158221167Sgnn} __hal_offload_atomic_db_wrapper_t;
159221167Sgnn
160221167Sgnn
161221167Sgnn
162221167Sgnn/*
163221167Sgnn * struct __hal_messaging_db_wrapper_t - Messaging Doorbell Wrapper
164221167Sgnn * @control_0:	Bits 0 to 7 - Doorbell type.
165221167Sgnn *		Bits 8 to 31 - Reserved.
166221167Sgnn *		Bits 32 to 63 - The number of new message bytes made available
167221167Sgnn *		by this doorbell entry.
168221167Sgnn * @control_1:	Bits 0 to 7 - Reserved.
169221167Sgnn *		Bits 8 to 15 - The number of Immediate messaging bytes included
170221167Sgnn *		in this doorbell.
171221167Sgnn *		Bits 16 to 63 - Reserved.
172221167Sgnn *
173221167Sgnn * Created by the host and written to the adapter via PIO to a Kernel Doorbell
174221167Sgnn * FIFO. All message doorbell wrapper fields must be written by the host as
175221167Sgnn * part of a doorbell write. Consumed by the adapter but not written by adapter.
176221167Sgnn */
177221167Sgnntypedef __vxge_os_attr_cacheline_aligned struct __hal_messaging_db_wrapper_t {
178221167Sgnn	u64		control_0;
179221167Sgnn#define	VXGE_HAL_MDBW_GET_TYPE(ctrl0)			bVAL8(ctrl0, 0)
180221167Sgnn#define	VXGE_HAL_MDBW_TYPE(val)				vBIT(val, 0, 8)
181221167Sgnn#define	VXGE_HAL_MDBW_TYPE_MDBW				3
182221167Sgnn
183221167Sgnn#define	VXGE_HAL_MDBW_GET_MESSAGE_BYTE_COUNT(ctrl0)	bVAL32(ctrl0, 32)
184221167Sgnn#define	VXGE_HAL_MDBW_MESSAGE_BYTE_COUNT(val)		vBIT(val, 32, 32)
185221167Sgnn
186221167Sgnn	u64		control_1;
187221167Sgnn#define	VXGE_HAL_MDBW_GET_IMMEDIATE_BYTE_COUNT(ctrl1)	bVAL8(ctrl1, 8)
188221167Sgnn#define	VXGE_HAL_MDBW_IMMEDIATE_BYTE_COUNT(val)		vBIT(val, 8, 8)
189221167Sgnn
190221167Sgnn} __hal_messaging_db_wrapper_t;
191221167Sgnn
192221167Sgnn
193221167Sgnnvoid
194221167Sgnn__hal_non_offload_db_post(vxge_hal_vpath_h vpath_handle,
195221167Sgnn    u64 txdl_ptr,
196221167Sgnn    u32 num_txds,
197221167Sgnn    u32 no_snoop);
198221167Sgnn
199221167Sgnnvoid
200221167Sgnn__hal_rxd_db_post(vxge_hal_vpath_h vpath_handle,
201221167Sgnn    u32 num_bytes);
202221167Sgnn
203221167Sgnnvxge_hal_status_e
204221167Sgnn__hal_non_offload_db_reset(vxge_hal_vpath_h vpath_handle);
205221167Sgnn
206221167Sgnn
207221167Sgnnvoid
208221167Sgnn__hal_message_db_post(vxge_hal_vpath_h vpath_handle,
209221167Sgnn    u32 num_msg_bytes,
210221167Sgnn    u8 *immed_msg,
211221167Sgnn    u32 immed_msg_len);
212221167Sgnn
213221167Sgnnvxge_hal_status_e
214221167Sgnn__hal_message_db_reset(vxge_hal_vpath_h vpath_handle);
215221167Sgnn
216221167Sgnn__EXTERN_END_DECLS
217221167Sgnn
218221167Sgnn#endif	/* VXGE_HAL_DOOR_BELLS_H */
219