cvmx-hfa.h revision 259065
11590Srgrimes/***********************license start*************** 2168417Syar * Copyright (c) 2011 Cavium Inc. (support@cavium.com). All rights 31590Srgrimes * reserved. 41590Srgrimes * 51590Srgrimes * 61590Srgrimes * Redistribution and use in source and binary forms, with or without 71590Srgrimes * modification, are permitted provided that the following conditions are 81590Srgrimes * met: 91590Srgrimes * 101590Srgrimes * * Redistributions of source code must retain the above copyright 111590Srgrimes * notice, this list of conditions and the following disclaimer. 121590Srgrimes * 131590Srgrimes * * Redistributions in binary form must reproduce the above 141590Srgrimes * copyright notice, this list of conditions and the following 151590Srgrimes * disclaimer in the documentation and/or other materials provided 161590Srgrimes * with the distribution. 171590Srgrimes 181590Srgrimes * * Neither the name of Cavium Inc. nor the names of 191590Srgrimes * its contributors may be used to endorse or promote products 201590Srgrimes * derived from this software without specific prior written 211590Srgrimes * permission. 221590Srgrimes 231590Srgrimes * This Software, including technical data, may be subject to U.S. export control 241590Srgrimes * laws, including the U.S. Export Administration Act and its associated 251590Srgrimes * regulations, and may be subject to export or import regulations in other 261590Srgrimes * countries. 271590Srgrimes 281590Srgrimes * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" 291590Srgrimes * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR 301590Srgrimes * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO 311590Srgrimes * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR 321590Srgrimes * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM 331590Srgrimes * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE, 341590Srgrimes * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF 351590Srgrimes * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR 361590Srgrimes * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR 371590Srgrimes * PERFORMANCE OF THE SOFTWARE LIES WITH YOU. 381590Srgrimes ***********************license end**************************************/ 391590Srgrimes 401590Srgrimes 411590Srgrimes 421590Srgrimes 431590Srgrimes 441590Srgrimes 451590Srgrimes 461590Srgrimes/** 471590Srgrimes * @file 481590Srgrimes * 491590Srgrimes * Interface to the CN63XX, CN68XX hardware HFA engine. 501590Srgrimes * 511590Srgrimes * <hr>$Revision: 49448 $<hr> 521590Srgrimes */ 531590Srgrimes 541590Srgrimes#ifndef __CVMX_HFA_H__ 551590Srgrimes#define __CVMX_HFA_H__ 561590Srgrimes 571590Srgrimes#ifndef CVMX_BUILD_FOR_LINUX_USER 581590Srgrimes#include "cvmx-llm.h" 591590Srgrimes#include "cvmx-wqe.h" 601590Srgrimes#include "cvmx-fpa.h" 611590Srgrimes#include "cvmx-bootmem.h" 621590Srgrimes 631590Srgrimes#ifdef CVMX_BUILD_FOR_LINUX_KERNEL 641590Srgrimes#include <asm/octeon/cvmx.h> 651590Srgrimes#include <asm/octeon/cvmx-config.h> 661590Srgrimes 671590Srgrimes#ifdef CVMX_ENABLE_DFA_FUNCTIONS 681590Srgrimes/* DFA queue cmd buffers */ 691590Srgrimes 701590Srgrimes#define CVMX_FPA_DFA_POOL (4) /**< DFA command buffers */ 711590Srgrimes#define CVMX_FPA_DFA_POOL_SIZE (2 * CVMX_CACHE_LINE_SIZE) 721590Srgrimes#endif 731590Srgrimes 741590Srgrimes#else 751590Srgrimes#include "executive-config.h" 761590Srgrimes#ifdef CVMX_ENABLE_DFA_FUNCTIONS 771590Srgrimes#include "cvmx-config.h" 781590Srgrimes#endif 791590Srgrimes#endif 801590Srgrimes#endif 811590Srgrimes 821590Srgrimes#define ENABLE_DEPRECATED /* Set to enable the old 18/36 bit names */ 831590Srgrimes 841590Srgrimes#ifdef __cplusplus 851590Srgrimesextern "C" { 861590Srgrimes#endif 871590Srgrimes 881590Srgrimes#define CVMX_DFA_ITYPE_MEMLOAD 0x0 891590Srgrimes#define CVMX_DFA_ITYPE_CACHELOAD 0x1 901590Srgrimes#define CVMX_DFA_ITYPE_GRAPHFREE 0x3 911590Srgrimes#define CVMX_DFA_ITYPE_GRAPHWALK 0x4 921590Srgrimes 931590Srgrimestypedef union { 941590Srgrimes uint64_t u64; 951590Srgrimes struct { 961590Srgrimes#ifdef __BIG_ENDIAN_BITFIELD 971590Srgrimes uint64_t size:24; 981590Srgrimes uint64_t addr:40; 991590Srgrimes#else 1001590Srgrimes uint64_t addr:40; 1011590Srgrimes uint64_t size:24; 1021590Srgrimes#endif 1031590Srgrimes } s; 1041590Srgrimes} cvmx_dfa_gather_entry_t; 1051590Srgrimes 1061590Srgrimestypedef union { 1071590Srgrimes struct { 1081590Srgrimes#ifdef __BIG_ENDIAN_BITFIELD 1091590Srgrimes uint64_t f1:3; 1101590Srgrimes uint64_t unused1:2; 1111590Srgrimes uint64_t snode:27; 1121590Srgrimes uint64_t gather_mode:1; 1131590Srgrimes uint64_t little_endian:1; 1141590Srgrimes uint64_t store_full:1; 1151590Srgrimes uint64_t load_through:1; 1161590Srgrimes uint64_t small:1; 1171590Srgrimes uint64_t itype:3; 1181590Srgrimes uint64_t unused0:2; 1191590Srgrimes uint64_t mbase:22; 1201590Srgrimes#else 121168386Syar uint64_t mbase:22; 122168386Syar uint64_t unused0:2; 123168386Syar uint64_t itype:3; 124168386Syar uint64_t small:1; 125168386Syar uint64_t load_through:1; 126168386Syar uint64_t store_full:1; 127168389Syar uint64_t little_endian:1; 128168389Syar uint64_t gather_mode:1; 129168389Syar uint64_t snode:27; 1301590Srgrimes uint64_t unused1:2; 1311590Srgrimes uint64_t f1:3; 1321590Srgrimes#endif 1331590Srgrimes } walk; 1341590Srgrimes struct { 1351590Srgrimes#ifdef __BIG_ENDIAN_BITFIELD 1361590Srgrimes uint64_t unused4:7; 1371590Srgrimes uint64_t dbase:9; 1381590Srgrimes uint64_t unused3:2; 1391590Srgrimes uint64_t cbase:14; 1401590Srgrimes uint64_t gather_mode:1; 1411590Srgrimes uint64_t little_endian:1; 1421590Srgrimes uint64_t store_full:1; 1431590Srgrimes uint64_t load_through:1; 1441590Srgrimes uint64_t unused2:1; 1451590Srgrimes uint64_t itype:3; 1461590Srgrimes uint64_t unused1:6; 1471590Srgrimes uint64_t dsize:10; 1481590Srgrimes uint64_t unused0:2; 1491590Srgrimes uint64_t pgid:6; 1501590Srgrimes#else 1511590Srgrimes uint64_t pgid:6; 1521590Srgrimes uint64_t unused0:2; 1531590Srgrimes uint64_t dsize:10; 1541590Srgrimes uint64_t unused1:6; 1551590Srgrimes uint64_t itype:3; 1561590Srgrimes uint64_t unused2:1; 1571590Srgrimes uint64_t load_through:1; 1581590Srgrimes uint64_t store_full:1; 1591590Srgrimes uint64_t little_endian:1; 1601590Srgrimes uint64_t gather_mode:1; 1611590Srgrimes uint64_t cbase:14; 1621590Srgrimes uint64_t unused3:2; 1631590Srgrimes uint64_t dbase:9; 1641590Srgrimes uint64_t unused4:7; 1651590Srgrimes#endif 1661590Srgrimes } cload; 1671590Srgrimes struct { 1681590Srgrimes#ifdef __BIG_ENDIAN_BITFIELD 1691590Srgrimes uint64_t unused2:32; 1701590Srgrimes uint64_t gather_mode:1; 1711590Srgrimes uint64_t little_endian:1; 1721590Srgrimes uint64_t store_full:1; 1731590Srgrimes uint64_t load_through:1; 1741590Srgrimes uint64_t unused1:1; 1751590Srgrimes uint64_t itype:3; 1761590Srgrimes uint64_t unused0:2; 1771590Srgrimes uint64_t mbase:22; 1781590Srgrimes#else 1791590Srgrimes uint64_t mbase:22; 1801590Srgrimes uint64_t unused0:2; 1811590Srgrimes uint64_t itype:3; 1821590Srgrimes uint64_t unused1:1; 1831590Srgrimes uint64_t load_through:1; 1841590Srgrimes uint64_t store_full:1; 1851590Srgrimes uint64_t little_endian:1; 1861590Srgrimes uint64_t gather_mode:1; 1871590Srgrimes uint64_t unused2:32; 1881590Srgrimes#endif 1891590Srgrimes } mload; 1901590Srgrimes struct { 1911590Srgrimes#ifdef __BIG_ENDIAN_BITFIELD 1921590Srgrimes uint64_t unused2:34; 1931590Srgrimes uint64_t store_full:1; 1941590Srgrimes uint64_t unused1:2; 1951590Srgrimes uint64_t itype:3; 1961590Srgrimes uint64_t unused0:24; 1971590Srgrimes#else 1981590Srgrimes uint64_t unused0:24; 1991590Srgrimes uint64_t itype:3; 2001590Srgrimes uint64_t unused1:2; 2011590Srgrimes uint64_t store_full:1; 2021590Srgrimes uint64_t unused2:34; 2031590Srgrimes#endif 2041590Srgrimes } free; 205} cvmx_dfa_word0_t; 206 207typedef 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 256typedef 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 313typedef 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 374typedef 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 */ 389int cvmx_hfa_initialize(void); 390 391 392/** 393 * Shutdown and cleanup resources used by the DFA 394 */ 395int 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 */ 404int 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 416void *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 429int hfa_bootmem_free (void *ptr, uint64_t size); 430 431#endif 432 433#ifdef __cplusplus 434} 435#endif 436 437#endif /* __CVMX_HFA_H__ */ 438