From 7d48ac5c7dfb52fc470bbad1013b4d460bc6a1e0 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Fri, 9 Mar 2018 14:30:38 -0800 Subject: soc/cavium: Integrate BDK files into coreboot * Make it compile. * Fix whitespace errors. * Fix printf formats. * Add missing headers includes * Guard headers with ifdefs Compile DRAM init code in romstage. Compile QLM, PCIe, RNG, PHY, GPIO, MDIO init code in ramstage. Change-Id: I0a93219a14bfb6ebe41103a825d5032b11e7f2c6 Signed-off-by: David Hendricks Reviewed-on: https://review.coreboot.org/25089 Reviewed-by: Philipp Deppenwiese Tested-by: build bot (Jenkins) --- .../include/bdk/libbdk-hal/bdk-access-native.h | 155 ---------- .../cavium/include/bdk/libbdk-hal/bdk-access.h | 81 +---- .../cavium/include/bdk/libbdk-hal/bdk-atomic.h | 74 +---- .../cavium/include/bdk/libbdk-hal/bdk-clock.h | 38 ++- .../cavium/include/bdk/libbdk-hal/bdk-config.h | 154 +++------- .../cavium/include/bdk/libbdk-hal/bdk-crc.h | 53 ---- .../cavium/include/bdk/libbdk-hal/bdk-ecam.h | 2 + .../include/bdk/libbdk-hal/bdk-error-report.h | 62 ---- .../cavium/include/bdk/libbdk-hal/bdk-fpa.h | 162 ---------- .../cavium/include/bdk/libbdk-hal/bdk-gpio.h | 3 + .../cavium/include/bdk/libbdk-hal/bdk-hal.h | 98 ------- .../cavium/include/bdk/libbdk-hal/bdk-key.h | 86 ------ .../cavium/include/bdk/libbdk-hal/bdk-l2c.h | 6 + .../cavium/include/bdk/libbdk-hal/bdk-mdio.h | 5 + .../cavium/include/bdk/libbdk-hal/bdk-mmc.h | 89 ------ .../cavium/include/bdk/libbdk-hal/bdk-mpi.h | 105 ------- .../cavium/include/bdk/libbdk-hal/bdk-nix.h | 105 ------- .../cavium/include/bdk/libbdk-hal/bdk-pbus-flash.h | 111 ------- .../cavium/include/bdk/libbdk-hal/bdk-pcie-flash.h | 109 ------- .../cavium/include/bdk/libbdk-hal/bdk-pcie.h | 36 ++- .../cavium/include/bdk/libbdk-hal/bdk-pki.h | 83 ------ .../cavium/include/bdk/libbdk-hal/bdk-pko.h | 126 -------- .../cavium/include/bdk/libbdk-hal/bdk-power-burn.h | 67 ----- .../cavium/include/bdk/libbdk-hal/bdk-qlm.h | 66 ++--- .../cavium/include/bdk/libbdk-hal/bdk-rng.h | 5 + .../cavium/include/bdk/libbdk-hal/bdk-rvu.h | 3 + .../cavium/include/bdk/libbdk-hal/bdk-spinlock.h | 3 + .../cavium/include/bdk/libbdk-hal/bdk-sso.h | 69 ----- .../cavium/include/bdk/libbdk-hal/bdk-tns.h | 109 ------- .../cavium/include/bdk/libbdk-hal/bdk-twsi.h | 14 +- .../cavium/include/bdk/libbdk-hal/bdk-usb.h | 9 +- .../cavium/include/bdk/libbdk-hal/bdk-utils.h | 5 +- .../cavium/include/bdk/libbdk-hal/bdk-vrm.h | 3 + .../include/bdk/libbdk-hal/device/bdk-device.h | 8 +- .../cavium/include/bdk/libbdk-hal/if/bdk-if.h | 326 +++++++++++++++++++++ .../include/bdk/libbdk-hal/qlm/bdk-qlm-common.h | 326 +++++++++++++++++++++ .../bdk/libbdk-hal/qlm/bdk-qlm-errata-cn8xxx.h | 152 ++++++++++ 37 files changed, 979 insertions(+), 1929 deletions(-) delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-access-native.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-crc.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-error-report.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-fpa.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-hal.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-key.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mmc.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mpi.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-nix.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pbus-flash.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pcie-flash.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pki.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pko.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-power-burn.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-sso.h delete mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-tns.h create mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/if/bdk-if.h create mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/qlm/bdk-qlm-common.h create mode 100644 src/vendorcode/cavium/include/bdk/libbdk-hal/qlm/bdk-qlm-errata-cn8xxx.h (limited to 'src/vendorcode/cavium/include/bdk/libbdk-hal') diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-access-native.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-access-native.h deleted file mode 100644 index aa9d87bf37..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-access-native.h +++ /dev/null @@ -1,155 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 - * Functions for accessing memory and CSRs when we are compiling - * natively. - * - *
$Revision: 38306 $
-*/ - -/** - * Convert a memory pointer (void*) into a hardware compatible - * memory address (uint64_t). Cavium hardware widgets don't - * understand logical addresses. - * - * @param ptr C style memory pointer - * @return Hardware physical address - */ -static inline uint64_t bdk_ptr_to_phys(void *ptr) __attribute__ ((pure, always_inline)); -static inline uint64_t bdk_ptr_to_phys(void *ptr) -{ - bdk_warn_if(!ptr, "bdk_ptr_to_phys() passed a NULL\n"); - return (long)ptr; -} - - -/** - * Convert a hardware physical address (uint64_t) into a - * memory pointer (void *). - * - * @param physical_address - * Hardware physical address to memory - * @return Pointer to memory - */ -static inline void *bdk_phys_to_ptr(uint64_t physical_address) __attribute__ ((pure, always_inline)); -static inline void *bdk_phys_to_ptr(uint64_t physical_address) -{ - bdk_warn_if(physical_address==0, "bdk_phys_to_ptr() passed a zero address\n"); - return (void*)(long)physical_address; -} - - -/* We have a full 64bit ABI. Writing to a 64bit address can be done with - a simple volatile pointer */ -#define BDK_BUILD_WRITE64(TYPE) \ -static inline void bdk_write64_##TYPE(uint64_t addr, TYPE##_t val) __attribute__ ((always_inline)); \ -static inline void bdk_write64_##TYPE(uint64_t addr, TYPE##_t val) \ -{ \ - *(volatile TYPE##_t *)bdk_phys_to_ptr(addr) = val; \ -} - -/* We have a full 64bit ABI. Writing to a 64bit address can be done with - a simple volatile pointer */ -#define BDK_BUILD_READ64(TYPE) \ -static inline TYPE##_t bdk_read64_##TYPE(uint64_t addr) __attribute__ ((always_inline)); \ -static inline TYPE##_t bdk_read64_##TYPE(uint64_t addr) \ -{ \ - return *(volatile TYPE##_t *)bdk_phys_to_ptr(addr); \ -} - -/* The following defines 8 functions for writing to a 64bit address. Each - takes two arguments, the address and the value to write. - bdk_write64_int64 bdk_write64_uint64 - bdk_write64_int32 bdk_write64_uint32 - bdk_write64_int16 bdk_write64_uint16 - bdk_write64_int8 bdk_write64_uint8 */ -BDK_BUILD_WRITE64(int64) -BDK_BUILD_WRITE64(int32) -BDK_BUILD_WRITE64(int16) -BDK_BUILD_WRITE64(int8) -BDK_BUILD_WRITE64(uint64) -BDK_BUILD_WRITE64(uint32) -BDK_BUILD_WRITE64(uint16) -BDK_BUILD_WRITE64(uint8) - -/* The following defines 8 functions for reading from a 64bit address. Each - takes the address as the only argument - bdk_read64_int64 bdk_read64_uint64 - bdk_read64_int32 bdk_read64_uint32 - bdk_read64_int16 bdk_read64_uint16 - bdk_read64_int8 bdk_read64_uint8 */ -BDK_BUILD_READ64(int64) -BDK_BUILD_READ64(int32) -BDK_BUILD_READ64(int16) -BDK_BUILD_READ64(int8) -BDK_BUILD_READ64(uint64) -BDK_BUILD_READ64(uint32) -BDK_BUILD_READ64(uint16) -BDK_BUILD_READ64(uint8) - - -/** - * Returns the number of bits set in the provided value. - * Simple wrapper for POP instruction. - * - * @param val 32 bit value to count set bits in - * - * @return Number of bits set - */ -static inline uint32_t bdk_pop(uint32_t val) -{ - return __builtin_popcount(val); -} - - -/** - * Returns the number of bits set in the provided value. - * Simple wrapper for DPOP instruction. - * - * @param val 64 bit value to count set bits in - * - * @return Number of bits set - */ -static inline int bdk_dpop(uint64_t val) -{ - return __builtin_popcountl(val); -} - diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-access.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-access.h index d50ecd7e5c..30078d3f8e 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-access.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-access.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_ACCESS_H__ +#define __CB_BDK_ACCESS_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -47,87 +49,14 @@ * @{ */ -#define BDK_FUNCTION static inline - -/** - * Convert a memory pointer (void*) into a hardware compatible - * memory address (uint64_t). Cavium hardware widgets don't - * understand logical addresses. - * - * @param ptr C style memory pointer - * @return Hardware physical address - */ -BDK_FUNCTION uint64_t bdk_ptr_to_phys(void *ptr); - -/** - * Convert a hardware physical address (uint64_t) into a - * memory pointer (void *). - * - * @param physical_address - * Hardware physical address to memory - * @return Pointer to memory - */ -BDK_FUNCTION void *bdk_phys_to_ptr(uint64_t physical_address); - -BDK_FUNCTION void bdk_write64_int64(uint64_t address, int64_t value); -BDK_FUNCTION void bdk_write64_uint64(uint64_t address, uint64_t value); -BDK_FUNCTION void bdk_write64_int32(uint64_t address, int32_t value); -BDK_FUNCTION void bdk_write64_uint32(uint64_t address, uint32_t value); -BDK_FUNCTION void bdk_write64_int16(uint64_t address, int16_t value); -BDK_FUNCTION void bdk_write64_uint16(uint64_t address, uint16_t value); -BDK_FUNCTION void bdk_write64_int8(uint64_t address, int8_t value); -BDK_FUNCTION void bdk_write64_uint8(uint64_t address, uint8_t value); - -BDK_FUNCTION int64_t bdk_read64_int64(uint64_t address); -BDK_FUNCTION uint64_t bdk_read64_uint64(uint64_t address); -BDK_FUNCTION int32_t bdk_read64_int32(uint64_t address); -BDK_FUNCTION uint32_t bdk_read64_uint32(uint64_t address); -BDK_FUNCTION int16_t bdk_read64_int16(uint64_t address); -BDK_FUNCTION uint16_t bdk_read64_uint16(uint64_t address); -BDK_FUNCTION int8_t bdk_read64_int8(uint64_t address); -BDK_FUNCTION uint8_t bdk_read64_uint8(uint64_t address); - -/** - * Returns the number of bits set in the provided value. - * Simple wrapper for POP instruction. - * - * @param val 32 bit value to count set bits in - * - * @return Number of bits set - */ -BDK_FUNCTION uint32_t bdk_pop(uint32_t val); - -/** - * Returns the number of bits set in the provided value. - * Simple wrapper for DPOP instruction. - * - * @param val 64 bit value to count set bits in - * - * @return Number of bits set - */ -BDK_FUNCTION int bdk_dpop(uint64_t val); - -/** - * Wait for the specified number of core clock cycles - * - * @param cycles - */ -extern void bdk_wait(uint64_t cycles); - -/** - * Wait for the specified number of micro seconds - * - * @param usec micro seconds to wait - */ -extern void bdk_wait_usec(uint64_t usec); +#include /** * Perform a soft reset of the chip * * @return */ -extern void bdk_reset_chip(bdk_node_t node); - -#undef BDK_FUNCTION +void bdk_reset_chip(bdk_node_t node); /** @} */ +#endif diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-atomic.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-atomic.h index 7f521a67e2..1b8f7847fd 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-atomic.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-atomic.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_ATOMIC_H__ +#define __CB_BDK_ATOMIC_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -197,26 +199,12 @@ static inline int bdk_atomic_compare_and_store32_nosync(uint32_t *ptr, uint32_t /* CN88XX pass 1.x has errata AP-22500: GlobalSync request during a multi-cycle ATOMIC stalls forever Don't use compare and swap on these chips */ - if (CAVIUM_IS_MODEL(CAVIUM_CN88XX_PASS1_X)) - { - asm volatile ("1: ldxr %w[v], [%[b]] \n" - " cmp %w[v], %w[o] \n" - " b.ne 2f \n" - " stxr %w[v], %w[n], [%[b]]\n" /* Returns zero on success */ - " cbnz %w[v], 1b \n" - " mov %w[v], %w[o] \n" - "2: \n" - : [mem] "+m" (*ptr), [v] "=&r" (val) - : [b] "r" (ptr), [n] "r" (new_val), [o] "r" (old_val) - : ); - } - else - { + asm volatile ("cas %w[o], %w[n], [%[b]]" : [mem] "+m" (*ptr), [o] "+r" (val) : [b] "r" (ptr), [n] "r" (new_val) : ); - } + return old_val == val; } @@ -239,26 +227,12 @@ static inline int bdk_atomic_compare_and_store32(uint32_t *ptr, uint32_t old_val /* CN88XX pass 1.x has errata AP-22500: GlobalSync request during a multi-cycle ATOMIC stalls forever Don't use compare and swap on these chips */ - if (CAVIUM_IS_MODEL(CAVIUM_CN88XX_PASS1_X)) - { - asm volatile ("1: ldaxr %w[v], [%[b]] \n" - " cmp %w[v], %w[o] \n" - " b.ne 2f \n" - " stlxr %w[v], %w[n], [%[b]]\n" /* Returns zero on success */ - " cbnz %w[v], 1b \n" - " mov %w[v], %w[o] \n" - "2: \n" - : [mem] "+m" (*ptr), [v] "=&r" (val) - : [b] "r" (ptr), [n] "r" (new_val), [o] "r" (old_val) - : ); - } - else - { + asm volatile ("casal %w[o], %w[n], [%[b]]" : [mem] "+m" (*ptr), [o] "+r" (val) : [b] "r" (ptr), [n] "r" (new_val) : ); - } + return old_val == val; } @@ -281,26 +255,12 @@ static inline int bdk_atomic_compare_and_store64_nosync(uint64_t *ptr, uint64_t /* CN88XX pass 1.x has errata AP-22500: GlobalSync request during a multi-cycle ATOMIC stalls forever Don't use compare and swap on these chips */ - if (CAVIUM_IS_MODEL(CAVIUM_CN88XX_PASS1_X)) - { - asm volatile ("1: ldxr %x[v], [%[b]] \n" - " cmp %x[v], %x[o] \n" - " b.ne 2f \n" - " stxr %x[v], %x[n], [%[b]]\n" /* Returns zero on success */ - " cbnz %x[v], 1b \n" - " mov %x[v], %x[o] \n" - "2: \n" - : [mem] "+m" (*ptr), [v] "=&r" (val) - : [b] "r" (ptr), [n] "r" (new_val), [o] "r" (old_val) - : ); - } - else - { + asm volatile ("cas %x[o], %x[n], [%[b]]" : [mem] "+m" (*ptr), [o] "+r" (val) : [b] "r" (ptr), [n] "r" (new_val) : ); - } + return old_val == val; } @@ -323,26 +283,11 @@ static inline int bdk_atomic_compare_and_store64(uint64_t *ptr, uint64_t old_val /* CN88XX pass 1.x has errata AP-22500: GlobalSync request during a multi-cycle ATOMIC stalls forever Don't use compare and swap on these chips */ - if (CAVIUM_IS_MODEL(CAVIUM_CN88XX_PASS1_X)) - { - asm volatile ("1: ldaxr %x[v], [%[b]] \n" - " cmp %x[v], %x[o] \n" - " b.ne 2f \n" - " stlxr %x[v], %x[n], [%[b]]\n" /* Returns zero on success */ - " cbnz %x[v], 1b \n" - " mov %x[v], %x[o] \n" - "2: \n" - : [mem] "+m" (*ptr), [v] "=&r" (val) - : [b] "r" (ptr), [n] "r" (new_val), [o] "r" (old_val) - : ); - } - else - { + asm volatile ("casal %x[o], %x[n], [%[b]]" : [mem] "+m" (*ptr), [o] "+r" (val) : [b] "r" (ptr), [n] "r" (new_val) : ); - } return old_val == val; } @@ -539,3 +484,4 @@ static inline uint32_t bdk_atomic_fetch_and_bclr32_nosync(uint32_t *ptr, uint32_ } /** @} */ +#endif /* !__CB_BDK_ATOMIC_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-clock.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-clock.h index d0d117c590..47345bd5a1 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-clock.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-clock.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_CLOCK_H__ +#define __CB_BDK_CLOCK_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -37,6 +39,13 @@ * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. ***********************license end**************************************/ +/* FIXME(dhendrix): added */ +#include +#include +/* FIXME(prudolph): added */ + +#include + /** * @file * @@ -48,7 +57,7 @@ * @{ */ -#define BDK_GTI_RATE 100000000ull +#define BDK_GTI_RATE 1000000ull /** * Enumeration of different Clocks. @@ -60,10 +69,30 @@ typedef enum{ BDK_CLOCK_SCLK, /**< Clock used by IO blocks. */ } bdk_clock_t; +static inline uint64_t clock_get_rate_slow(bdk_clock_t clock) +{ + const uint64_t REF_CLOCK = 50000000; + + switch (clock) { + case BDK_CLOCK_TIME: + return BDK_GTI_RATE; /* Programed as part of setup */ + case BDK_CLOCK_MAIN_REF: + return REF_CLOCK; + case BDK_CLOCK_RCLK: + return thunderx_get_core_clock(); + case BDK_CLOCK_SCLK: + return thunderx_get_io_clock(); + } + return 0; +} + /** * Called in __bdk_init to setup the global timer */ -extern void bdk_clock_setup(); +extern void bdk_clock_setup(bdk_node_t node); /* FIXME(dhendrix): added arg */ + +extern uint64_t __bdk_clock_get_count_slow(bdk_clock_t clock); +extern uint64_t __bdk_clock_get_rate_slow(bdk_node_t node, bdk_clock_t clock); /** * Get cycle count based on the clock type. @@ -74,7 +103,6 @@ extern void bdk_clock_setup(); static inline uint64_t bdk_clock_get_count(bdk_clock_t clock) __attribute__ ((always_inline)); static inline uint64_t bdk_clock_get_count(bdk_clock_t clock) { - extern uint64_t __bdk_clock_get_count_slow(bdk_clock_t clock); if (clock == BDK_CLOCK_TIME) { uint64_t clk; @@ -95,11 +123,11 @@ static inline uint64_t bdk_clock_get_count(bdk_clock_t clock) static inline uint64_t bdk_clock_get_rate(bdk_node_t node, bdk_clock_t clock) __attribute__ ((always_inline, pure)); static inline uint64_t bdk_clock_get_rate(bdk_node_t node, bdk_clock_t clock) { - extern uint64_t __bdk_clock_get_rate_slow(bdk_node_t node, bdk_clock_t clock) __attribute__ ((pure)); if (clock == BDK_CLOCK_TIME) return BDK_GTI_RATE; /* Programed as part of setup */ else - return __bdk_clock_get_rate_slow(node, clock); + return clock_get_rate_slow(clock); } /** @} */ +#endif /* !__CB_BDK_CLOCK_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h index 6848fd687c..9aa1a47251 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-config.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_CONFIG_H__ +#define __CB_BDK_CONFIG_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -37,6 +39,9 @@ * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. ***********************license end**************************************/ +#include +#include + /** * @file * @@ -90,6 +95,7 @@ typedef enum BDK_CONFIG_PCIE_PRESET_REQUEST_VECTOR, /* Parameters: Node, Port */ BDK_CONFIG_PCIE_WIDTH, /* Parameters: Node, Port */ BDK_CONFIG_PCIE_PHYSICAL_SLOT, /* Parameters: Node, Port */ + BDK_CONFIG_PCIE_SKIP_LINK_TRAIN, /* Parameters: Node, Port */ BDK_CONFIG_PCIE_FLASH, /* Parameters: Node, Port */ BDK_CONFIG_CCPI_LANE_REVERSE, /* No parameters */ BDK_CONFIG_CHIP_SKU, /* Parameter: Node */ @@ -200,21 +206,6 @@ typedef enum __BDK_CONFIG_END } bdk_config_t; -/** - * Internal BDK function to initialize the config system. Must be called before - * any configuration functions are called - */ -extern void __bdk_config_init(void); - -/** - * Return a help string for the given configuration parameter - * - * @param cfg_item Configuration parameter to get help for - * - * @return Help string for the user - */ -extern const char *bdk_config_get_help(bdk_config_t cfg_item); - /** * Get an integer configuration item * @@ -223,49 +214,7 @@ extern const char *bdk_config_get_help(bdk_config_t cfg_item); * * @return The value of the configuration item, or def_value if the item is not set */ -extern int64_t bdk_config_get_int(bdk_config_t cfg_item, ...); - -/** - * Get a string configuration item - * - * @param cfg_item Config item to get. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - * - * @return The value of the configuration item, or def_value if the item is not set - */ -extern const char *bdk_config_get_str(bdk_config_t cfg_item, ...); - -/** - * Get a binary blob - * - * @param blob_size Integer to receive the size of the blob - * @param cfg_item Config item to get. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - * - * @return The value of the configuration item, or def_value if the item is not set - */ -extern const void *bdk_config_get_blob(int *blob_size, bdk_config_t cfg_item, ...); - -/** - * Set an integer configuration item. Note this only sets the item in memory, - * persistent storage is not updated. The optional parameters for the setting are - * not supplied, meaning this function only changes the global default. - * - * @param value Configuration item value - * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - */ -extern void bdk_config_set_int_no_param(int64_t value, bdk_config_t cfg_item); - -/** - * Set an integer configuration item. Note this only sets the item in memory, - * persistent storage is not updated. - * - * @param value Configuration item value - * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - */ -extern void bdk_config_set_int(int64_t value, bdk_config_t cfg_item, ...); +int64_t bdk_config_get_int(bdk_config_t cfg_item, ...); /** * Set an integer configuration item. Note this only sets the item in memory, @@ -275,63 +224,17 @@ extern void bdk_config_set_int(int64_t value, bdk_config_t cfg_item, ...); * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the * parameters are listed following cfg_item. */ -extern void bdk_config_set_str(const char *value, bdk_config_t cfg_item, ...); +void bdk_config_set_int(int64_t value, bdk_config_t cfg_item, ...); /** - * Set a blob configuration item. Note this only sets the - * item in memory, persistent storage is not updated. The optional - * parameters for the setting are not supplied, meaning this function - * only changes the global default. - * - * @param size Size of the item in bytes. A size of zero removes the device tree field - * @param value Configuration item value - * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - */ -extern void bdk_config_set_blob_no_param(int size, const void *value, bdk_config_t cfg_item); - -/** - * Set a blob configuration item. Note this only sets the - * item in memory, persistent storage is not updated. - * - * @param size Size of the item in bytes. A size of zero removes the device tree field - * @param value Configuration item value - * @param cfg_item Config item to set. If the item takes parameters (see bdk_config_t), then the - * parameters are listed following cfg_item. - */ -extern void bdk_config_set_blob(int size, const void *value, bdk_config_t cfg_item, ...); - -/** - * Display the active configuration - */ -extern void bdk_config_show(void); - -/** - * Display a list of all posssible config items with help text - */ -extern void bdk_config_help(void); - -/** - * Save the current configuration to flash - * - * @return Zero on success, negative on failure - */ -extern int bdk_config_save(void); - -/** - * Takes the current live device tree and exports it to a memory address suitable - * for passing to the next binary in register X1. + * Get a string configuration item * - * @return Physical address of the device tree, or 0 on failure - */ -extern uint64_t __bdk_config_export_to_mem(void); - -/** - * Return a pointer to the device tree used for configuration + * @param cfg_item Config item to get. If the item takes parameters (see bdk_config_t), then the + * parameters are listed following cfg_item. * - * @return FDT or NULL on failure + * @return The value of the configuration item, or def_value if the item is not set */ -extern void* bdk_config_get_fdt(void); +const char *bdk_config_get_str(bdk_config_t cfg_item, ...); /** * Set the device tree used for configuration @@ -341,17 +244,26 @@ extern void* bdk_config_get_fdt(void); * * @return Zero on success, negative on failure */ -extern int bdk_config_set_fdt(void *fdt); +int bdk_config_set_fdt(const struct bdk_devicetree_key_value *fdt); -/** - * Write all default values to a FDT. Missing config items get defaults in the - * BDK config, this function adds those defaults to the FDT. This way other code - * gets the default value without needing special code. - * - * @param fdt FDT structure to fill defaults into - * - * @return Zero on success, negative on failure - */ -extern int bdk_config_expand_defaults(void *fdt); +typedef enum +{ + BDK_CONFIG_TYPE_INT, + BDK_CONFIG_TYPE_STR, + BDK_CONFIG_TYPE_STR_LIST, + BDK_CONFIG_TYPE_BINARY, +} bdk_config_type_t; + +typedef struct +{ + const char *format; /* Printf style format string to create the item name */ + const bdk_config_type_t ctype;/* Type of this item */ + int64_t default_value; /* Default value when no present. String defaults are cast to pointers from this */ + const int64_t min_value;/* Minimum valid value for INT parameters. Unused for Strings */ + const int64_t max_value;/* Maximum valid value for INT parameters. Unused for Strings */ +} bdk_config_info_t; + +extern bdk_config_info_t config_info[]; /** @} */ +#endif /* !__CB_BDK_CONFIG_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-crc.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-crc.h deleted file mode 100644 index 05fc59a378..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-crc.h +++ /dev/null @@ -1,53 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 - * - * Module to support CRC. - * - *
$Revision: 49448 $
- * - * @addtogroup hal - * @{ - */ - -uint32_t bdk_crc32(const void *ptr, int len, uint32_t iv); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-ecam.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-ecam.h index 3f90d11dc2..f6aa09601d 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-ecam.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-ecam.h @@ -37,6 +37,8 @@ * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. ***********************license end**************************************/ +#include + /** * @file * diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-error-report.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-error-report.h deleted file mode 100644 index 520780fa0a..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-error-report.h +++ /dev/null @@ -1,62 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 hardware error reporting. - * - *
$Revision: 49448 $
- * - * @addtogroup hal - * @{ - */ - -/** - * Call this function to check if any error interrupts are - * set in the chip. - */ -extern void (*bdk_error_check)(bdk_node_t node) BDK_WEAK; - -/** - * Call this function to setup error enables. - */ -extern void bdk_error_enable(bdk_node_t node) BDK_WEAK; - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-fpa.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-fpa.h deleted file mode 100644 index 8094cd0fa0..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-fpa.h +++ /dev/null @@ -1,162 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 hardware Free Pool Allocator. - * - * @addtogroup hal - * @{ - */ -#define BDK_FPA_NUM_AURAS 128 /* Must not be bigger than FPA_CONST[auras] or NPA_AF_LFX_AURAS_CFG[loc_aura_size] */ - -/** - * This enum represents the FPA hardware pools in use by the BDK - */ -typedef enum -{ - BDK_FPA_PACKET_POOL, /* Stores PKI packet buffers */ - BDK_FPA_SSO_POOL, /* Used for internal storage in the SSO, CN83XX and CN9XXX */ - BDK_FPA_PKO_POOL, /* Used for queue storage in the CN83XX PKO and CN9XXX SQB */ - BDK_FPA_NUM_POOLS = 16 /* Can be 16, or 32 for CN83XX. Must not be bigger than FPA_CONST[pools] */ -} bdk_fpa_pool_t; - -/** - * Structure representing the global state of the FPA - */ -typedef struct -{ - uint16_t buffer_size_pool[BDK_FPA_NUM_POOLS]; - uint16_t buffer_size_aura[BDK_FPA_NUM_AURAS]; - int next_free_aura; - int next_free_lf; /* Used on CN9XXX for RVU PF allocation */ - void *npa_auras_ptr; /* Pointer to Aura Context Table: BDK_FPA_NUM_AURAS * (Aura HW context) */ - void *npa_pools_ptr; /* Pointer to Pool Context Table: BDK_FPA_NUM_POOLS * (Pool HW context) */ -} __bdk_fpa_state_t; - -extern __bdk_fpa_state_t __bdk_fpa_node_state[BDK_NUMA_MAX_NODES]; - -/** - * Get a new block from an aura - * - * @param node Node to use in a Numa setup. See bdk-numa.h - * @param aura Aura to get the block from (0-BDK_FPA_NUM_AURAS) - * - * @return Pointer to the block or NULL on failure - */ -extern void* (*bdk_fpa_alloc)(bdk_node_t node, int aura); - -/** - * Free a block allocated with bdk_fpa_alloc(). Does NOT provide memory ordering - * for core stores. Software must insure all pending writes are flushed before - * calling this function. - * - * @param node Node to use in a Numa setup. See bdk-numa.h - * @param address Physical address to free to the FPA aura - * @param aura Aura number to free to (0-BDK_FPA_NUM_AURAS) - * @param num_cache_lines - * Cache lines to invalidate. Use this if the data in the buffer is no longer - * requires cache coherency. Normally best to set this to zero. - */ -extern void (*__bdk_fpa_raw_free)(bdk_node_t node, uint64_t address, int aura, int num_cache_lines); - -/** - * Fill a pool with buffers - * - * @param node Node to use in a Numa setup. See bdk-numa.h - * @param pool Pool to initialize (0 <= pool < BDK_FPA_NUM_POOLS) - * @param num_blocks Number of blocks - * - * @return Zero on Success, negative on failure - */ -extern int (*bdk_fpa_fill_pool)(bdk_node_t node, bdk_fpa_pool_t pool, int num_blocks); - -/** - * Initialize an Aura for a specific pool - * - * @param node Node to use in a Numa setup. See bdk-numa.h - * @param aura Aura to initialize, or -1 to dynamically allocate a free aura - * @param pool Pool this aura is for (0 <= pool < BDK_FPA_NUM_POOLS) - * @param num_blocks Number of buffers to allow this aura to contain. This may be different - * from the pool - * - * @return Aura number or negative on failure - */ -extern int (*bdk_fpa_init_aura)(bdk_node_t node, int aura, bdk_fpa_pool_t pool, int num_blocks); - -/** - * Free a block allocated with bdk_fpa_alloc(). Provides memory ordering - * for core stores. - * - * @param node Node to use in a Numa setup. See bdk-numa.h - * @param ptr Pointer to the block to free - * @param aura Aura number to free to (0-BDK_FPA_NUM_AURAS) - * @param num_cache_lines - * Cache lines to invalidate. Use this if the data in the buffer is no longer - * requires cache coherency. Normally best to set this to zero. - */ -static inline void bdk_fpa_free(bdk_node_t node, void *ptr, int aura, int num_cache_lines) -{ - BDK_WMB; - __bdk_fpa_raw_free(node, bdk_ptr_to_phys(ptr), aura, num_cache_lines); -} - -/** - * Get the size of blocks controlled by the aura - * - * @param node Node to use in a Numa setup. See bdk-numa.h - * @param aura Aura number to access (0-BDK_FPA_NUM_AURAS) - * - * @return Size of the block in bytes - */ -static inline int bdk_fpa_get_block_size(bdk_node_t node, int aura) -{ - __bdk_fpa_state_t *fpa_state = &__bdk_fpa_node_state[node]; - return fpa_state->buffer_size_aura[aura]; -} - -/** - * Global FPA initialization - * - * @return Zero on success, negative on failure - */ -int bdk_fpa_init(bdk_node_t node); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-gpio.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-gpio.h index 8be3a4c1ad..21a57cde3d 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-gpio.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-gpio.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_GPIO_H__ +#define __CB_BDK_GPIO_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -109,3 +111,4 @@ extern void bdk_gpio_select_pin(bdk_node_t node, int gpio, int pin); extern int bdk_gpio_get_num(void); /** @} */ +#endif /* !__CB_BDK_GPIO_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-hal.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-hal.h deleted file mode 100644 index 458ffede7c..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-hal.h +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef __BDK_HAL_H__ -#define __BDK_HAL_H__ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 - * - * Master include file for hardware support. Use bdk.h instead - * of including this file directly. - * - *
$Revision: 49448 $
- * - * @defgroup hal Hardware abstraction layer - */ - -/* Global define to control if the BDK configures units to send - don't write back requests for freed buffers. Set to 1 to enable - DWB, 0 to disable them. As the BDK normally fits inside L2, sending - DWB just causes more L2 operations without benefit */ -#define BDK_USE_DWB 0 - -#include "bdk-access.h" -#include "bdk-utils.h" -#include "bdk-config.h" -#include "bdk-atomic.h" -#include "bdk-spinlock.h" -#include "bdk-rvu.h" -#include "bdk-clock.h" -#include "bdk-crc.h" -#include "bdk-error-report.h" -#include "bdk-gpio.h" -#include "device/bdk-device.h" -#include "if/bdk-if.h" -#include "usb/bdk-usb-xhci-intf.h" -#include "bdk-ecam.h" -#include "bdk-fpa.h" -#include "bdk-pbus-flash.h" -#include "bdk-pki.h" -#include "bdk-pko.h" -#include "bdk-power-burn.h" -#include "bdk-sso.h" -#include "bdk-nic.h" -#include "bdk-nix.h" -#include "bdk-key.h" -#include "bdk-l2c.h" -#include "bdk-mdio.h" -#include "bdk-mpi.h" -#include "bdk-mmc.h" -#include "bdk-pcie.h" -#include "bdk-pcie-flash.h" -#include "bdk-qlm.h" -#include "qlm/bdk-qlm-errata-cn8xxx.h" -#include "bdk-rng.h" -#include "bdk-sata.h" -#include "bdk-twsi.h" -#include "bdk-usb.h" -#include "bdk-access-native.h" -#include "bdk-tns.h" -#include "bdk-vrm.h" -#include "aq_api/bdk-aqr-support.h" -#endif diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-key.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-key.h deleted file mode 100644 index c16bfd7559..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-key.h +++ /dev/null @@ -1,86 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 on chip key memory. Key memory is - * 8k on chip that is inaccessible from off chip. It can - * also be cleared using an external hardware pin. - * - *
$Revision: 49448 $
- * - * @addtogroup hal - * @{ - */ - -#define BDK_KEY_MEM_SIZE 8192 /* Size in bytes */ - -/** - * Read from KEY memory - * - * @param node Which node to use - * @param address Address (byte) in key memory to read - * 0 <= address < BDK_KEY_MEM_SIZE - * @return Value from key memory - */ -extern uint64_t bdk_key_read(bdk_node_t node, uint64_t address); - -/** - * Write to KEY memory - * - * @param node Which node to use - * @param address Address (byte) in key memory to write - * 0 <= address < BDK_KEY_MEM_SIZE - * @param value Value to write to key memory - */ -extern void bdk_key_write(bdk_node_t node, uint64_t address, uint64_t value); - -/** - * Allocate an area in key memory for storing data. Return a pointer to the - * memory on success. - * - * @param node Node to allocate on - * @param size_bytes Number of bytes to allocate - * - * @return Pointer to key memory, or NULL on failure - */ -extern void* bdk_key_alloc(bdk_node_t node, int size_bytes); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-l2c.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-l2c.h index cf14357f83..bcb82683be 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-l2c.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-l2c.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_L2C_H__ +#define __CB_BDK_L2C_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -37,6 +39,9 @@ * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. ***********************license end**************************************/ +/* FIXME(dhendricks): added */ +#include + /** * @file * @@ -177,3 +182,4 @@ int bdk_l2c_get_num_assoc(bdk_node_t node); int bdk_l2c_is_locked(bdk_node_t node); /** @} */ +#endif /* !__CB_BDK_L2C_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mdio.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mdio.h index 889f8d5d56..0540fa499a 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mdio.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mdio.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_HAL_MDIO_H__ +#define __CB_BDK_HAL_MDIO_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -473,4 +475,7 @@ extern int bdk_mdio_45_read(bdk_node_t node, int bus_id, int phy_id, int device, extern int bdk_mdio_45_write(bdk_node_t node, int bus_id, int phy_id, int device, int location, int val); +int bdk_mdio_init(bdk_node_t node); + /** @} */ +#endif diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mmc.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mmc.h deleted file mode 100644 index 93f3286379..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mmc.h +++ /dev/null @@ -1,89 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 MMC, eMMC, or SD - * - *
$Revision: 49448 $
- * - * @addtogroup hal - * @{ - */ - -/** - * Initialize a MMC for read/write - * - * @author creese (10/14/2013) - * @param chip_sel Chip select to use - * - * @return Size of the SD card, zero on failure - */ -extern int64_t bdk_mmc_initialize(bdk_node_t node, int chip_sel); - -/** - * Read blocks from a MMC card - * - * @author creese (10/14/2013) - * @param node Node to access - * @param chip_sel Chip select to use - * @param address Offset into the card in bytes. Must be a multiple of 512 - * @param buffer Buffer to read into - * @param length Length to read in bytes. Must be a multiple of 512 - * - * @return Zero on success, negative on failure - */ -extern int bdk_mmc_read(bdk_node_t node, int chip_sel, uint64_t address, void *buffer, int length); - -/** - * Write blocks to a MMC card - * - * @author creese (10/14/2013) - * @param node Node to access - * @param chip_sel Chip select to use - * @param address Offset into the card in bytes. Must be a multiple of 512 - * @param buffer Buffer to write - * @param length Length to write in bytes. Must be a multiple of 512 - * - * @return Zero on success, negative on failure - */ -extern int bdk_mmc_write(bdk_node_t node, int chip_sel, uint64_t address, const void *buffer, int length); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mpi.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mpi.h deleted file mode 100644 index 46da75b019..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-mpi.h +++ /dev/null @@ -1,105 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 SPI / MPI bus - * - *
$Revision: 49448 $
- * - * @addtogroup hal - * @{ - */ - -typedef enum -{ - BDK_MPI_FLAGS_ENABLE_CS0 = 1<<0, /**< Chip select 0 will be needed */ - BDK_MPI_FLAGS_ENABLE_CS1 = 1<<1, /**< Chip select 1 will be needed */ - BDK_MPI_FLAGS_ENABLE_CS2 = 1<<2, /**< Chip select 2 will be needed */ - BDK_MPI_FLAGS_ENABLE_CS3 = 1<<3, /**< Chip select 3 will be needed */ - BDK_MPI_FLAGS_CS_ACTIVE_HI = 1<<4, /**< Chip select is active high, else active low */ - BDK_MPI_FLAGS_ONE_WIRE = 1<<5, /**< Input and output are multiplexed over SPI_DO */ - BDK_MPI_FLAGS_IDLE_CLOCKS = 1<<7, /**< Continue to clock between commands */ - BDK_MPI_FLAGS_IDLE_LOW = 1<<8, /**< Clear the clock is idle high, Set the clock is idle low */ - BDK_MPI_FLAGS_LSB_FIRST = 1<<9, /**< Set to shift the LSB first, otherwise MSB will shift first */ -} bdk_mpi_flags_t; - -/** - * Initialize MPI/SPI for use. The different configuration - * options are encoded as bitmask inside the flags parameter. - * - * @param node Numa node to use - * @param clock_rate_hz - * Clock rate in Hz (1-16M) - * @param flags Setup flags ORed together - * - * @return Zero on success, negative on failure - */ -extern int bdk_mpi_initialize(bdk_node_t node, int clock_rate_hz, bdk_mpi_flags_t flags); - -/** - * Perform a SPI/MPI transfer. The transfer can contain tx_count - * bytes that are transferred out, followed by rx_count bytes - * that are read in. Both tx_count and rx_count may be zero if - * no transfer is needed. Transmit data is sent most significant - * byte first, unless BDK_MPI_FLAGS_LSB_FIRST is set. Receive data - * is in the return value with the last byte in the least - * signnificant byte. - * - * @param node Numa node to use - * @param chip_select - * Which chip select to enable during the transfer - * @param leave_cs_enabled - * Leave the chip select assert after the transaction. Normally can - * be zero. Set to non zero if you want to perform repeated - * transactions. - * @param tx_count Number of bytes to transfer before startng the rx/shift data. - * Can be zero. - * @param tx_data Data to transmit. The low order bytes are used for the data. Order - * of shift out is controlled by BDK_MPI_FLAGS_LSB_FIRST - * @param rx_count Number of bytes to read. These bytes will be in the return value - * least significant bytes - * - * @return Read data - */ -extern uint64_t bdk_mpi_transfer(bdk_node_t node, int chip_select, - int leave_cs_enabled, int tx_count, uint64_t tx_data, int rx_count); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-nix.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-nix.h deleted file mode 100644 index 118ceaebbb..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-nix.h +++ /dev/null @@ -1,105 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2016 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 NIX. - * - * @addtogroup hal - * @{ - */ - -typedef enum -{ - BDK_NIX_TYPE_CGX, - BDK_NIX_TYPE_LBK, -} bdk_nix_type_t; - -/** - * Configure NIC for a specific port. This is called for each - * port on every interface that connects to NIC. - * - * @param handle Handle for port to config - * @param ntype Type of LMAC this NIC connects to - * @param lmac_credits - * Size of the LMAC buffer in bytes. Used to configure the number of credits to - * setup between the NIC and LMAC - * - * @return Zero on success, negative on failure - */ -extern int bdk_nix_port_init(bdk_if_handle_t handle, bdk_nix_type_t ntype, int lmac_credits); - -/** - * Send a packet - * - * @param handle Handle of port to send on - * @param packet Packet to send - * - * @return Zero on success, negative on failure - */ -extern int bdk_nix_transmit(bdk_if_handle_t handle, const bdk_if_packet_t *packet); - -/** - * Get the current TX queue depth. Note that this operation may be slow - * and adversly affect packet IO performance. - * - * @param handle Port to check - * - * @return Depth of the queue in packets - */ -extern int bdk_nix_get_queue_depth(bdk_if_handle_t handle); - -/** - * Query NIC and fill in the transmit stats for the supplied - * interface handle. - * - * @param handle Port handle - */ -extern void bdk_nix_fill_tx_stats(bdk_if_handle_t handle); - -/** - * Query NIC and fill in the receive stats for the supplied - * interface handle. - * - * @param handle Port handle - */ -extern void bdk_nix_fill_rx_stats(bdk_if_handle_t handle); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pbus-flash.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pbus-flash.h deleted file mode 100644 index a5cd2d592d..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pbus-flash.h +++ /dev/null @@ -1,111 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2016-2017 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 - * - * This file provides bootbus flash operations - * - *
$Revision: 49448 $
- * - * @addtogroup hal - * @{ - */ - -typedef struct -{ - int start_offset; - int block_size; - int num_blocks; -} bdk_pbus_flash_region_t; - -/** - * Initialize the flash access library - */ -void bdk_pbus_flash_initialize(bdk_node_t node); - -/** - * Return a pointer to the flash chip - * - * @param chip_id Chip ID to return - * @return Zero if the chip doesn't exist - */ -uint64_t bdk_pbus_flash_get_base(int chip_id); - -/** - * Return the number of erasable regions on the chip - * - * @param chip_id Chip to return info for - * @return Number of regions - */ -int bdk_pbus_flash_get_num_regions(int chip_id); - -/** - * Return information about a flash chips region - * - * @param chip_id Chip to get info for - * @param region Region to get info for - * @return Region information - */ -const bdk_pbus_flash_region_t *bdk_pbus_flash_get_region_info(int chip_id, int region); - -/** - * Erase a block on the flash chip - * - * @param chip_id Chip to erase a block on - * @param region Region to erase a block in - * @param block Block number to erase - * @return Zero on success. Negative on failure - */ -int bdk_pbus_flash_erase_block(int chip_id, int region, int block); - -/** - * Write data to flash. The block must have already been erased. You can call - * this multiple times on the same block to piecemeal write it. - * - * @param chip_id Which flash to write - * @param offset Offset into device to start write - * @param data Data to write - * @param len Length of the data - * - * @return Zero on success. Negative on failure - */ -int bdk_pbus_flash_write(int chip_id, int offset, const void *data, int len); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pcie-flash.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pcie-flash.h deleted file mode 100644 index 6605e419bb..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pcie-flash.h +++ /dev/null @@ -1,109 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 programming the PCIe SPI flash used for config overrides - * - * @addtogroup hal - * @{ - */ - -#define BDK_PCIE_FLASH_PREAMBLE 0x9da1 -#define BDK_PCIE_FLASH_END 0x6a5d -#define BDK_PCIE_FLASH_MAX_OFFSET 256 - -/** - * Determine if access to the PCIe SPI flash is available - * - * @param node Numa node request is for - * @param pcie_port PCIe port to access - * - * @return One if available, zero if not - */ -extern int bdk_pcie_flash_is_available(bdk_node_t node, int pcie_port); - -/** - * Read the specified offset in the PCIe SPI flash and returns its - * value. In the case the EEPROM isn't there or can't be read -1 - * is returned. - * - * @param node Numa node request is for - * @param pcie_port PCIe port to access - * @param offset Offset in bytes, Must be a multiple of 8 - * - * @return Value read or -1 if the read failed - */ -extern uint64_t bdk_pcie_flash_read(bdk_node_t node, int pcie_port, int offset); - -/** - * Write a value to the PCIe SPI flash. The value should be of the - * format bdk_pemx_spi_data_t. - * - * @param node Numa node request is for - * @param pcie_port PCIe port to access - * @param offset Offset to write. Must be a multiple of 8 bytes. - * @param value Value to write - * - * @return Zero on success, negative on failure - */ -extern int bdk_pcie_flash_write(bdk_node_t node, int pcie_port, int offset, uint64_t value); - -/** - * Erase the PCIe SPI Flash - * - * @param node Numa node request is for - * @param pcie_port PCIe port to access - * - * @return Zero on success, negative on failure - */ -extern int bdk_pcie_flash_erase(bdk_node_t node, int pcie_port); - -/** - * Dump the PCIe SPI Flash - * - * @param node Numa node request is for - * @param pcie_port PCIe port to access - * - * @return Zero on success, negative on failure - */ -extern int bdk_pcie_flash_dump(bdk_node_t node, int pcie_port); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pcie.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pcie.h index d68a6d297f..3661427140 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pcie.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pcie.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_PCIE_H__ +#define __CB_BDK_PCIE_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -37,6 +39,9 @@ * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. ***********************license end**************************************/ +#include +#include + /** * @file * @@ -77,6 +82,15 @@ int bdk_pcie_get_num_ports(bdk_node_t node); */ int bdk_pcie_rc_initialize(bdk_node_t node, int pcie_port); +/** + * Return PCIe state + * + * @param pcie_port PCIe port to query + * + * @return True if port is up and running + */ +int bdk_pcie_is_running(bdk_node_t node, int pcie_port); + /** * Shutdown a PCIe port and put it in reset * @@ -221,16 +235,18 @@ uint64_t bdk_pcie_mem_read64(bdk_node_t node, int pcie_port, uint64_t address); void bdk_pcie_mem_write64(bdk_node_t node, int pcie_port, uint64_t address, uint64_t data); /** - * These are the operations defined that can vary per chip generation + * @INTERNAL + * Build a PCIe config space request address for a device + * + * @param pcie_port PCIe port to access + * @param bus Sub bus + * @param dev Device ID + * @param fn Device sub function + * @param reg Register to access + * + * @return 64bit IO address */ -typedef struct -{ - int (*get_num_ports)(bdk_node_t node); - int (*rc_initialize)(bdk_node_t node, int pcie_port); - int (*rc_shutdown)(bdk_node_t node, int pcie_port); - uint64_t (*get_base_address)(bdk_node_t node, int pcie_port, bdk_pcie_mem_t mem_type); - uint64_t (*get_base_size)(bdk_node_t node, int pcie_port, bdk_pcie_mem_t mem_type); - uint64_t (*build_config_addr)(bdk_node_t node, int pcie_port, int bus, int dev, int fn, int reg); -} __bdk_pcie_ops_t; +uint64_t pcie_build_config_addr(bdk_node_t node, int pcie_port, int bus, int dev, int fn, int reg); +#endif /* __CB_BDK_PCIE_H__ */ /** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pki.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pki.h deleted file mode 100644 index 3379d26644..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pki.h +++ /dev/null @@ -1,83 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 SSO. - * - * @addtogroup hal - * @{ - */ - -/** - * One time init of global Packet Input - * - * @return Zero on success, negative on failure - */ -extern int bdk_pki_global_init(bdk_node_t node); - -/** - * Configure packet input for a specific port. This is called for each - * port on every interface that is connected to packet input. - * - * @param handle Handle for port to config - * - * @return Zero on success, negative on failure - */ -extern int bdk_pki_port_init(bdk_if_handle_t handle); - -/** - * Enable PKI after all setup is complete - * - * @return Zero on success, negative on failure - */ -extern int bdk_pki_enable(bdk_node_t node); - -/** - * Query PKI and fill in the receive stats for the supplied interface handle. The - * interface must use PKI for RX. - * - * @param handle Port handle - * - * @return - */ -extern void bdk_pki_fill_rx_stats(bdk_if_handle_t handle); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pko.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pko.h deleted file mode 100644 index 90cd719b06..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-pko.h +++ /dev/null @@ -1,126 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 PKO. - * - * @addtogroup hal - * @{ - */ - -/* Maximum number of segments which fit flat lmtstore operation. - 1) LMTST for PKO can be a maximum of 15 64bit words - 2) PKO descriptors are 2 64bit words each - 3) Every send requires PKO_SEND_HDR_S for hardware - So 15 words / 2 = 7 possible descriptors - 7 - HDR = 6 descriptors left for GATHER */ -#define BDK_PKO_SEG_LIMIT 6 - -/** - * Perform global init of PKO - * - * @return Zero on success, negative on failure - */ -extern int bdk_pko_global_init(bdk_node_t node); - -/** - * Configure PKO for a specific port. This is called for each - * port on every interface that connects to PKO. - * - * @param handle Handle for port to config - * - * @return Zero on success, negative on failure - */ -extern int bdk_pko_port_init(bdk_if_handle_t handle); - -/** - * Enable PKO after all setup is complete - * - * @return Zero on success, negative on failure - */ -extern int bdk_pko_enable(bdk_node_t node); - -/** - * Get the current TX queue depth. Note that this operation may be slow - * and adversly affect packet IO performance. - * - * @param handle Port to check - * - * @return Depth of the queue in packets - */ -extern int bdk_pko_get_queue_depth(bdk_if_handle_t handle); - -/** - * Set PKO shapping as a specific queue level - * - * @param node Node to shape - * @param queue Queue to shape - * @param level Level in PKO - * @param is_red Non-zero of the rate is for the yellow/red transition. Zero for the - * green/yellow transition. - * @param is_packets Non-zero if the rate is packets/sec, otherwise rate is bits/sec - * @param rate Desired rate. A rate of zero disables shaping - * - * @return Zero on success, negative on failure - */ -extern int bdk_pko_shape(bdk_node_t node, int queue, int level, int is_red, int is_packets, uint64_t rate); - -/** - * Send a packet - * - * @param handle Handle of port to send on - * @param packet Packet to send - * - * @return Zero on success, negative on failure - */ -extern int bdk_pko_transmit(bdk_if_handle_t handle, const bdk_if_packet_t *packet); - -/** - * Query PKO and fill in the receive stats for the supplied - * interface handle. The interface must use PKO for TX. - * - * @param handle Port handle - * - * @return - */ -extern void bdk_pko_fill_tx_stats(bdk_if_handle_t handle); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-power-burn.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-power-burn.h deleted file mode 100644 index 570ef1073c..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-power-burn.h +++ /dev/null @@ -1,67 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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**************************************/ -typedef enum -{ - BDK_POWER_BURN_NONE, /* Disable power burn */ - BDK_POWER_BURN_FULL, /* Continuously burn power */ - BDK_POWER_BURN_CYCLE_10MS, /* Cycle: Burn for 10ms, idle for 10ms */ - BDK_POWER_BURN_CYCLE_1S, /* Cycle: Burn for 1s, idle for 1s */ - BDK_POWER_BURN_CYCLE_5S, /* Cycle: Burn for 5s, idle for 5s */ - BDK_POWER_BURN_CYCLE_1M, /* Cycle: Burn for 1m, idle for 1m */ - BDK_POWER_BURN_CYCLE_5M, /* Cycle: Burn for 5m, idle for 5m */ -} bdk_power_burn_type_t; - -/** - * Set the current power burn mode for a node - * - * @param node Node to control power burn for - * @param burn_type Mode of power burn - * - * @return Zero on success, negative on failure - */ -extern int bdk_power_burn(bdk_node_t node, bdk_power_burn_type_t burn_type); - -/** - * Set the throttle level percent for an entire chip - * - * @param node Node to set - * @param throttle Percent of Throttle level (0-100) - */ -extern void bdk_power_throttle(bdk_node_t node, int throttle_percent); - diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-qlm.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-qlm.h index 6cb1364196..1966f5ce85 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-qlm.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-qlm.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_QLM_H__ +#define __CB_BDK_QLM_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -47,6 +49,8 @@ * @addtogroup hal * @{ */ +#include +#include typedef enum { @@ -138,37 +142,6 @@ typedef struct uint32_t data[64][128]; /* Error count at location, saturates as max */ } bdk_qlm_eye_t; - -/** - * How to do the various QLM operations changes greatly - * between chips. Each chip has its specific operations - * stored in the structure below. The correct structure - * is chosen based on the chip we're running on. - */ -typedef struct -{ - uint32_t chip_model; - void (*init)(bdk_node_t node); - int (*get_num)(bdk_node_t node); - int (*get_lanes)(bdk_node_t node, int qlm); - bdk_qlm_modes_t (*get_mode)(bdk_node_t node, int qlm); - int (*set_mode)(bdk_node_t node, int qlm, bdk_qlm_modes_t mode, int baud_mhz, bdk_qlm_mode_flags_t flags); - int (*get_gbaud_mhz)(bdk_node_t node, int qlm); - int (*measure_refclock)(bdk_node_t node, int qlm); - int (*get_qlm_num)(bdk_node_t node, bdk_if_t iftype, int interface, int index); - int (*reset)(bdk_node_t node, int qlm); - int (*enable_prbs)(bdk_node_t node, int qlm, int prbs, bdk_qlm_direction_t dir); - int (*disable_prbs)(bdk_node_t node, int qlm); - uint64_t (*get_prbs_errors)(bdk_node_t node, int qlm, int lane, int clear); - void (*inject_prbs_error)(bdk_node_t node, int qlm, int lane); - int (*enable_loop)(bdk_node_t node, int qlm, bdk_qlm_loop_t loop); - int (*auto_config)(bdk_node_t node); - int (*dip_auto_config)(bdk_node_t node); - int (*tune_lane_tx)(bdk_node_t node, int qlm, int lane, int tx_swing, int tx_pre, int tx_post, int tx_gain, int tx_vboost); - int (*rx_equalization)(bdk_node_t node, int qlm, int lane); - int (*eye_capture)(bdk_node_t node, int qlm, int qlm_lane, bdk_qlm_eye_t *eye); -} bdk_qlm_ops_t; - /** * Initialize the QLM layer */ @@ -193,6 +166,19 @@ extern int bdk_qlm_get_num(bdk_node_t node); */ extern int bdk_qlm_get_lanes(bdk_node_t node, int qlm); +/** + * Lookup the hardware QLM number for a given interface type and index. This + * function will fail with a fatal error if called on invalid interfaces for + * a chip. It returns the QLM number for an interface without checking to + * see if the QLM is in the correct mode. + * + * @param iftype Interface type + * @param interface Interface index number + * + * @return QLM number. Dies on a fatal error on failure. + */ +int bdk_qlm_get_qlm_num(bdk_node_t node, bdk_if_t iftype, int interface, int index); + /** * Convert a mode into a configuration variable string value * @@ -278,23 +264,6 @@ extern int bdk_qlm_get_gbaud_mhz(bdk_node_t node, int qlm); */ extern int bdk_qlm_measure_clock(bdk_node_t node, int qlm); -/** - * Lookup the hardware QLM number for a given interface type and - * index. If the associated interface doesn't map to a QLM, - * returns -1. - * - * @param node Node to use in a Numa setup - * @param iftype Interface type - * @param interface Interface index number - * @param index Port on the interface. Most chips use the - * same mode for all ports, but there are - * exceptions. For example, BGX2 on CN83XX - * spans two DLMs. - * - * @return QLM number or -1 on failure - */ -extern int bdk_qlm_get(bdk_node_t node, bdk_if_t iftype, int interface, int index); - /** * Reset a QLM to its initial state * @@ -505,4 +474,5 @@ extern int bdk_qlm_margin_rx_restore(bdk_node_t node, int qlm, int qlm_lane, bdk extern int bdk_qlm_dip_auto_config(bdk_node_t node); +#endif /* __CB_BDK_QLM_H__ */ /** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-rng.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-rng.h index d5a7d0a43b..7f4b74ae70 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-rng.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-rng.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_RNG_H__ +#define __CB_BDK_RNG_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -76,4 +78,7 @@ extern uint32_t bdk_rng_get_random32(void); */ extern uint64_t bdk_rng_get_random64(void); + +int bdk_rng_init(bdk_node_t node); /** @} */ +#endif /* !__CB_BDK_RNG_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-rvu.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-rvu.h index 53b73ca4aa..99927dd5df 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-rvu.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-rvu.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_RVU_H__ +#define __CB_BDK_RVU_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -64,3 +66,4 @@ static inline int bdk_rvu_alloc_msix(bdk_node_t node, int msix_count) /** @} */ +#endif /* !__CB_BDK_RVU_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-spinlock.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-spinlock.h index 5e34a4f7b9..c9b5487700 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-spinlock.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-spinlock.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_SPINLOCK_H__ +#define __CB_BDK_SPINLOCK_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -144,3 +146,4 @@ static inline int bdk_spinlock_trylock(bdk_spinlock_t *lock) } /** @} */ +#endif /* !__CB_BDK_SPINLOCK_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-sso.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-sso.h deleted file mode 100644 index a04d5ca3cf..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-sso.h +++ /dev/null @@ -1,69 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 SSO. - * - * @addtogroup hal - * @{ - */ - -/** - * Initialize the SSO - * - * @return Zero on success, negative on failure - */ -extern int bdk_sso_init(bdk_node_t node); - -/** - * Register a bdk-if handle with the SSO code so the SSO can be used to receive - * traffic from it. - * - * @param handle Handle to register - */ -extern void bdk_sso_register_handle(bdk_if_handle_t handle); - -/** - * Function called during bdk_thread_yield() to process work while we're idle - */ -extern void bdk_sso_process_work(void); - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-tns.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-tns.h deleted file mode 100644 index 89264c8604..0000000000 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-tns.h +++ /dev/null @@ -1,109 +0,0 @@ -/***********************license start*********************************** -* Copyright (c) 2003-2017 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 - * - * Thunder Network Switch interface. - * - * $Revision$ - * - * @addtogroup hal - * @{ - */ - -/** - * Initialize the TNS block to enable clocks, allow register accesses, and - * perform some basic initialization in anticipation of future packet - * processing. - * - * TNS at power-up will be in BYPASS mode where packets from the vNIC pipes - * to the BGX ports will be direct, and this will not change that. - * - * This is normally called automatically in bdk-init-main.c. - * - * @param node Node to initialize - * - * @return Zero on success, negative on failure - */ -extern int bdk_tns_initialize(bdk_node_t node) BDK_WEAK; - -/** - * Disable TNS from processing packets. After this, TNS must be fully - * initialized. The NIC and BGX blocks must already be stopped before - * calling this function. - * - * Nota Bene: In CN88XX_PASS_1 there is a bug that prevents TNS DataPath - * from draining packets. So ensure that NIC and BGX have - * also drained their packet queues. - * - * @param node - * - * @return Zero on success, negative on failure - */ -extern int bdk_tns_shutdown(bdk_node_t node); - -/** - * Set the TNS 'profile' to passthru. I.e. do the necessary writes - * to the TNS datapath and TNS sst (Search, SDE, and TxQ) registers - * to configure the TNS to allow vNIC0..vNIC7 <-> LMAC0..LMAC7 traffic - * to flow straight through TNS (although the actual enabling of using - * the TNS is done elsewhere (in traffic-gen.)) - * - * @param node Node to configure - * - * @return Zero on success, negative on failure - */ -extern int bdk_tns_profile_passthru(bdk_node_t node) BDK_WEAK; - -/** - * Set the TNS 'profile' to bgxloopback. I.e. do the necessary writes - * to the TNS datapath and TNS sst (Search, SDE, and TxQ) registers - * to configure the TNS to allow any packets received on LMAC0..LMAC7 - * (BGX ports) to be reflected back to the same port after hitting the - * TNS (although the actual enabling of using the TNS is done elsewhere - * (in traffic-gen.)) - * - * @param node Node to configure - * - * @return Zero on success, negative on failure - */ -extern int bdk_tns_profile_bgxloopback(bdk_node_t node) BDK_WEAK; - -/** @} */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-twsi.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-twsi.h index 2840ca5c96..0a9911d9b1 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-twsi.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-twsi.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_TWSI_H__ +#define __CB_BDK_TWSI_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -49,16 +51,7 @@ * @addtogroup hal * @{ */ - -/** - * Initialize the TWSI blocks. This just sets the clock rate. - * Many times stuff will work without calling this, but some - * TWSI devices will fail. This is normally called automatically - * in bdk-init-main.c. - * - * @return Zero on success, negative on failure - */ -extern int bdk_twsix_initialize(bdk_node_t node) BDK_WEAK; +#include /** * Do a twsi read from a 7 bit device address using an (optional) @@ -100,3 +93,4 @@ extern int64_t bdk_twsix_read_ia(bdk_node_t node, int twsi_id, uint8_t dev_addr, extern int bdk_twsix_write_ia(bdk_node_t node, int twsi_id, uint8_t dev_addr, uint16_t internal_addr, int num_bytes, int ia_width_bytes, uint64_t data); /** @} */ +#endif /* !__CB_BDK_TWSI_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-usb.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-usb.h index 6e78e5db14..facc01f95d 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-usb.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-usb.h @@ -1,3 +1,5 @@ +#ifndef __BDK_HAL_USB_H__ +#define __BDK_HAL_USB_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -82,7 +84,7 @@ typedef enum * * @return Zero on success, negative on failure */ -extern int bdk_usb_initialize(bdk_node_t node, int usb_port, bdk_usb_clock_t clock_type); +int bdk_usb_initialize(bdk_node_t node, int usb_port, bdk_usb_clock_t clock_type); /** * Put the USB port into a specific testing mode @@ -93,7 +95,7 @@ extern int bdk_usb_initialize(bdk_node_t node, int usb_port, bdk_usb_clock_t clo * * @return Zero on success, negative on failure */ -extern int bdk_usb_test_mode(bdk_node_t node, int usb_port, bdk_usb_test_t test_mode); +int bdk_usb_test_mode(bdk_node_t node, int usb_port, bdk_usb_test_t test_mode); /** * Convert a USB test enumeration into a string for display to the user @@ -104,6 +106,7 @@ extern int bdk_usb_test_mode(bdk_node_t node, int usb_port, bdk_usb_test_t test_ * * @return String name of test */ -extern const char *bdk_usb_get_test_mode_string(bdk_node_t node, int usb_port, bdk_usb_test_t test_mode); +const char *bdk_usb_get_test_mode_string(bdk_node_t node, int usb_port, bdk_usb_test_t test_mode); /** @} */ +#endif diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-utils.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-utils.h index c0ed43582e..c83658644c 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-utils.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-utils.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_UTILS_H__ +#define __CB_BDK_UTILS_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -36,8 +38,8 @@ * QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. ***********************license end**************************************/ -#include "libbdk-arch/bdk-csrs-lmc.h" #include "libbdk-arch/bdk-csrs-rst.h" +#include /** * @file @@ -204,3 +206,4 @@ static inline void bdk_zero_memory(void *start, uint64_t length) } /** @} */ +#endif /* !__CB_BDK_UTILS_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-vrm.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-vrm.h index 8e6ec38209..0aeae94e30 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-vrm.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/bdk-vrm.h @@ -1,3 +1,5 @@ +#ifndef __CB_BDK_VRM_H__ +#define __CB_BDK_VRM_H__ /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -64,3 +66,4 @@ extern int bdk_vrm_initialize(bdk_node_t node); extern int bdk_vrm_poll(bdk_node_t node); /** @} */ +#endif /* !__CB_BDK_VRM_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/device/bdk-device.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/device/bdk-device.h index 3ca3f00710..3308859733 100644 --- a/src/vendorcode/cavium/include/bdk/libbdk-hal/device/bdk-device.h +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/device/bdk-device.h @@ -1,3 +1,6 @@ +#ifndef __CB_BDK_DEVICE_H__ +#define __CB_BDK_DEVICE_H__ + /***********************license start*********************************** * Copyright (c) 2003-2017 Cavium Inc. (support@cavium.com). All rights * reserved. @@ -250,10 +253,11 @@ extern void bdk_bar_write(const bdk_device_t *device, int bar, int size, uint64_ } else if (bdk_clock_get_count(BDK_CLOCK_TIME) > done) { \ result = -1; \ break; \ - } else \ - bdk_thread_yield(); \ + } \ } \ } while (0); \ result;}) /** @} */ + +#endif /* !__CB_BDK_DEVICE_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/if/bdk-if.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/if/bdk-if.h new file mode 100644 index 0000000000..c3ede0acc8 --- /dev/null +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/if/bdk-if.h @@ -0,0 +1,326 @@ +#ifndef __CB_BDK_HAL_IF_BDK_IF_H__ +#define __CB_BDK_HAL_IF_BDK_IF_H__ +/***********************license start*********************************** +* Copyright (c) 2003-2017 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 external interfaces (SGMII, XAUI, etc) + * + *
$Revision: 45089 $
+ * + * @defgroup packetio Packet Input / Output + * @addtogroup packetio + * @{ + */ + + +#define BDK_BGX_PKI 0 /* When defined and non zero BGX will use PKI interface for receive */ +#define BDK_BGX_PKO 0 /* When defined and non zero BGX will use PKO interface for transmit */ + +#define BDK_IF_MAX_GATHER 12 /* CN88XX RX supports 12 at most */ + +/* PHY address encoding: + Bits[31:24]: Node ID, 0xff for node the ethernet device is on + Bits[23:16]: Only used for TWSI + Bits[15:12]: PHY connection type (0=MDIO, 1=Fixed, 2=TWSI) + For MDIO: + Bits[31:24]: Node ID, 0xff for node the ethernet device is on + Bits[23:16]: 0 + Bits[15:12]: 0=MDIO + Bits[11:8]: MDIO bus number + Bits[7:0]: MDIO address + For Fixed: + Bits[31:24]: 0 + Bits[23:16]: Zero + Bits[15:12]: 1=Fixed + Bits[11:0]: 0 = 1Gb, 1 = 100Mb + For TWSI: + Bits[31:24]: Node ID, 0xff for node the ethernet device is on + Bits[23:16]: TWSI internal address width in bytes (0-2) + Bits[15:12]: 2=TWSI + Bits[11:8]: TWSI bus number + Bits[7:0]: TWSI address + */ +#define BDK_IF_PHY_TYPE_MASK 0xf000 +#define BDK_IF_PHY_MDIO 0x0000 +#define BDK_IF_PHY_TWSI 0x2000 +#define BDK_IF_PHY_FIXED_1GB 0x1000 +#define BDK_IF_PHY_FIXED_100MB 0x1001 + +/** + * Enumeration of different interfaces. + */ +typedef enum +{ + BDK_IF_BGX, + BDK_IF_PCIE, + BDK_IF_FAKE, + BDK_IF_LBK, + BDK_IF_RGX, + BDK_IF_CGX, + __BDK_IF_LAST +} bdk_if_t; + +typedef enum +{ + BDK_IF_FLAGS_HAS_FCS = 1, /* The device adds and removes an FCS. On thunder we assume the hardware strips FCS */ + BDK_IF_FLAGS_ENABLED = 2, +} bdk_if_flags_t; + +typedef union +{ + uint64_t u64; + struct + { + uint64_t reserved2 : 32; + unsigned speed : 24; + unsigned lanes : 6; + int full_duplex : 1; + int up : 1; + } s; +} bdk_if_link_t; + +typedef struct +{ + uint64_t dropped_octets; + uint64_t dropped_packets; + uint64_t octets; + uint64_t packets; + uint64_t errors; +} __bdk_if_stats_t; + +typedef struct +{ + __bdk_if_stats_t rx; + __bdk_if_stats_t tx; +} bdk_if_stats_t; + +typedef struct __bdk_if_port +{ + bdk_if_t iftype : 8; + bdk_node_t node : 8; + int interface : 8; + int index : 8; + bdk_if_flags_t flags : 8; + int pknd : 8; /* NIC/PKI packet kind */ + int16_t pki_channel; /* PKI/SSO channel number, or -1 if not used */ + int16_t pki_dstat; /* PKI DSTAT ID used for receive stats */ + int16_t pko_queue; /* PKO DQ number, or -1 if not used */ + int16_t aura; /* FPA aura number */ + int16_t nic_id; /* NIC ID in use, or -1 if not used. Encoded as NIC_VF * 8 + index */ + void * receiver; /* This is a bdk_if_packet_receiver_t */ + void * receiver_arg; + bdk_if_stats_t stats; + bdk_if_link_t link_info; + char name[16]; + struct __bdk_if_port *next; + struct __bdk_if_port *poll_next; + char priv[0]; +} __bdk_if_port_t; + +typedef __bdk_if_port_t *bdk_if_handle_t; + +/** + * Format of each gather/segment entry in a packet. This is unrelated to + * the underlying hardware format, but is designed to be simple to munge + * into a hardware format. Note that only 48 bits are stored for the + * address. This address is a physical address not mean for SMMU translation. + */ +typedef union +{ + uint64_t u; + struct + { +#if __BYTE_ORDER == __BIG_ENDIAN + uint64_t size : 16; + uint64_t address : 48; +#else + uint64_t address : 48; + uint64_t size : 16; +#endif + } s; +} bdk_packet_ptr_t; + +typedef enum +{ + BDK_IF_TYPE_UNKNOWN, /* Not set */ + BDK_IF_TYPE_UDP4, /* IPv4 + UDP */ + BDK_IF_TYPE_TCP4, /* IPv4 + TCP */ +} bdk_if_type_t; + +/** + * The packet format for the BDK. This structure is designed to be exactly + * one cache line to promote alignment and avoid false aliasing. Note that the + * packet structure is independent from the packet data and can have a shorter + * lifespan. The packet structure is normally on the stack and disappears on + * stack unwind. Code requiring its data to stick around needs to copy it, but + * not the data in the gather list. + */ +typedef struct +{ + bdk_if_handle_t if_handle; /* Handle to interface this packet was received on */ + int length; /* Length of the packet in bytes */ + int segments; /* Number of segments the packet is spread over */ + int rx_error; /* Error number when packet was receive or zero for no error */ + bdk_if_type_t packet_type : 16; /* Type of the packet, so sender doesn't need to walk packet */ + uint16_t mtu; /* MTU for hardware fragment, such as TSO */ + uint64_t reserved2; /* Reserved for future use */ + bdk_packet_ptr_t packet[BDK_IF_MAX_GATHER]; /* List of segements. Each has a physical address and length */ +} bdk_if_packet_t; + +typedef enum +{ + BDK_IF_LOOPBACK_NONE = 0, + BDK_IF_LOOPBACK_INTERNAL = 1, + BDK_IF_LOOPBACK_EXTERNAL = 2, + BDK_IF_LOOPBACK_INTERNAL_EXTERNAL = 3, +} bdk_if_loopback_t; + +typedef void (*bdk_if_packet_receiver_t)(const bdk_if_packet_t *packet, void *arg); + +typedef struct +{ + int priv_size; + int (*if_num_interfaces)(bdk_node_t node); /* Returns the number of interfaces possible on this chip */ + int (*if_num_ports)(bdk_node_t node, int interface); /* For given interface, returns the number of ports on it */ + int (*if_probe)(bdk_if_handle_t handle); /* Probe to see if a port exists */ + int (*if_init)(bdk_if_handle_t handle); /* One time hardware init */ + int (*if_enable)(bdk_if_handle_t handle); /* Enable packet IO. must be called after init */ + int (*if_disable)(bdk_if_handle_t handle); /* Disable packet IO */ + bdk_if_link_t (*if_link_get)(bdk_if_handle_t handle); /* Get link speed and state */ + void (*if_link_set)(bdk_if_handle_t handle, bdk_if_link_t link_info); /* Set link speed and state */ + const bdk_if_stats_t *(*if_get_stats)(bdk_if_handle_t handle); /* Get stats */ + int (*if_transmit)(bdk_if_handle_t handle, const bdk_if_packet_t *packet); /* TX a packet */ + int (*if_loopback)(bdk_if_handle_t handle, bdk_if_loopback_t loopback); /* Configure loopback for the port */ + int (*if_get_queue_depth)(bdk_if_handle_t handle); /* Get the current TX queue depth */ + uint64_t (*if_get_lane_mask)(bdk_if_handle_t handle); /* Get a mask of the QLM lanes used by this handle */ +} __bdk_if_ops_t; + +typedef struct +{ + int (*init)(void); + uint64_t (*alloc)(int length); + void (*free)(uint64_t address, int length); +} __bdk_if_global_ops_t; + +extern int bdk_if_is_configured(void); +extern int bdk_if_num_interfaces(bdk_node_t node, bdk_if_t iftype); +extern int bdk_if_num_ports(bdk_node_t node, bdk_if_t iftype, int interface); +extern bdk_if_handle_t bdk_if_next_port(bdk_if_handle_t handle); + +extern int bdk_if_enable(bdk_if_handle_t handle); +extern int bdk_if_disable(bdk_if_handle_t handle); +extern int bdk_if_loopback(bdk_if_handle_t handle, bdk_if_loopback_t loopback); + +extern const char *bdk_if_name(bdk_if_handle_t handle); +extern bdk_if_link_t bdk_if_link_get(bdk_if_handle_t handle); +extern bdk_if_link_t bdk_if_link_autoconf(bdk_if_handle_t handle); +extern const bdk_if_stats_t *bdk_if_get_stats(bdk_if_handle_t handle); +extern bdk_if_link_t __bdk_if_phy_get(bdk_node_t dev_node, int phy_addr); +extern int bdk_if_get_queue_depth(bdk_if_handle_t handle); +extern int bdk_if_link_wait_all(uint64_t timeout_us); +extern int bdk_if_phy_setup(bdk_node_t node); +extern int bdk_if_phy_vetesse_setup(bdk_node_t node, int qlm, int mdio_bus, int phy_addr); +extern int bdk_if_phy_marvell_setup(bdk_node_t node, int qlm, int mdio_bus, int phy_addr); +extern int bdk_if_phy_vsc8514_setup(bdk_node_t node, int qlm, int mdio_bus, int phy_addr); +extern int bdk_if_transmit(bdk_if_handle_t handle, bdk_if_packet_t *packet); +extern void bdk_if_register_for_packets(bdk_if_handle_t handle, bdk_if_packet_receiver_t receiver, void *arg); +extern int bdk_if_alloc(bdk_if_packet_t *packet, int length); +extern void bdk_if_free(bdk_if_packet_t *packet); +extern void bdk_if_packet_read(const bdk_if_packet_t *packet, int location, int length, void *data); +extern void bdk_if_packet_write(bdk_if_packet_t *packet, int location, int length, const void *data); + +extern uint64_t bdk_update_stat_with_overflow(uint64_t new_value, uint64_t old_value, int bit_size); +extern void __bdk_if_phy_xs_init(bdk_node_t dev_node, int phy_addr); + +/** + * Get interface type. Use this function instead of accessing the handle + * directly. The handle is considered private and may change. + * + * @param handle Handle of port to get info for + * + * @return Interface type + */ +static inline bdk_if_t bdk_if_get_type(bdk_if_handle_t handle) +{ + return handle->iftype; +} + +/** + * Called by each interface driver to process a received packet. After calling + * this function, it is the responsibility of each driver to free any resources + * used by the packet, probably by calling bdk_if_free(). + * + * @param packet Packet that was received + */ +static inline void bdk_if_dispatch_packet(const bdk_if_packet_t *packet) +{ + void *receiver_arg = packet->if_handle->receiver_arg; + bdk_if_packet_receiver_t receiver = packet->if_handle->receiver; + if (receiver) + receiver(packet, receiver_arg); +} + +/** + * Get the base QLM used by this handle. For network interfaces that uses QLMs, + * return the QLM number of lane 0. Note that some network interfaces span multiple + * QLM/DLM. This will return the lowest QLM/DLM number. + * + * @param handle Handle to query + * + * @return QLM/DLM number, or -1 if handle doesn't use SERDES + */ +extern int bdk_if_get_qlm(bdk_if_handle_t handle); + +/** + * Get a mask of the QLM/DLM lanes used by this handle. A bit is set for each lane + * used by the interface. Some ports span multiple QLM/DLM. In this case the bits + * set will be wider than the QLM/DLM, signalling that the next QLM/DLM is needed + * too. + * + * @param handle Handle to query + * + * @return Lane mask, or zero if no SERDES lanes are used + */ +extern uint64_t bdk_if_get_lane_mask(bdk_if_handle_t handle); + +/** @} */ +#endif diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/qlm/bdk-qlm-common.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/qlm/bdk-qlm-common.h new file mode 100644 index 0000000000..9bdf1dd40a --- /dev/null +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/qlm/bdk-qlm-common.h @@ -0,0 +1,326 @@ +/***********************license start*********************************** +* Copyright (c) 2003-2017 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**************************************/ +#ifndef __BDK_QLM_COMMON_H__ +#define __BDK_QLM_COMMON_H__ + +/* Common QLM code for Thunder based processors. The following chips + use the same style SERDES, using the code defined in this header. + CN88XX + CN83XX +*/ + +/* These constants represent the possible QLM reference clock speeds in Hz */ +#define REF_100MHZ 100000000 +#define REF_125MHZ 125000000 +#define REF_156MHZ 156250000 + +/** + * Figure out which lane mode to use for a given reference clock and GBaud + * + * @param mode_name String name for error messages + * @param qlm QlM being configured + * @param ref_clk Reference clock in hertz + * @param baud_mhz Baud rate in Mhz + * + * @return Lane mode or -1 on failure + */ +extern int __bdk_qlm_get_lane_mode_for_speed_and_ref_clk(const char *mode_name, int qlm, int ref_clk, int baud_mhz); + +/** + * Setup the PEM to either driver or receive reset from PRST based on RC or EP + * + * @param node Node to use in a Numa setup + * @param pem Which PEM to setuo + * @param is_endpoint + * Non zero if PEM is a EP + */ +extern void __bdk_qlm_setup_pem_reset(bdk_node_t node, int pem, int is_endpoint); + +/** + * Measure the reference clock of a QLM + * + * @param qlm QLM to measure + * + * @return Clock rate in Hz + */ +extern int __bdk_qlm_measure_refclock(bdk_node_t node, int qlm); + +/** + * Put a QLM into hardware reset + * + * @param node Node to use in a numa setup + * @param qlm QLM to use + * + * @return Zero on success, negative on failure + */ +extern int __bdk_qlm_reset(bdk_node_t node, int qlm); + +/** + * Enable PRBS on a QLM + * + * @param node Node to use in a numa setup + * @param qlm QLM to use + * @param prbs PRBS mode (31, etc) + * @param dir Directions to enable. This is so you can enable TX and later + * enable RX after TX has run for a time + * + * @return Zero on success, negative on failure + */ +extern int __bdk_qlm_enable_prbs(bdk_node_t node, int qlm, int prbs, bdk_qlm_direction_t dir); + +/** + * Disable PRBS on a QLM + * + * @param node Node to use in a numa setup + * @param qlm QLM to use + * + * @return Zero on success, negative on failure + */ +extern int __bdk_qlm_disable_prbs(bdk_node_t node, int qlm); + +/** + * Return the number of PRBS errors since PRBS started running + * + * @param node Node to use in numa setup + * @param qlm QLM to use + * @param lane Which lane + * @param clear Clear counter after return the current value + * + * @return Number of errors + */ +extern uint64_t __bdk_qlm_get_prbs_errors(bdk_node_t node, int qlm, int lane, int clear); + +/** + * Inject an error into PRBS + * + * @param node Node to use in numa setup + * @param qlm QLM to use + * @param lane Which lane + */ +extern void __bdk_qlm_inject_prbs_error(bdk_node_t node, int qlm, int lane); + +/** + * Enable shallow loopback on a QLM + * + * @param node Node to use in a numa setup + * @param qlm QLM to use + * @param loop Type of loopback. Not all QLMs support all modes + * + * @return Zero on success, negative on failure + */ +extern int __bdk_qlm_enable_loop(bdk_node_t node, int qlm, bdk_qlm_loop_t loop); + +/** + * Initialize the QLM mode table + * + * @param node Node to initialize + * @param qlm Which QLM + * @param ref_clk Reference clock of the QLM in Hz + */ +extern void __bdk_qlm_init_mode_table(bdk_node_t node, int qlm, int ref_clk); + +/** + * Given a valid PEM number, return its speed in Gbaud + * + * @param node Node to use in numa setup + * @param pem PEM to get speed of + * + * @return Speed in Gbaud. Zero if disabled + */ +extern int __bdk_qlm_get_gbaud_mhz_pem(bdk_node_t node, int pem); + +/** + * Get the speed of a QLM using its LMODE. This can't be used on PCIe QLMs. + * + * @param node Node to use in numa setup + * @param qlm Which QLM + * + * @return QLM speed on Gbaud + */ +extern int __bdk_qlm_get_gbaud_mhz_lmode(bdk_node_t node, int qlm); + +/** + * Converts a measured reference clock to a likely ideal value. Rounds + * clock speed to the nearest REF_*Mhz define. + * + * @param node Node to use in numa setup + * @param qlm Which QLM + * @param measured_hz + * Measured value + * + * @return Value exactly matching a define + */ +extern int __bdk_qlm_round_refclock(bdk_node_t node, int qlm, int measured_hz); + +/** + * For Cavium EVB and EBB board, query the MCU to determine the QLM setup. Applying + * any configuration found. + * + * @param node Node to configure + * + * @return Zero on success, negative on failure + */ +extern int bdk_qlm_mcu_auto_config(bdk_node_t node); + +/** + * Display the current settings of a QLM lane + * + * @param node Node the QLM is on + * @param qlm QLM to display + * @param qlm_lane Lane to use + * @param show_tx Display TX parameters + * @param show_rx Display RX parameters + */ +extern void bdk_qlm_display_settings(bdk_node_t node, int qlm, int qlm_lane, bool show_tx, bool show_rx); + +/** + * Perform RX equalization on a QLM + * + * @param node Node the QLM is on + * @param qlm QLM to perform RX equalization on + * @param qlm_lane Lane to use, or -1 for all lanes + * + * @return Zero on success, negative if any lane failed RX equalization + */ +extern int __bdk_qlm_rx_equalization(bdk_node_t node, int qlm, int qlm_lane); + +/** + * Configure the TX tuning parameters for a QLM lane. The tuning parameters can + * be specified as -1 to maintain their current value + * + * @param node Node to configure + * @param qlm QLM to configure + * @param lane Lane to configure + * @param tx_swing Transmit swing (coef 0) Range 0-31 + * @param tx_pre Pre cursor emphasis (Coef -1). Range 0-15 + * @param tx_post Post cursor emphasis (Coef +1). Range 0-31 + * @param tx_gain Transmit gain. Range 0-7 + * @param tx_vboost Transmit voltage boost. Range 0-1 + * + * @return Zero on success, negative on failure + */ +extern int __bdk_qlm_tune_lane_tx(bdk_node_t node, int qlm, int lane, int tx_swing, int tx_pre, int tx_post, int tx_gain, int tx_vboost); + +/** + * Some QLM speeds need to override the default tuning parameters + * + * @param node Node to use in a Numa setup + * @param qlm QLM to configure + * @param mode Desired mode + * @param baud_mhz Desired speed + */ +extern void __bdk_qlm_tune(bdk_node_t node, int qlm, bdk_qlm_modes_t mode, int baud_mhz); + +/** + * Capture an eye diagram for the given QLM lane. The output data is written + * to "eye". + * + * @param node Node to use in numa setup + * @param qlm QLM to use + * @param qlm_lane Which lane + * @param eye Output eye data + * + * @return Zero on success, negative on failure + */ +extern int __bdk_qlm_eye_capture_cn8xxx(bdk_node_t node, int qlm, int lane, bdk_qlm_eye_t *eye_data) BDK_WEAK; + +/** + * Disables DFE for the specified QLM lane(s). + * This function should only be called for low-loss channels. + * + * @param node Node to configure + * @param qlm QLM to configure + * @param lane Lane to configure, or -1 for all lanes + */ +extern void __bdk_qlm_dfe_disable(int node, int qlm, int lane); + +/** + * Check if a specific lane is using KR training. This is used by low level GSER + * code to remember which QLMs and lanes need to support KR training for BGX. The + * hardware doesn't have a bit set aside to record this, so we repurpose the + * register GSERX_SCRATCH. + * + * @param node Node to check + * @param qlm QLM to check + * @param lane Lane to check + * + * @return True if this lane uses KR with BGX, false otherwise + */ +extern bool __bdk_qlm_is_lane_kr(bdk_node_t node, int qlm, int lane); + +/** + * Set if a specific lane is using KR training. This is used by low level GSER + * code to remember which QLMs and lanes need to support KR training for BGX. The + * hardware doesn't have a bit set aside to record this, so we repurpose the + * register GSERX_SCRATCH. + * + * @param node Node to set + * @param qlm QLM to set + * @param lane Lane to set + * @param is_kr KR (true) or XFI/XLAUI (false) + */ +extern void __bdk_qlm_set_lane_kr(bdk_node_t node, int qlm, int lane, bool is_kr); + +/** + * Initialize a DLM/QLM for use with SATA controllers + * + * @param node Node to intialize + * @param qlm Which DLM/QLM to init + * @param baud_mhz QLM speed in Gbaud + * @param sata_first First SATA controller connected to this DLM/QLM + * @param sata_last Last SATA controller connected to this DLM/QLM (inclusive) + * + * @return Zero on success, negative on failure + */ +extern int __bdk_qlm_set_sata_cn8xxx(bdk_node_t node, int qlm, int baud_mhz, int sata_first, int sata_last); + +/** + * Initialize a DLM/QLM for use with SATA controllers + * + * @param node Node to intialize + * @param qlm Which DLM/QLM to init + * @param baud_mhz QLM speed in Gbaud + * @param sata_first First SATA controller connected to this DLM/QLM + * @param sata_last Last SATA controller connected to this DLM/QLM (inclusive) + * + * @return Zero on success, negative on failure + */ +extern int __bdk_qlm_set_sata_cn9xxx(bdk_node_t node, int qlm, int baud_mhz, int sata_first, int sata_last); + +#endif /* __BDK_QLM_COMMON_H__ */ diff --git a/src/vendorcode/cavium/include/bdk/libbdk-hal/qlm/bdk-qlm-errata-cn8xxx.h b/src/vendorcode/cavium/include/bdk/libbdk-hal/qlm/bdk-qlm-errata-cn8xxx.h new file mode 100644 index 0000000000..8c1b47ab64 --- /dev/null +++ b/src/vendorcode/cavium/include/bdk/libbdk-hal/qlm/bdk-qlm-errata-cn8xxx.h @@ -0,0 +1,152 @@ +/***********************license start*********************************** +* Copyright (c) 2003-2017 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**************************************/ +#ifndef __BDK_QLM_ERRATA_H__ +#define __BDK_QLM_ERRATA_H__ + +/** + * Errata GSER-25992 - RX EQ Default Settings Update

+ * For all GSER and all lanes when not PCIe EP: + * set GSER()_LANE()_RX_CFG_4[CFG_RX_ERRDET_CTRL<13:8>] = 13 (decimal) + * set GSER()_LANE()_RX_CTLE_CTRL[PCS_SDS_RX_CTLE_BIAS_CTRL] = 3 + * Applied when SERDES are configured for 8G and 10G.

+ * Applies to: + * CN88XX pass 1.x + * Fixed in hardware: + * CN88XX pass 2.x + * CN81XX + * CN83XX + * + * @param node Node to apply errata fix for + * @param qlm QLM to apply errata fix to + * @param baud_mhz QLM speed in Mhz + * + * @return Zero on success, negative on failure + */ +int __bdk_qlm_errata_gser_25992(bdk_node_t node, int qlm, int baud_mhz); + +/** + * (GSER-26150) 10G PHY PLL Temperature Failure + * + * 10 Gb temperature excursions can cause lock failure. Change + * the calibration point of the VCO at start up to shift some + * available range of the VCO from -deltaT direction to the + * +deltaT ramp direction allowing a greater range of VCO + * temperatures before experiencing the failure. + * + * Applies to: + * CN88XX pass 1.x + * Fix in hardware: + * CN88XX pass 2.x + * CN81XX + * CN83XX + * + * Only applies to QLMs running 8G and 10G + * + * @param node Node to apply errata to + * @param qlm QLM to apply errata fix to + * + * @return Zero on success, negative on failure + */ +int __bdk_qlm_errata_gser_26150(bdk_node_t node, int qlm, int baud_mhz); + +/** + * Errata (GSER-26636) 10G-KR/40G-KR - Inverted Tx Coefficient Direction Change + * Applied to all 10G standards (required for KR) but also applied to other + * standards in case software training is used. + * Applies to: + * CN88XX pass 1.x + * Fixed in hardware: + * CN88XX pass 2.x + * CN81XX + * CN83XX + * + * @param node Node to apply errata fix for + * @param qlm QLM to apply errata fix to + * @param baud_mhz QLM speed in Mhz + * + * @return Zero on success, negative on failure + */ +int __bdk_qlm_errata_gser_26636(bdk_node_t node, int qlm, int baud_mhz); + +/** + * (GSER-27140) SERDES has temperature drift sensitivity in the RX EQ

+ * SERDES temperature drift sensitivity in receiver. Issues have + * been found with the Bit Error Rate (BER) reliability of + * 10GBASE-KR links over the commercial temperature range (0 to 100C), + * especially when subjected to rapid thermal ramp stress testing. + * (See HRM for corresponding case temperature requirements for each speed grade.)

+ * Applies to: + * CN88XX pass 1.x + * CN88XX pass 2.x + * CN83XX pass 1.x + * CN81XX pass 1.x + * Fixed in hardware: + * TBD

+ * Only applies to QLMs running 10G + * + * @param node Note to apply errata fix to + * @param qlm QLM to apply errata fix to + * @param baud_mhz QLM baud rate in Mhz + * @param channel_loss + * Insertion loss at Nyquist rate (e.g. 5.125Ghz for XFI/XLAUI) in dB + * + * @return Zero on success, negative on failure + */ +int __bdk_qlm_errata_gser_27140(bdk_node_t node, int qlm, int baud_mhz, int channel_loss); + +/** + * Errata GSER-27882 -GSER 10GBASE-KR Transmit Equalizer + * Training may not update PHY Tx Taps. This function is not static + * so we can share it with BGX KR + * Applies to: + * CN88XX pass 1.x, 2.0, 2.1 + * Fixed in hardware: + * CN88XX pass 2.2 and higher + * CN81XX + * CN83XX + * + * @param node Node to apply errata fix for + * @param qlm QLM to apply errata fix to + * @param lane + * + * @return Zero on success, negative on failure + */ +int __bdk_qlm_errata_gser_27882(bdk_node_t node, int qlm, int lane); + +#endif /* __BDK_QLM_ERRATA_H__ */ -- cgit v1.2.3