From patchwork Tue Feb 13 22:03:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp838277dyb; Tue, 13 Feb 2024 14:16:20 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXiAAyRSldgPoo2+4j8RVyNOI3KttO0WgMdjlabA0NzJrWOPvGbh1pltscpWcfew0osYzdgMhSilQisnJp58Eubtd6F2A== X-Google-Smtp-Source: AGHT+IFMQBOLYZRIBeWNWI0N9C30rT4//J2LOuB9CZHBg1ZD9BoIzGltViWaNEiZeVwdKs3X4Nz9 X-Received: by 2002:a05:6a20:c890:b0:19e:a30e:7333 with SMTP id hb16-20020a056a20c89000b0019ea30e7333mr1107031pzb.25.1707862579875; Tue, 13 Feb 2024 14:16:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862579; cv=pass; d=google.com; s=arc-20160816; b=YW0gTxihU4AstZScICnCQsfEEqKqOAg9egc3zmZ1g9Dyrt/Wp/cGe5vBr7AeqfJRQ+ MgsJdnjkXHEVdIy/EQhAvTyQEezYq7oBw2CQSyCaxQXzm437i1Sfq6YUOOSDJCFFpxcu G9Uvhn+LNTInnJU4WSDDYmwabX66gYEM9YBU5DefbArf80joM2cLeoVLc+uciyiNhr1V Qe/N2z4hed6TiJJzYxQlBSL9sTZQmroqupKiH4UMG4Lhjgr5NJFghSi9EJuOHZxStVGY ZRQOmsqK3Ip5ZM3cK/Gck0BR3S4SBPOe5u7H0SNSNVYcxV08Jknb2hFHvG2eNW9cVcnr Bljg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=silDmACUiIN4OlWaMhBDDBG9aJpm66HeXuSytRzPWjU=; fh=3RoGHl0mZJuO2GQGfHUm4QtI7Ea7RFLrEvevqZGS584=; b=u5clhYBYdqYWJHIj8x4SydraoUv1NApCjnxlj4ZPZxVHrnSTctnvkCc+A0oxsTgYFA UmywQUMwz953RQy4smJXNAp67XECyqsr44yskaf+5WV0dWICRReOxYr8SsHga73RGqZl GfePia7OQsqK0gAP2z1zFxNyWn/69wRfb5TybPikSCQUbnc5Ov+fTxQCUnpVXzENN/hL J6FnstcK86USYScUxxC+xoNGEjiWm//Pr2/dVjgL+R0HuG0CJSfYNsJlbOJsj1Oye4jQ xbKbW5tnDYbcwjHzXPK8hyaH398/tnf8IB1WE3CPM+sooaxRvvD03ywAcBAa1xKMtfjC SKtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jXwLVOO6; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64420-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64420-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCUSb4NdI+vLP8SqNJoWn0J7DQpJDbpwwvz7/18NICPN4QT4cuHXImMJ0dpKLv8AlndtqdiD2n9+h23gCpcjn0N91Vmcww== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h26-20020a63385a000000b005d549553c07si2547668pgn.598.2024.02.13.14.16.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:16:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64420-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jXwLVOO6; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64420-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64420-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3E73F295BBA for ; Tue, 13 Feb 2024 22:07:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 751126341F; Tue, 13 Feb 2024 22:05:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jXwLVOO6" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 10BA16217F; Tue, 13 Feb 2024 22:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861902; cv=none; b=ipKMfI2ucwY7kPXyvrk1aGVt05wunZuwSHDIaXwCUJESUQqIGCpuPWW85OethdYQ1NReRdzbZEGbSAxQdN0UhiUNTetowgsNHMCk2oEniRRFSpXWuxT3IjWVbP2ZDmRyPu+5i5XeWAcEPMa3PSZ4VbuPGsnUl1nwZgNv3kR4lxg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861902; c=relaxed/simple; bh=yNXlZ++7NAGaOX0YYjxHAN+47k2zU7Fw/VvDET7htxY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BmgwyV5A8cCsfEge+beTXBVN8eUBDTTqIt6x3A5CGBfKuTY33WjLc1GTF8M5sLH9lc9J1h3LkScHZYbZ3umUtpxdFJuuCOHqzn7x9zhXzQLBWemBImZsIiPKFDLTyLPm1F68g+OfW6noSg988oY9HBmSwrD7VJSKopxZIyiqWJE= 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=jXwLVOO6; arc=none smtp.client-ip=209.85.218.45 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 Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a3c1a6c10bbso421905266b.3; Tue, 13 Feb 2024 14:04:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861898; x=1708466698; 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=silDmACUiIN4OlWaMhBDDBG9aJpm66HeXuSytRzPWjU=; b=jXwLVOO6EOauyFKCsoWBBdPtHNxyhAYfovuE8UflP7BObmCfpNI1v7sOQAJLEPj8s9 Oba80e+noQlVz1a9oWnTOSdO+5TZJb7bUN39nFrBUtTJMk9YQTU7fMxEopEJgrO6r4f8 wbFLmWWn6lvXo1HrJisq4CfslYGqnYg2z5J0cb1EcLUDPyBr/MeA+b1EbIqHtNhnxhh+ XASmlWZazy15XVzWXdBrtX0OengYrnY9BdSs9VxFx0xUSSxTqRwqBq+KqDbsqq1TtXy3 7cbsyw2oEPfm69BSY2JQy9rGr/0gL8jKqaILwMASEOnH9q49dbY2Oc+JxtDrZQurYc7S qlzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861898; x=1708466698; 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=silDmACUiIN4OlWaMhBDDBG9aJpm66HeXuSytRzPWjU=; b=VejM2BBvn3mUeI7kPl/x+AmCCmOd/Pu9IU8+mzBdSkr9oPiz2Pjb4xK5gGpf2IGdM+ RvygogrHGixEKcCdy4oMqVUd/KGTPldOx/ckFy5M4vxL+auHyZE1uL2fqW6j3Zs7Dy9J 9Z/vGdJyrwBINYNd23ow7neDHJHcYGmhJpFyrtWLdw72v+KikfuMyBcvMslFHLUVSryW ErnWEum+JceEZxq6VNGwoOEETy/egPSQIbKPPYG62dTjPXmHOQu21srtofALyjORNhOQ lo6Ad1IC2LNGaQCvh1QfsQ5ZJW6eon4Os79Y5CT0Sdce+9z6Tl2pgozYI5NBqOUL8C4p ylBQ== X-Forwarded-Encrypted: i=1; AJvYcCW5ixz+1kLO/h/FD+RcMQpXSciQA8raUm3Yo9ZHLZ4ZWW8vH2ljYFqlvoynATHi5SAHv3duwoEOXl+O/7acgsRruVlet6aIFcvURotH X-Gm-Message-State: AOJu0YxSK/XlVSMyNKXjUgo8tCvWZykU6vhW3aXtCXql9GUhg8fct0ei 9Gzc5g6wxNgxK8KRhwNcECWJhDyfsbvsTHIYSL2/nAGWLQgONDPofEsh1EnnYJ4= X-Received: by 2002:a17:906:3942:b0:a39:6c07:d31c with SMTP id g2-20020a170906394200b00a396c07d31cmr421164eje.25.1707861897737; Tue, 13 Feb 2024 14:04:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW2XgLzqsfLyjsePJy8TDVdmG1U/m0sZ2DzjH2daoQnPowSsVcGQ6863Gp850N7ma9gdoUnjdSurb74OPKWC+WV/3vEH5gVhcoqgKTJb4cXdn9J8VAuZNw8c4TKVbo08QGtvvRqNGyAQIPB9aXd7RGYZ/5hD1MlqnjRF90+6v3Nxo4rE+EiWw7ZlA6ZabpArjDY1G0Vo/G9lbSNZzW7M3cDPE8G3BrdJXfHDN01JWQ31UQ3+LnoSuS4yMR+Fu9l6KwB98eg4Y/VDfvfrcZ3ZdaCN+eQr4NByJAqnDk+I7SL4O+3Wk+IjgBh/rUBBV93GB3BGS1IBG/LxqbImiRXmegYczs7ZoBfFTjP2lT0n7Yd7U0c3KaCbsg7aFt7t3kMfvLxPRIU9wPKMEBszbKj0xVqThhLrn6sqHqWTsOTVsW9ErEWzkdNO2KyfXs6IQmekXXr5t/Lsvr6Dw== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:04:57 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Russell King , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 01/15] net: dsa: vsc73xx: use read_poll_timeout instead delay loop Date: Tue, 13 Feb 2024 23:03:14 +0100 Message-Id: <20240213220331.239031-2-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790823712584507254 X-GMAIL-MSGID: 1790823712584507254 This commit switches delay loop to read_poll_timeout macro during Arbiter empty check in adjust link function. As Russel King suggested: "This [change] avoids the issue that on the last iteration, the code reads the register, test it, find 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." It also remove one short msleep delay. Suggested-by: Russell King Signed-off-by: Pawel Dembicki Reviewed-by: Andrew Lunn Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli --- v4: - Resend patch v3: - Add "Reviewed-by" to commit message only v2: - introduced patch drivers/net/dsa/vitesse-vsc73xx-core.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index ae70eac3be28..8b2219404601 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -779,7 +779,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 +794,16 @@ 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)), + 1000, 10000, 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 Feb 13 22:03:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp849204dyb; Tue, 13 Feb 2024 14:44:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXXNdEpy2Xt4emI0PWRsmz4iXkEvxJ9c2JBf79SEmfMJd+dyda4n3vlKsFOXVAjkN15NSvbURV4+ENBvUBS+MKbpLLtiA== X-Google-Smtp-Source: AGHT+IEKVU1ULq6dKXPr2PtH5mievkGxksnIYwm7hvjTM3CI54T6pvLuCfLzwPpQgvekV4pRAy0G X-Received: by 2002:a17:902:db11:b0:1db:2ac9:f372 with SMTP id m17-20020a170902db1100b001db2ac9f372mr945022plx.45.1707864239811; Tue, 13 Feb 2024 14:43:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707864239; cv=pass; d=google.com; s=arc-20160816; b=nk7z5hQ9ZaXKrgD/hwFPdjeCZPKyLdEYzpc+Z5tO8DJD7BA7rppIKSQJJMFhvC4Rb0 Bqw7G9q6Cz1gDWdxegOV3F3nn8g0N/cBfisS/vto5vcyOHh6HR7M1KoGKS8po/N0Nffj 6uzUM8byx5gDRbSTS1qasuxX0jzQjz3qPZGgZft36tSAfK7ZcdIqO5OsA8X5VIGghu6l reyCiE0/kcUZal37kO9s1Duz6k09dv4E4WTykODxDJVhGqBjv1Z51cI47PqbRaeORM1d X3cLv/fS6eHCRHPDHElXZnKFwr7VwNn4zt0Rr248DQfrdtEFC2uZhrmHUm+At1H+okZZ wNUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uozxI0Ib0yVJTDnCXOq5igCfB80aUVjda0znERTIFFE=; fh=YHNhc+jrWoOQc/qpt9Dop3vuAVN2faEccUD4SjCj9Yo=; b=BqTRQc7BzjQ7evV8s2sNPiVP40jtJ2IzhOi2aoutSwbnrKriuhihaWYq80VJPCnN6O DHQIlPxkAYQJGNPKpmapuR880todbwErSsHOHiR4Niq/8Fg/3Xy9Bf0186OeOD/2OFgp 5G1fSx3lJDzS71jrY1lukh5MT0Sc+LLao3bpygYy7nZD3ZMDyQrlB7eSAaDeJjSTbzM1 HR/tphU67/5AqaM64ofL0PPITokF/G1lrDm3NVzhKezafudcrly3UgTIu5rPqX40YRcR Po4AyRPMu2o4TDR5aSTxSsXVRlNR4MnkvsZtmfYkihrVieKLnaOCU43P0pTdtPwQgbX4 VLxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j23q4WKU; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64424-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64424-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCVACylAO6IACh4uAw3QIq7Pm7kB0ggTGDMqEWLWamqpPAv535pidz/pq9EOuB1+0ffleFsL2M+rnJNlsM2rBSy2qfTbuA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x5-20020a170902a38500b001d8f2354fdfsi1025910pla.87.2024.02.13.14.43.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:43:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64424-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j23q4WKU; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64424-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64424-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 5BF03B3106B for ; Tue, 13 Feb 2024 22:09:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CEE869965; Tue, 13 Feb 2024 22:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j23q4WKU" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 0204B65BD4; Tue, 13 Feb 2024 22:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861918; cv=none; b=bJ3tIVF+fdSPVPVGnlrm4RNdMNAnGCJkx/N+dFsijnFHYoOn/eimto7vo+sNyyiBxhJu34Ni4m+/uzvBwf5n8B2wf3E+1Betr3RhRN4pra29GsPzLtQGHZXi06jEtx329NDO0+gM6ev9/9ZeQB5AqY7NzYENZvnKNAOyjKKyQwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861918; c=relaxed/simple; bh=FviLzxC93cNJ3wmxI/f91VZvhamslfx9I/NMWZYtlMY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=COa5Ss6g9CMuDqTkAM3wNZaAWKguJ1zPORnvN/QtA83CBR57LKzq2RWZbDobmvuVnmfRejhk30Sa3qob2ZcYgjgbg5IN+2gxEkvPzJ3/StWf9rNWLZVmhlN98Upgo1Z12uPYrjNYXtd5ihOH337oUw+S7UYERD+vPyXt/dT9oPI= 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=j23q4WKU; arc=none smtp.client-ip=209.85.218.53 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 Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a26f73732c5so684193266b.3; Tue, 13 Feb 2024 14:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861915; x=1708466715; 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=uozxI0Ib0yVJTDnCXOq5igCfB80aUVjda0znERTIFFE=; b=j23q4WKUwqMmPV2QUR8RXJeQsuj3NiOBfqfsBSw+xnPo2V9WolfCyN3X7RyWhCoC5o hshCUHc3GFUtrAz2Wh9KMrh4QVDBhHm9HhBt8W3bB/GLotgiz8n4lY0nsUoFUhZSgo0r 1Bgi8fy8wvHr4NQRvF6Jf2+Fx0KQHqtYt4wDbjT0riKkBut6TEM6hv6Omfs8InBmalmb m32c9rrwCmqnqmThu2c8M6DbuOAlrcvCSXb9B98/OuUeIPbczijSPK1CPxVNOlW0Cq9T 9I90z/z5P5vbdYBYxpbMKnM3Ga5Em21TJZLm4y/gxFgSjDaMBiWRN17oA1W6odOQHc6u GPVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861915; x=1708466715; 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=uozxI0Ib0yVJTDnCXOq5igCfB80aUVjda0znERTIFFE=; b=g4LV/+W5VTIQWwRs7S2Z1hf2SO7BMXYmEnckuR74YygT4sQ7ATtiEqWTdTSkYU+ISq 6nAL9lhMlgrmK+5vInqvpz2AQYfjQF9Zg9hFzU+j5c3clohv6/Edz3KPw8KU7JXJllEO iDsKPqqAWfEC8zamTZdbTdThy9IGuVk9ixs+x1eREQeBdMO3CqxxzOTC/z2bammJSJHD +RiyaIWXKFnKcKsfdWEcfNhXet6I8TtIRbLxM+d77bNWOpzjjXWT/Dsfy1FifsMXninY bNdej02bWBFuAs6IijW7jaaZ7/2N9qQ4tRHDtxJz6FILsoNZ0oflT+auh1WRUfSn0rPD 4xiQ== X-Forwarded-Encrypted: i=1; AJvYcCVR1NzGl1ikVvhiLvsqu6VV5wBNAG1olWOF8OJLjMN7Ly1w/kxRBanMvqzrF2P8X11VrYpYAjuaqsxsADUQyysfdBJRZ2fG9c5zwcKB X-Gm-Message-State: AOJu0YxFF8YQEElb82NspRH6FWeN3CbyepNrPDPp8FcPdYEG0GFn3LrT PAkUaC87Hm8NP18ZYC9CX6AMYJ0Fd4K+IX57En+VdnajPUJaAxQQqQWzYRTRJpg= X-Received: by 2002:a17:906:3c53:b0:a3d:1f59:7410 with SMTP id i19-20020a1709063c5300b00a3d1f597410mr361105ejg.22.1707861914895; Tue, 13 Feb 2024 14:05:14 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWcCp1Wq7upm9RDN2iKLObnLHXNsKYL/nEZ/usmgnU7yyegCtOARknmFzDEK6SbUX/A2DG/aT+hY0hSHKqCk5e/ZaDm2/r4O3andE+IoxSnxgMv0bGPH+PD2qzXbYCFXt5WqM7IA1TduCqYiNiqG58yFm01mP7ROLXVfXkX8EKaXHqtcdDejp4K5nISuZAu/18yMn1KcydiQvLJ+zPkyHRYp9wmBnT0I8P2pgUicieEimz8C6oPpIXuJIiX/7vDLjF3YSgZF7at1uI0LHX5QCotjR7TH3NY6Y+ztLYdvRCyiHXHBDpptWmz8jCzg/L9tR2IGCp7EuLBRdtF6hegwQfke2+010fYHxpeZ3UAu7leN0Rb3v2R2O3L3mOZwQS+g+aIIJ3V2+6Ta8rEHOrrrZ8GpUVR97WZ0vk4mLp/fSRKqvsw7hDkTKD9QXVmBaObDcPqjl8W0EoVZA== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:05:14 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Russell King , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 03/15] net: dsa: vsc73xx: use macros for rgmii recognition Date: Tue, 13 Feb 2024 23:03:16 +0100 Message-Id: <20240213220331.239031-4-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790825453122308218 X-GMAIL-MSGID: 1790825453122308218 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 Signed-off-by: Pawel Dembicki Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- v4: - introduced patch 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 70dd3f96dafb..5b54823b2caa 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -833,7 +833,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 Feb 13 22:03:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp851738dyb; Tue, 13 Feb 2024 14:50:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW/AwjsmCc2GtSx6aqvHtBzrNLF/rOsPzBl6xfngXxKugeXcQLu30ayRcyrbBrbxTvHmNFnkNNh3+nBLvuSl8Tquz2Nmw== X-Google-Smtp-Source: AGHT+IGl2W2duiRWo+zSdgWkhA1Ll+OifWJqjNKskLmEVaBbjZ3ptK3NMdyN2fqPEN59OAUyzviW X-Received: by 2002:a05:6358:5786:b0:179:a5f0:97b8 with SMTP id m6-20020a056358578600b00179a5f097b8mr771605rwf.17.1707864658681; Tue, 13 Feb 2024 14:50:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707864658; cv=pass; d=google.com; s=arc-20160816; b=zK80Rd6bT4RFbrBuYyPdSogjX6W/cenW+QWXFwIyeobXCIgc3zeoQSisp8/R6lVqUq I24KEFWH6XQnoUgqCnVckYuXB2nMy/5x3K0EDQ6/aSexy57QcS5HV0iOqpSHfYLJ8Vc0 jzrujcy21VqlvV7dwFkUEfYtn4S0G9aT4CXNEc+sjhe7hl5i7ePq8TNH5hvYjzdkNICf jHMSI0fKg1z1A5ycENcI1YYzHCJwxNFp+3RCGYrG7sVYETZg4Av7qmaRq8KrYMIu2Oog s6f8I8LvPhpQm2CohNHZUra5RWzgus64dl6zT4AqqOvbUDd3LT9QR8HAi3viJKnHac4v YE+Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=B9TYnreC1cjtgZPE9uArnAlQVNsjfWDdo5XqTKM9rnk=; fh=uiN2LpJogaIzIp3rVpUL0naafdEZTxsr96zPwFS8NwQ=; b=SDg+LRVgx1QXuwurbUCgGW07YysKdNgyBLO5wcPGUVLN2tE2/9zWugAEtSOGFRmD+b cipke0JATV/W7lirxwNJO3OPGKXW9eDFgjw/v/YYMLhQXCsOgITSb0Sbv3pBBkQ+pGD3 CFIxKIzk5CAqvk9w3Ftil/pd1m9GpI/LO9YiwkVU6fi6/m386Bz9C474byfrmt2SvgSH 3x1mgeHrLzhm5bHDEEX9lg0kUaJ8y+xa83zKvXMU99CjtUWxPbyTp3CZjxJhrPaGbHiD Pg2xMc75NhDd1u3D0VoFn5oD3WSYZ47wBzideNec9K+aBDGdSyAyoHZZzTELc7k+bG87 wxaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HI5B9SAR; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64426-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64426-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCXcToP6t2hmgS25xmBxh+KyEjN7/x0L8kXnNfYWCmtr8I/MnBLTb7Az05Seq0S+XAh3ssqA7DSkyVDdhFjdgY88cmxgxQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t24-20020a63b258000000b005cdfd4aa8b3si2608027pgo.193.2024.02.13.14.50.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:50:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64426-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HI5B9SAR; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64426-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64426-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id ACFB2B3169E for ; Tue, 13 Feb 2024 22:10:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96ED969D2C; Tue, 13 Feb 2024 22:05:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HI5B9SAR" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 3359469D1A; Tue, 13 Feb 2024 22:05:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861933; cv=none; b=K7AwKdrHtkqhPBdFTeC9MJ5bIStChuJAIiTFI740WHLT6tWGDeWmVGKLM+Ps53QxAy2ceGZeuEyqAEytZ2q05KX8BVK0IkpPqRcL11LFOHIcFrxhPttvDzndDIokSZJpbOpHpCN79sKOeP8EJ7LvbQnRZHCCgCA0D0m9fq4y/10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861933; c=relaxed/simple; bh=1fo9tqK0gVYT3dua0dTYP+mwom4X6HUKZw4ewOhVpTk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mc0TLr1+n143WAmECUEh+BEE5HNXRBeA5rf8YoSHISiLNQW+MRtmGCzMpVWVOw1QKIRYhkKZL1W2sEfE/d8He0h2vJ7ZIESZjuzWSXX8g42Iwtn8eisYiNsTBdHspFOKrVyxE66dPUUpTpngm6IOBe8LLUvxwaYK/G5ncG8m8OY= 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=HI5B9SAR; arc=none smtp.client-ip=209.85.218.53 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 Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a3be744df3fso514014966b.0; Tue, 13 Feb 2024 14:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861930; x=1708466730; 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=B9TYnreC1cjtgZPE9uArnAlQVNsjfWDdo5XqTKM9rnk=; b=HI5B9SAR3QRF52LQLQjRH9JiSAmXihtv0RB1AbEjyw+7e1eXLK4AYl3IsK+VNgELN/ DOfawtC22Va5yfqxE7K4CuZZNKnP7K0x4deh6pdCtt8rLZyI7D/tyxPiP23wGDgxMyLj dxYEesKxZ14KpYFqqoboBnCjgmkH1Kjt9mhk1Ud+dRjF70m0PO4o3AJsOros8I6hUmDj /bXJHoBQ/z01LOPSJ6kbm9iTLD7ElfGoPM7z1b5r+U9wZGXFne1kgmDM59WMcZL5cg3X 2NiB0p7ztwylJyPVUYT34T7DoaA5Ia58p2yFxoXE6ddjPUbYVTAlTsXkYhHx5+mSoT6z c2DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861930; x=1708466730; 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=B9TYnreC1cjtgZPE9uArnAlQVNsjfWDdo5XqTKM9rnk=; b=PGRBb15SsH7/skZOX88r2mj4oYHGjopUgxpgNqAn7FfJRB/CTeR5eFTqdfSeb14hX/ N/7az++FSmrtRKbyCDnWcT48ASSjZU6uIvq7OQTQPIm95+gy1iMWAGYPhOWeTHqMBG9Y 47bEEjcECQVnnhExCRko9R2XSamQj0nV5Xf726PzQeZ73tNLqqClYLIu4i105FScpfXH mfWyU1HX60dIG4P8mkL4W8Bv8q2yNCsIXlBkdZtoEN8jKpre6BxaiJFkF0oYESEDAfIS nfaiykg50ZjtmjslUZKkfGmnBkfvvavr3xJFjzh7tHAPCaz0AJFa2OXayVAtdH6kY1d8 tJJQ== X-Forwarded-Encrypted: i=1; AJvYcCVDIg7d/OxJA23kf85N6+/EXI3NSzpHSNPo2D0d+kYTylmIuj66nOyZd6b2gqzXNTrU8x/5Uxssk+1UVN57z4DhoiSMykGkiZZBglaj X-Gm-Message-State: AOJu0YwQSE7wDBLdsPWgRKINyIQziXqnE3lmboqI6fI78AVbzj+6Ow9/ OadlOo2RftpuaCmHj927xoW9EZzoFtLb0eAZIxXWAH36kYPKerSHcDTgNhxbtD8= X-Received: by 2002:a17:906:494e:b0:a3d:1378:143d with SMTP id f14-20020a170906494e00b00a3d1378143dmr480648ejt.2.1707861929878; Tue, 13 Feb 2024 14:05:29 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVmJZuTch5bGaS2/AjO6RP2r83H/GbJkv1d4TPfzC/UylgiK7INVXoXrbajJqbVxggfp8v2F1eK5g+EPwQIye5XWWuKGvygMCdEvpS7UYMpaLWf6ymSRG8KKep389gt1E583uDchIB0MA0RRz5kqmmj1cxmIVrFRmMZbBrBHzHJU8cvXtPuqf/gQWD7AzQZGMYirWSWu5ONdndEZz+hHKin6aauxzfvQ7yFmHKygFql2UJw1/t5LmjC8IO3OAePBUupLllOc07fJzuhWXksj5BDq0pQ9eiALE3aj7ak4ATgufa9QUB1Z9XFL0WYsYi7q8A1vDdmdBd8ahls9WLsQMmh5Z+uXJA608YS50H5OH0+JdQWCQGr2ZgO3RH211pDavcCBsI0DV3SuLoTWttsMAcFbit2ekr2AUrfAXUIpBYjPECEAW7Pcry9LCrp263VLHYxUXRpy5Pzcw== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:05:29 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 05/15] net: dsa: vsc73xx: add structure descriptions Date: Tue, 13 Feb 2024 23:03:18 +0100 Message-Id: <20240213220331.239031-6-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790825892497158919 X-GMAIL-MSGID: 1790825892497158919 This commit adds updates to the documentation describing the structures used in vsc73xx. This will help prevent kdoc-related issues in the future. Signed-off-by: Pawel Dembicki Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli --- v4: - introduced patch drivers/net/dsa/vitesse-vsc73xx.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx.h b/drivers/net/dsa/vitesse-vsc73xx.h index fee1378508b5..99c5c24ffde0 100644 --- a/drivers/net/dsa/vitesse-vsc73xx.h +++ b/drivers/net/dsa/vitesse-vsc73xx.h @@ -15,7 +15,15 @@ #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 +36,11 @@ struct vsc73xx { void *priv; }; +/** + * struct vsc73xx_ops - VSC73xx methods container: pointers to hardware-dependent functions + * @read: Pointer to the read function from the hardware-dependent interface + * @write: Pointer to the write function from the hardware-dependent interface + */ struct vsc73xx_ops { int (*read)(struct vsc73xx *vsc, u8 block, u8 subblock, u8 reg, u32 *val); From patchwork Tue Feb 13 22:03:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200689 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp836399dyb; Tue, 13 Feb 2024 14:11:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0aY9FlHarbTzHA98JWb2mSqweykd5pgSOzD62uDRwKIfJMnSdRnGTilGxZqMnZLhwHjbSirehpoaDDwY65IJZtGR3/w== X-Google-Smtp-Source: AGHT+IHVMSQIJ+A7VhssUxP3VrFJZzM57bE5Qkb0A/AeRLO8ikoNzXIPHFLg4xdd2qDiB94cAXqn X-Received: by 2002:a67:ebd4:0:b0:46d:2544:7106 with SMTP id y20-20020a67ebd4000000b0046d25447106mr771545vso.29.1707862308904; Tue, 13 Feb 2024 14:11:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862308; cv=pass; d=google.com; s=arc-20160816; b=cs6yYtEZIpYZe9LW7Esq6X8f9ZQQyTsPTHm3ogvgty1HOTDe+ll7lMXZiCARqvkSgt goDtxzZtnMdK+qOGO6FMXmQSvd6Q1vf3hhdtnkgQc1OaoegBnU1vcK+hvFUrYckA9k55 t3BmCHXOMnCUuWdGBu+QILjn+pSNIupnDZI7nsOWpI/Dp81IfakCHxGSiKSUKyNeYlT5 7ULjbPi2GxWQ3AqY9TYp85y4YZB8DIyAplk0ar1Bq+L/M7Y2zd1XSohfUdrYg25UIWax y/s9GDdneLl6JGmaEngkC85lnbmZxKQOTJ9zWJq7q39O0pTAvzMYzHWSjsJMe7AP+xrB kuEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bwJcHCbiEJFiPaixjIdrmQwiczYM9/vn6dsLmIZry58=; fh=5pkge5js3WTjZe8+A9yKP0lyqYRP7brOxOKEXyIDu6U=; b=nKVSoTMC/Hc9qZ81zZQuSV3PUPwL6Y2D7WtW75Z7So7Hj0pavpXDNcECtdiqjNVGTZ RpXLE60RfsyaSIXY9KQdtvSICymf+7Mwdaw/mBSPNuTKcCwKfVjjcrsa5SgFtmrda9Ac ZgCqURTaO6viKd4OVJqPthcrLAEUekac2kADNiTJ7JaqLtQ6vMGDgeD7gNPULWFArEjB 2RW7jRx2nO0Jgd9JX1/XVHWHzZPHKTpoLV1iHNcdNZka8lZz6cxF8rSm47JH7LDVgt7J SJMJDgQQBaCrn18n3K5xpV3BytdbQDAbRpifUsa88h89CA9RhxoQKG9E4ADn9qOpGjo2 weTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="jdFcB2/7"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64427-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64427-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCV0taHPHgJ7kcURWZNa3l0aK4YNhcg1FuL5e2urn6P2Imns0Ig1Uh4aIhjAhRvff+dEgpEcrEPg3fK7G56AjPtj1sTJ3w== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c8-20020ac86e88000000b0042c57060220si3738518qtv.20.2024.02.13.14.11.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:11:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64427-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="jdFcB2/7"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64427-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64427-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B03671C28004 for ; Tue, 13 Feb 2024 22:10:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A5AA69DF0; Tue, 13 Feb 2024 22:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jdFcB2/7" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 EFEA169D2E; Tue, 13 Feb 2024 22:05:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861938; cv=none; b=A568t7clR7kiXb20Mw3TWRNBbsTZDUtVm0CpsCe/+vUwhdmigcTzUF5jg0K0CTGgO40VtBMHwUqX94hwLluyjqDcA5sDfJk4Fjbh7JB6+b207Zoam8gyQp64cTFScYmZrWyG6ZSLwWPNbRwQsxwaZog7nxpJTh6T6mD8IM9bd4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861938; c=relaxed/simple; bh=aSfhz/n2RCJGOr6hG14wnL3tSy0jymdagBk+PlbYLf4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V55SxLFxsjk8Bxuhq1dzymyU0lWWx5hk46Y7ot3u4f9U5u0+qnuChg3/t9kwOQDtZK5kc+7xmZOIyYcSTGNwkoM2YmuGG3jnqNbSjOUyLRsHlUfFrubHkYeh+sWbHOV2GJ72RzYfL5uyPMCWyrDMdySBnpfqb254bCDxpzg9KfA= 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=jdFcB2/7; arc=none smtp.client-ip=209.85.218.50 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 Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a3cc2f9621aso149971666b.1; Tue, 13 Feb 2024 14:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861935; x=1708466735; 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=bwJcHCbiEJFiPaixjIdrmQwiczYM9/vn6dsLmIZry58=; b=jdFcB2/7kyE5ojdvbVC1UwXcBby/bARnk2hS0R9FTrcJrKeNLT9aVEGCWjMogapC7P XvVc5MIATgBr5nblEcep1ow/X3A5MXW9HYwZcnxFmZSRLsf7pAKDvL6tCohYOOKa8PDA neiXHqMd4y5uhKiGMD05Oe8izl3Xxf8/tksNGI9ywtJP7C6hSVv5iQ9YstmcmwqIMY4+ L2A19wvAkWPxbkEDaiORtrpQbg1Z6ZeyKAEKvyB6l8Tsq3SK+5Bq6RXLDO1W1G8CGDDd OuiiBcJMvBjGQSJ90fN2UHg3upPeWsMbkMJsS9C6JMYAtZBfKRUihuh50GINFr4+A4uL 6+sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861935; x=1708466735; 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=bwJcHCbiEJFiPaixjIdrmQwiczYM9/vn6dsLmIZry58=; b=gS2zK8CiOfZamNPivniJGuA8+DHfbI1dm2/Bu++ZsrEdkVYdzGIZkvGYsLlYCbUTBE PBk2T9W9vDqVOo6eG+0yWHeot0NRgOf+/fhVJbuChAHe3FXiGikmbVn8IiYd4AEHQz65 Mdbn6q1Q9beJIUYtSyEF+V+PC3F7/B/kxgZlTXZ5352LofhaYaIJkimwxYcEgdcGOFT/ jPiop0GJBYomH8ZdA7N+QN/NMQQGDEiAMrZeuoK8xB147djWJe3ChvBrJHLRF2jFwAQ6 xZbBz6wbg4YK3dPdL811nBD//f4x6mgxMkmqH9vWVOe8wa37XuGnn/wLZM7JGE7Su5Bt Vuiw== X-Forwarded-Encrypted: i=1; AJvYcCXxHLj7daSQfbSfoOF7EA5QeOyNbYcbL8atW2Ktguh0X857gZRW9DZBHPpEtl4+l7oLObcW6bDqKehcMcAgWgb+aj/eY+gpfPjfPPoF X-Gm-Message-State: AOJu0YwH+fI+WOU2hMD7TwSJWxE8hMhV3C/NxKr3y92tD13yofIF8w7f /4AVqjup8zKi3a0XYXzsRENBHjxNG2k1n4Jv8THvM+6bfahnZNQdQPnp38uo4aM= X-Received: by 2002:a17:906:5a8a:b0:a3c:f38b:ec4e with SMTP id l10-20020a1709065a8a00b00a3cf38bec4emr395277ejq.16.1707861934882; Tue, 13 Feb 2024 14:05:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXswr14b8uYnfaE61bHXSkCtVnwB0LXtgndBOSCLt2TaDGAF49nsx8CXfIr/v8kfzAvmoXp2KBr2DKaMaHA0hmAK28w94XApE0yZsNFXXbfNRvZ+bDrkrG1ENfElECB5TMgwFyevBXwtmAzrGhFq79XrzsNLgANoC5QfdOFW7eV7eBhwrhYWzovo/z/Bogq9qN0eqvwaBNHB2dux1exfrxrwwvf+rfwnj8wkvQiN4EKwE5N4E2kzwEyh3fQNusDSAvpQnzfIYFSOVmYLhapX5QR0q0rPZxixdOonGRqZurZKNjq0SG1QSjGMwcoZINcsRSZE3TYA+LQdeAb4f4kYDwLmiRxru8o+BMqklCEfX5+vA30yN2Ct0l6U8wwOA4VA6NOVHXXJvxy1gMUCzFw9I5Xg0Wza4NXV0DsL0e+MohVc0JDxR/CnHs3xNPKJrWwnEWXBJmB/PJgIQ== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:05:34 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 06/15] net: dsa: vsc73xx: add port_stp_state_set function Date: Tue, 13 Feb 2024 23:03:19 +0100 Message-Id: <20240213220331.239031-7-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790823428807208114 X-GMAIL-MSGID: 1790823428807208114 This isn't a fully functional implementation of 802.1D, but port_stp_state_set is required for a future tag8021q operations. This implementation handles properly all states, but vsc73xx doesn't forward STP packets. Reviewed-by: Linus Walleij Signed-off-by: Pawel Dembicki --- v4: - fully reworked port_stp_state_set v3: - use 'VSC73XX_MAX_NUM_PORTS' define - add 'state == BR_STATE_DISABLED' condition - fix style issues v2: - fix kdoc drivers/net/dsa/vitesse-vsc73xx-core.c | 83 ++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index 75597daaad17..1dca3c476fac 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -163,6 +163,10 @@ #define VSC73XX_AGENCTRL 0xf0 #define VSC73XX_CAPRST 0xff +#define VSC73XX_SRCMASKS_CPU_COPY BIT(27) +#define VSC73XX_SRCMASKS_MIRROR BIT(26) +#define VSC73XX_SRCMASKS_PORTS_MASK GENMASK(7, 0) + #define VSC73XX_MACACCESS_CPU_COPY BIT(14) #define VSC73XX_MACACCESS_FWD_KILL BIT(13) #define VSC73XX_MACACCESS_IGNORE_VLAN BIT(12) @@ -619,9 +623,6 @@ static int vsc73xx_setup(struct dsa_switch *ds) vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GMIIDELAY, VSC73XX_GMIIDELAY_GMII0_GTXDELAY_2_0_NS | VSC73XX_GMIIDELAY_GMII0_RXDELAY_2_0_NS); - /* Enable reception of frames on all ports */ - vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_RECVMASK, - 0x5f); /* IP multicast flood mask (table 144) */ vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_IFLODMSK, 0xff); @@ -841,9 +842,6 @@ static void vsc73xx_phylink_mac_link_up(struct dsa_switch *ds, int port, if (duplex == DUPLEX_FULL) val |= VSC73XX_MAC_CFG_FDX; - /* Enable port (forwarding) in the receieve mask */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, - VSC73XX_RECVMASK, BIT(port), BIT(port)); vsc73xx_adjust_enable_port(vsc, port, val); } @@ -1026,6 +1024,78 @@ static void vsc73xx_phylink_get_caps(struct dsa_switch *dsa, int port, config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000; } +static void vsc73xx_refresh_fwd_map(struct dsa_switch *ds, int port, bool configure) +{ + struct dsa_port *dp = dsa_to_port(ds, port); + struct vsc73xx *vsc = ds->priv; + int i; + + if (configure) { + u16 mask = BIT(CPU_PORT); + + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_SRCMASKS + CPU_PORT, BIT(port), BIT(port)); + + if (dp->bridge) { + struct dsa_port *other_dp; + + dsa_switch_for_each_user_port(other_dp, ds) { + if (other_dp->bridge == dp->bridge && + other_dp->index != port && + other_dp->stp_state == BR_STATE_FORWARDING) { + int other_port = other_dp->index; + + mask |= BIT(other_port); + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_SRCMASKS + other_port, + BIT(port), BIT(port)); + } + } + } + + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_SRCMASKS + port, + VSC73XX_SRCMASKS_PORTS_MASK, mask); + } else { + for (i = 0; i < vsc->ds->num_ports; i++) { + if (i == port) + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_SRCMASKS + i, + VSC73XX_SRCMASKS_PORTS_MASK, 0); + else + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_SRCMASKS + i, BIT(port), 0); + } + } +} + +/* FIXME: STP frames aren't forwarded at this moment. BPDU frames are + * forwarded only from and to PI/SI interface. For more info see chapter + * 2.7.1 (CPU Forwarding) in datasheet. + * This function is required for tag8021q operations. + */ + +static void vsc73xx_port_stp_state_set(struct dsa_switch *ds, int port, u8 state) +{ + struct vsc73xx *vsc = ds->priv; + u32 val; + + val = (state == BR_STATE_BLOCKING || state == BR_STATE_DISABLED) ? + 0 : BIT(port); + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_RECVMASK, BIT(port), val); + + val = (state == BR_STATE_LEARNING || state == BR_STATE_FORWARDING) ? + BIT(port) : 0; + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_LEARNMASK, BIT(port), val); + + /* CPU Port should always forward packets when user ports are forwarding + * so let's configure it from other ports only. + */ + if (port != CPU_PORT) + vsc73xx_refresh_fwd_map(ds, port, state == BR_STATE_FORWARDING); +} + static const struct dsa_switch_ops vsc73xx_ds_ops = { .get_tag_protocol = vsc73xx_get_tag_protocol, .setup = vsc73xx_setup, @@ -1041,6 +1111,7 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .port_disable = vsc73xx_port_disable, .port_change_mtu = vsc73xx_change_mtu, .port_max_mtu = vsc73xx_get_max_mtu, + .port_stp_state_set = vsc73xx_port_stp_state_set, .phylink_get_caps = vsc73xx_phylink_get_caps, }; From patchwork Tue Feb 13 22:03:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp837476dyb; Tue, 13 Feb 2024 14:14:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVHMQ3r67fqZC3ZBLwRpiW8SLA077sS0k8xaDwJlHBisvx6H9kr0zBbEnuC0tA4OvCN2v9FTjmjRqzcwcdeze0spP1ufw== X-Google-Smtp-Source: AGHT+IEX+K/BlIe9xOy7TJGOG1clxKsOfj1uQG8hS+wT46iM0K54vt4xadMVVHAURHwuhjGIoeKt X-Received: by 2002:a17:902:da91:b0:1db:2aed:786d with SMTP id j17-20020a170902da9100b001db2aed786dmr1369428plx.29.1707862477508; Tue, 13 Feb 2024 14:14:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862477; cv=pass; d=google.com; s=arc-20160816; b=A4A5BDbEEVSfux+J2kz397CwfKGmxUs3xMzlTamzS7Q9ZKCxOt3AarVQci8zRbDgk+ MKarxtb35CrICYSFsCO9YX6VVvzmv6yhAbJyIKGybKb0ktSllRA/bpvO82TgShCKJCCw vD2Rz1rNBu5sNY1Q2LcjbZN1JKyy6wc5DTRudFz1yilHW21s7at7/vU66LpUuvuG5yVG y4mfbCyJulAmqhdjbkJC6b8tmdVf8K79iKAnXsKfV9EhoAJh/LcQozSQ1nTw5dKnXEVe WnGW+mybzBaaxVdDi8V2V3vNXoH87Obuf7uNNWsOQ7CQfDptprXO/icar9R7AugbbEUy f+Mw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vzi2NYSYs1dw7+WI8H7EeIeC1vmz6Hbcl0TyOSg0RA8=; fh=laiMYmpfEDa2lOHk4PTEM6CpJCgkIYp0vliyvMFLoz0=; b=bcWVoAnK9yVALiivbCCV9Td6kXNTBUJ7tevKJgqz5LUw6RNJTlLu2vIB0SyL3/5AAg JJScLusm8tOSkoc8/EM9xYP5PJORKMXUr1DD/fg08VL1PDWYJBV4NjyxJaK1S0pb2ADS OPhJAkO/QRQoB5WPggm8UCfCIiDhQXXUpML6Vw8owfJbUp5U/tDO1pijHLdkBgmdY63p ZftB58Xvm315IQQ8S9eAnsunZci8InRalFKOgGCgMHjtf++OoJ845BC4COSuzUfvVyne iNYWe/vF3Td/Syc6eAUOJk12iH2yoy9bbi5TaKpnKBWH1BtmN081bN5g/0csRfcXAu/n iyTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mf+4QnTD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64428-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64428-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCWRIzSJK7X/+0x0ZGJ7Kg31SLj2osJH6/vF11eVui0o2AqoXLKl3Q8bf+hnph2gGDL71VVCU03nM3Apcwg04v5f1sGksg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b7-20020a170903228700b001d8a652d259si2673301plh.350.2024.02.13.14.14.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:14:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64428-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=mf+4QnTD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64428-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64428-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A1603289035 for ; Tue, 13 Feb 2024 22:11:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E540F6EB5C; Tue, 13 Feb 2024 22:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mf+4QnTD" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 94B8269DE3; Tue, 13 Feb 2024 22:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861945; cv=none; b=bka2kDm8sfN3oqfQX/EXAIC6U5nB54rvYONQI95CCajMhlKAqo3EL0atgDo3XnI0BV+j/FBjfUuJWfIo+R0gx3MpZ8jhitv2ATzNq8jRkWa1hSQlBaKfnzC0evKbQ2sSYKYHTx3w6K6xRpfvUsHpnKUkNeWL0cR2dJgLY+klPi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861945; c=relaxed/simple; bh=lWgQKkjGAD0xvMdwkE5D2xfJl+/qgEiproz1COUTSH0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ozsj9BnF5ve8kGXCyZWO4L1rOPyN5HePfszsG8ReBlcpJqU0BlOg2mXLwPaQAx2uudrZQsM/NDaKqVuegJREQ00CFpt3uomHtSvAU14o6GWM9tc5O6VO61csRZHc6UX6zMYv9XsClXtWeK5HpA1wFYEL0QtHpDcR2uPU62BF2Mo= 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=mf+4QnTD; arc=none smtp.client-ip=209.85.218.48 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 Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a2f79e79f0cso741538966b.2; Tue, 13 Feb 2024 14:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861940; x=1708466740; 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=vzi2NYSYs1dw7+WI8H7EeIeC1vmz6Hbcl0TyOSg0RA8=; b=mf+4QnTDVKVpORzxNTbI2t9j/5TyO6wgyJvHoKoFq/jVNvlOreaNyReigjMr6vFFKb yi6z+02YMYIt2wnbNOt86MD4gRDx3LKm0rrn7IT6RfMWJ0AhCg33a1pI0Kv4p/nka2wF R2vtux9PAfVaHukL4RL3ewpnP1JBYDAy0EyZ2p92Bca2ddKqrvrkzCHD13zsRf90t5ce dRfE0jQMZXjNJMMTi6SGxySTMWCcjXnUCIavLf5friwRh5fRG84kOef8d9ZXte+biOab iU/vkC4txsYouJR9SeP2dQMWNSPQkbVLp8g7CtbUwPJH0emBMaCaVfLCDV/qxKeKBreS OJiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861940; x=1708466740; 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=vzi2NYSYs1dw7+WI8H7EeIeC1vmz6Hbcl0TyOSg0RA8=; b=gQFfzXf3ZD8bDwJt96YPR9H067+A6DkpzFgREuAQSq9hqpo9flAMOg9dM4lUlrfqzB gd76ZhePsgY/SZYP2YxplLOX6v12A0lcCAbNrKkoxLbwPSuhDWo6wfVb52kmfPomncwf qShPJLTI1UmOTrXPjsSdSrMn9nBzm46cjV8W6hiR7Insk+TmJ5hXf1r4ku9Nw+TTEaB4 CfpZFPEv+6RcsqMKeEr8F/Z8cURm2HJMLCfNnbFF2mKXCyDZCbi5aVIv0KwJIv6ENRoa HC7E6gdJeRSNyC5ugXSZv+niwL7eqC5j8zwy0RRY53yeh4LZSVDm0k9gyY511YNFcLlI 58AQ== X-Forwarded-Encrypted: i=1; AJvYcCUbk0gjCeWa9GFfh1nX98eONma+5LtaseDfgdc7yE1ych1HtjRn1ZjhNE85Tb++G/0HNFm3m+inMizL5AMBj0hlOSNpfB9VcmO6fsZL X-Gm-Message-State: AOJu0YwCVQX2Rfyq8RLJxP8G/NXvaC0KQ+UskiKDzmyvA+4aEyuXmjs2 2oADv86zmiK7p68kM5AID3Uzph/GGWEhm1Qe7W07f6bMzTbP0sfAFi+l1lCSFgk= X-Received: by 2002:a17:906:a451:b0:a3c:930b:2d14 with SMTP id cb17-20020a170906a45100b00a3c930b2d14mr451209ejb.9.1707861940108; Tue, 13 Feb 2024 14:05:40 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUKAal6Mo6RK/gW++Aj54wuQEM03Tqmmipgrvtu3QyJnZqSQ0kV6Uz6bHPSzum5zhUjMDZtjsynzU6o/ctP/kggbc5f80kqxYhezyE01W+KIFmtUcfnfd8Iw09FmM7L13Aap7fPSjzPx2m+Rpp9BPwL4CY8tXrkBZCTmc6mX9E7zITA+G0AesR/ACNvBOSPMrUl4+D8bWmEql7jtPbXsSAwg4XiQ/itrILdyIQRHqtp5YIE8E+XtzkPz4N6uGkWxxBmDfFwSCbiYiDlLGb841GavTXr4qhV6aeOIJyZmtAtNElfVhRJhfcHbJYusHtjqqTPfQRNRWtys4YeWRtV85X4HSKSdR3nDG5HvfGftCt2rkQog7YiHL0b7/m7sBYjd2oFtc4Bs26SIzz39zsyAjdRyPu84WDkXo7aoh8xCKsaWiequyJhSVLsT5caJA6HHW33nV+8DHpXBg== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:05:39 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 07/15] net: dsa: vsc73xx: Add vlan filtering Date: Tue, 13 Feb 2024 23:03:20 +0100 Message-Id: <20240213220331.239031-8-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790823605521668386 X-GMAIL-MSGID: 1790823605521668386 This patch implements VLAN filtering for the vsc73xx driver. After starting VLAN filtering, the switch is reconfigured from QinQ to a simple VLAN aware mode. This is required because VSC73XX chips do not support inner VLAN tag filtering. Signed-off-by: Pawel Dembicki Reviewed-by: Linus Walleij --- v4: - reworked most of conditional register configs - simplified port_vlan function - move vlan table clearing from port_setup to setup - pvid configuration simplified (now kernel take care about no of pvids per port) - port vlans are stored in list now - introduce implementation of all untagged vlans state - many minor changes v3: - reworked all vlan commits - added storage variables for pvid and untagged vlans - move length extender settings to port setup - remove vlan table cleaning in wrong places v2: - no changes done drivers/net/dsa/vitesse-vsc73xx-core.c | 523 ++++++++++++++++++++++++- drivers/net/dsa/vitesse-vsc73xx.h | 25 ++ 2 files changed, 546 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index 1dca3c476fac..6c7bd1c200b4 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -21,9 +21,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -61,6 +63,8 @@ #define VSC73XX_CAT_DROP 0x6e #define VSC73XX_CAT_PR_MISC_L2 0x6f #define VSC73XX_CAT_PR_USR_PRIO 0x75 +#define VSC73XX_CAT_VLAN_MISC 0x79 +#define VSC73XX_CAT_PORT_VLAN 0x7a #define VSC73XX_Q_MISC_CONF 0xdf /* MAC_CFG register bits */ @@ -121,6 +125,17 @@ #define VSC73XX_ADVPORTM_IO_LOOPBACK BIT(1) #define VSC73XX_ADVPORTM_HOST_LOOPBACK BIT(0) +/* TXUPDCFG transmit modify setup bits */ +#define VSC73XX_TXUPDCFG_DSCP_REWR_MODE GENMASK(20, 19) +#define VSC73XX_TXUPDCFG_DSCP_REWR_ENA BIT(18) +#define VSC73XX_TXUPDCFG_TX_INT_TO_USRPRIO_ENA BIT(17) +#define VSC73XX_TXUPDCFG_TX_UNTAGGED_VID GENMASK(15, 4) +#define VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_ENA BIT(3) +#define VSC73XX_TXUPDCFG_TX_UPDATE_CRC_CPU_ENA BIT(1) +#define VSC73XX_TXUPDCFG_TX_INSERT_TAG BIT(0) + +#define VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_SHIFT 4 + /* CAT_DROP categorizer frame dropping register bits */ #define VSC73XX_CAT_DROP_DROP_MC_SMAC_ENA BIT(6) #define VSC73XX_CAT_DROP_FWD_CTRL_ENA BIT(4) @@ -134,6 +149,15 @@ #define VSC73XX_Q_MISC_CONF_EARLY_TX_512 (1 << 1) #define VSC73XX_Q_MISC_CONF_MAC_PAUSE_MODE BIT(0) +/* CAT_VLAN_MISC categorizer VLAN miscellaneous bits*/ +#define VSC73XX_CAT_VLAN_MISC_VLAN_TCI_IGNORE_ENA BIT(8) +#define VSC73XX_CAT_VLAN_MISC_VLAN_KEEP_TAG_ENA BIT(7) + +/* CAT_PORT_VLAN categorizer port VLAN*/ +#define VSC73XX_CAT_PORT_VLAN_VLAN_CFI BIT(15) +#define VSC73XX_CAT_PORT_VLAN_VLAN_USR_PRIO GENMASK(14, 12) +#define VSC73XX_CAT_PORT_VLAN_VLAN_VID GENMASK(11, 0) + /* Frame analyzer block 2 registers */ #define VSC73XX_STORMLIMIT 0x02 #define VSC73XX_ADVLEARN 0x03 @@ -188,7 +212,8 @@ #define VSC73XX_VLANACCESS_VLAN_MIRROR BIT(29) #define VSC73XX_VLANACCESS_VLAN_SRC_CHECK BIT(28) #define VSC73XX_VLANACCESS_VLAN_PORT_MASK GENMASK(9, 2) -#define VSC73XX_VLANACCESS_VLAN_TBL_CMD_MASK GENMASK(2, 0) +#define VSC73XX_VLANACCESS_VLAN_PORT_MASK_SHIFT 2 +#define VSC73XX_VLANACCESS_VLAN_TBL_CMD_MASK GENMASK(1, 0) #define VSC73XX_VLANACCESS_VLAN_TBL_CMD_IDLE 0 #define VSC73XX_VLANACCESS_VLAN_TBL_CMD_READ_ENTRY 1 #define VSC73XX_VLANACCESS_VLAN_TBL_CMD_WRITE_ENTRY 2 @@ -343,6 +368,12 @@ static const struct vsc73xx_counter vsc73xx_tx_counters[] = { { 29, "TxQoSClass3" }, /* non-standard counter */ }; +enum vsc73xx_port_vlan_conf { + VSC73XX_VLAN_FILTER, + VSC73XX_VLAN_FILTER_UNTAG_ALL, + VSC73XX_VLAN_IGNORE, +}; + int vsc73xx_is_addr_valid(u8 block, u8 subblock) { switch (block) { @@ -560,6 +591,82 @@ static enum dsa_tag_protocol vsc73xx_get_tag_protocol(struct dsa_switch *ds, return DSA_TAG_PROTO_NONE; } +static int vsc73xx_wait_for_vlan_table_cmd(struct vsc73xx *vsc) +{ + int ret, err; + u32 val; + + ret = read_poll_timeout(vsc73xx_read, err, + err < 0 || ((val & VSC73XX_VLANACCESS_VLAN_TBL_CMD_MASK) == + VSC73XX_VLANACCESS_VLAN_TBL_CMD_IDLE), + 1000, 10000, false, vsc, VSC73XX_BLOCK_ANALYZER, + 0, VSC73XX_VLANACCESS, &val); + if (ret) + return ret; + return err; +} + +static int +vsc73xx_read_vlan_table_entry(struct vsc73xx *vsc, u16 vid, u8 *portmap) +{ + u32 val; + int ret; + + vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_VLANTIDX, vid); + ret = vsc73xx_wait_for_vlan_table_cmd(vsc); + if (ret) + return ret; + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_VLANACCESS, + VSC73XX_VLANACCESS_VLAN_TBL_CMD_MASK, + VSC73XX_VLANACCESS_VLAN_TBL_CMD_READ_ENTRY); + ret = vsc73xx_wait_for_vlan_table_cmd(vsc); + if (ret) + return ret; + vsc73xx_read(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_VLANACCESS, &val); + *portmap = (val & VSC73XX_VLANACCESS_VLAN_PORT_MASK) >> + VSC73XX_VLANACCESS_VLAN_PORT_MASK_SHIFT; + return 0; +} + +static int +vsc73xx_write_vlan_table_entry(struct vsc73xx *vsc, u16 vid, u8 portmap) +{ + int ret; + + vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_VLANTIDX, vid); + ret = vsc73xx_wait_for_vlan_table_cmd(vsc); + if (ret) + return ret; + + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_VLANACCESS, + VSC73XX_VLANACCESS_VLAN_TBL_CMD_MASK | + VSC73XX_VLANACCESS_VLAN_SRC_CHECK | + VSC73XX_VLANACCESS_VLAN_PORT_MASK, + VSC73XX_VLANACCESS_VLAN_TBL_CMD_WRITE_ENTRY | + VSC73XX_VLANACCESS_VLAN_SRC_CHECK | + (portmap << VSC73XX_VLANACCESS_VLAN_PORT_MASK_SHIFT)); + + return vsc73xx_wait_for_vlan_table_cmd(vsc); +} + +static int +vsc73xx_update_vlan_table(struct vsc73xx *vsc, int port, u16 vid, bool set) +{ + u8 portmap; + int ret; + + ret = vsc73xx_read_vlan_table_entry(vsc, vid, &portmap); + if (ret) + return ret; + + if (set) + portmap |= BIT(port); + else + portmap &= ~BIT(port); + + return vsc73xx_write_vlan_table_entry(vsc, vid, portmap); +} + static int vsc73xx_setup(struct dsa_switch *ds) { struct vsc73xx *vsc = ds->priv; @@ -594,7 +701,7 @@ static int vsc73xx_setup(struct dsa_switch *ds) VSC73XX_MACACCESS, VSC73XX_MACACCESS_CMD_CLEAR_TABLE); - /* Clear VLAN table */ + /* Set VLAN table to default values*/ vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_VLANACCESS, VSC73XX_VLANACCESS_VLAN_TBL_CMD_CLEAR_TABLE); @@ -623,6 +730,9 @@ static int vsc73xx_setup(struct dsa_switch *ds) vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GMIIDELAY, VSC73XX_GMIIDELAY_GMII0_GTXDELAY_2_0_NS | VSC73XX_GMIIDELAY_GMII0_RXDELAY_2_0_NS); + /* Ingess VLAN reception mask (table 145) */ + vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_VLANMASK, + 0x5f); /* IP multicast flood mask (table 144) */ vsc73xx_write(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_IFLODMSK, 0xff); @@ -635,6 +745,12 @@ static int vsc73xx_setup(struct dsa_switch *ds) udelay(4); + /* Clear VLAN table*/ + for (i = 0; i < VLAN_N_VID; i++) + vsc73xx_write_vlan_table_entry(vsc, i, 0); + + INIT_LIST_HEAD(&vsc->vlans); + return 0; } @@ -1024,6 +1140,405 @@ static void vsc73xx_phylink_get_caps(struct dsa_switch *dsa, int port, config->mac_capabilities = MAC_SYM_PAUSE | MAC_10 | MAC_100 | MAC_1000; } +static void +vsc73xx_set_vlan_conf(struct vsc73xx *vsc, int port, + enum vsc73xx_port_vlan_conf port_vlan_conf) +{ + u32 val = (port_vlan_conf == VSC73XX_VLAN_IGNORE) ? + VSC73XX_CAT_VLAN_MISC_VLAN_TCI_IGNORE_ENA : 0; + + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_VLAN_MISC, + VSC73XX_CAT_VLAN_MISC_VLAN_TCI_IGNORE_ENA, val); + + val = (port_vlan_conf == VSC73XX_VLAN_IGNORE) ? + VSC73XX_CAT_VLAN_MISC_VLAN_KEEP_TAG_ENA : 0; + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_VLAN_MISC, + VSC73XX_CAT_VLAN_MISC_VLAN_KEEP_TAG_ENA, val); + + val = (port_vlan_conf == VSC73XX_VLAN_FILTER) ? + VSC73XX_TXUPDCFG_TX_INSERT_TAG : 0; + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_TXUPDCFG, + VSC73XX_TXUPDCFG_TX_INSERT_TAG, val); +} + +static int +vsc73xx_vlan_change_untagged(struct vsc73xx *vsc, int port, u16 vid, bool set, + bool operate_on_storage) +{ + u32 val; + + if (operate_on_storage) { + vsc->untagged_storage[port] = set ? vid : VLAN_N_VID; + return 0; + } + + val = set ? VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_ENA : 0; + vid = set ? vid : 0; + + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_TXUPDCFG, + VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_ENA, val); + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_TXUPDCFG, + VSC73XX_TXUPDCFG_TX_UNTAGGED_VID, + (vid << VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_SHIFT) & + VSC73XX_TXUPDCFG_TX_UNTAGGED_VID); + return 0; +} + +static int +vsc73xx_vlan_change_pvid(struct vsc73xx *vsc, int port, u16 vid, bool set, bool operate_on_storage) +{ + u32 val; + + if (operate_on_storage) { + vsc->pvid_storage[port] = set ? vid : VLAN_N_VID; + return 0; + } + + val = set ? 0 : VSC73XX_CAT_DROP_UNTAGGED_ENA; + vid = set ? vid : 0; + + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_DROP, + VSC73XX_CAT_DROP_UNTAGGED_ENA, val); + + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_PORT_VLAN, + VSC73XX_CAT_PORT_VLAN_VLAN_VID, + vid & VSC73XX_CAT_PORT_VLAN_VLAN_VID); + return 0; +} + +static bool +vsc73xx_port_get_pvid(struct vsc73xx *vsc, int port, u16 *vid, bool operate_on_storage) +{ + u32 val; + + if (operate_on_storage) { + if (vsc->pvid_storage[port] < VLAN_N_VID) { + *vid = vsc->pvid_storage[port]; + return true; + } + return false; + } + + vsc73xx_read(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_DROP, &val); + if (val & VSC73XX_CAT_DROP_UNTAGGED_ENA) + return false; + + vsc73xx_read(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_PORT_VLAN, &val); + *vid = val & VSC73XX_CAT_PORT_VLAN_VLAN_VID; + + return true; +} + +static bool vsc73xx_tag_8021q_active(struct dsa_port *dp) +{ + return !dsa_port_is_vlan_filtering(dp); +} + +static bool +vsc73xx_port_get_untagged(struct vsc73xx *vsc, int port, u16 *vid, bool operate_on_storage) +{ + u32 val; + + if (operate_on_storage) { + if (vsc->untagged_storage[port] < VLAN_N_VID) { + *vid = vsc->untagged_storage[port]; + return true; + } + return false; + } + + vsc73xx_read(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_TXUPDCFG, &val); + if (!(val & VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_ENA)) + return false; + + *vid = (val & VSC73XX_TXUPDCFG_TX_UNTAGGED_VID) >> + VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_SHIFT; + + return true; +} + +static struct vsc73xx_bridge_vlan *vsc73xx_bridge_vlan_find(struct vsc73xx *vsc, u16 vid) +{ + struct vsc73xx_bridge_vlan *vlan; + + list_for_each_entry(vlan, &vsc->vlans, list) + if (vlan->vid == vid) + return vlan; + + return NULL; +} + +static u16 vsc73xx_bridge_vlan_num_tagged(struct vsc73xx *vsc, int port, u16 ignored_vid) +{ + struct vsc73xx_bridge_vlan *vlan; + u16 num_tagged = 0; + + list_for_each_entry(vlan, &vsc->vlans, list) + if ((vlan->portmask & BIT(port)) && + !(vlan->untagged & BIT(port)) && + vlan->vid != ignored_vid) + num_tagged++; + + return num_tagged; +} + +static u16 vsc73xx_bridge_vlan_num_untagged(struct vsc73xx *vsc, int port, u16 ignored_vid) +{ + struct vsc73xx_bridge_vlan *vlan; + u16 num_untagged = 0; + + list_for_each_entry(vlan, &vsc->vlans, list) + if ((vlan->portmask & BIT(port)) && + (vlan->untagged & BIT(port)) && + vlan->vid != ignored_vid) + num_untagged++; + + return num_untagged; +} + +static u16 vsc73xx_find_first_vlan_untagged(struct vsc73xx *vsc, int port) +{ + struct vsc73xx_bridge_vlan *vlan; + + list_for_each_entry(vlan, &vsc->vlans, list) + if ((vlan->portmask & BIT(port)) && + (vlan->untagged & BIT(port))) + return vlan->vid; + + return VLAN_N_VID; +} + +static int +vsc73xx_port_vlan_filtering(struct dsa_switch *ds, int port, + bool vlan_filtering, struct netlink_ext_ack *extack) +{ + enum vsc73xx_port_vlan_conf port_vlan_conf = VSC73XX_VLAN_IGNORE; + struct vsc73xx *vsc = ds->priv; + bool store_untagged = false; + bool store_pvid = false; + u16 vlan_no, vlan_untagged; + + /* The swap processed bellow is required because vsc73xx is using tag8021q. + * When vlan_filtering is disabled, tag8021q use pvid/untagged vlans for + * port recognition. The values configured for vlans < 3072 are stored + * in storage table. When vlan_filtering is enabled, we need to restore + * pvid/untagged from storage and keep values used for tag8021q. + */ + + if (vlan_filtering) { + /* Use VLAN_N_VID to count all vlans */ + u16 num_untagged = vsc73xx_bridge_vlan_num_untagged(vsc, port, VLAN_N_VID); + + port_vlan_conf = (num_untagged > 1) ? + VSC73XX_VLAN_FILTER_UNTAG_ALL : VSC73XX_VLAN_FILTER; + + vlan_untagged = vsc73xx_find_first_vlan_untagged(vsc, port); + if (vlan_no < VLAN_N_VID) { + store_untagged = vsc73xx_port_get_untagged(vsc, port, &vlan_no, false); + vsc73xx_vlan_change_untagged(vsc, port, vlan_untagged, + vlan_untagged < VLAN_N_VID, false); + vsc->untagged_storage[port] = store_untagged ? vlan_no : VLAN_N_VID; + } + } else { + vsc73xx_vlan_change_untagged(vsc, port, vsc->untagged_storage[port], + vsc->untagged_storage[port] < VLAN_N_VID, false); + } + + vsc73xx_set_vlan_conf(vsc, port, port_vlan_conf); + + store_pvid = vsc73xx_port_get_pvid(vsc, port, &vlan_no, false); + vsc73xx_vlan_change_pvid(vsc, port, vsc->pvid_storage[port], + vsc->pvid_storage[port] < VLAN_N_VID, false); + vsc->pvid_storage[port] = store_pvid ? vlan_no : VLAN_N_VID; + + return 0; +} + +static int vsc73xx_port_vlan_add(struct dsa_switch *ds, int port, + const struct switchdev_obj_port_vlan *vlan, + struct netlink_ext_ack *extack) +{ + bool untagged = vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED; + bool pvid = vlan->flags & BRIDGE_VLAN_INFO_PVID; + struct vsc73xx_bridge_vlan *vsc73xx_vlan; + u16 vlan_no, num_tagged, num_untagged; + struct vsc73xx *vsc = ds->priv; + int ret; + + /* Be sure to deny alterations to the configuration done by tag_8021q. + */ + if (vid_is_dsa_8021q(vlan->vid)) { + NL_SET_ERR_MSG_MOD(extack, + "Range 3072-4095 reserved for dsa_8021q operation"); + return -EBUSY; + } + + num_tagged = vsc73xx_bridge_vlan_num_tagged(vsc, port, vlan->vid); + num_untagged = vsc73xx_bridge_vlan_num_untagged(vsc, port, vlan->vid); + + /* VSC73XX allow only three untagged states: none, one or all */ + if ((untagged && num_tagged > 0 && num_untagged > 0) || + (!untagged && num_untagged > 1)) { + NL_SET_ERR_MSG_MOD(extack, + "Port can have only none, one or all untagged vlan!\n"); + return -EBUSY; + } + + vsc73xx_vlan = vsc73xx_bridge_vlan_find(vsc, vlan->vid); + + if (!vsc73xx_vlan) { + vsc73xx_vlan = kzalloc(sizeof(*vsc73xx_vlan), GFP_KERNEL); + if (!vsc73xx_vlan) + return -ENOMEM; + + vsc73xx_vlan->vid = vlan->vid; + vsc73xx_vlan->portmask = BIT(port); + vsc73xx_vlan->untagged |= untagged ? BIT(port) : 0; + + INIT_LIST_HEAD(&vsc73xx_vlan->list); + list_add_tail(&vsc73xx_vlan->list, &vsc->vlans); + } else { + vsc73xx_vlan->portmask |= BIT(port); + + if (untagged) + vsc73xx_vlan->untagged |= BIT(port); + else + vsc73xx_vlan->untagged &= ~BIT(port); + } + + /* CPU port must be always tagged because port separation are based on 8021q.*/ + if (port != CPU_PORT) { + bool operate_on_storage = vsc73xx_tag_8021q_active(dsa_to_port(ds, port)); + + if (!operate_on_storage) { + enum vsc73xx_port_vlan_conf port_vlan_conf = VSC73XX_VLAN_FILTER; + + if (num_tagged == 0 && untagged) + port_vlan_conf = VSC73XX_VLAN_FILTER_UNTAG_ALL; + vsc73xx_set_vlan_conf(vsc, port, port_vlan_conf); + + if (port_vlan_conf == VSC73XX_VLAN_FILTER) { + if (untagged) { + ret = vsc73xx_vlan_change_untagged(vsc, port, vlan->vid, + true, + operate_on_storage); + if (ret) + return ret; + } else if (num_untagged == 1) { + vlan_no = vsc73xx_find_first_vlan_untagged(vsc, port); + ret = vsc73xx_vlan_change_untagged(vsc, port, vlan_no, true, + operate_on_storage); + if (ret) + return ret; + } + } + } + + if (pvid) { + ret = vsc73xx_vlan_change_pvid(vsc, port, vlan->vid, true, + operate_on_storage); + if (ret) + return ret; + } else { + if (vsc73xx_port_get_pvid(vsc, port, &vlan_no, false) && + vlan_no == vlan->vid) + vsc73xx_vlan_change_pvid(vsc, port, 0, false, false); + else if (vsc->pvid_storage[port] == vlan->vid) + vsc73xx_vlan_change_pvid(vsc, port, 0, false, true); + } + } + + return vsc73xx_update_vlan_table(vsc, port, vlan->vid, true); +} + +static int vsc73xx_port_vlan_del(struct dsa_switch *ds, int port, + const struct switchdev_obj_port_vlan *vlan) +{ + struct vsc73xx_bridge_vlan *vsc73xx_vlan; + u16 vlan_no, num_tagged, num_untagged; + struct vsc73xx *vsc = ds->priv; + bool operate_on_storage; + int ret; + + num_tagged = vsc73xx_bridge_vlan_num_tagged(vsc, port, vlan->vid); + num_untagged = vsc73xx_bridge_vlan_num_untagged(vsc, port, vlan->vid); + + ret = vsc73xx_update_vlan_table(vsc, port, vlan->vid, false); + if (ret) + return ret; + + operate_on_storage = vsc73xx_tag_8021q_active(dsa_to_port(ds, port)); + + if (!operate_on_storage) { + enum vsc73xx_port_vlan_conf port_vlan_conf = VSC73XX_VLAN_FILTER; + + if (num_tagged == 0) + port_vlan_conf = VSC73XX_VLAN_FILTER_UNTAG_ALL; + vsc73xx_set_vlan_conf(vsc, port, port_vlan_conf); + + if (num_untagged <= 1) { + vlan_no = vsc73xx_find_first_vlan_untagged(vsc, port); + vsc73xx_vlan_change_untagged(vsc, port, vlan_no, num_untagged, false); + } + } else if (vsc->untagged_storage[port] == vlan->vid) { + vsc73xx_vlan_change_untagged(vsc, port, 0, false, true); + } + + if (vsc73xx_port_get_pvid(vsc, port, &vlan_no, false) && vlan_no == vlan->vid) + vsc73xx_vlan_change_pvid(vsc, port, 0, false, false); + else if (vsc->pvid_storage[port] == vlan->vid) + vsc73xx_vlan_change_pvid(vsc, port, 0, false, true); + + vsc73xx_vlan = vsc73xx_bridge_vlan_find(vsc, vlan->vid); + + if (vsc73xx_vlan) { + vsc73xx_vlan->portmask &= ~BIT(port); + + if (vsc73xx_vlan->portmask) + return 0; + + list_del(&vsc73xx_vlan->list); + kfree(vsc73xx_vlan); + } + + return 0; +} + +static int vsc73xx_port_setup(struct dsa_switch *ds, int port) +{ + struct vsc73xx *vsc = ds->priv; + + /* Those bits are responsible for MTU only. Kernel take care about MTU, + * let's enable +8 bytes frame length unconditionally. + */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, + VSC73XX_MAC_CFG_VLAN_AWR | VSC73XX_MAC_CFG_VLAN_DBLAWR, + VSC73XX_MAC_CFG_VLAN_AWR | VSC73XX_MAC_CFG_VLAN_DBLAWR); + + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_DROP, + VSC73XX_CAT_DROP_TAGGED_ENA, 0); + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_DROP, + VSC73XX_CAT_DROP_UNTAGGED_ENA, + VSC73XX_CAT_DROP_UNTAGGED_ENA); + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_TXUPDCFG, + VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_ENA, 0); + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_TXUPDCFG, + VSC73XX_TXUPDCFG_TX_UNTAGGED_VID, 0); + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_PORT_VLAN, + VSC73XX_CAT_PORT_VLAN_VLAN_VID, 0); + + if (port == CPU_PORT) + vsc73xx_set_vlan_conf(vsc, port, VSC73XX_VLAN_FILTER); + else + vsc73xx_set_vlan_conf(vsc, port, VSC73XX_VLAN_IGNORE); + + /* Set storage values out of range */ + vsc->pvid_storage[port] = VLAN_N_VID; + vsc->untagged_storage[port] = VLAN_N_VID; + + return 0; +} + static void vsc73xx_refresh_fwd_map(struct dsa_switch *ds, int port, bool configure) { struct dsa_port *dp = dsa_to_port(ds, port); @@ -1107,11 +1622,15 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .get_strings = vsc73xx_get_strings, .get_ethtool_stats = vsc73xx_get_ethtool_stats, .get_sset_count = vsc73xx_get_sset_count, + .port_setup = vsc73xx_port_setup, .port_enable = vsc73xx_port_enable, .port_disable = vsc73xx_port_disable, .port_change_mtu = vsc73xx_change_mtu, .port_max_mtu = vsc73xx_get_max_mtu, .port_stp_state_set = vsc73xx_port_stp_state_set, + .port_vlan_filtering = vsc73xx_port_vlan_filtering, + .port_vlan_add = vsc73xx_port_vlan_add, + .port_vlan_del = vsc73xx_port_vlan_del, .phylink_get_caps = vsc73xx_phylink_get_caps, }; diff --git a/drivers/net/dsa/vitesse-vsc73xx.h b/drivers/net/dsa/vitesse-vsc73xx.h index 99c5c24ffde0..01eb2dd48f03 100644 --- a/drivers/net/dsa/vitesse-vsc73xx.h +++ b/drivers/net/dsa/vitesse-vsc73xx.h @@ -24,6 +24,14 @@ * @addr: MAC address used in flow control frames * @ops: Structure with hardware-dependent operations * @priv: Pointer to the configuration interface structure + * @pvid_storage: Storage table with PVID configured for other state of vlan_filtering. + * It have two roles: Keep PVID when PVID is configured but vlan filtering is off + * and keep PVID necessary for tag8021q operations when vlan filtering is enabled. + * @untagged_storage: Storage table with eggress untagged VLAN configured for + * other state of vlan_filtering.Keep VID necessary for tag8021q operations when + * vlan filtering is enabled. + * @vlans: List of configured vlans. Contain port mask and untagged status of every + * vlan configured in port vlan operation. It doesn't cover tag8021q vlans. */ struct vsc73xx { struct device *dev; @@ -34,6 +42,9 @@ struct vsc73xx { u8 addr[ETH_ALEN]; const struct vsc73xx_ops *ops; void *priv; + u16 pvid_storage[VSC73XX_MAX_NUM_PORTS]; + u16 untagged_storage[VSC73XX_MAX_NUM_PORTS]; + struct list_head vlans; }; /** @@ -48,6 +59,20 @@ struct vsc73xx_ops { u32 val); }; +/** + * struct vsc73xx_bridge_vlan - VSC73xx driver structure which keeps vlan database copy + * @vid: VLAN number + * @portmask: each bit represends one port + * @untagged: each bit represends one port configured with @vid untagged + * @list: list structure + */ +struct vsc73xx_bridge_vlan { + u16 vid; + u8 portmask; + u8 untagged; + struct list_head list; +}; + int vsc73xx_is_addr_valid(u8 block, u8 subblock); int vsc73xx_probe(struct vsc73xx *vsc); void vsc73xx_remove(struct vsc73xx *vsc); From patchwork Tue Feb 13 22:03:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp836421dyb; Tue, 13 Feb 2024 14:11:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWE10fRM8sRNkwNpRVwf0E4Bi4Ms/1yAaEMFF0bUiGp+cKkKr1eYCFgWwCrIvepSBolKIMKa/et854sG/KlSNAv/YQDkQ== X-Google-Smtp-Source: AGHT+IHJ64FACAcnWlLVZFtgT/pDmHaltTM931iFFvux4T97lbvXFylENeXj3SEak5rkP4t7S0Yo X-Received: by 2002:aa7:c352:0:b0:561:b8fd:7f67 with SMTP id j18-20020aa7c352000000b00561b8fd7f67mr645028edr.6.1707862312178; Tue, 13 Feb 2024 14:11:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862312; cv=pass; d=google.com; s=arc-20160816; b=pfC1J3TcnsZvhIPe2xJtl6XQnQsMjMLoAn/+kSRhtJDAsKAVS7jh2lPgmhApJC/gAg gvqmWFQLh608DXKfs3zu8vvGH4HWJY6pP2XLb0nMxPBSg2udYoegW4iv5Ui6ILB9OxP0 pegTFyr118F86zh/WgzQr2Uko1/Wxiiq04sDPXMjmRVLz65DOAnwlNMglui6k9fvVAuE YGVKn5tfWN3eag2Qn1AaNlfpiDjNECY51FZHS9o9QzrlaySA+/qXVADRONq4YS0t2s4D TSg+FZNjCpazrp4//sVHxW7uTRiicLfNOyVwbdRUMbm2bi8Xj9IhVscmTOcCGnRIiOkJ KH6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uU/EzzAZ+26p7VR+AL+8noQM2sIMSv95utTyaUMHIAk=; fh=umIx8bDLfXH3dcngM484ccfrQhmtju0agB5MzjvFDzo=; b=RmJ/j0utqTQdthix8gJwGRIhoUaAb+Oko7AHn9pxzJwrXV6DvJ/ux1X9XG86irP2KF Z9wnEn8fx4XJxx1admnetgZnN7TKgQztNndjIsWk7QV+pXniw0yrXRFsLhuB54cp3O6r KLBsF8f1WEi9vlJSz80tozEdgZNTwrbhVJa9ueuHHXW+7XCdnKxf1F6WGBU5Cqb2QUMg P0jHSs76+nidb35dazbf+k7flry1VjlFTAztEh5Q/9UMIdwS7fFTfnmI3691I6c1MlOp /stYQJoYxDpIgMhAImMQ1oXyMCmwhnmwcW0OvXMzmKE0qQkE40vfHVKkdnS1UIc8x+12 g3tA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RGN2gAOO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64430-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64430-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCV54vveAhd/V2AiZ/tip3RCcKne2m21WjeyF/Qx6pFhkiYiPALwhGk5gSQpzOzPpqUwNBULLFlXAg9I9a9CRsxVyVVj5A== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 16-20020a508750000000b00561bb592665si2219766edv.257.2024.02.13.14.11.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:11:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64430-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RGN2gAOO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64430-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64430-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8DA501F21246 for ; Tue, 13 Feb 2024 22:11:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1DE96F070; Tue, 13 Feb 2024 22:05:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RGN2gAOO" Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 7714369E10; Tue, 13 Feb 2024 22:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861949; cv=none; b=LwnTJMb6SZm2kySJD2nSQN6X3f6rDQxdI5ekPRTGljraEDYusV2ZJtS+fa7L40LzhwTfblhQDubYiSFxV1ieiifOpL/Je7vJsLtCmKO2Fc5FtGWsqkKTHviRdiPbIq0vB+U2PkocYLhOg86mJIoFbcCv8tH9nLIen74haMx2es0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861949; c=relaxed/simple; bh=30wAuor8M+3rBgvHsgL+WF5JOPTFm3WXG/R2QNvezrc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RstN8/PYxh8t3ReVU0USSMwiLE3QnMVuio6kBPWlYbiC2eTNAGESdIwDXi4dwmhApww3LObabNSheSuGX9pFA6iju8X1k0hOVsNObLXUACoHECbFe0rxLS0hBm0z10XMBhwSgJeFdnNjfqh8r/j+xZYiKlAyShWvOlhZw1e1VFk= 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=RGN2gAOO; arc=none smtp.client-ip=209.85.208.49 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 Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-55c2cf644f3so6453507a12.1; Tue, 13 Feb 2024 14:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861945; x=1708466745; 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=uU/EzzAZ+26p7VR+AL+8noQM2sIMSv95utTyaUMHIAk=; b=RGN2gAOOzCnhcKSSXCP1Lkq8+EYrYAwoUTqROc3YTp+Z2z0R2vjUeI4mHYd7AFISUo AKizuXy3z0pLtxqQZuB2sdGdMTfTSks/Mtv0nVdKvDM61urBKtDhwc6uGBhHuyCcdUbt 2dmICdRPHrRZkQwKKBeNhSf5PdCQ3x7cF40tJfEz1BOOa1l1i9rHiOWTf0gZuJMy4xmI RAhVRv3fjFZ2jxRZQzGlICFeAavQAxKqRnvk2dq1lRjF/n4ANjkcBnEhBlVfBrJu/wDs mf7b/B+hITEue1PjBCrEE8mL7Gg98bEuHuFZjQLfu9e6hi3yTtxMrAPav65dxl5TdjJ9 /Y/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861945; x=1708466745; 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=uU/EzzAZ+26p7VR+AL+8noQM2sIMSv95utTyaUMHIAk=; b=dVzput3A9muX7Vy6wg3io3Y+ERjibJydqdCPLsyKQM2kFq6+poU7l/+XriVxlA+1Rl crvxlgSll1IST7SJAZUE8j46VnJubp5u+w28p6QTeR7Nj9H4AueyQ+IB1HfOvDzirO5K ED9BKlkWI28KGhgM3X0ZTE+mehQq9YmiJJIcs9YiDs62K3oChbraKqPqe6daJXJQjQlg sEXtvnVo1XyR1q70jdSSiZA114/KFzJsgK+UGYQtPZHTp8Q/hJI8Wzg8E9AghNBwJ9p9 2Jw2ke+cZBY11pMNDFcbVDczn7yRgI+X15ZtTpRaWijIFz1UHb5LfyUMpHQUHHz3KWWf XJXA== X-Forwarded-Encrypted: i=1; AJvYcCUORXMzKrUhqUMjOtDlHrMn36/zttx4WW0rSLz+XRPsgeMk8tPBYyr5neV7hQ7I2jxBCY0e8HLPBQPEXg5ERZM24QahXJ/MdzRlOhyp X-Gm-Message-State: AOJu0YxNP4qkBOzhzGeSaQR5zCOqh3+6ApfrKWX1/7OhHVmJ2qhDHGRD xXCtu9ruUc+1hFOGbUgsCsW6axoV2DuUDJnAdT5GcSMZj5Wf2hc9CgVeTBoLRs4= X-Received: by 2002:a17:906:495:b0:a3d:1a89:7054 with SMTP id f21-20020a170906049500b00a3d1a897054mr486760eja.39.1707861945378; Tue, 13 Feb 2024 14:05:45 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWK4qxbePgjYGlDE0gi9ls5TD1pLfnEevyvGm8A1VCaFV6ho/2jGjFgvpPKd+2PGU5YRkEjchB8OaUr08bd5O1PO+NkneZp3vx7ROmfKa7/n8pZ1qZReg14zZIcrf79o/hG5gsibENB3qqaoKdF2shbQj06+X5cgUsrhX8L3TWUWlJOEGhXa+3z9KWO3vN9GmPTDOzgMvjV03w/WtyAJdlfXl326ElGH5Usi92MTXQXbC2Yup2zbeWZWst6+Dcjz40/EUIyPk+6X1mQ24OymhtUkX1pxrrToUrccERlAJsTK3MC+FaTKHOADT5gBFl6hSQSoFkqDXJJiWWPrs1Cq/CsHI4GYsdWs37nJHB+Vmj24bb1f/ZZoNQ/OcdlxBEhGdn52tnrtuEdlwB+ddv79iYnhkUKROND07n5k3Fn5b3GcEIjJx9HkpFsX5NOC7CJkNV+EwAdAfxjkA== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:05:45 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Vladimir Oltean , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 08/15] net: dsa: tag_sja1105: absorb logic for not overwriting precise info into dsa_8021q_rcv() Date: Tue, 13 Feb 2024 23:03:21 +0100 Message-Id: <20240213220331.239031-9-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790823432073030243 X-GMAIL-MSGID: 1790823432073030243 From: Vladimir Oltean In both sja1105_rcv() and sja1110_rcv(), we may have precise source port information coming from parallel hardware mechanisms, in addition to the tag_8021q header. Only sja1105_rcv() has extra logic to not overwrite that precise info with what's present in the VLAN tag. This is because sja1110_rcv() gets by, by having a reversed set of checks when assigning skb->dev. When the source port is imprecise (vbid >=1), source_port and switch_id will be set to zeroes by dsa_8021q_rcv(), which might be problematic. But by checking for vbid >= 1 first, sja1110_rcv() fends that off. We would like to make more code common between sja1105_rcv() and sja1110_rcv(), and for that, we need to make sure that sja1110_rcv() also goes through the precise source port preservation logic. Signed-off-by: Vladimir Oltean --- v4: - introduced patch net/dsa/tag_8021q.c | 32 +++++++++++++++++++++++++++++--- net/dsa/tag_sja1105.c | 23 +++-------------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index 71b26ae6db39..3cb0293793a5 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -497,9 +497,21 @@ struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, } EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_port_by_vbid); +/** + * dsa_8021q_rcv - Decode source information from tag_8021q header + * @skb: RX socket buffer + * @source_port: pointer to storage for precise source port information. + * If this is known already from outside tag_8021q, the pre-initialized + * value is preserved. If not known, pass -1. + * @switch_id: similar to source_port. + * @vbid: pointer to storage for imprecise bridge ID. Must be pre-initialized + * with -1. If a positive value is returned, the source_port and switch_id + * are invalid. + */ void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, int *vbid) { + int tmp_source_port, tmp_switch_id, tmp_vbid; u16 vid, tci; if (skb_vlan_tag_present(skb)) { @@ -513,11 +525,25 @@ void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, vid = tci & VLAN_VID_MASK; - *source_port = dsa_8021q_rx_source_port(vid); - *switch_id = dsa_8021q_rx_switch_id(vid); + tmp_source_port = dsa_8021q_rx_source_port(vid); + tmp_switch_id = dsa_8021q_rx_switch_id(vid); + tmp_vbid = dsa_tag_8021q_rx_vbid(vid); + + /* Precise source port information is unknown when receiving from a + * VLAN-unaware bridging domain, and tmp_source_port and tmp_switch_id + * are zeroes in this case. + * + * Preserve the source information from hardware-specific mechanisms, + * if available. This allows us to not overwrite a valid source port + * and switch ID with less precise values. + */ + if (tmp_vbid == 0 && *source_port == -1) + *source_port = tmp_source_port; + if (tmp_vbid == 0 && *switch_id == -1) + *switch_id = tmp_switch_id; if (vbid) - *vbid = dsa_tag_8021q_rx_vbid(vid); + *vbid = tmp_vbid; skb->priority = (tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; } diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 1aba1d05c27a..48886d4b7e3e 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -524,30 +524,13 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, /* Normal data plane traffic and link-local frames are tagged with * a tag_8021q VLAN which we have to strip */ - if (sja1105_skb_has_tag_8021q(skb)) { - int tmp_source_port = -1, tmp_switch_id = -1; - - sja1105_vlan_rcv(skb, &tmp_source_port, &tmp_switch_id, &vbid, - &vid); - /* Preserve the source information from the INCL_SRCPT option, - * if available. This allows us to not overwrite a valid source - * port and switch ID with zeroes when receiving link-local - * frames from a VLAN-unaware bridged port (non-zero vbid) or a - * VLAN-aware bridged port (non-zero vid). Furthermore, the - * tag_8021q source port information is only of trust when the - * vbid is 0 (precise port). Otherwise, tmp_source_port and - * tmp_switch_id will be zeroes. - */ - if (vbid == 0 && source_port == -1) - source_port = tmp_source_port; - if (vbid == 0 && switch_id == -1) - switch_id = tmp_switch_id; - } else if (source_port == -1 && switch_id == -1) { + if (sja1105_skb_has_tag_8021q(skb)) + sja1105_vlan_rcv(skb, &source_port, &switch_id, &vbid, &vid); + else if (source_port == -1 && switch_id == -1) /* Packets with no source information have no chance of * getting accepted, drop them straight away. */ return NULL; - } if (source_port != -1 && switch_id != -1) skb->dev = dsa_conduit_find_user(netdev, switch_id, source_port); From patchwork Tue Feb 13 22:03:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200693 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp836645dyb; Tue, 13 Feb 2024 14:12:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUxag27N17JV0yZNZCU1bF5w6DfhgchmyFEw5bB5fN54b27JOMSOiypDii4YRf/1xiRnPJ10RaMZCAJ6NpexaktX5Raxw== X-Google-Smtp-Source: AGHT+IFJj67xiRaYcMVDTFbkgKexGsrW6tDajKoS38K/JTjy4SJVvmVHY/RluytstpTxJAyJvZDx X-Received: by 2002:ad4:5baa:0:b0:68e:fd13:7c39 with SMTP id 10-20020ad45baa000000b0068efd137c39mr765277qvq.34.1707862350246; Tue, 13 Feb 2024 14:12:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862350; cv=pass; d=google.com; s=arc-20160816; b=XBqY447tXIp5kka4i96f+ZSC8AybmlgfiqCrcUWkZwT2lrXqQcXjYixpAxP06pkP+h C+7T4IJSCTMYy4EwU9v7tHLSVT6JcNmdXHKsVBFUaKHQoUc8peCje5sGzBWLbs5GXYL3 HHfhgkzJVsE8TFWrtjHnNsSbaB2f2v0oSqP8/QqXmwQkSmGMT60CscyAGvhZ0IJ6npmX iM17EMamRF/nqTbfBXP8UqVl+0cznaoOZrJcUj9O7RmeJTfRqe6vba62SIOTAZ7HfpdP 0MWDNARBYY6cx445crPN8kzJ5lSZrKSsWpQHSa20I9FMiAotUf2pmzdM0uCGQSQPkKiL 31Mw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=M+w6iJDAWTcoEwIs/CJsWDUTAWaRRDi08Wez6bn4quw=; fh=WkVm3eUvJWt2a1ESpAWb9q1aMTKJuUWmJ+bM+n/mRMU=; b=qONv2uxMJpDb8D9vueIXGr+0wTKIAe6juZTkxcIm/BqLpKfU/StnfHzFX5JCbsAJUG bsFRG18G8i5GU4Znk6dH4zzdN2E5GsnNu28X1CAf+UKT348bZbANVCCwuSU9N6J6AT5m gExz6p2qeLYJaubk+M0DK9edwfJSk37YJlGDL2rASaIOygpf7usspHt2agiYBjfktmcx X58cUjd+8WC1WUe+X5QhbmFUqNoW+g9iyCT/s5X6aWG1lwnAYlBV0aABTSZTjpSh7wZD tRTzl9AQa6QPVIPAoPHktrD7yycQmwJGHpEYK0Pbhe9v5LWD85jMxZc7pzQH2DVb/PX6 9jNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D55JQG4M; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64431-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64431-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCXtsOemK0cgYJhosFcC+h9L9C6N0YIx+ocAxXFU6owt5ldgGmwzcUkoulmaZP+yjxDU+mQb/UsyPIBJwDC51QleLIpsYA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id jv13-20020a05621429ed00b0068ed6e444edsi2841450qvb.372.2024.02.13.14.12.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:12:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64431-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=D55JQG4M; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64431-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64431-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 074E21C282DA for ; Tue, 13 Feb 2024 22:12:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8E836FB86; Tue, 13 Feb 2024 22:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D55JQG4M" Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (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 3557F6FB80; Tue, 13 Feb 2024 22:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861958; cv=none; b=mvHPsEbgJYcmm8M6+SIQemMEo8KfKpy4yu3R7+yiiM6NWFdm3JdYUI0XUb841VJZBZqfKkGYsSVOfLAb1E8Nojc2AysS72c2wW9nVyynzHyd5tvLJo149A7Up1ExDDYvS69XhIKCzSBjqDEA7j2jorQ9ub+HX74vkAOrH1M1ysY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861958; c=relaxed/simple; bh=FWHayuZw/Ot2rSgc/NXoN+gmwi8uEkTj3zeN+fbN+Uk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FSSyIEQu3tHy4vPOzGxpVOFxCmMx0njDoPQIv5wu173hghSEeZjNuhs9wS2MLTchP4UPn3AvEYOBjYj/QptV0nc58NMbAE4AiD8A3deDgurMamO9pJdJwMks6MlpKA/N7AHU5aUtx4YZSPOET771U7Lj7kKwvWRITN8yxOomcC4= 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=D55JQG4M; arc=none smtp.client-ip=209.85.218.42 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 Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a2f22bfb4e6so666336566b.0; Tue, 13 Feb 2024 14:05:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861954; x=1708466754; 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=M+w6iJDAWTcoEwIs/CJsWDUTAWaRRDi08Wez6bn4quw=; b=D55JQG4MmeTh7P/ySczjmRM5QIhRZanRPv2PIQf1kVtwYr3URNqoAoYNPNusrNcJyj m6eTke8v9jtXjHqM+Qs9nH8TuiSeXUkEWfWNoHRK9jI0jazFMzJfAnxYhvCQCLA5tCHO //4AxA9ORo+egcV/KbvKlKk1fBMXENRbb/snCI96ZY0nXs4ICMKYStCGOQchg3rR/Y9f +EXVczLPmxmqVZ9SOUiBnlkkwzrCWNftSW3yyisKlkkzd5AdkgNVevVVMZlcO71CywWI DRUr2oge9xSmJlLuNkPE3DG2GTepJ+hh3O00eAkgRxkuwinFQIozqQA2WaWTqR2mvm8X 3UnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861954; x=1708466754; 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=M+w6iJDAWTcoEwIs/CJsWDUTAWaRRDi08Wez6bn4quw=; b=C5aqXJ1M0A5tkwCeoxJotUzhm3cu0dd5zD1+ekShIQU/6GY3mXRj999ChXWPSywu+D xi2HFNhrYd8oDx4x+wdARmdqWiN0ix+HkD9cRbVZt5h4Vrc4GXM5qvOYHwp8vOuYBjZ0 xSyqpvo3aHVm1Iyh6SsjR7gGlvHImHys03Z1xPeAQrB6R7uOVI3fgTdloXDYdO/EgNKF msOaXXDd/XHLpr6QL3h+UNyJtr9hrmhzr443+K7V2zO/h+W6Ezebpxb72vnPS1e85pWK YufJIgA8/dh0uRGEP2KU6bazN1Ej3jNBPcN0GeND1bmr79rBnPzrCgMe/SzoILOwAUBd Ps5Q== X-Forwarded-Encrypted: i=1; AJvYcCUXD3VS+TwzFDmcORQpuZy4znZ0eiVxREGbWQa6sMx+MqeamvzTTfT2PTDhqdZqBfZLfyXDF3EHOWMBf2d3z6wFUVVBAI9VF7eE6HlI X-Gm-Message-State: AOJu0YwEaKPTqrN68H8Oz/2c4TwYAwjMnUx7S8KAatHb69nUzxkO+SHi 0CVpwkzJjBJpeVXU1bjNBlJc8ubBRUEK1HStvmoyzu9QCVliofr3FA9WHtYPMnI= X-Received: by 2002:a17:906:6812:b0:a3d:2146:5703 with SMTP id k18-20020a170906681200b00a3d21465703mr375059ejr.6.1707861953746; Tue, 13 Feb 2024 14:05:53 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU4GyoCdSkhUePgHnQ+n+8+Ok8bk9Nqu7JX5MvMPDSEe7mBwpL+x32F+XSEnfD8JDPCSyBvF4XI0U6bZq6a+Gjm7Y4XCtwjWXh5uewMvafmJcinE1bgeoP7szDCACqbLIC63gNO5nO9sbaZTSo61k0EdPwp1z0XDuSXOhJpjSFqQa/lsosvcASD/J+c6AIsyI0ztmtftDoMtP3kCA/U5a1QQCLjmNNTHwNQNEOOgu8ULivte/bZ3XCUM2VBN1ZHe5t58kNwLpNAbO+CZ2ISpga1PUiexcYlUtiFOQ6qeVkBf5xfcIagSEGTLypU+qi3tpL/bVz9QIt6N3Dkqgnr5lVM7qmVs7M90Twl9yq492I0LFzFQKOomNLYE/mP6C5jCPxOcMXbAyezlk39SCOu2H0SYPX015HgHtHjtJLYZM/SvlN9S9WE3pTYkkekm2LsVC7hmFOXblXcKw== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:05:53 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Vladimir Oltean , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 09/15] net: dsa: tag_sja1105: absorb entire sja1105_vlan_rcv() into dsa_8021q_rcv() Date: Tue, 13 Feb 2024 23:03:22 +0100 Message-Id: <20240213220331.239031-10-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790823471633926977 X-GMAIL-MSGID: 1790823471633926977 From: Vladimir Oltean tag_sja1105 has a wrapper over dsa_8021q_rcv(): sja1105_vlan_rcv(), which determines whether the packet came from a bridge with vlan_filtering=1 (the case resolved via dsa_find_designated_bridge_port_by_vid()), or if it contains a tag_8021q header. Looking at a new tagger implementation for vsc73xx, based also on tag_8021q, it is becoming clear that the logic is needed there as well. So instead of forcing each tagger to wrap around dsa_8021q_rcv(), let's merge the logic into the core. Signed-off-by: Vladimir Oltean --- v4: - introduced patch net/dsa/tag_8021q.c | 34 ++++++++++++++++++++++++++++------ net/dsa/tag_8021q.h | 2 +- net/dsa/tag_ocelot_8021q.c | 2 +- net/dsa/tag_sja1105.c | 32 ++++---------------------------- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index 3cb0293793a5..332b0ae02645 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -507,27 +507,39 @@ EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_port_by_vbid); * @vbid: pointer to storage for imprecise bridge ID. Must be pre-initialized * with -1. If a positive value is returned, the source_port and switch_id * are invalid. + * @vid: pointer to storage for original VID, in case tag_8021q decoding failed. + * + * If the packet has a tag_8021q header, decode it and set @source_port, + * @switch_id and @vbid, and strip the header. Otherwise set @vid and keep the + * header in the hwaccel area of the packet. */ void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, - int *vbid) + int *vbid, int *vid) { int tmp_source_port, tmp_switch_id, tmp_vbid; - u16 vid, tci; + __be16 vlan_proto; + u16 tmp_vid, tci; if (skb_vlan_tag_present(skb)) { + vlan_proto = skb->vlan_proto; tci = skb_vlan_tag_get(skb); __vlan_hwaccel_clear_tag(skb); } else { + struct vlan_ethhdr *hdr = vlan_eth_hdr(skb); + + vlan_proto = hdr->h_vlan_proto; skb_push_rcsum(skb, ETH_HLEN); __skb_vlan_pop(skb, &tci); skb_pull_rcsum(skb, ETH_HLEN); } - vid = tci & VLAN_VID_MASK; + tmp_vid = tci & VLAN_VID_MASK; + if (!vid_is_dsa_8021q(tmp_vid)) + goto not_tag_8021q; - tmp_source_port = dsa_8021q_rx_source_port(vid); - tmp_switch_id = dsa_8021q_rx_switch_id(vid); - tmp_vbid = dsa_tag_8021q_rx_vbid(vid); + tmp_source_port = dsa_8021q_rx_source_port(tmp_vid); + tmp_switch_id = dsa_8021q_rx_switch_id(tmp_vid); + tmp_vbid = dsa_tag_8021q_rx_vbid(tmp_vid); /* Precise source port information is unknown when receiving from a * VLAN-unaware bridging domain, and tmp_source_port and tmp_switch_id @@ -546,5 +558,15 @@ void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, *vbid = tmp_vbid; skb->priority = (tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; + return; + +not_tag_8021q: + if (vid) + *vid = tmp_vid; + if (vbid) + *vbid = -1; + + /* Put the tag back */ + __vlan_hwaccel_put_tag(skb, vlan_proto, tci); } EXPORT_SYMBOL_GPL(dsa_8021q_rcv); diff --git a/net/dsa/tag_8021q.h b/net/dsa/tag_8021q.h index 41f7167ac520..0c6671d7c1c2 100644 --- a/net/dsa/tag_8021q.h +++ b/net/dsa/tag_8021q.h @@ -14,7 +14,7 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, u16 tpid, u16 tci); void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, - int *vbid); + int *vbid, int *vid); struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, int vbid); diff --git a/net/dsa/tag_ocelot_8021q.c b/net/dsa/tag_ocelot_8021q.c index b059381310fe..8e8b1bef6af6 100644 --- a/net/dsa/tag_ocelot_8021q.c +++ b/net/dsa/tag_ocelot_8021q.c @@ -81,7 +81,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, { int src_port, switch_id; - dsa_8021q_rcv(skb, &src_port, &switch_id, NULL); + dsa_8021q_rcv(skb, &src_port, &switch_id, NULL, NULL); skb->dev = dsa_conduit_find_user(netdev, switch_id, src_port); if (!skb->dev) diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 48886d4b7e3e..7639ccb94d35 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -472,37 +472,14 @@ static bool sja1110_skb_has_inband_control_extension(const struct sk_buff *skb) return ntohs(eth_hdr(skb)->h_proto) == ETH_P_SJA1110; } -/* If the VLAN in the packet is a tag_8021q one, set @source_port and - * @switch_id and strip the header. Otherwise set @vid and keep it in the - * packet. - */ -static void sja1105_vlan_rcv(struct sk_buff *skb, int *source_port, - int *switch_id, int *vbid, u16 *vid) -{ - struct vlan_ethhdr *hdr = vlan_eth_hdr(skb); - u16 vlan_tci; - - if (skb_vlan_tag_present(skb)) - vlan_tci = skb_vlan_tag_get(skb); - else - vlan_tci = ntohs(hdr->h_vlan_TCI); - - if (vid_is_dsa_8021q(vlan_tci & VLAN_VID_MASK)) - return dsa_8021q_rcv(skb, source_port, switch_id, vbid); - - /* Try our best with imprecise RX */ - *vid = vlan_tci & VLAN_VID_MASK; -} - static struct sk_buff *sja1105_rcv(struct sk_buff *skb, struct net_device *netdev) { - int source_port = -1, switch_id = -1, vbid = -1; + int source_port = -1, switch_id = -1, vbid = -1, vid = -1; struct sja1105_meta meta = {0}; struct ethhdr *hdr; bool is_link_local; bool is_meta; - u16 vid; hdr = eth_hdr(skb); is_link_local = sja1105_is_link_local(skb); @@ -525,7 +502,7 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, * a tag_8021q VLAN which we have to strip */ if (sja1105_skb_has_tag_8021q(skb)) - sja1105_vlan_rcv(skb, &source_port, &switch_id, &vbid, &vid); + dsa_8021q_rcv(skb, &source_port, &switch_id, &vbid, &vid); else if (source_port == -1 && switch_id == -1) /* Packets with no source information have no chance of * getting accepted, drop them straight away. @@ -660,9 +637,8 @@ static struct sk_buff *sja1110_rcv_inband_control_extension(struct sk_buff *skb, static struct sk_buff *sja1110_rcv(struct sk_buff *skb, struct net_device *netdev) { - int source_port = -1, switch_id = -1, vbid = -1; + int source_port = -1, switch_id = -1, vbid = -1, vid = -1; bool host_only = false; - u16 vid = 0; if (sja1110_skb_has_inband_control_extension(skb)) { skb = sja1110_rcv_inband_control_extension(skb, &source_port, @@ -674,7 +650,7 @@ static struct sk_buff *sja1110_rcv(struct sk_buff *skb, /* Packets with in-band control extensions might still have RX VLANs */ if (likely(sja1105_skb_has_tag_8021q(skb))) - sja1105_vlan_rcv(skb, &source_port, &switch_id, &vbid, &vid); + dsa_8021q_rcv(skb, &source_port, &switch_id, &vbid, &vid); if (vbid >= 1) skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); From patchwork Tue Feb 13 22:03:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp848750dyb; Tue, 13 Feb 2024 14:42:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV7gQ747j1Sdx3ZBaDgV9kH6v7J3Ge1708BzCR1XR/yXLM4d8QAwtfqMMgUVFpdL5Z4Je/3aB9gKjvNIQ2tLGGcL7V7yQ== X-Google-Smtp-Source: AGHT+IFneSsN4z9aTYMI4bvJR1RKZX3OMp9ECuQmMzCIZd38JTJPN3ri2VsMSm9Pq/9Sjf7NsHGm X-Received: by 2002:a17:902:6908:b0:1d4:cd4d:923b with SMTP id j8-20020a170902690800b001d4cd4d923bmr883159plk.54.1707864164358; Tue, 13 Feb 2024 14:42:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707864164; cv=pass; d=google.com; s=arc-20160816; b=Um6+rmJ+aK3oKKr4pKZbQzzxbw+NdSuNDe//kR6OQ5ds1nlcuRsFgTtb3ICIlrbDyn PP12hfqv9buquEGT1RS5hUQSXdfLmZuR0B6T7f6TgqQy5ccxIGVFVjppSVWWt5qJJi1O aTYdtLBEUd1JdZ0ez92A1IdRZ0BsIBGxu6iYf+/lEf/FJbhEU6IJfkZEmd4m3XG9Oh5z Kh8JPdj6rsWUM6gb+h+ml+cMztYV9Q1gl4wG6EjTYtMWRStW5MvtktXghdkGJZEFjOQD r3qhZlJcMQeNBAqRsvVY9W0UHtSnD0CA9QUqngjox3mr2WbOe7DgkCZWGTOHg/Hew7Oo zFkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GsV3RWi5mt3annbxTmJGAA4zUOZXwChRzqMr98hPMQE=; fh=lQJIhq0z1Yu3J/wvpHAYhT8OnqGVRRmz9ZOqc+A3x5c=; b=xGPnI9I0WNuUe2/lUUdH0b+CJnJsTsRPz2Ug3ZxA6OpfH4e9GdlfKY5iz2WIt0kgzp yyKaOxn6gRbpNJCXG2gxN/1vO42OFVFbax61m80V6BrCioXUFs/TgDnv1Qb2x8r+cWZh J5vzVnnQ/GA403om3h/DB/T6JkHX9gFIZ6METpCv5PVMRuIT1BqiL3wgfgmmwt4JSIz8 q8bMuK8uRb0ORBotOA6qdWtcKf2QkQ80vjhhXaLAFuTXxnWphj5I1KG3xItLWHHwKyC2 dCuvQmiHZ4aTNYstT4vGhrehn0itz6qVdODmx11atqdTapc2FFx1o/VEskPlUSyYW/M6 181w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kVjMYKIR; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64433-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCXXWl0JGGAyVo99x1h+tgPO1o4gfsBQumLlB5lHkyGbQkR6andqb8IDuBgUdMbDuFUUQJGu15MRJnODUeZjfBIhIGq9hA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a13-20020a170902b58d00b001d8da2362b8si2570256pls.261.2024.02.13.14.42.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:42:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kVjMYKIR; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64433-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64433-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B8659B2339B for ; Tue, 13 Feb 2024 22:12:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DD6276C78; Tue, 13 Feb 2024 22:06:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kVjMYKIR" Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.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 21396768FB; Tue, 13 Feb 2024 22:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861967; cv=none; b=Hm+6AX8XSoRdGEDOxDeOUWKNppgImlxxQI/BIzGhTw18FjEkQYcrtLtobaYDQTtJv6yyjc0E1VJuw9jJwrDCxej9NoVLMe/CdL+tNlIyf1RAXX5oldrrWb0Cju/TTT+mLM9Us6AQRyD1pXv3RBkbfD74zF9hPNWRPsZOT8CXJ9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861967; c=relaxed/simple; bh=gbxVPJ6WPRdDj/VlfQnJSPWObXat+GMFe+pa9vsdy8U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cfYT6BX7H6aiiV5wEWXe39cUQn6CCw/lJE28D55IzNMfkkSkE+WH9JexDMsDf6St0JHub01AO1k3GMFSFgAG7QZa20DL463lGk1VLOm+nomtIht1uqIcrpnl2mJ/RJkWwtYXsRaGwiZ630wBX7+XKNm/VeYgtYZW71BgSiA7Sow= 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=kVjMYKIR; arc=none smtp.client-ip=209.85.167.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 Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-51176eb6a4bso5034634e87.3; Tue, 13 Feb 2024 14:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861964; x=1708466764; 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=GsV3RWi5mt3annbxTmJGAA4zUOZXwChRzqMr98hPMQE=; b=kVjMYKIRBQw1BhPhGNzwLcWenlmsxIlDH0bk7q62f9QqgCOFhiLHom0sfcqxxnDBaZ zQqZg9FCZ19q0yNv9tvrKlWnrdWdV+4EvXh8KJ3A77nQW4y5gwDV/n9hMdgx8e4XSAnX Zrq7KmG3Q4fv4fbBZaQaK8O++axGD/ew2X86QCTvSxhvIS5U83R/G+QucRTLcMViotWY TW67HrdmWXl7yF/9TUomAf2JF46jitowoKzCEdnTRekQYJx6XWyWP4Gwu0AHafqUutGd adMNkC1H37Xp8XmHJL1uziJ/lwspkRpJayShSytMwHMZ5VEEAS3EP1ZLsfi/jG3pUbRC iuqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861964; x=1708466764; 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=GsV3RWi5mt3annbxTmJGAA4zUOZXwChRzqMr98hPMQE=; b=AJHLUYO3MSfox04FFi01bJ2OntjPuoVWV1NodDTrY8bmHb4gSH9Cew02CgcKolK8OT K0BFSCWYlfpbtQ2Yhz9VxQSdIcEgvXpQbEQ+6LXBXb/SdVPc+8D0939JEhrVyE2TmcCz EGN19MfZSifmSC7lqEE7RTjlU/mAevsFxqxX2kpkqyixsSM49FmVgN5FHO/yb65PXkrP c/nGT+2sDIl78xTElLZSvVqmrCDa2SYjcMMIrJ1pt6/txnIIR3UrXwDEo2TB18w95zUJ VSQYaenBVjNlf73169jDJLLb6tq+QiqaKy7rKn8bcA6AYO+DroawkM84m63LT2j+pEA+ +rVw== X-Forwarded-Encrypted: i=1; AJvYcCWv8UcNaa5hf/PJ2d7ew1SBRMsPTUGOo3KlX0RoW8k4Hg4XS+bRk7CulItQLOSnXh8SBFLouIJiDdZQraNRcSjYPBMrA39tz0+k13f9 X-Gm-Message-State: AOJu0YzYYeoKEmPTfDT/qPwU/5VYHx/VmGWR89dekP/xOlyFPMc83rKg 1qQKH+6XIPyDrohesgf2V3uviw8tEdTS6fE3k5w8s32/l2L2MTjpr3bFaqec10k= X-Received: by 2002:ac2:4c2e:0:b0:511:48aa:d621 with SMTP id u14-20020ac24c2e000000b0051148aad621mr596887lfq.66.1707861963831; Tue, 13 Feb 2024 14:06:03 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXiHsKUaFLJtSg26Ue6/yjHqtoSQycOdoVPF9xVAWZZ6A8ApxSlgT5sYHHdOg34B4LVHABTZJjb0fgPUXgXbCsOWt5YX3U233/9BBONll1rm05kwglv/n6TM10oBK3cUVaxALALDmILw1qHV7unWBbqsU9jzQHtnF17vHouc9faqY+bFeh6WLzvsRVPQ+RBOt91zeODGWprJkcnitiayv59Ab+XqlW7yNX5LTPB/f6WLfKl8XjRVcPZ4NUXiuZCk3M0HGZY2XK//IsCTSJcA9DMLnGduafS1loL7JGVb40QzeZXlWXW6qC/OE1FnESHi4gk5a54FttHBSO9rwTHe7UW80ljfcYlpj6jASNxqyhEOha59HgUFsxBWgAx1nk1G6hBy46mhnIOVIb7xchrz27InXRt9RWXYlKYW0+vql5hUnXlA1ilhozc5oblaJS5fj5+8DCdk3ednavarxZSkL7kahApD8QLlO0YEKvjpSDJmpI= Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:06:03 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Vladimir Oltean , Pawel Dembicki , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 11/15] net: dsa: tag_sja1105: refactor skb->dev assignment to dsa_tag_8021q_find_user() Date: Tue, 13 Feb 2024 23:03:24 +0100 Message-Id: <20240213220331.239031-12-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790825373545573624 X-GMAIL-MSGID: 1790825373545573624 From: Vladimir Oltean A new tagging protocol implementation based on tag_8021q is on the horizon, and it appears that it also has to open-code the complicated logic of finding a source port based on a VLAN header. Create a single dsa_tag_8021q_find_user() and make sja1105 call it. Signed-off-by: Vladimir Oltean Signed-off-by: Pawel Dembicki --- v4: - introduce patch and change from master to conduit and slave to user net/dsa/tag_8021q.c | 19 ++++++++++++++++--- net/dsa/tag_8021q.h | 5 +++-- net/dsa/tag_sja1105.c | 17 +++++------------ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index 332b0ae02645..454d36c84671 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -468,8 +468,8 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, } EXPORT_SYMBOL_GPL(dsa_8021q_xmit); -struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, - int vbid) +static struct net_device * +dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, int vbid) { struct dsa_port *cpu_dp = conduit->dsa_ptr; struct dsa_switch_tree *dst = cpu_dp->dst; @@ -495,7 +495,20 @@ struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, return NULL; } -EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_port_by_vbid); + +struct net_device *dsa_tag_8021q_find_user(struct net_device *conduit, + int source_port, int switch_id, + int vid, int vbid) +{ + /* Always prefer precise source port information, if available */ + if (source_port != -1 && switch_id != -1) + return dsa_conduit_find_user(conduit, switch_id, source_port); + else if (vbid >= 1) + return dsa_tag_8021q_find_port_by_vbid(conduit, vbid); + + return dsa_find_designated_bridge_port_by_vid(conduit, vid); +} +EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_user); /** * dsa_8021q_rcv - Decode source information from tag_8021q header diff --git a/net/dsa/tag_8021q.h b/net/dsa/tag_8021q.h index 0c6671d7c1c2..27b8906f99ec 100644 --- a/net/dsa/tag_8021q.h +++ b/net/dsa/tag_8021q.h @@ -16,8 +16,9 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, int *vbid, int *vid); -struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, - int vbid); +struct net_device *dsa_tag_8021q_find_user(struct net_device *conduit, + int source_port, int switch_id, + int vid, int vbid); int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds, struct dsa_notifier_tag_8021q_vlan_info *info); diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 35a6346549f2..3e902af7eea6 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -509,12 +509,8 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, */ return NULL; - if (source_port != -1 && switch_id != -1) - skb->dev = dsa_conduit_find_user(netdev, switch_id, source_port); - else if (vbid >= 1) - skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); - else - skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); + skb->dev = dsa_tag_8021q_find_user(netdev, source_port, switch_id, + vid, vbid); if (!skb->dev) { netdev_warn(netdev, "Couldn't decode source port\n"); return NULL; @@ -652,12 +648,9 @@ static struct sk_buff *sja1110_rcv(struct sk_buff *skb, if (likely(sja1105_skb_has_tag_8021q(skb))) dsa_8021q_rcv(skb, &source_port, &switch_id, &vbid, &vid); - if (source_port != -1 && switch_id != -1) - skb->dev = dsa_conduit_find_user(netdev, switch_id, source_port); - else if (vbid >= 1) - skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); - else - skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); + skb->dev = dsa_tag_8021q_find_user(netdev, source_port, switch_id, + vid, vbid); + if (!skb->dev) { netdev_warn(netdev, "Couldn't decode source port\n"); return NULL; From patchwork Tue Feb 13 22:03:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp837785dyb; Tue, 13 Feb 2024 14:15:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUnKcEiO5kUECQINuA4W3r0qiFIow4iBtkHzaz7wVedVBMrjejogj47FSN5HvF6upTxiUnR/ALbTf/rFq3uowBV1LCbFQ== X-Google-Smtp-Source: AGHT+IGRiUVwyxYjdosdmA/xQuh0iSgieAJoIZPoKhJgAdYNSXnX02Zto83TmFvx9pZF4PPNsMOU X-Received: by 2002:a05:6a00:4194:b0:6e1:1c:1125 with SMTP id ca20-20020a056a00419400b006e1001c1125mr792035pfb.14.1707862517311; Tue, 13 Feb 2024 14:15:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862517; cv=pass; d=google.com; s=arc-20160816; b=bGzamgNQwrZQ7sHuel3c1NAqYHxuWw3PF23TvuZYwLPMevLRcABxHqq9Nesp6HasoT hcspa4EdkopIq6dKzBzitTx5XPlL00rCp8fy2N3wRK4M/hkDV6BK7Lpc7ySYi9lC7a+p n3BEt3tPQ2eWxnoTyO4YPAsNCeSl+j31L1cMnxrHcT9VDBcGmQgiDFYvT3to2YZYK1NC 52kGnplCjk7eiOLvboteyrC4g+E/JabOEQpqzSCiUs7S5y8VhFz3Q0Xa4LIvgAOjT1XS 9jJWQm2KpM5Yqzdtb2QOnY7rxrhiDtYJWd10eHwScrRwlZ37KttE4X9ZAWqBUNOx40yi Usww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5zhwy6nnxrLoJfssOqtXSEBpoc3WQJYfaNJ+nAZBweg=; fh=e9zkpaHWgRC2kzHmgsR8S8Skse6HCS0OphfOYm7nKbk=; b=h4p1nt2lqgjsFQTOhyA7WAcrLs2/RHnQKufcFXZ1epXv8SQ7Uv8l3oLa1kBkOF74yb koUThe8k7I/QKDWLhhky/kZX9Bkie1M2o5Hz6h2SsWniut9csurhssMDF04D1UCIGcXe qIKUtFtxdq5/FiEjZX3Q7IncoDl9hL1MhfyuxiRdsn7TCl/oEahzqnd4O+Jil+zysimA 0DCtRTr3l17cuGBAnMQBkYWU+F8gTYc4XAsCKx918oUlj6EjKl/B4qyMT/vDRQUXOKqe 40MJglJG1hyj9uqQbyd6FkwoLkpcop91PUX9OmlMNK9e+DIw4ganmeZBnba/2Wo0rnAZ gong==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PB6Cvi0J; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64434-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64434-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCUJ8Lj8uzZWW8gUIWi2aQEc8woeG3dYBkeABMpMNseBoZenB/vBvdCrt9s8Ck7cdYjpdoWM+MMMqMP7ZgYOENlwqbnTzA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w71-20020a63824a000000b005dc4ec48cbesi2499799pgd.827.2024.02.13.14.15.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:15:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64434-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PB6Cvi0J; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64434-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64434-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 23E0E283B79 for ; Tue, 13 Feb 2024 22:13:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E381077643; Tue, 13 Feb 2024 22:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PB6Cvi0J" Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 00E30768FB; Tue, 13 Feb 2024 22:06:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861975; cv=none; b=Dcieq+NpNxDezJK+Y71anhgt+bqTBE9reRlTKS0kO2z12e6I0+MiPduiP44jPM1aZOoI1lpTPjdL39fb3MouyGe3V9pXl1r0mPxky/ukba869O4Vsx+glvtnLN29t0m8HtlEueuKMEIIQ9MehqC7m6QSNd6NkeT1lIsvvaco/Z0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861975; c=relaxed/simple; bh=BcCICgTKVZ2L1mhpJOxhdMkT8Ko96qUkVtelruR9JTo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C7Aa73XuvKvV1HCUzl49ix5sxlC+tTeyvdu3j1BOPAXXncJBCPjjN/SF0D5cedfyEVABwsnsqvZax/WInY6fGq0a3vinTIZ5hyr+QZMPoFXk/ruBSMw5VtkgXaIVMu1tp5nbrNS6yTDBOmgepMfXmFv8e9Y+SjpOMSGUx+1L2LI= 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=PB6Cvi0J; arc=none smtp.client-ip=209.85.218.51 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 Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a3c1a6c10bbso421985766b.3; Tue, 13 Feb 2024 14:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861972; x=1708466772; 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=5zhwy6nnxrLoJfssOqtXSEBpoc3WQJYfaNJ+nAZBweg=; b=PB6Cvi0JvhJWsEei7cgZ9eN0Oxjed+vO9xs0VWJ2gZVwtH/IJ8VdUHkz8wDR3pnL+K eQ0mP9T7LZ7Xq0/5a7YdmDOU839rSXnG8vSNLB1m0VKKCvzdXC82KsanF0DakZ95BnSF KDXulcX40xr8bKSyHz2Jm1NeOhFzyC7UcbfVBisi8VMoi/V+HKpcAd6MeIeFzj3DweCN fABT5RJAgCK5j2aQBA2V4q3h2oZljJc49vzcU+DEttzlunPEb0zgt0AdUMh7WFeM/P6F 0a0O9Vi8yXmPanHIATh9BFRgPsn+XYwGVOwpaMCp9PraAs+SUHpMZPE5KpjQL8Wt7AmL wRHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861972; x=1708466772; 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=5zhwy6nnxrLoJfssOqtXSEBpoc3WQJYfaNJ+nAZBweg=; b=qpYb2G/R4l8rk1kb5fiQ67Ty5qIAHE/t9aw2yD9FhHg/FY2EFpQnt+i+pwKkfV8bLX ivMWg3JdLTuvmIBoDk7CoQ6zsIMCrUHZcxRFh8Wv2Rr5Sl21jPNRPchcZA/5NDfpm8co mZdSwSYquXhUDP4m/rOdojNtKvqc6f+RNXeEfoJKbHhSvMkqjJPaMxejTcxj1okW5SSN pq59jNZv/dMVwsu0ls3jrRpas7BfBBtUFMe+/qfhl6tBpCv1c2S8jQ4Z719/TKBikTok I+orp75IOgtLZh87v+D/TxZlOp+3AhR5CJD2rz84J3X84U2VdzRk78IJ4GVGItOyFfmI iJ7Q== X-Forwarded-Encrypted: i=1; AJvYcCVWasYGg17bnwB3Ik5uvffAtcZYYcIogwBBM98Pniczgno4E4/znlcMkOctxa16ZsKjlhSDXWK+YOG1nvmK6/SkN6EafGZB+pF3JCNB X-Gm-Message-State: AOJu0YyRGSE/l7vL+++WRQSo3JZ3e7DA7x2mHIsoojWrGcKsDWkBZdwk 5dWzOA7Q5qwb1SgpVAxCUMnZN13TMSCSGmNtuYSMgZVrkT45SQxClsRpm2q8RAU= X-Received: by 2002:a17:906:5589:b0:a3c:10a4:7a91 with SMTP id y9-20020a170906558900b00a3c10a47a91mr547728ejp.13.1707861971934; Tue, 13 Feb 2024 14:06:11 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVKRiR8sP59UO8EWHPP+/EBMRqEq6NFe3XE/hZAAghvCLSYCCtyN4lqBrrbOtkf50wGPZ4pO88D4vkD4NlLiYIZ0svDcMpWIZ7t5OtdiSV6p7X3lTWFMdLejjjme3+ux2XS/nB2M7wttJCUP387Wc77foUp5+cNyrcMAgSogTfuOq9ga44O0xGQvImvbE7t5VqJDhgUGgYeBKjKhDxUIuajWWcbFZvCBFRlyW41R/gxcuimFKgESZFwBM5dkkrm2Mm3iuXjPtXuWC4ADjXOW5pLnWf/xaIecwPlmwhp8ip2LmRo/RX87Kb/P68kcAUYfeXhXDxDH2Z2Te6ewPhmQKv6kYpQ5whrFtusL+6qYYdy6TOpGzUi2cOaTcvXnu5CLxVWiPJOAVlT7WwDDzNo5FjRzSgRZdQuOYT8aOc8DG2a/y2MIY7cMyRgXyj12Pzu0TFIsi6TW2qcZw== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:06:11 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 12/15] net: dsa: vsc73xx: introduce tag 8021q for vsc73xx Date: Tue, 13 Feb 2024 23:03:25 +0100 Message-Id: <20240213220331.239031-13-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790823647262730355 X-GMAIL-MSGID: 1790823647262730355 This commit introduces a new tagger based on 802.1q tagging. It's designed for the vsc73xx driver. The VSC73xx family doesn't have any tag support for the RGMII port, but it could be based on VLANs. Signed-off-by: Pawel Dembicki --- v4: - rebase to net-next/main v3: - Introduce a patch after the tagging patch split include/net/dsa.h | 2 ++ net/dsa/Kconfig | 6 ++++ net/dsa/Makefile | 1 + net/dsa/tag_vsc73xx_8021q.c | 69 +++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 net/dsa/tag_vsc73xx_8021q.c diff --git a/include/net/dsa.h b/include/net/dsa.h index 7c0da9effe4e..b79e136e4c41 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -56,6 +56,7 @@ struct phylink_link_state; #define DSA_TAG_PROTO_RTL8_4T_VALUE 25 #define DSA_TAG_PROTO_RZN1_A5PSW_VALUE 26 #define DSA_TAG_PROTO_LAN937X_VALUE 27 +#define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE 28 enum dsa_tag_protocol { DSA_TAG_PROTO_NONE = DSA_TAG_PROTO_NONE_VALUE, @@ -86,6 +87,7 @@ enum dsa_tag_protocol { DSA_TAG_PROTO_RTL8_4T = DSA_TAG_PROTO_RTL8_4T_VALUE, DSA_TAG_PROTO_RZN1_A5PSW = DSA_TAG_PROTO_RZN1_A5PSW_VALUE, DSA_TAG_PROTO_LAN937X = DSA_TAG_PROTO_LAN937X_VALUE, + DSA_TAG_PROTO_VSC73XX_8021Q = DSA_TAG_PROTO_VSC73XX_8021Q_VALUE, }; struct dsa_switch; diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig index 8e698bea99a3..e59360071c67 100644 --- a/net/dsa/Kconfig +++ b/net/dsa/Kconfig @@ -166,6 +166,12 @@ config NET_DSA_TAG_TRAILER Say Y or M if you want to enable support for tagging frames at with a trailed. e.g. Marvell 88E6060. +config NET_DSA_TAG_VSC73XX_8021Q + tristate "Tag driver for Microchip/Vitesse VSC73xx family of switches, using VLAN" + help + Say Y or M if you want to enable support for tagging frames with a + custom VLAN-based header. + config NET_DSA_TAG_XRS700X tristate "Tag driver for XRS700x switches" help diff --git a/net/dsa/Makefile b/net/dsa/Makefile index 8a1894a42552..555c07cfeb71 100644 --- a/net/dsa/Makefile +++ b/net/dsa/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_NET_DSA_TAG_RTL8_4) += tag_rtl8_4.o obj-$(CONFIG_NET_DSA_TAG_RZN1_A5PSW) += tag_rzn1_a5psw.o obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o +obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o # for tracing framework to find trace.h diff --git a/net/dsa/tag_vsc73xx_8021q.c b/net/dsa/tag_vsc73xx_8021q.c new file mode 100644 index 000000000000..0bf150a10576 --- /dev/null +++ b/net/dsa/tag_vsc73xx_8021q.c @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* Copyright (C) 2023 Pawel Dembicki + */ +#include + +#include "tag.h" +#include "tag_8021q.h" + +#define VSC73XX_8021Q_NAME "vsc73xx-8021q" + +static struct sk_buff *vsc73xx_xmit(struct sk_buff *skb, struct net_device *netdev) +{ + struct dsa_port *dp = dsa_user_to_port(netdev); + u16 queue_mapping = skb_get_queue_mapping(skb); + u16 tx_vid = dsa_tag_8021q_standalone_vid(dp); + u8 pcp; + + if (skb->offload_fwd_mark) { + unsigned int bridge_num = dsa_port_bridge_num_get(dp); + struct net_device *br = dsa_port_bridge_dev_get(dp); + + if (br_vlan_enabled(br)) + return skb; + + tx_vid = dsa_tag_8021q_bridge_vid(bridge_num); + } + + pcp = netdev_txq_to_tc(netdev, queue_mapping); + + return dsa_8021q_xmit(skb, netdev, ETH_P_8021Q, + ((pcp << VLAN_PRIO_SHIFT) | tx_vid)); +} + +static struct sk_buff *vsc73xx_rcv(struct sk_buff *skb, struct net_device *netdev) +{ + int src_port = -1, switch_id = -1, vbid = -1, vid = -1; + + if (skb_vlan_tag_present(skb)) { + /* Normal traffic path. */ + dsa_8021q_rcv(skb, &src_port, &switch_id, &vbid, &vid); + } else { + netdev_warn(netdev, "Couldn't decode source port\n"); + return NULL; + } + + skb->dev = dsa_tag_8021q_find_user(netdev, src_port, switch_id, vid, vbid); + if (!skb->dev) { + netdev_warn(netdev, "Couldn't decode source port\n"); + return NULL; + } + + dsa_default_offload_fwd_mark(skb); + + return skb; +} + +static const struct dsa_device_ops vsc73xx_8021q_netdev_ops = { + .name = VSC73XX_8021Q_NAME, + .proto = DSA_TAG_PROTO_VSC73XX_8021Q, + .xmit = vsc73xx_xmit, + .rcv = vsc73xx_rcv, + .needed_headroom = VLAN_HLEN, + .promisc_on_conduit = true, +}; + +MODULE_LICENSE("GPL"); +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_VSC73XX_8021Q, VSC73XX_8021Q_NAME); + +module_dsa_tag_driver(vsc73xx_8021q_netdev_ops); From patchwork Tue Feb 13 22:03:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp837856dyb; Tue, 13 Feb 2024 14:15:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWiugz+KgmVNsZ92qJB273Tqc1aM33i4K/MySO5P9X38Dkoc6EzVT2maHjeM/BqNdbQhOEhIlNc0BaIhdCn6hlN0ONH2Q== X-Google-Smtp-Source: AGHT+IHtjamzAy3AYHfMmZRfacm0HSol+wDPftwYZ6143VcX66pzYJ9ezvmQN73VKQyelPf4Yk7o X-Received: by 2002:a05:6a20:d04b:b0:19e:c32f:35fc with SMTP id hv11-20020a056a20d04b00b0019ec32f35fcmr1107753pzb.38.1707862525488; Tue, 13 Feb 2024 14:15:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862525; cv=pass; d=google.com; s=arc-20160816; b=nCAcKVlEeiOwvMqv9JowS6dSsHXglwomH4DfAoeG4RKuFtcstiwnbLRbRQiz2bRIyK Y2lnRZrWl+0zIfG6GDLvcJAWud+jgxSmTX4FliWVDISo7clUzAKR/F9LGVyRFimKzHBP eL0Iyp+ldmJiyDdIZYu28cPpQw003IDV8TWM2c+igyLAnHk8sNeHtNLftknJu9scKaKc e170/NyOGxlfzcFhjzYtsVxO41J9/OuykOkoBB7DPKo7knsF2o8h/Xn3Do6LHzUVfLrN qJwi/Z0eqSiMJvC4Ar4PKFZ3Nl+3MIkfrxhi2bUu5FvjTIK15xY51nhar1bAUdDTEN8l JMrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mfZ9Os2zb9RyFiipFThksRCzRqGevVK9igii64D1Y2Q=; fh=hn8WcgODslaYwzofAAW+oINuKmcf+iZuEZnPFaKTxS4=; b=mbmHfO0uGGOqxb4yZMqEXA2Kkv608ZgE+t3QXdUJ6gLDEvpahBD0kiH98YmMMZud27 1nrQ6gr3V1Wp0kMEdyGrYV/iz5FcXuh6ir+BrW2XX6BOHPyHgsGkf43zcPa56ftAnI02 DeS1FFV0aMNuMxJ06FLwv7JbScSfX57DLjWeWnrgsSeRto7mmGtirGRCVlM5MMgyBi1k nS0Lbef7+dhtf9TVxgKRIeAuz2n+95Ib2mnzoXk/JEqcfA2JyNtriqCqL1l4UlXVCiuF C7Sm+4QJ8QAzVUFzT1/Bq1TTzBvoHnQw38jCJ54U0KJkdbTs0IBareVEFmMfHyiYckuA NSvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FO30Vd2S; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64435-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64435-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCX0Iv0ecBBTNAJQlifnVfRldTNAaMcnmRrNCHGQMTkGRS0+U5iKNZ425Vu35TVJvfjVyZD6gMpoEMgefHR4pqrkbzQfqA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l26-20020a63ba5a000000b005dc491389a5si2692987pgu.812.2024.02.13.14.15.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:15:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64435-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FO30Vd2S; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64435-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64435-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 17DDE28451D for ; Tue, 13 Feb 2024 22:13:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3544A77A0C; Tue, 13 Feb 2024 22:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FO30Vd2S" Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 5C5C67764A; Tue, 13 Feb 2024 22:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861981; cv=none; b=S5Na0rNvXwKqUyClSPsE2kwDPjk5eL66B6lJfT3+L+dsaVHjM7Q0Y1L2xaVnwed8wtZypwahuSCnGUo1cOVgs7zsP8yF/P847AjBfOFx1jZMoR4Rx7Kniy9vlGfZjMVVQX89vAjd1ZVyC83f/pEeSYcf81tCYj39NY66HIi8Qco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861981; c=relaxed/simple; bh=t5Q6M/UoaVsi7X00J7NumI0UnmtqZT+dvCNVTiQagf4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CUSPxvRt5HGTN2Twvlz5wHwnLJcdeNdm32h5/4gpSx7CA1FeZXyHgGI2WMC/rgIv8sYsr+P+ER2n/OBRisHYU7w/XW7vrt+8OnolbLtlGV5OZaT2JviCfvVOCW+PaCXVJTEOsbU7bWB6/YaaS5ypr95ag/k19fo/WQ8pBVZ0D64= 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=FO30Vd2S; arc=none smtp.client-ip=209.85.208.53 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 Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-55f50cf2021so6431449a12.1; Tue, 13 Feb 2024 14:06:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861977; x=1708466777; 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=mfZ9Os2zb9RyFiipFThksRCzRqGevVK9igii64D1Y2Q=; b=FO30Vd2S+BfeIPNTWA9vGw/ywpZ39RQp9M15jUADxrUDEmuNYfkftHhzfv6/4nxEyo 0GyYi1CNWx95GDG56yMqjxbM+IeAkSOp55J7rKYz6QTze8wV+7y46SjEJvq+pMhwcJzw +zJuM5bZNe+sKzcm5nKrj4bqYWZWJBVAC898XwG27EhtPzOHZrs83KK/p74gVCyf0E/p z9InfZL/5BJfJNZRrxYIHQrdaCKEaDmLn+VdBwjJrXUa/38ZZXi6uBdHnNyggU8hXYcZ 71FcHHBK4nBtteBuZjHYfJ9KffAckMaNANywD/tFxAMZqg9O5jBmjcdgfbPL87BmAzI6 2IUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861977; x=1708466777; 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=mfZ9Os2zb9RyFiipFThksRCzRqGevVK9igii64D1Y2Q=; b=jyTpvhzg0J3sfjFojM1ZFGm1PHV2i8yOc7JcZjgGvo/3dl2uj+nyhNPaDZSDosn0sm f4660EHVWHON//82tFbPeEMMmFncLSNNHEdERkLAvWByYNDC8evM5VWu3fW9M1ALnDhP 1Jr6K+agE0GPvrUesqzNs0+MfkI6NhdsQWNqsxl5IoiILLwdSnr+CBsX/20KHMF+0Mfs PJi3PXWX9CV2S36lAVOV8orSUvR55K1NO64OFd+3lsG7XZUt3eTI0ER9mQX+1RanZ9QT SqifqyGx9ULUDKEtYiM+k2dOqIG1ICXFiGqoIU4iCncyGN/r8UuC90rh1vDJRFOq/T2d mhhw== X-Forwarded-Encrypted: i=1; AJvYcCWJ+vHVKPY7mvqdTmoyiYh7Ht909JkBmtE86JJTJamt2VJ0ckD5QQO81xOwRa1Jg2StK8JRySdE6D7lsb9CEW8biqtvtPz5MnnqhKO5 X-Gm-Message-State: AOJu0YwjV6r7QAmfSkKu+X/0fy6/2jzm6qGlybsNG5/xhCFDegwVDLlW tLNzDVfd8h3MbHXub+DHER7IYOONJNu4SWSPpcxoPUJa9NMrCIkd2x34hu2YCb8= X-Received: by 2002:a17:906:7199:b0:a3c:f91d:ee10 with SMTP id h25-20020a170906719900b00a3cf91dee10mr425752ejk.5.1707861977153; Tue, 13 Feb 2024 14:06:17 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX6RqQz2uCAeYoCezfNB55B61g9qnT055Q+w6LgTYjMLmCHJDRKeqaCjh8Wks6guhNtKuKKKpwUQmp5MtFI2aV+RH8B3c4maA+Jtlu2lYtRIfsxXIjO36WXNTx1/p4a1CGo6IhOJAkCP12sKGD0SeX0AvGWwHnfzm/4yZU9SfLSXNOsDFuFO7JikvTQfIZwETRN1rF7OqK5x1ej3ZZKe4X2/ctbXMIPob8mB/O+jT7JyLwURQoLDt3KSNtJZ6eEiDYyYNuIObM8VOuoQkXGuJMLnKh3XCwKXYq7QRyzRG6MtGXIw3GIBCP0VA6tdZCvxGh7JHgx/ms9Uc/qNP3sZE64R0v9M+CywwE3Gxw8iLNKrWDsz+LJGN5tp9GMdgQPRwkeBz5rK6BHqUnvYRcwawr6x4MaOz9wfeM9vAW5NSzAXxPWdHHcniXtk/TYFX9cEBzoQOf/dksHiA== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:06:16 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 13/15] net: dsa: vsc73xx: Implement vsc73xx 8021q tagger Date: Tue, 13 Feb 2024 23:03:26 +0100 Message-Id: <20240213220331.239031-14-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790823655503545325 X-GMAIL-MSGID: 1790823655503545325 This patch is a simple implementation of 802.1q tagging in the vsc73xx driver. Currently, devices with DSA_TAG_PROTO_NONE are not functional. The VSC73XX family doesn't provide any tag support for external Ethernet ports. The only option available is VLAN-based tagging, which requires constant hardware VLAN filtering. While the VSC73XX family supports provider bridging, it only supports QinQ without full implementation of 802.1AD. This means it only allows the doubled 0x8100 TPID. In the simple port mode, QinQ is enabled to preserve forwarding of VLAN-tagged frames. The tag driver introduces the most basic functionality required for proper tagging support. Signed-off-by: Pawel Dembicki --- v4: - adjust tag8021q implementation for changed untagged vlan storage - minor fixes v3: - Split tagger and tag implementation into separate commits drivers/net/dsa/Kconfig | 2 +- drivers/net/dsa/vitesse-vsc73xx-core.c | 38 ++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/Kconfig b/drivers/net/dsa/Kconfig index 3092b391031a..22a04636d09e 100644 --- a/drivers/net/dsa/Kconfig +++ b/drivers/net/dsa/Kconfig @@ -126,7 +126,7 @@ config NET_DSA_SMSC_LAN9303_MDIO config NET_DSA_VITESSE_VSC73XX tristate - select NET_DSA_TAG_NONE + select NET_DSA_TAG_VSC73XX_8021Q select FIXED_PHY select VITESSE_PHY select GPIOLIB diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index 6c7bd1c200b4..9f94ae8c763a 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 @@ -588,7 +589,7 @@ static enum dsa_tag_protocol vsc73xx_get_tag_protocol(struct dsa_switch *ds, * cannot access the tag. (See "Internal frame header" section * 3.9.1 in the manual.) */ - return DSA_TAG_PROTO_NONE; + return DSA_TAG_PROTO_VSC73XX_8021Q; } static int vsc73xx_wait_for_vlan_table_cmd(struct vsc73xx *vsc) @@ -670,7 +671,7 @@ vsc73xx_update_vlan_table(struct vsc73xx *vsc, int port, u16 vid, bool set) static int vsc73xx_setup(struct dsa_switch *ds) { struct vsc73xx *vsc = ds->priv; - int i; + int i, ret; dev_info(vsc->dev, "set up the switch\n"); @@ -739,6 +740,12 @@ static int vsc73xx_setup(struct dsa_switch *ds) mdelay(50); + rtnl_lock(); + ret = dsa_tag_8021q_register(ds, htons(ETH_P_8021Q)); + rtnl_unlock(); + if (ret) + return ret; + /* Release reset from the internal PHYs */ vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GLORESET, VSC73XX_GLORESET_PHY_RESET); @@ -1504,6 +1511,31 @@ static int vsc73xx_port_vlan_del(struct dsa_switch *ds, int port, return 0; } +static int vsc73xx_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, + u16 flags) +{ + bool untagged = flags & BRIDGE_VLAN_INFO_UNTAGGED; + bool pvid = flags & BRIDGE_VLAN_INFO_PVID; + struct vsc73xx *vsc = ds->priv; + bool operate_on_storage; + + operate_on_storage = !vsc73xx_tag_8021q_active(dsa_to_port(ds, port)); + + if (untagged) + vsc73xx_vlan_change_untagged(vsc, port, vid, true, operate_on_storage); + if (pvid) + vsc73xx_vlan_change_pvid(vsc, port, vid, true, operate_on_storage); + + return vsc73xx_update_vlan_table(vsc, port, vid, true); +} + +static int vsc73xx_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) +{ + struct vsc73xx *vsc = ds->priv; + + return vsc73xx_update_vlan_table(vsc, port, vid, false); +} + static int vsc73xx_port_setup(struct dsa_switch *ds, int port) { struct vsc73xx *vsc = ds->priv; @@ -1632,6 +1664,8 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .port_vlan_add = vsc73xx_port_vlan_add, .port_vlan_del = vsc73xx_port_vlan_del, .phylink_get_caps = vsc73xx_phylink_get_caps, + .tag_8021q_vlan_add = vsc73xx_tag_8021q_vlan_add, + .tag_8021q_vlan_del = vsc73xx_tag_8021q_vlan_del, }; static int vsc73xx_gpio_get(struct gpio_chip *chip, unsigned int offset) From patchwork Tue Feb 13 22:03:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 200695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp837227dyb; Tue, 13 Feb 2024 14:13:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXiI+LgzgvCnW0i5O2xjSk1KeWQnnMg5S0VQIxjH0l38AEVnU3LHb8MlN2/zssLICf3g+OWqwkZlHDDwhHc7jdhJKBo5A== X-Google-Smtp-Source: AGHT+IH1PiD49/SvuHbIBNXpctYyuUNcExVVE8YpcMDGkrz3MBlocOdtffWNmaHu/zcubtx/2g0o X-Received: by 2002:a05:620a:c18:b0:786:9b73:da23 with SMTP id l24-20020a05620a0c1800b007869b73da23mr963919qki.46.1707862437160; Tue, 13 Feb 2024 14:13:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707862437; cv=pass; d=google.com; s=arc-20160816; b=Uoaldis2oyCWcv11OeIqhclKy7++hb2bzywdhusOtC/VbdIZDPAjHwZYobUIWZCVrp rTWrPyl0Tr2RIr16YbAk8Pyc4OGhn9Ou8dF55srvL3YcVJJnKy+JLzjD7L0qoj+TQdf3 qCFLYFA7j95MAuF8QwZeWnazMmk9fA111NWu0Zi/u+JMHQ2sXpj2F89cbF7rBBTgKfm7 aIgDcO6350GET3wOIomfPRIcWzgX1iGWCH1RKCSg84fTFTJHFcJDzLj4gv+aZGf7PfHD 4Sf4Ms8GCTgqiTvuOZOlCbt9nRjtIDkNWQH+f1ATqR+P7lIc0AtQOdUBz9KKh6moIIRq ahpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5lfZKWMdVX06rkt/a2RPzvoVKkcprfsWZW9EdATKrus=; fh=udF9OvqOUv74WT/P/IrysM82m+WW3MvZ8gem/18VaH4=; b=lkxsRs3gR5qExJbEAbHi5AzjLHtllFTdvahIcg0jF+qjjwXyK+TskiFXTHrrzVskZf Fx3e7uB9d48blJTE8BJkjgCMeZr2bcLHPHRs4YZPxbMNczchuINDWeqjVLpUfQmqDJsW WKztjHpW/ZiwFnFLpb9k/0hkeHVySNL4jDn+wsEs/+xgPgG0GSZWYQ8xE+/JUlq7VGdG QebQQLeiXKCmQWV+i8+64Eh1MyvRT7LrX8arc0/zYiCCLPLXGn1QzTP5OpqMgrT71moy jtvXY5BoRFPphAdjergyJn/Fq5eEIAnxzzgDdKCkSs+VSBSjik0YVLnxO0h/YkGWU3bq bFvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ft7QnrOO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64436-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64436-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCX1aF0cEbbIrfszzBsskNmlsoxtU8Kv/hFKC/oDpWi7Tb7H1t1Lo6p91UFnGnuSuvodFUYsx3opcNZUiFo58g0sLhqp/g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id po30-20020a05620a385e00b00785b189cc93si9218994qkn.353.2024.02.13.14.13.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:13:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64436-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ft7QnrOO; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-64436-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64436-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DFFD71C2209F for ; Tue, 13 Feb 2024 22:13:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 298A864AAA; Tue, 13 Feb 2024 22:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ft7QnrOO" Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 C265A77A08; Tue, 13 Feb 2024 22:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861985; cv=none; b=VtcXVl7BfyR0y1kP3do183A7sA5GXUFzA80IwPkZcEA1cYZ6+rCsJCa84V8efLYW639uXRoZQTDRgjvPc/MciVDFNviixZLTQTD787oM1X+GH7Sew/SWaXbLE5y1XaiH7Bk2emOrE6NKU1QENChObHN5QxazquPFik42LmXhYeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861985; c=relaxed/simple; bh=hPoqurwpt0Nzd4K48f24Meg4YCMaFciuOSzhb8zDw9M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GSdWRA/QsSnyJFONPbAqYCNM+lsPClcJsH9iq0zhqP6xVK28glCMPvFbMgqBza+yhvo4XRswF7XQxSQU02OZyfl2ot4fg/cxHN036Bh8pTf4TO1iA0v5TNArOgsqUUUIomhaCaSpPiymm88OZqRDFxQLTqcIyBybvHYKm4lUHUQ= 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=ft7QnrOO; arc=none smtp.client-ip=209.85.218.41 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 Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a3d39b2c269so14278066b.3; Tue, 13 Feb 2024 14:06:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707861982; x=1708466782; 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=5lfZKWMdVX06rkt/a2RPzvoVKkcprfsWZW9EdATKrus=; b=ft7QnrOOe5JHSaAnVzT1evB3OFB5yfsZepKX/hYRC6p9YF0MntKZX9aQGzhP6IUggK DFRmuzlfHL2rbB1vkD0n5cuD4ZuwqOYoph1sXVY/LxB74SkYiwDD38XVDUk2BmPKJlCx +HF38OKglRghokU9/1b8+8uRLPqV3zMWty1KXiOmWk14Ckut/Ra/gkvT2Z+zWkepqH+v 3m/3ZIEJYtgg7yhAekcRhGBWOuU/zQtzUeC+8tz2VLnpsOonJZ/kXwiRE/bBOa0abGN1 gb/OYoFCwTxTdFpfm3pk59RAYDYOUTSeqAvV95aeM9ZUe8WFu3FRT9N4/ZfkOo+P+Zh6 9Vgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707861982; x=1708466782; 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=5lfZKWMdVX06rkt/a2RPzvoVKkcprfsWZW9EdATKrus=; b=fptdPLAMdjUwTEDauSuf5518CL5jbzsgJzKAMEluYdRhqe4JnTpheV73vckOZFyxRT +W82BpiuPrCknRZ1/npaoQvxGwMHYxMdTT82L8JxqqlqMIBQUo28tXBghS5+89+LTk+W ED7nS+0K3Xtnlyy8hc6t3vVxlV35mBAmswuyRoLo6cr7sSAXx14wfxpKyYkecZM15bKL XJHOiYPfgS6Jn10smboEqZlESG/30BAXKqm+uH66B9wM1YY8PMYGz4Veuil303Bm9czu kYWHInPqslU1PHpQDBF7L9DnSz89+beh2GBI9ICLBKwRmX+7kEo5bPtILnTvabqzod+M W5+A== X-Forwarded-Encrypted: i=1; AJvYcCW5U5PS9aRUoOlv2fMPzMUoguEHah7boxtxPu3airIuLQQV6DyhCiQZEXMupxNQ3TuRYijyzkHOFs86Ttu+OpdQls96rEhizURJeGzS X-Gm-Message-State: AOJu0Yz5GC2xuN/ibWsEyXbKjsAdkVNNFenI/j4BospKJ5sznFP7MGQA lVTFk33IxFo7eR7xgNDXOe6Uj4cFXV13IdG2k9/HCIU6H0ScdsG8kzTf3tNDQAs= X-Received: by 2002:a17:906:f10a:b0:a3c:fc34:d5c7 with SMTP id gv10-20020a170906f10a00b00a3cfc34d5c7mr435072ejb.61.1707861981841; Tue, 13 Feb 2024 14:06:21 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXlF7wPfzwC0FthiObG9mNggVsgoTXaW6orPkdbuVmifEyHR9vHn1/XxFTlRk3S9x1v+rPWep99t3BhAdOJLT3qtCEjLKegPqPeQlJytzkvL2nFaY1C6oJ65cnsP6YJ+shZidDyisFRajnSReRVWkMPw9IzfdjJeSJK0QbJJWaZ3M0wXflSrF3TLrimvcggo/FfraRWS3FCuV4OuRvuRU6pJclAwWKHxi4/mIfhDeUUW/44RsLIJvgF6y2QhAkGs0WBFKQK1Z8+Dl+G0B0LdZ1OT3MUnmFOBRH8sM84PZbJMGmgKxS+cuVH2ZZdgjFOD1X7bi9jocNMZGwqFVtpA9M8Q0IygPTXaUyq1qrucZHWn82432b/v61I6prmM93L/JAf46kvb8iiGf+a/W5hBUUAem1oHjZ76AEZalmnVjaE2HAgnCltP/n+2KHKMJlMD4mJ/1Tbzt6O3A== Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id p12-20020a170906b20c00b00a3bdf8ae86asm1706800ejz.10.2024.02.13.14.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:06:21 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Vladimir Oltean , Andrew Lunn , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , Alexandre Belloni , UNGLinuxDriver@microchip.com, Russell King , linux-kernel@vger.kernel.org Subject: [PATCH net-next v4 14/15] net: dsa: Define max num of bridges in tag8021q implementation Date: Tue, 13 Feb 2024 23:03:27 +0100 Message-Id: <20240213220331.239031-15-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240213220331.239031-1-paweldembicki@gmail.com> References: <20240213220331.239031-1-paweldembicki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790823562920871156 X-GMAIL-MSGID: 1790823562920871156 Max number of bridges in tag8021q implementation is strictly limited by VBID size: 3 bits. But zero is reserved and only 7 values can be used. This patch adds define which describe maximum possible value. Suggested-by: Vladimir Oltean Signed-off-by: Pawel Dembicki Reviewed-by: Florian Fainelli --- v4: - introduce patch drivers/net/dsa/sja1105/sja1105_main.c | 3 +-- include/linux/dsa/8021q.h | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 6646f7fb0f90..6e22d7a6bfa3 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -3156,8 +3156,7 @@ static int sja1105_setup(struct dsa_switch *ds) ds->vlan_filtering_is_global = true; ds->untag_bridge_pvid = true; ds->fdb_isolation = true; - /* tag_8021q has 3 bits for the VBID, and the value 0 is reserved */ - ds->max_num_bridges = 7; + ds->max_num_bridges = DSA_TAG_8021Q_MAX_NUM_BRIDGES; /* Advertise the 8 egress queues */ ds->num_tx_queues = SJA1105_NUM_TC; diff --git a/include/linux/dsa/8021q.h b/include/linux/dsa/8021q.h index f3664ee12170..1dda2a13b832 100644 --- a/include/linux/dsa/8021q.h +++ b/include/linux/dsa/8021q.h @@ -8,6 +8,11 @@ #include #include +/* VBID is limited to three bits only and zero is reserved. + * Only 7 bridges can be enumerated. + */ +#define DSA_TAG_8021Q_MAX_NUM_BRIDGES 7 + int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto); void dsa_tag_8021q_unregister(struct dsa_switch *ds);