From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513363636928264.282986824173; Fri, 15 Dec 2017 10:47:16 -0800 (PST) Received: from localhost ([::1]:48142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv0V-00013q-6h for importer@patchew.org; Fri, 15 Dec 2017 13:46:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuw5-000627-D7 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePuw2-0006g8-4Q for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:17 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60814 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePuw1-0006Oe-Sg for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:14 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuw4-0006JD-1R; Fri, 15 Dec 2017 18:42:17 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:43 +0000 Message-Id: <20171215184155.2543-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 01/13] net: move CRC32 calculation from compute_mcast_idx() into its own net_crc32() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Separate out the standard ethernet CRC32 calculation into a new net_crc32() function, renaming the constant POLYNOMIAL to POLYNOMIAL_BE to make it clear that this is a big-endian CRC32 calculation. As part of the constant rename, remove the duplicate definition of POLYNOMI= AL from eepro100.c and use the new POLYNOMIAL_BE constant instead. Once this is complete remove the existing CRC32 implementation from compute_mcast_idx() and call the new net_crc32() function in its place. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/eepro100.c | 4 +--- include/net/net.h | 3 ++- net/net.c | 16 +++++++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 1c0def555b..71cddfece4 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -323,8 +323,6 @@ static const uint16_t eepro100_mdi_mask[] =3D { 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; =20 -#define POLYNOMIAL 0x04c11db6 - static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s); =20 /* From FreeBSD (locally modified). */ @@ -342,7 +340,7 @@ static unsigned e100_compute_mcast_idx(const uint8_t *e= p) crc <<=3D 1; b >>=3D 1; if (carry) { - crc =3D ((crc ^ POLYNOMIAL) | carry); + crc =3D ((crc ^ POLYNOMIAL_BE) | carry); } } } diff --git a/include/net/net.h b/include/net/net.h index 1c55a93588..586098cb94 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -227,7 +227,8 @@ NetClientState *net_hub_port_find(int hub_id); =20 void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); =20 -#define POLYNOMIAL 0x04c11db6 +#define POLYNOMIAL_BE 0x04c11db6 +uint32_t net_crc32(const uint8_t *p, int len); unsigned compute_mcast_idx(const uint8_t *ep); =20 #define vmstate_offset_macaddr(_state, _field) \ diff --git a/net/net.c b/net/net.c index 39ef546708..a14dc9910c 100644 --- a/net/net.c +++ b/net/net.c @@ -1581,25 +1581,31 @@ int net_client_parse(QemuOptsList *opts_list, const= char *optarg) =20 /* From FreeBSD */ /* XXX: optimize */ -unsigned compute_mcast_idx(const uint8_t *ep) +uint32_t net_crc32(const uint8_t *p, int len) { uint32_t crc; int carry, i, j; uint8_t b; =20 crc =3D 0xffffffff; - for (i =3D 0; i < 6; i++) { - b =3D *ep++; + for (i =3D 0; i < len; i++) { + b =3D *p++; for (j =3D 0; j < 8; j++) { carry =3D ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01); crc <<=3D 1; b >>=3D 1; if (carry) { - crc =3D ((crc ^ POLYNOMIAL) | carry); + crc =3D ((crc ^ POLYNOMIAL_BE) | carry); } } } - return crc >> 26; + + return crc; +} + +unsigned compute_mcast_idx(const uint8_t *ep) +{ + return net_crc32(ep, ETH_ALEN) >> 26; } =20 QemuOptsList qemu_netdev_opts =3D { --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513363474982403.9735727849518; Fri, 15 Dec 2017 10:44:34 -0800 (PST) Received: from localhost ([::1]:48123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuxv-0007BS-IZ for importer@patchew.org; Fri, 15 Dec 2017 13:44:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuw5-000626-E8 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePuw2-0006iQ-PZ for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:17 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60817 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePuw2-0006S0-JH for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:14 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuw5-0006JD-Ah; Fri, 15 Dec 2017 18:42:18 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:44 +0000 Message-Id: <20171215184155.2543-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 02/13] net: introduce net_crc32_le() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 This provides a standard ethernet CRC32 little-endian implementation. Signed-off-by: Mark Cave-Ayland Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/net/net.h | 2 ++ net/net.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 586098cb94..4afac1a9dd 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -228,7 +228,9 @@ NetClientState *net_hub_port_find(int hub_id); void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); =20 #define POLYNOMIAL_BE 0x04c11db6 +#define POLYNOMIAL_LE 0xedb88320 uint32_t net_crc32(const uint8_t *p, int len); +uint32_t net_crc32_le(const uint8_t *p, int len); unsigned compute_mcast_idx(const uint8_t *ep); =20 #define vmstate_offset_macaddr(_state, _field) \ diff --git a/net/net.c b/net/net.c index a14dc9910c..4ecaf80bd1 100644 --- a/net/net.c +++ b/net/net.c @@ -1603,6 +1603,28 @@ uint32_t net_crc32(const uint8_t *p, int len) return crc; } =20 +uint32_t net_crc32_le(const uint8_t *p, int len) +{ + uint32_t crc; + int carry, i, j; + uint8_t b; + + crc =3D 0xffffffff; + for (i =3D 0; i < len; i++) { + b =3D *p++; + for (j =3D 0; j < 8; j++) { + carry =3D (crc & 0x1) ^ (b & 0x01); + crc >>=3D 1; + b >>=3D 1; + if (carry) { + crc ^=3D POLYNOMIAL_LE; + } + } + } + + return crc; +} + unsigned compute_mcast_idx(const uint8_t *ep) { return net_crc32(ep, ETH_ALEN) >> 26; --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513363631802817.7644814745692; Fri, 15 Dec 2017 10:47:11 -0800 (PST) Received: from localhost ([::1]:48141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv0T-00012J-V5 for importer@patchew.org; Fri, 15 Dec 2017 13:46:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuw5-00062A-Df for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePuw4-0006n3-0a for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:17 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60820 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePuw3-0006UX-PQ for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:15 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuw6-0006JD-Hv; Fri, 15 Dec 2017 18:42:19 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:45 +0000 Message-Id: <20171215184155.2543-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 03/13] pcnet: switch pcnet over to use net_crc32_le() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Instead of lnc_mchash() using its own implementation, we can simply call net_crc32_le() directly and apply the bit shift inline. Signed-off-by: Mark Cave-Ayland Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/pcnet.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index 654455355f..39d5d93525 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -38,6 +38,7 @@ #include "qemu/osdep.h" #include "hw/qdev.h" #include "net/net.h" +#include "net/eth.h" #include "qemu/timer.h" #include "qemu/sockets.h" #include "sysemu/sysemu.h" @@ -522,25 +523,6 @@ static inline void pcnet_rmd_store(PCNetState *s, stru= ct pcnet_RMD *rmd, be16_to_cpu(hdr->ether_type)); \ } while (0) =20 -#define MULTICAST_FILTER_LEN 8 - -static inline uint32_t lnc_mchash(const uint8_t *ether_addr) -{ -#define LNC_POLYNOMIAL 0xEDB88320UL - uint32_t crc =3D 0xFFFFFFFF; - int idx, bit; - uint8_t data; - - for (idx =3D 0; idx < 6; idx++) { - for (data =3D *ether_addr++, bit =3D 0; bit < MULTICAST_FILTER_LEN= ; bit++) { - crc =3D (crc >> 1) ^ (((crc ^ data) & 1) ? LNC_POLYNOMIAL : 0); - data >>=3D 1; - } - } - return crc; -#undef LNC_POLYNOMIAL -} - #define CRC(crc, ch) (crc =3D (crc >> 8) ^ crctab[(crc ^ (ch)) & 0xff]) =20 /* generated using the AUTODIN II polynomial @@ -656,7 +638,7 @@ static inline int ladr_match(PCNetState *s, const uint8= _t *buf, int size) s->csr[10] & 0xff, s->csr[10] >> 8, s->csr[11] & 0xff, s->csr[11] >> 8 }; - int index =3D lnc_mchash(hdr->ether_dhost) >> 26; + int index =3D net_crc32_le(hdr->ether_dhost, ETH_ALEN) >> 26; return !!(ladr[index >> 3] & (1 << (index & 7))); } return 0; --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513363883720312.6982640052978; Fri, 15 Dec 2017 10:51:23 -0800 (PST) Received: from localhost ([::1]:48168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv4j-0004UN-5o for importer@patchew.org; Fri, 15 Dec 2017 13:51:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuw6-00062d-ST for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePuw5-0006qy-Ii for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:18 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60826 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePuw5-0006Yg-9Q for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:17 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuw8-0006JD-0K; Fri, 15 Dec 2017 18:42:21 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:46 +0000 Message-Id: <20171215184155.2543-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 04/13] eepro100: switch eepro100 e100_compute_mcast_idx() over to use net_crc32() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of e100_compute_mcast_idx() using its own implementation, we can simply call net_crc32() directly and apply the bit shift inline. Signed-off-by: Mark Cave-Ayland Reviewed-by: Stefan Weil Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/eepro100.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 71cddfece4..e30fed830b 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -44,6 +44,7 @@ #include "hw/hw.h" #include "hw/pci/pci.h" #include "net/net.h" +#include "net/eth.h" #include "hw/nvram/eeprom93xx.h" #include "sysemu/sysemu.h" #include "sysemu/dma.h" @@ -325,28 +326,6 @@ static const uint16_t eepro100_mdi_mask[] =3D { =20 static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s); =20 -/* From FreeBSD (locally modified). */ -static unsigned e100_compute_mcast_idx(const uint8_t *ep) -{ - uint32_t crc; - int carry, i, j; - uint8_t b; - - crc =3D 0xffffffff; - for (i =3D 0; i < 6; i++) { - b =3D *ep++; - for (j =3D 0; j < 8; j++) { - carry =3D ((crc & 0x80000000L) ? 1 : 0) ^ (b & 0x01); - crc <<=3D 1; - b >>=3D 1; - if (carry) { - crc =3D ((crc ^ POLYNOMIAL_BE) | carry); - } - } - } - return (crc & BITS(7, 2)) >> 2; -} - /* Read a 16 bit control/status (CSR) register. */ static uint16_t e100_read_reg2(EEPRO100State *s, E100RegisterOffset addr) { @@ -843,7 +822,8 @@ static void set_multicast_list(EEPRO100State *s) uint8_t multicast_addr[6]; pci_dma_read(&s->dev, s->cb_address + 10 + i, multicast_addr, 6); TRACE(OTHER, logout("multicast entry %s\n", nic_dump(multicast_add= r, 6))); - unsigned mcast_idx =3D e100_compute_mcast_idx(multicast_addr); + unsigned mcast_idx =3D (net_crc32(multicast_addr, ETH_ALEN) & + BITS(7, 2)) >> 2; assert(mcast_idx < 64); s->mult[mcast_idx >> 3] |=3D (1 << (mcast_idx & 7)); } @@ -1679,7 +1659,7 @@ static ssize_t nic_receive(NetClientState *nc, const = uint8_t * buf, size_t size) if (s->configuration[21] & BIT(3)) { /* Multicast all bit is set, receive all multicast frames. */ } else { - unsigned mcast_idx =3D e100_compute_mcast_idx(buf); + unsigned mcast_idx =3D (net_crc32(buf, ETH_ALEN) & BITS(7, 2)) >= > 2; assert(mcast_idx < 64); if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) { /* Multicast frame is allowed in hash table. */ --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513364007527649.0926942406164; Fri, 15 Dec 2017 10:53:27 -0800 (PST) Received: from localhost ([::1]:48178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv6m-0006Gm-OG for importer@patchew.org; Fri, 15 Dec 2017 13:53:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuw7-00062j-Np for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePuw6-0006uP-MC for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:19 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60830 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePuw6-0006bb-G2 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:18 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuw9-0006JD-BS; Fri, 15 Dec 2017 18:42:22 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:47 +0000 Message-Id: <20171215184155.2543-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 05/13] sunhme: switch sunhme over to use net_crc32_le() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Instead of sunhme_crc32_le() using its own implementation, we can simply ca= ll net_crc32_le() directly and apply the bit shift inline. Signed-off-by: Mark Cave-Ayland Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/sunhme.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/hw/net/sunhme.c b/hw/net/sunhme.c index b1efa1b88d..7558fca8f9 100644 --- a/hw/net/sunhme.c +++ b/hw/net/sunhme.c @@ -698,29 +698,6 @@ static inline void sunhme_set_rx_ring_nr(SunHMEState *= s, int i) s->erxregs[HME_ERXI_RING >> 2] =3D ring; } =20 -#define POLYNOMIAL_LE 0xedb88320 -static uint32_t sunhme_crc32_le(const uint8_t *p, int len) -{ - uint32_t crc; - int carry, i, j; - uint8_t b; - - crc =3D 0xffffffff; - for (i =3D 0; i < len; i++) { - b =3D *p++; - for (j =3D 0; j < 8; j++) { - carry =3D (crc & 0x1) ^ (b & 0x01); - crc >>=3D 1; - b >>=3D 1; - if (carry) { - crc =3D crc ^ POLYNOMIAL_LE; - } - } - } - - return crc; -} - #define MIN_BUF_SIZE 60 =20 static ssize_t sunhme_receive(NetClientState *nc, const uint8_t *buf, @@ -761,7 +738,7 @@ static ssize_t sunhme_receive(NetClientState *nc, const= uint8_t *buf, trace_sunhme_rx_filter_bcast_match(); } else if (s->macregs[HME_MACI_RXCFG >> 2] & HME_MAC_RXCFG_HENABLE= ) { /* Didn't match local address, check hash filter */ - int mcast_idx =3D sunhme_crc32_le(buf, 6) >> 26; + int mcast_idx =3D net_crc32_le(buf, ETH_ALEN) >> 26; if (!(s->macregs[(HME_MACI_HASHTAB0 >> 2) - (mcast_idx >> 4)] & (1 << (mcast_idx & 0xf)))) { /* Didn't match hash filter */ --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513363473495799.3534854290855; Fri, 15 Dec 2017 10:44:33 -0800 (PST) Received: from localhost ([::1]:48124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuxv-0007C6-9O for importer@patchew.org; Fri, 15 Dec 2017 13:44:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuw5-000629-DB for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePuw2-0006gt-A9 for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:17 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60833 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePuw2-0006e6-4F for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:14 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuwA-0006JD-Ii; Fri, 15 Dec 2017 18:42:23 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:48 +0000 Message-Id: <20171215184155.2543-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 06/13] sungem: fix multicast filter CRC calculation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From the Linux sungem driver, we know that the multicast filter CRC is implemented using ether_crc_le() which isn't the same as calling zlib's crc32() function (the zlib implementation requires a complemented initial v= alue and also returns the complemented result). Fix the multicast filter by simply using the new net_crc32_le() function. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/sungem.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/net/sungem.c b/hw/net/sungem.c index 6aa8d1117b..60f1e479f3 100644 --- a/hw/net/sungem.c +++ b/hw/net/sungem.c @@ -11,12 +11,11 @@ #include "hw/pci/pci.h" #include "qemu/log.h" #include "net/net.h" +#include "net/eth.h" #include "net/checksum.h" #include "hw/net/mii.h" #include "sysemu/sysemu.h" #include "trace.h" -/* For crc32 */ -#include =20 #define TYPE_SUNGEM "sungem" =20 @@ -595,7 +594,7 @@ static ssize_t sungem_receive(NetClientState *nc, const= uint8_t *buf, } =20 /* Get MAC crc */ - mac_crc =3D crc32(~0, buf, 6); + mac_crc =3D net_crc32_le(buf, ETH_ALEN); =20 /* Packet isn't for me ? */ rx_cond =3D sungem_check_rx_mac(s, buf, mac_crc); --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151336362678018.553870746549478; Fri, 15 Dec 2017 10:47:06 -0800 (PST) Received: from localhost ([::1]:48143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv0V-00014E-La for importer@patchew.org; Fri, 15 Dec 2017 13:46:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuw5-00062B-EE for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePuw3-0006ll-Es for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:17 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60838 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePuw3-0006hx-8O for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:15 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuwB-0006JD-Mn; Fri, 15 Dec 2017 18:42:24 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:49 +0000 Message-Id: <20171215184155.2543-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 07/13] eepro100: use inline net_crc32() and bitshift instead of compute_mcast_idx() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This makes it much easier to compare the multicast CRC calculation endian a= nd bitshift against the Linux driver implementation. Signed-off-by: Mark Cave-Ayland --- hw/net/eepro100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index e30fed830b..a07a63247e 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -1679,7 +1679,7 @@ static ssize_t nic_receive(NetClientState *nc, const = uint8_t * buf, size_t size) rfd_status |=3D 0x0004; } else if (s->configuration[20] & BIT(6)) { /* Multiple IA bit set. */ - unsigned mcast_idx =3D compute_mcast_idx(buf); + unsigned mcast_idx =3D net_crc32(buf, ETH_ALEN) >> 26; assert(mcast_idx < 64); if (s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7))) { TRACE(RXTX, logout("%p accepted, multiple IA bit set\n", s)); --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513363765137889.5432719499014; Fri, 15 Dec 2017 10:49:25 -0800 (PST) Received: from localhost ([::1]:48153 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv2k-0002t4-0n for importer@patchew.org; Fri, 15 Dec 2017 13:49:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuw5-00062C-GP for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePuw4-0006oT-Ia for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:17 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60843 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePuw4-0006mb-CI for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:16 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuwC-0006JD-Pb; Fri, 15 Dec 2017 18:42:25 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:50 +0000 Message-Id: <20171215184155.2543-9-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 08/13] opencores_eth: use inline net_crc32() and bitshift instead of compute_mcast_idx() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This makes it much easier to compare the multicast CRC calculation endian a= nd bitshift against the Linux driver implementation. Signed-off-by: Mark Cave-Ayland --- hw/net/opencores_eth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/opencores_eth.c b/hw/net/opencores_eth.c index 268d6a7892..d42b79c08c 100644 --- a/hw/net/opencores_eth.c +++ b/hw/net/opencores_eth.c @@ -36,6 +36,7 @@ #include "hw/net/mii.h" #include "hw/sysbus.h" #include "net/net.h" +#include "net/eth.h" #include "sysemu/sysemu.h" #include "trace.h" =20 @@ -373,7 +374,7 @@ static ssize_t open_eth_receive(NetClientState *nc, if (memcmp(buf, bcast_addr, sizeof(bcast_addr)) =3D=3D 0) { miss =3D GET_REGBIT(s, MODER, BRO); } else if ((buf[0] & 0x1) || GET_REGBIT(s, MODER, IAM)) { - unsigned mcast_idx =3D compute_mcast_idx(buf); + unsigned mcast_idx =3D net_crc32(buf, ETH_ALEN) >> 26; miss =3D !(s->regs[HASH0 + mcast_idx / 32] & (1 << (mcast_idx % 32))); trace_open_eth_receive_mcast( --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513363473476608.7072469482208; Fri, 15 Dec 2017 10:44:33 -0800 (PST) Received: from localhost ([::1]:48126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuxz-0007F1-AP for importer@patchew.org; Fri, 15 Dec 2017 13:44:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePuw6-00062Y-PF for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePuw5-0006rT-Kj for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:18 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60846 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePuw5-0006pE-CY for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:42:17 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuwD-0006JD-Si; Fri, 15 Dec 2017 18:42:26 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:51 +0000 Message-Id: <20171215184155.2543-10-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 09/13] lan9118: use inline net_crc32() and bitshift instead of compute_mcast_idx() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This makes it much easier to compare the multicast CRC calculation endian a= nd bitshift against the Linux driver implementation. Signed-off-by: Mark Cave-Ayland --- hw/net/lan9118.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index 3db8937cac..b9032dac59 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" #include "net/net.h" +#include "net/eth.h" #include "hw/devices.h" #include "sysemu/sysemu.h" #include "hw/ptimer.h" @@ -504,7 +505,7 @@ static int lan9118_filter(lan9118_state *s, const uint8= _t *addr) } } else { /* Hash matching */ - hash =3D compute_mcast_idx(addr); + hash =3D net_crc32(addr, ETH_ALEN) >> 26; if (hash & 0x20) { return (s->mac_hashh >> (hash & 0x1f)) & 1; } else { --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513364142041514.9649221743299; Fri, 15 Dec 2017 10:55:42 -0800 (PST) Received: from localhost ([::1]:48186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv8g-0007lJ-Sg for importer@patchew.org; Fri, 15 Dec 2017 13:55:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv05-00015o-BA for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePv02-0005f1-3c for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:25 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60860 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePv01-0005db-TE for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:22 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuwE-0006JD-Tf; Fri, 15 Dec 2017 18:42:27 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:52 +0000 Message-Id: <20171215184155.2543-11-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 10/13] ftgmac100: use inline net_crc32() and bitshift instead of compute_mcast_idx() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This makes it much easier to compare the multicast CRC calculation endian a= nd bitshift against the Linux driver implementation. Signed-off-by: Mark Cave-Ayland --- hw/net/ftgmac100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c index 3c36ab9cec..704f452067 100644 --- a/hw/net/ftgmac100.c +++ b/hw/net/ftgmac100.c @@ -762,7 +762,7 @@ static int ftgmac100_filter(FTGMAC100State *s, const ui= nt8_t *buf, size_t len) } =20 /* TODO: this does not seem to work for ftgmac100 */ - mcast_idx =3D compute_mcast_idx(buf); + mcast_idx =3D net_crc32(buf, ETH_ALEN) >> 26; if (!(s->math[mcast_idx / 32] & (1 << (mcast_idx % 32)))) { return 0; } --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513363765121351.40890894643064; Fri, 15 Dec 2017 10:49:25 -0800 (PST) Received: from localhost ([::1]:48155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv2k-0002ty-Ae for importer@patchew.org; Fri, 15 Dec 2017 13:49:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv09-00019U-GR for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePv08-0005qR-MK for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:29 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60869 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePv08-0005pA-GA for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:28 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuwG-0006JD-3g; Fri, 15 Dec 2017 18:42:29 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:53 +0000 Message-Id: <20171215184155.2543-12-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 11/13] ne2000: use inline net_crc32() and bitshift instead of compute_mcast_idx() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This makes it much easier to compare the multicast CRC calculation endian a= nd bitshift against the Linux driver implementation. Signed-off-by: Mark Cave-Ayland --- hw/net/ne2000.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c index 3938e6ddd8..7e3b77c00f 100644 --- a/hw/net/ne2000.c +++ b/hw/net/ne2000.c @@ -25,6 +25,7 @@ #include "hw/hw.h" #include "hw/pci/pci.h" #include "net/net.h" +#include "net/eth.h" #include "ne2000.h" #include "hw/loader.h" #include "sysemu/sysemu.h" @@ -201,7 +202,7 @@ ssize_t ne2000_receive(NetClientState *nc, const uint8_= t *buf, size_t size_) /* multicast */ if (!(s->rxcr & 0x08)) return size; - mcast_idx =3D compute_mcast_idx(buf); + mcast_idx =3D net_crc32(buf, ETH_ALEN) >> 26; if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))) return size; } else if (s->mem[0] =3D=3D buf[0] && --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513364018647464.3352794851653; Fri, 15 Dec 2017 10:53:38 -0800 (PST) Received: from localhost ([::1]:48179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv6y-0006PP-2h for importer@patchew.org; Fri, 15 Dec 2017 13:53:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv05-00015l-AJ for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePv04-0005ha-4z for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:25 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60863 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePv03-0005gF-Um for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:24 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuwH-0006JD-7d; Fri, 15 Dec 2017 18:42:30 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:54 +0000 Message-Id: <20171215184155.2543-13-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 12/13] rtl8139: use inline net_crc32() and bitshift instead of compute_mcast_idx() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This makes it much easier to compare the multicast CRC calculation endian a= nd bitshift against the Linux driver implementation. Signed-off-by: Mark Cave-Ayland --- hw/net/rtl8139.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index a6b2a9f7a4..1cc95b8cba 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -882,7 +882,7 @@ static ssize_t rtl8139_do_receive(NetClientState *nc, c= onst uint8_t *buf, size_t return size; } =20 - int mcast_idx =3D compute_mcast_idx(buf); + int mcast_idx =3D net_crc32(buf, ETH_ALEN) >> 26; =20 if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))) { --=20 2.11.0 From nobody Tue Oct 28 21:10:13 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513364132927443.0778961293714; Fri, 15 Dec 2017 10:55:32 -0800 (PST) Received: from localhost ([::1]:48185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv8X-0007ew-9B for importer@patchew.org; Fri, 15 Dec 2017 13:55:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePv07-00017I-3u for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePv06-0005mF-FR for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:27 -0500 Received: from chuckie.co.uk ([82.165.15.123]:60866 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ePv06-0005ks-8W for qemu-devel@nongnu.org; Fri, 15 Dec 2017 13:46:26 -0500 Received: from host109-153-37-215.range109-153.btcentralplus.com ([109.153.37.215] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1ePuwI-0006JD-8g; Fri, 15 Dec 2017 18:42:31 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, jasowang@redhat.com, sw@weilnetz.de Date: Fri, 15 Dec 2017 18:41:55 +0000 Message-Id: <20171215184155.2543-14-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> References: <20171215184155.2543-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.153.37.215 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCHv3 13/13] net: remove unused compute_mcast_idx() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that all of the callers have been converted to compute the multicast in= dex inline using new net CRC functions, this function can now be dropped. Signed-off-by: Mark Cave-Ayland --- net/net.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/net/net.c b/net/net.c index 4ecaf80bd1..5bc0a343ae 100644 --- a/net/net.c +++ b/net/net.c @@ -1625,11 +1625,6 @@ uint32_t net_crc32_le(const uint8_t *p, int len) return crc; } =20 -unsigned compute_mcast_idx(const uint8_t *ep) -{ - return net_crc32(ep, ETH_ALEN) >> 26; -} - QemuOptsList qemu_netdev_opts =3D { .name =3D "netdev", .implied_opt_name =3D "type", --=20 2.11.0