Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp565538ybh; Tue, 21 Jul 2020 02:20:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMzX41IakwnZkcPnd2OOB1Hpt6YIEX7wI4lyaUPUYYNc5/MMgECy+CAJM1qTZ22JnHZXya X-Received: by 2002:a17:906:e215:: with SMTP id gf21mr23571710ejb.310.1595323216226; Tue, 21 Jul 2020 02:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595323216; cv=none; d=google.com; s=arc-20160816; b=yKi8C9eKZSIbpyx8uThN6dzNZNWRoxqkjU4p4L3icNUxcJBwfZ30+shkhyJnUKyil8 W/PGJGz5o48j8uWkFBb4LTszRXbBpbFvOS6ZX8So96dMp2aIehxvMePx5AUNjupXDRpV VHvcWQcjTDL87WYec2Oj5W5wn8KkTztxvCXTKsgcAa1B6RM8C6eIC3cHbd+0TTBJcOi8 kU55p+H79LpLsbOBOUiGZIyBWo/MqhqdpFXHz6Dh6VfHt9SSctwj00w2deQXm2ouLcJ7 AM9IgOCZNVhIVmhczJq7MsAQoUQaSGpJVC1Os9n3OMavVABvkzYVABxtZZJphc+M2TLm sbyQ== 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; bh=pNh1fxBdCulhLv+0rLSLXmO9tXUetc0HpfdXEN/Dn9M=; b=baVqMURqzLbDBKwyrtOw4X6+U3O7DQZ9ulCeYBmx8MqqiqwYr6lymLo+dk1ftm9+s1 NYiqTecuaU8qSdyBvOEdZlyRssVpitAlQ1SSi0RRCzSenGVV6zZ0CntLmFD5871yV76o LHTQ0TdSx+WSmNAQBiwm/t0g3bbaRajevYdDrp1o3cTWAwxTMSX6KqUPcG60rrpLkmu8 EXGWlnpEgohKy3HsMDr4PZYnkHuBzPxYDN1Oy8+zf6Z97B9YPfeZfTWWT6zMSulRLH17 VJc2dGDdni2yWQXfEqEQOm8q+oXfhC2fFl5I934XelWqidIqM6+r6tibkV7/Fy2A1DO3 rWKQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr11si9793767ejc.752.2020.07.21.02.19.53; Tue, 21 Jul 2020 02:20:16 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728927AbgGUJTi (ORCPT + 99 others); Tue, 21 Jul 2020 05:19:38 -0400 Received: from inva021.nxp.com ([92.121.34.21]:56076 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbgGUJTe (ORCPT ); Tue, 21 Jul 2020 05:19:34 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id B6A3420044D; Tue, 21 Jul 2020 11:19:32 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id AAF47200431; Tue, 21 Jul 2020 11:19:32 +0200 (CEST) Received: from fsr-ub1864-126.ea.freescale.net (fsr-ub1864-126.ea.freescale.net [10.171.82.212]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 75AB9202A9; Tue, 21 Jul 2020 11:19:32 +0200 (CEST) From: Ioana Ciornei To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Ioana Ciornei Subject: [PATCH 5/6] staging: dpaa2-ethsw: read the port state from firmware Date: Tue, 21 Jul 2020 12:19:18 +0300 Message-Id: <20200721091919.20394-6-ioana.ciornei@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200721091919.20394-1-ioana.ciornei@nxp.com> References: <20200721091919.20394-1-ioana.ciornei@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rely on the port state seen by the firmware since it will also be the one erroring out when trying to setup anything major when the port is up. Signed-off-by: Ioana Ciornei --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 9114437645a8..c6885912c60b 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -43,6 +43,25 @@ static int ethsw_add_vlan(struct ethsw_core *ethsw, u16 vid) return 0; } +static bool ethsw_port_is_up(struct ethsw_port_priv *port_priv) +{ + struct net_device *netdev = port_priv->netdev; + struct dpsw_link_state state; + int err; + + err = dpsw_if_get_link_state(port_priv->ethsw_data->mc_io, 0, + port_priv->ethsw_data->dpsw_handle, + port_priv->idx, &state); + if (err) { + netdev_err(netdev, "dpsw_if_get_link_state() err %d\n", err); + return true; + } + + WARN_ONCE(state.up > 1, "Garbage read into link_state"); + + return state.up ? true : false; +} + static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid) { struct ethsw_core *ethsw = port_priv->ethsw_data; @@ -61,7 +80,7 @@ static int ethsw_port_set_pvid(struct ethsw_port_priv *port_priv, u16 pvid) tci_cfg.vlan_id = pvid; /* Interface needs to be down to change PVID */ - up = netif_running(netdev); + up = ethsw_port_is_up(port_priv); if (up) { err = dpsw_if_disable(ethsw->mc_io, 0, ethsw->dpsw_handle, -- 2.25.1