aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2022-10-03 10:38:10 -0700
committerPeter Maydell <peter.maydell@linaro.org>2023-05-02 15:47:39 +0100
commit471896381ae895b1c4c2afe1eff2ce13d85e6c2c (patch)
tree9df54e7eb054706255d12fbe7e3a75514bf20a70 /hw
parentaecca1773fa504d90813b6f5e984f64b4b0f6493 (diff)
downloadqemu-471896381ae895b1c4c2afe1eff2ce13d85e6c2c.zip
qemu-471896381ae895b1c4c2afe1eff2ce13d85e6c2c.tar.gz
qemu-471896381ae895b1c4c2afe1eff2ce13d85e6c2c.tar.bz2
hw/net: npcm7xx_emc: set MAC in register space
The MAC address set from Qemu wasn't being saved into the register space. Reviewed-by: Hao Wu <wuhaotsh@google.com> Signed-off-by: Patrick Venture <venture@google.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> [PMM: moved variable declaration to top of function] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw')
-rw-r--r--hw/net/npcm7xx_emc.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c
index 7c86bb5..8156f70 100644
--- a/hw/net/npcm7xx_emc.c
+++ b/hw/net/npcm7xx_emc.c
@@ -98,6 +98,8 @@ static const char *emc_reg_name(int regno)
static void emc_reset(NPCM7xxEMCState *emc)
{
+ uint32_t value;
+
trace_npcm7xx_emc_reset(emc->emc_num);
memset(&emc->regs[0], 0, sizeof(emc->regs));
@@ -112,6 +114,16 @@ static void emc_reset(NPCM7xxEMCState *emc)
emc->tx_active = false;
emc->rx_active = false;
+
+ /* Set the MAC address in the register space. */
+ value = (emc->conf.macaddr.a[0] << 24) |
+ (emc->conf.macaddr.a[1] << 16) |
+ (emc->conf.macaddr.a[2] << 8) |
+ emc->conf.macaddr.a[3];
+ emc->regs[REG_CAMM_BASE] = value;
+
+ value = (emc->conf.macaddr.a[4] << 24) | (emc->conf.macaddr.a[5] << 16);
+ emc->regs[REG_CAML_BASE] = value;
}
static void npcm7xx_emc_reset(DeviceState *dev)
@@ -432,13 +444,25 @@ static bool emc_receive_filter1(NPCM7xxEMCState *emc, const uint8_t *buf,
}
case ETH_PKT_UCAST: {
bool matches;
+ uint32_t value;
+ struct MACAddr mac;
if (emc->regs[REG_CAMCMR] & REG_CAMCMR_AUP) {
return true;
}
+
+ value = emc->regs[REG_CAMM_BASE];
+ mac.a[0] = value >> 24;
+ mac.a[1] = value >> 16;
+ mac.a[2] = value >> 8;
+ mac.a[3] = value >> 0;
+ value = emc->regs[REG_CAML_BASE];
+ mac.a[4] = value >> 24;
+ mac.a[5] = value >> 16;
+
matches = ((emc->regs[REG_CAMCMR] & REG_CAMCMR_ECMP) &&
/* We only support one CAM register, CAM0. */
(emc->regs[REG_CAMEN] & (1 << 0)) &&
- memcmp(buf, emc->conf.macaddr.a, ETH_ALEN) == 0);
+ memcmp(buf, mac.a, ETH_ALEN) == 0);
if (emc->regs[REG_CAMCMR] & REG_CAMCMR_CCAM) {
*fail_reason = "MACADDR matched, comparison complemented";
return !matches;
@@ -661,15 +685,9 @@ static void npcm7xx_emc_write(void *opaque, hwaddr offset,
break;
case REG_CAMM_BASE + 0:
emc->regs[reg] = value;
- emc->conf.macaddr.a[0] = value >> 24;
- emc->conf.macaddr.a[1] = value >> 16;
- emc->conf.macaddr.a[2] = value >> 8;
- emc->conf.macaddr.a[3] = value >> 0;
break;
case REG_CAML_BASE + 0:
emc->regs[reg] = value;
- emc->conf.macaddr.a[4] = value >> 24;
- emc->conf.macaddr.a[5] = value >> 16;
break;
case REG_MCMDR: {
uint32_t prev;