From nobody Sat Apr 20 02:56:33 2024 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1575034665; cv=none; d=zohomail.com; s=zohoarc; b=V+jUDNzn/jEIsgFQQN/kFJtO6PKjOipU5ZAejuhPEJPG2l59BKXAryPGfU/avBJhuVx9Ffz3WRAyJuE4g8ZUH7TckXiKx6orqJyKOknJ8gwtO5WSxfoeAVOqegkQyQAgSJmMDH8PJjfbwsYdLZtzZQEnG6IT5ILO+/avOIUJh4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575034665; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+H5beYs7R9VzKoKtKDCo0/PtILiDZOqNPj6UEVTqWI8=; b=MQEyT5zIB+188BnbGXeZk11k1hPQXmswfWPRZqC8D6C9ce+cMpFer4E+9Yf5HRAVFe8JCPEg7SypQB0shRFkYsYw6pWtdBMtaEKkYYAQ1mX6F6R64wLFSA8eJN5dsVmDwpaF8R7u9vNSkEvlTH/Wka0AQ0y+s8uR6z8dGg31xIY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1575034665727283.0771376657476; Fri, 29 Nov 2019 05:37:45 -0800 (PST) Received: from localhost ([::1]:59168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iagSt-00025y-Fx for importer@patchew.org; Fri, 29 Nov 2019 08:37:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44871) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iac0y-0005np-RK for qemu-devel@nongnu.org; Fri, 29 Nov 2019 03:52:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iac0u-0000jz-Fb for qemu-devel@nongnu.org; Fri, 29 Nov 2019 03:52:33 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iac0u-0000Qs-7R; Fri, 29 Nov 2019 03:52:32 -0500 Received: by mail-wr1-x442.google.com with SMTP id t2so34045329wrr.1; Fri, 29 Nov 2019 00:52:28 -0800 (PST) Received: from PKL-BWASIM-LT.mgc.mentorg.com ([110.93.212.98]) by smtp.gmail.com with ESMTPSA id x13sm12490515wmc.19.2019.11.29.00.52.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2019 00:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+H5beYs7R9VzKoKtKDCo0/PtILiDZOqNPj6UEVTqWI8=; b=qXE5evr1plLKDoAiwd+QFIqDiPhVreKVkrMKLbRivLYKG4HxvcjfU7lOCzlNzguNT5 TZ0+lWOHLpJFsFnu/ABwvFBi1WDAvPXOHlIBZjnyCX6sq+ChKlGYJ3iOpmv46rJmL2Ak oFm+oZoI6X9zWSfg+zj1KGQ0A1wNbddIeA2PgSPYdGU1xIaEO8IEKc6ClyN0r6Wkqa8B EL6OJfng+mvqqDbCTuYTpiq+vEvJMidIjhI0X0yaKPosriD9cxx2JjncWRhg2XKn8VvZ Ya3+9/XVBmZaPDvrJwKXFyqzNHH0M6t4d17sizeyj3vdsiUQQTmMuRcJhJdqei9n8BMg E1WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+H5beYs7R9VzKoKtKDCo0/PtILiDZOqNPj6UEVTqWI8=; b=G9tn4B75GBiK1Ph6/TzB3hFFckYlSPyQRPxcYfrQXH363AAn+KCEXDyEQMLe37kFKJ H7hA9SSnsXqNIwenHbJW8lFk/S7V+gDFYrYCrOXwHbVWRID5dWAAwXy/eWQuxd7BHwUp BFsALKSkDNGxd/BXiOoKRkEz4/TifM3/L/kD/etqsiGUoOOqLN2t5Sq2NcTBdtgeVWY1 RtOsSKmKECg2gMa8LJAYrSj+uvR6QVJajcSVep9N1vhEV2kRfEDaeW6TXvAsPtx6bov3 41Gt/SbS95ZdFcsiBe/J3/lw1nY36X2qRB8oIMJBcvoOjGrpmHfSgos4xfDF+/XE8Uuo ajiw== X-Gm-Message-State: APjAAAXAf7oOjMBwGeHjVmkUbJpV/83tnlAssst+kfzOTr5tRZlITaV6 EY9Nz/rD6PMbYCSA+uNRC1L5pwZcIbA= X-Google-Smtp-Source: APXvYqx5vRQcJKkpsPM4qjZVgJ5vlYFJyZgmTMtbe5XE9ssyEOxZSkay76gBk8a4c9GRjImS+8YV7g== X-Received: by 2002:adf:f5cf:: with SMTP id k15mr2678894wrp.182.1575017546576; Fri, 29 Nov 2019 00:52:26 -0800 (PST) From: bilalwasim676@gmail.com To: qemu-devel@nongnu.org Subject: [PATCH v2] net/cadence_gem: Updating the GEM MAC IP to properly filter out multicast addresses. Date: Fri, 29 Nov 2019 13:52:16 +0500 Message-Id: <20191129085216.5108-1-bilalwasim676@gmail.com> X-Mailer: git-send-email 2.19.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-Mailman-Approved-At: Fri, 29 Nov 2019 08:30:34 -0500 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, qemu-arm@nongnu.org, bilal_wasim@mentor.com, alistair@alistair23.me, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: bwasim 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 | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index b8be73dc55..042188c1ba 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -34,6 +34,7 @@ #include "qemu/module.h" #include "sysemu/dma.h" #include "net/checksum.h" +#include "net/eth.h" =20 #ifdef CADENCE_GEM_ERR_DEBUG #define DB_PRINT(...) do { \ @@ -601,7 +602,7 @@ static void gem_receive_updatestats(CadenceGEMState *s,= const uint8_t *packet, } =20 /* Error-free Multicast Frames counter */ - if (packet[0] =3D=3D 0x01) { + if (is_multicast_ether_addr(packet)) { s->regs[GEM_RXMULTICNT]++; } =20 @@ -690,21 +691,25 @@ static int gem_mac_address_filter(CadenceGEMState *s,= const uint8_t *packet) } =20 /* 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_ether_addr(packet) + && (s->regs[GEM_NWCFG] & GEM_NWCFG_MCAST_HASH)) || + (is_unicast_ether_addr(packet) + && (s->regs[GEM_NWCFG] & GEM_NWCFG_UCAST_HASH))) { unsigned hash_index; =20 hash_index =3D calc_mac_hash(packet); if (hash_index < 32) { if (s->regs[GEM_HASHLO] & (1<regs[GEM_HASHHI] & (1<