The enable_rdma devlink param controls whether the RDMA auxiliary device (irdma) is instantiated, but only in driverinit cmode. Changing it requires a devlink reload, which also unregisters the netdev, so its addresses, routes and other configuration are lost. Add the runtime cmode, which only unplugs or plugs the RDMA auxiliary device and leaves the netdev alone: devlink dev param set pci/0000:03:00.0 name enable_rdma \ value false cmode runtime Unlike setting both enable_roce and enable_iwarp to false, the selected RDMA protocol is kept, and the auxiliary device stays unplugged after a reset or when switching between RoCEv2 and iWARP, as ice_plug_aux_dev() checks the new ICE_FLAG_RDMA_RUNTIME_DIS. Enabling it at runtime requires it to be enabled in driverinit cmode and enable_roce or enable_iwarp to be set, and a reload resets it to the driverinit value, like for mlx5. Cc: Tony Nguyen Cc: Przemek Kitszel Cc: Tatyana Nikolova Cc: Jacob Moroni Cc: Jiri Pirko Cc: Leon Romanovsky Cc: intel-wired-lan@lists.osuosl.org Cc: netdev@vger.kernel.org Cc: linux-rdma@vger.kernel.org Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Simon Horman Cc: Willem de Bruijn Cc: Jonathan Corbet Cc: Shuah Khan Cc: Randy Dunlap Cc: Andrew Lunn Cc: linux-doc@vger.kernel.org Signed-off-by: Stefan Metzmacher --- Documentation/networking/devlink/ice.rst | 7 ++ .../net/ethernet/intel/ice/devlink/devlink.c | 66 ++++++++++++++++++- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_idc.c | 5 +- 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/Documentation/networking/devlink/ice.rst b/Documentation/networking/devlink/ice.rst index 792e9f8c846a..0db36e85e522 100644 --- a/Documentation/networking/devlink/ice.rst +++ b/Documentation/networking/devlink/ice.rst @@ -22,6 +22,13 @@ Parameters * - ``enable_iwarp`` - runtime - mutually exclusive with ``enable_roce`` + * - ``enable_rdma`` + - driverinit, runtime + - Controls whether the RDMA auxiliary device (irdma) is instantiated. + In runtime mode it is unplugged or plugged again without reloading + the PF, so the netdev and its configuration stay. Enabling it in + runtime mode requires it to be enabled in driverinit mode, and a + reload resets the runtime mode to the driverinit value. * - ``tx_scheduling_layers`` - permanent - The ice hardware uses hierarchical scheduling for Tx with a fixed diff --git a/drivers/net/ethernet/intel/ice/devlink/devlink.c b/drivers/net/ethernet/intel/ice/devlink/devlink.c index 5a69f0f8a7bc..8d816631df69 100644 --- a/drivers/net/ethernet/intel/ice/devlink/devlink.c +++ b/drivers/net/ethernet/intel/ice/devlink/devlink.c @@ -1268,6 +1268,9 @@ static int ice_devlink_reinit_up(struct ice_pf *pf) if (err) goto unroll_pf_init; + /* a reload resets enable_rdma to its driverinit value */ + clear_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags); + /* No need to take devl_lock, it's already taken by devlink API */ err = ice_load(pf); if (err) @@ -1626,6 +1629,62 @@ ice_devlink_msix_min_pf_validate(struct devlink *devlink, u32 id, return 0; } +static int ice_devlink_enable_rdma_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx, + struct netlink_ext_ack *extack) +{ + struct ice_pf *pf = devlink_priv(devlink); + + ctx->val.vbool = ice_is_rdma_ena(pf) && + !test_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags); + + return 0; +} + +/* + * In runtime cmode the RDMA auxiliary device is unplugged or plugged + * again, without reloading the PF, so the netdev and its configuration + * stay. While it is disabled, ice_plug_aux_dev() does nothing, e.g. after + * a reset or when switching between RoCEv2 and iWARP. A reload resets it + * to the value of the driverinit cmode. + */ +static int ice_devlink_enable_rdma_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx, + struct netlink_ext_ack *extack) +{ + struct ice_pf *pf = devlink_priv(devlink); + bool disable = !ctx->val.vbool; + int ret; + + if (!disable && !ice_is_rdma_ena(pf)) { + NL_SET_ERR_MSG_MOD(extack, + "RDMA is disabled in driverinit cmode, enable it there and reload"); + return -EOPNOTSUPP; + } + + if (test_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags) == disable) + return 0; + + if (disable) { + set_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags); + ice_unplug_aux_dev(pf); + return 0; + } + + if (!pf->cdev_info || !pf->cdev_info->rdma_protocol) { + NL_SET_ERR_MSG_MOD(extack, + "Neither enable_roce nor enable_iwarp is set"); + return -EOPNOTSUPP; + } + + clear_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags); + ret = ice_plug_aux_dev(pf); + if (ret) + set_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags); + + return ret; +} + static int ice_devlink_enable_rdma_validate(struct devlink *devlink, u32 id, union devlink_param_value *val, struct netlink_ext_ack *extack) @@ -1654,8 +1713,11 @@ static const struct devlink_param ice_dvl_rdma_params[] = { ice_devlink_enable_iw_get, ice_devlink_enable_iw_set, ice_devlink_enable_iw_validate), - DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), - NULL, NULL, ice_devlink_enable_rdma_validate), + DEVLINK_PARAM_GENERIC(ENABLE_RDMA, BIT(DEVLINK_PARAM_CMODE_DRIVERINIT) | + BIT(DEVLINK_PARAM_CMODE_RUNTIME), + ice_devlink_enable_rdma_get, + ice_devlink_enable_rdma_set, + ice_devlink_enable_rdma_validate), }; static const struct devlink_param ice_dvl_msix_params[] = { diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 432da05c48c0..98555265fbaa 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -526,6 +526,7 @@ enum ice_pf_flags { ICE_FLAG_GNSS, /* GNSS successfully initialized */ ICE_FLAG_DPLL, /* SyncE/PTP dplls initialized */ ICE_FLAG_LLDP_AQ_FLTR, + ICE_FLAG_RDMA_RUNTIME_DIS, /* enable_rdma disabled in runtime cmode */ ICE_PF_FLAGS_NBITS /* must be last */ }; diff --git a/drivers/net/ethernet/intel/ice/ice_idc.c b/drivers/net/ethernet/intel/ice/ice_idc.c index 102d63c3018b..01a14b9f8f6a 100644 --- a/drivers/net/ethernet/intel/ice/ice_idc.c +++ b/drivers/net/ethernet/intel/ice/ice_idc.c @@ -299,9 +299,10 @@ int ice_plug_aux_dev(struct ice_pf *pf) int ret; /* if this PF doesn't support a technology that requires auxiliary - * devices, then gracefully exit + * devices, or it was disabled via enable_rdma in runtime cmode, + * then gracefully exit */ - if (!ice_is_rdma_ena(pf)) + if (!ice_is_rdma_ena(pf) || test_bit(ICE_FLAG_RDMA_RUNTIME_DIS, pf->flags)) return 0; cdev = pf->cdev_info; -- 2.43.0