From patchwork Tue Apr 16 19:00:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 13632412 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B1F0137C20; Tue, 16 Apr 2024 19:01:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294113; cv=none; b=aWKp0Mu7iCtP6EK5Ivqo2eu8QNXk4WsF5BPkKu0stViINKa0Uou0ZG+PDG6vkkpHkr6gAzsfnYsBStG2G8jWQQvYcZB404Q6qiKQxBqUe3BkrP7ivT/GS+VdudnVJlAGmfTnGWNyQelR9Ra0/oEezA9emENa+Rz0atn8g0sQ7Vk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294113; c=relaxed/simple; bh=BePdJSykhshlcr2YLO3jLgL/BTM8kwYjCt0Yom6wGWQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mQ17tdVvoSZa0BwpBh7o0f9TtGAJhffWvPBcZm69qzZX1MyjCW9/WjTdslJ/cJTxNW0RPc1GPo71aQ6GuvS+KXax4QXIz6wccqtZQENKHLC4LsaqhzpU0GyYZAJ2kpnIIympQ76vyX/T7EpL33fyNg96nG5axzf6DFDr+Tueu90= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YdvyB2jj; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YdvyB2jj" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5176f217b7bso8399335e87.0; Tue, 16 Apr 2024 12:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713294108; x=1713898908; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NYEbbEojAMlE7H2adRDmr9HxTMtGNMen5CotsghfLJA=; b=YdvyB2jjZ9yeS+dCIds8cL4ivoLmYitGAPc03fajWJtCs6cagshFMIP+pYPD1IWjjD Us16XWl3jx6cIGs/4rtp6R6RULJ5xX1itALDg3waHtsJk5RQ2Drg2OPJzYEkRF0LfZBk IdaHAQyzzw3Dz6x0nwW1/D1mdu19fA0AGG8wBWBNbYSI8oyN2/icBxNlEMOUJ+Gc7VSt /o4TP5s/qcXTi9CpzQH9HjQMjlKGPdkx5tRG9NQI5d8oa9bmL1HAnoJKf7Re1HuWOZlb P6gmZkZZaCWPaFAED2Fri7+a3DyJ3GNqeYaOlzqtnRHZPTZyiQVsBw+6s2VAJwC3areA prLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713294108; x=1713898908; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NYEbbEojAMlE7H2adRDmr9HxTMtGNMen5CotsghfLJA=; b=g8/19Y7wU08+xGgoeHiRFR2hO5Zv6p/v2KC3/vtWYTe56AlDkON0donnSkuhT2xuOb +R3VlY1lSe923QMugyWi7e6iSc5HQqc6dNdg5yhncBUmHcuh+hb9ERHBfGoEkwj3VK/e xkV5e6AwUwXtC8+4Ubw/G+4ft0wStCqyt/aZTGgYlqrD8wOSM2p/EOiqQOl1k2kmOI53 i8bF6iJn2eInt5if7QclsktVojZNlgzaA4fB/3BRU0ekcYr8ga1NZoNewbPRI3+cpNao xltluWEx89h8xh3CaOdf38tVGI/KsipL5RsZ5AyWFifZsmWkeAeSu/Q5t4m4X7MBX6Ho TJpA== X-Forwarded-Encrypted: i=1; AJvYcCXle3xKxJEUkqL73CHNA3+dKiwMfB36Incj5xKJEib0iWRjkRklt4Qd2w8VumDTP2bac/cj2XR/dtJu9oL1XTIuoUPd0o6nV/41AB2h X-Gm-Message-State: AOJu0Yx/Vt7jxVg096ga4MVDSq7UVoHawddmQza/uxeFvIXwHzsEvavr voEGbH5xbPhxJjPA/V3S0QfBBQfWat9WMeyif3J62/w01EvZ3vnvymAFH2RA X-Google-Smtp-Source: AGHT+IGgcI1149zan/0AxJ4+r+OgGOtsb9wBpusG6lDB5ojJ02bJheTzCFtVwqehxnLD/P9fJBdOsA== X-Received: by 2002:a19:9151:0:b0:513:cfaa:e618 with SMTP id y17-20020a199151000000b00513cfaae618mr10958242lfj.0.1713294107999; Tue, 16 Apr 2024 12:01:47 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id mm10-20020a170906cc4a00b00a524531a580sm5247981ejb.152.2024.04.16.12.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 12:01:47 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Pawel Dembicki , Russell King , Andrew Lunn , Linus Walleij , Florian Fainelli , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/5] net: dsa: vsc73xx: use read_poll_timeout instead delay loop Date: Tue, 16 Apr 2024 21:00:51 +0200 Message-Id: <20240416190055.3277007-2-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416190055.3277007-1-paweldembicki@gmail.com> References: <20240416190055.3277007-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Switch the delay loop during the Arbiter empty check from vsc73xx_adjust_link() to use read_poll_timeout(). Functionally, one msleep() call is eliminated at the end of the loop in the timeout case. As Russell King suggested: "This [change] avoids the issue that on the last iteration, the code reads the register, tests it, finds the condition that's being waiting for is false, _then_ waits and end up printing the error message - that last wait is rather useless, and as the arbiter state isn't checked after waiting, it could be that we had success during the last wait." Suggested-by: Russell King Reviewed-by: Andrew Lunn Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Signed-off-by: Pawel Dembicki --- drivers/net/dsa/vitesse-vsc73xx-core.c | 30 ++++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index ae70eac3be28..ab5771d4d828 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -268,6 +269,9 @@ #define IS_7398(a) ((a)->chipid == VSC73XX_CHIPID_ID_7398) #define IS_739X(a) (IS_7395(a) || IS_7398(a)) +#define VSC73XX_POLL_SLEEP_US 1000 +#define VSC73XX_POLL_TIMEOUT_US 10000 + struct vsc73xx_counter { u8 counter; const char *name; @@ -779,7 +783,7 @@ static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, * after a PHY or the CPU port comes up or down. */ if (!phydev->link) { - int maxloop = 10; + int ret, err; dev_dbg(vsc->dev, "port %d: went down\n", port); @@ -794,19 +798,17 @@ static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, VSC73XX_ARBDISC, BIT(port), BIT(port)); /* Wait until queue is empty */ - vsc73xx_read(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBEMPTY, &val); - while (!(val & BIT(port))) { - msleep(1); - vsc73xx_read(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBEMPTY, &val); - if (--maxloop == 0) { - dev_err(vsc->dev, - "timeout waiting for block arbiter\n"); - /* Continue anyway */ - break; - } - } + ret = read_poll_timeout(vsc73xx_read, err, + err < 0 || (val & BIT(port)), + VSC73XX_POLL_SLEEP_US, + VSC73XX_POLL_TIMEOUT_US, false, + vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_ARBEMPTY, &val); + if (ret) + dev_err(vsc->dev, + "timeout waiting for block arbiter\n"); + else if (err < 0) + dev_err(vsc->dev, "error reading arbiter\n"); /* Put this port into reset */ vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, From patchwork Tue Apr 16 19:00:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 13632413 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3211137C35; Tue, 16 Apr 2024 19:01:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294113; cv=none; b=UUGoJm1EyboAg/YuwSGGnKIkoDaDf4TyDBa2bWB+87LkFP1ypycSWVh+RBq40sejxERepM35wArAuarSPaYy49HDpUNZ08V9Kb/zZOuFqdEvVQx3Eah71AORCFIrYDyzqWDJrAII9U+plC74S1oonJAqvs/L31lh+bJjqgjuTjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294113; c=relaxed/simple; bh=iunS7RdlSNLfjw+wsEHngEIXajXfHIW2L0HMEkMOhhE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Vz4QbWvQeplfN/1azY+j2IC73f/m2O4tg5yTVn0e6M3fovLJ6jXyMPu2Hlz0memY1rB6e4Vaq/EWmvBka3HCCEMmh0WBJlu0aHH7RRglZYy/bj+mmUlBxGwAGuINLiXczm2yp1JbT+QbeCfYtWz6JPSZRaHBlv53XkFDbZLm2Dc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GuXD+DLv; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GuXD+DLv" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a52223e004dso544119366b.2; Tue, 16 Apr 2024 12:01:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713294110; x=1713898910; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B29Rnbt2mWdYScm6tMkBaB/w2loLTJotW+GQx6ISYPQ=; b=GuXD+DLvr2IM/Yu5JvoPtrmQ4vxyXIINvz1aVzqFUJcFvlrr1HfBUSssxoxSJusIVo pAkt+5jvPM6vF4vUH3KRa4ed86cKfdvOMi8T/8lCbO94eGzozIO3JIwvS19P0UtRM898 mLQjKzfqyovf1Fm0DWMXuXbB3oO69H0ElVXZ+saQTUfY6tDK5L3wNLdGk+Pv5VAJcdHv F72Zwoij9vwuLbYU5jIdU6+fwizZ5zUzPdfSGDawCO+FIIkyL3kbihMFNhmA9les3E2F EUcfXR9DakSPcXX2//K4S+lTvluSBRWK5cB1MypDCr32GLbp6ileD02jJXXVd32e5Am3 7qnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713294110; x=1713898910; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B29Rnbt2mWdYScm6tMkBaB/w2loLTJotW+GQx6ISYPQ=; b=JEae4YETLTg7RE36FJQW/Fd4xPzc4OXaH/xRhnlaz9Vc62/VFNXTtGeVKkEEQ1U3Qe GPVX6Abw3btA4XisXU8J3drOe438J81Giaz+DgG7bLK6aBn6QBedSW2NioeD2McMs1Wo ZfERFckaZQAjxiBynDNPNyG4Sy1VsKhkw5YSNBcqhWgFxJGP1v6IO+NM8xl9RUhewh/B fUt3BSemZNwXd4RLrsFiEI3QrCl9I4IgUizunodNYRKE1bK6eEZZnCi45ve/hQxxAOiy 3ZVll25Mrwl6nPg+x/4wwDU22D6WrWgRbR7kioX0BTqBVFJG/rxht6yHhWiprztNzeC7 O5QQ== X-Forwarded-Encrypted: i=1; AJvYcCU/5fNQUnzG0OTCGod96ZdcFwKPV/oUNX5bk7cun60jKwSrudxO0uZZtXVHsa6DMBDW6e14A4f3I2ubtSaZnINNC/X0Tpz6UnFu7E64 X-Gm-Message-State: AOJu0Yz1SZrCwoIv4zazhnlGS3dsPSd3w86RvaBj9tXbsLnli6UoXaCn AHu0TG07svwRtGugUrYIWFb5p3yeoCasJicuprpm03sjvhwDEibf7tXgtQnZ X-Google-Smtp-Source: AGHT+IGKWI3mBZJ0DB2D1w9ShREiOPgvZ1tmXJBCNMGpDQbO4ODlvFN1Z263+Cf6qWxGGSZosXH75g== X-Received: by 2002:a17:907:1747:b0:a4e:65e5:9ffc with SMTP id lf7-20020a170907174700b00a4e65e59ffcmr10374442ejc.75.1713294109643; Tue, 16 Apr 2024 12:01:49 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id mm10-20020a170906cc4a00b00a524531a580sm5247981ejb.152.2024.04.16.12.01.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 12:01:49 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Pawel Dembicki , Florian Fainelli , Linus Walleij , Russell King , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/5] net: dsa: vsc73xx: convert to PHYLINK Date: Tue, 16 Apr 2024 21:00:52 +0200 Message-Id: <20240416190055.3277007-3-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416190055.3277007-1-paweldembicki@gmail.com> References: <20240416190055.3277007-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This patch replaces the adjust_link api with the phylink apis that provide equivalent functionality. The remaining functionality from the adjust_link is now covered in the phylink_mac_link_* and phylink_mac_config. Removes: .adjust_link Adds: .phylink_mac_config .phylink_mac_link_up .phylink_mac_link_down Reviewed-by: Florian Fainelli Reviewed-by: Linus Walleij Reviewed-by: Russell King (Oracle) Signed-off-by: Pawel Dembicki --- drivers/net/dsa/vitesse-vsc73xx-core.c | 235 ++++++++++++------------- 1 file changed, 109 insertions(+), 126 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index ab5771d4d828..cb2e7e256279 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -717,52 +717,43 @@ static void vsc73xx_init_port(struct vsc73xx *vsc, int port) port, VSC73XX_C_RX0, 0); } -static void vsc73xx_adjust_enable_port(struct vsc73xx *vsc, - int port, struct phy_device *phydev, - u32 initval) +static void vsc73xx_reset_port(struct vsc73xx *vsc, int port, u32 initval) { - u32 val = initval; - u8 seed; - - /* Reset this port FIXME: break out subroutine */ - val |= VSC73XX_MAC_CFG_RESET; - vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, val); - - /* Seed the port randomness with randomness */ - get_random_bytes(&seed, 1); - val |= seed << VSC73XX_MAC_CFG_SEED_OFFSET; - val |= VSC73XX_MAC_CFG_SEED_LOAD; - val |= VSC73XX_MAC_CFG_WEXC_DIS; - vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, val); + int ret, err; + u32 val; - /* Flow control for the PHY facing ports: - * Use a zero delay pause frame when pause condition is left - * Obey pause control frames - * When generating pause frames, use 0xff as pause value - */ - vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_FCCONF, - VSC73XX_FCCONF_ZERO_PAUSE_EN | - VSC73XX_FCCONF_FLOW_CTRL_OBEY | - 0xff); + /* Disable RX on this port */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, + VSC73XX_MAC_CFG, + VSC73XX_MAC_CFG_RX_EN, 0); - /* Disallow backward dropping of frames from this port */ + /* Discard packets */ vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_SBACKWDROP, BIT(port), 0); + VSC73XX_ARBDISC, BIT(port), BIT(port)); + + /* Wait until queue is empty */ + ret = read_poll_timeout(vsc73xx_read, err, + err < 0 || (val & BIT(port)), + VSC73XX_POLL_SLEEP_US, + VSC73XX_POLL_TIMEOUT_US, false, + vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_ARBEMPTY, &val); + if (ret) + dev_err(vsc->dev, + "timeout waiting for block arbiter\n"); + else if (err < 0) + dev_err(vsc->dev, "error reading arbiter\n"); - /* Enable TX, RX, deassert reset, stop loading seed */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, - VSC73XX_MAC_CFG, - VSC73XX_MAC_CFG_RESET | VSC73XX_MAC_CFG_SEED_LOAD | - VSC73XX_MAC_CFG_TX_EN | VSC73XX_MAC_CFG_RX_EN, - VSC73XX_MAC_CFG_TX_EN | VSC73XX_MAC_CFG_RX_EN); + /* Put this port into reset */ + vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, + VSC73XX_MAC_CFG_RESET | initval); } -static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, - struct phy_device *phydev) +static void vsc73xx_phylink_mac_config(struct dsa_switch *ds, int port, + unsigned int mode, + const struct phylink_link_state *state) { struct vsc73xx *vsc = ds->priv; - u32 val; - /* Special handling of the CPU-facing port */ if (port == CPU_PORT) { /* Other ports are already initialized but not this one */ @@ -778,102 +769,92 @@ static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, VSC73XX_ADVPORTM_ENA_GTX | VSC73XX_ADVPORTM_DDR_MODE); } +} + +static void vsc73xx_phylink_mac_link_down(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface) +{ + struct vsc73xx *vsc = ds->priv; - /* This is the MAC confiuration that always need to happen - * after a PHY or the CPU port comes up or down. + /* This routine is described in the datasheet (below ARBDISC register + * description) */ - if (!phydev->link) { - int ret, err; - - dev_dbg(vsc->dev, "port %d: went down\n", - port); - - /* Disable RX on this port */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, - VSC73XX_MAC_CFG, - VSC73XX_MAC_CFG_RX_EN, 0); - - /* Discard packets */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBDISC, BIT(port), BIT(port)); - - /* Wait until queue is empty */ - ret = read_poll_timeout(vsc73xx_read, err, - err < 0 || (val & BIT(port)), - VSC73XX_POLL_SLEEP_US, - VSC73XX_POLL_TIMEOUT_US, false, - vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBEMPTY, &val); - if (ret) - dev_err(vsc->dev, - "timeout waiting for block arbiter\n"); - else if (err < 0) - dev_err(vsc->dev, "error reading arbiter\n"); - - /* Put this port into reset */ - vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, - VSC73XX_MAC_CFG_RESET); - - /* Accept packets again */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBDISC, BIT(port), 0); - - /* Allow backward dropping of frames from this port */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_SBACKWDROP, BIT(port), BIT(port)); - - /* Receive mask (disable forwarding) */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, - VSC73XX_RECVMASK, BIT(port), 0); + vsc73xx_reset_port(vsc, port, 0); - return; - } + /* Allow backward dropping of frames from this port */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_SBACKWDROP, BIT(port), BIT(port)); - /* Figure out what speed was negotiated */ - if (phydev->speed == SPEED_1000) { - dev_dbg(vsc->dev, "port %d: 1000 Mbit mode full duplex\n", - port); - - /* Set up default for internal port or external RGMII */ - if (phydev->interface == PHY_INTERFACE_MODE_RGMII) - val = VSC73XX_MAC_CFG_1000M_F_RGMII; - else - val = VSC73XX_MAC_CFG_1000M_F_PHY; - vsc73xx_adjust_enable_port(vsc, port, phydev, val); - } else if (phydev->speed == SPEED_100) { - if (phydev->duplex == DUPLEX_FULL) { - val = VSC73XX_MAC_CFG_100_10M_F_PHY; - dev_dbg(vsc->dev, - "port %d: 100 Mbit full duplex mode\n", - port); - } else { - val = VSC73XX_MAC_CFG_100_10M_H_PHY; - dev_dbg(vsc->dev, - "port %d: 100 Mbit half duplex mode\n", - port); - } - vsc73xx_adjust_enable_port(vsc, port, phydev, val); - } else if (phydev->speed == SPEED_10) { - if (phydev->duplex == DUPLEX_FULL) { - val = VSC73XX_MAC_CFG_100_10M_F_PHY; - dev_dbg(vsc->dev, - "port %d: 10 Mbit full duplex mode\n", - port); - } else { - val = VSC73XX_MAC_CFG_100_10M_H_PHY; - dev_dbg(vsc->dev, - "port %d: 10 Mbit half duplex mode\n", - port); - } - vsc73xx_adjust_enable_port(vsc, port, phydev, val); - } else { - dev_err(vsc->dev, - "could not adjust link: unknown speed\n"); - } + /* Receive mask (disable forwarding) */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_RECVMASK, BIT(port), 0); +} + +static void vsc73xx_phylink_mac_link_up(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface, + struct phy_device *phydev, + int speed, int duplex, + bool tx_pause, bool rx_pause) +{ + struct vsc73xx *vsc = ds->priv; + u32 val; + u8 seed; + + if (speed == SPEED_1000) + val = VSC73XX_MAC_CFG_GIGA_MODE | VSC73XX_MAC_CFG_TX_IPG_1000M; + else + val = VSC73XX_MAC_CFG_TX_IPG_100_10M; + + if (interface == PHY_INTERFACE_MODE_RGMII) + val |= VSC73XX_MAC_CFG_CLK_SEL_1000M; + else + val |= VSC73XX_MAC_CFG_CLK_SEL_EXT; + + if (duplex == DUPLEX_FULL) + val |= VSC73XX_MAC_CFG_FDX; + + /* This routine is described in the datasheet (below ARBDISC register + * description) + */ + vsc73xx_reset_port(vsc, port, val); + + /* Seed the port randomness with randomness */ + get_random_bytes(&seed, 1); + val |= seed << VSC73XX_MAC_CFG_SEED_OFFSET; + val |= VSC73XX_MAC_CFG_SEED_LOAD; + val |= VSC73XX_MAC_CFG_WEXC_DIS; + vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, val); + + /* Flow control for the PHY facing ports: + * Use a zero delay pause frame when pause condition is left + * Obey pause control frames + * When generating pause frames, use 0xff as pause value + */ + vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_FCCONF, + VSC73XX_FCCONF_ZERO_PAUSE_EN | + VSC73XX_FCCONF_FLOW_CTRL_OBEY | + 0xff); + + /* Accept packets again */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_ARBDISC, BIT(port), 0); /* Enable port (forwarding) in the receieve mask */ vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_RECVMASK, BIT(port), BIT(port)); + + /* Disallow backward dropping of frames from this port */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_SBACKWDROP, BIT(port), 0); + + /* Enable TX, RX, deassert reset, stop loading seed */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, + VSC73XX_MAC_CFG, + VSC73XX_MAC_CFG_RESET | VSC73XX_MAC_CFG_SEED_LOAD | + VSC73XX_MAC_CFG_TX_EN | VSC73XX_MAC_CFG_RX_EN, + VSC73XX_MAC_CFG_TX_EN | VSC73XX_MAC_CFG_RX_EN); } static int vsc73xx_port_enable(struct dsa_switch *ds, int port, @@ -1060,7 +1041,9 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .setup = vsc73xx_setup, .phy_read = vsc73xx_phy_read, .phy_write = vsc73xx_phy_write, - .adjust_link = vsc73xx_adjust_link, + .phylink_mac_config = vsc73xx_phylink_mac_config, + .phylink_mac_link_down = vsc73xx_phylink_mac_link_down, + .phylink_mac_link_up = vsc73xx_phylink_mac_link_up, .get_strings = vsc73xx_get_strings, .get_ethtool_stats = vsc73xx_get_ethtool_stats, .get_sset_count = vsc73xx_get_sset_count, From patchwork Tue Apr 16 19:00:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 13632414 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26BBC137C4F; Tue, 16 Apr 2024 19:01:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294114; cv=none; b=szFCGaRfOxjAfKozZEtIgCza75C9DrjOolA6VYqcBR0V6r+XnfFZUdE4HdJGD7TkF5/9t53UM2uHqZTmcxPnqhgG43Qv0x7I3ChD5b2ZpAUacKYXHURj6aOFszfp9Ex3OwVJQrx61bNrn8WqFCk9DluloJ8vsRacBhT0mSmFpow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294114; c=relaxed/simple; bh=eP76AH0to6uy37hdR0BpiHwMNRT3oXZ7/bfC04nZexc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GIkUsRIm4RTgEv3VpE+p5Eby2o2Y6HH55LIwnS5iz+xuBBeCQK5pg8Sm6yczTixTe6KUNOEi4j5nQNOoGYVdjafkamRal7NsH+jsBH+C4ydCZ83u5VCmUZaw81Z2MoLgXXFLqZ0TsRxrGpNdaKDn9vezDLFvIhtzgB4V27OpzQw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g1cy2K07; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g1cy2K07" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a44ad785a44so579924266b.3; Tue, 16 Apr 2024 12:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713294111; x=1713898911; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uY+yGYsg6qN0h3E2Q9QI5zY4qFMN3uFTB/yfBOf/FWE=; b=g1cy2K077BpmWCSjLoc9h2W98TzgyZWoKJluQBdAL5xXQt1BDF/cr1KtyqDoLgyYqe 25XHgKXo52Ov2LGehZj1DhkXTwRyULYso1cyvgHfXgzeXCsEYSSAkEunkOGJpNTm4Ror TwfePA+d8j58nfVNeIWBahLcmXoRwkSVMT/HyrR1MT7KYvU1opO85QESycPR7akU3vcO hsEGxyl3bQKXAAWIbGMzmFObm6U83u4ayYjkdM3U3rwaJFjg+SBl9lTpFgd7YEVPATfW jkyuJgvYo5psxc0r1rljnMskVxyzrEsIdF9VoYdwtgJrKviw+x4HD4vfkB0Ar0vB7OVy EhcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713294111; x=1713898911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uY+yGYsg6qN0h3E2Q9QI5zY4qFMN3uFTB/yfBOf/FWE=; b=EX3faaYSuL9baUwJ0pH9vONxjH+Bu9ihaBxmWR+DYGCseBsopPizk5h7gJvNLTA3n6 PKCFXGDkKfUKHzXxZuSNU1Lg0xKnnPCTqFf20MWY1HAt/JpOSUBXyFrpj2KmCxapfaVA brfnEw4Y/rQxchAPAgAoMCR0lVE7fItMhWP8h9JqdClVgFNLjm/RdwPCFbQ6LLUYgHHW fuxSq9EABv8EwmzToQKNlO8tCSPLaMecZ0jhoRMn2YamsT5S/qgA9AJwdZZAQ90OaPzz lRD5wtU2V2SDbIJOWiDq75FutGyt6dUH5hHbFjz7TjocRS1h1zQ7SvJlkI4385mWJTZ7 dtjA== X-Forwarded-Encrypted: i=1; AJvYcCXj+LCsMhXdzmQMrcafwTSGkCJQ14V7mWKUouJP5SddTbrOyfQoEYSee3KIFd9WpUe02jJste6BZTEjL3yH4EaOPOK40l7euTWlPNI8 X-Gm-Message-State: AOJu0YxS8pAp+Y68NIHCZgaBlRU4onWQWCIKhPuU8BvUFYYxAVFT4x5a 1Gm4i1k6emwVTBfQUQ3bAQu9kM21OCN2zuZE38Gz2vyVXJGrNW2g6MQdPgR5 X-Google-Smtp-Source: AGHT+IFEBH5z1ulSd1Fd+3attlK6nznzQ44bS3x84UkPsP4taaapzy6wG1fZEhW1di9CsUGisjbx0w== X-Received: by 2002:a17:906:7145:b0:a52:8a8a:593a with SMTP id z5-20020a170906714500b00a528a8a593amr3393313ejj.2.1713294111183; Tue, 16 Apr 2024 12:01:51 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id mm10-20020a170906cc4a00b00a524531a580sm5247981ejb.152.2024.04.16.12.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 12:01:50 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Pawel Dembicki , Russell King , Linus Walleij , Florian Fainelli , Vladimir Oltean , Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/5] net: dsa: vsc73xx: use macros for rgmii recognition Date: Tue, 16 Apr 2024 21:00:53 +0200 Message-Id: <20240416190055.3277007-4-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416190055.3277007-1-paweldembicki@gmail.com> References: <20240416190055.3277007-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org It's preparation for future use. At this moment, the RGMII port is used only for a connection to the MAC interface, but in the future, someone could connect a PHY to it. Using the "phy_interface_mode_is_rgmii" macro allows for the proper recognition of all RGMII modes. Suggested-by: Russell King (Oracle) Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean Reviewed-by: Russell King (Oracle) Signed-off-by: Pawel Dembicki --- drivers/net/dsa/vitesse-vsc73xx-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index cb2e7e256279..8ed8fc997d6d 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -807,7 +807,7 @@ static void vsc73xx_phylink_mac_link_up(struct dsa_switch *ds, int port, else val = VSC73XX_MAC_CFG_TX_IPG_100_10M; - if (interface == PHY_INTERFACE_MODE_RGMII) + if (phy_interface_mode_is_rgmii(interface)) val |= VSC73XX_MAC_CFG_CLK_SEL_1000M; else val |= VSC73XX_MAC_CFG_CLK_SEL_EXT; From patchwork Tue Apr 16 19:00:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 13632415 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D85221386D0; Tue, 16 Apr 2024 19:01:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294116; cv=none; b=AqkXV2xbwF6joVwHX0dhsJmygQxw5z37pOxiIbtjQQdAf2qI3uTQz3PrtToAJAgpZ2lYQXz9is//2EI2aqOKvO+eWnySncRBJ8R5xp2QtAlaVXVX6lQH4/pnQECdbewNKiubKPpYiwqkrfDq5MwCBCUSOj4ePaEKb1d+lQh8FHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294116; c=relaxed/simple; bh=7L1j0x6OhKtrQNLFBM1nnXbMMwq5wuw0psNfkPFdO4w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TKemdiSCN8TNBjDjfjTTLR1yOSLbJLOwE5xVEAbieHbXoH3BbyBL9iYNwnqrqufoxTKVk4k7WVb9flqA8LnyOMtdHDgjbdD9dtBP+Hq28YTHL6LdBHyULUd+2WVg6ABihSWDcvsmQ4d+86iiMVou3/sX3MwALP2wScZRcUYFTGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Lf1sV/s6; arc=none smtp.client-ip=209.85.208.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Lf1sV/s6" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-56fd7df9ea9so5610804a12.0; Tue, 16 Apr 2024 12:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713294113; x=1713898913; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SUzg9stfaBGBJD0DXmvP+Xu180vDdPP5gPXWEt3B/dA=; b=Lf1sV/s6zKfWtlSzl+7WV615qOt1FGmZSs2/tkPC0qtseIHEHnwYwVadeBNP6zI4zh xINI0rvft9YRc97JkWqXU+J2frbR7vLVC/+VU2seglWv1wlCAiWhjnkH1gEUCAho2rAz HFfwkGfhMp2WOODFezLGS1fnKp4uU6Vj9290xo5fv+ddveFnmBDjrHXU0S41qUqFgtz8 Og7JtVs5j5bvULJWJiTaZEAJwk+Wua0nAShHPc9lNBVnB1v0d2hgqfslvWNnfxe/Yp2s +Jsm25Z6FDs7HqoB+SzSRQbyyftGtorl6mX0kKFC7u5h/o5E+bACLp/v0Xa6a/L0fpA3 65ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713294113; x=1713898913; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SUzg9stfaBGBJD0DXmvP+Xu180vDdPP5gPXWEt3B/dA=; b=Vf58iM7IpZIztmXWqW4vZV0Sf++kzTeedNBpLzwIP+xhQEvej4ShOhJ8DpPStfXnY0 H4BYsCok0xjHoL91/Bi2AgxRi0bOZjIi6b8Y5oPZKCRNN7g7TAH3myZnWeu/gcT6M1cs +/THL17wIfRdAfwStBfsI7jrv2gTwi0XiXzy0l3UCFsfPR+tUlk4KCav4F4EGINCBZU9 Gpdl0NiZkBvYYe5aTK8UZJagWEK8+PltF+Z+UWxq5cNR6+0TygcIGvRznwOC0RlrqouJ Qi9oy6GFSGgtI8oXk5II+gOCJmwFT6jMQNWbb7nmS4ZYhjR4rnPnBid6khTBA3+Bwjbw o4uA== X-Forwarded-Encrypted: i=1; AJvYcCUVWwCSUEL8amfwEnokImov9OQnTrhM9uJlAXUXF/p6i0HwjimTiNGK7ypqH901i4p1JAnZ2r+UoWXfy7RHi9QTLtzscSaxW/Kv2K11 X-Gm-Message-State: AOJu0YzUJ0uBfTUnmNa/yKuK7NtUx+2+a/hRthLju1ETj9+v/Bsl6vn+ E7lTf0naDv4BjxoJ8DKUMBZmE+rBWo+zcnuvX1E7ev6wLTWW7qfMmrdfGElA X-Google-Smtp-Source: AGHT+IHiby57dumfGXRpJITan2ipUCR/MNemrzvBhF1c2p2KSHdpZ847RLQr1ppsTKjBqYG/VyaBrw== X-Received: by 2002:a17:906:3c4d:b0:a52:28ba:2ce0 with SMTP id i13-20020a1709063c4d00b00a5228ba2ce0mr8156527ejg.29.1713294112720; Tue, 16 Apr 2024 12:01:52 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id mm10-20020a170906cc4a00b00a524531a580sm5247981ejb.152.2024.04.16.12.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 12:01:52 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Pawel Dembicki , Vladimir Oltean , Linus Walleij , Florian Fainelli , Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next 4/5] net: dsa: vsc73xx: Add define for max num of ports Date: Tue, 16 Apr 2024 21:00:54 +0200 Message-Id: <20240416190055.3277007-5-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416190055.3277007-1-paweldembicki@gmail.com> References: <20240416190055.3277007-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This patch introduces a new define: VSC73XX_MAX_NUM_PORTS, which can be used in the future instead of a hardcoded value. Currently, the only hardcoded value is vsc->ds->num_ports. It is being replaced with the new define. Suggested-by: Vladimir Oltean Reviewed-by: Vladimir Oltean Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Signed-off-by: Pawel Dembicki --- drivers/net/dsa/vitesse-vsc73xx-core.c | 13 +------------ drivers/net/dsa/vitesse-vsc73xx.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index 8ed8fc997d6d..425999d7bf41 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -1180,23 +1180,12 @@ int vsc73xx_probe(struct vsc73xx *vsc) vsc->addr[0], vsc->addr[1], vsc->addr[2], vsc->addr[3], vsc->addr[4], vsc->addr[5]); - /* The VSC7395 switch chips have 5+1 ports which means 5 - * ordinary ports and a sixth CPU port facing the processor - * with an RGMII interface. These ports are numbered 0..4 - * and 6, so they leave a "hole" in the port map for port 5, - * which is invalid. - * - * The VSC7398 has 8 ports, port 7 is again the CPU port. - * - * We allocate 8 ports and avoid access to the nonexistant - * ports. - */ vsc->ds = devm_kzalloc(dev, sizeof(*vsc->ds), GFP_KERNEL); if (!vsc->ds) return -ENOMEM; vsc->ds->dev = dev; - vsc->ds->num_ports = 8; + vsc->ds->num_ports = VSC73XX_MAX_NUM_PORTS; vsc->ds->priv = vsc; vsc->ds->ops = &vsc73xx_ds_ops; diff --git a/drivers/net/dsa/vitesse-vsc73xx.h b/drivers/net/dsa/vitesse-vsc73xx.h index 30b1f0a36566..fee1378508b5 100644 --- a/drivers/net/dsa/vitesse-vsc73xx.h +++ b/drivers/net/dsa/vitesse-vsc73xx.h @@ -3,6 +3,17 @@ #include #include +/* The VSC7395 switch chips have 5+1 ports which means 5 ordinary ports and + * a sixth CPU port facing the processor with an RGMII interface. These ports + * are numbered 0..4 and 6, so they leave a "hole" in the port map for port 5, + * which is invalid. + * + * The VSC7398 has 8 ports, port 7 is again the CPU port. + * + * We allocate 8 ports and avoid access to the nonexistent ports. + */ +#define VSC73XX_MAX_NUM_PORTS 8 + /** * struct vsc73xx - VSC73xx state container */ From patchwork Tue Apr 16 19:00:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 13632416 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A06413473F; Tue, 16 Apr 2024 19:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294117; cv=none; b=VRMUPGoUUlm4WvmIB4k5xRPEqeRce68gz4QS0pCrXg+Ap6kt4tCMMUeZbxO84x3ptyGEoxjFohfoj2dzKOKcEaq1Sr7gBKNg1l0zVuKvW6agwOtxid+hAJppdUhyl7px9WvvnWnz3ERAynpMwdMUlqXaipllDa7VXC+bSxzJeGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713294117; c=relaxed/simple; bh=Iqa1jZFbSawQjr+CJUz7nVCyrQTIWjYRq/y+SFNwWHo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=buIWiyj92RdIaL58E0VDSz6GD2j2V4dLRxGPrYRbcIybLgOXl05su7HIh++/ekzDvwAjmDLr4H/XjHIohsGL8P7p/im17frvAwAy+e0ZEuoz1MClp3iKU54kccSZu5iYSyfYj00XZRSjyFtHCcIQb8Yql3u3JnYTlPyvZbZIyTc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=h4kccgOM; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h4kccgOM" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a523524e5baso581109566b.3; Tue, 16 Apr 2024 12:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713294114; x=1713898914; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jZpJcz4q96m6H/9BjAU0EaM5FaeOMwdztZTURkwBQn4=; b=h4kccgOMtt4cuiihkEbZv9W4jVNGW6/Cx5Bcwu1d7Nh8iGC6LmrIQpZZE8ttyAhp65 MfAErLRTnR/CjOkcrTMI5ZZQm1GhwpoZtlHGffEwSxb35chPwCbndEFoW74UvSjRG5hN CmDjqkY80VFs4VVhejJznEIEzfrJmoulC8SZq3R81V1KN+9GUNcVQ67ArgGn34VezDPt 6/5Hr8UxhJFFzWV4+wROb1fm4bRx5CryP96W8EMSt7s/xOTjXLxgVyZMEUWPPwZreXjW MqqetXuCB8rUOyqEq+FK4yVVwt4paaFFtZ7TmwhkOA2xv2iaenCVo2heJlJQhy7sI6/9 o3Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713294114; x=1713898914; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jZpJcz4q96m6H/9BjAU0EaM5FaeOMwdztZTURkwBQn4=; b=ElV1k+eUbj9Aj67AKEERP96yByGm73mvJCKG/S9DN8gBYJTzQ2eVPNrman6zel5uHc 6SYt8HcHAPInttEsh7zq0walBH0WhktXIr8+dbOJm/bErLB/wG4sLfyHsI0epdJA5Ljt nW/Ts5R2porFNwywp/dh+90mgMZY5fD63PrByNbr1LgbecyrjiG64uDlMNMJt2SlNOwP vxp8MvGcxt3NAB4gZT3oQgFIP+chUkL4jMUHSs9IgDeNiykV0pLhMIogcJcZKhv4DuT9 ZodvMG5KkYXFjtkQ/0yvjYruVWWDJdhCKWcA7Msbz8YJo27kogK1JugQOpCwowRpvr/x tGqg== X-Forwarded-Encrypted: i=1; AJvYcCVcqQSEh1Fp9Fuhwi8/44tYMJhc3EA52HiArSm/nciZvDPKIBPgTfOSWI3k2WvWH9ZDXiHXPBFE3XcgIQT0tmKbo5pbwsIA2R941MQr X-Gm-Message-State: AOJu0Yz44zK2ICv28HAj0XpLsfKTTfN/8v3fIDhjIm+OVSev1WRa88Ds I1g9p6kOAzWurgNPHjip2hnCD6t4UrGGnPxVP1bHbyBkGVx9FvzKEk3uSI1y X-Google-Smtp-Source: AGHT+IFtz5PGkW2Z9Ps1y2/0w7YPPFU74m3LSkzcbMbLPyvEGuQON7EzjEJ/yIrXR1c1c/POvEskiQ== X-Received: by 2002:a17:906:5799:b0:a52:6c4b:cc18 with SMTP id k25-20020a170906579900b00a526c4bcc18mr5099905ejq.71.1713294114162; Tue, 16 Apr 2024 12:01:54 -0700 (PDT) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id mm10-20020a170906cc4a00b00a524531a580sm5247981ejb.152.2024.04.16.12.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 12:01:53 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Pawel Dembicki , Linus Walleij , Florian Fainelli , Vladimir Oltean , Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/5] net: dsa: vsc73xx: add structure descriptions Date: Tue, 16 Apr 2024 21:00:55 +0200 Message-Id: <20240416190055.3277007-6-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416190055.3277007-1-paweldembicki@gmail.com> References: <20240416190055.3277007-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org This commit adds updates to the documentation describing the structures used in vsc73xx. This will help prevent kdoc-related issues in the future. Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean Signed-off-by: Pawel Dembicki --- drivers/net/dsa/vitesse-vsc73xx.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx.h b/drivers/net/dsa/vitesse-vsc73xx.h index fee1378508b5..2997f7e108b1 100644 --- a/drivers/net/dsa/vitesse-vsc73xx.h +++ b/drivers/net/dsa/vitesse-vsc73xx.h @@ -15,7 +15,16 @@ #define VSC73XX_MAX_NUM_PORTS 8 /** - * struct vsc73xx - VSC73xx state container + * struct vsc73xx - VSC73xx state container: main data structure + * @dev: The device pointer + * @reset: The descriptor for the GPIO line tied to the reset pin + * @ds: Pointer to the DSA core structure + * @gc: Main structure of the GPIO controller + * @chipid: Storage for the Chip ID value read from the CHIPID register of the + * switch + * @addr: MAC address used in flow control frames + * @ops: Structure with hardware-dependent operations + * @priv: Pointer to the configuration interface structure */ struct vsc73xx { struct device *dev; @@ -28,6 +37,11 @@ struct vsc73xx { void *priv; }; +/** + * struct vsc73xx_ops - VSC73xx methods container + * @read: Method for register reading over the hardware-dependent interface + * @write: Method for register writing over the hardware-dependent interface + */ struct vsc73xx_ops { int (*read)(struct vsc73xx *vsc, u8 block, u8 subblock, u8 reg, u32 *val);