From patchwork Fri Feb 23 21:00:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp842081dyb; Fri, 23 Feb 2024 13:02:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVH1gOHNS5J9Z4QW6ZjpUGGqQ9tZVtO2OTT3KCOqg5ZGy/YiPj9XJ1YVpFXngyMO2RBnSneVwGKny/MhrOqBXwcr2sMYQ== X-Google-Smtp-Source: AGHT+IGOKlExwFFLLQMZw+HQj9/ss4xyrukhtsDia9oYmau9UiGZ4G+fDfJz81S1pGNDKIQ42yg+ X-Received: by 2002:a05:6a00:3246:b0:6e2:ed1d:c5c6 with SMTP id bn6-20020a056a00324600b006e2ed1dc5c6mr914923pfb.22.1708722126422; Fri, 23 Feb 2024 13:02:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722126; cv=pass; d=google.com; s=arc-20160816; b=voifS2WiCF3LTPzBo7yywsORq7mVo++pl3w2EfE9BL6IV8aGg4we5FXrGxpe2ObG6/ wZEa2Pk7cZIeXs4w7EShlvR6gBk027dlhNa3ub3eABO86OoQqwsHhxgL2qoNgpL2Ii4+ /lOU2jJ3DSD1ogtdtiZBnBwvujRl7mjFyWWTcbpUxvtzkE9A1xhX+oFOPMm3BsyhZKGp i4WzVntaSktmvyyT8APoT59WkArojYeVCdSqXQ7CBj24L2BjHbnVkUWgeQqBQHhxY0qx WJVH6tpI05cvZHigS4VIh22uFxV3nC5wf6UtfnhbohkpmdiN5YluK4iuH8iI9AneWsUY RFyA== 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=QouBmNwC5Mz1DDSViLi9LfWxt2YyADxYyZ8tYZSUz6c=; fh=a9brY79PUn4bZZJGAsgs1QQcjuaBEI275K22lkeNfFY=; b=P76iU1O1S5zYQ6PF3dliZmyy5R2Jb3QSKZbSPTm85iLXw4YblT7ht8oqBzLZEKvEfC 5aE5nIQNhjE/HOCf58VMVPHaBIFUcm+ofjxZHqKA2J0Yqdff6S7cTI5V7r0H3Ch473c4 67a8Lc4kL951HsCALCpnVHo7xn/gBEmBoMrggOKC4FMJHaK2UiGDHvSTH1/YEDcsZFQ5 aBvehVdWcWa9wQhk2XVdvdNaNdwExa9Lc/Ij3wV1wX+Q3LhDdbhz6X4D9cI7XDWVkd+I WYPQpYXuE5uWgFmYMVKN5kfPvBzYtfJ5U+UQ9a3QzgozV5O1dg/7QjCA2dpoyukfu3kj OaJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=LZkQfmV9; 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-79160-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79160-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w127-20020a636285000000b005dc4baf54desi12787620pgb.769.2024.02.23.13.02.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79160-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=LZkQfmV9; 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-79160-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79160-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 32978283FDA for ; Fri, 23 Feb 2024 21:02:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B02114939C; Fri, 23 Feb 2024 21:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LZkQfmV9" 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 8372E14532B; Fri, 23 Feb 2024 21:01:44 +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=1708722106; cv=none; b=gR8oVuJ/AgiDfjPI+1wFUlT2oV5clhsQJ560hdm6il2/lJIkRUm8a6tGXf7jGC7Ccs8/oXepHeDrHwIAKil93AhM9d4u1GKIX2kfUl3mhF0MCR4Ro5LLL0qRP01s5FGQFd6VRAzoXsoXHJ1eP+uFUKGvqyY5zvhHKnJlk9OrdXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722106; c=relaxed/simple; bh=9fsXlW8k/82RP59Hyg0tIsH191jUNaBCZk2e6c+plbE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PX8LtAUZn6gYgbcOF0ryYnW1LRuqL4ulkQ1g7MD2WWivqmTaeibriv+ED3RW8E+x6N+1HTViYLaFYEWXCKykinzTa7DsMMXE4PhR6jpvUDJzts23Dn6tAMnUSAIraA3SleKCBVfSrH5aUrfGDInX+uvgQFLhbzHAeCWn7L5qBk4= 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=LZkQfmV9; 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-564d9b0e96dso1033848a12.2; Fri, 23 Feb 2024 13:01:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722102; x=1709326902; 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=QouBmNwC5Mz1DDSViLi9LfWxt2YyADxYyZ8tYZSUz6c=; b=LZkQfmV9jkh4J2cPZVvJLYkwY5hwpptqTF3SFuVaCbyvEFxy1rAEottee777Xgl7Wn s8AzwKc3y0d5wVUh8XBW/R8N3by6xFfzO2Md5pTschuTKITSAQ5zBlRjn774fIaVkzTl kRlnVYYnl0w9vI69ZZ+AX1GQ0+vKh5rtN6YUVKKDDCixiorQRE77W3gsPn1y2iHz5/jK oAfYDyM8nrmFKKCiQdk2KaMS++OLsUzMiLo0mBEr5JWqUiueedYIrTT7aTpU2X2W7Z3+ KYsB9x/fVDoefu4Fnb70qyZ0BbY2ocRgFjhAb017l72RonQ/N19t0FG6b+V445kyLauL 2g+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722102; x=1709326902; 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=QouBmNwC5Mz1DDSViLi9LfWxt2YyADxYyZ8tYZSUz6c=; b=FSVVeuc5vk3+ARBTqVmHz5ZimWTxk//jOk4lZAMcgijjbaoS3enVDoxLRqIL2/TOB/ kW/aKx2PaRdiPmZIu8YfYn8U6srlA/aeKimgJg+dcKzn7QPaMwPi4DDr0ziCbC7RyEwi HGuGxxkw2jP5KnRChYGoHBjKiUQnl4cCWT8f/O6w1WvJhnBdxuTcgN/Gg75F+S7AYIyo 43H5dJg0ynvgFhTznok1CARjiq2JNrgQKkCA1TT0K/64hnJqvwGw2BLw1cQyAE/TsvUr QRVrwcb8apEZu24wYfheU+rD16tsUkmhOMItzTrZlPr7N4KQGLbqX8+n3gTHTPU+ULVE dwgA== X-Forwarded-Encrypted: i=1; AJvYcCVHl8xljZCDROysb9ST7Tl8ZF0Nr9U+72XuiJpJ1njnHcNX3PsnlhcZUyk2OBfIZp5mBbN2JC/T6y8s5yHjzYtMy/JGmtPCI/YER12u X-Gm-Message-State: AOJu0YwWJEmQpjgBmpuIpIDnKeU/cQOOd3xknuPIzMNGUYdvW0w7UY1P iOqNjDArbAD4YFZezAMoVi6DxG4z6w67U/W1dntnTRnLxVoGnjhqjtx4IRuv3ZQ= X-Received: by 2002:a17:906:7c55:b0:a3e:6501:339d with SMTP id g21-20020a1709067c5500b00a3e6501339dmr666452ejp.61.1708722102190; Fri, 23 Feb 2024 13:01:42 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:01:41 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Russell King , Andrew Lunn , Florian Fainelli , 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 v5 01/16] net: dsa: vsc73xx: use read_poll_timeout instead delay loop Date: Fri, 23 Feb 2024 22:00:31 +0100 Message-Id: <20240223210049.3197486-2-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725012417119179 X-GMAIL-MSGID: 1791725012417119179 Switch the delay loop during the Arbiter empty check from vsc73xx_adjust_link() to use read_poll_timeout(). Functionally, one msleep() call is eliminated at the end of the loop in the timeout case. As Russell King suggested: "This [change] avoids the issue that on the last iteration, the code reads the register, tests it, finds the condition that's being waiting for is false, _then_ waits and end up printing the error message - that last wait is rather useless, and as the arbiter state isn't checked after waiting, it could be that we had success during the last wait." Suggested-by: Russell King Reviewed-by: Andrew Lunn Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Signed-off-by: Pawel Dembicki --- v5: - improved commit description - added two defines instead magic numbers - added include with iopoll.h v4: - resend patch v3: - added "Reviewed-by" to commit message only v2: - introduced patch drivers/net/dsa/vitesse-vsc73xx-core.c | 30 ++++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index ae70eac3be28..ab5771d4d828 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -268,6 +269,9 @@ #define IS_7398(a) ((a)->chipid == VSC73XX_CHIPID_ID_7398) #define IS_739X(a) (IS_7395(a) || IS_7398(a)) +#define VSC73XX_POLL_SLEEP_US 1000 +#define VSC73XX_POLL_TIMEOUT_US 10000 + struct vsc73xx_counter { u8 counter; const char *name; @@ -779,7 +783,7 @@ static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, * after a PHY or the CPU port comes up or down. */ if (!phydev->link) { - int maxloop = 10; + int ret, err; dev_dbg(vsc->dev, "port %d: went down\n", port); @@ -794,19 +798,17 @@ static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, VSC73XX_ARBDISC, BIT(port), BIT(port)); /* Wait until queue is empty */ - vsc73xx_read(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBEMPTY, &val); - while (!(val & BIT(port))) { - msleep(1); - vsc73xx_read(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBEMPTY, &val); - if (--maxloop == 0) { - dev_err(vsc->dev, - "timeout waiting for block arbiter\n"); - /* Continue anyway */ - break; - } - } + ret = read_poll_timeout(vsc73xx_read, err, + err < 0 || (val & BIT(port)), + VSC73XX_POLL_SLEEP_US, + VSC73XX_POLL_TIMEOUT_US, false, + vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_ARBEMPTY, &val); + if (ret) + dev_err(vsc->dev, + "timeout waiting for block arbiter\n"); + else if (err < 0) + dev_err(vsc->dev, "error reading arbiter\n"); /* Put this port into reset */ vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, From patchwork Fri Feb 23 21:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp842506dyb; Fri, 23 Feb 2024 13:02:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXUsgCQvHzOQxqEdec9eg+S6KWzEfR4kVxzshajj2aGrupwxB0kLea2SMe/8o887VVkA8CP+7KuwFlxlVQai75ad6XLHQ== X-Google-Smtp-Source: AGHT+IEfeQRDOJwlYw7ev8LBxR3vb/eMpKwAJgRiD2NjUBMqYvQggJVfvKDcOyAT2LnbdklhD0dJ X-Received: by 2002:a17:906:289b:b0:a3f:d797:42ec with SMTP id o27-20020a170906289b00b00a3fd79742ecmr737149ejd.53.1708722163939; Fri, 23 Feb 2024 13:02:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722163; cv=pass; d=google.com; s=arc-20160816; b=q9s0UryuvpqUia/RUHfgxjTjYC0CJLKrfSbN4LPoGG6ayeqIM7iq+gypg4CIMBDyq0 Yrn790cUf0q7yS1B3cEnSfQRznvgm4344DP3i7BLOMHNWc5Vte7h46IWjQLZiCuYYzso hyI1cA1GtukZ7yIH9gB5Z4KdG4VSH4IJrE1u4UPRjfuekAvkEuB4efww1Dm3ACeOnXKi O5qfilF7i+SDM3aTdU2WS/iPKeqtKpE0YjEhg0tu0ubDLbsmSb/krLPfD3QxdyirBudW aOeQzXfTaoWOofvR5zpLHAYQkSufjBi/5mlc00R6/fWsMD/Y2SuCDak8/jyy9LGExH50 tnJQ== 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=kegIZxvQ3V5ErtuAqBTi6g+zqDh2Ar8Wl8I510MU1cI=; fh=NcFs1KvAiROHUfEnvcRTSCnSzsKV5ryoJcD999kihL4=; b=GjiZwPpqwJeDXScREXRyADUxWLu4GrdHnD3Dk1K8aIZaWKqIxAOb+91yeY10LM/I5M qpsRjHEeKfVR+r3m4QR0bRHEEHm3+hrmlygrK/LL5+n3gzaPW1QDFaF0SdBPdG9Qxj/y 9q7ljXHWcOH3AyAwtQZ2Z5iac35pGr+K2EIo4IgBF0uzxvMEVcnV5erDFoTxMxhMCAHX 6mB7gnmKLp7HQ31aLuirfBWlBmw/0OEF/GXa8d0HYBH2xpXa5mTCdYRCrdwWulq0Hr+a w81OFdG55c5x60FM9fgYgzTMjGFB0LmXmS1ZnxonZEsiz+u1TP0gH7+iK0DTNZZt2KvR MSuA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KfKZKgPN; 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-79162-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79162-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id di14-20020a170906730e00b00a3f851fb768si1595694ejc.581.2024.02.23.13.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79162-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KfKZKgPN; 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-79162-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79162-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 8EAA31F22DF8 for ; Fri, 23 Feb 2024 21:02:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46F7F149381; Fri, 23 Feb 2024 21:02:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KfKZKgPN" Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.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 E2EFE149396; Fri, 23 Feb 2024 21:01:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722119; cv=none; b=K49Z3bt9RhlsoHXTMrka4dDGufLseT3wLxwUL02m/ELYsXBYdKHwe1nlV9SBgDF5P9fkKf2iUWCmbi8EWJ5YGzuD5JL5rYEHsZjj0LdgM11xF6MY1OcmheanIE+++sAoSasXUUkOaUPEAjg4B+H3XVX/M1Ac2CUQP/z+Xw3YGug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722119; c=relaxed/simple; bh=YzSS2jEc2yrsg0NpWculskSZdP/jfRB/wDseRYqsnQY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LzASsB/+gTtupduUxA99jpfZ8tL7r20lJwmLbNgu9okV9pU24w2kA2fXnLuF7yyvr/zbRfK8YRM3igKXWY6pm4Op/Agvigufzl39HaGKrKIC2dDkje0O92CBwZrRcKUk6TfDl62nu6NVfpzliDOgK/ztEhF3hzcg8ZKmkUXc+TM= 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=KfKZKgPN; arc=none smtp.client-ip=209.85.167.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-lf1-f42.google.com with SMTP id 2adb3069b0e04-512c2e8c6cfso1563064e87.1; Fri, 23 Feb 2024 13:01:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722116; x=1709326916; 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=kegIZxvQ3V5ErtuAqBTi6g+zqDh2Ar8Wl8I510MU1cI=; b=KfKZKgPNVQpc5bk9gznxBwZ8RuF9ki4tAzdxZW5js68e+FQ9dqr87CyrEjovVW3XbV mkjQcVZaXQhDpfXgRQ+a0vsXY2zAum1Ozgl5pRhrMu7cHYkmU+i/bKnVbnvbJatY8rfp pEq2i9npa4p37gz43fgm5Fbt/P+dQ0KlR4TaAv0r7tNuLMShv7ofRRz7ktzmFPhSXGXV 0HRTcB5x5boFkWN2nS9FYfxumU+f2ORGJjmEbHtibIIvZRByeh7RXwtfS4H33/EX1Yj4 VNcXYoNgDfMurN+w0jmePHS2omrM+m3UTPwGniPwlbsnRRh36wekkyxSR+KJekJW4HeR DAPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722116; x=1709326916; 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=kegIZxvQ3V5ErtuAqBTi6g+zqDh2Ar8Wl8I510MU1cI=; b=nHXXWZc7z2TuHaeRQ5hI/eyguZIALPDPVujGIha5sWDkJr9hEncAnTGX0yXNT+EOb9 NSP4TuiS57kIYJPwYDAOB+OJW35XFQtTHQM5GPlny9GeEm1r0X11XVdFBTu3G82V1JEj VzVjcVsZjZ6RGfV7nWiqDCD2k3ErKuC9PhWWxaz1ek3IFED8Iy8LxT+JJ9rp5awcoN1q A7JgXmqPDpJVnLGNFfUPJ2kc0kjGbcYoQj7HPMJXn0puJnR5j2f3h+0LocdM65sXz/jv 44BTV5YRqZYjNZY+nkvDdNKwVrHTSajB7w0mqxtL8QuGO/dqH488N6MZ8onbxogMaR9G 8vag== X-Forwarded-Encrypted: i=1; AJvYcCXub1jtOL5w9oeJ0sHO8JGWQVRernOuDTg+VEIVlXBFe3qZyYg2EKBt2uRcgHwgAjrEVSJKdzQ5iY7l+fvqoawYDZJZ/yKQgjhMJQ74 X-Gm-Message-State: AOJu0Yxj2qSSxvEqMsm4WbckrHaUprIUWxfS4sbHb+72Wzy2NyAMv/nH l42iOCkVp5exa3B6H6PK6cTgA13W+yjF3gAc5Z67JUJsvuh2ylNw+yhio9WKpbw= X-Received: by 2002:a05:6512:242:b0:512:b935:c542 with SMTP id b2-20020a056512024200b00512b935c542mr634057lfo.59.1708722115443; Fri, 23 Feb 2024 13:01:55 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:01:55 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Russell King , Florian Fainelli , Vladimir Oltean , Andrew Lunn , Florian Fainelli , "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 v5 03/16] net: dsa: vsc73xx: use macros for rgmii recognition Date: Fri, 23 Feb 2024 22:00:33 +0100 Message-Id: <20240223210049.3197486-4-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725051866694436 X-GMAIL-MSGID: 1791725051866694436 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 --- v5: - added 'Reviewed-by' only 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 cb2e7e256279..8ed8fc997d6d 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -807,7 +807,7 @@ static void vsc73xx_phylink_mac_link_up(struct dsa_switch *ds, int port, else val = VSC73XX_MAC_CFG_TX_IPG_100_10M; - if (interface == PHY_INTERFACE_MODE_RGMII) + if (phy_interface_mode_is_rgmii(interface)) val |= VSC73XX_MAC_CFG_CLK_SEL_1000M; else val |= VSC73XX_MAC_CFG_CLK_SEL_EXT; From patchwork Fri Feb 23 21:00:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp842860dyb; Fri, 23 Feb 2024 13:03:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU89irQqbIU6jx2j4GdMVGnl2vuCz+0vw4pAGAf1skXFm97in/lwnKbFrWwckq6dVgvRWnG5wP7HO4QdUnh5N4LzJhoug== X-Google-Smtp-Source: AGHT+IF+oUVqzfYtOmNk/PCtTFFhQtU1nHqVAeL94HiZUFmloThi+qgYsOdaxl/aHIAs+qg/MoGv X-Received: by 2002:a05:6214:3985:b0:68f:b7cd:303e with SMTP id ny5-20020a056214398500b0068fb7cd303emr1765920qvb.24.1708722199005; Fri, 23 Feb 2024 13:03:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722198; cv=pass; d=google.com; s=arc-20160816; b=FKQRLOsPJ/Tn/q0hfhjElMZM52UCxGJytQn1SH+TXXPjsl8QCh1VQua+UMnTl0DoCc xOTrTj/8Maxag0EEoWgWj7cgQa3MhEeNN+lpson3VBUSMa1yCmpa3JB4K+uVXMgGfPOC nzV6rcSP7oBNPmToLKxdysRfLAzqCBPblxwETmfl74GmyqmKymSFNuuid+CMSYSKAYtl 2BrqjLL6PeXMpmGZsTCsZxNuD9rlTl29cBvIy/XdP07oKnhPWzHx7cMUNx4QYQCnfaAd h9c2RNkRcjlmdVp5e6iFsX1Nl0fcrR9Akm/e+vLHGHVPFFwUE2UopE8AWFbVjBTXSIEY ELOw== 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=08NWjQnKcjY+6Ilk3BwFDKrpVp02goqIQe5ciPfYtik=; fh=TigQmXRNu/TJF43B9Cg23656I8teNLssQOn5dat2AyA=; b=o39m0lh2/BIHzh7cMAwlBGhIQeKQr2q+/gGLgePLXxuFeOau3xXnkOzzM0LP9uwozd YD3wGA1cwZJRSS70Eei1N6laA60YZehvFmh8kn+84vOB8bBCeNJyvKe3XmCavl7G+OR4 Btnfd8VERb5iPivrhPTyHkAHtRfyAXIC+bK0OgiXSBX6qJA4RZUePeKkhjaGmRaXN1HL noQk0UXTFuUsh5stbrTChPlMQw4By80xjJuAnOkSKtIvfci/QsS3JO3uHkZfO8AdQM3Q QW5fxklmirJaiDeBgJCB0b+2DlpCvi1aFUnQvpWYbU0z+3oCdEPTcqyH/C0Q/Jboh7Ix zD8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kZekfT0l; 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-79164-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79164-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gg15-20020a056214252f00b0068f8d23a983si9353721qvb.549.2024.02.23.13.03.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:03:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79164-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=kZekfT0l; 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-79164-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79164-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 B6DF41C23DE9 for ; Fri, 23 Feb 2024 21:03:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87AAD14DFC2; Fri, 23 Feb 2024 21:02:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kZekfT0l" Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 45EF4146E71; Fri, 23 Feb 2024 21:02:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722131; cv=none; b=qg2ddBM+X2KE1GhlceHpLWk5cUfuaAURoIQzloVJvQxet52Rabwb8Q95/iC/Oz3IpqWPIuNu1w5GYXKBiSTFHyfF37ziINsvLW0psMhue3If9ZjnbRoEAZitCdU5SE2G7crUfpWd/JACxpptjpS8iMQMPELLoTL9r8khr1Vf4Nw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722131; c=relaxed/simple; bh=jDveqTSmY5Obwiw3CEMCB1M279nvlZqw4xJmx+i2XN8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z9aC5PG2GDY8jHx40OG7Wdxdq8/FP7qR5alTz5Pja4UvUDoZp3+tD0gU811pbH5Mq0v8OGlPS+Q9YmLUAodSvzoMZHJuZmcPjMhYNVic0ezEtqwZ7cyWvibvhTEBF0XEW1bLifv2w+42CkHO81K9mL4MyUKseDzqLvWpnTc/z6o= 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=kZekfT0l; arc=none smtp.client-ip=209.85.218.43 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-f43.google.com with SMTP id a640c23a62f3a-a3122b70439so118108466b.3; Fri, 23 Feb 2024 13:02:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722127; x=1709326927; 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=08NWjQnKcjY+6Ilk3BwFDKrpVp02goqIQe5ciPfYtik=; b=kZekfT0lNa7Csz+tGqbI+ABXCIpW9ZemNHrtbC/QYfisFAvftUC9gQXpUbGPxnSY1G JT3qZ1NRL7x+qYAN4Wu08hAzVxIs3lQnQdo3T2bqY4SKjmskjAtrzA8ri4OmZ3e9QgJS 1mRlSFxX3CX9K3qEubIQXK/Ihh8pSjp/7EirWQS+5Dc4xMD2kBO9FWnOfJGmi/4XZzoA aWd3Gk5lHroN/73+OnlxMmvL9yWG34ZKZC2FT/R3EnIPB+d2UOJkXHvlh8RgsgNYXE9B v8ehK1VgotTk+BeH/214goQyCj/yiMIuFQP9MzzVhXEJUXCYkvKzx0xYqyTwor8XfUGG Qgpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722127; x=1709326927; 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=08NWjQnKcjY+6Ilk3BwFDKrpVp02goqIQe5ciPfYtik=; b=OWWoCW9QlY0h9sHIw9ftJpfum4sQ41nm118NfPEEcqtuJvF2+CQI/T8DUn7lPXq05s GBFHA3QGoEgmZFSFFy1SgoDLvX30j4OIIstGgQa7P2KYilLViFqirdMiXBFIG4B6v8iz x+04MA0VfvZFe47eeWPrdOwZFc4JNUELbIm/Szd+xmyQgHngbtdFNncVb94HR26LDSs8 lHBoblei6Qolz0FpjbNBqKvURTSSq3FgMjJ8szR7wC+Xx7Lfanf0KSDXbB2+cupv8OYL Tws5SEJxP0Caxf/5CwelVMe4rfxlK3yiMVfRRMIR+n6nZRWlWXeBN2Q9IgPgizUz0YR9 yxmA== X-Forwarded-Encrypted: i=1; AJvYcCVBBb87hPv78OfIMyTKwTqKA858nvuhkovvT3Q4XbdmocnWi0BCWV/Tu/oBRcd/Ns+3HdgY8LZtSm+czppXo01gR8eM1643ti6Zc55Y X-Gm-Message-State: AOJu0YwE+Z1hjbS/XCAk2N/nlfevnEKlaDRQjPWQRc8APKjX4zCsogAj syC8fTy+8Kwkic5TDJmnJyL9r4UJ7q82Wy7woXUjTfY2aOawXysbnZ6YT4lFY8s= X-Received: by 2002:a17:906:688a:b0:a3e:4093:89df with SMTP id n10-20020a170906688a00b00a3e409389dfmr675430ejr.74.1708722127288; Fri, 23 Feb 2024 13:02:07 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:06 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Florian Fainelli , 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 v5 05/16] net: dsa: vsc73xx: add structure descriptions Date: Fri, 23 Feb 2024 22:00:35 +0100 Message-Id: <20240223210049.3197486-6-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725088446138067 X-GMAIL-MSGID: 1791725088446138067 This commit adds updates to the documentation describing the structures used in vsc73xx. This will help prevent kdoc-related issues in the future. Reviewed-by: Linus Walleij Reviewed-by: Florian Fainelli Signed-off-by: Pawel Dembicki --- v5: - improved description and stick to 80 characters per line v4: - introduced patch drivers/net/dsa/vitesse-vsc73xx.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx.h b/drivers/net/dsa/vitesse-vsc73xx.h index fee1378508b5..e7b08599a625 100644 --- a/drivers/net/dsa/vitesse-vsc73xx.h +++ b/drivers/net/dsa/vitesse-vsc73xx.h @@ -15,7 +15,16 @@ #define VSC73XX_MAX_NUM_PORTS 8 /** - * struct vsc73xx - VSC73xx state container + * struct vsc73xx - VSC73xx state container: main data structure + * @dev: The device pointer + * @reset: The descriptor for the GPIO line tied to the reset pin + * @ds: Pointer to the DSA core structure + * @gc: Main structure of the GPIO controller + * @chipid: Storage for the Chip ID value read from the CHIPID register of the + * sswitch + * @addr: MAC address used in flow control frames + * @ops: Structure with hardware-dependent operations + * @priv: Pointer to the configuration interface structure */ struct vsc73xx { struct device *dev; @@ -28,6 +37,11 @@ struct vsc73xx { void *priv; }; +/** + * struct vsc73xx_ops - VSC73xx methods container + * @read: Method for register reading over the hardware-dependent interface + * @write: Method for register writing over the hardware-dependent interface + */ struct vsc73xx_ops { int (*read)(struct vsc73xx *vsc, u8 block, u8 subblock, u8 reg, u32 *val); From patchwork Fri Feb 23 21:00:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp843038dyb; Fri, 23 Feb 2024 13:03:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVl/2QSI1r5WDYDaC2bg5yjZT1hmg5hnhvmBddPmU25rGYfofGkdWJZFGqqF+HanfWGfcaC/93GDTGPU6FrquF4JfmRMQ== X-Google-Smtp-Source: AGHT+IGBmxrPhyJfNS7402QLU6R/ELXUNPZjIKXapF34jAANPWFu5BYCwm373GCzXj/sv/d18hIw X-Received: by 2002:a19:6545:0:b0:512:bdd3:150d with SMTP id c5-20020a196545000000b00512bdd3150dmr564756lfj.52.1708722218855; Fri, 23 Feb 2024 13:03:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722218; cv=pass; d=google.com; s=arc-20160816; b=PkwgZq0tRDVZDJ9EO+vvKuJgxVh22Aw7ay1XeaV0Bm/GqROBoofq57AhGzvKvLFS4x fJG2qAfXAiTFoZYIm2WuLG5lcmp8QJaxDT9Mpf+VdcO2qN8Z56D3CEMOO+caj0TGVPg2 8bDUfOrjFCUhhGPXTjF7DeqlS8dwzd76w2sQrP//Yo1hCfegE+9ypZ6zvaz6Tyek7FqT JxHRA7Xz5GjeMPq4dapFiZkj7HCKUl90Fib81xYkm/S39dPmvxyBWpByr68UPU321IpS FtidUvFttkg+6GwSuOwz/MI64h0iVglii+vU662o4m9f2elAmhCm8d2eTpMQol2IRzZy B7uw== 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=NmSDk0c3liZ0FTN/I0gFbiEYHUdcrbT6AD0dmbXbwOI=; fh=80ZPNF67BwwQza99yd17MOE7RgIV1S1wK8Xeq+8339g=; b=RC3d3I7BMJBmYMsVXsq/XqKKc1XaypCsYjPBLWTYnUTFiLm56J1AMJSZifv7BaSJhV 4kpTjaReUI5FcVlTJbB7QT6NH1N8yO4hn4LhyMvXeJlSdHWk3XoBkjdjd5QsjPZCeDRv KuOR64dCSDuFucr/XZW1CbvVylVOzTslHBV+yQH3ZB3UEbJZFO2fO4NGZoAV4C9Hcqp+ SGhmxia+w7gR5vf16kJJ1AxLwk+xjWyEoZwGyFjj84Jyw2gPIL/N4A3NFmZiKzGoGwVE xwXqw0EmlRpYWQggvWqoyYjlhJ8sD46AJZpjFo1VKoO4XuL5XTDdmihU1laSFUS273FG z+Kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CjJfLlRb; 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-79165-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79165-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id le2-20020a170907170200b00a3f2147fcc3si2969001ejc.90.2024.02.23.13.03.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:03:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79165-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CjJfLlRb; 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-79165-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79165-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 4A8011F25E79 for ; Fri, 23 Feb 2024 21:03:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1DBB1493A0; Fri, 23 Feb 2024 21:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CjJfLlRb" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 819F8146E71; Fri, 23 Feb 2024 21:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722138; cv=none; b=kk94k0a/AgQgCL3NytM9xkBtoAFymr82BT6f4qXG12/9I89+5B7dTc7V32690OA8YEq7VGl2FFEnsbQ0zCxxY7hNvAWGRD4vclpOF2SEjDBVy2URS9DmQpKFIYntP3owaooL+TiIHLXkzRIUExr6v6ub/jxGVB7gQkiuhJGUZRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722138; c=relaxed/simple; bh=IUnbtBh/jU7L8ituS+NKI77KKtYzeb3KBPhVBtjGX9M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V1pr4di+LxFxMAYXUF3J2Qf3sYihw/DZROHh1nidcUwurLhyUZ7nENTzZKIVAhfRkvSF/5/kEvgenuOp6Mp8ofEN2ql5t7gpBX2Alh2jAkTUa8zPlp2zDfHhv5y14OQ/fH9NJ8zFF4lDuGIIBFQP1OtVmviJmjTlfgxd0p3/9+0= 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=CjJfLlRb; arc=none smtp.client-ip=209.85.167.43 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-f43.google.com with SMTP id 2adb3069b0e04-512c2e8c6cfso1563422e87.1; Fri, 23 Feb 2024 13:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722134; x=1709326934; 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=NmSDk0c3liZ0FTN/I0gFbiEYHUdcrbT6AD0dmbXbwOI=; b=CjJfLlRb4i63vq+cXiiB8rKMfEm5wsbSGDJeWcVAbNBJMW8j4WblNnHVid4yN9W9le hwD20dthzP4pWDq6paB05Yt70dmizotE2J5NACsUVZgCb0rF2Q+whOxsm2ZIs0PkfxyY L3RYun7HFWjYGCdB4hcjC6ycRRLS7Rk3sO+4HFaT5twKEqGSleRSFFWF6PULHs2vFADE zDi8fYToAGKJVx072BjJC9sWZzDt3TUkO61r+kioEKYegp8FBktjH1OWxzOlV5KY2/V8 Gr1z1lmYYWieSs4GwabVT64VTDWHxRn984/6Ic+MXs4QCGYhcJ7jhHEiYENFZmNWStBh Nybw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722134; x=1709326934; 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=NmSDk0c3liZ0FTN/I0gFbiEYHUdcrbT6AD0dmbXbwOI=; b=opCKGBvaip6N8VGKB/clpnR0jfBMuYmKHPkoehfU9hIn3sOPOFDvdBZp+GHTL0fCMV nFq2UyUQS+XLYRtpwG4QQtzoaorVG+fXfWSivxpjZ7iTAgSNuAltQKIEIpmIt4XP12pk bvCnIPQpS1ONuFOFWTM97I6Py1ABoEKVWNGKh1uLxCIt//cCs9/hUQjB/ZEbs1ejGMjU IArgoXlzGRTcyfIn5dVRV4N3jHHJcn14pb6ENTQ/4NylTOMzkNHM+DzJgp2uPsCk1a5U bL4XZuJEzrYXiwdsmnHzJBG5LUFDYScVrjhFzdJLo3R/qrWfCMlM9IL9cN6NKC46NoPw 3qTg== X-Forwarded-Encrypted: i=1; AJvYcCWRwO45njiqgTD6oIvqqB1t2kCiXF4V7uWItqZLVQynaKYKPuH3O0HYVsHUYdsAGDiNGorwbQYzRnaH2A2071Z19BQgxeikRMcnGnku X-Gm-Message-State: AOJu0Yw3/FF0fmfWZ1cQqGKLSAdZk5VGXQ8ge1If5GE8DFDHYjMwaclP ft8dnWSuC/M7N70oNjYIctIBu9XX0VjIP1t/ywsCpfhMx4bxOk3izaWH+vrPTuc= X-Received: by 2002:ac2:5970:0:b0:512:b362:e790 with SMTP id h16-20020ac25970000000b00512b362e790mr546591lfp.34.1708722134333; Fri, 23 Feb 2024 13:02:14 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:13 -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 v5 06/16] net: dsa: vsc73xx: add port_stp_state_set function Date: Fri, 23 Feb 2024 22:00:36 +0100 Message-Id: <20240223210049.3197486-7-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725109488554517 X-GMAIL-MSGID: 1791725109488554517 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. Signed-off-by: Pawel Dembicki --- v5: - remove unneeded 'RECVMASK' operations - reorganise vsc73xx_refresh_fwd_map function 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 | 99 +++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index 425999d7bf41..c3ef4c22f687 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -164,6 +164,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) @@ -623,9 +627,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); @@ -785,10 +786,6 @@ static void vsc73xx_phylink_mac_link_down(struct dsa_switch *ds, int port, /* Allow backward dropping of frames from this port */ vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, VSC73XX_SBACKWDROP, BIT(port), BIT(port)); - - /* Receive mask (disable forwarding) */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, - VSC73XX_RECVMASK, BIT(port), 0); } static void vsc73xx_phylink_mac_link_up(struct dsa_switch *ds, int port, @@ -841,10 +838,6 @@ static void vsc73xx_phylink_mac_link_up(struct dsa_switch *ds, int port, vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, VSC73XX_ARBDISC, BIT(port), 0); - /* Enable port (forwarding) in the receieve mask */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, - VSC73XX_RECVMASK, BIT(port), BIT(port)); - /* Disallow backward dropping of frames from this port */ vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, VSC73XX_SBACKWDROP, BIT(port), 0); @@ -1036,6 +1029,89 @@ 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, u8 state) +{ + struct dsa_port *other_dp, *dp = dsa_to_port(ds, port); + struct vsc73xx *vsc = ds->priv; + u16 mask; + + if (state != BR_STATE_FORWARDING) { + /* Ports that aren't in the forwarding state must not + * forward packets anywhere. + */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_SRCMASKS + port, + VSC73XX_SRCMASKS_PORTS_MASK, 0); + + dsa_switch_for_each_available_port(other_dp, ds) { + if (other_dp == dp) + continue; + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_SRCMASKS + other_dp->index, + BIT(port), 0); + } + + return; + } + + /* Forwarding ports must forward to the CPU and to other ports + * in the same bridge + */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_SRCMASKS + CPU_PORT, BIT(port), BIT(port)); + + mask = BIT(CPU_PORT); + + if (dp->bridge) { + 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); +} + +/* 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 tag_8021q 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); +} + static const struct dsa_switch_ops vsc73xx_ds_ops = { .get_tag_protocol = vsc73xx_get_tag_protocol, .setup = vsc73xx_setup, @@ -1051,6 +1127,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 Fri Feb 23 21:00:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp843307dyb; Fri, 23 Feb 2024 13:04:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQA08ATgff3iLBw9vzfM4H+P6o1V4I+LhApRDRg9MrUDmLajmH0s+OTV522ylPyB3OP28dCT5M6PxhF0iZAPTPE1FHlA== X-Google-Smtp-Source: AGHT+IGru4DCv7tqP6X2SvFlz0nK1U2YRJIIk13uEzqIFQwanvQPEzbKYPMIHo0ZssvQUPqP+KzB X-Received: by 2002:a17:906:f286:b0:a3f:4d95:ff69 with SMTP id gu6-20020a170906f28600b00a3f4d95ff69mr618805ejb.38.1708722248096; Fri, 23 Feb 2024 13:04:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722248; cv=pass; d=google.com; s=arc-20160816; b=fjEYZ7LXsB7+R3GNfIVh1HymJVFi/8prHWGYpsddS0OZj63Vov2te44ZKmrWA989X9 iTgt3J71PDRWsz3tqtVlqOA4TzehJHtWXBctqqeFT4fd5ygzucYo+OX62MVUFWXhFspq VgjguAj0Q6jZGyJk3SbxduJimRrXMb+StcAQv1yl1kgS6842GebH3B4Pjtuyf+hhQHPr WdzPXHWK2qW+DTso+b2WmskWoBd+dA+g0B5tghwvEPUAvGcJqslOTpizz3TBr13DcaU9 VA7tS/kX5HRFUQPVqa+CgW0BuQ5YUycY5pn2nJPCteW0ZCuxi+WCMFmDHGZL5Ot7I3a2 WXMg== 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=mhgF0KndogaQ4hiNACt7+FiqREIf4PihWNEH6HY1lds=; fh=PpXOIwVlne8Kk+r9MOZOcaA9z5DnRhNY4zG2DPIWDkM=; b=FKAm2+0K1vWDcpj5vEJQJAF6Ex5UehoRBdcb8bvrlyiSLyN9AAPiuo+KHtJF9VS1Pe oaLNXp7apg0ZemIIzfw6UJi7I/ZlPhfUbTzD3BkT7jRmWX/mP8V2bO3OQoFrJs7F0n6T D30y748FPondZQ+gNSV1JZPJJLldfaiaBFr55OEaaFHpFEUq/yBo07klk8xcFydShepS nv6yrikBG8JXOb4pbmqtlhfGZmrIC5MjnWkgew0CtWTTB2Ra8JyW8msvJ9kzlNOBrVJ/ myinP09E5nWAC4qzxT7C2bV79uoSOSmuBbDY38W9ZScgg4e0fO6vYyVJ6oES2aOUjb6l eySA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="SnEy/YDP"; 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-79166-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79166-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dk8-20020a170906f0c800b00a3ee6998ee2si3838806ejb.441.2024.02.23.13.04.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:04:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79166-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="SnEy/YDP"; 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-79166-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79166-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 8973B1F261C2 for ; Fri, 23 Feb 2024 21:04:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A31D114E2F5; Fri, 23 Feb 2024 21:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SnEy/YDP" 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 6E5A2146E71; Fri, 23 Feb 2024 21:02:23 +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=1708722146; cv=none; b=kXYxmRzQVUT4Hb/A/CtT6Q9qT3weOa/jS93wQdODPSiErYlqLmOTH0H1u4q5moQs6eNOocy9MxfI2g8RiYIbUDnG1eQ9yxjholLPqmKp4SALxv4Aw6R06alO9jrHZDty+202Y9Kz8pfJbTdbOaQXQkfJqW7Neqwyb0Yzq18UUwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722146; c=relaxed/simple; bh=1FS1ymrskWa5czitCxLd7qTbgAeF7WMP47xFmyGFtZw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZBeKRKpxAKU/M3p46F+ZCcZ07oxv96uLn+x+8OM+Pk13zWxCNelowsyEz/joyd+UxABpqc1RIMWbuZqgFSCsNYuUk0owIIU8MiEYqz4QQffvQGRboC8xUsNIQ3uX4TPQu4ygRgq8I9uH8GU91CDwqHZWtlqHItWHx+4CfcSL8go= 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=SnEy/YDP; 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-a3f48422fb6so191517466b.3; Fri, 23 Feb 2024 13:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722141; x=1709326941; 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=mhgF0KndogaQ4hiNACt7+FiqREIf4PihWNEH6HY1lds=; b=SnEy/YDPlKJmc99tEQ3xP3R347x7phk1lz8H/w0hs8+3fUaFG3BT9fHaTw7wbQCAXN phq6wXwc5QVVB1Iw7K2ayv5XA9mMsE6Z8AjYGOUT8unfxhMHvngnaM3+7PNkNLgF+q2a 35hmhn8p3xFPgEjPebW/+uzVF/+al7QyI7Nel4ss7JUwsnolryBQmG/ePJlDtUZq/c2D Daf7yvZYf/FZdsJudgw+1JSQKSjbI/BS9dE/fpac7fB1OVRgZRw7IaFlmx/jy5+HenCz ANa5nggjwUG/e/mK4KJbeiavBOJXHRbHZQbPWkwcNksHar92es6TWBLBYWlBzEp7zB1a dkcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722141; x=1709326941; 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=mhgF0KndogaQ4hiNACt7+FiqREIf4PihWNEH6HY1lds=; b=Bs+mT6llj2fOIkUCbxv/+UmUMhz0ct1C9f4VL+Lv7OTD7kHJ4BP93Fhjy60cGJq9jc qlGpagrp5g8H4+1VMsLi6FfzqSNmGFXsfoMmgDLRZj879b9s1a5qe1gUUC1d6V2kXjwV cz9+NdPQG2/V3jXE13WcBgduUuamdhkQkY9dX7Prho7vWCyNWcwToqXD9cKmVJWGqpmO nP/ku7MTvEVFhdwF2vBYwXC0HHl7Wp61BEnFFEyrRrEEZcmZwwUP9n1MMO+6AVywzJBI bDMNHNgqLmMr+Yq8tR41ZyXFqH0mkhRToJ93m7HTiL3+YQw85uAP68TJ4z4/3khrQ0S9 jO9g== X-Forwarded-Encrypted: i=1; AJvYcCV89xcFQ18opsEdg2NRx2B+ckCxKl0wnagZUGxEnBC+vrk5ugxFr2AfoxyM18MXZt/Hqy3lwtSGd8qAEwzBHcoTfg7Czod7OOX4AU+4 X-Gm-Message-State: AOJu0Yx+Mgk+8q9blPVUq17HFZQScbbdNqVNdyqlM0cnr612udc4fJ+8 dnDIAQ9sXwavbOJEU5Bl1sEEyuwK4IxO4/4TpFIKTkRS5hDxfw7GK7YTlKyZ5qM= X-Received: by 2002:a17:906:bc8c:b0:a3f:50ad:fd71 with SMTP id lv12-20020a170906bc8c00b00a3f50adfd71mr615710ejb.19.1708722141366; Fri, 23 Feb 2024 13:02:21 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:21 -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 v5 07/16] net: dsa: vsc73xx: Add vlan filtering Date: Fri, 23 Feb 2024 22:00:37 +0100 Message-Id: <20240223210049.3197486-8-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725139711400007 X-GMAIL-MSGID: 1791725139711400007 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 --- v5: - fix possible leak in 'vsc73xx_port_vlan_add' - use proper variable in statement from 'vsc73xx_port_vlan_filtering' - change 'vlan_no' name to 'vid' - codding style improvements - comment improvements - handle return of 'vsc73xx_update_bits' - reduce I/O operations - use 'size_t' for counting variables 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 | 570 ++++++++++++++++++++++++- drivers/net/dsa/vitesse-vsc73xx.h | 29 ++ 2 files changed, 597 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index c3ef4c22f687..87ad8b78f141 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -22,9 +22,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -62,6 +64,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 */ @@ -122,6 +126,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) @@ -135,6 +150,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 @@ -189,7 +213,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 @@ -347,6 +372,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) { @@ -564,6 +595,91 @@ 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), + VSC73XX_POLL_SLEEP_US, VSC73XX_POLL_TIMEOUT_US, + 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; @@ -598,7 +714,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); @@ -627,6 +743,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); @@ -639,6 +758,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; } @@ -1029,6 +1154,443 @@ 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 = 0; + + if (port_vlan_conf == VSC73XX_VLAN_IGNORE) + val = VSC73XX_CAT_VLAN_MISC_VLAN_TCI_IGNORE_ENA | + VSC73XX_CAT_VLAN_MISC_VLAN_KEEP_TAG_ENA; + + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_CAT_VLAN_MISC, + VSC73XX_CAT_VLAN_MISC_VLAN_TCI_IGNORE_ENA | + 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 = 0; + + if (operate_on_storage) { + vsc->untagged_storage[port] = set ? vid : VLAN_N_VID; + return 0; + } + + if (set) + val = VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_ENA | + ((vid << VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_SHIFT) & + VSC73XX_TXUPDCFG_TX_UNTAGGED_VID); + + return vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, + VSC73XX_TXUPDCFG, + VSC73XX_TXUPDCFG_TX_UNTAGGED_VID_ENA | + VSC73XX_TXUPDCFG_TX_UNTAGGED_VID, val); +} + +static int vsc73xx_vlan_change_pvid(struct vsc73xx *vsc, int port, u16 vid, + bool set, bool operate_on_storage) +{ + int ret; + 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; + + ret = vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, + VSC73XX_CAT_DROP, + VSC73XX_CAT_DROP_UNTAGGED_ENA, val); + if (ret) + return ret; + + return 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); +} + +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 size_t +vsc73xx_bridge_vlan_num_tagged(struct vsc73xx *vsc, int port, u16 ignored_vid) +{ + struct vsc73xx_bridge_vlan *vlan; + size_t 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 size_t +vsc73xx_bridge_vlan_num_untagged(struct vsc73xx *vsc, int port, u16 ignored_vid) +{ + struct vsc73xx_bridge_vlan *vlan; + size_t 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 vid, vlan_untagged; + + /* The swap processed below is required because vsc73xx is using + * tag_8021q. When vlan_filtering is disabled, tag_8021q uses + * 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 tag_8021q. + */ + if (vlan_filtering) { + /* Use VLAN_N_VID to count all vlans */ + size_t 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_untagged < VLAN_N_VID) { + store_untagged = vsc73xx_port_get_untagged(vsc, port, + &vid, + false); + vsc73xx_vlan_change_untagged(vsc, port, vlan_untagged, + true, false); + vsc->untagged_storage[port] = store_untagged ? + vid : 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, &vid, 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 ? vid : 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 dsa_port *dp = dsa_to_port(ds, port); + struct vsc73xx_bridge_vlan *vsc73xx_vlan; + size_t num_tagged, num_untagged; + struct vsc73xx *vsc = ds->priv; + int ret; + u16 vid; + + /* 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; + } + + /* The processed vlan->vid is excluded from the search because the VLAN + * can be re-added with a different set of flags, so it's easiest to + * ignore its old flags from the VLAN database software copy. + */ + 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"); + 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 is based on + * tag_8021q. + */ + if (port != CPU_PORT) { + bool operate_on_storage = vsc73xx_tag_8021q_active(dp); + + 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, + false); + if (ret) + goto err; + } else if (num_untagged == 1) { + vid = vsc73xx_find_first_vlan_untagged(vsc, + port); + ret = vsc73xx_vlan_change_untagged(vsc, + port, + vid, + true, + false); + if (ret) + goto err; + } + } + } + + if (pvid) { + ret = vsc73xx_vlan_change_pvid(vsc, port, vlan->vid, + true, + operate_on_storage); + if (ret) + goto err; + } else if (vsc73xx_port_get_pvid(vsc, port, &vid, false) && + vid == 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); + } + } + + ret = vsc73xx_update_vlan_table(vsc, port, vlan->vid, true); + if (!ret) + return 0; +err: + list_del(&vsc73xx_vlan->list); + kfree(vsc73xx_vlan); + return ret; +} + +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; + size_t num_tagged, num_untagged; + struct vsc73xx *vsc = ds->priv; + bool operate_on_storage; + int ret; + u16 vid; + + 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) { + vid = vsc73xx_find_first_vlan_untagged(vsc, port); + vsc73xx_vlan_change_untagged(vsc, port, vid, + 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, &vid, false) && vid == 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 | + 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 | + 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); + + /* Initially, there is no backup VLAN configuration to keep track of, so + * configure the 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, u8 state) { struct dsa_port *other_dp, *dp = dsa_to_port(ds, port); @@ -1123,11 +1685,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 e7b08599a625..facc50f1e320 100644 --- a/drivers/net/dsa/vitesse-vsc73xx.h +++ b/drivers/net/dsa/vitesse-vsc73xx.h @@ -25,6 +25,17 @@ * @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 has two alternating roles: it stores the PVID when + * configured by the bridge but VLAN filtering is off, and it stores the + * PVID necessary for tag_8021q operation when bridge VLAN filtering is + * enabled. + * @untagged_storage: Storage table with eggres 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. Contains port mask and untagged status of + * every vlan configured in port vlan operation. It doesn't cover tag_8021q + * vlans. */ struct vsc73xx { struct device *dev; @@ -35,6 +46,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; }; /** @@ -49,6 +63,21 @@ 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 Fri Feb 23 21:00:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp843497dyb; Fri, 23 Feb 2024 13:04:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrhVELRQcNFdFcitXw0ILP2H6QEJNC9f7SMbi4x0Ab7g6kGHLGOafMHcxvMr2VYhFs2KEhqRH1RAJ4bsEru1Yj6X+jVA== X-Google-Smtp-Source: AGHT+IEuYUSLqgFny7WoUMSEil1+n/SwfR0b0kvUfcPN3Aiq0KkeovpKi6x8CQS2UUQaq2omTEoY X-Received: by 2002:a17:90b:8f:b0:299:2cba:7588 with SMTP id bb15-20020a17090b008f00b002992cba7588mr971727pjb.1.1708722265111; Fri, 23 Feb 2024 13:04:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722265; cv=pass; d=google.com; s=arc-20160816; b=LW2ioLeF8itQMe1XhfN00GgxaVugTMPDfmmqZwj1vWnmGCRzFU1Vd6LLG/avxYUFAF qOjAZWi72yDJBbcDAulRngx1w724PSVidf+Fz5o0O2L3zFmPmml+7zZGrgDJzYoSnbIS pGgIGr/XYZBVhkODBjz2eJKSVEEtBeOgUsoYOi9UzLqZqkMdgg7xSObhtLsPA7WcjUs6 c+jINQzqNMu7Onsy9qygm6USCQwsc0marmmETHkiVqvHnTQI57vD8QlYNuQBri+TmP9s gAtVi7zV/mmTIJxK+faq7Ck2CGRUcHE9XnzbID41ngWh1xpWcPQp1i552HItI5ek4pVo zKlA== 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=vcBeMQ6U+yvrfqhVopecDLTi+IwDrZJeE1wPHz5lZzs=; fh=THgy3vEVk7oMPh54GQ9JCorSDdKhuJMuwBiPQiizCH4=; b=I84Y9AyCb+80Ik+mD6wzZeCo1SZF9SApH2fXraT9BTCjLyyYRJK8CGWXHgRa5fjxcD 7SFmddi60QmOL71BqaRf3WGmppP3NJ/2mxT9XuGNx9d+hIXTJNUdNvuK4693vLuqCwGq F0ckfY3WbP4M4w/fSr8VjT953gBxhevbD0fvE9sceNxAYsF8iNnXJdxGjooSN6K2eMqw 7bwkHWpbA3TX4hErUioduUzl+Xm2Wyy6uFhaiG/y8GC3qTwgRseR4mhiIJPxbbzaYTiM TxJcPXs0Iw4F9B/TC8AeoiAI/q06ZiXDK5ompzOq0mUzNmbNPd77BGdyCojYPoeW1x9a nyYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VJZHHeJQ; 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-79167-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79167-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id mi1-20020a17090b4b4100b0029983f36d50si1734272pjb.173.2024.02.23.13.04.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:04:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79167-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=VJZHHeJQ; 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-79167-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79167-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 AAF06B225F8 for ; Fri, 23 Feb 2024 21:04:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4CD8146E71; Fri, 23 Feb 2024 21:02:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VJZHHeJQ" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.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 1561D1493B6; Fri, 23 Feb 2024 21:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722150; cv=none; b=bNZLYJwncN/IzW8U9iokhI7AQUzjwy1evsXJ2rNg3lkFfJTNW3HoVaieUj+6+T6ErgLHAuc17SKY8a3n/S3SS+MKGp7a0T265soJjCIkSlnZuSvcAELIxq58R2mKe/GDmV6zuQAvaUlo8qFruNLu2JRWf89RqO272Srm9Rs/bgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722150; c=relaxed/simple; bh=Ge4QXGCmrLjaNvVszjPRi3oZ/cuOJtfxYaMZ7XeCdNo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FZAWxVHH/sC7fgFBD4zmgk6KyAXpOmGBTwZmHJG1VvSBAZUPtu0MhP0fqfEY7DPBcZYKrCgd7gIoP4dt9sbRX2AJpi5S7wNz0l86NP7L+B+/d5UGRHuNkwJ460sI7vo6oDQ848njh6X7yl2K4rWRpEo+aGocBauVzq5ZW0KxbbQ= 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=VJZHHeJQ; arc=none smtp.client-ip=209.85.208.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-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5640fef9fa6so1649096a12.0; Fri, 23 Feb 2024 13:02:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722147; x=1709326947; 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=vcBeMQ6U+yvrfqhVopecDLTi+IwDrZJeE1wPHz5lZzs=; b=VJZHHeJQgnY00gZsXrt9NurbfQnBScobSmvrwzmB8oIk7CKqFmjqHwbDKytFZyJR+v GbgVp6OeAJeLLWcyvH4Ls0OL/k5OqVDQUbtrtscBWpz/3EbqqRc34jH69EQOvOF1IwuU 4PalivfV/o+Zx3p91iabLU7wYa6t+/tUwlbPqjPF54OAUSrulDmWmzTi9bgOsKGv7XFn Tec0aNEzkSp8zbTAu2vUPIs9bRLND07mwC2Z/xYTaRfG6/WE7MpFa3xEUPDhIk+vtF6w Ok338ND+H8ZNnRSHMczlc1zocEVzwyAyFBd1HsN+yyj5U1DSc4+cqCKdGDk0+1ihmgzP LdRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722147; x=1709326947; 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=vcBeMQ6U+yvrfqhVopecDLTi+IwDrZJeE1wPHz5lZzs=; b=lqUMdGoROvE7gvYWX1fczW/k+gyYVAnly3S2Z3sSOI05dkSTolar/PcOPCavhKkN8X 2Ywz6llG8mqDRDd7Kg9/mdZqHRpjgRr8i4IBR8nm+k2gc00QDW/7WwoYnUq74D05uL+8 E+TrYW+TtavSWTI+OrUyrX0LaQKz/WxemJfDbFrzCDZvnvxweE/WOup4RVZk0JgWxSwL 19ErH6l3zjNIberJldrsMgspUc5FNsjbjvIkeaPRS/S0HipUSKAt2KIDARIv8PpKyH62 eN2pURF939NHGnxn3fHzZOBJu8/ws9q+zscplCloLnnS/Aw1Dt8Kd5T/lapKRBreDVJ6 afhw== X-Forwarded-Encrypted: i=1; AJvYcCXYUu1yzd2GRW/oKkf3c4DARNZfoJMFvJ+yQNJ0u47DqxCHZ8iWgj3Ny0vJihLKhfIKl8NL0V84Wo91gXOzh+CV54bPCta8dCL0GOPu X-Gm-Message-State: AOJu0YylRS+GC78AgVOBWeLfabd5KJTMN6yfQJwUsewzdXjnafGI8I+a G6+FSyUfmfH7PH0TyMv15TwPVHiZc4/zA3tzjAVYZytTC2/LbKi8kvdV2y9318g= X-Received: by 2002:a17:906:a40f:b0:a3e:8300:7647 with SMTP id l15-20020a170906a40f00b00a3e83007647mr663043ejz.63.1708722147035; Fri, 23 Feb 2024 13:02:27 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:26 -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 v5 08/16] net: dsa: tag_sja1105: absorb logic for not overwriting precise info into dsa_8021q_rcv() Date: Fri, 23 Feb 2024 22:00:38 +0100 Message-Id: <20240223210049.3197486-9-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725157990007191 X-GMAIL-MSGID: 1791725157990007191 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 Signed-off-by: Pawel Dembicki --- v5: - add missing SoB 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 Fri Feb 23 21:00:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp843774dyb; Fri, 23 Feb 2024 13:04:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVBTdtR1ke7f09gJ+2FTSpJAAoeYvqT4lJjMK2F2pLomWnqcaqxKtYfCJhZC224lpteah+YLh1lV/KOsItCx3WDKrYKPA== X-Google-Smtp-Source: AGHT+IHRdvRex/0J1SFSrOlIVAbCsPsYC1AxaFOWVWuDU+k5QFNJjKkydvMsVFtfn9TLaegPZGsP X-Received: by 2002:a2e:3a0f:0:b0:2d2:2dbb:3898 with SMTP id h15-20020a2e3a0f000000b002d22dbb3898mr157639lja.31.1708722293305; Fri, 23 Feb 2024 13:04:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722293; cv=pass; d=google.com; s=arc-20160816; b=eculjaOklGRlDeDfMG4dy+jDTIkdCbgGD/e6tpF+jjlrjnVIZAuh2OdNoDNNCjGt5G 9rwsiELwrodbfI7GLv771TwyoQ8GsVUhtXAZyAr2lX929IYdHRAPuVEiXZhxnDTt3ho8 4hqMKlT78k/a9iIcYpTqfq2RfWwyoSFZmMkFb5y084ncOVdcb45OdlPI919AuAPRNGLm zElB/moFHyxyqaJZs4IQNL/kgv1CkGIOhARTr49wRS91itxwY/jxgeWeY9iIftecxvD6 01J9ctzoAk01thIwb3D9St8aWBfy2YYAXppNKYYwomPWhQ/nxWIsLX1ftE1QCVH2k74b WhuQ== 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=0NLCOmx0IepUq3FGeXL96wdgQ4A1ty/0t9iA55p68ic=; fh=KorcLfUJwvmWlef2o0ZqjNL9fr69dZKjAyUgHqgQIDE=; b=cdddc+Um9QUa3F/3Dq25+mWjwAwSQ8U/tYTsurJg0b5P1bGOSdKGL/67iYmX1lqDNi sIDuXB31AetqayuF8ziP4Ck9lC4reJwDpKXDd5aEvr23L8PwJAwxgsNED8cu/iptcGmq 8SadUMQZewszDSsiUNsVUtgX9MQH9rrZSHeUALMutAE8W5oobw8ecihNuv9We8xYNfVT dTszGBV4wLgvfUN+DnYTOymTAaZhpkyRew1+4rWJo+XZVFZk5+e1n9JJPzzGaKM0lFvn q8g/DetwtxgKRGq6e517I0cyZDt5TBxDM3QUz+WW2tDkUDFZ+ionR6pH7ItD8U+rOH7O xdHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PNXStYk7; 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-79169-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79169-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x8-20020a50ba88000000b0056401546810si6184380ede.17.2024.02.23.13.04.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:04:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79169-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PNXStYk7; 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-79169-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79169-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 E0A931F26357 for ; Fri, 23 Feb 2024 21:04:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B953149381; Fri, 23 Feb 2024 21:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PNXStYk7" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 0CD5514EFC5; Fri, 23 Feb 2024 21:02:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722161; cv=none; b=lWc+bv5RFngLWJ7C+Cseifwwzr56hVQdDoDL+gNRGoKXFh+JHZNDbzEGkGtCv1Mb45DlqNzxOvN4fIi9wEo/0tZkUkHK6fwTkWGDn0lEj7cistqOB4Kxw5uuOae7YKQh39AMWNbbVss9XR67aP82AYFYkA1eHov5Ozk++hRB+dE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722161; c=relaxed/simple; bh=2iUVpsRP+GziJHbqwVWUqIeakMzbVBwpep9BwrCTVN0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Xt0vyel0C9vsK/EA8XXa7GfpbtxHFtzf8q4MN0bQrPkhxaC8XeKhaYL4uqO/8svKr0qdKImHaCP0f0qTcbGTpbtLdK8aUQPDaj2gL+Lm1V5Ir/ToOPZd4YSPgTCA0jGTdhOV++ZyjddHfCl8UmqQUIcKoJ+7RxNmClpZaQ3yRK8= 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=PNXStYk7; arc=none smtp.client-ip=209.85.218.54 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-f54.google.com with SMTP id a640c23a62f3a-a3e8c1e4aa7so127023266b.2; Fri, 23 Feb 2024 13:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722158; x=1709326958; 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=0NLCOmx0IepUq3FGeXL96wdgQ4A1ty/0t9iA55p68ic=; b=PNXStYk70Er1WvWKORv5EiLjIBatBy+v3gb8FvENboTSbZLSAYa7gRjOHXA2QlAZt0 3lFg/56GI1UNw7Hty4SLOkkrquZuJuVbbWon/MKe1FNiBVEewnNiDigce7MoIEJTq1bQ Ab7Xw26lQXet+Xs3TZHSA7jikc+sHFTK/5BzxFiScz2zwNFF70cifDvJ/ISRc6f7Crc3 5JGkQ7np69Sy9cNuPT4YfrtDxKh5MW+ukMBzzS7RwFmd0IoLlvAFdxjDT4R46Ng3+TJp BrsDSBh44PRDZbwhllQR0HvrcbKy4BycHumplud4+d/LezoxRa239cAngC0rPRE0ADrA /ulQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722158; x=1709326958; 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=0NLCOmx0IepUq3FGeXL96wdgQ4A1ty/0t9iA55p68ic=; b=j47woY2c7M5wCt9bK8U5iXWEsVLGzOJoUuRWBx/ARplVGJX72WwsJbxTZ4eseVvXcQ Tbz1TyFzh8LEWlpu1zXCpSZII2hGFKAyczuAUC4I5F/rcH2lxEu5LTGPAL1rHDZS0orw MXDRr2Q0c4wDzVBlwA8RUAKNaK8KsO+fEzJ3+VsaXlen3WAm7IrJmwjjrWO7yRwsfT/F P7IPRppcBMuA3rLHpMuup/KDhVkW8I3nKtcgyI5m19Q2CTzVUlGeG9IXZknz9VP1Pg9W x/w4nKGfVNHI1OaI9Mta9eax+iKram+O29ptj1LslKXVrBhJXF9sbq4UDFldE2ZpjH7P B/eQ== X-Forwarded-Encrypted: i=1; AJvYcCXpLM5ocNDNRjzWfMq0bQEJuVNWZa0klKCdITOGDMa2cOBFbmNVQ+QHwYFJh/J/+lFskkmCTOZQ0RVjJi/REYBdMNjE4zkSK6pYNqVQ X-Gm-Message-State: AOJu0YyKGt4WPTsedDrfZ6WQknnIVY2licYi/x+MpLk7lCRjgz/YPh3m i61PcU8SXufRH9EyFaD16K7YRyMHZNJhD05/TsZfG974hLbaSMfn9Jl1H6hajGk= X-Received: by 2002:a17:906:d20e:b0:a3f:9f38:ded with SMTP id w14-20020a170906d20e00b00a3f9f380dedmr584159ejz.69.1708722157949; Fri, 23 Feb 2024 13:02:37 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:37 -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 v5 10/16] net: dsa: tag_sja1105: prefer precise source port info on SJA1110 too Date: Fri, 23 Feb 2024 22:00:40 +0100 Message-Id: <20240223210049.3197486-11-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725187750689328 X-GMAIL-MSGID: 1791725187750689328 From: Vladimir Oltean Now that dsa_8021q_rcv() handles better the case where we don't overwrite the precise source information if it comes from an external (non-tag_8021q) source, we can now unify the call sequence between sja1105_rcv() and sja1110_rcv(). This is a preparatory change for creating a higher-level wrapper for the entire sequence which will live in tag_8021q. Signed-off-by: Vladimir Oltean Signed-off-by: Pawel Dembicki --- v5: - resend only v4: - introduce patch and replace 'slave' with 'conduit' after rebase net/dsa/tag_sja1105.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 7639ccb94d35..35a6346549f2 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -652,12 +652,12 @@ 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 (vbid >= 1) + 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 if (source_port == -1 || switch_id == -1) - skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); else - skb->dev = dsa_conduit_find_user(netdev, switch_id, source_port); + skb->dev = dsa_find_designated_bridge_port_by_vid(netdev, vid); if (!skb->dev) { netdev_warn(netdev, "Couldn't decode source port\n"); return NULL; From patchwork Fri Feb 23 21:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205689 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp844594dyb; Fri, 23 Feb 2024 13:06:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWfSsTGW8jg4npf6p5hl6FTtb2yAoAVJ+zkJaLV0TRX6IQB+XVm2fB7ffJ7RhbssTraMw836sd+cILkCvJbWASz+/Uwdg== X-Google-Smtp-Source: AGHT+IGxLLmtcTENAhMtcKh43Tn1q3RXevnlxnWjlSzEME5YkDc7CHvfTFcghxczJNhnmubXmKHl X-Received: by 2002:a17:90a:a613:b0:299:10d8:31cb with SMTP id c19-20020a17090aa61300b0029910d831cbmr1029609pjq.12.1708722382330; Fri, 23 Feb 2024 13:06:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722382; cv=pass; d=google.com; s=arc-20160816; b=Bn1XZUBiE9KuiCdEHAL5OiiLdPYeD9pUg8PhlD66IxH7oHOqsW6VHvpEXwwcCRqxyy hyW1lDXGUAPeh36vFkJm1I+Y7tH4FkP7A5qMhB8BFmKB827N1JEBExDyxkD0NBGZaJpW l4K5IVp2H+nGkV5wCydXokauNLR+jpJHbj77tLiKD+DLSEYm9qthXgjmJzcEaNDjhWM3 p0EHv8JA3yZuCvgerawqHl1LHzp7Nz4Pnc4DaVXYPZ63XCf0Ey2FZDks0kS2FeIqfZ4j L2Ps/0CwfD7ccmi1o5LwdLXx88/MLv1vV2hkc8gB/Up1oH9rzJxu4bRZPPgD+5Rn2vmU u4BA== 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=C/esy7XtdM/Uq4jCB2UtvNoZm2r9dK5BL2ynsWoKYNM=; fh=SQ9IoN9XT5SzNEn0vmkGOQROLHvACckJVMrbnWKzstw=; b=aixsJQRL+s+DG1t/X5H4RtWmE/xQa1agaqA58h9xXi2/xuVRDfzmk3nz1KBUJEA1cB D4+nlgILVcXKGT7IrFwCdIwA/1d5AmLC7Cfm9MgDYVhCL8B3ZPfW+AJVP4T5EIJrKJSQ pjvs80wXl80nJiZFdBLKojXHD1DJ34vdJcYlGQBVzEziSR9wdtIYiAeEI8tJ0sca+MOU 1qHeDd/J9KtXkUMkHTvi31qKuqV71eHEkMf5QIeI7cGqHbWo31pcko62/eiGucJCetPk VvSNXmd+qDchDHbwocJp2mpN8YZimettp+tY0XuhYJkbJuUyftxEyEQb7+2P6FmUOQav Mxpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=PygFljCI; 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-79170-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79170-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id ee15-20020a17090afc4f00b00296f86d4ffbsi1772371pjb.90.2024.02.23.13.06.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:06:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79170-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=PygFljCI; 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-79170-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79170-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 A2CCCB23482 for ; Fri, 23 Feb 2024 21:05:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E507014F97C; Fri, 23 Feb 2024 21:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PygFljCI" 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 3BD9114F96B; Fri, 23 Feb 2024 21:02:44 +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=1708722167; cv=none; b=aQiFxH8EYVmfyYUrvsk3+YMzV89mUfIFjT8+YVFqsHBERd3OWqTyIIRdfTYfT456mZb0fQixBBHgMt2wOnBiy9zT83Ybrk7OiX117KxXb4wzyswu0kQIsmWUl+1bCTdGCIav6vwKD/Pd7H+2YWB0OT442eoCWLQTBbvoDlzd1zE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722167; c=relaxed/simple; bh=cg5+yosR/5Tn9ofG8K0XW7tcyBhYZ/r6xGlE4FO9pW0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=idVkAplsDEDSkx3xP9XECGJ+C1dSppHIvo1+4ci6MUnV9vNu0iZ0OwYpTuS0hyfC8/RSl1ETSm3J7CPtoGMzkWjtayYbGroxXwUCIcYY1ZbkdaNjyMzvLu1fKyF7jL+DZNcv8mDCtcfsrcBwTEhr3t73fMa4/+mGWeXGMB0IvnA= 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=PygFljCI; 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-a3ddc13bbb3so128093566b.0; Fri, 23 Feb 2024 13:02:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722163; x=1709326963; 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=C/esy7XtdM/Uq4jCB2UtvNoZm2r9dK5BL2ynsWoKYNM=; b=PygFljCIAIdWBWqEIo5BN83pbMUdhlZ/MrtC9VPicDsoUscmN1qeDI60KUllufCY52 XxVk20c4YETwwOFXbT69FjOeWSsU2BVHxmwnIU8Oi4j4nL1yl2LV7PZpXM85+P4ZPGTh La0kRxlHtLdxym82lGYC9FOz24yWRmk9uhk69W1YikubkyywUjY1ztAqaAMdYFAVJPwg IM0QOtG1KxsgDXA/sFPwjD94/ru5MH3SDwQgZZrmStHmsVtX0TA3Yb3PNS1SehKZos1l WzzgviUTg2BPg2xZxHJWrLvfAKiK1DeUmzSXiaiojOVPtclrVTLt/ACJQ477YZYcn3ez wpgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722163; x=1709326963; 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=C/esy7XtdM/Uq4jCB2UtvNoZm2r9dK5BL2ynsWoKYNM=; b=u2n6M7AfoWad8fD8h1iFgK5yR57TbfEiAMLjDOM6a94FLm5VfP/uGJ6FFA1lasRH39 UbQ0jwrAEt5t4DuCuEcuZa4zSkpmOBH6ggRIkwbKSpY3nTzzuBYqYkg7ErdjRX6NAapu oeDCJP20lzHAbUozAG8mNYxBSqWzqp+inSB5D7kPq5x+v9c7oNgvQuUg2myid1xCxry4 ApXpMnbiFZB1HeGo+Fm02f/k7/XhG7EAlkhJqU8J1tpBuF6GFyS5w5crs5Kb95WJVeTw hv8iI2fei10M1t5ZYfWPHLYoIuVd7w4YR0uF5i+f8tnppbOGfHlvQ6iOLvLAAJH9kPB4 i7zQ== X-Forwarded-Encrypted: i=1; AJvYcCUq5QJM8CtJ1kj9C9hlGusLX7K0jhxHW7Sb6/WhBWR1ahZgTiRNoZH8KRTAo4qfzqIhvOHkDeDJJBhWgXxFxcCBzCxQFRIY7GrJCaPr X-Gm-Message-State: AOJu0YwX7B9gKObAzHJDuvlXLrP6A3GgARX6zWAGRwYxpEJVsNhJRWcf rY14HV+mpx001lWiAeZNX4WjngxqE3WNpEorthwKrK3vhmKAAWZJXImLCPL45EI= X-Received: by 2002:a17:906:338b:b0:a41:36d2:f342 with SMTP id v11-20020a170906338b00b00a4136d2f342mr789187eja.31.1708722163059; Fri, 23 Feb 2024 13:02:43 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:42 -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 v5 11/16] net: dsa: tag_sja1105: refactor skb->dev assignment to dsa_tag_8021q_find_user() Date: Fri, 23 Feb 2024 22:00:41 +0100 Message-Id: <20240223210049.3197486-12-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725280529841117 X-GMAIL-MSGID: 1791725280529841117 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 --- v5: - resend only 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 Fri Feb 23 21:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp844140dyb; Fri, 23 Feb 2024 13:05:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXACawUaiHefZNlp/B65UChRpmAaLFlm27Ir+LSCK0cQwqSHQKPLH3S0eBR17xEvhVr1d9jjgHOyGKur8kmW7NJMfARsQ== X-Google-Smtp-Source: AGHT+IFRm2EgF7xne4w00wqu9vk1C9mjG9rNzN1gtayaC7q3LHWYYodUlYpSQYQUfIZaAHNtEd3G X-Received: by 2002:a17:90a:d712:b0:299:2240:43d with SMTP id y18-20020a17090ad71200b002992240043dmr836208pju.30.1708722332696; Fri, 23 Feb 2024 13:05:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722332; cv=pass; d=google.com; s=arc-20160816; b=JpLumKC2zY5NBWf3EvoXNoKta/ct7o/ev0BtIL3h/hOe0woG9Ky7LaW7pih+9Zv/Wp iWq7qVGavW2DRo7Qr7C4kog09NMf40ntGwKyw9L+KuJIQPSrkMWijHH4y0tbSD4Uv+Fc pKdbDLi3n8R9qDePV0Jdu5913Z2yza/sSeygx7231QczDoNTm1jMSrYGSGuJDVjQFQbk x7hRGrvKjCSfyUXFWfC0GdpycplOH5aV8YTewl5VGQKVkNReC9FqE3tcbCY43vvqhfIX ztQoPsBIQaIUq5Za0WiW2JjOdw+mPLhBETw7xKBQFREHEk75+ZnwaHxcZ3yXbNBgz9OU 4GAg== 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=CS69myIkjHM/Z9zwIn1rxkv4VNTb80UGHf3LfnDuhFs=; fh=pcKLZdomdsTNFQMfHzEfwXlLvCdbPI1fWmuoo4yBJB8=; b=IjipCa/pGm2qFeNPyUO+0SSRMoQReEgs/I8OShoKIiTI2IfyJGyvFoYbxfeeHKtrML y9OAgXD03pUr7KOkOvjQe7Yvo/usAAkqRXGQ0g28xLbarrizQk8Pzg3TKe8xpwhF4lDx WP4bQMN6OoAW1SCvn/SdOlJJHZDYFCFYv5L9vLCkDYG5XcPCfnOPzrtfkYw7diAG9zmb j/ngtw+aFJEkTEMcLv4+E6EZoKd28ApGgvsAaiLqGf8JaQAt93nhoVgWrtpXygeir9j5 luSMas+hxZ4rwaut/z5WH5GpFtteS9/zFUU6PJncAk+yQW+8UR05pougZBBqKccGcQ1t Bc6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=iAdqjQr7; 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-79171-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79171-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id me9-20020a17090b17c900b0029a890a03aasi973945pjb.44.2024.02.23.13.05.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:05:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79171-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=iAdqjQr7; 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-79171-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79171-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 D0DB8284493 for ; Fri, 23 Feb 2024 21:05:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC98814CAAA; Fri, 23 Feb 2024 21:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iAdqjQr7" 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 0249D14F97D; Fri, 23 Feb 2024 21:02:49 +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=1708722171; cv=none; b=kAMvTK8VMcM+lN42E1PS5uH+WHsDIwjyt6iquTogq/CTEtEyZBgoBLR6LZd0hcYdKsYCQBOVl0u5/pwko2gb/hdUT12cL0iGlH26p7FFsouEEjgS86v5dTd8D9Wi9Q41giiiOYLqnogOJhoEqfHOmFzRrml67G5oWGAMrNE6bnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722171; c=relaxed/simple; bh=8uvTSaExNf5N7PUZxerkiyfetwuQs19cLIADLSML+BY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eSjr/no+rRDrdzGUzkmI0q5746Wl0u6B4jPHZkGheA41SkfEB39VAH+5dp+93TNBcSNz+V8BnWlmrn0L4ppDrc7ouwShPB3e8HiWEKfXIGiZsK61BLIhuNhX52dX9IwozHA1kSJnl971vjNdkx/ckciDgInWJ2yTzQ9qr84u/PU= 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=iAdqjQr7; 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-a26fa294e56so213728066b.0; Fri, 23 Feb 2024 13:02:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722168; x=1709326968; 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=CS69myIkjHM/Z9zwIn1rxkv4VNTb80UGHf3LfnDuhFs=; b=iAdqjQr7QixbARClfSI9xuqFvxlbMTxFojdvK70s9BdsEX1rYdr6cbSd5PGjn1XkPr jEBjf33/Bp/kWDoaLyisjWaiYBe+9DQFKg+WLSo8uyftYoOs8aQfS2/wZc1kpjggwckM pZwkUiEzcp7jYX/di9EcdropASCs9YrG3qf8/bZ+MDKzzVeJZjlRlFB5T9WLiR63eH63 in6q4bVndCijabFWdGW6Sl7LRHTcLEnrx7aCW6pe0nwgTCs2VYnVkwQt1eeLKgNpVsFP 9iHnrgfx/BFpw8gwpCo7MXJ+CVeE+lLH8zGIUrnWCatbmmZeaAYQgHTYmED7+xO+FJzD KPpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722168; x=1709326968; 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=CS69myIkjHM/Z9zwIn1rxkv4VNTb80UGHf3LfnDuhFs=; b=NvLC05v8PGIn51MKcreYum2L1r6mx5PhESisPYYNNQqy2OTYH9nD0CfijCnFiIJBwc AJLkssDmbTNH/B3chmQBRjzWvnC6uUI97BxNChryflU2uu9MkgLGoKzHACn1tvYMx8VE oss4P0WxvScH1oeX3lFeNph82KVppj4GBjj6GVSTt7GbcTEKX3mrioSkHcITol2Iy3+Q Fma/JmOkzBJ4903jUx6IQ1+PRwf/m9IJZgmzwVK80SvE8hXP782lL7A93OpRYdKewUoa 3cPWlqgIdWJ4tmjOuAn4RSBpUcwkFTtCBg5AOtrWcZwXF645WU9qlOsT0+OHlkTBR+9N 35qg== X-Forwarded-Encrypted: i=1; AJvYcCX0ml8QEdRDYwMOGKBCVvcoLgHZIWfP8xxyp/lHNCyO2v9U41LIrmHLQ7/+Te0twpdZRM1hMJJfl5JTarkCG3nM9S18uw5vwWKQRDMv X-Gm-Message-State: AOJu0YyNL4FyIFFRG994iTdJ3IYVHxZZVI5IpOGs0RRnIew7tNZXlqug iSzBzJLm+apLRch/sNIzGrOmud6mgTmNKLSTHIAlyH5N3kY4IWQ0nO4tRIfWSvQ= X-Received: by 2002:a17:906:a850:b0:a3e:980c:699d with SMTP id dx16-20020a170906a85000b00a3e980c699dmr631390ejb.57.1708722168076; Fri, 23 Feb 2024 13:02:48 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:47 -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 v5 12/16] net: dsa: vsc73xx: introduce tag 8021q for vsc73xx Date: Fri, 23 Feb 2024 22:00:42 +0100 Message-Id: <20240223210049.3197486-13-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725229159127691 X-GMAIL-MSGID: 1791725229159127691 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 --- v5: - removed skb_vlan_tag_present(skb) checking - use 80 characters per line limit 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 | 66 +++++++++++++++++++++++++++++++++++++ 4 files changed, 75 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..3197c2f0d472 --- /dev/null +++ b/net/dsa/tag_vsc73xx_8021q.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* Copyright (C) 2024 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; + + dsa_8021q_rcv(skb, &src_port, &switch_id, &vbid, &vid); + + 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 Fri Feb 23 21:00:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp844317dyb; Fri, 23 Feb 2024 13:05:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVMpMv2vNNG4ratFh845NHOqwApaej4/gtmoaKUYk/riLvl2xKxLguxcBekXwNLqlI5uF3WphU1XpZTFBCVzyqZlHx9+g== X-Google-Smtp-Source: AGHT+IFi+7IZi0ljtetcYlNrtYef3apoPLy3HjwfEVOBZATr3uvyI6CMRlcl20Y7qKHMz4UQRO3k X-Received: by 2002:a17:906:603:b0:a3e:fc79:c92b with SMTP id s3-20020a170906060300b00a3efc79c92bmr649949ejb.31.1708722349369; Fri, 23 Feb 2024 13:05:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722349; cv=pass; d=google.com; s=arc-20160816; b=x/BvDegSTUQxnHMoRZIRIwyHF4j/A+g6ZxzA2NYDbV19lcUYjfW08H8LNBpX9rOENq EH2MvkD+39np9wsOw2jTvf4HLO8MIoqMKqcXS9qiZzthX/sZmPgRMghRgobqf3RraK7C mK49k2MDut0TY7IoBn8e3qUeTq/SFFbt4wPyv+6WrYnaZf+D4Vz/2TO/ySEDay30zPCI xJBlExuBXDURUQ0A3mcb5y6M7JFukqafSjE2dFBomwDvLOX1RUTqgrMmy5kr1hn0qJ87 deZ5/D6qrqHE4zp+GsmpCb69c5H5lyNIGAjkz2thzEscx29XLIrOwGRTfPCu8MGNCiuB zW/A== 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=nFS2hcwK9/ZRU15faSWV/LrndwlGzgKuFOE0N4Cou2w=; fh=23tYfXdAU5Zfka5Hp8A/PA1L9sEZFaodAPxnXFvSoqg=; b=qgbZpgwt2b3ngh7nTQbNoXqStiri3pclS7+ASr0BBCK6g/3kBeU+pVQQ37cC5PqWol Q/9MCsf7t0/FzgunO5W9lS51hJPQobIKf6KDjXFCEe2f0zS13pI864CbTakxwifN18vk q8/jtNxqwOcC4hJLubmNw179/MKIR5Y4s+9rN+cG2rsE6mPwZzoZTn+e+U/F3XR/MKx4 4Dw6AE252ptxvxAiXipAHgS+1dihDIqehPRc/r+ocVLAfhLKHa6vVAY6S8zIJA9QJ1gE HU5w90Ue/6YYfYZRo8niwiyiNNqUWKnXBK/b1LmEeGumr+ZZDhBPYSxPVVUtEgPG/itB mHoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c0l1tv5b; 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-79172-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79172-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ov1-20020a170906fc0100b00a3f80a348aesi1768644ejb.119.2024.02.23.13.05.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:05:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79172-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c0l1tv5b; 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-79172-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79172-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 CB6431F2648A for ; Fri, 23 Feb 2024 21:05:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 59324151CF9; Fri, 23 Feb 2024 21:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c0l1tv5b" 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 7B3F714F99E; Fri, 23 Feb 2024 21:02:55 +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=1708722177; cv=none; b=WQmKl6QAitV1aUolPnRsMSUoAAbIcdH5+PsevGKSGVGd3XTmbglK0ktjuNbQOlJGf3kRSiX4UwHWNMQlRdkqVXbBsWLkAhCV+2hJOBkqiacBJbXUhaK0WO2h0qpiiOkal076TwioMeiqtQhP0050NiiwwUNYuFdgcMkyLwwdpa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722177; c=relaxed/simple; bh=wqknE9u4+0m61qZz7WSBRU/y1adl1GpWbvzVjWqRpQs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=R+uFE5njIAdNINaKhDHZglK+bvDyfG/+bXIauPVJ8ER8eifXDdzA0BQaNVo0Pbbte5sPj6xGv6XUP4bLj0vIE/cbiNI/flgodlrAUHiDFVuWsJNzsMEi2Fpx754IB7/9vqnDLW3YEI9glcLWhTFy/RgxzEnIHtelmurs0yh3mE4= 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=c0l1tv5b; 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-564e4df00f3so1563852a12.3; Fri, 23 Feb 2024 13:02:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722173; x=1709326973; 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=nFS2hcwK9/ZRU15faSWV/LrndwlGzgKuFOE0N4Cou2w=; b=c0l1tv5bp6t0Mlqw6p2pCwUVvnCvmZAhdpDM3SAc0/EHlGac/1GOOEpVgZevB1JCke oadC0TY1zhV19uq2/bXLeNdmHuO3W+32RygkzaZtIyzLbhSKHhPujz8K+9PbeVLaKSFE jpquO3ijaysec/dJb0SKR4TsQ6rzCEPSE0Uing/gtNMlo6RRj5lEDjE4hlnDMFw1/gmy JEoXRSvZaj1azb9i/hhqzqh90B/eVYgguVuKDPNkJd1c4gh7sE0aRpnO8tIa7HlN/+Ft wdXFTltT+Li9c6S7uNMlGyGaZ6OA7egDcCRLJ4NSjJ7x40kpWNkplcy9ngw+EVWObku7 DxsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722173; x=1709326973; 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=nFS2hcwK9/ZRU15faSWV/LrndwlGzgKuFOE0N4Cou2w=; b=onfer8bLbFpIlZzajkZYbPiZ6WalFeMBrWNJDz7n76WfVtvgU/+8zqLYKCVcn+MoZF JQse+BnaL+ftTwPDWmIJKYQq9jcqepFDbF56EDerg+i3VIXr2uzBaJpwJ3HSzRulYKZT CRPDCLol/HhPMniv6mXPyZz48u/iZjbOnoVMoqyxX4wqhzXSTOdgMzclqXeO/V4uUA9b /QIdNlZYOqIhfNlglrG5hwUBU7+lF2X6LOoTfbU//t8efuYIxvJLQF88A1SKjTtopfqy oLhv0GjsZ9D+5z9bKhrUqjNgeGyIWdqlTlZgLMRWbaTnqNXsyp0D/bdmUE3bimwjQdXQ zttA== X-Forwarded-Encrypted: i=1; AJvYcCXxNxiFs8B13lfbboBrv7jGF4HKRuyFG767uq404ssSIyiQAd5WZ1ZMGgLwhr3UTF2TG4v6V2wHhXNrcDIutE3z+hW0aFquTUAmGyBW X-Gm-Message-State: AOJu0YyChmwwwMbUnUXsBBymisveoRQ8gkXA7fFgruTpguhqUkr0WXYs eHgQOZqEP+bIqflYBnmIr+ykOfUaBAOpPEv1MHb+uWhwJKRFacVnXL5762FMQ58= X-Received: by 2002:a17:906:6855:b0:a42:1347:17c0 with SMTP id a21-20020a170906685500b00a42134717c0mr376499ejs.50.1708722173289; Fri, 23 Feb 2024 13:02:53 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:53 -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 v5 13/16] net: dsa: vsc73xx: Implement the tag_8021q VLAN operations Date: Fri, 23 Feb 2024 22:00:43 +0100 Message-Id: <20240223210049.3197486-14-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725246147313445 X-GMAIL-MSGID: 1791725246147313445 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. Signed-off-by: Pawel Dembicki --- v5: - improve commit message 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 | 39 ++++++++++++++++++++++++-- 2 files changed, 38 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 87ad8b78f141..1132a86538a3 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -592,7 +592,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) @@ -683,7 +683,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"); @@ -752,6 +752,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); @@ -1554,6 +1560,33 @@ 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; @@ -1695,6 +1728,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 Fri Feb 23 21:00:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205688 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp844442dyb; Fri, 23 Feb 2024 13:06:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJXuX3vK9AWHN0m72/H21XGf2NuNVSCTeW0wWXcIHgwa02byfqew51WCChCMB2ZVZ+MyNzumxo+H3wD4ybuJZ7+NroQw== X-Google-Smtp-Source: AGHT+IGEzCPFseerAQiJvTdqJfN+uN70q34LjmEQlDhK7sWc5m+PTDEptpjxdZ5s+82Y+2UYGFjV X-Received: by 2002:a05:6a20:5d81:b0:1a0:ce38:34d5 with SMTP id km1-20020a056a205d8100b001a0ce3834d5mr894395pzb.61.1708722365752; Fri, 23 Feb 2024 13:06:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722365; cv=pass; d=google.com; s=arc-20160816; b=lDhzeN3sJsxQSJhJdDRWI5ZdnSdNirB6XP7f8E0nLRSKUgcG9QISZw3yqEK1vqNU2E thceCxbSfSiP+RFVg/hHdMR2tH71N1dFQwFRTl+NfhGvFp+GlEi0wPjgoGz2CymR8Rpq EiYk+szRQIqcGB2FmJE9ts3wVYb0iVj2kBLN9TCUz3XC/6HbqDdcuIBa5r8GinWWb0HS OslmI95xhjg1G3wWGe1lkCh4BqafvrMlFVw0nz858uLC/4QyP5UYvqo6oWW6l1Cv+YvO vYrrFPiWCdui6anORAcCmV5axXP7LbRouAXl/+fDJ2ChbpCCd2IlMuCwQzcoNviJMLnn lQ1w== 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=tztr1+TqGO5v+hvzGEs9lKsceCvS2t24CDtG8/HmH0c=; fh=NOpM/DR146n/TO8HWhLEawJNmVa3gJ8E/DFpd55DaJI=; b=1AyfbkfbysATwNH0BAvAIvHUNVYEqCjZ8yHQxwE8XD1MADYfp5SiZmCKVAHV71+AY1 Tou6nXHMLSU0Ayxi9JLKL3dkLNz0JnFHarDG24XXfjsfpMeMU6/i+hwX0+5Hz02Ojjj9 HGoZRbKF24mG1cy/kW5B4V43eOMajjRYJZi22xtLgkmMjFE3f3zrdZoImxLtjU/VXLPd ZtMl7vbHrZkOP7ixGfn1Cq317Yz/I+oJoaQo7L8jLmdqaPGWUv3ZX5Z91Wr8jPp+jL4D l1YmJzB/QqnxZy8Rrpg+Cn0Pi5teGOHWdzxjgTt22EhELcYz86uo45dW3MHt0IBNjhlv B2Bg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=G0uYtcE7; 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-79173-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79173-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g4-20020a056a000b8400b006e3fce37039si11203668pfj.351.2024.02.23.13.06.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:06:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79173-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=G0uYtcE7; 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-79173-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79173-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 89C47282D37 for ; Fri, 23 Feb 2024 21:06:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A91AF153BEA; Fri, 23 Feb 2024 21:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G0uYtcE7" 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 5F111152DE9; Fri, 23 Feb 2024 21:03:00 +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=1708722182; cv=none; b=Fsw7kWamShKZgg14CWaRpxRnK5RksncYAaiJDHz5F6jh6FKX+1AVal5RFjBhnvcsxetrXah59KTM5AGJ4y64+txRnaCZJXV59mzFWyxRsEBIl0XC+V+p2MfLxmR+h1wDxJXsvs2riHx8CBDSEllo2lQkzsEY1IcVCq1b6553TjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722182; c=relaxed/simple; bh=NbST3xiq/8f/mXsRyb+dmsw+eV52rzAmQa09GQXYbtQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rFshRgLy63wq5ZsqpP8xgC/w7Jae7oTZgW/MPEpHD8jP8M7Iu1SG86OZDZz36fBwcL0dT6Lx6pVjpkb7PDc4+G8hkgN5DBj4RniHIsqONXX1PwDLQS5Bzbe9Pj/Dcq2KZWewYUlTN+KimvqL0HPJQBba0mCCw1UJIC4669MQY+M= 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=G0uYtcE7; 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-a2f22bfb4e6so126469666b.0; Fri, 23 Feb 2024 13:03:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722178; x=1709326978; 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=tztr1+TqGO5v+hvzGEs9lKsceCvS2t24CDtG8/HmH0c=; b=G0uYtcE7St9lo9QEdODm242GVehp9ba4gi5Zb8XNTXlyiD3/CYIheGkA3uCU5vX/xU tnGGWxB+uHj/f0JOQX5zfFdEjmX63MrnTFue23HzvrREsFjPTWDQCZ9+vEd/EASixfzM AcCdtZoIACuMGQvlXHRjk6BJpcTd/jolEXQ/m7JAJ7SlCXWj6sdqaG0IIt6gZ+2FGTJw 8klSFDfb74a5OSCaeUVuUr+GxC/SnPIns7Myi1lnteOcZKrymbWqWknxCyvmqQCNj8y8 kWYoxv5b4rX09CxU4BsYCc3OjanZgfOk3qua0UPWCBZnx4+0F2NSz/1rFBVhdsks31G/ a+fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722178; x=1709326978; 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=tztr1+TqGO5v+hvzGEs9lKsceCvS2t24CDtG8/HmH0c=; b=WCnSHEeVRaEJl8uWPyUq16PkL1LsYHebnPAsX6OTfHu6C0aAzbVdZ0G/iTrfPX9Scr qR841/Rd4lGbPW0hZdcOT2YGO2+2PUxVd8H7apgWObztCcssB1kMM5hQAqEPU44VApPp R7pBSE8pvKvwq+4nH3HT8mDAyIFID3LGZ3YO9sTvq2DmEH2Sj74emYvgo9ORrgw8OCDQ AGdEn01y+I+JMyydF9MSj/rNbkH2q5DSOlqZOwlXx6g52IjPRQsrMSRLPevRZMJhAoFu 5osk3br//i+FMHbgjbPeg/MCngAEhW3r0fQYLnEv+huA+onVoDXYDeTG3HKO0SbjkizZ ZdYQ== X-Forwarded-Encrypted: i=1; AJvYcCVaJy6kWwYzN2uTiyAJVtbN8PENs9qGkCwFtqLOSVIciRVFLJWSTU4zLIf26MMkeOtDRIDrMfpJT4dNKUH+d/hfJBOcrRfZunJRKRca X-Gm-Message-State: AOJu0Yw7hK0daIDejxgqgyT7iHOG5KqXHxOhzuU9RYF1bBlVbJg5N49/ h92BvlbnUu0zoOlJKsQxQv36kvoN3mZMKXpLSWz7bslDOJ+1etksyOZFq0HLOiI= X-Received: by 2002:a17:907:20b9:b0:a3e:6aae:d342 with SMTP id pw25-20020a17090720b900b00a3e6aaed342mr641518ejb.47.1708722178402; Fri, 23 Feb 2024 13:02:58 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:02:58 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: linus.walleij@linaro.org, Pawel Dembicki , Vladimir Oltean , Florian Fainelli , 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 v5 14/16] net: dsa: Define max num of bridges in tag8021q implementation Date: Fri, 23 Feb 2024 22:00:44 +0100 Message-Id: <20240223210049.3197486-15-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725263499566939 X-GMAIL-MSGID: 1791725263499566939 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 --- v5: - added 'Reviewed-by' only 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); From patchwork Fri Feb 23 21:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 205690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp844612dyb; Fri, 23 Feb 2024 13:06:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW33P71FS7PnobArgQPtRg/IeRwUuXZvi+eng+Cm58ZyRPFtj9URAONlwjhZk1si6A08b79JEj+JxHHdjeCrBT+o1CekQ== X-Google-Smtp-Source: AGHT+IFbn4xiXEHaEw84/A4JWVt3CJP+4vmYeQZHAotK8k7eNaIUuEwMpDRm2go1Qvc0F2JENqmx X-Received: by 2002:a05:6a21:9186:b0:1a0:901f:f64f with SMTP id tp6-20020a056a21918600b001a0901ff64fmr1018217pzb.28.1708722384215; Fri, 23 Feb 2024 13:06:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708722384; cv=pass; d=google.com; s=arc-20160816; b=W15QZuUK5I9cA00RVMdxTvosvZwxhnWeozgB12GDKZMsb2f3lFjwViyWL0M/+MADVn vmZGneFMn6DBIV9dB+cf5wjDHTHfZ2nKxzbTbcPBcxmmFrxDo7qCrtet9OUL6ah6YznB Xj1PFEVeTCR2yDn0gIrBl/45CjUpWrYtTU6B/gHwaqL26dcs3ronJQz2IbMNyna9QqRT niYkzBAXoGJ7goQJM3u8yPxg56OeL+Lcq9/pmy3ECcHO8YHjtk4NlBrL2sCBSF72G8wr iLK1UOsuh8ebZ16VgYldSzU+Y5OFKJaLWXBhNbu7+j1E8Nrw6rSCowXwjw/hQ5oO7S7t RkhA== 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=CsgqUU+5bw6FiOn7ZlwWk12GQwooTmRMzEUA6afssIg=; fh=Rbl2WgLHw7bTGX4xpkN6FQkjwtnhHMHkX3lIbYtjgxM=; b=g6auHA7WlhdlArZwlzVXjnwrBMlAYWcZrhXiYd24spPlWRVARUTHlqYWJcdyzzFfpR kZI2mGRF2v8D4TAaYe6+WIy0KKk0XzRSqSqzpvq5uuy+JOgdqDci6IcsDecszJPPbdXi C4cxlrux0Ut8oqk9tdTEukH4eJtx8UTee6f4WEGPleQSv2YmyyJXj4bilJWhoUSSJW9W nKH2KJfXjCdfEKStVi9scj8JGaTnAHShjuIIFZL0GevKf7G/qifGpI6MEZKpPym87agq 9or5fVCj/JLYPmkr8XiZtwNBhrxEl5vZG2TM+5XEMp4oOv5UCBO9jTs7pOu6/H7jdiPl 4I/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=g4DjGv+m; 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-79174-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79174-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w2-20020a056a0014c200b006e4642ac55csi10023514pfu.93.2024.02.23.13.06.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:06:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79174-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=g4DjGv+m; 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-79174-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79174-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 0965028493F for ; Fri, 23 Feb 2024 21:06:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3066F155A55; Fri, 23 Feb 2024 21:03:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g4DjGv+m" Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.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 B859514939E; Fri, 23 Feb 2024 21:03:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722188; cv=none; b=P447Cq64vuYL2agoJSGtqL9C/2485/Krv5qCUSTO22JnJSesHksusPQXGYmgd/PgY43OakvU62kXUxAPJId5ZeHxlLBDM3pJMjhbA+uSAWIfn56rL+aZ2rVfVq4ZJDDpEcr1X28UWripa3NhL0NahOwtI0UN2D0y8DLatlb+5RQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708722188; c=relaxed/simple; bh=zxFuSdqwAGFS78xhXJ+6ExlfTO7DkUchW5bvMLNLJ+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RktHnUm2BH6hG8WasWpWJC1RA9DGzDOqlxaAdeLYsPil+Mm4bCbIPUbW0/E+5amRzEpjgaYD52P2I70iZMBCByphTf+PczoPPAUoa49VWSBeq5C9ctKZ501sVTPXKopp1Ax5nxPCkUef7Os/l0k5Np04nT5XX3VxVPAitn9ttV8= 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=g4DjGv+m; arc=none smtp.client-ip=209.85.167.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-lf1-f41.google.com with SMTP id 2adb3069b0e04-512ab55fde6so1070090e87.2; Fri, 23 Feb 2024 13:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708722185; x=1709326985; 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=CsgqUU+5bw6FiOn7ZlwWk12GQwooTmRMzEUA6afssIg=; b=g4DjGv+mj114mgehuOiE327nRVIHyPZD12UNw5jv5s0l8nzPFfFmn71gceighoIMg8 gJbTdUdzdLLMx7B9CQq0ZK8gU7rxVyqSybThf1d4yDPPiXzHTOSGSkfAFT2XPuZMPuR5 xE1xlQMaM183O4O5c9c8hL7UjLOdUWCR0owKIR/RIXkUG1v33LaOmLlMHVPqVN+7iVOA UP1ngFKBjbvttHgiX/8NAevP4kmn+YcZc2OP3RwYd2zrD6regxutCZ5ABkA/aagtg3P9 AsA2pBksVUEbSvv0etBjU74xui56BM1sIKP+4UTsXIi0WjI3//HA+Ac4R/s9aZlDxeJF WUnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708722185; x=1709326985; 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=CsgqUU+5bw6FiOn7ZlwWk12GQwooTmRMzEUA6afssIg=; b=SxHUkwVW9wUmsGubEd0xvEs5QX8dqf81apxcATpjtAm0s8p73bwI8+wca8+o22dYMV UdTyLIGtj1XAicUCBjm2PCp5bTmiXK9ziuGaG+V2wbZza3G8qwMWgwDtlFTNgMU8+wyx +Rm4UjpyhmiQrsyKi+yVTxEwwFc3nTbAXP9GYu70S+xyogoE72ka5cJaXAoeQ4oz1DRX dE9MceneSJ95ado1nO269I4WJZCKNRdQrQH53vgqeYopx7avTmtQYFvRaH6SYsmScINQ dhrE9I73Bfc+bdNZETnm5gYKCavRxNrwkymoCDd2aX2K9ErEv3Qjr0x9Ucz921Mrw01R OPBA== X-Forwarded-Encrypted: i=1; AJvYcCVfYY+ZbX5vVc0iSibu/WFE82dJ4Uqrb7DD478Nnyqwm3GTvWTHIGoe/qC5Fn6TSRara5SoEsYKytVOdtvglZIXPj2OOwrD8E5IQI2B X-Gm-Message-State: AOJu0Yx47WW5Dl/hALRZp69MQEToaw+oHjANbjPKS4oZnBb2NMOSrPfc c4V4V16EvIH86KjkUBL4ql5PT1mTwcGdKXwiFD3+sAx1fOrcHOtzBB2bCFr8x4w= X-Received: by 2002:a05:6512:324a:b0:512:d689:51cb with SMTP id c10-20020a056512324a00b00512d68951cbmr499841lfr.26.1708722184723; Fri, 23 Feb 2024 13:03:04 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id st11-20020a170907c08b00b00a3e559aaff9sm6185424ejc.29.2024.02.23.13.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:03:04 -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 v5 15/16] net: dsa: vsc73xx: Add bridge support Date: Fri, 23 Feb 2024 22:00:45 +0100 Message-Id: <20240223210049.3197486-16-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240223210049.3197486-1-paweldembicki@gmail.com> References: <20240223210049.3197486-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: 1791725282532595284 X-GMAIL-MSGID: 1791725282532595284 This patch adds bridge support for vsc73xx driver. It introduce two functions for port_bridge_join and vsc73xx_port_bridge_leave handling. Those functions implement forwarding adjust and use dsa_tag_8021q_bridge_* api for adjust VLAN configuration. Reviewed-by: Linus Walleij Signed-off-by: Pawel Dembicki Reviewed-by: Vladimir Oltean --- v5: - added 'Reviewed-by' only v4: - remove forward configuration after stp patch refactoring - implement new define with max num of bridges for tag8021q devices v3: - All vlan commits was reworked - move VLAN_AWR and VLAN_DBLAWR to port setup in other commit - drop vlan table upgrade v2: - no changes done drivers/net/dsa/vitesse-vsc73xx-core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index 1132a86538a3..8dc366461b9c 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -687,6 +687,9 @@ static int vsc73xx_setup(struct dsa_switch *ds) dev_info(vsc->dev, "set up the switch\n"); + ds->untag_bridge_pvid = true; + ds->max_num_bridges = DSA_TAG_8021Q_MAX_NUM_BRIDGES; + /* Issue RESET */ vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GLORESET, VSC73XX_GLORESET_MASTER_RESET); @@ -1587,6 +1590,22 @@ static int vsc73xx_tag_8021q_vlan_del(struct dsa_switch *ds, int port, u16 vid) return vsc73xx_update_vlan_table(vsc, port, vid, false); } +static int vsc73xx_port_bridge_join(struct dsa_switch *ds, int port, + struct dsa_bridge bridge, + bool *tx_fwd_offload, + struct netlink_ext_ack *extack) +{ + *tx_fwd_offload = true; + + return dsa_tag_8021q_bridge_join(ds, port, bridge); +} + +static void vsc73xx_port_bridge_leave(struct dsa_switch *ds, int port, + struct dsa_bridge bridge) +{ + dsa_tag_8021q_bridge_leave(ds, port, bridge); +} + static int vsc73xx_port_setup(struct dsa_switch *ds, int port) { struct vsc73xx *vsc = ds->priv; @@ -1721,6 +1740,8 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .port_setup = vsc73xx_port_setup, .port_enable = vsc73xx_port_enable, .port_disable = vsc73xx_port_disable, + .port_bridge_join = vsc73xx_port_bridge_join, + .port_bridge_leave = vsc73xx_port_bridge_leave, .port_change_mtu = vsc73xx_change_mtu, .port_max_mtu = vsc73xx_get_max_mtu, .port_stp_state_set = vsc73xx_port_stp_state_set,