net/i40e: fix Rx packet statistics
[dpdk.git] / drivers / net / sfc / sfc_log.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2019-2021 Xilinx, Inc.
4  * Copyright(c) 2016-2019 Solarflare Communications Inc.
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 #define SFC_LOG_PREFIX_MAX      32
32
33 /* Log PMD message, automatically add prefix and \n */
34 #define SFC_LOG(sas, level, type, ...) \
35         do {                                                            \
36                 const struct sfc_adapter_shared *_sas = (sas);          \
37                                                                         \
38                 rte_log(level, type,                                    \
39                         RTE_FMT("%s" RTE_FMT_HEAD(__VA_ARGS__ ,) "\n",  \
40                                 _sas->log_prefix,                       \
41                                 RTE_FMT_TAIL(__VA_ARGS__,)));           \
42         } while (0)
43
44 #define sfc_err(sa, ...) \
45         do {                                                            \
46                 const struct sfc_adapter *_sa = (sa);                   \
47                                                                         \
48                 SFC_LOG(_sa->priv.shared, RTE_LOG_ERR,                  \
49                         _sa->priv.logtype_main, __VA_ARGS__);           \
50         } while (0)
51
52 #define sfc_warn(sa, ...) \
53         do {                                                            \
54                 const struct sfc_adapter *_sa = (sa);                   \
55                                                                         \
56                 SFC_LOG(_sa->priv.shared, RTE_LOG_WARNING,              \
57                         _sa->priv.logtype_main, __VA_ARGS__);           \
58         } while (0)
59
60 #define sfc_notice(sa, ...) \
61         do {                                                            \
62                 const struct sfc_adapter *_sa = (sa);                   \
63                                                                         \
64                 SFC_LOG(_sa->priv.shared, RTE_LOG_NOTICE,               \
65                         _sa->priv.logtype_main, __VA_ARGS__);           \
66         } while (0)
67
68 #define sfc_info(sa, ...) \
69         do {                                                            \
70                 const struct sfc_adapter *_sa = (sa);                   \
71                                                                         \
72                 SFC_LOG(_sa->priv.shared, RTE_LOG_INFO,                 \
73                         _sa->priv.logtype_main, __VA_ARGS__);           \
74         } while (0)
75
76 #define sfc_dbg(sa, ...) \
77         do {                                                            \
78                 const struct sfc_adapter *_sa = (sa);                   \
79                                                                         \
80                 SFC_LOG(_sa->priv.shared, RTE_LOG_DEBUG,                \
81                         _sa->priv.logtype_main, __VA_ARGS__);           \
82         } while (0)
83
84 #define sfc_log_init(sa, ...) \
85         do {                                                            \
86                 const struct sfc_adapter *_sa = (sa);                   \
87                                                                         \
88                 SFC_LOG(_sa->priv.shared, RTE_LOG_INFO,                 \
89                         _sa->priv.logtype_main,                         \
90                         RTE_FMT("%s(): "                                \
91                                 RTE_FMT_HEAD(__VA_ARGS__ ,),            \
92                                 __func__,                               \
93                                 RTE_FMT_TAIL(__VA_ARGS__ ,)));          \
94         } while (0)
95
96
97 #endif /* _SFC_LOG_H_ */