GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / scsi / bfa / include / cs / bfa_trc.h
blob57963080f7894b21648da0ed2dd55a0506bfd427
1 /*
2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 #ifndef __BFA_TRC_H__
18 #define __BFA_TRC_H__
20 #include <bfa_os_inc.h>
22 #ifndef BFA_TRC_MAX
23 #define BFA_TRC_MAX (4 * 1024)
24 #endif
26 #ifndef BFA_TRC_TS
27 #define BFA_TRC_TS(_trcm) ((_trcm)->ticks++)
28 #endif
30 struct bfa_trc_s {
31 #ifdef __BIGENDIAN
32 u16 fileno;
33 u16 line;
34 #else
35 u16 line;
36 u16 fileno;
37 #endif
38 u32 timestamp;
39 union {
40 struct {
41 u32 rsvd;
42 u32 u32;
43 } u32;
44 u64 u64;
45 } data;
49 struct bfa_trc_mod_s {
50 u32 head;
51 u32 tail;
52 u32 ntrc;
53 u32 stopped;
54 u32 ticks;
55 u32 rsvd[3];
56 struct bfa_trc_s trc[BFA_TRC_MAX];
60 enum {
61 BFA_TRC_FW = 1, /* firmware modules */
62 BFA_TRC_HAL = 2, /* BFA modules */
63 BFA_TRC_FCS = 3, /* BFA FCS modules */
64 BFA_TRC_LDRV = 4, /* Linux driver modules */
65 BFA_TRC_SDRV = 5, /* Solaris driver modules */
66 BFA_TRC_VDRV = 6, /* vmware driver modules */
67 BFA_TRC_WDRV = 7, /* windows driver modules */
68 BFA_TRC_AEN = 8, /* AEN module */
69 BFA_TRC_BIOS = 9, /* bios driver modules */
70 BFA_TRC_EFI = 10, /* EFI driver modules */
71 BNA_TRC_WDRV = 11, /* BNA windows driver modules */
72 BNA_TRC_VDRV = 12, /* BNA vmware driver modules */
73 BNA_TRC_SDRV = 13, /* BNA Solaris driver modules */
74 BNA_TRC_LDRV = 14, /* BNA Linux driver modules */
75 BNA_TRC_HAL = 15, /* BNA modules */
76 BFA_TRC_CNA = 16, /* Common modules */
77 BNA_TRC_IMDRV = 17 /* BNA windows intermediate driver modules */
79 #define BFA_TRC_MOD_SH 10
80 #define BFA_TRC_MOD(__mod) ((BFA_TRC_ ## __mod) << BFA_TRC_MOD_SH)
82 /**
83 * Define a new tracing file (module). Module should match one defined above.
85 #define BFA_TRC_FILE(__mod, __submod) \
86 static int __trc_fileno = ((BFA_TRC_ ## __mod ## _ ## __submod) | \
87 BFA_TRC_MOD(__mod))
90 #define bfa_trc32(_trcp, _data) \
91 __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
94 #ifndef BFA_BOOT_BUILD
95 #define bfa_trc(_trcp, _data) \
96 __bfa_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u64)_data)
97 #else
98 void bfa_boot_trc(struct bfa_trc_mod_s *trcmod, u16 fileno,
99 u16 line, u32 data);
100 #define bfa_trc(_trcp, _data) \
101 bfa_boot_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
102 #endif
105 static inline void
106 bfa_trc_init(struct bfa_trc_mod_s *trcm)
108 trcm->head = trcm->tail = trcm->stopped = 0;
109 trcm->ntrc = BFA_TRC_MAX;
113 static inline void
114 bfa_trc_stop(struct bfa_trc_mod_s *trcm)
116 trcm->stopped = 1;
119 #ifdef FWTRC
120 extern void dc_flush(void *data);
121 #else
122 #define dc_flush(data)
123 #endif
126 static inline void
127 __bfa_trc(struct bfa_trc_mod_s *trcm, int fileno, int line, u64 data)
129 int tail = trcm->tail;
130 struct bfa_trc_s *trc = &trcm->trc[tail];
132 if (trcm->stopped)
133 return;
135 trc->fileno = (u16) fileno;
136 trc->line = (u16) line;
137 trc->data.u64 = data;
138 trc->timestamp = BFA_TRC_TS(trcm);
139 dc_flush(trc);
141 trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
142 if (trcm->tail == trcm->head)
143 trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
144 dc_flush(trcm);
148 static inline void
149 __bfa_trc32(struct bfa_trc_mod_s *trcm, int fileno, int line, u32 data)
151 int tail = trcm->tail;
152 struct bfa_trc_s *trc = &trcm->trc[tail];
154 if (trcm->stopped)
155 return;
157 trc->fileno = (u16) fileno;
158 trc->line = (u16) line;
159 trc->data.u32.u32 = data;
160 trc->timestamp = BFA_TRC_TS(trcm);
161 dc_flush(trc);
163 trcm->tail = (trcm->tail + 1) & (BFA_TRC_MAX - 1);
164 if (trcm->tail == trcm->head)
165 trcm->head = (trcm->head + 1) & (BFA_TRC_MAX - 1);
166 dc_flush(trcm);
169 #ifndef BFA_PERF_BUILD
170 #define bfa_trc_fp(_trcp, _data) bfa_trc(_trcp, _data)
171 #else
172 #define bfa_trc_fp(_trcp, _data)
173 #endif
175 #endif /* __BFA_TRC_H__ */