hw/net: add DEC Tulip NIC emulation
RFC 1/1 hw/net: add DEC Tulip NIC emulation
From: Antony Pavlov <[email protected]>
This patch adds emulation of DEC/Intel Tulip 21143 with some external chips:
* Intel LXT971A 10/100 Mbps PHY MII Tranceiver;
* Microchip 93LC46B 1K Microwire Compatible Serial EEPROM.
Restrictions and TODOs:
- Tulip always work in promisc-mode with no packet filtering (TODO: check qemu packet filtering interfaces)
- Address errors in packet descriptors are not checked
- Tulip is bound to PCI, no other bus is possible for now (TODO: Rewrite code to permit Tulip to live on buses other than PCI)
- Internal transceiver is not emulated
The reason: internal transceiver works with 10 Mbps but we need 100Mbps which only external transceivers can give.
- Link status is not emulated, it's always ON
(TODO: use standard qemu interface)
- Incorrect behavior of the Tulip driver is not checked and there's no error signaling via register CSR5
- Only transfer/receive (TI/RI) interrupts are emulated
- Subsystem IDs in EEPROM image are not good
(TODO: find proper IDs)
TESTING
-------
NOTE:
buildroot with tulip-friendly config for qemu is here:
https://github.com/dmitrysmagin/buildroot.git : master (configs/qemu_mips_malta_tulip_defconfig)
$ git clone https://github.com/dmitrysmagin/qemu.git $ cd qemu $ ./configure --target-list=mips-softmmu ... $ make ... $ ./mips-softmmu/qemu-system-mips \ -M malta \ -m 256 \ -nodefaults \ -nographic \ -kernel qemu-malta-testing/vmlinux \ -initrd qemu-malta-testing/rootfs.cpio \ -serial stdio \ -net nic,vlan=0,model=tulip,macaddr=00:11:22:33:44:ee
Linux version 3.12.0 (exmortis@lazar) (gcc version 4.7.3 (Sourcery CodeBench Lite 2013.05-66) ) #1 SMP Thu Nov 14 11:58:04 MSK 2013
...
Welcome to Buildroot
buildroot login: root
# lspci -d 0x1011:
00:12.0 Ethernet controller: Digital Equipment Corporation DECchip 21142/43 (rev 41)
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:11:22:33:44:EE
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)To test data transfer please use '-net tap,vlan=0,...' or '-net vde,vlan=0,...' (depends on your local network settings).
--- default-configs/pci.mak | 1 + hw/net/Makefile.objs | 1 + hw/net/tulip.c | 680 ++++++++++++++++++++++++++++++++++++++++++++ hw/net/tulip_mdio.c | 196 +++++++++++++ hw/net/tulip_mdio.h | 98 +++++++ hw/net/tulip_uwire_eeprom.c | 111 ++++++++ hw/net/tulip_uwire_eeprom.h | 60 ++++ hw/pci/pci.c | 2 + include/hw/pci/pci_ids.h | 1 + 9 files changed, 1150 insertions(+) create mode 100644 hw/net/tulip.c create mode 100644 hw/net/tulip_mdio.c create mode 100644 hw/net/tulip_mdio.h create mode 100644 hw/net/tulip_uwire_eeprom.c create mode 100644 hw/net/tulip_uwire_eeprom.h
default-configs/pci.mak +1 -0
@@ -18,6 +18,7 @@ CONFIG_MEGASAS_SCSI_PCI=y CONFIG_RTL8139_PCI=y CONFIG_E1000_PCI=y CONFIG_VMXNET3_PCI=y +CONFIG_TULIP_PCI=y CONFIG_IDE_CORE=y CONFIG_IDE_QDEV=y CONFIG_IDE_PCI=y
hw/net/Makefile.objs +1 -0
@@ -10,6 +10,7 @@ common-obj-$(CONFIG_E1000_PCI) += e1000.o common-obj-$(CONFIG_RTL8139_PCI) += rtl8139.o common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet_tx_pkt.o vmxnet_rx_pkt.o common-obj-$(CONFIG_VMXNET3_PCI) += vmxnet3.o +common-obj-$(CONFIG_TULIP_PCI) += tulip.o tulip_uwire_eeprom.o tulip_mdio.o common-obj-$(CONFIG_SMC91C111) += smc91c111.o common-obj-$(CONFIG_LAN9118) += lan9118.o
hw/net/tulip.c new file +680 -0
680 lines not on this page · raw message
hw/net/tulip_mdio.c new file +196 -0
196 lines not on this page · raw message
hw/net/tulip_mdio.h new file +98 -0
98 lines not on this page · raw message
hw/net/tulip_uwire_eeprom.c new file +111 -0
111 lines not on this page · raw message
hw/net/tulip_uwire_eeprom.h new file +60 -0
60 lines not on this page · raw message
hw/pci/pci.c +2 -0
@@ -1600,6 +1600,7 @@ static const char * const pci_nic_models[] = {"e1000" ,"pcnet" ,"virtio" , +"tulip" , NULL };
@@ -1612,6 +1613,7 @@ static const char * const pci_nic_names[] = {"e1000" ,"pcnet" ,"virtio-net-pci" , +"tulip" , NULL };
include/hw/pci/pci_ids.h +1 -0
@@ -58,6 +58,7 @@#define PCI_DEVICE_ID_LSI_SAS1078 0x0060#define PCI_VENDOR_ID_DEC 0x1011 +#define PCI_DEVICE_ID_DEC_21142 0x0019#define PCI_DEVICE_ID_DEC_21154 0x0026#define PCI_VENDOR_ID_CIRRUS 0x1013
Signature · 1 line
1.8.4.rc3
Quoted 22 lines · Dmitry Smagin
From: Antony Pavlov <[email protected]>
This patch adds emulation of DEC/Intel Tulip 21143 with some external chips:
* Intel LXT971A 10/100 Mbps PHY MII Tranceiver;
* Microchip 93LC46B 1K Microwire Compatible Serial EEPROM.Restrictions and TODOs:
- Tulip always work in promisc-mode with no packet filtering (TODO: check qemu packet filtering interfaces)- Address errors in packet descriptors are not checked
- Tulip is bound to PCI, no other bus is possible for now (TODO: Rewrite code to permit Tulip to live on buses other than PCI)
- Internal transceiver is not emulated
The reason: internal transceiver works with 10 Mbps but we need 100Mbps which only external transceivers can give.- Link status is not emulated, it's always ON
(TODO: use standard qemu interface)
Quoted 7 lines
- Incorrect behavior of the Tulip driver is not checked and there's no error signaling via register CSR5
- Only transfer/receive (TI/RI) interrupts are emulated
- Subsystem IDs in EEPROM image are not good
(TODO: find proper IDs)
The NIC needs to tell QEMU when it transitions from a rx descriptors exhausted state to a rx refilled state. For example, the e1000 NIC calls qemu_flush_queued_packets(qemu_get_queue(s->nic)) when the RDT hardware register is written to by the guest.
This is necessary since the netdev (e.g. tap) disables receive when the NIC runs out of rx descriptors.
hw/net/tulip.c line 478
Quoted 8 lines
hw/net/tulip.c new file +8
-0+static const VMStateDescription vmstate_tulip = { + .name ="tulip" , + .version_id =2 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE (dev, TulipState), +VMSTATE_MACADDR (conf.macaddr, TulipState),
This looks a little sparse :). Other hardware registers probably need to be saved/loaded too.