Back to home page

OSCL-LXR

 
 

    


0001 /***********************license start***************
0002  * Author: Cavium Networks
0003  *
0004  * Contact: support@caviumnetworks.com
0005  * This file is part of the OCTEON SDK
0006  *
0007  * Copyright (c) 2003-2008 Cavium Networks
0008  *
0009  * This file is free software; you can redistribute it and/or modify
0010  * it under the terms of the GNU General Public License, Version 2, as
0011  * published by the Free Software Foundation.
0012  *
0013  * This file is distributed in the hope that it will be useful, but
0014  * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
0015  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
0016  * NONINFRINGEMENT.  See the GNU General Public License for more
0017  * details.
0018  *
0019  * You should have received a copy of the GNU General Public License
0020  * along with this file; if not, write to the Free Software
0021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0022  * or visit http://www.gnu.org/licenses/.
0023  *
0024  * This file may also be available under a different license from Cavium.
0025  * Contact Cavium Networks for more information
0026  ***********************license end**************************************/
0027 
0028 /*
0029  * File defining checks for different Octeon features.
0030  */
0031 
0032 #ifndef __OCTEON_FEATURE_H__
0033 #define __OCTEON_FEATURE_H__
0034 #include <asm/octeon/cvmx-mio-defs.h>
0035 #include <asm/octeon/cvmx-rnm-defs.h>
0036 
0037 enum octeon_feature {
0038     /* CN68XX uses port kinds for packet interface */
0039     OCTEON_FEATURE_PKND,
0040     /* CN68XX has different fields in word0 - word2 */
0041     OCTEON_FEATURE_CN68XX_WQE,
0042     /*
0043      * Octeon models in the CN5XXX family and higher support
0044      * atomic add instructions to memory (saa/saad).
0045      */
0046     OCTEON_FEATURE_SAAD,
0047     /* Does this Octeon support the ZIP offload engine? */
0048     OCTEON_FEATURE_ZIP,
0049     OCTEON_FEATURE_DORM_CRYPTO,
0050     /* Does this Octeon support PCI express? */
0051     OCTEON_FEATURE_PCIE,
0052     /* Does this Octeon support SRIOs */
0053     OCTEON_FEATURE_SRIO,
0054     /*  Does this Octeon support Interlaken */
0055     OCTEON_FEATURE_ILK,
0056     /* Some Octeon models support internal memory for storing
0057      * cryptographic keys */
0058     OCTEON_FEATURE_KEY_MEMORY,
0059     /* Octeon has a LED controller for banks of external LEDs */
0060     OCTEON_FEATURE_LED_CONTROLLER,
0061     /* Octeon has a trace buffer */
0062     OCTEON_FEATURE_TRA,
0063     /* Octeon has a management port */
0064     OCTEON_FEATURE_MGMT_PORT,
0065     /* Octeon has a raid unit */
0066     OCTEON_FEATURE_RAID,
0067     /* Octeon has a builtin USB */
0068     OCTEON_FEATURE_USB,
0069     /* Octeon IPD can run without using work queue entries */
0070     OCTEON_FEATURE_NO_WPTR,
0071     /* Octeon has DFA state machines */
0072     OCTEON_FEATURE_DFA,
0073     /* Octeon MDIO block supports clause 45 transactions for 10
0074      * Gig support */
0075     OCTEON_FEATURE_MDIO_CLAUSE_45,
0076     /*
0077      *  CN52XX and CN56XX used a block named NPEI for PCIe
0078      *  access. Newer chips replaced this with SLI+DPI.
0079      */
0080     OCTEON_FEATURE_NPEI,
0081     OCTEON_FEATURE_HFA,
0082     OCTEON_FEATURE_DFM,
0083     OCTEON_FEATURE_CIU2,
0084     OCTEON_FEATURE_CIU3,
0085     /* Octeon has FPA first seen on 78XX */
0086     OCTEON_FEATURE_FPA3,
0087     OCTEON_FEATURE_FAU,
0088     OCTEON_MAX_FEATURE
0089 };
0090 
0091 enum octeon_feature_bits {
0092     OCTEON_HAS_CRYPTO = 0x0001, /* Crypto acceleration using COP2 */
0093 };
0094 extern enum octeon_feature_bits __octeon_feature_bits;
0095 
0096 /**
0097  * octeon_has_crypto() - Check if this OCTEON has crypto acceleration support.
0098  *
0099  * Returns: Non-zero if the feature exists. Zero if the feature does not exist.
0100  */
0101 static inline int octeon_has_crypto(void)
0102 {
0103     return __octeon_feature_bits & OCTEON_HAS_CRYPTO;
0104 }
0105 
0106 /**
0107  * Determine if the current Octeon supports a specific feature. These
0108  * checks have been optimized to be fairly quick, but they should still
0109  * be kept out of fast path code.
0110  *
0111  * @feature: Feature to check for. This should always be a constant so the
0112  *        compiler can remove the switch statement through optimization.
0113  *
0114  * Returns Non zero if the feature exists. Zero if the feature does not
0115  *     exist.
0116  */
0117 static inline bool octeon_has_feature(enum octeon_feature feature)
0118 {
0119     switch (feature) {
0120     case OCTEON_FEATURE_SAAD:
0121         return !OCTEON_IS_MODEL(OCTEON_CN3XXX);
0122 
0123     case OCTEON_FEATURE_DORM_CRYPTO:
0124         if (OCTEON_IS_MODEL(OCTEON_CN6XXX)) {
0125             union cvmx_mio_fus_dat2 fus_2;
0126             fus_2.u64 = cvmx_read_csr(CVMX_MIO_FUS_DAT2);
0127             return !fus_2.s.nocrypto && !fus_2.s.nomul && fus_2.s.dorm_crypto;
0128         } else {
0129             return false;
0130         }
0131 
0132     case OCTEON_FEATURE_PCIE:
0133         return OCTEON_IS_MODEL(OCTEON_CN56XX)
0134             || OCTEON_IS_MODEL(OCTEON_CN52XX)
0135             || OCTEON_IS_MODEL(OCTEON_CN6XXX)
0136             || OCTEON_IS_MODEL(OCTEON_CN7XXX);
0137 
0138     case OCTEON_FEATURE_SRIO:
0139         return OCTEON_IS_MODEL(OCTEON_CN63XX)
0140             || OCTEON_IS_MODEL(OCTEON_CN66XX);
0141 
0142     case OCTEON_FEATURE_ILK:
0143         return (OCTEON_IS_MODEL(OCTEON_CN68XX));
0144 
0145     case OCTEON_FEATURE_KEY_MEMORY:
0146         return OCTEON_IS_MODEL(OCTEON_CN38XX)
0147             || OCTEON_IS_MODEL(OCTEON_CN58XX)
0148             || OCTEON_IS_MODEL(OCTEON_CN56XX)
0149             || OCTEON_IS_MODEL(OCTEON_CN6XXX);
0150 
0151     case OCTEON_FEATURE_LED_CONTROLLER:
0152         return OCTEON_IS_MODEL(OCTEON_CN38XX)
0153             || OCTEON_IS_MODEL(OCTEON_CN58XX)
0154             || OCTEON_IS_MODEL(OCTEON_CN56XX);
0155 
0156     case OCTEON_FEATURE_TRA:
0157         return !(OCTEON_IS_MODEL(OCTEON_CN30XX)
0158              || OCTEON_IS_MODEL(OCTEON_CN50XX));
0159     case OCTEON_FEATURE_MGMT_PORT:
0160         return OCTEON_IS_MODEL(OCTEON_CN56XX)
0161             || OCTEON_IS_MODEL(OCTEON_CN52XX)
0162             || OCTEON_IS_MODEL(OCTEON_CN6XXX);
0163 
0164     case OCTEON_FEATURE_RAID:
0165         return OCTEON_IS_MODEL(OCTEON_CN56XX)
0166             || OCTEON_IS_MODEL(OCTEON_CN52XX)
0167             || OCTEON_IS_MODEL(OCTEON_CN6XXX);
0168 
0169     case OCTEON_FEATURE_USB:
0170         return !(OCTEON_IS_MODEL(OCTEON_CN38XX)
0171              || OCTEON_IS_MODEL(OCTEON_CN58XX));
0172 
0173     case OCTEON_FEATURE_NO_WPTR:
0174         return (OCTEON_IS_MODEL(OCTEON_CN56XX)
0175             || OCTEON_IS_MODEL(OCTEON_CN52XX)
0176             || OCTEON_IS_MODEL(OCTEON_CN6XXX))
0177               && !OCTEON_IS_MODEL(OCTEON_CN56XX_PASS1_X)
0178               && !OCTEON_IS_MODEL(OCTEON_CN52XX_PASS1_X);
0179 
0180     case OCTEON_FEATURE_MDIO_CLAUSE_45:
0181         return !(OCTEON_IS_MODEL(OCTEON_CN3XXX)
0182              || OCTEON_IS_MODEL(OCTEON_CN58XX)
0183              || OCTEON_IS_MODEL(OCTEON_CN50XX));
0184 
0185     case OCTEON_FEATURE_NPEI:
0186         return OCTEON_IS_MODEL(OCTEON_CN56XX)
0187             || OCTEON_IS_MODEL(OCTEON_CN52XX);
0188 
0189     case OCTEON_FEATURE_PKND:
0190         return OCTEON_IS_MODEL(OCTEON_CN68XX);
0191 
0192     case OCTEON_FEATURE_CN68XX_WQE:
0193         return OCTEON_IS_MODEL(OCTEON_CN68XX);
0194 
0195     case OCTEON_FEATURE_CIU2:
0196         return OCTEON_IS_MODEL(OCTEON_CN68XX);
0197     case OCTEON_FEATURE_CIU3:
0198     case OCTEON_FEATURE_FPA3:
0199         return OCTEON_IS_MODEL(OCTEON_CN78XX)
0200             || OCTEON_IS_MODEL(OCTEON_CNF75XX)
0201             || OCTEON_IS_MODEL(OCTEON_CN73XX);
0202     case OCTEON_FEATURE_FAU:
0203         return !(OCTEON_IS_MODEL(OCTEON_CN78XX)
0204              || OCTEON_IS_MODEL(OCTEON_CNF75XX)
0205              || OCTEON_IS_MODEL(OCTEON_CN73XX));
0206 
0207     default:
0208         break;
0209     }
0210     return false;
0211 }
0212 
0213 #endif /* __OCTEON_FEATURE_H__ */