summaryrefslogtreecommitdiffstats
path: root/sys/contrib/octeon-sdk/cvmx-hfa.h
blob: 0dd86561416d1709599109d41a65c06200f83fe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
/***********************license start***************
 * Copyright (c) 2011  Cavium Inc. (support@cavium.com). All rights
 * reserved.
 *
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   * Redistributions 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 Cavium Inc. nor the names of
 *     its contributors may be used to endorse or promote products
 *     derived from this software without specific prior written
 *     permission.

 * This Software, including technical data, may be subject to U.S. export  control
 * laws, including the U.S. Export Administration Act and its  associated
 * regulations, and may be subject to export or import  regulations in other
 * countries.

 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
 ***********************license end**************************************/







/**
 * @file
 *
 * Interface to the CN63XX, CN68XX hardware HFA engine.
 *
 * <hr>$Revision: 49448 $<hr>
 */

#ifndef __CVMX_HFA_H__
#define __CVMX_HFA_H__

#ifndef CVMX_BUILD_FOR_LINUX_USER
#include "cvmx-llm.h"
#include "cvmx-wqe.h"
#include "cvmx-fpa.h"
#include "cvmx-bootmem.h"

#ifdef CVMX_BUILD_FOR_LINUX_KERNEL
#include <asm/octeon/cvmx.h>
#include <asm/octeon/cvmx-config.h>

#ifdef CVMX_ENABLE_DFA_FUNCTIONS
/* DFA queue cmd buffers */

#define CVMX_FPA_DFA_POOL                   (4)             /**< DFA command buffers */
#define CVMX_FPA_DFA_POOL_SIZE              (2 * CVMX_CACHE_LINE_SIZE)
#endif 

#else
#include "executive-config.h"
#ifdef CVMX_ENABLE_DFA_FUNCTIONS
#include "cvmx-config.h"
#endif
#endif
#endif

#define ENABLE_DEPRECATED   /* Set to enable the old 18/36 bit names */

#ifdef	__cplusplus
extern "C" {
#endif

#define	CVMX_DFA_ITYPE_MEMLOAD		0x0
#define	CVMX_DFA_ITYPE_CACHELOAD	0x1
#define	CVMX_DFA_ITYPE_GRAPHFREE	0x3
#define	CVMX_DFA_ITYPE_GRAPHWALK	0x4

typedef union {
   uint64_t u64;
   struct {
#ifdef __BIG_ENDIAN_BITFIELD
      uint64_t size:24;
      uint64_t addr:40;
#else
      uint64_t addr:40;
      uint64_t size:24;
#endif
   } s;
} cvmx_dfa_gather_entry_t;

typedef union {
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t f1:3;
        uint64_t unused1:2;
        uint64_t snode:27;
        uint64_t gather_mode:1;
        uint64_t little_endian:1;
        uint64_t store_full:1;
        uint64_t load_through:1;
        uint64_t small:1;
        uint64_t itype:3;
        uint64_t unused0:2;
        uint64_t mbase:22;
#else
        uint64_t mbase:22;
        uint64_t unused0:2;
        uint64_t itype:3;
        uint64_t small:1;
        uint64_t load_through:1;
        uint64_t store_full:1;
        uint64_t little_endian:1;
        uint64_t gather_mode:1;
        uint64_t snode:27;
        uint64_t unused1:2;
        uint64_t f1:3;
#endif
    } walk;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused4:7;
        uint64_t dbase:9;
        uint64_t unused3:2;
        uint64_t cbase:14;
        uint64_t gather_mode:1;
        uint64_t little_endian:1;
        uint64_t store_full:1;
        uint64_t load_through:1;
        uint64_t unused2:1;
        uint64_t itype:3;
        uint64_t unused1:6;
        uint64_t dsize:10;
        uint64_t unused0:2;
        uint64_t pgid:6;
#else
        uint64_t pgid:6;
        uint64_t unused0:2;
        uint64_t dsize:10;
        uint64_t unused1:6;
        uint64_t itype:3;
        uint64_t unused2:1;
        uint64_t load_through:1;
        uint64_t store_full:1;
        uint64_t little_endian:1;
        uint64_t gather_mode:1;
        uint64_t cbase:14;
        uint64_t unused3:2;
        uint64_t dbase:9;
        uint64_t unused4:7;
#endif
    } cload;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused2:32;
        uint64_t gather_mode:1;
        uint64_t little_endian:1;
        uint64_t store_full:1;
        uint64_t load_through:1;
        uint64_t unused1:1;
        uint64_t itype:3;
        uint64_t unused0:2;
        uint64_t mbase:22;
#else
        uint64_t mbase:22;
        uint64_t unused0:2;
        uint64_t itype:3;
        uint64_t unused1:1;
        uint64_t load_through:1;
        uint64_t store_full:1;
        uint64_t little_endian:1;
        uint64_t gather_mode:1;
        uint64_t unused2:32;
#endif
    } mload;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused2:34;
        uint64_t store_full:1;
        uint64_t unused1:2;
        uint64_t itype:3;
        uint64_t unused0:24;
#else
        uint64_t unused0:24;
        uint64_t itype:3;
        uint64_t unused1:2;
        uint64_t store_full:1;
        uint64_t unused2:34;
#endif
    } free;
} cvmx_dfa_word0_t;

typedef union {
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t rmax:16;
        uint64_t f2:8;
        uint64_t rptr:40;
#else
        uint64_t rptr:40;
        uint64_t f2:8;
        uint64_t rmax:16;
#endif
    } walk;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused1:13;
        uint64_t rmax:3;
        uint64_t unused0:8;
        uint64_t rptr:40;
#else
        uint64_t rptr:40;
        uint64_t unused0:8;
        uint64_t rmax:3;
        uint64_t unused1:13;
#endif
    } cload;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused1:4;
        uint64_t rmax:12;
        uint64_t unused0:8;
        uint64_t rptr:40;
#else
        uint64_t rptr:40;
        uint64_t unused0:8;
        uint64_t rmax:12;
        uint64_t unused1:4;
#endif
    } mload;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused:24;
        uint64_t rptr:40;
#else
        uint64_t rptr:40;
        uint64_t unused:24;
#endif
    } free;
} cvmx_dfa_word1_t;

typedef union {
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t dlen:16;
		uint64_t srepl:2;
        uint64_t unused:2;
        uint64_t clmsk:4;
        uint64_t dptr:40;
#else
        uint64_t dptr:40;
        uint64_t clmsk:4;
        uint64_t unused:2;
		uint64_t srepl:2;
        uint64_t dlen:16;
#endif
    } walk;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t dlen:16;
        uint64_t unused:4;
        uint64_t clmsk:4;
        uint64_t dptr:40;
#else
        uint64_t dptr:40;
        uint64_t clmsk:4;
        uint64_t unused:4;
        uint64_t dlen:16;
#endif
    } cload;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t dlen:16;
        uint64_t repl:2;
        uint64_t unused:2;
        uint64_t clmsk:4;
        uint64_t dptr:40;
#else
        uint64_t dptr:40;
        uint64_t clmsk:4;
        uint64_t unused:2;
        uint64_t repl:2;
        uint64_t dlen:16;
#endif
    } mload;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused1:20;
        uint64_t clmsk:4;
        uint64_t unused0:40;
#else
        uint64_t unused0:40;
        uint64_t clmsk:4;
        uint64_t unused1:20;
#endif
    } free;
} cvmx_dfa_word2_t;

typedef union {
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused1:2;
        uint64_t vgid:8;
        uint64_t unused0:5;
        uint64_t f3:9;
        uint64_t wqptr:40;
#else
        uint64_t wqptr:40;
        uint64_t f3:9;
        uint64_t unused0:5;
        uint64_t vgid:8;
        uint64_t unused1:2;
#endif
    } walk;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused1:2;
        uint64_t vgid:8;
        uint64_t unused0:7;
        uint64_t f4:7;
        uint64_t wqptr:40;
#else
        uint64_t wqptr:40;
        uint64_t f4:7;
        uint64_t unused0:7;
        uint64_t vgid:8;
        uint64_t unused1:2;
#endif
    } cload;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused1:2;
        uint64_t vgid:8;
        uint64_t unused0:7;
        uint64_t f4:7;
        uint64_t wqptr:40;
#else
        uint64_t wqptr:40;
        uint64_t f4:7;
        uint64_t unused0:7;
        uint64_t vgid:8;
        uint64_t unused1:2;
#endif
    } mload;
    struct {
#ifdef __BIG_ENDIAN_BITFIELD
        uint64_t unused1:2;
        uint64_t vgid:8;
        uint64_t unused0:14;
        uint64_t wqptr:40;
#else
        uint64_t wqptr:40;
        uint64_t unused0:14;
        uint64_t vgid:8;
        uint64_t unused1:2;
#endif
    } free;
} cvmx_dfa_word3_t;

typedef union {
    uint64_t u64[4];
    struct {
        cvmx_dfa_word0_t word0;
        cvmx_dfa_word1_t word1;
        cvmx_dfa_word2_t word2;
        cvmx_dfa_word3_t word3;
    };
} cvmx_dfa_command_t;

#ifdef CVMX_ENABLE_DFA_FUNCTIONS
/**
 * Initialize the DFA hardware before use
 * Returns 0 on success, -1 on failure
 */
int cvmx_hfa_initialize(void);


/**
 * Shutdown and cleanup resources used by the DFA
 */
int cvmx_hfa_shutdown(void);

/**
 * Submit a command to the HFA block
 *
 * @param command HFA command to submit
 *
 * @return Zero on success, negative on failure
 */
int cvmx_hfa_submit(cvmx_dfa_command_t *command);

/**
 * Allocate a block of memory from the free list that was passed
 * to the application by the bootloader.
 * 
 * @param size      Size in bytes of block to allocate
 * @param alignment Alignment required - must be power of 2
 *
 *  @return pointer to block of memory, NULL on error 
 */

void *hfa_bootmem_alloc (uint64_t size, uint64_t alignment);

/**
 * Frees a block to the bootmem allocator list.  
 *
 * @param ptr  	   address of block  (memory pointer (void*))
 * @param size     size of block in bytes.
 *
 * @return 1 on success,
 *         0 on failure
 *
 */

int  hfa_bootmem_free (void *ptr, uint64_t size);

#endif

#ifdef	__cplusplus
}
#endif

#endif /* __CVMX_HFA_H__ */
OpenPOWER on IntegriCloud