Lines Matching +full:fw +full:- +full:cfg
1 // SPDX-License-Identifier: GPL-2.0
13 head = rings->head; in ice_fwlog_ring_full()
14 tail = rings->tail; in ice_fwlog_ring_full()
16 if (head < tail && (tail - head == (rings->size - 1))) in ice_fwlog_ring_full()
18 else if (head > tail && (tail == (head - 1))) in ice_fwlog_ring_full()
26 return rings->head == rings->tail; in ice_fwlog_ring_empty()
31 *item = (*item + 1) & (size - 1); in ice_fwlog_ring_increment()
39 nr_bytes = rings->size * ICE_AQ_MAX_BUF_LEN; in ice_fwlog_alloc_ring_buffs()
42 return -ENOMEM; in ice_fwlog_alloc_ring_buffs()
44 for (i = 0; i < rings->size; i++) { in ice_fwlog_alloc_ring_buffs()
45 struct ice_fwlog_data *ring = &rings->rings[i]; in ice_fwlog_alloc_ring_buffs()
47 ring->data_size = ICE_AQ_MAX_BUF_LEN; in ice_fwlog_alloc_ring_buffs()
48 ring->data = mem; in ice_fwlog_alloc_ring_buffs()
59 for (i = 0; i < rings->size; i++) { in ice_fwlog_free_ring_buffs()
60 struct ice_fwlog_data *ring = &rings->rings[i]; in ice_fwlog_free_ring_buffs()
66 vfree(ring->data); in ice_fwlog_free_ring_buffs()
68 ring->data = NULL; in ice_fwlog_free_ring_buffs()
69 ring->data_size = 0; in ice_fwlog_free_ring_buffs()
75 * ice_fwlog_realloc_rings - reallocate the FW log rings
86 * the driver presents the interface to the FW log data as a number of in ice_fwlog_realloc_rings()
91 * the user the driver knows that the data is correct and the FW log in ice_fwlog_realloc_rings()
95 if (ring_size == hw->fwlog_ring.size) in ice_fwlog_realloc_rings()
110 dev_warn(ice_hw_to_dev(hw), "Unable to allocate memory for FW log ring data buffers\n"); in ice_fwlog_realloc_rings()
116 ice_fwlog_free_ring_buffs(&hw->fwlog_ring); in ice_fwlog_realloc_rings()
117 kfree(hw->fwlog_ring.rings); in ice_fwlog_realloc_rings()
119 hw->fwlog_ring.rings = ring.rings; in ice_fwlog_realloc_rings()
120 hw->fwlog_ring.size = ring.size; in ice_fwlog_realloc_rings()
121 hw->fwlog_ring.index = index; in ice_fwlog_realloc_rings()
122 hw->fwlog_ring.head = 0; in ice_fwlog_realloc_rings()
123 hw->fwlog_ring.tail = 0; in ice_fwlog_realloc_rings()
127 * ice_fwlog_init - Initialize FW logging configuration
135 /* only support fw log commands on PF 0 */ in ice_fwlog_init()
136 if (hw->bus.func) in ice_fwlog_init()
137 return -EINVAL; in ice_fwlog_init()
144 /* read the current config from the FW and store it */ in ice_fwlog_init()
145 status = ice_fwlog_get(hw, &hw->fwlog_cfg); in ice_fwlog_init()
149 hw->fwlog_ring.rings = kcalloc(ICE_FWLOG_RING_SIZE_DFLT, in ice_fwlog_init()
150 sizeof(*hw->fwlog_ring.rings), in ice_fwlog_init()
152 if (!hw->fwlog_ring.rings) { in ice_fwlog_init()
153 dev_warn(ice_hw_to_dev(hw), "Unable to allocate memory for FW log rings\n"); in ice_fwlog_init()
154 return -ENOMEM; in ice_fwlog_init()
157 hw->fwlog_ring.size = ICE_FWLOG_RING_SIZE_DFLT; in ice_fwlog_init()
158 hw->fwlog_ring.index = ICE_FWLOG_RING_SIZE_INDEX_DFLT; in ice_fwlog_init()
160 status = ice_fwlog_alloc_ring_buffs(&hw->fwlog_ring); in ice_fwlog_init()
162 dev_warn(ice_hw_to_dev(hw), "Unable to allocate memory for FW log ring data buffers\n"); in ice_fwlog_init()
163 ice_fwlog_free_ring_buffs(&hw->fwlog_ring); in ice_fwlog_init()
164 kfree(hw->fwlog_ring.rings); in ice_fwlog_init()
168 ice_debugfs_fwlog_init(hw->back); in ice_fwlog_init()
170 …dev_warn(ice_hw_to_dev(hw), "FW logging is not supported in this NVM image. Please update the NVM … in ice_fwlog_init()
177 * ice_fwlog_deinit - unroll FW logging configuration
184 struct ice_pf *pf = hw->back; in ice_fwlog_deinit()
187 /* only support fw log commands on PF 0 */ in ice_fwlog_deinit()
188 if (hw->bus.func) in ice_fwlog_deinit()
191 ice_debugfs_pf_deinit(hw->back); in ice_fwlog_deinit()
193 /* make sure FW logging is disabled to not put the FW in a weird state in ice_fwlog_deinit()
196 hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA; in ice_fwlog_deinit()
197 status = ice_fwlog_set(hw, &hw->fwlog_cfg); in ice_fwlog_deinit()
199 dev_warn(ice_hw_to_dev(hw), "Unable to turn off FW logging, status: %d\n", in ice_fwlog_deinit()
202 kfree(pf->ice_debugfs_pf_fwlog_modules); in ice_fwlog_deinit()
204 pf->ice_debugfs_pf_fwlog_modules = NULL; in ice_fwlog_deinit()
208 dev_warn(ice_hw_to_dev(hw), "Unable to unregister FW logging, status: %d\n", in ice_fwlog_deinit()
211 if (hw->fwlog_ring.rings) { in ice_fwlog_deinit()
212 ice_fwlog_free_ring_buffs(&hw->fwlog_ring); in ice_fwlog_deinit()
213 kfree(hw->fwlog_ring.rings); in ice_fwlog_deinit()
218 * ice_fwlog_supported - Cached for whether FW supports FW logging or not
226 return hw->fwlog_supported; in ice_fwlog_supported()
230 * ice_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30)
234 * @options: options from ice_fwlog_cfg->options structure
249 return -ENOMEM; in ice_aq_fwlog_set()
262 cmd->cmd_flags = ICE_AQC_FW_LOG_CONF_SET_VALID; in ice_aq_fwlog_set()
263 cmd->ops.cfg.log_resolution = cpu_to_le16(log_resolution); in ice_aq_fwlog_set()
264 cmd->ops.cfg.mdl_cnt = cpu_to_le16(num_entries); in ice_aq_fwlog_set()
267 cmd->cmd_flags |= ICE_AQC_FW_LOG_CONF_AQ_EN; in ice_aq_fwlog_set()
269 cmd->cmd_flags |= ICE_AQC_FW_LOG_CONF_UART_EN; in ice_aq_fwlog_set()
281 * ice_fwlog_set - Set the firmware logging settings
283 * @cfg: config used to set firmware logging
289 * If the PF wishes to receive FW logging then it must register via
293 int ice_fwlog_set(struct ice_hw *hw, struct ice_fwlog_cfg *cfg) in ice_fwlog_set() argument
296 return -EOPNOTSUPP; in ice_fwlog_set()
298 return ice_aq_fwlog_set(hw, cfg->module_entries, in ice_fwlog_set()
299 ICE_AQC_FW_LOG_ID_MAX, cfg->options, in ice_fwlog_set()
300 cfg->log_resolution); in ice_fwlog_set()
304 * ice_aq_fwlog_get - Get the current firmware logging configuration (0xFF32)
306 * @cfg: firmware logging configuration to populate
308 static int ice_aq_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg) in ice_aq_fwlog_get() argument
318 memset(cfg, 0, sizeof(*cfg)); in ice_aq_fwlog_get()
322 return -ENOMEM; in ice_aq_fwlog_get()
327 cmd->cmd_flags = ICE_AQC_FW_LOG_AQ_QUERY; in ice_aq_fwlog_get()
331 ice_debug(hw, ICE_DBG_FW_LOG, "Failed to get FW log configuration\n"); in ice_aq_fwlog_get()
335 module_id_cnt = le16_to_cpu(cmd->ops.cfg.mdl_cnt); in ice_aq_fwlog_get()
337 ice_debug(hw, ICE_DBG_FW_LOG, "FW returned less than the expected number of FW log module IDs\n"); in ice_aq_fwlog_get()
339 …ice_debug(hw, ICE_DBG_FW_LOG, "FW returned more than expected number of FW log module IDs, setting… in ice_aq_fwlog_get()
344 cfg->log_resolution = le16_to_cpu(cmd->ops.cfg.log_resolution); in ice_aq_fwlog_get()
345 if (cmd->cmd_flags & ICE_AQC_FW_LOG_CONF_AQ_EN) in ice_aq_fwlog_get()
346 cfg->options |= ICE_FWLOG_OPTION_ARQ_ENA; in ice_aq_fwlog_get()
347 if (cmd->cmd_flags & ICE_AQC_FW_LOG_CONF_UART_EN) in ice_aq_fwlog_get()
348 cfg->options |= ICE_FWLOG_OPTION_UART_ENA; in ice_aq_fwlog_get()
349 if (cmd->cmd_flags & ICE_AQC_FW_LOG_QUERY_REGISTERED) in ice_aq_fwlog_get()
350 cfg->options |= ICE_FWLOG_OPTION_IS_REGISTERED; in ice_aq_fwlog_get()
357 cfg->module_entries[i].module_id = in ice_aq_fwlog_get()
358 le16_to_cpu(fw_module->module_identifier); in ice_aq_fwlog_get()
359 cfg->module_entries[i].log_level = fw_module->log_level; in ice_aq_fwlog_get()
368 * ice_fwlog_get - Get the firmware logging settings
370 * @cfg: config to populate based on current firmware logging settings
372 int ice_fwlog_get(struct ice_hw *hw, struct ice_fwlog_cfg *cfg) in ice_fwlog_get() argument
375 return -EOPNOTSUPP; in ice_fwlog_get()
377 return ice_aq_fwlog_get(hw, cfg); in ice_fwlog_get()
381 * ice_aq_fwlog_register - Register PF for firmware logging events (0xFF31)
398 * ice_fwlog_register - Register the PF for firmware logging
409 return -EOPNOTSUPP; in ice_fwlog_register()
415 hw->fwlog_cfg.options |= ICE_FWLOG_OPTION_IS_REGISTERED; in ice_fwlog_register()
421 * ice_fwlog_unregister - Unregister the PF from firmware logging
429 return -EOPNOTSUPP; in ice_fwlog_unregister()
435 hw->fwlog_cfg.options &= ~ICE_FWLOG_OPTION_IS_REGISTERED; in ice_fwlog_unregister()
441 * ice_fwlog_set_supported - Set if FW logging is supported by FW
444 * If FW returns success to the ice_aq_fwlog_get call then it supports FW
448 * the FW support FW logging.
452 struct ice_fwlog_cfg *cfg; in ice_fwlog_set_supported() local
455 hw->fwlog_supported = false; in ice_fwlog_set_supported()
457 cfg = kzalloc(sizeof(*cfg), GFP_KERNEL); in ice_fwlog_set_supported()
458 if (!cfg) in ice_fwlog_set_supported()
461 /* don't call ice_fwlog_get() because that would check to see if FW in ice_fwlog_set_supported()
464 status = ice_aq_fwlog_get(hw, cfg); in ice_fwlog_set_supported()
466 …debug(hw, ICE_DBG_FW_LOG, "ice_aq_fwlog_get failed, FW logging is not supported on this version of… in ice_fwlog_set_supported()
469 hw->fwlog_supported = true; in ice_fwlog_set_supported()
471 kfree(cfg); in ice_fwlog_set_supported()