Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp700297imm; Wed, 4 Jul 2018 04:33:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcCvTcbMN3YdOzJ9Rti+0ZTqT14Szr6h1WNI2WklGrYQ68zu9kj90Kom3aSv1D48dZF0a7R X-Received: by 2002:a62:11c4:: with SMTP id 65-v6mr1827341pfr.54.1530704004842; Wed, 04 Jul 2018 04:33:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530704004; cv=none; d=google.com; s=arc-20160816; b=mbF7APCLoyDJyIcre5O69oKK7+8oPqlN45U/LVAR6DbCnnsap5qL+Ql539CFu8Z6sH WwO1e2A2ubRb3mMuaI1nlglLAoRv7ppVFS4dGT7xyr8oOV2JYu9DrJ3KqnT/U1VdWU4j ffJzzs3oA5ixqOHbxsKT/40PvpnmN/GiGpIrv8z07BqOoEGiUOEAUyYgaqvcEyAzywh/ fZSne/25V3aXCahy4fpdfeM0HUewYzNYXPZ+msxF4i/qoUTozyMgDHXTRQbDeduqNGJy V8mCPRCowIcxVzrfrEJvojcxkX5+XaEVlJQW9Vchw5S/RUz+a9eXxvcPUSWiu3g74jt4 qfDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Z5Yb0nWkEaX7lDi/RyJCpNKz45ge++MngKONeHguP88=; b=0i/7ahtT0v6F9YwJLxrfciMDIs2s5rD/BC7iZVZhy0GAlH1xAzAbqCTjtLDDtEWYvU 9mohDexQ5ijakIz1ZQJE4sG9TuPpxmB/YppC2axhAfU8viyOEI2WVqfymQnZgsvF+jKo CMKs37KS+dn5k9OG4KnkXLh0opQDK/3/TNEIwf5o/4A/G+QoQ4vU+XmzCqkO88LKdOfh ei3/yRTCcJK+bTz4agUIJl979LJ6wvVyWxiNncoLRFVLENP1uXaWUjbpqA+7s30kcMWF AW4i5DMyvWdl+e+/DiTpZxHA0qI+ycLtZ8Pt2mic3/+12o/wdwqg1gIHa54SGAlRecsX Tskg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si1606163pgl.267.2018.07.04.04.33.10; Wed, 04 Jul 2018 04:33:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933699AbeGDLcA (ORCPT + 99 others); Wed, 4 Jul 2018 07:32:00 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:46025 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934162AbeGDLbY (ORCPT ); Wed, 4 Jul 2018 07:31:24 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with ESMTPS (AES256-SHA encrypted); 4 Jul 2018 14:34:09 +0300 Received: from dev-l-vrt-136.mtl.labs.mlnx (dev-l-vrt-136.mtl.labs.mlnx [10.134.136.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w64BVJTH031389; Wed, 4 Jul 2018 14:31:19 +0300 Received: from dev-l-vrt-136.mtl.labs.mlnx (localhost [127.0.0.1]) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id w64BVJUa024654; Wed, 4 Jul 2018 14:31:19 +0300 Received: (from moshe@localhost) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id w64BVJu3024653; Wed, 4 Jul 2018 14:31:19 +0300 From: Moshe Shemesh To: "David S. Miller" Cc: Vasundhara Volam , Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Moshe Shemesh Subject: [PATCH net-next 07/10] mlx4: Add mlx4 initial parameters table and register it Date: Wed, 4 Jul 2018 14:30:34 +0300 Message-Id: <1530703837-24563-8-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1530703837-24563-1-git-send-email-moshe@mellanox.com> References: <1530703837-24563-1-git-send-email-moshe@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Create initial parameters table for mlx4. The table consists of two generic parameters and two driver-specific parameters. Generic: internal_err_reset - Enable reset device on internal errors. This parameter can be configured on mlx4 either on runtime or during driver initialization. max_macs - Max number of MACs per ETH port. For mlx4 this parameter value range is between 1 and 128. This parameter can be configured on mlx4 only during driver initialization. Driver specific: enable_64b_cqe_eqe - Enable 64 byte CQEs/EQEs when the FW supports it. This parameter can be configured on mlx4 only during driver initialization. enable_4k_uar - Enable using 4K UAR. This parameter can be configured on mlx4 only during driver initialization. Register the parameters table on mlx4_init_one() and unregister on mlx4_remove_one(). Signed-off-by: Moshe Shemesh Signed-off-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlx4/main.c | 108 +++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 8720147..2445f79 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c @@ -177,6 +177,101 @@ struct mlx4_port_config { static atomic_t pf_loading = ATOMIC_INIT(0); +static int mlx4_devlink_ierr_reset_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + ctx->val.vbool = !!mlx4_internal_err_reset; + return 0; +} + +static int mlx4_devlink_ierr_reset_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + mlx4_internal_err_reset = ctx->val.vbool; + return 0; +} + +static int +mlx4_devlink_max_macs_validate(struct devlink *devlink, u32 id, + union devlink_param_value val, + struct netlink_ext_ack *extack) +{ + u32 value = val.vu32; + + if (value < 1 || value > 128) + return -ERANGE; + + if (!is_power_of_2(value)) { + NL_SET_ERR_MSG_MOD(extack, "max_macs supported must be power of 2"); + return -EINVAL; + } + + return 0; +} + +enum mlx4_devlink_param_id { + MLX4_DEVLINK_PARAM_ID_BASE = DEVLINK_PARAM_GENERIC_ID_MAX, + MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE, + MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR, +}; + +static const struct devlink_param mlx4_devlink_params[] = { + DEVLINK_PARAM_GENERIC(INT_ERR_RESET, + BIT(DEVLINK_PARAM_CMODE_RUNTIME) | + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), + mlx4_devlink_ierr_reset_get, + mlx4_devlink_ierr_reset_set, NULL), + DEVLINK_PARAM_GENERIC(MAX_MACS, + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), + NULL, NULL, mlx4_devlink_max_macs_validate), + DEVLINK_PARAM_DRIVER(MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE, + "enable_64b_cqe_eqe", DEVLINK_PARAM_TYPE_BOOL, + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), + NULL, NULL, NULL), + DEVLINK_PARAM_DRIVER(MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR, + "enable_4k_uar", DEVLINK_PARAM_TYPE_BOOL, + BIT(DEVLINK_PARAM_CMODE_DRIVERINIT), + NULL, NULL, NULL), +}; + +static void mlx4_devlink_set_init_value(struct devlink *devlink, u32 param_id, + union devlink_param_value init_val) +{ + struct mlx4_priv *priv = devlink_priv(devlink); + struct mlx4_dev *dev = &priv->dev; + int err; + + err = devlink_param_driverinit_value_set(devlink, param_id, init_val); + if (err) + mlx4_warn(dev, + "devlink set parameter %u value failed (err = %d)", + param_id, err); +} + +static void mlx4_devlink_set_params_init_values(struct devlink *devlink) +{ + union devlink_param_value value; + + value.vbool = !!mlx4_internal_err_reset; + mlx4_devlink_set_init_value(devlink, + DEVLINK_PARAM_GENERIC_ID_INT_ERR_RESET, + value); + + value.vu32 = 1UL << log_num_mac; + mlx4_devlink_set_init_value(devlink, + DEVLINK_PARAM_GENERIC_ID_MAX_MACS, value); + + value.vbool = enable_64b_cqe_eqe; + mlx4_devlink_set_init_value(devlink, + MLX4_DEVLINK_PARAM_ID_ENABLE_64B_CQE_EQE, + value); + + value.vbool = enable_4k_uar; + mlx4_devlink_set_init_value(devlink, + MLX4_DEVLINK_PARAM_ID_ENABLE_4K_UAR, + value); +} + static inline void mlx4_set_num_reserved_uars(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) { @@ -3792,14 +3887,21 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) ret = devlink_register(devlink, &pdev->dev); if (ret) goto err_persist_free; - - ret = __mlx4_init_one(pdev, id->driver_data, priv); + ret = devlink_params_register(devlink, mlx4_devlink_params, + ARRAY_SIZE(mlx4_devlink_params)); if (ret) goto err_devlink_unregister; + mlx4_devlink_set_params_init_values(devlink); + ret = __mlx4_init_one(pdev, id->driver_data, priv); + if (ret) + goto err_params_unregister; pci_save_state(pdev); return 0; +err_params_unregister: + devlink_params_unregister(devlink, mlx4_devlink_params, + ARRAY_SIZE(mlx4_devlink_params)); err_devlink_unregister: devlink_unregister(devlink); err_persist_free: @@ -3936,6 +4038,8 @@ static void mlx4_remove_one(struct pci_dev *pdev) pci_release_regions(pdev); mlx4_pci_disable_device(dev); + devlink_params_unregister(devlink, mlx4_devlink_params, + ARRAY_SIZE(mlx4_devlink_params)); devlink_unregister(devlink); kfree(dev->persist); devlink_free(devlink); -- 1.8.3.1