1 /******************************************************************************
2  *
3  *  Copyright (C) 1999-2012 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 #ifndef BT_TRACE_H
19 #define BT_TRACE_H
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 /* External declaration for appl_trace_level here to avoid to add the
26  * declaration in all the files using APPL_TRACExxx macros */
27 extern uint8_t appl_trace_level;
28 
29 /* Prototype for message logging function. */
30 extern void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...);
31 extern void LogMsg_0(uint32_t trace_set_mask, const char* p_str);
32 extern void LogMsg_1(uint32_t trace_set_mask, const char* fmt_str,
33                      uintptr_t p1);
34 extern void LogMsg_2(uint32_t trace_set_mask, const char* fmt_str, uintptr_t p1,
35                      uintptr_t p2);
36 extern void LogMsg_3(uint32_t trace_set_mask, const char* fmt_str, uintptr_t p1,
37                      uintptr_t p2, uintptr_t p3);
38 extern void LogMsg_4(uint32_t trace_set_mask, const char* fmt_str, uintptr_t p1,
39                      uintptr_t p2, uintptr_t p3, uintptr_t p4);
40 extern void LogMsg_5(uint32_t trace_set_mask, const char* fmt_str, uintptr_t p1,
41                      uintptr_t p2, uintptr_t p3, uintptr_t p4, uintptr_t p5);
42 extern void LogMsg_6(uint32_t trace_set_mask, const char* fmt_str, uintptr_t p1,
43                      uintptr_t p2, uintptr_t p3, uintptr_t p4, uintptr_t p5,
44                      uintptr_t p6);
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 
50 /******************************************************************************
51 **
52 ** Trace configurable parameters
53 **
54 ******************************************************************************/
55 
56 /* Enables or disables verbose trace information. */
57 #ifndef BT_TRACE_VERBOSE
58 #define BT_TRACE_VERBOSE FALSE
59 #endif
60 
61 /* Enables or disables protocol trace information. */
62 #ifndef BT_TRACE_PROTOCOL
63 #define BT_TRACE_PROTOCOL TRUE /* Android requires TRUE */
64 #endif
65 
66 /******************************************************************************
67 **
68 ** Trace Levels
69 **
70 ** The following values may be used for different levels:
71 **      BT_TRACE_LEVEL_NONE    0        * No trace messages to be generated
72 **      BT_TRACE_LEVEL_ERROR   1        * Error condition trace messages
73 **      BT_TRACE_LEVEL_WARNING 2        * Warning condition trace messages
74 **      BT_TRACE_LEVEL_API     3        * API traces
75 **      BT_TRACE_LEVEL_EVENT   4        * Debug messages for events
76 **      BT_TRACE_LEVEL_DEBUG   5        * Debug messages (general)
77 ******************************************************************************/
78 
79 /* Core Stack default trace levels */
80 #ifndef HCI_INITIAL_TRACE_LEVEL
81 #define HCI_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG
82 #endif
83 
84 #ifndef LLCP_INITIAL_TRACE_LEVEL
85 #define LLCP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG
86 #endif
87 
88 #ifndef APPL_INITIAL_TRACE_LEVEL
89 #define APPL_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG
90 #endif
91 
92 #ifndef NFC_INITIAL_TRACE_LEVEL
93 #define NFC_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG
94 #endif
95 
96 #ifndef SMP_INITIAL_TRACE_LEVEL
97 #define SMP_INITIAL_TRACE_LEVEL BT_TRACE_LEVEL_DEBUG
98 #endif
99 
100 #define BT_TRACE_0(l, t, m) \
101   LogMsg_0((TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t)), (m))
102 #define BT_TRACE_1(l, t, m, p1)                                   \
103   LogMsg_1(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), \
104            (uintptr_t)(p1))
105 #define BT_TRACE_2(l, t, m, p1, p2)                               \
106   LogMsg_2(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), \
107            (uintptr_t)(p1), (uintptr_t)(p2))
108 #define BT_TRACE_3(l, t, m, p1, p2, p3)                           \
109   LogMsg_3(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), \
110            (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3))
111 #define BT_TRACE_4(l, t, m, p1, p2, p3, p4)                       \
112   LogMsg_4(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m), \
113            (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3), (uintptr_t)(p4))
114 #define BT_TRACE_5(l, t, m, p1, p2, p3, p4, p5)                                \
115   LogMsg_5(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m),              \
116            (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3), (uintptr_t)(p4), \
117            (uintptr_t)(p5))
118 #define BT_TRACE_6(l, t, m, p1, p2, p3, p4, p5, p6)                            \
119   LogMsg_6(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | (t), (m),              \
120            (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3), (uintptr_t)(p4), \
121            (uintptr_t)(p5), (uintptr_t)(p6))
122 
123 #define BT_ERROR_TRACE_0(l, m) \
124   LogMsg_0(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR, (m))
125 #define BT_ERROR_TRACE_1(l, m, p1)                                             \
126   LogMsg_1(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR, (m), \
127            (uintptr_t)(p1))
128 #define BT_ERROR_TRACE_2(l, m, p1, p2)                                         \
129   LogMsg_2(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR, (m), \
130            (uintptr_t)(p1), (uintptr_t)(p2))
131 #define BT_ERROR_TRACE_3(l, m, p1, p2, p3)                                     \
132   LogMsg_3(TRACE_CTRL_GENERAL | (l) | TRACE_ORG_STACK | TRACE_TYPE_ERROR, (m), \
133            (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3))
134 
135 /* Define tracing for the LLCP unit
136 */
137 #define LLCP_TRACE_ERROR0(m)                             \
138   {                                                      \
139     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR)     \
140       BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m); \
141   }
142 #define LLCP_TRACE_ERROR1(m, p1)                             \
143   {                                                          \
144     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR)         \
145       BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m, p1); \
146   }
147 #define LLCP_TRACE_ERROR2(m, p1, p2)                             \
148   {                                                              \
149     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR)             \
150       BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m, p1, p2); \
151   }
152 #define LLCP_TRACE_ERROR3(m, p1, p2, p3)                             \
153   {                                                                  \
154     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                 \
155       BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m, p1, p2, p3); \
156   }
157 #define LLCP_TRACE_ERROR4(m, p1, p2, p3, p4)                             \
158   {                                                                      \
159     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                     \
160       BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m, p1, p2, p3, p4); \
161   }
162 #define LLCP_TRACE_ERROR5(m, p1, p2, p3, p4, p5)                             \
163   {                                                                          \
164     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                         \
165       BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5); \
166   }
167 #define LLCP_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)                        \
168   {                                                                         \
169     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                        \
170       BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5, \
171                  p6);                                                       \
172   }
173 
174 #define LLCP_TRACE_WARNING0(m)                             \
175   {                                                        \
176     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING)     \
177       BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m); \
178   }
179 #define LLCP_TRACE_WARNING1(m, p1)                             \
180   {                                                            \
181     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING)         \
182       BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m, p1); \
183   }
184 #define LLCP_TRACE_WARNING2(m, p1, p2)                             \
185   {                                                                \
186     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING)             \
187       BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m, p1, p2); \
188   }
189 #define LLCP_TRACE_WARNING3(m, p1, p2, p3)                             \
190   {                                                                    \
191     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                 \
192       BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m, p1, p2, p3); \
193   }
194 #define LLCP_TRACE_WARNING4(m, p1, p2, p3, p4)                             \
195   {                                                                        \
196     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                     \
197       BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m, p1, p2, p3, p4); \
198   }
199 #define LLCP_TRACE_WARNING5(m, p1, p2, p3, p4, p5)                             \
200   {                                                                            \
201     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                         \
202       BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5); \
203   }
204 #define LLCP_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)                        \
205   {                                                                           \
206     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                        \
207       BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5, \
208                  p6);                                                         \
209   }
210 
211 #define LLCP_TRACE_API0(m)                             \
212   {                                                    \
213     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API)     \
214       BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_API, m); \
215   }
216 #define LLCP_TRACE_API1(m, p1)                             \
217   {                                                        \
218     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API)         \
219       BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_API, m, p1); \
220   }
221 #define LLCP_TRACE_API2(m, p1, p2)                             \
222   {                                                            \
223     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API)             \
224       BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_API, m, p1, p2); \
225   }
226 #define LLCP_TRACE_API3(m, p1, p2, p3)                             \
227   {                                                                \
228     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API)                 \
229       BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_API, m, p1, p2, p3); \
230   }
231 #define LLCP_TRACE_API4(m, p1, p2, p3, p4)                             \
232   {                                                                    \
233     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API)                     \
234       BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_API, m, p1, p2, p3, p4); \
235   }
236 #define LLCP_TRACE_API5(m, p1, p2, p3, p4, p5)                             \
237   {                                                                        \
238     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API)                         \
239       BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_API, m, p1, p2, p3, p4, p5); \
240   }
241 #define LLCP_TRACE_API6(m, p1, p2, p3, p4, p5, p6)                             \
242   {                                                                            \
243     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_API)                             \
244       BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_API, m, p1, p2, p3, p4, p5, p6); \
245   }
246 
247 #define LLCP_TRACE_EVENT0(m)                             \
248   {                                                      \
249     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT)     \
250       BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m); \
251   }
252 #define LLCP_TRACE_EVENT1(m, p1)                             \
253   {                                                          \
254     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT)         \
255       BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m, p1); \
256   }
257 #define LLCP_TRACE_EVENT2(m, p1, p2)                             \
258   {                                                              \
259     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT)             \
260       BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m, p1, p2); \
261   }
262 #define LLCP_TRACE_EVENT3(m, p1, p2, p3)                             \
263   {                                                                  \
264     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                 \
265       BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m, p1, p2, p3); \
266   }
267 #define LLCP_TRACE_EVENT4(m, p1, p2, p3, p4)                             \
268   {                                                                      \
269     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                     \
270       BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m, p1, p2, p3, p4); \
271   }
272 #define LLCP_TRACE_EVENT5(m, p1, p2, p3, p4, p5)                             \
273   {                                                                          \
274     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                         \
275       BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5); \
276   }
277 #define LLCP_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)                        \
278   {                                                                         \
279     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                        \
280       BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5, \
281                  p6);                                                       \
282   }
283 
284 #define LLCP_TRACE_DEBUG0(m)                             \
285   {                                                      \
286     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)     \
287       BT_TRACE_0(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m); \
288   }
289 #define LLCP_TRACE_DEBUG1(m, p1)                             \
290   {                                                          \
291     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)         \
292       BT_TRACE_1(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m, p1); \
293   }
294 #define LLCP_TRACE_DEBUG2(m, p1, p2)                             \
295   {                                                              \
296     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)             \
297       BT_TRACE_2(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m, p1, p2); \
298   }
299 #define LLCP_TRACE_DEBUG3(m, p1, p2, p3)                             \
300   {                                                                  \
301     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                 \
302       BT_TRACE_3(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m, p1, p2, p3); \
303   }
304 #define LLCP_TRACE_DEBUG4(m, p1, p2, p3, p4)                             \
305   {                                                                      \
306     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                     \
307       BT_TRACE_4(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4); \
308   }
309 #define LLCP_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)                             \
310   {                                                                          \
311     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                         \
312       BT_TRACE_5(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5); \
313   }
314 #define LLCP_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)                        \
315   {                                                                         \
316     if (llcp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                        \
317       BT_TRACE_6(TRACE_LAYER_LLCP, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5, \
318                  p6);                                                       \
319   }
320 
321 /* Define tracing for the NFC unit
322 */
323 #define NFC_TRACE_ERROR0(m)                             \
324   {                                                     \
325     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR)     \
326       BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m); \
327   }
328 #define NFC_TRACE_ERROR1(m, p1)                             \
329   {                                                         \
330     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR)         \
331       BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m, p1); \
332   }
333 #define NFC_TRACE_ERROR2(m, p1, p2)                             \
334   {                                                             \
335     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR)             \
336       BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m, p1, p2); \
337   }
338 #define NFC_TRACE_ERROR3(m, p1, p2, p3)                             \
339   {                                                                 \
340     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                 \
341       BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m, p1, p2, p3); \
342   }
343 #define NFC_TRACE_ERROR4(m, p1, p2, p3, p4)                             \
344   {                                                                     \
345     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                     \
346       BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m, p1, p2, p3, p4); \
347   }
348 #define NFC_TRACE_ERROR5(m, p1, p2, p3, p4, p5)                             \
349   {                                                                         \
350     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                         \
351       BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5); \
352   }
353 #define NFC_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)                        \
354   {                                                                        \
355     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                        \
356       BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5, \
357                  p6);                                                      \
358   }
359 
360 #define NFC_TRACE_WARNING0(m)                             \
361   {                                                       \
362     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING)     \
363       BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m); \
364   }
365 #define NFC_TRACE_WARNING1(m, p1)                             \
366   {                                                           \
367     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING)         \
368       BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m, p1); \
369   }
370 #define NFC_TRACE_WARNING2(m, p1, p2)                             \
371   {                                                               \
372     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING)             \
373       BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m, p1, p2); \
374   }
375 #define NFC_TRACE_WARNING3(m, p1, p2, p3)                             \
376   {                                                                   \
377     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                 \
378       BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m, p1, p2, p3); \
379   }
380 #define NFC_TRACE_WARNING4(m, p1, p2, p3, p4)                             \
381   {                                                                       \
382     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                     \
383       BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m, p1, p2, p3, p4); \
384   }
385 #define NFC_TRACE_WARNING5(m, p1, p2, p3, p4, p5)                             \
386   {                                                                           \
387     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                         \
388       BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5); \
389   }
390 #define NFC_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)                        \
391   {                                                                          \
392     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                        \
393       BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5, \
394                  p6);                                                        \
395   }
396 
397 #define NFC_TRACE_API0(m)                             \
398   {                                                   \
399     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API)     \
400       BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_API, m); \
401   }
402 #define NFC_TRACE_API1(m, p1)                             \
403   {                                                       \
404     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API)         \
405       BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_API, m, p1); \
406   }
407 #define NFC_TRACE_API2(m, p1, p2)                             \
408   {                                                           \
409     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API)             \
410       BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_API, m, p1, p2); \
411   }
412 #define NFC_TRACE_API3(m, p1, p2, p3)                             \
413   {                                                               \
414     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API)                 \
415       BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_API, m, p1, p2, p3); \
416   }
417 #define NFC_TRACE_API4(m, p1, p2, p3, p4)                             \
418   {                                                                   \
419     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API)                     \
420       BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_API, m, p1, p2, p3, p4); \
421   }
422 #define NFC_TRACE_API5(m, p1, p2, p3, p4, p5)                             \
423   {                                                                       \
424     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API)                         \
425       BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_API, m, p1, p2, p3, p4, p5); \
426   }
427 #define NFC_TRACE_API6(m, p1, p2, p3, p4, p5, p6)                             \
428   {                                                                           \
429     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_API)                             \
430       BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_API, m, p1, p2, p3, p4, p5, p6); \
431   }
432 
433 #define NFC_TRACE_EVENT0(m)                             \
434   {                                                     \
435     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT)     \
436       BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m); \
437   }
438 #define NFC_TRACE_EVENT1(m, p1)                             \
439   {                                                         \
440     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT)         \
441       BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m, p1); \
442   }
443 #define NFC_TRACE_EVENT2(m, p1, p2)                             \
444   {                                                             \
445     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT)             \
446       BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m, p1, p2); \
447   }
448 #define NFC_TRACE_EVENT3(m, p1, p2, p3)                             \
449   {                                                                 \
450     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                 \
451       BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m, p1, p2, p3); \
452   }
453 #define NFC_TRACE_EVENT4(m, p1, p2, p3, p4)                             \
454   {                                                                     \
455     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                     \
456       BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m, p1, p2, p3, p4); \
457   }
458 #define NFC_TRACE_EVENT5(m, p1, p2, p3, p4, p5)                             \
459   {                                                                         \
460     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                         \
461       BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5); \
462   }
463 #define NFC_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)                        \
464   {                                                                        \
465     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                        \
466       BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5, \
467                  p6);                                                      \
468   }
469 
470 #define NFC_TRACE_DEBUG0(m)                             \
471   {                                                     \
472     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)     \
473       BT_TRACE_0(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m); \
474   }
475 #define NFC_TRACE_DEBUG1(m, p1)                             \
476   {                                                         \
477     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)         \
478       BT_TRACE_1(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m, p1); \
479   }
480 #define NFC_TRACE_DEBUG2(m, p1, p2)                             \
481   {                                                             \
482     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)             \
483       BT_TRACE_2(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m, p1, p2); \
484   }
485 #define NFC_TRACE_DEBUG3(m, p1, p2, p3)                             \
486   {                                                                 \
487     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                 \
488       BT_TRACE_3(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m, p1, p2, p3); \
489   }
490 #define NFC_TRACE_DEBUG4(m, p1, p2, p3, p4)                             \
491   {                                                                     \
492     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                     \
493       BT_TRACE_4(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4); \
494   }
495 #define NFC_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)                             \
496   {                                                                         \
497     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                         \
498       BT_TRACE_5(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5); \
499   }
500 #define NFC_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)                        \
501   {                                                                        \
502     if (nfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                        \
503       BT_TRACE_6(TRACE_LAYER_NFC, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5, \
504                  p6);                                                      \
505   }
506 
507 #define NCI_TRACE_ERROR0(m)                             \
508   {                                                     \
509     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_ERROR)    \
510       BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m); \
511   }
512 #define NCI_TRACE_ERROR1(m, p1)                             \
513   {                                                         \
514     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_ERROR)        \
515       BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m, p1); \
516   }
517 #define NCI_TRACE_ERROR2(m, p1, p2)                             \
518   {                                                             \
519     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_ERROR)            \
520       BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m, p1, p2); \
521   }
522 #define NCI_TRACE_ERROR3(m, p1, p2, p3)                             \
523   {                                                                 \
524     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                \
525       BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m, p1, p2, p3); \
526   }
527 #define NCI_TRACE_ERROR4(m, p1, p2, p3, p4)                             \
528   {                                                                     \
529     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                    \
530       BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m, p1, p2, p3, p4); \
531   }
532 #define NCI_TRACE_ERROR5(m, p1, p2, p3, p4, p5)                             \
533   {                                                                         \
534     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                        \
535       BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5); \
536   }
537 #define NCI_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)                        \
538   {                                                                        \
539     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                       \
540       BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5, \
541                  p6);                                                      \
542   }
543 
544 #define NCI_TRACE_WARNING0(m)                             \
545   {                                                       \
546     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_WARNING)    \
547       BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m); \
548   }
549 #define NCI_TRACE_WARNING1(m, p1)                             \
550   {                                                           \
551     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_WARNING)        \
552       BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m, p1); \
553   }
554 #define NCI_TRACE_WARNING2(m, p1, p2)                             \
555   {                                                               \
556     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_WARNING)            \
557       BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m, p1, p2); \
558   }
559 #define NCI_TRACE_WARNING3(m, p1, p2, p3)                             \
560   {                                                                   \
561     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                \
562       BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m, p1, p2, p3); \
563   }
564 #define NCI_TRACE_WARNING4(m, p1, p2, p3, p4)                             \
565   {                                                                       \
566     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                    \
567       BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m, p1, p2, p3, p4); \
568   }
569 #define NCI_TRACE_WARNING5(m, p1, p2, p3, p4, p5)                             \
570   {                                                                           \
571     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                        \
572       BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5); \
573   }
574 #define NCI_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)                        \
575   {                                                                          \
576     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                       \
577       BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5, \
578                  p6);                                                        \
579   }
580 
581 #define NCI_TRACE_API0(m)                             \
582   {                                                   \
583     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_API)    \
584       BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_API, m); \
585   }
586 #define NCI_TRACE_API1(m, p1)                             \
587   {                                                       \
588     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_API)        \
589       BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_API, m, p1); \
590   }
591 #define NCI_TRACE_API2(m, p1, p2)                             \
592   {                                                           \
593     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_API)            \
594       BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_API, m, p1, p2); \
595   }
596 #define NCI_TRACE_API3(m, p1, p2, p3)                             \
597   {                                                               \
598     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_API)                \
599       BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_API, m, p1, p2, p3); \
600   }
601 #define NCI_TRACE_API4(m, p1, p2, p3, p4)                             \
602   {                                                                   \
603     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_API)                    \
604       BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_API, m, p1, p2, p3, p4); \
605   }
606 #define NCI_TRACE_API5(m, p1, p2, p3, p4, p5)                             \
607   {                                                                       \
608     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_API)                        \
609       BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_API, m, p1, p2, p3, p4, p5); \
610   }
611 #define NCI_TRACE_API6(m, p1, p2, p3, p4, p5, p6)                             \
612   {                                                                           \
613     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_API)                            \
614       BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_API, m, p1, p2, p3, p4, p5, p6); \
615   }
616 
617 #define NCI_TRACE_EVENT0(m)                             \
618   {                                                     \
619     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_EVENT)    \
620       BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m); \
621   }
622 #define NCI_TRACE_EVENT1(m, p1)                             \
623   {                                                         \
624     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_EVENT)        \
625       BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m, p1); \
626   }
627 #define NCI_TRACE_EVENT2(m, p1, p2)                             \
628   {                                                             \
629     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_EVENT)            \
630       BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m, p1, p2); \
631   }
632 #define NCI_TRACE_EVENT3(m, p1, p2, p3)                             \
633   {                                                                 \
634     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                \
635       BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m, p1, p2, p3); \
636   }
637 #define NCI_TRACE_EVENT4(m, p1, p2, p3, p4)                             \
638   {                                                                     \
639     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                    \
640       BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m, p1, p2, p3, p4); \
641   }
642 #define NCI_TRACE_EVENT5(m, p1, p2, p3, p4, p5)                             \
643   {                                                                         \
644     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                        \
645       BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5); \
646   }
647 #define NCI_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)                        \
648   {                                                                        \
649     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                       \
650       BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5, \
651                  p6);                                                      \
652   }
653 
654 #define NCI_TRACE_DEBUG0(m)                             \
655   {                                                     \
656     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)    \
657       BT_TRACE_0(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m); \
658   }
659 #define NCI_TRACE_DEBUG1(m, p1)                             \
660   {                                                         \
661     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)        \
662       BT_TRACE_1(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m, p1); \
663   }
664 #define NCI_TRACE_DEBUG2(m, p1, p2)                             \
665   {                                                             \
666     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)            \
667       BT_TRACE_2(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m, p1, p2); \
668   }
669 #define NCI_TRACE_DEBUG3(m, p1, p2, p3)                             \
670   {                                                                 \
671     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                \
672       BT_TRACE_3(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m, p1, p2, p3); \
673   }
674 #define NCI_TRACE_DEBUG4(m, p1, p2, p3, p4)                             \
675   {                                                                     \
676     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                    \
677       BT_TRACE_4(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4); \
678   }
679 #define NCI_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)                             \
680   {                                                                         \
681     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                        \
682       BT_TRACE_5(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5); \
683   }
684 #define NCI_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)                        \
685   {                                                                        \
686     if (ncit_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                       \
687       BT_TRACE_6(TRACE_LAYER_NCI, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5, \
688                  p6);                                                      \
689   }
690 
691 #define RW_TRACE_ERROR0(m)                             \
692   {                                                    \
693     if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR)     \
694       BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m); \
695   }
696 #define RW_TRACE_ERROR1(m, p1)                             \
697   {                                                        \
698     if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR)         \
699       BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m, p1); \
700   }
701 #define RW_TRACE_ERROR2(m, p1, p2)                             \
702   {                                                            \
703     if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR)             \
704       BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m, p1, p2); \
705   }
706 #define RW_TRACE_ERROR3(m, p1, p2, p3)                             \
707   {                                                                \
708     if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                 \
709       BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m, p1, p2, p3); \
710   }
711 #define RW_TRACE_ERROR4(m, p1, p2, p3, p4)                             \
712   {                                                                    \
713     if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                     \
714       BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m, p1, p2, p3, p4); \
715   }
716 #define RW_TRACE_ERROR5(m, p1, p2, p3, p4, p5)                             \
717   {                                                                        \
718     if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                         \
719       BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5); \
720   }
721 #define RW_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)                             \
722   {                                                                            \
723     if (rw_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                             \
724       BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5, p6); \
725   }
726 
727 #define RW_TRACE_WARNING0(m)                             \
728   {                                                      \
729     if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING)     \
730       BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m); \
731   }
732 #define RW_TRACE_WARNING1(m, p1)                             \
733   {                                                          \
734     if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING)         \
735       BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m, p1); \
736   }
737 #define RW_TRACE_WARNING2(m, p1, p2)                             \
738   {                                                              \
739     if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING)             \
740       BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m, p1, p2); \
741   }
742 #define RW_TRACE_WARNING3(m, p1, p2, p3)                             \
743   {                                                                  \
744     if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                 \
745       BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m, p1, p2, p3); \
746   }
747 #define RW_TRACE_WARNING4(m, p1, p2, p3, p4)                             \
748   {                                                                      \
749     if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                     \
750       BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m, p1, p2, p3, p4); \
751   }
752 #define RW_TRACE_WARNING5(m, p1, p2, p3, p4, p5)                             \
753   {                                                                          \
754     if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                         \
755       BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5); \
756   }
757 #define RW_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)                        \
758   {                                                                         \
759     if (rw_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                        \
760       BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5, \
761                  p6);                                                       \
762   }
763 
764 #define RW_TRACE_API0(m)                             \
765   {                                                  \
766     if (rw_cb.trace_level >= BT_TRACE_LEVEL_API)     \
767       BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_API, m); \
768   }
769 #define RW_TRACE_API1(m, p1)                             \
770   {                                                      \
771     if (rw_cb.trace_level >= BT_TRACE_LEVEL_API)         \
772       BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_API, m, p1); \
773   }
774 #define RW_TRACE_API2(m, p1, p2)                             \
775   {                                                          \
776     if (rw_cb.trace_level >= BT_TRACE_LEVEL_API)             \
777       BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_API, m, p1, p2); \
778   }
779 #define RW_TRACE_API3(m, p1, p2, p3)                             \
780   {                                                              \
781     if (rw_cb.trace_level >= BT_TRACE_LEVEL_API)                 \
782       BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_API, m, p1, p2, p3); \
783   }
784 #define RW_TRACE_API4(m, p1, p2, p3, p4)                             \
785   {                                                                  \
786     if (rw_cb.trace_level >= BT_TRACE_LEVEL_API)                     \
787       BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_API, m, p1, p2, p3, p4); \
788   }
789 #define RW_TRACE_API5(m, p1, p2, p3, p4, p5)                             \
790   {                                                                      \
791     if (rw_cb.trace_level >= BT_TRACE_LEVEL_API)                         \
792       BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_API, m, p1, p2, p3, p4, p5); \
793   }
794 #define RW_TRACE_API6(m, p1, p2, p3, p4, p5, p6)                             \
795   {                                                                          \
796     if (rw_cb.trace_level >= BT_TRACE_LEVEL_API)                             \
797       BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_API, m, p1, p2, p3, p4, p5, p6); \
798   }
799 
800 #define RW_TRACE_EVENT0(m)                             \
801   {                                                    \
802     if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT)     \
803       BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m); \
804   }
805 #define RW_TRACE_EVENT1(m, p1)                             \
806   {                                                        \
807     if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT)         \
808       BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m, p1); \
809   }
810 #define RW_TRACE_EVENT2(m, p1, p2)                             \
811   {                                                            \
812     if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT)             \
813       BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m, p1, p2); \
814   }
815 #define RW_TRACE_EVENT3(m, p1, p2, p3)                             \
816   {                                                                \
817     if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                 \
818       BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m, p1, p2, p3); \
819   }
820 #define RW_TRACE_EVENT4(m, p1, p2, p3, p4)                             \
821   {                                                                    \
822     if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                     \
823       BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m, p1, p2, p3, p4); \
824   }
825 #define RW_TRACE_EVENT5(m, p1, p2, p3, p4, p5)                             \
826   {                                                                        \
827     if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                         \
828       BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5); \
829   }
830 #define RW_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)                             \
831   {                                                                            \
832     if (rw_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                             \
833       BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5, p6); \
834   }
835 
836 #define RW_TRACE_DEBUG0(m)                             \
837   {                                                    \
838     if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)     \
839       BT_TRACE_0(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m); \
840   }
841 #define RW_TRACE_DEBUG1(m, p1)                             \
842   {                                                        \
843     if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)         \
844       BT_TRACE_1(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m, p1); \
845   }
846 #define RW_TRACE_DEBUG2(m, p1, p2)                             \
847   {                                                            \
848     if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)             \
849       BT_TRACE_2(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m, p1, p2); \
850   }
851 #define RW_TRACE_DEBUG3(m, p1, p2, p3)                             \
852   {                                                                \
853     if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                 \
854       BT_TRACE_3(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m, p1, p2, p3); \
855   }
856 #define RW_TRACE_DEBUG4(m, p1, p2, p3, p4)                             \
857   {                                                                    \
858     if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                     \
859       BT_TRACE_4(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4); \
860   }
861 #define RW_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)                             \
862   {                                                                        \
863     if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                         \
864       BT_TRACE_5(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5); \
865   }
866 #define RW_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)                             \
867   {                                                                            \
868     if (rw_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                             \
869       BT_TRACE_6(TRACE_LAYER_RW, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5, p6); \
870   }
871 
872 #define CE_TRACE_ERROR0(m)                             \
873   {                                                    \
874     if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR)     \
875       BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m); \
876   }
877 #define CE_TRACE_ERROR1(m, p1)                             \
878   {                                                        \
879     if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR)         \
880       BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m, p1); \
881   }
882 #define CE_TRACE_ERROR2(m, p1, p2)                             \
883   {                                                            \
884     if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR)             \
885       BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m, p1, p2); \
886   }
887 #define CE_TRACE_ERROR3(m, p1, p2, p3)                             \
888   {                                                                \
889     if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                 \
890       BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m, p1, p2, p3); \
891   }
892 #define CE_TRACE_ERROR4(m, p1, p2, p3, p4)                             \
893   {                                                                    \
894     if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                     \
895       BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m, p1, p2, p3, p4); \
896   }
897 #define CE_TRACE_ERROR5(m, p1, p2, p3, p4, p5)                             \
898   {                                                                        \
899     if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                         \
900       BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5); \
901   }
902 #define CE_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)                             \
903   {                                                                            \
904     if (ce_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                             \
905       BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5, p6); \
906   }
907 
908 #define CE_TRACE_WARNING0(m)                             \
909   {                                                      \
910     if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING)     \
911       BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m); \
912   }
913 #define CE_TRACE_WARNING1(m, p1)                             \
914   {                                                          \
915     if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING)         \
916       BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m, p1); \
917   }
918 #define CE_TRACE_WARNING2(m, p1, p2)                             \
919   {                                                              \
920     if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING)             \
921       BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m, p1, p2); \
922   }
923 #define CE_TRACE_WARNING3(m, p1, p2, p3)                             \
924   {                                                                  \
925     if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                 \
926       BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m, p1, p2, p3); \
927   }
928 #define CE_TRACE_WARNING4(m, p1, p2, p3, p4)                             \
929   {                                                                      \
930     if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                     \
931       BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m, p1, p2, p3, p4); \
932   }
933 #define CE_TRACE_WARNING5(m, p1, p2, p3, p4, p5)                             \
934   {                                                                          \
935     if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                         \
936       BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5); \
937   }
938 #define CE_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)                        \
939   {                                                                         \
940     if (ce_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                        \
941       BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5, \
942                  p6);                                                       \
943   }
944 
945 #define CE_TRACE_API0(m)                             \
946   {                                                  \
947     if (ce_cb.trace_level >= BT_TRACE_LEVEL_API)     \
948       BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_API, m); \
949   }
950 #define CE_TRACE_API1(m, p1)                             \
951   {                                                      \
952     if (ce_cb.trace_level >= BT_TRACE_LEVEL_API)         \
953       BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_API, m, p1); \
954   }
955 #define CE_TRACE_API2(m, p1, p2)                             \
956   {                                                          \
957     if (ce_cb.trace_level >= BT_TRACE_LEVEL_API)             \
958       BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_API, m, p1, p2); \
959   }
960 #define CE_TRACE_API3(m, p1, p2, p3)                             \
961   {                                                              \
962     if (ce_cb.trace_level >= BT_TRACE_LEVEL_API)                 \
963       BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_API, m, p1, p2, p3); \
964   }
965 #define CE_TRACE_API4(m, p1, p2, p3, p4)                             \
966   {                                                                  \
967     if (ce_cb.trace_level >= BT_TRACE_LEVEL_API)                     \
968       BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_API, m, p1, p2, p3, p4); \
969   }
970 #define CE_TRACE_API5(m, p1, p2, p3, p4, p5)                             \
971   {                                                                      \
972     if (ce_cb.trace_level >= BT_TRACE_LEVEL_API)                         \
973       BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_API, m, p1, p2, p3, p4, p5); \
974   }
975 #define CE_TRACE_API6(m, p1, p2, p3, p4, p5, p6)                             \
976   {                                                                          \
977     if (ce_cb.trace_level >= BT_TRACE_LEVEL_API)                             \
978       BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_API, m, p1, p2, p3, p4, p5, p6); \
979   }
980 
981 #define CE_TRACE_EVENT0(m)                             \
982   {                                                    \
983     if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT)     \
984       BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m); \
985   }
986 #define CE_TRACE_EVENT1(m, p1)                             \
987   {                                                        \
988     if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT)         \
989       BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m, p1); \
990   }
991 #define CE_TRACE_EVENT2(m, p1, p2)                             \
992   {                                                            \
993     if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT)             \
994       BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m, p1, p2); \
995   }
996 #define CE_TRACE_EVENT3(m, p1, p2, p3)                             \
997   {                                                                \
998     if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                 \
999       BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m, p1, p2, p3); \
1000   }
1001 #define CE_TRACE_EVENT4(m, p1, p2, p3, p4)                             \
1002   {                                                                    \
1003     if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                     \
1004       BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m, p1, p2, p3, p4); \
1005   }
1006 #define CE_TRACE_EVENT5(m, p1, p2, p3, p4, p5)                             \
1007   {                                                                        \
1008     if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                         \
1009       BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5); \
1010   }
1011 #define CE_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)                             \
1012   {                                                                            \
1013     if (ce_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                             \
1014       BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5, p6); \
1015   }
1016 
1017 #define CE_TRACE_DEBUG0(m)                             \
1018   {                                                    \
1019     if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)     \
1020       BT_TRACE_0(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m); \
1021   }
1022 #define CE_TRACE_DEBUG1(m, p1)                             \
1023   {                                                        \
1024     if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)         \
1025       BT_TRACE_1(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m, p1); \
1026   }
1027 #define CE_TRACE_DEBUG2(m, p1, p2)                             \
1028   {                                                            \
1029     if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)             \
1030       BT_TRACE_2(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m, p1, p2); \
1031   }
1032 #define CE_TRACE_DEBUG3(m, p1, p2, p3)                             \
1033   {                                                                \
1034     if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                 \
1035       BT_TRACE_3(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m, p1, p2, p3); \
1036   }
1037 #define CE_TRACE_DEBUG4(m, p1, p2, p3, p4)                             \
1038   {                                                                    \
1039     if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                     \
1040       BT_TRACE_4(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4); \
1041   }
1042 #define CE_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)                             \
1043   {                                                                        \
1044     if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                         \
1045       BT_TRACE_5(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5); \
1046   }
1047 #define CE_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)                             \
1048   {                                                                            \
1049     if (ce_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                             \
1050       BT_TRACE_6(TRACE_LAYER_CE, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5, p6); \
1051   }
1052 
1053 #define NDEF_TRACE_ERROR0(m)                             \
1054   {                                                      \
1055     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR)     \
1056       BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m); \
1057   }
1058 #define NDEF_TRACE_ERROR1(m, p1)                             \
1059   {                                                          \
1060     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR)         \
1061       BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m, p1); \
1062   }
1063 #define NDEF_TRACE_ERROR2(m, p1, p2)                             \
1064   {                                                              \
1065     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR)             \
1066       BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m, p1, p2); \
1067   }
1068 #define NDEF_TRACE_ERROR3(m, p1, p2, p3)                             \
1069   {                                                                  \
1070     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                 \
1071       BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m, p1, p2, p3); \
1072   }
1073 #define NDEF_TRACE_ERROR4(m, p1, p2, p3, p4)                             \
1074   {                                                                      \
1075     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                     \
1076       BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m, p1, p2, p3, p4); \
1077   }
1078 #define NDEF_TRACE_ERROR5(m, p1, p2, p3, p4, p5)                             \
1079   {                                                                          \
1080     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                         \
1081       BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5); \
1082   }
1083 #define NDEF_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)                        \
1084   {                                                                         \
1085     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                        \
1086       BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5, \
1087                  p6);                                                       \
1088   }
1089 
1090 #define NDEF_TRACE_WARNING0(m)                             \
1091   {                                                        \
1092     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING)     \
1093       BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m); \
1094   }
1095 #define NDEF_TRACE_WARNING1(m, p1)                             \
1096   {                                                            \
1097     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING)         \
1098       BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m, p1); \
1099   }
1100 #define NDEF_TRACE_WARNING2(m, p1, p2)                             \
1101   {                                                                \
1102     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING)             \
1103       BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m, p1, p2); \
1104   }
1105 #define NDEF_TRACE_WARNING3(m, p1, p2, p3)                             \
1106   {                                                                    \
1107     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                 \
1108       BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m, p1, p2, p3); \
1109   }
1110 #define NDEF_TRACE_WARNING4(m, p1, p2, p3, p4)                             \
1111   {                                                                        \
1112     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1113       BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m, p1, p2, p3, p4); \
1114   }
1115 #define NDEF_TRACE_WARNING5(m, p1, p2, p3, p4, p5)                             \
1116   {                                                                            \
1117     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                         \
1118       BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5); \
1119   }
1120 #define NDEF_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)                        \
1121   {                                                                           \
1122     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                        \
1123       BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5, \
1124                  p6);                                                         \
1125   }
1126 
1127 #define NDEF_TRACE_API0(m)                             \
1128   {                                                    \
1129     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API)     \
1130       BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_API, m); \
1131   }
1132 #define NDEF_TRACE_API1(m, p1)                             \
1133   {                                                        \
1134     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API)         \
1135       BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_API, m, p1); \
1136   }
1137 #define NDEF_TRACE_API2(m, p1, p2)                             \
1138   {                                                            \
1139     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API)             \
1140       BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_API, m, p1, p2); \
1141   }
1142 #define NDEF_TRACE_API3(m, p1, p2, p3)                             \
1143   {                                                                \
1144     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API)                 \
1145       BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_API, m, p1, p2, p3); \
1146   }
1147 #define NDEF_TRACE_API4(m, p1, p2, p3, p4)                             \
1148   {                                                                    \
1149     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API)                     \
1150       BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_API, m, p1, p2, p3, p4); \
1151   }
1152 #define NDEF_TRACE_API5(m, p1, p2, p3, p4, p5)                             \
1153   {                                                                        \
1154     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API)                         \
1155       BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_API, m, p1, p2, p3, p4, p5); \
1156   }
1157 #define NDEF_TRACE_API6(m, p1, p2, p3, p4, p5, p6)                             \
1158   {                                                                            \
1159     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_API)                             \
1160       BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_API, m, p1, p2, p3, p4, p5, p6); \
1161   }
1162 
1163 #define NDEF_TRACE_EVENT0(m)                             \
1164   {                                                      \
1165     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT)     \
1166       BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m); \
1167   }
1168 #define NDEF_TRACE_EVENT1(m, p1)                             \
1169   {                                                          \
1170     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT)         \
1171       BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m, p1); \
1172   }
1173 #define NDEF_TRACE_EVENT2(m, p1, p2)                             \
1174   {                                                              \
1175     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT)             \
1176       BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m, p1, p2); \
1177   }
1178 #define NDEF_TRACE_EVENT3(m, p1, p2, p3)                             \
1179   {                                                                  \
1180     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                 \
1181       BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m, p1, p2, p3); \
1182   }
1183 #define NDEF_TRACE_EVENT4(m, p1, p2, p3, p4)                             \
1184   {                                                                      \
1185     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                     \
1186       BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m, p1, p2, p3, p4); \
1187   }
1188 #define NDEF_TRACE_EVENT5(m, p1, p2, p3, p4, p5)                             \
1189   {                                                                          \
1190     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                         \
1191       BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5); \
1192   }
1193 #define NDEF_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)                        \
1194   {                                                                         \
1195     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                        \
1196       BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5, \
1197                  p6);                                                       \
1198   }
1199 
1200 #define NDEF_TRACE_DEBUG0(m)                             \
1201   {                                                      \
1202     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)     \
1203       BT_TRACE_0(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m); \
1204   }
1205 #define NDEF_TRACE_DEBUG1(m, p1)                             \
1206   {                                                          \
1207     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)         \
1208       BT_TRACE_1(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m, p1); \
1209   }
1210 #define NDEF_TRACE_DEBUG2(m, p1, p2)                             \
1211   {                                                              \
1212     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)             \
1213       BT_TRACE_2(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m, p1, p2); \
1214   }
1215 #define NDEF_TRACE_DEBUG3(m, p1, p2, p3)                             \
1216   {                                                                  \
1217     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                 \
1218       BT_TRACE_3(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m, p1, p2, p3); \
1219   }
1220 #define NDEF_TRACE_DEBUG4(m, p1, p2, p3, p4)                             \
1221   {                                                                      \
1222     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                     \
1223       BT_TRACE_4(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4); \
1224   }
1225 #define NDEF_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)                             \
1226   {                                                                          \
1227     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                         \
1228       BT_TRACE_5(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5); \
1229   }
1230 #define NDEF_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)                        \
1231   {                                                                         \
1232     if (ndef_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                        \
1233       BT_TRACE_6(TRACE_LAYER_NDEF, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5, \
1234                  p6);                                                       \
1235   }
1236 
1237 /* Define tracing for the NFA unit
1238 */
1239 #define NFA_TRACE_ERROR0(m)                             \
1240   {                                                     \
1241     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \
1242       BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m); \
1243   }
1244 #define NFA_TRACE_ERROR1(m, p1)                             \
1245   {                                                         \
1246     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR)     \
1247       BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m, p1); \
1248   }
1249 #define NFA_TRACE_ERROR2(m, p1, p2)                             \
1250   {                                                             \
1251     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR)         \
1252       BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m, p1, p2); \
1253   }
1254 #define NFA_TRACE_ERROR3(m, p1, p2, p3)                             \
1255   {                                                                 \
1256     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR)             \
1257       BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m, p1, p2, p3); \
1258   }
1259 #define NFA_TRACE_ERROR4(m, p1, p2, p3, p4)                             \
1260   {                                                                     \
1261     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                 \
1262       BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m, p1, p2, p3, p4); \
1263   }
1264 #define NFA_TRACE_ERROR5(m, p1, p2, p3, p4, p5)                             \
1265   {                                                                         \
1266     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                     \
1267       BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5); \
1268   }
1269 #define NFA_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)                        \
1270   {                                                                        \
1271     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                    \
1272       BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5, \
1273                  p6);                                                      \
1274   }
1275 
1276 #define NFA_TRACE_WARNING0(m)                             \
1277   {                                                       \
1278     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \
1279       BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m); \
1280   }
1281 #define NFA_TRACE_WARNING1(m, p1)                             \
1282   {                                                           \
1283     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING)     \
1284       BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m, p1); \
1285   }
1286 #define NFA_TRACE_WARNING2(m, p1, p2)                             \
1287   {                                                               \
1288     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING)         \
1289       BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m, p1, p2); \
1290   }
1291 #define NFA_TRACE_WARNING3(m, p1, p2, p3)                             \
1292   {                                                                   \
1293     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING)             \
1294       BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m, p1, p2, p3); \
1295   }
1296 #define NFA_TRACE_WARNING4(m, p1, p2, p3, p4)                             \
1297   {                                                                       \
1298     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                 \
1299       BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m, p1, p2, p3, p4); \
1300   }
1301 #define NFA_TRACE_WARNING5(m, p1, p2, p3, p4, p5)                             \
1302   {                                                                           \
1303     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1304       BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5); \
1305   }
1306 #define NFA_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)                        \
1307   {                                                                          \
1308     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                    \
1309       BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5, \
1310                  p6);                                                        \
1311   }
1312 
1313 #define NFA_TRACE_API0(m)                             \
1314   {                                                   \
1315     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API) \
1316       BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_API, m); \
1317   }
1318 #define NFA_TRACE_API1(m, p1)                             \
1319   {                                                       \
1320     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API)     \
1321       BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_API, m, p1); \
1322   }
1323 #define NFA_TRACE_API2(m, p1, p2)                             \
1324   {                                                           \
1325     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API)         \
1326       BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_API, m, p1, p2); \
1327   }
1328 #define NFA_TRACE_API3(m, p1, p2, p3)                             \
1329   {                                                               \
1330     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API)             \
1331       BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_API, m, p1, p2, p3); \
1332   }
1333 #define NFA_TRACE_API4(m, p1, p2, p3, p4)                             \
1334   {                                                                   \
1335     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API)                 \
1336       BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_API, m, p1, p2, p3, p4); \
1337   }
1338 #define NFA_TRACE_API5(m, p1, p2, p3, p4, p5)                             \
1339   {                                                                       \
1340     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API)                     \
1341       BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_API, m, p1, p2, p3, p4, p5); \
1342   }
1343 #define NFA_TRACE_API6(m, p1, p2, p3, p4, p5, p6)                             \
1344   {                                                                           \
1345     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_API)                         \
1346       BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_API, m, p1, p2, p3, p4, p5, p6); \
1347   }
1348 
1349 #define NFA_TRACE_EVENT0(m)                             \
1350   {                                                     \
1351     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \
1352       BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m); \
1353   }
1354 #define NFA_TRACE_EVENT1(m, p1)                             \
1355   {                                                         \
1356     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT)     \
1357       BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m, p1); \
1358   }
1359 #define NFA_TRACE_EVENT2(m, p1, p2)                             \
1360   {                                                             \
1361     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT)         \
1362       BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m, p1, p2); \
1363   }
1364 #define NFA_TRACE_EVENT3(m, p1, p2, p3)                             \
1365   {                                                                 \
1366     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT)             \
1367       BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m, p1, p2, p3); \
1368   }
1369 #define NFA_TRACE_EVENT4(m, p1, p2, p3, p4)                             \
1370   {                                                                     \
1371     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                 \
1372       BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m, p1, p2, p3, p4); \
1373   }
1374 #define NFA_TRACE_EVENT5(m, p1, p2, p3, p4, p5)                             \
1375   {                                                                         \
1376     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                     \
1377       BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5); \
1378   }
1379 #define NFA_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)                        \
1380   {                                                                        \
1381     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                    \
1382       BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5, \
1383                  p6);                                                      \
1384   }
1385 
1386 #define NFA_TRACE_DEBUG0(m)                             \
1387   {                                                     \
1388     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \
1389       BT_TRACE_0(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m); \
1390   }
1391 #define NFA_TRACE_DEBUG1(m, p1)                             \
1392   {                                                         \
1393     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)     \
1394       BT_TRACE_1(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m, p1); \
1395   }
1396 #define NFA_TRACE_DEBUG2(m, p1, p2)                             \
1397   {                                                             \
1398     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)         \
1399       BT_TRACE_2(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m, p1, p2); \
1400   }
1401 #define NFA_TRACE_DEBUG3(m, p1, p2, p3)                             \
1402   {                                                                 \
1403     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)             \
1404       BT_TRACE_3(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m, p1, p2, p3); \
1405   }
1406 #define NFA_TRACE_DEBUG4(m, p1, p2, p3, p4)                             \
1407   {                                                                     \
1408     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                 \
1409       BT_TRACE_4(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4); \
1410   }
1411 #define NFA_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)                             \
1412   {                                                                         \
1413     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                     \
1414       BT_TRACE_5(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5); \
1415   }
1416 #define NFA_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)                        \
1417   {                                                                        \
1418     if (nfa_sys_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                    \
1419       BT_TRACE_6(TRACE_LAYER_NFA, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5, \
1420                  p6);                                                      \
1421   }
1422 
1423 /* Define tracing for the NFA P2P unit
1424 */
1425 #define P2P_TRACE_ERROR0(m)                             \
1426   {                                                     \
1427     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_ERROR) \
1428       BT_TRACE_0(TRACE_LAYER_P2P, TRACE_TYPE_ERROR, m); \
1429   }
1430 #define P2P_TRACE_ERROR1(m, p1)                             \
1431   {                                                         \
1432     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_ERROR)     \
1433       BT_TRACE_1(TRACE_LAYER_P2P, TRACE_TYPE_ERROR, m, p1); \
1434   }
1435 #define P2P_TRACE_ERROR2(m, p1, p2)                             \
1436   {                                                             \
1437     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_ERROR)         \
1438       BT_TRACE_2(TRACE_LAYER_P2P, TRACE_TYPE_ERROR, m, p1, p2); \
1439   }
1440 #define P2P_TRACE_ERROR3(m, p1, p2, p3)                             \
1441   {                                                                 \
1442     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_ERROR)             \
1443       BT_TRACE_3(TRACE_LAYER_P2P, TRACE_TYPE_ERROR, m, p1, p2, p3); \
1444   }
1445 #define P2P_TRACE_ERROR4(m, p1, p2, p3, p4)                             \
1446   {                                                                     \
1447     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                 \
1448       BT_TRACE_4(TRACE_LAYER_P2P, TRACE_TYPE_ERROR, m, p1, p2, p3, p4); \
1449   }
1450 #define P2P_TRACE_ERROR5(m, p1, p2, p3, p4, p5)                             \
1451   {                                                                         \
1452     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                     \
1453       BT_TRACE_5(TRACE_LAYER_P2P, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5); \
1454   }
1455 #define P2P_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)                        \
1456   {                                                                        \
1457     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_ERROR)                    \
1458       BT_TRACE_6(TRACE_LAYER_P2P, TRACE_TYPE_ERROR, m, p1, p2, p3, p4, p5, \
1459                  p6);                                                      \
1460   }
1461 
1462 #define P2P_TRACE_WARNING0(m)                             \
1463   {                                                       \
1464     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_WARNING) \
1465       BT_TRACE_0(TRACE_LAYER_P2P, TRACE_TYPE_WARNING, m); \
1466   }
1467 #define P2P_TRACE_WARNING1(m, p1)                             \
1468   {                                                           \
1469     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_WARNING)     \
1470       BT_TRACE_1(TRACE_LAYER_P2P, TRACE_TYPE_WARNING, m, p1); \
1471   }
1472 #define P2P_TRACE_WARNING2(m, p1, p2)                             \
1473   {                                                               \
1474     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_WARNING)         \
1475       BT_TRACE_2(TRACE_LAYER_P2P, TRACE_TYPE_WARNING, m, p1, p2); \
1476   }
1477 #define P2P_TRACE_WARNING3(m, p1, p2, p3)                             \
1478   {                                                                   \
1479     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_WARNING)             \
1480       BT_TRACE_3(TRACE_LAYER_P2P, TRACE_TYPE_WARNING, m, p1, p2, p3); \
1481   }
1482 #define P2P_TRACE_WARNING4(m, p1, p2, p3, p4)                             \
1483   {                                                                       \
1484     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                 \
1485       BT_TRACE_4(TRACE_LAYER_P2P, TRACE_TYPE_WARNING, m, p1, p2, p3, p4); \
1486   }
1487 #define P2P_TRACE_WARNING5(m, p1, p2, p3, p4, p5)                             \
1488   {                                                                           \
1489     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1490       BT_TRACE_5(TRACE_LAYER_P2P, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5); \
1491   }
1492 #define P2P_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)                        \
1493   {                                                                          \
1494     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_WARNING)                    \
1495       BT_TRACE_6(TRACE_LAYER_P2P, TRACE_TYPE_WARNING, m, p1, p2, p3, p4, p5, \
1496                  p6);                                                        \
1497   }
1498 
1499 #define P2P_TRACE_API0(m)                             \
1500   {                                                   \
1501     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_API) \
1502       BT_TRACE_0(TRACE_LAYER_P2P, TRACE_TYPE_API, m); \
1503   }
1504 #define P2P_TRACE_API1(m, p1)                             \
1505   {                                                       \
1506     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_API)     \
1507       BT_TRACE_1(TRACE_LAYER_P2P, TRACE_TYPE_API, m, p1); \
1508   }
1509 #define P2P_TRACE_API2(m, p1, p2)                             \
1510   {                                                           \
1511     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_API)         \
1512       BT_TRACE_2(TRACE_LAYER_P2P, TRACE_TYPE_API, m, p1, p2); \
1513   }
1514 #define P2P_TRACE_API3(m, p1, p2, p3)                             \
1515   {                                                               \
1516     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_API)             \
1517       BT_TRACE_3(TRACE_LAYER_P2P, TRACE_TYPE_API, m, p1, p2, p3); \
1518   }
1519 #define P2P_TRACE_API4(m, p1, p2, p3, p4)                             \
1520   {                                                                   \
1521     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_API)                 \
1522       BT_TRACE_4(TRACE_LAYER_P2P, TRACE_TYPE_API, m, p1, p2, p3, p4); \
1523   }
1524 #define P2P_TRACE_API5(m, p1, p2, p3, p4, p5)                             \
1525   {                                                                       \
1526     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_API)                     \
1527       BT_TRACE_5(TRACE_LAYER_P2P, TRACE_TYPE_API, m, p1, p2, p3, p4, p5); \
1528   }
1529 #define P2P_TRACE_API6(m, p1, p2, p3, p4, p5, p6)                             \
1530   {                                                                           \
1531     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_API)                         \
1532       BT_TRACE_6(TRACE_LAYER_P2P, TRACE_TYPE_API, m, p1, p2, p3, p4, p5, p6); \
1533   }
1534 
1535 #define P2P_TRACE_EVENT0(m)                             \
1536   {                                                     \
1537     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_EVENT) \
1538       BT_TRACE_0(TRACE_LAYER_P2P, TRACE_TYPE_EVENT, m); \
1539   }
1540 #define P2P_TRACE_EVENT1(m, p1)                             \
1541   {                                                         \
1542     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_EVENT)     \
1543       BT_TRACE_1(TRACE_LAYER_P2P, TRACE_TYPE_EVENT, m, p1); \
1544   }
1545 #define P2P_TRACE_EVENT2(m, p1, p2)                             \
1546   {                                                             \
1547     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_EVENT)         \
1548       BT_TRACE_2(TRACE_LAYER_P2P, TRACE_TYPE_EVENT, m, p1, p2); \
1549   }
1550 #define P2P_TRACE_EVENT3(m, p1, p2, p3)                             \
1551   {                                                                 \
1552     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_EVENT)             \
1553       BT_TRACE_3(TRACE_LAYER_P2P, TRACE_TYPE_EVENT, m, p1, p2, p3); \
1554   }
1555 #define P2P_TRACE_EVENT4(m, p1, p2, p3, p4)                             \
1556   {                                                                     \
1557     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                 \
1558       BT_TRACE_4(TRACE_LAYER_P2P, TRACE_TYPE_EVENT, m, p1, p2, p3, p4); \
1559   }
1560 #define P2P_TRACE_EVENT5(m, p1, p2, p3, p4, p5)                             \
1561   {                                                                         \
1562     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                     \
1563       BT_TRACE_5(TRACE_LAYER_P2P, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5); \
1564   }
1565 #define P2P_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)                        \
1566   {                                                                        \
1567     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_EVENT)                    \
1568       BT_TRACE_6(TRACE_LAYER_P2P, TRACE_TYPE_EVENT, m, p1, p2, p3, p4, p5, \
1569                  p6);                                                      \
1570   }
1571 
1572 #define P2P_TRACE_DEBUG0(m)                             \
1573   {                                                     \
1574     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_DEBUG) \
1575       BT_TRACE_0(TRACE_LAYER_P2P, TRACE_TYPE_DEBUG, m); \
1576   }
1577 #define P2P_TRACE_DEBUG1(m, p1)                             \
1578   {                                                         \
1579     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)     \
1580       BT_TRACE_1(TRACE_LAYER_P2P, TRACE_TYPE_DEBUG, m, p1); \
1581   }
1582 #define P2P_TRACE_DEBUG2(m, p1, p2)                             \
1583   {                                                             \
1584     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)         \
1585       BT_TRACE_2(TRACE_LAYER_P2P, TRACE_TYPE_DEBUG, m, p1, p2); \
1586   }
1587 #define P2P_TRACE_DEBUG3(m, p1, p2, p3)                             \
1588   {                                                                 \
1589     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)             \
1590       BT_TRACE_3(TRACE_LAYER_P2P, TRACE_TYPE_DEBUG, m, p1, p2, p3); \
1591   }
1592 #define P2P_TRACE_DEBUG4(m, p1, p2, p3, p4)                             \
1593   {                                                                     \
1594     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                 \
1595       BT_TRACE_4(TRACE_LAYER_P2P, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4); \
1596   }
1597 #define P2P_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)                             \
1598   {                                                                         \
1599     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                     \
1600       BT_TRACE_5(TRACE_LAYER_P2P, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5); \
1601   }
1602 #define P2P_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)                        \
1603   {                                                                        \
1604     if (nfa_p2p_cb.trace_level >= BT_TRACE_LEVEL_DEBUG)                    \
1605       BT_TRACE_6(TRACE_LAYER_P2P, TRACE_TYPE_DEBUG, m, p1, p2, p3, p4, p5, \
1606                  p6);                                                      \
1607   }
1608 
1609 /* define traces for application */
1610 #define APPL_TRACE_ERROR0(m)                                            \
1611   {                                                                     \
1612     if (appl_trace_level >= BT_TRACE_LEVEL_ERROR)                       \
1613       LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1614                    TRACE_TYPE_ERROR,                                    \
1615                (m));                                                    \
1616   }
1617 #define APPL_TRACE_ERROR1(m, p1)                                        \
1618   {                                                                     \
1619     if (appl_trace_level >= BT_TRACE_LEVEL_ERROR)                       \
1620       LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1621                    TRACE_TYPE_ERROR,                                    \
1622                (m), (uintptr_t)(p1));                                   \
1623   }
1624 #define APPL_TRACE_ERROR2(m, p1, p2)                                    \
1625   {                                                                     \
1626     if (appl_trace_level >= BT_TRACE_LEVEL_ERROR)                       \
1627       LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1628                    TRACE_TYPE_ERROR,                                    \
1629                (m), (uintptr_t)(p1), (uintptr_t)(p2));                  \
1630   }
1631 #define APPL_TRACE_ERROR3(m, p1, p2, p3)                                \
1632   {                                                                     \
1633     if (appl_trace_level >= BT_TRACE_LEVEL_ERROR)                       \
1634       LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1635                    TRACE_TYPE_ERROR,                                    \
1636                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3)); \
1637   }
1638 #define APPL_TRACE_ERROR4(m, p1, p2, p3, p4)                            \
1639   {                                                                     \
1640     if (appl_trace_level >= BT_TRACE_LEVEL_ERROR)                       \
1641       LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1642                    TRACE_TYPE_ERROR,                                    \
1643                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1644                (uintptr_t)(p4));                                        \
1645   }
1646 #define APPL_TRACE_ERROR5(m, p1, p2, p3, p4, p5)                        \
1647   {                                                                     \
1648     if (appl_trace_level >= BT_TRACE_LEVEL_ERROR)                       \
1649       LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1650                    TRACE_TYPE_ERROR,                                    \
1651                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1652                (uintptr_t)(p4), (uintptr_t)(p5));                       \
1653   }
1654 #define APPL_TRACE_ERROR6(m, p1, p2, p3, p4, p5, p6)                    \
1655   {                                                                     \
1656     if (appl_trace_level >= BT_TRACE_LEVEL_ERROR)                       \
1657       LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1658                    TRACE_TYPE_ERROR,                                    \
1659                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1660                (uintptr_t)(p4), (uintptr_t)(p5), (uintptr_t)(p6));      \
1661   }
1662 
1663 #define APPL_TRACE_WARNING0(m)                                          \
1664   {                                                                     \
1665     if (appl_trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1666       LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1667                    TRACE_TYPE_WARNING,                                  \
1668                (m));                                                    \
1669   }
1670 #define APPL_TRACE_WARNING1(m, p1)                                      \
1671   {                                                                     \
1672     if (appl_trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1673       LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1674                    TRACE_TYPE_WARNING,                                  \
1675                (m), (uintptr_t)(p1));                                   \
1676   }
1677 #define APPL_TRACE_WARNING2(m, p1, p2)                                  \
1678   {                                                                     \
1679     if (appl_trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1680       LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1681                    TRACE_TYPE_WARNING,                                  \
1682                (m), (uintptr_t)(p1), (uintptr_t)(p2));                  \
1683   }
1684 #define APPL_TRACE_WARNING3(m, p1, p2, p3)                              \
1685   {                                                                     \
1686     if (appl_trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1687       LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1688                    TRACE_TYPE_WARNING,                                  \
1689                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3)); \
1690   }
1691 #define APPL_TRACE_WARNING4(m, p1, p2, p3, p4)                          \
1692   {                                                                     \
1693     if (appl_trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1694       LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1695                    TRACE_TYPE_WARNING,                                  \
1696                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1697                (uintptr_t)(p4));                                        \
1698   }
1699 #define APPL_TRACE_WARNING5(m, p1, p2, p3, p4, p5)                      \
1700   {                                                                     \
1701     if (appl_trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1702       LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1703                    TRACE_TYPE_WARNING,                                  \
1704                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1705                (uintptr_t)(p4), (uintptr_t)(p5));                       \
1706   }
1707 #define APPL_TRACE_WARNING6(m, p1, p2, p3, p4, p5, p6)                  \
1708   {                                                                     \
1709     if (appl_trace_level >= BT_TRACE_LEVEL_WARNING)                     \
1710       LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1711                    TRACE_TYPE_WARNING,                                  \
1712                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1713                (uintptr_t)(p4), (uintptr_t)(p5), (uintptr_t)(p6));      \
1714   }
1715 
1716 #define APPL_TRACE_API0(m)                                              \
1717   {                                                                     \
1718     if (appl_trace_level >= BT_TRACE_LEVEL_API)                         \
1719       LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1720                    TRACE_TYPE_API,                                      \
1721                (m));                                                    \
1722   }
1723 #define APPL_TRACE_API1(m, p1)                                          \
1724   {                                                                     \
1725     if (appl_trace_level >= BT_TRACE_LEVEL_API)                         \
1726       LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1727                    TRACE_TYPE_API,                                      \
1728                (m), (uintptr_t)(p1));                                   \
1729   }
1730 #define APPL_TRACE_API2(m, p1, p2)                                      \
1731   {                                                                     \
1732     if (appl_trace_level >= BT_TRACE_LEVEL_API)                         \
1733       LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1734                    TRACE_TYPE_API,                                      \
1735                (m), (uintptr_t)(p1), (uintptr_t)(p2));                  \
1736   }
1737 #define APPL_TRACE_API3(m, p1, p2, p3)                                  \
1738   {                                                                     \
1739     if (appl_trace_level >= BT_TRACE_LEVEL_API)                         \
1740       LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1741                    TRACE_TYPE_API,                                      \
1742                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3)); \
1743   }
1744 #define APPL_TRACE_API4(m, p1, p2, p3, p4)                              \
1745   {                                                                     \
1746     if (appl_trace_level >= BT_TRACE_LEVEL_API)                         \
1747       LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1748                    TRACE_TYPE_API,                                      \
1749                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1750                (uintptr_t)(p4));                                        \
1751   }
1752 #define APPL_TRACE_API5(m, p1, p2, p3, p4, p5)                          \
1753   {                                                                     \
1754     if (appl_trace_level >= BT_TRACE_LEVEL_API)                         \
1755       LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1756                    TRACE_TYPE_API,                                      \
1757                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1758                (uintptr_t)(p4), (uintptr_t)(p5));                       \
1759   }
1760 #define APPL_TRACE_API6(m, p1, p2, p3, p4, p5, p6)                      \
1761   {                                                                     \
1762     if (appl_trace_level >= BT_TRACE_LEVEL_API)                         \
1763       LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1764                    TRACE_TYPE_API,                                      \
1765                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1766                (uintptr_t)(p4), (uintptr_t)(p5), (uintptr_t)(p6));      \
1767   }
1768 
1769 #define APPL_TRACE_EVENT0(m)                                            \
1770   {                                                                     \
1771     if (appl_trace_level >= BT_TRACE_LEVEL_EVENT)                       \
1772       LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1773                    TRACE_TYPE_EVENT,                                    \
1774                (m));                                                    \
1775   }
1776 #define APPL_TRACE_EVENT1(m, p1)                                        \
1777   {                                                                     \
1778     if (appl_trace_level >= BT_TRACE_LEVEL_EVENT)                       \
1779       LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1780                    TRACE_TYPE_EVENT,                                    \
1781                (m), (uintptr_t)(p1));                                   \
1782   }
1783 #define APPL_TRACE_EVENT2(m, p1, p2)                                    \
1784   {                                                                     \
1785     if (appl_trace_level >= BT_TRACE_LEVEL_EVENT)                       \
1786       LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1787                    TRACE_TYPE_EVENT,                                    \
1788                (m), (uintptr_t)(p1), (uintptr_t)(p2));                  \
1789   }
1790 #define APPL_TRACE_EVENT3(m, p1, p2, p3)                                \
1791   {                                                                     \
1792     if (appl_trace_level >= BT_TRACE_LEVEL_EVENT)                       \
1793       LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1794                    TRACE_TYPE_EVENT,                                    \
1795                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3)); \
1796   }
1797 #define APPL_TRACE_EVENT4(m, p1, p2, p3, p4)                            \
1798   {                                                                     \
1799     if (appl_trace_level >= BT_TRACE_LEVEL_EVENT)                       \
1800       LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1801                    TRACE_TYPE_EVENT,                                    \
1802                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1803                (uintptr_t)(p4));                                        \
1804   }
1805 #define APPL_TRACE_EVENT5(m, p1, p2, p3, p4, p5)                        \
1806   {                                                                     \
1807     if (appl_trace_level >= BT_TRACE_LEVEL_EVENT)                       \
1808       LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1809                    TRACE_TYPE_EVENT,                                    \
1810                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1811                (uintptr_t)(p4), (uintptr_t)(p5));                       \
1812   }
1813 #define APPL_TRACE_EVENT6(m, p1, p2, p3, p4, p5, p6)                    \
1814   {                                                                     \
1815     if (appl_trace_level >= BT_TRACE_LEVEL_EVENT)                       \
1816       LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1817                    TRACE_TYPE_EVENT,                                    \
1818                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1819                (uintptr_t)(p4), (uintptr_t)(p5), (uintptr_t)(p6));      \
1820   }
1821 
1822 #define APPL_TRACE_DEBUG0(m)                                            \
1823   {                                                                     \
1824     if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG)                       \
1825       LogMsg_0(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1826                    TRACE_TYPE_DEBUG,                                    \
1827                (m));                                                    \
1828   }
1829 #define APPL_TRACE_DEBUG1(m, p1)                                        \
1830   {                                                                     \
1831     if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG)                       \
1832       LogMsg_1(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1833                    TRACE_TYPE_DEBUG,                                    \
1834                (m), (uintptr_t)(p1));                                   \
1835   }
1836 #define APPL_TRACE_DEBUG2(m, p1, p2)                                    \
1837   {                                                                     \
1838     if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG)                       \
1839       LogMsg_2(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1840                    TRACE_TYPE_DEBUG,                                    \
1841                (m), (uintptr_t)(p1), (uintptr_t)(p2));                  \
1842   }
1843 #define APPL_TRACE_DEBUG3(m, p1, p2, p3)                                \
1844   {                                                                     \
1845     if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG)                       \
1846       LogMsg_3(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1847                    TRACE_TYPE_DEBUG,                                    \
1848                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3)); \
1849   }
1850 #define APPL_TRACE_DEBUG4(m, p1, p2, p3, p4)                            \
1851   {                                                                     \
1852     if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG)                       \
1853       LogMsg_4(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1854                    TRACE_TYPE_DEBUG,                                    \
1855                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1856                (uintptr_t)(p4));                                        \
1857   }
1858 #define APPL_TRACE_DEBUG5(m, p1, p2, p3, p4, p5)                        \
1859   {                                                                     \
1860     if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG)                       \
1861       LogMsg_5(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1862                    TRACE_TYPE_DEBUG,                                    \
1863                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1864                (uintptr_t)(p4), (uintptr_t)(p5));                       \
1865   }
1866 #define APPL_TRACE_DEBUG6(m, p1, p2, p3, p4, p5, p6)                    \
1867   {                                                                     \
1868     if (appl_trace_level >= BT_TRACE_LEVEL_DEBUG)                       \
1869       LogMsg_6(TRACE_CTRL_GENERAL | TRACE_LAYER_NONE | TRACE_ORG_APPL | \
1870                    TRACE_TYPE_DEBUG,                                    \
1871                (m), (uintptr_t)(p1), (uintptr_t)(p2), (uintptr_t)(p3),  \
1872                (uintptr_t)(p4), (uintptr_t)(p5), (uintptr_t)(p6));      \
1873   }
1874 
1875 #endif /* BT_TRACE_H */
1876