aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki@daynix.com>2022-11-03 18:54:16 +0900
committerThomas Huth <thuth@redhat.com>2022-11-06 10:14:26 +0100
commitdfa644b231a55e50571b99bc65a2fff530e6913c (patch)
tree37622248bbedb55d15e25ce18d82514d865d556b
parentff4f45811fb2ca8f17ef78361128b03dbb679185 (diff)
downloadqemu-dfa644b231a55e50571b99bc65a2fff530e6913c.zip
qemu-dfa644b231a55e50571b99bc65a2fff530e6913c.tar.gz
qemu-dfa644b231a55e50571b99bc65a2fff530e6913c.tar.bz2
tests/qtest/e1000e-test: Use e1000_regs.h
The register definitions in tests/qtest/e1000e-test.c had names different from hw/net/e1000_regs.h, which made it hard to understand what test codes corresponds to the implementation. Use hw/net/e1000_regs.h from tests/qtest/libqos/e1000e.c to remove these duplications. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20221103095416.110162-1-akihiko.odaki@daynix.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com>
-rw-r--r--tests/qtest/e1000e-test.c66
1 files changed, 10 insertions, 56 deletions
diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c
index 4cdd823..08adc52 100644
--- a/tests/qtest/e1000e-test.c
+++ b/tests/qtest/e1000e-test.c
@@ -33,34 +33,11 @@
#include "qemu/bitops.h"
#include "libqos/libqos-malloc.h"
#include "libqos/e1000e.h"
+#include "hw/net/e1000_regs.h"
static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator *alloc)
{
- struct {
- uint64_t buffer_addr;
- union {
- uint32_t data;
- struct {
- uint16_t length;
- uint8_t cso;
- uint8_t cmd;
- } flags;
- } lower;
- union {
- uint32_t data;
- struct {
- uint8_t status;
- uint8_t css;
- uint16_t special;
- } fields;
- } upper;
- } descr;
-
- static const uint32_t dtyp_data = BIT(20);
- static const uint32_t dtyp_ext = BIT(29);
- static const uint32_t dcmd_rs = BIT(27);
- static const uint32_t dcmd_eop = BIT(24);
- static const uint32_t dsta_dd = BIT(0);
+ struct e1000_tx_desc descr;
static const int data_len = 64;
char buffer[64];
int ret;
@@ -73,10 +50,10 @@ static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator *a
/* Prepare TX descriptor */
memset(&descr, 0, sizeof(descr));
descr.buffer_addr = cpu_to_le64(data);
- descr.lower.data = cpu_to_le32(dcmd_rs |
- dcmd_eop |
- dtyp_ext |
- dtyp_data |
+ descr.lower.data = cpu_to_le32(E1000_TXD_CMD_RS |
+ E1000_TXD_CMD_EOP |
+ E1000_TXD_CMD_DEXT |
+ E1000_TXD_DTYP_D |
data_len);
/* Put descriptor to the ring */
@@ -86,7 +63,8 @@ static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator *a
e1000e_wait_isr(d, E1000E_TX0_MSG_ID);
/* Check DD bit */
- g_assert_cmphex(le32_to_cpu(descr.upper.data) & dsta_dd, ==, dsta_dd);
+ g_assert_cmphex(le32_to_cpu(descr.upper.data) & E1000_TXD_STAT_DD, ==,
+ E1000_TXD_STAT_DD);
/* Check data sent to the backend */
ret = recv(test_sockets[0], &recv_len, sizeof(recv_len), 0);
@@ -101,31 +79,7 @@ static void e1000e_send_verify(QE1000E *d, int *test_sockets, QGuestAllocator *a
static void e1000e_receive_verify(QE1000E *d, int *test_sockets, QGuestAllocator *alloc)
{
- union {
- struct {
- uint64_t buffer_addr;
- uint64_t reserved;
- } read;
- struct {
- struct {
- uint32_t mrq;
- union {
- uint32_t rss;
- struct {
- uint16_t ip_id;
- uint16_t csum;
- } csum_ip;
- } hi_dword;
- } lower;
- struct {
- uint32_t status_error;
- uint16_t length;
- uint16_t vlan;
- } upper;
- } wb;
- } descr;
-
- static const uint32_t esta_dd = BIT(0);
+ union e1000_rx_desc_extended descr;
char test[] = "TEST";
int len = htonl(sizeof(test));
@@ -162,7 +116,7 @@ static void e1000e_receive_verify(QE1000E *d, int *test_sockets, QGuestAllocator
/* Check DD bit */
g_assert_cmphex(le32_to_cpu(descr.wb.upper.status_error) &
- esta_dd, ==, esta_dd);
+ E1000_RXD_STAT_DD, ==, E1000_RXD_STAT_DD);
/* Check data sent to the backend */
memread(data, buffer, sizeof(buffer));