From patchwork Wed Apr 21 17:47:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saeed Mahameed X-Patchwork-Id: 425739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38BE5C433B4 for ; Wed, 21 Apr 2021 17:47:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 048F96140D for ; Wed, 21 Apr 2021 17:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244933AbhDURs0 (ORCPT ); Wed, 21 Apr 2021 13:48:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:59418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244922AbhDURsP (ORCPT ); Wed, 21 Apr 2021 13:48:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 46BC361455; Wed, 21 Apr 2021 17:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619027261; bh=m3ZN1fpMHwCP+UEAw/uCN4eS/ECaYS0RBytP4dTpVgc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NxNYfxAKiBZ+ahvYaUjtjuiGq46530FR9pjzA0srnztjnBrgt+IRvhy0tYAHFDM7l WR4MM70YHTnnFEAoenFTX/ENyGlTTGtnOH0LTxF2ROiaHQhxS/1esD5QOxTjWPINYH phUmUrsRTztvfYHF9EKBn4EvWYNTKV9oskRax+65kpgXGH4QauC/2j0W1H5KBP6hJb HQ+7Vx0Dnk6PzQWTsfPvJIQVgzHmxkpzDiCSZ3NjjrUeiYFbuJX5hQSKLcAlbzEhpn TNfbArvEvzsrK2bjQPb4um6HU5MG1Nn14+HAw61zBQkrKkb1cSbHrKdIk+yv39TfX0 tJ/o4Xpj2k++A== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Parav Pandit , Vu Pham , Saeed Mahameed Subject: [net-next 07/11] net/mlx5: SF, Store and use start function id Date: Wed, 21 Apr 2021 10:47:19 -0700 Message-Id: <20210421174723.159428-8-saeed@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210421174723.159428-1-saeed@kernel.org> References: <20210421174723.159428-1-saeed@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Parav Pandit SF ids in the device are in two different contiguous ranges. One for the local controller and second for the external host controller. Prepare code to handle multiple start function id by storing it in the table. Signed-off-by: Parav Pandit Reviewed-by: Vu Pham Signed-off-by: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c index 9140c81aa03a..c3126031c2bf 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c @@ -19,18 +19,23 @@ struct mlx5_sf_hw_table { struct mlx5_core_dev *dev; struct mlx5_sf_hw *sfs; int max_local_functions; + u16 start_fn_id; struct mutex table_lock; /* Serializes sf deletion and vhca state change handler. */ struct notifier_block vhca_nb; }; u16 mlx5_sf_sw_to_hw_id(const struct mlx5_core_dev *dev, u16 sw_id) { - return sw_id + mlx5_sf_start_function_id(dev); + struct mlx5_sf_hw_table *table = dev->priv.sf_hw_table; + + return table->start_fn_id + sw_id; } static u16 mlx5_sf_hw_to_sw_id(const struct mlx5_core_dev *dev, u16 hw_id) { - return hw_id - mlx5_sf_start_function_id(dev); + struct mlx5_sf_hw_table *table = dev->priv.sf_hw_table; + + return hw_id - table->start_fn_id; } int mlx5_sf_hw_table_sf_alloc(struct mlx5_core_dev *dev, u32 usr_sfnum) @@ -164,6 +169,7 @@ int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev) table->dev = dev; table->sfs = sfs; table->max_local_functions = max_functions; + table->start_fn_id = mlx5_sf_start_function_id(dev); dev->priv.sf_hw_table = table; mlx5_core_dbg(dev, "SF HW table: max sfs = %d\n", max_functions); return 0;