32 #define BFA_TRC_MAX (4 * 1024)
35 #define BFA_TRC_TS(_trcm) \
39 do_gettimeofday(&tv); \
40 (tv.tv_sec*1000000+tv.tv_usec); \
44 #define BFA_TRC_TS(_trcm) ((_trcm)->ticks++)
81 #define BFA_TRC_MOD_SH 10
82 #define BFA_TRC_MOD(__mod) ((BFA_TRC_ ## __mod) << BFA_TRC_MOD_SH)
87 #define BFA_TRC_FILE(__mod, __submod) \
88 static int __trc_fileno = ((BFA_TRC_ ## __mod ## _ ## __submod) | \
92 #define bfa_trc32(_trcp, _data) \
93 __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
94 #define bfa_trc(_trcp, _data) \
95 __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u64)_data)
101 trcm->
ntrc = BFA_TRC_MAX;
124 trcm->
tail = (trcm->
tail + 1) & (BFA_TRC_MAX - 1);
126 trcm->
head = (trcm->
head + 1) & (BFA_TRC_MAX - 1);
133 int tail = trcm->
tail;
144 trcm->
tail = (trcm->
tail + 1) & (BFA_TRC_MAX - 1);
146 trcm->
head = (trcm->
head + 1) & (BFA_TRC_MAX - 1);
149 #define bfa_sm_fault(__mod, __event) do { \
150 bfa_trc(__mod, (((u32)0xDEAD << 16) | __event)); \
151 printk(KERN_ERR "Assertion failure: %s:%d: %d", \
152 __FILE__, __LINE__, (__event)); \
156 #define bfa_q_first(_q) ((void *)(((struct list_head *) (_q))->next))
157 #define bfa_q_next(_qe) (((struct list_head *) (_qe))->next)
158 #define bfa_q_prev(_qe) (((struct list_head *) (_qe))->prev)
163 #define bfa_q_qe_init(_qe) { \
164 bfa_q_next(_qe) = (struct list_head *) NULL; \
165 bfa_q_prev(_qe) = (struct list_head *) NULL; \
171 #define bfa_q_deq(_q, _qe) do { \
172 if (!list_empty(_q)) { \
173 (*((struct list_head **) (_qe))) = bfa_q_next(_q); \
174 bfa_q_prev(bfa_q_next(*((struct list_head **) _qe))) = \
175 (struct list_head *) (_q); \
176 bfa_q_next(_q) = bfa_q_next(*((struct list_head **) _qe));\
178 *((struct list_head **) (_qe)) = (struct list_head *) NULL;\
185 #define bfa_q_deq_tail(_q, _qe) { \
186 if (!list_empty(_q)) { \
187 *((struct list_head **) (_qe)) = bfa_q_prev(_q); \
188 bfa_q_next(bfa_q_prev(*((struct list_head **) _qe))) = \
189 (struct list_head *) (_q); \
190 bfa_q_prev(_q) = bfa_q_prev(*(struct list_head **) _qe);\
192 *((struct list_head **) (_qe)) = (struct list_head *) NULL;\
212 #define bfa_q_is_on_q(_q, _qe) \
213 bfa_q_is_on_q_func(_q, (struct list_head *)(_qe))
227 #define bfa_sm_state_decl(oc, st, otype, etype) \
228 static void oc ## _sm_ ## st(otype * fsm, etype event)
230 #define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state))
231 #define bfa_sm_send_event(_sm, _event) ((_sm)->sm((_sm), (_event)))
232 #define bfa_sm_get_state(_sm) ((_sm)->sm)
233 #define bfa_sm_cmp_state(_sm, _state) ((_sm)->sm == (bfa_sm_t)(_state))
243 #define BFA_SM(_sm) ((bfa_sm_t)(_sm))
256 #define bfa_fsm_state_decl(oc, st, otype, etype) \
257 static void oc ## _sm_ ## st(otype * fsm, etype event); \
258 static void oc ## _sm_ ## st ## _entry(otype * fsm)
260 #define bfa_fsm_set_state(_fsm, _state) do { \
261 (_fsm)->fsm = (bfa_fsm_t)(_state); \
262 _state ## _entry(_fsm); \
265 #define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event)))
266 #define bfa_fsm_get_state(_fsm) ((_fsm)->fsm)
267 #define bfa_fsm_cmp_state(_fsm, _state) \
268 ((_fsm)->fsm == (bfa_fsm_t)(_state))
275 while (smt[i].sm && smt[i].sm != sm)
328 wwn2str(
char *wwn_str,
u64 wwn)
336 sprintf(wwn_str,
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
w.byte[0],
337 w.byte[1],
w.byte[2],
w.byte[3],
w.byte[4],
w.byte[5],
338 w.byte[6],
w.byte[7]);
342 fcid2str(
char *fcid_str,
u32 fcid)
350 sprintf(fcid_str,
"%02x:%02x:%02x",
f.byte[1],
f.byte[2],
f.byte[3]);
353 #define bfa_swap_3b(_x) \
354 ((((_x) & 0xff) << 16) | \
355 ((_x) & 0x00ff00) | \
356 (((_x) & 0xff0000) >> 16))
359 #define bfa_hton3b(_x) bfa_swap_3b(_x)
361 #define bfa_hton3b(_x) (_x)
364 #define bfa_ntoh3b(_x) bfa_hton3b(_x)