OpenNSL API Guide and Reference Manual
error.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * (C) Copyright Broadcom Corporation 2013-2016
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  **********************************************************************
18  * File: error.h
19  * Details: This file defines common error codes to be shared
20  * between API layers.
21  *
22  * Its contents are not used directly by applications;
23  * it is used only by header files of parent APIs which
24  * need to define error codes.
25  *********************************************************************/
26 
27 #ifndef _SHR_ERROR_H
28 #define _SHR_ERROR_H
29 
30 typedef enum {
41  _SHR_E_BUSY = -10,
42  _SHR_E_FAIL = -11,
44  _SHR_E_BADID = -13,
48  _SHR_E_INIT = -17,
49  _SHR_E_PORT = -18,
50 
51  _SHR_E_LIMIT = -19 /* Must come last */
52 } _shr_error_t;
53 /* __doxy_func_body_end__ */
54 
55 #define _SHR_ERRMSG_INIT { \
56  "Ok", /* E_NONE */ \
57  "Internal error", /* E_INTERNAL */ \
58  "Out of memory", /* E_MEMORY */ \
59  "Invalid unit", /* E_UNIT */ \
60  "Invalid parameter", /* E_PARAM */ \
61  "Table empty", /* E_EMPTY */ \
62  "Table full", /* E_FULL */ \
63  "Entry not found", /* E_NOT_FOUND */ \
64  "Entry exists", /* E_EXISTS */ \
65  "Operation timed out", /* E_TIMEOUT */ \
66  "Operation still running", /* E_BUSY */ \
67  "Operation failed", /* E_FAIL */ \
68  "Operation disabled", /* E_DISABLED */ \
69  "Invalid identifier", /* E_BADID */ \
70  "No resources for operation", /* E_RESOURCE */ \
71  "Invalid configuration", /* E_CONFIG */ \
72  "Feature unavailable", /* E_UNAVAIL */ \
73  "Feature not initialized", /* E_INIT */ \
74  "Invalid port", /* E_PORT */ \
75  "Unknown error" /* E_LIMIT */ \
76  }
77 /* __doxy_func_body_end__ */
78 
79 extern char *_shr_errmsg[];
80 
81 #define _SHR_ERRMSG(r) \
82  _shr_errmsg[(((int)r) <= 0 && ((int)r) > _SHR_E_LIMIT) ? -(r) : -_SHR_E_LIMIT]
83 
84 #define _SHR_E_SUCCESS(rv) ((rv) >= 0)
85 #define _SHR_E_FAILURE(rv) ((rv) < 0)
86 
87 #define _SHR_ERROR_TRACE(__errcode__)
88 #define _SHR_RETURN(__expr__) return (__expr__)
89 
90 #define _SHR_E_IF_ERROR_RETURN(op) \
91  do { int __rv__; if ((__rv__ = (op)) < 0) { _SHR_ERROR_TRACE(__rv__); return(__rv__); } } while(0)
92 /* __doxy_func_body_end__ */
93 
94 #define _SHR_E_IF_ERROR_CLEAN_RETURN(op,exop) \
95  do { int __rv__; if ((__rv__ = (op)) < 0) { _SHR_ERROR_TRACE(__rv__); (exop); return(__rv__); } } while(0)
96 /* __doxy_func_body_end__ */
97 
98 #define _SHR_E_IF_ERROR_NOT_UNAVAIL_RETURN(op) \
99  do { \
100  int __rv__; \
101  if (((__rv__ = (op)) < 0) && (__rv__ != _SHR_E_UNAVAIL)) { \
102  return(__rv__); \
103  } \
104  } while(0)
105 /* __doxy_func_body_end__ */
106 
107 
108 typedef enum {
127  _SHR_SWITCH_EVENT_COUNT /* last, as always */
129 /* __doxy_func_body_end__ */
130 
131 #endif /* !_SHR_ERROR_H */