1 /***********************license start***************
2 * Copyright (c) 2003-2008 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 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
46 * File defining checks for different Octeon features.
48 * <hr>$Revision: 30468 $<hr>
51 #ifndef __OCTEON_FEATURE_H__
52 #define __OCTEON_FEATURE_H__
60 OCTEON_FEATURE_SAAD, /* Octeon models in the CN5XXX family and higher support atomic add instructions to memory (saa/saad) */
61 OCTEON_FEATURE_ZIP, /* Does this Octeon support the ZIP offload engine? */
62 OCTEON_FEATURE_CRYPTO, /* Does this Octeon support crypto acceleration using COP2? */
63 OCTEON_FEATURE_PCIE, /* Does this Octeon support PCI express? */
64 OCTEON_FEATURE_KEY_MEMORY, /* Some Octeon models support internal memory for storing cryptographic keys */
65 OCTEON_FEATURE_LED_CONTROLLER, /* Octeon has a LED controller for banks of external LEDs */
66 OCTEON_FEATURE_TRA, /* Octeon has a trace buffer */
67 OCTEON_FEATURE_MGMT_PORT, /* Octeon has a management port */
68 OCTEON_FEATURE_RAID, /* Octeon has a raid unit */
69 OCTEON_FEATURE_USB, /* Octeon has a builtin USB */
70 OCTEON_FEATURE_NO_WPTR, /* Octeon IPD can run without using work queue entries */
71 OCTEON_FEATURE_DFA, /* Octeon has DFA state machines */
72 OCTEON_FEATURE_MDIO_CLAUSE_45, /* Octeon MDIO block supports clause 45 transactions for 10 Gig support */
76 * Determine if the current Octeon supports a specific feature. These
77 * checks have been optimized to be fairly quick, but they should still
78 * be kept out of fast path code.
80 * @param feature Feature to check for. This should always be a constant so the
81 * compiler can remove the switch statement through optimization.
83 * @return Non zero if the feature exists. Zero if the feature does not
86 static inline int octeon_has_feature(octeon_feature_t feature)
90 case OCTEON_FEATURE_SAAD:
91 return !OCTEON_IS_MODEL(OCTEON_CN3XXX);
93 case OCTEON_FEATURE_ZIP:
94 if (OCTEON_IS_MODEL(OCTEON_CN30XX) || OCTEON_IS_MODEL(OCTEON_CN50XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
96 else if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1))
99 return (!cvmx_fuse_read(121));
101 case OCTEON_FEATURE_CRYPTO:
102 return (!cvmx_fuse_read(90));
104 case OCTEON_FEATURE_PCIE:
105 return (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX));
107 case OCTEON_FEATURE_KEY_MEMORY:
108 case OCTEON_FEATURE_LED_CONTROLLER:
109 return (OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN56XX));
110 case OCTEON_FEATURE_TRA:
111 return !(OCTEON_IS_MODEL(OCTEON_CN30XX) || OCTEON_IS_MODEL(OCTEON_CN50XX));
112 case OCTEON_FEATURE_MGMT_PORT:
113 return (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX));
114 case OCTEON_FEATURE_RAID:
115 return (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX));
116 case OCTEON_FEATURE_USB:
117 return !(OCTEON_IS_MODEL(OCTEON_CN38XX) || OCTEON_IS_MODEL(OCTEON_CN58XX));
118 case OCTEON_FEATURE_NO_WPTR:
119 return ((OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX)) &&
120 !OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X) && !OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X));
121 case OCTEON_FEATURE_DFA:
122 if (!OCTEON_IS_MODEL(OCTEON_CN38XX) && !OCTEON_IS_MODEL(OCTEON_CN31XX) && !OCTEON_IS_MODEL(OCTEON_CN58XX))
124 else if (OCTEON_IS_MODEL(OCTEON_CN3020))
126 else if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1))
129 return(!cvmx_fuse_read(120));
130 case OCTEON_FEATURE_MDIO_CLAUSE_45:
131 return (!(OCTEON_IS_MODEL(OCTEON_CN3XXX) || OCTEON_IS_MODEL(OCTEON_CN58XX) || OCTEON_IS_MODEL(OCTEON_CN50XX)));
140 #endif /* __OCTEON_FEATURE_H__ */