openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

bfcmap_err.h (2640B)


      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 BFCMAP_ERR_H
      9 #define BFCMAP_ERR_H
     10 
     11 typedef enum {
     12     BFCMAP_E_NONE		=  0,
     13     BFCMAP_E_INTERNAL	= -1,
     14     BFCMAP_E_MEMORY		= -2,
     15     BFCMAP_E_PARAM		= -3,
     16     BFCMAP_E_EMPTY          = -4,
     17     BFCMAP_E_FULL		= -5,
     18     BFCMAP_E_NOT_FOUND		= -6,
     19     BFCMAP_E_EXISTS		= -7,
     20     BFCMAP_E_TIMEOUT		= -8,
     21     BFCMAP_E_FAIL		= -9, 
     22     BFCMAP_E_DISABLED		= -10,
     23     BFCMAP_E_BADID		= -11,
     24     BFCMAP_E_RESOURCE		= -12,
     25     BFCMAP_E_CONFIG		= -13,
     26     BFCMAP_E_UNAVAIL		= -14,
     27     BFCMAP_E_INIT		= -15,
     28     BFCMAP_E_PORT		= -16,
     29     BFCMAP_E_UNKNOWN           = -17
     30 } bfcmap_error_t;
     31 
     32 #define	BFCMAP_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 *bfcmap_errmsg[];
     54 
     55 #define	BFCMAP_ERRMSG(r)		\
     56 	bfcmap_errmsg[((r) <= 0 && (r) > BFCMAP_E_UNKNOWN) ? -(r) : -BFCMAP_E_UNKNOWN]
     57 
     58 #define BFCMAP_E_SUCCESS(rv)		((rv) >= 0)
     59 #define BFCMAP_E_FAILURE(rv)		((rv) < 0)
     60 
     61 /*
     62  * Macro:
     63  *	BFCMAP_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 BFCMAP_E_IF_ERROR_RETURN(op) \
     73     do { int __rv__; if ((__rv__ = (op)) < 0) return(__rv__); } while(0)
     74 
     75 #define BFCMAP_E_IF_ERROR_NOT_UNAVAIL_RETURN(op)                        \
     76     do {                                                                \
     77         int __rv__;                                                     \
     78         if (((__rv__ = (op)) < 0) && (__rv__ != BFCMAP_E_UNAVAIL)) {      \
     79             return(__rv__);                                             \
     80         }                                                               \
     81     } while(0)
     82 
     83 #endif /* BFCMAP_ERR_H */
     84 
     85