Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ice: prepare for moving file to libie

s/ice/libie

There is no function for filling default descriptor in libie. Zero
descriptor structure and set opcode without calling the function.

Make functions that are caled only in ice_fwlog.c static.

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>

authored by

Michal Swiatkowski and committed by
Tony Nguyen
02f44dac 2ab5eb4b

+359 -356
+3 -3
drivers/net/ethernet/intel/ice/ice_common.c
··· 995 995 static int __fwlog_init(struct ice_hw *hw) 996 996 { 997 997 struct ice_pf *pf = hw->back; 998 - struct ice_fwlog_api api = { 998 + struct libie_fwlog_api api = { 999 999 .pdev = pf->pdev, 1000 1000 .send_cmd = __fwlog_send_cmd, 1001 1001 .priv = hw, ··· 1012 1012 1013 1013 api.debugfs_root = pf->ice_debugfs_pf; 1014 1014 1015 - return ice_fwlog_init(&hw->fwlog, &api); 1015 + return libie_fwlog_init(&hw->fwlog, &api); 1016 1016 } 1017 1017 1018 1018 /** ··· 1197 1197 return; 1198 1198 1199 1199 ice_debugfs_pf_deinit(hw->back); 1200 - ice_fwlog_deinit(&hw->fwlog); 1200 + libie_fwlog_deinit(&hw->fwlog); 1201 1201 } 1202 1202 1203 1203 /**
+315 -309
drivers/net/ethernet/intel/ice/ice_fwlog.c
··· 12 12 /* create a define that has an extra module that doesn't really exist. this 13 13 * is so we can add a module 'all' to easily enable/disable all the modules 14 14 */ 15 - #define ICE_NR_FW_LOG_MODULES (LIBIE_AQC_FW_LOG_ID_MAX + 1) 15 + #define LIBIE_NR_FW_LOG_MODULES (LIBIE_AQC_FW_LOG_ID_MAX + 1) 16 16 17 17 /* the ordering in this array is important. it matches the ordering of the 18 18 * values in the FW so the index is the same value as in 19 19 * libie_aqc_fw_logging_mod 20 20 */ 21 - static const char * const ice_fwlog_module_string[] = { 21 + static const char * const libie_fwlog_module_string[] = { 22 22 "general", 23 23 "ctrl", 24 24 "link", ··· 55 55 }; 56 56 57 57 /* the ordering in this array is important. it matches the ordering of the 58 - * values in the FW so the index is the same value as in ice_fwlog_level 58 + * values in the FW so the index is the same value as in libie_fwlog_level 59 59 */ 60 - static const char * const ice_fwlog_level_string[] = { 60 + static const char * const libie_fwlog_level_string[] = { 61 61 "none", 62 62 "error", 63 63 "warning", ··· 65 65 "verbose", 66 66 }; 67 67 68 - static const char * const ice_fwlog_log_size[] = { 68 + static const char * const libie_fwlog_log_size[] = { 69 69 "128K", 70 70 "256K", 71 71 "512K", ··· 73 73 "2M", 74 74 }; 75 75 76 - static bool ice_fwlog_ring_empty(struct ice_fwlog_ring *rings) 76 + static bool libie_fwlog_ring_empty(struct libie_fwlog_ring *rings) 77 77 { 78 78 return rings->head == rings->tail; 79 79 } 80 80 81 - static void ice_fwlog_ring_increment(u16 *item, u16 size) 81 + static void libie_fwlog_ring_increment(u16 *item, u16 size) 82 82 { 83 83 *item = (*item + 1) & (size - 1); 84 84 } 85 85 86 - static int ice_fwlog_alloc_ring_buffs(struct ice_fwlog_ring *rings) 86 + static int libie_fwlog_alloc_ring_buffs(struct libie_fwlog_ring *rings) 87 87 { 88 88 int i, nr_bytes; 89 89 u8 *mem; 90 90 91 - nr_bytes = rings->size * ICE_AQ_MAX_BUF_LEN; 91 + nr_bytes = rings->size * LIBIE_AQ_MAX_BUF_LEN; 92 92 mem = vzalloc(nr_bytes); 93 93 if (!mem) 94 94 return -ENOMEM; 95 95 96 96 for (i = 0; i < rings->size; i++) { 97 - struct ice_fwlog_data *ring = &rings->rings[i]; 97 + struct libie_fwlog_data *ring = &rings->rings[i]; 98 98 99 - ring->data_size = ICE_AQ_MAX_BUF_LEN; 99 + ring->data_size = LIBIE_AQ_MAX_BUF_LEN; 100 100 ring->data = mem; 101 - mem += ICE_AQ_MAX_BUF_LEN; 101 + mem += LIBIE_AQ_MAX_BUF_LEN; 102 102 } 103 103 104 104 return 0; 105 105 } 106 106 107 - static void ice_fwlog_free_ring_buffs(struct ice_fwlog_ring *rings) 107 + static void libie_fwlog_free_ring_buffs(struct libie_fwlog_ring *rings) 108 108 { 109 109 int i; 110 110 111 111 for (i = 0; i < rings->size; i++) { 112 - struct ice_fwlog_data *ring = &rings->rings[i]; 112 + struct libie_fwlog_data *ring = &rings->rings[i]; 113 113 114 114 /* the first ring is the base memory for the whole range so 115 115 * free it ··· 122 122 } 123 123 } 124 124 125 - #define ICE_FWLOG_INDEX_TO_BYTES(n) ((128 * 1024) << (n)) 125 + #define LIBIE_FWLOG_INDEX_TO_BYTES(n) ((128 * 1024) << (n)) 126 126 /** 127 - * ice_fwlog_realloc_rings - reallocate the FW log rings 127 + * libie_fwlog_realloc_rings - reallocate the FW log rings 128 128 * @fwlog: pointer to the fwlog structure 129 129 * @index: the new index to use to allocate memory for the log data 130 130 * 131 131 */ 132 - static void ice_fwlog_realloc_rings(struct ice_fwlog *fwlog, int index) 132 + static void libie_fwlog_realloc_rings(struct libie_fwlog *fwlog, int index) 133 133 { 134 - struct ice_fwlog_ring ring; 134 + struct libie_fwlog_ring ring; 135 135 int status, ring_size; 136 136 137 137 /* convert the number of bytes into a number of 4K buffers. externally ··· 143 143 * the user the driver knows that the data is correct and the FW log 144 144 * can be correctly parsed by the tools 145 145 */ 146 - ring_size = ICE_FWLOG_INDEX_TO_BYTES(index) / ICE_AQ_MAX_BUF_LEN; 146 + ring_size = LIBIE_FWLOG_INDEX_TO_BYTES(index) / LIBIE_AQ_MAX_BUF_LEN; 147 147 if (ring_size == fwlog->ring.size) 148 148 return; 149 149 ··· 157 157 158 158 ring.size = ring_size; 159 159 160 - status = ice_fwlog_alloc_ring_buffs(&ring); 160 + status = libie_fwlog_alloc_ring_buffs(&ring); 161 161 if (status) { 162 162 dev_warn(&fwlog->pdev->dev, "Unable to allocate memory for FW log ring data buffers\n"); 163 - ice_fwlog_free_ring_buffs(&ring); 163 + libie_fwlog_free_ring_buffs(&ring); 164 164 kfree(ring.rings); 165 165 return; 166 166 } 167 167 168 - ice_fwlog_free_ring_buffs(&fwlog->ring); 168 + libie_fwlog_free_ring_buffs(&fwlog->ring); 169 169 kfree(fwlog->ring.rings); 170 170 171 171 fwlog->ring.rings = ring.rings; ··· 176 176 } 177 177 178 178 /** 179 - * ice_fwlog_print_module_cfg - print current FW logging module configuration 179 + * libie_fwlog_supported - Cached for whether FW supports FW logging or not 180 + * @fwlog: pointer to the fwlog structure 181 + * 182 + * This will always return false if called before libie_init_hw(), so it must be 183 + * called after libie_init_hw(). 184 + */ 185 + static bool libie_fwlog_supported(struct libie_fwlog *fwlog) 186 + { 187 + return fwlog->supported; 188 + } 189 + 190 + /** 191 + * libie_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30) 192 + * @fwlog: pointer to the fwlog structure 193 + * @entries: entries to configure 194 + * @num_entries: number of @entries 195 + * @options: options from libie_fwlog_cfg->options structure 196 + * @log_resolution: logging resolution 197 + */ 198 + static int 199 + libie_aq_fwlog_set(struct libie_fwlog *fwlog, 200 + struct libie_fwlog_module_entry *entries, u16 num_entries, 201 + u16 options, u16 log_resolution) 202 + { 203 + struct libie_aqc_fw_log_cfg_resp *fw_modules; 204 + struct libie_aq_desc desc = {0}; 205 + struct libie_aqc_fw_log *cmd; 206 + int status; 207 + int i; 208 + 209 + fw_modules = kcalloc(num_entries, sizeof(*fw_modules), GFP_KERNEL); 210 + if (!fw_modules) 211 + return -ENOMEM; 212 + 213 + for (i = 0; i < num_entries; i++) { 214 + fw_modules[i].module_identifier = 215 + cpu_to_le16(entries[i].module_id); 216 + fw_modules[i].log_level = entries[i].log_level; 217 + } 218 + 219 + desc.opcode = cpu_to_le16(libie_aqc_opc_fw_logs_config); 220 + desc.flags = cpu_to_le16(LIBIE_AQ_FLAG_SI) | 221 + cpu_to_le16(LIBIE_AQ_FLAG_RD); 222 + 223 + cmd = libie_aq_raw(&desc); 224 + 225 + cmd->cmd_flags = LIBIE_AQC_FW_LOG_CONF_SET_VALID; 226 + cmd->ops.cfg.log_resolution = cpu_to_le16(log_resolution); 227 + cmd->ops.cfg.mdl_cnt = cpu_to_le16(num_entries); 228 + 229 + if (options & LIBIE_FWLOG_OPTION_ARQ_ENA) 230 + cmd->cmd_flags |= LIBIE_AQC_FW_LOG_CONF_AQ_EN; 231 + if (options & LIBIE_FWLOG_OPTION_UART_ENA) 232 + cmd->cmd_flags |= LIBIE_AQC_FW_LOG_CONF_UART_EN; 233 + 234 + status = fwlog->send_cmd(fwlog->priv, &desc, fw_modules, 235 + sizeof(*fw_modules) * num_entries); 236 + 237 + kfree(fw_modules); 238 + 239 + return status; 240 + } 241 + 242 + /** 243 + * libie_fwlog_set - Set the firmware logging settings 244 + * @fwlog: pointer to the fwlog structure 245 + * @cfg: config used to set firmware logging 246 + * 247 + * This function should be called whenever the driver needs to set the firmware 248 + * logging configuration. It can be called on initialization, reset, or during 249 + * runtime. 250 + * 251 + * If the PF wishes to receive FW logging then it must register via 252 + * libie_fwlog_register. Note, that libie_fwlog_register does not need to be called 253 + * for init. 254 + */ 255 + static int libie_fwlog_set(struct libie_fwlog *fwlog, 256 + struct libie_fwlog_cfg *cfg) 257 + { 258 + if (!libie_fwlog_supported(fwlog)) 259 + return -EOPNOTSUPP; 260 + 261 + return libie_aq_fwlog_set(fwlog, cfg->module_entries, 262 + LIBIE_AQC_FW_LOG_ID_MAX, cfg->options, 263 + cfg->log_resolution); 264 + } 265 + 266 + /** 267 + * libie_aq_fwlog_register - Register PF for firmware logging events (0xFF31) 268 + * @fwlog: pointer to the fwlog structure 269 + * @reg: true to register and false to unregister 270 + */ 271 + static int libie_aq_fwlog_register(struct libie_fwlog *fwlog, bool reg) 272 + { 273 + struct libie_aq_desc desc = {0}; 274 + struct libie_aqc_fw_log *cmd; 275 + 276 + desc.opcode = cpu_to_le16(libie_aqc_opc_fw_logs_register); 277 + desc.flags = cpu_to_le16(LIBIE_AQ_FLAG_SI); 278 + cmd = libie_aq_raw(&desc); 279 + 280 + if (reg) 281 + cmd->cmd_flags = LIBIE_AQC_FW_LOG_AQ_REGISTER; 282 + 283 + return fwlog->send_cmd(fwlog->priv, &desc, NULL, 0); 284 + } 285 + 286 + /** 287 + * libie_fwlog_register - Register the PF for firmware logging 288 + * @fwlog: pointer to the fwlog structure 289 + * 290 + * After this call the PF will start to receive firmware logging based on the 291 + * configuration set in libie_fwlog_set. 292 + */ 293 + int libie_fwlog_register(struct libie_fwlog *fwlog) 294 + { 295 + int status; 296 + 297 + if (!libie_fwlog_supported(fwlog)) 298 + return -EOPNOTSUPP; 299 + 300 + status = libie_aq_fwlog_register(fwlog, true); 301 + if (status) 302 + dev_dbg(&fwlog->pdev->dev, "Failed to register for firmware logging events over ARQ\n"); 303 + else 304 + fwlog->cfg.options |= LIBIE_FWLOG_OPTION_IS_REGISTERED; 305 + 306 + return status; 307 + } 308 + 309 + /** 310 + * libie_fwlog_unregister - Unregister the PF from firmware logging 311 + * @fwlog: pointer to the fwlog structure 312 + */ 313 + static int libie_fwlog_unregister(struct libie_fwlog *fwlog) 314 + { 315 + int status; 316 + 317 + if (!libie_fwlog_supported(fwlog)) 318 + return -EOPNOTSUPP; 319 + 320 + status = libie_aq_fwlog_register(fwlog, false); 321 + if (status) 322 + dev_dbg(&fwlog->pdev->dev, "Failed to unregister from firmware logging events over ARQ\n"); 323 + else 324 + fwlog->cfg.options &= ~LIBIE_FWLOG_OPTION_IS_REGISTERED; 325 + 326 + return status; 327 + } 328 + 329 + /** 330 + * libie_fwlog_print_module_cfg - print current FW logging module configuration 180 331 * @cfg: pointer to the fwlog cfg structure 181 332 * @module: module to print 182 333 * @s: the seq file to put data into 183 334 */ 184 335 static void 185 - ice_fwlog_print_module_cfg(struct ice_fwlog_cfg *cfg, int module, 186 - struct seq_file *s) 336 + libie_fwlog_print_module_cfg(struct libie_fwlog_cfg *cfg, int module, 337 + struct seq_file *s) 187 338 { 188 - struct ice_fwlog_module_entry *entry; 339 + struct libie_fwlog_module_entry *entry; 189 340 190 341 if (module != LIBIE_AQC_FW_LOG_ID_MAX) { 191 342 entry = &cfg->module_entries[module]; 192 343 193 344 seq_printf(s, "\tModule: %s, Log Level: %s\n", 194 - ice_fwlog_module_string[entry->module_id], 195 - ice_fwlog_level_string[entry->log_level]); 345 + libie_fwlog_module_string[entry->module_id], 346 + libie_fwlog_level_string[entry->log_level]); 196 347 } else { 197 348 int i; 198 349 ··· 351 200 entry = &cfg->module_entries[i]; 352 201 353 202 seq_printf(s, "\tModule: %s, Log Level: %s\n", 354 - ice_fwlog_module_string[entry->module_id], 355 - ice_fwlog_level_string[entry->log_level]); 203 + libie_fwlog_module_string[entry->module_id], 204 + libie_fwlog_level_string[entry->log_level]); 356 205 } 357 206 } 358 207 } 359 208 360 - static int ice_find_module_by_dentry(struct dentry **modules, struct dentry *d) 209 + static int libie_find_module_by_dentry(struct dentry **modules, struct dentry *d) 361 210 { 362 211 int i, module; 363 212 364 213 module = -1; 365 214 /* find the module based on the dentry */ 366 - for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) { 215 + for (i = 0; i < LIBIE_NR_FW_LOG_MODULES; i++) { 367 216 if (d == modules[i]) { 368 217 module = i; 369 218 break; ··· 374 223 } 375 224 376 225 /** 377 - * ice_debugfs_module_show - read from 'module' file 226 + * libie_debugfs_module_show - read from 'module' file 378 227 * @s: the opened file 379 228 * @v: pointer to the offset 380 229 */ 381 - static int ice_debugfs_module_show(struct seq_file *s, void *v) 230 + static int libie_debugfs_module_show(struct seq_file *s, void *v) 382 231 { 383 - struct ice_fwlog *fwlog = s->private; 232 + struct libie_fwlog *fwlog = s->private; 384 233 const struct file *filp = s->file; 385 234 struct dentry *dentry; 386 235 int module; 387 236 388 237 dentry = file_dentry(filp); 389 238 390 - module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry); 239 + module = libie_find_module_by_dentry(fwlog->debugfs_modules, dentry); 391 240 if (module < 0) { 392 241 dev_info(&fwlog->pdev->dev, "unknown module\n"); 393 242 return -EINVAL; 394 243 } 395 244 396 - ice_fwlog_print_module_cfg(&fwlog->cfg, module, s); 245 + libie_fwlog_print_module_cfg(&fwlog->cfg, module, s); 397 246 398 247 return 0; 399 248 } 400 249 401 - static int ice_debugfs_module_open(struct inode *inode, struct file *filp) 250 + static int libie_debugfs_module_open(struct inode *inode, struct file *filp) 402 251 { 403 - return single_open(filp, ice_debugfs_module_show, inode->i_private); 252 + return single_open(filp, libie_debugfs_module_show, inode->i_private); 404 253 } 405 254 406 255 /** 407 - * ice_debugfs_module_write - write into 'module' file 256 + * libie_debugfs_module_write - write into 'module' file 408 257 * @filp: the opened file 409 258 * @buf: where to find the user's data 410 259 * @count: the length of the user's data 411 260 * @ppos: file position offset 412 261 */ 413 262 static ssize_t 414 - ice_debugfs_module_write(struct file *filp, const char __user *buf, 415 - size_t count, loff_t *ppos) 263 + libie_debugfs_module_write(struct file *filp, const char __user *buf, 264 + size_t count, loff_t *ppos) 416 265 { 417 - struct ice_fwlog *fwlog = file_inode(filp)->i_private; 266 + struct libie_fwlog *fwlog = file_inode(filp)->i_private; 418 267 struct dentry *dentry = file_dentry(filp); 419 268 struct device *dev = &fwlog->pdev->dev; 420 269 char user_val[16], *cmd_buf; ··· 428 277 if (IS_ERR(cmd_buf)) 429 278 return PTR_ERR(cmd_buf); 430 279 431 - module = ice_find_module_by_dentry(fwlog->debugfs_modules, dentry); 280 + module = libie_find_module_by_dentry(fwlog->debugfs_modules, dentry); 432 281 if (module < 0) { 433 282 dev_info(dev, "unknown module\n"); 434 283 return -EINVAL; ··· 438 287 if (cnt != 1) 439 288 return -EINVAL; 440 289 441 - log_level = sysfs_match_string(ice_fwlog_level_string, user_val); 290 + log_level = sysfs_match_string(libie_fwlog_level_string, user_val); 442 291 if (log_level < 0) { 443 292 dev_info(dev, "unknown log level '%s'\n", user_val); 444 293 return -EINVAL; ··· 459 308 return count; 460 309 } 461 310 462 - static const struct file_operations ice_debugfs_module_fops = { 311 + static const struct file_operations libie_debugfs_module_fops = { 463 312 .owner = THIS_MODULE, 464 - .open = ice_debugfs_module_open, 313 + .open = libie_debugfs_module_open, 465 314 .read = seq_read, 466 315 .release = single_release, 467 - .write = ice_debugfs_module_write, 316 + .write = libie_debugfs_module_write, 468 317 }; 469 318 470 319 /** 471 - * ice_debugfs_nr_messages_read - read from 'nr_messages' file 320 + * libie_debugfs_nr_messages_read - read from 'nr_messages' file 472 321 * @filp: the opened file 473 322 * @buffer: where to write the data for the user to read 474 323 * @count: the size of the user's buffer 475 324 * @ppos: file position offset 476 325 */ 477 - static ssize_t ice_debugfs_nr_messages_read(struct file *filp, 478 - char __user *buffer, size_t count, 479 - loff_t *ppos) 326 + static ssize_t libie_debugfs_nr_messages_read(struct file *filp, 327 + char __user *buffer, size_t count, 328 + loff_t *ppos) 480 329 { 481 - struct ice_fwlog *fwlog = filp->private_data; 330 + struct libie_fwlog *fwlog = filp->private_data; 482 331 char buff[32] = {}; 483 332 484 333 snprintf(buff, sizeof(buff), "%d\n", ··· 488 337 } 489 338 490 339 /** 491 - * ice_debugfs_nr_messages_write - write into 'nr_messages' file 340 + * libie_debugfs_nr_messages_write - write into 'nr_messages' file 492 341 * @filp: the opened file 493 342 * @buf: where to find the user's data 494 343 * @count: the length of the user's data 495 344 * @ppos: file position offset 496 345 */ 497 346 static ssize_t 498 - ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf, 499 - size_t count, loff_t *ppos) 347 + libie_debugfs_nr_messages_write(struct file *filp, const char __user *buf, 348 + size_t count, loff_t *ppos) 500 349 { 501 - struct ice_fwlog *fwlog = filp->private_data; 350 + struct libie_fwlog *fwlog = filp->private_data; 502 351 struct device *dev = &fwlog->pdev->dev; 503 352 char user_val[8], *cmd_buf; 504 353 s16 nr_messages; ··· 533 382 return count; 534 383 } 535 384 536 - static const struct file_operations ice_debugfs_nr_messages_fops = { 385 + static const struct file_operations libie_debugfs_nr_messages_fops = { 537 386 .owner = THIS_MODULE, 538 387 .open = simple_open, 539 - .read = ice_debugfs_nr_messages_read, 540 - .write = ice_debugfs_nr_messages_write, 388 + .read = libie_debugfs_nr_messages_read, 389 + .write = libie_debugfs_nr_messages_write, 541 390 }; 542 391 543 392 /** 544 - * ice_debugfs_enable_read - read from 'enable' file 393 + * libie_debugfs_enable_read - read from 'enable' file 545 394 * @filp: the opened file 546 395 * @buffer: where to write the data for the user to read 547 396 * @count: the size of the user's buffer 548 397 * @ppos: file position offset 549 398 */ 550 - static ssize_t ice_debugfs_enable_read(struct file *filp, 551 - char __user *buffer, size_t count, 552 - loff_t *ppos) 399 + static ssize_t libie_debugfs_enable_read(struct file *filp, 400 + char __user *buffer, size_t count, 401 + loff_t *ppos) 553 402 { 554 - struct ice_fwlog *fwlog = filp->private_data; 403 + struct libie_fwlog *fwlog = filp->private_data; 555 404 char buff[32] = {}; 556 405 557 406 snprintf(buff, sizeof(buff), "%u\n", 558 407 (u16)(fwlog->cfg.options & 559 - ICE_FWLOG_OPTION_IS_REGISTERED) >> 3); 408 + LIBIE_FWLOG_OPTION_IS_REGISTERED) >> 3); 560 409 561 410 return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff)); 562 411 } 563 412 564 413 /** 565 - * ice_debugfs_enable_write - write into 'enable' file 414 + * libie_debugfs_enable_write - write into 'enable' file 566 415 * @filp: the opened file 567 416 * @buf: where to find the user's data 568 417 * @count: the length of the user's data 569 418 * @ppos: file position offset 570 419 */ 571 420 static ssize_t 572 - ice_debugfs_enable_write(struct file *filp, const char __user *buf, 573 - size_t count, loff_t *ppos) 421 + libie_debugfs_enable_write(struct file *filp, const char __user *buf, 422 + size_t count, loff_t *ppos) 574 423 { 575 - struct ice_fwlog *fwlog = filp->private_data; 424 + struct libie_fwlog *fwlog = filp->private_data; 576 425 char user_val[8], *cmd_buf; 577 426 bool enable; 578 427 ssize_t ret; ··· 594 443 goto enable_write_error; 595 444 596 445 if (enable) 597 - fwlog->cfg.options |= ICE_FWLOG_OPTION_ARQ_ENA; 446 + fwlog->cfg.options |= LIBIE_FWLOG_OPTION_ARQ_ENA; 598 447 else 599 - fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA; 448 + fwlog->cfg.options &= ~LIBIE_FWLOG_OPTION_ARQ_ENA; 600 449 601 - ret = ice_fwlog_set(fwlog, &fwlog->cfg); 450 + ret = libie_fwlog_set(fwlog, &fwlog->cfg); 602 451 if (ret) 603 452 goto enable_write_error; 604 453 605 454 if (enable) 606 - ret = ice_fwlog_register(fwlog); 455 + ret = libie_fwlog_register(fwlog); 607 456 else 608 - ret = ice_fwlog_unregister(fwlog); 457 + ret = libie_fwlog_unregister(fwlog); 609 458 610 459 if (ret) 611 460 goto enable_write_error; ··· 626 475 return ret; 627 476 } 628 477 629 - static const struct file_operations ice_debugfs_enable_fops = { 478 + static const struct file_operations libie_debugfs_enable_fops = { 630 479 .owner = THIS_MODULE, 631 480 .open = simple_open, 632 - .read = ice_debugfs_enable_read, 633 - .write = ice_debugfs_enable_write, 481 + .read = libie_debugfs_enable_read, 482 + .write = libie_debugfs_enable_write, 634 483 }; 635 484 636 485 /** 637 - * ice_debugfs_log_size_read - read from 'log_size' file 486 + * libie_debugfs_log_size_read - read from 'log_size' file 638 487 * @filp: the opened file 639 488 * @buffer: where to write the data for the user to read 640 489 * @count: the size of the user's buffer 641 490 * @ppos: file position offset 642 491 */ 643 - static ssize_t ice_debugfs_log_size_read(struct file *filp, 644 - char __user *buffer, size_t count, 645 - loff_t *ppos) 492 + static ssize_t libie_debugfs_log_size_read(struct file *filp, 493 + char __user *buffer, size_t count, 494 + loff_t *ppos) 646 495 { 647 - struct ice_fwlog *fwlog = filp->private_data; 496 + struct libie_fwlog *fwlog = filp->private_data; 648 497 char buff[32] = {}; 649 498 int index; 650 499 651 500 index = fwlog->ring.index; 652 - snprintf(buff, sizeof(buff), "%s\n", ice_fwlog_log_size[index]); 501 + snprintf(buff, sizeof(buff), "%s\n", libie_fwlog_log_size[index]); 653 502 654 503 return simple_read_from_buffer(buffer, count, ppos, buff, strlen(buff)); 655 504 } 656 505 657 506 /** 658 - * ice_debugfs_log_size_write - write into 'log_size' file 507 + * libie_debugfs_log_size_write - write into 'log_size' file 659 508 * @filp: the opened file 660 509 * @buf: where to find the user's data 661 510 * @count: the length of the user's data 662 511 * @ppos: file position offset 663 512 */ 664 513 static ssize_t 665 - ice_debugfs_log_size_write(struct file *filp, const char __user *buf, 666 - size_t count, loff_t *ppos) 514 + libie_debugfs_log_size_write(struct file *filp, const char __user *buf, 515 + size_t count, loff_t *ppos) 667 516 { 668 - struct ice_fwlog *fwlog = filp->private_data; 517 + struct libie_fwlog *fwlog = filp->private_data; 669 518 struct device *dev = &fwlog->pdev->dev; 670 519 char user_val[8], *cmd_buf; 671 520 ssize_t ret; ··· 683 532 if (ret != 1) 684 533 return -EINVAL; 685 534 686 - index = sysfs_match_string(ice_fwlog_log_size, user_val); 535 + index = sysfs_match_string(libie_fwlog_log_size, user_val); 687 536 if (index < 0) { 688 537 dev_info(dev, "Invalid log size '%s'. The value must be one of 128K, 256K, 512K, 1M, 2M\n", 689 538 user_val); 690 539 ret = -EINVAL; 691 540 goto log_size_write_error; 692 - } else if (fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED) { 541 + } else if (fwlog->cfg.options & LIBIE_FWLOG_OPTION_IS_REGISTERED) { 693 542 dev_info(dev, "FW logging is currently running. Please disable FW logging to change log_size\n"); 694 543 ret = -EINVAL; 695 544 goto log_size_write_error; 696 545 } 697 546 698 547 /* free all the buffers and the tracking info and resize */ 699 - ice_fwlog_realloc_rings(fwlog, index); 548 + libie_fwlog_realloc_rings(fwlog, index); 700 549 701 550 /* if we get here, nothing went wrong; return count since we didn't 702 551 * really write anything ··· 714 563 return ret; 715 564 } 716 565 717 - static const struct file_operations ice_debugfs_log_size_fops = { 566 + static const struct file_operations libie_debugfs_log_size_fops = { 718 567 .owner = THIS_MODULE, 719 568 .open = simple_open, 720 - .read = ice_debugfs_log_size_read, 721 - .write = ice_debugfs_log_size_write, 569 + .read = libie_debugfs_log_size_read, 570 + .write = libie_debugfs_log_size_write, 722 571 }; 723 572 724 573 /** 725 - * ice_debugfs_data_read - read from 'data' file 574 + * libie_debugfs_data_read - read from 'data' file 726 575 * @filp: the opened file 727 576 * @buffer: where to write the data for the user to read 728 577 * @count: the size of the user's buffer 729 578 * @ppos: file position offset 730 579 */ 731 - static ssize_t ice_debugfs_data_read(struct file *filp, char __user *buffer, 732 - size_t count, loff_t *ppos) 580 + static ssize_t libie_debugfs_data_read(struct file *filp, char __user *buffer, 581 + size_t count, loff_t *ppos) 733 582 { 734 - struct ice_fwlog *fwlog = filp->private_data; 583 + struct libie_fwlog *fwlog = filp->private_data; 735 584 int data_copied = 0; 736 585 bool done = false; 737 586 738 - if (ice_fwlog_ring_empty(&fwlog->ring)) 587 + if (libie_fwlog_ring_empty(&fwlog->ring)) 739 588 return 0; 740 589 741 - while (!ice_fwlog_ring_empty(&fwlog->ring) && !done) { 742 - struct ice_fwlog_data *log; 590 + while (!libie_fwlog_ring_empty(&fwlog->ring) && !done) { 591 + struct libie_fwlog_data *log; 743 592 u16 cur_buf_len; 744 593 745 594 log = &fwlog->ring.rings[fwlog->ring.head]; ··· 761 610 buffer += cur_buf_len; 762 611 count -= cur_buf_len; 763 612 *ppos += cur_buf_len; 764 - ice_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size); 613 + libie_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size); 765 614 } 766 615 767 616 return data_copied; 768 617 } 769 618 770 619 /** 771 - * ice_debugfs_data_write - write into 'data' file 620 + * libie_debugfs_data_write - write into 'data' file 772 621 * @filp: the opened file 773 622 * @buf: where to find the user's data 774 623 * @count: the length of the user's data 775 624 * @ppos: file position offset 776 625 */ 777 626 static ssize_t 778 - ice_debugfs_data_write(struct file *filp, const char __user *buf, size_t count, 779 - loff_t *ppos) 627 + libie_debugfs_data_write(struct file *filp, const char __user *buf, size_t count, 628 + loff_t *ppos) 780 629 { 781 - struct ice_fwlog *fwlog = filp->private_data; 630 + struct libie_fwlog *fwlog = filp->private_data; 782 631 struct device *dev = &fwlog->pdev->dev; 783 632 ssize_t ret; 784 633 ··· 789 638 /* any value is allowed to clear the buffer so no need to even look at 790 639 * what the value is 791 640 */ 792 - if (!(fwlog->cfg.options & ICE_FWLOG_OPTION_IS_REGISTERED)) { 641 + if (!(fwlog->cfg.options & LIBIE_FWLOG_OPTION_IS_REGISTERED)) { 793 642 fwlog->ring.head = 0; 794 643 fwlog->ring.tail = 0; 795 644 } else { ··· 814 663 return ret; 815 664 } 816 665 817 - static const struct file_operations ice_debugfs_data_fops = { 666 + static const struct file_operations libie_debugfs_data_fops = { 818 667 .owner = THIS_MODULE, 819 668 .open = simple_open, 820 - .read = ice_debugfs_data_read, 821 - .write = ice_debugfs_data_write, 669 + .read = libie_debugfs_data_read, 670 + .write = libie_debugfs_data_write, 822 671 }; 823 672 824 673 /** 825 - * ice_debugfs_fwlog_init - setup the debugfs directory 674 + * libie_debugfs_fwlog_init - setup the debugfs directory 826 675 * @fwlog: pointer to the fwlog structure 827 676 * @root: debugfs root entry on which fwlog director will be registered 828 677 */ 829 - static void ice_debugfs_fwlog_init(struct ice_fwlog *fwlog, struct dentry *root) 678 + static void libie_debugfs_fwlog_init(struct libie_fwlog *fwlog, 679 + struct dentry *root) 830 680 { 831 681 struct dentry *fw_modules_dir; 832 682 struct dentry **fw_modules; ··· 836 684 /* allocate space for this first because if it fails then we don't 837 685 * need to unwind 838 686 */ 839 - fw_modules = kcalloc(ICE_NR_FW_LOG_MODULES, sizeof(*fw_modules), 687 + fw_modules = kcalloc(LIBIE_NR_FW_LOG_MODULES, sizeof(*fw_modules), 840 688 GFP_KERNEL); 841 689 if (!fw_modules) 842 690 return; ··· 849 697 if (IS_ERR(fw_modules_dir)) 850 698 goto err_create_module_files; 851 699 852 - for (i = 0; i < ICE_NR_FW_LOG_MODULES; i++) { 853 - fw_modules[i] = debugfs_create_file(ice_fwlog_module_string[i], 700 + for (i = 0; i < LIBIE_NR_FW_LOG_MODULES; i++) { 701 + fw_modules[i] = debugfs_create_file(libie_fwlog_module_string[i], 854 702 0600, fw_modules_dir, fwlog, 855 - &ice_debugfs_module_fops); 703 + &libie_debugfs_module_fops); 856 704 if (IS_ERR(fw_modules[i])) 857 705 goto err_create_module_files; 858 706 } 859 707 860 708 debugfs_create_file("nr_messages", 0600, fwlog->debugfs, fwlog, 861 - &ice_debugfs_nr_messages_fops); 709 + &libie_debugfs_nr_messages_fops); 862 710 863 711 fwlog->debugfs_modules = fw_modules; 864 712 865 713 debugfs_create_file("enable", 0600, fwlog->debugfs, fwlog, 866 - &ice_debugfs_enable_fops); 714 + &libie_debugfs_enable_fops); 867 715 868 716 debugfs_create_file("log_size", 0600, fwlog->debugfs, fwlog, 869 - &ice_debugfs_log_size_fops); 717 + &libie_debugfs_log_size_fops); 870 718 871 719 debugfs_create_file("data", 0600, fwlog->debugfs, fwlog, 872 - &ice_debugfs_data_fops); 720 + &libie_debugfs_data_fops); 873 721 874 722 return; 875 723 ··· 878 726 kfree(fw_modules); 879 727 } 880 728 881 - static bool ice_fwlog_ring_full(struct ice_fwlog_ring *rings) 729 + static bool libie_fwlog_ring_full(struct libie_fwlog_ring *rings) 882 730 { 883 731 u16 head, tail; 884 732 ··· 894 742 } 895 743 896 744 /** 897 - * ice_fwlog_supported - Cached for whether FW supports FW logging or not 898 - * @fwlog: pointer to the fwlog structure 899 - * 900 - * This will always return false if called before ice_init_hw(), so it must be 901 - * called after ice_init_hw(). 902 - */ 903 - static bool ice_fwlog_supported(struct ice_fwlog *fwlog) 904 - { 905 - return fwlog->supported; 906 - } 907 - 908 - /** 909 - * ice_aq_fwlog_get - Get the current firmware logging configuration (0xFF32) 745 + * libie_aq_fwlog_get - Get the current firmware logging configuration (0xFF32) 910 746 * @fwlog: pointer to the fwlog structure 911 747 * @cfg: firmware logging configuration to populate 912 748 */ 913 - static int ice_aq_fwlog_get(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg) 749 + static int libie_aq_fwlog_get(struct libie_fwlog *fwlog, 750 + struct libie_fwlog_cfg *cfg) 914 751 { 915 752 struct libie_aqc_fw_log_cfg_resp *fw_modules; 753 + struct libie_aq_desc desc = {0}; 916 754 struct libie_aqc_fw_log *cmd; 917 - struct libie_aq_desc desc; 918 755 u16 module_id_cnt; 919 756 int status; 920 757 void *buf; ··· 911 770 912 771 memset(cfg, 0, sizeof(*cfg)); 913 772 914 - buf = kzalloc(ICE_AQ_MAX_BUF_LEN, GFP_KERNEL); 773 + buf = kzalloc(LIBIE_AQ_MAX_BUF_LEN, GFP_KERNEL); 915 774 if (!buf) 916 775 return -ENOMEM; 917 776 918 - ice_fill_dflt_direct_cmd_desc(&desc, libie_aqc_opc_fw_logs_query); 777 + desc.opcode = cpu_to_le16(libie_aqc_opc_fw_logs_query); 778 + desc.flags = cpu_to_le16(LIBIE_AQ_FLAG_SI); 919 779 cmd = libie_aq_raw(&desc); 920 780 921 781 cmd->cmd_flags = LIBIE_AQC_FW_LOG_AQ_QUERY; 922 782 923 - status = fwlog->send_cmd(fwlog->priv, &desc, buf, ICE_AQ_MAX_BUF_LEN); 783 + status = fwlog->send_cmd(fwlog->priv, &desc, buf, LIBIE_AQ_MAX_BUF_LEN); 924 784 if (status) { 925 785 dev_dbg(&fwlog->pdev->dev, "Failed to get FW log configuration\n"); 926 786 goto status_out; ··· 938 796 939 797 cfg->log_resolution = le16_to_cpu(cmd->ops.cfg.log_resolution); 940 798 if (cmd->cmd_flags & LIBIE_AQC_FW_LOG_CONF_AQ_EN) 941 - cfg->options |= ICE_FWLOG_OPTION_ARQ_ENA; 799 + cfg->options |= LIBIE_FWLOG_OPTION_ARQ_ENA; 942 800 if (cmd->cmd_flags & LIBIE_AQC_FW_LOG_CONF_UART_EN) 943 - cfg->options |= ICE_FWLOG_OPTION_UART_ENA; 801 + cfg->options |= LIBIE_FWLOG_OPTION_UART_ENA; 944 802 if (cmd->cmd_flags & LIBIE_AQC_FW_LOG_QUERY_REGISTERED) 945 - cfg->options |= ICE_FWLOG_OPTION_IS_REGISTERED; 803 + cfg->options |= LIBIE_FWLOG_OPTION_IS_REGISTERED; 946 804 947 805 fw_modules = (struct libie_aqc_fw_log_cfg_resp *)buf; 948 806 ··· 960 818 } 961 819 962 820 /** 963 - * ice_fwlog_set_supported - Set if FW logging is supported by FW 821 + * libie_fwlog_set_supported - Set if FW logging is supported by FW 964 822 * @fwlog: pointer to the fwlog structure 965 823 * 966 - * If FW returns success to the ice_aq_fwlog_get call then it supports FW 824 + * If FW returns success to the libie_aq_fwlog_get call then it supports FW 967 825 * logging, else it doesn't. Set the fwlog_supported flag accordingly. 968 826 * 969 827 * This function is only meant to be called during driver init to determine if 970 828 * the FW support FW logging. 971 829 */ 972 - static void ice_fwlog_set_supported(struct ice_fwlog *fwlog) 830 + static void libie_fwlog_set_supported(struct libie_fwlog *fwlog) 973 831 { 974 - struct ice_fwlog_cfg *cfg; 832 + struct libie_fwlog_cfg *cfg; 975 833 int status; 976 834 977 835 fwlog->supported = false; ··· 980 838 if (!cfg) 981 839 return; 982 840 983 - status = ice_aq_fwlog_get(fwlog, cfg); 841 + status = libie_aq_fwlog_get(fwlog, cfg); 984 842 if (status) 985 - dev_dbg(&fwlog->pdev->dev, "ice_aq_fwlog_get failed, FW logging is not supported on this version of FW, status %d\n", 843 + dev_dbg(&fwlog->pdev->dev, "libie_aq_fwlog_get failed, FW logging is not supported on this version of FW, status %d\n", 986 844 status); 987 845 else 988 846 fwlog->supported = true; ··· 991 849 } 992 850 993 851 /** 994 - * ice_fwlog_init - Initialize FW logging configuration 852 + * libie_fwlog_init - Initialize FW logging configuration 995 853 * @fwlog: pointer to the fwlog structure 996 854 * @api: api structure to init fwlog 997 855 * 998 856 * This function should be called on driver initialization during 999 - * ice_init_hw(). 857 + * libie_init_hw(). 1000 858 */ 1001 - int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api *api) 859 + int libie_fwlog_init(struct libie_fwlog *fwlog, struct libie_fwlog_api *api) 1002 860 { 1003 861 fwlog->api = *api; 1004 - ice_fwlog_set_supported(fwlog); 862 + libie_fwlog_set_supported(fwlog); 1005 863 1006 - if (ice_fwlog_supported(fwlog)) { 864 + if (libie_fwlog_supported(fwlog)) { 1007 865 int status; 1008 866 1009 867 /* read the current config from the FW and store it */ 1010 - status = ice_aq_fwlog_get(fwlog, &fwlog->cfg); 868 + status = libie_aq_fwlog_get(fwlog, &fwlog->cfg); 1011 869 if (status) 1012 870 return status; 1013 871 1014 - fwlog->ring.rings = kcalloc(ICE_FWLOG_RING_SIZE_DFLT, 872 + fwlog->ring.rings = kcalloc(LIBIE_FWLOG_RING_SIZE_DFLT, 1015 873 sizeof(*fwlog->ring.rings), 1016 874 GFP_KERNEL); 1017 875 if (!fwlog->ring.rings) { ··· 1019 877 return -ENOMEM; 1020 878 } 1021 879 1022 - fwlog->ring.size = ICE_FWLOG_RING_SIZE_DFLT; 1023 - fwlog->ring.index = ICE_FWLOG_RING_SIZE_INDEX_DFLT; 880 + fwlog->ring.size = LIBIE_FWLOG_RING_SIZE_DFLT; 881 + fwlog->ring.index = LIBIE_FWLOG_RING_SIZE_INDEX_DFLT; 1024 882 1025 - status = ice_fwlog_alloc_ring_buffs(&fwlog->ring); 883 + status = libie_fwlog_alloc_ring_buffs(&fwlog->ring); 1026 884 if (status) { 1027 885 dev_warn(&fwlog->pdev->dev, "Unable to allocate memory for FW log ring data buffers\n"); 1028 - ice_fwlog_free_ring_buffs(&fwlog->ring); 886 + libie_fwlog_free_ring_buffs(&fwlog->ring); 1029 887 kfree(fwlog->ring.rings); 1030 888 return status; 1031 889 } 1032 890 1033 - ice_debugfs_fwlog_init(fwlog, api->debugfs_root); 891 + libie_debugfs_fwlog_init(fwlog, api->debugfs_root); 1034 892 } else { 1035 893 dev_warn(&fwlog->pdev->dev, "FW logging is not supported in this NVM image. Please update the NVM to get FW log support\n"); 1036 894 } ··· 1039 897 } 1040 898 1041 899 /** 1042 - * ice_fwlog_deinit - unroll FW logging configuration 900 + * libie_fwlog_deinit - unroll FW logging configuration 1043 901 * @fwlog: pointer to the fwlog structure 1044 902 * 1045 - * This function should be called in ice_deinit_hw(). 903 + * This function should be called in libie_deinit_hw(). 1046 904 */ 1047 - void ice_fwlog_deinit(struct ice_fwlog *fwlog) 905 + void libie_fwlog_deinit(struct libie_fwlog *fwlog) 1048 906 { 1049 907 int status; 1050 908 1051 909 /* make sure FW logging is disabled to not put the FW in a weird state 1052 910 * for the next driver load 1053 911 */ 1054 - fwlog->cfg.options &= ~ICE_FWLOG_OPTION_ARQ_ENA; 1055 - status = ice_fwlog_set(fwlog, &fwlog->cfg); 912 + fwlog->cfg.options &= ~LIBIE_FWLOG_OPTION_ARQ_ENA; 913 + status = libie_fwlog_set(fwlog, &fwlog->cfg); 1056 914 if (status) 1057 915 dev_warn(&fwlog->pdev->dev, "Unable to turn off FW logging, status: %d\n", 1058 916 status); ··· 1061 919 1062 920 fwlog->debugfs_modules = NULL; 1063 921 1064 - status = ice_fwlog_unregister(fwlog); 922 + status = libie_fwlog_unregister(fwlog); 1065 923 if (status) 1066 924 dev_warn(&fwlog->pdev->dev, "Unable to unregister FW logging, status: %d\n", 1067 925 status); 1068 926 1069 927 if (fwlog->ring.rings) { 1070 - ice_fwlog_free_ring_buffs(&fwlog->ring); 928 + libie_fwlog_free_ring_buffs(&fwlog->ring); 1071 929 kfree(fwlog->ring.rings); 1072 930 } 1073 931 } 1074 932 1075 933 /** 1076 - * ice_aq_fwlog_set - Set FW logging configuration AQ command (0xFF30) 1077 - * @fwlog: pointer to the fwlog structure 1078 - * @entries: entries to configure 1079 - * @num_entries: number of @entries 1080 - * @options: options from ice_fwlog_cfg->options structure 1081 - * @log_resolution: logging resolution 1082 - */ 1083 - static int 1084 - ice_aq_fwlog_set(struct ice_fwlog *fwlog, 1085 - struct ice_fwlog_module_entry *entries, u16 num_entries, 1086 - u16 options, u16 log_resolution) 1087 - { 1088 - struct libie_aqc_fw_log_cfg_resp *fw_modules; 1089 - struct libie_aqc_fw_log *cmd; 1090 - struct libie_aq_desc desc; 1091 - int status; 1092 - int i; 1093 - 1094 - fw_modules = kcalloc(num_entries, sizeof(*fw_modules), GFP_KERNEL); 1095 - if (!fw_modules) 1096 - return -ENOMEM; 1097 - 1098 - for (i = 0; i < num_entries; i++) { 1099 - fw_modules[i].module_identifier = 1100 - cpu_to_le16(entries[i].module_id); 1101 - fw_modules[i].log_level = entries[i].log_level; 1102 - } 1103 - 1104 - ice_fill_dflt_direct_cmd_desc(&desc, libie_aqc_opc_fw_logs_config); 1105 - desc.flags |= cpu_to_le16(LIBIE_AQ_FLAG_RD); 1106 - 1107 - cmd = libie_aq_raw(&desc); 1108 - 1109 - cmd->cmd_flags = LIBIE_AQC_FW_LOG_CONF_SET_VALID; 1110 - cmd->ops.cfg.log_resolution = cpu_to_le16(log_resolution); 1111 - cmd->ops.cfg.mdl_cnt = cpu_to_le16(num_entries); 1112 - 1113 - if (options & ICE_FWLOG_OPTION_ARQ_ENA) 1114 - cmd->cmd_flags |= LIBIE_AQC_FW_LOG_CONF_AQ_EN; 1115 - if (options & ICE_FWLOG_OPTION_UART_ENA) 1116 - cmd->cmd_flags |= LIBIE_AQC_FW_LOG_CONF_UART_EN; 1117 - 1118 - status = fwlog->send_cmd(fwlog->priv, &desc, fw_modules, 1119 - sizeof(*fw_modules) * num_entries); 1120 - 1121 - kfree(fw_modules); 1122 - 1123 - return status; 1124 - } 1125 - 1126 - /** 1127 - * ice_fwlog_set - Set the firmware logging settings 1128 - * @fwlog: pointer to the fwlog structure 1129 - * @cfg: config used to set firmware logging 1130 - * 1131 - * This function should be called whenever the driver needs to set the firmware 1132 - * logging configuration. It can be called on initialization, reset, or during 1133 - * runtime. 1134 - * 1135 - * If the PF wishes to receive FW logging then it must register via 1136 - * ice_fwlog_register. Note, that ice_fwlog_register does not need to be called 1137 - * for init. 1138 - */ 1139 - int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg) 1140 - { 1141 - if (!ice_fwlog_supported(fwlog)) 1142 - return -EOPNOTSUPP; 1143 - 1144 - return ice_aq_fwlog_set(fwlog, cfg->module_entries, 1145 - LIBIE_AQC_FW_LOG_ID_MAX, cfg->options, 1146 - cfg->log_resolution); 1147 - } 1148 - 1149 - /** 1150 - * ice_aq_fwlog_register - Register PF for firmware logging events (0xFF31) 1151 - * @fwlog: pointer to the fwlog structure 1152 - * @reg: true to register and false to unregister 1153 - */ 1154 - static int ice_aq_fwlog_register(struct ice_fwlog *fwlog, bool reg) 1155 - { 1156 - struct libie_aqc_fw_log *cmd; 1157 - struct libie_aq_desc desc; 1158 - 1159 - ice_fill_dflt_direct_cmd_desc(&desc, libie_aqc_opc_fw_logs_register); 1160 - cmd = libie_aq_raw(&desc); 1161 - 1162 - if (reg) 1163 - cmd->cmd_flags = LIBIE_AQC_FW_LOG_AQ_REGISTER; 1164 - 1165 - return fwlog->send_cmd(fwlog->priv, &desc, NULL, 0); 1166 - } 1167 - 1168 - /** 1169 - * ice_fwlog_register - Register the PF for firmware logging 1170 - * @fwlog: pointer to the fwlog structure 1171 - * 1172 - * After this call the PF will start to receive firmware logging based on the 1173 - * configuration set in ice_fwlog_set. 1174 - */ 1175 - int ice_fwlog_register(struct ice_fwlog *fwlog) 1176 - { 1177 - int status; 1178 - 1179 - if (!ice_fwlog_supported(fwlog)) 1180 - return -EOPNOTSUPP; 1181 - 1182 - status = ice_aq_fwlog_register(fwlog, true); 1183 - if (status) 1184 - dev_dbg(&fwlog->pdev->dev, "Failed to register for firmware logging events over ARQ\n"); 1185 - else 1186 - fwlog->cfg.options |= ICE_FWLOG_OPTION_IS_REGISTERED; 1187 - 1188 - return status; 1189 - } 1190 - 1191 - /** 1192 - * ice_fwlog_unregister - Unregister the PF from firmware logging 1193 - * @fwlog: pointer to the fwlog structure 1194 - */ 1195 - int ice_fwlog_unregister(struct ice_fwlog *fwlog) 1196 - { 1197 - int status; 1198 - 1199 - if (!ice_fwlog_supported(fwlog)) 1200 - return -EOPNOTSUPP; 1201 - 1202 - status = ice_aq_fwlog_register(fwlog, false); 1203 - if (status) 1204 - dev_dbg(&fwlog->pdev->dev, "Failed to unregister from firmware logging events over ARQ\n"); 1205 - else 1206 - fwlog->cfg.options &= ~ICE_FWLOG_OPTION_IS_REGISTERED; 1207 - 1208 - return status; 1209 - } 1210 - 1211 - /** 1212 - * ice_get_fwlog_data - copy the FW log data from ARQ event 934 + * libie_get_fwlog_data - copy the FW log data from ARQ event 1213 935 * @fwlog: fwlog that the FW log event is associated with 1214 936 * @buf: event buffer pointer 1215 937 * @len: len of event descriptor 1216 938 */ 1217 - void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len) 939 + void libie_get_fwlog_data(struct libie_fwlog *fwlog, u8 *buf, u16 len) 1218 940 { 1219 - struct ice_fwlog_data *log; 941 + struct libie_fwlog_data *log; 1220 942 1221 943 log = &fwlog->ring.rings[fwlog->ring.tail]; 1222 944 ··· 1088 1082 log->data_size = len; 1089 1083 1090 1084 memcpy(log->data, buf, log->data_size); 1091 - ice_fwlog_ring_increment(&fwlog->ring.tail, fwlog->ring.size); 1085 + libie_fwlog_ring_increment(&fwlog->ring.tail, fwlog->ring.size); 1092 1086 1093 - if (ice_fwlog_ring_full(&fwlog->ring)) { 1087 + if (libie_fwlog_ring_full(&fwlog->ring)) { 1094 1088 /* the rings are full so bump the head to create room */ 1095 - ice_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size); 1089 + libie_fwlog_ring_increment(&fwlog->ring.head, fwlog->ring.size); 1096 1090 } 1097 1091 }
+37 -41
drivers/net/ethernet/intel/ice/ice_fwlog.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* Copyright (C) 2022, Intel Corporation. */ 3 3 4 - #ifndef _ICE_FWLOG_H_ 5 - #define _ICE_FWLOG_H_ 4 + #ifndef _LIBIE_FWLOG_H_ 5 + #define _LIBIE_FWLOG_H_ 6 6 #include "ice_adminq_cmd.h" 7 7 8 - struct ice_hw; 9 - 10 8 /* Only a single log level should be set and all log levels under the set value 11 - * are enabled, e.g. if log level is set to ICE_FW_LOG_LEVEL_VERBOSE, then all 12 - * other log levels are included (except ICE_FW_LOG_LEVEL_NONE) 9 + * are enabled, e.g. if log level is set to LIBIE_FW_LOG_LEVEL_VERBOSE, then all 10 + * other log levels are included (except LIBIE_FW_LOG_LEVEL_NONE) 13 11 */ 14 - enum ice_fwlog_level { 15 - ICE_FWLOG_LEVEL_NONE = 0, 16 - ICE_FWLOG_LEVEL_ERROR = 1, 17 - ICE_FWLOG_LEVEL_WARNING = 2, 18 - ICE_FWLOG_LEVEL_NORMAL = 3, 19 - ICE_FWLOG_LEVEL_VERBOSE = 4, 20 - ICE_FWLOG_LEVEL_INVALID, /* all values >= this entry are invalid */ 12 + enum libie_fwlog_level { 13 + LIBIE_FWLOG_LEVEL_NONE = 0, 14 + LIBIE_FWLOG_LEVEL_ERROR = 1, 15 + LIBIE_FWLOG_LEVEL_WARNING = 2, 16 + LIBIE_FWLOG_LEVEL_NORMAL = 3, 17 + LIBIE_FWLOG_LEVEL_VERBOSE = 4, 18 + LIBIE_FWLOG_LEVEL_INVALID, /* all values >= this entry are invalid */ 21 19 }; 22 20 23 - struct ice_fwlog_module_entry { 21 + struct libie_fwlog_module_entry { 24 22 /* module ID for the corresponding firmware logging event */ 25 23 u16 module_id; 26 24 /* verbosity level for the module_id */ 27 25 u8 log_level; 28 26 }; 29 27 30 - struct ice_fwlog_cfg { 28 + struct libie_fwlog_cfg { 31 29 /* list of modules for configuring log level */ 32 - struct ice_fwlog_module_entry module_entries[LIBIE_AQC_FW_LOG_ID_MAX]; 30 + struct libie_fwlog_module_entry module_entries[LIBIE_AQC_FW_LOG_ID_MAX]; 33 31 /* options used to configure firmware logging */ 34 32 u16 options; 35 - #define ICE_FWLOG_OPTION_ARQ_ENA BIT(0) 36 - #define ICE_FWLOG_OPTION_UART_ENA BIT(1) 37 - /* set before calling ice_fwlog_init() so the PF registers for firmware 38 - * logging on initialization 33 + #define LIBIE_FWLOG_OPTION_ARQ_ENA BIT(0) 34 + #define LIBIE_FWLOG_OPTION_UART_ENA BIT(1) 35 + /* set before calling libie_fwlog_init() so the PF registers for 36 + * firmware logging on initialization 39 37 */ 40 - #define ICE_FWLOG_OPTION_REGISTER_ON_INIT BIT(2) 41 - /* set in the ice_aq_fwlog_get() response if the PF is registered for FW 42 - * logging events over ARQ 38 + #define LIBIE_FWLOG_OPTION_REGISTER_ON_INIT BIT(2) 39 + /* set in the libie_aq_fwlog_get() response if the PF is registered for 40 + * FW logging events over ARQ 43 41 */ 44 - #define ICE_FWLOG_OPTION_IS_REGISTERED BIT(3) 42 + #define LIBIE_FWLOG_OPTION_IS_REGISTERED BIT(3) 45 43 46 44 /* minimum number of log events sent per Admin Receive Queue event */ 47 45 u16 log_resolution; 48 46 }; 49 47 50 - struct ice_fwlog_data { 48 + struct libie_fwlog_data { 51 49 u16 data_size; 52 50 u8 *data; 53 51 }; 54 52 55 - struct ice_fwlog_ring { 56 - struct ice_fwlog_data *rings; 53 + struct libie_fwlog_ring { 54 + struct libie_fwlog_data *rings; 57 55 u16 index; 58 56 u16 size; 59 57 u16 head; 60 58 u16 tail; 61 59 }; 62 60 63 - #define ICE_FWLOG_RING_SIZE_INDEX_DFLT 3 64 - #define ICE_FWLOG_RING_SIZE_DFLT 256 65 - #define ICE_FWLOG_RING_SIZE_MAX 512 61 + #define LIBIE_FWLOG_RING_SIZE_INDEX_DFLT 3 62 + #define LIBIE_FWLOG_RING_SIZE_DFLT 256 63 + #define LIBIE_FWLOG_RING_SIZE_MAX 512 66 64 67 - struct ice_fwlog { 68 - struct ice_fwlog_cfg cfg; 65 + struct libie_fwlog { 66 + struct libie_fwlog_cfg cfg; 69 67 bool supported; /* does hardware support FW logging? */ 70 - struct ice_fwlog_ring ring; 68 + struct libie_fwlog_ring ring; 71 69 struct dentry *debugfs; 72 70 /* keep track of all the dentrys for FW log modules */ 73 71 struct dentry **debugfs_modules; 74 - struct_group_tagged(ice_fwlog_api, api, 72 + struct_group_tagged(libie_fwlog_api, api, 75 73 struct pci_dev *pdev; 76 74 int (*send_cmd)(void *, struct libie_aq_desc *, void *, u16); 77 75 void *priv; ··· 77 79 ); 78 80 }; 79 81 80 - int ice_fwlog_init(struct ice_fwlog *fwlog, struct ice_fwlog_api *api); 81 - void ice_fwlog_deinit(struct ice_fwlog *fwlog); 82 - int ice_fwlog_set(struct ice_fwlog *fwlog, struct ice_fwlog_cfg *cfg); 83 - int ice_fwlog_register(struct ice_fwlog *fwlog); 84 - int ice_fwlog_unregister(struct ice_fwlog *fwlog); 85 - void ice_get_fwlog_data(struct ice_fwlog *fwlog, u8 *buf, u16 len); 86 - #endif /* _ICE_FWLOG_H_ */ 82 + int libie_fwlog_init(struct libie_fwlog *fwlog, struct libie_fwlog_api *api); 83 + void libie_fwlog_deinit(struct libie_fwlog *fwlog); 84 + int libie_fwlog_register(struct libie_fwlog *fwlog); 85 + void libie_get_fwlog_data(struct libie_fwlog *fwlog, u8 *buf, u16 len); 86 + #endif /* _LIBIE_FWLOG_H_ */
+2 -2
drivers/net/ethernet/intel/ice/ice_main.c
··· 1540 1540 } 1541 1541 break; 1542 1542 case ice_aqc_opc_fw_logs_event: 1543 - ice_get_fwlog_data(&hw->fwlog, event.msg_buf, 1544 - le16_to_cpu(event.desc.datalen)); 1543 + libie_get_fwlog_data(&hw->fwlog, event.msg_buf, 1544 + le16_to_cpu(event.desc.datalen)); 1545 1545 break; 1546 1546 case ice_aqc_opc_lldp_set_mib_change: 1547 1547 ice_dcb_process_lldp_set_mib_change(pf, &event);
+1 -1
drivers/net/ethernet/intel/ice/ice_type.h
··· 948 948 u8 fw_patch; /* firmware patch version */ 949 949 u32 fw_build; /* firmware build number */ 950 950 951 - struct ice_fwlog fwlog; 951 + struct libie_fwlog fwlog; 952 952 953 953 /* Device max aggregate bandwidths corresponding to the GL_PWR_MODE_CTL 954 954 * register. Used for determining the ITR/INTRL granularity during
+1
include/linux/net/intel/libie/adminq.h
··· 9 9 10 10 #define LIBIE_CHECK_STRUCT_LEN(n, X) \ 11 11 static_assert((n) == sizeof(struct X)) 12 + #define LIBIE_AQ_MAX_BUF_LEN 4096 12 13 13 14 /** 14 15 * struct libie_aqc_generic - Generic structure used in adminq communication