]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - sys/contrib/octeon-sdk/cvmx-hfa.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / sys / contrib / octeon-sdk / cvmx-hfa.h
1 /***********************license start***************
2  * Copyright (c) 2011  Cavium Inc. (support@cavium.com). All rights
3  * reserved.
4  *
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  *   * Redistributions of source code must retain the above copyright
11  *     notice, this list of conditions and the following disclaimer.
12  *
13  *   * Redistributions in binary form must reproduce the above
14  *     copyright notice, this list of conditions and the following
15  *     disclaimer in the documentation and/or other materials provided
16  *     with the distribution.
17
18  *   * Neither the name of Cavium Inc. nor the names of
19  *     its contributors may be used to endorse or promote products
20  *     derived from this software without specific prior written
21  *     permission.
22
23  * This Software, including technical data, may be subject to U.S. export  control
24  * laws, including the U.S. Export Administration Act and its  associated
25  * regulations, and may be subject to export or import  regulations in other
26  * countries.
27
28  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29  * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30  * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31  * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32  * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33  * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34  * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35  * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36  * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
37  * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38  ***********************license end**************************************/
39
40
41
42
43
44
45
46 /**
47  * @file
48  *
49  * Interface to the CN63XX, CN68XX hardware HFA engine.
50  *
51  * <hr>$Revision: 49448 $<hr>
52  */
53
54 #ifndef __CVMX_HFA_H__
55 #define __CVMX_HFA_H__
56
57 #ifndef CVMX_BUILD_FOR_LINUX_USER
58 #include "cvmx-llm.h"
59 #include "cvmx-wqe.h"
60 #include "cvmx-fpa.h"
61 #include "cvmx-bootmem.h"
62
63 #ifdef CVMX_BUILD_FOR_LINUX_KERNEL
64 #include <asm/octeon/cvmx.h>
65 #include <asm/octeon/cvmx-config.h>
66
67 #ifdef CVMX_ENABLE_DFA_FUNCTIONS
68 /* DFA queue cmd buffers */
69
70 #define CVMX_FPA_DFA_POOL                   (4)             /**< DFA command buffers */
71 #define CVMX_FPA_DFA_POOL_SIZE              (2 * CVMX_CACHE_LINE_SIZE)
72 #endif 
73
74 #else
75 #include "executive-config.h"
76 #ifdef CVMX_ENABLE_DFA_FUNCTIONS
77 #include "cvmx-config.h"
78 #endif
79 #endif
80 #endif
81
82 #define ENABLE_DEPRECATED   /* Set to enable the old 18/36 bit names */
83
84 #ifdef  __cplusplus
85 extern "C" {
86 #endif
87
88 #define CVMX_DFA_ITYPE_MEMLOAD          0x0
89 #define CVMX_DFA_ITYPE_CACHELOAD        0x1
90 #define CVMX_DFA_ITYPE_GRAPHFREE        0x3
91 #define CVMX_DFA_ITYPE_GRAPHWALK        0x4
92
93 typedef union {
94    uint64_t u64;
95    struct {
96 #ifdef __BIG_ENDIAN_BITFIELD
97       uint64_t size:24;
98       uint64_t addr:40;
99 #else
100       uint64_t addr:40;
101       uint64_t size:24;
102 #endif
103    } s;
104 } cvmx_dfa_gather_entry_t;
105
106 typedef union {
107     struct {
108 #ifdef __BIG_ENDIAN_BITFIELD
109         uint64_t f1:3;
110         uint64_t unused1:2;
111         uint64_t snode:27;
112         uint64_t gather_mode:1;
113         uint64_t little_endian:1;
114         uint64_t store_full:1;
115         uint64_t load_through:1;
116         uint64_t small:1;
117         uint64_t itype:3;
118         uint64_t unused0:2;
119         uint64_t mbase:22;
120 #else
121         uint64_t mbase:22;
122         uint64_t unused0:2;
123         uint64_t itype:3;
124         uint64_t small:1;
125         uint64_t load_through:1;
126         uint64_t store_full:1;
127         uint64_t little_endian:1;
128         uint64_t gather_mode:1;
129         uint64_t snode:27;
130         uint64_t unused1:2;
131         uint64_t f1:3;
132 #endif
133     } walk;
134     struct {
135 #ifdef __BIG_ENDIAN_BITFIELD
136         uint64_t unused4:7;
137         uint64_t dbase:9;
138         uint64_t unused3:2;
139         uint64_t cbase:14;
140         uint64_t gather_mode:1;
141         uint64_t little_endian:1;
142         uint64_t store_full:1;
143         uint64_t load_through:1;
144         uint64_t unused2:1;
145         uint64_t itype:3;
146         uint64_t unused1:6;
147         uint64_t dsize:10;
148         uint64_t unused0:2;
149         uint64_t pgid:6;
150 #else
151         uint64_t pgid:6;
152         uint64_t unused0:2;
153         uint64_t dsize:10;
154         uint64_t unused1:6;
155         uint64_t itype:3;
156         uint64_t unused2:1;
157         uint64_t load_through:1;
158         uint64_t store_full:1;
159         uint64_t little_endian:1;
160         uint64_t gather_mode:1;
161         uint64_t cbase:14;
162         uint64_t unused3:2;
163         uint64_t dbase:9;
164         uint64_t unused4:7;
165 #endif
166     } cload;
167     struct {
168 #ifdef __BIG_ENDIAN_BITFIELD
169         uint64_t unused2:32;
170         uint64_t gather_mode:1;
171         uint64_t little_endian:1;
172         uint64_t store_full:1;
173         uint64_t load_through:1;
174         uint64_t unused1:1;
175         uint64_t itype:3;
176         uint64_t unused0:2;
177         uint64_t mbase:22;
178 #else
179         uint64_t mbase:22;
180         uint64_t unused0:2;
181         uint64_t itype:3;
182         uint64_t unused1:1;
183         uint64_t load_through:1;
184         uint64_t store_full:1;
185         uint64_t little_endian:1;
186         uint64_t gather_mode:1;
187         uint64_t unused2:32;
188 #endif
189     } mload;
190     struct {
191 #ifdef __BIG_ENDIAN_BITFIELD
192         uint64_t unused2:34;
193         uint64_t store_full:1;
194         uint64_t unused1:2;
195         uint64_t itype:3;
196         uint64_t unused0:24;
197 #else
198         uint64_t unused0:24;
199         uint64_t itype:3;
200         uint64_t unused1:2;
201         uint64_t store_full:1;
202         uint64_t unused2:34;
203 #endif
204     } free;
205 } cvmx_dfa_word0_t;
206
207 typedef union {
208     struct {
209 #ifdef __BIG_ENDIAN_BITFIELD
210         uint64_t rmax:16;
211         uint64_t f2:8;
212         uint64_t rptr:40;
213 #else
214         uint64_t rptr:40;
215         uint64_t f2:8;
216         uint64_t rmax:16;
217 #endif
218     } walk;
219     struct {
220 #ifdef __BIG_ENDIAN_BITFIELD
221         uint64_t unused1:13;
222         uint64_t rmax:3;
223         uint64_t unused0:8;
224         uint64_t rptr:40;
225 #else
226         uint64_t rptr:40;
227         uint64_t unused0:8;
228         uint64_t rmax:3;
229         uint64_t unused1:13;
230 #endif
231     } cload;
232     struct {
233 #ifdef __BIG_ENDIAN_BITFIELD
234         uint64_t unused1:4;
235         uint64_t rmax:12;
236         uint64_t unused0:8;
237         uint64_t rptr:40;
238 #else
239         uint64_t rptr:40;
240         uint64_t unused0:8;
241         uint64_t rmax:12;
242         uint64_t unused1:4;
243 #endif
244     } mload;
245     struct {
246 #ifdef __BIG_ENDIAN_BITFIELD
247         uint64_t unused:24;
248         uint64_t rptr:40;
249 #else
250         uint64_t rptr:40;
251         uint64_t unused:24;
252 #endif
253     } free;
254 } cvmx_dfa_word1_t;
255
256 typedef union {
257     struct {
258 #ifdef __BIG_ENDIAN_BITFIELD
259         uint64_t dlen:16;
260                 uint64_t srepl:2;
261         uint64_t unused:2;
262         uint64_t clmsk:4;
263         uint64_t dptr:40;
264 #else
265         uint64_t dptr:40;
266         uint64_t clmsk:4;
267         uint64_t unused:2;
268                 uint64_t srepl:2;
269         uint64_t dlen:16;
270 #endif
271     } walk;
272     struct {
273 #ifdef __BIG_ENDIAN_BITFIELD
274         uint64_t dlen:16;
275         uint64_t unused:4;
276         uint64_t clmsk:4;
277         uint64_t dptr:40;
278 #else
279         uint64_t dptr:40;
280         uint64_t clmsk:4;
281         uint64_t unused:4;
282         uint64_t dlen:16;
283 #endif
284     } cload;
285     struct {
286 #ifdef __BIG_ENDIAN_BITFIELD
287         uint64_t dlen:16;
288         uint64_t repl:2;
289         uint64_t unused:2;
290         uint64_t clmsk:4;
291         uint64_t dptr:40;
292 #else
293         uint64_t dptr:40;
294         uint64_t clmsk:4;
295         uint64_t unused:2;
296         uint64_t repl:2;
297         uint64_t dlen:16;
298 #endif
299     } mload;
300     struct {
301 #ifdef __BIG_ENDIAN_BITFIELD
302         uint64_t unused1:20;
303         uint64_t clmsk:4;
304         uint64_t unused0:40;
305 #else
306         uint64_t unused0:40;
307         uint64_t clmsk:4;
308         uint64_t unused1:20;
309 #endif
310     } free;
311 } cvmx_dfa_word2_t;
312
313 typedef union {
314     struct {
315 #ifdef __BIG_ENDIAN_BITFIELD
316         uint64_t unused1:2;
317         uint64_t vgid:8;
318         uint64_t unused0:5;
319         uint64_t f3:9;
320         uint64_t wqptr:40;
321 #else
322         uint64_t wqptr:40;
323         uint64_t f3:9;
324         uint64_t unused0:5;
325         uint64_t vgid:8;
326         uint64_t unused1:2;
327 #endif
328     } walk;
329     struct {
330 #ifdef __BIG_ENDIAN_BITFIELD
331         uint64_t unused1:2;
332         uint64_t vgid:8;
333         uint64_t unused0:7;
334         uint64_t f4:7;
335         uint64_t wqptr:40;
336 #else
337         uint64_t wqptr:40;
338         uint64_t f4:7;
339         uint64_t unused0:7;
340         uint64_t vgid:8;
341         uint64_t unused1:2;
342 #endif
343     } cload;
344     struct {
345 #ifdef __BIG_ENDIAN_BITFIELD
346         uint64_t unused1:2;
347         uint64_t vgid:8;
348         uint64_t unused0:7;
349         uint64_t f4:7;
350         uint64_t wqptr:40;
351 #else
352         uint64_t wqptr:40;
353         uint64_t f4:7;
354         uint64_t unused0:7;
355         uint64_t vgid:8;
356         uint64_t unused1:2;
357 #endif
358     } mload;
359     struct {
360 #ifdef __BIG_ENDIAN_BITFIELD
361         uint64_t unused1:2;
362         uint64_t vgid:8;
363         uint64_t unused0:14;
364         uint64_t wqptr:40;
365 #else
366         uint64_t wqptr:40;
367         uint64_t unused0:14;
368         uint64_t vgid:8;
369         uint64_t unused1:2;
370 #endif
371     } free;
372 } cvmx_dfa_word3_t;
373
374 typedef union {
375     uint64_t u64[4];
376     struct {
377         cvmx_dfa_word0_t word0;
378         cvmx_dfa_word1_t word1;
379         cvmx_dfa_word2_t word2;
380         cvmx_dfa_word3_t word3;
381     };
382 } cvmx_dfa_command_t;
383
384 #ifdef CVMX_ENABLE_DFA_FUNCTIONS
385 /**
386  * Initialize the DFA hardware before use
387  * Returns 0 on success, -1 on failure
388  */
389 int cvmx_hfa_initialize(void);
390
391
392 /**
393  * Shutdown and cleanup resources used by the DFA
394  */
395 int cvmx_hfa_shutdown(void);
396
397 /**
398  * Submit a command to the HFA block
399  *
400  * @param command HFA command to submit
401  *
402  * @return Zero on success, negative on failure
403  */
404 int cvmx_hfa_submit(cvmx_dfa_command_t *command);
405
406 /**
407  * Allocate a block of memory from the free list that was passed
408  * to the application by the bootloader.
409  * 
410  * @param size      Size in bytes of block to allocate
411  * @param alignment Alignment required - must be power of 2
412  *
413  *  @return pointer to block of memory, NULL on error 
414  */
415
416 void *hfa_bootmem_alloc (uint64_t size, uint64_t alignment);
417
418 /**
419  * Frees a block to the bootmem allocator list.  
420  *
421  * @param ptr      address of block  (memory pointer (void*))
422  * @param size     size of block in bytes.
423  *
424  * @return 1 on success,
425  *         0 on failure
426  *
427  */
428
429 int  hfa_bootmem_free (void *ptr, uint64_t size);
430
431 #endif
432
433 #ifdef  __cplusplus
434 }
435 #endif
436
437 #endif /* __CVMX_HFA_H__ */