aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2021-03-30 14:05:33 +0100
committerPeter Maydell <peter.maydell@linaro.org>2021-03-30 14:05:33 +0100
commita62ee00aa063b8fa27076ec5100b2475fcd677ed (patch)
tree3b2a47ba8b4cd2c3d7673aa1bd23aef2b476455a /tests
parent7993b0f83fe5c3f8555e79781d5d098f99751a94 (diff)
net/npcm7xx_emc.c: Fix handling of receiving packets when RSDR not set
Turning REG_MCMDR_RXON is enough to start receiving packets. Signed-off-by: Doug Evans <dje@google.com> Message-id: 20210319195044.741821-1-dje@google.com Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/npcm7xx_emc-test.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c
index 7a28173195..9eec71d87c 100644
--- a/tests/qtest/npcm7xx_emc-test.c
+++ b/tests/qtest/npcm7xx_emc-test.c
@@ -492,9 +492,6 @@ static void enable_tx(QTestState *qts, const EMCModule *mod,
mcmdr |= REG_MCMDR_TXON;
emc_write(qts, mod, REG_MCMDR, mcmdr);
}
-
- /* Prod the device to send the packet. */
- emc_write(qts, mod, REG_TSDR, 1);
}
static void emc_send_verify1(QTestState *qts, const EMCModule *mod, int fd,
@@ -558,6 +555,9 @@ static void emc_send_verify(QTestState *qts, const EMCModule *mod, int fd,
enable_tx(qts, mod, &desc[0], NUM_TX_DESCRIPTORS, desc_addr,
with_irq ? REG_MIEN_ENTXINTR : 0);
+ /* Prod the device to send the packet. */
+ emc_write(qts, mod, REG_TSDR, 1);
+
/*
* It's problematic to observe the interrupt for each packet.
* Instead just wait until all the packets go out.
@@ -643,13 +643,10 @@ static void enable_rx(QTestState *qts, const EMCModule *mod,
mcmdr |= REG_MCMDR_RXON | mcmdr_flags;
emc_write(qts, mod, REG_MCMDR, mcmdr);
}
-
- /* Prod the device to accept a packet. */
- emc_write(qts, mod, REG_RSDR, 1);
}
static void emc_recv_verify(QTestState *qts, const EMCModule *mod, int fd,
- bool with_irq)
+ bool with_irq, bool pump_rsdr)
{
NPCM7xxEMCRxDesc desc[NUM_RX_DESCRIPTORS];
uint32_t desc_addr = DESC_ADDR;
@@ -679,6 +676,15 @@ static void emc_recv_verify(QTestState *qts, const EMCModule *mod, int fd,
enable_rx(qts, mod, &desc[0], NUM_RX_DESCRIPTORS, desc_addr,
with_irq ? REG_MIEN_ENRXINTR : 0, 0);
+ /*
+ * If requested, prod the device to accept a packet.
+ * This isn't necessary, the linux driver doesn't do this.
+ * Test doing/not-doing this for robustness.
+ */
+ if (pump_rsdr) {
+ emc_write(qts, mod, REG_RSDR, 1);
+ }
+
/* Send test packet to device's socket. */
ret = iov_send(fd, iov, 2, 0, sizeof(len) + sizeof(test));
g_assert_cmpint(ret, == , sizeof(test) + sizeof(len));
@@ -826,8 +832,14 @@ static void test_rx(gconstpointer test_data)
qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic");
- emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=*/false);
- emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=*/true);
+ emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=*/false,
+ /*pump_rsdr=*/false);
+ emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=*/false,
+ /*pump_rsdr=*/true);
+ emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=*/true,
+ /*pump_rsdr=*/false);
+ emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=*/true,
+ /*pump_rsdr=*/true);
emc_test_ptle(qts, td->module, test_sockets[0]);
qtest_quit(qts);