/***********************license start*************** * Copyright (c) 2003-2009 Cavium Networks (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 Networks nor the names of * its contributors may be used to endorse or promote products * derived from this software without specific prior written * permission. * * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" * AND WITH ALL FAULTS AND CAVIUM NETWORKS 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. * * * For any questions regarding licensing please contact marketing@caviumnetworks.com * ***********************license end**************************************/ /** * @file * Small utility functions and macros to ease programming of Octeon. * *
* 6 5 4 3 3 2 1 * 3 5 7 9 1 3 5 7 0 * +-------+-------+-------+-------+-------+-------+-------+------+ * 000000000000000000000000___________value000000000000000000000000 ** * @param high_bit Highest bit value can occupy (inclusive) 0-63 * @param low_bit Lowest bit value can occupy inclusive 0-high_bit * @param value Value to use * @return Value masked and shifted */ static inline uint64_t cvmx_build_bits(uint64_t high_bit, uint64_t low_bit, uint64_t value) { return ((value & cvmx_build_mask(high_bit - low_bit + 1)) << low_bit); } /** * Return the number of cores available in the chip * * @return */ static inline uint32_t cvmx_octeon_num_cores(void) { uint32_t ciu_fuse = (uint32_t)cvmx_read_csr(CVMX_CIU_FUSE) & 0xffff; return cvmx_pop(ciu_fuse); } /** * Return true if Octeon is CN38XX pass 1 * * @return */ static inline int cvmx_octeon_is_pass1(void) { return OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1); } /** * Return true if Octeon is CN36XX * * @return */ static inline int cvmx_octeon_model_CN36XX(void) { return(OCTEON_IS_MODEL(OCTEON_CN38XX) && !OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1) &&cvmx_fuse_read(264)); } /** * @deprecated * Determine if Octeon supports the DFA state machines. This function is * deprecated, use octeon_has_feature(OCTEON_FEATURE_DFA) instead. * * @return Non zero if DFA is supported */ static inline int cvmx_octeon_dfa_present(void) __attribute__((deprecated)); static inline int cvmx_octeon_dfa_present(void) { return octeon_has_feature(OCTEON_FEATURE_DFA); } /** * @deprecated * Determine if Octeon supports ZIP. This function is deprecated, use * octeon_has_feature(OCTEON_FEATURE_ZIP) instead. * * @return Non zero if DFA is supported */ static inline int cvmx_octeon_zip_present(void) __attribute__((deprecated)); static inline int cvmx_octeon_zip_present(void) { return octeon_has_feature(OCTEON_FEATURE_ZIP); } /** * @deprecated * Determine if Octeon supports Crypto acceleration. This function is * deprecated, use octeon_has_feature(OCTEON_FEATURE_CRYPTO) instead. * * @return Non zero if DFA is supported */ static inline int cvmx_octeon_crypto_present(void) __attribute__((deprecated)); static inline int cvmx_octeon_crypto_present(void) { return octeon_has_feature(OCTEON_FEATURE_CRYPTO); } /** * @deprecated * This function is a trival wrapper around cvmx_read64_uint64(). Use * cvmx_read64_uint64() instead as this function is deprecated. * * @param address * * @return */ static inline uint64_t cvmx_read64(uint64_t address) __attribute__((deprecated)); static inline uint64_t cvmx_read64(uint64_t address) { return cvmx_read64_uint64(address); } /** * @deprecated * This function is a trival wrapper around cvmx_write64_uint64(). Use * cvmx_write64_uint64() instead as this function is deprecated. * * @param address Location to write ro * @param value Value to write * * @return */ static inline void cvmx_write64(uint64_t address, uint64_t value) __attribute__((deprecated)); static inline void cvmx_write64(uint64_t address, uint64_t value) { cvmx_write64_uint64(address, value); } #ifdef __cplusplus } #endif #endif /* __CVMX_UTILS_H__ */