From patchwork Fri Mar 1 22:16:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp186897dyc; Fri, 1 Mar 2024 14:18:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV//mGoaMn/BHklni9wvwjmkR2Tjbdr7SA1XNbxOspHKok7CLv7TwdawOu4Jp9JqT4N+d8sgLbmuhOvgpBUEAfOwgqAIw== X-Google-Smtp-Source: AGHT+IFXs/3rNjdF4sq281Fc+SjbeUZMDGX8NFacaDAWQo3PmFh6MRUzWFr/TOtWoOY6avRIlQmn X-Received: by 2002:a05:6402:2267:b0:566:bf36:60d4 with SMTP id du7-20020a056402226700b00566bf3660d4mr2315905edb.35.1709331489614; Fri, 01 Mar 2024 14:18:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331489; cv=pass; d=google.com; s=arc-20160816; b=VADXUI8dpYfnGd2nxe0/MBD+Gm3+quftqNMdNVMJWR/uRNrDPPJyfueprOo91Y/dJD G8OzYOTr5Bg2yyW1QRKeEXuCPeErZgwWWqgRmONS2MecqJwuJwt4aUpWoN0an5pT5VMJ Zso/v4H3O6ZWE7OBj0Tdvk5Tx5xdFimdtdKlxBnCk45E6AYtXumvhCYXHPRkq3WOw+qb 6sanSYPke6MQpSoszThlBrGUd++xeIlrQq2dyvcltvY0gvazdNCwWPNtaxBFOjGJdq30 p9UMJ+sjiwYbxHMxTkdG+5M0udqAJoCslnOcG4Giaj6n71ZmmiCUGGCtHVEl5dsImIwo QfKA== 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=Dqe39XKaGE46c6cFjGmEYyL944xkhI+5L3MWmcenajs=; fh=lY5ALUgdAk9nHW2MQkj6oRTqbAI/0NWw6WiuJHKbwLo=; b=O9gvgvo7ahUNV+ob7uKrh3DHwtdK54lltvU6gwp2ZNBr6MW5x/Aql2hHTGmD4Sz7EM 7kxdAfeKmfgbSPx+2JKCCv4W4OrHkq9Av8M79Njj8IXJLbfA+Bfauz2/aKaFmMieBKuX 2EWbOwW8f8C8IV7hLDkDACaYqIvlEbR9dYinpUuFhwf8utwT7Gk4Pe3/aEW6Wasj1SHq c1XleB9mhBIARzsX+adrQGbE6LXv1UQP+oScOl+qQa3Mgn5yWaZIAK/1GnzZxaKx2WXG d/VNlwNpkLHtmLQLV4g5FH6eB9vWANsIcteA4iYISPwbPHTXLo4vgGWkSLAPCjNlp+OC HEIw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nYBkTV71; 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-89176-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89176-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 s24-20020a508d18000000b00566d27b66b2si868948eds.633.2024.03.01.14.18.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89176-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=nYBkTV71; 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-89176-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89176-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 1304F1F232BA for ; Fri, 1 Mar 2024 22:18:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F9125A102; Fri, 1 Mar 2024 22:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nYBkTV71" 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 940F859B52; Fri, 1 Mar 2024 22:17:32 +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=1709331454; cv=none; b=HZPZt4JvsYRyM1xX+/7YhiL0D/mTgMnVuTVgDSO9xv+oQrzUKnL3NSylNL+WzoaXHfP3/L+crUz0zwegDrUWMX04DiGh051phdI2YKDSoSSt+J02W5Zqx9yL8m8QvYZSLZHvOJ3W4W4TFeiE6X5j0zuF3XhJiwsJq7SAmEHEue4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331454; c=relaxed/simple; bh=ZwzIRjxKo4W2uHrdDhdnCy++0skBBDr3Vzf96PWE78g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WtrgSQMTuvSDK+xntLBrE27fat3sgdu0Iz6A5gVYnd1SzfLU1i4kTtQWhN02n3YDVesL/G98qeVjjhffynncx8ap2Wqa170T+YctKu1kpuDluffJcMNZ0tEvkWAWbTt0GzwYOQjB3FQvys0dF0c+2dFwDgeM/IhVWJ7uGvh5C2Y= 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=nYBkTV71; 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-563d56ee65cso4331933a12.2; Fri, 01 Mar 2024 14:17:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331450; x=1709936250; 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=Dqe39XKaGE46c6cFjGmEYyL944xkhI+5L3MWmcenajs=; b=nYBkTV71Q/xwc1U2RCt8IFi44aTLECFpL6F8AeGdjE75kD1YwPSQPlCC3wCsSVkgWn 4jaAN1M2i8OhxwVTxDdqo6n8pkIvn7uJTW0DWxmPfOApZuJgbwDbb1A29PcUz3C6Wl08 phJJjaQ9Y3zdpwy5CfdJIMUPxZ/GDCa+S2auHzmnYJOnMyETSZUNu+8YwYU0hWNxVjvZ BVJsRmnueK4WZpyq0c6xIWZxpbj+U7IcXbaPx2V6LKoPCsQdINp9ju7CNL/mUXZPNEPE d5Xm/VCFQrudKmwUcggOBBV1pq1lV2t87jzmMLG1LfgjuN+JLX2LZcWQGrBPNuS1QSt7 2AbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331450; x=1709936250; 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=Dqe39XKaGE46c6cFjGmEYyL944xkhI+5L3MWmcenajs=; b=o0/bx6mphJw6Oybiv38U20DdSSfEBnbm/wgdMBCOGz9atYmhz+lp7De75IBvmdO2dI iYZKDFYmMgyWmRei91v6b+kWZXEuue7PbR4/wuAI+0NG7BAxCX/zw1M9MI9ROanpG9k0 bJYn7+4uFpcLRkJ6kzzdjrhHcwrfm1pjGJ9pILTm/gvp/aC1TM9R8uuO8ZnSTGfWVYiX vjoiJUbN/v4VcjwX5GevWxskS/Htt9iOEVXzU336U8gApNVi66DbEWhjIEdC5jn8qGEY rJQFSbJXMqOaAoPa1A2Monr5+S+elNFjVDCNmg3wTbTEZ24sNxvB5YI/o7Iod0dHVl/z W25w== X-Forwarded-Encrypted: i=1; AJvYcCWeRGS4zaqOzLkTO6tNDP7JGkDMqMEbeOgmLBpr2zzdX1j3B194IMBhNKYJvMuS5U2wsqW2SxMIwXrAS0SHCiA0DYYwjJSN2qEugxTg X-Gm-Message-State: AOJu0YxDvQm9W3YV6f+/X8yqxBqvXEMcaRpNYJ3Ktno43w96tAlWHfIU gRHX5QqIJvq9JiokMed0QlelB2fhD/fXZG8zzfMLv0diSuTimO8C0SblIwddz1s= X-Received: by 2002:a17:906:ad85:b0:a44:9a2f:dabb with SMTP id la5-20020a170906ad8500b00a449a2fdabbmr1799076ejb.20.1709331450464; Fri, 01 Mar 2024 14:17:30 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:17:30 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 01/16] net: dsa: vsc73xx: use read_poll_timeout instead delay loop Date: Fri, 1 Mar 2024 23:16:23 +0100 Message-Id: <20240301221641.159542-2-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792363975742217675 X-GMAIL-MSGID: 1792363975742217675 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 --- v6: - resend only 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 Mar 1 22:16:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209106 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp187857dyc; Fri, 1 Mar 2024 14:20:26 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWQDGQ6ft3y6gLTArf6+QuItC3Ny0GK0eB4k2YyLpj5azmrLwSePzA+a7wPCiNqlsLuUtRDiN/q8N1/YFwivAOJnEvVPg== X-Google-Smtp-Source: AGHT+IEKDbbnkWjQ+H5AR22ZYRCA8mnpowUC82ySDfCqxGER4UYGbogIZPnDe5ZVPhidvNrkhEvp X-Received: by 2002:a05:6e02:1c2f:b0:363:bcae:f77f with SMTP id m15-20020a056e021c2f00b00363bcaef77fmr3371937ilh.0.1709331626105; Fri, 01 Mar 2024 14:20:26 -0800 (PST) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x7-20020a056a00270700b006e57271c4a9si4118846pfv.33.2024.03.01.14.20.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:20:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89177-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=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=EHd4K+lk; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-89177-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89177-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (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 A1808B2682E for ; Fri, 1 Mar 2024 22:18:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F04DC5A4E5; Fri, 1 Mar 2024 22:17:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EHd4K+lk" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 A4BC55A0F7; Fri, 1 Mar 2024 22:17:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331458; cv=none; b=LVSBenjhE/FV2Sb8iTAU7v8G9xzHHidnEOb7HhBZKdCWKqkm+pdDtCWFuJ5FV36hpYOp9+5ubS+jtNbUwC7SHBj/y3Fko2ymcmLohZfwOw0K43fj6/UEUtmOrruJdDnqJYzJ4OlYr6noFhuGgX4kL+Zp9/A6LXxUaq4ZcCOqhsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331458; c=relaxed/simple; bh=AUT3d98BN36iVpQBCLQndItQ97wTCDJ9Sn2fjVqS50g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X0Xxvfbnzaa5ahd4M7Ec8JgpqW1bIPC0DI7HnLz7njfW8lXPkcHmu8VNTqzWLoPJKVJmWUaDv7azllDA2aOZcfJ6MqJKQvpGYVpBsy1f5HtBduTbKNI+xKM1/iTw5xTcoAHqsZ7EtLSW+L/GaO3WXyA5CRdn+ask5ljcOyz6lcY= 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=EHd4K+lk; arc=none smtp.client-ip=209.85.218.46 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-f46.google.com with SMTP id a640c23a62f3a-a4429c556efso428709366b.0; Fri, 01 Mar 2024 14:17:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331454; x=1709936254; 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=esyWdk7pK43NcDbXyKWe3ASdlab0DBbFS/CLGYhdRr8=; b=EHd4K+lkNWpx//aWqrEoTK17EeX7E4iZYK0A7UZM8crD5gn9AAT5hD+lJeeAxPBgNn xDAp2yg9dWRoQ7tcxPJTtoKghtF+3PpLRrnLrZN7PMMmjC2XC+7pGLJp899VQ5fbtvG+ iZrJFllIlXbE8NJhqI6EhX6GEo0OmrdB18DgN07Anrf5jYOBQxe/fydIYCDhQgCUhzzY QlOtHLyU2sWKWH58inKoIAUL96pfwPQjx63NXVnwY0OiteMwtmfBuwh29YI4d+EMxZ73 yUKszIR5Wb+r2XLgT2Fhg/jPzJHF3M/BI+NHTLazvisTooYEu4BTxiNSjgVs5oXpgnrB XKcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331454; x=1709936254; 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=esyWdk7pK43NcDbXyKWe3ASdlab0DBbFS/CLGYhdRr8=; b=tChzVK3N41IKVpavz3AyiBeuUFDl18PmP6N9bqOgEdTmvSYllG6Nvo0zdf/L32MtDU 1rX8D/jkppuAdISzQj5wY0d/zPoGDqAP2ktC0U/jNseD2jykXVerIbC73cddfjR/NMl1 Jiw9L2pDhl63Ru900cXYs8zNBn0rcEQsxK26/ZhLe+tfw7GycRh6s9Sk4fLa6DfykVgj 1q5A5nZlGSEvEYDd6kcxwNYgxwoQKxHFb9K0bwK0hWCGsTIDfP82qUGdiNpVJ7nXVH6f gCMb2imJRSkxMS/w5j3kPoCyOV0+FEYSiLAuWJIeZokv0I8lQWuzfmjvBiabO3K4v680 38+w== X-Forwarded-Encrypted: i=1; AJvYcCWzFIHIavS80VmCqnwOfU6BSlJkt4ctXAIisRNlNbVz10qyR3/ona1TvSyR2cz+4mnJo8asCwAFvC3gDufnh1RAU4+/OwGt//YenWbk X-Gm-Message-State: AOJu0YyzZjmYboQ3R0HXVRjLzytf4eQlsuniM5lSiKvcTE5CERpUcyh9 6sEl6fR4KTBnBT2PIb/7z/ZMG0N8R5xIBRca80JdOLUNOiP/Iz70rgftP4FCvCo= X-Received: by 2002:a17:906:b85a:b0:a43:de54:c02b with SMTP id ga26-20020a170906b85a00b00a43de54c02bmr2268488ejb.17.1709331454469; Fri, 01 Mar 2024 14:17:34 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:17:34 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 02/16] net: dsa: vsc73xx: convert to PHYLINK Date: Fri, 1 Mar 2024 23:16:24 +0100 Message-Id: <20240301221641.159542-3-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364119459064139 X-GMAIL-MSGID: 1792364119459064139 This patch replaces the adjust_link api with the phylink apis that provide equivalent functionality. The remaining functionality from the adjust_link is now covered in the phylink_mac_link_* and phylink_mac_config. Removes: adjust_link Adds: phylink_mac_config phylink_mac_link_up phylink_mac_link_down Signed-off-by: Pawel Dembicki --- v6: - resend only v5: - introduce MAC reset function with procedure described in datasheet - reorganise routines - move 'Accept packets again' routine to 'phylink_mac_link_up' - fix one FIXME v4: - update commit descripion - remove phylink_get_caps after rebase to current net-next/main v3: - remove legacy_pre_march2020 after rebase v2: - replace switch to if and get rid of macros in vsc73xx_phylink_mac_link_up function drivers/net/dsa/vitesse-vsc73xx-core.c | 235 ++++++++++++------------- 1 file changed, 109 insertions(+), 126 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index ab5771d4d828..cb2e7e256279 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -717,52 +717,43 @@ static void vsc73xx_init_port(struct vsc73xx *vsc, int port) port, VSC73XX_C_RX0, 0); } -static void vsc73xx_adjust_enable_port(struct vsc73xx *vsc, - int port, struct phy_device *phydev, - u32 initval) +static void vsc73xx_reset_port(struct vsc73xx *vsc, int port, u32 initval) { - u32 val = initval; - u8 seed; - - /* Reset this port FIXME: break out subroutine */ - val |= VSC73XX_MAC_CFG_RESET; - vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, val); - - /* Seed the port randomness with randomness */ - get_random_bytes(&seed, 1); - val |= seed << VSC73XX_MAC_CFG_SEED_OFFSET; - val |= VSC73XX_MAC_CFG_SEED_LOAD; - val |= VSC73XX_MAC_CFG_WEXC_DIS; - vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, val); + int ret, err; + u32 val; - /* Flow control for the PHY facing ports: - * Use a zero delay pause frame when pause condition is left - * Obey pause control frames - * When generating pause frames, use 0xff as pause value - */ - vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_FCCONF, - VSC73XX_FCCONF_ZERO_PAUSE_EN | - VSC73XX_FCCONF_FLOW_CTRL_OBEY | - 0xff); + /* Disable RX on this port */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, + VSC73XX_MAC_CFG, + VSC73XX_MAC_CFG_RX_EN, 0); - /* Disallow backward dropping of frames from this port */ + /* Discard packets */ vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_SBACKWDROP, BIT(port), 0); + VSC73XX_ARBDISC, BIT(port), BIT(port)); + + /* Wait until queue is empty */ + ret = read_poll_timeout(vsc73xx_read, err, + err < 0 || (val & BIT(port)), + VSC73XX_POLL_SLEEP_US, + VSC73XX_POLL_TIMEOUT_US, false, + vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_ARBEMPTY, &val); + if (ret) + dev_err(vsc->dev, + "timeout waiting for block arbiter\n"); + else if (err < 0) + dev_err(vsc->dev, "error reading arbiter\n"); - /* Enable TX, RX, deassert reset, stop loading seed */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, - VSC73XX_MAC_CFG, - VSC73XX_MAC_CFG_RESET | VSC73XX_MAC_CFG_SEED_LOAD | - VSC73XX_MAC_CFG_TX_EN | VSC73XX_MAC_CFG_RX_EN, - VSC73XX_MAC_CFG_TX_EN | VSC73XX_MAC_CFG_RX_EN); + /* Put this port into reset */ + vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, + VSC73XX_MAC_CFG_RESET | initval); } -static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, - struct phy_device *phydev) +static void vsc73xx_phylink_mac_config(struct dsa_switch *ds, int port, + unsigned int mode, + const struct phylink_link_state *state) { struct vsc73xx *vsc = ds->priv; - u32 val; - /* Special handling of the CPU-facing port */ if (port == CPU_PORT) { /* Other ports are already initialized but not this one */ @@ -778,102 +769,92 @@ static void vsc73xx_adjust_link(struct dsa_switch *ds, int port, VSC73XX_ADVPORTM_ENA_GTX | VSC73XX_ADVPORTM_DDR_MODE); } +} + +static void vsc73xx_phylink_mac_link_down(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface) +{ + struct vsc73xx *vsc = ds->priv; - /* This is the MAC confiuration that always need to happen - * after a PHY or the CPU port comes up or down. + /* This routine is described in the datasheet (below ARBDISC register + * description) */ - if (!phydev->link) { - int ret, err; - - dev_dbg(vsc->dev, "port %d: went down\n", - port); - - /* Disable RX on this port */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, - VSC73XX_MAC_CFG, - VSC73XX_MAC_CFG_RX_EN, 0); - - /* Discard packets */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBDISC, BIT(port), BIT(port)); - - /* Wait until queue is empty */ - ret = read_poll_timeout(vsc73xx_read, err, - err < 0 || (val & BIT(port)), - VSC73XX_POLL_SLEEP_US, - VSC73XX_POLL_TIMEOUT_US, false, - vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBEMPTY, &val); - if (ret) - dev_err(vsc->dev, - "timeout waiting for block arbiter\n"); - else if (err < 0) - dev_err(vsc->dev, "error reading arbiter\n"); - - /* Put this port into reset */ - vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, - VSC73XX_MAC_CFG_RESET); - - /* Accept packets again */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_ARBDISC, BIT(port), 0); - - /* Allow backward dropping of frames from this port */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, - VSC73XX_SBACKWDROP, BIT(port), BIT(port)); - - /* Receive mask (disable forwarding) */ - vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, - VSC73XX_RECVMASK, BIT(port), 0); + vsc73xx_reset_port(vsc, port, 0); - return; - } + /* Allow backward dropping of frames from this port */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_SBACKWDROP, BIT(port), BIT(port)); - /* Figure out what speed was negotiated */ - if (phydev->speed == SPEED_1000) { - dev_dbg(vsc->dev, "port %d: 1000 Mbit mode full duplex\n", - port); - - /* Set up default for internal port or external RGMII */ - if (phydev->interface == PHY_INTERFACE_MODE_RGMII) - val = VSC73XX_MAC_CFG_1000M_F_RGMII; - else - val = VSC73XX_MAC_CFG_1000M_F_PHY; - vsc73xx_adjust_enable_port(vsc, port, phydev, val); - } else if (phydev->speed == SPEED_100) { - if (phydev->duplex == DUPLEX_FULL) { - val = VSC73XX_MAC_CFG_100_10M_F_PHY; - dev_dbg(vsc->dev, - "port %d: 100 Mbit full duplex mode\n", - port); - } else { - val = VSC73XX_MAC_CFG_100_10M_H_PHY; - dev_dbg(vsc->dev, - "port %d: 100 Mbit half duplex mode\n", - port); - } - vsc73xx_adjust_enable_port(vsc, port, phydev, val); - } else if (phydev->speed == SPEED_10) { - if (phydev->duplex == DUPLEX_FULL) { - val = VSC73XX_MAC_CFG_100_10M_F_PHY; - dev_dbg(vsc->dev, - "port %d: 10 Mbit full duplex mode\n", - port); - } else { - val = VSC73XX_MAC_CFG_100_10M_H_PHY; - dev_dbg(vsc->dev, - "port %d: 10 Mbit half duplex mode\n", - port); - } - vsc73xx_adjust_enable_port(vsc, port, phydev, val); - } else { - dev_err(vsc->dev, - "could not adjust link: unknown speed\n"); - } + /* Receive mask (disable forwarding) */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_RECVMASK, BIT(port), 0); +} + +static void vsc73xx_phylink_mac_link_up(struct dsa_switch *ds, int port, + unsigned int mode, + phy_interface_t interface, + struct phy_device *phydev, + int speed, int duplex, + bool tx_pause, bool rx_pause) +{ + struct vsc73xx *vsc = ds->priv; + u32 val; + u8 seed; + + if (speed == SPEED_1000) + val = VSC73XX_MAC_CFG_GIGA_MODE | VSC73XX_MAC_CFG_TX_IPG_1000M; + else + val = VSC73XX_MAC_CFG_TX_IPG_100_10M; + + if (interface == PHY_INTERFACE_MODE_RGMII) + val |= VSC73XX_MAC_CFG_CLK_SEL_1000M; + else + val |= VSC73XX_MAC_CFG_CLK_SEL_EXT; + + if (duplex == DUPLEX_FULL) + val |= VSC73XX_MAC_CFG_FDX; + + /* This routine is described in the datasheet (below ARBDISC register + * description) + */ + vsc73xx_reset_port(vsc, port, val); + + /* Seed the port randomness with randomness */ + get_random_bytes(&seed, 1); + val |= seed << VSC73XX_MAC_CFG_SEED_OFFSET; + val |= VSC73XX_MAC_CFG_SEED_LOAD; + val |= VSC73XX_MAC_CFG_WEXC_DIS; + vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_MAC_CFG, val); + + /* Flow control for the PHY facing ports: + * Use a zero delay pause frame when pause condition is left + * Obey pause control frames + * When generating pause frames, use 0xff as pause value + */ + vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, VSC73XX_FCCONF, + VSC73XX_FCCONF_ZERO_PAUSE_EN | + VSC73XX_FCCONF_FLOW_CTRL_OBEY | + 0xff); + + /* Accept packets again */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_ARBDISC, BIT(port), 0); /* Enable port (forwarding) in the receieve mask */ vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, VSC73XX_RECVMASK, BIT(port), BIT(port)); + + /* Disallow backward dropping of frames from this port */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ARBITER, 0, + VSC73XX_SBACKWDROP, BIT(port), 0); + + /* Enable TX, RX, deassert reset, stop loading seed */ + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_MAC, port, + VSC73XX_MAC_CFG, + VSC73XX_MAC_CFG_RESET | VSC73XX_MAC_CFG_SEED_LOAD | + VSC73XX_MAC_CFG_TX_EN | VSC73XX_MAC_CFG_RX_EN, + VSC73XX_MAC_CFG_TX_EN | VSC73XX_MAC_CFG_RX_EN); } static int vsc73xx_port_enable(struct dsa_switch *ds, int port, @@ -1060,7 +1041,9 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .setup = vsc73xx_setup, .phy_read = vsc73xx_phy_read, .phy_write = vsc73xx_phy_write, - .adjust_link = vsc73xx_adjust_link, + .phylink_mac_config = vsc73xx_phylink_mac_config, + .phylink_mac_link_down = vsc73xx_phylink_mac_link_down, + .phylink_mac_link_up = vsc73xx_phylink_mac_link_up, .get_strings = vsc73xx_get_strings, .get_ethtool_stats = vsc73xx_get_ethtool_stats, .get_sset_count = vsc73xx_get_sset_count, From patchwork Fri Mar 1 22:16:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp187170dyc; Fri, 1 Mar 2024 14:18:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVbvYhc0+fO/iSQ+EgI6RDVLYZ02FqzsOnj1Drc1hhFVyV3ksxTrgKXGlSPS95d1ltIG1BkAoWupYM7xqGkzBm35t2zcw== X-Google-Smtp-Source: AGHT+IE/nuj/1biKdbI7ny88EsRUOeYjK8vo8PikDosgl+L3Th2RifUuW5feMr73DLvG0My/z3NN X-Received: by 2002:a05:6e02:b28:b0:364:2328:22ba with SMTP id e8-20020a056e020b2800b00364232822bamr3509996ilu.12.1709331525113; Fri, 01 Mar 2024 14:18:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331525; cv=pass; d=google.com; s=arc-20160816; b=A2gydN8OLIRlEI8rHdkaoT88Wzw3TyeEx+MXOdYeF9vCW19h18qwWi/QwJghN5jI5d pEA2ZvSQRqpOVTKuGuEs5dESRjc7QBM3FU4iIdu75XIGN1E6+y0QbQpWHdSZvwVG96bd 4wNRDOXf9AD0EVqRXzeVigeNNt5MiMmovRhiFTjXRLFSmS5JMUQZslUfuUeTv41rfJTU WxbsKaV1Tq458JNkfkzyFLYg8Mnxy01FmLJvbmGp7goc+lGXQQYgwle3H2lpI9bz0wRZ ioEyCb+TxZ3LFQziCEnculoDbasuR5T/RqSHeqJN9+FRNc6+ZmiHYJlw1wpX55ed5qeT aWhg== 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=Vz1OG2yxyOrvNMyrVQ5ZIeKhi3z1LeqYLOa11e4nui4=; fh=fuOgjgsJLXydoontb549Fns0Kp23cwKE9MufZD+jR9g=; b=ofJ2KXn8TeWQGXHqNNgWhcqrRYkGIIxw0hrm8qpHW5kjh11vRNd0auqmssfozWvIbx CMfWh7gNGRYVt4ir8/zVUqx+uaaKNHhKjR/OW73XgAyl+7Fuwn/LM/RnK+zxuMS3Y15/ yFG3SqmPpGyUw70ZBV/dbqKrxvtdCY6LuSXzMnrr8ZEgckq6PvH3x8IsHAkVd9Et1Lcv ZQKVAxp2iwQ29jv7UjLQEtC1UMqKBk3Zs/ZvUzaMmS729dM+dGjV4SC5/IfPQb5L4pUc eeoK1zb/8UH4GiRQmAZWZlDFO2ya+WlFxMmMTCYAwaYSmG/LpJEKHe4HrZqZVxPG+uHD M0Xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Bw6mCLGv; 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-89178-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89178-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 s194-20020a6377cb000000b005cd8486d5ccsi4435994pgc.65.2024.03.01.14.18.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89178-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=Bw6mCLGv; 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-89178-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89178-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 E652C282F5B for ; Fri, 1 Mar 2024 22:18:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEAED5917C; Fri, 1 Mar 2024 22:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bw6mCLGv" Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C8575A11D; Fri, 1 Mar 2024 22:17:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331462; cv=none; b=WlMBdkbPpUtXfLpE4oEyH0jgRqi6oc9ruvmrcLluGJKxAAP2fIxcBR7tF211+kftDmsmfhYjLqKq+ineeksxLunJ5ytY+86ktXqk2DnNy7L/V29VjkyDt4EJYI1E9ZPnZp3NHOAVyM9rkMlRZ0qKj4lKuYLzpyNoJsOhA1gN9wI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331462; c=relaxed/simple; bh=JwjSgNGcouDuJW2a7u8TjPRSQvah6uYvnF4LKqBzFvU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A6jsLgZIvhKh37dbnxXQo7C7LSNQBNFCR3WtkU59xNqkv6MiiH/VlSPrnpZHPE4+upjGmMUHseOhwg+AhepdEeaH3tO7WZQNE4XL8nkh4JePZ24v4VOAI4yMnBR71rE3Pwr5ePX5q5AI46rvfmPH5E15fo4dPcOT3y5lGxjyd7E= 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=Bw6mCLGv; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a446478b04bso267857966b.3; Fri, 01 Mar 2024 14:17:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331458; x=1709936258; 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=Vz1OG2yxyOrvNMyrVQ5ZIeKhi3z1LeqYLOa11e4nui4=; b=Bw6mCLGvYO1GGZ0oIOvMW6LpN4ryvjiPr92curFHl8L2gMmLFDBTMb+ds7EisMRBLl GFSmGHWpxHzsCOTBa1e00qP9OVOtFq/DPOvj5J9bbaf6c4M6vTxMTMmf1+0hE1+aweTq uJSxUzB7Vp9cnnGVWpiuT18QXPgmvHpuQhjdzLIalnF3KWuhgJpIjijtnLcmn6WSE36R 2gSSzdTiyl2yvVYAv7f3xMFHB28ldLB7y5dzXQqd1zlcd56zHlAyCREY61UWykJUi7Gq D9otQwUk0nIeNTvwrP7WRctkrCwhIfDVU0CBrlFKHCI6fvdqwfevAAglfXj3+GZZrRBC HvEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331458; x=1709936258; 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=Vz1OG2yxyOrvNMyrVQ5ZIeKhi3z1LeqYLOa11e4nui4=; b=ggItA67wMXmStY4cB2hIP8sjLo12DccCfqzrewKaoXtf0kAMN1vVB2nTy4yjV5leh5 LWI0whncKsgnGYqVudRyL0dKE95O6Nj+jFcOCP6u4BiW3i+kNGyH+nj3R1etR/u8inuI JgoQz1Od4Kq59y8paPYGoARGKVAlyk/My7Iws5I8te+B5izufpIiXfEexhWhI9/xgJ18 b81F/FoER4kR4i9B3r3LaT9M+tJmrbgPlgKwRVpnDzMM6PgXtia48o5V9ZGHnmV6udGZ gmTGbp/vq1vSprVbvMdodTBU4hToP49PZWTWC2E0+/M0yA95Ai37m8iE9YGcqLOMtx57 B4DA== X-Forwarded-Encrypted: i=1; AJvYcCW1PbY45spzrLfGOhfmJ/q68Ta3aDdMe4ylzVoLdBtHZNnD1KfLFBIZWOGqRH9in4Url+RYbEjX0zG7xHmh9jzE5kxKC91nv/ZDKWy/ X-Gm-Message-State: AOJu0Yy5npWqpPKtM16BbRyA7gOLNRaJAgtMw/NlebyJbaZkD+kjJXvw DBu5dvu3eyAxxMvzsMNSSTHLCzAwYQ6HrS+ZeGrnh6N4le/Vc8S9b3ZhNnXiPJo= X-Received: by 2002:a17:906:240a:b0:a44:2b1a:e257 with SMTP id z10-20020a170906240a00b00a442b1ae257mr2113326eja.55.1709331458353; Fri, 01 Mar 2024 14:17:38 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:17:38 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 03/16] net: dsa: vsc73xx: use macros for rgmii recognition Date: Fri, 1 Mar 2024 23:16:25 +0100 Message-Id: <20240301221641.159542-4-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364013076023899 X-GMAIL-MSGID: 1792364013076023899 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 --- v6: - resend only 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 Mar 1 22:16:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209108 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp188092dyc; Fri, 1 Mar 2024 14:21:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUpL7sx2lj+Caa+t68MGFdM99l53tZoGAjSd0dnA1curfFpqHzg3k7ITtTaTAp9sZ20L7QeDFnchxSBLkR8iTg2nlsERA== X-Google-Smtp-Source: AGHT+IHt2/DuNESACS2ZmFOm1rVGloDSqsSJnv9aDymL3BMJpNAva0XxUveBx/5XsBDj7J2oJhYt X-Received: by 2002:a05:6a20:1441:b0:1a0:fd3e:5339 with SMTP id a1-20020a056a20144100b001a0fd3e5339mr3087587pzi.10.1709331662285; Fri, 01 Mar 2024 14:21:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331662; cv=pass; d=google.com; s=arc-20160816; b=Iu/tiBSs9qjjgunVeZnifFasGq7eeEIAmtmO9N/56Rxs5B6QRht5UBRSOUF2W5TX5b FuWsMFZFh9m1e1t8sekeUsv56+Zm7mcGsF8AMr/ZYVIZdDgmIJBjxQbp1IYsdMgGd1Xb x3kKwyQzL6oI+SU4lEXRtycnvfXHwpaph1080wGmVv578sKyTtqzQEAR+sDMmK3gtmjS aCzQOZntYCPlnabUxBSgV5Cr412r3rx8JwbMNJGDr7HEGxtOyWWKLVCYOEB/OtbPmX0d 3/GRNdZteVXQ8BcsXBE9UAgqEiT+uhLtZ9AFT8Kg9P6piewDn1mQO/eXH4Dhce2yF7Xs LxsQ== 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=zngMc+/G2xBaVj+Hq+WsLXMEauJLoXOmUweXtku0rXE=; fh=yiCNhXEgSLydRgwWlXqoATjiTLSOAlObq6t1LgOFkEE=; b=sfyJGO5ESD0rbkhd7Ui9fA9RGgOm1lJo/BRDxtQ6OYHY5oFtNt/j6WgctARl5b7Iwg ndzNNC2KElz8jgtrrXobHDwh5pdrlge2JO0S7bWmC6YASxkUfHUjwOyvDKlQuZnM+tjZ UIFS+D/G5gh1fgZ2/ViYVa0mx9R3SJHcXI/VIyU21jlVUjZcMwTfY9SqjfLm1ZOHjzmS 26t3DDGZ8i6e0+Fs0t20uSeIkJj7vUyfe/q+CJ+lKq7q6vMbkqkp+3MBvMdyICKhnMeU Ec/XLEvk6bwha9LwQLqw3MKYDzS+7k4o0L2ksOmc8QEuoZ73GGc34gzdA/S9U4NZ3k7q e9kw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IQLlIMnm; 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-89179-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89179-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 bt17-20020a056a00439100b006e5cb85b5a1si1625355pfb.263.2024.03.01.14.21.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:21:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89179-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=IQLlIMnm; 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-89179-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89179-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 5393BB22F3B for ; Fri, 1 Mar 2024 22:19:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 144E55B5A1; Fri, 1 Mar 2024 22:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IQLlIMnm" Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81A485A793; Fri, 1 Mar 2024 22:17:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331466; cv=none; b=XVXzy9XGogVJ7Vs3AomLlQ/0vgZ6nZifAD2ZMOWGi4iXLSbxQ/Bh2FP9vz6cOQZ1l2tUmu9yJUwzX0sOrscTprHW/zjKmIh2AYsN3mqxJm03ZnjZ85Q9bDN9aBfArJk/tp+6uG4fp7RRiK5ESDxWLhKA6x/5fHoKkyYyPT1KrFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331466; c=relaxed/simple; bh=qrSILNVLjjjNKJyj1WGPEYiYZQSzoBxN9C17+GLublE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=I5lHwi46v+Nj0TmS6gKePmEEhlc6Jy+jXarcVqaTfqmrWeB5+PrIeTjx4NvWAoUfZICo1OSYVPiJi9HnJpOzrnSkhPY7jD451fYKlk+pPVAI8a/QHpUPTHJRmfr8UCWn6dIpNOVYhuz4VdF2FZ3J+Js03c6hNN0j5vjCVB5vqW4= 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=IQLlIMnm; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a28a6cef709so428866566b.1; Fri, 01 Mar 2024 14:17:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331462; x=1709936262; 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=zngMc+/G2xBaVj+Hq+WsLXMEauJLoXOmUweXtku0rXE=; b=IQLlIMnmu33hfz6xNGt2rMVfPxwRnkEZC3yCzDEjTuTE0xpNtusjd3XwE3mDvq+n+1 hrjaczGHpb5HHixNbnZrloWcsbHK14a0BHMd25uBBoDFlvvEpiQEOEq3EQ9GGvWh+fhM tBnv8Ct2xTXZ0nV1b3f6Q1RfxLugwU3PN8RYbhfTTw/uZLh6O420dSn8TQZKg9vJ+NTd 5KuUzT8/+OISB6rbKZDcpIMaRdIpkMVfoyDEEi3y0RcZ1JKIgjiJQnywiXL+WTFDWsND 3N+qJ660bSUOMfGhyc4iSVkAl0iLjv7RRSaXd513v2A8NeTrQG7PajSN5S2gIonH1Aq6 KVFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331462; x=1709936262; 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=zngMc+/G2xBaVj+Hq+WsLXMEauJLoXOmUweXtku0rXE=; b=BX96A9E2YtpnzVBNQi6Yv4+vZK66IojsPSVrTBaIyq5SBKvWwz/gP9gu3aRrViqaR5 LyvNwwYrE+wGWeC04T5GYEFlCSqIa7iu7z85JRtaxCpRlBNygwzMl0WeGBzRGngEGHGJ /la1alti79scrAvB1HdHGvvkS83KYG4ejyi94oNozDpkal2aR8OocUFJp9iD1CU77hfw clF2rfU4uHuF6rizk2nXeDfrBkZpQXVgkkDTLp2bvqMiMFg5A7YiPWJblL90zFdbjtXw j2th481QKKTecbO3+IXPSD5aelAzZn9zXgn7Q8YEwWId1Ebf0/0go0YbZzDNone1SABx cgDw== X-Forwarded-Encrypted: i=1; AJvYcCXKfpdSvJ+ZfanneyqKIsNepL/qBL2T98+AemIoEyFE4c+kzXI6Hc8ImHrCU3fYTElA3JH1D326kc74MN+HM5HWkMXAqO8oiqUN9kuh X-Gm-Message-State: AOJu0Yz3hN6KbmKJBBsp0wY79ltUEISAEXsUmMWlP/xsHjxXF3mrmGaD WDxSzqTcrR7k3fu9USd2euNaN+FCeNXaQbul6Jo5rGsv0T4MHDerhA/awzJaB08= X-Received: by 2002:a17:906:d92f:b0:a43:af0b:ec31 with SMTP id rn15-20020a170906d92f00b00a43af0bec31mr2342994ejb.53.1709331462405; Fri, 01 Mar 2024 14:17:42 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:17:41 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 04/16] net: dsa: vsc73xx: Add define for max num of ports Date: Fri, 1 Mar 2024 23:16:26 +0100 Message-Id: <20240301221641.159542-5-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364156994600124 X-GMAIL-MSGID: 1792364156994600124 This patch introduces a new define: VSC73XX_MAX_NUM_PORTS, which can be used in the future instead of a hardcoded value. Currently, the only hardcoded value is vsc->ds->num_ports. It is being replaced with the new define. Suggested-by: Vladimir Oltean Signed-off-by: Pawel Dembicki Reviewed-by: Vladimir Oltean Reviewed-by: Linus Walleij --- v6: - resend only v5: - added 'Reviewed-by' only v4: - Resend patch v3: - Introduce patch drivers/net/dsa/vitesse-vsc73xx-core.c | 13 +------------ drivers/net/dsa/vitesse-vsc73xx.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index 8ed8fc997d6d..425999d7bf41 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -1180,23 +1180,12 @@ int vsc73xx_probe(struct vsc73xx *vsc) vsc->addr[0], vsc->addr[1], vsc->addr[2], vsc->addr[3], vsc->addr[4], vsc->addr[5]); - /* The VSC7395 switch chips have 5+1 ports which means 5 - * ordinary ports and a sixth CPU port facing the processor - * with an RGMII interface. These ports are numbered 0..4 - * and 6, so they leave a "hole" in the port map for port 5, - * which is invalid. - * - * The VSC7398 has 8 ports, port 7 is again the CPU port. - * - * We allocate 8 ports and avoid access to the nonexistant - * ports. - */ vsc->ds = devm_kzalloc(dev, sizeof(*vsc->ds), GFP_KERNEL); if (!vsc->ds) return -ENOMEM; vsc->ds->dev = dev; - vsc->ds->num_ports = 8; + vsc->ds->num_ports = VSC73XX_MAX_NUM_PORTS; vsc->ds->priv = vsc; vsc->ds->ops = &vsc73xx_ds_ops; diff --git a/drivers/net/dsa/vitesse-vsc73xx.h b/drivers/net/dsa/vitesse-vsc73xx.h index 30b1f0a36566..fee1378508b5 100644 --- a/drivers/net/dsa/vitesse-vsc73xx.h +++ b/drivers/net/dsa/vitesse-vsc73xx.h @@ -3,6 +3,17 @@ #include #include +/* The VSC7395 switch chips have 5+1 ports which means 5 ordinary ports and + * a sixth CPU port facing the processor with an RGMII interface. These ports + * are numbered 0..4 and 6, so they leave a "hole" in the port map for port 5, + * which is invalid. + * + * The VSC7398 has 8 ports, port 7 is again the CPU port. + * + * We allocate 8 ports and avoid access to the nonexistent ports. + */ +#define VSC73XX_MAX_NUM_PORTS 8 + /** * struct vsc73xx - VSC73xx state container */ From patchwork Fri Mar 1 22:16:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209103 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp187428dyc; Fri, 1 Mar 2024 14:19:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXjkLW2/BW/2Q1Ppwobd4CJglhfh4hd9pFbeB2816wMqFAX/cJCgYht6nPThEUy8EuIXWgTgrVptzNbeFVkoM9kU4Iugg== X-Google-Smtp-Source: AGHT+IHlnd1M9qfR5uyfqtVlu0qpnctNFXdEAtiduKanq0QNoxKrNvIFdJhEBHwk6qoVnQZMhunA X-Received: by 2002:a17:906:f856:b0:a44:37cd:8385 with SMTP id ks22-20020a170906f85600b00a4437cd8385mr2450459ejb.22.1709331563514; Fri, 01 Mar 2024 14:19:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331563; cv=pass; d=google.com; s=arc-20160816; b=Cl5wHzot2LOaGSDgkJpMuTixNNKuyd4/u8Jy2tNr2NJy7RIB7rOI7ttDen6pgOaze/ aONyWL5VRTy9tgrpiHSjJXhS8mcHRfRcJpfzf2C38w3YpXN17urxWogU/o5o/wrHvxN+ SvCt1I0gWM9Vf8AoxzLppVXAdBW1eJKbMV6Lm0O6F/nnHcFQIXqJUaoN4w+5sbgMDCRW vqmnFEu1HVSye/ukhbaAiRBX1L1urPDrXbDPPQr7Q2RsTZrF5xOE8WjErKhej85IgX0u UilNtol6FCkiin1VARGD/m5Or4+OnPwCAHydAfeK8B83q+vfq2Qu39z5xxoCSx4hQF9T D9PA== 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=uWAyEufici4LW1NGI1K5M7JMhAe9f13aH7DQNZOl3HA=; fh=uIEKckiK2OVV1FXa2WvqZjma4sVMll+yf2HsiQ44YUQ=; b=dtSYA+HzbveLAXADdQfzV6J/hDPGOjNDA4kk55sCtSfXNEsS/YGKdcHuiAkdcukGoP d2gVgbKqSG8xGpQ4JStFpcGJ5dK767yp5n1oUT7RjI7KY3lln0Twlo6duyM9yIovxzV4 gJ94EuUAGa5xtmsSxkyL0nC9V+e8J6aIcBCepX91z2r1qTK/bmZBlca0SJXPNbzwIH/4 nQfg28TUEd6Dkt8OBWyyRXYvDmw0l68+HkXbPVijXQQJQgkr9Ii1g8qi7IRRqzYXUunL 1DD4ONVa65bI+jPeOqfVNCV03tKqjBcXbzimCaU4AOjdsACXDobmkD7rac+wO1r1kB+B zmvg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="D47/Hl6N"; 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-89180-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89180-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 p25-20020a1709066a9900b00a3f84ea82edsi1818820ejr.519.2024.03.01.14.19.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:19:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89180-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="D47/Hl6N"; 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-89180-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89180-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 274E41F2378C for ; Fri, 1 Mar 2024 22:19:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C77085B668; Fri, 1 Mar 2024 22:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D47/Hl6N" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 64A2D5B210; Fri, 1 Mar 2024 22:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331470; cv=none; b=fFRM5QIx7X8GUodhDkTjBm59GAHKglibVLUxFHXsIrXlV7miGGMCFl0Ylud6zZmiwAreDyQIsk7oKHK+fmgUeXoQ4jh0cWpTsMtNYU26icHKQHwawCwFNdpNBQ1i+kADB01Jnc3LdJavb7SVE6fBoo9NHPaOLMUo2104eQny0HY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331470; c=relaxed/simple; bh=P+qM/C9/KxfJ6Z2vsMsL0FPnDbUOdsujMsbIp0BPgEA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rWOeBl0MZ/Cg6aNHG0JjXskp5tb43gne3VLeUwezujTHeIXYWnGUcsDjEylghMUwn0ImbQzOhENgqFoHH+63+EQ/yVKfHtv2Rt4kElWZvZIAUZeg1mZiyNltWTAsTXEh6MLMtQNY8PKub+2wo1iuixUF2YAe3oJ0ujlM6mDaR1Y= 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=D47/Hl6N; arc=none smtp.client-ip=209.85.218.46 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-f46.google.com with SMTP id a640c23a62f3a-a44cdb2d3a6so18225166b.2; Fri, 01 Mar 2024 14:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331466; x=1709936266; 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=uWAyEufici4LW1NGI1K5M7JMhAe9f13aH7DQNZOl3HA=; b=D47/Hl6Nzv/DEE/eIswemDscsIoG1WDfKNYKV+3HZABHhh3RPWhMxX0RFviYLbviT6 ijCZkGqqkFBxNRb5LrECa0MbC7/YK5xwmzk9VcsF1xLyFDeHL5GWohS/xeOtdGBC79UI lU9779DtNy0f2E9o/cEW3Ki+D5uI8yGdCtRIOZj4APQ1UxscvQFuHouxmR43Pt+eWBK8 XpJqh8r6u1aoKN8f8cjCN7U2KLpro9WJOWecRqlau8/WZj8oez/+MCAeUvEkCBFsgk0s t9nh9dXp/XAazO9TsiwJjyW6Umm7cdID8+Y2GNL2QmJq7TWs+zKew4u+36JB4uwDKUxx jwxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331466; x=1709936266; 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=uWAyEufici4LW1NGI1K5M7JMhAe9f13aH7DQNZOl3HA=; b=fdqiqVACU1m+Suug8IMSkpLdI8mcPZjiFwruVGUx209YR5THp94e0mWxY9MbLq8ocs 5shYDX51t8bifp8Laubx6wUBNl3Lx8i9KSxqP70Be4cfSg+0SYuHMi3Mt0Z+irhoxsk6 3yKHbyRnblubvrxITwLt7V8Df5okJPnYMxTDHwZlzb0PXcDn5ACAA1ThqmR8wAeM8aWL E45pZ3kVMkO8Y2bL4eG/laF8kaBMAtjFyTrTAt8OwV70ywMwNKVP3xCpRYele8Nw9XIz fBO20vZ9DqvKdKlapTEzcgCyMAQGotz4ujofC5owfReoea43c4A41AaSQ0t60ojYVv2S HXcw== X-Forwarded-Encrypted: i=1; AJvYcCVewxw/f5fWV7AceEMO/NtbaAjQqMcdal3+CWaTAl8pnrkzboYN7ZVziB9UFLlIiUR5leb3nrkm4RRyiGq+rIVEOx2xzsAKzukNYdFf X-Gm-Message-State: AOJu0YwyXPcJi5wtd55L1bzIbW7lpuMVQklWmB+dP9LRMjXhIPGWyOZD FjSqo9Ub3WDccrymvgh4bumKnha7jNbdmGvGwNJCenNgo9fH1FKqXN/KG/Xaoww= X-Received: by 2002:a17:906:a197:b0:a43:af0b:c1c0 with SMTP id s23-20020a170906a19700b00a43af0bc1c0mr2418087ejy.16.1709331466332; Fri, 01 Mar 2024 14:17:46 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:17:46 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 05/16] net: dsa: vsc73xx: add structure descriptions Date: Fri, 1 Mar 2024 23:16:27 +0100 Message-Id: <20240301221641.159542-6-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364053117749533 X-GMAIL-MSGID: 1792364053117749533 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 --- v6: - resend only 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 Mar 1 22:16:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209115 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp189287dyc; Fri, 1 Mar 2024 14:24:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLSO7rjKT8YPCxZtjv0oH1pO/+qzccELNb1GgcIxCU5/67Umc+eq/g5gLQyCMmIwnz5+lqMEe1AxOyuRIVypKfoifePA== X-Google-Smtp-Source: AGHT+IGR89I379Ab5UP0dHeJ06NyQJCUHdISfzyIrMvYIYvIcWSnc5JZjOurvWZy7BGEXpFIC+Ex X-Received: by 2002:a17:903:28e:b0:1db:c536:803c with SMTP id j14-20020a170903028e00b001dbc536803cmr3216581plr.33.1709331840282; Fri, 01 Mar 2024 14:24:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331840; cv=pass; d=google.com; s=arc-20160816; b=TPQT+pIcKXH+EpeSyJy/fFJhtc8EeE/5txZ8skMUNvUk5BfkONi7ys+cgAH2GCFM3l NcH79IhyoS95QnVKF8IjvrsrZ0Lj0+ezIPk9iWYkOjXsPFmr02GG67i29ffiYozkrhNx 4DY8LFJ/R9xurmcwQVjV4qyaiZke8X4xJty0nKwUlo6dTwpLmMUBGpZJtIHNi8HjaP48 M/CGTFQof9u54jwzMH6HsYGCe9+Dc8dCLfFF3WO2QO5zz21bjhcq9BRQUqTSzms+EW4C tFD6Mi6kOJWJ4XCVj3oc8oHqcYYDlVnLVh2lU65/gzwcEuFrBxUS4rkugzShWvb1EApI zBJA== 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=flIukc0OLjZlVsp2pS8pjLIhLLZZrkUNTCljng+ImU8=; fh=F2l7bkf7j0hQvgY3QP/lH/y3Dxa8PTKNEQ2e4xYVNwM=; b=0KbzNbuDvW03W14Ih2XYSlNpH+xIOJNMkraGOEOupzh4ckgB8q27KpcstEpVKIFWnb t46JgrSqang8T43quAvzJU1EGi462P8xjXOSdE9DgmNcIscnqTpRlS0MK1VS0dvZkxe6 vLIVJwpEeXFfPKoUUVyswOHlC6cJitU6aPd2x5zz19cSKo/RRYU2rmhDZaiJKorb56eS 5hdN/r3M12gicd9p+WhSQrTmuGmfEQNylsqpDNru3b0vHFY3Kiiwg8JZd5nU0lUlqhgw hYwdWPwPAeCtwmx9luy4zpAiZ0m1THMbGX4FZz1iZuIGCkVijasBtjbrcb8PYzQf8DfB 0XIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=X7X+RHrq; 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-89181-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89181-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 z6-20020a170902d54600b001dbd8225034si4738006plf.590.2024.03.01.14.23.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:24:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89181-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=X7X+RHrq; 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-89181-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89181-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 9AF24B22218 for ; Fri, 1 Mar 2024 22:19:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4ACA05B68D; Fri, 1 Mar 2024 22:17:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X7X+RHrq" Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 0A1BE5B5DE; Fri, 1 Mar 2024 22:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331473; cv=none; b=dvz6fPzW9fs2o4B+4wsJ6yS5O7kmbsS5G7DzMLPymph8qln1qhljLND5KPsMHUOUx/RHISd7FC8+2ZF+OnTOtKCMaeEmxd4jFotNg9o7Rppgbnw/PD55kTpDTLAd1S4irInpjtA/aySNZJmGvPJ8NLM8SukzaqDwyI4zqKWfRJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331473; c=relaxed/simple; bh=vDrl10Ha6ROxrXIkoog7fre3HIJoCxXOX2Kvv9JHM9k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OhQ6N5WpjwdfLdKLdr5DbuVZP4EvNFgxEn0T5yI2ms9NzGw8e+CadBRLVo7+TBYGW1C+2T/kyXIKb3cTnmEGrmseQD0rm0XWYlo5/QWRUqLT4QJlzOgn6TRMBeF9Hsb6GjB2yrzmmaoFF3GbR1HaSgo+S7V1blRbVU5vGKqrSQ0= 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=X7X+RHrq; arc=none smtp.client-ip=209.85.218.46 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-f46.google.com with SMTP id a640c23a62f3a-a4499ef8b5aso139712866b.0; Fri, 01 Mar 2024 14:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331470; x=1709936270; 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=flIukc0OLjZlVsp2pS8pjLIhLLZZrkUNTCljng+ImU8=; b=X7X+RHrqMKmuUZ6Ez8YskMfkPJkD2R+CJkrgPr0LYolhCK8VTypDjFj01R8fslQQQI 6RuLUg0sLV2E3M4P15FWuZ339O05BStqHzL8aP85zG4B53tUeBbVhT5rvlA+EyH9W31C VlAeveS69RwmQvoB9WLm6usuoD+GnN63X4WkmNc9jVIBjfcBgrkexee4qlNRcd/8hBf8 4ifB3AkxDyCuEGocQBH08H7sDtuQ7rcPrEZBJ3Cwra33Osly/pTkdod+hovyEdH7AeA+ slzhUHHiAe3hmVwVMSd1sBj9f6y8SjtCpcK3rlogQ2Ly2cUdUIv5i9ffSHcg9mogX/Ll Xj8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331470; x=1709936270; 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=flIukc0OLjZlVsp2pS8pjLIhLLZZrkUNTCljng+ImU8=; b=YVVCATP3iDe8XGEcr7ibTdhNKBOnsHsCsKzQwx/1G0rtPnuLkcC3l31WqR//pqQbLB /nfcrHNzSSF0+5ifU7lxcPlwDKMnlH/109UwWAsSfNr3LM/utH92lc+Bbayf2LXy5JAv z+ct4KP6dwPvPrwgJwCDK/3sQ/SwIvpdFdI6MJr1Kfc6H8+te3H+eFdG0IUfikYcFl99 uvf2iHaUY743MHdOexFcH66qEkSIxHaAZ51ESDG0p3PgzGXT4d1xeXnptbXvN+0j6u2k 3pwdoF3VYCWej6RBNbDwCnFdSbKUUGcG+MrfYVQlxFZ+0tT+LwI0dvbleiP4f2LUI5NO N/qg== X-Forwarded-Encrypted: i=1; AJvYcCVbe79G00ru4xN0yKplQUjrD6rC/oTJc3LwrUrGhumtiXWtjnCKW2c9CNcnFK+AC0T1oEuHeCYzZfWvJtgtn7E4Z8mej3Yfh/8vMvFh X-Gm-Message-State: AOJu0Yy9s8d5k1HtL7eiWKqCYROQl8GEDJIFc/R4Ohn+4f4WEXHxspDE yfdw1zlSQTsYfXx39jcgHZirX5TD7Y8s7JixJ03+LL++obVkMKNdJVbRX3lPgmY= X-Received: by 2002:a17:906:3b0e:b0:a44:4ed8:6a53 with SMTP id g14-20020a1709063b0e00b00a444ed86a53mr2047732ejf.29.1709331470300; Fri, 01 Mar 2024 14:17:50 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:17:49 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 06/16] net: dsa: vsc73xx: add port_stp_state_set function Date: Fri, 1 Mar 2024 23:16:28 +0100 Message-Id: <20240301221641.159542-7-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364343662764100 X-GMAIL-MSGID: 1792364343662764100 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 --- v6: - fix inconsistent indenting 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..d1e84a9a83d1 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 Mar 1 22:16:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209105 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp187792dyc; Fri, 1 Mar 2024 14:20:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVZ/dpFIx5cckTLnamNhiddtEROlZmH6oMt1PUJiIvabjaxMwSvAxCuhh7gqzwa55HL8x4+D5JX77GbQVP+tSwDotNGqw== X-Google-Smtp-Source: AGHT+IEqi6LEoCAfPLpWwP1dCyUY8h/ALIcNmrNHatG2RpHq9mqXI9FgEcTcHLNIfIHjtOT1k2pn X-Received: by 2002:a05:6a00:2384:b0:6e5:7ff:53ff with SMTP id f4-20020a056a00238400b006e507ff53ffmr4007121pfc.6.1709331616521; Fri, 01 Mar 2024 14:20:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331616; cv=pass; d=google.com; s=arc-20160816; b=QZV1vKkiSzBTBSIIDI504176f8JOUWHZfTjPKFQZAUginBQjqBKlIEI6NdTY2hG5Zi 5kdgU2YcGtzSrd1ro35wYjzFSvwAP0lKgl2bugrGqi5RtR/cqOaM24NISl0483BPIYr/ vXukeUf+NMLIcZWeSSnYkXZ4TJmGN9ANeYOqQ6tiLP+ArDTKxOtG5mCalLEB6RYwlYq/ ZS0zgAGXDX5m1OYLUBTGWY6dg/zSBDGjvW676T50E1roj6aDp7uSTnJqPJ4l7IylAjcM PUaboHJg+eEwaYVb0eB205Xo/hMLOY4n+NRl8MpXlesrsrUkZRZz4cp+wYeqPX/2N8+W vgCQ== 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=6fP7h4hKOg0cEIDrFoZMLzBUyuWULVy+8pAfs6YEfLM=; fh=eQZO+Y36mruOVPJfORhpcl+pW0KVOd/A40AWD3Jb84o=; b=RHHLf3Y10BhuCcpimhm5WxK99AjrFfpm+12Pl+CEMCWSZysEum6qP5JqtKnTE0QU5g XWrPTc1r+6JLOai6UOl3ueO3buVBPPF3cEKQ84MmC1EqJdsmJaMhfKf92kbAG4Vrc6Dr +tetVEkeuhRKrcVxxWgVjOYwS7piP2S6f/FFf4MDFq4UtdplQvLkdOZXr7LyEF+V0cP0 mjvK8QOW25Z9EQb1D7g15ZB2xVHWvXMgyTa5P7ALU4sDVwSZu68brLa820tmdV1RH0be M4eg4Jc380nqsP8/0kK5GLSpPJf5gB8YTjWnSQ7zJsp6ZbtcCctAVNDf415i6UKqdscl viDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QFFOxAPr; 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-89182-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89182-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 ld15-20020a056a004f8f00b006e5db93342esi761998pfb.158.2024.03.01.14.20.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:20:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89182-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=QFFOxAPr; 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-89182-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89182-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 4F1CA286923 for ; Fri, 1 Mar 2024 22:20:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 087275C5EB; Fri, 1 Mar 2024 22:18:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QFFOxAPr" 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 BB0EA5B689; Fri, 1 Mar 2024 22:17:56 +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=1709331479; cv=none; b=BLNicZAyT2k1wyf7CywzaItW1rIriVyoKw4mjBiiq7B4unnjDwAyjaI41qGtM3HS4/5iie/9mE194wSFKVABxv7yNnZ0z5ZuwDGs9D+0GhnKJK/5nMv17vKAFg01ZNlGHz41x/RLhYEayJJXGhf2t1Z7zqAtWt75NoGIHhW9YMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331479; c=relaxed/simple; bh=3AaoL+2vCGP+F0J1Bz1z8Yin48tJx/B2p2ORjaq0Kg0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XJdGV52cJkSsL/fDJc/BA6BLRy0WnuAYif7zDFb6oTNAJQ68gZ1y/pHzn2RRG6F7uaOThIC5/v5HWsrr1xq4ZdkAhZPFno7HpiUfhFW9hMes05ca1VL97kAuifVnzpcLAZRpGAvR9wVckX0/D9ezH0eRDlvn7MhbjjVOQ7jH8jA= 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=QFFOxAPr; 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-a443d2b78caso359383666b.1; Fri, 01 Mar 2024 14:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331475; x=1709936275; 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=6fP7h4hKOg0cEIDrFoZMLzBUyuWULVy+8pAfs6YEfLM=; b=QFFOxAPrQ+QbamhQaUdDhsWvs6FnGTsUSXynsUKtW30k7z+tgEafWM9mDX87hjSkzm JtXKcEqmmXzk7GeQ/SxC7X7m370e7Dr2IY8JR9CoqSOVeFm3WoxYQDnOAzygDTkszt8J GTtungIA7mReeijG56seRG8AMy6TmIRhOe/SKznoTvvBcb9G4GJAIgsv64Bvt9w1AHs9 XOfrEObSErHx1aaQl+PfZzUozAD7P6ZzhbZ/I8eZm61hY0/4PIWcJ1DGbCY2gov+OjR0 Ktpv9dURb6WNJoN6bAeHGMqKZlReZtmlAfwQ/RceDTJ82kduu4K3Pz8TQNPWudC+7Nmw rqZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331475; x=1709936275; 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=6fP7h4hKOg0cEIDrFoZMLzBUyuWULVy+8pAfs6YEfLM=; b=NA0/Jjk3GzmCG22Z034WcIR2cEFesvba35w7DsVfiGJ//s0I6JtHKLoodPKp43wEn5 coCw2pjwv2Myn2+E1paOq2CwF2FIQsuqObNECYdBWPPjBS0q26AcfG32ODI0DrcpIhzb c50KZlDhHHOTVXF8Y9uvsAOqmuCBOskuXUMo7mpmswRDoHmKXwO2QILMUU9KTglDxoDK yuPNnfjVzqyio6N/ItIIgJEDFuDZTAJy7D6RfKJkpQZ5ZNuMdKBVGKW9FhI4aNHBksG+ c25h4rLhFTM4+z4h6IZTxzKkCpk7/969tDV65OOmzPY9gKEqRK0MKzmQXx7exlEyhhrq rmNg== X-Forwarded-Encrypted: i=1; AJvYcCUU2KBWae0uuvkpfw/qGf8ulWG9y0Pg4OiKiW1ruGLLu19Z9Agkq0eN5RghN8DfkeBhS46IOsXlfpMCiKJjBzPUV6RJN99Hc1oexij3 X-Gm-Message-State: AOJu0YyZcCCSO57nkJPcIXGLuuUlwT/lmvzygUttKFwLcLpDx/9O4BGa ipBTbwUpG5aF+2Ae9Jx0zel5PYmVnOByVGC684V2XkmuMptaW7T4ineDHtYhXsc= X-Received: by 2002:a17:906:5a9a:b0:a43:bf25:989 with SMTP id l26-20020a1709065a9a00b00a43bf250989mr2123273ejq.9.1709331474575; Fri, 01 Mar 2024 14:17:54 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:17:54 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 07/16] net: dsa: vsc73xx: Add vlan filtering Date: Fri, 1 Mar 2024 23:16:29 +0100 Message-Id: <20240301221641.159542-8-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364108872373807 X-GMAIL-MSGID: 1792364108872373807 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 --- v6: - resend only 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 d1e84a9a83d1..c643f445f026 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 Mar 1 22:16:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209104 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp187761dyc; Fri, 1 Mar 2024 14:20:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLgrGtGIdrSEovCGMv+XgmBhI9GKDod4jLRzViqos9Fpoq9fnKXP4PTVy0hjtz9fcGydhKZxgBSZ4XaFKhlR0Wpc/lfw== X-Google-Smtp-Source: AGHT+IEjFbl+xGgQfx7B5CwL7ugumARI72o5IT74kE2B5bsUkpQhJZD4F3XGOpFtx4X5wCaRdwz2 X-Received: by 2002:a05:6808:3c8d:b0:3c1:8066:7531 with SMTP id gs13-20020a0568083c8d00b003c180667531mr4575668oib.26.1709331614371; Fri, 01 Mar 2024 14:20:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331614; cv=pass; d=google.com; s=arc-20160816; b=nlGuPhStc/PLSowAtPWwrgf6/tzDnTuQPJP6hsPJjKJ7cSZ/tvGCSXbvBPOBKdlwm/ elCHTjF3TFXI5Vo7TPpLyHNLCbOtrzliSMCA2c0IPG6vWDRNEzu6Oii7RMzrjyKhCB4T Es/YKsFf3cP3Evhy8ykLItaXs1TJHvNXvHBmuJD/0azJ31wTqJQo0AaDiFP/sBay8w/7 YeFE6KkbGx087M/EUTI17r5FJpBMcoYjkd5wnFOUsto4geDMEpquw4KGyWSLnICo3/Xf MDmQLIqPrszIVc7PuYN5xLP68j86sPZx5ASQTI+YVXjljJlYfnPyU+bVC9UNRt36HeFN uM6A== 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=9U/RPAQekDfsiTLh+gi653ipzg+ntrQzlfFlL0y3WFc=; fh=xgOU9t3j8rw7tuVUjy1cVrn4S8DRH1N+gLkZqVHXww4=; b=exZ6n9NegB1gJPOKJwaH9rFcVlaEwIsvq+xfguOLL7rr1ddXH+q5U79lDEWctNX+fH dXtlqBoMe6ZCGUiLUddAa7kbaNr6rnh7GNK1uXpiSz6p1R4Ah0BXDUCzcVUJBnC3rnsN ueltSCygJe5M6q9QGYA2fQa7SmtU0IdqP0wdQ89gBPg6tzFOrVLpMu1rZ3D8DuVBLacH +slFUhwvT217slQlE17fEfslLXqNAyY/roYXa7AJ/6hxvNguX5SMaglGWcJkXk76s/1l tzLN/d4gwO66rljgttWNWXqOUAHGAD0DApHesUdk8hS5/AyZY+6X+rJP/9Ohcv7Uh+LB l2Uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Zz3z4Ugx; 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-89183-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89183-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 fv1-20020a056214240100b0068f58ecb142si4417064qvb.583.2024.03.01.14.20.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:20:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89183-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=Zz3z4Ugx; 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-89183-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89183-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 043FA1C208A2 for ; Fri, 1 Mar 2024 22:20:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9920E5C5E4; Fri, 1 Mar 2024 22:18:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zz3z4Ugx" Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70F1C59B7A; Fri, 1 Mar 2024 22:18:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331482; cv=none; b=W6/g6//Vya0Sr4cvmWxhxMoxMmNEYUF2ynBwExFj71BNHUwRvvUG82FcT2SeZfiWgHxexxddf4tbNy9LUiw3yea0El+WX8X8Uy+fft9s2pPXvEyx3BSadlOOeO5cF+cLoHtM+lMde2QQ/REwjZRrCB5PF2ICRPgvSsUQKBAdwTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331482; c=relaxed/simple; bh=qX9bMC08bJpC9TvDx/M1Rc2xJM1aKrcgzAL/tAfbyIU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B9wXYcnVuf2I4xDc7m/9dxVjTIucBt9Y5Nos2x8Lff+/UMdK4H+euqbSW/TBKwetUPGNf+gToBMo1hENNfUlTIkUcm8fsogpK2aVRzZzZ+O82UkFic5uL2V3WcfjfCzxCLLT6klciQ+sxkKmodsV411/Y8vNudVEK5uaUmokY40= 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=Zz3z4Ugx; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-566e6192da8so1376468a12.1; Fri, 01 Mar 2024 14:18:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331478; x=1709936278; 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=9U/RPAQekDfsiTLh+gi653ipzg+ntrQzlfFlL0y3WFc=; b=Zz3z4Ugxkoc3ElDXWA9ljndKjUIB7QpXl3Db3a/DhyfklmStMdyhrGs41T0MdtORtH vgmoSVE+ExBttGIaB9I2/Dw/ZygKIBEfPFwPLJ3TVNxpm9JNygGISmyRRoivER+djLKt gCce7wVpxi1ivGKOe43Y++b5C1ZPWzJmBZNpgPJyuM/PkGHem2fxaUpu7TKg/4pWJnLS 0p34gSLTQEvptDn9AAOMnb9DxYfqLiuDuPFOKUsglqEJnkljylqRnxWUpGuutsohnTGO Acnk1sj3M9uxiIgueMVMCyPfK4gHzQ5bpxquqomzLDuTeik0bpabBhlwU9eAMc7siJyN UvDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331478; x=1709936278; 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=9U/RPAQekDfsiTLh+gi653ipzg+ntrQzlfFlL0y3WFc=; b=gocafSEfLhMdRBuA4mvXPGZBeB+o8IDMduR6cRPV3wgfYgDc13qBO7Ez2InfUSderF bybF3oezFaPax3Oc2qGy0vXEZzOzSx0qQiQ/igrwcKQwo9+W2GA0idcX29ty95ieRFTo OdMY6d3esZbiaBk7dQCPwRgNhoXouoY6klNYNMV1yn6CY1uF0Evx9jX2J8LUkBonMgHD mtmk/3MD/UFyGlsZU0JYMhqIUjAP/jNw27CzecUNheXvoO57xJJWb2UIl1hMmwYBcxSY xlXKBT/Zftnj7QUCMoGVh0LRC1f+KXjSgQpcsyD0MzsyQ8AR44urzIQF7IgKDTo3EvVj Lcxg== X-Forwarded-Encrypted: i=1; AJvYcCV3dHJDWkq/w1xSlUT0MffyDYoXTTys9ZirlegY9pt9KVzhsWQJiHK8PI7VxGK8tHf7WTrPGCWVuFwPSDxkNdC0sGWLaiG7Cs0nf8eH X-Gm-Message-State: AOJu0YwzHB5Zq8qU7lTklS52pRTFF/qhaNSuJ0FocK4B98xD81HFT6lq aCBgZXSbHZCYsyfHIZ9q9Wx3Xdz8zyBn+3Xo78mUOD84TVzI6FlEv4NtrNkqKvM= X-Received: by 2002:a17:906:f35b:b0:a44:19f2:1be1 with SMTP id hg27-20020a170906f35b00b00a4419f21be1mr2557643ejb.5.1709331478484; Fri, 01 Mar 2024 14:17:58 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:17:58 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 08/16] net: dsa: tag_sja1105: absorb logic for not overwriting precise info into dsa_8021q_rcv() Date: Fri, 1 Mar 2024 23:16:30 +0100 Message-Id: <20240301221641.159542-9-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364106767776087 X-GMAIL-MSGID: 1792364106767776087 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 --- v6: - resend only 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 Mar 1 22:16: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: 209107 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp187966dyc; Fri, 1 Mar 2024 14:20:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWYLBYD5tb6ChF5FEg7BxrJVNJBTaYAiviALr5jSqbwL6ikSxKg+nVMhjPYTR8T9z9EVzgwoAQQ02C+n/zUXKTJCjxZ2Q== X-Google-Smtp-Source: AGHT+IERlCtzDalKW1AfpdToBDeDSA9+f5w1RMsSYiA/Aq1m/bjggHEvh4PdualqZWbJfvSU0ZDT X-Received: by 2002:a17:906:6d06:b0:a3f:86ca:ed2f with SMTP id m6-20020a1709066d0600b00a3f86caed2fmr2232820ejr.49.1709331639038; Fri, 01 Mar 2024 14:20:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331639; cv=pass; d=google.com; s=arc-20160816; b=XyQYxSDAfJN0j4rD/KpsmPXCf3Q7km2E8Rxe6TD1rzzVfYvafKitJpOjPbPmUYmWt5 B6c9w0lUo2BBrNGsBnyZItGIbEWUdGvEChnsIuVYD9m4mi+x7c+Z+dKZSyi3+NSUxC0o 6RnlJ7WhYzWFpgruvCMRGcbbrXHMGVYxW6V7c91cWOJ7hwDhS0nwm8lxOzjGw9MdnO+J kKMelR9Wv4Iz8gsRALOa9R6ORy4G660Xq0N3NO8mdKDNJAZqCIB6iNRefB60VqVv8ZOd 2RWHSlQdlBIArDzs3TS+2w4W9hPDW27m6gn8BUh8YOJ3kThLDdYwDCI/1JzDCrBbUlP8 flHA== 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=JU9X249kHtPzT0alvJAjDE6UcKYnwGN6FTBizoJpsAw=; fh=U6zXtyk2erT1uvlqgZgk5BX/B5Bn0TfPuBtfMMM1T2A=; b=CmffLatXVVw8heda6l8raoxvwZW9M6ZHMKslqYZXwKjb5bJgHQUIAy25Omxj7IYkVb 4tPxyfAkaMqCLxD70XLwkAMr1+JPyhrGfnLcZtON3wluAvDrypP4KZbjchwaYWn6ltwl uCUBX3YzEEe4zG9tf13sJmplPEdy/jMpcCFl8hS5URZw/aXvtrtoxL98+onVd3tJZacG +8DbZ46XivcPjk8PUcDc5WPhu9SuZIKtu7oOJC2wpIRzJA1gfHYdL2lxu6DXTATep1/4 ySLqE9BDl1JeCcwjVbeRsuyRYbkt60RvOe6C8HQIb9XW5bK/SaTk0zkUx0Qeg6DeGqoZ pKHw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=htKi3izk; 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-89184-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89184-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 ji8-20020a170907980800b00a3fa6c624absi1781259ejc.866.2024.03.01.14.20.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:20:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89184-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=htKi3izk; 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-89184-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89184-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 737821F2384A for ; Fri, 1 Mar 2024 22:20:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A4615C604; Fri, 1 Mar 2024 22:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="htKi3izk" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 748CC5BAFE; Fri, 1 Mar 2024 22:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331486; cv=none; b=kVnZJYOyP9AKvuVWdRKxYDLmY6VfFPo1LnpugmItclFneawUShfccwKLd+w1bLGTRwRPyLb6Z+mTqaxDAylsRLMMCajB63mXqUofTCzImhlDbLYJMWFzCPnKY/dieYHdK1hKAVKqZA5AMjpahNLSnI1z3PCQRbL3pIL6W8h+KWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331486; c=relaxed/simple; bh=RrlHvI43NWEIkK07lbs2CrYemJqLavaj66WPTKAVubY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h+kMjz9izWJE+fy9ewAGMvD9KHRoWZW+ZfQ7Iw6NDpqaRax90Jjd3BocUBBwQmK41Q1DE1oDkTE9eCsZ7izXzkOAMD0f2TlyHdMfsNn3I17gZGZ/1qV6IEzRN93sMpnb31hFNgZVqrLn2dpw6ANNku/fuUN52s0IjibL1v15YUg= 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=htKi3izk; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a26fa294e56so489656666b.0; Fri, 01 Mar 2024 14:18:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331482; x=1709936282; 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=JU9X249kHtPzT0alvJAjDE6UcKYnwGN6FTBizoJpsAw=; b=htKi3izk1sB0pDyoIlNOHchK04JI/nxsVrb+AQEqB2p/X7za9TFSe5iwEZagL9jPJg vIe15tmrsRUNWOjeKLkb9agVGIC1xJJmBwUpyseIcf/zLVmH2K9hyKgTUP9W91ugs1iV d8GnXm7vihYp0eh61NADQFa4tVkvV2YJq98HR9PH3hC8yueCJ0AD7DAQvcAYXtGSvfyj DAhxGt2e9h4TLP7G5Po3Jhy4qmaeYHrhUIZ4svqWQSH0WJYlfhmGhIkgs8A3waE5VMLq nMQbhDQcd3b4tz0C83EZXittp4/mETlYwIbQMlPjLl2rfN/FKR7spOAdYfGKRZ9cJsYr AjdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331482; x=1709936282; 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=JU9X249kHtPzT0alvJAjDE6UcKYnwGN6FTBizoJpsAw=; b=pvzsLbHqVbDMNtNcyzVGMgicgxE0kTf/mSgJQI3ty7/FqZKLh3ocx6pU/98YtMpOYa UuXvUCcLregShSOaWEJb0ReQLlZ/YyA5o89V3WBRwmqd4UDmfT2j0OEVfahxAZ22Uf8u 0zOTCRqZbirr8rwy7euDoSCBTd015TcNe7PVMk4b/8DSwvY9pFmQ9nJCJnq+dblliieP HbWWTpSe2UPFXWMGolIMUDVMAxP5zzAhMSq4pH3e5Gk/bO5voefB5I8mIC7146SKyRAg 0t9gQFFYdXuez1G6RsZRlRLbMKZ8R9RsigzttcKl/n2z+KfLhN9ov9kS6wc7OdwAidzO gIsQ== X-Forwarded-Encrypted: i=1; AJvYcCUhH/7mB6vyLpZ2VSdsqGcOpu5AYwV+wiPHyGW3ITBgmXK20qAbHkZZa31Kc2+rR+O9oxyojIyiR1VKjF/bDxGsaJ+D2dTmzBiRFgcg X-Gm-Message-State: AOJu0YxzqKDwOAnW7h0CbX0GmDjEDHMCv1orT1FNvkJ3mnahlkGSVvNv TTWW/bzvIecYGr/uz+c29FmkEVi1pQdx8cb1+GbKjVe7ynG1dA3g9FJfQ0A/nk4= X-Received: by 2002:a17:906:578c:b0:a44:1d7d:fb57 with SMTP id k12-20020a170906578c00b00a441d7dfb57mr2319716ejq.54.1709331482470; Fri, 01 Mar 2024 14:18:02 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:02 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 09/16] net: dsa: tag_sja1105: absorb entire sja1105_vlan_rcv() into dsa_8021q_rcv() Date: Fri, 1 Mar 2024 23:16:31 +0100 Message-Id: <20240301221641.159542-10-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364132652651899 X-GMAIL-MSGID: 1792364132652651899 From: Vladimir Oltean tag_sja1105 has a wrapper over dsa_8021q_rcv(): sja1105_vlan_rcv(), which determines whether the packet came from a bridge with vlan_filtering=1 (the case resolved via dsa_find_designated_bridge_port_by_vid()), or if it contains a tag_8021q header. Looking at a new tagger implementation for vsc73xx, based also on tag_8021q, it is becoming clear that the logic is needed there as well. So instead of forcing each tagger to wrap around dsa_8021q_rcv(), let's merge the logic into the core. Signed-off-by: Vladimir Oltean Signed-off-by: Pawel Dembicki --- v6: - resend only v5: - add missing SoB v4: - introduced patch net/dsa/tag_8021q.c | 34 ++++++++++++++++++++++++++++------ net/dsa/tag_8021q.h | 2 +- net/dsa/tag_ocelot_8021q.c | 2 +- net/dsa/tag_sja1105.c | 32 ++++---------------------------- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c index 3cb0293793a5..332b0ae02645 100644 --- a/net/dsa/tag_8021q.c +++ b/net/dsa/tag_8021q.c @@ -507,27 +507,39 @@ EXPORT_SYMBOL_GPL(dsa_tag_8021q_find_port_by_vbid); * @vbid: pointer to storage for imprecise bridge ID. Must be pre-initialized * with -1. If a positive value is returned, the source_port and switch_id * are invalid. + * @vid: pointer to storage for original VID, in case tag_8021q decoding failed. + * + * If the packet has a tag_8021q header, decode it and set @source_port, + * @switch_id and @vbid, and strip the header. Otherwise set @vid and keep the + * header in the hwaccel area of the packet. */ void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, - int *vbid) + int *vbid, int *vid) { int tmp_source_port, tmp_switch_id, tmp_vbid; - u16 vid, tci; + __be16 vlan_proto; + u16 tmp_vid, tci; if (skb_vlan_tag_present(skb)) { + vlan_proto = skb->vlan_proto; tci = skb_vlan_tag_get(skb); __vlan_hwaccel_clear_tag(skb); } else { + struct vlan_ethhdr *hdr = vlan_eth_hdr(skb); + + vlan_proto = hdr->h_vlan_proto; skb_push_rcsum(skb, ETH_HLEN); __skb_vlan_pop(skb, &tci); skb_pull_rcsum(skb, ETH_HLEN); } - vid = tci & VLAN_VID_MASK; + tmp_vid = tci & VLAN_VID_MASK; + if (!vid_is_dsa_8021q(tmp_vid)) + goto not_tag_8021q; - tmp_source_port = dsa_8021q_rx_source_port(vid); - tmp_switch_id = dsa_8021q_rx_switch_id(vid); - tmp_vbid = dsa_tag_8021q_rx_vbid(vid); + tmp_source_port = dsa_8021q_rx_source_port(tmp_vid); + tmp_switch_id = dsa_8021q_rx_switch_id(tmp_vid); + tmp_vbid = dsa_tag_8021q_rx_vbid(tmp_vid); /* Precise source port information is unknown when receiving from a * VLAN-unaware bridging domain, and tmp_source_port and tmp_switch_id @@ -546,5 +558,15 @@ void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, *vbid = tmp_vbid; skb->priority = (tci & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; + return; + +not_tag_8021q: + if (vid) + *vid = tmp_vid; + if (vbid) + *vbid = -1; + + /* Put the tag back */ + __vlan_hwaccel_put_tag(skb, vlan_proto, tci); } EXPORT_SYMBOL_GPL(dsa_8021q_rcv); diff --git a/net/dsa/tag_8021q.h b/net/dsa/tag_8021q.h index 41f7167ac520..0c6671d7c1c2 100644 --- a/net/dsa/tag_8021q.h +++ b/net/dsa/tag_8021q.h @@ -14,7 +14,7 @@ struct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, u16 tpid, u16 tci); void dsa_8021q_rcv(struct sk_buff *skb, int *source_port, int *switch_id, - int *vbid); + int *vbid, int *vid); struct net_device *dsa_tag_8021q_find_port_by_vbid(struct net_device *conduit, int vbid); diff --git a/net/dsa/tag_ocelot_8021q.c b/net/dsa/tag_ocelot_8021q.c index b059381310fe..8e8b1bef6af6 100644 --- a/net/dsa/tag_ocelot_8021q.c +++ b/net/dsa/tag_ocelot_8021q.c @@ -81,7 +81,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, { int src_port, switch_id; - dsa_8021q_rcv(skb, &src_port, &switch_id, NULL); + dsa_8021q_rcv(skb, &src_port, &switch_id, NULL, NULL); skb->dev = dsa_conduit_find_user(netdev, switch_id, src_port); if (!skb->dev) diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 48886d4b7e3e..7639ccb94d35 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -472,37 +472,14 @@ static bool sja1110_skb_has_inband_control_extension(const struct sk_buff *skb) return ntohs(eth_hdr(skb)->h_proto) == ETH_P_SJA1110; } -/* If the VLAN in the packet is a tag_8021q one, set @source_port and - * @switch_id and strip the header. Otherwise set @vid and keep it in the - * packet. - */ -static void sja1105_vlan_rcv(struct sk_buff *skb, int *source_port, - int *switch_id, int *vbid, u16 *vid) -{ - struct vlan_ethhdr *hdr = vlan_eth_hdr(skb); - u16 vlan_tci; - - if (skb_vlan_tag_present(skb)) - vlan_tci = skb_vlan_tag_get(skb); - else - vlan_tci = ntohs(hdr->h_vlan_TCI); - - if (vid_is_dsa_8021q(vlan_tci & VLAN_VID_MASK)) - return dsa_8021q_rcv(skb, source_port, switch_id, vbid); - - /* Try our best with imprecise RX */ - *vid = vlan_tci & VLAN_VID_MASK; -} - static struct sk_buff *sja1105_rcv(struct sk_buff *skb, struct net_device *netdev) { - int source_port = -1, switch_id = -1, vbid = -1; + int source_port = -1, switch_id = -1, vbid = -1, vid = -1; struct sja1105_meta meta = {0}; struct ethhdr *hdr; bool is_link_local; bool is_meta; - u16 vid; hdr = eth_hdr(skb); is_link_local = sja1105_is_link_local(skb); @@ -525,7 +502,7 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, * a tag_8021q VLAN which we have to strip */ if (sja1105_skb_has_tag_8021q(skb)) - sja1105_vlan_rcv(skb, &source_port, &switch_id, &vbid, &vid); + dsa_8021q_rcv(skb, &source_port, &switch_id, &vbid, &vid); else if (source_port == -1 && switch_id == -1) /* Packets with no source information have no chance of * getting accepted, drop them straight away. @@ -660,9 +637,8 @@ static struct sk_buff *sja1110_rcv_inband_control_extension(struct sk_buff *skb, static struct sk_buff *sja1110_rcv(struct sk_buff *skb, struct net_device *netdev) { - int source_port = -1, switch_id = -1, vbid = -1; + int source_port = -1, switch_id = -1, vbid = -1, vid = -1; bool host_only = false; - u16 vid = 0; if (sja1110_skb_has_inband_control_extension(skb)) { skb = sja1110_rcv_inband_control_extension(skb, &source_port, @@ -674,7 +650,7 @@ static struct sk_buff *sja1110_rcv(struct sk_buff *skb, /* Packets with in-band control extensions might still have RX VLANs */ if (likely(sja1105_skb_has_tag_8021q(skb))) - sja1105_vlan_rcv(skb, &source_port, &switch_id, &vbid, &vid); + dsa_8021q_rcv(skb, &source_port, &switch_id, &vbid, &vid); if (vbid >= 1) skb->dev = dsa_tag_8021q_find_port_by_vbid(netdev, vbid); From patchwork Fri Mar 1 22:16:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp188403dyc; Fri, 1 Mar 2024 14:21:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUAE+u9+dKW0pTn9hJtFY43PcsSUeO7AvfIUiLyOnNqNtKTIJKsmBorHtI89HLpWeaZabnsB2WjFIzEpmA95utzyIFgNw== X-Google-Smtp-Source: AGHT+IG/8wP1GJ5uCdSOCNUL2fARxQc6mmIQg02oFf0NYZXWPUvr/NeIeXotg5syFNL+xYXstuxD X-Received: by 2002:ad4:5890:0:b0:68f:ddf5:abac with SMTP id dz16-20020ad45890000000b0068fddf5abacmr2745204qvb.7.1709331707546; Fri, 01 Mar 2024 14:21:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331707; cv=pass; d=google.com; s=arc-20160816; b=T0Pz3lFd9kpPOhLLQ3pTYAJM68FHrHSTMfLWNGx0AcrN8cs8gKgLBXPcHoUOCOR8Xi 7y3HLabe4LlmlTfFDqPBPdqepPQU1bxuA15Woh1U5zRMba0SbRhrZTyV7JxIIvZXrgyC NAc/+WKGBs2V+OMMDil/hRSEZ2RtpAGk1vp5Mf2t5X74Ca74coMm6/fKg4/PyrJ8N4lV 8/lgQ9B4vcY0wrB1sfEfCCMiPFKUSIHG+I6rXz1jSLnicSe6mRxrw+Pq/smQI055GcWT Avip66qD75ZdE3eI1GzOaAOw0eENKbtHjTsGInUMNixyDoR/F1NC7kcdKiZpHsnTN0++ TP9Q== 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=8eAOK6LG+DqrzRy5jAnNYEM/hys4zUVsiXRG3NHFhSI=; fh=KAH+Yoo7cqi+NrKXVTNaEqVALf1m/UVuHvW/DJOrHAA=; b=k5x4ydTFU4akkaYTy4o3Rp2z9sBmzI90GbrHNHACJ5iOQFSgaVzwxRgp/ATCf03pp+ oD2aL3Nf8V5YdgEA6FRObz1feurwilDRpr9CUapDOxGtrEILb0sbms0XfEJC0qgXiqox tNCjdEkowSuvF8Z9jN5PWvFsTq1dxMI5bwrlhZc+PDuBRmmURLOfact8V0MwH3gtanEr 6I8lpHco0F0Mp8/VbNGwDizPVXe/Rxnm/KyiOWQW6HGXUqcfGpB8jgJxBbGet9ShsuFx rZGsg1RwmtUcbwLn1W5pguNQ64TfK5zkIbP0bFLsiLhCy6BK6ku573S1dU7unhKdc7tV BzvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fOkF0okA; 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-89185-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89185-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 ks15-20020a056214310f00b00686a0c905e1si4340980qvb.463.2024.03.01.14.21.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:21:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89185-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=fOkF0okA; 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-89185-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89185-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 1EABE1C22289 for ; Fri, 1 Mar 2024 22:20:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C7AFC5C912; Fri, 1 Mar 2024 22:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fOkF0okA" 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 3E70D5A0FA; Fri, 1 Mar 2024 22:18:08 +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=1709331489; cv=none; b=F6GiUweeFvOUehzmZXiGz9VWlDnA39LZnpxOETkF7WJSMfTd4syZvQvoEQXmBE0NvmQP17vacD0xGPaLxaa57+1lI6mxtpslB7sRhvZWVvVTAmNtAPeat9m5b9kpRyGdZAntZJkNR2bf8DLuNLfaMjFjeAGUi0P21mIu2yxLUEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331489; c=relaxed/simple; bh=Mpw8JDktOqAHVSnGhPK7OvlSmt3P/Pn9/iGcawwaPNA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rHUDMxMMkopDzb+hy3wHf+jTFVKLMPQ0+4f+1ycF7dXqng3GwEmBfgBnSWwMKRdyFLHEMP/nNgFatzelQS0NruDQO1oaIjM/1kp44SyAH3FjuG8r7lL18o0P+XHJ1m45h9GweWcgJIGyqMzy3LHjTIoGPNve9ikMpH/i25Uaiy0= 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=fOkF0okA; 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-a293f2280c7so497772966b.1; Fri, 01 Mar 2024 14:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331486; x=1709936286; 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=8eAOK6LG+DqrzRy5jAnNYEM/hys4zUVsiXRG3NHFhSI=; b=fOkF0okAJ7wZf0VYkVkm7GHBVz65sXVcMutqgBxfhlTqHogY0mtNeg/KG+tFnjYr1m H4rGSWBzx6sXJ/TA01HAD+aBfB6UVP8yKNUc14YYaW/nZBOt1G5+P/ElqwvD40wF0MBr XL/mLu3OxJkIe8rzfTxsM1XkQVJPcdqqUL/9tNq3pUhBONr+jmq5HdZ7si4SJlaRM5Ef zEqG5ZloNpaqZJ4RV53WPrln/BmxcL/evvQdZS25Sl3x2wmFQFkLLudjTX41F2CUtp/K gqCYqAiB7ExTAo7ELo/kPuyFvx3SpkRW3S8eOJy7BiGQKyd1sj6w2aKEaDdnoigZoDYM 3p4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331486; x=1709936286; 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=8eAOK6LG+DqrzRy5jAnNYEM/hys4zUVsiXRG3NHFhSI=; b=K3EXAZzyditA7j+9gG1b3KEvVvxSEe9kyVukfTRl/1ujWge/usi292/VrEp/KbLEMt ChvbURZVMB422BrKtf8JkEUxUClTz6O+YqiwSH+0wvZG29lykfrg6EZHGR5Cfy373uZj Na5iIYA+huro+j8hJQoeKWdCJhg9egppPMJ2zYTNuPPxSC1Qe5r6SMWBpL966Ph3Mnub N7Ofv8uJ+azhP8u5i9LeSBH7FPUtIqgBkNSswuNr6qyZEcOJ6Z0W6DrG8tv4/S3Dmire yZYq231SxjnSwt97OFqPtxS2O/uwDdFfG9yP120iTL+cle5/kf6mdu8AMgv8HD5IIjCb Q52A== X-Forwarded-Encrypted: i=1; AJvYcCW6S388+vbzvvxtNdUDeGpYp0FKYUBG6Key7sUyzBN3JzCzHeMWJqcgRe2cNTRSEZhsiumVKR/k6XbFwokOwYVMPJW7ZYEI9BAQbA3W X-Gm-Message-State: AOJu0YxfJjzHTOoUI1UepQPKhuDv43lJ/WcmiXRCFoRTRSRUI+VqWqUU +JHUaGjPNetwKuhvnDSLQOOcQU1rliL3kYgjUs0UNCA0/BlzwzrCBtaFWG3mihg= X-Received: by 2002:a17:906:4558:b0:a43:9857:8112 with SMTP id s24-20020a170906455800b00a4398578112mr2365844ejq.20.1709331486353; Fri, 01 Mar 2024 14:18:06 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:06 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 10/16] net: dsa: tag_sja1105: prefer precise source port info on SJA1110 too Date: Fri, 1 Mar 2024 23:16:32 +0100 Message-Id: <20240301221641.159542-11-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364204442378781 X-GMAIL-MSGID: 1792364204442378781 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 --- v6,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 Mar 1 22:16: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: 209109 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp188240dyc; Fri, 1 Mar 2024 14:21:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUidgX+L6SqNCgyV2Zx4PSSPojaLpmWJw7C4TdgSqTlJ7itJHb+ctdsSrUU4t1O1u2Y2VkCBaEQZWKNbyGBO+Mv5vF9dw== X-Google-Smtp-Source: AGHT+IE1VyxORNgy3djHmYiYWVdYkYEZpV+Ewe8L8JFPna2GC9kDNTDcXMoB8cxv76IPA4XXz0/G X-Received: by 2002:a05:6402:35d5:b0:566:ff31:7974 with SMTP id z21-20020a05640235d500b00566ff317974mr239566edc.34.1709331685147; Fri, 01 Mar 2024 14:21:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331685; cv=pass; d=google.com; s=arc-20160816; b=rwS4pVyBbFBrOuZv7QPeG3TP0dvdQDCRsFtWBsSYiW90bWIl9561qZPVXqhMbnlr/b MZEtZPYNLR84Q0tw/IjGu1d+MG9AyxIXZLF6y64fM0+iONnMiIEpWYoWjYCi7ALje9Xz lC9rYsEQMwMB/igi63f+SbuNfIZVFURie706pnWRQOhJ8OW1qP04D9ZvoSg8kucZw1LP azGnDBIjyGKR6AW2kyVHii7YxBrL3Hg6UMSfJB2YSXm0SFwN435/t/Vx34THFJt/cVYw lpqsqI0zTCYAhLTxI6R/cx1jIx+2UUEeswbpKYjOisaJkkgs4sIaPo7S5q7l6lNFqTxr Q/4g== 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=79CWB+FAWzBWpGynqkW+uoHcutiDjMhuchSIrgf3T2E=; fh=Ublt/Wfp2zCBaqmX3OOoC99OeWaP7CSsVxmOAdt1mZ8=; b=VquFKXjUNlRRjdaYbVklJwlL88QQQB4tuhEcYXgtEtRU1/rKKI6QdNZNtiEW7IGS0v SB6AFG2pbOGxytrjjzZmg7FfaWGxe3EOK9GHtfMQ+aSR0HVxcRE6PYlctL2F2r53tyl0 IhaWGhHwCQnCQivja8o592i+7MH41w9QssPtOdkfJ6OtClIMadfSZeWtb+xUnYIAA7eJ 1KqZiVYvc2gLPXNKY39MSdX1arDbJqIV8D3CA3QCLiuQjbKjy02LxEr+WO9bQkaheSYd gfe58gg7deLpoeyMzdo2pQhdr3htJRWbFM/pP8qGcuQDxsrLVdWTYF0cve6kKHYX+Exg ByoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jqhhlJJc; 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-89187-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89187-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 v20-20020a056402349400b00566c23aca61si1120403edc.331.2024.03.01.14.21.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:21:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89187-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=jqhhlJJc; 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-89187-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89187-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 7A1361F239C8 for ; Fri, 1 Mar 2024 22:21:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF9B05A115; Fri, 1 Mar 2024 22:18:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jqhhlJJc" 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 95F235C90B; Fri, 1 Mar 2024 22:18:12 +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=1709331494; cv=none; b=XFX0U1fcYRDjS3kd4itItKx5p9j2rb7Dkz39+QkkK0q1Q9rb4Cwjbsh7SewULhivGYtaRhy2baEFSe0A2HXnUFkL1GK+W0TNIOkML+YkW3hrFjqYUgY4/85IVg74K451R7I8l+Cr+4ztzp2eDz83mKk5NR+a0riMSW2roNTPQFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331494; c=relaxed/simple; bh=IfQrtti16WuHwjOGf3KP2KKdwU/2ZkAy/e81LJ1LFZ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B0RDCAT/7ro2W3w007rfbfzbhad3qTp5PqUJdGaf+ymXAl8Rcch9I+eVuMnWiSwzoZ4hkCp4KpwMPpEkEBhYtSS6Ua2vrGVg4Q7/h6go9RYDb9MalFwIKOLCA0TT6k+BXsaM3CPLlpgiAqwiEeyztpSpEnStZG4fBDLoTDZ5Qxc= 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=jqhhlJJc; 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-a44b0b2c7cdso121140066b.0; Fri, 01 Mar 2024 14:18:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331490; x=1709936290; 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=79CWB+FAWzBWpGynqkW+uoHcutiDjMhuchSIrgf3T2E=; b=jqhhlJJcT8eCacloxSwAtv3jZOCu9cDz99177FW1J1U/ryrKP6QEJMfmKOZtYQKSqk usBVTDULyqBoAoYfvehNTO2dGGfYctHT0wTl8m6qNJv6iyjn4UkkEzuzf8CQUvEzvIpz Avi5yMBRXNJ/effZMsvTHb82rLQ7wclARuENC/TdM5CDLj95z+2kbC3Lrdo7jGZ7VFU+ HIXkqxbqAHeZKwWMfr8dai70xjRg+OHnQyurJZkIUkdaCh1Bg/jhBtxFUYIXPc+1Wewi 2uL3KwPCoNFqFMjAk16/F/ZWeRvzfDpvAa9yK19x+8Y7TnfzfVTq84ow7NCNdIZlVMFj 7WeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331490; x=1709936290; 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=79CWB+FAWzBWpGynqkW+uoHcutiDjMhuchSIrgf3T2E=; b=MovO2M526IsZejSl7Lzw1BTvMOCDSNGbwSKNzH0T29+9SNS+KzO0mYf48WRXAiLkgs VqLFvLXUkQDxMZDTl/TED/H1YO2e5BWnYCGigYQUB/dGq8STachhW7Q/CPDUsKt+Z5cH U+Vn+RxntZLErRpuqqGN28ddmYPg6Bmle7unDKMPb1eBJow9hyIWRm3RCBvIK2t+bUlt HrlB1EhGwCWfUZhnsP4QV1eZDsskYKujrZ+OA/34fNJpDXwNGO8WCDITX/IzLfhZcyDG aLP/tzmMyruOxibYqNFl4pdO+gBObZesOgh/WtoRYb+rAFy4ZWccLwjF1kgKGxhnFCU6 wfUg== X-Forwarded-Encrypted: i=1; AJvYcCVpnVLtVU7ha2vc7eWvIQpjOWClzyDJK9WNikTgZ0pGuvQaJ9M5I/ZcaO/zcMzrbZdeIY8HLBHX/XQxETCrCBSmWrVuSk0Sza+rDyLr X-Gm-Message-State: AOJu0YwtRafdiiTHElY8pRTXwL2pxchY7x74srX2bUl3N4xjuvqMrY5X PsOJmDiQ5wcRGtRTCTQOkOtrsvnexS6I1tOLRVqOlC2I/OA3+oa2kUwKAdpa+Gw= X-Received: by 2002:a17:906:fa92:b0:a3e:d5ac:9995 with SMTP id lt18-20020a170906fa9200b00a3ed5ac9995mr2106250ejb.59.1709331490348; Fri, 01 Mar 2024 14:18:10 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:09 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 11/16] net: dsa: tag_sja1105: refactor skb->dev assignment to dsa_tag_8021q_find_user() Date: Fri, 1 Mar 2024 23:16:33 +0100 Message-Id: <20240301221641.159542-12-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364181135240566 X-GMAIL-MSGID: 1792364181135240566 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 --- v6, 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 Mar 1 22:16:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pawel Dembicki X-Patchwork-Id: 209110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp188373dyc; Fri, 1 Mar 2024 14:21:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWZHZbeB7ngF4qZdaeLeVNJmgldX2knxapldDh0cADuwA+6m1g0o7npENmfYm4p/Yr9tTvOLXkn9HKZPnFmu1hf3Xc5gg== X-Google-Smtp-Source: AGHT+IHC8hFvKujpias5tP6XDC/AZOaJ9hBavzdoRAwV1XXWungmZOyMQWNdNwMExfereFDxdFOx X-Received: by 2002:a17:906:8c6:b0:a44:4d9b:9069 with SMTP id o6-20020a17090608c600b00a444d9b9069mr2153917eje.49.1709331703612; Fri, 01 Mar 2024 14:21:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331703; cv=pass; d=google.com; s=arc-20160816; b=0PH9rRHG11VNBV5axrqjPO5k5G6fS8PZKJr6HAGGEFo7yKTDbiGg4AUfv4nnWtyKIa f26S6mZEsYLV1UfvMnXwY/I9DCxMv0Eol05mKKf1dz2GrVCo7AZvVl0IR4Wg8ZXC36S0 5bRncQon03mLfuGLkT0981Ju9O79u1i1DD5JC1hnuG85EoXn4kMUr4Rv4qLZVg2k7wmc wmAvM+N2VIhes5gWv+Ges4FzzVfy5aYAMhXjOxJgnlEWYTyUmOJS4BmZDAiiNZwpSqgb 7V8zjxPZC5iOHccdvdObbah6E3FXl8vPQduVdoEtQ69tXx+L4jWVMLM3Oy/fiO2MO5ul sbCQ== 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=Vn4+WllD6JXLNkDjfXdWXQe2i3/2663vlUPRUYagr8w=; fh=3jA4nih41mYdWC+Vys7PG5yjDJYpfW99NK6DZGOAUFw=; b=PCN/BdwSBRRx1L+7Dq/+DbUmLdl3Xg7yfM7wzu8gjvYZCi8LV9dY6O8AKR543HUn21 kDK1FDyNjPFTUjkw0N8hV+gyVuAao5+W2KxnZoAVsQqC4cB5IVK20WGCVcFzaGxmSma2 +7dP5VBv5H5MobfcMZ1J+yQF8ufBsY0mDXsol1FCT31XBisb0O5KjIqusi1fW89GSUWt 4SIrocVv3uH4TT/Qn9crEC3JFhSGGAahGxTdH+6rnBlMfwL7xlYL8eYFIOB5oTojfsjd vvzQusTC+Co8v/ZnteG+lnOCApCEq2Tonz4y1fk0Fxkz5HAy168nnEZVMveb8dov/sBV 8N3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="e23Vp/Ns"; 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-89188-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89188-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. [147.75.80.249]) by mx.google.com with ESMTPS id hr40-20020a1709073fa800b00a4160485d26si1848352ejc.1041.2024.03.01.14.21.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:21:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89188-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="e23Vp/Ns"; 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-89188-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89188-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 118231F23212 for ; Fri, 1 Mar 2024 22:21:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 745125915F; Fri, 1 Mar 2024 22:18:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e23Vp/Ns" 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 397DE5D488; Fri, 1 Mar 2024 22:18:15 +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=1709331498; cv=none; b=JhY2jII6hThkO/uwQX6gh32WBu177O7x79bZ3/hqOi6ai+RjNjuoPr4gYd7P15p5VBz1UVqxo2b56vi2EftnIqnbrl0s3LmR//hem0CsCDNYaOEzxmlsi1/2W9CW5dX6Z7Pbgj2wCRpQX2+SZ0RdQgrP70HcSvp7QGyChJMxumQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331498; c=relaxed/simple; bh=/1F9YYIoPOojx+Y/5PVuMCp5WWB8XjaIlMq3YBpJFJk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=og+tiwoIMWz5r3hNkVtE1Hs7g4VoSx7MkQOr/Kl+D+KBlm4NtzQPQUmGo0WNaDqml8GeCluTv5anLarQiG95KWaRJSW5sOgntg+//u9Q7iLOBx6j2A1sP5GyJCmWa5vj2/2hhML5cGBXyjirJdraTw0YxfANQYpc6TNajsoccv8= 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=e23Vp/Ns; 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-5643ae47cd3so3772387a12.3; Fri, 01 Mar 2024 14:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331494; x=1709936294; 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=Vn4+WllD6JXLNkDjfXdWXQe2i3/2663vlUPRUYagr8w=; b=e23Vp/NskZ/RkTKEw+Mnivzf87CMuVF/vjtJVntVxwOu3rPn9JLQynn/2eQe7GwPKm 7C5m+ZvAiqGD0wYw8ZFPMFxQR8UVPyeopvvmsSvbpIPAweFwWWZmNvV8dKo3TCVcpBNN qRqFadL16UuiKkhzbXag+bAxFkV7qM08d9up1D6EUr+c9nE5M9SyQVQyhl/9cbyAhDTm x7Jd7TiMvFURVC1E7s3j6yzmkQc062sZnC/MOiR5A1M0/FF103KDPNNokPKKcjyHr5hd JLX/1ThCM8lcJU02mh8W9iOAx1tm6NCeAb9Y9qCPu6dsA43ppyt9sFsYd9fq8dSgqFor 8U9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331494; x=1709936294; 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=Vn4+WllD6JXLNkDjfXdWXQe2i3/2663vlUPRUYagr8w=; b=UdljbM3YCIiCC+0WxRlqNU+OPVnNoYV00xR7x9yG3JmCK4JbrXL1UhAsWbcOoS3FdJ FAq02mSlkyhH1irrNwrFgyYPvU3Ntq2lP6JCKHv1Yz+kRCKwlqQHSQWfF8DLPPJw4IIQ 6LTgjLGQdBBo5gka+s4jXx4T6kbNgEWooAaUXxW0kQee5NiBLaHIpd9MMN1GUUbUEapq p1sGGBH0n45prp4xOmxtdSboKYieLYgnCdBV/AlWGSJrfHFEUCTgg8hyzdrNbWO7lGSR BDGIDgM7dtHAnj8zmnCj4W7wOSlIGajJXYeEG0zNIxZNW0t0v2h2Or+o1AHsfqql/v9W nOmQ== X-Forwarded-Encrypted: i=1; AJvYcCWkxMapekGO2Priw8JIwbLRwUwpov07LL/hoGD793bnTlIdVbXH4mUeLTFgyi+7euZFnNrSkqL43CSnDIxxqqTBbuFetpVeSr9CXSZY X-Gm-Message-State: AOJu0YxpxRtlLg7hA0XU4RZ/SdewBYFfiPBX0Ybu5W1EIwiCAy8FT4DH AySf+YkdJEvxmo8/C4t94iyic+cHDidA1vy3cSodDuT0/cD26vBbrT1dUBOjb6U= X-Received: by 2002:a17:906:2b15:b0:a44:56cf:b58e with SMTP id a21-20020a1709062b1500b00a4456cfb58emr2306121ejg.18.1709331494356; Fri, 01 Mar 2024 14:18:14 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:14 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 12/16] net: dsa: vsc73xx: introduce tag 8021q for vsc73xx Date: Fri, 1 Mar 2024 23:16:34 +0100 Message-Id: <20240301221641.159542-13-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364200616209652 X-GMAIL-MSGID: 1792364200616209652 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 --- v6: - added missing MODULE_DESCRIPTION() 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 | 67 +++++++++++++++++++++++++++++++++++++ 4 files changed, 76 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..f7bc0261d54d --- /dev/null +++ b/net/dsa/tag_vsc73xx_8021q.c @@ -0,0 +1,67 @@ +// 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_DESCRIPTION("DSA tag driver for VSC73XX family of switches, using VLAN"); +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_VSC73XX_8021Q, VSC73XX_8021Q_NAME); + +module_dsa_tag_driver(vsc73xx_8021q_netdev_ops); From patchwork Fri Mar 1 22:16: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: 209112 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp188584dyc; Fri, 1 Mar 2024 14:22:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU44N0+CuT3ldbvl9FHhQHgvi+CVaKSi++o22VXHPiQb5V27DdDnwMBIJXEAf6zRTF5Rdq7Y+m11UwN8/Q74uxpheKqEA== X-Google-Smtp-Source: AGHT+IE9fDxvLzoNi3nD+yMIjD/6Bhf/7B/vcUI96yjUlO/5FqSuT3OYACNos6L+zjT9wT6BTIod X-Received: by 2002:ae9:c30f:0:b0:785:b95c:a128 with SMTP id n15-20020ae9c30f000000b00785b95ca128mr2770147qkg.67.1709331738199; Fri, 01 Mar 2024 14:22:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331738; cv=pass; d=google.com; s=arc-20160816; b=UECHApYCR8HeSKBxTwQ/j69nMWmYdZjaR636KCiXlrMY3Dv9hvsL0J4pOPQVi/Vypt mMXSyL47mk9BBbx/IgYrmJJgV22PPzPK03sdN4CQtGTRho5yMcNFXeu0FBGXrsL7pXJA w3+PqYt6WefpGzJ3YCfJrN5C9PD7AIHGQsjtlw9/ym8WPZ3dTQKBNFOkzA/9IX8OGzvM qxhY0BrlgP3V2BqcO9T93oyjp2StUr6UFTICf0+bJxs8dG+yMtfba3p1FfPGfNoIFF64 VLWox9Y+w1vc0VJr5SZJfFpeI/Z5fuzIR1WlZkLKRztNHDwd5/1EGhbJhRiR4oPRAwRY 3nTA== 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=SkTG3Clv94c5jYZKV1oVVIC0KyY9HhflvF0/nRm9lOY=; fh=cvniEYZaF97PcqrYiA62L5v4Srp40dDYU4aR+5UAkC8=; b=zfd4x+44fkXxWUVi6my5rzxZCUTinroFFyd+TPBAcBuLB+8BFkfVF5sxtIiRakqATQ yYszhJ4aQf0hDxojzrctbQkMavy1kETPdGW5607Wljp4zmLGlbuzQmqCW/GUkpa+Z0Mu bNSlCAmgAv003HH63M0e9d4BmA4jIoFEKqPS0clMxPVFigqzz1Cn6j2OGP80LOigp9vw 7fSpR5/TJfqlHo9fy2i9QsBADDOMrCmJznwYkTiLmT5heZje3YEupWDeIIanjA9EIiyq QmybUwcXXapxIPUS0fcTZ0ze5aONkCpYrtou9U6NIarUaiLTbVAeLsuXuuiziY22R5nV BxLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NehbFsZU; 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-89189-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89189-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. [147.75.199.223]) by mx.google.com with ESMTPS id qj1-20020a05620a880100b00785d4e12821si726911qkn.41.2024.03.01.14.22.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:22:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89189-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NehbFsZU; 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-89189-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89189-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 D77F91C21F03 for ; Fri, 1 Mar 2024 22:22:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F36B05D904; Fri, 1 Mar 2024 22:18:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NehbFsZU" Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 284ED5D48F; Fri, 1 Mar 2024 22:18:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331501; cv=none; b=uiZCBtwkZb2JbViljwaWkgjZlRoaaICZ2n2pX8KDvT+uGzuE35MfckCQHW/nAGCLsABMqDJ/6neAcVf9z/rWJbrCKd7DQ9X1GMPeH6jgeUX2r69fLoCwdcDrOgnnoKKZ8Jhm2rYYNHlsijYi9hncSaG37IP28JdxoF5L5CIsK9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331501; c=relaxed/simple; bh=g7oHv0s8fzKVC6d0N1BA5pGhmCqS8rRs+SghD8JRZvE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RwdurPHizj2rlAN8EYYNyZibxEcUPCd7nagrt+EhrxUwQ9K//xT7GLcP+7LThh6OrN/Y6U2xE0gokK8CuLBQPraXgOswakS4NeHMKwdiotGTQMQdbIrr5HsFMKxFpWKSyZ+7CQ9svPOzT5eWUUkMSkd2zZbZsTu09i2CYAGn01M= 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=NehbFsZU; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a441d7c6125so336604866b.2; Fri, 01 Mar 2024 14:18:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331498; x=1709936298; 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=SkTG3Clv94c5jYZKV1oVVIC0KyY9HhflvF0/nRm9lOY=; b=NehbFsZU2M0hsTtx4+/xQg1CyyOWFlTaYzXnUAqH8MfpYuknMCXSbtdefLz8T/1rIY 4JpJbhKwgolOV7yq9KGg355p1//NbBESlty9QoKgC17zUo/Eu50jDjDpAV/lAypRwCi9 wRr5altodj1qW77ikfJYykefjFHJywvWMwS6HoT54+tDZrbFL30fFX9rwWFT/GAdKiEw mbocO+/OSiOYTDp7YrdbaEik4toQpqu5dn1FXnDMDQLEA5vDlZZi6McBvjDRrTzsRwbY yyh0sKTmM6hLM9d0xi9l2dO6c31iTbAnG09oMnIrVQDIJEvnvaSrDx/j98VpCeXJCPtj AEbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331498; x=1709936298; 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=SkTG3Clv94c5jYZKV1oVVIC0KyY9HhflvF0/nRm9lOY=; b=RL9xI21+F6v3E7h6KJWmyxqPw8N/3A5gck7p4hqQnnhttpCBXOG98m+BHA14sM+guO cDAv5XGCu6puaL7cdjMSTyCgG8dc//Q75mLwzSXMGHTsoU3M2MJqgenmfeooThv8lWaq W5E84eEB2idmXUjrxzEXB3kQ99LiB7uGVrrehWRKp37dVlKPzd86K+zMKRce456NKpjt DNNPk5PsqCtRyuw9sWph1LGDNdUvUfhHIEDlc+8dM9NpXWJ+Crt+86rNYTPH6Iu1T35U NXTkDCr4ijU9253Fb5hpVvVqm+/dIgxaSYDvTL0mTf0LKvRoSy5gLx+wEUjLyH2XcpPd EMKw== X-Forwarded-Encrypted: i=1; AJvYcCVm8GEo80D40TMKDD91xwlBDyg6PXll0Wq96cf0uJtnyQ+7LJAVfsURrNSvHe3TqIYdWfFxXScKUDYfxFuqTQxZLtXqmIdacZW2dNkz X-Gm-Message-State: AOJu0Yw3msZFF6r61ZMFqqlg50qZaBMo0FkEykvoN6tRhx2jD9j7zhYo L2f70XblQn0L4pUAIBWOiiXBb6990tQNgF3VVgw/WDeKefxXIJ19R/oZBNpvvME= X-Received: by 2002:a17:906:5fd6:b0:a3f:a009:690 with SMTP id k22-20020a1709065fd600b00a3fa0090690mr2229223ejv.14.1709331498275; Fri, 01 Mar 2024 14:18:18 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:17 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 13/16] net: dsa: vsc73xx: Implement the tag_8021q VLAN operations Date: Fri, 1 Mar 2024 23:16:35 +0100 Message-Id: <20240301221641.159542-14-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364236662987314 X-GMAIL-MSGID: 1792364236662987314 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 --- v6: - resend only 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 c643f445f026..f8175a33c0a6 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 Mar 1 22:16: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: 209113 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp188630dyc; Fri, 1 Mar 2024 14:22:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUli6WGIHBuCWbxyH/ARRqoUnIYG8cyQFIlHrw0ZN2OTVlbgz1Vb96quaBNxGDI8j/dYi0DIGYq7h4A3e2Vx9QJ/G4k8Q== X-Google-Smtp-Source: AGHT+IGiOhTHOPbp1CtHnayuFQ4YD4O2tMDvIekVmVLgDWmiZrWWaMoshNnz1JfHEOoVvqp9tSGy X-Received: by 2002:a05:6808:318e:b0:3c1:a268:5bac with SMTP id cd14-20020a056808318e00b003c1a2685bacmr4227841oib.55.1709331744930; Fri, 01 Mar 2024 14:22:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709331744; cv=pass; d=google.com; s=arc-20160816; b=Tv+WyJTFKDANKoAPA9r/hse8n9gGWMBT5s9spoXr19L+UsePYh5ErRos+myrTnPeXq dXa4GupfqR8ZWvDV3olsvjIAc+Dfwn1/f2rTe19wCsVbPpticWSeTBHn2t5nDB40wy0s l00HaLqIGjDmV+ulFErrpPHULQ6Ocqooix7Qsg3hAYkAboWULRWdS6q+4brYXOQaK/a8 hH0qdxOxr6DKHQhyKIep851E4cmvZqeSextm9A91Hbse5u6Gsce8YmRxyauA8XjnITzF a8SIpbQbJKJe/a3PK6bxgub5w0ji4YBvyAKqYvd+AUsBB1Ivw23mzCAjkEgpYvd99TCT +dUA== 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=81KI0+qdfK3ZHf++P129aHWPYoB3eKSzWQe3DkfQMFE=; fh=5maFFmTDMDhghtXEDJRH/ru/7aj2yey5EjE3Lc+4k7c=; b=k1RSVuGzxK557/UL9kjZUiC7Y4wm27XQDcmBgGqOnduPoAYjxvhG/rChpKv1R66XrZ Soak02mCiBB0WtjsCi0Y3F9xZOsXKHGno9udoioaULC9NCZZWLdvETygo1Bp1qF//EIg U1gKUrAoec7lIF7bkF2eG937tJ4jJ6vq19rMrLNM3UPna3xRPWSBUKECtNnIT4utuTDo bIsHvEffI6HZptajmtSwOaT2LcG186Sbp+KkFiqLazgfiYrZCntO1d+BxNxOKLbJRs/U A07BIt6Qucfrlt97uRAOxjZnprURQTzFyuamDG6CHcvoxsVRt3CAc4tVQEIQTpJDtpBh QujQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AVTwwBxn; 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-89190-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89190-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 v22-20020a05622a145600b0042ece85bba6si1740879qtx.602.2024.03.01.14.22.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89190-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=AVTwwBxn; 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-89190-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89190-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 6F4141C21AC3 for ; Fri, 1 Mar 2024 22:22:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50E855A4CA; Fri, 1 Mar 2024 22:18:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AVTwwBxn" 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 F1AB55D750; Fri, 1 Mar 2024 22:18:23 +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=1709331505; cv=none; b=RL7SVH9dM4b8Lnavzq3RUR3RCaUKR5JpjIbXIoJznKhiSjsfEVkeLda+90BTqc4TOvK9trO60ZeOkB3a0TsuX7n4c0seFWfPUATCKhVWgX5jJ1B77Bhn2f9I/pbhAxDv0i5Uf+HU0afNAHzGXLVPJV3SkDkaskTAsadnDWRbSlw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331505; c=relaxed/simple; bh=uXM915q/jgE2mr1r6Kmy1ijhQ1VyMY2aqb2scH6K9jo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=q1z6zg9b5gXULbs4184wJ/ZiZId0u/Zd0dGCozV2GvF1hN/zXfUweWVgWYFlmNqrFqyoxRqJE0cA19gBBtewV38U5IaV1pPHSFC2c4tFzGp2ilBMZlKS/xCi6mIkcQszD+3nlT3UjpYTQyewe2GX80NUodADmSRa2wokVTcwnE0= 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=AVTwwBxn; 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-a44cdb2d3a6so18278866b.2; Fri, 01 Mar 2024 14:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331502; x=1709936302; 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=81KI0+qdfK3ZHf++P129aHWPYoB3eKSzWQe3DkfQMFE=; b=AVTwwBxnU1ezdEX2OrY4yYu4EkRy66dXfwPIGxa/LQEGHxQIxKbMJJs3aqimCx48aS FnHgTEzRU7ea3j9JV2Umu6Wlp0xmxMmKIC7YxKj0GaLU/psn1B6CQvKEE/qcHbTZCBro S7dCW3/gUpJodxzlw4wHIJkWcO1FJovWDRW+37cBVkaUkMEHCHF34wTwCZIqYq0zJH0p KfD12TWzT+d9Waj2OEJCVGccUbY0FXVL+cfnuG29OJOctMXGiElYE0lzUPB7oeuNGIB5 I7fO0xyd/EdVMuas9nq05HbJrivx+zFcvs5efKM3s777w7/RyLjZKt99CQjmg7EHPL60 dlBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331502; x=1709936302; 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=81KI0+qdfK3ZHf++P129aHWPYoB3eKSzWQe3DkfQMFE=; b=WteueFgxMjorQPdZpqlg+ezQLhrMF7K/sVwDtpPk10fLu2oKXxV55/YC1G9HWeCBkI obIVpQXRjcbOvU5et3LMI8sMTSTj3BJlBRKAVGsP49eIDX5e7F8UIbpXuTHQFlQ7a27V pmQXjCYumVJFNm5BwSu4TWeocycVN8Z5HoXO8X+joryEYJOG+TRTt8ENAQzKhuHZF/4w icZMistM4QMhfjlKF8QdOrOGlQCZ6g/nTGphV0OGaSRoppf5fCrtSZa4ol5Oybn8PHiB Xwqto0Q0YxFacdT/5y9a/cr7RyHnAyFPP59eaSWg8SFbw9/HrxmekUCzfwdeFIMGQPEi NyMA== X-Forwarded-Encrypted: i=1; AJvYcCVnGjJFo7uIg7KRezj8sEFwsHCprI82uV0U2sHUO/3EvLrlQL31FOdXDrkg07hI1hUtgTTptPX83myM+dI7N8YAWaijgLUMsyb/qDXS X-Gm-Message-State: AOJu0YzGy/gtdacpxvaORvhn5hkvX3VghoGAL+dqZ7pJ1DHSGqfnzifm r0u+zQ0yhK13JT2lAQYyb8Sqhvne6wf6EdB7OCHfvfUiVsVsguC/F1Z2rmwz0dE= X-Received: by 2002:a17:906:f355:b0:a43:a12b:1951 with SMTP id hg21-20020a170906f35500b00a43a12b1951mr2270723ejb.2.1709331502188; Fri, 01 Mar 2024 14:18:22 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:21 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 14/16] net: dsa: Define max num of bridges in tag8021q implementation Date: Fri, 1 Mar 2024 23:16:36 +0100 Message-Id: <20240301221641.159542-15-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364244020979131 X-GMAIL-MSGID: 1792364244020979131 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 --- v6: - resend only 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 Mar 1 22:16: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: 209116 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp190485dyc; Fri, 1 Mar 2024 14:27:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVqFfv1KJG9w+PN9gDcgd/8WtnyVSZTaBJgoL2bxiRTEFEWfoEeSDavywHhP5sS3N//3e9E7ncHLvV2f0y48gZa3ejSaA== X-Google-Smtp-Source: AGHT+IEghdflFrk3GPfD+Jx+QxdSh1fBmB06GdLAefq+Nw+2+dnBsicRLmnMnCQwVOfBXMp4MVV/ X-Received: by 2002:a05:6a20:2587:b0:1a1:45e5:b618 with SMTP id k7-20020a056a20258700b001a145e5b618mr348666pzd.16.1709332026847; Fri, 01 Mar 2024 14:27:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709332026; cv=pass; d=google.com; s=arc-20160816; b=Smkfjc6acpJC0jrMF01o7r3xJUxR1egCOV79F28jGeoqw3I7KNMC9ggdKXHZao6EJW qw/rF7zbATZoCdOl6igOMPgXoHa8rdnAKQmyOTfOOTjbKFhLe4UfzxrmkLje6r7zRrdt CnPwLMNpsN6DmDZ/CchjoTeMn1Cf5H5YCHqENwWxF9/Ym8087Z/iUhEukKuY9fFA74RE XIrQ0FE0ElJyo/OI40zZZ6gxGz+Y/ybZrRoCfhZehIguSTqERVYoilOn5tUCCubyFc3x bip3bKXJ3jRKMc4pMS/qB7dI9mkGQLCyOBS2pPTlJMy0tGM/ccX4llGbAEsVJfiuIhXM K7/g== 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=cYa5oSkzGFM4mmqUgWirMBxknEvs8NNQYFQwruOE0as=; fh=zQ+dJwtrLRzmx/ST9VYYVO1k9DUpEA+8NqMqWl6aW2o=; b=KZ4ehpygEnCC04mQ+whDWCI93KCoXk0tUysI+x4PaU4dFydRtfoVmd+33FG5lUrOaP Eg2GB0x48vPxWMwqJ3CD1QEwrmJpbO/ol0j1Q36zV/zHbq4se9fzhH09jvwWDqOz/TVK n28VE/41BVPmmHkwS3O3XasW7FfZvg42ieryldfkuBfBB9ZTe18UqBdv2hGoLP8wl3EL s/BqHkZ+49BrVdn7tn+Gf/freNeBvJXd+ZLXWCsEemM7f4bNovVDKIfJEfkQuItyh4rC 18IT8Uclp1f8yFjDRJV2SfYC3CkTOq0GLZB4KsliYkKOgXSK/BmOil9JiF/IQvkfBy1K vC5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WfvIHDnc; 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-89191-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89191-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 z8-20020a170902ccc800b001d9aa55e4aasi4501728ple.396.2024.03.01.14.27.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:27:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89191-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=WfvIHDnc; 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-89191-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89191-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 B4AA6B26E81 for ; Fri, 1 Mar 2024 22:22:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E0375DF3B; Fri, 1 Mar 2024 22:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WfvIHDnc" 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 118B35DF0F; Fri, 1 Mar 2024 22:18:27 +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=1709331509; cv=none; b=H+fYT/aFHjO9gG7yfnAS1jryWstE/vjHM/W+SdS5fgcysw+XdW2/OL+C7frFL7aPZoF37SgYMOwYgNDN3pJ+ASJ8HWR7R7QGZTwkIK7F3nnL/eyu2NRehBEKm/IQ+H1ZIEfbfdMI7SMwfH7vNvcJ63tnl0Hcux+VvxO2w1mvIWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709331509; c=relaxed/simple; bh=oMWfEUdkiHtgDJv4f5ewX+cq0ViokbW9l3TCC6Yn3Ws=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AgZeicsAVl5tj0YvryRxVhAe12KirB3IreUOGr1uU7Sis1ffng8dOJNSAhlmN/777J31gCqRzATEiXHhwzlNpeNVv8AUafnq9fpMAsbv3u2L/tJLvuoX9fADYUd33SWGf3GRJzszcJmA3SIb+fWjg8NfUW7FnPcSlOxRu8SMbgA= 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=WfvIHDnc; 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-a3566c0309fso359571766b.1; Fri, 01 Mar 2024 14:18:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709331506; x=1709936306; 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=cYa5oSkzGFM4mmqUgWirMBxknEvs8NNQYFQwruOE0as=; b=WfvIHDncr7+bVQaaYaSdNSUDyC8ktj/Q2RhKc/cq46ga80VpYRLz49vQcgMX+iNbPJ jqQEC/S/SYlLxu1ZqOvaHMkSkuaXlWM/1138TtwglEF+n7jRtFegf7ZMXZUGrMiSWZqT 2GzGwF3LXSuDiPA7oOM2I1FWXpDlSpsneBRcXlBvi9CS11NNqoZqkgtpkirZPUSZj7C6 LqJpOwg8hXiltPloaCjo1I29hU58PhodGD2QMeL/Ay+GgWMD7HUj8qYerpYAWEkv4bor C7PW9dSiGLPE/hD1b8DxzLldCzWm9ktQh0BEEN7brauATQZIkSoR1ZlRF1RJiDU8kRTH Og8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709331506; x=1709936306; 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=cYa5oSkzGFM4mmqUgWirMBxknEvs8NNQYFQwruOE0as=; b=UkO06QkL/OOPUeXpu2sPVwxQHf0sKGtJsL1GleIV8GOYj6+voyWi6venZX5tUYj592 PVrFFyu3CEF2Dn422gGcDrMLdWHDDpyHRirwKTgU8XQwpOb/G7B7u+awocl7RwU1OkEu OdktLTaTAbedatWVcNp+LaSWqGj7Lm1QuQNdASl7kFdY5ZOLx77JTo3DJ21k0znNAJZF qYkPOXe59XNqiwi0dlHRBF/s6Dcb+pQ1JvNduLfOCuW0+31uyGEUSbaWywcEnxO47jcQ obJbQA3ef/f3BFBYfGaBp39aaCID7avb9UckP9jsTwi1edmn7yh58AFfWNIAaygHr2jT v70Q== X-Forwarded-Encrypted: i=1; AJvYcCWyOrXilgPj8x5HGZuQTvAivwl++ua7JTfcX6X9qateJb9p7PCcf7ipbjalyBcpSK6KkuRIC9qnYDDpZhXAb9+qFkk+ibG0msdLN1dD X-Gm-Message-State: AOJu0Yyp5uC+12DTV2lWoY+TbPX+HAvdhhOnVmGwRakkwcD4rkX1MfpJ PXspt3dtV9sCp9MmeqCf0RkczBJajwWQ0rxCagS7Hw79pyiKNYKLsPkNlBsksnU= X-Received: by 2002:a17:906:4685:b0:a44:97fc:bc56 with SMTP id a5-20020a170906468500b00a4497fcbc56mr2039398ejr.76.1709331506049; Fri, 01 Mar 2024 14:18:26 -0800 (PST) Received: from WBEC325.dom.lan ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id g16-20020a17090613d000b00a3f480154a3sm2091122ejc.65.2024.03.01.14.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 14:18:25 -0800 (PST) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Linus Walleij , Simon Horman , 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 v6 15/16] net: dsa: vsc73xx: Add bridge support Date: Fri, 1 Mar 2024 23:16:37 +0100 Message-Id: <20240301221641.159542-16-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240301221641.159542-1-paweldembicki@gmail.com> References: <20240301221641.159542-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: 1792364538912678127 X-GMAIL-MSGID: 1792364538912678127 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 --- v6: - resend only 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 f8175a33c0a6..e7dea48672d7 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,