|
16 | 16 | #include "bnxt_vfr.h" |
17 | 17 | #include "bnxt_devlink.h" |
18 | 18 | #include "bnxt_ethtool.h" |
| 19 | +#include "bnxt_ulp.h" |
| 20 | +#include "bnxt_ptp.h" |
19 | 21 |
|
20 | 22 | static int |
21 | 23 | bnxt_dl_flash_update(struct devlink *dl, |
@@ -280,13 +282,108 @@ void bnxt_dl_health_recovery_done(struct bnxt *bp) |
280 | 282 | static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req, |
281 | 283 | struct netlink_ext_ack *extack); |
282 | 284 |
|
| 285 | +static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change, |
| 286 | + enum devlink_reload_action action, |
| 287 | + enum devlink_reload_limit limit, |
| 288 | + struct netlink_ext_ack *extack) |
| 289 | +{ |
| 290 | + struct bnxt *bp = bnxt_get_bp_from_dl(dl); |
| 291 | + int rc = 0; |
| 292 | + |
| 293 | + switch (action) { |
| 294 | + case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: { |
| 295 | + if (BNXT_PF(bp) && bp->pf.active_vfs) { |
| 296 | + NL_SET_ERR_MSG_MOD(extack, |
| 297 | + "reload is unsupported when VFs are allocated\n"); |
| 298 | + return -EOPNOTSUPP; |
| 299 | + } |
| 300 | + rtnl_lock(); |
| 301 | + if (bp->dev->reg_state == NETREG_UNREGISTERED) { |
| 302 | + rtnl_unlock(); |
| 303 | + return -ENODEV; |
| 304 | + } |
| 305 | + bnxt_ulp_stop(bp); |
| 306 | + if (netif_running(bp->dev)) { |
| 307 | + rc = bnxt_close_nic(bp, true, true); |
| 308 | + if (rc) { |
| 309 | + NL_SET_ERR_MSG_MOD(extack, "Failed to close"); |
| 310 | + dev_close(bp->dev); |
| 311 | + rtnl_unlock(); |
| 312 | + break; |
| 313 | + } |
| 314 | + } |
| 315 | + bnxt_vf_reps_free(bp); |
| 316 | + rc = bnxt_hwrm_func_drv_unrgtr(bp); |
| 317 | + if (rc) { |
| 318 | + NL_SET_ERR_MSG_MOD(extack, "Failed to deregister"); |
| 319 | + if (netif_running(bp->dev)) |
| 320 | + dev_close(bp->dev); |
| 321 | + rtnl_unlock(); |
| 322 | + break; |
| 323 | + } |
| 324 | + bnxt_cancel_reservations(bp, false); |
| 325 | + bnxt_free_ctx_mem(bp); |
| 326 | + kfree(bp->ctx); |
| 327 | + bp->ctx = NULL; |
| 328 | + break; |
| 329 | + } |
| 330 | + default: |
| 331 | + rc = -EOPNOTSUPP; |
| 332 | + } |
| 333 | + |
| 334 | + return rc; |
| 335 | +} |
| 336 | + |
| 337 | +static int bnxt_dl_reload_up(struct devlink *dl, enum devlink_reload_action action, |
| 338 | + enum devlink_reload_limit limit, u32 *actions_performed, |
| 339 | + struct netlink_ext_ack *extack) |
| 340 | +{ |
| 341 | + struct bnxt *bp = bnxt_get_bp_from_dl(dl); |
| 342 | + int rc = 0; |
| 343 | + |
| 344 | + *actions_performed = 0; |
| 345 | + switch (action) { |
| 346 | + case DEVLINK_RELOAD_ACTION_DRIVER_REINIT: { |
| 347 | + bnxt_fw_init_one(bp); |
| 348 | + bnxt_vf_reps_alloc(bp); |
| 349 | + if (netif_running(bp->dev)) |
| 350 | + rc = bnxt_open_nic(bp, true, true); |
| 351 | + bnxt_ulp_start(bp, rc); |
| 352 | + if (!rc) { |
| 353 | + bnxt_reenable_sriov(bp); |
| 354 | + bnxt_ptp_reapply_pps(bp); |
| 355 | + } |
| 356 | + break; |
| 357 | + } |
| 358 | + default: |
| 359 | + return -EOPNOTSUPP; |
| 360 | + } |
| 361 | + |
| 362 | + if (!rc) { |
| 363 | + bnxt_print_device_info(bp); |
| 364 | + if (netif_running(bp->dev)) { |
| 365 | + mutex_lock(&bp->link_lock); |
| 366 | + bnxt_report_link(bp); |
| 367 | + mutex_unlock(&bp->link_lock); |
| 368 | + } |
| 369 | + *actions_performed |= BIT(action); |
| 370 | + } else if (netif_running(bp->dev)) { |
| 371 | + dev_close(bp->dev); |
| 372 | + } |
| 373 | + rtnl_unlock(); |
| 374 | + return rc; |
| 375 | +} |
| 376 | + |
283 | 377 | static const struct devlink_ops bnxt_dl_ops = { |
284 | 378 | #ifdef CONFIG_BNXT_SRIOV |
285 | 379 | .eswitch_mode_set = bnxt_dl_eswitch_mode_set, |
286 | 380 | .eswitch_mode_get = bnxt_dl_eswitch_mode_get, |
287 | 381 | #endif /* CONFIG_BNXT_SRIOV */ |
288 | 382 | .info_get = bnxt_dl_info_get, |
289 | 383 | .flash_update = bnxt_dl_flash_update, |
| 384 | + .reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT), |
| 385 | + .reload_down = bnxt_dl_reload_down, |
| 386 | + .reload_up = bnxt_dl_reload_up, |
290 | 387 | }; |
291 | 388 |
|
292 | 389 | static const struct devlink_ops bnxt_vf_dl_ops; |
|
0 commit comments