ethdev: fix TPID handling in flow API
[dpdk.git] / drivers / net / sfc / sfc_log.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright (c) 2016-2018 Solarflare Communications Inc.
4  * All rights reserved.
5  *
6  * This software was jointly developed between OKTET Labs (under contract
7  * for Solarflare) and Solarflare Communications, Inc.
8  */
9
10 #ifndef _SFC_LOG_H_
11 #define _SFC_LOG_H_
12
13 /** Generic driver log type */
14 extern uint32_t sfc_logtype_driver;
15
16 /** Common log type name prefix */
17 #define SFC_LOGTYPE_PREFIX      "pmd.net.sfc."
18
19 /** Log PMD generic message, add a prefix and a line break */
20 #define SFC_GENERIC_LOG(level, ...) \
21         rte_log(RTE_LOG_ ## level, sfc_logtype_driver,                  \
22                 RTE_FMT("PMD: " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",       \
23                         RTE_FMT_TAIL(__VA_ARGS__ ,)))
24
25 /** Name prefix for the per-device log type used to report basic information */
26 #define SFC_LOGTYPE_MAIN_STR    SFC_LOGTYPE_PREFIX "main"
27
28 /** Device MCDI log type name prefix */
29 #define SFC_LOGTYPE_MCDI_STR    SFC_LOGTYPE_PREFIX "mcdi"
30
31 /** Level value used by MCDI log statements */
32 #define SFC_LOG_LEVEL_MCDI      RTE_LOG_INFO
33
34 /* Log PMD message, automatically add prefix and \n */
35 #define SFC_LOG(sa, level, type, ...) \
36         do {                                                            \
37                 const struct sfc_adapter *__sa = (sa);                  \
38                                                                         \
39                 rte_log(level, type,                                    \
40                         RTE_FMT("PMD: sfc_efx " PCI_PRI_FMT " #%" PRIu8 \
41                                 ": " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",  \
42                                 __sa->pci_addr.domain,                  \
43                                 __sa->pci_addr.bus,                     \
44                                 __sa->pci_addr.devid,                   \
45                                 __sa->pci_addr.function,                \
46                                 __sa->port_id,                          \
47                                 RTE_FMT_TAIL(__VA_ARGS__,)));           \
48         } while (0)
49
50 #define sfc_err(sa, ...) \
51         do {                                                            \
52                 const struct sfc_adapter *_sa = (sa);                   \
53                                                                         \
54                 SFC_LOG(_sa, RTE_LOG_ERR, _sa->logtype_main,            \
55                         __VA_ARGS__);                                   \
56         } while (0)
57
58 #define sfc_warn(sa, ...) \
59         do {                                                            \
60                 const struct sfc_adapter *_sa = (sa);                   \
61                                                                         \
62                 SFC_LOG(_sa, RTE_LOG_WARNING, _sa->logtype_main,        \
63                         __VA_ARGS__);                                   \
64         } while (0)
65
66 #define sfc_notice(sa, ...) \
67         do {                                                            \
68                 const struct sfc_adapter *_sa = (sa);                   \
69                                                                         \
70                 SFC_LOG(_sa, RTE_LOG_NOTICE, _sa->logtype_main,         \
71                         __VA_ARGS__);                                   \
72         } while (0)
73
74 #define sfc_info(sa, ...) \
75         do {                                                            \
76                 const struct sfc_adapter *_sa = (sa);                   \
77                                                                         \
78                 SFC_LOG(_sa, RTE_LOG_INFO, _sa->logtype_main,           \
79                         __VA_ARGS__);                                   \
80         } while (0)
81
82 #define sfc_log_init(sa, ...) \
83         do {                                                            \
84                 const struct sfc_adapter *_sa = (sa);                   \
85                                                                         \
86                 SFC_LOG(_sa, RTE_LOG_INFO, _sa->logtype_main,           \
87                         RTE_FMT("%s(): "                                \
88                                 RTE_FMT_HEAD(__VA_ARGS__ ,),            \
89                                 __func__,                               \
90                                 RTE_FMT_TAIL(__VA_ARGS__ ,)));          \
91         } while (0)
92
93 #define sfc_log_mcdi(sa, ...) \
94         do {                                                            \
95                 const struct sfc_adapter *_sa = (sa);                   \
96                                                                         \
97                 SFC_LOG(_sa, SFC_LOG_LEVEL_MCDI, _sa->mcdi.logtype,     \
98                         __VA_ARGS__);                                   \
99         } while (0)
100
101
102 #endif /* _SFC_LOG_H_ */