From patchwork Sat Jun 8 13:03:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 1112486 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eRfIxTS1"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45LfjS2CMDz9s9y for ; Sat, 8 Jun 2019 23:03:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727174AbfFHNDz (ORCPT ); Sat, 8 Jun 2019 09:03:55 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35456 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726976AbfFHNDx (ORCPT ); Sat, 8 Jun 2019 09:03:53 -0400 Received: by mail-wm1-f65.google.com with SMTP id c6so4296048wml.0 for ; Sat, 08 Jun 2019 06:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CLqH0w/I6sunkxJ22Wy2o1Iuu5mQCzkmSEeU1R8OL+4=; b=eRfIxTS1nNMDW36zkPzwuCMsmUcsF/Erb80aRrxbeqVdEPUc8Vfe+gZZ56IhVCNaMZ Ip5UVhMAorkEm05H2YO3xtINasMm5ZngWTPGpEPmz4rcPIADtSajmTlfQWGigY9lBYs3 /+67FDgMieumyigs4bOWof7uyQmy9A+WcvVY/OYXAcmUOXBypXtA14GlWVCXIpfAr4Zd KeBAwyg2LZgKBXX3CFskjpATTkXAWOo5cho86b9HmP1s/OvPTZrYJeH1aw0M71SCU8aL 1NoowHmpZbTu+rItD/DmEBg8cgIDkWRXFNBDpKWSY5+I9OSSGea1LJPM6grVPEFdwrxS WOIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CLqH0w/I6sunkxJ22Wy2o1Iuu5mQCzkmSEeU1R8OL+4=; b=S/I3o3HXvRCPBbVt8cTKkB1THqeVu9r+/atiMaMl43omRmPRbAz03VSdbAT/FuHO5x U32QEjIFpevAjZodqxkvCwXL1IGGYS1YHA6EvfC6Edh2EEwycI9Az8cwV2RaJY76d1ej gWxY4XRwewa0sQEkW1apSjVhif+Nf9T5WP5eFCfvxJtHWNhSg/BSuhVl8xA+ot0dTEKJ hl9IPvTEBXJHBZ7rvV2jG4FqDrcf78rI91llbhRVggdeON+lvcHOh0gepFD8Ltk85JUb DQkj6/7DHnl3UvDT3JSL9jM6MeqglvLsZ6K4TZm2GKezdwxJ7Osfdpvv/AP5h0Ew/Apk yGaA== X-Gm-Message-State: APjAAAVsmXM2MDG5EvVplvaz5YA2rxcU4SiS00kxEWWfVUVLr3vzp2/z Tt9ON1Zx3wKd4HHGazBnJlE= X-Google-Smtp-Source: APXvYqzUfOqgCnplc0syQBZuMKIRB8LPpQLCvJkjzFzd4pJsusWKa0k2Hc44AAyT9M14SrUgaHXYhw== X-Received: by 2002:a05:600c:c6:: with SMTP id u6mr7296462wmm.153.1559999031434; Sat, 08 Jun 2019 06:03:51 -0700 (PDT) Received: from localhost.localdomain ([188.26.252.192]) by smtp.gmail.com with ESMTPSA id 128sm4632766wme.12.2019.06.08.06.03.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Jun 2019 06:03:51 -0700 (PDT) From: Vladimir Oltean To: f.fainelli@gmail.com, vivien.didelot@gmail.com, andrew@lunn.ch, davem@davemloft.net Cc: netdev@vger.kernel.org, Vladimir Oltean Subject: [PATCH net-next 1/4] net: dsa: sja1105: Use SPEED_{10, 100, 1000, UNKNOWN} macros Date: Sat, 8 Jun 2019 16:03:41 +0300 Message-Id: <20190608130344.661-2-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190608130344.661-1-olteanv@gmail.com> References: <20190608130344.661-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a cosmetic patch that replaces the link speed numbers used in the driver with the corresponding ethtool macros. Signed-off-by: Vladimir Oltean Suggested-by: Andrew Lunn Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- drivers/net/dsa/sja1105/sja1105_main.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 15bee785fd6d..580568922f35 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -689,12 +689,12 @@ static int sja1105_parse_dt(struct sja1105_private *priv, return rc; } -/* Convert back and forth MAC speed from Mbps to SJA1105 encoding */ +/* Convert link speed from SJA1105 to ethtool encoding */ static int sja1105_speed[] = { - [SJA1105_SPEED_AUTO] = 0, - [SJA1105_SPEED_10MBPS] = 10, - [SJA1105_SPEED_100MBPS] = 100, - [SJA1105_SPEED_1000MBPS] = 1000, + [SJA1105_SPEED_AUTO] = SPEED_UNKNOWN, + [SJA1105_SPEED_10MBPS] = SPEED_10, + [SJA1105_SPEED_100MBPS] = SPEED_100, + [SJA1105_SPEED_1000MBPS] = SPEED_1000, }; /* Set link speed and enable/disable traffic I/O in the MAC configuration @@ -720,17 +720,17 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; switch (speed_mbps) { - case 0: + case SPEED_UNKNOWN: /* No speed update requested */ speed = SJA1105_SPEED_AUTO; break; - case 10: + case SPEED_10: speed = SJA1105_SPEED_10MBPS; break; - case 100: + case SPEED_100: speed = SJA1105_SPEED_100MBPS; break; - case 1000: + case SPEED_1000: speed = SJA1105_SPEED_1000MBPS; break; default: @@ -786,7 +786,7 @@ static void sja1105_mac_config(struct dsa_switch *ds, int port, struct sja1105_private *priv = ds->priv; if (!state->link) - sja1105_adjust_port_config(priv, port, 0, false); + sja1105_adjust_port_config(priv, port, SPEED_UNKNOWN, false); else sja1105_adjust_port_config(priv, port, state->speed, true); } @@ -1311,7 +1311,7 @@ static int sja1105_static_config_reload(struct sja1105_private *priv) goto out; for (i = 0; i < SJA1105_NUM_PORTS; i++) { - bool enabled = (speed_mbps[i] != 0); + bool enabled = (speed_mbps[i] != SPEED_UNKNOWN); if (i != dsa_upstream_port(priv->ds, i)) sja1105_bridge_stp_state_set(priv->ds, i, stp_state[i]); From patchwork Sat Jun 8 13:03:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 1112487 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="d7oakhBl"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45LfjT6CFvz9s9y for ; Sat, 8 Jun 2019 23:03:57 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727245AbfFHND4 (ORCPT ); Sat, 8 Jun 2019 09:03:56 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39895 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726873AbfFHNDx (ORCPT ); Sat, 8 Jun 2019 09:03:53 -0400 Received: by mail-wm1-f66.google.com with SMTP id z23so4276194wma.4 for ; Sat, 08 Jun 2019 06:03:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kH7cTNKzXAl7w0isQMDYh/vyxa08pdn3kODTCppe4Lg=; b=d7oakhBlFJ7Vf8aXiDAHodLWg23ISQj0Vml/BD91OUSCNgSyeaNdQ2dHCk73SCzDVJ xa00RRP4AXXevjqqUGI1UmeR2VILbG4jgeefan0U7ZQGx5lfJzcPtnPJtcXex9YMuGo9 1mtaVAr9FItHhk5W5BmW1r77utgqn+VGGDHfwuYVz/7HBN6nk/0fW+BwGA5f9b1QzQCT oM+97gzZUBVoORA82wC4OcqQOv4n0XcUt5CfBEQROP4B4keQJOrDdEKpowlJc8GhHm1N cafiY+IlOGXnmBe7NKhUmcCy96rXE54riRZytgB9TghwpK7d9TiVTEtDQViph469VCJ6 d9ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kH7cTNKzXAl7w0isQMDYh/vyxa08pdn3kODTCppe4Lg=; b=XDyM2F2GB9ETLy8PH3XCldCjbrmocY0qpgfZrSDIRy4ZcDlFtK9/skEwCP8YPkAJ84 Ols1ZrROlwiKaAygre2EKMmZlDKmPUq+z7MKfeoqTlpaqlEoah3rrKWOoiiOcC4npvy1 cfnIfnRUIgo67ncDVlTvRyXvJ2aF/lfpeXJyYdfisaI0WlJMFX31cLVssPxca/uZIA6J HxERGZJxovnIZelQMbWfFMDsCoH4qrKPwr65FpO9BKq3HS8qOhSgJ9AavO+kQSkEOf3K WDLo6s8elpNiY2METt463ief1VBXv5wTvauG8bjXuPPrlOmpzCiDPqXSl8w3SsoMyIW1 hA6g== X-Gm-Message-State: APjAAAWzOz9uw4rs7An+PegktaScOb2UpgGwi8hg3W/aSnm8Ay0E5W59 08fVT4fQTp/65eEZLvOJnwk= X-Google-Smtp-Source: APXvYqwq/a6D4bBbug3L9CiA6ekvy31UnEpTZJ84jhd3DGcfrb9NZWwsuDAslZEB7VoKVCb465aIpw== X-Received: by 2002:a05:600c:28d:: with SMTP id 13mr1347477wmk.5.1559999032288; Sat, 08 Jun 2019 06:03:52 -0700 (PDT) Received: from localhost.localdomain ([188.26.252.192]) by smtp.gmail.com with ESMTPSA id 128sm4632766wme.12.2019.06.08.06.03.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Jun 2019 06:03:51 -0700 (PDT) From: Vladimir Oltean To: f.fainelli@gmail.com, vivien.didelot@gmail.com, andrew@lunn.ch, davem@davemloft.net Cc: netdev@vger.kernel.org, Vladimir Oltean Subject: [PATCH net-next 2/4] net: dsa: sja1105: Update some comments about PHYLIB Date: Sat, 8 Jun 2019 16:03:42 +0300 Message-Id: <20190608130344.661-3-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190608130344.661-1-olteanv@gmail.com> References: <20190608130344.661-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Since the driver is now using PHYLINK exclusively, it makes sense to remove all references to it and replace them with PHYLINK. Signed-off-by: Vladimir Oltean Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- drivers/net/dsa/sja1105/Kconfig | 2 +- drivers/net/dsa/sja1105/sja1105_main.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/sja1105/Kconfig b/drivers/net/dsa/sja1105/Kconfig index 049cea8240e4..105e8d3e380e 100644 --- a/drivers/net/dsa/sja1105/Kconfig +++ b/drivers/net/dsa/sja1105/Kconfig @@ -9,7 +9,7 @@ tristate "NXP SJA1105 Ethernet switch family support" This is the driver for the NXP SJA1105 automotive Ethernet switch family. These are 5-port devices and are managed over an SPI interface. Probing is handled based on OF bindings and so is the - linkage to phylib. The driver supports the following revisions: + linkage to PHYLINK. The driver supports the following revisions: - SJA1105E (Gen. 1, No TT-Ethernet) - SJA1105T (Gen. 1, TT-Ethernet) - SJA1105P (Gen. 2, No SGMII, No TT-Ethernet) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 580568922f35..d7f4dbfdb15d 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -70,8 +70,7 @@ static int sja1105_init_mac_settings(struct sja1105_private *priv) /* Keep standard IFG of 12 bytes on egress. */ .ifg = 0, /* Always put the MAC speed in automatic mode, where it can be - * retrieved from the PHY object through phylib and - * sja1105_adjust_port_config. + * adjusted at runtime by PHYLINK. */ .speed = SJA1105_SPEED_AUTO, /* No static correction for 1-step 1588 events */ @@ -116,7 +115,6 @@ static int sja1105_init_mac_settings(struct sja1105_private *priv) if (!table->entries) return -ENOMEM; - /* Override table based on phylib DT bindings */ table->entry_count = SJA1105_NUM_PORTS; mac = table->entries; @@ -157,7 +155,7 @@ static int sja1105_init_mii_settings(struct sja1105_private *priv, if (!table->entries) return -ENOMEM; - /* Override table based on phylib DT bindings */ + /* Override table based on PHYLINK DT bindings */ table->entry_count = SJA1105_MAX_XMII_PARAMS_COUNT; mii = table->entries; From patchwork Sat Jun 8 13:03:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 1112489 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Kjox+jjQ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45LfjY6Xhwz9s9y for ; Sat, 8 Jun 2019 23:04:01 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727326AbfFHNEB (ORCPT ); Sat, 8 Jun 2019 09:04:01 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43551 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727177AbfFHNDz (ORCPT ); Sat, 8 Jun 2019 09:03:55 -0400 Received: by mail-wr1-f65.google.com with SMTP id r18so4735026wrm.10 for ; Sat, 08 Jun 2019 06:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mfWLb0EWYPqM4Q0OC6o5kRcBWqGopiM+bcboQM4mLfY=; b=Kjox+jjQFn9+x5a9qAfJAGqAUhpaeRY1F/L3/7evo6akWelLG8Ucer2JFENbUAW+Rp BWvJ8353okkYHzMyqMX148MvMeJtlJtEFoBTnYaRJS+AqmTWsjsLKEH2OFeNgVCYqU7Q RLQtx8UEH9Uwk1Bp3sTSIxjj+/+mx1+rG12ryZ6+vTQEQDh+1diZd4nx2x7zvshRuEfH w7H1fCuECMydE3vwLs73bvUhaOCuc4gRaZEHHtUxIMjo5sc4rRtPpxLMQHn4HdMes5fs 0pno25enDFT14KNiTAWC7lFn7qhi0E+VOsNlkvCju7v+TiFlaqWsS6rCCo/z3g/KYhEH TFHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mfWLb0EWYPqM4Q0OC6o5kRcBWqGopiM+bcboQM4mLfY=; b=uIjJ+83yKMa8jJSatZIcRo2y+YfeYV1mG9sBoWRDgo4HfaYQyrkm9bqKbw7F0lmsJO Xp4zwM7ZaOhe2oWUpPwzCpkYh6xlhVTttSEt5vNwYn76trPlRK4C9OOxq7S1IH0z6mcu P7xKfsMWwxNIsR+bTffBW0VMCIxB4wIDe0LLsZZKwC4zrcbAlPTfP8Y6HTaSoDezwg7q S9CVytZ8ucOT7nxpfdlXgek2Wida/OFNatPYgc2PY7C/17JJOasDHkYq14nKPp2YtzGp RetmrtIuqfxRzgVIbHiVuF4DknznBuQPZ+cAys8Q9oBc2V3WmlM5z+j+SQ2xYVrIIM34 pi+A== X-Gm-Message-State: APjAAAXQ1hRSgiKlY0ciVAxYXQlDrWOOg50TMcYNdBoacAdL5dtuOlZo SzMISfcGsf1NS4BNMI6Ygac= X-Google-Smtp-Source: APXvYqwAcxPxIdPiVXoE/kWu18Dath2NwCHg38/DiPymml9NnZ/eg38vACqEfnFP2cKGLEjuARTL0w== X-Received: by 2002:adf:dcc2:: with SMTP id x2mr3112212wrm.55.1559999033240; Sat, 08 Jun 2019 06:03:53 -0700 (PDT) Received: from localhost.localdomain ([188.26.252.192]) by smtp.gmail.com with ESMTPSA id 128sm4632766wme.12.2019.06.08.06.03.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Jun 2019 06:03:52 -0700 (PDT) From: Vladimir Oltean To: f.fainelli@gmail.com, vivien.didelot@gmail.com, andrew@lunn.ch, davem@davemloft.net Cc: netdev@vger.kernel.org, Vladimir Oltean Subject: [PATCH net-next 3/4] net: dsa: sja1105: Export the sja1105_inhibit_tx function Date: Sat, 8 Jun 2019 16:03:43 +0300 Message-Id: <20190608130344.661-4-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190608130344.661-1-olteanv@gmail.com> References: <20190608130344.661-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This will be used to stop egress traffic in .phylink_mac_link_up. Signed-off-by: Vladimir Oltean Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- drivers/net/dsa/sja1105/sja1105.h | 2 ++ drivers/net/dsa/sja1105/sja1105_spi.c | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h index 38b6c7c7db86..ed66d00eb394 100644 --- a/drivers/net/dsa/sja1105/sja1105.h +++ b/drivers/net/dsa/sja1105/sja1105.h @@ -138,6 +138,8 @@ int sja1105_spi_send_long_packed_buf(const struct sja1105_private *priv, sja1105_spi_rw_mode_t rw, u64 base_addr, void *packed_buf, u64 buf_len); int sja1105_static_config_upload(struct sja1105_private *priv); +int sja1105_inhibit_tx(const struct sja1105_private *priv, + unsigned long port_bitmap, bool tx_inhibited); extern struct sja1105_info sja1105e_info; extern struct sja1105_info sja1105t_info; diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c index d729a0f0b28e..d7ff74259b31 100644 --- a/drivers/net/dsa/sja1105/sja1105_spi.c +++ b/drivers/net/dsa/sja1105/sja1105_spi.c @@ -285,20 +285,22 @@ static int sja1105_cold_reset(const struct sja1105_private *priv) return priv->info->reset_cmd(priv, &reset); } -static int sja1105_inhibit_tx(const struct sja1105_private *priv, - const unsigned long *port_bitmap) +int sja1105_inhibit_tx(const struct sja1105_private *priv, + unsigned long port_bitmap, bool tx_inhibited) { const struct sja1105_regs *regs = priv->info->regs; u64 inhibit_cmd; - int port, rc; + int rc; rc = sja1105_spi_send_int(priv, SPI_READ, regs->port_control, &inhibit_cmd, SJA1105_SIZE_PORT_CTRL); if (rc < 0) return rc; - for_each_set_bit(port, port_bitmap, SJA1105_NUM_PORTS) - inhibit_cmd |= BIT(port); + if (tx_inhibited) + inhibit_cmd |= port_bitmap; + else + inhibit_cmd &= ~port_bitmap; return sja1105_spi_send_int(priv, SPI_WRITE, regs->port_control, &inhibit_cmd, SJA1105_SIZE_PORT_CTRL); @@ -415,7 +417,7 @@ int sja1105_static_config_upload(struct sja1105_private *priv) * Tx on all ports and waiting for current packet to drain. * Otherwise, the PHY will see an unterminated Ethernet packet. */ - rc = sja1105_inhibit_tx(priv, &port_bitmap); + rc = sja1105_inhibit_tx(priv, port_bitmap, true); if (rc < 0) { dev_err(dev, "Failed to inhibit Tx on ports\n"); return -ENXIO; From patchwork Sat Jun 8 13:03:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 1112488 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Zt2pvhAJ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45LfjW6Cfdz9s9y for ; Sat, 8 Jun 2019 23:03:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727294AbfFHND6 (ORCPT ); Sat, 8 Jun 2019 09:03:58 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40728 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727204AbfFHND4 (ORCPT ); Sat, 8 Jun 2019 09:03:56 -0400 Received: by mail-wr1-f66.google.com with SMTP id p11so4748952wre.7 for ; Sat, 08 Jun 2019 06:03:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=39QNo9ECHkyXqHs4cTZCq8XeZ66f1WCzkbq6hIAJpWI=; b=Zt2pvhAJDapQMr+PbTvSpM03OKAxnjuXBrrk1/9ohuq/7kULtT9s7s3cOyxAMyGfhB sEXhdqNMIpjsEicTie7vpCBZaHlJ9SNj7K80HavTWipMFWC5wgvZjw/18OcO9usfdajt B7Z4wsCPgXMFaH6Cbpa3lTrNMy5AUDdy0qpfCL7mEUGXHBdueE0QS0O0dGO1U53DjBbx bfOKt33alGvHwjTB6BE6ZpRahdyBI5frSiUVgA4uyo4HhGmyhYSaFtiKhdNPQcWnDNNl TsFvUAPvP6K7Ui05xw+oxPgKxuKUGiORUkR9KGQYZ5cmgjVQdyS33ruOGukHIrU9psmr +GDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=39QNo9ECHkyXqHs4cTZCq8XeZ66f1WCzkbq6hIAJpWI=; b=UI8oK+PwErRCQTLuYoRpSNr2QytZbG+EnUjrwZNYJakRrvx65ptOVi+xxuFfCRpKLK njGIIPWgoqrUkHjoZGZfk65s64+miiEIjVFZGs7MaUWIMWl3GbIjYsRBjXoec1mRR+VN rQf5lqzx0UV3KuV21rVZPhNefov1TLr+ur0ar/HNBfoLN+Bz/8ssFQ44x5iSowDwjrAo 59fIEgi/eIQfxsaIivy4W9L07i8GtIhSBLfLvM5jh1KCKUKpnbIhivfZZ1UXrXYEcBjU sMaGq6jSd7G+q3GWpHB9J2QW81p6bfQo6x3JKt4/JBnLJhBjejOAciI5AhBb0VEKRSTM 4jNA== X-Gm-Message-State: APjAAAXd6G666dr/v5gV+0fWc0LkUqObwadujhZEtlPi3a6SRkIoefa5 kff+mYVosOEXHuiy9XGE82Z+njwwf8w= X-Google-Smtp-Source: APXvYqz/uKpD6Z7F86lW2TepJvwUwev26c87sxeYnDhizvBbArXv0KSiP2TJb1RtIwLHZ4iAoJaXiA== X-Received: by 2002:a5d:6709:: with SMTP id o9mr24073523wru.301.1559999034235; Sat, 08 Jun 2019 06:03:54 -0700 (PDT) Received: from localhost.localdomain ([188.26.252.192]) by smtp.gmail.com with ESMTPSA id 128sm4632766wme.12.2019.06.08.06.03.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 08 Jun 2019 06:03:53 -0700 (PDT) From: Vladimir Oltean To: f.fainelli@gmail.com, vivien.didelot@gmail.com, andrew@lunn.ch, davem@davemloft.net Cc: netdev@vger.kernel.org, Vladimir Oltean Subject: [PATCH net-next 4/4] net: dsa: sja1105: Rethink the PHYLINK callbacks Date: Sat, 8 Jun 2019 16:03:44 +0300 Message-Id: <20190608130344.661-5-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190608130344.661-1-olteanv@gmail.com> References: <20190608130344.661-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The first fact that needs to be stated is that the per-MAC settings in SJA1105 called EGRESS and INGRESS do *not* disable egress and ingress on the MAC. They only prevent non-link-local traffic from being sent/received on this port. So instead of having .phylink_mac_config essentially mess with the STP state and force it to DISABLED/BLOCKING (which also brings useless complications in sja1105_static_config_reload), simply add the .phylink_mac_link_down and .phylink_mac_link_up callbacks which inhibit TX at the MAC level, while leaving RX essentially enabled. Also stop from trying to put the link down in .phylink_mac_config, which is incorrect. Signed-off-by: Vladimir Oltean Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- drivers/net/dsa/sja1105/sja1105_main.c | 114 +++++++++---------------- 1 file changed, 40 insertions(+), 74 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index d7f4dbfdb15d..56b357a421de 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -695,18 +695,10 @@ static int sja1105_speed[] = { [SJA1105_SPEED_1000MBPS] = SPEED_1000, }; -/* Set link speed and enable/disable traffic I/O in the MAC configuration - * for a specific port. - * - * @speed_mbps: If 0, leave the speed unchanged, else adapt MAC to PHY speed. - * @enabled: Manage Rx and Tx settings for this port. If false, overrides the - * settings from the STP state, but not persistently (does not - * overwrite the static MAC info for this port). - */ +/* Set link speed in the MAC configuration for a specific port. */ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, - int speed_mbps, bool enabled) + int speed_mbps) { - struct sja1105_mac_config_entry dyn_mac; struct sja1105_xmii_params_entry *mii; struct sja1105_mac_config_entry *mac; struct device *dev = priv->ds->dev; @@ -714,8 +706,14 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, sja1105_speed_t speed; int rc; - mii = priv->static_config.tables[BLK_IDX_XMII_PARAMS].entries; + /* On P/Q/R/S, one can read from the device via the MAC reconfiguration + * tables. On E/T, MAC reconfig tables are not readable, only writable. + * We have to *know* what the MAC looks like. For the sake of keeping + * the code common, we'll use the static configuration tables as a + * reasonable approximation for both E/T and P/Q/R/S. + */ mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; + mii = priv->static_config.tables[BLK_IDX_XMII_PARAMS].entries; switch (speed_mbps) { case SPEED_UNKNOWN: @@ -736,26 +734,16 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, return -EINVAL; } - /* If requested, overwrite SJA1105_SPEED_AUTO from the static MAC - * configuration table, since this will be used for the clocking setup, - * and we no longer need to store it in the static config (already told - * hardware we want auto during upload phase). + /* Overwrite SJA1105_SPEED_AUTO from the static MAC configuration + * table, since this will be used for the clocking setup, and we no + * longer need to store it in the static config (already told hardware + * we want auto during upload phase). */ mac[port].speed = speed; - /* On P/Q/R/S, one can read from the device via the MAC reconfiguration - * tables. On E/T, MAC reconfig tables are not readable, only writable. - * We have to *know* what the MAC looks like. For the sake of keeping - * the code common, we'll use the static configuration tables as a - * reasonable approximation for both E/T and P/Q/R/S. - */ - dyn_mac = mac[port]; - dyn_mac.ingress = enabled && mac[port].ingress; - dyn_mac.egress = enabled && mac[port].egress; - /* Write to the dynamic reconfiguration tables */ - rc = sja1105_dynamic_config_write(priv, BLK_IDX_MAC_CONFIG, - port, &dyn_mac, true); + rc = sja1105_dynamic_config_write(priv, BLK_IDX_MAC_CONFIG, port, + &mac[port], true); if (rc < 0) { dev_err(dev, "Failed to write MAC config: %d\n", rc); return rc; @@ -767,9 +755,6 @@ static int sja1105_adjust_port_config(struct sja1105_private *priv, int port, * the clock setup does interrupt the clock signal for a certain time * which causes trouble for all PHYs relying on this signal. */ - if (!enabled) - return 0; - phy_mode = mii->xmii_mode[port]; if (phy_mode != XMII_MODE_RGMII) return 0; @@ -784,9 +769,24 @@ static void sja1105_mac_config(struct dsa_switch *ds, int port, struct sja1105_private *priv = ds->priv; if (!state->link) - sja1105_adjust_port_config(priv, port, SPEED_UNKNOWN, false); - else - sja1105_adjust_port_config(priv, port, state->speed, true); + return; + + sja1105_adjust_port_config(priv, port, state->speed); +} + +static void sja1105_mac_link_down(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface) +{ + sja1105_inhibit_tx(ds->priv, BIT(port), true); +} + +static void sja1105_mac_link_up(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface, + struct phy_device *phydev) +{ + sja1105_inhibit_tx(ds->priv, BIT(port), false); } static void sja1105_phylink_validate(struct dsa_switch *ds, int port, @@ -1241,27 +1241,6 @@ static void sja1105_bridge_leave(struct dsa_switch *ds, int port, sja1105_bridge_member(ds, port, br, false); } -static u8 sja1105_stp_state_get(struct sja1105_private *priv, int port) -{ - struct sja1105_mac_config_entry *mac; - - mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; - - if (!mac[port].ingress && !mac[port].egress && !mac[port].dyn_learn) - return BR_STATE_BLOCKING; - if (mac[port].ingress && !mac[port].egress && !mac[port].dyn_learn) - return BR_STATE_LISTENING; - if (mac[port].ingress && !mac[port].egress && mac[port].dyn_learn) - return BR_STATE_LEARNING; - if (mac[port].ingress && mac[port].egress && mac[port].dyn_learn) - return BR_STATE_FORWARDING; - /* This is really an error condition if the MAC was in none of the STP - * states above. But treating the port as disabled does nothing, which - * is adequate, and it also resets the MAC to a known state later on. - */ - return BR_STATE_DISABLED; -} - /* For situations where we need to change a setting at runtime that is only * available through the static configuration, resetting the switch in order * to upload the new static config is unavoidable. Back up the settings we @@ -1272,27 +1251,18 @@ static int sja1105_static_config_reload(struct sja1105_private *priv) { struct sja1105_mac_config_entry *mac; int speed_mbps[SJA1105_NUM_PORTS]; - u8 stp_state[SJA1105_NUM_PORTS]; int rc, i; mac = priv->static_config.tables[BLK_IDX_MAC_CONFIG].entries; - /* Back up settings changed by sja1105_adjust_port_config and - * sja1105_bridge_stp_state_set and restore their defaults. + /* Back up the dynamic link speed changed by sja1105_adjust_port_config + * in order to temporarily restore it to SJA1105_SPEED_AUTO - which the + * switch wants to see in the static config in order to allow us to + * change it through the dynamic interface later. */ for (i = 0; i < SJA1105_NUM_PORTS; i++) { speed_mbps[i] = sja1105_speed[mac[i].speed]; mac[i].speed = SJA1105_SPEED_AUTO; - if (i == dsa_upstream_port(priv->ds, i)) { - mac[i].ingress = true; - mac[i].egress = true; - mac[i].dyn_learn = true; - } else { - stp_state[i] = sja1105_stp_state_get(priv, i); - mac[i].ingress = false; - mac[i].egress = false; - mac[i].dyn_learn = false; - } } /* Reset switch and send updated static configuration */ @@ -1309,13 +1279,7 @@ static int sja1105_static_config_reload(struct sja1105_private *priv) goto out; for (i = 0; i < SJA1105_NUM_PORTS; i++) { - bool enabled = (speed_mbps[i] != SPEED_UNKNOWN); - - if (i != dsa_upstream_port(priv->ds, i)) - sja1105_bridge_stp_state_set(priv->ds, i, stp_state[i]); - - rc = sja1105_adjust_port_config(priv, i, speed_mbps[i], - enabled); + rc = sja1105_adjust_port_config(priv, i, speed_mbps[i]); if (rc < 0) goto out; } @@ -1933,6 +1897,8 @@ static const struct dsa_switch_ops sja1105_switch_ops = { .set_ageing_time = sja1105_set_ageing_time, .phylink_validate = sja1105_phylink_validate, .phylink_mac_config = sja1105_mac_config, + .phylink_mac_link_up = sja1105_mac_link_up, + .phylink_mac_link_down = sja1105_mac_link_down, .get_strings = sja1105_get_strings, .get_ethtool_stats = sja1105_get_ethtool_stats, .get_sset_count = sja1105_get_sset_count,