8a5e2302f97dab819fb70e6e8a970bd5aa2c024a
[deb_dpdk.git] / drivers / net / sfc / sfc_log.h
1 /*-
2  *   BSD LICENSE
3  *
4  * Copyright (c) 2016-2017 Solarflare Communications Inc.
5  * All rights reserved.
6  *
7  * This software was jointly developed between OKTET Labs (under contract
8  * for Solarflare) and Solarflare Communications, Inc.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  *    this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  *    this list of conditions and the following disclaimer in the documentation
17  *    and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
29  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32 #ifndef _SFC_LOG_H_
33 #define _SFC_LOG_H_
34
35 /* Log PMD message, automatically add prefix and \n */
36 #define SFC_LOG(sa, level, ...) \
37         do {                                                            \
38                 const struct rte_eth_dev *_dev = (sa)->eth_dev;         \
39                 const struct rte_pci_device *_pci_dev = SFC_DEV_TO_PCI(_dev); \
40                                                                         \
41                 RTE_LOG(level, PMD,                                     \
42                         RTE_FMT("sfc_efx " PCI_PRI_FMT " #%" PRIu8 ": " \
43                                 RTE_FMT_HEAD(__VA_ARGS__,) "\n",        \
44                                 _pci_dev->addr.domain,                  \
45                                 _pci_dev->addr.bus,                     \
46                                 _pci_dev->addr.devid,                   \
47                                 _pci_dev->addr.function,                \
48                                 _dev->data->port_id,                    \
49                                 RTE_FMT_TAIL(__VA_ARGS__,)));           \
50         } while (0)
51
52 #define sfc_err(sa, ...) \
53         SFC_LOG(sa, ERR, __VA_ARGS__)
54
55 #define sfc_warn(sa, ...) \
56         SFC_LOG(sa, WARNING, __VA_ARGS__)
57
58 #define sfc_notice(sa, ...) \
59         SFC_LOG(sa, NOTICE, __VA_ARGS__)
60
61 #define sfc_info(sa, ...) \
62         SFC_LOG(sa, INFO, __VA_ARGS__)
63
64 #define sfc_log_init(sa, ...) \
65         do {                                                            \
66                 const struct sfc_adapter *_sa = (sa);                   \
67                                                                         \
68                 if (_sa->debug_init)                                    \
69                         SFC_LOG(_sa, INFO,                              \
70                                 RTE_FMT("%s(): "                        \
71                                         RTE_FMT_HEAD(__VA_ARGS__,),     \
72                                         __func__,                       \
73                                         RTE_FMT_TAIL(__VA_ARGS__,)));   \
74         } while (0)
75
76 #endif /* _SFC_LOG_H_ */