Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2750973pxj; Mon, 31 May 2021 09:49:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycMP6gXIOzOdEQhiV/+MBYktwafC1wMNy1yRfDvFPSSAcQJH3omTV4ugLZ5Bdkyvgyk/Ci X-Received: by 2002:a05:6402:1111:: with SMTP id u17mr26670289edv.87.1622479753116; Mon, 31 May 2021 09:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622479753; cv=none; d=google.com; s=arc-20160816; b=0fga6cbfCR+HvKRYj00pNO2naKxZKRUo9ro1KHGwf59djRkObZYE8yKkqNOVy4cWYl VFQq2byQ2UNgaLJqGU2M/howa3ZcGYzC8GP7D2P93084TeEvfea8PrMcUC/WHWJg2GyX Z3JfO+vs3ZLAAGWURF9pdHZHtXflGZOgUJ46903RvOIiwLMf+T0bPxNqyi6Cdav+FGHm 7zEtkPfXua1mAPpf6IGB6MG2CPfPO8thE7m0rrOEYHveL7MUfGikbdB7LW7EGu3Fb//b TS8/BFwOQkx3u/5/zvYv258tSp6KGS2oKCLuROTjwiOIuApsLIfb4s+vd3PqvYpfVXRd iWXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1L0aHeooQ3JwCwrpJxFXZ/QKahYVslsVY/cTU23Blu0=; b=MXL7eetIFGyvdhKxePhbgzDo/rNlH2AYWHYkLkR4Kj38Yp9zAPGWd3loslHqnxkQa0 hh5LaTTfEg1+Ho8F0rLjljQySYdAh6Ck5a4LhgefRe02LhAyP5RBaolVtKN4LMDHFoR6 Ms9FaVJVysi0Jbce4ulEXd/3dtlW6SmEWFqsCfD6rpQL0wcpB4j4JHcTppN5Jj/4dbUq Gle7Sb5r87l7tXAFLAgPuAxAliTjznjvjvHagbAAKPWnBpCJDeOlgWrsaxw0f9G74geA ay/05cW3Yk5jwBTItGUy304iRjpaXWTu2uTRANo+KZ8rcMD0ZzhNNyAY44cr5Ezz4O3X wzXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GC+ThZN+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fl21si13434070ejc.601.2021.05.31.09.48.50; Mon, 31 May 2021 09:49:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GC+ThZN+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233724AbhEaQtU (ORCPT + 99 others); Mon, 31 May 2021 12:49:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:48436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233668AbhEaOzr (ORCPT ); Mon, 31 May 2021 10:55:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B7FB961CBC; Mon, 31 May 2021 14:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469601; bh=aCnRtdLTHE7mvfjNQ/ufORA4asijPcucrG2cyfn+lPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GC+ThZN+7PE071qsEp5ReoBr++zj4B7Ec7ZxYqYkld+4PS5icInk0BNphDETyqpY7 U71RmLO+LoPSF8TqWe7pSl+oA25/Gw0rnw0uLTEZRScNwchz+Db0haz9Tyt+3fZZ5Y 03oKErEd39IlJS5ifkSNeWjuCLxilrppaOV6lxwA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Parav Pandit , Vu Pham , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.12 261/296] net/mlx5: SF, Fix show state inactive when its inactivated Date: Mon, 31 May 2021 15:15:16 +0200 Message-Id: <20210531130712.527844382@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Parav Pandit [ Upstream commit 82041634d96e87b41c600a673f10150d9f21f742 ] When a SF is inactivated and when it is in a TEARDOWN_REQUEST state, driver still returns its state as active. This is incorrect. Fix it by treating TEARDOWN_REQEUST as inactive state. When a SF is still attached to the driver, on user request to reactivate EINVAL error is returned. Inform user about it with better code EBUSY and informative error message. Fixes: 6a3273217469 ("net/mlx5: SF, Port function state change support") Signed-off-by: Parav Pandit Reviewed-by: Vu Pham Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- .../ethernet/mellanox/mlx5/core/sf/devlink.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c index c2ba41bb7a70..96c4509e5838 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c @@ -128,10 +128,10 @@ static enum devlink_port_fn_state mlx5_sf_to_devlink_state(u8 hw_state) switch (hw_state) { case MLX5_VHCA_STATE_ACTIVE: case MLX5_VHCA_STATE_IN_USE: - case MLX5_VHCA_STATE_TEARDOWN_REQUEST: return DEVLINK_PORT_FN_STATE_ACTIVE; case MLX5_VHCA_STATE_INVALID: case MLX5_VHCA_STATE_ALLOCATED: + case MLX5_VHCA_STATE_TEARDOWN_REQUEST: default: return DEVLINK_PORT_FN_STATE_INACTIVE; } @@ -184,14 +184,17 @@ sf_err: return err; } -static int mlx5_sf_activate(struct mlx5_core_dev *dev, struct mlx5_sf *sf) +static int mlx5_sf_activate(struct mlx5_core_dev *dev, struct mlx5_sf *sf, + struct netlink_ext_ack *extack) { int err; if (mlx5_sf_is_active(sf)) return 0; - if (sf->hw_state != MLX5_VHCA_STATE_ALLOCATED) - return -EINVAL; + if (sf->hw_state != MLX5_VHCA_STATE_ALLOCATED) { + NL_SET_ERR_MSG_MOD(extack, "SF is inactivated but it is still attached"); + return -EBUSY; + } err = mlx5_cmd_sf_enable_hca(dev, sf->hw_fn_id); if (err) @@ -218,7 +221,8 @@ static int mlx5_sf_deactivate(struct mlx5_core_dev *dev, struct mlx5_sf *sf) static int mlx5_sf_state_set(struct mlx5_core_dev *dev, struct mlx5_sf_table *table, struct mlx5_sf *sf, - enum devlink_port_fn_state state) + enum devlink_port_fn_state state, + struct netlink_ext_ack *extack) { int err = 0; @@ -226,7 +230,7 @@ static int mlx5_sf_state_set(struct mlx5_core_dev *dev, struct mlx5_sf_table *ta if (state == mlx5_sf_to_devlink_state(sf->hw_state)) goto out; if (state == DEVLINK_PORT_FN_STATE_ACTIVE) - err = mlx5_sf_activate(dev, sf); + err = mlx5_sf_activate(dev, sf, extack); else if (state == DEVLINK_PORT_FN_STATE_INACTIVE) err = mlx5_sf_deactivate(dev, sf); else @@ -257,7 +261,7 @@ int mlx5_devlink_sf_port_fn_state_set(struct devlink *devlink, struct devlink_po goto out; } - err = mlx5_sf_state_set(dev, table, sf, state); + err = mlx5_sf_state_set(dev, table, sf, state, extack); out: mlx5_sf_table_put(table); return err; -- 2.30.2