From: bilalwasim676@gmail.com
To: qemu-devel@nongnu.org
Cc: edgar.iglesias@gmail.com, qemu-arm@nongnu.org,
bilal_wasim@mentor.com, alistair@alistair23.me,
peter.maydell@linaro.org
Subject: [PATCH v3] net/cadence_gem: Updating the GEM MAC IP to properly filter out multicast addresses.
Date: Fri, 29 Nov 2019 15:24:14 +0500 [thread overview]
Message-ID: <20191129102414.14060-1-bilalwasim676@gmail.com> (raw)
From: bwasim <bilal_wasim@mentor.com>
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 <bilal_wasim@mentor.com>
---
hw/net/cadence_gem.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index b8be73dc55..6400b3653b 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"
#ifdef CADENCE_GEM_ERR_DEBUG
#define DB_PRINT(...) do { \
@@ -601,7 +602,7 @@ static void gem_receive_updatestats(CadenceGEMState *s, const uint8_t *packet,
}
/* Error-free Multicast Frames counter */
- if (packet[0] == 0x01) {
+ if (is_multicast_ether_addr(packet)) {
s->regs[GEM_RXMULTICNT]++;
}
@@ -690,21 +691,25 @@ static int gem_mac_address_filter(CadenceGEMState *s, const uint8_t *packet)
}
/* Accept packets -w- hash match? */
- if ((packet[0] == 0x01 && (s->regs[GEM_NWCFG] & GEM_NWCFG_MCAST_HASH)) ||
- (packet[0] != 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;
hash_index = calc_mac_hash(packet);
if (hash_index < 32) {
if (s->regs[GEM_HASHLO] & (1<<hash_index)) {
- return packet[0] == 0x01 ? GEM_RX_MULTICAST_HASH_ACCEPT :
- GEM_RX_UNICAST_HASH_ACCEPT;
+ return is_multicast_ether_addr(packet) ?
+ GEM_RX_MULTICAST_HASH_ACCEPT :
+ GEM_RX_UNICAST_HASH_ACCEPT;
}
} else {
hash_index -= 32;
if (s->regs[GEM_HASHHI] & (1<<hash_index)) {
- return packet[0] == 0x01 ? GEM_RX_MULTICAST_HASH_ACCEPT :
- GEM_RX_UNICAST_HASH_ACCEPT;
+ return is_multicast_ether_addr(packet) ?
+ GEM_RX_MULTICAST_HASH_ACCEPT :
+ GEM_RX_UNICAST_HASH_ACCEPT;
}
}
}
@@ -1083,7 +1088,7 @@ static void gem_transmit_updatestats(CadenceGEMState *s, const uint8_t *packet,
}
/* Error-free Multicast Frames counter */
- if (packet[0] == 0x01) {
+ if (is_multicast_ether_addr(packet)) {
s->regs[GEM_TXMCNT]++;
}
--
2.19.1.windows.1
next reply other threads:[~2019-11-29 13:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-29 10:24 bilalwasim676 [this message]
2019-11-29 11:22 ` [PATCH v3] net/cadence_gem: Updating the GEM MAC IP to properly filter out multicast addresses Edgar E. Iglesias
2019-11-29 11:25 ` Wasim, Bilal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191129102414.14060-1-bilalwasim676@gmail.com \
--to=bilalwasim676@gmail.com \
--cc=alistair@alistair23.me \
--cc=bilal_wasim@mentor.com \
--cc=edgar.iglesias@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).