1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2016-2018 Solarflare Communications Inc.
6 * This software was jointly developed between OKTET Labs (under contract
7 * for Solarflare) and Solarflare Communications, Inc.
13 /** Generic driver log type */
14 extern uint32_t sfc_logtype_driver;
16 /** Common log type name prefix */
17 #define SFC_LOGTYPE_PREFIX "pmd.net.sfc."
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__ ,)))
25 /** Name prefix for the per-device log type used to report basic information */
26 #define SFC_LOGTYPE_MAIN_STR SFC_LOGTYPE_PREFIX "main"
28 /** Device MCDI log type name prefix */
29 #define SFC_LOGTYPE_MCDI_STR SFC_LOGTYPE_PREFIX "mcdi"
31 /** Level value used by MCDI log statements */
32 #define SFC_LOG_LEVEL_MCDI RTE_LOG_INFO
34 /* Log PMD message, automatically add prefix and \n */
35 #define SFC_LOG(sa, level, type, ...) \
37 const struct sfc_adapter *__sa = (sa); \
39 rte_log(level, type, \
40 RTE_FMT("PMD: sfc_efx " \
41 PCI_PRI_FMT " #%" PRIu16 \
42 ": " RTE_FMT_HEAD(__VA_ARGS__ ,) "\n", \
43 __sa->pci_addr.domain, \
45 __sa->pci_addr.devid, \
46 __sa->pci_addr.function, \
48 RTE_FMT_TAIL(__VA_ARGS__,))); \
51 #define sfc_err(sa, ...) \
53 const struct sfc_adapter *_sa = (sa); \
55 SFC_LOG(_sa, RTE_LOG_ERR, _sa->priv.logtype_main, \
59 #define sfc_warn(sa, ...) \
61 const struct sfc_adapter *_sa = (sa); \
63 SFC_LOG(_sa, RTE_LOG_WARNING, _sa->priv.logtype_main, \
67 #define sfc_notice(sa, ...) \
69 const struct sfc_adapter *_sa = (sa); \
71 SFC_LOG(_sa, RTE_LOG_NOTICE, _sa->priv.logtype_main, \
75 #define sfc_info(sa, ...) \
77 const struct sfc_adapter *_sa = (sa); \
79 SFC_LOG(_sa, RTE_LOG_INFO, _sa->priv.logtype_main, \
83 #define sfc_log_init(sa, ...) \
85 const struct sfc_adapter *_sa = (sa); \
87 SFC_LOG(_sa, RTE_LOG_INFO, _sa->priv.logtype_main, \
89 RTE_FMT_HEAD(__VA_ARGS__ ,), \
91 RTE_FMT_TAIL(__VA_ARGS__ ,))); \
94 #define sfc_log_mcdi(sa, ...) \
96 const struct sfc_adapter *_sa = (sa); \
98 SFC_LOG(_sa, SFC_LOG_LEVEL_MCDI, _sa->mcdi.logtype, \
103 #endif /* _SFC_LOG_H_ */