1 /* SPDX-License-Identifier: BSD-3-Clause */ 2 /* Copyright (c) 2021, 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 /*$FreeBSD$*/ 32 33 #ifndef _ICE_FWLOG_H_ 34 #define _ICE_FWLOG_H_ 35 #include "ice_adminq_cmd.h" 36 37 struct ice_hw; 38 39 /* Only a single log level should be set and all log levels under the set value 40 * are enabled, e.g. if log level is set to ICE_FW_LOG_LEVEL_VERBOSE, then all 41 * other log levels are included (except ICE_FW_LOG_LEVEL_NONE) 42 */ 43 enum ice_fwlog_level { 44 ICE_FWLOG_LEVEL_NONE = 0, 45 ICE_FWLOG_LEVEL_ERROR = 1, 46 ICE_FWLOG_LEVEL_WARNING = 2, 47 ICE_FWLOG_LEVEL_NORMAL = 3, 48 ICE_FWLOG_LEVEL_VERBOSE = 4, 49 ICE_FWLOG_LEVEL_INVALID, /* all values >= this entry are invalid */ 50 }; 51 52 struct ice_fwlog_module_entry { 53 /* module ID for the corresponding firmware logging event */ 54 u16 module_id; 55 /* verbosity level for the module_id */ 56 u8 log_level; 57 }; 58 59 struct ice_fwlog_cfg { 60 /* list of modules for configuring log level */ 61 struct ice_fwlog_module_entry module_entries[ICE_AQC_FW_LOG_ID_MAX]; 62 #define ICE_FWLOG_OPTION_ARQ_ENA BIT(0) 63 #define ICE_FWLOG_OPTION_UART_ENA BIT(1) 64 /* set before calling ice_fwlog_init() so the PF registers for firmware 65 * logging on initialization 66 */ 67 #define ICE_FWLOG_OPTION_REGISTER_ON_INIT BIT(2) 68 /* set in the ice_fwlog_get() response if the PF is registered for FW 69 * logging events over ARQ 70 */ 71 #define ICE_FWLOG_OPTION_IS_REGISTERED BIT(3) 72 /* options used to configure firmware logging */ 73 u16 options; 74 /* minimum number of log events sent per Admin Receive Queue event */ 75 u8 log_resolution; 76 }; 77 78 void ice_fwlog_set_support_ena(struct ice_hw *hw); 79 bool ice_fwlog_supported(struct ice_hw *hw); 80 enum ice_status ice_fwlog_init(struct ice_hw *hw, struct ice_fwlog_cfg *cfg); 81 enum ice_status ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg); 82 enum ice_status ice_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg); 83 enum ice_status 84 ice_fwlog_update_modules(struct ice_hw *hw, 85 struct ice_fwlog_module_entry *entries, 86 u16 num_entries); 87 enum ice_status ice_fwlog_register(struct ice_hw *hw); 88 enum ice_status ice_fwlog_unregister(struct ice_hw *hw); 89 void 90 ice_fwlog_event_dump(struct ice_hw *hw, struct ice_aq_desc *desc, void *buf); 91 #endif /* _ICE_FWLOG_H_ */ 92