Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2205693pxb; Mon, 18 Jan 2021 10:59:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxO0vL6YoIdi4grnIfIQG8oWBwpIQUd2+D3osKH9JEt7gW/rUv6ix07J3HH3UM0yrV6wvWO X-Received: by 2002:a17:906:48f:: with SMTP id f15mr712666eja.392.1610996388051; Mon, 18 Jan 2021 10:59:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1610996388; cv=pass; d=google.com; s=arc-20160816; b=xxet3wtbOj26VVQurnoAJ3nU6OGaZLTpvBKJ6L4c+Bv55y/EydQYKRLgX7WLaqfCIu MjPAfss5OYqgTs6aSdz1tGpY3n6rmmXFEz2Ec17Cnj83Rn4NiVPHyZ+FZp8sbaUzjIWc JXnxJoiJDamqJbBNH6ko9qC5NizT+bCUZxa63BDf65CKy1UNNBmQuJMY+RMBPIQ5OGPo 6otJ5NXW4Xp+ouVa4NQqONO4sU32Crhpn8pj9XSSSypLywbHjAIBEtt0C0Jlxdp/qQY2 PWffY9gyEC9WmwlNAC3irYOg16owDD5QHFjUNfYWZhZtBId25VEZSep8A/D9UXmPp/Ks LMFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=zWSudLwQ1wk23uf0seOQefx1bzPO+ET9lJaSxnYXzGc=; b=IBYgdJ4mk1cBgnZh+WNlKLn8PcB7KxYvPdn3OGTjnaYjkniUP8sKzt4i+rqlJnhMKS QT8heKhUhFI/JJ72Dabcq15RC6AOsPe2DiicOOrvxdNRZMfn0wtMGuIcee7WL70PQvJu ceChZjpPjqy1k789xRBpJqLgj6F8ueKQbkugVtNbJsBqtnYxAihBXamZWfxV+0uNJUSD HBQ9IeDgNEKZH4Rac7uT6YRl3ZyolkWDXuqcM0Fx3gP4cHvz2G6yYK060/kAOSJjwxMY HzyefuQ352n0nwQma3mdWuh1HAdmg02wauL4+1MLpEP5KIwHqdtkgsUdRcVZIZE/Lho/ 2qjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=NlVSSx++; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ca23si8919121edb.262.2021.01.18.10.59.20; Mon, 18 Jan 2021 10:59:48 -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=@nxp.com header.s=selector2 header.b=NlVSSx++; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407965AbhARS4h (ORCPT + 99 others); Mon, 18 Jan 2021 13:56:37 -0500 Received: from mail-eopbgr60060.outbound.protection.outlook.com ([40.107.6.60]:55552 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2407898AbhARSzv (ORCPT ); Mon, 18 Jan 2021 13:55:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X8S4gV8P16Do2utLyM4vwk/skWCTA39+7wIDgNQ820RkPD8fivRekXR3vAUJfV5zNj3D+NqDrJgGUiUPDbSOu0r/m04/G0HbMGSSLoHF+5S/aLmY2G/MiL/+bo04WszLtfOyPrayv9LLb/KgXNyvG+a/np5HV3NZ+/zdcUhPkD/m1MAFItui1l5PZvse0ylUm6Gqd3irjNQ1KbIcjAq3JPIjKMdzUud9PxtCSGxWr95+R0/2ki2zJ7aPT1TH4B66gj4ILcd1wd6ef1g1+xtvq2zBKr8rYcMh+oVQBCHJf/lhSk6x8o2u78DhlM0uJURPI2bgOku3NR8lt1P4wtMUiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zWSudLwQ1wk23uf0seOQefx1bzPO+ET9lJaSxnYXzGc=; b=gnjRvaqVAQeo2fcdCkGesGzOVsx/yyUq90zmLGHzxPlUyY1RQzfBwSaCAAmhu7/LqWghQXA06Rr0Ws3Cg3t384BS2+b3c924qBN2mTOL6wh7pj+A+C0wlbxIzXCbXVIHRONqibVM+OUTsF9TtjQvCnK8RpwLbVEcOrOGc+CjHtoNhcQuTJNYhPz/SoJHqQDFrxMzm4JrCqhtWpx3D5gj0i779TjR/ffWLwX79Gg7sNnv/V0R3P8gPDIi/9E1v/hFD/RZj493sWCmZ6jNex6ud86UsCfRs+Tp5UqzmtRJJh991Emm6ft3/tBeZNjTRXBUXpIO0zc/TScr6B56Gl6Txw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zWSudLwQ1wk23uf0seOQefx1bzPO+ET9lJaSxnYXzGc=; b=NlVSSx++1F2I8HdhZgfxl5O90BtC6QHbZMWax/FsfdWaOzhPNmo18b7ox248q8p27Hlf/9pa3bktlwaA8u+cidAg4durYMDKvjPm/XPRgq6wy0ayGb8zLT0nb1QR1bt7rg6NAlAGyWAtDZSjXoU9jFDtJUVDxyZ/1nu8t6mNFFY= Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by VI1PR0402MB3711.eurprd04.prod.outlook.com (2603:10a6:803:18::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Mon, 18 Jan 2021 18:55:02 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::2c43:e9c9:db64:fa57]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::2c43:e9c9:db64:fa57%5]) with mapi id 15.20.3763.013; Mon, 18 Jan 2021 18:55:02 +0000 From: Vladimir Oltean To: "Bedel, Alban" CC: Claudiu Manoil , Alexandre Belloni , "UNGLinuxDriver@microchip.com" , "David S. Miller" , Jakub Kicinski , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] net: mscc: ocelot: Fix multicast to the CPU port Thread-Topic: [PATCH] net: mscc: ocelot: Fix multicast to the CPU port Thread-Index: AQHW7bOA9fYvcfmYzUChcnWV1prsRqotu3KA Date: Mon, 18 Jan 2021 18:55:01 +0000 Message-ID: <20210118185501.6wejo4xwb2lidicm@skbuf> References: <20210118160317.554018-1-alban.bedel@aerq.com> In-Reply-To: <20210118160317.554018-1-alban.bedel@aerq.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: aerq.com; dkim=none (message not signed) header.d=none;aerq.com; dmarc=none action=none header.from=nxp.com; x-originating-ip: [5.12.227.87] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 85e53ce7-e104-4f9c-8295-08d8bbe28fa8 x-ms-traffictypediagnostic: VI1PR0402MB3711: x-ld-processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Wmq1Y76bvgGsK8tJmaevz5Mfs+J9iOZg2xhzAftry1Y1t5POVDATbYvlUqRbWvnm017JFPyqGGZreiar7zRniKPO2Ou0zH+RaBlvNPL/aC5gMuOAxpSLjiex+bu2YEdEhtfIYi4cdGZJU7z4DZyY0a7mv7Zq5mUeXhZ9yBWTPCJLNrwUuWpC4IyPssibEpFijCFpoH3hk7z/lGiWeXGXaUO853H14xHLc8HPTJRcPi1o73PiSNu7GbkmZBQDArz2mylFCqIC5ECRRjqVb4zxS23oJJRFnPdLNa/Wxtx1Aq0ME7U5djY3KSKKCPfor1WFrBlkdqum/+KLlbnZ9llg7XxAj4AncSIG+J5IfT0cEdUSrySkDP47V2nkcpNR5KoR8JBqThZIl+Oxg/xfUNDoj8SUloWe5dfGVXV8CPIpbawk+R7FRZ/byWj2DtVk1dKLnThmMYnL+eYdlw9yifzFtw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(7916004)(4636009)(376002)(136003)(39860400002)(366004)(346002)(396003)(1076003)(186003)(71200400001)(6506007)(26005)(5660300002)(44832011)(83380400001)(76116006)(54906003)(316002)(66946007)(66476007)(66446008)(8676002)(86362001)(33716001)(6916009)(2906002)(66556008)(966005)(6486002)(478600001)(6512007)(8936002)(64756008)(4326008)(9686003);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?sR4bRZkH+4ekq+L9ZIkF44NptrdEuHgfynrus0Dyzgv8Ue2lAyihum4D8MT1?= =?us-ascii?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gzsiNFQsJ33Rre3mukJH1?= =?us-ascii?Q?ZdsUOZFpZJsFLFwYrW83x8XEUOWQ67v3SqXfzXLsZOB4e5deFgD6h1MdHE+r?= =?us-ascii?Q?w8YX?= Content-Type: text/plain; charset="us-ascii" Content-ID: <5825BCDFE6426548BECBBF83C7635D22@eurprd04.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85e53ce7-e104-4f9c-8295-08d8bbe28fa8 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Jan 2021 18:55:01.9134 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: mgnCRYiiHC/lZfcKuHLibJ4rhwgGK8EzuTz98heEd9xU/7BUqdT2ZwhZHFl8bO7OK0AVlfDyi+UXYLzkIrwlHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3711 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alban, On Mon, Jan 18, 2021 at 05:03:17PM +0100, Alban Bedel wrote: > Multicast entries in the MAC table use the high bits of the MAC > address to encode the ports that should get the packets. But this port > mask does not work for the CPU port, to receive these packets on the > CPU port the MAC_CPU_COPY flag must be set. >=20 > Because of this IPv6 was effectively not working because neighbor > solicitations were never received. This was not apparent before commit > 9403c158 (net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet mdb > entries) as the IPv6 entries were broken so all incoming IPv6 > multicast was then treated as unknown and flooded on all ports. >=20 > To fix this problem add a new `flags` parameter to ocelot_mact_learn() > and set MAC_CPU_COPY when the CPU port is in the port set. We still > leave the CPU port in the bitfield as it doesn't seems to hurt. >=20 > Signed-off-by: Alban Bedel > Fixes: 9403c158 (net: mscc: ocelot: support IPv4, IPv6 and plain Ethernet= mdb entries) > --- Good catch, it seems that I really did not test that patch with multicast traffic received on the CPU (and not only that patch, but ever since, in fact), shame on me. What I don't like your patch is how it spills over the entire ocelot driver, yet still fails to compile. You missed a bunch of ocelot_mact_learn calls from ocelot_net.c (8 of them, in fact). I don't know which kernel tree you applied this patch to, but clearly not "net"/master: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git I would prefer to see a more self-contained bug fix, such as potentially this one: -----------------------------[cut here]----------------------------- diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc= /ocelot.c index a560d6be2a44..4d7443b123bd 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -56,18 +56,46 @@ static void ocelot_mact_select(struct ocelot *ocelot, =20 } =20 +static unsigned long +ocelot_decode_ports_from_mdb(const unsigned char *addr, + enum macaccess_entry_type entry_type) +{ + unsigned long ports =3D 0; + + if (entry_type =3D=3D ENTRYTYPE_MACv4) { + ports =3D addr[2]; + ports |=3D addr[1] << 8; + } else if (entry_type =3D=3D ENTRYTYPE_MACv6) { + ports =3D addr[1]; + ports |=3D addr[0] << 8; + } + + return ports; +} + int ocelot_mact_learn(struct ocelot *ocelot, int port, const unsigned char mac[ETH_ALEN], unsigned int vid, enum macaccess_entry_type type) { + u32 flags =3D ANA_TABLES_MACACCESS_VALID | + ANA_TABLES_MACACCESS_DEST_IDX(port) | + ANA_TABLES_MACACCESS_ENTRYTYPE(type) | + ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN); + ocelot_mact_select(ocelot, mac, vid); =20 + /* Little API trickery to make this function "just work" when the CPU + * port module is included in the port mask for multicast IP entries. + */ + if (type =3D=3D ENTRYTYPE_MACv4 || type =3D=3D ENTRYTYPE_MACv6) { + unsigned long ports =3D ocelot_decode_ports_from_mdb(mac, type); + + if (ports & BIT(ocelot->num_phys_ports)) + flags |=3D ANA_TABLES_MACACCESS_MAC_CPU_COPY; + } + /* Issue a write command */ - ocelot_write(ocelot, ANA_TABLES_MACACCESS_VALID | - ANA_TABLES_MACACCESS_DEST_IDX(port) | - ANA_TABLES_MACACCESS_ENTRYTYPE(type) | - ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN), - ANA_TABLES_MACACCESS); + ocelot_write(ocelot, flags, ANA_TABLES_MACACCESS); =20 return ocelot_mact_wait_for_completion(ocelot); } -----------------------------[cut here]----------------------------- It has the advantage of actually compiling, plus it should be easier to backport because the changes are all in one place. Please make sure to read: Documentation/process/submitting-patches.rst (this will tell you what is wrong with your Fixes: tag) Documentation/networking/netdev-FAQ.rst (this will tell you what is wrong with this patch's --subject-prefix, and why the patch does not build on the trees it is supposed to be applied to): https://patchwork.kernel.org/project/netdevbpf/patch/20210118160317.554018-= 1-alban.bedel@aerq.com/=