xref: /freebsd/sys/dev/ice/ice_fwlog.h (revision 7899f917b1c0ea178f1d2be0cfb452086d079d23)
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*  Copyright (c) 2024, Intel Corporation
3  *  All rights reserved.
4  *
5  *  Redistribution and use in source and binary forms, with or without
6  *  modification, are permitted provided that the following conditions are met:
7  *
8  *   1. Redistributions of source code must retain the above copyright notice,
9  *      this list of conditions and the following disclaimer.
10  *
11  *   2. Redistributions in binary form must reproduce the above copyright
12  *      notice, this list of conditions and the following disclaimer in the
13  *      documentation and/or other materials provided with the distribution.
14  *
15  *   3. Neither the name of the Intel Corporation nor the names of its
16  *      contributors may be used to endorse or promote products derived from
17  *      this software without specific prior written permission.
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, THE
21  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  *  POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _ICE_FWLOG_H_
33 #define _ICE_FWLOG_H_
34 #include "ice_adminq_cmd.h"
35 
36 struct ice_hw;
37 
38 /* Only a single log level should be set and all log levels under the set value
39  * are enabled, e.g. if log level is set to ICE_FW_LOG_LEVEL_VERBOSE, then all
40  * other log levels are included (except ICE_FW_LOG_LEVEL_NONE)
41  */
42 enum ice_fwlog_level {
43 	ICE_FWLOG_LEVEL_NONE = 0,
44 	ICE_FWLOG_LEVEL_ERROR = 1,
45 	ICE_FWLOG_LEVEL_WARNING = 2,
46 	ICE_FWLOG_LEVEL_NORMAL = 3,
47 	ICE_FWLOG_LEVEL_VERBOSE = 4,
48 	ICE_FWLOG_LEVEL_INVALID, /* all values >= this entry are invalid */
49 };
50 
51 struct ice_fwlog_module_entry {
52 	/* module ID for the corresponding firmware logging event */
53 	u16 module_id;
54 	/* verbosity level for the module_id */
55 	u8 log_level;
56 };
57 
58 struct ice_fwlog_cfg {
59 	/* list of modules for configuring log level */
60 	struct ice_fwlog_module_entry module_entries[ICE_AQC_FW_LOG_ID_MAX];
61 #define ICE_FWLOG_OPTION_ARQ_ENA		BIT(0)
62 #define ICE_FWLOG_OPTION_UART_ENA		BIT(1)
63 	/* set before calling ice_fwlog_init() so the PF registers for firmware
64 	 * logging on initialization
65 	 */
66 #define ICE_FWLOG_OPTION_REGISTER_ON_INIT	BIT(2)
67 	/* set in the ice_fwlog_get() response if the PF is registered for FW
68 	 * logging events over ARQ
69 	 */
70 #define ICE_FWLOG_OPTION_IS_REGISTERED		BIT(3)
71 	/* options used to configure firmware logging */
72 	u16 options;
73 	/* minimum number of log events sent per Admin Receive Queue event */
74 	u16 log_resolution;
75 };
76 
77 void ice_fwlog_set_support_ena(struct ice_hw *hw);
78 bool ice_fwlog_supported(struct ice_hw *hw);
79 enum ice_status ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
80 enum ice_status ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
81 enum ice_status ice_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
82 enum ice_status
83 ice_fwlog_update_modules(struct ice_hw *hw,
84 			 struct ice_fwlog_module_entry *entries,
85 			 u16 num_entries);
86 enum ice_status ice_fwlog_register(struct ice_hw *hw);
87 enum ice_status ice_fwlog_unregister(struct ice_hw *hw);
88 void
89 ice_fwlog_event_dump(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf);
90 #endif /* _ICE_FWLOG_H_ */
91