xref: /freebsd/sys/dev/ice/ice_fwlog.h (revision f2635e844dd138ac9dfba676f27d41750049af26)
156429daeSEric Joyner /* SPDX-License-Identifier: BSD-3-Clause */
2015f8cc5SEric Joyner /*  Copyright (c) 2024, Intel Corporation
356429daeSEric Joyner  *  All rights reserved.
456429daeSEric Joyner  *
556429daeSEric Joyner  *  Redistribution and use in source and binary forms, with or without
656429daeSEric Joyner  *  modification, are permitted provided that the following conditions are met:
756429daeSEric Joyner  *
856429daeSEric Joyner  *   1. Redistributions of source code must retain the above copyright notice,
956429daeSEric Joyner  *      this list of conditions and the following disclaimer.
1056429daeSEric Joyner  *
1156429daeSEric Joyner  *   2. Redistributions in binary form must reproduce the above copyright
1256429daeSEric Joyner  *      notice, this list of conditions and the following disclaimer in the
1356429daeSEric Joyner  *      documentation and/or other materials provided with the distribution.
1456429daeSEric Joyner  *
1556429daeSEric Joyner  *   3. Neither the name of the Intel Corporation nor the names of its
1656429daeSEric Joyner  *      contributors may be used to endorse or promote products derived from
1756429daeSEric Joyner  *      this software without specific prior written permission.
1856429daeSEric Joyner  *
1956429daeSEric Joyner  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2056429daeSEric Joyner  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2156429daeSEric Joyner  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2256429daeSEric Joyner  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
2356429daeSEric Joyner  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2456429daeSEric Joyner  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2556429daeSEric Joyner  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2656429daeSEric Joyner  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2756429daeSEric Joyner  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2856429daeSEric Joyner  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2956429daeSEric Joyner  *  POSSIBILITY OF SUCH DAMAGE.
3056429daeSEric Joyner  */
3156429daeSEric Joyner 
3256429daeSEric Joyner #ifndef _ICE_FWLOG_H_
3356429daeSEric Joyner #define _ICE_FWLOG_H_
3456429daeSEric Joyner #include "ice_adminq_cmd.h"
3556429daeSEric Joyner 
3656429daeSEric Joyner struct ice_hw;
3756429daeSEric Joyner 
3856429daeSEric Joyner /* Only a single log level should be set and all log levels under the set value
3956429daeSEric Joyner  * are enabled, e.g. if log level is set to ICE_FW_LOG_LEVEL_VERBOSE, then all
4056429daeSEric Joyner  * other log levels are included (except ICE_FW_LOG_LEVEL_NONE)
4156429daeSEric Joyner  */
4256429daeSEric Joyner enum ice_fwlog_level {
4356429daeSEric Joyner 	ICE_FWLOG_LEVEL_NONE = 0,
4456429daeSEric Joyner 	ICE_FWLOG_LEVEL_ERROR = 1,
4556429daeSEric Joyner 	ICE_FWLOG_LEVEL_WARNING = 2,
4656429daeSEric Joyner 	ICE_FWLOG_LEVEL_NORMAL = 3,
4756429daeSEric Joyner 	ICE_FWLOG_LEVEL_VERBOSE = 4,
4856429daeSEric Joyner 	ICE_FWLOG_LEVEL_INVALID, /* all values >= this entry are invalid */
4956429daeSEric Joyner };
5056429daeSEric Joyner 
5156429daeSEric Joyner struct ice_fwlog_module_entry {
5256429daeSEric Joyner 	/* module ID for the corresponding firmware logging event */
5356429daeSEric Joyner 	u16 module_id;
5456429daeSEric Joyner 	/* verbosity level for the module_id */
5556429daeSEric Joyner 	u8 log_level;
5656429daeSEric Joyner };
5756429daeSEric Joyner 
5856429daeSEric Joyner struct ice_fwlog_cfg {
5956429daeSEric Joyner 	/* list of modules for configuring log level */
6056429daeSEric Joyner 	struct ice_fwlog_module_entry module_entries[ICE_AQC_FW_LOG_ID_MAX];
6156429daeSEric Joyner #define ICE_FWLOG_OPTION_ARQ_ENA		BIT(0)
6256429daeSEric Joyner #define ICE_FWLOG_OPTION_UART_ENA		BIT(1)
6356429daeSEric Joyner 	/* set before calling ice_fwlog_init() so the PF registers for firmware
6456429daeSEric Joyner 	 * logging on initialization
6556429daeSEric Joyner 	 */
6656429daeSEric Joyner #define ICE_FWLOG_OPTION_REGISTER_ON_INIT	BIT(2)
6756429daeSEric Joyner 	/* set in the ice_fwlog_get() response if the PF is registered for FW
6856429daeSEric Joyner 	 * logging events over ARQ
6956429daeSEric Joyner 	 */
7056429daeSEric Joyner #define ICE_FWLOG_OPTION_IS_REGISTERED		BIT(3)
7156429daeSEric Joyner 	/* options used to configure firmware logging */
7256429daeSEric Joyner 	u16 options;
7356429daeSEric Joyner 	/* minimum number of log events sent per Admin Receive Queue event */
748923de59SPiotr Kubaj 	u16 log_resolution;
7556429daeSEric Joyner };
7656429daeSEric Joyner 
7756429daeSEric Joyner void ice_fwlog_set_support_ena(struct ice_hw *hw);
7856429daeSEric Joyner bool ice_fwlog_supported(struct ice_hw *hw);
79*f2635e84SEric Joyner int ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
80*f2635e84SEric Joyner int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
81*f2635e84SEric Joyner int ice_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg);
82*f2635e84SEric Joyner int
8356429daeSEric Joyner ice_fwlog_update_modules(struct ice_hw *hw,
8456429daeSEric Joyner 			 struct ice_fwlog_module_entry *entries,
8556429daeSEric Joyner 			 u16 num_entries);
86*f2635e84SEric Joyner int ice_fwlog_register(struct ice_hw *hw);
87*f2635e84SEric Joyner int ice_fwlog_unregister(struct ice_hw *hw);
8856429daeSEric Joyner void
8956429daeSEric Joyner ice_fwlog_event_dump(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf);
9056429daeSEric Joyner #endif /* _ICE_FWLOG_H_ */
91