All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sir_common.h
Go to the documentation of this file.
1 /*
2  * sir_common.h
3  *
4  * Created on: Mar 7, 2014
5  * Author: root
6  */
7 
8 #ifndef SIR_COMMON_H_
9 #define SIR_COMMON_H_
10 
11 #include <cvmx.h>
12 
13 /* Debug levels.
14  * 1 : Lowest level with minimum dxebug information
15  *
16 */
17 typedef enum
18 {
27 
28 // Macro's for modulo 2**32 arithmetic
29 #define SIR_MOD232_EQ(a,b) ((a)==(b))
30 
31 #define SIR_MOD232_LT(a,b) ((int)((a)-(b)) < 0 )
32 #define SIR_MOD232_LEQ(a,b) ((int)((a)-(b)) <= 0)
33 #define SIR_MOD232_GT(a,b) ((int)((a)-(b)) > 0 )
34 #define SIR_MOD232_GEQ(a,b) ((int)((a)-(b)) >= 0)
35 
36 #define SIR_MOD232_SUB(a,b) ({ uint32_t ret=(uint32_t)((long)((a)-(b))); ret;})
37 #define SIR_MOD232_ADD(a,b) ({ uint32_t ret=(uint32_t)((a)+(b)); ret;})
38 
39 #define SIR_MOD232_MIN(a,b) ((SIR_MOD232_LT(a,b)) ? (a):(b))
40 #define SIR_MOD232_MAX(a,b) ((SIR_MOD232_GT(a,b)) ? (a):(b))
41 
42 #ifdef OCTEON_DEBUG_ENABLED
43 //#define OCTEON_DEBUG_LEVEL SIR_INFO_LEVEL_1
44 #ifndef OCTEON_DEBUG_LEVEL
45 #define OCTEON_DEBUG_LEVEL SIR_WARNING_DEBUG_LEVEL
46 #endif
47 #ifdef __linux__
48 #define SIR_COMMON_DEBUG_MSG(lvl, format, args...) \
49 { \
50  if (lvl <= OCTEON_DEBUG_LEVEL) \
51  { \
52  printf("Core:%d:",cvmx_get_core_num()); \
53  printf("[DBG %d %s:%d] ", lvl, __FUNCTION__,__LINE__); \
54  printf(format, ##args); \
55  } \
56 }
57 #else
58 #define SIR_COMMON_DEBUG_MSG(lvl, format, args...) \
59 { \
60  if (lvl <= OCTEON_DEBUG_LEVEL) \
61  { \
62  printf("[DBG %d %s:%d] ", lvl, __FUNCTION__,__LINE__); \
63  printf(format, ##args); \
64  } \
65 }
66 #endif
67 #else
68 #define SIR_COMMON_DEBUG_MSG(lvl, format, args...);
69 #endif
70 
71 #define sirius_panic(...) \
72  { \
73  printf("SIRIUS_PANIC:" __VA_ARGS__); \
74  exit(-1); \
75  }
76 
77 #define SIRIUS_ASSERT(exp,msg) \
78  { \
79  if(!(exp)) sirius_panic msg; \
80  }
81 
82 struct TDoubleID
83 {
84  uint64_t ui64ID1;
85  uint64_t ui64ID2;
86 #ifdef __cplusplus
87  bool operator==(const TDoubleID &T) const
88  {
89  return ((T.ui64ID1 == ui64ID1) && (T.ui64ID2 == ui64ID2)) ? true : false;
90  }
91  bool operator!=(const TDoubleID &T) const
92  {
93  return ((T.ui64ID1 != ui64ID1) || (T.ui64ID2 != ui64ID2)) ? true : false;
94  }
95 #endif
96 };
97 
98 struct T5Tuple
99 {
100  uint64_t ui64ID1;
101  uint64_t ui64ID2;
102  uint64_t ui64ID3;
103  uint64_t ui64ID4;
104  uint64_t ui64ID5;
105 
106 #ifdef __cplusplus
107  bool operator==(const T5Tuple &T) const
108  {
109  return ((T.ui64ID1 == ui64ID1) && (T.ui64ID2 == ui64ID2) && (T.ui64ID3 == ui64ID3) && (T.ui64ID4 == ui64ID4) && (T.ui64ID5 == ui64ID5)) ? true : false;
110  }
111  bool operator!=(const T5Tuple &T) const
112  {
113  return ((T.ui64ID1 != ui64ID1) || (T.ui64ID2 != ui64ID2) || (T.ui64ID3 != ui64ID3) || (T.ui64ID4 != ui64ID4) || (T.ui64ID5 != ui64ID5)) ? true : false;
114  }
115 #endif
116 };
117 
118 #endif /* SIR_COMMON_H_ */
uint64_t ui64ID2
Definition: sir_common.h:101
bool operator==(const T5Tuple &T) const
Definition: sir_common.h:107
uint64_t ui64ID3
Definition: sir_common.h:102
EDebugLevel
Definition: sir_common.h:17
bool operator!=(const T5Tuple &T) const
Definition: sir_common.h:111
bool operator==(const TDoubleID &T) const
Definition: sir_common.h:87
uint64_t ui64ID2
Definition: sir_common.h:85
uint64_t ui64ID1
Definition: sir_common.h:100
bool operator!=(const TDoubleID &T) const
Definition: sir_common.h:91
uint64_t ui64ID1
Definition: sir_common.h:84
uint64_t ui64ID4
Definition: sir_common.h:103
uint64_t ui64ID5
Definition: sir_common.h:104