Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3948985pxb; Mon, 4 Oct 2021 13:24:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkZZAgQNID14Fh+ycFKoQskoHYi5wapo8VGmR06UjsjZ+uF25/MwLGY1nz2+yS7inzBiT6 X-Received: by 2002:a63:125f:: with SMTP id 31mr12557932pgs.98.1633379087217; Mon, 04 Oct 2021 13:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633379087; cv=none; d=google.com; s=arc-20160816; b=H4fdMc0E465/Oa1KoASgTeDDTz8Dc/02hGhSZHpXTEEVMKtxhkS3sV/GGFjymlePyF pdVh507prllQMddFyx7Z/LpBvwg1mkc84n3a0I6kpz7Bg2W4PxehfJLX0Q9SPNvjryfD eTMANuZwGpCkaIDZdgtJ6D+xHnCy+qTOa1wE6ibTXg7U5GdJkzoCZbGTO1Zmb1aCOT/F Csxk4rvZ9DXMTlKwEG+Fop9laaYDHEOZQV0OXFhypE1MEBvDEVKq08GhtQ3Nd9/uz41n y78VMvyUnmEvHp/82d22MovwNw6sa/QK/3/4NhvCu6TmoejHNWQAz2Mfv2IiN+X+C8nh TZHQ== 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=+6AXVosbhQVkwiKNF644P6JaHDxaf363huy7/E1Gjdw=; b=a9gRZTbst4DeDlSTpaiMcJeGUH/M8IWIBA8Oc1OdDn4Luvlyoj1Ob69++M2EmV1pTQ zSOMPybiRQZZa1qQJdnDIFYf42Edr5qZeCuXwBuuNwcife6qRf6L3sNAPY9bzMRMIr/N GsB1TtmcHfED96MOoqzSgcZe+U4bhhuPnYBC4mNUFuEE6qD9YydqCqH8vQmRzKtZT+Gh Y9lUlCGsH0rZ1hiLm6GzsAzA9OA7ZcdXU/voP21HaQ2vaoLx9bcy1Iew/JhVr5Vg5uX3 JXeW6ei9RB8WBJXjikzgD0wH/WXcNAS8proa+b2O49vQ4z2bxf5Il7MglNr1Jyklt0TF PlxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PlemMmIh; 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 s19si19934008plr.405.2021.10.04.13.24.35; Mon, 04 Oct 2021 13:24:47 -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=PlemMmIh; 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 S237130AbhJDN3z (ORCPT + 99 others); Mon, 4 Oct 2021 09:29:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:42998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237301AbhJDN2U (ORCPT ); Mon, 4 Oct 2021 09:28:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4833961CF1; Mon, 4 Oct 2021 13:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353148; bh=ACW6hK/bxBhrKoJRAmXCY1vQZLYwpA0ua52mYen6ehU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PlemMmIh65bRqw9KMQd0MYB2YFwh3pgu4UQzCJKfK+dLEqfUS0FEK6zAmiJtKZIWC bYUhd46n8IEaS1BOyBKP7pIpplDi/u3O34VzBEb46/PcbuL0o8qzBPxhm68I7mm+Dh 4SSOt0NEKsx0ZNO879MMHyHjC9Twub3Q6sqOWndo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lama Kayal , Tariq Toukan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.14 015/172] net/mlx4_en: Resolve bad operstate value Date: Mon, 4 Oct 2021 14:51:05 +0200 Message-Id: <20211004125045.460790743@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@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: Lama Kayal [ Upstream commit 72a3c58d18fd780eecd80178bb2132ce741a0a74 ] Any link state change that's done prior to net device registration isn't reflected on the state, thus the operational state is left obsolete, with 'UNKNOWN' status. To resolve the issue, query link state from FW upon open operations to ensure operational state is updated. Fixes: c27a02cd94d6 ("mlx4_en: Add driver for Mellanox ConnectX 10GbE NIC") Signed-off-by: Lama Kayal Signed-off-by: Tariq Toukan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/mellanox/mlx4/en_netdev.c | 47 ++++++++++++------- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 - 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 1e672bc36c4d..a6878e5f922a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -1272,7 +1272,6 @@ static void mlx4_en_do_set_rx_mode(struct work_struct *work) if (!netif_carrier_ok(dev)) { if (!mlx4_en_QUERY_PORT(mdev, priv->port)) { if (priv->port_state.link_state) { - priv->last_link_state = MLX4_DEV_EVENT_PORT_UP; netif_carrier_on(dev); en_dbg(LINK, priv, "Link Up\n"); } @@ -1560,26 +1559,36 @@ static void mlx4_en_service_task(struct work_struct *work) mutex_unlock(&mdev->state_lock); } -static void mlx4_en_linkstate(struct work_struct *work) +static void mlx4_en_linkstate(struct mlx4_en_priv *priv) +{ + struct mlx4_en_port_state *port_state = &priv->port_state; + struct mlx4_en_dev *mdev = priv->mdev; + struct net_device *dev = priv->dev; + bool up; + + if (mlx4_en_QUERY_PORT(mdev, priv->port)) + port_state->link_state = MLX4_PORT_STATE_DEV_EVENT_PORT_DOWN; + + up = port_state->link_state == MLX4_PORT_STATE_DEV_EVENT_PORT_UP; + if (up == netif_carrier_ok(dev)) + netif_carrier_event(dev); + if (!up) { + en_info(priv, "Link Down\n"); + netif_carrier_off(dev); + } else { + en_info(priv, "Link Up\n"); + netif_carrier_on(dev); + } +} + +static void mlx4_en_linkstate_work(struct work_struct *work) { struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv, linkstate_task); struct mlx4_en_dev *mdev = priv->mdev; - int linkstate = priv->link_state; mutex_lock(&mdev->state_lock); - /* If observable port state changed set carrier state and - * report to system log */ - if (priv->last_link_state != linkstate) { - if (linkstate == MLX4_DEV_EVENT_PORT_DOWN) { - en_info(priv, "Link Down\n"); - netif_carrier_off(priv->dev); - } else { - en_info(priv, "Link Up\n"); - netif_carrier_on(priv->dev); - } - } - priv->last_link_state = linkstate; + mlx4_en_linkstate(priv); mutex_unlock(&mdev->state_lock); } @@ -2082,9 +2091,11 @@ static int mlx4_en_open(struct net_device *dev) mlx4_en_clear_stats(dev); err = mlx4_en_start_port(dev); - if (err) + if (err) { en_err(priv, "Failed starting port:%d\n", priv->port); - + goto out; + } + mlx4_en_linkstate(priv); out: mutex_unlock(&mdev->state_lock); return err; @@ -3171,7 +3182,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, spin_lock_init(&priv->stats_lock); INIT_WORK(&priv->rx_mode_task, mlx4_en_do_set_rx_mode); INIT_WORK(&priv->restart_task, mlx4_en_restart); - INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate); + INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate_work); INIT_DELAYED_WORK(&priv->stats_task, mlx4_en_do_get_stats); INIT_DELAYED_WORK(&priv->service_task, mlx4_en_service_task); #ifdef CONFIG_RFS_ACCEL diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index f3d1a20201ef..6bf558c5ec10 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -552,7 +552,6 @@ struct mlx4_en_priv { struct mlx4_hwq_resources res; int link_state; - int last_link_state; bool port_up; int port; int registered; -- 2.33.0