Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1683808pxb; Wed, 9 Feb 2022 02:06:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwSVZOJAW7NrK4jsR5IJlvqtZa4HiOrTTO6nk1erUnVSlp+NzBtU2vWip6kBxyzXZt3iDY X-Received: by 2002:a62:784a:: with SMTP id t71mr1502215pfc.56.1644401197876; Wed, 09 Feb 2022 02:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644401197; cv=none; d=google.com; s=arc-20160816; b=cOzGRpHjgHtpvbfcrLNBGNmO6x2sVkrMB17x7VmcY49L6rc2OJKz5oxIaVuMfUikA+ 9PvlrvhNBaVaTod/Um2nTit4HbDA62QrqPiGr3kIGOk63SnkR9FbHQNAndX57532FUiT nbaUhqFKxjZWy3E8u9X6bAqyWprIvZtdOK0acrko+mK7VcpIZjxNmZrT+XV6t2iafIac Fr7V/O+513HQ6v8YY5HuMlz0yI1jVpV+KDFH9pvREfoKn+nCkXJ8jcBT9WfE+Omliprf Pt4N++WKA0bXdy3JHWOwsbscuJPlLk4KPW8MMKjni1ni7GNjjoZFMOJ1JP+hPBBWlbUr 4feQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cEAT+Hy10Io/v/6MX2mvQJLKyjX37zLdKJy2cGs9ssg=; b=Y/6fugVkWm1zYF1EEda0NRc/HLt09gFT8bEfKxpz8G+sqsjLfdwVIhOvPjlH3jGK4E JsV+Tu/h5qALkQA9GtiT8kD3znyorW5nZV/W1FPlf3XMDIqoe1LdaTOS/onjk4s4iR9u 7qLYzKjhISxr3OeJjoxR7/CjvAXZRukbIqGHHdmyQUkFDrSNwlcv6tJr2tDg/wSGTvPc gjW8cZWAGjgaJGXcw2Llr0HszkoAEKh+Q3lwnbiCGg3ou+mHlktEiLZiI6jR0ZybbQ+n IIgf0CvQcQ3sQbqrhF3KozHQEFwiDO3oa0LXPn4/zgvmhhyDNDUuHmA+zLclEDjgZUdS y8jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VyAN6wJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s12si2491661plq.16.2022.02.09.02.06.24; Wed, 09 Feb 2022 02:06:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VyAN6wJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354230AbiBGKK1 (ORCPT + 99 others); Mon, 7 Feb 2022 05:10:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244994AbiBGKIH (ORCPT ); Mon, 7 Feb 2022 05:08:07 -0500 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29032C043181; Mon, 7 Feb 2022 02:08:06 -0800 (PST) Received: by mail-lf1-x143.google.com with SMTP id x23so25894360lfc.0; Mon, 07 Feb 2022 02:08:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=cEAT+Hy10Io/v/6MX2mvQJLKyjX37zLdKJy2cGs9ssg=; b=VyAN6wJkNW7abvMrzl7SF3wzE97exy5eu7WmTzSN/TOxB5I/EWFzIYd7yfLAUu21Xu BYgDBMggIiQ1lmLxYy0ZdfIkXc58GNd+CKyEvB7BCXkEWoQeRyxPI/jpCUcwMOow3JNB gxoWkImounf5/SN0rcQHZBn0tri5gozybXcsJwayWGf3AtiY5c8bzX0YhjGn7e+TIdLE tAhkQEEGaI0NmkuNjZarowcREP1UowuHaFpfBXbGCaAGxoML6WxJ4X5YIz2xz8vXBzX2 wE/3+A63YSnzIROSRsFCuaynNLRM1RQhhYSfaBL3UEfbaqtnJwvTNuz9+TqCLxfQyBrA XBDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=cEAT+Hy10Io/v/6MX2mvQJLKyjX37zLdKJy2cGs9ssg=; b=XjcxSrgGp/YoCtjwqJpX90eb8+K91D+zk3GIPaeMMJ+PdErEzux4hkxufCuaUoL/MS abMPgxMyD7fLrQJtK3OVHl6jRjCoQTShVI6qjo+7dYCW8O3cqGss3ViAGxxralOB3rl2 7VP5alX3Tcjb+xtb2UlmAl6te2D1k5Da203h2rRlcD5wOKxcZJysRIU0JpdAdKK1F3zW AiUebcPBVl6XeV+Sxzfz92rYfziOFEPRJByQ/W/hLVEOQZRXMLifRyTRkOKLAo/L4F/F W4lR19ZzroZsGPegyyKM//3YUl1IpNUBaV3eqcasEq/w4QuNZrdIEFIIerx2N4jZzlfi cOYw== X-Gm-Message-State: AOAM53376lCRxt+jvcqFBSjmXCI7FM3DTovIkUeXkM6j+4v5baJtsGX9 el4yHhZ3bZLSTELjyTYNU60= X-Received: by 2002:ac2:54b7:: with SMTP id w23mr7704396lfk.6.1644228484590; Mon, 07 Feb 2022 02:08:04 -0800 (PST) Received: from wse-c0127.beijerelectronics.com ([208.127.141.29]) by smtp.gmail.com with ESMTPSA id k12sm1546034ljh.45.2022.02.07.02.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 02:08:04 -0800 (PST) From: Hans Schultz X-Google-Original-From: Hans Schultz To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, Hans Schultz , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/4] net: dsa: mv88e6xxx: Add support for bridge port locked feature Date: Mon, 7 Feb 2022 11:07:41 +0100 Message-Id: <20220207100742.15087-4-schultz.hans+netdev@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220207100742.15087-1-schultz.hans+netdev@gmail.com> References: <20220207100742.15087-1-schultz.hans+netdev@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Supporting bridge port locked mode using the 802.1X mode in Marvell mv88e6xxx switchcores is described in the '88E6096/88E6097/88E6097F Datasheet', sections 4.4.6, 4.4.7 and 5.1.2.1 (Drop on Lock). This feature is implemented here facilitated by the locked port flag. Signed-off-by: Hans Schultz --- drivers/net/dsa/mv88e6xxx/chip.c | 9 ++++++++- drivers/net/dsa/mv88e6xxx/port.c | 33 ++++++++++++++++++++++++++++++++ drivers/net/dsa/mv88e6xxx/port.h | 3 +++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 58ca684d73f7..eed3713b97ae 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -5881,7 +5881,7 @@ static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port, const struct mv88e6xxx_ops *ops; if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | - BR_BCAST_FLOOD)) + BR_BCAST_FLOOD | BR_PORT_LOCKED)) return -EINVAL; ops = chip->info->ops; @@ -5939,6 +5939,13 @@ static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, goto out; } + if (flags.mask & BR_PORT_LOCKED) { + bool locked = !!(flags.val & BR_PORT_LOCKED); + + err = mv88e6xxx_port_set_lock(chip, port, locked); + if (err) + goto out; + } out: mv88e6xxx_reg_unlock(chip); diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c index ab41619a809b..2279936429f9 100644 --- a/drivers/net/dsa/mv88e6xxx/port.c +++ b/drivers/net/dsa/mv88e6xxx/port.c @@ -1234,6 +1234,39 @@ int mv88e6xxx_port_set_mirror(struct mv88e6xxx_chip *chip, int port, return err; } +int mv88e6xxx_port_set_lock(struct mv88e6xxx_chip *chip, int port, + bool locked) +{ + u16 reg; + int err; + + err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL0, ®); + if (err) + return err; + + reg &= ~MV88E6XXX_PORT_CTL0_DROP_ON_LOCK; + if (locked) + reg |= MV88E6XXX_PORT_CTL0_DROP_ON_LOCK; + + err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_CTL0, reg); + if (err) + return err; + + err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, ®); + if (err) + return err; + + reg &= ~MV88E6XXX_PORT_ASSOC_VECTOR_LOCKED_PORT; + if (locked) + reg |= MV88E6XXX_PORT_ASSOC_VECTOR_LOCKED_PORT; + + err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, reg); + if (err) + return err; + + return 0; +} + int mv88e6xxx_port_set_8021q_mode(struct mv88e6xxx_chip *chip, int port, u16 mode) { diff --git a/drivers/net/dsa/mv88e6xxx/port.h b/drivers/net/dsa/mv88e6xxx/port.h index 03382b66f800..655d942ac657 100644 --- a/drivers/net/dsa/mv88e6xxx/port.h +++ b/drivers/net/dsa/mv88e6xxx/port.h @@ -365,6 +365,9 @@ int mv88e6xxx_port_set_fid(struct mv88e6xxx_chip *chip, int port, u16 fid); int mv88e6xxx_port_get_pvid(struct mv88e6xxx_chip *chip, int port, u16 *pvid); int mv88e6xxx_port_set_pvid(struct mv88e6xxx_chip *chip, int port, u16 pvid); +int mv88e6xxx_port_set_lock(struct mv88e6xxx_chip *chip, int port, + bool locked); + int mv88e6xxx_port_set_8021q_mode(struct mv88e6xxx_chip *chip, int port, u16 mode); int mv88e6095_port_tag_remap(struct mv88e6xxx_chip *chip, int port); -- 2.30.2