devlink.c (a0f45672d5e14af053d2dc5f552381351f6eeac0) | devlink.c (c9e563cae19e529abcc2cb90b4b793952f209260) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2025, Intel Corporation. */ 3 4#include "ixgbe.h" 5#include "devlink.h" 6#include "ixgbe_fw_update.h" 7 8struct ixgbe_info_ctx { --- 308 unchanged lines hidden (view full) --- 317 struct ixgbe_hw *hw = &adapter->hw; 318 struct ixgbe_info_ctx *ctx; 319 int err; 320 321 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); 322 if (!ctx) 323 return -ENOMEM; 324 | 1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2025, Intel Corporation. */ 3 4#include "ixgbe.h" 5#include "devlink.h" 6#include "ixgbe_fw_update.h" 7 8struct ixgbe_info_ctx { --- 308 unchanged lines hidden (view full) --- 317 struct ixgbe_hw *hw = &adapter->hw; 318 struct ixgbe_info_ctx *ctx; 319 int err; 320 321 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); 322 if (!ctx) 323 return -ENOMEM; 324 |
325 if (hw->mac.type == ixgbe_mac_e610) 326 ixgbe_refresh_fw_version(adapter); 327 |
|
325 ixgbe_info_get_dsn(adapter, ctx); 326 err = devlink_info_serial_number_put(req, ctx->buf); 327 if (err) 328 goto free_ctx; 329 330 err = hw->eeprom.ops.read_pba_string(hw, ctx->buf, sizeof(ctx->buf)); 331 if (err) 332 goto free_ctx; --- 27 unchanged lines hidden (view full) --- 360 goto free_ctx; 361 362 err = ixgbe_devlink_pending_info_get_e610(adapter, req, ctx); 363free_ctx: 364 kfree(ctx); 365 return err; 366} 367 | 328 ixgbe_info_get_dsn(adapter, ctx); 329 err = devlink_info_serial_number_put(req, ctx->buf); 330 if (err) 331 goto free_ctx; 332 333 err = hw->eeprom.ops.read_pba_string(hw, ctx->buf, sizeof(ctx->buf)); 334 if (err) 335 goto free_ctx; --- 27 unchanged lines hidden (view full) --- 363 goto free_ctx; 364 365 err = ixgbe_devlink_pending_info_get_e610(adapter, req, ctx); 366free_ctx: 367 kfree(ctx); 368 return err; 369} 370 |
371/** 372 * ixgbe_devlink_reload_empr_start - Start EMP reset to activate new firmware 373 * @devlink: pointer to the devlink instance to reload 374 * @netns_change: if true, the network namespace is changing 375 * @action: the action to perform. Must be DEVLINK_RELOAD_ACTION_FW_ACTIVATE 376 * @limit: limits on what reload should do, such as not resetting 377 * @extack: netlink extended ACK structure 378 * 379 * Allow user to activate new Embedded Management Processor firmware by 380 * issuing device specific EMP reset. Called in response to 381 * a DEVLINK_CMD_RELOAD with the DEVLINK_RELOAD_ACTION_FW_ACTIVATE. 382 * 383 * Note that teardown and rebuild of the driver state happens automatically as 384 * part of an interrupt and watchdog task. This is because all physical 385 * functions on the device must be able to reset when an EMP reset occurs from 386 * any source. 387 * 388 * Return: the exit code of the operation. 389 */ 390static int ixgbe_devlink_reload_empr_start(struct devlink *devlink, 391 bool netns_change, 392 enum devlink_reload_action action, 393 enum devlink_reload_limit limit, 394 struct netlink_ext_ack *extack) 395{ 396 struct ixgbe_adapter *adapter = devlink_priv(devlink); 397 struct ixgbe_hw *hw = &adapter->hw; 398 u8 pending; 399 int err; 400 401 if (hw->mac.type != ixgbe_mac_e610) 402 return -EOPNOTSUPP; 403 404 err = ixgbe_get_pending_updates(adapter, &pending, extack); 405 if (err) 406 return err; 407 408 /* Pending is a bitmask of which flash banks have a pending update, 409 * including the main NVM bank, the Option ROM bank, and the netlist 410 * bank. If any of these bits are set, then there is a pending update 411 * waiting to be activated. 412 */ 413 if (!pending) { 414 NL_SET_ERR_MSG_MOD(extack, "No pending firmware update"); 415 return -ECANCELED; 416 } 417 418 if (adapter->fw_emp_reset_disabled) { 419 NL_SET_ERR_MSG_MOD(extack, 420 "EMP reset is not available. To activate firmware, a reboot or power cycle is needed"); 421 return -ECANCELED; 422 } 423 424 err = ixgbe_aci_nvm_update_empr(hw); 425 if (err) 426 NL_SET_ERR_MSG_MOD(extack, 427 "Failed to trigger EMP device reset to reload firmware"); 428 429 return err; 430} 431 432/*Wait for 10 sec with 0.5 sec tic. EMPR takes no less than half of a sec */ 433#define IXGBE_DEVLINK_RELOAD_TIMEOUT_SEC 20 434 435/** 436 * ixgbe_devlink_reload_empr_finish - finishes EMP reset 437 * @devlink: pointer to the devlink instance 438 * @action: the action to perform. 439 * @limit: limits on what reload should do 440 * @actions_performed: actions performed 441 * @extack: netlink extended ACK structure 442 * 443 * Wait for new NVM to be loaded during EMP reset. 444 * 445 * Return: -ETIME when timer is exceeded, 0 on success. 446 */ 447static int ixgbe_devlink_reload_empr_finish(struct devlink *devlink, 448 enum devlink_reload_action action, 449 enum devlink_reload_limit limit, 450 u32 *actions_performed, 451 struct netlink_ext_ack *extack) 452{ 453 struct ixgbe_adapter *adapter = devlink_priv(devlink); 454 struct ixgbe_hw *hw = &adapter->hw; 455 int i = 0; 456 u32 fwsm; 457 458 do { 459 /* Just right away after triggering EMP reset the FWSM register 460 * may be not cleared yet, so begin the loop with the delay 461 * in order to not check the not updated register. 462 */ 463 mdelay(500); 464 465 fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM(hw)); 466 467 if (i++ >= IXGBE_DEVLINK_RELOAD_TIMEOUT_SEC) 468 return -ETIME; 469 470 } while (!(fwsm & IXGBE_FWSM_FW_VAL_BIT)); 471 472 *actions_performed = BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE); 473 474 return 0; 475} 476 |
|
368static const struct devlink_ops ixgbe_devlink_ops = { 369 .info_get = ixgbe_devlink_info_get, 370 .supported_flash_update_params = 371 DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK, 372 .flash_update = ixgbe_flash_pldm_image, | 477static const struct devlink_ops ixgbe_devlink_ops = { 478 .info_get = ixgbe_devlink_info_get, 479 .supported_flash_update_params = 480 DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK, 481 .flash_update = ixgbe_flash_pldm_image, |
482 .reload_actions = BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE), 483 .reload_down = ixgbe_devlink_reload_empr_start, 484 .reload_up = ixgbe_devlink_reload_empr_finish, |
|
373}; 374 375/** 376 * ixgbe_allocate_devlink - Allocate devlink instance 377 * @dev: device to allocate devlink for 378 * 379 * Allocate a devlink instance for this physical function. 380 * --- 62 unchanged lines hidden --- | 485}; 486 487/** 488 * ixgbe_allocate_devlink - Allocate devlink instance 489 * @dev: device to allocate devlink for 490 * 491 * Allocate a devlink instance for this physical function. 492 * --- 62 unchanged lines hidden --- |