2 * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
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.
20 #include <bfa_os_inc.h>
23 #define BFA_TRC_MAX (4 * 1024)
27 #define BFA_TRC_TS(_trcm) ((_trcm)->ticks++)
49 struct bfa_trc_mod_s
{
56 struct bfa_trc_s trc
[BFA_TRC_MAX
];
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)
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) | \
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)
98 void bfa_boot_trc(struct bfa_trc_mod_s
*trcmod
, u16 fileno
,
100 #define bfa_trc(_trcp, _data) \
101 bfa_boot_trc((_trcp)->trcmod, __trc_fileno, __LINE__, (u32)_data)
106 bfa_trc_init(struct bfa_trc_mod_s
*trcm
)
108 trcm
->head
= trcm
->tail
= trcm
->stopped
= 0;
109 trcm
->ntrc
= BFA_TRC_MAX
;
114 bfa_trc_stop(struct bfa_trc_mod_s
*trcm
)
120 extern void dc_flush(void *data
);
122 #define dc_flush(data)
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
];
135 trc
->fileno
= (u16
) fileno
;
136 trc
->line
= (u16
) line
;
137 trc
->data
.u64
= data
;
138 trc
->timestamp
= BFA_TRC_TS(trcm
);
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);
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
];
157 trc
->fileno
= (u16
) fileno
;
158 trc
->line
= (u16
) line
;
159 trc
->data
.u32
.u32
= data
;
160 trc
->timestamp
= BFA_TRC_TS(trcm
);
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);
169 #ifndef BFA_PERF_BUILD
170 #define bfa_trc_fp(_trcp, _data) bfa_trc(_trcp, _data)
172 #define bfa_trc_fp(_trcp, _data)
175 #endif /* __BFA_TRC_H__ */