]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/contrib/octeon-sdk/octeon-feature.h
Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.
[FreeBSD/releng/8.2.git] / sys / contrib / octeon-sdk / octeon-feature.h
1 /***********************license start***************
2  *  Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
3  *  reserved.
4  *
5  *
6  *  Redistribution and use in source and binary forms, with or without
7  *  modification, are permitted provided that the following conditions are
8  *  met:
9  *
10  *      * Redistributions of source code must retain the above copyright
11  *        notice, this list of conditions and the following disclaimer.
12  *
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.
17  *
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
21  *        permission.
22  *
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.
33  *
34  *
35  *  For any questions regarding licensing please contact marketing@caviumnetworks.com
36  *
37  ***********************license end**************************************/
38
39
40
41
42
43 /**
44  * @file
45  *
46  * File defining checks for different Octeon features.
47  *
48  * <hr>$Revision: 30468 $<hr>
49  */
50
51 #ifndef __OCTEON_FEATURE_H__
52 #define __OCTEON_FEATURE_H__
53
54 #ifdef  __cplusplus
55 extern "C" {
56 #endif
57
58 typedef enum
59 {
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 */
73 } octeon_feature_t;
74
75 /**
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.
79  *
80  * @param feature Feature to check for. This should always be a constant so the
81  *                compiler can remove the switch statement through optimization.
82  *
83  * @return Non zero if the feature exists. Zero if the feature does not
84  *         exist.
85  */
86 static inline int octeon_has_feature(octeon_feature_t feature)
87 {
88     switch (feature)
89     {
90         case OCTEON_FEATURE_SAAD:
91             return !OCTEON_IS_MODEL(OCTEON_CN3XXX);
92
93         case OCTEON_FEATURE_ZIP:
94             if (OCTEON_IS_MODEL(OCTEON_CN30XX) || OCTEON_IS_MODEL(OCTEON_CN50XX) || OCTEON_IS_MODEL(OCTEON_CN52XX))
95                 return 0;
96             else if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1))
97                 return 1;
98             else
99                 return (!cvmx_fuse_read(121));
100
101         case OCTEON_FEATURE_CRYPTO:
102             return (!cvmx_fuse_read(90));
103
104         case OCTEON_FEATURE_PCIE:
105             return (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN52XX));
106
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))
123                 return 0;
124             else if (OCTEON_IS_MODEL(OCTEON_CN3020))
125                 return 0;
126             else if (OCTEON_IS_MODEL(OCTEON_CN38XX_PASS1))
127                 return 1;
128             else
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)));
132     }
133     return 0;
134 }
135
136 #ifdef  __cplusplus
137 }
138 #endif
139
140 #endif    /* __OCTEON_FEATURE_H__ */