1 /****************************************************************************
2 * Copyright 2002-2005: Level 5 Networks Inc.
3 * Copyright 2005-2008: Solarflare Communications Inc,
4 * 9501 Jeronimo Road, Suite 250,
5 * Irvine, CA 92618, USA
7 * Maintained by Solarflare Communications
8 * <linux-xen-drivers@solarflare.com>
9 * <onload-dev@solarflare.com>
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published
13 * by the Free Software Foundation, incorporated herein by reference.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 ****************************************************************************
28 * \brief Falcon specific definitions
32 #ifndef __EF_VI_FALCON_H__
33 #define __EF_VI_FALCON_H__
35 #define EFHW_4K 0x00001000u
36 #define EFHW_8K 0x00002000u
38 /* include the autogenerated register definitions */
40 #include "ef_vi_falcon_core.h"
41 #include "ef_vi_falcon_desc.h"
42 #include "ef_vi_falcon_event.h"
45 /*----------------------------------------------------------------------------
47 * Helpers to turn bit shifts into dword shifts and check that the bit fields
48 * haven't overflown the dword etc. Aim is to preserve consistency with the
49 * autogenerated headers - once stable we could hard code.
51 *---------------------------------------------------------------------------*/
53 /* mask constructors */
54 #define __FALCON_MASK(WIDTH,T) ((((T)1) << (WIDTH)) - 1)
55 #define __EFVI_MASK32(WIDTH) __FALCON_MASK((WIDTH),uint32_t)
56 #define __EFVI_MASK64(WIDTH) __FALCON_MASK((WIDTH),uint64_t)
58 #define __EFVI_FALCON_MASKFIELD32(LBN, WIDTH) ((uint32_t) \
59 (__EFVI_MASK32(WIDTH) << (LBN)))
61 /* constructors for fields which span the first and second dwords */
62 #define __LW(LBN) (32 - LBN)
63 #define LOW(v, LBN, WIDTH) ((uint32_t) \
64 (((v) & __EFVI_MASK64(__LW((LBN)))) << (LBN)))
65 #define HIGH(v, LBN, WIDTH) ((uint32_t)(((v) >> __LW((LBN))) & \
66 __EFVI_MASK64((WIDTH - __LW((LBN))))))
67 /* constructors for fields within the second dword */
68 #define __DW2(LBN) ((LBN) - 32)
70 /* constructors for fields which span the second and third dwords */
71 #define __LW2(LBN) (64 - LBN)
72 #define LOW2(v, LBN, WIDTH) ((uint32_t) \
73 (((v) & __EFVI_MASK64(__LW2((LBN)))) << ((LBN) - 32)))
74 #define HIGH2(v, LBN, WIDTH) ((uint32_t) \
75 (((v) >> __LW2((LBN))) & __EFVI_MASK64((WIDTH - __LW2((LBN))))))
77 /* constructors for fields within the third dword */
78 #define __DW3(LBN) ((LBN) - 64)
81 /* constructors for fields which span the third and fourth dwords */
82 #define __LW3(LBN) (96 - LBN)
83 #define LOW3(v, LBN, WIDTH) ((uint32_t) \
84 (((v) & __EFVI_MASK64(__LW3((LBN)))) << ((LBN) - 64)))
85 #define HIGH3(v, LBN, WIDTH) ((unit32_t) \
86 (((v) >> __LW3((LBN))) & __EFVI_MASK64((WIDTH - __LW3((LBN))))))
88 /* constructors for fields within the fourth dword */
89 #define __DW4(LBN) ((LBN) - 96)
91 /* checks that the autogenerated headers our consistent with our model */
92 #define WIDTHCHCK(a, b) ef_assert((a) == (b))
93 #define RANGECHCK(v, WIDTH) \
94 ef_assert(((uint64_t)(v) & ~(__EFVI_MASK64((WIDTH)))) == 0)
96 /* fields within the first dword */
97 #define DWCHCK(LBN, WIDTH) ef_assert(((LBN) >= 0) &&(((LBN)+(WIDTH)) <= 32))
99 /* fields which span the first and second dwords */
100 #define LWCHK(LBN, WIDTH) ef_assert(WIDTH >= __LW(LBN))
102 /*----------------------------------------------------------------------------
104 * Buffer virtual addresses (4K buffers)
106 *---------------------------------------------------------------------------*/
108 /* Form a buffer virtual address from buffer ID and offset. If the offset
109 ** is larger than the buffer size, then the buffer indexed will be
110 ** calculated appropriately. It is the responsibility of the caller to
111 ** ensure that they have valid buffers programmed at that address.
113 #define EFVI_FALCON_VADDR_4K_S (12)
114 #define EFVI_FALCON_VADDR_M 0xfffff /* post shift mask */
117 #define EFVI_FALCON_BUFFER_4K_ADDR(id,off) \
118 (((id) << EFVI_FALCON_VADDR_4K_S) + (off))
120 #define EFVI_FALCON_BUFFER_4K_PAGE(vaddr) \
121 (((vaddr) >> EFVI_FALCON_VADDR_4K_S) & EFVI_FALCON_VADDR_M)
123 #define EFVI_FALCON_BUFFER_4K_OFF(vaddr) \
124 ((vaddr) & __EFVI_MASK32(EFVI_FALCON_VADDR_4K_S))
127 /*----------------------------------------------------------------------------
131 *---------------------------------------------------------------------------*/
133 #define EFVI_FALCON_CLOCK_ASIC_HZ (125000)
134 #define EFVI_FALCON_CLOCK_FPGA_HZ (62500)
135 #define EFVI_FALCON_CLOCK_HZ EFVI_FALCON_CLOCK_ASIC_HZ
138 /*----------------------------------------------------------------------------
142 *---------------------------------------------------------------------------*/
144 /* Event-Queue Timer granularity - measured in us
145 Given by: 4096 * 3 cycle * clock period */
147 #define EFVI_FALCON_EVQTIMER_PERIOD_US ((4096 * 3 * 1000) / EFVI_FALCON_CLOCK_HZ)
150 #define EFVI_FALCON_TIMER_MODE_DIS 0 /* disabled */
151 #define EFVI_FALCON_TIMER_MODE_RUN 1 /* started counting right away */
152 #define EFVI_FALCON_TIMER_MODE_HOLD 2 /* trigger mode (user queues) */
154 #define EFVI_FALCON_EVQTIMER_HOLD (EFVI_FALCON_TIMER_MODE_HOLD << TIMER_MODE_LBN)
155 #define EFVI_FALCON_EVQTIMER_RUN (EFVI_FALCON_TIMER_MODE_RUN << TIMER_MODE_LBN)
156 #define EFVI_FALCON_EVQTIMER_DISABLE (EFVI_FALCON_TIMER_MODE_DIS << TIMER_MODE_LBN)
159 /* ---- ef_vi_event helpers --- */
161 #define EFVI_FALCON_EVENT_CODE(evp) \
162 ((evp)->u64 & EFVI_FALCON_EVENT_CODE_MASK)
164 #define EFVI_FALCON_EVENT_SW_DATA_MASK 0x0000ffff
166 #define __EFVI_FALCON_OPEN_MASK(WIDTH) ((((uint64_t)1) << (WIDTH)) - 1)
168 #define EFVI_FALCON_EVENT_CODE_MASK \
169 (__EFVI_FALCON_OPEN_MASK(EV_CODE_WIDTH) << EV_CODE_LBN)
172 #endif /* __EF_VI_FALCON_H__ */