Skip to contentSkip to conversation

Add npcm7xx emc model

PATCH Applied Doug Evans via 3 participants 7 messages Feb 13, 2021 – Feb 18, 2021 Arm/Amlogic Meson SoC support

v4 of 5 Applied Latest is v5 →

lore
Share & tools
lore
#1 lore raw

PATCH v4 1/3 hw/net: Add npcm7xx emc model

In reply to Doug Evans via

This is a 10/100 ethernet device that has several features. Only the ones needed by the Linux driver have been implemented. See npcm7xx_emc.c for a list of unimplemented features.

---

Differences from v3:
- no change

Differences from v2:
- move call to qemu_set_irq
- remove use of C99 mixed decls/statements
- add use of g_autofree

 hw/net/meson.build           |   1 +
 hw/net/npcm7xx_emc.c         | 857 +++++++++++++++++++++++++++++++++++
 hw/net/trace-events          |  17 +
 include/hw/net/npcm7xx_emc.h | 286 ++++++++++++
 4 files changed, 1161 insertions(+)
 create mode 100644 hw/net/npcm7xx_emc.c
 create mode 100644 include/hw/net/npcm7xx_emc.h
hw/net/meson.build +1 -0
index 4a7051b54a..af0749c42b 100644
@@ -35,6 +35,7 @@ softmmu_ss.add(when: 'CONFIG_I82596_COMMON', if_true: files('i82596.c'))
 softmmu_ss.add(when: 'CONFIG_SUNHME', if_true: files('sunhme.c'))
 softmmu_ss.add(when: 'CONFIG_FTGMAC100', if_true: files('ftgmac100.c'))
 softmmu_ss.add(when: 'CONFIG_SUNGEM', if_true: files('sungem.c'))
+softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_emc.c'))
 
 softmmu_ss.add(when: 'CONFIG_ETRAXFS', if_true: files('etraxfs_eth.c'))
 softmmu_ss.add(when: 'CONFIG_COLDFIRE', if_true: files('mcf_fec.c'))
hw/net/npcm7xx_emc.c new file +857 -0

857 lines not on this page · raw message

hw/net/trace-events +17 -0
index 5db45456d9..baf25ffa7e 100644
@@ -429,3 +429,20 @@ imx_fec_receive_last(int last) "rx frame flags 0x%04x"
 imx_enet_receive(size_t size) "len %zu"
 imx_enet_receive_len(uint64_t addr, int len) "rx_bd 0x%"PRIx64" length %d"
 imx_enet_receive_last(int last) "rx frame flags 0x%04x"
+
+# npcm7xx_emc.c
+npcm7xx_emc_reset(int emc_num) "Resetting emc%d"
+npcm7xx_emc_update_tx_irq(int level) "Setting tx irq to %d"
+npcm7xx_emc_update_rx_irq(int level) "Setting rx irq to %d"
+npcm7xx_emc_set_mista(uint32_t flags) "ORing 0x%x into MISTA"
+npcm7xx_emc_cpu_owned_desc(uint32_t addr) "Can't process cpu-owned descriptor @0x%x"
+npcm7xx_emc_sent_packet(uint32_t len) "Sent %u byte packet"
+npcm7xx_emc_tx_done(uint32_t ctxdsa) "TX done, CTXDSA=0x%x"
+npcm7xx_emc_can_receive(int can_receive) "Can receive: %d"
+npcm7xx_emc_packet_filtered_out(const char* fail_reason) "Packet filtered out: %s"
+npcm7xx_emc_packet_dropped(uint32_t len) "%u byte packet dropped"
+npcm7xx_emc_receiving_packet(uint32_t len) "Receiving %u byte packet"
+npcm7xx_emc_received_packet(uint32_t len) "Received %u byte packet"
+npcm7xx_emc_rx_done(uint32_t crxdsa) "RX done, CRXDSA=0x%x"
+npcm7xx_emc_reg_read(int emc_num, uint32_t result, const char *name, int regno) "emc%d: 0x%x = reg[%s/%d]"
+npcm7xx_emc_reg_write(int emc_num, const char *name, int regno, uint32_t value) "emc%d: reg[%s/%d] = 0x%x"
include/hw/net/npcm7xx_emc.h new file +286 -0

286 lines not on this page · raw message

Signature · 1 line
2.30.0.478.g8a0d178c01-goog
#0 lore raw

v4 cover Add npcm7xx emc model

This is a 10/100 ethernet device that has several features. Only the ones needed by the Linux driver have been implemented. See npcm7xx_emc.c for a list of unimplemented features.

Doug Evans (3):
hw/net: Add npcm7xx emc model
hw/arm: Add npcm7xx emc model
tests/qtests: Add npcm7xx emc model test

 docs/system/arm/nuvoton.rst    |   3 +-
 hw/arm/npcm7xx.c               |  50 +-
 hw/net/meson.build             |   1 +
 hw/net/npcm7xx_emc.c           | 857 ++++++++++++++++++++++++++++++++
 hw/net/trace-events            |  17 +
 include/hw/arm/npcm7xx.h       |   2 +
 include/hw/net/npcm7xx_emc.h   | 286 +++++++++++
 tests/qtest/meson.build        |   1 +
 tests/qtest/npcm7xx_emc-test.c | 862 +++++++++++++++++++++++++++++++++
 9 files changed, 2076 insertions(+), 3 deletions(-)
 create mode 100644 hw/net/npcm7xx_emc.c
 create mode 100644 include/hw/net/npcm7xx_emc.h
 create mode 100644 tests/qtest/npcm7xx_emc-test.c
Signature · 25 lines
2.30.0.478.g8a0d178c01-goog

Differences from v3:

1/3 hw/net: Add npcm7xx emc model
- no change

2/3 hw/arm: Add npcm7xx emc model
- no change

3/3 tests/qtests: Add npcm7xx emc model test
- handle big endian hosts, tested on sparc64

Differences from v2:

1/3 hw/net: Add npcm7xx emc model
- move call to qemu_set_irq
- remove use of C99 mixed decls/statements
- add use of g_autofree

2/3 hw/arm: Add npcm7xx emc model
- none, patch ok as is

3/3 tests/qtests: Add npcm7xx emc model test
- remove use of C99 mixed decls/statements
#2 lore raw

PATCH v4 2/3 hw/arm: Add npcm7xx emc model

This is a 10/100 ethernet device that has several features. Only the ones needed by the Linux driver have been implemented. See npcm7xx_emc.c for a list of unimplemented features.

---

Differences from v3:
- no change

Differences from v2:
- none, patch ok as is

 docs/system/arm/nuvoton.rst |  3 ++-
 hw/arm/npcm7xx.c            | 50 +++++++++++++++++++++++++++++++++++--
 include/hw/arm/npcm7xx.h    |  2 ++
 3 files changed, 52 insertions(+), 3 deletions(-)
docs/system/arm/nuvoton.rst +2 -1
index a1786342e2..c6e9a4c17e 100644
@@ -43,6 +43,7 @@ Supported devices
  * GPIO controller
  * Analog to Digital Converter (ADC)
  * Pulse Width Modulation (PWM)
+ * Ethernet controller (EMC)
 
 Missing devices
 ---------------
@@ -56,7 +57,7 @@ Missing devices
    * Shared memory (SHM)
    * eSPI slave interface
 
- * Ethernet controllers (GMAC and EMC)
+ * Ethernet controller (GMAC)
  * USB device (USBD)
  * SMBus controller (SMBF)
  * Peripheral SPI controller (PSPI)
hw/arm/npcm7xx.c +48 -2

86 lines not on this page · raw message

include/hw/arm/npcm7xx.h +2 -0
index f6227aa8aa..3bfc75aafe 100644
@@ -25,6 +25,7 @@
 #include "hw/misc/npcm7xx_gcr.h"
 #include "hw/misc/npcm7xx_pwm.h"
 #include "hw/misc/npcm7xx_rng.h"
+#include "hw/net/npcm7xx_emc.h"
 #include "hw/nvram/npcm7xx_otp.h"
 #include "hw/timer/npcm7xx_timer.h"
 #include "hw/ssi/npcm7xx_fiu.h"
@@ -88,6 +89,7 @@ typedef struct NPCM7xxState {
     EHCISysBusState     ehci;
     OHCISysBusState     ohci;
     NPCM7xxFIUState     fiu[2];
+    NPCM7xxEMCState     emc[2];
 } NPCM7xxState;
 
 #define TYPE_NPCM7XX    "npcm7xx"
Signature · 1 line
2.30.0.478.g8a0d178c01-goog
#3 lore raw

PATCH v4 3/3 tests/qtests: Add npcm7xx emc model test

In reply to Doug Evans via

---

Differences from v3:
- handle big endian hosts, tested on sparc64

Differences from v2:
- remove use of C99 mixed decls/statements

 tests/qtest/meson.build        |   1 +
 tests/qtest/npcm7xx_emc-test.c | 862 +++++++++++++++++++++++++++++++++
 2 files changed, 863 insertions(+)
 create mode 100644 tests/qtest/npcm7xx_emc-test.c
tests/qtest/meson.build +1 -0
index c83bc211b6..f7c369f3d5 100644
@@ -136,6 +136,7 @@ qtests_sparc64 = \
 
 qtests_npcm7xx = \
   ['npcm7xx_adc-test',
+   'npcm7xx_emc-test',
    'npcm7xx_gpio-test',
    'npcm7xx_pwm-test',
    'npcm7xx_rng-test',
tests/qtest/npcm7xx_emc-test.c new file +862 -0

862 lines not on this page · raw message

Signature · 1 line
2.30.0.478.g8a0d178c01-goog
#4 lore raw
In reply to Doug Evans via
Quoted 10 lines · Doug Evans

This is a 10/100 ethernet device that has several features. Only the ones needed by the Linux driver have been implemented. See npcm7xx_emc.c for a list of unimplemented features.

Doug Evans (3):
hw/net: Add npcm7xx emc model
hw/arm: Add npcm7xx emc model
tests/qtests: Add npcm7xx emc model test

Applied to target-arm.next, thanks.

-- PMM

#5 lore raw
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Doug Evans

This is a 10/100 ethernet device that has several features. Only the ones needed by the Linux driver have been implemented. See npcm7xx_emc.c for a list of unimplemented features.

Quoted 8 lines
Quoted 5 lines

Doug Evans (3):
hw/net: Add npcm7xx emc model
hw/arm: Add npcm7xx emc model
tests/qtests: Add npcm7xx emc model test

Applied to target-arm.next, thanks.

Dropped again: it failed some oddball config in the gitlab CI:
https://gitlab.com/qemu-project/qemu/-/jobs/1034174731#L12

-- PMM

#6 lore raw
Quoted 16 lines · Peter Maydell
Quoted 14 lines · Peter Maydell
Quoted 10 lines · Doug Evans

This is a 10/100 ethernet device that has several features. Only the ones needed by the Linux driver have been implemented. See npcm7xx_emc.c for a list of unimplemented features.

Doug Evans (3):
hw/net: Add npcm7xx emc model
hw/arm: Add npcm7xx emc model
tests/qtests: Add npcm7xx emc model test

Quoted 7 lines
Quoted 1 line

Applied to target-arm.next, thanks.

Dropped again: it failed some oddball config in the gitlab CI:
https://gitlab.com/qemu-project/qemu/-/jobs/1034174731#L12

-- PMM

Yeah, the test needs to watch for --disable-slirp. Fixed in v5:
https://lists.nongnu.org/archive/html/qemu-devel/2021-02/msg06030.html