Commit 459e39dd authored by Wen-chien Jesse Sung's avatar Wen-chien Jesse Sung Committed by Thadeu Lima de Souza Cascardo
parent 217f8de3
The software content under this Broadcom Switch / OpenNSL is divided into two
parts, and each part has its respective license.
One portion of the software is Broadcom Switch APIs is governed by the
Apache 2.0 license. It is located at
https://github.com/Broadcom-Switch/OpenNSL/Legal/LICENSE-Apache2.
Such open source software will also expressly reference the Apache 2.0
license at the beginning of the software file.
The other portion of the software is called Broadcom Advanced Switch APIs.
This software is governed by the Broadcom Advanced Switch APIs license.
This license is set out in the
https://github.com/Broadcom-Switch/OpenNSL/Legal/LICENSE-Adv file.
Copyright 2015-2016 Broadcom Corporation. All rights reserved.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
OpenNSL
======
OpenNSL 3.1.0.x Switch Specification and Software
Overview
========
Open Network Switch Layer (OpenNSL) is a library of network switch APIs that
is openly available for programming Broadcom network switch silicon based
platforms. These open APIs enable development of networking application
software based on Broadcom network switch architecture based platforms.
Documentation
=============
Detailed documentation can be found at http://Broadcom-Switch.github.io/OpenNSL/doc/html/index.html.
Legal
=====
Please see LEGAL_TERMS for the use of and access of the Broadcom-Switch Page
License
=======
Licenses for the software are available at the applicable level of the
software repository under the "LICENSE" file
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
********************************************************************
* File: commdefs.h
* Details: OpenNSL specific defines and options
*******************************************************************/
#ifndef _SAL_COMMDEFS_H
#define _SAL_COMMDEFS_H
#define LIB_DLL_EXPORTED __attribute__((__visibility__("default")))
#endif /* !_SAL_COMMDEFS_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
********************************************************************
* File: compiler.h
* Details: Compiler specific defines and options
*******************************************************************/
#ifndef _SAL_COMPILER_H
#define _SAL_COMPILER_H
/*
* Define attributes according to compiler.
* Currently we have used GNU C, Diab Data, and Borland compilers.
*/
#define COMPILER_HAS_CONST
#define COMPILER_HAS_STATIC
#ifndef __KERNEL__
#define COMPILER_HAS_DOUBLE
#endif
/*
* Return a string containing the current FILE:LINE location in the code.
*
*/
#ifndef FILE_LINE_STRING
#define __STRINGIFY(x) #x
#define _STRINGIFY(x) __STRINGIFY(x)
#define FILE_LINE_STRING() (__FILE__ ":" _STRINGIFY(__LINE__))
#endif /* FILE_LINE_STRING */
#if defined(__GNUC__) && !defined(__PEDANTIC__)
#define COMPILER_HAS_LONGLONG
#if defined(VXWORKS) && ((CPU == PPC860) || (CPU == PPC603) || (CPU == PPC32))
/*
* WRS T2 (Cygnus 2.7.2) PPC compiler can't handle 64-bit properly.
* It generates bad code for shift by 32. It also generates false
* "variable might be used initialized" warnings for COMPILER_ZERO.
*/
#if (VX_VERSION == 55) || (VX_VERSION >= 62)
# define COMPILER_HAS_LONGLONG_SHIFT
#else
# undef COMPILER_HAS_LONGLONG_SHIFT
#endif
#else
# define COMPILER_HAS_LONGLONG_SHIFT
#endif
#define COMPILER_HAS_LONGLONG_ADDSUB
#define COMPILER_HAS_LONGLONG_MUL
#define COMPILER_HAS_LONGLONG_DIV
#define COMPILER_HAS_LONGLONG_ANDOR
#define COMPILER_HAS_LONGLONG_COMPARE
#if ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) >= 30201
/* gcc 3.2.1 is the earliest version known to support the format attribute
when applied to function pointers. gcc 3.0.0 is known to *not* support
this. */
#define COMPILER_HAS_FUNCTION_POINTER_FORMAT_ATTRIBUTE
#endif
#ifndef __STRICT_ANSI__
#define COMPILER_HAS_INLINE
#endif
#define COMPILER_ATTRIBUTE(_a) __attribute__ (_a)
#define COMPILER_REFERENCE(_a) ((void)(_a))
#define FUNCTION_NAME() (__FUNCTION__)
#elif (defined(__DCC__) && (__DCC__ == 1)) && !defined(__PEDANTIC__)
#define COMPILER_HAS_LONGLONG
#define COMPILER_HAS_LONGLONG_SHIFT
#define COMPILER_HAS_LONGLONG_ADDSUB
#define COMPILER_HAS_LONGLONG_MUL
#define COMPILER_HAS_LONGLONG_DIV
#define COMPILER_HAS_LONGLONG_ANDOR
#define COMPILER_HAS_LONGLONG_COMPARE
#define COMPILER_ATTRIBUTE(_a)
#define COMPILER_REFERENCE(_a) ((void)(_a))
#if (defined(DIAB_VER)) && (DIAB_VER == 4)
/* Older versions of DCC do not support __FUNCTION__ */
#define FUNCTION_NAME() FILE_LINE_STRING()
#else
#define FUNCTION_NAME() (__FUNCTION__)
#endif
#else /* !defined(__GNUC__) */
#define COMPILER_ATTRIBUTE(_a)
#define COMPILER_REFERENCE(_a) ((void)(_a))
#ifndef FUNCTION_NAME
/*
* No portable ANSI method to accomplish this.
* Just return the location in the code instead.
*/
#define FUNCTION_NAME() FILE_LINE_STRING()
#endif /* FUNCTION_NAME */
#endif /* !defined(__GNUC__) */
/* GreenHills compiler */
#ifdef GHS
#define COMPILER_HAS_LONGLONG
#define COMPILER_HAS_LONGLONG_SHIFT
#define COMPILER_HAS_LONGLONG_ADDSUB
#define COMPILER_HAS_LONGLONG_MUL
#define COMPILER_HAS_LONGLONG_DIV
#define COMPILER_HAS_LONGLONG_ANDOR
#define COMPILER_HAS_LONGLONG_COMPARE
/* GreenHills compiler has __FUNCTION__ built-in macro not __func__ */
#define __func__ __FUNCTION__
#endif
/*
* __attribute__ for function pointers
*/
#ifdef COMPILER_HAS_FUNCTION_POINTER_FORMAT_ATTRIBUTE
#define COMPILER_ATTRIBUTE_FUNCTION_POINTER(_a) COMPILER_ATTRIBUTE(_a)
#else
#define COMPILER_ATTRIBUTE_FUNCTION_POINTER(_a)
#endif
#ifdef __PEDANTIC__
#define COMPILER_STRING_CONST_LIMIT 509
#endif
/*
* Compiler overrides that can be configured in Make.local
*/
#ifdef COMPILER_OVERRIDE_NO_LONGLONG
#undef COMPILER_HAS_LONGLONG
#undef COMPILER_HAS_LONGLONG_SHIFT
#undef COMPILER_HAS_LONGLONG_ADDSUB
#undef COMPILER_HAS_LONGLONG_MUL
#undef COMPILER_HAS_LONGLONG_DIV
#undef COMPILER_HAS_LONGLONG_ANDOR
#undef COMPILER_HAS_LONGLONG_COMPARE
#endif
#ifdef COMPILER_OVERRIDE_NO_DOUBLE
#undef COMPILER_HAS_DOUBLE
#endif
#ifdef COMPILER_OVERRIDE_NO_INLINE
#undef COMPILER_HAS_INLINE
#endif
#ifdef COMPILER_OVERRIDE_NO_CONST
#undef COMPILER_HAS_CONST
#endif
#ifdef COMPILER_OVERRIDE_NO_STATIC
#undef COMPILER_HAS_STATIC
#endif
/*
* 64-bit word order
*/
#ifdef __BORLAND__
/* The Borland cpp does not expand correctly in the macros below...sigh */
static int u64_MSW = 1;
static int u64_LSW = 0;
#else
# ifdef BE_HOST
# define u64_MSW 0
# define u64_LSW 1
# else /* LE_HOST */
# define u64_MSW 1
# define u64_LSW 0
# endif /* LE_HOST */
#endif /* __BORLAND__ */
/*
* 64-bit type
*/
#ifdef LONGS_ARE_64BITS
#define COMPILER_64BIT
#define COMPILER_UINT64 unsigned long
#define COMPILER_INT64 long
#define u64_H(v) (((uint32 *) &(v))[u64_MSW])
#define u64_L(v) (((uint32 *) &(v))[u64_LSW])
#define COMPILER_64_INIT(_hi, _lo) ( (((long) (_hi)) << 32) | (_lo))
#else /* !LONGS_ARE_64BITS */
#ifdef COMPILER_HAS_LONGLONG
#define COMPILER_64BIT
#define COMPILER_UINT64 unsigned long long
#define COMPILER_INT64 long long
#define u64_H(v) (((uint32 *) &(v))[u64_MSW])
#define u64_L(v) (((uint32 *) &(v))[u64_LSW])
#define COMPILER_64_INIT(_hi, _lo) ( (((long long) (_hi)) << 32) | (_lo))
#else /* !COMPILER_HAS_LONGLONG */
typedef struct sal_uint64_s { unsigned int u64_w[2]; } sal_uint64_t;
typedef struct sal_int64_s { int u64_w[2]; } sal_int64_t;
#define COMPILER_UINT64 sal_uint64_t
#define COMPILER_INT64 sal_int64_t
#define u64_H(v) ((v).u64_w[u64_MSW])
#define u64_L(v) ((v).u64_w[u64_LSW])
#ifdef BE_HOST
#define COMPILER_64_INIT(_hi, _lo) { { _hi, _lo } }
#else
#define COMPILER_64_INIT(_hi, _lo) { { _lo, _hi } }
#endif
#endif /* !COMPILER_HAS_LONGLONG */
#endif /* LONGS_ARE_64BITS */
/*
* 32-/64-bit type conversions
*/
#ifdef COMPILER_HAS_LONGLONG_SHIFT
#define COMPILER_64_TO_32_LO(dst, src) ((dst) = (uint32) (src))
#define COMPILER_64_TO_32_HI(dst, src) ((dst) = (uint32) ((src) >> 32))
#define COMPILER_64_HI(src) ((uint32) ((src) >> 32))
#define COMPILER_64_LO(src) ((uint32) (src))
#define COMPILER_64_ZERO(dst) ((dst) = 0)
#define COMPILER_64_IS_ZERO(src) ((src) == 0)
#define COMPILER_64_SET(dst, src_hi, src_lo) \
((dst) = (((uint64) ((uint32)(src_hi))) << 32) | ((uint64) ((uint32)(src_lo))))
#else /* !COMPILER_HAS_LONGLONG_SHIFT */
#define COMPILER_64_TO_32_LO(dst, src) ((dst) = u64_L(src))
#define COMPILER_64_TO_32_HI(dst, src) ((dst) = u64_H(src))
#define COMPILER_64_HI(src) u64_H(src)
#define COMPILER_64_LO(src) u64_L(src)
#define COMPILER_64_ZERO(dst) (u64_H(dst) = u64_L(dst) = 0)
#define COMPILER_64_IS_ZERO(src) (u64_H(src) == 0 && u64_L(src) == 0)
#define COMPILER_64_SET(dst, src_hi, src_lo) \
do { \
u64_H(dst) = (src_hi); \
u64_L(dst) = (src_lo); \
} while (0)
#endif /* !COMPILER_HAS_LONGLONG_SHIFT */
/*
* 64-bit addition and subtraction
*/
#ifdef COMPILER_HAS_LONGLONG_ADDSUB
#define COMPILER_64_ADD_64(dst, src) ((dst) += (src))
#define COMPILER_64_ADD_32(dst, src) ((dst) += (src))
#define COMPILER_64_SUB_64(dst, src) ((dst) -= (src))
#define COMPILER_64_SUB_32(dst, src) ((dst) -= (src))
#else /* !COMPILER_HAS_LONGLONG_ADDSUB */
#define COMPILER_64_ADD_64(dst, src) \
do { \
uint32 __t = u64_L(dst); \
u64_L(dst) += u64_L(src); \
if (u64_L(dst) < __t) { \
u64_H(dst) += u64_H(src) + 1; \
} else { \
u64_H(dst) += u64_H(src); \
} \
} while (0)
#define COMPILER_64_ADD_32(dst, src) \
do { \
uint32 __t = u64_L(dst); \
u64_L(dst) += (src); \
if (u64_L(dst) < __t) { \
u64_H(dst)++; \
} \
} while (0)
#define COMPILER_64_SUB_64(dst, src) \
do { \
uint32 __t = u64_L(dst); \
u64_L(dst) -= u64_L(src); \
if (u64_L(dst) > __t) { \
u64_H(dst) -= u64_H(src) + 1; \
} else { \
u64_H(dst) -= u64_H(src); \
} \
} while (0)
#define COMPILER_64_SUB_32(dst, src) \
do { \
uint32 __t = u64_L(dst); \
u64_L(dst) -= (src); \
if (u64_L(dst) > __t) { \
u64_H(dst)--; \
} \
} while (0)
#endif /* !COMPILER_HAS_LONGLONG_ADDSUB */
/*
* 64-bit multiplication
*/
#ifdef COMPILER_HAS_LONGLONG_MUL
#define COMPILER_64_UMUL_32(dst, src) ((dst) *= (src))
#else /* !COMPILER_HAS_LONGLONG_MUL */
/* Multiply of unsigned 64-bit and unsigned 32-bit integers, no overflow handling */
#define COMPILER_64_UMUL_32(dst, src) \
do { \
uint32 __d[4]; \
uint32 __s[2]; \
uint32 __r[4]; \
uint32 __t[2]; \
__d[0] = u64_L(dst) & 0xffff; \
__d[1] = u64_L(dst) >> 16; \
__d[2] = u64_H(dst) & 0xffff; \
__d[3] = u64_H(dst) >> 16; \
__s[0] = (src) & 0xffff; \
__s[1] = (src) >> 16; \
__r[0] = __d[0] * __s[0]; \
__r[1] = __d[1] * __s[0] + __d[0] * __s[1]; \
__r[2] = __d[2] * __s[0] + __d[1] * __s[1]; \
__r[3] = __d[3] * __s[0] + __d[2] * __s[1]; \
__t[0] = __r[1] << 16; \
__t[1] = __t[0] + __r[0]; \
COMPILER_64_SET((dst), (__r[3] << 16) + __r[2] + (__r[1] >> 16) + (__t[1] < __t[0] ? 1 : 0), \
__t[1] \
); \
} while (0);
#endif /* !COMPILER_HAS_LONGLONG_MUL */
/*
* 64-bit logical operations
*/
#ifdef COMPILER_HAS_LONGLONG_ANDOR
#define COMPILER_64_AND(dst, src) ((dst) &= (src))
#define COMPILER_64_OR(dst, src) ((dst) |= (src))
#define COMPILER_64_XOR(dst, src) ((dst) ^= (src))
#define COMPILER_64_NOT(dst) ((dst) = ~(dst))
#else /* !COMPILER_HAS_LONGLONG_ANDOR */
#define COMPILER_64_AND(dst, src) \
do { \
u64_H((dst)) &= u64_H((src)); \
u64_L((dst)) &= u64_L((src)); \
} while (0)
#define COMPILER_64_OR(dst, src) \
do { \
u64_H((dst)) |= u64_H((src)); \
u64_L((dst)) |= u64_L((src)); \
} while (0)
#define COMPILER_64_XOR(dst, src) \
do { \
u64_H((dst)) ^= u64_H((src)); \
u64_L((dst)) ^= u64_L((src)); \
} while (0)
#define COMPILER_64_NOT(dst) \
do { \
u64_H((dst)) = ~u64_H((dst)); \
u64_L((dst)) = ~u64_L((dst)); \
} while (0)
#endif /* !COMPILER_HAS_LONGLONG_ANDOR */
#define COMPILER_64_ALLONES(dst) \
COMPILER_64_ZERO((dst));\
COMPILER_64_NOT((dst))
/*
* 64-bit shift
*/
#ifdef COMPILER_HAS_LONGLONG_SHIFT
#define COMPILER_64_SHL(dst, bits) ((dst) <<= (bits))
#define COMPILER_64_SHR(dst, bits) ((dst) >>= (bits))
#define COMPILER_64_BITTEST(val, n) \
((((uint64)val) & (((uint64) 1)<<(n))) != ((uint64) 0))
#else /* !COMPILER_HAS_LONGLONG_SHIFT */
#define COMPILER_64_SHL(dst, bits) \
do { \
int __b = (bits); \
if (__b >= 32) { \
u64_H(dst) = u64_L(dst); \
u64_L(dst) = 0; \
__b -= 32; \
} \
u64_H(dst) = (u64_H(dst) << __b) | \
(__b ? u64_L(dst) >> (32 - __b) : 0); \
u64_L(dst) <<= __b; \
} while (0)
#define COMPILER_64_SHR(dst, bits) \
do { \
int __b = (bits); \
if (__b >= 32) { \
u64_L(dst) = u64_H(dst); \
u64_H(dst) = 0; \
__b -= 32; \
} \
u64_L(dst) = (u64_L(dst) >> __b) | \
(__b ? u64_H(dst) << (32 - __b) : 0); \
u64_H(dst) >>= __b; \
} while (0)
#define COMPILER_64_BITTEST(val, n) \
( (((n) < 32) && (u64_L(val) & (1 << (n)))) || \
(((n) >= 32) && (u64_H(val) & (1 << ((n) - 32)))) )
#endif /* !COMPILER_HAS_LONGLONG_SHIFT */
/*
* 64-bit compare operations
*/
#ifdef COMPILER_HAS_LONGLONG_COMPARE
#define COMPILER_64_EQ(src1, src2) ((src1) == (src2))
#define COMPILER_64_NE(src1, src2) ((src1) != (src2))
#define COMPILER_64_LT(src1, src2) ((src1) < (src2))
#define COMPILER_64_LE(src1, src2) ((src1) <= (src2))
#define COMPILER_64_GT(src1, src2) ((src1) > (src2))
#define COMPILER_64_GE(src1, src2) ((src1) >= (src2))
#else /* !COMPILER_HAS_LONGLONG_COMPARE */
#define COMPILER_64_EQ(src1, src2) (u64_H(src1) == u64_H(src2) && \
u64_L(src1) == u64_L(src2))
#define COMPILER_64_NE(src1, src2) (u64_H(src1) != u64_H(src2) || \
u64_L(src1) != u64_L(src2))
#define COMPILER_64_LT(src1, src2) (u64_H(src1) < u64_H(src2) || \
((u64_H(src1) == u64_H(src2) && \
u64_L(src1) < u64_L(src2))))
#define COMPILER_64_LE(src1, src2) (u64_H(src1) < u64_H(src2) || \
((u64_H(src1) == u64_H(src2) && \
u64_L(src1) <= u64_L(src2))))
#define COMPILER_64_GT(src1, src2) (u64_H(src1) > u64_H(src2) || \
((u64_H(src1) == u64_H(src2) && \
u64_L(src1) > u64_L(src2))))
#define COMPILER_64_GE(src1, src2) (u64_H(src1) > u64_H(src2) || \
((u64_H(src1) == u64_H(src2) && \
u64_L(src1) >= u64_L(src2))))
#endif /* !COMPILER_HAS_LONGLONG_COMPARE */
/* Set up a mask of width bits offset lft_shft. No error checking */
#define COMPILER_64_MASK_CREATE(dst, width, lft_shift) \
do { \
COMPILER_64_ALLONES(dst); \
COMPILER_64_SHR((dst), (64 - (width))); \
COMPILER_64_SHL((dst), (lft_shift)); \
} while (0)
#define COMPILER_64_DELTA(src, last, new)\
do { \
COMPILER_64_ZERO(src);\
COMPILER_64_ADD_64(src, new);\
COMPILER_64_SUB_64(src, last);\
} while(0)
#define COMPILER_64_BITSET(dst, n) \
do { \
uint64 temp64; \
COMPILER_64_SET(temp64, 0, 1); \
COMPILER_64_SHL(temp64, n); \
COMPILER_64_OR(dst, temp64); \
} while(0)
#define COMPILER_64_BITCLR(dst, n) \
do { \
uint64 temp64; \
COMPILER_64_SET(temp64, 0, 1); \
COMPILER_64_SHL(temp64, n); \
COMPILER_64_NOT(temp64); \
COMPILER_64_AND(dst, temp64); \
} while(0)
/*
* 64-bit division
*/
#if defined COMPILER_HAS_LONGLONG_DIV && ! defined (__KERNEL__)
#define COMPILER_64_UDIV_64(dst, src) ((dst) /= (src))
#else /* !(defined COMPILER_HAS_LONGLONG_DIV && ! defined (__KERNEL__)) */
/* Divide of unsigned 64-bit and unsigned 64-bit integers, no overflow handling */
#define COMPILER_64_UDIV_64(dst, src) \
do { \
uint32 q_hi = 0, q_lo = 0; \
while( COMPILER_64_GE(dst, src) ) \
{ \
COMPILER_64_SUB_64(dst, src); \
if (++q_lo == 0) ++q_hi; \
} \
COMPILER_64_SET(dst, q_hi, q_lo); \
} while (0)
#endif /* defined COMPILER_HAS_LONGLONG_DIV && ! defined (__KERNEL__) */
/*
* Some macros for double support
*
* You can use the COMPILER_DOUBLE macro
* if you would prefer double precision, but it is not necessary.
* If you need more control (or you need to print :), then
* then you should use the COMPILER_HAS_DOUBLE macro explicitly.
*
*/
#ifdef COMPILER_HAS_DOUBLE
#define COMPILER_DOUBLE double
#define COMPILER_DOUBLE_FORMAT "f"
#define COMPILER_64_TO_DOUBLE(f, i64) \
((f) = COMPILER_64_HI(i64) * 4294967296.0 + COMPILER_64_LO(i64))
#define COMPILER_32_TO_DOUBLE(f, i32) \
((f) = (double) (i32))
#else
#define COMPILER_DOUBLE uint32
#define COMPILER_DOUBLE_FORMAT "u"
#define COMPILER_64_TO_DOUBLE(f, i64) ((f) = COMPILER_64_LO(i64))
#define COMPILER_32_TO_DOUBLE(f, i32) ((f) = (i32))
#endif
/*
* Version of inline that is turned off for compilers that do
* not support inline.
*/
#ifndef INLINE
# ifdef COMPILER_HAS_INLINE
# define INLINE inline
# else
# define INLINE
# endif
#endif /* !INLINE */
/*
* Version of const that is turned off for compilers that do
* not support const.
*/
#ifndef CONST
# ifdef COMPILER_HAS_CONST
# define CONST const
# else
# define CONST
# endif
#endif /* !CONST */
/*
* Some compilers/linkers/OSs do not put static symbols in the
* symbol table, which can make debugging harder.
*/
#ifndef STATIC
# if defined(COMPILER_HAS_STATIC)
# define STATIC static
# else
# define STATIC
# endif
#endif /* !STATIC */
#endif /* !_SAL_COMPILER_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************
*
* \file driver.h
*
* \brief This file contains utility functions called externally
*
**********************************************************************/
#ifndef DRIVER_H
#define DRIVER_H
typedef struct opennsl_config_s
{
char *cfg_fname; /* Configuration file name along with the path */
unsigned int flags; /* OpenNSL boot up flags */
char *wb_fname; /* File to store warmboot configuration *
* along with the path */
char *rmcfg_fname; /* RM config file name along with the path */
} opennsl_init_t;
/*****************************************************************//**
* \brief Function to initialize the switch.
*
* \param init [IN] pointer to structure that contains path to
* platform customization config file, boot flags.
*
* \return OPENNSL_E_XXX OpenNSL API return code
********************************************************************/
extern int opennsl_driver_init(opennsl_init_t *init);
/**************************************************************************//**
* \brief To get platform boot flags
*
* \return unsigned int Boot flags
*****************************************************************************/
extern unsigned int opennsl_driver_boot_flags_get(void);
/*****************************************************************//**
* \brief Bringup diagnostic shell prompt and process the input commands.
*
* \return OPENNSL_E_XXX OpenNSL API return code
********************************************************************/
extern int opennsl_driver_shell();
/*****************************************************************//**
* \brief Process diagnostic shell command.
*
* \param commandBuf [IN] pointer to hold the diagnostic shell command
*
* \return OPENNSL_E_XXX OpenNSL API return code
********************************************************************/
extern int opennsl_driver_process_command(char *commandBuf);
extern char *readline(const char *prompt);
#endif /* DRIVER_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*********************************************************************
* File: types.h
* Details: Type definitions
********************************************************************/
#ifndef _SAL_TYPES_H
#define _SAL_TYPES_H
#include <sal/compiler.h>
/*
* Define platform-independent types
*/
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef DONT_CARE
#define DONT_CARE 0
#endif
#define VOL volatile
/*
* Define unsigned and signed integers with guaranteed sizes.
* Adjust if your compiler uses different sizes for short or int.
*/
typedef unsigned char uint8; /* 8-bit quantity */
typedef unsigned short uint16; /* 16-bit quantity */
typedef unsigned int uint32; /* 32-bit quantity */
typedef COMPILER_UINT64 uint64; /* 64-bit quantity */
typedef signed char int8; /* 8-bit quantity */
typedef signed short int16; /* 16-bit quantity */
typedef signed int int32; /* 32-bit quantity */
typedef COMPILER_INT64 int64; /* 64-bit quantity */
#define BITS2BYTES(x) (((x) + 7) / 8)
#define BITS2WORDS(x) (((x) + 31) / 32)
#define BYTES2BITS(x) ((x) * 8)
#define BYTES2WORDS(x) (((x) + 3) / 4)
#define WORDS2BITS(x) ((x) * 32)
#define WORDS2BYTES(x) ((x) * 4)
#define COUNTOF(ary) ((int) (sizeof (ary) / sizeof ((ary)[0])))
typedef uint32 sal_paddr_t; /* Physical address (PCI address) */
#ifdef PTRS_ARE_64BITS
typedef uint64 sal_vaddr_t; /* Virtual address (Host address) */
#define PTR_TO_INT(x) ((uint32)(((sal_vaddr_t)(x))&0xFFFFFFFF))
#define PTR_HI_TO_INT(x) ((uint32)((((sal_vaddr_t)(x))>>32)&0xFFFFFFFF))
#else
typedef uint32 sal_vaddr_t; /* Virtual address (Host address) */
#define PTR_TO_INT(x) ((uint32)(x))
#define PTR_HI_TO_INT(x) (0)
#endif
#define INT_TO_PTR(x) ((void *)((sal_vaddr_t)(x)))
#define PTR_TO_UINTPTR(x) ((sal_vaddr_t)(x))
#define UINTPTR_TO_PTR(x) ((void *)(x))
typedef union
{
uint8 u8;
uint16 u16;
uint32 u32;
uint64 u64;
sal_paddr_t paddr;
sal_vaddr_t vaddr;
void *ptr;
} any_t;
typedef uint8 sal_mac_addr_t[6]; /* MAC address */
typedef uint32 sal_ip_addr_t; /* IP Address */
/* sal_mac_addr_t mac; Just generate a list of the macs for display */
#define SAL_MAC_ADDR_LIST(mac) \
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
#define SAL_MACADDR_STR_LEN 18 /* Formatted MAC address */
#define SAL_IPADDR_STR_LEN 16 /* Formatted IP address */
/* Adjust justification for uint32 writes to fields */
/* dst is an array name of type uint32 [] */
#define SAL_MAC_ADDR_TO_UINT32(mac, dst) do {\
(dst)[0] = (((uint32)(mac)[2]) << 24 | \
((uint32)(mac)[3]) << 16 | \
((uint32)(mac)[4]) << 8 | \
((uint32)(mac)[5])); \
(dst)[1] = (((uint32)(mac)[0]) << 8 | \
((uint32)(mac)[1])); \
} while (0)
/* Adjust justification for uint32 writes to fields */
/* src is an array name of type uint32 [] */
#define SAL_MAC_ADDR_FROM_UINT32(mac, src) do {\
(mac)[0] = (uint8) ((src)[1] >> 8 & 0xff); \
(mac)[1] = (uint8) ((src)[1] & 0xff); \
(mac)[2] = (uint8) ((src)[0] >> 24); \
(mac)[3] = (uint8) ((src)[0] >> 16 & 0xff); \
(mac)[4] = (uint8) ((src)[0] >> 8 & 0xff); \
(mac)[5] = (uint8) ((src)[0] & 0xff); \
} while (0)
/* dst is a uint64 */
#define SAL_MAC_ADDR_TO_UINT64(mac, dst) do { \
uint32 _val[2]; \
SAL_MAC_ADDR_TO_UINT32(mac, _val); \
COMPILER_64_SET(dst, _val[1], _val[0]); \
} while (0)
/* src is a uint64 */
#define SAL_MAC_ADDR_FROM_UINT64(mac, src) do { \
uint32 _val[2]; \
COMPILER_64_TO_32_LO(_val[0], src); \
COMPILER_64_TO_32_HI(_val[1], src); \
SAL_MAC_ADDR_FROM_UINT32(mac, _val); \
} while (0)
/* Adjust IP6 justification for uint32 field accesses */
/*
* These macros are used on IP6 "half addresses", being
* either the "upper" 64 bits or the "lower" 64 bits of
* an IPv6 address.
*/
/* dst is an array name of type uint32 [] */
#define SAL_IP6_ADDR_HALF_TO_UINT32(ip6, dst) do {\
(dst)[1] = (((uint32)(ip6)[0]) << 24 | \
((uint32)(ip6)[1]) << 16 | \
((uint32)(ip6)[2]) << 8 | \
((uint32)(ip6)[3])); \
(dst)[0] = (((uint32)(ip6)[4]) << 24 | \
((uint32)(ip6)[5]) << 16 | \
((uint32)(ip6)[6]) << 8 | \
((uint32)(ip6)[7])); \
} while (0)
/* src is an array name of type uint32 [] */
#define SAL_IP6_ADDR_HALF_FROM_UINT32(ip6, src) do {\
(ip6)[0] = (uint8) ((src)[1] >> 24); \
(ip6)[1] = (uint8) ((src)[1] >> 16 & 0xff); \
(ip6)[2] = (uint8) ((src)[1] >> 8 & 0xff); \
(ip6)[3] = (uint8) ((src)[1] & 0xff); \
(ip6)[4] = (uint8) ((src)[0] >> 24); \
(ip6)[5] = (uint8) ((src)[0] >> 16 & 0xff); \
(ip6)[6] = (uint8) ((src)[0] >> 8 & 0xff); \
(ip6)[7] = (uint8) ((src)[0] & 0xff); \
} while (0)
/*
* These macros are used on full 128-bit IP6 addresses.
*/
/* dst is an array name of type uint32 [] */
#define SAL_IP6_ADDR_TO_UINT32(ip6, dst) do {\
SAL_IP6_ADDR_HALF_TO_UINT32(&((ip6)[8]), (dst)); \
SAL_IP6_ADDR_HALF_TO_UINT32((ip6), &((dst)[2])); \
} while (0)
/* src is an array name of type uint32 [] */
#define SAL_IP6_ADDR_FROM_UINT32(ip6, src) do {\
SAL_IP6_ADDR_HALF_FROM_UINT32(&((ip6)[8]), (src)); \
SAL_IP6_ADDR_HALF_FROM_UINT32((ip6), &((src)[2])); \
} while (0)
/* Device bus types */
#define SAL_PCI_DEV_TYPE 0x00001 /* PCI device */
#define SAL_SPI_DEV_TYPE 0x00002 /* SPI device */
#define SAL_EB_DEV_TYPE 0x00004 /* EB device */
#define SAL_ICS_DEV_TYPE 0x00008 /* ICS device */
#define SAL_MII_DEV_TYPE 0x00010 /* MII device */
#define SAL_RCPU_DEV_TYPE 0x00020 /* RCPU device */
#define SAL_I2C_DEV_TYPE 0x00040 /* I2C device */
#define SAL_AXI_DEV_TYPE 0x00080 /* AXI device */
#define SAL_EMMI_DEV_TYPE 0x10000 /* EMMI device */
#define SAL_DEV_BUS_TYPE_MASK 0xf00ff /* Odd for historical reasons */
/* Device types */
#define SAL_SWITCH_DEV_TYPE 0x00100 /* Switch device */
#define SAL_ETHER_DEV_TYPE 0x00200 /* Ethernet device */
#define SAL_CPU_DEV_TYPE 0x00400 /* CPU device */
#define SAL_DEV_TYPE_MASK 0x00f00
/* Access types */
#define SAL_DEV_BUS_RD_16BIT 0x01000 /* 16 bit reads on bus */
#define SAL_DEV_BUS_WR_16BIT 0x02000 /* 16 bit writes on bus */
#define SAL_DEV_BUS_ALT 0x04000 /* Alternate access */
#define SAL_DEV_BUS_MSI 0x08000 /* Message-signaled interrupts */
#define SAL_DEV_FLAG_MASK 0x0f000
/* BDE reserved mask (cannot be used by SAL) */
#define SAL_DEV_BDE_MASK 0xff000000
/* Backward compatibility */
#define SAL_ET_DEV_TYPE SAL_MII_DEV_TYPE
/* Special access addresses */
#define SAL_DEV_OP_EMMI_INIT 0x0fff1000
#endif /* !_SAL_TYPES_H */
/**************************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**************************************************************************/
/*****************************************************************//**
*
*\file version.h
*
*\brief This file contains functions to get the build details
*
********************************************************************/
#ifndef _OPENNSL_VERSION_H
#define _OPENNSL_VERSION_H
#include "sal/commdefs.h"
/*****************************************************************//**
*\brief To get the OpenNSL version.
*
*\retval char* OpenNSL version
********************************************************************/
extern char* opennsl_version_get() LIB_DLL_EXPORTED;
#endif /* _OPENNSL_VERSION_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************
* File: bitop.h
* Details: Bit Array Operations
*********************************************************************/
#ifndef _SHR_BITOP_H
#define _SHR_BITOP_H
#include <sal/types.h>
/* Base type for declarations */
#define SHR_BITDCL uint32
#define SHR_BITWID 32
/* (internal) Number of SHR_BITDCLs needed to contain _max bits */
#define _SHR_BITDCLSIZE(_max) (((_max) + SHR_BITWID - 1) / SHR_BITWID)
/* Size for giving to malloc and memset to handle _max bits */
#define SHR_BITALLOCSIZE(_max) (_SHR_BITDCLSIZE(_max) * sizeof (SHR_BITDCL))
/* Declare bit array _n of size _max bits */
#define SHR_BITDCLNAME(_n, _max) SHR_BITDCL _n[_SHR_BITDCLSIZE(_max)]
/* (internal) Generic operation macro on bit array _a, with bit _b */
#define _SHR_BITOP(_a, _b, _op) \
(((_a)[(_b) / SHR_BITWID]) _op (1U << ((_b) % SHR_BITWID)))
/* Specific operations */
#define SHR_BITGET(_a, _b) _SHR_BITOP(_a, _b, &)
#define SHR_BITSET(_a, _b) _SHR_BITOP(_a, _b, |=)
#define SHR_BITCLR(_a, _b) _SHR_BITOP(_a, _b, &= ~)
#define SHR_BIT_ITER(_a, _max, _b) \
for ((_b) = 0; (_b) < (_max); (_b)++) \
if ((_a)[(_b) / SHR_BITWID] == 0) \
(_b) += (SHR_BITWID - 1); \
else if (SHR_BITGET((_a), (_b)))
/* clear _c bits starting from _b in bit array _a */
extern void shr_bitop_range_clear(SHR_BITDCL *a, CONST int b, CONST int c);
#define SHR_BITCLR_RANGE(_a, _b, _c) \
(shr_bitop_range_clear(_a, _b, _c))
/* set _c bits starting from _b in bit array _a */
extern void shr_bitop_range_set(SHR_BITDCL *a, CONST int b, CONST int c);
#define SHR_BITSET_RANGE(_a, _b, _c) \
(shr_bitop_range_set(_a, _b, _c))
/*
* Copy _e bits from bit array _c offset _d to bit array _a offset _b
* There should be no overlap between source _c and desstination _a
* _a[_b:_b + _e] = _c[_d:_d + _e]
*/
extern void shr_bitop_range_copy(SHR_BITDCL *a,
CONST int b,
CONST SHR_BITDCL *c,
CONST int d,
CONST int e);
#define SHR_BITCOPY_RANGE(_a, _b, _c, _d, _e) \
(shr_bitop_range_copy(_a, _b, _c, _d, _e))
/* Result is 0 only if all bits in the range are 0 */
#define SHR_BITTEST_RANGE(_bits, _first, _bit_count, _result) \
(_result) = !(shr_bitop_range_null(_bits, _first, _bit_count))
extern void shr_bitop_range_and(CONST SHR_BITDCL *bits1,
CONST SHR_BITDCL *bits2,
CONST int first,
CONST int bit_count,
SHR_BITDCL *dest);
extern void shr_bitop_range_or(CONST SHR_BITDCL *bits1,
CONST SHR_BITDCL *bits2,
CONST int first,
CONST int bit_count,
SHR_BITDCL *dest);
extern void shr_bitop_range_xor(CONST SHR_BITDCL *bits1,
CONST SHR_BITDCL *bits2,
CONST int first,
CONST int bit_count,
SHR_BITDCL *dest);
extern void shr_bitop_range_remove(CONST SHR_BITDCL *bits1,
CONST SHR_BITDCL *bits2,
CONST int first,
CONST int bit_count,
SHR_BITDCL *dest);
#define SHR_BITAND_RANGE(_bits1, _bits2, _first, _bit_count, _dest) \
(shr_bitop_range_and(_bits1, _bits2, _first, _bit_count, _dest))
#define SHR_BITOR_RANGE(_bits1, _bits2, _first, _bit_count, _dest) \
(shr_bitop_range_or(_bits1, _bits2, _first, _bit_count, _dest))
#define SHR_BITXOR_RANGE(_bits1, _bits2, _first, _bit_count, _dest) \
(shr_bitop_range_xor(_bits1, _bits2, _first, _bit_count, _dest))
#define SHR_BITREMOVE_RANGE(_bits1, _bits2, _first, _bit_count, _dest) \
(shr_bitop_range_remove(_bits1, _bits2, _first, _bit_count, _dest))
extern void shr_bitop_range_negate(CONST SHR_BITDCL *bits1,
CONST int first,
CONST int bit_count,
SHR_BITDCL *dest);
#define SHR_BITNEGATE_RANGE(_bits1, _first, _bit_count, _dest) \
(shr_bitop_range_negate(_bits1, _first, _bit_count, _dest))
extern int shr_bitop_range_null(CONST SHR_BITDCL *a, CONST int first, CONST int bit_count);
extern int shr_bitop_range_eq(CONST SHR_BITDCL *bits1, CONST SHR_BITDCL *bits2,
CONST int first, CONST int range);
extern void shr_bitop_range_count(CONST SHR_BITDCL *bits, CONST int first,
CONST int range, int *count);
#define SHR_BITNULL_RANGE(_bits, _first, _range) \
(shr_bitop_range_null(_bits, _first, _range))
#define SHR_BITEQ_RANGE(_bits1, _bits2, _first, _range) \
(shr_bitop_range_eq(_bits1, _bits2, _first, _range))
#define SHR_BITCOUNT_RANGE(_bits, _count, _first, _range) \
shr_bitop_range_count(_bits, _first, _range, &(_count))
#endif /* !_SHR_BITOP_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************
* File: error.h
* Details: This file defines common error codes to be shared
* between API layers.
*
* Its contents are not used directly by applications;
* it is used only by header files of parent APIs which
* need to define error codes.
*********************************************************************/
#ifndef _SHR_ERROR_H
#define _SHR_ERROR_H
typedef enum {
_SHR_E_NONE = 0,
_SHR_E_INTERNAL = -1,
_SHR_E_MEMORY = -2,
_SHR_E_UNIT = -3,
_SHR_E_PARAM = -4,
_SHR_E_EMPTY = -5,
_SHR_E_FULL = -6,
_SHR_E_NOT_FOUND = -7,
_SHR_E_EXISTS = -8,
_SHR_E_TIMEOUT = -9,
_SHR_E_BUSY = -10,
_SHR_E_FAIL = -11,
_SHR_E_DISABLED = -12,
_SHR_E_BADID = -13,
_SHR_E_RESOURCE = -14,
_SHR_E_CONFIG = -15,
_SHR_E_UNAVAIL = -16,
_SHR_E_INIT = -17,
_SHR_E_PORT = -18,
_SHR_E_LIMIT = -19 /* Must come last */
} _shr_error_t;
#define _SHR_ERRMSG_INIT { \
"Ok", /* E_NONE */ \
"Internal error", /* E_INTERNAL */ \
"Out of memory", /* E_MEMORY */ \
"Invalid unit", /* E_UNIT */ \
"Invalid parameter", /* E_PARAM */ \
"Table empty", /* E_EMPTY */ \
"Table full", /* E_FULL */ \
"Entry not found", /* E_NOT_FOUND */ \
"Entry exists", /* E_EXISTS */ \
"Operation timed out", /* E_TIMEOUT */ \
"Operation still running", /* E_BUSY */ \
"Operation failed", /* E_FAIL */ \
"Operation disabled", /* E_DISABLED */ \
"Invalid identifier", /* E_BADID */ \
"No resources for operation", /* E_RESOURCE */ \
"Invalid configuration", /* E_CONFIG */ \
"Feature unavailable", /* E_UNAVAIL */ \
"Feature not initialized", /* E_INIT */ \
"Invalid port", /* E_PORT */ \
"Unknown error" /* E_LIMIT */ \
}
extern char *_shr_errmsg[];
#define _SHR_ERRMSG(r) \
_shr_errmsg[(((int)r) <= 0 && ((int)r) > _SHR_E_LIMIT) ? -(r) : -_SHR_E_LIMIT]
#define _SHR_E_SUCCESS(rv) ((rv) >= 0)
#define _SHR_E_FAILURE(rv) ((rv) < 0)
#define _SHR_ERROR_TRACE(__errcode__)
#define _SHR_RETURN(__expr__) return (__expr__)
#define _SHR_E_IF_ERROR_RETURN(op) \
do { int __rv__; if ((__rv__ = (op)) < 0) { _SHR_ERROR_TRACE(__rv__); return(__rv__); } } while(0)
#define _SHR_E_IF_ERROR_NOT_UNAVAIL_RETURN(op) \
do { \
int __rv__; \
if (((__rv__ = (op)) < 0) && (__rv__ != _SHR_E_UNAVAIL)) { \
return(__rv__); \
} \
} while(0)
typedef enum {
_SHR_SWITCH_EVENT_IO_ERROR = 1,
_SHR_SWITCH_EVENT_PARITY_ERROR = 2,
_SHR_SWITCH_EVENT_THREAD_ERROR = 3,
_SHR_SWITCH_EVENT_ACCESS_ERROR = 4,
_SHR_SWITCH_EVENT_ASSERT_ERROR = 5,
_SHR_SWITCH_EVENT_MODID_CHANGE = 6,
_SHR_SWITCH_EVENT_DOS_ATTACK = 7,
_SHR_SWITCH_EVENT_STABLE_FULL = 8,
_SHR_SWITCH_EVENT_STABLE_ERROR = 9,
_SHR_SWITCH_EVENT_UNCONTROLLED_SHUTDOWN = 10,
_SHR_SWITCH_EVENT_WARM_BOOT_DOWNGRADE = 11,
_SHR_SWITCH_EVENT_TUNE_ERROR = 12,
_SHR_SWITCH_EVENT_DEVICE_INTERRUPT = 13,
_SHR_SWITCH_EVENT_ALARM = 14,
_SHR_SWITCH_EVENT_MMU_BST_TRIGGER = 15,
_SHR_SWITCH_EVENT_EPON_ALARM = 16,
_SHR_SWITCH_EVENT_RUNT_DETECT = 17,
_SHR_SWITCH_EVENT_COUNT /* last, as always */
} _shr_switch_event_t;
#endif /* !_SHR_ERROR_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************
* File: gport.h
* Details: This file defines common error codes to be shared
* between API layers.
*
* Its contents are not used directly by applications;
* it is used only by header files of parent APIs which
* need to define error codes.
*********************************************************************/
#ifndef _SHR_GPORT_H
#define _SHR_GPORT_H
/*
* Defines:
* _SHR_GPORT_*
* Purpose:
* GPORT (Generic port) definitions. GPORT can be used to specify
* a {module, port} pair, trunk, and other port types.
*/
#define _SHR_GPORT_NONE (0)
#define _SHR_GPORT_INVALID (-1)
#define _SHR_GPORT_TYPE_LOCAL 1 /* Port on local unit */
#define _SHR_GPORT_TYPE_MODPORT 2 /* Module ID and port */
#define _SHR_GPORT_TYPE_TRUNK 3 /* Trunk ID */
#define _SHR_GPORT_TYPE_LOCAL_CPU 5 /* CPU destination */
#define _SHR_GPORT_TYPE_UCAST_QUEUE_GROUP 9 /* Queue Group */
#define _SHR_GPORT_TYPE_MCAST 11 /* Multicast Set */
#define _SHR_GPORT_TYPE_MCAST_QUEUE_GROUP 12 /* Multicast Queue Group */
#define _SHR_GPORT_TYPE_SCHEDULER 13 /* Scheduler */
#define _SHR_GPORT_TYPE_CHILD 20 /* Child port */
#define _SHR_GPORT_TYPE_EGRESS_GROUP 21 /* Egress group port */
#define _SHR_GPORT_TYPE_EGRESS_CHILD 22 /* Egress child port */
#define _SHR_GPORT_TYPE_EGRESS_MODPORT 23 /* Egress Mod and port */
#define _SHR_GPORT_TYPE_UCAST_SUBSCRIBER_QUEUE_GROUP 24 /* Local Queue Group */
#define _SHR_GPORT_TYPE_MCAST_SUBSCRIBER_QUEUE_GROUP 25 /* Local Multicast Queue Group */
#define _SHR_GPORT_TYPE_COSQ 30 /* cosq gport */
#define _SHR_GPORT_TYPE_PROFILE 40
#define _SHR_GPORT_TYPE_DESTMOD_QUEUE_GROUP 41 /* DMVOQ gport */
#define _SHR_COSQ_GPORT_COMMON_CORE_BITS 3
#define _SHR_COSQ_GPORT_COMMON_CORE_MASK ((1 << _SHR_COSQ_GPORT_COMMON_CORE_BITS) - 1)
#define _SHR_COSQ_GPORT_COMMON_ALL_CORES_VALUE _SHR_COSQ_GPORT_COMMON_CORE_MASK
#define _SHR_CORE_ALL -17
#define _SHR_CORE_FIELD2ID(field) ((field) != _SHR_COSQ_GPORT_COMMON_ALL_CORES_VALUE ? field : _SHR_CORE_ALL)
#define _SHR_CORE_ID2FIELD(id) ((id) != _SHR_CORE_ALL ? id : _SHR_COSQ_GPORT_COMMON_ALL_CORES_VALUE)
#define _SHR_GPORT_TYPE_SHIFT 26
#define _SHR_GPORT_TYPE_MASK 0x3f
#define _SHR_GPORT_MODID_SHIFT 11
#define _SHR_GPORT_MODID_MASK 0x7fff
#define _SHR_GPORT_PORT_SHIFT 0
#define _SHR_GPORT_PORT_MASK 0x7ff
#define _SHR_GPORT_TRUNK_SHIFT 0
#define _SHR_GPORT_TRUNK_MASK 0x3ffffff
#define _SHR_GPORT_UCAST_QUEUE_GROUP_SHIFT 0
#define _SHR_GPORT_UCAST_QUEUE_GROUP_MASK 0x3ffffff
#define _SHR_GPORT_UCAST_QUEUE_GROUP_QID_SHIFT 0
#define _SHR_GPORT_UCAST_QUEUE_GROUP_QID_MASK 0x3fff
#define _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_SHIFT 14
#define _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_MASK 0xfff
#define _SHR_GPORT_SCHEDULER_SHIFT 0
#define _SHR_GPORT_SCHEDULER_MASK 0x7fffff
#define _SHR_GPORT_SCHEDULER_CORE_SHIFT 23
#define _SHR_GPORT_SCHEDULER_CORE_MASK _SHR_COSQ_GPORT_COMMON_CORE_MASK
#define _SHR_GPORT_SCHEDULER_NODE_SHIFT 0
#define _SHR_GPORT_SCHEDULER_NODE_MASK 0xfffff
#define _SHR_GPORT_IS_MODPORT(_gport) \
(((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_MODPORT)
#define _SHR_GPORT_MODPORT_SET(_gport, _module, _port) \
((_gport) = (_SHR_GPORT_TYPE_MODPORT << _SHR_GPORT_TYPE_SHIFT) | \
(((_module) & _SHR_GPORT_MODID_MASK) << _SHR_GPORT_MODID_SHIFT) | \
(((_port) & _SHR_GPORT_PORT_MASK) << _SHR_GPORT_PORT_SHIFT))
#define _SHR_GPORT_MODPORT_MODID_GET(_gport) \
(((_gport) >> _SHR_GPORT_MODID_SHIFT) & _SHR_GPORT_MODID_MASK)
#define _SHR_GPORT_MODPORT_PORT_GET(_gport) \
(((_gport) >> _SHR_GPORT_PORT_SHIFT) & _SHR_GPORT_PORT_MASK)
#define _SHR_GPORT_IS_TRUNK(_gport) \
(((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_TRUNK)
#define _SHR_GPORT_TRUNK_SET(_gport, _trunk_id) \
((_gport) = (_SHR_GPORT_TYPE_TRUNK << _SHR_GPORT_TYPE_SHIFT) | \
(((_trunk_id) & _SHR_GPORT_TRUNK_MASK) << _SHR_GPORT_TRUNK_SHIFT))
#define _SHR_GPORT_TRUNK_GET(_gport) \
(((_gport) >> _SHR_GPORT_TRUNK_SHIFT) & _SHR_GPORT_TRUNK_MASK)
#define _SHR_GPORT_IS_SCHEDULER(_gport) \
(((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_SCHEDULER)
#define _SHR_GPORT_SCHEDULER_SET(_gport, _id) \
_SHR_GPORT_SCHEDULER_CORE_SET(_gport, _id, _SHR_CORE_ALL)
#define _SHR_GPORT_SCHEDULER_GET(_gport) \
(((_gport) >> _SHR_GPORT_SCHEDULER_SHIFT) & _SHR_GPORT_SCHEDULER_MASK)
#define _SHR_GPORT_LOCAL_CPU \
(_SHR_GPORT_TYPE_LOCAL_CPU << _SHR_GPORT_TYPE_SHIFT)
#define _SHR_GPORT_IS_UCAST_QUEUE_GROUP(_gport) \
(((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_UCAST_QUEUE_GROUP)
#define _SHR_GPORT_UCAST_QUEUE_GROUP_SET(_gport, _qid) \
_SHR_GPORT_UCAST_QUEUE_GROUP_SYSQID_SET(_gport, \
_SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_MASK, \
_qid)
#define _SHR_GPORT_UCAST_QUEUE_GROUP_SYSQID_SET(_gport, _sysport_id, _qid) \
((_gport) = (_SHR_GPORT_TYPE_UCAST_QUEUE_GROUP << _SHR_GPORT_TYPE_SHIFT) | \
(((_sysport_id) & _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_MASK) << _SHR_GPORT_UCAST_QUEUE_GROUP_SYSPORTID_SHIFT) | \
(((_qid) & _SHR_GPORT_UCAST_QUEUE_GROUP_QID_MASK) << _SHR_GPORT_UCAST_QUEUE_GROUP_QID_SHIFT))
#define _SHR_GPORT_IS_MCAST_QUEUE_GROUP(_gport) \
(((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_MCAST_QUEUE_GROUP)
#define _SHR_GPORT_IS_COSQ(_gport) \
(((_gport) >> _SHR_GPORT_TYPE_SHIFT) == _SHR_GPORT_TYPE_COSQ)
#define _SHR_GPORT_SCHEDULER_CORE_GET(_gport) \
_SHR_CORE_FIELD2ID((((_gport) >> _SHR_GPORT_SCHEDULER_CORE_SHIFT) & _SHR_GPORT_SCHEDULER_CORE_MASK))
#define _SHR_GPORT_SCHEDULER_CORE_SET(_gport, _scheduler_id, _core_id) \
((_gport) = (_SHR_GPORT_TYPE_SCHEDULER << _SHR_GPORT_TYPE_SHIFT) | \
(((_scheduler_id) & _SHR_GPORT_SCHEDULER_MASK) << _SHR_GPORT_SCHEDULER_SHIFT) | \
(((_SHR_CORE_ID2FIELD(_core_id)) & _SHR_GPORT_SCHEDULER_CORE_MASK) << _SHR_GPORT_SCHEDULER_CORE_SHIFT))
#define _SHR_GPORT_SCHEDULER_NODE_SET(_gport, _level, _node) \
((_gport) = (_SHR_GPORT_TYPE_SCHEDULER << _SHR_GPORT_TYPE_SHIFT) | \
(((_level) & _SHR_GPORT_SCHEDULER_LEVEL_MASK) << _SHR_GPORT_SCHEDULER_LEVEL_SHIFT) | \
(((_node) & _SHR_GPORT_SCHEDULER_NODE_MASK) << _SHR_GPORT_SCHEDULER_NODE_SHIFT))
#define _SHR_GPORT_SCHEDULER_NODE_GET(_gport) \
(((_gport) >> _SHR_GPORT_SCHEDULER_NODE_SHIFT) & _SHR_GPORT_SCHEDULER_NODE_MASK)
#endif /* !_SHR_GPORT_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************
* File: pbmp.h
* Details: Port Bitmap Macros
*********************************************************************/
#ifndef _SHR_PBMP_H
#define _SHR_PBMP_H
#include <sal/types.h>
/*
* Port Bitmap Macros
*
* These macros are never used directly (well, except in the C code
* support routines that are used to help implement the macros).
*
* This header requires that the uint32 type be defined before inclusion.
* Using <sal/types.h> is the simplest (and recommended) way of doing
* this.
*
* There following macros are made available. All have names starting
* with _SHR_, which have been elided from this list:
*
* Constants or Expressions suitable for assignment:
* PBMP_PORT_MAX the maximum number of ports supported
* PBMP_WORD_MAX the maximum number of words in a bitmap
* PBMP_WORD_GET(b, w) return word w (0..WORD_MAX-1) from bitmap b
* PBMP_FMT_LEN length of char[] array for PBMP_FMT
* PBMP_FMT(b,s) %s'able format of bitmap b into string s
* returns s
*
* Predicates: (return 0 or 1, suitable for using in if statements)
* PBMP_MEMBER(b, p) is port p a member of bitmap b?
* PBMP_IS_NULL(b) is bitmap b empty?
* PBMP_NOT_NULL(b) is bitmap b not empty?
* PBMP_EQ(b1, b2) are bitmaps b1 and b2 equal?
* PBMP_NEQ(b1, b2) are bitmaps b1 and b2 not equal?
* PBMP_PORT_VALID(p) is p a valid port number? (0..PORT_MAX)
*
* Statements: (cannot be used as a predicate)
* PBMP_CLEAR(b) zero out a bitmap
* PBMP_COUNT(b, c) store how many bits are on in b into integer c
* PBMP_ITER(b, p) {...} iterate over bitmap b, setting p to each bit
* PBMP_ASSIGN(b1, b2) copy bitmap b2 into b1
* PBMP_AND(b1, b2) and bitmap b2 into b1
* PBMP_OR(b1, b2) or bitmap b2 into b1
* PBMP_XOR(b1, b2) exclusive or bitmap b2 into b1
* PBMP_REMOVE(b1, b2) remove bits in bitmap b2 from b1
* PBMP_NEGATE(b1, b2) copy the bitwise negation of bitmap b2 into b1
* PBMP_PORT_SET(b, p) clear bitmap b, then turn bit p on
* PBMP_PORT_ADD(b, p) turn bit p on in bitmap b
* PBMP_PORT_REMOVE(b, p) turn bit p off in bitmap b
* PBMP_PORT_FLIP(b, p) flip the sense of bit p on in bitmap b
* PBMP_WORD_SET(b, w, v) set word w (0..WORD_MAX-1) from bitmap b to v
*
* Internal forms: (should not be used outside of this header file)
* PBMP_WENT(p) word index for bit p
* PBMP_WBIT(p) word bitmask for bit p
* PBMP_BMCLEAR(b) clear a bitmap
* PBMP_BMNULL(b) is bitmap b empty?
* PBMP_BMEQ(b1, b2) are bitmaps b1 and b2 equal?
* PBMP_BMOP(b1, b2, op) execute op on a word basis on bitmaps b1, b2
* PBMP_ENTRY(b, p) the word of bitmap b that holds bit p
*
* There are 4 styles of implementation for the bitmap macros supported:
* 1. The historic single uint32 implementation (-D_SHR_PBMP_WIDTH=0)
* This is expected to be removed after a decent time of mourning.
* 2. An array of a single uint32 in a struct (-D_SHR_PBMP_WIDTH=32,
* the default). Macros are special cased to handle this efficiently.
* 3. An array of two uint32 in a struct (-D_SHR_PBMP_WIDTH=64, used).
* Macros are again special cased for efficiency.
* 4. An array of more than two uint32 in a struct (-D_SHR_PBMP_WIDTH=256
* for example). Most things are done inline, with a couple of helper
* functions used to implement some macros.
*/
#ifndef _SHR_PBMP_WIDTH
#define _SHR_PBMP_PORT_MAX 256
#define _SHR_PBMP_WIDTH (((_SHR_PBMP_PORT_MAX + 32 - 1)/32)*32)
#endif
#ifndef _SHR_PBMP_PORT_MAX
#define _SHR_PBMP_PORT_MAX _SHR_PBMP_WIDTH
#endif
#define _SHR_PBMP_WORD_WIDTH 32
#define _SHR_PBMP_WORD_MAX \
((_SHR_PBMP_WIDTH + _SHR_PBMP_WORD_WIDTH-1) / _SHR_PBMP_WORD_WIDTH)
typedef struct _shr_pbmp {
uint32 pbits[_SHR_PBMP_WORD_MAX];
} _shr_pbmp_t;
#define _SHR_PBMP_WORD_GET(bm, word) ((bm).pbits[(word)])
#define _SHR_PBMP_WORD_SET(bm, word, val) ((bm).pbits[(word)] = (val))
/*
* Common cases are one word (1..32 ports) and two words (33..64 ports).
* If not the common cases, more complicated code is generated using helper
* functions.
*/
#if _SHR_PBMP_WORD_MAX == 1 /* 32 bit maps */
#define _SHR_PBMP_WENT(port) (0)
#define _SHR_PBMP_WBIT(port) (1U<<(port))
/* helper defines used in the generic section below */
#define _SHR_PBMP_BMCLEAR(bm) (_SHR_PBMP_WORD_GET(bm, 0) = 0)
#define _SHR_PBMP_BMNULL(bm) (_SHR_PBMP_WORD_GET(bm, 0) == 0)
#define _SHR_PBMP_BMEQ(bma, bmb) \
(_SHR_PBMP_WORD_GET(bma, 0) == _SHR_PBMP_WORD_GET(bmb, 0))
#define _SHR_PBMP_BMOP(bma, bmb, op) do { \
_SHR_PBMP_WORD_GET(bma, 0) op _SHR_PBMP_WORD_GET(bmb, 0); \
} while (0)
#define _SHR_PBMP_COUNT(bm, count) \
(count = _shr_popcount(_SHR_PBMP_WORD_GET(bm, 0)))
#elif _SHR_PBMP_WORD_MAX == 2 /* 64 bit maps */
#define _SHR_PBMP_WENT(port) ((port)/_SHR_PBMP_WORD_WIDTH)
#define _SHR_PBMP_WBIT(port) (1U<<((port) % _SHR_PBMP_WORD_WIDTH))
#define _SHR_PBMP_BMCLEAR(bm) \
(_SHR_PBMP_WORD_GET(bm, 0) = _SHR_PBMP_WORD_GET(bm, 1) = 0)
#define _SHR_PBMP_BMNULL(bm) \
(_SHR_PBMP_WORD_GET(bm, 0) == 0 && _SHR_PBMP_WORD_GET(bm, 1) == 0)
#define _SHR_PBMP_BMEQ(bma, bmb) \
((_SHR_PBMP_WORD_GET(bma, 0) == _SHR_PBMP_WORD_GET(bmb, 0)) && \
(_SHR_PBMP_WORD_GET(bma, 1) == _SHR_PBMP_WORD_GET(bmb, 1)))
#define _SHR_PBMP_BMOP(bma, bmb, op) do { \
_SHR_PBMP_WORD_GET(bma, 0) op _SHR_PBMP_WORD_GET(bmb, 0); \
_SHR_PBMP_WORD_GET(bma, 1) op _SHR_PBMP_WORD_GET(bmb, 1); \
} while (0)
#define _SHR_PBMP_COUNT(bm, count) \
(count = _shr_popcount(_SHR_PBMP_WORD_GET(bm, 0)) + \
_shr_popcount(_SHR_PBMP_WORD_GET(bm, 1)))
#elif _SHR_PBMP_WORD_MAX == 3 /* 96 bit maps */
#define _SHR_PBMP_WENT(port) ((port)/_SHR_PBMP_WORD_WIDTH)
#define _SHR_PBMP_WBIT(port) (1U << ((port) % _SHR_PBMP_WORD_WIDTH))
#define _SHR_PBMP_BMCLEAR(bm) \
(_SHR_PBMP_WORD_GET(bm, 0) = _SHR_PBMP_WORD_GET(bm, 1) = \
_SHR_PBMP_WORD_GET(bm, 2) = 0)
#define _SHR_PBMP_BMNULL(bm) \
(_SHR_PBMP_WORD_GET(bm, 0) == 0 && _SHR_PBMP_WORD_GET(bm, 1) == 0 && \
_SHR_PBMP_WORD_GET(bm, 2) == 0)
#define _SHR_PBMP_BMEQ(bma, bmb) \
((_SHR_PBMP_WORD_GET(bma, 0) == _SHR_PBMP_WORD_GET(bmb, 0)) && \
(_SHR_PBMP_WORD_GET(bma, 1) == _SHR_PBMP_WORD_GET(bmb, 1)) && \
(_SHR_PBMP_WORD_GET(bma, 2) == _SHR_PBMP_WORD_GET(bmb, 2)))
#define _SHR_PBMP_BMOP(bma, bmb, op) do { \
_SHR_PBMP_WORD_GET(bma, 0) op _SHR_PBMP_WORD_GET(bmb, 0); \
_SHR_PBMP_WORD_GET(bma, 1) op _SHR_PBMP_WORD_GET(bmb, 1); \
_SHR_PBMP_WORD_GET(bma, 2) op _SHR_PBMP_WORD_GET(bmb, 2); \
} while (0)
#define _SHR_PBMP_COUNT(bm, count) \
(count = _shr_popcount(_SHR_PBMP_WORD_GET(bm, 0)) + \
_shr_popcount(_SHR_PBMP_WORD_GET(bm, 1)) + \
_shr_popcount(_SHR_PBMP_WORD_GET(bm, 2)))
#elif _SHR_PBMP_WORD_MAX == 5 /* 160 bit maps */
#define _SHR_PBMP_WENT(port) ((port)/_SHR_PBMP_WORD_WIDTH)
#define _SHR_PBMP_WBIT(port) (1U << ((port) % _SHR_PBMP_WORD_WIDTH))
#define _SHR_PBMP_BMCLEAR(bm) \
(_SHR_PBMP_WORD_GET(bm, 0) = _SHR_PBMP_WORD_GET(bm, 1) = \
_SHR_PBMP_WORD_GET(bm, 2) = _SHR_PBMP_WORD_GET(bm, 3) = \
_SHR_PBMP_WORD_GET(bm, 4) = 0)
#define _SHR_PBMP_BMNULL(bm) \
(_SHR_PBMP_WORD_GET(bm, 0) == 0 && _SHR_PBMP_WORD_GET(bm, 1) == 0 && \
_SHR_PBMP_WORD_GET(bm, 2) == 0 && _SHR_PBMP_WORD_GET(bm, 3) == 0 && \
_SHR_PBMP_WORD_GET(bm, 4) == 0)
#define _SHR_PBMP_BMEQ(bma, bmb) \
((_SHR_PBMP_WORD_GET(bma, 0) == _SHR_PBMP_WORD_GET(bmb, 0)) && \
(_SHR_PBMP_WORD_GET(bma, 1) == _SHR_PBMP_WORD_GET(bmb, 1)) && \
(_SHR_PBMP_WORD_GET(bma, 2) == _SHR_PBMP_WORD_GET(bmb, 2)) && \
(_SHR_PBMP_WORD_GET(bma, 3) == _SHR_PBMP_WORD_GET(bmb, 3)) && \
(_SHR_PBMP_WORD_GET(bma, 4) == _SHR_PBMP_WORD_GET(bmb, 4)))
#define _SHR_PBMP_BMOP(bma, bmb, op) do { \
_SHR_PBMP_WORD_GET(bma, 0) op _SHR_PBMP_WORD_GET(bmb, 0); \
_SHR_PBMP_WORD_GET(bma, 1) op _SHR_PBMP_WORD_GET(bmb, 1); \
_SHR_PBMP_WORD_GET(bma, 2) op _SHR_PBMP_WORD_GET(bmb, 2); \
_SHR_PBMP_WORD_GET(bma, 3) op _SHR_PBMP_WORD_GET(bmb, 3); \
_SHR_PBMP_WORD_GET(bma, 4) op _SHR_PBMP_WORD_GET(bmb, 4); \
} while (0)
#define _SHR_PBMP_COUNT(bm, count) \
(count = _shr_popcount(_SHR_PBMP_WORD_GET(bm, 0)) + \
_shr_popcount(_SHR_PBMP_WORD_GET(bm, 1)) + \
_shr_popcount(_SHR_PBMP_WORD_GET(bm, 2)) + \
_shr_popcount(_SHR_PBMP_WORD_GET(bm, 3)) + \
_shr_popcount(_SHR_PBMP_WORD_GET(bm, 4)))
#else /* _SHR_PBMP_WORD_MAX == 4 || > 5 */ /* 144 or > 160 bit maps */
/* For use by pbmp.c */
#define _SHR_DEFINE_PBMP_FUNCTIONS
extern int _shr_pbmp_bmnull(_shr_pbmp_t *);
extern int _shr_pbmp_bmeq(_shr_pbmp_t *, _shr_pbmp_t *);
#define _SHR_PBMP_WENT(port) ((port)/_SHR_PBMP_WORD_WIDTH)
#define _SHR_PBMP_WBIT(port) (1U<<((port) % _SHR_PBMP_WORD_WIDTH))
#define _SHR_PBMP_BMCLEAR(bm) do { \
int _w; \
for (_w = 0; _w < _SHR_PBMP_WORD_MAX; _w++) { \
_SHR_PBMP_WORD_GET(bm, _w) = 0; \
} \
} while (0)
#define _SHR_PBMP_BMNULL(bm) (_shr_pbmp_bmnull(&bm))
#define _SHR_PBMP_BMEQ(bma, bmb) (_shr_pbmp_bmeq(&bma, &bmb))
#define _SHR_PBMP_BMOP(bma, bmb, op) do { \
int _w; \
for (_w = 0; _w < _SHR_PBMP_WORD_MAX; _w++) { \
_SHR_PBMP_WORD_GET(bma, _w) op _SHR_PBMP_WORD_GET(bmb, _w); \
} \
} while (0)
#define _SHR_PBMP_COUNT(bm, count) do { \
int _w; \
count = 0; \
for (_w = 0; _w < _SHR_PBMP_WORD_MAX; _w++) { \
count += _shr_popcount(_SHR_PBMP_WORD_GET(bm, _w)); \
} \
} while(0)
#endif /* _SHR_PBMP_WORD_MAX */
/* generics that use the previously defined helpers */
#define _SHR_PBMP_CLEAR(bm) _SHR_PBMP_BMCLEAR(bm)
#define _SHR_PBMP_ITER(bm, port) \
for ((port) = 0; (port) < _SHR_PBMP_PORT_MAX; (port)++) \
if (_SHR_PBMP_MEMBER((bm), (port)))
#define _SHR_PBMP_IS_NULL(bm) (_SHR_PBMP_BMNULL(bm))
#define _SHR_PBMP_NOT_NULL(bm) (!_SHR_PBMP_BMNULL(bm))
#define _SHR_PBMP_EQ(bma, bmb) (_SHR_PBMP_BMEQ(bma, bmb))
#define _SHR_PBMP_NEQ(bma, bmb) (!_SHR_PBMP_BMEQ(bma, bmb))
/* Assignment operators */
#define _SHR_PBMP_ASSIGN(dst, src) (dst) = (src)
#define _SHR_PBMP_AND(bma, bmb) _SHR_PBMP_BMOP(bma, bmb, &=)
#define _SHR_PBMP_OR(bma, bmb) _SHR_PBMP_BMOP(bma, bmb, |=)
#define _SHR_PBMP_XOR(bma, bmb) _SHR_PBMP_BMOP(bma, bmb, ^=)
#define _SHR_PBMP_REMOVE(bma, bmb) _SHR_PBMP_BMOP(bma, bmb, &= ~)
#define _SHR_PBMP_NEGATE(bma, bmb) _SHR_PBMP_BMOP(bma, bmb, = ~)
/* Port PBMP operators */
#define _SHR_PBMP_ENTRY(bm, port) \
(_SHR_PBMP_WORD_GET(bm,_SHR_PBMP_WENT(port)))
#define _SHR_PBMP_MEMBER(bm, port) \
((_SHR_PBMP_ENTRY(bm, port) & _SHR_PBMP_WBIT(port)) != 0)
#define _SHR_PBMP_PORT_SET(bm, port) do { \
_SHR_PBMP_CLEAR(bm); \
_SHR_PBMP_PORT_ADD(bm, port); \
} while(0)
#define _SHR_PBMP_PORT_ADD(bm, port) \
(_SHR_PBMP_ENTRY(bm, port) |= _SHR_PBMP_WBIT(port))
#define _SHR_PBMP_PORT_REMOVE(bm, port) \
(_SHR_PBMP_ENTRY(bm, port) &= ~_SHR_PBMP_WBIT(port))
#define _SHR_PBMP_PORT_FLIP(bm, port) \
(_SHR_PBMP_ENTRY(bm, port) ^= _SHR_PBMP_WBIT(port))
extern char *_shr_pbmp_format(_shr_pbmp_t, char *);
#define _SHR_PBMP_FMT(bm, buf) _shr_pbmp_format(bm, buf)
#define _SHR_PBMP_FMT_LEN ((_SHR_PBMP_WORD_MAX*8)+3)
#endif /* !_SHR_PBMP_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************
* File: phyconfig.h
* Details: This file defines PHY configuration modes.
*
* Its contents are not used directly by applications;
* it is used only by header files of parent APIs which
* need to define port modes.
*********************************************************************/
#ifndef _SHR_PHYCONFIG_H
#define _SHR_PHYCONFIG_H
#include <shared/port.h>
#include <shared/portmode.h>
#include <shared/port_ability.h>
/*
* Structure:
* _shr_phy_config_t
* Purpose:
* Defines the operating mode of a PHY.
*/
typedef struct _shr_phy_config_s {
int enable;
int preferred;
int autoneg_enable;
_shr_port_mode_t autoneg_advert;
_shr_port_ability_t advert_ability;
int force_speed;
int force_duplex;
int master;
_shr_port_mdix_t mdix;
} _shr_phy_config_t;
typedef int (*_shr_port_phy_reset_cb_t)(int unit, _shr_port_t port,
void *user_data);
typedef void (*_shr_port_medium_status_cb_t)(int unit, int port,
_shr_port_medium_t medium,
void *user_arg);
#endif /* !_SHR_PHYCONFIG_H */
/******************************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
* File: phyreg.h
* Details: This file defines common PHY register definition.
*
* Its contents are not used directly by applications;
* it is used only by header files of parent APIs which
* need to define PHY register definition.
******************************************************************************/
#ifndef _SHR_PHYREG_H
#define _SHR_PHYREG_H
#define _SHR_PORT_PHY_INTERNAL 0x00000001
#define _SHR_PORT_PHY_NOMAP 0x00000002
#define _SHR_PORT_PHY_CLAUSE45 0x00000004
#define _SHR_PORT_PHY_I2C_DATA8 0x00000008
#define _SHR_PORT_PHY_I2C_DATA16 0x00000010
#define _SHR_PORT_PHY_CLAUSE45_ADDR(_devad, _regad) \
((((_devad) & 0x3F) << 16) | \
((_regad) & 0xFFFF))
#endif /* !_SHR_PHYREG_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
********************************************************************
* File: port.h
* Details: This file defines common network port parameters.
*
* Its contents are not used directly by applications;
* it is used only by header files of parent APIs
* which need to define port parameters.
* *******************************************************************/
#ifndef _SHR_PORT_H
#define _SHR_PORT_H
/*
* Typedef:
* _shr_port_t
* Purpose:
* Port number type for shared definitions
*/
#include <sal/types.h>
typedef int _shr_port_t;
/*
* Defines:
* _SHR_PORT_DUPLEX_*
* Purpose:
* Defines duplexity of a port
*/
typedef enum _shr_port_duplex_e {
_SHR_PORT_DUPLEX_HALF,
_SHR_PORT_DUPLEX_FULL,
_SHR_PORT_DUPLEX_COUNT /* last, please */
} _shr_port_duplex_t;
/*
* Defines:
* _SHR_PORT_IF_*
* Purpose:
* Defines interface type between MAC and PHY.
*/
typedef enum _shr_port_if_e {
_SHR_PORT_IF_NOCXN, /* No physical connection */
_SHR_PORT_IF_NULL, /* Pass-through connection without PHY */
_SHR_PORT_IF_MII,
_SHR_PORT_IF_GMII,
_SHR_PORT_IF_SGMII,
_SHR_PORT_IF_TBI,
_SHR_PORT_IF_XGMII,
_SHR_PORT_IF_RGMII,
_SHR_PORT_IF_RvMII,
_SHR_PORT_IF_SFI,
_SHR_PORT_IF_XFI,
_SHR_PORT_IF_KR,
_SHR_PORT_IF_KR4,
_SHR_PORT_IF_CR,
_SHR_PORT_IF_CR4,
_SHR_PORT_IF_XLAUI,
_SHR_PORT_IF_SR,
_SHR_PORT_IF_RXAUI,
_SHR_PORT_IF_XAUI,
_SHR_PORT_IF_SPAUI,
_SHR_PORT_IF_QSGMII,
_SHR_PORT_IF_ILKN,
_SHR_PORT_IF_RCY,
_SHR_PORT_IF_FAT_PIPE,
_SHR_PORT_IF_CGMII,
_SHR_PORT_IF_CAUI,
_SHR_PORT_IF_LR,
_SHR_PORT_IF_LR4,
_SHR_PORT_IF_SR4,
_SHR_PORT_IF_KX,
_SHR_PORT_IF_ZR,
_SHR_PORT_IF_SR10,
_SHR_PORT_IF_OTL,
_SHR_PORT_IF_CPU,
_SHR_PORT_IF_OLP,
_SHR_PORT_IF_OAMP,
_SHR_PORT_IF_ERP,
_SHR_PORT_IF_TM_INTERNAL_PKT,
_SHR_PORT_IF_SR2,
_SHR_PORT_IF_KR2,
_SHR_PORT_IF_CR2,
_SHR_PORT_IF_XFI2,
_SHR_PORT_IF_XLAUI2,
_SHR_PORT_IF_CR10,
_SHR_PORT_IF_KR10,
_SHR_PORT_IF_LR10,
_SHR_PORT_IF_ER,
_SHR_PORT_IF_ER2,
_SHR_PORT_IF_ER4,
_SHR_PORT_IF_CX,
_SHR_PORT_IF_CX2,
_SHR_PORT_IF_CX4,
_SHR_PORT_IF_CAUI_C2C,
_SHR_PORT_IF_CAUI_C2M,
_SHR_PORT_IF_VSR,
_SHR_PORT_IF_LR2,
_SHR_PORT_IF_LRM,
_SHR_PORT_IF_XLPPI,
_SHR_PORT_IF_COUNT /* last, please */
} _shr_port_if_t;
/*
* Defines:
* _SHR_PORT_STP_*
* Purpose:
* Defines the spanning tree states of a port.
*/
typedef enum _shr_port_stp_e {
_SHR_PORT_STP_DISABLE = 0,
_SHR_PORT_STP_BLOCK = 1,
_SHR_PORT_STP_LISTEN = 2,
_SHR_PORT_STP_LEARN = 3,
_SHR_PORT_STP_FORWARD = 4,
_SHR_PORT_STP_COUNT = 5 /* last, please */
} _shr_port_stp_t;
/*
* Defines:
* _SHR_PORT_MDIX_*
* Purpose:
* Defines the MDI crossover (MDIX) modes for the port
*/
typedef enum _shr_port_mdix_e {
_SHR_PORT_MDIX_AUTO,
_SHR_PORT_MDIX_FORCE_AUTO,
_SHR_PORT_MDIX_NORMAL,
_SHR_PORT_MDIX_XOVER,
_SHR_PORT_MDIX_COUNT /* last, please */
} _shr_port_mdix_t;
/*
* Defines:
* _SHR_PORT_MDIX_STATUS_*
* Purpose:
* Defines the MDI crossover state
*/
typedef enum _shr_port_mdix_status_e {
_SHR_PORT_MDIX_STATUS_NORMAL,
_SHR_PORT_MDIX_STATUS_XOVER,
_SHR_PORT_MDIX_STATUS_COUNT /* last, please */
} _shr_port_mdix_status_t;
/*
* Defines:
* _SHR_PORT_MEDIUM_*
* Purpose:
* Supported physical mediums
*/
typedef enum _shr_port_medium_e {
_SHR_PORT_MEDIUM_NONE = 0,
_SHR_PORT_MEDIUM_COPPER = 1,
_SHR_PORT_MEDIUM_FIBER = 2,
_SHR_PORT_MEDIUM_COUNT /* last, please */
} _shr_port_medium_t;
#endif /* !_SHR_PORT_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*******************************************************************
* File: port_ability.h
* Details: This file defines common network port modes.
* Its contents are not used directly by applications;
* it is used only by header files of parent APIs which
* need to define port modes.
******************************************************************/
#ifndef _SHR_PORTABILITY_H
#define _SHR_PORTABILITY_H
typedef unsigned int _shr_pa_encap_t;
typedef struct _shr_port_ability_s {
_shr_port_mode_t speed_half_duplex;
_shr_port_mode_t speed_full_duplex;
_shr_port_mode_t pause;
_shr_port_mode_t interface;
_shr_port_mode_t medium;
_shr_port_mode_t loopback;
_shr_port_mode_t flags;
_shr_port_mode_t eee;
_shr_port_mode_t fcmap;
_shr_pa_encap_t encap;
_shr_port_mode_t fec;
} _shr_port_ability_t;
#define _SHR_PA_ABILITY_ALL (0xffffffff)
#define _SHR_PA_ABILITY_NONE (0)
/*
* Defines:
* _SHR_PA_SPEED_*
* Purpose:
* Defines for half duplex port speeds.
*/
#define _SHR_PA_SPEED_10MB (1 << 0)
#define _SHR_PA_SPEED_EXTENDED (1 << 1)
#define _SHR_PA_SPEED_27GB (1 << 2)
#define _SHR_PA_SPEED_50GB (1 << 3)
#define _SHR_PA_SPEED_53GB (1 << 4)
#define _SHR_PA_SPEED_100MB (1 << 5)
#define _SHR_PA_SPEED_1000MB (1 << 6)
#define _SHR_PA_SPEED_2500MB (1 << 7)
#define _SHR_PA_SPEED_3000MB (1 << 8)
#define _SHR_PA_SPEED_5000MB (1 << 9)
#define _SHR_PA_SPEED_6000MB (1 << 10)
#define _SHR_PA_SPEED_10GB (1 << 11)
#define _SHR_PA_SPEED_11GB (1 << 12)
#define _SHR_PA_SPEED_12GB (1 << 13)
#define _SHR_PA_SPEED_12P5GB (1 << 14)
#define _SHR_PA_SPEED_13GB (1 << 15)
#define _SHR_PA_SPEED_15GB (1 << 16)
#define _SHR_PA_SPEED_16GB (1 << 17)
#define _SHR_PA_SPEED_20GB (1 << 18)
#define _SHR_PA_SPEED_21GB (1 << 19)
#define _SHR_PA_SPEED_23GB (1 << 20)
#define _SHR_PA_SPEED_24GB (1 << 21)
#define _SHR_PA_SPEED_25GB (1 << 22)
#define _SHR_PA_SPEED_30GB (1 << 23)
#define _SHR_PA_SPEED_40GB (1 << 24)
#define _SHR_PA_SPEED_42GB (1 << 25)
#define _SHR_PA_SPEED_100GB (1 << 26)
#define _SHR_PA_SPEED_120GB (1 << 27)
#define _SHR_PA_SPEED_127GB (1 << 28)
#define _SHR_PA_SPEED_106GB (1 << 29)
#define _SHR_PA_SPEED_48GB (1 << 30)
#define _SHR_PA_SPEED_32GB (1 << 31)
/*
* Defines:
* _SHR_PA_PAUSE_*
* Purpose:
* Defines for flow control abilities.
*/
#define _SHR_PA_PAUSE_TX (1 << 0) /* TX pause capable */
#define _SHR_PA_PAUSE_RX (1 << 1) /* RX pause capable */
#define _SHR_PA_PAUSE_ASYMM (1 << 2) /* Asymm pause capable (R/O) */
/*
* Defines:
* _SHR_PA_FEC_*
* Purpose:
* Defines for FEC abilities.
*/
#define _SHR_PA_FEC (1 << 0) /* FEC ability support */
#define _SHR_PA_FEC_REQUEST (1 << 1) /* FEC ability request */
/*
* Defines:
* _SHR_PA_INTF_*
* Purpose:
* Defines for port interfaces supported.
*/
#define _SHR_PA_INTF_TBI (1 << 0) /* TBI mode supported */
#define _SHR_PA_INTF_MII (1 << 1) /* MII mode supported */
#define _SHR_PA_INTF_GMII (1 << 2) /* GMII mode supported */
#define _SHR_PA_INTF_RGMII (1 << 3) /* RGMII mode supported */
#define _SHR_PA_INTF_SGMII (1 << 4) /* SGMII mode supported */
#define _SHR_PA_INTF_XGMII (1 << 5) /* XGMII mode supported */
#define _SHR_PA_INTF_QSGMII (1 << 6) /* QSGMII mode supported */
#define _SHR_PA_INTF_CGMII (1 << 7) /* CGMII mode supported */
/*
* Defines:
* _SHR_PA_MEDIUM_*
* Purpose:
* Defines for port medium modes.
*/
#define _SHR_PA_MEDIUM_COPPER (1 << 0)
#define _SHR_PA_MEDIUM_FIBER (1 << 1)
/*
* Defines:
* _SHR_PA_LOOPBACK_*
* Purpose:
* Defines for port loopback modes.
*/
#define _SHR_PA_LB_NONE (1 << 0) /* Useful for automated test */
#define _SHR_PA_LB_MAC (1 << 1) /* MAC loopback supported */
#define _SHR_PA_LB_PHY (1 << 2) /* PHY loopback supported */
#define _SHR_PA_LB_LINE (1 << 3) /* PHY lineside loopback */
/*
* Defines:
* _SHR_PA_FLAGS_*
* Purpose:
* Defines for the reest of port ability flags.
*/
#define _SHR_PA_AUTONEG (1 << 0) /* Auto-negotiation */
#define _SHR_PA_COMBO (1 << 1) /* COMBO ports support both
* copper and fiber interfaces */
#define _SHR_PA_PAUSE (_SHR_PA_PAUSE_TX | _SHR_PA_PAUSE_RX)
#define _SHR_PA_SPEED_ALL (_SHR_PA_SPEED_127GB | \
_SHR_PA_SPEED_120GB | \
_SHR_PA_SPEED_106GB | \
_SHR_PA_SPEED_100GB | \
_SHR_PA_SPEED_53GB | \
_SHR_PA_SPEED_50GB | \
_SHR_PA_SPEED_42GB | \
_SHR_PA_SPEED_40GB | \
_SHR_PA_SPEED_32GB | \
_SHR_PA_SPEED_30GB | \
_SHR_PA_SPEED_27GB | \
_SHR_PA_SPEED_25GB | \
_SHR_PA_SPEED_24GB | \
_SHR_PA_SPEED_23GB | \
_SHR_PA_SPEED_21GB | \
_SHR_PA_SPEED_20GB | \
_SHR_PA_SPEED_16GB | \
_SHR_PA_SPEED_15GB | \
_SHR_PA_SPEED_13GB | \
_SHR_PA_SPEED_12P5GB | \
_SHR_PA_SPEED_12GB | \
_SHR_PA_SPEED_11GB | \
_SHR_PA_SPEED_10GB | \
_SHR_PA_SPEED_6000MB | \
_SHR_PA_SPEED_5000MB | \
_SHR_PA_SPEED_3000MB | \
_SHR_PA_SPEED_2500MB | \
_SHR_PA_SPEED_1000MB | \
_SHR_PA_SPEED_100MB | \
_SHR_PA_SPEED_10MB)
#define _SHR_PA_SPEED_MAX(m) (((m) & _SHR_PA_SPEED_127GB) ? 127000 : \
((m) & _SHR_PA_SPEED_120GB) ? 120000 : \
((m) & _SHR_PA_SPEED_106GB) ? 106000 : \
((m) & _SHR_PA_SPEED_100GB) ? 100000 : \
((m) & _SHR_PA_SPEED_53GB) ? 53000 : \
((m) & _SHR_PA_SPEED_50GB) ? 50000 : \
((m) & _SHR_PA_SPEED_42GB) ? 42000 : \
((m) & _SHR_PA_SPEED_40GB) ? 40000 : \
((m) & _SHR_PA_SPEED_32GB) ? 32000 : \
((m) & _SHR_PA_SPEED_30GB) ? 30000 : \
((m) & _SHR_PA_SPEED_27GB) ? 27000 : \
((m) & _SHR_PA_SPEED_25GB) ? 25000 : \
((m) & _SHR_PA_SPEED_24GB) ? 24000 : \
((m) & _SHR_PA_SPEED_23GB) ? 23000 : \
((m) & _SHR_PA_SPEED_21GB) ? 21000 : \
((m) & _SHR_PA_SPEED_20GB) ? 20000 : \
((m) & _SHR_PA_SPEED_16GB) ? 16000 : \
((m) & _SHR_PA_SPEED_15GB) ? 15000 : \
((m) & _SHR_PA_SPEED_13GB) ? 13000 : \
((m) & _SHR_PA_SPEED_12P5GB) ? 12500 : \
((m) & _SHR_PA_SPEED_12GB) ? 12000 : \
((m) & _SHR_PA_SPEED_11GB) ? 11000 : \
((m) & _SHR_PA_SPEED_10GB) ? 10000 : \
((m) & _SHR_PA_SPEED_6000MB) ? 6000 : \
((m) & _SHR_PA_SPEED_5000MB) ? 5000 : \
((m) & _SHR_PA_SPEED_3000MB) ? 3000 : \
((m) & _SHR_PA_SPEED_2500MB) ? 2500 : \
((m) & _SHR_PA_SPEED_1000MB) ? 1000 : \
((m) & _SHR_PA_SPEED_100MB) ? 100 : \
((m) & _SHR_PA_SPEED_10MB) ? 10 : 0)
#define _SHR_PA_SPEED(s) ((127000 == (s)) ? _SHR_PA_SPEED_127GB : \
(120000 == (s)) ? _SHR_PA_SPEED_120GB : \
(106000 == (s)) ? _SHR_PA_SPEED_106GB : \
(100000 == (s)) ? _SHR_PA_SPEED_100GB : \
(53000 == (s)) ? _SHR_PA_SPEED_53GB : \
(50000 == (s)) ? _SHR_PA_SPEED_50GB : \
(42000 == (s)) ? _SHR_PA_SPEED_42GB : \
(40000 == (s)) ? _SHR_PA_SPEED_40GB : \
(32000 == (s)) ? _SHR_PA_SPEED_32GB : \
(30000 == (s)) ? _SHR_PA_SPEED_30GB : \
(27000 == (s)) ? _SHR_PA_SPEED_27GB : \
(25000 == (s)) ? _SHR_PA_SPEED_25GB : \
(24000 == (s)) ? _SHR_PA_SPEED_24GB : \
(23000 == (s)) ? _SHR_PA_SPEED_23GB : \
(21000 == (s)) ? _SHR_PA_SPEED_21GB : \
(20000 == (s)) ? _SHR_PA_SPEED_20GB : \
(16000 == (s)) ? _SHR_PA_SPEED_16GB : \
(15000 == (s)) ? _SHR_PA_SPEED_15GB : \
(13000 == (s)) ? _SHR_PA_SPEED_13GB : \
(12500 == (s)) ? _SHR_PA_SPEED_12P5GB : \
(12000 == (s)) ? _SHR_PA_SPEED_12GB : \
(11000 == (s)) ? _SHR_PA_SPEED_11GB : \
(10000 == (s)) ? _SHR_PA_SPEED_10GB : \
(6000 == (s)) ? _SHR_PA_SPEED_6000MB : \
(5000 == (s)) ? _SHR_PA_SPEED_5000MB : \
(3000 == (s)) ? _SHR_PA_SPEED_3000MB : \
(2500 == (s)) ? _SHR_PA_SPEED_2500MB : \
(1000 == (s)) ? _SHR_PA_SPEED_1000MB : \
(100 == (s)) ? _SHR_PA_SPEED_100MB : \
(10 == (s)) ? _SHR_PA_SPEED_10MB : 0)
/*
* Defines:
* _SHR_PA_EEE_*
* Purpose:
* Defines for EEE
*/
#define _SHR_PA_EEE_100MB_BASETX (1 << 0) /* EEE for 100M-BaseTX */
#define _SHR_PA_EEE_1GB_BASET (1 << 1) /* EEE for 1G-BaseT */
#define _SHR_PA_EEE_10GB_BASET (1 << 2) /* EEE for 10G-BaseT */
#define _SHR_PA_EEE_10GB_KX (1 << 3) /* EEE for 10G-KX */
#define _SHR_PA_EEE_10GB_KX4 (1 << 4) /* EEE for 10G-KX4 */
#define _SHR_PA_EEE_10GB_KR (1 << 5) /* EEE for 10G-KR */
#define _SHR_PA_FCMAP (1 << 0)
#define _SHR_PA_FCMAP_FCMAC_LOOPBACK (1 << 1)
#define _SHR_PA_FCMAP_AUTONEG (1 << 2)
#define _SHR_PA_FCMAP_2GB (1 << 3)
#define _SHR_PA_FCMAP_4GB (1 << 4)
#define _SHR_PA_FCMAP_8GB (1 << 5)
#define _SHR_PA_FCMAP_16GB (1 << 6)
#endif /* !_SHR_PORTABILITY_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*********************************************************************
* File: portmode.h
* Details: This file defines common network port modes.
*
* Its contents are not used directly by applications;
* it is used only by header files of parent APIs which
* need to define port modes.
********************************************************************/
#ifndef _SHR_PORTMODE_H
#define _SHR_PORTMODE_H
typedef unsigned int _shr_port_mode_t;
/*
* Defines:
* _SHR_PM_*
* Purpose:
* Defines for port modes.
*/
#define _SHR_PM_10MB_HD (1 << 0)
#define _SHR_PM_10MB_FD (1 << 1)
#define _SHR_PM_100MB_HD (1 << 2)
#define _SHR_PM_100MB_FD (1 << 3)
#define _SHR_PM_1000MB_HD (1 << 4)
#define _SHR_PM_1000MB_FD (1 << 5)
#define _SHR_PM_2500MB_HD (1 << 6)
#define _SHR_PM_2500MB_FD (1 << 7)
#define _SHR_PM_10GB_HD (1 << 8)
#define _SHR_PM_10GB_FD (1 << 9)
#define _SHR_PM_PAUSE_TX (1 << 10) /* TX pause capable */
#define _SHR_PM_PAUSE_RX (1 << 11) /* RX pause capable */
#define _SHR_PM_PAUSE_ASYMM (1 << 12) /* Asymm pause capable (R/O) */
#define _SHR_PM_TBI (1 << 13) /* TBI mode supported */
#define _SHR_PM_MII (1 << 14) /* MII mode supported */
#define _SHR_PM_GMII (1 << 15) /* GMII mode supported */
#define _SHR_PM_SGMII (1 << 16) /* SGMII mode supported */
#define _SHR_PM_XGMII (1 << 17) /* XGMII mode supported */
#define _SHR_PM_LB_MAC (1 << 18) /* MAC loopback supported */
#define _SHR_PM_LB_NONE (1 << 19) /* Useful for automated test */
#define _SHR_PM_LB_PHY (1 << 20) /* PHY loopback supported */
#define _SHR_PM_AN (1 << 21) /* Auto-negotiation */
#define _SHR_PM_3000MB_HD (1 << 29)
#define _SHR_PM_3000MB_FD (1 << 30)
#define _SHR_PM_12GB_HD (1 << 22)
#define _SHR_PM_12GB_FD (1 << 23)
#define _SHR_PM_13GB_HD (1 << 24)
#define _SHR_PM_13GB_FD (1 << 25)
#define _SHR_PM_16GB_HD (1 << 26)
#define _SHR_PM_16GB_FD (1 << 27)
#define _SHR_PM_COMBO (1 << 31) /* COMBO ports support both
* copper and fiber interfaces */
#define _SHR_PM_PAUSE (_SHR_PM_PAUSE_TX | _SHR_PM_PAUSE_RX)
#define _SHR_PM_10MB (_SHR_PM_10MB_HD | _SHR_PM_10MB_FD)
#define _SHR_PM_100MB (_SHR_PM_100MB_HD | _SHR_PM_100MB_FD)
#define _SHR_PM_1000MB (_SHR_PM_1000MB_HD | _SHR_PM_1000MB_FD)
#define _SHR_PM_2500MB (_SHR_PM_2500MB_HD | _SHR_PM_2500MB_FD)
#define _SHR_PM_3000MB (_SHR_PM_3000MB_HD | _SHR_PM_3000MB_FD)
#define _SHR_PM_10GB (_SHR_PM_10GB_HD | _SHR_PM_10GB_FD)
#define _SHR_PM_12GB (_SHR_PM_12GB_HD | _SHR_PM_12GB_FD)
#define _SHR_PM_13GB (_SHR_PM_13GB_HD | _SHR_PM_13GB_FD)
#define _SHR_PM_16GB (_SHR_PM_16GB_HD | _SHR_PM_16GB_FD)
#define _SHR_PM_SPEED_ALL (_SHR_PM_16GB | \
_SHR_PM_13GB | \
_SHR_PM_12GB | \
_SHR_PM_10GB | \
_SHR_PM_3000MB | \
_SHR_PM_2500MB | \
_SHR_PM_1000MB | \
_SHR_PM_100MB | \
_SHR_PM_10MB)
#define _SHR_PM_SPEED_MAX(m) (((m) & _SHR_PM_16GB) ? 16000 : \
((m) & _SHR_PM_13GB) ? 13000 : \
((m) & _SHR_PM_12GB) ? 12000 : \
((m) & _SHR_PM_10GB) ? 10000 : \
((m) & _SHR_PM_3000MB) ? 3000 : \
((m) & _SHR_PM_2500MB) ? 2500 : \
((m) & _SHR_PM_1000MB) ? 1000 : \
((m) & _SHR_PM_100MB) ? 100 : \
((m) & _SHR_PM_10MB) ? 10 : 0)
#define _SHR_PM_SPEED(s) ((16000 == (s)) ? _SHR_PM_16GB : \
(13000 == (s)) ? _SHR_PM_13GB : \
(12000 == (s)) ? _SHR_PM_12GB : \
(10000 == (s)) ? _SHR_PM_10GB : \
(3000 == (s)) ? _SHR_PM_3000MB : \
(2500 == (s)) ? _SHR_PM_2500MB : \
(1000 == (s)) ? _SHR_PM_1000MB : \
(100 == (s)) ? _SHR_PM_100MB : \
(10 == (s)) ? _SHR_PM_10MB : 0)
#define _SHR_PM_FD (_SHR_PM_16GB_FD | \
_SHR_PM_13GB_FD | \
_SHR_PM_12GB_FD | \
_SHR_PM_10GB_FD | \
_SHR_PM_3000MB_FD | \
_SHR_PM_2500MB_FD | \
_SHR_PM_1000MB_FD | \
_SHR_PM_100MB_FD | \
_SHR_PM_10MB_FD)
#define _SHR_PM_HD (_SHR_PM_16GB_HD | \
_SHR_PM_13GB_HD | \
_SHR_PM_12GB_HD | \
_SHR_PM_10GB_HD | \
_SHR_PM_3000MB_HD | \
_SHR_PM_2500MB_HD | \
_SHR_PM_1000MB_HD | \
_SHR_PM_100MB_HD | \
_SHR_PM_10MB_HD)
#endif /* !_SHR_PORTMODE_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*********************************************************************
* File: rx.h
* Details: Packet Receive Reason Types
********************************************************************/
#ifndef _SHR_RX_H_
#define _SHR_RX_H_
#include <shared/bitop.h>
/*
* PKT RX Packet Reasons; reason CPU received the packet.
* Notes: It is possible no reasons are set (directed to CPU from ARL
* for example), or multiple reasons may be set.
*/
typedef enum _shr_rx_reason_e {
_SHR_RX_INVALID = 0,
_SHR_RX_ARP = 1, /* ARP Packet */
_SHR_RX_BPDU = 2, /* BPDU Packet */
_SHR_RX_BROADCAST = 3, /* Broadcast packet */
_SHR_RX_CLASS_BASED_MOVE = 4, /* Class-based move prevented */
_SHR_RX_CLASS_TAG_PACKETS = 5, /* Higig Header with PPD=1 */
_SHR_RX_CONTROL = 6, /* Control frame or reserved addr */
_SHR_RX_CPU_LEARN = 7, /* CPU Learned (or VLAN not found */
/* on Strata devices) */
_SHR_RX_DEST_LOOKUP_FAIL = 8, /* Destination lookup fail (or L3 */
/* station move on Strata devices) */
_SHR_RX_DHCP = 9, /* DHCP packets */
_SHR_RX_DOS_ATTACK = 10, /* DOS Attack Packet */
_SHR_RX_E2E_HOL_IBP = 11, /* E2E HOL or IBP Packet */
_SHR_RX_ENCAP_HIGIG_ERROR = 12, /* Non-HG packets received on an */
/* E-HG port */
_SHR_RX_FILTER_MATCH = 13, /* Filter Match */
_SHR_RX_GRE_CHECKSUM = 14, /* GRE checksum */
_SHR_RX_GRE_SOURCE_ROUTE = 15, /* GRE source routing */
_SHR_RX_HIGIG_CONTROL = 16, /* Higig Packet with Control Opcode */
_SHR_RX_HIGIG_HDR_ERROR = 17, /* Higig+ header errors */
_SHR_RX_ICMP_REDIRECT = 18, /* ICMP Recirect */
_SHR_RX_IGMP = 19, /* IGMP packet */
_SHR_RX_INGRESS_FILTER = 20, /* Ingress Filter (VLAN membership) */
_SHR_RX_IP = 21, /* IP packet */
_SHR_RX_IPFIX_RATE_VIOLATION = 22, /* IPFIX flows exceed metering */
_SHR_RX_IP_MCAST_MISS = 23, /* IPMC miss */
_SHR_RX_IP_OPTION_VERSION = 24, /* IP options present or IP ver != 4 */
_SHR_RX_IPMC = 25, /* Class D IP multicast packet */
_SHR_RX_IPMC_RSVD = 26, /* IPMC Reserved Packet */
_SHR_RX_L2_CPU = 27, /* L2_TABLE - copy to CPU (on 5690) */
_SHR_RX_L2_DEST_MISS = 28, /* L2 destination lookup failure */
_SHR_RX_L2_LEARN_LIMIT = 29, /* L2 Learn Limit */
_SHR_RX_L2_MOVE = 30, /* L2 Station Movement */
_SHR_RX_L2_MTU_FAIL = 31, /* L2 MTU check fail */
_SHR_RX_L2_NON_UNICAST_MISS = 32, /* L2 Non-Unicast lookup miss */
_SHR_RX_L2_SOURCE_MISS = 33, /* L2 source lookup failure */
_SHR_RX_L3_ADDR_BIND_FAIL = 34, /* MAC to IP bind check failure */
_SHR_RX_L3_DEST_MISS = 35, /* L3 DIP Miss */
_SHR_RX_L3_HEADER_ERROR = 36, /* L3 header - IP options, */
_SHR_RX_L3_MTU_FAIL = 37, /* L3 MTU check fail */
_SHR_RX_L3_SLOW_PATH = 38, /* L3 slow path processed pkt. */
_SHR_RX_L3_SOURCE_MISS = 39, /* L3 SIP Miss */
_SHR_RX_L3_SOUCE_MOVE = 40, /* L3 Station Movement */
_SHR_RX_MARTIAN_ADDR = 41, /* Pkt. with Martian address */
_SHR_RX_MCAST_IDX_ERROR = 42, /* Multicast index error */
_SHR_RX_MCAST_MISS = 43, /* MC miss */
_SHR_RX_MIM_SERVICE_ERROR = 44, /* MiM terminated unicast packets */
/* that do not have a valid I-SID */
_SHR_RX_MPLS_CTRL_WORD_ERROR = 45, /* MPLS Control Word type is not 0 */
_SHR_RX_MPLS_ERROR = 46, /* MPLS error */
_SHR_RX_MPLS_INVALID_ACTION = 47, /* MPLS Invalid Action */
_SHR_RX_MPLS_INVALID_PAYLOAD = 48, /* MPLS Invalid Payload */
_SHR_RX_MPLS_LABEL_MISS = 49, /* MPLS table miss */
_SHR_RX_MPLS_SEQUENCE_NUMBER = 50, /* MPLS Sequence number */
_SHR_RX_MPLS_TTL = 51, /* MPLS TTL */
_SHR_RX_MULTICAST = 52, /* Multicast packet */
_SHR_RX_NHOP = 53, /* Copy to CPU from NH Idx Tbl */
_SHR_RX_OAM_ERROR = 54, /* OAM packets to CPU for error cases */
_SHR_RX_OAM_SLOW_PATH = 55, /* OAM packets to CPU - slowpath */
/* process */
_SHR_RX_OAM_LMDM = 56, /* OAM LMM/LMR, DMM/DMR packets to CPU */
_SHR_RX_PARITY_ERROR = 57, /* Parity error on IP tables */
_SHR_RX_PROTOCOL = 58, /* Protocol Packet */
_SHR_RX_SAMPLE_DEST = 59, /* Egress sFlow sampled */
_SHR_RX_SAMPLE_SOURCE = 60, /* Ingress sFlow sampled */
_SHR_RX_SHARED_VLAN_MISMATCH = 61, /* Private VLAN Mismatch */
_SHR_RX_SOURCE_ROUTE = 62, /* Source routing bit set */
_SHR_RX_TIME_STAMP = 63, /* Network time sync packet */
_SHR_RX_TTL = 64, /* TTL <= 0 or TTL < IPMC threshold */
_SHR_RX_TTL1 = 65, /* L3UC or IPMC packet with TTL */
/* equal to 1 */
_SHR_RX_TUNNEL_ERROR = 66, /* Tunnel error trap */
_SHR_RX_UDP_CHECKSUM = 67, /* UDP checksum */
_SHR_RX_UNKNOWN_VLAN = 68, /* Unknown VLAN; VID = 0xfff; */
/* CPU Learn bit (on 5690 devices) */
_SHR_RX_URPF_FAIL = 69, /* URPF Check Failed */
_SHR_RX_VC_LABEL_MISS = 70, /* VPLS table miss */
_SHR_RX_VLAN_FILTER_MATCH = 71, /* VLAN Filter Match */
_SHR_RX_WLAN_CLIENT_ERROR = 72, /* ROC error packets to the CPU */
_SHR_RX_WLAN_SLOW_PATH = 73, /* WLAN packets slowpath to the CPU */
_SHR_RX_WLAN_DOT1X_DROP = 74, /* WLAN client is unauthenticated */
_SHR_RX_EXCEPTION_FLOOD = 75, /* Exception processing or flooding */
/* (Robo chips) */
_SHR_RX_TIMESYNC = 76, /* Time Sync protocol packet */
_SHR_RX_EAV_DATA = 77, /* Ethernet AV data packet */
_SHR_RX_SAME_PORT_BRIDGE = 78, /* Hairpin or Same port */
/* switching/bridging */
_SHR_RX_SPLIT_HORIZON = 79, /* Basic bridging or VPLS Split */
/* horizon */
_SHR_RX_L4_ERROR = 80, /* TCP/UDP header or port number */
/* errors */
_SHR_RX_STP = 81, /* STP Ingress or Egress checks */
_SHR_RX_EGRESS_FILTER_REDIRECT = 82, /* Vlan egress filter redirect */
_SHR_RX_FILTER_REDIRECT = 83, /* Field processor redirect */
_SHR_RX_LOOPBACK = 84, /* Loopbacked */
_SHR_RX_VLAN_TRANSLATE = 85, /* VLAN translation table missed when */
/* it is expected to hit */
_SHR_RX_MMRP = 86, /* Packet of type MMRP */
_SHR_RX_SRP = 87, /* Packet of type SRP */
_SHR_RX_TUNNEL_CONTROL = 88, /* Tunnel control packet */
_SHR_RX_L2_MARKED = 89, /* L2 table marked */
_SHR_RX_WLAN_SLOWPATH_KEEPALIVE = 90, /* WLAN slowpath to the CPU, */
/* otherwise dropped */
_SHR_RX_STATION = 91, /* MPLS sent to CPU */
_SHR_RX_NIV = 92, /* NIV packet */
_SHR_RX_NIV_PRIO_DROP = 93, /* NIV packet, priority drop */
_SHR_RX_NIV_INTERFACE_MISS = 94, /* NIV packet, interface miss */
_SHR_RX_NIV_RPF_FAIL = 95, /* NIV packet, RPF failed */
_SHR_RX_NIV_TAG_INVALID = 96, /* NIV packet, invalid tag */
_SHR_RX_NIV_TAG_DROP = 97, /* NIV packet, tag drop */
_SHR_RX_NIV_UNTAG_DROP = 98, /* NIV packet, untagged drop */
_SHR_RX_TRILL = 99, /* TRILL packet */
_SHR_RX_TRILL_INVALID = 100, /* TRILL packet, header error */
_SHR_RX_TRILL_MISS = 101, /* TRILL packet, lookup miss */
_SHR_RX_TRILL_RPF_FAIL = 102, /* TRILL packet, RPF check failed */
_SHR_RX_TRILL_SLOWPATH = 103, /* TRILL packet, slowpath to CPU */
_SHR_RX_TRILL_CORE_IS_IS = 104, /* TRILL packet, Core IS-IS */
_SHR_RX_TRILL_TTL = 105, /* TRILL packet, TTL check failed */
_SHR_RX_BFD_SLOWPATH = 106, /* The BFD packet is being fwd to the */
/* local uC for processing */
_SHR_RX_BFD = 107, /* BFD Error */
_SHR_RX_MIRROR = 108, /* Mirror packet */
_SHR_RX_REGEX_ACTION = 109, /* Flow tracker */
_SHR_RX_REGEX_MATCH = 110, /* Signature Match */
_SHR_RX_FAILOVER_DROP = 111, /* Protection drop data */
_SHR_RX_WLAN_TUNNEL_ERROR = 112, /* WLAN shim header error to CPU */
_SHR_RX_CONGESTION_CNM_PROXY = 113, /* Congestion CNM Proxy */
_SHR_RX_CONGESTION_CNM_PROXY_ERROR = 114, /* Congestion CNM Proxy Error */
_SHR_RX_CONGESTION_CNM = 115, /* Congestion CNM Internal Packet */
_SHR_RX_MPLS_UNKNOWN_ACH = 116, /* MPLS Unknown ACH */
_SHR_RX_MPLS_LOOKUPS_EXCEEDED = 117, /* MPLS out of lookups */
_SHR_RX_MPLS_RESERVED_ENTROPY_LABEL = 118, /* MPLS Entropy label in unallowed */
/* range */
_SHR_RX_MPLS_ILLEGAL_RESERVED_LABEL = 119, /* MPLS illegal reserved label */
_SHR_RX_MPLS_ROUTER_ALERT_LABEL = 120, /* MPLS alert label */
_SHR_RX_NIV_PRUNE = 121, /* NIV access port pruning (dst = src) */
_SHR_RX_VIRTUAL_PORT_PRUNE = 122, /* SVP == DVP */
_SHR_RX_NON_UNICAST_DROP = 123, /* Explicit multicast packet drop */
_SHR_RX_TRILL_PACKET_PORT_MISMATCH = 124, /* TRILL packet vs Rbridge port */
/* conflict */
_SHR_RX_WLAN_CLIENT_MOVE = 125, /* WLAN client moved */
_SHR_RX_WLAN_SOURCE_PORT_MISS = 126, /* WLAN SVP miss */
_SHR_RX_WLAN_CLIENT_SOURCE_MISS = 127, /* WLAN client database SA miss */
_SHR_RX_WLAN_CLIENT_DEST_MISS = 128, /* WLAN client database DA miss */
_SHR_RX_WLAN_MTU = 129, /* WLAN MTU error */
_SHR_RX_TRILL_NAME = 130, /* TRILL packet, Name check failed */
_SHR_RX_L2GRE_SIP_MISS = 131, /* L2 GRE SIP miss */
_SHR_RX_L2GRE_VPN_ID_MISS = 132, /* L2 GRE VPN id miss */
_SHR_RX_TIMESYNC_UNKNOWN_VERSION = 133, /* Unknown version of IEEE1588 */
_SHR_RX_BFD_ERROR = 134, /* BFD ERROR */
_SHR_RX_BFD_UNKNOWN_VERSION = 135, /* BFD UNKNOWN VERSION */
_SHR_RX_BFD_INVALID_VERSION = 136, /* BFD INVALID VERSION */
_SHR_RX_BFD_LOOKUP_FAILURE = 137, /* BFD LOOKUP FAILURE */
_SHR_RX_BFD_INVALID_PACKET = 138, /* BFD INVALID PACKET */
_SHR_RX_VXLAN_SIP_MISS = 139, /* Vxlan SIP miss */
_SHR_RX_VXLAN_VPN_ID_MISS = 140, /* Vxlan VPN id miss */
_SHR_RX_FCOE_ZONE_CHECK_FAIL = 141, /* Fcoe zone check failed */
_SHR_RX_IPMC_INTERFACE_MISMATCH = 142, /* IPMC input interface check failed */
_SHR_RX_NAT = 143, /* NAT */
_SHR_RX_TCP_UDP_NAT_MISS = 144, /* TCP/UDP packet NAT lookup miss */
_SHR_RX_ICMP_NAT_MISS = 145, /* ICMP packet NAT lookup miss */
_SHR_RX_NAT_FRAGMENT = 146, /* NAT lookup on fragmented packet */
_SHR_RX_NAT_MISS = 147, /* Non TCP/UDP/ICMP packet NAT lookup */
/* miss */
_SHR_RX_UNKNOWN_SUBTENTING_PORT = 148, /* UNKNOWN_SUBTENTING_PORT */
_SHR_RX_LLTAG_ABSENT_DROP = 149, /* LLTAG_ABSENT */
_SHR_RX_LLTAG_PRESENT_DROP = 150, /* LLTAG_PRESENT */
_SHR_RX_OAM_CCM_SLOWPATH = 151, /* OAM CCM packet copied to CPU */
_SHR_RX_OAM_INCOMPLETE_OPCODE = 152, /* OAM INCOMPLETE_OPCODE */
_SHR_RX_BHH_OAM_PACKET = 153, /* BHH OAM Packet */
_SHR_RX_RESERVED_0 = 154, /* Broadcom Reserved */
_SHR_RX_OAM_MPLS_LMDM = 155, /* MPLS LM/DM (RFC 6374) packet */
_SHR_RX_SAT = 156, /* OAM SAT pkt */
_SHR_RX_SAMPLE_SOURCE_FLEX = 157, /* Flexible sampled packets to CPU */
_SHR_RX_REASON_COUNT = 158 /* MUST BE LAST */
} _shr_rx_reason_t;
#define _SHR_RX_REASON_NAMES_INITIALIZER { \
"Invalid", \
"Arp", \
"Bpdu", \
"Broadcast", \
"ClassBasedMove", \
"ClassTagPackets", \
"Control", \
"CpuLearn", \
"DestLookupFail", \
"Dhcp", \
"DosAttack", \
"E2eHolIbp", \
"EncapHiGigError", \
"FilterMatch", \
"GreChecksum", \
"GreSourceRoute", \
"HigigControl", \
"HigigHdrError", \
"IcmpRedirect", \
"Igmp", \
"IngressFilter", \
"Ip", \
"IpfixRateViolation", \
"IpMcastMiss", \
"IpOptionVersion", \
"Ipmc", \
"IpmcRsvd", \
"L2Cpu", \
"L2DestMiss", \
"L2LearnLimit", \
"L2Move", \
"L2MtuFail", \
"L2NonUnicastMiss", \
"L2SourceMiss", \
"L3AddrBindFail", \
"L3DestMiss", \
"L3HeaderError", \
"L3MtuFail", \
"L3Slowpath", \
"L3SourceMiss", \
"L3SourceMove", \
"MartianAddr", \
"McastIdxError", \
"McastMiss", \
"MimServiceError", \
"MplsCtrlWordError", \
"MplsError", \
"MplsInvalidAction", \
"MplsInvalidPayload", \
"MplsLabelMiss", \
"MplsSequenceNumber", \
"MplsTtl", \
"Multicast", \
"Nhop", \
"OamError", \
"OamSlowPath", \
"OamLMDM", \
"ParityError", \
"Protocol", \
"SampleDest", \
"SampleSource", \
"SharedVlanMismatch", \
"SourceRoute", \
"TimeStamp", \
"Ttl", \
"Ttl1", \
"TunnelError", \
"UdpChecksum", \
"UnknownVlan", \
"UrpfFail", \
"VcLabelMiss", \
"VlanFilterMatch", \
"WlanClientError", \
"WlanSlowPath", \
"WlanDot1xDrop", \
"ExceptionFlood", \
"Timesync", \
"EavData", \
"SamePortBridge", \
"SplitHorizon", \
"L4Error", \
"Stp", \
"EgressFilterRedirect", \
"FilterRedirect", \
"Loopback", \
"VlanTranslate", \
"Mmrp", \
"Srp", \
"TunnelControl", \
"L2Marked", \
"WlanSlowpathKeepalive", \
"Station", \
"Niv", \
"NivPrioDrop", \
"NivInterfaceMiss", \
"NivRpfFail", \
"NivTagInvalid", \
"NivTagDrop", \
"NivUntagDrop", \
"Trill", \
"TrillInvalid", \
"TrillMiss", \
"TrillRpfFail", \
"TrillSlowpath", \
"TrillCoreIsIs", \
"TrillTtl", \
"BfdSlowpath", \
"Bfd", \
"Mirror", \
"RegexAction", \
"RegexMatch", \
"FailoverDrop", \
"WlanTunnelError", \
"CongestionCnmProxy", \
"CongestionCnmProxyError", \
"CongestionCnm", \
"MplsUnknownAch", \
"MplsLookupsExceeded", \
"MplsReservedEntropyLabel", \
"MplsIllegalReservedLabel", \
"MplsRouterAlertLabel", \
"NivPrune", \
"VirtualPortPrune", \
"NonUnicastDrop", \
"TrillPacketPortMismatch", \
"WlanClientMove", \
"WlanSourcePortMiss", \
"WlanClientSourceMiss", \
"WlanClientDestMiss", \
"WlanMtu", \
"TrillName", \
"L2GreSipMiss", \
"L2GreVpnIdMiss", \
"TimesyncUnknownVersion", \
"BfdError", \
"BfdUnknownVersion", \
"BfdInvalidVersion", \
"BfdLookupFailure", \
"BfdInvalidPacket", \
"VxlanSipMiss", \
"VxlanVpnIdMiss", \
"FcoeZoneCheckFail", \
"IpmcInterfaceMismatch", \
"Nat", \
"TcpUdpNatMiss", \
"IcmpNatMiss", \
"NatFragment", \
"NatMiss", \
"UnknownSubtentingPort", \
"LLTagAbsentDrop", \
"LLTagpresenDrop", \
"OAMCCMslowpath", \
"OAMIncompleteOpcode", \
"OAMCCMpacket", \
"Reserved0", \
"OAMMplsLmDM", \
"SAT", \
"SampleSourceFlex" \
}
/*
* Set of "reasons" (see _SHR_RX_*) why a packet came to the CPU.
*/
typedef struct _shr_rx_reasons_s {
SHR_BITDCL pbits[_SHR_BITDCLSIZE(_SHR_RX_REASON_COUNT)];
} _shr_rx_reasons_t;
/*
* Macro to check if a reason (_SHR_RX_*) is included in a
* set of reasons (_shr_rx_reasons_t). Returns:
* zero => reason is not included in the set
* non-zero => reason is included in the set
*/
#define _SHR_RX_REASON_GET(_reasons, _reason) \
SHR_BITGET(((_reasons).pbits), (_reason))
/*
* Macro to add a reason (_SHR_RX_*) to a set of
* reasons (_shr_rx_reasons_t)
*/
#define _SHR_RX_REASON_SET(_reasons, _reason) \
SHR_BITSET(((_reasons).pbits), (_reason))
/*
* Macro to add all reasons (_SHR_RX_*) to a set of
* reasons (_shr_rx_reasons_t)
*/
#define _SHR_RX_REASON_SET_ALL(_reasons) \
SHR_BITSET_RANGE(((_reasons).pbits), 0, _SHR_RX_REASON_COUNT)
/*
* Macro to clear a reason (_SHR_RX_*) from a set of
* reasons (_shr_rx_reasons_t)
*/
#define _SHR_RX_REASON_CLEAR(_reasons, _reason) \
SHR_BITCLR(((_reasons).pbits), (_reason))
/*
* Macro to clear a set of reasons (_shr_rx_reasons_t).
*/
#define _SHR_RX_REASON_CLEAR_ALL(_reasons) \
SHR_BITCLR_RANGE(((_reasons).pbits), 0, _SHR_RX_REASON_COUNT)
#define _SHR_RX_REASON_IS_NULL(_reasons) \
SHR_BITNULL_RANGE(((_reasons).pbits), \
0, _SHR_RX_REASON_COUNT)
#define _SHR_RX_REASON_ITER(_reasons, reason) \
for(reason = _SHR_RX_INVALID; reason < (int)_SHR_RX_REASON_COUNT; reason++) \
if(_SHR_RX_REASON_GET(_reasons, reason))
#define _SHR_RX_REASON_COUNT(_reasons, _count) \
SHR_BITCOUNT_RANGE(((_reasons).pbits), _count, \
0, _SHR_RX_REASON_COUNT)
#define _SHR_RX_REASON_EQ(_reasons1, _reasons2) \
SHR_BITEQ_RANGE(((_reasons1).pbits), ((_reasons2).pbits), \
0, _SHR_RX_REASON_COUNT)
#define _SHR_RX_REASON_NEQ(_reasons1, _reasons2) \
(!SHR_BITEQ_RANGE(((_reasons1).pbits), ((_reasons2).pbits), \
0, _SHR_RX_REASON_COUNT))
#define _SHR_RX_REASON_AND(_reasons1, _reasons2) \
SHR_BITAND_RANGE(((_reasons1).pbits), ((_reasons2).pbits), 0, \
_SHR_RX_REASON_COUNT, ((_reasons1).pbits))
#define _SHR_RX_REASON_OR(_reasons1, _reasons2) \
SHR_BITOR_RANGE(((_reasons1).pbits), ((_reasons2).pbits), 0, \
_SHR_RX_REASON_COUNT, ((_reasons1).pbits))
#define _SHR_RX_REASON_XOR(_reasons1, _reasons2) \
SHR_BITXOR_RANGE(((_reasons1).pbits), ((_reasons2).pbits), 0, \
_SHR_RX_REASON_COUNT, ((_reasons1).pbits))
#define _SHR_RX_REASON_REMOVE(_reasons1, _reasons2) \
SHR_BITREMOVE_RANGE(((_reasons1).pbits), ((_reasons2).pbits), 0, \
_SHR_RX_REASON_COUNT, ((_reasons1).pbits));
#define _SHR_RX_REASON_NEGATE(_reasons1, _reasons2) \
SHR_BITNEGATE_RANGE(((_reasons2).pbits), 0, \
_SHR_RX_REASON_COUNT, ((_reasons1).pbits));
#endif /* _SHR_RX_H_ */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*********************************************************************
* File: switch.h
********************************************************************/
#ifndef _SHR_SWITCH_H
#define _SHR_SWITCH_H
#define _SHR_SWITCH_MAX_PIPES 4 /* Max number of pipes (or slices) */
#define _SHR_SWITCH_STABLE_NONE 0 /* No storage */
#define _SHR_SWITCH_STABLE_DEVICE_NEXT_HOP 1 /* Use next hop table */
#define _SHR_SWITCH_STABLE_DEVICE_EXT_MEM 2 /* Use external TCAM/SRAM */
#define _SHR_SWITCH_STABLE_APPLICATION 3 /* Use application storage */
#endif /* !_SHR_SWITCH_H */
/*********************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************
* File: types.h
* Details: Shared data types
*********************************************************************/
#ifndef _SHR_TYPES_H_
#define _SHR_TYPES_H_
typedef int8 _shr_dma_chan_t;
typedef enum {
_SHR_COLOR_GREEN = 0,
_SHR_COLOR_YELLOW = 1,
_SHR_COLOR_RED = 2,
_SHR_COLOR_BLACK = 3,
_SHR_COLOR_PRESERVE = 4,
_SHR_COLOR_COUNT = 5
} _shr_color_t;
typedef enum {
_SHR_FORWARDING_TYPE_L2 = 0, /* L2 switching forwarding. */
_SHR_FORWARDING_TYPE_IP4UCAST = 1, /* IPv4 Unicast Routing forwarding. */
_SHR_FORWARDING_TYPE_IP4MCAST = 2, /* IPv4 Multicast Routing forwarding. */
_SHR_FORWARDING_TYPE_IP6UCAST = 3, /* IPv6 Unicast Routing forwarding. */
_SHR_FORWARDING_TYPE_IP6MCAST = 4, /* IPv6 Multicast Routing forwarding. */
_SHR_FORWARDING_TYPE_MPLS = 5, /* MPLS Switching forwarding. */
_SHR_FORWARDING_TYPE_TRILL = 6, /* Trill forwarding. */
_SHR_FORWARDING_TYPE_RXREASON = 7, /* Forwarding according to a RxReason. */
_SHR_FORWARDING_TYPE_TRAFFIC_MANAGMENT = 8, /* Traffic Management forwarding, when
an external Packet Processor sets the
forwarding decision. */
_SHR_FORWARDING_TYPE_SNOOP = 9, /* Snooped packet. */
_SHR_FORWARDING_TYPE_FCoE = 10, /* Fiber Channel over Ethernet
forwarding. */
_SHR_FORWARDING_TYPE_COUNT = 11 /* Always Last. Not a usable value. */
} _shr_forwarding_type_t;
#endif /* _SHR_TYPES_H_ */
/******************************************************************************
*
* (C) Copyright Broadcom Corporation 2013-2016
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
* File: util.h
* Details: This file defines general utility routines.
*
* Its contents are not used directly by applications;
* it is used only by header files of parent APIs which
* need to access these routines.
******************************************************************************/
#ifndef _SHR_UTIL_H
#define _SHR_UTIL_H
#include <sal/types.h>
extern int _shr_popcount(unsigned int);
#endif /* !_SHR_UTIL_H */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: ibde.h,v 1.27 2012/11/02 23:10:59 bpeela Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#ifndef __IBDE_H__
#define __IBDE_H__
#include <sal/types.h>
/*
* Represents a collection of devices
*/
typedef struct ibde_dev_s {
uint16 device;
uint8 rev;
sal_vaddr_t base_address;
sal_vaddr_t base_address1;
sal_vaddr_t base_address2;
} ibde_dev_t;
typedef struct ibde_s {
const char *(*name)(void);
/* Returns the number of devices available */
/* Each device is is accessed through a handle */
/* Handles are assumed to index the array of devices */
/* Support SWITCH or ETHERNET or CPU devices */
int (*num_devices)(int type);
#define BDE_ALL_DEVICES 0
#define BDE_SWITCH_DEVICES 1
#define BDE_ETHER_DEVICES 2
#define BDE_CPU_DEVICES 3
const ibde_dev_t *(*get_dev)(int d);
/*
* Get types of underlaying devices.
* A combination of bus type and functional type is returned.
* In case of bus type, support PCI and SPI device types.
* In case of functional type, specify if underlaying device is
* a switching or ethernet device.
*/
uint32 (*get_dev_type)(int d);
#define BDE_PCI_DEV_TYPE SAL_PCI_DEV_TYPE /* PCI device */
#define BDE_SPI_DEV_TYPE SAL_SPI_DEV_TYPE /* SPI device */
#define BDE_EB_DEV_TYPE SAL_EB_DEV_TYPE /* EB device */
#define BDE_ICS_DEV_TYPE SAL_ICS_DEV_TYPE /* ICS device */
#define BDE_MII_DEV_TYPE SAL_MII_DEV_TYPE /* MII device */
#define BDE_I2C_DEV_TYPE SAL_I2C_DEV_TYPE /* I2C device */
#define BDE_AXI_DEV_TYPE SAL_AXI_DEV_TYPE /* AXI device */
#define BDE_EMMI_DEV_TYPE SAL_EMMI_DEV_TYPE /* EMMI device */
#define BDE_DEV_BUS_ALT SAL_DEV_BUS_ALT /* Alternate Access */
#define BDE_DEV_BUS_MSI SAL_DEV_BUS_MSI /* Message-signaled interrupts */
#define BDE_DEV_BUS_TYPE_MASK SAL_DEV_BUS_TYPE_MASK
#define BDE_SWITCH_DEV_TYPE SAL_SWITCH_DEV_TYPE /* Switch device */
#define BDE_ETHER_DEV_TYPE SAL_ETHER_DEV_TYPE /* Ethernet device */
#define BDE_CPU_DEV_TYPE SAL_CPU_DEV_TYPE /* CPU device */
#define BDE_BYTE_SWAP 0x01000000 /* SW byte swap */
#define BDE_256K_REG_SPACE 0x20000000 /* Map 256K (v 64K) */
#define BDE_128K_REG_SPACE 0x40000000 /* Map 128K (v 64K) */
#define BDE_320K_REG_SPACE 0x80000000 /* Map 256K+64K */
/* Bus supports only 16bit reads */
#define BDE_DEV_BUS_RD_16BIT SAL_DEV_BUS_RD_16BIT
/* Bus supports only 16bit writes */
#define BDE_DEV_BUS_WR_16BIT SAL_DEV_BUS_WR_16BIT
/* Backward compatibility */
#define BDE_ET_DEV_TYPE BDE_MII_DEV_TYPE
#define BDE_DEV_MEM_MAPPED(_d) \
((_d) & (BDE_PCI_DEV_TYPE | BDE_ICS_DEV_TYPE | BDE_EB_DEV_TYPE |\
BDE_EMMI_DEV_TYPE | BDE_AXI_DEV_TYPE))
/*
* PCI Bus Access
*/
uint32 (*pci_conf_read)(int d, uint32 addr);
int (*pci_conf_write)(int d, uint32 addr, uint32 data);
void (*pci_bus_features)(int d, int *be_pio, int *be_packet,
int *be_other);
uint32 (*read)(int d, uint32 addr);
int (*write)(int d, uint32 addr, uint32 data);
uint32* (*salloc)(int d, int size, const char *name);
void (*sfree)(int d, void *ptr);
int (*sflush)(int d, void *addr, int length);
int (*sinval)(int d, void *addr, int length);
int (*interrupt_connect)(int d, void (*)(void*), void *data);
int (*interrupt_disconnect)(int d);
sal_paddr_t (*l2p)(int d, void *laddr);
uint32 *(*p2l)(int d, sal_paddr_t paddr);
/*
* SPI Access via SMP
*/
int (*spi_read)(int d, uint32 addr, uint8 *buf, int len);
int (*spi_write)(int d, uint32 addr, uint8 *buf, int len);
/* Special SPI access addresses */
#define BDE_DEV_OP_EMMI_INIT SAL_DEV_OP_EMMI_INIT
/*
* iProc register access
*/
uint32 (*iproc_read)(int d, uint32 addr);
int (*iproc_write)(int d, uint32 addr, uint32 data);
/*
* Shared memory access
*/
uint32 (*shmem_read)(int dev, uint32 addr, uint8 *buf, uint32 len);
void (*shmem_write)(int dev, uint32 addr, uint8 *buf, uint32 len);
sal_vaddr_t (*shmem_map)(int dev, uint32 addr, uint32 size);
} ibde_t;
/* System BDE */
extern ibde_t *bde;
#endif /* __IBDE_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: kcom.h,v 1.9 2012/10/24 09:55:42 mlarsen Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*
* File: kcom.h
* Purpose: User/Kernel message definitions
*/
#ifndef _KCOM_H
#define _KCOM_H
#include <sal/types.h>
#define KCOM_CHAN_KNET "KCOM_KNET"
/*
* Message types
*/
#define KCOM_MSG_TYPE_CMD 1 /* Command */
#define KCOM_MSG_TYPE_RSP 2 /* Command response */
#define KCOM_MSG_TYPE_EVT 3 /* Unsolicited event */
/*
* Message opcodes
*/
#define KCOM_M_NONE 0 /* Should not be used */
#define KCOM_M_VERSION 1 /* Protocol version */
#define KCOM_M_STRING 2 /* For debug messages */
#define KCOM_M_HW_RESET 3 /* H/W not ready */
#define KCOM_M_HW_INIT 4 /* H/W initialized */
#define KCOM_M_ETH_HW_CONFIG 5 /* ETH HW config*/
#define KCOM_M_DETACH 6 /* Detach kernel module */
#define KCOM_M_NETIF_CREATE 11 /* Create network interface */
#define KCOM_M_NETIF_DESTROY 12 /* Destroy network interface */
#define KCOM_M_NETIF_LIST 13 /* Get list of network interface IDs */
#define KCOM_M_NETIF_GET 14 /* Get network interface info */
#define KCOM_M_FILTER_CREATE 21 /* Create Rx filter */
#define KCOM_M_FILTER_DESTROY 22 /* Destroy Rx filter */
#define KCOM_M_FILTER_LIST 23 /* Get list of Rx filter IDs */
#define KCOM_M_FILTER_GET 24 /* Get Rx filter info */
#define KCOM_M_DMA_INFO 31 /* Tx/Rx DMA info */
#define KCOM_VERSION 8 /* Protocol version */
/*
* Message status codes
*/
#define KCOM_E_NONE 0 /* No errors */
#define KCOM_E_PARAM 1 /* Invalid/unsupported parameter */
#define KCOM_E_RESOURCE 2 /* Out of memory or other resource */
#define KCOM_E_NOT_FOUND 3 /* Requested object not found */
typedef struct kcom_msg_hdr_s {
uint8 type;
uint8 opcode;
uint8 seqno;
uint8 status;
uint8 unit;
uint8 reserved;
uint16 id;
} kcom_msg_hdr_t;
/*
* Object types
*/
/*
* System network interface
*
* Network interface types:
*
* KCOM_NETIF_T_VLAN
* Transmits to this interface will go to ingress PIPE of switch
* CPU port using specified VLAN ID. Packet will be switched.
*
* KCOM_NETIF_T_PORT
* Transmits to this interface will go to unmodified to specified
* physical switch port. All switching logic is bypassed.
*
* KCOM_NETIF_T_META
* Transmits to this interface will be done using raw meta data
* as DMA descriptors. Currently used for RCPU mode only.
*
* Network interface flags:
*
* KCOM_NETIF_F_ADD_TAG
* Add VLAN tag to packets sent directly to physical port.
*
* KCOM_NETIF_F_RCPU_ENCAP
* Use RCPU encapsulation for packets that enter and exit this
* interface.
*/
#define KCOM_NETIF_T_VLAN 0
#define KCOM_NETIF_T_PORT 1
#define KCOM_NETIF_T_META 2
#define KCOM_NETIF_F_ADD_TAG (1U << 0)
#define KCOM_NETIF_F_RCPU_ENCAP (1U << 1)
#define KCOM_NETIF_NAME_MAX 16
typedef struct kcom_netif_s {
uint16 id;
uint8 type;
uint8 flags;
uint8 port;
uint8 reserved;
uint16 vlan;
uint16 qnum;
uint8 macaddr[6];
char name[KCOM_NETIF_NAME_MAX];
} kcom_netif_t;
/*
* Packet filters
*
* Filters work like software TCAMs where a mask is applied to the
* source data, and the result is then compared to the filter data.
*
* Filters are checked in priority order with the lowest priority
* values being checked first (i.e. 0 is the highest priority).
*
* Filter types:
*
* KCOM_FILTER_T_RX_PKT
* Filter data and mask are applied to the Rx DMA control block
* as well as to the Rx packet contents.
*
* Destination types:
*
* KCOM_DEST_T_NULL
* Packet is dropped.
*
* KCOM_DEST_T_NETIF
* Packet is sent to network interface with ID <dest_id>.
*
* KCOM_DEST_T_API
* Packet is sent to Rx API through queue <dest_id>.
*
* KCOM_DEST_T_CB
* Packet destination is obtained from kernel call-back function.
*
* Filter flags:
*
* KCOM_FILTER_F_ANY_DATA
* When this flags is set the filter will match any packet on
* the associated unit.
*
* KCOM_FILTER_F_STRIP_TAG
* Strip VLAN tag before packet is sent to destination.
* This flag only applies to KCOM_DEST_T_NETIF.
*
*/
#define KCOM_FILTER_BYTES_MAX 256
#define KCOM_FILTER_WORDS_MAX BYTES2WORDS(KCOM_FILTER_BYTES_MAX)
#define KCOM_FILTER_T_RX_PKT 1
#define KCOM_DEST_T_NULL 0
#define KCOM_DEST_T_NETIF 1
#define KCOM_DEST_T_API 2
#define KCOM_DEST_T_CB 3
#define KCOM_FILTER_F_ANY_DATA (1U << 0)
#define KCOM_FILTER_F_STRIP_TAG (1U << 1)
#define KCOM_FILTER_DESC_MAX 32
typedef struct kcom_filter_s {
uint16 id;
uint8 type;
uint8 priority;
char desc[KCOM_FILTER_DESC_MAX];
uint32 flags;
uint16 dest_type;
uint16 dest_id;
uint16 dest_proto;
uint16 mirror_type;
uint16 mirror_id;
uint16 mirror_proto;
uint16 oob_data_offset;
uint16 oob_data_size;
uint16 pkt_data_offset;
uint16 pkt_data_size;
union {
uint8 b[KCOM_FILTER_BYTES_MAX];
uint32 w[KCOM_FILTER_WORDS_MAX];
} data;
union {
uint8 b[KCOM_FILTER_BYTES_MAX];
uint32 w[KCOM_FILTER_WORDS_MAX];
} mask;
} kcom_filter_t;
/*
* DMA buffer information
*
* Cookie field is reserved use by application (32/64-bit pointer).
*
* For Tx operation the application will submit the start address of
* the Tx DCB chain which is queued for transfer by the kernel module.
* Once DMA is done a DMA event is returned to the application with an
* optional sequence number.
*
* For Rx operation the application will submit the start address of
* the Rx DCB chain which should be use for packet reception by the
* kernel module. Once DMA is done a DMA event is returned to the
* application with an optional sequence number.
*
* Cookie field is reserved use by application (32/64-bit pointer).
*
* Packet info types:
*
* KCOM_DMA_INFO_T_TX_DCB
* Data is physical start address of Tx DCB chain.
*
* KCOM_DMA_INFO_T_RX_DCB
* Data is physical start address of Rx DCB chain.
*
* Packet info flags:
*
* KCOM_DMA_INFO_F_TX_DONE
* This flag is set by the kernel module and means that one or more
* packets have been sent.
*
* KCOM_DMA_INFO_F_RX_DONE
* This flag is set by the kernel module and means that one or more
* Rx buffers contain valid packet data.
*/
#define KCOM_DMA_INFO_T_TX_DCB 1
#define KCOM_DMA_INFO_T_RX_DCB 2
#define KCOM_DMA_INFO_F_TX_DONE (1U << 0)
#define KCOM_DMA_INFO_F_RX_DONE (1U << 1)
typedef struct kcom_dma_info_s {
uint8 type;
uint8 cnt;
uint16 size;
uint16 chan;
uint16 flags;
union {
void *p;
uint8 b[8];
} cookie;
union {
uint32 dcb_start;
struct {
uint32 tx;
uint32 rx;
} seqno;
} data;
} kcom_dma_info_t;
#define KCOM_ETH_HW_T_RESET 1
#define KCOM_ETH_HW_T_INIT 2
#define KCOM_ETH_HW_T_OTHER 3
#define KCOM_ETH_HW_C_ALL 0xff
#define KCOM_ETH_HW_RESET_F_TX (1U << 0)
#define KCOM_ETH_HW_RESET_F_RX (1U << 1)
#define KCOM_ETH_HW_RESET_F_TX_RECLAIM (1U << 2)
#define KCOM_ETH_HW_RESET_F_RX_RECLAIM (1U << 3)
#define KCOM_ETH_HW_INIT_F_TX (1U << 0)
#define KCOM_ETH_HW_INIT_F_RX (1U << 1)
#define KCOM_ETH_HW_INIT_F_RX_FILL (1U << 2)
#define KCOM_ETH_HW_OTHER_F_FIFO_LOOPBACK (1U << 0)
#define KCOM_ETH_HW_OTHER_F_INTERRUPT (1U << 1)
typedef struct kcom_eth_hw_config_s {
uint8 type;
uint8 chan;
uint32 flags;
uint32 value;
} kcom_eth_hw_config_t;
/*
* Message types
*/
/*
* Request KCOM interface version of kernel module.
*/
typedef struct kcom_msg_version_s {
kcom_msg_hdr_t hdr;
uint32 version;
uint32 netif_max;
uint32 filter_max;
} kcom_msg_version_t;
/*
* Send literal string to/from kernel module.
* Mainly for debugging purposes.
*/
#define KCOM_MSG_STRING_MAX 128
typedef struct kcom_msg_string_s {
kcom_msg_hdr_t hdr;
uint32 len;
char val[KCOM_MSG_STRING_MAX];
} kcom_msg_string_t;
/*
* Indicate that eth hardware is about to be reset. Active
* DMA operations should be aborted and DMA and interrupts
* should be disabled.
*/
/*
* Indicate that eth hardware has been properly initialized
* for DMA operation to commence.
*/
typedef struct kcom_msg_eth_hw_config_s {
kcom_msg_hdr_t hdr;
kcom_eth_hw_config_t config;
} kcom_msg_eth_hw_config_t;
/*
* Indicate that switch hardware is about to be reset. Active
* DMA operations should be aborted and DMA and interrupts
* should be disabled.
*/
typedef struct kcom_msg_hw_reset_s {
kcom_msg_hdr_t hdr;
uint32 channels;
} kcom_msg_hw_reset_t;
/*
* Indicate that switch hardware has been properly initialized
* for DMA operation to commence.
*/
typedef struct kcom_msg_hw_init_s {
kcom_msg_hdr_t hdr;
uint16 dcb_size;
uint16 dcb_type;
uint32 cdma_channels;
} kcom_msg_hw_init_t;
/*
* Release blocked IOCTL threads and clean up as necessary.
*/
typedef struct kcom_msg_detach_s {
kcom_msg_hdr_t hdr;
uint32 flags;
} kcom_msg_detach_t;
/*
* Create new system network interface. The network interface will
* be associated with the specified switch unit number.
* The interface id and name will be assigned by the kernel module.
*/
typedef struct kcom_msg_netif_create_s {
kcom_msg_hdr_t hdr;
kcom_netif_t netif;
} kcom_msg_netif_create_t;
/*
* Destroy system network interface.
*/
typedef struct kcom_msg_netif_destroy_s {
kcom_msg_hdr_t hdr;
} kcom_msg_netif_destroy_t;
/*
* Get list of currently defined system network interfaces.
*/
#ifndef KCOM_NETIF_MAX
#define KCOM_NETIF_MAX 128
#endif
typedef struct kcom_msg_netif_list_s {
kcom_msg_hdr_t hdr;
uint32 ifcnt;
uint16 id[KCOM_NETIF_MAX];
} kcom_msg_netif_list_t;
/*
* Get detailed network interface information.
*/
typedef struct kcom_msg_netif_get_s {
kcom_msg_hdr_t hdr;
kcom_netif_t netif;
} kcom_msg_netif_get_t;
/*
* Create new packet filter.
* The filter id will be assigned by the kernel module.
*/
typedef struct kcom_msg_filter_create_s {
kcom_msg_hdr_t hdr;
kcom_filter_t filter;
} kcom_msg_filter_create_t;
/*
* Destroy packet filter.
*/
typedef struct kcom_msg_filter_destroy_s {
kcom_msg_hdr_t hdr;
} kcom_msg_filter_destroy_t;
/*
* Get list of currently defined packet filters.
*/
#ifndef KCOM_FILTER_MAX
/* OPENNSL_FIXUP - Increased the filters to 1024 from 128 */
#define KCOM_FILTER_MAX 1024
#endif
typedef struct kcom_msg_filter_list_s {
kcom_msg_hdr_t hdr;
uint32 fcnt;
uint16 id[KCOM_FILTER_MAX];
} kcom_msg_filter_list_t;
/*
* Get detailed packet filter information.
*/
typedef struct kcom_msg_filter_get_s {
kcom_msg_hdr_t hdr;
kcom_filter_t filter;
} kcom_msg_filter_get_t;
/*
* DMA info
*/
typedef struct kcom_msg_dma_info_s {
kcom_msg_hdr_t hdr;
kcom_dma_info_t dma_info;
} kcom_msg_dma_info_t;
/*
* All messages (e.g. for generic receive)
*/
typedef union kcom_msg_s {
kcom_msg_hdr_t hdr;
kcom_msg_version_t version;
kcom_msg_string_t string;
kcom_msg_hw_reset_t hw_reset;
kcom_msg_hw_init_t hw_init;
kcom_msg_eth_hw_config_t eth_hw_config;
kcom_msg_detach_t detach;
kcom_msg_netif_create_t netif_create;
kcom_msg_netif_destroy_t netif_destroy;
kcom_msg_netif_list_t netif_list;
kcom_msg_netif_get_t netif_get;
kcom_msg_filter_create_t filter_create;
kcom_msg_filter_destroy_t filter_destroy;
kcom_msg_filter_list_t filter_list;
kcom_msg_filter_get_t filter_get;
kcom_msg_dma_info_t dma_info;
} kcom_msg_t;
/*
* KCOM communication channel vectors
*
* open
* Open KCOM channel.
*
* close
* Close KCOM channel.
*
* send
* Send KCOM message. If bufsz is non-zero, a synchronous send will be
* performed (if supported) and the function will return the number of
* bytes in the response.
*
* recv
* Receive KCOM message. This function is used t oreceive unsolicited
* messages from the kernel. If synchronous send is not supported, this
* function is also used to retrieve responses to command messages.
*/
typedef struct kcom_chan_s {
void *(*open)(char *name);
int (*close)(void *handle);
int (*send)(void *handle, void *msg, unsigned int len, unsigned int bufsz);
int (*recv)(void *handle, void *msg, unsigned int bufsz);
} kcom_chan_t;
#endif /* _KCOM_H */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: sync.h,v 1.1 2005/06/25 22:26:59 mlarsen Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#ifndef _SAL_SYNC_H
#define _SAL_SYNC_H
typedef struct sal_sem_s{
char sal_opaque_type;
} *sal_sem_t;
#define sal_sem_FOREVER (-1)
#define sal_sem_BINARY 1
#define sal_sem_COUNTING 0
sal_sem_t sal_sem_create(char *desc, int binary, int initial_count);
void sal_sem_destroy(sal_sem_t b);
int sal_sem_take(sal_sem_t b, int usec);
int sal_sem_give(sal_sem_t b);
#endif /* !_SAL_SYNC_H */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: thread.h,v 1.1 2005/06/25 22:26:59 mlarsen Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#ifndef _SAL_THREAD_H
#define _SAL_THREAD_H
#include <sal/types.h>
void sal_usleep(uint32 usec);
void sal_udelay(uint32 usec);
#endif /* !_SAL_THREAD_H */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: types.h,v 1.3 2013/04/06 06:19:14 mlarsen Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*
* File: types.h
* Purpose: SAL type definitions
*/
#ifndef _SAL_TYPES_H
#define _SAL_TYPES_H
/*
* Define platform-independent types
*/
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#ifndef DONT_CARE
#define DONT_CARE 0
#endif
#define VOL volatile
/*
* 64-bit type
*/
#ifdef LONGS_ARE_64BITS
#define COMPILER_64BIT
#define COMPILER_UINT64 unsigned long
#define u64_H(v) (((uint32 *) &(v))[u64_MSW])
#define u64_L(v) (((uint32 *) &(v))[u64_LSW])
#else /* !LONGS_ARE_64BITS */
#define COMPILER_64BIT
#define COMPILER_UINT64 unsigned long long
#define u64_H(v) (((uint32 *) &(v))[u64_MSW])
#define u64_L(v) (((uint32 *) &(v))[u64_LSW])
#endif /* LONGS_ARE_64BITS */
/*
* Define unsigned and signed integers with guaranteed sizes.
* Adjust if your compiler uses different sizes for short or int.
*/
typedef unsigned char uint8; /* 8-bit quantity */
typedef unsigned short uint16; /* 16-bit quantity */
typedef unsigned int uint32; /* 32-bit quantity */
typedef COMPILER_UINT64 uint64; /* 64-bit quantity */
typedef signed char int8; /* 8-bit quantity */
typedef signed short int16; /* 16-bit quantity */
typedef signed int int32; /* 32-bit quantity */
#define BITS2BYTES(x) (((x) + 7) / 8)
#define BITS2WORDS(x) (((x) + 31) / 32)
#define BYTES2BITS(x) ((x) * 8)
#define BYTES2WORDS(x) (((x) + 3) / 4)
#define WORDS2BITS(x) ((x) * 32)
#define WORDS2BYTES(x) ((x) * 4)
#define COUNTOF(ary) ((int) (sizeof (ary) / sizeof ((ary)[0])))
typedef uint32 sal_paddr_t; /* Physical address (PCI address) */
#ifdef PTRS_ARE_64BITS
typedef uint64 sal_vaddr_t; /* Virtual address (Host address) */
#define PTR_TO_INT(x) ((uint32)(((sal_vaddr_t)(x))&0xFFFFFFFF))
#else
typedef uint32 sal_vaddr_t; /* Virtual address (Host address) */
#define PTR_TO_INT(x) ((uint32)(x))
#endif
#define INT_TO_PTR(x) ((void *)((sal_vaddr_t)(x)))
#define PTR_TO_UINTPTR(x) ((sal_vaddr_t)(x))
#define UINTPTR_TO_PTR(x) ((void *)(x))
typedef union
{
uint8 u8;
uint16 u16;
uint32 u32;
uint64 u64;
sal_paddr_t paddr;
sal_vaddr_t vaddr;
void *ptr;
} any_t;
/* Device bus types */
#define SAL_PCI_DEV_TYPE 0x00001 /* PCI device */
#define SAL_SPI_DEV_TYPE 0x00002 /* SPI device */
#define SAL_EB_DEV_TYPE 0x00004 /* EB device */
#define SAL_ICS_DEV_TYPE 0x00008 /* ICS device */
#define SAL_MII_DEV_TYPE 0x00010 /* MII device */
#define SAL_RCPU_DEV_TYPE 0x00020 /* RCPU device */
#define SAL_I2C_DEV_TYPE 0x00040 /* I2C device */
#define SAL_AXI_DEV_TYPE 0x00080 /* AXI device */
#define SAL_EMMI_DEV_TYPE 0x10000 /* EMMI device */
#define SAL_DEV_BUS_TYPE_MASK 0xf00ff /* Odd for historical reasons */
/* Device types */
#define SAL_SWITCH_DEV_TYPE 0x00100 /* Switch device */
#define SAL_ETHER_DEV_TYPE 0x00200 /* Ethernet device */
#define SAL_CPU_DEV_TYPE 0x00400 /* CPU device */
#define SAL_DEV_TYPE_MASK 0x00f00
/* Access types */
#define SAL_DEV_BUS_RD_16BIT 0x01000 /* 16 bit reads on bus */
#define SAL_DEV_BUS_WR_16BIT 0x02000 /* 16 bit writes on bus */
#define SAL_DEV_BUS_ALT 0x04000 /* Alternate access */
#define SAL_DEV_BUS_MSI 0x08000 /* Message-signaled interrupts */
#define SAL_DEV_FLAG_MASK 0x0f000
/* BDE reserved mask (cannot be used by SAL) */
#define SAL_DEV_BDE_MASK 0xff000000
/* Backward compatibility */
#define SAL_ET_DEV_TYPE SAL_MII_DEV_TYPE
/* Special access addresses */
#define SAL_DEV_OP_EMMI_INIT 0x0fff1000
#endif /* !_SAL_TYPES_H */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: sdk_config.h,v 1.5 2012/03/02 15:13:56 yaronm Exp $
* $Copyright: (c) 2006 Broadcom Corp.
* All Rights Reserved.$
*
*
*/
#ifndef __SDK_CONFIG_H__
#define __SDK_CONFIG_H__
/*
* Include custom overrides
*/
#ifdef SDK_INCLUDE_CUSTOM_CONFIG
#include <sdk_custom_config.h>
#endif
/*
* Memory Barrier operation if required.
* Defaults to nothing.
*/
#ifndef SDK_CONFIG_MEMORY_BARRIER
#define SDK_CONFIG_MEMORY_BARRIER
#endif
#endif /* __SDK_CONFIG_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: cmic.h,v 1.1 2008/10/16 09:41:21 mlarsen Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*
* File: cmic.h
* Purpose: Maps out structures used for CMIC operations and
* exports routines and constants.
*/
#ifndef _SOC_CMIC_H
#define _SOC_CMIC_H
/* IRQ Register (RO) */
#define CMIC_IRQ_STAT 0x00000144
/* IRQ Mask Registers (R/W) */
#define CMIC_IRQ_MASK 0x00000148
#define CMIC_IRQ_MASK_1 0x0000006C
#define CMIC_IRQ_MASK_2 0x00000070
#endif /* !_SOC_CMIC_H */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* Copyright: (c) 2016 Broadcom Corp.
* All Rights Reserved.
*/
#ifndef _SOC_DEVIDS_H
#define _SOC_DEVIDS_H
#define BROADCOM_VENDOR_ID 0x14e4
#define BCM5690_DEVICE_ID 0x5690
#define BCM5690_A0_REV_ID 1
#define BCM5690_A1_REV_ID 2
#define BCM5690_A2_REV_ID 3
#define BCM5691_DEVICE_ID 0x5691
#define BCM5691_A0_REV_ID 1
#define BCM5691_A1_REV_ID 2
#define BCM5691_A2_REV_ID 3
#define BCM5692_DEVICE_ID 0x5692
#define BCM5692_A0_REV_ID 1
#define BCM5692_A1_REV_ID 2
#define BCM5692_A2_REV_ID 3
#define BCM5693_DEVICE_ID 0x5693
#define BCM5693_A0_REV_ID 1
#define BCM5693_A1_REV_ID 2
#define BCM5693_A2_REV_ID 3
#define BCM5695_DEVICE_ID 0x5695
#define BCM5695_A0_REV_ID 1
#define BCM5695_A1_REV_ID 2
#define BCM5695_B0_REV_ID 0x11
#define BCM5696_DEVICE_ID 0x5696
#define BCM5696_A0_REV_ID 1
#define BCM5696_A1_REV_ID 2
#define BCM5696_B0_REV_ID 0x11
#define BCM5697_DEVICE_ID 0x5697
#define BCM5697_A0_REV_ID 1
#define BCM5697_A1_REV_ID 2
#define BCM5697_B0_REV_ID 0x11
#define BCM5698_DEVICE_ID 0x5698
#define BCM5698_A0_REV_ID 1
#define BCM5698_A1_REV_ID 2
#define BCM5698_B0_REV_ID 0x11
#define BCM5670_DEVICE_ID 0x5670
#define BCM5670_A0_REV_ID 1
#define BCM5670_A1_REV_ID 2
#define BCM5671_DEVICE_ID 0x5671
#define BCM5671_A0_REV_ID 1
#define BCM5671_A1_REV_ID 2
#define BCM5671_A2_REV_ID 3
#define BCM5675_DEVICE_ID 0x5675
#define BCM5675_A0_REV_ID 1
#define BCM5675_A1_REV_ID 2
#define BCM5676_DEVICE_ID 0x5676
#define BCM5676_A0_REV_ID 1
#define BCM5676_A1_REV_ID 2
#define BCM5673_DEVICE_ID 0x5673
#define BCM5673_A0_REV_ID 1
#define BCM5673_A1_REV_ID 2
#define BCM5673_A2_REV_ID 3
#define BCM5674_DEVICE_ID 0x5674
#define BCM5674_A0_REV_ID 1
#define BCM56100_DEVICE_ID 0xb100
#define BCM56100_A0_REV_ID 1
#define BCM56100_A1_REV_ID 2
#define BCM56101_DEVICE_ID 0xb101
#define BCM56101_A0_REV_ID 1
#define BCM56101_A1_REV_ID 2
#define BCM56102_DEVICE_ID 0xb102
#define BCM56102_A0_REV_ID 1
#define BCM56102_A1_REV_ID 2
#define BCM56105_DEVICE_ID 0xb105
#define BCM56105_A0_REV_ID 1
#define BCM56105_A1_REV_ID 2
#define BCM56106_DEVICE_ID 0xb106
#define BCM56106_A0_REV_ID 1
#define BCM56106_A1_REV_ID 2
#define BCM56107_DEVICE_ID 0xb107
#define BCM56107_A0_REV_ID 1
#define BCM56107_A1_REV_ID 2
#define BCM56110_DEVICE_ID 0xb110
#define BCM56110_A0_REV_ID 1
#define BCM56111_DEVICE_ID 0xb111
#define BCM56111_A0_REV_ID 1
#define BCM56112_DEVICE_ID 0xb112
#define BCM56112_A0_REV_ID 1
#define BCM56115_DEVICE_ID 0xb115
#define BCM56115_A0_REV_ID 1
#define BCM56116_DEVICE_ID 0xb116
#define BCM56116_A0_REV_ID 1
#define BCM56117_DEVICE_ID 0xb117
#define BCM56117_A0_REV_ID 1
#define BCM56300_DEVICE_ID 0xb300
#define BCM56300_A0_REV_ID 1
#define BCM56300_A1_REV_ID 2
#define BCM56300_B0_REV_ID 0x11
#define BCM56300_B1_REV_ID 0x12
#define BCM56301_DEVICE_ID 0xb301
#define BCM56301_A0_REV_ID 1
#define BCM56301_A1_REV_ID 2
#define BCM56301_B0_REV_ID 0x11
#define BCM56301_B1_REV_ID 0x12
#define BCM56302_DEVICE_ID 0xb302
#define BCM56302_A0_REV_ID 1
#define BCM56302_A1_REV_ID 2
#define BCM56302_B0_REV_ID 0x11
#define BCM56302_B1_REV_ID 0x12
#define BCM56303_DEVICE_ID 0xb303
#define BCM56303_A1_REV_ID 2
#define BCM56303_A0_REV_ID 1
#define BCM56303_B0_REV_ID 0x11
#define BCM56303_B1_REV_ID 0x12
#define BCM56304_DEVICE_ID 0xb304
#define BCM56304_A0_REV_ID 1
#define BCM56304_A1_REV_ID 2
#define BCM56304_B0_REV_ID 0x11
#define BCM56304_B1_REV_ID 0x12
#define BCM56404_DEVICE_ID 0xb404
#define BCM56404_A0_REV_ID 1
#define BCM56404_A1_REV_ID 2
#define BCM56305_DEVICE_ID 0xb305
#define BCM56305_A0_REV_ID 1
#define BCM56305_A1_REV_ID 2
#define BCM56305_B0_REV_ID 0x11
#define BCM56305_B1_REV_ID 0x12
#define BCM56306_DEVICE_ID 0xb306
#define BCM56306_A0_REV_ID 1
#define BCM56306_A1_REV_ID 2
#define BCM56306_B0_REV_ID 0x11
#define BCM56306_B1_REV_ID 0x12
#define BCM56307_DEVICE_ID 0xb307
#define BCM56307_A0_REV_ID 1
#define BCM56307_A1_REV_ID 2
#define BCM56307_B0_REV_ID 0x11
#define BCM56307_B1_REV_ID 0x12
#define BCM56308_DEVICE_ID 0xb308
#define BCM56308_A0_REV_ID 1
#define BCM56308_A1_REV_ID 2
#define BCM56308_B0_REV_ID 0x11
#define BCM56308_B1_REV_ID 0x12
#define BCM56309_DEVICE_ID 0xb309
#define BCM56309_A0_REV_ID 1
#define BCM56309_A1_REV_ID 2
#define BCM56309_B0_REV_ID 0x11
#define BCM56309_B1_REV_ID 0x12
#define BCM56310_DEVICE_ID 0xb310
#define BCM56310_A0_REV_ID 1
#define BCM56311_DEVICE_ID 0xb311
#define BCM56311_A0_REV_ID 1
#define BCM56312_DEVICE_ID 0xb312
#define BCM56312_A0_REV_ID 1
#define BCM56313_DEVICE_ID 0xb313
#define BCM56313_A0_REV_ID 1
#define BCM56314_DEVICE_ID 0xb314
#define BCM56314_A0_REV_ID 1
#define BCM56315_DEVICE_ID 0xb315
#define BCM56315_A0_REV_ID 1
#define BCM56316_DEVICE_ID 0xb316
#define BCM56316_A0_REV_ID 1
#define BCM56317_DEVICE_ID 0xb317
#define BCM56317_A0_REV_ID 1
#define BCM56318_DEVICE_ID 0xb318
#define BCM56318_A0_REV_ID 1
#define BCM56319_DEVICE_ID 0xb319
#define BCM56319_A0_REV_ID 1
#ifndef EXCLUDE_BCM56324
#define BCM56322_DEVICE_ID 0xb322
#define BCM56322_A0_REV_ID 1
#define BCM56324_DEVICE_ID 0xb324
#define BCM56324_A0_REV_ID 1
#endif
#define BCM53300_DEVICE_ID 0xb006
#define BCM53300_A0_REV_ID 0x11
#define BCM53300_A1_REV_ID 0x12
#define BCM53301_DEVICE_ID 0xb206
#define BCM53301_A0_REV_ID 0x11
#define BCM53301_A1_REV_ID 0x12
#define BCM53302_DEVICE_ID 0xb008
#define BCM53302_A0_REV_ID 0x11
#define BCM53302_A1_REV_ID 0x12
#define BCM56500_DEVICE_ID 0xb500
#define BCM56500_A0_REV_ID 1
#define BCM56500_A1_REV_ID 2
#define BCM56500_B0_REV_ID 0x11
#define BCM56500_B1_REV_ID 0x12
#define BCM56500_B2_REV_ID 0x13
#define BCM56501_DEVICE_ID 0xb501
#define BCM56501_A0_REV_ID 1
#define BCM56501_A1_REV_ID 2
#define BCM56501_B0_REV_ID 0x11
#define BCM56501_B1_REV_ID 0x12
#define BCM56501_B2_REV_ID 0x13
#define BCM56502_DEVICE_ID 0xb502
#define BCM56502_A0_REV_ID 1
#define BCM56502_A1_REV_ID 2
#define BCM56502_B0_REV_ID 0x11
#define BCM56502_B1_REV_ID 0x12
#define BCM56502_B2_REV_ID 0x13
#define BCM56503_DEVICE_ID 0xb503
#define BCM56503_A0_REV_ID 1
#define BCM56503_A1_REV_ID 2
#define BCM56503_B0_REV_ID 0x11
#define BCM56503_B1_REV_ID 0x12
#define BCM56503_B2_REV_ID 0x13
#define BCM56504_DEVICE_ID 0xb504
#define BCM56504_A0_REV_ID 1
#define BCM56504_A1_REV_ID 2
#define BCM56504_B0_REV_ID 0x11
#define BCM56504_B1_REV_ID 0x12
#define BCM56504_B2_REV_ID 0x13
#define BCM56505_DEVICE_ID 0xb505
#define BCM56505_A0_REV_ID 1
#define BCM56505_A1_REV_ID 2
#define BCM56505_B0_REV_ID 0x11
#define BCM56505_B1_REV_ID 0x12
#define BCM56505_B2_REV_ID 0x13
#define BCM56506_DEVICE_ID 0xb506
#define BCM56506_A0_REV_ID 1
#define BCM56506_A1_REV_ID 2
#define BCM56506_B0_REV_ID 0x11
#define BCM56506_B1_REV_ID 0x12
#define BCM56506_B2_REV_ID 0x13
#define BCM56507_DEVICE_ID 0xb507
#define BCM56507_A0_REV_ID 1
#define BCM56507_A1_REV_ID 2
#define BCM56507_B0_REV_ID 0x11
#define BCM56507_B1_REV_ID 0x12
#define BCM56507_B2_REV_ID 0x13
#define BCM56508_DEVICE_ID 0xb508
#define BCM56508_A0_REV_ID 1
#define BCM56508_A1_REV_ID 2
#define BCM56508_B0_REV_ID 0x11
#define BCM56508_B1_REV_ID 0x12
#define BCM56508_B2_REV_ID 0x13
#define BCM56509_DEVICE_ID 0xb509
#define BCM56509_A0_REV_ID 1
#define BCM56509_A1_REV_ID 2
#define BCM56509_B0_REV_ID 0x11
#define BCM56509_B1_REV_ID 0x12
#define BCM56509_B2_REV_ID 0x13
#define BCM56600_DEVICE_ID 0xb600
#define BCM56600_A0_REV_ID 1
#define BCM56600_B0_REV_ID 0x11
#define BCM56600_C0_REV_ID 0x21
#define BCM56601_DEVICE_ID 0xb601
#define BCM56601_A0_REV_ID 1
#define BCM56601_B0_REV_ID 0x11
#define BCM56601_C0_REV_ID 0x21
#define BCM56602_DEVICE_ID 0xb602
#define BCM56602_A0_REV_ID 1
#define BCM56602_B0_REV_ID 0x11
#define BCM56602_C0_REV_ID 0x21
#define BCM56603_DEVICE_ID 0xb603
#define BCM56603_A0_REV_ID 1
#define BCM56603_B0_REV_ID 0x11
#define BCM56603_C0_REV_ID 0x21
#define BCM56605_DEVICE_ID 0xb605
#define BCM56605_A0_REV_ID 1
#define BCM56605_B0_REV_ID 0x11
#define BCM56605_C0_REV_ID 0x21
#define BCM56606_DEVICE_ID 0xb606
#define BCM56606_A0_REV_ID 1
#define BCM56606_B0_REV_ID 0x11
#define BCM56606_C0_REV_ID 0x21
#define BCM56607_DEVICE_ID 0xb607
#define BCM56607_A0_REV_ID 1
#define BCM56607_B0_REV_ID 0x11
#define BCM56607_C0_REV_ID 0x21
#define BCM56608_DEVICE_ID 0xb608
#define BCM56608_A0_REV_ID 1
#define BCM56608_B0_REV_ID 0x11
#define BCM56608_C0_REV_ID 0x21
#define BCM56580_DEVICE_ID 0xb580
#define BCM56580_A0_REV_ID 1
#define BCM56700_DEVICE_ID 0xb700
#define BCM56700_A0_REV_ID 1
#define BCM56701_DEVICE_ID 0xb701
#define BCM56701_A0_REV_ID 1
#define BCM56800_DEVICE_ID 0xb800
#define BCM56800_A0_REV_ID 1
#define BCM56801_DEVICE_ID 0xb801
#define BCM56801_A0_REV_ID 1
#define BCM56802_DEVICE_ID 0xb802
#define BCM56802_A0_REV_ID 1
#define BCM56803_DEVICE_ID 0xb803
#define BCM56803_A0_REV_ID 1
#define BCM56224_DEVICE_ID 0xb224
#define BCM56224_A0_REV_ID 1
#define BCM56224_B0_REV_ID 0x11
#define BCM56225_DEVICE_ID 0xb225
#define BCM56225_A0_REV_ID 1
#define BCM56225_B0_REV_ID 0x11
#define BCM56226_DEVICE_ID 0xb226
#define BCM56226_A0_REV_ID 1
#define BCM56226_B0_REV_ID 0x11
#define BCM56227_DEVICE_ID 0xb227
#define BCM56227_A0_REV_ID 1
#define BCM56227_B0_REV_ID 0x11
#define BCM56228_DEVICE_ID 0xb228
#define BCM56228_A0_REV_ID 1
#define BCM56228_B0_REV_ID 0x11
#define BCM56229_DEVICE_ID 0xb229
#define BCM56229_A0_REV_ID 1
#define BCM56229_B0_REV_ID 0x11
#define BCM56024_DEVICE_ID 0xb024
#define BCM56024_A0_REV_ID 1
#define BCM56024_B0_REV_ID 0x11
#define BCM56025_DEVICE_ID 0xb025
#define BCM56025_A0_REV_ID 1
#define BCM56025_B0_REV_ID 0x11
#define BCM53724_DEVICE_ID 0xc724
#define BCM53724_A0_REV_ID 1
#define BCM53724_B0_REV_ID 0x11
#define BCM53726_DEVICE_ID 0xc726
#define BCM53726_A0_REV_ID 1
#define BCM53726_B0_REV_ID 0x11
#define BCM53312_DEVICE_ID 0xc312
#define BCM53312_A0_REV_ID 1
#define BCM53312_B0_REV_ID 0x11
#define BCM53313_DEVICE_ID 0xc313
#define BCM53313_A0_REV_ID 1
#define BCM53313_B0_REV_ID 0x11
#define BCM53314_DEVICE_ID 0xc314
#define BCM53314_A0_REV_ID 1
#define BCM53314_B0_REV_ID 0x11
#define BCM53322_DEVICE_ID 0xc322
#define BCM53322_A0_REV_ID 1
#define BCM53323_DEVICE_ID 0xc323
#define BCM53323_A0_REV_ID 1
#define BCM53324_DEVICE_ID 0xc324
#define BCM53324_A0_REV_ID 1
#define BCM56218_DEVICE_ID 0xB218
#define BCM56218_A0_REV_ID 1
#define BCM56218_A1_REV_ID 2
#define BCM56218_A2_REV_ID 3
#define BCM56218X_DEVICE_ID 0xc710
#define BCM56218X_A0_REV_ID 1
#define BCM56218X_A1_REV_ID 2
#define BCM56218X_A2_REV_ID 3
#define BCM56219_DEVICE_ID 0xB219
#define BCM56219_A0_REV_ID 1
#define BCM56219_A1_REV_ID 2
#define BCM56219_A2_REV_ID 3
#define BCM56218R_DEVICE_ID 0xB21A
#define BCM56218R_A0_REV_ID 1
#define BCM56218R_A1_REV_ID 2
#define BCM56218R_A2_REV_ID 3
#define BCM56219R_DEVICE_ID 0xB21B
#define BCM56219R_A0_REV_ID 1
#define BCM56219R_A1_REV_ID 2
#define BCM56219R_A2_REV_ID 3
#define BCM56214_DEVICE_ID 0xB214
#define BCM56214_A0_REV_ID 1
#define BCM56214_A1_REV_ID 2
#define BCM56214_A2_REV_ID 3
#define BCM56215_DEVICE_ID 0xB215
#define BCM56215_A0_REV_ID 1
#define BCM56215_A1_REV_ID 2
#define BCM56215_A2_REV_ID 3
#define BCM56214R_DEVICE_ID 0xB21C
#define BCM56214R_A0_REV_ID 1
#define BCM56214R_A1_REV_ID 2
#define BCM56214R_A2_REV_ID 3
#define BCM56215R_DEVICE_ID 0xB21D
#define BCM56215R_A0_REV_ID 1
#define BCM56215R_A1_REV_ID 2
#define BCM56215R_A2_REV_ID 3
#define BCM56216_DEVICE_ID 0xB216
#define BCM56216_A0_REV_ID 1
#define BCM56216_A1_REV_ID 2
#define BCM56216_A2_REV_ID 3
#define BCM56217_DEVICE_ID 0xB217
#define BCM56217_A0_REV_ID 1
#define BCM56217_A1_REV_ID 2
#define BCM56217_A2_REV_ID 3
#define BCM56212_DEVICE_ID 0xB212
#define BCM56212_A0_REV_ID 1
#define BCM56212_A1_REV_ID 2
#define BCM56212_A2_REV_ID 3
#define BCM56213_DEVICE_ID 0xB213
#define BCM56213_A0_REV_ID 1
#define BCM56213_A1_REV_ID 2
#define BCM56213_A2_REV_ID 3
#define BCM53718_DEVICE_ID 0xC71A
#define BCM53718_A0_REV_ID 1
#define BCM53718_A1_REV_ID 2
#define BCM53718_A2_REV_ID 3
#define BCM53714_DEVICE_ID 0xC71B
#define BCM53714_A0_REV_ID 1
#define BCM53714_A1_REV_ID 2
#define BCM53714_A2_REV_ID 3
#define BCM53716_DEVICE_ID 0xC716
#define BCM53716_A0_REV_ID 1
#define BCM53716_A1_REV_ID 2
#define BCM53716_A2_REV_ID 3
#define BCM56018_DEVICE_ID 0xB018
#define BCM56018_A0_REV_ID 1
#define BCM56018_A1_REV_ID 2
#define BCM56018_A2_REV_ID 3
#define BCM56014_DEVICE_ID 0xB014
#define BCM56014_A0_REV_ID 1
#define BCM56014_A1_REV_ID 2
#define BCM56014_A2_REV_ID 3
#define BCM56510_DEVICE_ID 0xb510
#define BCM56510_A0_REV_ID 1
#define BCM56511_DEVICE_ID 0xb511
#define BCM56511_A0_REV_ID 1
#define BCM56512_DEVICE_ID 0xb512
#define BCM56512_A0_REV_ID 1
#define BCM56513_DEVICE_ID 0xb513
#define BCM56513_A0_REV_ID 1
#define BCM56514_DEVICE_ID 0xb514
#define BCM56514_A0_REV_ID 1
#define BCM56516_DEVICE_ID 0xb516
#define BCM56516_A0_REV_ID 1
#define BCM56517_DEVICE_ID 0xb517
#define BCM56517_A0_REV_ID 1
#define BCM56518_DEVICE_ID 0xb518
#define BCM56518_A0_REV_ID 1
#define BCM56519_DEVICE_ID 0xb519
#define BCM56519_A0_REV_ID 1
#define BCM56620_DEVICE_ID 0xb620
#define BCM56620_A0_REV_ID 1
#define BCM56620_A1_REV_ID 2
#define BCM56620_B0_REV_ID 0x11
#define BCM56620_B1_REV_ID 0x12
#define BCM56620_B2_REV_ID 0x13
#define BCM56624_DEVICE_ID 0xb624
#define BCM56624_A0_REV_ID 1
#define BCM56624_A1_REV_ID 2
#define BCM56624_B0_REV_ID 0x11
#define BCM56624_B1_REV_ID 0x12
#define BCM56624_B2_REV_ID 0x13
#define BCM56626_DEVICE_ID 0xb626
#define BCM56626_A0_REV_ID 1
#define BCM56626_A1_REV_ID 2
#define BCM56626_B0_REV_ID 0x11
#define BCM56626_B1_REV_ID 0x12
#define BCM56626_B2_REV_ID 0x13
#define BCM56628_DEVICE_ID 0xb628
#define BCM56628_A0_REV_ID 1
#define BCM56628_A1_REV_ID 2
#define BCM56628_B0_REV_ID 0x11
#define BCM56628_B1_REV_ID 0x12
#define BCM56628_B2_REV_ID 0x13
#define BCM56629_DEVICE_ID 0xb629
#define BCM56629_A0_REV_ID 1
#define BCM56629_A1_REV_ID 2
#define BCM56629_B0_REV_ID 0x11
#define BCM56629_B1_REV_ID 0x12
#define BCM56629_B2_REV_ID 0x13
#define BCM56680_DEVICE_ID 0xb680
#define BCM56680_A0_REV_ID 1
#define BCM56680_A1_REV_ID 2
#define BCM56680_B0_REV_ID 0x11
#define BCM56680_B1_REV_ID 0x12
#define BCM56680_B2_REV_ID 0x13
#define BCM56684_DEVICE_ID 0xb684
#define BCM56684_A0_REV_ID 1
#define BCM56684_A1_REV_ID 2
#define BCM56684_B0_REV_ID 0x11
#define BCM56684_B1_REV_ID 0x12
#define BCM56684_B2_REV_ID 0x13
#define BCM56686_DEVICE_ID 0xb686
#define BCM56686_B0_REV_ID 0x11
#define BCM56686_B1_REV_ID 0x12
#define BCM56686_B2_REV_ID 0x13
#define BCM56820_DEVICE_ID 0xb820
#define BCM56820_A0_REV_ID 1
#define BCM56820_B0_REV_ID 0x11
#define BCM56821_DEVICE_ID 0xb821
#define BCM56821_A0_REV_ID 1
#define BCM56821_B0_REV_ID 0x11
#define BCM56822_DEVICE_ID 0xb822
#define BCM56822_A0_REV_ID 1
#define BCM56822_B0_REV_ID 0x11
#define BCM56823_DEVICE_ID 0xb823
#define BCM56823_A0_REV_ID 1
#define BCM56823_B0_REV_ID 0x11
#define BCM56825_DEVICE_ID 0xb825
#define BCM56825_B0_REV_ID 0x11
#define BCM56720_DEVICE_ID 0xb720
#define BCM56720_A0_REV_ID 1
#define BCM56720_B0_REV_ID 0x11
#define BCM56721_DEVICE_ID 0xb721
#define BCM56721_A0_REV_ID 1
#define BCM56721_B0_REV_ID 0x11
#define BCM56725_DEVICE_ID 0xb725
#define BCM56725_A0_REV_ID 1
#define BCM56725_B0_REV_ID 0x11
#define BCM56630_DEVICE_ID 0xb630
#define BCM56630_A0_REV_ID 1
#define BCM56630_B0_REV_ID 0x11
#define BCM56634_DEVICE_ID 0xb634
#define BCM56634_A0_REV_ID 1
#define BCM56634_B0_REV_ID 0x11
#define BCM56636_DEVICE_ID 0xb636
#define BCM56636_A0_REV_ID 1
#define BCM56636_B0_REV_ID 0x11
#define BCM56638_DEVICE_ID 0xb638
#define BCM56638_A0_REV_ID 1
#define BCM56638_B0_REV_ID 0x11
#define BCM56639_DEVICE_ID 0xb639
#define BCM56639_A0_REV_ID 1
#define BCM56639_B0_REV_ID 0x11
#define BCM56685_DEVICE_ID 0xb685
#define BCM56685_A0_REV_ID 1
#define BCM56685_B0_REV_ID 0x11
#define BCM56689_DEVICE_ID 0xb689
#define BCM56689_A0_REV_ID 1
#define BCM56689_B0_REV_ID 0x11
#define BCM56520_DEVICE_ID 0xb520
#define BCM56520_A0_REV_ID 1
#define BCM56520_B0_REV_ID 0x11
#define BCM56521_DEVICE_ID 0xb521
#define BCM56521_A0_REV_ID 1
#define BCM56521_B0_REV_ID 0x11
#define BCM56522_DEVICE_ID 0xb522
#define BCM56522_A0_REV_ID 1
#define BCM56522_B0_REV_ID 0x11
#define BCM56524_DEVICE_ID 0xb524
#define BCM56524_A0_REV_ID 1
#define BCM56524_B0_REV_ID 0x11
#define BCM56526_DEVICE_ID 0xb526
#define BCM56526_A0_REV_ID 1
#define BCM56526_B0_REV_ID 0x11
#define BCM56534_DEVICE_ID 0xb534
#define BCM56534_B0_REV_ID 0x11
#define BCM56538_DEVICE_ID 0xb538
#define BCM56538_B0_REV_ID 0x11
#define BCM56331_DEVICE_ID 0xb331
#define BCM56331_A0_REV_ID 1
#define BCM56331_B0_REV_ID 0x11
#define BCM56331_B1_REV_ID 0x12
#define BCM56333_DEVICE_ID 0xb333
#define BCM56333_A0_REV_ID 1
#define BCM56333_B0_REV_ID 0x11
#define BCM56333_B1_REV_ID 0x12
#define BCM56334_DEVICE_ID 0xb334
#define BCM56334_A0_REV_ID 1
#define BCM56334_B0_REV_ID 0x11
#define BCM56334_B1_REV_ID 0x12
#define BCM56338_DEVICE_ID 0xb338
#define BCM56338_A0_REV_ID 1
#define BCM56338_B0_REV_ID 0x11
#define BCM56338_B1_REV_ID 0x12
#define BCM56320_DEVICE_ID 0xb320
#define BCM56320_A0_REV_ID 1
#define BCM56320_B0_REV_ID 0x11
#define BCM56320_B1_REV_ID 0x12
#define BCM56321_DEVICE_ID 0xb321
#define BCM56321_A0_REV_ID 1
#define BCM56321_B0_REV_ID 0x11
#define BCM56321_B1_REV_ID 0x12
#define BCM56548H_DEVICE_ID 0xB54A
#define BCM56548H_A0_REV_ID 1
#define BCM56548_DEVICE_ID 0xb548
#define BCM56548_A0_REV_ID 1
#define BCM56547_DEVICE_ID 0xb547
#define BCM56547_A0_REV_ID 1
#define BCM56346_DEVICE_ID 0xb346
#define BCM56346_A0_REV_ID 1
#define BCM56345_DEVICE_ID 0xb345
#define BCM56345_A0_REV_ID 1
#define BCM56344_DEVICE_ID 0xb344
#define BCM56344_A0_REV_ID 1
#define BCM56342_DEVICE_ID 0xb342
#define BCM56342_A0_REV_ID 1
#define BCM56340_DEVICE_ID 0xb340
#define BCM56340_A0_REV_ID 1
#define BCM56049_DEVICE_ID 0xb049
#define BCM56049_A0_REV_ID 1
#define BCM56048_DEVICE_ID 0xb048
#define BCM56048_A0_REV_ID 1
#define BCM56047_DEVICE_ID 0xb047
#define BCM56047_A0_REV_ID 1
#define BCM56042_DEVICE_ID 0xb042
#define BCM56042_A0_REV_ID 1
#define BCM56041_DEVICE_ID 0xb041
#define BCM56041_A0_REV_ID 1
#define BCM56040_DEVICE_ID 0xb040
#define BCM56040_A0_REV_ID 1
#define BCM56132_DEVICE_ID 0xb132
#define BCM56132_A0_REV_ID 1
#define BCM56132_B0_REV_ID 0x11
#define BCM56132_B1_REV_ID 0x12
#define BCM56134_DEVICE_ID 0xb134
#define BCM56134_A0_REV_ID 1
#define BCM56134_B0_REV_ID 0x11
#define BCM56134_B1_REV_ID 0x12
#define BCM56230_DEVICE_ID 0xb230
#define BCM56230_B1_REV_ID 0x12
#define BCM56231_DEVICE_ID 0xb231
#define BCM56231_B1_REV_ID 0x12
#define BCM56140_DEVICE_ID 0xb140
#define BCM56140_A0_REV_ID 1
#define BCM56142_DEVICE_ID 0xb142
#define BCM56142_A0_REV_ID 1
#define BCM56143_DEVICE_ID 0xb143
#define BCM56143_A0_REV_ID 1
#define BCM56144_DEVICE_ID 0xb144
#define BCM56144_A0_REV_ID 1
#define BCM56146_DEVICE_ID 0xb146
#define BCM56146_A0_REV_ID 1
#define BCM56147_DEVICE_ID 0xb147
#define BCM56147_A0_REV_ID 1
#define BCM56149_DEVICE_ID 0xb149
#define BCM56149_A0_REV_ID 1
#define BCM56840_DEVICE_ID 0xb840
#define BCM56840_A0_REV_ID 1
#define BCM56840_A1_REV_ID 2
#define BCM56840_A2_REV_ID 3
#define BCM56840_A3_REV_ID 4
#define BCM56840_A4_REV_ID 5
#define BCM56840_B0_REV_ID 0x11
#define BCM56840_B1_REV_ID 0x12
#define BCM56841_DEVICE_ID 0xb841
#define BCM56841_A0_REV_ID 1
#define BCM56841_A1_REV_ID 2
#define BCM56841_A2_REV_ID 3
#define BCM56841_A3_REV_ID 4
#define BCM56841_A4_REV_ID 5
#define BCM56841_B0_REV_ID 0x11
#define BCM56841_B1_REV_ID 0x12
#define BCM56843_DEVICE_ID 0xb843
#define BCM56843_A0_REV_ID 1
#define BCM56843_A1_REV_ID 2
#define BCM56843_A2_REV_ID 3
#define BCM56843_A3_REV_ID 4
#define BCM56843_A4_REV_ID 5
#define BCM56843_B0_REV_ID 0x11
#define BCM56843_B1_REV_ID 0x12
#define BCM56845_DEVICE_ID 0xb845
#define BCM56845_A0_REV_ID 1
#define BCM56845_A1_REV_ID 2
#define BCM56845_A2_REV_ID 3
#define BCM56845_A3_REV_ID 4
#define BCM56845_A4_REV_ID 5
#define BCM56845_B0_REV_ID 0x11
#define BCM56845_B1_REV_ID 0x12
#define BCM56743_DEVICE_ID 0xb743
#define BCM56743_A0_REV_ID 1
#define BCM56743_A1_REV_ID 2
#define BCM56743_A2_REV_ID 3
#define BCM56743_A3_REV_ID 4
#define BCM56743_A4_REV_ID 5
#define BCM56743_B0_REV_ID 0x11
#define BCM56743_B1_REV_ID 0x12
#define BCM56745_DEVICE_ID 0xb745
#define BCM56745_A0_REV_ID 1
#define BCM56745_A1_REV_ID 2
#define BCM56745_A2_REV_ID 3
#define BCM56745_A3_REV_ID 4
#define BCM56745_A4_REV_ID 5
#define BCM56745_B0_REV_ID 0x11
#define BCM56745_B1_REV_ID 0x12
#define BCM56260_DEVICE_ID 0xb260
#define BCM56260_A0_REV_ID 1
#define BCM56260_B0_REV_ID 0x11
#define BCM56261_DEVICE_ID 0xb261
#define BCM56261_A0_REV_ID 1
#define BCM56261_B0_REV_ID 0x11
#define BCM56262_DEVICE_ID 0xb262
#define BCM56262_A0_REV_ID 1
#define BCM56262_B0_REV_ID 0x11
#define BCM56263_DEVICE_ID 0xb263
#define BCM56263_A0_REV_ID 1
#define BCM56263_B0_REV_ID 0x11
#define BCM56265_DEVICE_ID 0xb265
#define BCM56265_A0_REV_ID 1
#define BCM56265_B0_REV_ID 0x11
#define BCM56266_DEVICE_ID 0xb266
#define BCM56266_A0_REV_ID 1
#define BCM56266_B0_REV_ID 0x11
#define BCM56267_DEVICE_ID 0xb267
#define BCM56267_A0_REV_ID 1
#define BCM56267_B0_REV_ID 0x11
#define BCM56268_DEVICE_ID 0xb268
#define BCM56268_A0_REV_ID 1
#define BCM56268_B0_REV_ID 0x11
#define BCM56233_DEVICE_ID 0xb233
#define BCM56233_B0_REV_ID 0x11
#define BCM56460_DEVICE_ID 0xb460
#define BCM56460_A0_REV_ID 1
#define BCM56460_B0_REV_ID 0x11
#define BCM56461_DEVICE_ID 0xb461
#define BCM56461_A0_REV_ID 1
#define BCM56461_B0_REV_ID 0x11
#define BCM56462_DEVICE_ID 0xb462
#define BCM56462_A0_REV_ID 1
#define BCM56462_B0_REV_ID 0x11
#define BCM56463_DEVICE_ID 0xb463
#define BCM56463_A0_REV_ID 1
#define BCM56463_B0_REV_ID 0x11
#define BCM56465_DEVICE_ID 0xb465
#define BCM56465_A0_REV_ID 1
#define BCM56465_B0_REV_ID 0x11
#define BCM56466_DEVICE_ID 0xb466
#define BCM56466_A0_REV_ID 1
#define BCM56466_B0_REV_ID 0x11
#define BCM56467_DEVICE_ID 0xb467
#define BCM56467_A0_REV_ID 1
#define BCM56467_B0_REV_ID 0x11
#define BCM56468_DEVICE_ID 0xb468
#define BCM56468_A0_REV_ID 1
#define BCM56468_B0_REV_ID 0x11
#define BCM56842_DEVICE_ID 0xb842
#define BCM56842_A0_REV_ID 1
#define BCM56842_A1_REV_ID 2
#define BCM56844_DEVICE_ID 0xb844
#define BCM56844_A0_REV_ID 1
#define BCM56844_A1_REV_ID 2
#define BCM56846_DEVICE_ID 0xb846
#define BCM56846_A0_REV_ID 1
#define BCM56846_A1_REV_ID 2
#define BCM56549_DEVICE_ID 0xb549
#define BCM56549_A0_REV_ID 1
#define BCM56549_A1_REV_ID 2
#define BCM56053_DEVICE_ID 0xb053
#define BCM56053_A0_REV_ID 1
#define BCM56053_A1_REV_ID 2
#define BCM56831_DEVICE_ID 0xb831
#define BCM56831_A0_REV_ID 1
#define BCM56831_A1_REV_ID 2
#define BCM56835_DEVICE_ID 0xb835
#define BCM56835_A0_REV_ID 1
#define BCM56835_A1_REV_ID 2
#define BCM56838_DEVICE_ID 0xb838
#define BCM56838_A0_REV_ID 1
#define BCM56838_A1_REV_ID 2
#define BCM56847_DEVICE_ID 0xb847
#define BCM56847_A0_REV_ID 1
#define BCM56847_A1_REV_ID 2
#define BCM56847_A2_REV_ID 3
#define BCM56847_A3_REV_ID 4
#define BCM56847_A4_REV_ID 5
#define BCM56847_B0_REV_ID 0x11
#define BCM56847_B1_REV_ID 0x12
#define BCM56849_DEVICE_ID 0xb849
#define BCM56849_A0_REV_ID 1
#define BCM56849_A1_REV_ID 2
#define BCM56742_DEVICE_ID 0xb742
#define BCM56742_A0_REV_ID 1
#define BCM56742_A1_REV_ID 2
#define BCM56742_A2_REV_ID 3
#define BCM56744_DEVICE_ID 0xb744
#define BCM56744_A0_REV_ID 1
#define BCM56744_A1_REV_ID 2
#define BCM56746_DEVICE_ID 0xb746
#define BCM56746_A0_REV_ID 1
#define BCM56746_A1_REV_ID 2
#define BCM88230_DEVICE_ID 0x0230
#define BCM88230_A0_REV_ID 1
#define BCM88230_B0_REV_ID 0x11
#define BCM88230_C0_REV_ID 0x21
#define BCM88231_DEVICE_ID 0x0231
#define BCM88231_A0_REV_ID 1
#define BCM88231_B0_REV_ID 0x11
#define BCM88231_C0_REV_ID 0x21
#define BCM88235_DEVICE_ID 0x0235
#define BCM88235_A0_REV_ID 1
#define BCM88235_B0_REV_ID 0x11
#define BCM88235_C0_REV_ID 0x21
#define BCM88236_DEVICE_ID 0x0236
#define BCM88236_A0_REV_ID 1
#define BCM88236_B0_REV_ID 0x11
#define BCM88236_C0_REV_ID 0x21
#define BCM88239_DEVICE_ID 0x0239
#define BCM88239_A0_REV_ID 1
#define BCM88239_B0_REV_ID 0x11
#define BCM88239_C0_REV_ID 0x21
#define BCM56613_DEVICE_ID 0xb613
#define BCM56613_A0_REV_ID 1
#define BCM56613_B0_REV_ID 0x11
#define BCM56613_C0_REV_ID 0x21
#define BCM56930_DEVICE_ID 0xb930
#define BCM56930_A0_REV_ID 1
#define BCM56930_B0_REV_ID 0x11
#define BCM56930_C0_REV_ID 0x21
#define BCM56931_DEVICE_ID 0xb931
#define BCM56931_A0_REV_ID 1
#define BCM56931_B0_REV_ID 0x11
#define BCM56931_C0_REV_ID 0x21
#define BCM56935_DEVICE_ID 0xb935
#define BCM56935_A0_REV_ID 1
#define BCM56935_B0_REV_ID 0x11
#define BCM56935_C0_REV_ID 0x21
#define BCM56936_DEVICE_ID 0xb936
#define BCM56936_A0_REV_ID 1
#define BCM56936_B0_REV_ID 0x11
#define BCM56936_C0_REV_ID 0x21
#define BCM56939_DEVICE_ID 0xb939
#define BCM56939_A0_REV_ID 1
#define BCM56939_B0_REV_ID 0x11
#define BCM56939_C0_REV_ID 0x21
#define BCM88732_DEVICE_ID 0x0732
#define BCM88732_A0_REV_ID 1
#define BCM88732_A1_REV_ID 2
#define BCM88732_A2_REV_ID 4
#define BCM88732_B0_REV_ID 0x11
#define BCM88732_B1_REV_ID 0x12
#define BCM88732_B2_REV_ID 0x13
#define BCM56640_DEVICE_ID 0xb640
#define BCM56640_A0_REV_ID 1
#define BCM56640_A1_REV_ID 2
#define BCM56640_B0_REV_ID 0x11
#define BCM56643_DEVICE_ID 0xb643
#define BCM56643_A0_REV_ID 1
#define BCM56643_A1_REV_ID 2
#define BCM56643_B0_REV_ID 0x11
#define BCM56644_DEVICE_ID 0xb644
#define BCM56644_A0_REV_ID 1
#define BCM56644_A1_REV_ID 2
#define BCM56644_B0_REV_ID 0x11
#define BCM56648_DEVICE_ID 0xb648
#define BCM56648_A0_REV_ID 1
#define BCM56648_A1_REV_ID 2
#define BCM56648_B0_REV_ID 0x11
#define BCM56649_DEVICE_ID 0xb649
#define BCM56649_A0_REV_ID 1
#define BCM56649_A1_REV_ID 2
#define BCM56649_B0_REV_ID 0x11
#define BCM56540_DEVICE_ID 0xb540
#define BCM56540_A0_REV_ID 1
#define BCM56540_A1_REV_ID 2
#define BCM56540_B0_REV_ID 0x11
#define BCM56541_DEVICE_ID 0xb541
#define BCM56541_A0_REV_ID 1
#define BCM56541_A1_REV_ID 2
#define BCM56541_B0_REV_ID 0x11
#define BCM56542_DEVICE_ID 0xb542
#define BCM56542_A0_REV_ID 1
#define BCM56542_A1_REV_ID 2
#define BCM56542_B0_REV_ID 0x11
#define BCM56543_DEVICE_ID 0xb543
#define BCM56543_A0_REV_ID 1
#define BCM56543_A1_REV_ID 2
#define BCM56543_B0_REV_ID 0x11
#define BCM56544_DEVICE_ID 0xb544
#define BCM56544_A0_REV_ID 1
#define BCM56544_A1_REV_ID 2
#define BCM56544_B0_REV_ID 0x11
#define BCM56545_DEVICE_ID 0xb545
#define BCM56545_A0_REV_ID 1
#define BCM56545_A1_REV_ID 2
#define BCM56545_B0_REV_ID 0x11
#define BCM56546_DEVICE_ID 0xb546
#define BCM56546_A0_REV_ID 1
#define BCM56546_A1_REV_ID 2
#define BCM56546_B0_REV_ID 0x11
#define BCM56044_DEVICE_ID 0xb044
#define BCM56044_B0_REV_ID 0x11
#define BCM56045_DEVICE_ID 0xb045
#define BCM56045_A0_REV_ID 1
#define BCM56045_A1_REV_ID 2
#define BCM56045_B0_REV_ID 0x11
#define BCM56046_DEVICE_ID 0xb046
#define BCM56046_A0_REV_ID 1
#define BCM56046_A1_REV_ID 2
#define BCM56046_B0_REV_ID 0x11
#define BCM56440_DEVICE_ID 0xb440
#define BCM56440_A0_REV_ID 1
#define BCM56440_B0_REV_ID 0x11
#define BCM56441_DEVICE_ID 0xb441
#define BCM56441_A0_REV_ID 1
#define BCM56441_B0_REV_ID 0x11
#define BCM56442_DEVICE_ID 0xb442
#define BCM56442_A0_REV_ID 1
#define BCM56442_B0_REV_ID 0x11
#define BCM56443_DEVICE_ID 0xb443
#define BCM56443_A0_REV_ID 1
#define BCM56443_B0_REV_ID 0x11
#define BCM56445_DEVICE_ID 0xb445
#define BCM56445_A0_REV_ID 1
#define BCM56445_B0_REV_ID 0x11
#define BCM56446_DEVICE_ID 0xb446
#define BCM56446_A0_REV_ID 1
#define BCM56446_B0_REV_ID 0x11
#define BCM56447_DEVICE_ID 0xb447
#define BCM56447_A0_REV_ID 1
#define BCM56447_B0_REV_ID 0x11
#define BCM56448_DEVICE_ID 0xb448
#define BCM56448_A0_REV_ID 1
#define BCM56448_B0_REV_ID 0x11
#define BCM56449_DEVICE_ID 0xb449
#define BCM56449_A0_REV_ID 1
#define BCM56449_B0_REV_ID 0x11
#define BCM56240_DEVICE_ID 0xb240
#define BCM56240_A0_REV_ID 1
#define BCM56240_B0_REV_ID 0x11
#define BCM56241_DEVICE_ID 0xb241
#define BCM56241_A0_REV_ID 1
#define BCM56241_B0_REV_ID 0x11
#define BCM56242_DEVICE_ID 0xb242
#define BCM56242_A0_REV_ID 1
#define BCM56242_B0_REV_ID 0x11
#define BCM56243_DEVICE_ID 0xb243
#define BCM56243_A0_REV_ID 1
#define BCM56243_B0_REV_ID 0x11
#define BCM56245_DEVICE_ID 0xb245
#define BCM56245_A0_REV_ID 1
#define BCM56245_B0_REV_ID 0x11
#define BCM56246_DEVICE_ID 0xb246
#define BCM56246_A0_REV_ID 1
#define BCM56246_B0_REV_ID 0x11
#define BCM55440_DEVICE_ID 0xa440
#define BCM55440_A0_REV_ID 1
#define BCM55440_B0_REV_ID 0x11
#define BCM55441_DEVICE_ID 0xa441
#define BCM55441_A0_REV_ID 1
#define BCM55441_B0_REV_ID 0x11
#define BCM55450_DEVICE_ID 0xa450
#define BCM55450_A0_REV_ID 1
#define BCM55450_B0_REV_ID 0x11
#define BCM55450_B1_REV_ID 0x12
#define BCM55455_DEVICE_ID 0xa455
#define BCM55455_A0_REV_ID 1
#define BCM55455_B0_REV_ID 0x11
#define BCM55455_B1_REV_ID 0x12
#define BCM56248_DEVICE_ID 0xb248
#define BCM56248_A0_REV_ID 1
#define BCM56248_B0_REV_ID 0x11
#define BCM56248_B1_REV_ID 0x12
#define BCM56450_DEVICE_ID 0xb450
#define BCM56450_A0_REV_ID 1
#define BCM56450_B0_REV_ID 0x11
#define BCM56450_B1_REV_ID 0x12
#define BCM56452_DEVICE_ID 0xb452
#define BCM56452_A0_REV_ID 1
#define BCM56452_B0_REV_ID 0x11
#define BCM56452_B1_REV_ID 0x12
#define BCM56454_DEVICE_ID 0xb454
#define BCM56454_A0_REV_ID 1
#define BCM56454_B0_REV_ID 0x11
#define BCM56454_B1_REV_ID 0x12
#define BCM56455_DEVICE_ID 0xb455
#define BCM56455_A0_REV_ID 1
#define BCM56455_B0_REV_ID 0x11
#define BCM56455_B1_REV_ID 0x12
#define BCM56456_DEVICE_ID 0xb456
#define BCM56456_A0_REV_ID 1
#define BCM56456_B0_REV_ID 0x11
#define BCM56456_B1_REV_ID 0x12
#define BCM56457_DEVICE_ID 0xb457
#define BCM56457_A0_REV_ID 1
#define BCM56457_B0_REV_ID 0x11
#define BCM56457_B1_REV_ID 0x12
#define BCM56458_DEVICE_ID 0xb458
#define BCM56458_A0_REV_ID 1
#define BCM56458_B0_REV_ID 0x11
#define BCM56458_B1_REV_ID 0x12
#define BCM56850_DEVICE_ID 0xb850
#define BCM56850_A0_REV_ID 1
#define BCM56850_A1_REV_ID 2
#define BCM56850_A2_REV_ID 3
#define BCM56851_DEVICE_ID 0xb851
#define BCM56851_A0_REV_ID 1
#define BCM56851_A1_REV_ID 2
#define BCM56851_A2_REV_ID 3
#define BCM56852_DEVICE_ID 0xb852
#define BCM56852_A0_REV_ID 1
#define BCM56852_A1_REV_ID 2
#define BCM56852_A2_REV_ID 3
#define BCM56853_DEVICE_ID 0xb853
#define BCM56853_A0_REV_ID 1
#define BCM56853_A1_REV_ID 2
#define BCM56853_A2_REV_ID 3
#define BCM56854_DEVICE_ID 0xb854
#define BCM56854_A0_REV_ID 1
#define BCM56854_A1_REV_ID 2
#define BCM56854_A2_REV_ID 3
#define BCM56855_DEVICE_ID 0xb855
#define BCM56855_A0_REV_ID 1
#define BCM56855_A1_REV_ID 2
#define BCM56855_A2_REV_ID 3
#define BCM56834_DEVICE_ID 0xb834
#define BCM56834_A0_REV_ID 1
#define BCM56834_A1_REV_ID 2
#define BCM56834_A2_REV_ID 3
#define BCM56860_DEVICE_ID 0xb860
#define BCM56860_A0_REV_ID 1
#define BCM56860_A1_REV_ID 2
#define BCM56861_DEVICE_ID 0xb861
#define BCM56861_A0_REV_ID 1
#define BCM56861_A1_REV_ID 2
#define BCM56862_DEVICE_ID 0xb862
#define BCM56862_A0_REV_ID 1
#define BCM56862_A1_REV_ID 2
#define BCM56864_DEVICE_ID 0xb864
#define BCM56864_A0_REV_ID 1
#define BCM56864_A1_REV_ID 2
#define BCM56865_DEVICE_ID 0xb865
#define BCM56865_A0_REV_ID 1
#define BCM56865_A1_REV_ID 2
#define BCM56866_DEVICE_ID 0xb866
#define BCM56866_A0_REV_ID 1
#define BCM56866_A1_REV_ID 2
#define BCM56867_DEVICE_ID 0xb867
#define BCM56867_A0_REV_ID 1
#define BCM56867_A1_REV_ID 2
#define BCM56868_DEVICE_ID 0xb868
#define BCM56868_A0_REV_ID 1
#define BCM56868_A1_REV_ID 2
#define BCM56760_DEVICE_ID 0xb760
#define BCM56760_A0_REV_ID 1
#define BCM56760_A1_REV_ID 2
#define BCM56832_DEVICE_ID 0xb832
#define BCM56832_A0_REV_ID 1
#define BCM56832_A1_REV_ID 2
#define BCM56833_DEVICE_ID 0xb833
#define BCM56833_A0_REV_ID 1
#define BCM56833_A1_REV_ID 2
#define BCM56836_DEVICE_ID 0xb836
#define BCM56836_A0_REV_ID 1
#define BCM56836_A1_REV_ID 2
#define BCM56750_DEVICE_ID 0xb750
#define BCM56750_A0_REV_ID 1
#define BCM56750_A1_REV_ID 2
#define BCM56750_A2_REV_ID 3
#define BCM56830_DEVICE_ID 0xb830
#define BCM56830_A0_REV_ID 1
#define BCM56830_A1_REV_ID 2
#define BCM56830_A2_REV_ID 3
#define BCM56150_DEVICE_ID 0xb150
#define BCM56150_A0_REV_ID 1
#define BCM56151_DEVICE_ID 0xb151
#define BCM56151_A0_REV_ID 1
#define BCM56152_DEVICE_ID 0xb152
#define BCM56152_A0_REV_ID 1
#define BCM53342_DEVICE_ID 0x8342
#define BCM53342_A0_REV_ID 1
#define BCM53343_DEVICE_ID 0x8343
#define BCM53343_A0_REV_ID 1
#define BCM53344_DEVICE_ID 0x8344
#define BCM53344_A0_REV_ID 1
#define BCM53346_DEVICE_ID 0x8346
#define BCM53346_A0_REV_ID 1
#define BCM53347_DEVICE_ID 0x8347
#define BCM53347_A0_REV_ID 1
#define BCM53333_DEVICE_ID 0x8333
#define BCM53333_A0_REV_ID 1
#define BCM53334_DEVICE_ID 0x8334
#define BCM53334_A0_REV_ID 1
#define BCM53393_DEVICE_ID 0x8393
#define BCM53393_A0_REV_ID 1
#define BCM53394_DEVICE_ID 0x8394
#define BCM53394_A0_REV_ID 1
#define BCM53400_DEVICE_ID 0x8400
#define BCM53400_A0_REV_ID 1
#define BCM56060_DEVICE_ID 0xb060
#define BCM56060_A0_REV_ID 1
#define BCM56062_DEVICE_ID 0xb062
#define BCM56062_A0_REV_ID 1
#define BCM56063_DEVICE_ID 0xb063
#define BCM56063_A0_REV_ID 1
#define BCM56064_DEVICE_ID 0xb064
#define BCM56064_A0_REV_ID 1
#define BCM56065_DEVICE_ID 0xb065
#define BCM56065_A0_REV_ID 1
#define BCM56066_DEVICE_ID 0xb066
#define BCM56066_A0_REV_ID 1
#define BCM53401_DEVICE_ID 0x8401
#define BCM53411_DEVICE_ID 0x8411
#define BCM53401_A0_REV_ID 1
#define BCM53402_DEVICE_ID 0x8402
#define BCM53412_DEVICE_ID 0x8412
#define BCM53402_A0_REV_ID 1
#define BCM53403_DEVICE_ID 0x8403
#define BCM53413_DEVICE_ID 0x8413
#define BCM53403_A0_REV_ID 1
#define BCM53404_DEVICE_ID 0x8404
#define BCM53414_DEVICE_ID 0x8414
#define BCM53404_A0_REV_ID 1
#define BCM53405_DEVICE_ID 0x8405
#define BCM53415_DEVICE_ID 0x8415
#define BCM53405_A0_REV_ID 1
#define BCM53406_DEVICE_ID 0x8406
#define BCM53416_DEVICE_ID 0x8416
#define BCM53406_A0_REV_ID 1
#define BCM53408_DEVICE_ID 0x8408
#define BCM53418_DEVICE_ID 0x8418
#define BCM53408_A0_REV_ID 1
#define BCM53365_DEVICE_ID 0x8365
#define BCM53365_A0_REV_ID 1
#define BCM53454_DEVICE_ID 0x8454
#define BCM53455_DEVICE_ID 0x8455
#define BCM53454_A0_REV_ID 1
#define BCM53456_DEVICE_ID 0x8456
#define BCM53457_DEVICE_ID 0x8457
#define BCM53456_A0_REV_ID 1
#define BCM53422_DEVICE_ID 0x8422
#define BCM53422_A0_REV_ID 1
#define BCM53424_DEVICE_ID 0x8424
#define BCM53424_A0_REV_ID 1
#define BCM53426_DEVICE_ID 0x8426
#define BCM53426_A0_REV_ID 1
#define BCM56960_DEVICE_ID 0xb960
#define BCM56960_A0_REV_ID 1
#define BCM56960_B0_REV_ID 0x11
#define BCM56960_B1_REV_ID 0x12
#define BCM56961_DEVICE_ID 0xb961
#define BCM56961_A0_REV_ID 1
#define BCM56961_B0_REV_ID 0x11
#define BCM56961_B1_REV_ID 0x12
#define BCM56962_DEVICE_ID 0xb962
#define BCM56962_A0_REV_ID 1
#define BCM56962_B0_REV_ID 0x11
#define BCM56962_B1_REV_ID 0x12
#define BCM56963_DEVICE_ID 0xb963
#define BCM56963_A0_REV_ID 1
#define BCM56963_B0_REV_ID 0x11
#define BCM56963_B1_REV_ID 0x12
#define BCM56930_DEVICE_ID 0xb930
#define BCM56930_A0_REV_ID 1
#define BCM56930_B0_REV_ID 0x11
#define BCM56930_B1_REV_ID 0x12
#define BCM56968_DEVICE_ID 0xb968
#define BCM56968_A0_REV_ID 1
#define BCM56968_B0_REV_ID 0x11
#define BCM56968_B1_REV_ID 0x12
#define BCM5665_DEVICE_ID 0x5665
#define BCM5665_A0_REV_ID 1
#define BCM5665_B0_REV_ID 0x11
#define BCM5655_DEVICE_ID 0x5655
#define BCM5655_A0_REV_ID 1
#define BCM5655_B0_REV_ID 0x11
#define BCM5650_DEVICE_ID 0x5650
#define BCM5650_A0_REV_ID 1
#define BCM5650_B0_REV_ID 0x11
#define BCM5650_C0_REV_ID 0x21
#define BROADCOM_PHYID_HIGH 0x0040
#define BCM5338_PHYID_LOW 0x62b0
#define BCM5338_A0_REV_ID 0
#define BCM5338_A1_REV_ID 1
#define BCM5338_B0_REV_ID 3
#define BCM5324_PHYID_LOW 0xbc20
#define BCM5324_PHYID_HIGH 0x143
#define BCM5324_A1_PHYID_HIGH 0x153
#define BCM5324_DEVICE_ID 0xbc20
#define BCM5324_A0_REV_ID 0
#define BCM5324_A1_REV_ID 1
#define BCM5324_A2_REV_ID 2
#define BCM5380_PHYID_LOW 0x6250
#define BCM5380_A0_REV_ID 0
#define BCM5388_PHYID_LOW 0x6288
#define BCM5388_A0_REV_ID 0
#define BCM5396_PHYID_LOW 0xbd70
#define BCM5396_PHYID_HIGH 0x143
#define BCM5396_DEVICE_ID 0x96
#define BCM5396_A0_REV_ID 0
#define BCM5389_PHYID_LOW 0xbd70
#define BCM5389_PHYID_HIGH 0x143
#define BCM5389_DEVICE_ID 0x89
#define BCM5389_A0_REV_ID 0
#define BCM5389_A1_DEVICE_ID 0x86
#define BCM5389_A1_REV_ID 1
#define BCM5398_PHYID_LOW 0xbcd0
#define BCM5398_PHYID_HIGH 0x0143
#define BCM5398_DEVICE_ID 0x98
#define BCM5398_A0_REV_ID 0
#define BCM5325_PHYID_LOW 0xbc30
#define BCM5325_PHYID_HIGH 0x143
#define BCM5325_DEVICE_ID 0xbc30
#define BCM5325_A0_REV_ID 0
#define BCM5325_A1_REV_ID 1
#define BCM5348_PHYID_LOW 0xbe40
#define BCM5348_PHYID_HIGH 0x0143
#define BCM5348_DEVICE_ID 0x48
#define BCM5348_A0_REV_ID 0
#define BCM5348_A1_REV_ID 1
#define BCM5397_PHYID_LOW 0xbcd0
#define BCM5397_PHYID_HIGH 0x0143
#define BCM5397_DEVICE_ID 0x97
#define BCM5397_A0_REV_ID 0
#define BCM5347_PHYID_LOW 0xbe40
#define BCM5347_PHYID_HIGH 0x0143
#define BCM5347_DEVICE_ID 0x47
#define BCM5347_A0_REV_ID 0
#define BCM5395_PHYID_LOW 0xbcf0
#define BCM5395_PHYID_HIGH 0x0143
#define BCM5395_DEVICE_ID 0xbcf0
#define BCM5395_A0_REV_ID 0
#define BCM53242_PHYID_LOW 0xbf10
#define BCM53242_PHYID_HIGH 0x0143
#define BCM53242_DEVICE_ID 0xbf10
#define BCM53242_A0_REV_ID 0
#define BCM53242_B0_REV_ID 4
#define BCM53242_B1_REV_ID 5
#define BCM53262_PHYID_LOW 0xbf20
#define BCM53262_PHYID_HIGH 0x0143
#define BCM53262_DEVICE_ID 0xbf20
#define BCM53262_A0_REV_ID 0
#define BCM53262_B0_REV_ID 4
#define BCM53262_B1_REV_ID 5
#define BCM53115_PHYID_LOW 0xbf80
#define BCM53115_PHYID_HIGH 0x0143
#define BCM53115_DEVICE_ID 0xbf80
#define BCM53115_A0_REV_ID 0
#define BCM53115_A1_REV_ID 1
#define BCM53115_B0_REV_ID 2
#define BCM53115_B1_REV_ID 3
#define BCM53115_C0_REV_ID 8
#define BCM53118_PHYID_LOW 0xbfe0
#define BCM53118_PHYID_HIGH 0x0143
#define BCM53118_DEVICE_ID 0xbfe0
#define BCM53118_A0_REV_ID 0
#define BCM53118_B0_REV_ID 4
#define BCM53118_B1_REV_ID 5
#define BCM53280_PHYID_LOW 0x5e90
#define BCM53280_PHYID_HIGH 0x0362
#define BCM53280_DEVICE_ID (0x4 | BCM53280_PHYID_LOW)
#define BCM53280_A0_REV_ID 0
#define BCM53280_B0_REV_ID 0x4
#define BCM53280_B1_REV_ID 0x5
#define BCM53280_B2_REV_ID 0x6
#define BCM53286_DEVICE_ID (0x4 | BCM53280_PHYID_LOW)
#define BCM53288_DEVICE_ID (0xc | BCM53280_PHYID_LOW)
#define BCM53284_DEVICE_ID (0x7 | BCM53280_PHYID_LOW)
#define BCM53283_DEVICE_ID (0x6 | BCM53280_PHYID_LOW)
#define BCM53282_DEVICE_ID (0x5 | BCM53280_PHYID_LOW)
#define BCM53101_PHYID_LOW 0x5ed0
#define BCM53101_PHYID_HIGH 0x0362
#define BCM53101_DEVICE_ID 0x5ed0
#define BCM53101_A0_REV_ID 0
#define BCM53101_B0_REV_ID 4
#define BCM53125_PHYID_LOW 0x5f20
#define BCM53125_PHYID_HIGH 0x0362
#define BCM53125_DEVICE_ID 0x5f20
#define BCM53125_A0_REV_ID 0
#define BCM53125_B0_REV_ID 0x4
#define BCM53125_MODEL_ID 0x53125
#define BCM53128_PHYID_LOW 0x5e10
#define BCM53128_PHYID_HIGH 0x0362
#define BCM53128_DEVICE_ID 0x5e10
#define BCM53128_A0_REV_ID 0
#define BCM53128_B0_REV_ID 0x4
#define BCM53128_MODEL_ID 0x53128
#define BCM53600_PHYID_LOW 0x5f40
#define BCM53600_PHYID_HIGH 0x0362
#define BCM53600_DEVICE_ID (0x3 | BCM53600_PHYID_LOW)
#define BCM53600_A0_REV_ID 0
#define BCM53602_DEVICE_ID (0x1 | BCM53600_PHYID_LOW)
#define BCM53603_DEVICE_ID (0x2 | BCM53600_PHYID_LOW)
#define BCM53604_DEVICE_ID (0x3 | BCM53600_PHYID_LOW)
#define BCM53606_DEVICE_ID (0x7 | BCM53600_PHYID_LOW)
#define BCM89500_PHYID_LOW 0x5d30
#define BCM89500_PHYID_HIGH 0x0362
#define BCM89500_DEVICE_ID 0x9500
#define BCM89501_DEVICE_ID 0x9501
#define BCM89200_DEVICE_ID 0x9200
#define BCM89500_A0_REV_ID 0
#define BCM89500_B0_REV_ID 0x4
#define BCM89500_MODEL_ID 0x89500
#define BCM53010_PHYID_LOW 0x8760
#define BCM53010_PHYID_HIGH 0x600d
#define BCM53010_DEVICE_ID 0x3010
#define BCM53011_DEVICE_ID 0x3011
#define BCM53012_DEVICE_ID 0x3012
#define BCM53010_A0_REV_ID 0
#define BCM53010_A2_REV_ID 0x2
#define BCM53010_MODEL_ID 0x53010
#define BCM53018_PHYID_LOW 0x87c0
#define BCM53018_PHYID_HIGH 0x600d
#define BCM53017_DEVICE_ID 0x3016
#define BCM53018_DEVICE_ID 0x3018
#define BCM53019_DEVICE_ID 0x3019
#define BCM53018_A0_REV_ID 0
#define BCM53018_MODEL_ID 0x53016
#define BCM53020_PHYID_LOW 0x87f0
#define BCM53020_PHYID_HIGH 0x600d
#define BCM53020_DEVICE_ID 0x8022
#define BCM53022_DEVICE_ID 0x8022
#define BCM53023_DEVICE_ID 0x8023
#define BCM53025_DEVICE_ID 0x8025
#define BCM58625_DEVICE_ID 0x8625
#define BCM58622_DEVICE_ID 0x8622
#define BCM58623_DEVICE_ID 0x8623
#define BCM58525_DEVICE_ID 0x8525
#define BCM58522_DEVICE_ID 0x8522
#define BCM53020_A0_REV_ID 0
#define BCM53020_MODEL_ID 0x3025
#define BCM4713_DEVICE_ID 0x4713
#define BCM4713_A0_REV_ID 0
#define BCM4713_A9_REV_ID 9
#define BCM53000_GMAC_DEVICE_ID 0x4715
#define BCM53000_A0_REV_ID 0
#define BCM53010_GMAC_DEVICE_ID 0x4715
#define BCM53000PCIE_DEVICE_ID 0x5300
#define SANDBURST_VENDOR_ID 0x17ba
#define BME3200_DEVICE_ID 0x0280
#define BME3200_A0_REV_ID 0x0000
#define BME3200_B0_REV_ID 0x0001
#define BM9600_DEVICE_ID 0x0480
#define BM9600_A0_REV_ID 0x0000
#define BM9600_B0_REV_ID 0x0010
#define QE2000_DEVICE_ID 0x0300
#define QE2000_A1_REV_ID 0x0001
#define QE2000_A2_REV_ID 0x0002
#define QE2000_A3_REV_ID 0x0003
#define QE2000_A4_REV_ID 0x0004
#define BCM88020_DEVICE_ID 0x0380
#define BCM88020_A0_REV_ID 0x0000
#define BCM88020_A1_REV_ID 0x0001
#define BCM88020_A2_REV_ID 0x0002
#define BCM88025_DEVICE_ID 0x0580
#define BCM88025_A0_REV_ID 0x0000
#define BCM88030_DEVICE_ID 0x0038
#define BCM88030_A0_REV_ID 0x0001
#define BCM88030_A1_REV_ID 0x0002
#define BCM88030_B0_REV_ID 0x0011
#define BCM88030_B1_REV_ID 0x0012
#define BCM88034_DEVICE_ID 0x0034
#define BCM88034_A0_REV_ID (BCM88030_A0_REV_ID)
#define BCM88034_A1_REV_ID (BCM88030_A1_REV_ID)
#define BCM88034_B0_REV_ID (BCM88030_B0_REV_ID)
#define BCM88034_B1_REV_ID (BCM88030_B1_REV_ID)
#define BCM88039_DEVICE_ID 0x0039
#define BCM88039_A0_REV_ID (BCM88030_A0_REV_ID)
#define BCM88039_A1_REV_ID (BCM88030_A1_REV_ID)
#define BCM88039_B0_REV_ID (BCM88030_B0_REV_ID)
#define BCM88039_B1_REV_ID (BCM88030_B1_REV_ID)
#define BCM88130_DEVICE_ID 0x0480
#define BCM88130_A0_REV_ID 0x0000
#define BCM88130_A1_REV_ID 0x0001
#define BCM88130_B0_REV_ID 0x0010
#define PLX_VENDOR_ID 0x10b5
#define PLX9656_DEVICE_ID 0x9656
#define PLX9656_REV_ID 0x0000
#define PLX9056_DEVICE_ID 0x9056
#define PLX9056_REV_ID 0x0000
#define TK371X_DEVICE_ID 0x8600
#define TK371X_A0_REV_ID 0x0
#define PETRAB_DEVICE_ID 0xa100
#define PETRAB_A0_REV_ID 0x0001
#define BCM88640_DEVICE_ID (PETRAB_DEVICE_ID)
#define BCM88640_A0_REV_ID (PETRAB_A0_REV_ID)
#define ARAD_DEVICE_ID 0x8650
#define ARAD_A0_REV_ID 0x0000
#define ARAD_B0_REV_ID 0x0011
#define ARAD_B1_REV_ID 0x0012
#define BCM88650_DEVICE_ID ARAD_DEVICE_ID
#define BCM88650_A0_REV_ID ARAD_A0_REV_ID
#define BCM88650_B0_REV_ID ARAD_B0_REV_ID
#define BCM88650_B1_REV_ID ARAD_B1_REV_ID
#define BCM88750_DEVICE_ID 0x8750
#define BCM88750_A0_REV_ID 0x0000
#define BCM88750_B0_REV_ID 0x0011
#define BCM88753_DEVICE_ID 0x8753
#define BCM88753_A0_REV_ID 0x0000
#define BCM88753_B0_REV_ID 0x0011
#define BCM88754_DEVICE_ID 0x8754
#define BCM88754_A0_REV_ID 0x0000
#define BCM88754_ORIGINAL_VENDOR_ID 0x16FC
#define BCM88754_ORIGINAL_DEVICE_ID 0x020F
#define BCM88754_A0_ORIGINAL_REV_ID 0x0001
#define BCM88755_DEVICE_ID 0x8755
#define BCM88755_B0_REV_ID 0x0011
#define BCM88770_DEVICE_ID 0x8770
#define BCM88770_A1_REV_ID 0x0002
#define BCM88773_DEVICE_ID 0x8773
#define BCM88773_A1_REV_ID 0x0002
#define BCM88774_DEVICE_ID 0x8774
#define BCM88774_A1_REV_ID 0x0002
#define BCM88775_DEVICE_ID 0x8775
#define BCM88775_A1_REV_ID 0x0002
#define BCM88776_DEVICE_ID 0x8776
#define BCM88776_A1_REV_ID 0x0002
#define BCM88950_DEVICE_ID 0x8950
#define BCM88950_A0_REV_ID 0x0001
#define BCM88950_A1_REV_ID 0x0002
#define BCM88953_DEVICE_ID 0x8953
#define BCM88953_A1_REV_ID 0x0002
#define BCM88954_DEVICE_ID 0x8954
#define BCM88954_A1_REV_ID 0x0002
#define BCM88955_DEVICE_ID 0x8955
#define BCM88955_A1_REV_ID 0x0002
#define BCM88956_DEVICE_ID 0x8956
#define BCM88956_A1_REV_ID 0x0002
#define ARADPLUS_DEVICE_ID 0x8660
#define ARADPLUS_A0_REV_ID 0x0001
#define BCM88660_DEVICE_ID ARADPLUS_DEVICE_ID
#define BCM88660_A0_REV_ID ARADPLUS_A0_REV_ID
#define JERICHO_DEVICE_ID 0x8675
#define JERICHO_A0_REV_ID 0x0001
#define JERICHO_B0_REV_ID 0x0011
#define JERICHO_A1_REV_ID 0x0002
#define BCM88670_DEVICE_ID 0x8670
#define BCM88670_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88670_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88671_DEVICE_ID 0x8671
#define BCM88671_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88671_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88671M_DEVICE_ID 0x867A
#define BCM88671M_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88671M_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88670_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88671_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88671M_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88673_DEVICE_ID 0x8673
#define BCM88673_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88673_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88674_DEVICE_ID 0x8674
#define BCM88674_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88674_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88675_DEVICE_ID JERICHO_DEVICE_ID
#define BCM88675_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88675_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88675M_DEVICE_ID 0x867B
#define BCM88675M_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88675M_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88676_DEVICE_ID 0x8676
#define BCM88676_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88676_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88676M_DEVICE_ID 0x867C
#define BCM88676M_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88676M_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88678_DEVICE_ID 0x8678
#define BCM88678_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88678_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88679_DEVICE_ID 0x8679
#define BCM88679_A0_REV_ID JERICHO_A0_REV_ID
#define BCM88679_A1_REV_ID JERICHO_A1_REV_ID
#define BCM88673_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88674_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88675_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88675M_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88676_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88676M_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88678_B0_REV_ID JERICHO_B0_REV_ID
#define BCM88679_B0_REV_ID JERICHO_B0_REV_ID
#define QMX_DEVICE_ID 0x8375
#define QMX_A0_REV_ID 0x0001
#define QMX_B0_REV_ID 0x0011
#define QMX_A1_REV_ID 0x0002
#define BCM88370_DEVICE_ID 0x8370
#define BCM88370_A0_REV_ID QMX_A0_REV_ID
#define BCM88370_A1_REV_ID QMX_A1_REV_ID
#define BCM88371_DEVICE_ID 0x8371
#define BCM88371_A0_REV_ID QMX_A0_REV_ID
#define BCM88371_A1_REV_ID QMX_A1_REV_ID
#define BCM88371M_DEVICE_ID 0x837A
#define BCM88371M_A0_REV_ID QMX_A0_REV_ID
#define BCM88371M_A1_REV_ID QMX_A1_REV_ID
#define BCM88375_DEVICE_ID QMX_DEVICE_ID
#define BCM88375_A0_REV_ID QMX_A0_REV_ID
#define BCM88375_A1_REV_ID QMX_A1_REV_ID
#define BCM88376_DEVICE_ID 0x8376
#define BCM88376_A0_REV_ID QMX_A0_REV_ID
#define BCM88376_A1_REV_ID QMX_A1_REV_ID
#define BCM88376M_DEVICE_ID 0x837B
#define BCM88376M_A0_REV_ID QMX_A0_REV_ID
#define BCM88376M_A1_REV_ID QMX_A1_REV_ID
#define BCM88377_DEVICE_ID 0x8377
#define BCM88377_A0_REV_ID QMX_A0_REV_ID
#define BCM88377_A1_REV_ID QMX_A1_REV_ID
#define BCM88378_DEVICE_ID 0x8378
#define BCM88378_A0_REV_ID QMX_A0_REV_ID
#define BCM88378_A1_REV_ID QMX_A1_REV_ID
#define BCM88379_DEVICE_ID 0x8379
#define BCM88379_A0_REV_ID QMX_A0_REV_ID
#define BCM88379_A1_REV_ID QMX_A1_REV_ID
#define BCM88370_B0_REV_ID QMX_B0_REV_ID
#define BCM88371_B0_REV_ID QMX_B0_REV_ID
#define BCM88371M_B0_REV_ID QMX_B0_REV_ID
#define BCM88375_B0_REV_ID QMX_B0_REV_ID
#define BCM88376_B0_REV_ID QMX_B0_REV_ID
#define BCM88376M_B0_REV_ID QMX_B0_REV_ID
#define BCM88377_B0_REV_ID QMX_B0_REV_ID
#define BCM88378_B0_REV_ID QMX_B0_REV_ID
#define BCM88379_B0_REV_ID QMX_B0_REV_ID
#define QAX_DEVICE_ID 0x8470
#define QAX_A0_REV_ID 0x0001
#define QAX_B0_REV_ID 0x0011
#define BCM88470_DEVICE_ID QAX_DEVICE_ID
#define BCM88470_A0_REV_ID QAX_A0_REV_ID
#define ARDON_DEVICE_ID 0x8202
#define ARDON_A0_REV_ID 0x0000
#define BCM88202_DEVICE_ID ARDON_DEVICE_ID
#define BCM88202_A0_REV_ID ARDON_A0_REV_ID
#define BCM2801PM_DEVICE_ID 0x2801
#define BCM2801PM_A0_REV_ID 0x0000
#define BCM88360_DEVICE_ID 0x8360
#define BCM88360_A0_REV_ID ARADPLUS_A0_REV_ID
#define BCM88361_DEVICE_ID 0x8361
#define BCM88361_A0_REV_ID ARADPLUS_A0_REV_ID
#define BCM88363_DEVICE_ID 0x8363
#define BCM88363_A0_REV_ID ARADPLUS_A0_REV_ID
#define BCM88460_DEVICE_ID 0x8460
#define BCM88460_A0_REV_ID ARADPLUS_A0_REV_ID
#define BCM88461_DEVICE_ID 0x8461
#define BCM88461_A0_REV_ID ARADPLUS_A0_REV_ID
#define BCM88560_DEVICE_ID 0x8560
#define BCM88560_A0_REV_ID ARADPLUS_A0_REV_ID
#define BCM88561_DEVICE_ID 0x8561
#define BCM88561_A0_REV_ID ARADPLUS_A0_REV_ID
#define BCM88562_DEVICE_ID 0x8562
#define BCM88562_A0_REV_ID ARADPLUS_A0_REV_ID
#define BCM88661_DEVICE_ID 0x8661
#define BCM88661_A0_REV_ID ARADPLUS_A0_REV_ID
#define BCM88664_DEVICE_ID 0x8664
#define BCM88664_A0_REV_ID ARADPLUS_A0_REV_ID
#define JERICHO2_DEVICE_ID 0x8850
#define JERICHO2_P3_REV_ID 0x0001
#define BCM88850_DEVICE_ID JERICHO2_DEVICE_ID
#define BCM88850_P3_REV_ID JERICHO2_P3_REV_ID
#define BCM88350_DEVICE_ID 0x8350
#define BCM88350_B1_REV_ID ARAD_B1_REV_ID
#define BCM88351_DEVICE_ID 0x8351
#define BCM88351_B1_REV_ID ARAD_B1_REV_ID
#define BCM88450_DEVICE_ID 0x8450
#define BCM88450_B1_REV_ID ARAD_B1_REV_ID
#define BCM88451_DEVICE_ID 0x8451
#define BCM88451_B1_REV_ID ARAD_B1_REV_ID
#define BCM88550_DEVICE_ID 0x8550
#define BCM88550_B1_REV_ID ARAD_B0_REV_ID
#define BCM88551_DEVICE_ID 0x8551
#define BCM88551_B1_REV_ID ARAD_B1_REV_ID
#define BCM88552_DEVICE_ID 0x8552
#define BCM88552_B1_REV_ID ARAD_B1_REV_ID
#define BCM88651_DEVICE_ID 0x8651
#define BCM88651_B1_REV_ID ARAD_B1_REV_ID
#define BCM88654_DEVICE_ID 0x8654
#define BCM88654_B1_REV_ID ARAD_B1_REV_ID
#define PCP_PCI_VENDOR_ID 0x1172
#define PCP_PCI_DEVICE_ID 0x4
#define ACP_PCI_VENDOR_ID 0x10ee
#define ACP_PCI_DEVICE_ID 0x7011
#define ACP_PCI_REV_ID 0x0001
#endif
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Make.config,v 1.3 2011/09/08 06:37:31 mlarsen Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
ifneq ($(strip $(override-target)),)
override TARGET=$(override-target)
endif
export TARGET
#
# Set up the target name, and the target base variables.
#
# target = The full name of the target such as vxworks-bmw
# targetbase = 1st part of target (e.g. vxworks)
# targetplat = 2nd part of target (e.g. x86) if any; otherwise same as 1st
#
target = ${TARGET}
targetsplt = $(subst -, , ${target}) # change hyphens to spaces
targetbase = $(word 1,${targetsplt})
targetplat = $(subst ${targetbase}-,,${TARGET})
#
# Common configuration for all platforms
# (Additional platform-dependent configurations are in Makefile.xxx)
#
#
# THIS FILE SHOULD NOT BE MODIFIED LOCALLY, to override, add a file
# $SDK/make/Make.local that sets your local settings, and/or provide
# a path to your settings using the MAKE_LOCAL variable. If
# either of these files exists, their values will override those in this makefile.
#
ifdef MAKE_LOCAL
-include ${MAKE_LOCAL}
endif
-include ${SDK}/make/Make.local
ifdef ALL_CHIPS
ROBO_CHIPS = 1
ESW_CHIPS = 1
else
ifndef ROBO_CHIPS
ESW_CHIPS = 1
endif
endif # ALL_CHIPS
#
# By default, turn off the "changing directory" message.
#
MAKEFLAGS += --no-print-directory
#
# Use gmake by default
#
include ${SDK}/make/Make.tools
include ${SDK}/make/Makefile.${target}
# use QUIET=1 to control printing of compilation lines
ifdef QUIET
Q:=@
else
Q:=
endif
#
# Suffix to add to the "target" files to allow local builds with different
# flags. Set "target_suffix" to XXX to cause the build to put built objects
# in ${target}${target_suffix}. This allows things like building a debug
# version with different flags. This may also be set in another Makefile.
#
#target_suffix :=
#
# Optional suffix to add to the build directory and output binary files
# to allow multiple builds to co-exist for various reasons.
#
#chip_suffix := -$(shell echo $(CHIP) | tr A-Z a-z)
#
# Combined suffixes
#
all_suffix = ${chip_suffix}${target_suffix}
#
# Default location to place binaries and make depend files for building
# purposes.
#
ifeq "$(HOSTTYPE)" "Windows2000PC"
BLDROOTWITHDRIVE = ${SDK}/build/${target}${all_suffix}${bldroot_suffix}
BLDROOT = ${SDK_NO_DRIVE_NAME}/build/${target}${all_suffix}${bldroot_suffix}
else # ifeq "$(HOSTTYPE)" "Windows2000PC"
ifndef SDKBUILD
SDKBUILD :=build
endif
BLDROOT = ${SDK}/${SDKBUILD}/$(if ${BLDCONFIG},${BLDCONFIG}/)${target}${all_suffix}${bldroot_suffix}
endif # ifeq "$(HOSTTYPE)" "Windows2000PC"
# This is needed because we cannot include Make.vxworks before Make.config
ifndef DEST_DIR_SUFFIX
export DEST_DIR_SUFFIX :=$(subst $(realpath $(SDK))/systems,,$(realpath $(CURDIR)/$(dir ($(firstword $(MAKEFILE_LIST))))))
ifeq ($(MAKELEVEL),0)
endif
endif
ifeq ($(DEST_DIR),)
export DEST_DIR :=${SDK}/${SDKBUILD}$(if ${BLDCONFIG},/${BLDCONFIG})$(DEST_DIR_SUFFIX)
endif
ifdef LOCALDIR
BLDDIR = ${BLDROOT}/${LOCALDIR}
ifeq "$(HOSTTYPE)" "Windows2000PC"
BLDDIRWITHDRIVE = ${BLDROOTWITHDRIVE}/${LOCALDIR}
endif
else # ifdef LOCALDIR
BLDDIR = ${BLDROOT}
ifeq "$(HOSTTYPE)" "Windows2000PC"
BLDDIRWITHDRIVE = ${BLDROOTWITHDRIVE}
endif
endif # ifdef LOCALDIR
LIBDIR = ${BLDROOT}
#
# Export directory, where build objects used by the outside world are
# placed (exported header files, libs, bins)
#
EXPDIR = ${SDK}/export/${target}${all_suffix}
#
# Standard include paths
#
INCDIR = ${SDK}/include
#
# Compilation Flags
#
# Flags may be added to (see below)
#
INCFLAGS = -I${INCDIR} -I${SDK}/systems
CFLAGS += ${INCFLAGS}
CXXFLAGS += ${INCFLAGS}
CPPFLAGS += ${INCFLAGS}
#
# Debug #ifdef control
#
# Compiling out #ifdef DEBUG code saves about 1.3% on executable size.
# It is recommended to leave debug enabled when developing applications.
#
ifndef DEBUG_IFDEFS
DEBUG_IFDEFS=TRUE
endif
ifeq ($(DEBUG_IFDEFS),TRUE)
CFLAGS += -DBROADCOM_DEBUG
CXXFLAGS += -DBROADCOM_DEBUG
CPPFLAGS += -DBROADCOM_DEBUG
endif
#
# Debug symbol information control
#
ifndef DEBUG_SYMBOLS
DEBUG_SYMBOLS=TRUE
endif
ifeq ($(DEBUG_SYMBOLS),TRUE)
CFLAGS += -g
CXXFLAGS += -g
CPPFLAGS += -g
endif
#
# If DEBUG_CFLAGS is set, add its contents to CFLAGS.
# May be useful for setting on the command line or adding to Make.local.
# Example: gmake DEBUG_CFLAGS=-save-temps system.c
#
ifneq ($(DEBUG_CFLAGS),)
CFLAGS += $(DEBUG_CFLAGS)
CXXFLAGS += $(DEBUG_CFLAGS)
CPPFLAGS += $(DEBUG_CFLAGS)
endif
#
# Optimization level
#
# Set DEBUG_OPTIMIZE to TRUE (default) to use a normal optimization
# determined by OPTFLAGS_DEFAULT in the platform Makefile.
# Set DEBUG_OPTIMIZE to FALSE to use no optimization,
# strongly recommended when using any debugger.
# Set DEBUG_OPTIMIZE to any other option string to request specific
# optimization flags (for example -O2).
#
ifndef DEBUG_OPTIMIZE
DEBUG_OPTIMIZE=TRUE
endif
ifeq ($(DEBUG_OPTIMIZE),TRUE)
OPTFLAGS += $(OPTFLAGS_DEFAULT)
else
ifneq ($(DEBUG_OPTIMIZE),FALSE)
OPTFLAGS += $(DEBUG_OPTIMIZE)
endif
endif
#
# Debug assertion control.
#
# Compiling out assert() saves about 1.1% on executable size,
# however doing so is VERY MUCH discouraged.
#
ifndef DEBUG_ASSERTS
DEBUG_ASSERTS=TRUE
endif
ifeq ($(DEBUG_ASSERTS),FALSE)
CFLAGS += -DNDEBUG
CXXFLAGS += -DNDEBUG
CPPFLAGS += -DNDEBUG
endif
#
# GCC pedantic mode.
#
ifeq ($(DEBUG_PEDANTIC),TRUE)
CFGFLAGS += -D__PEDANTIC__
CFLAGS += --pedantic
CXXFLAGS += --pedantic
endif
#
# In each directory, build a list of local sources, objects, and headers
#
LSRCS = $(wildcard *.c *.cpp *.s *.cc *.C)
LOBJS = $(addsuffix .o, $(basename ${LSRCS}))
BOBJS = $(addprefix ${BLDDIR}/,${LOBJS})
LHDRS = $(wildcard *.h *.H)
LDOTIS = $(wildcard *.i)
#
# Rule to create object file (build) directory
#
.PHONY: all install clean distclean
.PRECIOUS: ${BLDDIR}/.tree
%/.tree:
@$(ECHO) 'Creating build directory $(dir $@)'
@$(MKDIR) $(dir $@)
@$(ECHO) "Build Directory for ${LOCALDIR} Created" > $@
# Rule allowing build through CPP only, creates .E file from .c file.
%.E: %.c
$Q${CC} -E ${CFLAGS} $< | sed -e '/^ *$$/d' -e p -e d > $@
# Rule allowing build through source only, creates .s file from .c file.
%.s: %.c
$Q${CC} -S ${CFLAGS} $<
#
# Default Build rules for .c --> .o, leaving the binary in BLDDIR/X.o,
# even if file not built from directory of source.
#
ifeq ($(FAST),1)
${BLDDIR}/%.o: %.c
else
ifdef GENERATE_C_FILES
${BLDDIR}/%.o: %.c
else
${BLDDIR}/%.o: %.c
endif
endif
ifdef QUIET
@${ECHO} Compiling ${LOCALDIR}/$<
endif
ifdef LOCAL_D_FILE
$Q$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $< --write-user-dependencies
-@/bin/cp $*.d $(BLDDIR)/$*.d
-@/bin/rm -f $*.d
else
$Q$(CC) -MD -MF $(BLDDIR)/$*.d $(CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
endif
@/bin/cp $(BLDDIR)/$*.d $(BLDDIR)/$*.tmp;\
/bin/sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' \
< $(BLDDIR)/$*.d >> $(BLDDIR)/$*.tmp; \
/bin/sed \
-e 's| \([0-9a-zA-Z]\)| '$(SDK)/$(LOCALDIR)'\/\1|g' \
-e 's|^\([0-9a-zA-Z]\)|'$(SDK)/$(LOCALDIR)'/\1|g' \
-e 's| \(\.\.\/\)| '$(SDK)/$(LOCALDIR)'\/\1|g' \
-e 's|'$(SDK)'|'$$\{SDK\}'|g' \
-e 's/\w*\/\.\.\/*//g' \
-e 's/\w*\/\.\.\/*//g' \
-e 's/\w*\/\.\.\/*//g' \
< $(BLDDIR)/$*.tmp > $(BLDDIR)/$*.P; \
/bin/rm -f $(BLDDIR)/$*.d $(BLDDIR)/$*.tmp
${BLDDIR}/%.o: %.s
ifdef QUIET
@${ECHO} Assembling ${LOCALDIR}/$<
endif
$Q${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c $< -o $@
${BLDDIR}/%.o: %.cpp
ifdef QUIET
@${ECHO} Compiling ${LOCALDIR}/$<
endif
$Q${CXX} -c ${CXXFLAGS} -c $< -o $@
${BLDDIR}/%.o: %.cc ${BLDDIR}/.tree
ifdef QUIET
@${ECHO} Compiling ${LOCALDIR}/$<
endif
$Q${CXX} -c ${CXXFLAGS} -c $< -o $@
#
# Cause "make foo.o" in any subdirectory to put the object in the build
# directory instead of the local directory.
#
%.o: ${BLDDIR}/%.o
@
#
# List of directories where built objects live.
# (we are not making the export directories for now)
#
#DIRS = ${BLDDIR} ${EXPDIR}/lib ${EXPDIR}/bin ${EXPDIR}/include
DIRS = ${BLDDIR}
ifeq (C_COMPILER,$(MAKECMDGOALS))
C_COMPILER:
@echo $(CC)
endif
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Make.depend,v 1.14 2011/04/12 15:35:33 yshtil Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
# Default rule to build dependencies. This builds a x.d file for each
# x.c file that describes the dependencies. We then conditionally include
# the generated .d files.
#
#
# If making 'clean', do not include any .d files. If they are included,
# gmake intrinsically tries to remake them all.
#
ifeq (,$(findstring clean,$(MAKECMDGOALS)))
ZFS :=$(wildcard *.zf)
ZFC := $(ZFS:.zf=.c)
ifdef GENERATE_C_FILES
ifndef GEN_INCS
$(error "GEN_INCS was not defined")
endif
ZF_GEN = ${SDK}/tools/zFrameCodeGen.pl
# 1=.zf
define ZFS_RULE
$(1:.zf=Console.c) : $(1:.zf=.c)
@echo updated $$@ from $$?
$(1:.zf=.c) : $(1) $(ZF_GEN)
@$(PERL) $(ZF_GEN) -s -z . -p . -g $1 -t c
@echo generated ${LOCALDIR}/$$@ from $(1)
@mv $$(*F).cx $$@
@if [ -e $$(*F)Console.cx ] ; then \
mv $$(*F)Console.cx $$(*F)Console.c; \
echo Created $$(*F)Console.c ;\
fi
@if [ -e $$(*F)Console.hx ] ; then \
echo Created $(GEN_INCS)/$$(*F)Console.hx ;\
mv $$(*F)Console.hx $(GEN_INCS)/ ; \
fi
@mv $$(*F).hx $(GEN_INCS)/
endef
$(foreach zf,$(ZFS),$(eval $(call ZFS_RULE,$(zf))))
${BLDDIR}/%.P : ${BLDDIR}/.tree %.c
.PHONY: GENFILES
GENFILES: $(ZFC)
$(BOBJS) : $(ZFC)
else
#
# Attempt to build the depend files. If it fails, the depend file is
# removed so that it is not included in later builds.
#
${BLDDIR}/%.P : %.c ${BLDDIR}/.tree
@$(ECHO) Dependencies for ${LOCALDIR}/$<
${BLDDIR}/%.P : %.cc ${BLDDIR}/.tree
@$(ECHO) Dependencies for ${LOCALDIR}/$<
endif
#
# If there are C or C++ files in this directory, include the
# depend files for them.
#
ifeq ($(findstring _COMPILER,$(MAKECMDGOALS))$(findstring variable,$(MAKECMDGOALS)),)
ifneq ($(strip ${LSRCS}),)
ifneq (,$(findstring .o,$(MAKECMDGOALS)))
-include $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.P)) $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.sig))
else
-include $(addprefix ${BLDDIR}/,$(addsuffix .P,$(basename $(LSRCS)))) $(addprefix ${BLDDIR}/,$(addsuffix .sig,$(basename $(LSRCS))))
endif
endif
endif
endif # !CLEANING
clean_d::
ifdef QUIET
@$(ECHO) Cleaning dependencies for ${LOCALDIR}
endif
ifdef GENERATE_C_FILES
$Q$(RM) $(ZFC:%=$(SDK)/$(LOCALDIR)/%) $(ZFC:%.c=$(SDK)/$(LOCALDIR)/%Console.c)
endif
clean:: clean_d
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Make.kernlib,v 1.7 2011/08/21 07:18:42 bhanup Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
# Make rules/targets for handling libraries
.SECONDARY:: ${BOBJS}
targetlibsoname = ${lib}.so.${SHAREDLIBVER}
targetlibrealname = ${targetlibsoname}
targetlibso = ${LIBDIR}/${targetlibrealname}
ifeq ($(TOOLS),Borland)
LIBSUFFIX=lib
${LIBDIR}/%.lib: ${BORLAND_BOBJS}
$(RM) $@
$(FOREACH) -subdir "$(LIBDIR)" \
"tlib $@ $(foreach obj, $(BORLAND_LOBJS), +-$(obj))"
else # !Borland
LIBSUFFIX=a
${LIBDIR}/%.a: ${BOBJS}
ifdef QUIET
@$(ECHO) Building library $(notdir $@)
endif
$Q$(RM) $@
$Q$(AR) ${ARFLAGS} $@ $(sort ${BOBJS})
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
$(CC) -shared -Wl,-soname,${targetlibsoname} -o ${targetlibso} ${BOBJS} -lc
endif # LINUX_MAKE_SHARED_LIB #
endif # !Borland
targetlib = ${LIBDIR}/${lib}.${LIBSUFFIX}
all:: ${BLDDIR}/.tree ${targetlib}
install:: all
clean::
ifdef QUIET
@$(ECHO) Cleaning objects for ${LOCALDIR} and ${lib}
endif
$Q$(RM) ${BOBJS}
$Q$(RM) ${targetlib}
distclean:: clean
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Make.lib,v 1.14 2010/11/18 00:27:38 yshtil Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
# Make rules/targets for handling libraries
.SECONDARY:: ${BOBJS}
BOBJS_FAST = ${BOBJS}
BOBJS_MAKE_CMD =
ifeq ($(FAST),1)
ifneq ($(strip $(BOBJS)),)
BOBJS_FAST =
BOBJS_ARGS = -j9
BOBJS_MAKE_CMD = pwd && make LSRUN=$(SDK)/tools/lsrun.pl $(BOBJS_ARGS) ${BOBJS}
endif
endif
ifeq ($(TOOLS),Borland)
LIBSUFFIX=lib
${LIBDIR}/%.lib: ${BORLAND_BOBJS}
$(RM) $@
$(FOREACH) -subdir "$(LIBDIR)" \
"tlib $@ $(foreach obj, $(BORLAND_LOBJS), +-$(obj))"
else # !Borland
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
LIBSUFFIX=so.${SHAREDLIBVER}
else
LIBSUFFIX=a
endif
targetlib = ${LIBDIR}/${lib}.${LIBSUFFIX}
all:: ${BLDDIR}/.tree ${targetlib}
${LIBDIR}/%.${LIBSUFFIX}: ${BOBJS_FAST}
$(BOBJS_MAKE_CMD)
ifdef QUIET
@$(ECHO) Building library $(notdir $@)
endif
$Q$(RM) $@
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
$(CC) -shared -Wl,-soname,${lib}.${LIBSUFFIX} -o ${targetlib} ${BOBJS} -lc
else
${Q}cd $(dir $(word 1,${BOBJS}));$(AR) ${ARFLAGS} $@ $(sort $(notdir ${BOBJS}))
endif
endif # !Borland
install:: all
clean::
ifdef QUIET
@$(ECHO) Cleaning objects for ${LOCALDIR} and ${lib}
endif
$Q$(RM) ${BOBJS}
$Q$(RM) ${targetlib}
distclean:: clean
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
#
# $Id: Make.linux,v 1.18 2012/03/02 15:09:07 yaronm Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
# Common make targets for Linux user and kernel builds included by top
# level Linux makefiles
#
# Variables referenced:
#
# LINUX_MAKE_FLAGS
# Additional flags passed to Make
#
# LINUX_MAKE_USER
# Defined: user build
# Undefined: kernel build
#
# LINUX_MAKE_DIR
# Common makefile location, if it is not ../common
#
#
export DEST_DIR_SUFFIX :=$(subst $(realpath $(SDK))/systems,,$(realpath $(CURDIR)/$(dir ($(firstword $(MAKEFILE_LIST))))))
ifeq (,$(kernel_version))
kernel_version=2_4
endif
ifndef LINUX_MAKE_SHARED_LIB
LINUX_MAKE_SHARED_LIB=0
endif
ifeq (,$(SHAREDLIBVER))
SHAREDLIBVER=1
endif
ifndef LINUX_MAKE_DIR
ifdef LINUX_MAKE_USER
LINUX_MAKE_DIR := $(SDK)/systems/linux/user/common
else
LINUX_MAKE_DIR := $(SDK)/systems/linux/kernel/common
endif
endif
ifdef LINUX_MAKE_USER
CMD = $(LINUX_MAKE_FLAGS) -C $(LINUX_MAKE_DIR) \
platform=$(platform) bldroot_suffix=/$(platform) kernel_version=$(kernel_version) \
LINUX_MAKE_SHARED_LIB=$(LINUX_MAKE_SHARED_LIB) SHAREDLIBVER=$(SHAREDLIBVER)
else
export LINUX_MAKE_KERNEL := 1
CMD = $(LINUX_MAKE_FLAGS) -C $(LINUX_MAKE_DIR) \
platform=$(platform) kernel_version=$(kernel_version)
endif
ifneq (,$(MIPS_TOOLS_DIR))
CMD += MIPS_TOOLS_DIR=$(MIPS_TOOLS_DIR)
endif
ifneq (,$(MIPS_CROSS_COMPILE))
CMD += MIPS_CROSS_COMPILE=$(MIPS_CROSS_COMPILE)
endif
ifneq (,$(LINUX_INCLUDE))
CMD += LINUX_INCLUDE=$(LINUX_INCLUDE)
endif
# gmake does not understand $(CMD) to be a submake
# options are to +$(CMD) or $(MAKE) $(CMD)
# trying the latter
build:
$(MAKE) $(CMD)
DELIVER clean C_COMPILER CXX_COMPILER variable mod bcm user:
$(MAKE) $(CMD) $@
clean_d: clean
distclean:
$(MAKE) $(CMD) $@
.PHONY: build clean distclean clean_d DELIVER variable mod bcm user
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Make.subdirs,v 1.8 2010/06/22 15:23:57 alai Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
# Make rules/targets for handling subdirectories
.PHONY: ${subdirs}
all:: ${subdirs}
ifdef QUIET
@$(ECHO) Subdirectory build for ${subdirs}
endif
${subdirs}::
$Q$(MAKE) -C $@ kernel_version=$(kernel_version) LINUX_MAKE_SHARED_LIB=${LINUX_MAKE_SHARED_LIB} SHAREDLIBVER=${SHAREDLIBVER}
ifeq "$(HOSTTYPE)" "Windows2000PC"
clean clean_d install distclean::
ifdef QUIET
@$(ECHO) Subdirectory $@ for ${subdirs}
endif
$Q$(FOREACH) "$(subdirs)" "${MAKE} -C ## $@"
else
clean clean_d install distclean::
ifdef QUIET
@$(ECHO) Subdirectory $@ for ${subdirs}
endif
@(for name in $(subdirs); do $(MAKE) -C $$name $@; done)
endif
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Make.tools,v 1.2 2011/09/06 21:30:39 yshtil Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
SYSNAME := $(shell uname -s)
HCC ?=/usr/bin/gcc
SED = /bin/sed
COMPRESS = /usr/bin/compress
PERL = /usr/bin/perl
LN = /bin/ln
HOSTTYPE= i386-linux
#
# Platform Independent
#
MKTOOL = $(PERL) ${SDK}/tools/mktool.pl
RM = $(MKTOOL) -rm
MKDIR = $(MKTOOL) -md
FOREACH = $(MKTOOL) -foreach
CP = $(MKTOOL) -cp
MAKEDEP = $(MKTOOL) -dep
ECHO = $(MKTOOL) -echo
MKBEEP = ${MKTOOL} -beep
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Makefile.linux-gto-2_6,v 1.42 2013/03/23 00:35:18 gururaj Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
# User must select one platform from below.By default WR_LINUX is selected. .
ifeq (,$(BUILD_PLATFORM))
#BUILD_PLATFORM=ELDK
BUILD_PLATFORM=WR_LINUX
endif
# Specify the ELDK version you want to use for building SDK.
ifeq (,$(ELDK_VERSION))
ifeq (ELDK,$(BUILD_PLATFORM))
ELDK_VERSION=4.0
endif
endif
# Specify the KERNEL VERSION you want to use for building SDK.
ifeq (,$(KERN_VER))
ifeq (ELDK,$(BUILD_PLATFORM))
KERN_VER=2.6.21.7
endif
endif
# Specify the Windriver Linux version here.For example '2.0' as shown below.
ifeq (WR_LINUX,$(BUILD_PLATFORM))
ifeq (,$(WRS_LINUX_VERSION))
WRS_LINUX_VERSION=2.0
endif
endif
#glibc_small and glibc_std have their own cross-compilation tools and and path for these tools are different as implemented below. To enable glibc_small build, line given below should be uncommented.
#WRL_GLIBC_SMALL=TRUE
ifeq (2.0,$(WRS_LINUX_VERSION))
ifeq ($(WRL_GLIBC_SMALL),TRUE)
ifeq (,$(CROSS_COMPILE))
CROSS_COMPILE := powerpc-wrs-linux-gnu-ppc_e500v2-glibc_small-
endif
KERNDIR ?=/projects/ntsw-tools/linux/wrslinux_2.0/gto/glibc_small/build/linux-2.6.21-standard
else
ifeq (,$(CROSS_COMPILE))
CROSS_COMPILE := powerpc-wrs-linux-gnu-ppc_e500v2-glibc_std-
endif
KERNDIR ?= /projects/ntsw-tools/linux/wrslinux_2.0/gto/glibc_std/build/linux-2.6.21-standard
endif
export WRL_GLIBC_SMALL
# After this point glibc_std and glibc_small share these flags
WRLINUX_BASE ?=/tools/windriver/linux_ed/2.0_GA/Linux
TOOLCHAIN_EXEC_PREFIX=$(WRLINUX_BASE)/gnu/4.1-wrlinux-2.0/x86-linux2
TOOLCHAIN_BIN_DIR=$(TOOLCHAIN_EXEC_PREFIX)
WIND_LIC_PROXY=$(WRLINUX_BASE)/setup/x86-linux2/bin
WRLINUX_GNU_PATH = $(WRLINUX_BASE)/gnu/4.1-wrlinux-2.0/x86-linux2/bin
override PATH := $(TOOLCHAIN_EXEC_PREFIX):$(KERNDIR)/../../host-cross/bin:$(KERNDIR)/../../host-cross/powerpc-wrs-linux-gnu/bin:$(WRLINUX_GNU_PATH):$(PATH)
export TOOLCHAIN_EXEC_PREFIX TOOLCHAIN_BIN_DIR WIND_LIC_PROXY
endif
ifeq (3.0,$(WRS_LINUX_VERSION))
ifeq ($(WRL_GLIBC_SMALL),TRUE)
ifeq (,$(CROSS_COMPILE))
CROSS_COMPILE := powerpc-wrs-linux-gnu-ppc_e500v2-glibc_small-
endif
KERNDIR ?=/projects/ntsw-tools/linux/wrslinux_3.0/gto/bcm98548xmc_30_glibc_small/build/linux-broadcom_bcm98548xmc-standard-build
KERNDIR_STD ?=/projects/ntsw-tools/linux/wrslinux_3.0/gto/bcm98548xmc_30_glibc_small/build/linux
else
ifeq (,$(CROSS_COMPILE))
CROSS_COMPILE := powerpc-wrs-linux-gnu-ppc_e500v2-glibc_std-
endif
KERNDIR ?=/projects/ntsw-tools/linux/wrslinux_3.0/gto/bcm98548xmc_30_glibc_std_debug/build/linux-broadcom_bcm98548xmc-standard-build
KERNDIR_STD ?=/projects/ntsw-tools/linux/wrslinux_3.0/gto/bcm98548xmc_30_glibc_std_debug/build/linux
endif
export WRL_GLIBC_SMALL
# After this point glibc_std and glibc_small share these flags
WRLINUX_BASE ?=/tools/windriver/linux_ed/3.0/Linux
TOOLCHAIN_EXEC_PREFIX=$(WRLINUX_BASE)/wrlinux-3.0/layers/wrll-toolchain-4.3-85/powerpc/toolchain/x86-linux2
TOOLCHAIN_BIN_DIR=$(TOOLCHAIN_EXEC_PREFIX)
WIND_LIC_PROXY=$(WRLINUX_BASE)/setup/x86-linux2/bin
WRLINUX_GNU_PATH = $(WRLINUX_BASE)/wrlinux-3.0/layers/wrll-toolchain-4.3-85/powerpc/toolchain/x86-linux2/bin
override PATH := $(TOOLCHAIN_EXEC_PREFIX):$(KERNDIR_STD)/../../host-cross/bin:$(KERNDIR_STD)/../../host-cross/powerpc-wrs-linux-gnu/bin:$(WRLINUX_GNU_PATH):$(PATH)
export TOOLCHAIN_EXEC_PREFIX TOOLCHAIN_BIN_DIR WIND_LIC_PROXY
LINUX_INCLUDE_STD := $(KERNDIR_STD)/include
endif
ifeq (ELDK,$(BUILD_PLATFORM))
ifeq (2.6.21.7, $(KERN_VER))
ifeq (,$(CROSS_COMPILE))
CROSS_COMPILE := ppc_85xx-
endif
ifeq (4.0, $(ELDK_VERSION))
override PATH := /tools/eldk/4.0/usr/bin:$(PATH)
else
override PATH := /tools/eldk/4.1/usr/bin:$(PATH)
endif
KERNDIR ?= /projects/ntsw-tools/linux/eldk/gto_eldk/linux-2.6.21.7
endif
endif
ifeq (ELDK,$(BUILD_PLATFORM))
ifeq (2.6.24.4, $(KERN_VER))
ifeq (,$(CROSS_COMPILE))
CROSS_COMPILE := ppc_85xx-
endif
ifeq (4.0, $(ELDK_VERSION))
override PATH := /tools/eldk/4.0/usr/bin:$(PATH)
else
override PATH := /tools/eldk/4.1/usr/bin:$(PATH)
endif
KERNDIR ?= /projects/ntsw-tools/linux/eldk/gto_eldk/linux-2.6.24.4
endif
endif
ifeq (ELDK,$(BUILD_PLATFORM))
ifeq (2.6.25, $(KERN_VER))
ifeq (,$(CROSS_COMPILE))
CROSS_COMPILE := ppc_85xx-
endif
ifeq (4.0, $(ELDK_VERSION))
override PATH := /tools/eldk/4.0/usr/bin:$(PATH)
else
override PATH := /tools/eldk/4.1/usr/bin:$(PATH)
endif
KERNDIR ?= /projects/ntsw-tools/linux/eldk/gto_eldk/linux-2.6.25
endif
endif
# Default Linux include directory
ifeq (,$(LINUX_INCLUDE))
LINUX_INCLUDE := $(KERNDIR)/include
endif
CFGFLAGS += -DSYS_BE_PIO=1 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=1
ENDIAN = BE_HOST=1
CFGFLAGS += -D$(ENDIAN)
CFGFLAGS += -DBCM_PLATFORM_STRING=\"GTO_MPC8548\"
CFGFLAGS += -DSAL_BDE_DMA_MEM_DEFAULT=32
# Extra variables.
EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
ARCH = powerpc
KBUILD_VERBOSE = 1
export ARCH KBUILD_VERBOSE
# From linux/arch/ppc/Makefile
comma = ,
basetarget = $(basename $(notdir $@))
modname = $(basetarget)
name-fix = $(subst $(comma),_,$(subst -,_,$1))
basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
modname_flags = $(if $(filter 1,$(words $(modname))),\
-D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
ifeq (,$(KFLAG_INCLD))
ifeq (4.0,$(ELDK_VERSION))
ifeq (ELDK,$(BUILD_PLATFORM))
KFLAG_INCLD = /tools/eldk/4.0/usr/lib/gcc/powerpc-linux/4.0.0/include
endif
endif
ifeq (4.1,$(ELDK_VERSION))
ifeq (ELDK,$(BUILD_PLATFORM))
KFLAG_INCLD = /tools/eldk/4.1/usr/lib/gcc/powerpc-linux/4.0.0/include
endif
endif
ifeq (2.0,$(WRS_LINUX_VERSION))
KFLAG_INCLD = $(WRLINUX_GNU_PATH)/../lib/gcc/powerpc-wrs-linux-gnu/4.1.2/include
endif
ifeq (3.0,$(WRS_LINUX_VERSION))
KFLAG_INCLD = $(WRLINUX_GNU_PATH)/../lib/gcc/powerpc-wrs-linux-gnu/4.3.2/include
endif
endif
ifdef BROADCOM_SVK
ifdef BCM_BME3200_B0
PLX_PCI2LBUS=1
endif
ifdef BCM_BM9600_B0
PLX_PCI2LBUS=1
endif
ifeq ($PLX_PCI2LBUS, 1)
CFLAGS += -DBCM_PLX9656_LOCAL_BUS -DBDE_LINUX_NON_INTERRUPTIBLE
endif
endif
ifdef DPP_CHIPS
CFLAGS += -DDUNE_BCM -D__DUNE_GTO_BCM_CPU__ -D__DUNE_LINUX_BCM_CPU_PCIE__ -D__DUNE_LINUX_BCM_CPU_PCP_DMA__
CFGFLAGS += -DSOC_CM_FUNCTION
endif
ifdef DFE_CHIPS
CFLAGS += -DDUNE_BCM -D__DUNE_GTO_BCM_CPU__ -D__DUNE_LINUX_BCM_CPU_PCIE__
CFGFLAGS += -DSOC_CM_FUNCTION
endif
ifdef SHADOW_PLX
CFLAGS += -DBCM_PLX9656_LOCAL_BUS -DBDE_LINUX_NON_INTERRUPTIBLE -DSHADOW_SVK
endif
ifeq (,$(KFLAGS))
KFLAGS := -D__KERNEL__ -m32 -nostdinc -isystem $(KFLAG_INCLD) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/version.h -include $(LINUX_INCLUDE)/generated/autoconf.h -I$(KERNDIR)/arch/powerpc -I$(KERNDIR)/arch/powerpc -I$(KERNDIR)/arch/powerpc/include -I$(KERNDIR)/include/asm-powerpc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -msoft-float -pipe -ffixed-r2 -mmultiple -mno-altivec -funit-at-a-time -Wa,-me500 -fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign
endif
#Wind river Linux 3.0 needs addtional flags
ifeq (3.0,$(WRS_LINUX_VERSION))
# Use MSI interrupts if kernel is compiled with MSI support.
#CFLAGS += -DBDE_LINUX_USE_MSI_INTERRUPT
KFLAGS += -I$(LINUX_INCLUDE_STD) -I$(KERNDIR_STD)/arch/powerpc -I$(KERNDIR_STD)/arch/powerpc/include -I$(KERNDIR_STD)/include.asm-powerpc -mno-spe
endif
ifneq ($(targetplat),user)
include ${SDK}/make/Makefile.linux-kernel-2_6
endif
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Makefile.linux-kernel,v 1.27 2012/06/25 20:23:24 assafz Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
# Configuration Flags
# Filter out features that cannot or should not be supported in kernel mode
_FEATURE_EXCLUDE_LIST += EDITLINE TCL OOB_RCPU CINT APIMODE DUNE_UI C_UNIT
FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST))
# Tools
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
LD = $(CROSS_COMPILE)ld
AR = $(CROSS_COMPILE)ar
ARFLAGS = -rc
STRIP = $(CROSS_COMPILE)strip
RANLIB = $(CROSS_COMPILE)ranlib
OBJCOPY = $(CROSS_COMPILE)objcopy
# Handle differences between gcc 2.x and gcc 3.x
gcc-tune-flag = $(shell if ${CC} -dumpspecs | grep mcpu >/dev/null; then echo cpu; else echo tune; fi)
# Configuration Variables
# OSType Defines: This defines the type of RTOS or microkernel which you
# are compiling the SAL (and its associated driver) for. New platforms
# can be created by porting the routines (system.c) to your platform and
# adding the define in this Makefile.
OSTYPE = LINUX
#
# ORIGIN is used to Optionally select different CFLAGS. It is used to import
# source from other vendors. If SOURCE=Broadcom, then the BCM_ flags are added
# to those passed to the compiler. If SOURCE != Broadcom, BCM_ flags are NOT
# added.
#
# Default specifies Broadcom
#
ifndef ORIGIN
ORIGIN = Broadcom
endif
#
# STD_{C|CPP|CXX}FLAGS - Standard flags used by ALL compilations
# BCM_{C|CPP|CXX}FLAGS - Flags used for Broadcom source files
# OPT_{C|CPP|CXX}FLAGS - Defined in local make files BEFORE inclusion of
# this Makefile, to define local "Extra" flags.
#
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
-I$(SDK)/systems/bde/linux/include \
-I$(LINUX_INCLUDE)
CFGFLAGS += -DNO_FILEIO -DNO_CTRL_C -DNO_MEMTUNE
CFGFLAGS += -D$(OSTYPE)
# No user sal for the linux kernel
# NO_SAL_APPL=1
STD_CFLAGS = $(KFLAGS) $(CFGFLAGS)
STD_CPPFLAGS = ${STD_CFLAGS}
STD_CXXFLAGS = ${STD_CFLAGS}
BCM_CFLAGS = -Wall -Werror
BCM_CPPFLAGS = ${BCM_CFLAGS}
BCM_CXXFLAGS = ${BCM_CFLAGS}
ifeq (${ORIGIN}, Broadcom)
CFLAGS += ${STD_CFLAGS} ${BCM_CFLAGS} ${OPT_CFLAGS}
CPPFLAGS += ${STD_CPPFLAGS} ${BCM_CPPFLAGS} ${OPT_CPPFLAGS}
CXXFLAGS += ${STD_CXXFLAGS} ${BCM_CXXFLAGS} ${OPT_CXXFLAGS}
else
CFLAGS += ${STD_CFLAGS} ${OPT_CFLAGS}
CPPFLAGS += ${STD_CPPFLAGS} ${OPT_CPPFLAGS}
CXXFLAGS += ${STD_CXXFLAGS} ${OPT_CXXFLAGS}
endif
#
# Ignore pedantic flag for kernel modules
#
ifdef DEBUG_PEDANTIC
DEBUG_PEDANTIC = FALSE
endif
#
# DEPEND is used as a command to generate the list of dependencies.
# The format of the output must be
# "file.o : file.c a/b/c.h d/e/f.h ...",
# if it is on multiple lines, each line must end in a backslash.
# The output MUST be on standard out.
#
DEPEND = ${CC} -M $(CFLAGS) $<
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Makefile.linux-kernel-2_6,v 1.40 2012/10/22 01:56:23 alai Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
# Configuration Flags
# Filter out features that cannot or should not be supported in kernel mode
_FEATURE_EXCLUDE_LIST += EDITLINE TCL OOB_RCPU CINT APIMODE DUNE_UI C_UNIT
FEATURE_EXCLUDE_LIST = $(sort $(_FEATURE_EXCLUDE_LIST))
# Tools
# Conditionally Replaces DEFAULT var
ifeq ($(origin CC),default)
CC = $(LSRUN) $(CROSS_COMPILE)gcc
endif
ifeq ($(origin CXX),default)
CXX = $(CROSS_COMPILE)g++
endif
ifeq ($(origin LD),default)
LD = $(CROSS_COMPILE)ld
endif
ifeq ($(origin AR),default)
AR = $(CROSS_COMPILE)ar
endif
ifeq ($(origin AS),default)
AS = $(CROSS_COMPILE)as
endif
ifeq ($(origin ARFLAGS),default)
ARFLAGS = -rc
endif
STRIP = $(CROSS_COMPILE)strip
RANLIB = $(CROSS_COMPILE)ranlib
OBJCOPY = $(CROSS_COMPILE)objcopy
NM = $(CROSS_COMPILE)nm
# Handle differences between gcc 2.x and gcc 3.x
gcc-tune-flag = $(shell if ${CC} -dumpspecs | grep mcpu >/dev/null; then echo cpu; else echo tune; fi)
# Configuration Variables
# OSType Defines: This defines the type of RTOS or microkernel which you
# are compiling the SAL (and its associated driver) for. New platforms
# can be created by porting the routines (system.c) to your platform and
# adding the define in this Makefile.
OSTYPE = LINUX
#
# ORIGIN is used to Optionally select different CFLAGS. It is used to import
# source from other vendors. If SOURCE=Broadcom, then the BCM_ flags are added
# to those passed to the compiler. If SOURCE != Broadcom, BCM_ flags are NOT
# added.
#
# Default specifies Broadcom
#
ifndef ORIGIN
ORIGIN = Broadcom
endif
#
# STD_{C|CPP|CXX}FLAGS - Standard flags used by ALL compilations
# BCM_{C|CPP|CXX}FLAGS - Flags used for Broadcom source files
# OPT_{C|CPP|CXX}FLAGS - Defined in local make files BEFORE inclusion of
# this Makefile, to define local "Extra" flags.
#
ifdef IPROC_BUILD
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
-I$(SDK)/systems/bde/linux/include \
-I$(LINUX_INCLUDE) \
-I$(KERNDIR)/arch/$(ARCH)
else
CFGFLAGS += -I$(SDK)/systems/linux/kernel/modules/include \
-I$(SDK)/systems/bde/linux/include \
-I$(LINUX_INCLUDE) \
-I$(LINUX_INCLUDE)/asm/gcc \
-I$(LINUX_INCLUDE)/asm/mach-generic \
-I$(KERNDIR)/arch/$(ARCH)
endif
CFGFLAGS += -DNO_FILEIO -DNO_CTRL_C -DNO_MEMTUNE
CFGFLAGS += -D$(OSTYPE)
# No user sal for the linux kernel
# NO_SAL_APPL=1
STD_CFLAGS = $(KFLAGS) $(CFGFLAGS)
STD_CPPFLAGS = ${STD_CFLAGS}
STD_CXXFLAGS = ${STD_CFLAGS}
ifndef BCM_CFLAGS
BCM_CFLAGS = -Wall -Werror
endif
BCM_CPPFLAGS = ${BCM_CFLAGS}
BCM_CXXFLAGS = ${BCM_CFLAGS}
ifeq (${ORIGIN}, Broadcom)
CFLAGS += ${STD_CFLAGS} ${BCM_CFLAGS} ${OPT_CFLAGS}
CPPFLAGS += ${STD_CPPFLAGS} ${BCM_CPPFLAGS} ${OPT_CPPFLAGS}
CXXFLAGS += ${STD_CXXFLAGS} ${BCM_CXXFLAGS} ${OPT_CXXFLAGS}
else
CFLAGS += ${STD_CFLAGS} ${OPT_CFLAGS}
CPPFLAGS += ${STD_CPPFLAGS} ${OPT_CPPFLAGS}
CXXFLAGS += ${STD_CXXFLAGS} ${OPT_CXXFLAGS}
endif
#
# Ignore pedantic flag for kernel modules
#
ifdef DEBUG_PEDANTIC
DEBUG_PEDANTIC = FALSE
endif
#
# DEPEND is used as a command to generate the list of dependencies.
# The format of the output must be
# "file.o : file.c a/b/c.h d/e/f.h ...",
# if it is on multiple lines, each line must end in a backslash.
# The output MUST be on standard out.
#
DEPEND = ${CC} -M $(CFLAGS) $<
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Makefile.linux-kmodule-3_6,v 1.2 2013/01/10 01:00:49 bpeela Exp $
# $Copyright: (c) 2006 Broadcom Corp.
# All Rights Reserved.$
# Due to the extensive use of driver libraries, the SDK usually builds
# kernel modules from a precompiled object. To avoid various warnings
# and conflicts, the pre-compiled object must be named differently
# from the target module, and the object file itself should be
# appended with "_shipped".
# If a module exports any symbols, then the exporting source file must
# be compiled within the kernel source tree for correct generation of
# module symbol versions. The symbol source file should be passed to
# this Makefile via the MODULE_SYM variable.
MODULE := $(MOD_NAME).o
KMODULE := $(MOD_NAME).ko
PRE_COMPILED_OBJ := obj_$(MOD_NAME).o
obj-m := $(MODULE)
$(MOD_NAME)-y := $(MODULE_SYM) $(PRE_COMPILED_OBJ)
ifeq (,$(CROSS_COMPILE))
export CROSS_COMPILE
endif
SAVE_CFLAGS := ${CFLAGS}
include $(SDK)/make/Make.config
PWD := $(shell pwd)
ifneq ($(ARCH),)
# ELDK does not seem to `automatically' define ARCH where other gccs may
A := ARCH=$(ARCH)
export ARCH
endif
# Standard SDK include path for building source files that export
# kernel symbols.
override EXTRA_CFLAGS = -I${SDK}/include -I${SDK}/systems/linux/kernel/modules/include -I${SDK}/systems/bde/linux/include
# The precopiled object needs a dummy command file to avoid warnings
# from the Kbuild scripts (modpost stage).
# Kernels before 2.6.17 do not support external module symbols files,
# so we create a dummy to prevent build failures.
$(KMODULE):
rm -f *.o *.ko .*.cmd
rm -fr .tmp_versions
ln -s $(LIBDIR)/$(MODULE) $(PRE_COMPILED_OBJ)_shipped
echo "suppress warning" > .$(PRE_COMPILED_OBJ).cmd
$(MAKE) -C $(KERNDIR) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules
if [ ! -f Module.symvers ]; then echo "old kernel (pre-2.6.17)" > Module.symvers; fi
cp -f $(KMODULE) $(LIBDIR)
rm -f $(PRE_COMPILED_OBJ)_shipped
EXTRA_CFLAGS = $(CFLAGS)
CFLAGS := ${SAVE_CFLAGS}
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Makefile.linux-x86-common-2_6,v 1.13 2011/08/23 02:32:54 mlarsen Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
CFGFLAGS += -DSYS_BE_PIO=0 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=0
ENDIAN = LE_HOST=1
CFGFLAGS += -D$(ENDIAN)
CFGFLAGS += -DBCM_PLATFORM_STRING=\"X86\"
CFGFLAGS += -DSAL_BDE_DMA_MEM_DEFAULT=16
# Extra variables.
EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
comma = ,
basetarget = $(basename $(notdir $@))
modname = $(basetarget)
name-fix = $(subst $(comma),_,$(subst -,_,$1))
basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
modname_flags = $(if $(filter 1,$(words $(modname))),\
-D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
ifneq ($(targetplat),user)
# By default we exclude -Werror from x86 kernel builds
BCM_CFLAGS = -Wall
include ${SDK}/make/Makefile.linux-kernel-2_6
endif
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Makefile.linux-x86-generic-common-2_6,v 1.2 2011/08/23 01:35:32 mlarsen Exp $
# $Copyright: (c) 2008 Broadcom Corp.
# All Rights Reserved.$
# Default kernel source directory
ifeq (,$(KERNDIR))
KERNDIR := /lib/modules/$(shell uname -r)/build
export KERNDIR
endif
# Default architecture
ifeq (,$(ARCH))
ARCH = $(shell uname -p)
ifneq (x86_64,$(ARCH))
ARCH = i386
endif
endif
# Noisy kernel build
KBUILD_VERBOSE = 1
export ARCH KBUILD_VERBOSE KERNDIR
# Default Linux include directory
ifeq (,$(LINUX_INCLUDE))
LINUX_INCLUDE := $(KERNDIR)/include
endif
# autoconf.h was moved in later kernels
AUTOCONF = $(KERNDIR)/include/generated/autoconf.h
ifeq (,$(shell ls $(AUTOCONF) 2>/dev/null))
AUTOCONF = $(KERNDIR)/include/linux/autoconf.h
endif
# gcc system include path
SYSINC = $(shell gcc -print-search-dirs | grep install | cut -c 10-)include
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# $Id: Makefile.linux-x86-smp_generic_64-2_6,v 1.5 2012/02/21 21:36:45 miyarn Exp $
# $Copyright: (c) 2008 Broadcom Corp.
# All Rights Reserved.$
CFGFLAGS += -DLONGS_ARE_64BITS
CFGFLAGS += -DPTRS_ARE_64BITS
CFGFLAGS += -DSAL_SPL_LOCK_ON_IRQ
include ${SDK}/make/Makefile.linux-x86-generic-common-2_6
ifeq (,$(KFLAGS))
KFLAGS := -nostdinc -isystem $(SYSINC) -I$(KERNDIR)/include -I$(KERNDIR)/arch/x86/include -include $(AUTOCONF) -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign
endif
KFLAGS += -I$(LINUX_INCLUDE)/uapi -I$(LINUX_INCLUDE)/generated/uapi -I$(KERNDIR)/arch/x86/include/generated -I$(KERNDIR)/arch/x86/include/uapi -I$(KERNDIR)/arch/x86/include/generated/uapi
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
KFLAGS += -fPIC -mcmodel=small
else
KFLAGS += -mcmodel=kernel
endif
include ${SDK}/make/Makefile.linux-x86-common-2_6
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/***********************************************************************
*
* $Id: linux-bde.h,v 1.24 2013/01/30 16:52:27 gili Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*
* Linux Broadcom Device Enumerators
*
*
* There are two Linux BDEs:
*
* 1. Linux Kernel BDE
*
* This is a kernel module implementing a BDE
* for the driver running as part of the kernel.
*
* It manages the devices through the linux PCI interfaces,
* and manages a chunk of contiguous, boot-time allocated
* DMA memory. This is all that is needed if the BCM driver
* is run as part of the kernel (in another module).
*
* 2. Linux User BDE
*
* This is a kernel module and userland library which implement
* a complete BDE for applications running in userland.
*
* The kernel module relies upon the real kernel bde,
* and allows a user space application (through the user library)
* to talk directly to the devices. It also virtualized the device
* interrupts, so the entire driver can be run as a userspace
* application.
*
* While this causes a significant degradation in performance,
* because the system runs as a user application, the development
* and debugging process is about a gillion times easier.
* After the core logic is debugged, it can be retargeted using
* only the kernel bde and run in the kernel.
*
*
**********************************************************************/
#ifndef __LINUX_BDE_H__
#define __LINUX_BDE_H__
#include <sal/types.h>
#include <ibde.h>
/*
* Device Major Numbers
*
* The kernel and user bdes need unique major numbers
* on systems that do not use devfs.
*
* They are defined here, along with the module names,
* to document them if you need to mknod them (or open) them,
* and to keep them unique.
*
*/
#include <linux/version.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
#define LINUX_BDE_DMA_DEVICE_SUPPORT
#endif
#define LINUX_KERNEL_BDE_NAME "linux-kernel-bde"
#define LINUX_KERNEL_BDE_MAJOR 127
#define LINUX_USER_BDE_NAME "linux-user-bde"
#define LINUX_USER_BDE_MAJOR 126
/* Max devices */
/* 16 switch chips + 2 out-of-band Ethernet + 2 CPUs */
#define LINUX_BDE_MAX_SWITCH_DEVICES 16
#define LINUX_BDE_MAX_ETHER_DEVICES 2
#define LINUX_BDE_MAX_CPU_DEVICES 2
#define LINUX_BDE_MAX_DEVICES (LINUX_BDE_MAX_SWITCH_DEVICES + \
LINUX_BDE_MAX_ETHER_DEVICES + \
LINUX_BDE_MAX_CPU_DEVICES)
/*
* PCI devices will be initialized by the Linux Kernel,
* regardless of architecture.
*
* You need only provide bus endian settings.
*/
typedef struct linux_bde_bus_s {
int be_pio;
int be_packet;
int be_other;
} linux_bde_bus_t;
/* Device state used for PCI hot swap case. */
/*
* BDE_DEV_STATE_NORMAL : A device is probed normally. Or when the device
* resource has been updated after "CHANGED", the state will move back to
* "NORMAL".
*/
#define BDE_DEV_STATE_NORMAL (0)
/*
* BDE_DEV_STATE_REMOVED : A previous probed device was removed.
* We will avoid any device access while the device is in this state.
* The state will be moved to "CHANGED" if the device is re-inserted
* and re-probed.
*/
#define BDE_DEV_STATE_REMOVED (1)
/*
* BDE_DEV_STATE_CHANGED : The device is re-probed after having been removed.
* The resouces assigned to the device might have been changed after
* re-probing, so we need to re-initialize our resource database accordingly.
* The state will change to "NORMAL" when the resource have been updated.
*/
#define BDE_DEV_STATE_CHANGED (2)
extern int linux_bde_create(linux_bde_bus_t* bus, ibde_t** bde);
extern int linux_bde_destroy(ibde_t* bde);
#ifdef BCM_INSTANCE_SUPPORT
extern int linux_bde_instance_attach(unsigned int dev_mask,unsigned int dma_size);
#endif
#ifdef __KERNEL__
/*
* Backdoors provided by the kernel bde
*
*/
/*
* The user bde needs to get some physical addresses for
* the userland code to mmap.
*/
extern int lkbde_get_dma_info(uint32 *pbase, uint32 *size);
extern uint32 lkbde_get_dev_phys(int d);
extern uint32 lkbde_get_dev_phys_hi(int d);
/*
* Virtual device address needed by kernel space
* interrupt handler.
*/
extern void *lkbde_get_dev_virt(int d);
/*
* The user bde needs to get some physical addresses for
* the userland code to mmap. The following functions
* supports multiple resources for a single device.
*/
extern int lkbde_get_dev_resource(int d, int rsrc, uint32 *flags,
uint32 *phys_lo, uint32 *phys_hi);
/*
* Backdoor to retrieve OS device structure to be used for
* DMA operations.
*/
extern void *lkbde_get_dma_dev(int d);
/*
* Backdoor to retrieve original hardware/OS device.
*/
extern void *lkbde_get_hw_dev(int d);
/*
* Retrive the device state from Kernel BDE.
* Used for KNET and User BDE for pci hot swap case.
*/
extern int lkbde_dev_state_get(int d, uint32 *state);
extern int lkbde_dev_state_set(int d, uint32 state);
/*
* Retrive the mapping between emulated HW device and instance id
*/
extern int lkbde_dev_instid_get(int d, uint32 *instid);
extern int lkbde_dev_instid_set(int d, uint32 instid);
/*
* Functions that allow an interrupt handler in user mode to
* coexist with interrupt handler in kernel module.
*/
extern int lkbde_irq_mask_set(int d, uint32 addr, uint32 mask, uint32 fmask);
extern int lkbde_irq_mask_get(int d, uint32 *mask, uint32 *fmask);
#if (defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT))
extern int lkbde_cpu_write(int d, uint32 addr, uint32 *buf);
extern int lkbde_cpu_read(int d, uint32 addr, uint32 *buf);
extern int lkbde_cpu_pci_register(int d);
#endif
/*
* This flag must be OR'ed onto the device number when calling
* interrupt_connect/disconnect and irq_mask_set functions from
* a secondary device driver.
*/
#define LKBDE_ISR2_DEV 0x8000
#if defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT)
#include <linux/version.h>
#if defined(__DUNE_LINUX_BCM_CPU_PCIE__) && LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
#ifndef _SIMPLE_MEMORY_ALLOCATION_
#define _SIMPLE_MEMORY_ALLOCATION_ 1
#endif
#ifndef USE_LINUX_BDE_MMAP
#define USE_LINUX_BDE_MMAP 1
#endif
#endif
#endif
#if defined(IPROC_CMICD) && defined(CONFIG_CMA)
#ifndef _SIMPLE_MEMORY_ALLOCATION_
#define _SIMPLE_MEMORY_ALLOCATION_ 1
#endif
#endif
/* Don't use _SIMPLE_MEMORY_ALLOCATION_ method for newer kernel than 3.10.0 */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
#ifndef _SIMPLE_MEMORY_ALLOCATION_
#define _SIMPLE_MEMORY_ALLOCATION_ 0
#endif
#endif
/* Allocation via dma_alloc_coherent is turned off by default */
#ifndef _SIMPLE_MEMORY_ALLOCATION_
#define _SIMPLE_MEMORY_ALLOCATION_ 9 /* compile in the allocation method, but do not use it by default */
#endif
/* By default we use our private mmap only if /dev/mem mmap has restrictions */
#ifndef USE_LINUX_BDE_MMAP
#ifdef CONFIG_STRICT_DEVMEM
#define USE_LINUX_BDE_MMAP 1
#else
#define USE_LINUX_BDE_MMAP 0
#endif
#endif
#endif /* __KERNEL__ */
#endif /* __LINUX_BDE_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: mpool.h,v 1.2 2005/01/17 19:53:06 csm Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#ifndef __MPOOL_H__
#define __MPOOL_H__
struct mpool_mem_s;
typedef struct mpool_mem_s* mpool_handle_t;
extern int mpool_init(void);
extern mpool_handle_t mpool_create(void* base_address, int size);
extern void* mpool_alloc(mpool_handle_t pool, int size);
extern void mpool_free(mpool_handle_t pool, void* ptr);
extern int mpool_destroy(mpool_handle_t pool);
extern int mpool_usage(mpool_handle_t pool);
#endif /* __MPOOL_H__ */
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# -*- Makefile -*-
# $Id: Makefile,v 1.18 2013/01/10 01:00:43 bpeela Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
# Makefile for Linux kernel BDE
#
LOCALDIR = systems/bde/linux/kernel
# Make sure we build for the kernel if this is a user-mode build
ifneq ($(platform), )
override-target=linux-$(platform)
endif
include $(SDK)/make/Make.config
LIBS = $(LIBDIR)/libkern.a
BDE = linux-kernel-bde.o
ifdef ROBO_CHIPS
CFLAGS += -I$(ET_ROBO) -I${SDK}/include/shared/et
ET_ROBO = ${SDK}/systems/drv/et
endif
# need to add vpath sources
VPATH = ../shared $(ET_ROBO)
# Add the srcs to be found by vpath
LSRCS += mpool.c
ifdef ROBO_CHIPS
platformsplt = $(subst -, , ${platform}) # change hyphens to spaces
platformbase = $(word 1,${platformsplt})
ifeq ($(platformbase), keystone)
LSRCS += etc_robo_spi.c aiutils.c
else
ifeq ($(platformbase), keystone_le)
LSRCS += etc_robo_spi.c aiutils.c
else
ifeq ($(platformbase), iproc)
LSRCS += robo_srab.c aiutils.c
endif
endif
endif # platformbase
endif # ROBO_CHIPS
# Add shared BDE sources
VPATH += ../../shared
LSRCS += shbde_pci.c shbde_iproc.c shbde_mdio.c
CFLAGS += -I../../shared/include
LHDRS += mpool.h
LOBJS = $(addsuffix .o, $(basename $(LSRCS)))
BOBJS = $(addprefix $(BLDDIR)/,$(LOBJS))
ifneq ($(kernel_version),2_4)
KERNEL_MODULE_DIR = kernel_module
THIS_MOD_NAME := linux-kernel-bde
MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o
KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko
build: kernel_libs $(MODULE) $(KMODULE)
else
MODULE = $(LIBDIR)/linux-kernel-bde.o
build: kernel_libs $(MODULE)
endif
$(MODULE): $(BLDDIR)/.tree kernel_libs $(BOBJS)
mkdir -p $(@D)
$(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@
ifneq ($(kernel_version),2_4)
$(KMODULE): $(MODULE)
rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR)
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
endif
kernel_libs:
$(MAKE) -C $(SDK)/systems/linux/kernel/modules/shared
include $(SDK)/make/Make.depend
# Make.depend is before clean:: so that Make.depend's clean:: runs first.
clean::
$(MAKE) -C $(SDK)/systems/linux/kernel/modules/shared $@
$(RM) $(BOBJS) $(MODULE)
$(RM) $(BLDDIR)/$(KERNEL_MODULE_DIR)
distclean::
ifneq ($(kernel_version),2_4)
.PHONY: build kernel_libs
endif
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: $
* $Copyright: (c) 2014 Broadcom Corp.
* All Rights Reserved.$
*
*/
#include <gmodule.h>
#include <shbde.h>
#include <shbde_iproc.h>
#include "linux_shbde.h"
/* Hardware abstractions for shared BDE functions */
static unsigned short
linux_pcic16_read(void *pci_dev, unsigned int addr)
{
u16 data = 0;
pci_read_config_word((struct pci_dev *)pci_dev, addr, &data);
return data;
}
static void
linux_pcic16_write(void *pci_dev, unsigned int addr, unsigned short data)
{
pci_write_config_word((struct pci_dev *)pci_dev, addr, (u16)data);
}
static unsigned int
linux_pcic32_read(void *pci_dev, unsigned int addr)
{
u32 data = 0;
pci_read_config_dword((struct pci_dev *)pci_dev, addr, &data);
return data;
}
static void
linux_pcic32_write(void *pci_dev, unsigned int addr, unsigned int data)
{
pci_write_config_dword((struct pci_dev *)pci_dev, addr, (u32)data);
}
static unsigned int
linux_io32_read(void *addr)
{
return *((volatile u32 *)addr);
}
static void
linux_io32_write(void *addr, unsigned int data)
{
*((volatile u32 *)addr) = data;
}
static void
linux_usleep(int usec)
{
udelay(usec);
}
/* To get the PCI parent device under linux, from only the device pointer */
static void *
linux_pci_parent_device_get(void *pci_dev)
{
return (void *)(((struct pci_dev *)pci_dev)->bus->self);
}
/*
* Function:
* linux_shbde_hal_init
* Purpose:
* Initialize hardware abstraction module for Linux kernel.
* Parameters:
* shbde - pointer to uninitialized hardware abstraction module
* log_func - optional log output function
* Returns:
* Always 0
*/
int
linux_shbde_hal_init(shbde_hal_t *shbde, shbde_log_func_t log_func)
{
memset(shbde, 0, sizeof(*shbde));
shbde->log_func = log_func;
shbde->pcic16_read = linux_pcic16_read;
shbde->pcic16_write = linux_pcic16_write;
shbde->pcic32_read = linux_pcic32_read;
shbde->pcic32_write = linux_pcic32_write;
shbde->io32_read = linux_io32_read;
shbde->io32_write = linux_io32_write;
shbde->usleep = linux_usleep;
shbde->pci_parent_device_get = linux_pci_parent_device_get;
return 0;
}
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: $
* $Copyright: (c) 2014 Broadcom Corp.
* All Rights Reserved.$
*
*/
#ifndef __LINUX_SHBDE_H__
#define __LINUX_SHBDE_H__
#include <shbde.h>
#include <shbde_pci.h>
#include <shbde_iproc.h>
extern int
linux_shbde_hal_init(shbde_hal_t *shbde, shbde_log_func_t log_func);
#endif /* __LINUX_SHBDE_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: mpool.c,v 1.18 2012/03/02 15:53:32 yaronm Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#include <mpool.h>
#ifdef __KERNEL__
/*
* Abstractions used when compiling for Linux kernel mode.
*/
#include <lkm.h>
/*
* We cannot use the linux kernel SAL for MALLOC/FREE because
* the current implementation of sal_alloc() allocates memory
* out of an mpool created by this module...
*/
#define MALLOC(x) kmalloc(x, GFP_ATOMIC)
#define FREE(x) kfree(x)
static spinlock_t _mpool_lock;
#define MPOOL_LOCK_INIT() spin_lock_init(&_mpool_lock)
#define MPOOL_LOCK() unsigned long flags; spin_lock_irqsave(&_mpool_lock, flags)
#define MPOOL_UNLOCK() spin_unlock_irqrestore(&_mpool_lock, flags)
#else /* !__KERNEL__*/
/*
* Abstractions used when compiling for Linux user mode.
*/
#include <stdlib.h>
#include <sal/core/sync.h>
#define MALLOC(x) malloc(x)
#define FREE(x) free(x)
static sal_sem_t _mpool_lock;
#define MPOOL_LOCK_INIT() _mpool_lock = sal_sem_create("mpool_lock", 1, 1)
#define MPOOL_LOCK() sal_sem_take(_mpool_lock, sal_sem_FOREVER)
#define MPOOL_UNLOCK() sal_sem_give(_mpool_lock)
#endif /* __KERNEL__ */
/* Allow external override for system cache line size */
#ifndef BCM_CACHE_LINE_BYTES
#ifdef L1_CACHE_BYTES
#define BCM_CACHE_LINE_BYTES L1_CACHE_BYTES
#else
#define BCM_CACHE_LINE_BYTES 128 /* Should be fine on most platforms */
#endif
#endif
typedef struct mpool_mem_s {
unsigned char *address;
int size;
struct mpool_mem_s *next;
} mpool_mem_t;
/*
* Function: mpool_init
*
* Purpose:
* Initialize mpool lock.
* Parameters:
* None
* Returns:
* Always 0
*/
int
mpool_init(void)
{
MPOOL_LOCK_INIT();
return 0;
}
#ifdef TRACK_DMA_USAGE
static int _dma_mem_used = 0;
#endif
/*
* Function: mpool_alloc
*
* Purpose:
* Allocate memory block from mpool.
* Parameters:
* pool - mpool handle (from mpool_create)
* size - size of memory block to allocate
* Returns:
* Pointer to allocated memory block or NULL if allocation fails.
*/
void *
mpool_alloc(mpool_handle_t pool, int size)
{
mpool_mem_t *ptr = pool, *newptr = NULL;
int mod;
MPOOL_LOCK();
mod = size & (BCM_CACHE_LINE_BYTES - 1);
if (mod != 0 ) {
size += (BCM_CACHE_LINE_BYTES - mod);
}
while (ptr && ptr->next) {
if (ptr->next->address - (ptr->address + ptr->size) >= size) {
break;
}
ptr = ptr->next;
}
if (!(ptr && ptr->next)) {
MPOOL_UNLOCK();
return NULL;
}
newptr = MALLOC(sizeof(mpool_mem_t));
if (!newptr) {
MPOOL_UNLOCK();
return NULL;
}
newptr->address = ptr->address + ptr->size;
newptr->size = size;
newptr->next = ptr->next;
ptr->next = newptr;
#ifdef TRACK_DMA_USAGE
_dma_mem_used += size;
#endif
MPOOL_UNLOCK();
return newptr->address;
}
/*
* Function: mpool_free
*
* Purpose:
* Free memory block allocated from mpool..
* Parameters:
* pool - mpool handle (from mpool_create)
* addr - address of memory block to free
* Returns:
* Nothing
*/
void
mpool_free(mpool_handle_t pool, void *addr)
{
unsigned char *address = (unsigned char *)addr;
mpool_mem_t *ptr = pool, *prev = NULL;
MPOOL_LOCK();
while (ptr && ptr->next) {
if (ptr->next->address == address) {
#ifdef TRACK_DMA_USAGE
_dma_mem_used -= ptr->next->size;
#endif
break;
}
ptr = ptr->next;
}
if (ptr && ptr->next) {
prev = ptr;
ptr = ptr->next;
prev->next = ptr->next;
FREE(ptr);
}
MPOOL_UNLOCK();
}
/*
* Function: mpool_create
*
* Purpose:
* Create and initialize mpool control structures.
* Parameters:
* base_ptr - pointer to mpool memory block
* size - total size of mpool memory block
* Returns:
* mpool handle
* Notes
* The mpool handle returned must be used for subsequent
* memory allocations from the mpool.
*/
mpool_handle_t
mpool_create(void *base_ptr, int size)
{
mpool_mem_t *head, *tail;
int mod = (int)(((unsigned long)base_ptr) & (BCM_CACHE_LINE_BYTES - 1));
MPOOL_LOCK();
if (mod) {
base_ptr = (char*)base_ptr + (BCM_CACHE_LINE_BYTES - mod);
size -= (BCM_CACHE_LINE_BYTES - mod);
}
size &= ~(BCM_CACHE_LINE_BYTES - 1);
head = (mpool_mem_t *)MALLOC(sizeof(mpool_mem_t));
if (head == NULL) {
return NULL;
}
tail = (mpool_mem_t *)MALLOC(sizeof(mpool_mem_t));
if (tail == NULL) {
FREE(head);
return NULL;
}
head->size = tail->size = 0;
head->address = base_ptr;
tail->address = head->address + size;
head->next = tail;
tail->next = NULL;
MPOOL_UNLOCK();
return head;
}
/*
* Function: mpool_destroy
*
* Purpose:
* Free mpool control structures.
* Parameters:
* pool - mpool handle (from mpool_create)
* Returns:
* Always 0
*/
int
mpool_destroy(mpool_handle_t pool)
{
mpool_mem_t *ptr, *next;
MPOOL_LOCK();
for (ptr = pool; ptr; ptr = next) {
next = ptr->next;
FREE(ptr);
}
MPOOL_UNLOCK();
return 0;
}
/*
* Function: mpool_usage
*
* Purpose:
* Report total sum of allocated mpool memory.
* Parameters:
* pool - mpool handle (from mpool_create)
* Returns:
* Number of bytes currently allocated using mpool_alloc.
*/
int
mpool_usage(mpool_handle_t pool)
{
int usage = 0;
mpool_mem_t *ptr;
MPOOL_LOCK();
for (ptr = pool; ptr; ptr = ptr->next) {
usage += ptr->size;
}
MPOOL_UNLOCK();
return usage;
}
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# -*- Makefile -*-
# $Id: Makefile,v 1.1 2008/10/16 09:41:22 mlarsen Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
LOCALDIR = systems/bde/linux/user/kernel
# Make sure we build for the kernel if this is a user-mode build
ifneq ($(platform), )
override-target=linux-$(platform)
endif
include $(SDK)/make/Make.config
LIBS = $(LIBDIR)/libkern.a
ifneq ($(kernel_version),2_4)
KERNEL_MODULE_DIR = kernel_module
THIS_MOD_NAME := linux-user-bde
MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o
KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko
build: kernel_libs $(MODULE) $(KMODULE)
else
MODULE = $(LIBDIR)/linux-user-bde.o
build: kernel_libs $(MODULE)
endif
KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../../kernel/kernel_module/Module.symvers
$(MODULE): $(BLDDIR)/.tree $(BOBJS) $(LIBS)
$(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@
ifneq ($(kernel_version),2_4)
$(KMODULE): $(MODULE)
rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR)
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
endif
kernel_libs:
$(MAKE) -C $(SDK)/systems/linux/kernel/modules/shared
include $(SDK)/make/Make.depend
# Make.depend is before clean:: so that Make.depend's clean:: runs first.
clean::
$(MAKE) -C $(SDK)/systems/linux/kernel/modules/shared $@
$(RM) $(BOBJS) $(MODULE)
.PHONY: build kernel_libs
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: linux-user-bde.c,v 1.80 2013/06/14 22:31:44 mlarsen Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*
* Linux User BDE Helper Module
*/
#include <gmodule.h>
#include <mpool.h>
#include <linux-bde.h>
#include <sal/core/thread.h>
#include <sal/core/sync.h>
#include <soc/devids.h>
#include "linux-user-bde.h"
#ifdef KEYSTONE
#include <shared/et/bcmdevs.h>
#endif
MODULE_AUTHOR("Broadcom Corporation");
MODULE_DESCRIPTION("User BDE Helper Module");
MODULE_LICENSE("GPL");
/* CMIC/CMICe defines */
#define CMIC_IRQ_STAT 0x00000144
#define CMIC_IRQ_MASK 0x00000148
#define CMIC_IRQ_MASK_1 0x0000006C
#define CMIC_IRQ_MASK_2 0x00000070
/* CMICm defines */
#define CMIC_CMCx_IRQ_STAT0_OFFSET(x) (0x31400 + (0x1000 * x))
#define CMIC_CMCx_IRQ_STAT1_OFFSET(x) (0x31404 + (0x1000 * x))
#define CMIC_CMCx_IRQ_STAT2_OFFSET(x) (0x31408 + (0x1000 * x))
#define CMIC_CMCx_IRQ_STAT3_OFFSET(x) (0x3140c + (0x1000 * x))
#define CMIC_CMCx_IRQ_STAT4_OFFSET(x) (0x31410 + (0x1000 * x))
#define CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(x) (0x31414 + (0x1000 * x))
#define CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(x) (0x31418 + (0x1000 * x))
#define CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(x) (0x3141c + (0x1000 * x))
#define CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(x) (0x31420 + (0x1000 * x))
#define CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(x) (0x31424 + (0x1000 * x))
/* CMICd defines */
#define CMIC_CMCx_IRQ_STAT5_OFFSET(x) (0x314b0 + (0x1000 * x))
#define CMIC_CMCx_IRQ_STAT6_OFFSET(x) (0x314b4 + (0x1000 * x))
#define CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(x) (0x314b8 + (0x1000 * x))
#define CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(x) (0x314bc + (0x1000 * x))
#define CMIC_CMCx_UC0_IRQ_MASK0_OFFSET(x) (0x31428 + (0x1000 * x))
#define CMIC_CMCx_UC0_IRQ_MASK1_OFFSET(x) (0x3142c + (0x1000 * x))
#define CMIC_CMCx_UC0_IRQ_MASK2_OFFSET(x) (0x31430 + (0x1000 * x))
#define CMIC_CMCx_UC0_IRQ_MASK3_OFFSET(x) (0x31434 + (0x1000 * x))
#define CMIC_CMCx_UC0_IRQ_MASK4_OFFSET(x) (0x31438 + (0x1000 * x))
/* Allow override of default CMICm CMC */
#ifndef BDE_CMICM_PCIE_CMC
#define BDE_CMICM_PCIE_CMC 0
#endif
/* Allow override of default CMICm CMC */
#ifndef BDE_CMICD_PCIE_CMC
#define BDE_CMICD_PCIE_CMC 0
#endif
/* Defines used to distinguish CMICe from CMICm */
#define CMICE_DEV_REV_ID (0x178 / sizeof(uint32))
static ibde_t *user_bde = NULL;
typedef void (*isr_f)(void *);
typedef struct bde_ctrl_s {
uint32 dev_type;
int irq;
int enabled;
int devid;
isr_f isr;
uint32 *ba;
int inst; /* associate to _bde_inst_resource[] */
} bde_ctrl_t;
static bde_ctrl_t _devices[LINUX_BDE_MAX_DEVICES];
static wait_queue_head_t _ether_interrupt_wq;
static atomic_t _ether_interrupt_has_taken_place = ATOMIC_INIT(0);
/*
* Multiple instance resource data structure.
* To keep the DMA resource per instance.
* And track the DMA pool usage.
*/
static int _bde_multi_inst = 0;
typedef struct {
unsigned int inst_id;
unsigned int dma_offset;
unsigned int dma_size;
wait_queue_head_t intr_wq;
atomic_t intr;
} bde_inst_resource_t;
static bde_inst_resource_t _bde_inst_resource[LINUX_BDE_MAX_DEVICES];
typedef struct {
uint32 total_size; /* Total size of the pool in MB */
uint32 pbase; /* Physical base address of the DMA pool */
uint32 offset; /* Current offset of the pool in MB */
}_dma_pool_t;
static _dma_pool_t _dma_pool;
#define ONE_MB (1024 * 1024)
#ifdef KEYSTONE
/*
* Enforce PCIE transaction ordering. Commit the write transaction.
*/
#define SSOC_WRITEL(val, addr) \
do { \
writel((val), (addr)); \
__asm__ __volatile__("sync"); \
} while(0)
#else
#define SSOC_WRITEL(val, addr) \
writel((val), (addr))
#endif
/*
* Function: _interrupt
*
* Purpose:
* Interrupt Handler.
* Mask all interrupts on device and wake up interrupt
* thread. It is assumed that the interrupt thread unmasks
* interrupts again when interrupt handling is complete.
* Parameters:
* ctrl - BDE control structure for this device.
* Returns:
* Nothing
*/
static void
_cmic_interrupt(bde_ctrl_t *ctrl)
{
int d;
uint32_t mask = 0, stat, imask = 0, fmask = 0;
bde_inst_resource_t *res;
d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t));
res = &_bde_inst_resource[ctrl->inst];
/* Check for secondary interrupt handler */
if (lkbde_irq_mask_get(d, &mask, &fmask) < 0) {
fmask = 0;
}
if (fmask != 0) {
imask = mask & ~fmask;
/* Check for pending user mode interrupts */
stat = user_bde->read(d, CMIC_IRQ_STAT);
if ((stat & imask) == 0) {
/* All handled in kernel mode */
lkbde_irq_mask_set(d, CMIC_IRQ_MASK, imask, 0);
return;
}
}
lkbde_irq_mask_set(d, CMIC_IRQ_MASK, 0, 0);
atomic_set(&res->intr, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&res->intr_wq);
#else
wake_up_interruptible(&res->intr_wq);
#endif
}
static void
_cmicm_interrupt(bde_ctrl_t *ctrl)
{
int d;
int cmc = BDE_CMICM_PCIE_CMC;
uint32 stat, mask = 0, fmask = 0, imask = 0;
bde_inst_resource_t *res;
d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t));
res = &_bde_inst_resource[ctrl->inst];
lkbde_irq_mask_get(d, &mask, &fmask);
while (fmask) {
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT0_OFFSET(cmc));
imask = mask & ~fmask;
if (stat & imask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT1_OFFSET(cmc));
if (ctrl->dev_type & BDE_AXI_DEV_TYPE) {
mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK1_OFFSET(cmc));
} else {
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc));
}
if (stat & mask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT2_OFFSET(cmc));
if (ctrl->dev_type & BDE_AXI_DEV_TYPE) {
mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK2_OFFSET(cmc));
} else {
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc));
}
if (stat & mask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT3_OFFSET(cmc));
if (ctrl->dev_type & BDE_AXI_DEV_TYPE) {
mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK3_OFFSET(cmc));
} else {
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc));
}
if (stat & mask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT4_OFFSET(cmc));
if (ctrl->dev_type & BDE_AXI_DEV_TYPE) {
mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK4_OFFSET(cmc));
} else {
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc));
}
if (stat & mask) {
break;
}
return;
}
if (ctrl->dev_type & BDE_AXI_DEV_TYPE) {
lkbde_irq_mask_set(d, CMIC_CMCx_UC0_IRQ_MASK0_OFFSET(cmc), 0, 0);
user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK1_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK2_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK3_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK4_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK0_OFFSET(1), 0);
user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK0_OFFSET(2), 0);
}
else {
lkbde_irq_mask_set(d, CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(cmc), 0, 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(1), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(2), 0);
}
atomic_set(&res->intr, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&res->intr_wq);
#else
wake_up_interruptible(&res->intr_wq);
#endif
}
static void
_cmicd_interrupt(bde_ctrl_t *ctrl)
{
int d;
int cmc = BDE_CMICD_PCIE_CMC;
uint32 stat, mask = 0, fmask = 0, imask = 0;
bde_inst_resource_t *res;
d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t));
res = &_bde_inst_resource[ctrl->inst];
lkbde_irq_mask_get(d, &mask, &fmask);
while (fmask) {
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT0_OFFSET(cmc));
imask = mask & ~fmask;
if (stat & imask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT1_OFFSET(cmc));
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc));
if (stat & mask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT2_OFFSET(cmc));
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc));
if (stat & mask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT3_OFFSET(cmc));
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc));
if (stat & mask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT4_OFFSET(cmc));
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc));
if (stat & mask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT5_OFFSET(cmc));
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(cmc));
if (stat & mask) {
break;
}
stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT6_OFFSET(cmc));
mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(cmc));
if (stat & mask) {
break;
}
return;
}
lkbde_irq_mask_set(d, CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(cmc), 0, 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(cmc), 0);
user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(cmc), 0);
atomic_set(&res->intr, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&res->intr_wq);
#else
wake_up_interruptible(&res->intr_wq);
#endif
}
static void
_bcm88750_interrupt(bde_ctrl_t *ctrl)
{
int d;
bde_inst_resource_t *res;
d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t));
res = &_bde_inst_resource[ctrl->inst];
lkbde_irq_mask_set(d, CMIC_IRQ_MASK, 0, 0);
lkbde_irq_mask_set(d, CMIC_IRQ_MASK_1, 0, 0);
lkbde_irq_mask_set(d, CMIC_IRQ_MASK_2, 0, 0);
atomic_set(&res->intr, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&res->intr_wq);
#else
wake_up_interruptible(&res->intr_wq);
#endif
}
static void
_qe2k_interrupt(bde_ctrl_t *ctrl)
{
bde_inst_resource_t *res;
res = &_bde_inst_resource[ctrl->inst];
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x20/sizeof(uint32));
atomic_set(&res->intr, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&res->intr_wq);
#else
wake_up_interruptible(&res->intr_wq);
#endif
}
static void
_fe2k_interrupt(bde_ctrl_t *ctrl)
{
bde_inst_resource_t *res;
res = &_bde_inst_resource[ctrl->inst];
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x18/sizeof(uint32)); /* PC_INTERRUPT_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x24/sizeof(uint32)); /* PC_ERROR0_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x2c/sizeof(uint32)); /* PC_ERROR1_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x34/sizeof(uint32)); /* PC_UNIT_MASK */
atomic_set(&res->intr, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&res->intr_wq);
#else
wake_up_interruptible(&res->intr_wq);
#endif
}
static void
_fe2kxt_interrupt(bde_ctrl_t *ctrl)
{
bde_inst_resource_t *res;
res = &_bde_inst_resource[ctrl->inst];
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x2c/sizeof(uint32)); /* PC_INTERRUPT_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x38/sizeof(uint32)); /* PC_ERROR0_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x40/sizeof(uint32)); /* PC_ERROR1_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x50/sizeof(uint32)); /* PC_UNIT_MASK */
atomic_set(&res->intr, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&res->intr_wq);
#else
wake_up_interruptible(&res->intr_wq);
#endif
}
static void
_bme3200_interrupt(bde_ctrl_t *ctrl)
{
bde_inst_resource_t *res;
res = &_bde_inst_resource[ctrl->inst];
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x54/sizeof(uint32)); /* PI_PT_ERROR0 */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x5c/sizeof(uint32)); /* PI_PT_ERROR1 */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x64/sizeof(uint32)); /* PI_PT_ERROR2 */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x6c/sizeof(uint32)); /* PI_PT_ERROR3 */
atomic_set(&res->intr, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&res->intr_wq);
#else
wake_up_interruptible(&res->intr_wq);
#endif
}
static void
_bm9600_interrupt(bde_ctrl_t *ctrl)
{
bde_inst_resource_t *res;
res = &_bde_inst_resource[ctrl->inst];
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x5c/sizeof(uint32)); /* PI_INTERRUPT_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0xc/sizeof(uint32)); /* PI_UNIT_INTERRUPT0_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x14/sizeof(uint32)); /* PI_UNIT_INTERRUPT1_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x1c/sizeof(uint32)); /* PI_UNIT_INTERRUPT2_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x24/sizeof(uint32)); /* PI_UNIT_INTERRUPT3_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x2c/sizeof(uint32)); /* PI_UNIT_INTERRUPT4_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x34/sizeof(uint32)); /* PI_UNIT_INTERRUPT5_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x3c/sizeof(uint32)); /* PI_UNIT_INTERRUPT6_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x44/sizeof(uint32)); /* PI_UNIT_INTERRUPT7_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x4c/sizeof(uint32)); /* PI_UNIT_INTERRUPT8_MASK */
SSOC_WRITEL(0xffffffff, ctrl->ba + 0x54/sizeof(uint32)); /* PI_UNIT_INTERRUPT9_MASK */
atomic_set(&res->intr, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&res->intr_wq);
#else
wake_up_interruptible(&res->intr_wq);
#endif
}
/* The actual interrupt handler of ethernet devices */
static void
_ether_interrupt(bde_ctrl_t *ctrl)
{
#ifdef KEYSTONE
/*
* Since the two GMAC cores are sharing the same IRQ.
* Add the checking to handle the interrupt events.
*/
if ((ctrl->devid == BCM53000_GMAC_ID)) {
if ((readl(ctrl->ba + 0x020/4) & readl(ctrl->ba + 0x024/4)) == 0) {
return;
}
}
#endif
SSOC_WRITEL(0, ctrl->ba + 0x024/4);
atomic_set(&_ether_interrupt_has_taken_place, 1);
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wake_up(&_ether_interrupt_wq);
#else
wake_up_interruptible(&_ether_interrupt_wq);
#endif
}
static struct _intr_mode_s {
isr_f isr;
const char *name;
} _intr_mode[] = {
{ (isr_f)_cmic_interrupt, "CMIC/CMICe" },
{ (isr_f)_cmicm_interrupt, "CMICm" },
{ (isr_f)_cmicd_interrupt, "CMICd" },
{ (isr_f)_qe2k_interrupt, "QE2K" },
{ (isr_f)_fe2k_interrupt, "FE2K" },
{ (isr_f)_fe2kxt_interrupt, "FE2KXT" },
{ (isr_f)_bme3200_interrupt, "BME3200" },
{ (isr_f)_bm9600_interrupt, "BM9600" },
{ (isr_f)_bcm88750_interrupt, "BCM88750" },
{ NULL, NULL }
};
static const char *
_intr_mode_str(void *isr)
{
int imx;
imx = 0;
while (_intr_mode[imx].isr != NULL) {
if (isr == _intr_mode[imx].isr) {
return _intr_mode[imx].name;
}
imx++;
}
return NULL;
}
static void
_devices_init(int d)
{
bde_ctrl_t *ctrl;
ctrl = &_devices[d];
/* Initialize our control info */
ctrl->dev_type = user_bde->get_dev_type(d);
ctrl->devid = user_bde->get_dev(d)->device;
ctrl->inst = 0;
if (BDE_DEV_MEM_MAPPED(ctrl->dev_type)) {
ctrl->enabled = 0;
ctrl->ba = lkbde_get_dev_virt(d);
}
if (ctrl->dev_type & BDE_SWITCH_DEV_TYPE) {
switch (user_bde->get_dev(d)->device) {
case QE2000_DEVICE_ID:
ctrl->isr = (isr_f)_qe2k_interrupt;
break;
case BCM88020_DEVICE_ID:
ctrl->isr = (isr_f)_fe2k_interrupt;
break;
case BCM88025_DEVICE_ID:
ctrl->isr = (isr_f)_fe2kxt_interrupt;
break;
case BME3200_DEVICE_ID:
ctrl->isr = (isr_f)_bme3200_interrupt;
break;
case BM9600_DEVICE_ID:
ctrl->isr = (isr_f)_bm9600_interrupt;
break;
case BCM88750_DEVICE_ID:
case BCM88753_DEVICE_ID:
case BCM88754_DEVICE_ID:
case BCM88755_DEVICE_ID:
ctrl->isr = (isr_f)_bcm88750_interrupt;
break;
/* FIXME: might use _devices[i].dev_type & BDE_AXI_DEV_TYPE*/
case BCM88670_DEVICE_ID:
case BCM88671_DEVICE_ID:
case BCM88671M_DEVICE_ID:
case BCM88673_DEVICE_ID:
case BCM88674_DEVICE_ID:
case BCM88675_DEVICE_ID:
case BCM88675M_DEVICE_ID:
case BCM88676_DEVICE_ID:
case BCM88676M_DEVICE_ID:
case BCM88678_DEVICE_ID:
case BCM88679_DEVICE_ID:
case BCM88370_DEVICE_ID:
case BCM88371_DEVICE_ID:
case BCM88371M_DEVICE_ID:
case BCM88375_DEVICE_ID:
case BCM88376_DEVICE_ID:
case BCM88376M_DEVICE_ID:
case BCM88377_DEVICE_ID:
case BCM88378_DEVICE_ID:
case BCM88379_DEVICE_ID:
case BCM88770_DEVICE_ID:
case BCM88773_DEVICE_ID:
case BCM88774_DEVICE_ID:
case BCM88775_DEVICE_ID:
case BCM88776_DEVICE_ID:
case BCM88470_DEVICE_ID:
case BCM88950_DEVICE_ID:
case BCM88953_DEVICE_ID:
case BCM88954_DEVICE_ID:
case BCM88955_DEVICE_ID:
case BCM88956_DEVICE_ID:
ctrl->isr = (isr_f)_cmicd_interrupt;
break;
default:
ctrl->isr = (isr_f)_cmic_interrupt;
if ((ctrl->dev_type & BDE_256K_REG_SPACE) &&
#ifdef BCM_PETRA_SUPPORT /* FIXME remove code when hardware design is fixed */
ctrl->devid != 0x1234 &&
#endif
readl(ctrl->ba + CMICE_DEV_REV_ID) == 0) {
ctrl->isr = (isr_f)_cmicm_interrupt;
}
break;
}
if (_intr_mode_str(ctrl->isr) == NULL) {
gprintk("Warning: Unknown interrupt mode\n");
}
}
}
/*
* Function: _init
*
* Purpose:
* Module initialization.
* Attaches to kernel BDE.
* Parameters:
* None
* Returns:
* Always 0
*/
static int
_init(void)
{
int i;
uint32 pbase, dmasize;
bde_inst_resource_t *res;
/* Connect to the kernel bde */
if ((linux_bde_create(NULL, &user_bde) < 0) || user_bde == NULL) {
return -ENODEV;
}
init_waitqueue_head(&_ether_interrupt_wq);
lkbde_get_dma_info(&pbase, &dmasize);
memset(&_dma_pool, 0, sizeof(_dma_pool));
_dma_pool.pbase = pbase;
_dma_pool.total_size = dmasize / ONE_MB;
memset(_devices, 0, sizeof(_devices));
/* Use _bde_inst_resource[0] as the default resource */
memset(_bde_inst_resource, 0, sizeof(_bde_inst_resource));
res = &_bde_inst_resource[0];
res->dma_offset = 0;
res->dma_size = _dma_pool.total_size;
init_waitqueue_head(&res->intr_wq);
atomic_set(&res->intr, 0);
for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) {
res->inst_id |= (1 << i);
_devices_init(i);
}
return 0;
}
/*
* Function: _cleanup
*
* Purpose:
* Module cleanup function.
* Parameters:
* None
* Returns:
* Always 0
*/
static int
_cleanup(void)
{
int i;
if (user_bde) {
for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) {
if (_devices[i].enabled &&
BDE_DEV_MEM_MAPPED(_devices[i].dev_type)) {
user_bde->interrupt_disconnect(i);
}
lkbde_dev_instid_set(i, 0);
}
linux_bde_destroy(user_bde);
user_bde = NULL;
}
return 0;
}
/*
* Function: _pprint
*
* Purpose:
* Print proc filesystem information.
* Parameters:
* None
* Returns:
* Always 0
*/
static int
_pprint(void)
{
int idx;
const char *name;
bde_inst_resource_t *res;
uint32 state, instid;
pprintf("Broadcom Device Enumerator (%s)\n", LINUX_USER_BDE_NAME);
for (idx = 0; idx < user_bde->num_devices(BDE_ALL_DEVICES); idx++) {
name = _intr_mode_str(_devices[idx].isr);
if (name == NULL) {
name = "unknown";
}
pprintf("\t%d: Interrupt mode %s ",idx, name);
(void)lkbde_dev_state_get(idx, &state);
if (state == BDE_DEV_STATE_REMOVED) {
pprintf(" Device REMOVED ! \n");
} else {
(void)lkbde_dev_instid_get(idx, &instid);
if (instid) {
pprintf("Inst id 0x%x\n",instid);
} else {
pprintf("\n");
}
}
}
pprintf("Instance resource \n");
for (idx = 0; idx < user_bde->num_devices(BDE_ALL_DEVICES); idx++) {
res = &_bde_inst_resource[idx];
if (res->inst_id) {
pprintf("\tDev mask 0x%x : "
"DMA offset %d size %d MB\n",
res->inst_id,
res->dma_offset,
res->dma_size);
}
}
return 0;
}
/*
* Allocate the DMA resource from DMA pool
* Parameter :
* dma_size (IN): allocate dma_size in MB
* dma_offset (OUT): dma offset in MB
*/
static int
_dma_resource_alloc(unsigned int dma_size, unsigned int *dma_offset)
{
uint32 left;
left = _dma_pool.total_size - _dma_pool.offset;
if (dma_size > left) {
gprintk("ERROR: Run out the dma resource!\n");
return -1;
}
*dma_offset = _dma_pool.offset;
_dma_pool.offset += dma_size;
return 0;
}
static int
_dma_resource_get(int inst_id, uint32 *pbase, uint32* size)
{
int i;
unsigned int dma_size = 0, dma_offset = 0;
bde_inst_resource_t *res;
for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) {
res = &_bde_inst_resource[i];
if (res->inst_id == inst_id) {
dma_size = res->dma_size;
dma_offset = res->dma_offset;
break;
}
}
*pbase = _dma_pool.pbase + dma_offset * ONE_MB;
*size = dma_size * ONE_MB;
return 0;
}
static int
_instance_validate(unsigned int inst_id, unsigned int dmasize)
{
int i;
bde_inst_resource_t *res;
for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) {
res = &_bde_inst_resource[i];
if (res->inst_id == inst_id) {
if (res->dma_size != dmasize) {
if(_devices[i].inst == 0){
/* Skip _instance_validate (not init yet) */
return LUBDE_SUCCESS;
}
gprintk("ERROR: dma_size mismatch\n");
return LUBDE_FAIL;
}
return (1);
}
}
return LUBDE_SUCCESS;
}
static int
_device_reprobe(void)
{
int i;
for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) {
if (_devices[i].devid == 0) {
_devices_init(i);
}
}
return 0;
}
static int
_instance_attach(unsigned int inst_id, unsigned int dma_size)
{
unsigned int dma_offset;
int i, exist;
bde_inst_resource_t *res;
int inst_idx = -1;
uint32 instid;
/* Reprobe the system for hot-plugged device */
_device_reprobe();
/* Validate the resource with inst_id */
exist = _instance_validate(inst_id, dma_size);
if (exist < 0) {
return LUBDE_FAIL;
}
if (exist > 0) {
return LUBDE_SUCCESS;
}
if (_dma_resource_alloc(dma_size, &dma_offset) < 0) {
return LUBDE_FAIL;
}
for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) {
res = &_bde_inst_resource[i];
if ((_bde_multi_inst == 0) || (res->inst_id == 0)) {
res->inst_id = inst_id;
res->dma_offset = dma_offset;
res->dma_size = dma_size;
_bde_multi_inst++;
inst_idx = i;
init_waitqueue_head(&res->intr_wq);
atomic_set(&res->intr, 0);
break;
}
}
for (i = 0; i < user_bde->num_devices(BDE_ALL_DEVICES); i++) {
if (inst_id & (1 << i)) {
_devices[i].inst = inst_idx;
/* Pass the instid to the kernel BDE */
if (lkbde_dev_instid_get(i, &instid) == 0) {
if (!instid) {
lkbde_dev_instid_set(i, inst_id);
}
}
}
}
return LUBDE_SUCCESS;
}
/*
* Function: _ioctl
*
* Purpose:
* Handle IOCTL commands from user mode.
* Parameters:
* cmd - IOCTL cmd
* arg - IOCTL parameters
* Returns:
* 0 on success, <0 on error
*/
static int
_ioctl(unsigned int cmd, unsigned long arg)
{
lubde_ioctl_t io;
uint32 pbase, size;
const ibde_dev_t *bde_dev;
int inst_id;
bde_inst_resource_t *res;
if (copy_from_user(&io, (void *)arg, sizeof(io))) {
return -EFAULT;
}
io.rc = LUBDE_SUCCESS;
switch(cmd) {
case LUBDE_VERSION:
io.d0 = KBDE_VERSION;
break;
case LUBDE_GET_NUM_DEVICES:
io.d0 = user_bde->num_devices(io.dev);
break;
case LUBDE_GET_DEVICE:
bde_dev = user_bde->get_dev(io.dev);
if (bde_dev) {
io.d0 = bde_dev->device;
io.d1 = bde_dev->rev;
if (BDE_DEV_MEM_MAPPED(_devices[io.dev].dev_type)) {
/* Get physical address to map */
io.d2 = lkbde_get_dev_phys(io.dev);
io.d3 = lkbde_get_dev_phys_hi(io.dev);
}
} else {
io.rc = LUBDE_FAIL;
}
break;
case LUBDE_GET_DEVICE_TYPE:
io.d0 = _devices[io.dev].dev_type;
break;
case LUBDE_GET_BUS_FEATURES:
user_bde->pci_bus_features(io.dev, (int *) &io.d0, (int *) &io.d1,
(int *) &io.d2);
break;
case LUBDE_PCI_CONFIG_PUT32:
if (_devices[io.dev].dev_type & BDE_PCI_DEV_TYPE) {
user_bde->pci_conf_write(io.dev, io.d0, io.d1);
} else {
io.rc = LUBDE_FAIL;
}
break;
case LUBDE_PCI_CONFIG_GET32:
if (_devices[io.dev].dev_type & BDE_PCI_DEV_TYPE) {
io.d0 = user_bde->pci_conf_read(io.dev, io.d0);
} else {
io.rc = LUBDE_FAIL;
}
break;
case LUBDE_GET_DMA_INFO:
inst_id = io.dev;
if (_bde_multi_inst){
_dma_resource_get(inst_id, &pbase, &size);
} else {
lkbde_get_dma_info(&pbase, &size);
}
io.d0 = pbase;
io.d1 = size;
/* Optionally enable DMA mmap via /dev/linux-kernel-bde */
io.d2 = USE_LINUX_BDE_MMAP;
break;
case LUBDE_ENABLE_INTERRUPTS:
if (_devices[io.dev].dev_type & BDE_SWITCH_DEV_TYPE) {
if (_devices[io.dev].isr && !_devices[io.dev].enabled) {
user_bde->interrupt_connect(io.dev,
_devices[io.dev].isr,
_devices+io.dev);
_devices[io.dev].enabled = 1;
}
} else {
/* Process ethernet device interrupt */
/* FIXME: for multiple chips */
if (!_devices[io.dev].enabled) {
user_bde->interrupt_connect(io.dev,
(void(*)(void *))_ether_interrupt,
_devices+io.dev);
_devices[io.dev].enabled = 1;
}
}
break;
case LUBDE_DISABLE_INTERRUPTS:
if (_devices[io.dev].enabled) {
user_bde->interrupt_disconnect(io.dev);
_devices[io.dev].enabled = 0;
}
break;
case LUBDE_WAIT_FOR_INTERRUPT:
if (_devices[io.dev].dev_type & BDE_SWITCH_DEV_TYPE) {
res = &_bde_inst_resource[_devices[io.dev].inst];
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wait_event_timeout(res->intr_wq,
atomic_read(&res->intr) != 0, 100);
#else
wait_event_interruptible(res->intr_wq,
atomic_read(&res->intr) != 0);
#endif
/*
* Even if we get multiple interrupts, we
* only run the interrupt handler once.
*/
atomic_set(&res->intr, 0);
} else {
#ifdef BDE_LINUX_NON_INTERRUPTIBLE
wait_event_timeout(_ether_interrupt_wq,
atomic_read(&_ether_interrupt_has_taken_place) != 0, 100);
#else
wait_event_interruptible(_ether_interrupt_wq,
atomic_read(&_ether_interrupt_has_taken_place) != 0);
#endif
/*
* Even if we get multiple interrupts, we
* only run the interrupt handler once.
*/
atomic_set(&_ether_interrupt_has_taken_place, 0);
}
break;
case LUBDE_USLEEP:
sal_usleep(io.d0);
break;
case LUBDE_UDELAY:
sal_udelay(io.d0);
break;
case LUBDE_SEM_OP:
switch (io.d0) {
case LUBDE_SEM_OP_CREATE:
io.p0 = (bde_kernel_addr_t)sal_sem_create("", io.d1, io.d2);
break;
case LUBDE_SEM_OP_DESTROY:
sal_sem_destroy((sal_sem_t)io.p0);
break;
case LUBDE_SEM_OP_TAKE:
io.rc = sal_sem_take((sal_sem_t)io.p0, io.d2);
break;
case LUBDE_SEM_OP_GIVE:
io.rc = sal_sem_give((sal_sem_t)io.p0);
break;
default:
io.rc = LUBDE_FAIL;
break;
}
break;
case LUBDE_WRITE_IRQ_MASK:
io.rc = lkbde_irq_mask_set(io.dev, io.d0, io.d1, 0);
break;
case LUBDE_SPI_READ_REG:
if (user_bde->spi_read(io.dev, io.d0, io.dx.buf, io.d1) == -1) {
io.rc = LUBDE_FAIL;
}
break;
case LUBDE_SPI_WRITE_REG:
if (user_bde->spi_write(io.dev, io.d0, io.dx.buf, io.d1) == -1) {
io.rc = LUBDE_FAIL;
}
break;
case LUBDE_READ_REG_16BIT_BUS:
io.d1 = user_bde->read(io.dev, io.d0);
break;
case LUBDE_WRITE_REG_16BIT_BUS:
io.rc = user_bde->write(io.dev, io.d0, io.d1);
break;
#if (defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT))
case LUBDE_CPU_WRITE_REG:
{
if (lkbde_cpu_write(io.dev, io.d0, (uint32*)io.dx.buf) == -1) {
io.rc = LUBDE_FAIL;
}
break;
}
case LUBDE_CPU_READ_REG:
{
if (lkbde_cpu_read(io.dev, io.d0, (uint32*)io.dx.buf) == -1) {
io.rc = LUBDE_FAIL;
}
break;
}
case LUBDE_CPU_PCI_REGISTER:
{
if (lkbde_cpu_pci_register(io.dev) == -1) {
io.rc = LUBDE_FAIL;
}
break;
}
#endif
case LUBDE_DEV_RESOURCE:
bde_dev = user_bde->get_dev(io.dev);
if (bde_dev) {
if (BDE_DEV_MEM_MAPPED(_devices[io.dev].dev_type)) {
/* Get physical address to map */
io.rc = lkbde_get_dev_resource(io.dev, io.d0,
&io.d1, &io.d2, &io.d3);
}
} else {
io.rc = LUBDE_FAIL;
}
break;
case LUBDE_IPROC_READ_REG:
io.d1 = user_bde->iproc_read(io.dev, io.d0);
if (io.d1 == -1) {
io.rc = LUBDE_FAIL;
}
break;
case LUBDE_IPROC_WRITE_REG:
if (user_bde->iproc_write(io.dev, io.d0, io.d1) == -1) {
io.rc = LUBDE_FAIL;
}
break;
case LUBDE_ATTACH_INSTANCE:
io.rc = _instance_attach(io.d0, io.d1);
break;
case LUBDE_GET_DEVICE_STATE:
io.rc = lkbde_dev_state_get(io.dev, &io.d0);
break;
default:
gprintk("Error: Invalid ioctl (%08x)\n", cmd);
io.rc = LUBDE_FAIL;
break;
}
if (copy_to_user((void *)arg, &io, sizeof(io))) {
return -EFAULT;
}
return 0;
}
/* Workaround for broken Busybox/PPC insmod */
static char _modname[] = LINUX_USER_BDE_NAME;
static gmodule_t _gmodule =
{
name: LINUX_USER_BDE_NAME,
major: LINUX_USER_BDE_MAJOR,
init: _init,
cleanup: _cleanup,
pprint: _pprint,
ioctl: _ioctl,
};
gmodule_t*
gmodule_get(void)
{
_gmodule.name = _modname;
return &_gmodule;
}
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: linux-user-bde.h,v 1.23 2013/02/25 17:46:08 mason Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#ifndef __LINUX_USER_BDE_H__
#define __LINUX_USER_BDE_H__
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux-bde.h>
#ifndef __KERNEL__
#include <stdint.h>
#endif
#if defined(SAL_BDE_32BIT_USER_64BIT_KERNEL) || defined(PTRS_ARE_64BITS)
typedef uint64_t bde_kernel_addr_t;
#else
typedef uint32_t bde_kernel_addr_t;
#endif
/* Ioctl control structure */
typedef struct {
unsigned int dev; /* Device ID */
unsigned int rc; /* Operation Return Code */
unsigned int d0; /* Operation specific data */
unsigned int d1;
unsigned int d2;
unsigned int d3;
bde_kernel_addr_t p0;
union {
unsigned int dw[2];
unsigned char buf[64];
} dx;
} lubde_ioctl_t;
/* LUBDE ioctls */
#define LUBDE_MAGIC 'L'
#define LUBDE_VERSION _IO(LUBDE_MAGIC, 0)
#define LUBDE_GET_NUM_DEVICES _IO(LUBDE_MAGIC, 1)
#define LUBDE_GET_DEVICE _IO(LUBDE_MAGIC, 2)
#define LUBDE_PCI_CONFIG_PUT32 _IO(LUBDE_MAGIC, 3)
#define LUBDE_PCI_CONFIG_GET32 _IO(LUBDE_MAGIC, 4)
#define LUBDE_GET_DMA_INFO _IO(LUBDE_MAGIC, 5)
#define LUBDE_ENABLE_INTERRUPTS _IO(LUBDE_MAGIC, 6)
#define LUBDE_DISABLE_INTERRUPTS _IO(LUBDE_MAGIC, 7)
#define LUBDE_USLEEP _IO(LUBDE_MAGIC, 8)
#define LUBDE_WAIT_FOR_INTERRUPT _IO(LUBDE_MAGIC, 9)
#define LUBDE_SEM_OP _IO(LUBDE_MAGIC, 10)
#define LUBDE_UDELAY _IO(LUBDE_MAGIC, 11)
#define LUBDE_GET_DEVICE_TYPE _IO(LUBDE_MAGIC, 12)
#define LUBDE_SPI_READ_REG _IO(LUBDE_MAGIC, 13)
#define LUBDE_SPI_WRITE_REG _IO(LUBDE_MAGIC, 14)
#define LUBDE_READ_REG_16BIT_BUS _IO(LUBDE_MAGIC, 19)
#define LUBDE_WRITE_REG_16BIT_BUS _IO(LUBDE_MAGIC, 20)
#define LUBDE_GET_BUS_FEATURES _IO(LUBDE_MAGIC, 21)
#define LUBDE_WRITE_IRQ_MASK _IO(LUBDE_MAGIC, 22)
#define LUBDE_CPU_WRITE_REG _IO(LUBDE_MAGIC, 23)
#define LUBDE_CPU_READ_REG _IO(LUBDE_MAGIC, 24)
#define LUBDE_CPU_PCI_REGISTER _IO(LUBDE_MAGIC, 25)
#define LUBDE_DEV_RESOURCE _IO(LUBDE_MAGIC, 26)
#define LUBDE_IPROC_READ_REG _IO(LUBDE_MAGIC, 27)
#define LUBDE_IPROC_WRITE_REG _IO(LUBDE_MAGIC, 28)
#define LUBDE_ATTACH_INSTANCE _IO(LUBDE_MAGIC, 29)
#define LUBDE_GET_DEVICE_STATE _IO(LUBDE_MAGIC, 30)
#define LUBDE_SEM_OP_CREATE 1
#define LUBDE_SEM_OP_DESTROY 2
#define LUBDE_SEM_OP_TAKE 3
#define LUBDE_SEM_OP_GIVE 4
#define LUBDE_SUCCESS 0
#define LUBDE_FAIL ((unsigned int)-1)
/*
* Version history
* 1:add LUBDE_GET_DEVICE_STATE to support PCI hot plug
*/
#define KBDE_VERSION 1
/* This is the signal that will be used
* when an interrupt occurs
*/
#ifndef __KERNEL__
#include <signal.h>
#endif
#define LUBDE_INTERRUPT_SIGNAL SIGUSR1
#define LUBDE_ETHER_INTERRUPT_SIGNAL SIGUSR2
#endif /* __LUBDE_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: $
* $Copyright: (c) 2014 Broadcom Corp.
* All Rights Reserved.$
*
*/
#ifndef __SHBDE_H__
#define __SHBDE_H__
typedef void (*shbde_log_func_t)(int level, const char *str, int param);
#define SHBDE_ERR 0
#define SHBDE_WARN 1
#define SHBDE_DBG 2
/* Hardware abstraction functions */
typedef struct shbde_hal_s {
/* Optional log output interface */
shbde_log_func_t log_func;
/* PCI configuration access */
unsigned char (*pcic8_read)(void *pci_dev, unsigned int reg);
void (*pcic8_write)(void *pci_dev, unsigned int reg, unsigned char data);
unsigned short (*pcic16_read)(void *pci_dev, unsigned int reg);
void (*pcic16_write)(void *pci_dev, unsigned int reg, unsigned short data);
unsigned int (*pcic32_read)(void *pci_dev, unsigned int reg);
void (*pcic32_write)(void *pci_dev, unsigned int reg, unsigned int data);
/* iProc register access */
unsigned int (*io32_read)(void *addr);
void (*io32_write)(void *addr, unsigned int);
/* usleep function (optional) */
void (*usleep)(int usec);
/* PCI parent device access */
void *(*pci_parent_device_get)(void *pci_dev);
} shbde_hal_t;
/* iProc configuration (primarily used for PCI-AXI bridge) */
typedef struct shbde_iproc_config_s {
unsigned int dev_id;
unsigned int dev_rev;
unsigned int use_msi;
unsigned int iproc_ver;
unsigned int dma_hi_bits;
unsigned int mdio_base_addr;
unsigned int pcie_phy_addr;
unsigned int adjust_pcie_preemphasis;
} shbde_iproc_config_t;
#endif /* __SHBDE_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: $
* $Copyright: (c) 2014 Broadcom Corp.
* All Rights Reserved.$
*
*/
#ifndef __SHBDE_IPROC_H__
#define __SHBDE_IPROC_H__
#include <shbde.h>
extern int
shbde_iproc_config_init(shbde_iproc_config_t *icfg,
unsigned int dev_id, unsigned int dev_rev);
extern int
shbde_iproc_paxb_init(shbde_hal_t *shbde, void *iproc_regs,
shbde_iproc_config_t *icfg);
extern unsigned int
shbde_iproc_pci_read(shbde_hal_t *shbde, void *iproc_regs,
unsigned int addr);
extern void
shbde_iproc_pci_write(shbde_hal_t *shbde, void *iproc_regs,
unsigned int addr, unsigned int data);
extern int
shbde_iproc_pcie_preemphasis_set(shbde_hal_t *shbde, void *iproc_regs,
shbde_iproc_config_t *icfg, void *pci_dev);
#endif /* __SHBDE_IPROC_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: $
* $Copyright: (c) 2015 Broadcom Corp.
* All Rights Reserved.$
*
*/
#ifndef __SHBDE_MDIO_H__
#define __SHBDE_MDIO_H__
#include <shbde.h>
typedef struct shbde_mdio_ctrl_s {
/* Primary HAL*/
shbde_hal_t *shbde;
/* Context for iProc MDIO register access */
void *regs;
/* Base address for MDIO registers */
unsigned int base_addr;
/* iProc MDIO register access */
unsigned int (*io32_read)(shbde_hal_t *shbde, void *iproc_regs,
unsigned int addr);
void (*io32_write)(shbde_hal_t *shbde, void *iproc_regs,
unsigned int addr, unsigned int data);
} shbde_mdio_ctrl_t;
extern int
shbde_iproc_mdio_init(shbde_mdio_ctrl_t *smc);
extern int
shbde_iproc_mdio_read(shbde_mdio_ctrl_t *smc, unsigned int phy_addr,
unsigned int reg, unsigned int *val);
extern int
shbde_iproc_mdio_write(shbde_mdio_ctrl_t *smc, unsigned int phy_addr,
unsigned int reg, unsigned int val);
#endif /* __SHBDE_MDIO_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: $
* $Copyright: (c) 2014 Broadcom Corp.
* All Rights Reserved.$
*
*/
#ifndef __SHBDE_PCI_H__
#define __SHBDE_PCI_H__
#include <shbde.h>
extern unsigned int
shbde_pci_pcie_cap(shbde_hal_t *shbde, void *pci_dev);
extern int
shbde_pci_is_pcie(shbde_hal_t *shbde, void *pci_dev);
extern int
shbde_pci_is_iproc(shbde_hal_t *shbde, void *pci_dev, int *cmic_bar);
extern int
shbde_pci_max_payload_set(shbde_hal_t *shbde, void *pci_dev, int maxpayload);
#endif /* __SHBDE_PCI_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: $
* $Copyright: (c) 2014 Broadcom Corp.
* All Rights Reserved.$
*
*/
#include <shbde_iproc.h>
#include <shbde_mdio.h>
#include <shbde_pci.h>
/* PAXB register offsets within PCI BAR0 window */
#define BAR0_PAXB_ENDIANESS 0x2030
#define BAR0_PAXB_PCIE_EP_AXI_CONFIG 0x2104
#define BAR0_PAXB_CONFIG_IND_ADDR 0x2120
#define BAR0_PAXB_CONFIG_IND_DATA 0x2124
#define BAR0_PAXB_IMAP0_0 0x2c00
#define BAR0_PAXB_IMAP0_1 0x2c04
#define BAR0_PAXB_IMAP0_2 0x2c08
#define BAR0_PAXB_IMAP0_7 0x2c1c
#define BAR0_PAXB_OARR_FUNC0_MSI_PAGE 0x2d34
#define BAR0_PAXB_OARR_2 0x2d60
#define BAR0_PAXB_OARR_2_UPPER 0x2d64
#define BAR0_DMU_PCU_PCIE_SLAVE_RESET_MODE 0x7024
/* Force byte pointer for offset adjustments */
#define ROFFS(_ptr, _offset) ((unsigned char*)(_ptr) + (_offset))
#define PAXB_CONFIG_IND_ADDRr_PROTOCOL_LAYERf_SHFT 11
#define PAXB_CONFIG_IND_ADDRr_PROTOCOL_LAYERf_MASK 0x3
#define PAXB_CONFIG_IND_ADDRr_ADDRESSf_SHFT 0
#define PAXB_CONFIG_IND_ADDRr_ADDRESSf_MASK 0x7ff
/* Register value set/get by field */
#define REG_FIELD_SET(_r, _f, _r_val, _f_val) \
_r_val = ((_r_val) & ~(_r##_##_f##_MASK << _r##_##_f##_SHFT)) | \
(((_f_val) & _r##_##_f##_MASK) << _r##_##_f##_SHFT)
#define REG_FIELD_GET(_r, _f, _r_val) \
(((_r_val) >> _r##_##_f##_SHFT) & _r##_##_f##_MASK)
/* PCIe capabilities definition */
#ifndef PCI_EXP_LNKSTA
#define PCI_EXP_LNKSTA 0x12
#endif
/* Current Link Speed 5.0GT/s */
#ifndef PCI_EXP_LNKSTA_CLS_5_0GB
#define PCI_EXP_LNKSTA_CLS_5_0GB 2
#endif
#ifndef PCI_EXP_LNKSTA2
#define PCI_EXP_LNKSTA2 0x32
#endif
/* Current Deemphasis Level -3.5 dB */
#ifndef PCI_EXP_LNKSTA2_CDL_3_5DB
#define PCI_EXP_LNKSTA2_CDL_3_5DB 0x1
#endif
static unsigned int
iproc32_read(shbde_hal_t *shbde, void *addr)
{
if (!shbde || !shbde->io32_read) {
return 0;
}
return shbde->io32_read(addr);
}
static void
iproc32_write(shbde_hal_t *shbde, void *addr, unsigned int data)
{
if (!shbde || !shbde->io32_write) {
return;
}
shbde->io32_write(addr, data);
}
static void
wait_usec(shbde_hal_t *shbde, int usec)
{
if (shbde && shbde->usleep) {
shbde->usleep(usec);
} else {
int idx;
volatile int count;
for (idx = 0; idx < usec; idx++) {
for (count = 0; count < 100; count++);
}
}
}
/*
* Function:
* shbde_iproc_config_init
* Purpose:
* Initialize iProc configuration parameters
* Parameters:
* icfg - pointer to empty iProc configuration structure
* Returns:
* -1 if error, otherwise 0
*/
int
shbde_iproc_config_init(shbde_iproc_config_t *icfg,
unsigned int dev_id, unsigned int dev_rev)
{
if (!icfg) {
return -1;
}
/* Save device ID and revision */
icfg->dev_id = dev_id;
icfg->dev_rev = dev_rev;
/* Check device families first */
switch (icfg->dev_id & 0xfff0) {
case 0x8400: /* Greyhound Lite */
case 0x8410: /* Greyhound */
case 0x8420: /* Bloodhound */
case 0x8450: /* Elkhound */
case 0xb060: /* Ranger2(Greyhound) */
case 0x8360: /* Greyhound Lite w/o L3 */
case 0xb260: /* saber2 */
case 0xb460: /* saber2+ */
case 0xb230: /* Dagger2 */
icfg->iproc_ver = 7;
icfg->dma_hi_bits = 0x2;
break;
default:
break;
}
/* Check for PCIe PHY address that needs PCIe preemphasis and
* assign the MDIO base address
*/
switch (icfg->dev_id & 0xfff0) {
case 0xb150: /* Hurricane2 */
case 0x8340: /* Wolfhound */
case 0x8330: /* Foxhound */
case 0x8390: /* Dearhound */
icfg->mdio_base_addr = 0x18032000;
icfg->pcie_phy_addr = 0x2;
break;
case 0xb340: /* Helilx4 */
case 0xb540: /* FireScout */
case 0xb040: /* Spiral, Ranger */
icfg->mdio_base_addr = 0x18032000;
icfg->pcie_phy_addr = 0x5;
icfg->adjust_pcie_preemphasis = 1;
break;
case 0xa450: /* Katana2 */
case 0xb240:
case 0xb450:
icfg->mdio_base_addr = 0x18032000;
icfg->pcie_phy_addr = 0x5;
icfg->adjust_pcie_preemphasis = 1;
break;
default:
break;
}
/* Check for exceptions */
switch (icfg->dev_id) {
default:
break;
}
return 0;
}
/*
* Function:
* shbde_iproc_paxb_init
* Purpose:
* Initialize iProc PCI-AXI bridge for CMIC access
* Parameters:
* shbde - pointer to initialized hardware abstraction module
* iproc_regs - memory mapped iProc registers in PCI BAR
* icfg - iProc configuration parameters
* Returns:
* -1 if error, otherwise 0
*/
int
shbde_iproc_paxb_init(shbde_hal_t *shbde, void *iproc_regs,
shbde_iproc_config_t *icfg)
{
void *reg;
unsigned int data;
int pci_num;
if (!iproc_regs || !icfg) {
return -1;
}
/*
* The following code attempts to auto-detect the correct
* iProc PCI endianess configuration by reading a well-known
* register (the endianess configuration register itself).
* Note that the PCI endianess may be different for different
* big endian host processors.
*/
reg = ROFFS(iproc_regs, BAR0_PAXB_ENDIANESS);
/* Select big endian */
iproc32_write(shbde, reg, 0x01010101);
/* Check if endianess register itself is correct endian */
if (iproc32_read(shbde, reg) != 1) {
/* If not, then assume little endian */
iproc32_write(shbde, reg, 0x0);
}
/* Select which PCI core to use */
pci_num = 0;
reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_2);
data = iproc32_read(shbde, reg);
if (data & 0x1000) {
/* PAXB_1 is mapped to sub-window 2 */
pci_num = 1;
}
/* Default DMA mapping if uninitialized */
if (icfg->dma_hi_bits == 0) {
icfg->dma_hi_bits = 0x1;
if (pci_num == 1) {
icfg->dma_hi_bits = 0x2;
}
}
/* Enable iProc DMA to external host memory */
reg = ROFFS(iproc_regs, BAR0_PAXB_PCIE_EP_AXI_CONFIG);
iproc32_write(shbde, reg, 0x0);
reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_2);
iproc32_write(shbde, reg, 0x1);
reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_2_UPPER);
iproc32_write(shbde, reg, icfg->dma_hi_bits);
/* Configure MSI interrupt page */
if (icfg->use_msi) {
reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_FUNC0_MSI_PAGE);
data = iproc32_read(shbde, reg);
iproc32_write(shbde, reg, data | 0x1);
}
return pci_num;
}
/*
* Function:
* shbde_iproc_pci_read
* Purpose:
* Read iProc register through PCI BAR 0
* Parameters:
* shbde - pointer to initialized hardware abstraction module
* iproc_regs - memory mapped iProc registers in PCI BAR
* addr - iProc register address in AXI memory space
* Returns:
* Register value
*/
unsigned int
shbde_iproc_pci_read(shbde_hal_t *shbde, void *iproc_regs,
unsigned int addr)
{
unsigned int subwin_base;
void *reg;
if (!iproc_regs) {
return -1;
}
/* Sub-window size is 0x1000 (4K) */
subwin_base = (addr & ~0xfff) | 0x1;
/* Update base address for sub-window 7 */
reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_7);
iproc32_write(shbde, reg, subwin_base);
/* Read register through sub-window 7 */
reg = ROFFS(iproc_regs, 0x7000 + (addr & 0xfff));
return iproc32_read(shbde, reg);
}
/*
* Function:
* shbde_iproc_pci_write
* Purpose:
* Write iProc register through PCI BAR 0
* Parameters:
* shbde - pointer to initialized hardware abstraction module
* iproc_regs - memory mapped iProc registers in PCI BAR
* addr - iProc register address in AXI memory space
* data - data to write to iProc register
* Returns:
* Register value
*/
void
shbde_iproc_pci_write(shbde_hal_t *shbde, void *iproc_regs,
unsigned int addr, unsigned int data)
{
unsigned int subwin_base;
void *reg;
if (!iproc_regs) {
return;
}
/* Sub-window size is 0x1000 (4K) */
subwin_base = (addr & ~0xfff) | 0x1;
/* Update base address for sub-window 7 */
reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_7);
iproc32_write(shbde, reg, subwin_base);
/* Write register through sub-window 7 */
reg = ROFFS(iproc_regs, 0x7000 + (addr & 0xfff));
iproc32_write(shbde, reg, data);
}
int
shbde_iproc_pcie_preemphasis_set(shbde_hal_t *shbde, void *iproc_regs,
shbde_iproc_config_t *icfg, void *pci_dev)
{
shbde_mdio_ctrl_t mdio_ctrl, *smc = &mdio_ctrl;
unsigned int phy_addr, data;
void *reg;
unsigned int pcie_cap_base;
unsigned short link_stat, link_stat2;
if (!icfg) {
return -1;
}
/* PHY address for PCIe link */
phy_addr = icfg->pcie_phy_addr;
if (phy_addr == 0 || icfg->mdio_base_addr == 0) {
return 0;
}
/* Initialize MDIO control */
smc->shbde = shbde;
smc->regs = iproc_regs;
smc->base_addr = icfg->mdio_base_addr;
smc->io32_read = shbde_iproc_pci_read;
smc->io32_write = shbde_iproc_pci_write;
shbde_iproc_mdio_init(smc);
/* PCIe SerDes Gen1/Gen2 CDR Track Bandwidth Adjustment
* for Better Jitter Tolerance
*/
shbde_iproc_mdio_write(smc, phy_addr, 0x1f, 0x8630);
shbde_iproc_mdio_write(smc, phy_addr, 0x13, 0x190);
shbde_iproc_mdio_write(smc, phy_addr, 0x19, 0x191);
if (!icfg->adjust_pcie_preemphasis) {
return 0;
}
/* Check to see if the PCIe SerDes deemphasis needs to be changed
* based on the advertisement from the root complex
*/
/* Find PCIe capability base */
if (!shbde || !shbde->pcic16_read || !pci_dev) {
return -1;
}
pcie_cap_base = shbde_pci_pcie_cap(shbde, pci_dev);
if (pcie_cap_base) {
link_stat = shbde->pcic16_read(pci_dev,
pcie_cap_base + PCI_EXP_LNKSTA);
link_stat2 = shbde->pcic16_read(pci_dev,
pcie_cap_base + PCI_EXP_LNKSTA2);
if (((link_stat & 0xf) == PCI_EXP_LNKSTA_CLS_5_0GB) &&
(link_stat2 & PCI_EXP_LNKSTA2_CDL_3_5DB)) {
/* Device is operating at Gen2 speeds and RC requested -3.5dB */
/* Change the transmitter setting */
shbde_iproc_mdio_write(smc, phy_addr, 0x1f, 0x8610);
shbde_iproc_mdio_read(smc, phy_addr, 0x17, &data);
data &= ~0xf00;
data |= 0x700;
shbde_iproc_mdio_write(smc, phy_addr, 0x17, data);
/* Force the PCIe link to retrain */
data = 0;
REG_FIELD_SET(PAXB_CONFIG_IND_ADDRr, PROTOCOL_LAYERf, data, 0x2);
REG_FIELD_SET(PAXB_CONFIG_IND_ADDRr, ADDRESSf, data, 0x4);
reg = ROFFS(iproc_regs, BAR0_PAXB_CONFIG_IND_ADDR);
iproc32_write(shbde, reg, data);
reg = ROFFS(iproc_regs, BAR0_PAXB_CONFIG_IND_DATA);
data = iproc32_read(shbde, reg);
data &= ~0x4000;
iproc32_write(shbde, reg, data);
data |= 0x4000;
iproc32_write(shbde, reg, data);
data &= ~0x4000;
iproc32_write(shbde, reg, data);
/* Wait a short while for the retraining to complete */
wait_usec(shbde, 1000);
}
}
return 0;
}
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: $
* $Copyright: (c) 2015 Broadcom Corp.
* All Rights Reserved.$
*
*/
#include <shbde_mdio.h>
/* iProc MDIO register offset */
#define MII_MGMT_CTRL 0x0
#define MII_MGMT_CMD_DATA 0x4
/* iProc MII register with fields definition */
#define MII_MGMT_CTRLr_MDCDIVf_SHFT 0
#define MII_MGMT_CTRLr_MDCDIVf_MASK 0x7f
#define MII_MGMT_CTRLr_BSYf_SHFT 8
#define MII_MGMT_CTRLr_BSYf_MASK 0x1
#define MII_MGMT_CMD_DATAr_DATAf_SHFT 0
#define MII_MGMT_CMD_DATAr_DATAf_MASK 0xffff
#define MII_MGMT_CMD_DATAr_TAf_SHFT 16
#define MII_MGMT_CMD_DATAr_TAf_MASK 0x3
#define MII_MGMT_CMD_DATAr_RAf_SHFT 18
#define MII_MGMT_CMD_DATAr_RAf_MASK 0x1f
#define MII_MGMT_CMD_DATAr_PAf_SHFT 23
#define MII_MGMT_CMD_DATAr_PAf_MASK 0x1f
#define MII_MGMT_CMD_DATAr_OPf_SHFT 28
#define MII_MGMT_CMD_DATAr_OPf_MASK 0x3
#define MII_MGMT_CMD_DATAr_SBf_SHFT 30
#define MII_MGMT_CMD_DATAr_SBf_MASK 0x3
/* Register field value set/get */
#define REG_FIELD_SET(_r, _f, _r_val, _f_val) \
_r_val = ((_r_val) & ~(_r##_##_f##_MASK << _r##_##_f##_SHFT)) | \
(((_f_val) & _r##_##_f##_MASK) << _r##_##_f##_SHFT)
#define REG_FIELD_GET(_r, _f, _r_val) \
(((_r_val) >> _r##_##_f##_SHFT) & _r##_##_f##_MASK)
#define LOG_OUT(_shbde, _lvl, _str, _prm) \
if ((_shbde)->log_func) { \
(_shbde)->log_func(_lvl, _str, _prm); \
}
#define LOG_ERR(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_ERR, _str, _prm)
#define LOG_WARN(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_WARN, _str, _prm)
#define LOG_DBG(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_DBG, _str, _prm)
static unsigned int
mdio32_read(shbde_mdio_ctrl_t *smc, unsigned int offset)
{
if (!smc || !smc->io32_read) {
return 0;
}
return smc->io32_read(smc->shbde, smc->regs, smc->base_addr + offset);
}
static void
mdio32_write(shbde_mdio_ctrl_t *smc, unsigned int offset, unsigned int data)
{
if (!smc || !smc->io32_read) {
return;
}
smc->io32_write(smc->shbde, smc->regs, smc->base_addr + offset, data);
}
static void
wait_usec(shbde_mdio_ctrl_t *smc, int usec)
{
shbde_hal_t *shbde = smc->shbde;
if (shbde && shbde->usleep) {
shbde->usleep(usec);
} else {
int idx;
volatile int count;
for (idx = 0; idx < usec; idx++) {
for (count = 0; count < 100; count++);
}
}
}
static int
iproc_mdio_wait_for_busy(shbde_mdio_ctrl_t *smc)
{
int mii_busy;
unsigned int reg_val;
int count = 1000;
/* Wait until MII is not busy */
do {
reg_val = mdio32_read(smc, MII_MGMT_CTRL);
mii_busy = REG_FIELD_GET(MII_MGMT_CTRLr, BSYf, reg_val);
if (!mii_busy) {
break;
}
wait_usec(smc, 10);
count --;
} while (count > 0);
return mii_busy;
}
int
shbde_iproc_mdio_init(shbde_mdio_ctrl_t *smc)
{
shbde_hal_t *shbde = smc->shbde;
unsigned int reg_val = 0;
/* Enable the iProc internal MDIO interface */
REG_FIELD_SET(MII_MGMT_CTRLr, MDCDIVf, reg_val, 0x7f);
mdio32_write(smc, MII_MGMT_CTRL, reg_val);
if (shbde && !shbde->usleep) {
LOG_DBG(shbde, "shbde_mdio: no registration of usleep vector", 0);
}
wait_usec(smc, 100);
return 0;
}
int
shbde_iproc_mdio_read(shbde_mdio_ctrl_t *smc, unsigned int phy_addr,
unsigned int reg, unsigned int *val)
{
unsigned int reg_val = 0;
REG_FIELD_SET(MII_MGMT_CMD_DATAr, SBf, reg_val, 0x1);
REG_FIELD_SET(MII_MGMT_CMD_DATAr, TAf, reg_val, 0x2);
REG_FIELD_SET(MII_MGMT_CMD_DATAr, OPf, reg_val, 0x2);
REG_FIELD_SET(MII_MGMT_CMD_DATAr, PAf, reg_val, phy_addr);
REG_FIELD_SET(MII_MGMT_CMD_DATAr, RAf, reg_val, reg);
mdio32_write(smc, MII_MGMT_CMD_DATA, reg_val);
if (iproc_mdio_wait_for_busy(smc)) {
*val = 0;
LOG_DBG(smc->shbde, "shbde_iproc_mdio_read busy", reg);
return -1;
}
reg_val = mdio32_read(smc, MII_MGMT_CMD_DATA);
*val = REG_FIELD_GET(MII_MGMT_CMD_DATAr, DATAf, reg_val);
return 0;
}
int
shbde_iproc_mdio_write(shbde_mdio_ctrl_t *smc, unsigned int phy_addr,
unsigned int reg, unsigned int val)
{
unsigned int reg_val = 0;
REG_FIELD_SET(MII_MGMT_CMD_DATAr, SBf, reg_val, 0x1);
REG_FIELD_SET(MII_MGMT_CMD_DATAr, TAf, reg_val, 0x2);
REG_FIELD_SET(MII_MGMT_CMD_DATAr, OPf, reg_val, 0x1);
REG_FIELD_SET(MII_MGMT_CMD_DATAr, PAf, reg_val, phy_addr);
REG_FIELD_SET(MII_MGMT_CMD_DATAr, RAf, reg_val, reg);
REG_FIELD_SET(MII_MGMT_CMD_DATAr, DATAf, reg_val, val);
mdio32_write(smc, MII_MGMT_CMD_DATA, reg_val);
if (iproc_mdio_wait_for_busy(smc)) {
LOG_DBG(smc->shbde, "shbde_iproc_mdio_write busy", reg);
return -1;
}
/* Wait for some time for the write to take effect */
wait_usec(smc, 100);
return 0;
}
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: $
* $Copyright: (c) 2014 Broadcom Corp.
* All Rights Reserved.$
*
*/
#include <shbde_pci.h>
/* PCIe capabilities */
#ifndef PCI_CAPABILITY_LIST
#define PCI_CAPABILITY_LIST 0x34
#endif
#ifndef PCI_CAP_ID_EXP
#define PCI_CAP_ID_EXP 0x10
#endif
#ifndef PCI_EXP_DEVCAP
#define PCI_EXP_DEVCAP 4
#endif
#ifndef PCI_EXP_DEVCTL
#define PCI_EXP_DEVCTL 8
#endif
#ifndef PCI_EXT_CAP_START
#define PCI_EXT_CAP_START 0x100
#endif
#ifndef PCI_EXT_CAP_ID
#define PCI_EXT_CAP_ID(_hdr) (_hdr & 0x0000ffff)
#endif
#ifndef PCI_EXT_CAP_VER
#define PCI_EXT_CAP_VER(_hdr) ((_hdr >> 16) & 0xf)
#endif
#ifndef PCI_EXT_CAP_NEXT
#define PCI_EXT_CAP_NEXT(_hdr) ((_hdr >> 20) & 0xffc)
#endif
#ifndef PCI_EXT_CAP_ID_VNDR
#define PCI_EXT_CAP_ID_VNDR 0x0b
#endif
#define LOG_OUT(_shbde, _lvl, _str, _prm) \
if ((_shbde)->log_func) { \
(_shbde)->log_func(_lvl, _str, _prm); \
}
#define LOG_ERR(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_ERR, _str, _prm)
#define LOG_WARN(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_WARN, _str, _prm)
#define LOG_DBG(_shbde, _str, _prm) LOG_OUT(_shbde, SHBDE_DBG, _str, _prm)
#ifndef NULL
#define NULL (void *)0
#endif
/*
* Warpper functions with null-pointer checks.
*/
static unsigned int
pcic16_read(shbde_hal_t *shbde, void *pci_dev,
unsigned int addr)
{
if (!shbde || !shbde->pcic16_read) {
return 0;
}
return shbde->pcic16_read(pci_dev, addr);
}
static void
pcic16_write(shbde_hal_t *shbde, void *pci_dev,
unsigned int addr, unsigned int data)
{
if (!shbde || !shbde->pcic16_write) {
return;
}
shbde->pcic16_write(pci_dev, addr, data);
}
static unsigned int
pcic32_read(shbde_hal_t *shbde, void *pci_dev,
unsigned int addr)
{
if (!shbde || !shbde->pcic32_read) {
return 0;
}
return shbde->pcic32_read(pci_dev, addr);
}
static void *
pci_parent_device_get(shbde_hal_t *shbde, void *pci_dev)
{
if (!shbde || !shbde->pci_parent_device_get) {
return NULL;
}
return shbde->pci_parent_device_get(pci_dev);
}
/*
* Function:
* shbde_pci_pcie_cap
* Purpose:
* Return offset of PCIe capabilities in PCI configuration space
* Parameters:
* shbde - pointer to initialized hardware abstraction module
* dev - PCI device handle (passed back to PCI HAL functions)
* Returns:
* PCI_CAP_ID_EXP offset in PCI configuration space if PCIe, otherwise 0
*/
unsigned int
shbde_pci_pcie_cap(shbde_hal_t *shbde, void *pci_dev)
{
unsigned int cap_base, rval;
cap_base = pcic16_read(shbde, pci_dev, PCI_CAPABILITY_LIST);
while (cap_base) {
rval = pcic16_read(shbde, pci_dev, cap_base);
if ((rval & 0xff) == PCI_CAP_ID_EXP) {
break;
}
cap_base = (rval >> 8) & 0xff;
}
return cap_base;
}
/*
* Function:
* shbde_pci_is_pcie
* Purpose:
* Check if PCI device is PCIe device
* Parameters:
* shbde - pointer to initialized hardware abstraction module
* dev - PCI device handle (passed back to PCI HAL functions)
* Returns:
* 1 if PCIe, otherwise 0
*/
int
shbde_pci_is_pcie(shbde_hal_t *shbde, void *pci_dev)
{
return shbde_pci_pcie_cap(shbde, pci_dev) ? 1 : 0;
}
/*
* Function:
* shbde_pci_is_iproc
* Purpose:
* Check if PCI device is iProc-based
* Parameters:
* shbde - pointer to initialized hardware abstraction module
* dev - PCI device handle (passed back to PCI HAL functions)
* cmic_bar - (OUT) PCI BAR which contains switch CMIC registers
* Returns:
* 1 if iProc-based, otherwise 0
*/
int
shbde_pci_is_iproc(shbde_hal_t *shbde, void *pci_dev, int *cmic_bar)
{
unsigned int cap_base, rval;
if (!shbde_pci_is_pcie(shbde, pci_dev)) {
return 0;
}
/* Look for PCIe vendor-specific extended capability (VSEC) */
cap_base = PCI_EXT_CAP_START;
while (cap_base) {
rval = pcic32_read(shbde, pci_dev, cap_base);
if (rval == 0xffffffff) {
/* Assume PCI HW read error */
return 0;
}
if (PCI_EXT_CAP_ID(rval) == PCI_EXT_CAP_ID_VNDR) {
break;
}
cap_base = PCI_EXT_CAP_NEXT(rval);
}
if (cap_base) {
/*
* VSEC layout:
*
* 0x00: PCI Express Extended Capability Header
* 0x04: Vendor-Specific Header
* 0x08: Vendor-Specific Register 1
* 0x0c: Vendor-Specific Register 2
* ...
* 0x24: Vendor-Specific Register 8
*/
rval = pcic32_read(shbde, pci_dev, cap_base + 8);
LOG_DBG(shbde, "Found VSEC", rval);
/* Determine PCI BAR of CMIC */
*cmic_bar = 0;
if ((rval == 0x101) || (rval == 0x100)) { /* FIXME SDK-65019 SABER2_TOT_PRE_MERGE */
*cmic_bar = 2;
}
/* Assume iProc device */
return 1;
}
return 0;
}
/*
* Function:
* shbde_pci_max_payload_set
* Purpose:
* Set PCIe maximum payload
* Parameters:
* shbde - pointer to initialized hardware abstraction module
* dev - PCI device handle (passed back to PCI HAL functions)
* maxpayload - maximum payload (in byte)
* Returns:
* -1 if error, otherwise 0
* Notes:
* If not PCIe device, set the PCI retry count to infinte instead.
*/
int
shbde_pci_max_payload_set(shbde_hal_t *shbde, void *pci_dev, int maxpayload)
{
unsigned int cap_base, parent_cap_base;
unsigned int devcap, devctl, parent_devctl;
int max_val, max_cap, parent_max_val;
void *parent_pci_dev;
cap_base = shbde_pci_pcie_cap(shbde, pci_dev);
if (cap_base == 0) {
/* Not PCIe */
return 0;
}
/* Get current device control settings */
devctl = pcic16_read(shbde, pci_dev, cap_base + PCI_EXP_DEVCTL);
/* Get current max payload setting */
max_val = (devctl >> 5) & 0x7;
if (maxpayload) {
/* Get encoding from byte value */
max_val = 0;
while ((1 << (max_val + 7)) < maxpayload) {
max_val++;
}
LOG_DBG(shbde, "Set max payload size", maxpayload);
LOG_DBG(shbde, "Set max payload val", max_val);
/* Get max supported payload size */
devcap = pcic16_read(shbde, pci_dev, cap_base + PCI_EXP_DEVCAP);
max_cap = (devcap & 0x7);
/* Do not exceed device capabilities */
if (max_val > max_cap) {
max_val = max_cap;
LOG_DBG(shbde,
"Payload size exceeds device capability",
maxpayload);
}
/* Get currently set max payload size for the parent device
* in the PCI tree (if it exists).
*/
parent_pci_dev = pci_parent_device_get(shbde, pci_dev);
if (parent_pci_dev != NULL) {
parent_cap_base = shbde_pci_pcie_cap(shbde, parent_pci_dev);
parent_devctl = pcic16_read(shbde,
parent_pci_dev,
parent_cap_base + PCI_EXP_DEVCTL);
parent_max_val = (parent_devctl >> 5) & 0x7;
/* Do not exceed current parent max payload setting (our device
* should have an MPS setting <= current parent MPS setting in
* the tree of PCIe devices).
*/
if (max_val > parent_max_val) {
max_val = parent_max_val;
LOG_DBG(shbde,
"Payload size exceeds current parent device setting",
maxpayload);
}
}
/* Update max payload size */
devctl &= ~(0x7 << 5);
devctl |= (max_val) << 5;
/* Update max request size */
devctl &= ~(0x7 << 12);
devctl |= (max_val << 12);
}
/* Always disable relaxed ordering */
devctl &= ~(1 << 4);
/* Update device control settings */
pcic16_write(shbde, pci_dev, cap_base + PCI_EXP_DEVCTL, devctl);
/* Warn if non-default setting is used */
if (max_val > 0) {
LOG_WARN(shbde,
"Selected payload size may not be supported by all "
"PCIe bridges by default.",
(1 << (max_val + 7)));
}
return 0;
}
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# -*- Makefile -*-
# $Id: Makefile,v 1.10 2006/07/10 08:07:45 ako Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
# Makefile for SOC SAL support
#
LOCALDIR = systems/linux/kernel/modules
include ${SDK}/make/Make.config
subdirs=shared uk-proxy bcm-diag-full bcm-core bcm-net bcm-diag
include ${SDK}/make/Make.subdirs
include ${SDK}/make/Make.depend
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# -*- Makefile -*-
# $Id: Makefile,v 1.3 2012/07/17 07:39:51 mlarsen Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
LOCALDIR = systems/linux/kernel/modules/bcm-knet
include ${SDK}/make/Make.config
LIBS = $(LIBDIR)/libkern.a
ifeq ($(kernel_version),2_4)
MODULE = $(LIBDIR)/linux-bcm-knet.o
else
KERNEL_MODULE_DIR = kernel_module
THIS_MOD_NAME := linux-bcm-knet
MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o
KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko
build: $(MODULE) $(KMODULE)
endif
KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../../../../bde/linux/kernel/kernel_module/Module.symvers
ifeq (,$(findstring -DPROXY_SUPPORT=0,$(CFLAGS)))
KBUILD_EXTRA_SYMBOLS += ${BLDDIR}/../uk-proxy/kernel_module/Module.symvers
endif
# BCM Network Device
$(MODULE): $(BLDDIR)/.tree $(BOBJS) $(LIBS)
$(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@
ifneq ($(kernel_version),2_4)
$(KMODULE): $(MODULE)
rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR)
mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR)
cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile
cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers
MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko
endif
# Make.depend is before clean:: so that Make.depend's clean:: runs first.
include ${SDK}/make/Make.depend
clean::
$(RM) $(BLDDIR)/version.c $(BLDDIR)/version.o
$(RM) $(BOBJS) $(MODULE)
ifneq ($(kernel_version),2_4)
.PHONY: build
endif
This source diff could not be displayed because it is too large. You can view the blob instead.
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: bcm-knet.h,v 1.4 2013/03/01 07:54:20 mlarsen Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#ifndef __LINUX_BCM_KNET_H__
#define __LINUX_BCM_KNET_H__
#ifndef __KERNEL__
#include <stdint.h>
#endif
typedef struct {
int rc;
int len;
int bufsz;
int reserved;
uint64_t buf;
} bkn_ioctl_t;
#ifdef __KERNEL__
/*
* Call-back interfaces for other Linux kernel drivers.
*/
#include <linux/skbuff.h>
typedef struct sk_buff *
(*knet_skb_cb_f)(struct sk_buff *skb, int dev_no, void *meta);
typedef int
(*knet_filter_cb_f)(uint8_t *pkt, int size, int dev_no, void *meta,
int chan, kcom_filter_t *filter);
extern int
bkn_rx_skb_cb_register(knet_skb_cb_f rx_cb);
extern int
bkn_rx_skb_cb_unregister(knet_skb_cb_f rx_cb);
extern int
bkn_tx_skb_cb_register(knet_skb_cb_f tx_cb);
extern int
bkn_tx_skb_cb_unregister(knet_skb_cb_f tx_cb);
extern int
bkn_filter_cb_register(knet_filter_cb_f filter_cb);
extern int
bkn_filter_cb_unregister(knet_filter_cb_f filter_cb);
#endif
#endif /* __LINUX_BCM_KNET_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: gmodule.h,v 1.9 2013/01/23 04:43:06 gili Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#ifndef __COMMON_LINUX_KRN_GMODULE_H__
#define __COMMON_LINUX_KRN_GMODULE_H__
#include <lkm.h>
typedef struct gmodule_s {
const char* name;
int major;
int minor;
int (*init)(void);
int (*cleanup)(void);
int (*pprint)(void);
int (*open)(void);
int (*ioctl)(unsigned int cmd, unsigned long arg);
int (*close)(void);
int (*mmap) (struct file *filp, struct vm_area_struct *vma);
} gmodule_t;
/* The framework will ask for your module definition */
extern gmodule_t* gmodule_get(void);
/* Proc Filesystem information */
extern int pprintf(const char* fmt, ...)
__attribute__ ((format (printf, 1, 2)));
extern int gmodule_vpprintf(char** page, const char* fmt, va_list args)
__attribute__ ((format (printf, 2, 0)));
extern int gmodule_pprintf(char** page, const char* fmt, ...)
__attribute__ ((format (printf, 2, 3)));
extern int gprintk(const char* fmt, ...)
__attribute__ ((format (printf, 1, 2)));
extern int gdbg(const char* fmt, ...)
__attribute__ ((format (printf, 1, 2)));
#define GDBG gdbg
#endif /* __COMMON_LINUX_KRN_GMODULE_H__ */
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: lkm.h,v 1.22 2013/03/06 23:44:17 mlarsen Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#ifndef __COMMON_LINUX_KRN_LKM_H__
#define __COMMON_LINUX_KRN_LKM_H__
#ifndef __KERNEL__
# define __KERNEL__
#endif
#ifndef MODULE
# define MODULE
#endif
#include <linux/init.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
#include <linux/config.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
#include <linux/kconfig.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
#include <linux/slab.h>
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
#include <linux/smp_lock.h>
#endif
#include <linux/module.h>
/* Helper defines for multi-version kernel support */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
#define LKM_2_4
#else
#define LKM_2_6
#endif
#include <linux/kernel.h> /* printk() */
#include <linux/fs.h> /* everything... */
#include <linux/errno.h> /* error codes */
#include <linux/types.h> /* size_t */
#include <linux/proc_fs.h>
#include <linux/fcntl.h> /* O_ACCMODE */
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/stat.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <asm/io.h>
#include <asm/hardirq.h>
#include <asm/uaccess.h>
#ifdef CONFIG_DEVFS_FS
#include <linux/devfs_fs_kernel.h>
#endif
#define PROC_INTERFACE_KERN_VER_3_10 (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
/* Compatibility Macros */
#ifdef LKM_2_4
#include <linux/compatmac.h>
#include <linux/wrapper.h>
#define LKM_MOD_PARAM(n,ot,nt,d) MODULE_PARM(n,ot)
#define LKM_MOD_PARAM_ARRAY(n,ot,nt,c,d) MODULE_PARM(n,ot)
#define LKM_EXPORT_SYM(s)
#define _free_netdev kfree
#else /* LKM_2_6 */
#define LKM_MOD_PARAM(n,ot,nt,d) module_param(n,nt,d)
#define LKM_MOD_PARAM_ARRAY(n,ot,nt,c,d) module_param_array(n,nt,c,d)
#define LKM_EXPORT_SYM(s) EXPORT_SYMBOL(s)
#define _free_netdev free_netdev
#endif /* LKM_2_x */
#ifndef list_for_each_safe
#define list_for_each_safe(l,t,i) t = 0; list_for_each((l),(i))
#endif
#ifndef reparent_to_init
#define reparent_to_init()
#endif
#ifndef MODULE_LICENSE
#define MODULE_LICENSE(str)
#endif
#ifndef EXPORT_NO_SYMBOLS
#define EXPORT_NO_SYMBOLS
#endif
#ifndef DEFINE_SPINLOCK
#define DEFINE_SPINLOCK(_lock) spinlock_t _lock = SPIN_LOCK_UNLOCKED
#endif
#ifndef __SPIN_LOCK_UNLOCKED
#define __SPIN_LOCK_UNLOCKED(_lock) SPIN_LOCK_UNLOCKED
#endif
#ifndef lock_kernel
#ifdef preempt_disable
#define lock_kernel() preempt_disable()
#else
#define lock_kernel()
#endif
#endif
#ifndef unlock_kernel
#ifdef preempt_enable
#define unlock_kernel() preempt_enable()
#else
#define unlock_kernel()
#endif
#endif
#ifndef init_MUTEX_LOCKED
#define init_MUTEX_LOCKED(_sem) sema_init(_sem, 0)
#endif
#ifdef CONFIG_BCM98245
#define CONFIG_BMW
#endif
#if PROC_INTERFACE_KERN_VER_3_10
#define PROC_CREATE(_entry, _name, _acc, _path, _fops) \
do { \
_entry = proc_create(_name, _acc, _path, _fops); \
} while (0)
#define PROC_CREATE_DATA(_entry, _name, _acc, _path, _fops, _data) \
do { \
_entry = proc_create_data(_name, _acc, _path, _fops, _data); \
} while (0)
#define PROC_PDE_DATA(_node) PDE_DATA(_node)
#else
#define PROC_CREATE(_entry, _name, _acc, _path, _fops) \
do { \
_entry = create_proc_entry(_name, _acc, _path); \
if (_entry) { \
_entry->proc_fops = _fops; \
} \
} while (0)
#define PROC_CREATE_DATA(_entry, _name, _acc, _path, _fops, _data) \
do { \
_entry = create_proc_entry(_name, _acc, _path); \
if (_entry) { \
_entry->proc_fops = _fops; \
_entry->data=_data; \
} \
} while (0)
#define PROC_PDE_DATA(_node) PROC_I(_node)->pde->data
#endif
#endif /* __COMMON_LINUX_KRN_LKM_H__ */
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# -*- Makefile -*-
# $Id: Makefile,v 1.2 2005/01/17 19:53:10 csm Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
LOCALDIR = systems/linux/kernel/modules/shared
include ${SDK}/make/Make.config
lib = libkern
include ${SDK}/make/Make.kernlib
include ${SDK}/make/Make.depend
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: gmodule.c,v 1.20 2013/01/23 04:43:08 gili Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*
* Generic Linux Module Framework
*
* Hooks up your driver to the kernel
*/
#include <lkm.h>
#include <gmodule.h>
#include <linux/init.h>
#include <linux/seq_file.h>
/* Module Vector Table */
static gmodule_t* _gmodule = NULL;
/* Allow DEVFS Support on 2.4 Kernels */
#if defined(LKM_2_4) && defined(CONFIG_DEVFS_FS)
#define GMODULE_CONFIG_DEVFS_FS
#endif
#ifdef GMODULE_CONFIG_DEVFS_FS
devfs_handle_t devfs_handle = NULL;
#endif
/* FIXME: support dynamic debugging */
static int _dbg_enable = 0;
static int
gvprintk(const char* fmt, va_list args)
__attribute__ ((format (printf, 1, 0)));
static int
gvprintk(const char* fmt, va_list args)
{
static char _buf[256];
strcpy(_buf, "");
sprintf(_buf, "%s (%d): ", _gmodule->name, current->pid);
vsprintf(_buf+strlen(_buf), fmt, args);
printk(_buf);
return 0;
}
int
gprintk(const char* fmt, ...)
{
int rv;
va_list args;
va_start(args, fmt);
rv = gvprintk(fmt, args);
va_end(args);
return rv;
}
int
gdbg(const char* fmt, ...)
{
int rv = 0;
va_list args;
va_start(args, fmt);
if(_dbg_enable) {
rv = gvprintk(fmt, args);
}
va_end(args);
return rv;
}
/*
* Proc FS Utilities
*/
#if PROC_INTERFACE_KERN_VER_3_10
static struct seq_file* _proc_buf = NULL;
int
pprintf(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
seq_vprintf(_proc_buf, fmt, args);
va_end(args);
return 0;
}
static int _gmodule_proc_show(struct seq_file *m, void *v){
_proc_buf = m;
_gmodule->pprint();
return 0;
}
static int
_gmodule_proc_open(struct inode * inode, struct file * file) {
if(_gmodule->open) {
_gmodule->open();
}
return single_open(file, _gmodule_proc_show, NULL);
}
static ssize_t
_gmodule_proc_write(struct file *file, const char *buffer,
size_t count, loff_t *loff)
{
/* Workaround to toggle debugging */
if(count > 2) {
if(buffer[0] == 'd') {
_dbg_enable = buffer[1] - '0';
GDBG("Debugging Enabled");
}
}
return count;
}
static int _gmodule_proc_release(struct inode * inode, struct file * file) {
if(_gmodule->close) {
_gmodule->close();
}
return single_release(inode, file);
}
struct file_operations _gmodule_proc_fops = {
owner: THIS_MODULE,
open: _gmodule_proc_open,
read: seq_read,
llseek: seq_lseek,
write: _gmodule_proc_write,
release: _gmodule_proc_release,
};
#else
int
gmodule_vpprintf(char** page_ptr, const char* fmt, va_list args)
{
*page_ptr += vsprintf(*page_ptr, fmt, args);
return 0;
}
int
gmodule_pprintf(char** page_ptr, const char* fmt, ...)
{
int rv;
va_list args;
va_start(args, fmt);
rv = gmodule_vpprintf(page_ptr, fmt, args);
va_end(args);
return rv;
}
static char* _proc_buf = NULL;
int
pprintf(const char* fmt, ...)
{
int rv;
va_list args;
va_start(args, fmt);
rv = gmodule_vpprintf(&_proc_buf, fmt, args);
va_end(args);
return rv;
}
#define PSTART(b) _proc_buf = b
#define PPRINT proc_print
#define PEND(b) (_proc_buf-b)
static int
_gmodule_pprint(char* buf)
{
PSTART(buf);
_gmodule->pprint();
return PEND(buf);
}
static int
_gmodule_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
*eof = 1;
return _gmodule_pprint(page);
}
static int
_gmodule_write_proc(struct file *file, const char *buffer,
unsigned long count, void *data)
{
/* Workaround to toggle debugging */
if(count > 2) {
if(buffer[0] == 'd') {
_dbg_enable = buffer[1] - '0';
GDBG("Debugging Enabled");
}
}
return count;
}
#endif
static int
_gmodule_create_proc(void)
{
struct proc_dir_entry* ent;
#if PROC_INTERFACE_KERN_VER_3_10
if((ent = proc_create(_gmodule->name,
S_IRUGO | S_IWUGO,
NULL,
&_gmodule_proc_fops)) != NULL) {
return 0;
}
#else
if((ent = create_proc_entry(_gmodule->name, S_IRUGO | S_IWUGO, NULL)) != NULL) {
ent->read_proc = _gmodule_read_proc;
ent->write_proc = _gmodule_write_proc;
return 0;
}
#endif
return -1;
}
static void
_gmodule_remove_proc(void)
{
remove_proc_entry(_gmodule->name, NULL);
}
static int
_gmodule_open(struct inode *inode, struct file *filp)
{
if(_gmodule->open) {
_gmodule->open();
}
return 0;
}
static int
_gmodule_release(struct inode *inode, struct file *filp)
{
if(_gmodule->close) {
_gmodule->close();
}
return 0;
}
#ifdef HAVE_UNLOCKED_IOCTL
static long
_gmodule_unlocked_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{
if(_gmodule->ioctl) {
return _gmodule->ioctl(cmd, arg);
} else {
return -1;
}
}
#else
static int
_gmodule_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
if(_gmodule->ioctl) {
return _gmodule->ioctl(cmd, arg);
} else {
return -1;
}
}
#endif
#ifdef HAVE_COMPAT_IOCTL
static long
_gmodule_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
if(_gmodule->ioctl) {
return _gmodule->ioctl(cmd, arg);
} else {
return -1;
}
}
#endif
static int
_gmodule_mmap(struct file *filp, struct vm_area_struct *vma)
{
if (_gmodule->mmap) {
return _gmodule->mmap(filp, vma);
}
#ifdef BCM_PLX9656_LOCAL_BUS
vma->vm_flags |= VM_RESERVED | VM_IO;
pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE | _PAGE_GUARDED;
if (io_remap_pfn_range( vma,
vma->vm_start,
vma->vm_pgoff,
vma->vm_end - vma->vm_start,
vma->vm_page_prot)) {
return (-EAGAIN);
}
return (0);
#else/* BCM_PLX9656_LOCAL_BUS */
return -EPERM;
#endif/* BCM_PLX9656_LOCAL_BUS */
}
/* FILE OPERATIONS */
struct file_operations _gmodule_fops = {
#ifdef HAVE_UNLOCKED_IOCTL
unlocked_ioctl: _gmodule_unlocked_ioctl,
#else
ioctl: _gmodule_ioctl,
#endif
open: _gmodule_open,
release: _gmodule_release,
mmap: _gmodule_mmap,
#ifdef HAVE_COMPAT_IOCTL
compat_ioctl: _gmodule_compat_ioctl,
#endif
};
void __exit
cleanup_module(void)
{
if(!_gmodule) return;
/* Specific Cleanup */
if(_gmodule->cleanup) {
_gmodule->cleanup();
}
/* Remove any proc entries */
if(_gmodule->pprint) {
_gmodule_remove_proc();
}
/* Finally, remove ourselves from the universe */
#ifdef GMODULE_CONFIG_DEVFS_FS
if(devfs_handle) devfs_unregister(devfs_handle);
#else
unregister_chrdev(_gmodule->major, _gmodule->name);
#endif
}
int __init
init_module(void)
{
int rc;
/* Get our definition */
_gmodule = gmodule_get();
if(!_gmodule) return -ENODEV;
/* Register ourselves */
#ifdef GMODULE_CONFIG_DEVFS_FS
devfs_handle = devfs_register(NULL,
_gmodule->name,
DEVFS_FL_NONE,
_gmodule->major,
_gmodule->minor,
S_IFCHR | S_IRUGO | S_IWUGO,
&_gmodule_fops,
NULL);
if(!devfs_handle) {
printk(KERN_WARNING "%s: can't register device with devfs",
_gmodule->name);
}
rc = 0;
#else
rc = register_chrdev(_gmodule->major,
_gmodule->name,
&_gmodule_fops);
if (rc < 0) {
printk(KERN_WARNING "%s: can't get major %d",
_gmodule->name, _gmodule->major);
return rc;
}
if(_gmodule->major == 0) {
_gmodule->major = rc;
}
#endif
/* Specific module Initialization */
if(_gmodule->init) {
int rc;
if((rc = _gmodule->init()) < 0) {
#ifdef GMODULE_CONFIG_DEVFS_FS
if(devfs_handle) devfs_unregister(devfs_handle);
#else
unregister_chrdev(_gmodule->major, _gmodule->name);
#endif
return rc;
}
}
/* Add a /proc entry, if valid */
if(_gmodule->pprint) {
_gmodule_create_proc();
}
return 0; /* succeed */
}
/*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to
* you under the terms of the GNU General Public License version 2 (the
* "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
* with the following added to such license:
*
* As a special exception, the copyright holders of this software give
* you permission to link this software with independent modules, and to
* copy and distribute the resulting executable under terms of your
* choice, provided that you also meet, for each linked independent
* module, the terms and conditions of the license of that module. An
* independent module is a module which is not derived from this
* software. The special exception does not apply to any modifications
* of the software.
*/
/*
* $Id: ksal.c,v 1.1 2008/10/16 09:41:23 mlarsen Exp $
* $Copyright: (c) 2005 Broadcom Corp.
* All Rights Reserved.$
*/
#include <sal/core/sync.h>
#include <sal/core/thread.h>
#include "lkm.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
#include <linux/semaphore.h>
#else
#include <asm/semaphore.h>
#endif
#include <linux/interrupt.h>
#include <linux/sched.h>
#include <linux/time.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
#include <linux/sched/rt.h>
#endif
#ifdef MAX_USER_RT_PRIO
/* Assume 2.6 scheduler */
#define SAL_YIELD(task) \
yield()
#else
/* Assume 2.4 scheduler */
#define SAL_YIELD(task) \
do { \
task->policy |= SCHED_YIELD; \
schedule(); \
} while (0)
#endif
#define SECOND_USEC (1000000)
#define USECS_PER_JIFFY (SECOND_USEC / HZ)
#define USEC_TO_JIFFIES(usec) ((usec + (USECS_PER_JIFFY - 1)) / USECS_PER_JIFFY)
#define sal_alloc(size, desc) kmalloc(size, GFP_KERNEL)
#define sal_free(ptr) kfree(ptr)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
#define WQ_SLEEP(a, b) wait_event_interruptible_timeout(a, NULL, b)
#else
#define WQ_SLEEP(a, b) interruptible_sleep_on_timeout(&(a), b)
#endif
/*
* sem_ctrl_t
*
* The semaphore control type uses the binary property to implement
* timed semaphores with improved performance using wait queues.
*/
typedef struct sem_ctrl_s {
struct semaphore sem;
int binary;
int cnt;
wait_queue_head_t wq;
} sem_ctrl_t;
sal_sem_t
sal_sem_create(char *desc, int binary, int initial_count)
{
sem_ctrl_t *s;
if ((s = sal_alloc(sizeof(*s), desc)) != 0) {
sema_init(&s->sem, initial_count);
s->binary = binary;
if (s->binary) {
init_waitqueue_head(&s->wq);
}
}
return (sal_sem_t) s;
}
void
sal_sem_destroy(sal_sem_t b)
{
sem_ctrl_t *s = (sem_ctrl_t *) b;
if (s == NULL) {
return;
}
/*
* the linux kernel does not have a sema_destroy(s)
*/
sal_free(s);
}
int
sal_sem_take(sal_sem_t b, int usec)
{
sem_ctrl_t *s = (sem_ctrl_t *) b;
int err;
if (usec == sal_sem_FOREVER && !in_interrupt()) {
err = down_interruptible(&s->sem);
} else {
int time_wait = 1;
int cnt = s->cnt;
for (;;) {
if (down_trylock(&s->sem) == 0) {
err = 0;
break;
}
if (s->binary) {
/* Wait for event or timeout */
if (time_wait > 1) {
err = 1;
break;
}
err = wait_event_interruptible_timeout(s->wq, cnt != s->cnt,
USEC_TO_JIFFIES(usec));
if (err < 0) {
break;
}
time_wait++;
} else {
/* Retry algorithm with exponential backoff */
if (time_wait > usec) {
time_wait = usec;
}
sal_usleep(time_wait);
usec -= time_wait;
if (usec == 0) {
err = ETIMEDOUT;
break;
}
if ((time_wait *= 2) > 100000) {
time_wait = 100000;
}
}
}
}
return err ? -1 : 0;
}
int
sal_sem_give(sal_sem_t b)
{
sem_ctrl_t *s = (sem_ctrl_t *) b;
up(&s->sem);
if (s->binary) {
s->cnt++;
wake_up_interruptible(&s->wq);
}
return 0;
}
uint32
sal_time_usecs(void)
{
struct timeval ltv;
do_gettimeofday(&ltv);
return (ltv.tv_sec * SECOND_USEC + ltv.tv_usec);
}
void
sal_usleep(uint32 usec)
{
uint32 start_usec;
wait_queue_head_t queue;
if (usec <= SECOND_USEC / HZ) {
start_usec = sal_time_usecs();
do {
SAL_YIELD(current);
} while ((sal_time_usecs() - start_usec) < usec);
} else {
init_waitqueue_head(&queue);
WQ_SLEEP(queue, USEC_TO_JIFFIES(usec));
}
}
void
sal_udelay(uint32 usec)
{
static volatile int _sal_udelay_counter;
static int loops = 0;
int ix, iy;
if (loops == 0 || usec == 0) { /* Need calibration? */
int max_loops;
int start = 0, stop = 0;
int mpt = USECS_PER_JIFFY; /* usec/tick */
for (loops = 1; loops < 0x1000 && stop == start; loops <<= 1) {
/* Wait for clock turn over */
for (stop = start = jiffies; start == stop; start = jiffies) {
/* Empty */
}
sal_udelay(mpt); /* Single recursion */
stop = jiffies;
}
max_loops = loops / 2; /* Loop above overshoots */
start = stop = 0;
if (loops < 4) {
loops = 4;
}
for (loops /= 4; loops < max_loops && stop == start; loops++) {
/* Wait for clock turn over */
for (stop = start = jiffies; start == stop; start = jiffies) {
/* Empty */
}
sal_udelay(mpt); /* Single recursion */
stop = jiffies;
}
}
for (iy = 0; iy < usec; iy++) {
for (ix = 0; ix < loops; ix++) {
_sal_udelay_counter++; /* Prevent optimizations */
}
}
}
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# -*- Makefile -*-
# $Id: Makefile,v 1.4 2011/09/09 10:07:52 mlarsen Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
#
SDK :=$(shell if [ -n "$$SDK" ] ; then\
echo $$SDK;\
else\
cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
dir=`cd ../;pwd`; \
if [ "$$dir" = "/" ] ; then \
echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \
exit 1; \
fi ; \
cd $$dir; \
done ; \
pwd; \
fi)
ifeq ($(SDK),)
$(error Please run this in a tree)
endif
export SDK
override-target=linux-$(platform)
ifeq ($(LINUX_MAKE_SHARED_LIB),1)
libext = so.$(SHAREDLIBVER)
else
libext = a
endif
ifeq (,$(platform))
$(error Internal error: platform variable is not set)
endif
include $(SDK)/make/Make.config
LOCALDIR=systems/linux/user/common
include $(SDK)/make/Make.depend
kernel-override=linux-$(platform)
ifdef BLDCONFIG
KERN_BLDROOT=${SDK}/${SDKBUILD}/${BLDCONFIG}/$(kernel-override)$(bldroot_suffix)
else
KERN_BLDROOT=${SDK}/${SDKBUILD}/$(kernel-override)$(bldroot_suffix)
endif
ifeq (,$(kernel_version))
kernel_version=2_4
endif
ifeq ($(kernel_version),2_6)
KOBJ=ko
else
KOBJ=o
endif
ifneq (,$(TOOLS_DIR))
override PATH := $(TOOLS_DIR):$(PATH)
endif
ifeq ($(DEST_DIR),)
DEST_DIR=${BLDDIR}
endif
KERNEL_BDE_LOCAL :=linux-kernel-bde.$(KOBJ)
KERNEL_BDE :=$(DEST_DIR)/$(KERNEL_BDE_LOCAL)
USER_BDE_LOCAL :=linux-user-bde.$(KOBJ)
USER_BDE=$(DEST_DIR)/$(USER_BDE_LOCAL)
BCM_KNET_LOCAL :=linux-bcm-knet.$(KOBJ)
BCM_KNET=$(DEST_DIR)/$(BCM_KNET_LOCAL)
ifeq (,$(findstring DELIVER,$(MAKECMDGOALS)))
.DEFAULT_GOAL := all
all_targets := kernel_modules $(KERNEL_BDE) $(USER_BDE)
LOCAL_TARGETS :=
ifeq ($(NO_LOCAL_TARGETS),)
LOCAL_TARGETS +=$(patsubst %,$(realpath ..)/$(platform)/%,$(KERNEL_BDE_LOCAL) $(USER_BDE_LOCAL))
all_targets +=$(LOCAL_TARGETS)
endif
# Build all by default
ifndef BUILD_KNET
BUILD_KNET = 1
endif
ifeq ($(BUILD_KNET),1)
# Kernel network support
all_targets += $(BCM_KNET)
ifeq ($(NO_LOCAL_TARGETS),)
LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(BCM_KNET_LOCAL))
all_targets +=$(LOCAL_TARGETS)
endif
ADD_TO_CFLAGS += -I$(SDK)/systems/linux/kernel/modules/include
COND_KNET_LIBS = libuser.$(libext)
endif
all: $(BLDDIR)/.tree $(all_targets)
ifeq ($(NO_LOCAL_TARGETS),)
define LOCAL_TARGET_DEF
$(1) : $(DEST_DIR)/$(notdir $(1))
cp $$? $$@
endef
endif
# User BDE libraries
ADD_TO_CFLAGS += -I$(SDK)/systems/bde/linux/include
# Use raw IOCTL for KNET
ADD_TO_CFLAGS += -DPROXY_SUPPORT=0
CFLAGS += $(ADD_TO_CFLAGS)
kernel_modules:
$(MAKE) -C $(SDK)/systems/bde/linux/kernel kernel_version=$(kernel_version)
$(MAKE) -C $(SDK)/systems/bde/linux/user/kernel kernel_version=$(kernel_version)
ifeq ($(BUILD_KNET),1)
$(MAKE) -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \
subdirs="shared bcm-knet" override-target=linux-$(platform) CFLAGS="$(CFLAGS)"
endif
$(KERNEL_BDE): $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ)
mkdir -p $(@D)
$(OBJCOPY) --strip-debug $< $@
$(USER_BDE): $(KERN_BLDROOT)/linux-user-bde.$(KOBJ)
$(OBJCOPY) --strip-debug $< $@
$(BCM_KNET): $(KERN_BLDROOT)/linux-bcm-knet.$(KOBJ)
$(OBJCOPY) --strip-debug $< $@
ifeq ($(NO_LOCAL_TARGETS),)
$(foreach targ,$(LOCAL_TARGETS),$(eval $(call LOCAL_TARGET_DEF,$(targ))))
endif
clean::
$(MAKE) -C $(SDK)/systems/bde/linux/kernel $@
$(MAKE) -C $(SDK)/systems/bde/linux/user/kernel $@
$(MAKE) -C $(SDK)/systems/linux/kernel/modules \
subdirs="shared bcm-knet" \
override-target=linux-$(platform) $@
$(RM) $(KERNEL_BDE) $(USER_BDE)
$(RM) $(BCM_KNET)
$(RM) $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ)
$(RM) $(KERN_BLDROOT)/linux-user-bde.$(KOBJ)
$(RM) $(KERN_BLDROOT)/linux-bcm-knet.$(KOBJ)
$(RM) $(LOCAL_TARGETS)
distclean:: clean
.PHONY: variable
#
# Echo variable values used for configuration
# usage: make VAR=CC variable
#
variable::
@echo $($(VAR))
else
ifndef DELIVERY
$(error DELIVERY required)
endif
DELIVERABLES := $(KERNEL_BDE) $(USER_BDE)
# 1= source
define DELIVERY_RULE
_DEL_TARG += $(DELIVERY)/$(notdir $(1))
$(DELIVERY)/$(notdir $(1)) : $(1)
@mkdir -p $(DELIVERY)
ifeq ($(filter $(notdir $(BCM)) $(notdir $(BCM).dbg),$(notdir $1)),)
$(OBJCOPY) --strip-debug $$< $$@
else
$(CP) -p $$< $$@
endif
endef
$(foreach f,$(DELIVERABLES),$(eval $(call DELIVERY_RULE,$(f))))
DELIVER: $(_DEL_TARG)
endif
# Make.config defines remaining phony targets
.PHONY: build kernel_modules DELIVER
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# -*- Makefile -*-
# $Id: Makefile,v 1.9 2009/05/21 20:09:56 gururaj Exp $
# $Copyright: (c) 2007 Broadcom Corp.
# All Rights Reserved.$
#
# This make job requires the following environment variables to be set:
#
# SDK - path to StrataXGS SDK root directory
#
# Optionally the following environment variables can be set to
# override the default build server configuration:
#
# PPC_TOOLS_DIR - path to build tools (if not in PATH already)
# PPC_CROSS_COMPILE - cross compile tools prefix
# LINUX_INCLUDE - path to Linux kernel include directory
#
SDK :=$(shell if [ -n "$$SDK" ] ; then\
echo $$SDK;\
else\
cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
dir=`cd ../;pwd`; \
if [ "$$dir" = "/" ] ; then \
echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \
exit 1; \
fi ; \
cd $$dir; \
done ; \
pwd; \
fi)
ifeq ($(SDK),)
$(error Please run this in a tree)
endif
export SDK
override kernel_version=2_6
platform=gto-$(kernel_version)
LINUX_MAKE_USER=1
export LINKER_RELAX=1
# Select the build environment
#BUILD_PLATFORM=ELDK
#BUILD_PLATFORM=WR_LINUX
#Select the LINUX KERNEL VERSION
#KERN_VER = 2.6.21.7
#KERN_VER = 2.6.24.4
#KERN_VER = 2.6.25
# Select the ELDK version
#ELDK_VERSION=4.1
#ELDK_VERSION=4.0
#Select WRS Linux version
#WRS_LINUX_VERSION=2.0
#WRS_LINUX_VERSION=3.0
export KERN_VER
export ELDK_VERSION
export BUILD_PLATFORM
export WRS_LINUX_VERSION
include ${SDK}/make/Make.linux
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
# -*- Makefile -*-
# $Id: Makefile,v 1.2 2008/06/12 19:25:32 mpall Exp $
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved.$
SDK :=$(shell if [ -n "$$SDK" ] ; then\
echo $$SDK;\
else\
cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
dir=`cd ../;pwd`; \
if [ "$$dir" = "/" ] ; then \
echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \
exit 1; \
fi ; \
cd $$dir; \
done ; \
pwd; \
fi)
ifeq ($(SDK),)
$(error Please run this in a tree)
endif
export SDK
override kernel_version=2_6
platform=x86-smp_generic_64-$(kernel_version)
LINUX_MAKE_USER=1
include ${SDK}/make/Make.linux
#
# Unless you and Broadcom execute a separate written software license
# agreement governing use of this software, this software is licensed to
# you under the terms of the GNU General Public License version 2 (the
# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php,
# with the following added to such license:
#
# As a special exception, the copyright holders of this software give
# you permission to link this software with independent modules, and to
# copy and distribute the resulting executable under terms of your
# choice, provided that you also meet, for each linked independent
# module, the terms and conditions of the license of that module. An
# independent module is a module which is not derived from this
# software. The special exception does not apply to any modifications
# of the software.
#
#
# mktool.pl
#
# $Id: mktool.pl,v 1.5 2011/04/12 09:05:28 sraj Exp $
#
# $Copyright: (c) 2005 Broadcom Corp.
# All Rights Reserved. $
use File::Path;
use File::Find;
use File::Copy;
use Cwd;
($prog = $0) =~ s/.*\///;
SWITCH:
{
$op = shift;
if ($op eq "-rm") { mktool_rm(@ARGV); last SWITCH; }
if ($op eq "-cp") { mktool_cp(@ARGV); last SWITCH; }
if ($op eq "-md") { mktool_md(@ARGV); last SWITCH; }
if ($op eq "-ln") { mktool_ln(@ARGV); last SWITCH; }
if ($op eq "-foreach") { mktool_foreach(@ARGV); last SWITCH; }
if ($op eq "-dep") { mktool_makedep(@ARGV); last SWITCH; }
if ($op eq "-echo") { mktool_echo(@ARGV); last SWITCH; }
if ($op eq "-beep") { mktool_beep(@ARGV); last SWITCH; }
die("$prog: unknown option '$op'\n");
}
exit 0;
#
# mktool_execute
#
# Executes a command, returns exist status.
# Performs token special translation before execution.
#
sub mktool_execute
{
my $token = shift;
my @cmds = @_;
# printf("mktool_execute: token = '$token'\n");
foreach $cmd (@cmds)
{
#printf("mktool_execute: cmd = '$cmd'\n");
$cmd =~ s/\#\#/$token/g;
if($cmd =~ /^-p/)
{
$cmd =~ s/^-p//;
printf("$cmd\n");
}
else
{
system($cmd);
my $excode = ($? >> 8);
exit $excode if $excode;
}
}
}
$find_regexp = "";
@find_cmd;
#
# mktool_foreach
#
sub mktool_foreach
{
if($_[0] eq "-find")
{
shift;
$find_dir = shift;
$find_regexp = shift;
@find_cmds = @_;
if(!($find_dir =~ /^\//))
{
$find_dir = cwd() . "/" . $find_dir;
}
find(\&_mktool_foreach_find_wanted, $find_dir);
}
else
{
my $subdir = 0;
if($_[0] eq "-subdir")
{
$subdir = 1;
shift;
}
my @thingies = split(' ', shift);
foreach $thingy (@thingies)
{
chdir $thingy unless $subdir == 0;
mktool_execute($thingy, @_);
chdir ".." unless $subdir == 0;
}
}
}
sub _mktool_foreach_find_wanted
{
my $expr = "\$File::Find::name =~ /\^$find_regexp\$/";
if(eval($expr))
{
mktool_execute($File::Find::name, @find_cmds);
exit $excode if $excode;
}
}
#
# rm
#
# Removes a list of objects
#
sub mktool_rm
{
my($f);
foreach $f (@_) {
eval { rmtree($f) };
if ($@) {
die "$prog $op: failed to remove $f: $@\n";
}
}
}
#
# md
#
# Makes a list of directories
#
sub mktool_md
{
my($dir);
foreach $dir (@_) {
$dir =~ s!/+$!!;
eval { mkpath($dir) };
if ($@) {
die "$prog $op: failed to make directory $dir: $@\n";
}
}
}
sub mktool_cp
{
my($from, $to) = @_;
if (@_ != 2) {
die "$prog $op: must have two arguments\n";
}
copy($from, $to) ||
die "$prog $op: failed to copy $from to $to: $!\n";
}
sub mktool_ln
{
my($old, $new) = @_;
if (@_ != 2) {
die "$prog $op: must have two arguments\n";
}
link ($old, $new) ||
die "$prog $op: failed to link $new to $old: $!\n";
}
# @echo "$@ \\" > ${BLDDIR}/$(notdir $@)
# @if ($(DEPEND)) >> $(BLDDIR)/$(notdir $@); then \
# exit 0; \
# else \
# rm -f ${BLDDIR}/$(notdir $@); \
# exit 1; \
# fi
# $(MAKEDEP) "$@" "$(BLDDIR)/$(notdir $@)" "$(DEPEND)"
sub mktool_makedep
{
my ($source, $target, $cmd, $curdir) = @_;
my @result = `$cmd`;
my $sdk = $ENV{'SDK'};
my $count;
my $tmp;
local $resultant;
## Comman $cmd
#Command $cmd
print <<MKTOOL;
mktool.pl::
curdir $curdir
MKTOOL
# derive the path to the target
$curdir = "$sdk/$curdir";
# save the basename
$dirName = substr($target,0,rindex($target,"\/"));
# prepare the top line of the %.d file
$resultant="$source \\\n\${BLDDIR}/";
if(!$?)
{
foreach $line (@result)
{
$line =~ s/^#.*\n//g; # some makedeps produce comments
$line =~ s/\n+$//; # toss trailing newlines
$line =~ s/(\s+)(\.\/)/ /g; # remove leading ./
# insert SDK path before ../
$line =~ s/(\s+)(\.\.\/)/${1}$curdir\/${2}/g;
# insert SDK path
$line =~ s/(\s+)(\w+)/${1}$curdir\/${2}/g;
$count=0;
$tmp=$line;
while( (index($line,"..")>-1) & ($count < 20) )
{
$line=~s/\/\w+\/\.\.//;
# if we hit a major recursion, revert the line, report
# this to the output and drop out of the loop, but do
# continue, this should not halt generation
if($count++>19)
{
print "mktool.pl: could not process $line \n\n";
print ":: curdir $curdir\n";
print ":: target $target\n";
print ":: cmd $cmd\n";
$line=$tmp;
}
}
# set all the paths to use the $SDK variable
$line =~ s/$ENV{'SDK'}/\$\{SDK\}/g;
$resultant=$resultant . $line;
}
# some compilers return extra newlines
$resultant=~s/\n//g;
# now clean up the result
$resultant=~s/\\/\\\n/g;
mktool_md($dirName) unless (-d $dirName);
open (TARGET, ">$target") ||
die("$prog $op: cannot open '$target' for writing: $!\n");
print TARGET "$resultant\n";
close(TARGET);
}
}
sub mktool_echo
{
print "@_\n";
}
sub mktool_beep
{
-t STDOUT && defined $ENV{MAKEBEEP} && print "\007";
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment