blmi_err.h (2576B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 */ 7 8 #ifndef BLMI_ERR_H 9 #define BLMI_ERR_H 10 11 typedef enum { 12 BLMI_E_NONE = 0, 13 BLMI_E_INTERNAL = -1, 14 BLMI_E_MEMORY = -2, 15 BLMI_E_PARAM = -3, 16 BLMI_E_EMPTY = -4, 17 BLMI_E_FULL = -5, 18 BLMI_E_NOT_FOUND = -6, 19 BLMI_E_EXISTS = -7, 20 BLMI_E_TIMEOUT = -8, 21 BLMI_E_FAIL = -9, 22 BLMI_E_DISABLED = -10, 23 BLMI_E_BADID = -11, 24 BLMI_E_RESOURCE = -12, 25 BLMI_E_CONFIG = -13, 26 BLMI_E_UNAVAIL = -14, 27 BLMI_E_INIT = -15, 28 BLMI_E_PORT = -16, 29 BLMI_E_UNKNOWN = -17 30 } blmi_error_t; 31 32 #define BLMI_ERRMSG_INIT { \ 33 "Ok", /* E_NONE */ \ 34 "Internal error", /* E_INTERNAL */ \ 35 "Out of memory", /* E_MEMORY */ \ 36 "Invalid parameter", /* E_PARAM */ \ 37 "Table empty", /* E_EMPTY */ \ 38 "Table full", /* E_FULL */ \ 39 "Entry not found", /* E_NOT_FOUND */ \ 40 "Entry exists", /* E_EXISTS */ \ 41 "Operation timed out", /* E_TIMEOUT */ \ 42 "Operation failed", /* E_FAIL */ \ 43 "Operation disabled", /* E_DISABLED */ \ 44 "Invalid identifier", /* E_BADID */ \ 45 "No resources for operation", /* E_RESOURCE */ \ 46 "Invalid configuration", /* E_CONFIG */ \ 47 "Feature unavailable", /* E_UNAVAIL */ \ 48 "Feature not initialized", /* E_INIT */ \ 49 "Invalid port", /* E_PORT */ \ 50 "Unknown error", /* E_UNKNOWN*/ \ 51 } 52 53 extern char *blmi_errmsg[]; 54 55 #define BLMI_ERRMSG(r) \ 56 blmi_errmsg[((r) <= 0 && (r) > BLMI_E_UNKNOWN) ? -(r) : -BLMI_E_UNKNOWN] 57 58 #define BLMI_E_SUCCESS(rv) ((rv) >= 0) 59 #define BLMI_E_FAILURE(rv) ((rv) < 0) 60 61 /* 62 * Macro: 63 * BLMI_E_IF_ERROR_RETURN 64 * Purpose: 65 * Evaluate _op as an expression, and if an error, return. 66 * Notes: 67 * This macro uses a do-while construct to maintain expected 68 * "C" blocking, and evaluates "op" ONLY ONCE so it may be 69 * a function call that has side affects. 70 */ 71 72 #define BLMI_E_IF_ERROR_RETURN(op) \ 73 do { int __rv__; if ((__rv__ = (op)) < 0) return(__rv__); } while(0) 74 75 #define BLMI_E_IF_ERROR_NOT_UNAVAIL_RETURN(op) \ 76 do { \ 77 int __rv__; \ 78 if (((__rv__ = (op)) < 0) && (__rv__ != BLMI_E_UNAVAIL)) { \ 79 return(__rv__); \ 80 } \ 81 } while(0) 82 83 #endif /* BLMI_ERR_H */ 84 85