From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73173154A0 for ; Wed, 5 Jul 2023 17:58:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4375FC433BC; Wed, 5 Jul 2023 17:58:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688579903; bh=J5azMA4gAKCKdBOSKSIqmmi2MSMIkVnyQS78BzXQSfY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EHiyJiTZu5iJiVlnxTV9Wd7nF8nn2bovzfb1hWCpHzEHRf9hh8NSZRuY28vFeMvbm SrRRbAdDNven+e5dEK311G8AzgHReF5f1fLGerdo5nHReF2crS9rF3cdgYTtv5Megs OEPyVs6dWFO7VYFxDHB71Oeou1kew2GRV3xQJleEh1uHvitt4dhwyhUmWzAYJaFgFv B3lk/TmdomlQyyw7HS/8MMrbKMR9V+B7tZGkni7KlSIpmyAEUqdWKfrwkAcZTCNHdg 9e2ELQj4xu8+XG8Yi/suqOkRCOZTA4ywAj45cAJDwM5XmjF57di+wd3yASs/uDaP1S Yk0Fol2sYWe5w== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Maher Sanalla , Shay Drory Subject: [net V2 8/9] net/mlx5: Query hca_cap_2 only when supported Date: Wed, 5 Jul 2023 10:57:56 -0700 Message-ID: <20230705175757.284614-9-saeed@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230705175757.284614-1-saeed@kernel.org> References: <20230705175757.284614-1-saeed@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Maher Sanalla On vport enable, where fw's hca caps are queried, the driver queries hca_caps_2 without checking if fw truly supports them, causing a false failure of vfs vport load and blocking SRIOV enablement on old devices such as CX4 where hca_caps_2 support is missing. Thus, add a check for the said caps support before accessing them. Fixes: e5b9642a33be ("net/mlx5: E-Switch, Implement devlink port function cmds to control migratable") Signed-off-by: Maher Sanalla Reviewed-by: Shay Drory Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c index faec7d7a4400..243c455f1029 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c @@ -807,6 +807,9 @@ static int mlx5_esw_vport_caps_get(struct mlx5_eswitch *esw, struct mlx5_vport * hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability); vport->info.roce_enabled = MLX5_GET(cmd_hca_cap, hca_caps, roce); + if (!MLX5_CAP_GEN_MAX(esw->dev, hca_cap_2)) + goto out_free; + memset(query_ctx, 0, query_out_sz); err = mlx5_vport_get_other_func_cap(esw->dev, vport->vport, query_ctx, MLX5_CAP_GENERAL_2); -- 2.41.0