Lines Matching full:bp
26 static void __bnxt_fw_recover(struct bnxt *bp) in __bnxt_fw_recover() argument
28 if (test_bit(BNXT_STATE_FW_FATAL_COND, &bp->state) || in __bnxt_fw_recover()
29 test_bit(BNXT_STATE_FW_NON_FATAL_COND, &bp->state)) in __bnxt_fw_recover()
30 bnxt_fw_reset(bp); in __bnxt_fw_recover()
32 bnxt_fw_exception(bp); in __bnxt_fw_recover()
40 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_dl_flash_update() local
43 if (!BNXT_PF(bp)) { in bnxt_dl_flash_update()
50 rc = bnxt_flash_package_from_fw_obj(bp->dev, params->fw, 0, extack); in bnxt_dl_flash_update()
58 static int bnxt_hwrm_remote_dev_reset_set(struct bnxt *bp, bool remote_reset) in bnxt_hwrm_remote_dev_reset_set() argument
63 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF) in bnxt_hwrm_remote_dev_reset_set()
66 rc = bnxt_hwrm_func_cfg_short_req_init(bp, &req); in bnxt_hwrm_remote_dev_reset_set()
75 return hwrm_req_send(bp, req); in bnxt_hwrm_remote_dev_reset_set()
105 struct bnxt *bp = devlink_health_reporter_priv(reporter); in bnxt_fw_diagnose() local
106 struct bnxt_fw_health *h = bp->fw_health; in bnxt_fw_diagnose()
109 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { in bnxt_fw_diagnose()
120 fw_status = bnxt_fw_health_readl(bp, BNXT_FW_HEALTH_REG); in bnxt_fw_diagnose()
152 fw_resets = bnxt_fw_health_readl(bp, BNXT_FW_RESET_CNT_REG); in bnxt_fw_diagnose()
166 struct bnxt *bp = devlink_health_reporter_priv(reporter); in bnxt_fw_dump() local
175 dump_len = bnxt_get_coredump_length(bp, BNXT_DUMP_LIVE); in bnxt_fw_dump()
183 rc = bnxt_get_coredump(bp, BNXT_DUMP_LIVE, data, &dump_len); in bnxt_fw_dump()
199 struct bnxt *bp = devlink_health_reporter_priv(reporter); in bnxt_fw_recover() local
201 if (bp->fw_health->severity == SEVERITY_FATAL) in bnxt_fw_recover()
204 set_bit(BNXT_STATE_RECOVER, &bp->state); in bnxt_fw_recover()
205 __bnxt_fw_recover(bp); in bnxt_fw_recover()
218 __bnxt_dl_reporter_create(struct bnxt *bp, in __bnxt_dl_reporter_create() argument
223 reporter = devlink_health_reporter_create(bp->dl, ops, 0, bp); in __bnxt_dl_reporter_create()
225 netdev_warn(bp->dev, "Failed to create %s health reporter, rc = %ld\n", in __bnxt_dl_reporter_create()
233 void bnxt_dl_fw_reporters_create(struct bnxt *bp) in bnxt_dl_fw_reporters_create() argument
235 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_dl_fw_reporters_create()
238 fw_health->fw_reporter = __bnxt_dl_reporter_create(bp, &bnxt_dl_fw_reporter_ops); in bnxt_dl_fw_reporters_create()
241 void bnxt_dl_fw_reporters_destroy(struct bnxt *bp) in bnxt_dl_fw_reporters_destroy() argument
243 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_dl_fw_reporters_destroy()
251 void bnxt_devlink_health_fw_report(struct bnxt *bp) in bnxt_devlink_health_fw_report() argument
253 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_devlink_health_fw_report()
260 __bnxt_fw_recover(bp); in bnxt_devlink_health_fw_report()
271 __bnxt_fw_recover(bp); in bnxt_devlink_health_fw_report()
274 void bnxt_dl_health_fw_status_update(struct bnxt *bp, bool healthy) in bnxt_dl_health_fw_status_update() argument
276 struct bnxt_fw_health *fw_health = bp->fw_health; in bnxt_dl_health_fw_status_update()
292 void bnxt_dl_health_fw_recovery_done(struct bnxt *bp) in bnxt_dl_health_fw_recovery_done() argument
294 struct bnxt_dl *dl = devlink_priv(bp->dl); in bnxt_dl_health_fw_recovery_done()
296 devlink_health_reporter_recovery_done(bp->fw_health->fw_reporter); in bnxt_dl_health_fw_recovery_done()
297 bnxt_hwrm_remote_dev_reset_set(bp, dl->remote_reset); in bnxt_dl_health_fw_recovery_done()
304 bnxt_dl_livepatch_report_err(struct bnxt *bp, struct netlink_ext_ack *extack, in bnxt_dl_livepatch_report_err() argument
311 netdev_err(bp->dev, "Illegal live patch opcode"); in bnxt_dl_livepatch_report_err()
337 netdev_err(bp->dev, "Unexpected live patch error: %d\n", err); in bnxt_dl_livepatch_report_err()
354 bnxt_dl_livepatch_activate(struct bnxt *bp, struct netlink_ext_ack *extack) in bnxt_dl_livepatch_activate() argument
366 if (~bp->fw_cap & BNXT_FW_CAP_LIVEPATCH) { in bnxt_dl_livepatch_activate()
371 rc = hwrm_req_init(bp, query_req, HWRM_FW_LIVEPATCH_QUERY); in bnxt_dl_livepatch_activate()
374 query_resp = hwrm_req_hold(bp, query_req); in bnxt_dl_livepatch_activate()
376 rc = hwrm_req_init(bp, patch_req, HWRM_FW_LIVEPATCH); in bnxt_dl_livepatch_activate()
378 hwrm_req_drop(bp, query_req); in bnxt_dl_livepatch_activate()
382 patch_resp = hwrm_req_hold(bp, patch_req); in bnxt_dl_livepatch_activate()
386 rc = hwrm_req_send(bp, query_req); in bnxt_dl_livepatch_activate()
409 rc = hwrm_req_send(bp, patch_req); in bnxt_dl_livepatch_activate()
411 bnxt_dl_livepatch_report_err(bp, extack, patch_resp); in bnxt_dl_livepatch_activate()
426 hwrm_req_drop(bp, query_req); in bnxt_dl_livepatch_activate()
427 hwrm_req_drop(bp, patch_req); in bnxt_dl_livepatch_activate()
436 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_dl_reload_down() local
441 bnxt_ulp_stop(bp); in bnxt_dl_reload_down()
443 netdev_lock(bp->dev); in bnxt_dl_reload_down()
444 if (bnxt_sriov_cfg(bp)) { in bnxt_dl_reload_down()
447 netdev_unlock(bp->dev); in bnxt_dl_reload_down()
449 bnxt_ulp_start(bp, 0); in bnxt_dl_reload_down()
452 if (bp->dev->reg_state == NETREG_UNREGISTERED) { in bnxt_dl_reload_down()
453 netdev_unlock(bp->dev); in bnxt_dl_reload_down()
455 bnxt_ulp_start(bp, 0); in bnxt_dl_reload_down()
458 if (netif_running(bp->dev)) in bnxt_dl_reload_down()
459 bnxt_close_nic(bp, true, true); in bnxt_dl_reload_down()
460 bnxt_vf_reps_free(bp); in bnxt_dl_reload_down()
461 rc = bnxt_hwrm_func_drv_unrgtr(bp); in bnxt_dl_reload_down()
464 if (netif_running(bp->dev)) in bnxt_dl_reload_down()
465 netif_close(bp->dev); in bnxt_dl_reload_down()
466 netdev_unlock(bp->dev); in bnxt_dl_reload_down()
470 bnxt_cancel_reservations(bp, false); in bnxt_dl_reload_down()
471 bnxt_free_ctx_mem(bp, false); in bnxt_dl_reload_down()
476 return bnxt_dl_livepatch_activate(bp, extack); in bnxt_dl_reload_down()
477 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET) { in bnxt_dl_reload_down()
481 if (!bnxt_hwrm_reset_permitted(bp)) { in bnxt_dl_reload_down()
487 netdev_lock(bp->dev); in bnxt_dl_reload_down()
488 if (bp->dev->reg_state == NETREG_UNREGISTERED) { in bnxt_dl_reload_down()
489 netdev_unlock(bp->dev); in bnxt_dl_reload_down()
493 if (netif_running(bp->dev)) in bnxt_dl_reload_down()
494 set_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); in bnxt_dl_reload_down()
495 rc = bnxt_hwrm_firmware_reset(bp->dev, in bnxt_dl_reload_down()
502 clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); in bnxt_dl_reload_down()
503 netdev_unlock(bp->dev); in bnxt_dl_reload_down()
519 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_dl_reload_up() local
522 netdev_assert_locked(bp->dev); in bnxt_dl_reload_up()
527 bnxt_fw_init_one(bp); in bnxt_dl_reload_up()
528 bnxt_vf_reps_alloc(bp); in bnxt_dl_reload_up()
529 if (netif_running(bp->dev)) in bnxt_dl_reload_up()
530 rc = bnxt_open_nic(bp, true, true); in bnxt_dl_reload_up()
532 bnxt_reenable_sriov(bp); in bnxt_dl_reload_up()
533 bnxt_ptp_reapply_pps(bp); in bnxt_dl_reload_up()
543 if (bp->fw_cap & BNXT_FW_CAP_ERROR_RECOVERY) in bnxt_dl_reload_up()
544 timeout = start + bp->fw_health->normal_func_wait_dsecs * HZ / 10; in bnxt_dl_reload_up()
545 if (!netif_running(bp->dev)) in bnxt_dl_reload_up()
548 netdev_unlock(bp->dev); in bnxt_dl_reload_up()
550 while (test_bit(BNXT_STATE_FW_ACTIVATE, &bp->state)) { in bnxt_dl_reload_up()
556 if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state)) { in bnxt_dl_reload_up()
564 netdev_lock(bp->dev); in bnxt_dl_reload_up()
567 clear_bit(BNXT_STATE_FW_ACTIVATE, &bp->state); in bnxt_dl_reload_up()
575 bnxt_print_device_info(bp); in bnxt_dl_reload_up()
576 if (netif_running(bp->dev)) { in bnxt_dl_reload_up()
577 mutex_lock(&bp->link_lock); in bnxt_dl_reload_up()
578 bnxt_report_link(bp); in bnxt_dl_reload_up()
579 mutex_unlock(&bp->link_lock); in bnxt_dl_reload_up()
582 } else if (netif_running(bp->dev)) { in bnxt_dl_reload_up()
583 netif_close(bp->dev); in bnxt_dl_reload_up()
585 netdev_unlock(bp->dev); in bnxt_dl_reload_up()
588 bnxt_ulp_start(bp, rc); in bnxt_dl_reload_up()
592 static bool bnxt_nvm_test(struct bnxt *bp, struct netlink_ext_ack *extack) in bnxt_nvm_test() argument
599 if (bnxt_find_nvram_item(bp->dev, BNX_DIR_TYPE_VPD, in bnxt_nvm_test()
612 if (bnxt_get_nvram_item(bp->dev, index, 0, datalen, buf)) { in bnxt_nvm_test()
617 if (bnxt_flash_nvram(bp->dev, BNX_DIR_TYPE_VPD, BNX_DIR_ORDINAL_FIRST, in bnxt_nvm_test()
640 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_dl_selftest_run() local
643 return bnxt_nvm_test(bp, extack) ? in bnxt_dl_selftest_run()
731 static int bnxt_hwrm_get_nvm_cfg_ver(struct bnxt *bp, u32 *nvm_cfg_ver) in bnxt_hwrm_get_nvm_cfg_ver() argument
742 rc = hwrm_req_init(bp, req, HWRM_NVM_GET_VARIABLE); in bnxt_hwrm_get_nvm_cfg_ver()
746 data = hwrm_req_dma_slice(bp, req, sizeof(*data), &data_dma_addr); in bnxt_hwrm_get_nvm_cfg_ver()
753 if (!BNXT_CHIP_P5_PLUS(bp)) { in bnxt_hwrm_get_nvm_cfg_ver()
760 hwrm_req_hold(bp, req); in bnxt_hwrm_get_nvm_cfg_ver()
768 rc = hwrm_req_send_silent(bp, req); in bnxt_hwrm_get_nvm_cfg_ver()
773 if (BNXT_CHIP_P5_PLUS(bp)) { in bnxt_hwrm_get_nvm_cfg_ver()
782 hwrm_req_drop(bp, req); in bnxt_hwrm_get_nvm_cfg_ver()
786 static int bnxt_dl_info_put(struct bnxt *bp, struct devlink_info_req *req, in bnxt_dl_info_put() argument
793 if ((bp->flags & BNXT_FLAG_CHIP_P5_PLUS) && in bnxt_dl_info_put()
812 static int bnxt_dl_livepatch_info_put(struct bnxt *bp, in bnxt_dl_livepatch_info_put() argument
821 if (~bp->fw_cap & BNXT_FW_CAP_LIVEPATCH) in bnxt_dl_livepatch_info_put()
824 rc = hwrm_req_init(bp, query, HWRM_FW_LIVEPATCH_QUERY); in bnxt_dl_livepatch_info_put()
835 resp = hwrm_req_hold(bp, query); in bnxt_dl_livepatch_info_put()
836 rc = hwrm_req_send(bp, query); in bnxt_dl_livepatch_info_put()
856 hwrm_req_drop(bp, query); in bnxt_dl_livepatch_info_put()
866 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_dl_info_get() local
875 if (BNXT_PF(bp) && (bp->flags & BNXT_FLAG_DSN_VALID)) { in bnxt_dl_info_get()
877 bp->dsn[7], bp->dsn[6], bp->dsn[5], bp->dsn[4], in bnxt_dl_info_get()
878 bp->dsn[3], bp->dsn[2], bp->dsn[1], bp->dsn[0]); in bnxt_dl_info_get()
884 if (strlen(bp->board_serialno)) { in bnxt_dl_info_get()
885 rc = devlink_info_board_serial_number_put(req, bp->board_serialno); in bnxt_dl_info_get()
890 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_FIXED, in bnxt_dl_info_get()
892 bp->board_partno); in bnxt_dl_info_get()
896 sprintf(buf, "%X", bp->chip_num); in bnxt_dl_info_get()
897 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_FIXED, in bnxt_dl_info_get()
902 ver_resp = &bp->ver_resp; in bnxt_dl_info_get()
904 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_FIXED, in bnxt_dl_info_get()
909 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, in bnxt_dl_info_get()
911 bp->nvm_cfg_ver); in bnxt_dl_info_get()
917 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, in bnxt_dl_info_get()
922 if (BNXT_PF(bp) && !bnxt_hwrm_get_nvm_cfg_ver(bp, &ver)) { in bnxt_dl_info_get()
925 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, in bnxt_dl_info_get()
957 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, in bnxt_dl_info_get()
962 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, in bnxt_dl_info_get()
964 bp->hwrm_ver_supp); in bnxt_dl_info_get()
968 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, in bnxt_dl_info_get()
973 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_RUNNING, in bnxt_dl_info_get()
978 rc = bnxt_hwrm_nvm_get_dev_info(bp, &nvm_dev_info); in bnxt_dl_info_get()
981 if (!bnxt_get_pkginfo(bp->dev, buf, sizeof(buf))) in bnxt_dl_info_get()
982 return bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, in bnxt_dl_info_get()
990 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, in bnxt_dl_info_get()
998 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, in bnxt_dl_info_get()
1006 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, in bnxt_dl_info_get()
1014 rc = bnxt_dl_info_put(bp, req, BNXT_VERSION_STORED, in bnxt_dl_info_get()
1019 if (BNXT_CHIP_P5_PLUS(bp)) { in bnxt_dl_info_get()
1020 rc = bnxt_dl_livepatch_info_put(bp, req, BNXT_FW_SRT_PATCH); in bnxt_dl_info_get()
1024 return bnxt_dl_livepatch_info_put(bp, req, BNXT_FW_CRT_PATCH); in bnxt_dl_info_get()
1028 static int __bnxt_hwrm_nvm_req(struct bnxt *bp, in __bnxt_hwrm_nvm_req() argument
1039 idx = bp->pf.port_id; in __bnxt_hwrm_nvm_req()
1041 idx = bp->pf.fw_fid - BNXT_FIRST_PF_FID; in __bnxt_hwrm_nvm_req()
1043 data = hwrm_req_dma_slice(bp, req, sizeof(*data), &data_dma_addr); in __bnxt_hwrm_nvm_req()
1046 hwrm_req_drop(bp, req); in __bnxt_hwrm_nvm_req()
1057 resp = hwrm_req_hold(bp, req); in __bnxt_hwrm_nvm_req()
1061 rc = hwrm_req_send(bp, msg); in __bnxt_hwrm_nvm_req()
1063 rc = hwrm_req_send_silent(bp, msg); in __bnxt_hwrm_nvm_req()
1074 hwrm_req_drop(bp, req); in __bnxt_hwrm_nvm_req()
1076 netdev_err(bp->dev, "PF does not have admin privileges to modify NVM config\n"); in __bnxt_hwrm_nvm_req()
1080 static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg, in bnxt_hwrm_nvm_req() argument
1088 if (BNXT_VF(bp)) { in bnxt_hwrm_nvm_req()
1089 hwrm_req_drop(bp, req); in bnxt_hwrm_nvm_req()
1096 return __bnxt_hwrm_nvm_req(bp, nvm_param, msg, val); in bnxt_hwrm_nvm_req()
1104 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_dl_nvm_param_get() local
1108 rc = hwrm_req_init(bp, req, HWRM_NVM_GET_VARIABLE); in bnxt_dl_nvm_param_get()
1112 rc = bnxt_hwrm_nvm_req(bp, id, req, &ctx->val); in bnxt_dl_nvm_param_get()
1123 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_dl_nvm_param_set() local
1127 rc = hwrm_req_init(bp, req, HWRM_NVM_SET_VARIABLE); in bnxt_dl_nvm_param_set()
1134 return bnxt_hwrm_nvm_req(bp, id, req, &ctx->val); in bnxt_dl_nvm_param_set()
1143 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_dl_roce_validate() local
1148 rc = hwrm_req_init(bp, req, HWRM_NVM_GET_VARIABLE); in bnxt_dl_roce_validate()
1152 if (__bnxt_hwrm_nvm_req(bp, &nvm_roce_cap, req, &roce_cap)) { in bnxt_dl_roce_validate()
1186 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_remote_dev_reset_get() local
1188 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF) in bnxt_remote_dev_reset_get()
1199 struct bnxt *bp = bnxt_get_bp_from_dl(dl); in bnxt_remote_dev_reset_set() local
1202 rc = bnxt_hwrm_remote_dev_reset_set(bp, ctx->val.vbool); in bnxt_remote_dev_reset_set()
1243 static int bnxt_dl_params_register(struct bnxt *bp) in bnxt_dl_params_register() argument
1248 if (bp->hwrm_spec_code < 0x10600) in bnxt_dl_params_register()
1251 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF) in bnxt_dl_params_register()
1254 rc = devlink_params_register(bp->dl, bnxt_dl_params, num_params); in bnxt_dl_params_register()
1256 netdev_warn(bp->dev, "devlink_params_register failed. rc=%d\n", in bnxt_dl_params_register()
1261 static void bnxt_dl_params_unregister(struct bnxt *bp) in bnxt_dl_params_unregister() argument
1265 if (bp->hwrm_spec_code < 0x10600) in bnxt_dl_params_unregister()
1268 if (~bp->fw_cap & BNXT_FW_CAP_HOT_RESET_IF) in bnxt_dl_params_unregister()
1271 devlink_params_unregister(bp->dl, bnxt_dl_params, num_params); in bnxt_dl_params_unregister()
1274 int bnxt_dl_register(struct bnxt *bp) in bnxt_dl_register() argument
1282 if (BNXT_PF(bp)) in bnxt_dl_register()
1287 dl = devlink_alloc(devlink_ops, sizeof(struct bnxt_dl), &bp->pdev->dev); in bnxt_dl_register()
1289 netdev_warn(bp->dev, "devlink_alloc failed\n"); in bnxt_dl_register()
1293 bp->dl = dl; in bnxt_dl_register()
1295 bp_dl->bp = bp; in bnxt_dl_register()
1299 if (pci_find_ext_capability(bp->pdev, PCI_EXT_CAP_ID_SRIOV) && in bnxt_dl_register()
1300 bp->hwrm_spec_code > 0x10803) in bnxt_dl_register()
1301 bp->eswitch_mode = DEVLINK_ESWITCH_MODE_LEGACY; in bnxt_dl_register()
1303 if (!BNXT_PF(bp)) in bnxt_dl_register()
1307 attrs.phys.port_number = bp->pf.port_id; in bnxt_dl_register()
1308 memcpy(attrs.switch_id.id, bp->dsn, sizeof(bp->dsn)); in bnxt_dl_register()
1309 attrs.switch_id.id_len = sizeof(bp->dsn); in bnxt_dl_register()
1310 devlink_port_attrs_set(&bp->dl_port, &attrs); in bnxt_dl_register()
1311 rc = devlink_port_register(dl, &bp->dl_port, bp->pf.port_id); in bnxt_dl_register()
1313 netdev_err(bp->dev, "devlink_port_register failed\n"); in bnxt_dl_register()
1317 rc = bnxt_dl_params_register(bp); in bnxt_dl_register()
1326 devlink_port_unregister(&bp->dl_port); in bnxt_dl_register()
1332 void bnxt_dl_unregister(struct bnxt *bp) in bnxt_dl_unregister() argument
1334 struct devlink *dl = bp->dl; in bnxt_dl_unregister()
1337 if (BNXT_PF(bp)) { in bnxt_dl_unregister()
1338 bnxt_dl_params_unregister(bp); in bnxt_dl_unregister()
1339 devlink_port_unregister(&bp->dl_port); in bnxt_dl_unregister()