1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Networks (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * * Neither the name of Cavium Networks nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
23 * This Software, including technical data, may be subject to U.S. export control
24 * laws, including the U.S. Export Administration Act and its associated
25 * regulations, and may be subject to export or import regulations in other
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
48 * File defining checks for different Octeon features.
50 * <hr>$Revision: 30468 $<hr>
53 #ifndef __OCTEON_FEATURE_H__
54 #define __OCTEON_FEATURE_H__
62 OCTEON_FEATURE_SAAD, /**< Octeon models in the CN5XXX family and higher support atomic add instructions to memory (saa/saad) */
63 OCTEON_FEATURE_ZIP, /**< Does this Octeon support the ZIP offload engine? */
64 OCTEON_FEATURE_CRYPTO, /**< Does this Octeon support crypto acceleration using COP2? */
65 OCTEON_FEATURE_DORM_CRYPTO, /**< Can crypto be enabled by calling cvmx_crypto_dormant_enable()? */
66 OCTEON_FEATURE_PCIE, /**< Does this Octeon support PCI express? */
67 OCTEON_FEATURE_SRIO, /**< Does this Octeon support SRIOs */
68 OCTEON_FEATURE_KEY_MEMORY, /**< Some Octeon models support internal memory for storing cryptographic keys */
69 OCTEON_FEATURE_LED_CONTROLLER, /**< Octeon has a LED controller for banks of external LEDs */
70 OCTEON_FEATURE_TRA, /**< Octeon has a trace buffer */
71 OCTEON_FEATURE_MGMT_PORT, /**< Octeon has a management port */
72 OCTEON_FEATURE_RAID, /**< Octeon has a raid unit */
73 OCTEON_FEATURE_USB, /**< Octeon has a builtin USB */
74 OCTEON_FEATURE_NO_WPTR, /**< Octeon IPD can run without using work queue entries */
75 OCTEON_FEATURE_DFA, /**< Octeon has DFA state machines */
76 OCTEON_FEATURE_MDIO_CLAUSE_45, /**< Octeon MDIO block supports clause 45 transactions for 10 Gig support */
77 OCTEON_FEATURE_NPEI, /**< CN52XX and CN56XX used a block named NPEI for PCIe access. Newer chips replaced this with SLI+DPI */
81 * Determine if the current Octeon supports a specific feature. These
82 * checks have been optimized to be fairly quick, but they should still
83 * be kept out of fast path code.
85 * @param feature Feature to check for. This should always be a constant so the
86 * compiler can remove the switch statement through optimization.
88 * @return Non zero if the feature exists. Zero if the feature does not
91 static inline int octeon_has_feature(octeon_feature_t feature)
95 case OCTEON_FEATURE_SAAD:
96 return !OCTEON_IS_MODEL(OCTEON_CN3XXX);
98 case OCTEON_FEATURE_ZIP:
99 if (OCTEON_IS_MODEL(OCTEON_CN30XX) || OCTEON_IS_MODEL(OCTEON_CN50XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
102 return !cvmx_fuse_read(121);
104 case OCTEON_FEATURE_CRYPTO:
105 if (OCTEON_IS_MODEL(OCTEON_CN6XXX)) {
106 cvmx_mio_fus_dat2_t fus_2;
107 fus_2.u64 = cvmx_read_csr(CVMX_MIO_FUS_DAT2);
108 if (fus_2.s.nocrypto || fus_2.s.nomul) {
110 } else if (!fus_2.s.dorm_crypto) {
113 cvmx_rnm_ctl_status_t st;
114 st.u64 = cvmx_read_csr(CVMX_RNM_CTL_STATUS);
118 return !cvmx_fuse_read(90);
121 case OCTEON_FEATURE_DORM_CRYPTO:
122 if (OCTEON_IS_MODEL(OCTEON_CN6XXX)) {
123 cvmx_mio_fus_dat2_t fus_2;
124 fus_2.u64 = cvmx_read_csr(CVMX_MIO_FUS_DAT2);
125 return !fus_2.s.nocrypto && !fus_2.s.nomul && fus_2.s.dorm_crypto;
130 case OCTEON_FEATURE_PCIE:
131 return (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN6XXX));
133 case OCTEON_FEATURE_SRIO:
134 return (OCTEON_IS_MODEL(OCTEON_CN6XXX));
136 case OCTEON_FEATURE_KEY_MEMORY:
137 return OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN6XXX);
139 case OCTEON_FEATURE_LED_CONTROLLER:
140 return OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN56XX);
142 case OCTEON_FEATURE_TRA:
143 return !(OCTEON_IS_MODEL(OCTEON_CN30XX) || OCTEON_IS_MODEL(OCTEON_CN50XX));
144 case OCTEON_FEATURE_MGMT_PORT:
145 return OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN6XXX);
147 case OCTEON_FEATURE_RAID:
148 return OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN6XXX);
150 case OCTEON_FEATURE_USB:
151 return !(OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX));
153 case OCTEON_FEATURE_NO_WPTR:
154 return (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN6XXX)) &&
155 !OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X) && !OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X);
157 case OCTEON_FEATURE_DFA:
158 if (!OCTEON_IS_MODEL(OCTEON_CN38XX) && !OCTEON_IS_MODEL(OCTEON_CN31XX) && !OCTEON_IS_MODEL(OCTEON_CN58XX))
160 else if (OCTEON_IS_MODEL(OCTEON_CN3020))
163 return !cvmx_fuse_read(120);
165 case OCTEON_FEATURE_MDIO_CLAUSE_45:
166 return !(OCTEON_IS_MODEL(OCTEON_CN3XXX) || OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN50XX));
168 case OCTEON_FEATURE_NPEI:
169 return (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX));
178 #endif /* __OCTEON_FEATURE_H__ */