From nobody Sun Feb 8 22:08:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1574958600; cv=none; d=zohomail.com; s=zohoarc; b=awSFJsvIiMAumGkCGuOfTYRZ+KFtPb28Lx3JGrdDF1ZaiSzbf+JhCJbyguayu4LYbvpyHh9MdsT39Fmk4R0LjfsK4o2ZtCBprZZzVttpYMBVwwx2X3woqZUcgcSgegzZyLOR7N+IbeISuqF4HtrpfwRnrUK0bd/o+Bp3b16132w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1574958600; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=R/+xaktGgkZSTImBHUBgHCoOZlz3eTlyLia9sp3DLtQ=; b=DSCQOZQ2vvTka6Y6uvxmfXxG68byNXxtB3RYS4Yq5+mdP+MvddeXrCC9h1HY3seQWjS90xMNAqHEt63LBZvE+Pvys4Cxs3OKo9pODG2zw8kXTjI2xCK6woVp39W5GMRQ5IjWU5YiqdFj72wJtPtHRraqZxIaCvgY0utzGPR+SYs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1574958600739940.0437055257112; Thu, 28 Nov 2019 08:30:00 -0800 (PST) Received: from localhost ([::1]:50722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iaMg1-0006sM-7i for importer@patchew.org; Thu, 28 Nov 2019 11:29:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46875) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iaLf1-0004pP-Ju for qemu-devel@nongnu.org; Thu, 28 Nov 2019 10:24:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iaLR7-0005t6-CY for qemu-devel@nongnu.org; Thu, 28 Nov 2019 10:10:30 -0500 Received: from esa2.mentor.iphmx.com ([68.232.141.98]:46874) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iaLR6-0005Nl-QZ; Thu, 28 Nov 2019 10:10:29 -0500 Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 28 Nov 2019 07:10:21 -0800 IronPort-SDR: 0Qx/Hmk2Tm0jkHE9VaqRqg/re2aQRSOq5gcaUZwPGuCVTNKrKeaZ3z76CQtkYICti6U/vnR/2Z J7hY4TssFUIHoBaNYCSHItVtwiwfLk6dgaQ9Su9/yOBpUAkRVoQJMjYzzheemapP77fW5Df4Uy vMwe7AkINgDQJ4I3tM/wkHvVdFZHqwz3j5KU8SyQRoNmTlx5KLM7XwCL2Gxq9hO7afrDLsslEF XI4OcPB9jV+XsW0pFPe8t0CUYklEBco6JU5/inHA2gTWFZIHFsMTCV8KZrzG4QCVVJE48EUO21 Q6E= X-IronPort-AV: E=Sophos;i="5.69,253,1571731200"; d="scan'208,217";a="43544433" IronPort-SDR: SN3mSj21GxZ1A4a2j+Wrih5vVWVzNqZIjEf3/7D7+s7JRVevWrGzC0whS3U+fPrj8vzbuVudWO /R1pdP/0L+QWZy8MNymyIEAuFEpBffRmSqEIhFlH9cggRgiEOSrG6QdoQa3nuU43okf0Dt8Cx2 kkSq1ngXLXJuP7diHpP2k6fAyjjZYcM1m8TDoawSKZcskAxvSX2UVlY8lLx38xqFytFaFP0YC+ BVdaQOjxNWvcWIlhBbZ8VTmyyW0DePQZ+TznhihHzkp9K3NZ4Xca1NBgZ6zBpSrJ2DsNBexIPb RA8= From: "Wasim, Bilal" To: "qemu-devel@nongnu.org" Subject: [PATCH] Updating the GEM MAC IP to properly filter out the multicast addresses Thread-Topic: [PATCH] Updating the GEM MAC IP to properly filter out the multicast addresses Thread-Index: AdWl/aPyGC40ldXeTIuqOxj9pJGCcw== Date: Thu, 28 Nov 2019 15:10:16 +0000 Message-ID: <2632212d4c8a40bead72ffdcf288e600@SVR-IES-MBX-03.mgc.mentorg.com> Accept-Language: en-GB, en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [137.202.0.90] Content-Type: multipart/alternative; boundary="_000_2632212d4c8a40bead72ffdcf288e600SVRIESMBX03mgcmentorgco_" MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 68.232.141.98 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "edgar.iglesias@gmail.com" , "alistair@alistair23.me" , "qemu-arm@nongnu.org" , "peter.maydell@linaro.org" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" --_000_2632212d4c8a40bead72ffdcf288e600SVRIESMBX03mgcmentorgco_ Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" [PATCH] Updating the GEM MAC IP to properly filter out the multicast addresses. The current code makes a bad assumption that the most-significant byte of the MAC address is used to determine if the address is multicast or unicast, but in reality only a single bit is used to determine this. This caused IPv6 to not work.. Fix is now in place and has been tested with ZCU102-A53 / IPv6 on a TAP interface. Works well.. Signed-off-by: Bilal Wasim --- hw/net/cadence_gem.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index b8be73d..f8bcbb3 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -315,6 +315,12 @@ #define GEM_MODID_VALUE 0x00020118 +/* IEEE has specified that the most significant bit of the most significan= t byte be used for + * distinguishing between Unicast and Multicast addresses. + * If its a 1, that means multicast, 0 means unicast. */ +#define IS_MULTICAST(address) (((address[0] & 0x01) =3D=3D 0x01)= ? 1 : 0) +#define IS_UNICAST(address) (!IS_MULTICAST(address)) + static inline uint64_t tx_desc_get_buffer(CadenceGEMState *s, uint32_t *des= c) { uint64_t ret =3D desc[0]; @@ -690,21 +696,21 @@ static int gem_mac_address_filter(CadenceGEMState *s,= const uint8_t *packet) } /* Accept packets -w- hash match? */ - if ((packet[0] =3D=3D 0x01 && (s->regs[GEM_NWCFG] & GEM_NWCFG_MCAST_HA= SH)) || - (packet[0] !=3D 0x01 && (s->regs[GEM_NWCFG] & GEM_NWCFG_UCAST_HASH= ))) { + if ((IS_MULTICAST(packet) && (s->regs[GEM_NWCFG] & GEM_NWCFG_MCAST_HAS= H)) || + (IS_UNICAST(packet) && (s->regs[GEM_NWCFG] & GEM_NWCFG_UCAST_HAS= H))) { unsigned hash_index; hash_index =3D calc_mac_hash(packet); if (hash_index < 32) { if (s->regs[GEM_HASHLO] & (1<regs[GEM_HASHHI] & (1<

[PATCH] Updating the GEM MAC IP to properly filter o= ut the multicast

addresses. The current code makes a bad assumption t= hat the most-significant

byte of the MAC address is used to determine if the = address is multicast or

unicast, but in reality only a single bit is used to= determine this. This

caused IPv6 to not work.. Fix is now in place and ha= s been tested with

ZCU102-A53 / IPv6 on a TAP interface. Works well..

 

Signed-off-by: Bilal Wasim <bilal_wasim@mentor.co= m>

---

hw/net/cadence_gem.c | 18 +++++&= #43;++++++------

1 file changed, 12 insertions(+), 6 deletions(-)=

 

diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_g= em.c

index b8be73d..f8bcbb3 100644

--- a/hw/net/cadence_gem.c

+++ b/hw/net/cadence_gem.c

@@ -315,6 +315,12 @@

 #define GEM_MODID_VALUE 0x00020118<= /p>

+/* IEEE has specified that the most significant= bit of the most significant byte be used for

+ * distinguishing between Unicast and Multicast= addresses.

+ * If its a 1, that means multicast, 0 means un= icast.   */

+#define IS_MULTICAST(address)   =         (((address[0] & 0x01) =3D=3D= 0x01) ? 1 : 0)

+#define IS_UNICAST(address)   &n= bsp;         (!IS_MULTICAST(address= ))

+

static inline uint64_t tx_desc_get_buffer(CadenceGEM= State *s, uint32_t *desc)

{

     uint64_t ret =3D desc[0];

@@ -690,21 +696,21 @@ static int gem_mac_address= _filter(CadenceGEMState *s, const uint8_t *packet)

     }

     /* Accept packets -w- = hash match? */

-    if ((packet[0] =3D=3D 0x01 &= & (s->regs[GEM_NWCFG] & GEM_NWCFG_MCAST_HASH)) ||

-        (packet[= 0] !=3D 0x01 && (s->regs[GEM_NWCFG] & GEM_NWCFG_UCAST_HASH))= ) {

+    if ((IS_MULTICAST(packet) &a= mp;& (s->regs[GEM_NWCFG] & GEM_NWCFG_MCAST_HASH)) ||<= /p>

+        (IS_= UNICAST(packet)   && (s->regs[GEM_NWCFG] & GEM_NWC= FG_UCAST_HASH))) {

         uns= igned hash_index;

        &nbs= p;hash_index =3D calc_mac_hash(packet);

         if = (hash_index < 32) {

        &nbs= p;    if (s->regs[GEM_HASHLO] & (1<<hash_index)= ) {

-         &n= bsp;      return packet[0] =3D=3D 0x01 ? GEM_= RX_MULTICAST_HASH_ACCEPT :

-        &nb= sp;            =             &nb= sp;         GEM_RX_UNICAST_HASH_ACC= EPT;

+        = ;        return IS_MULTICAST(packet) ? G= EM_RX_MULTICAST_HASH_ACCEPT :

+        = ;            &n= bsp;            = ;             G= EM_RX_UNICAST_HASH_ACCEPT;

        &nbs= p;    }

         } e= lse {

        &nbs= p;    hash_index -=3D 32;

        &nbs= p;    if (s->regs[GEM_HASHHI] & (1<<hash_index)= ) {

-        &nb= sp;       return packet[0] =3D=3D 0x01 ? GEM_= RX_MULTICAST_HASH_ACCEPT :

-        &nb= sp;            =             &nb= sp;         GEM_RX_UNICAST_HASH_ACC= EPT;

+        = ;        return IS_MULTICAST(packet) ? G= EM_RX_MULTICAST_HASH_ACCEPT :

+        = ;            &n= bsp;            = ;             G= EM_RX_UNICAST_HASH_ACCEPT;

        &nbs= p;    }

         }

     }

--

2.9.3

 

--_000_2632212d4c8a40bead72ffdcf288e600SVRIESMBX03mgcmentorgco_--