net/enic: use dynamic log types
[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 /* Log PMD message, automatically add prefix and \n */
14 #define SFC_LOG(sa, level, ...) \
15         do {                                                            \
16                 const struct sfc_adapter *__sa = (sa);                  \
17                                                                         \
18                 RTE_LOG(level, PMD,                                     \
19                         RTE_FMT("sfc_efx " PCI_PRI_FMT " #%" PRIu8 ": " \
20                                 RTE_FMT_HEAD(__VA_ARGS__,) "\n",        \
21                                 __sa->pci_addr.domain,                  \
22                                 __sa->pci_addr.bus,                     \
23                                 __sa->pci_addr.devid,                   \
24                                 __sa->pci_addr.function,                \
25                                 __sa->port_id,                          \
26                                 RTE_FMT_TAIL(__VA_ARGS__,)));           \
27         } while (0)
28
29 #define sfc_err(sa, ...) \
30         SFC_LOG(sa, ERR, __VA_ARGS__)
31
32 #define sfc_warn(sa, ...) \
33         SFC_LOG(sa, WARNING, __VA_ARGS__)
34
35 #define sfc_notice(sa, ...) \
36         SFC_LOG(sa, NOTICE, __VA_ARGS__)
37
38 #define sfc_info(sa, ...) \
39         SFC_LOG(sa, INFO, __VA_ARGS__)
40
41 #define sfc_log_init(sa, ...) \
42         do {                                                            \
43                 const struct sfc_adapter *_sa = (sa);                   \
44                                                                         \
45                 if (_sa->debug_init)                                    \
46                         SFC_LOG(_sa, INFO,                              \
47                                 RTE_FMT("%s(): "                        \
48                                         RTE_FMT_HEAD(__VA_ARGS__,),     \
49                                         __func__,                       \
50                                         RTE_FMT_TAIL(__VA_ARGS__,)));   \
51         } while (0)
52
53 #endif /* _SFC_LOG_H_ */