Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1380324pxj; Fri, 4 Jun 2021 12:53:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWr59PxNg6B9cWJr2PYIrdXBE/QsGrfYHceTNo+5abpnT75TMJh0eFvrDxbDwolwkpqw71 X-Received: by 2002:a50:bb6a:: with SMTP id y97mr6484795ede.345.1622836400065; Fri, 04 Jun 2021 12:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622836400; cv=none; d=google.com; s=arc-20160816; b=gObtTbPD9voM7SqwTrKqewBON/eG7j9ET6D3V1ScyFSD6PPViEzd2SqqTTY8ghfvjn dSIHQc7wOtBGkl4XKkrd4ARouNYUWVxAW88DFkooqSvdKJvR+gBSvyaPRYxA6cHf7bKA t0B7JqEctoSY6V/10wsvYHZYr6+49JgNLU4Na0nGkl3md6rQxGrxfazM5UwneXRvKzI5 VAaZJ9TDkcyRxayNcr+2XeeJ5WvfNIbrrDe85zX2ZB26OW1p8LLonSvO3qMatSp/vVHy r4Srh68Ml1hl57Z46giY5i/kCW3pZJc2xme5dcA6IAM4+wQuDl7+XCaA9S0+JJGm1oDe DZwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hJ0x4oOHu3bQuGASm+jPBHpyUmZu2v+qW1jB1EYCSz8=; b=DoH0JCZyI9elPnESqK36bf5eZBwtPeS0SIonldU61FY5+Zom19G1INStB6hJiBctax b7PTO9aGdehyPCLYZd6uoLvSJRAlpTRP0wsoMvb4f47SipsxzHurWJK4zctWRpN1v/Cf 4dve8vMBq2BcvtHGvCTShIK6mGa5kUP3UkC6OjGQ+hy9ePIP6JnF8xKHQWyh7ikEApuU XU5uTReSf0r5ooSUnWAwpIKcaG8CCTgcx59Nmq79BTBeGi+hfdaCLv/hGm4xRVBOXAF/ JhY7ZgYbeCR70vK4w+2TNHUrdvZd8Gb7GShwb7K2SI3fJP++vdklE1oAStKnl1+nmCCn wIpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VzyWPGNf; 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 kl18si5875941ejc.160.2021.06.04.12.52.57; Fri, 04 Jun 2021 12:53:20 -0700 (PDT) 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=20161025 header.b=VzyWPGNf; 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 S230435AbhFDTxr (ORCPT + 99 others); Fri, 4 Jun 2021 15:53:47 -0400 Received: from mail-ot1-f43.google.com ([209.85.210.43]:35804 "EHLO mail-ot1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbhFDTxr (ORCPT ); Fri, 4 Jun 2021 15:53:47 -0400 Received: by mail-ot1-f43.google.com with SMTP id 69-20020a9d0a4b0000b02902ed42f141e1so10222793otg.2; Fri, 04 Jun 2021 12:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hJ0x4oOHu3bQuGASm+jPBHpyUmZu2v+qW1jB1EYCSz8=; b=VzyWPGNfbub9INVBk/qeXI9dUAwBaDPj5LSOQq5yqQxKLMTg45q5T7ePyV0w2jU1fH 9rpyWPjdV7NPksVJcWU35mmfMbEDB3eJ5Gog/W5M48w8F2PAxjsw0iMPfVYpscl9wVBj brT/nTOUAuUJZc+Z5kkrzWA6NqWgwddM6bX8yGp/C3rniy1eb21DIz+KK6JSIBrVSb3x 180kpvRkOunDqxHkRBpSr61sA8t/62Uj1/qOCs5rJZRYUG1ZLInvfW+DXUZD0fMLnXEH Qgr5HqyH4MzozF26xTifXFr/Rqz71ynnAJD4zB1RVoZrvtv1jffa0b8iqBiUPMNZ4AtY soZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hJ0x4oOHu3bQuGASm+jPBHpyUmZu2v+qW1jB1EYCSz8=; b=f6W3ov3CG+PC6cqj4bGaaasNh3ieWM6CIVV/q3TMG+MqM/rDGNgV980QGoOw1FY6/k VYoQz/CQJUmSiLIP6IZTOKAY0U0KXA/8RPZfc2PR7Uq9kJrs47GGQ54Uygj4PuYRhGsY i41GGxaVti7ojFv68oipworEX+sxRXs0naH37FE43bWgYtMl3hNe6mfdirKxBE+ARO2a xnHjYtsjoul/d9jhSAYS5kr3pHDyZyQ6Aa7TLyq9PJeaLIIQFEbfbDPc6YOYuxZvU+vz nXiDQ3zzA2ZFx+1wj6sgApmc0soMw5CE10eChWea8stwx/OU2m7tTV/b1AYLvXxTpr/3 nANw== X-Gm-Message-State: AOAM533KSoXE1yXmzyqbdFy7xKOOYbqo89SJX6naq4Ufo20dl3nmTKre lb05nyhO1ajymdDYTzpbKLpdGfTgODDLQLpWn98s/lDMrAeb1T8= X-Received: by 2002:a9d:b86:: with SMTP id 6mr3155739oth.340.1622836243857; Fri, 04 Jun 2021 12:50:43 -0700 (PDT) MIME-Version: 1.0 References: <20210604162922.76954-1-george.mccollister@gmail.com> <20210604185511.yi5zejpz37rklzfw@skbuf> In-Reply-To: <20210604185511.yi5zejpz37rklzfw@skbuf> From: George McCollister Date: Fri, 4 Jun 2021 14:50:31 -0500 Message-ID: Subject: Re: [PATCH net-next] net: dsa: xrs700x: allow HSR/PRP supervision dupes for node_table To: Vladimir Oltean Cc: netdev , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , open list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 4, 2021 at 1:55 PM Vladimir Oltean wrote: > > On Fri, Jun 04, 2021 at 11:29:22AM -0500, George McCollister wrote: > > Add an inbound policy filter which matches the HSR/PRP supervision > > MAC range and forwards to the CPU port without discarding duplicates. > > This is required to correctly populate time_in[A] and time_in[B] in the > > HSR/PRP node_table. Leave the policy disabled by default and > > enable/disable it when joining/leaving hsr. > > > > Signed-off-by: George McCollister > > --- > > What happens if duplicates are discarded for supervision frames and > time_in[A] or time_in[B] is not updated in the node table? It'll indicate an error condition that doesn't exist though everything will work just fine. It'll call hsr_nl_ringerror() and show only time_in[A] or time_in[B] updating in /sys/kernel/debug/hsr/hsr0/node_table. IEC 62439-3 specifies an SNMP MIB that contains the node_table. I've implemented Net-SNMP mibgroup code to provide the node table data for remote monitoring. Basically if time_in[A] and time_in[B] aren't both updating it means: For HSR there is a break in the ring. For PRP: A device has a cable connecting to a switch unplugged or a failed port. > > > drivers/net/dsa/xrs700x/xrs700x.c | 67 +++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 67 insertions(+) > > > > diff --git a/drivers/net/dsa/xrs700x/xrs700x.c b/drivers/net/dsa/xrs700x/xrs700x.c > > index fde6e99274b6..a79066174a77 100644 > > --- a/drivers/net/dsa/xrs700x/xrs700x.c > > +++ b/drivers/net/dsa/xrs700x/xrs700x.c > > @@ -79,6 +79,9 @@ static const struct xrs700x_mib xrs700x_mibs[] = { > > XRS700X_MIB(XRS_EARLY_DROP_L, "early_drop", tx_dropped), > > }; > > > > +static const u8 eth_hsrsup_addr[ETH_ALEN] = { > > + 0x01, 0x15, 0x4e, 0x00, 0x01, 0x00}; > > + > > What if the user sets a different last address byte for supervision frames? Below I only actually use 40 bits in the policy. See comment in the code. > > > static void xrs700x_get_strings(struct dsa_switch *ds, int port, > > u32 stringset, u8 *data) > > { > > @@ -329,6 +332,50 @@ static int xrs700x_port_add_bpdu_ipf(struct dsa_switch *ds, int port) > > return 0; > > } > > > > +/* Add an inbound policy filter which matches the HSR/PRP supervision MAC > > + * range and forwards to the CPU port without discarding duplicates. > > + * This is required to correctly populate the HSR/PRP node_table. > > + * Leave the policy disabled, it will be enabled as needed. > > + */ > > +static int xrs700x_port_add_hsrsup_ipf(struct dsa_switch *ds, int port) > > +{ > > + struct xrs700x *priv = ds->priv; > > + unsigned int val = 0; > > + int i = 0; > > + int ret; > > + > > + /* Compare 40 bits of the destination MAC address. */ > > + ret = regmap_write(priv->regmap, XRS_ETH_ADDR_CFG(port, 1), 40 << 2); > > + if (ret) > > + return ret; > > + > > + /* match HSR/PRP supervision destination 01:15:4e:00:01:XX */ > > + for (i = 0; i < sizeof(eth_hsrsup_addr); i += 2) { > > + ret = regmap_write(priv->regmap, XRS_ETH_ADDR_0(port, 1) + i, > > + eth_hsrsup_addr[i] | > > + (eth_hsrsup_addr[i + 1] << 8)); > > + if (ret) > > + return ret; > > + } > > + > > + /* Mirror HSR/PRP supervision to CPU port */ > > + for (i = 0; i < ds->num_ports; i++) { > > + if (dsa_is_cpu_port(ds, i)) > > + val |= BIT(i); > > + } > > + > > + ret = regmap_write(priv->regmap, XRS_ETH_ADDR_FWD_MIRROR(port, 1), val); > > + if (ret) > > + return ret; > > + > > + /* Allow must be set prevent duplicate discard */ > > + ret = regmap_write(priv->regmap, XRS_ETH_ADDR_FWD_ALLOW(port, 1), val); > > + if (ret) > > + return ret; > > + > > + return 0; > > +} > > + > > static int xrs700x_port_setup(struct dsa_switch *ds, int port) > > { > > bool cpu_port = dsa_is_cpu_port(ds, port); > > @@ -358,6 +405,10 @@ static int xrs700x_port_setup(struct dsa_switch *ds, int port) > > ret = xrs700x_port_add_bpdu_ipf(ds, port); > > if (ret) > > return ret; > > + > > + ret = xrs700x_port_add_hsrsup_ipf(ds, port); > > + if (ret) > > + return ret; > > } > > > > return 0; > > @@ -565,6 +616,14 @@ static int xrs700x_hsr_join(struct dsa_switch *ds, int port, > > XRS_PORT_FORWARDING); > > regmap_fields_write(priv->ps_forward, port, XRS_PORT_FORWARDING); > > > > + /* Enable inbound policy added by xrs700x_port_add_hsrsup_ipf() > > + * which allows HSR/PRP supervision forwarding to the CPU port without > > + * discarding duplicates. > > + */ > > + regmap_update_bits(priv->regmap, > > + XRS_ETH_ADDR_CFG(partner->index, 1), 1, 1); > > + regmap_update_bits(priv->regmap, XRS_ETH_ADDR_CFG(port, 1), 1, 1); > > + > > hsr_pair[0] = port; > > hsr_pair[1] = partner->index; > > for (i = 0; i < ARRAY_SIZE(hsr_pair); i++) { > > @@ -611,6 +670,14 @@ static int xrs700x_hsr_leave(struct dsa_switch *ds, int port, > > XRS_PORT_FORWARDING); > > regmap_fields_write(priv->ps_forward, port, XRS_PORT_FORWARDING); > > > > + /* Disable inbound policy added by xrs700x_port_add_hsrsup_ipf() > > + * which allows HSR/PRP supervision forwarding to the CPU port without > > + * discarding duplicates. > > + */ > > + regmap_update_bits(priv->regmap, > > + XRS_ETH_ADDR_CFG(partner->index, 1), 1, 0); > > + regmap_update_bits(priv->regmap, XRS_ETH_ADDR_CFG(port, 1), 1, 0); > > + > > hsr_pair[0] = port; > > hsr_pair[1] = partner->index; > > for (i = 0; i < ARRAY_SIZE(hsr_pair); i++) { > > -- > > 2.11.0 > >