octeon-feature.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /***********************license start***************
  2. * Author: Cavium Networks
  3. *
  4. * Contact: [email protected]
  5. * This file is part of the OCTEON SDK
  6. *
  7. * Copyright (c) 2003-2008 Cavium Networks
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more
  17. * details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this file; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. * or visit http://www.gnu.org/licenses/.
  23. *
  24. * This file may also be available under a different license from Cavium.
  25. * Contact Cavium Networks for more information
  26. ***********************license end**************************************/
  27. /*
  28. * File defining checks for different Octeon features.
  29. */
  30. #ifndef __OCTEON_FEATURE_H__
  31. #define __OCTEON_FEATURE_H__
  32. #include <asm/octeon/cvmx-mio-defs.h>
  33. #include <asm/octeon/cvmx-rnm-defs.h>
  34. enum octeon_feature {
  35. /* CN68XX uses port kinds for packet interface */
  36. OCTEON_FEATURE_PKND,
  37. /* CN68XX has different fields in word0 - word2 */
  38. OCTEON_FEATURE_CN68XX_WQE,
  39. /*
  40. * Octeon models in the CN5XXX family and higher support
  41. * atomic add instructions to memory (saa/saad).
  42. */
  43. OCTEON_FEATURE_SAAD,
  44. /* Does this Octeon support the ZIP offload engine? */
  45. OCTEON_FEATURE_ZIP,
  46. OCTEON_FEATURE_DORM_CRYPTO,
  47. /* Does this Octeon support PCI express? */
  48. OCTEON_FEATURE_PCIE,
  49. /* Does this Octeon support SRIOs */
  50. OCTEON_FEATURE_SRIO,
  51. /* Does this Octeon support Interlaken */
  52. OCTEON_FEATURE_ILK,
  53. /* Some Octeon models support internal memory for storing
  54. * cryptographic keys */
  55. OCTEON_FEATURE_KEY_MEMORY,
  56. /* Octeon has a LED controller for banks of external LEDs */
  57. OCTEON_FEATURE_LED_CONTROLLER,
  58. /* Octeon has a trace buffer */
  59. OCTEON_FEATURE_TRA,
  60. /* Octeon has a management port */
  61. OCTEON_FEATURE_MGMT_PORT,
  62. /* Octeon has a raid unit */
  63. OCTEON_FEATURE_RAID,
  64. /* Octeon has a builtin USB */
  65. OCTEON_FEATURE_USB,
  66. /* Octeon IPD can run without using work queue entries */
  67. OCTEON_FEATURE_NO_WPTR,
  68. /* Octeon has DFA state machines */
  69. OCTEON_FEATURE_DFA,
  70. /* Octeon MDIO block supports clause 45 transactions for 10
  71. * Gig support */
  72. OCTEON_FEATURE_MDIO_CLAUSE_45,
  73. /*
  74. * CN52XX and CN56XX used a block named NPEI for PCIe
  75. * access. Newer chips replaced this with SLI+DPI.
  76. */
  77. OCTEON_FEATURE_NPEI,
  78. OCTEON_FEATURE_HFA,
  79. OCTEON_FEATURE_DFM,
  80. OCTEON_FEATURE_CIU2,
  81. OCTEON_FEATURE_CIU3,
  82. /* Octeon has FPA first seen on 78XX */
  83. OCTEON_FEATURE_FPA3,
  84. OCTEON_FEATURE_FAU,
  85. OCTEON_MAX_FEATURE
  86. };
  87. enum octeon_feature_bits {
  88. OCTEON_HAS_CRYPTO = 0x0001, /* Crypto acceleration using COP2 */
  89. };
  90. extern enum octeon_feature_bits __octeon_feature_bits;
  91. /**
  92. * octeon_has_crypto() - Check if this OCTEON has crypto acceleration support.
  93. *
  94. * Returns: Non-zero if the feature exists. Zero if the feature does not exist.
  95. */
  96. static inline int octeon_has_crypto(void)
  97. {
  98. return __octeon_feature_bits & OCTEON_HAS_CRYPTO;
  99. }
  100. /**
  101. * Determine if the current Octeon supports a specific feature. These
  102. * checks have been optimized to be fairly quick, but they should still
  103. * be kept out of fast path code.
  104. *
  105. * @feature: Feature to check for. This should always be a constant so the
  106. * compiler can remove the switch statement through optimization.
  107. *
  108. * Returns Non zero if the feature exists. Zero if the feature does not
  109. * exist.
  110. */
  111. static inline bool octeon_has_feature(enum octeon_feature feature)
  112. {
  113. switch (feature) {
  114. case OCTEON_FEATURE_SAAD:
  115. return !OCTEON_IS_MODEL(OCTEON_CN3XXX);
  116. case OCTEON_FEATURE_DORM_CRYPTO:
  117. if (OCTEON_IS_MODEL(OCTEON_CN6XXX)) {
  118. union cvmx_mio_fus_dat2 fus_2;
  119. fus_2.u64 = cvmx_read_csr(CVMX_MIO_FUS_DAT2);
  120. return !fus_2.s.nocrypto && !fus_2.s.nomul && fus_2.s.dorm_crypto;
  121. } else {
  122. return false;
  123. }
  124. case OCTEON_FEATURE_PCIE:
  125. return OCTEON_IS_MODEL(OCTEON_CN56XX)
  126. || OCTEON_IS_MODEL(OCTEON_CN52XX)
  127. || OCTEON_IS_MODEL(OCTEON_CN6XXX)
  128. || OCTEON_IS_MODEL(OCTEON_CN7XXX);
  129. case OCTEON_FEATURE_SRIO:
  130. return OCTEON_IS_MODEL(OCTEON_CN63XX)
  131. || OCTEON_IS_MODEL(OCTEON_CN66XX);
  132. case OCTEON_FEATURE_ILK:
  133. return (OCTEON_IS_MODEL(OCTEON_CN68XX));
  134. case OCTEON_FEATURE_KEY_MEMORY:
  135. return OCTEON_IS_MODEL(OCTEON_CN38XX)
  136. || OCTEON_IS_MODEL(OCTEON_CN58XX)
  137. || OCTEON_IS_MODEL(OCTEON_CN56XX)
  138. || OCTEON_IS_MODEL(OCTEON_CN6XXX);
  139. case OCTEON_FEATURE_LED_CONTROLLER:
  140. return OCTEON_IS_MODEL(OCTEON_CN38XX)
  141. || OCTEON_IS_MODEL(OCTEON_CN58XX)
  142. || OCTEON_IS_MODEL(OCTEON_CN56XX);
  143. case OCTEON_FEATURE_TRA:
  144. return !(OCTEON_IS_MODEL(OCTEON_CN30XX)
  145. || OCTEON_IS_MODEL(OCTEON_CN50XX));
  146. case OCTEON_FEATURE_MGMT_PORT:
  147. return OCTEON_IS_MODEL(OCTEON_CN56XX)
  148. || OCTEON_IS_MODEL(OCTEON_CN52XX)
  149. || OCTEON_IS_MODEL(OCTEON_CN6XXX);
  150. case OCTEON_FEATURE_RAID:
  151. return OCTEON_IS_MODEL(OCTEON_CN56XX)
  152. || OCTEON_IS_MODEL(OCTEON_CN52XX)
  153. || OCTEON_IS_MODEL(OCTEON_CN6XXX);
  154. case OCTEON_FEATURE_USB:
  155. return !(OCTEON_IS_MODEL(OCTEON_CN38XX)
  156. || OCTEON_IS_MODEL(OCTEON_CN58XX));
  157. case OCTEON_FEATURE_NO_WPTR:
  158. return (OCTEON_IS_MODEL(OCTEON_CN56XX)
  159. || OCTEON_IS_MODEL(OCTEON_CN52XX)
  160. || OCTEON_IS_MODEL(OCTEON_CN6XXX))
  161. && !OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X)
  162. && !OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X);
  163. case OCTEON_FEATURE_MDIO_CLAUSE_45:
  164. return !(OCTEON_IS_MODEL(OCTEON_CN3XXX)
  165. || OCTEON_IS_MODEL(OCTEON_CN58XX)
  166. || OCTEON_IS_MODEL(OCTEON_CN50XX));
  167. case OCTEON_FEATURE_NPEI:
  168. return OCTEON_IS_MODEL(OCTEON_CN56XX)
  169. || OCTEON_IS_MODEL(OCTEON_CN52XX);
  170. case OCTEON_FEATURE_PKND:
  171. return OCTEON_IS_MODEL(OCTEON_CN68XX);
  172. case OCTEON_FEATURE_CN68XX_WQE:
  173. return OCTEON_IS_MODEL(OCTEON_CN68XX);
  174. case OCTEON_FEATURE_CIU2:
  175. return OCTEON_IS_MODEL(OCTEON_CN68XX);
  176. case OCTEON_FEATURE_CIU3:
  177. case OCTEON_FEATURE_FPA3:
  178. return OCTEON_IS_MODEL(OCTEON_CN78XX)
  179. || OCTEON_IS_MODEL(OCTEON_CNF75XX)
  180. || OCTEON_IS_MODEL(OCTEON_CN73XX);
  181. case OCTEON_FEATURE_FAU:
  182. return !(OCTEON_IS_MODEL(OCTEON_CN78XX)
  183. || OCTEON_IS_MODEL(OCTEON_CNF75XX)
  184. || OCTEON_IS_MODEL(OCTEON_CN73XX));
  185. default:
  186. break;
  187. }
  188. return false;
  189. }
  190. #endif /* __OCTEON_FEATURE_H__ */