[Letux-kernel] jz4730 Ethernet - works now (unreliable and with some deficiencies)
H. Nikolaus Schaller
hns at goldelico.com
Fri Mar 12 14:58:05 CET 2021
Hi all,
> Am 12.03.2021 um 13:04 schrieb H. Nikolaus Schaller <hns at goldelico.com>:
>
> Hi Paul,
>
>> Am 11.03.2021 um 22:48 schrieb Paul Boddie <paul at boddie.org.uk>:
>>
>> On Thursday, 11 March 2021 13:38:05 CET H. Nikolaus Schaller wrote:
>>>
>>> just a small note: mii does NOT depend on generic DMA working (only MMC does
>>> so far):
>>>
>>> The Ethernet MAC controller uses a dedicated DMA controller to transfer data
>>> between the Ethernet MAC module and the host memory.
>>>
>>> It is very similar to the DMA descriptors of the LCDC.
>>> And the jz4730 ethernet driver has code to do the setup of the buffers.
>>
>> This is very promising and perhaps time-saving, too. I should really look at
>> the manual and see what the details are.
>
> more good news:
> * my reworked driver seems to send out valid ethernet packets
> * because my router did recognize a new device on the LAN and did report the MAC address I had passed when loading the module
> * after manually resetting the ETH irq bit in ICMR I also did see ethernet receive interrupts
> * it seems as if the received packets do not reach DHCP because that fails to work
>
> This all means the PHY does not need to be in DT and does not need a dedicated driver :)
> We may even omit the 'mdio' node in DT because it is not used anywhere as far as I can see.
>
> Here is what the ifconfig statistic says after some experimentations (and setting a manual IPv4 address):
>
> eth0 Link encap:Ethernet HWaddr 00:0a:0b:0c:0d:ff
> inet addr:192.168.2.130 Bcast:192.168.2.255 Mask:255.255.255.0
> inet6 addr: fe80::20a:bff:fe0c:dff/64 Scope:Link
> inet6 addr: 2001:16b8:26a4:e200:20a:bff:fe0c:dff/64 Scope:Global
> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
> RX packets:211 errors:0 dropped:80 overruns:0 frame:0
> TX packets:0 errors:1 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:1000
> RX bytes:20847 (20.3 KiB) TX bytes:1417 (1.3 KiB)
>
> So (again) we have a problem that the IRQ mask is not set up properly or automatically.
> We may have another bug in irq-ingenic.c
after hacking some unmask/mask code for the IRQ it seems to basically work!
root at letux:~# modprobe eth_jz4730
[ 2329.694345] jz4730-eth 13100000.ethernet: There is no MAC address, use default ..
[ 2329.725666] jz_eth_open
[ 2329.728434] jz_init_hw
[ 2329.730988] stop_eth
[ 2329.742288] pwm-backlight backlight: Looking up power-supply from device tree
root at letux:~# [ 2329.781499] panel-simple claa070vc01: Looking up power-supply from device tree
[ 2329.791761] jz4730-eth 13100000.ethernet: JZ On-Chip ethernet (MAC 00:ef:a3:c1:00:03, IRQ 0)
[ 2329.896400] panel-simple claa070vc01: Looking up power-supply property in node /claa070vc01 failed
[ 2329.917782] jz4730-eth 13100000.ethernet: found PHY idx 0 at 16
[ 2329.924221] panel-simple claa070vc01: supply power not found, using dummy regulator
[ 2329.942140] panel_dpi_probe: 00000000
[ 2329.954489] panel-simple claa070vc01: Specify missing connector_type
[ 2329.978351] jz4730-eth 13100000.ethernet: Found 1 PHY on JZ MAC
[ 2329.986267] jz4730-eth 13100000.ethernet: BMCR ====> 0x3100
[ 2329.996154] jz4730-eth 13100000.ethernet: BMSR ====> 0x786d
[ 2330.005176] jz4730-eth 13100000.ethernet: ANAR ====> 0x01e1
[ 2330.012109] jz4730-eth 13100000.ethernet: ANLPAR ====> 0x4de1
[ 2330.021736] jz4730-eth 13100000.ethernet: REG16 ====> 0x000c
[ 2330.030670] jz4730-eth 13100000.ethernet: REG17 ====> 0x05c0
[ 2330.039605] jz4730-eth 13100000.ethernet: ID2 ====> 0x0000
[ 2330.048362] jz4730-eth 13100000.ethernet: ID3 ====> 0x8201
[ 2330.062114] jz4730-eth 13100000.ethernet: Provide Mode: (1)10BaseT-HD
[ 2330.070842] jz4730-eth 13100000.ethernet: Provide Mode: (2)10BaseT-FD
[ 2330.079569] jz4730-eth 13100000.ethernet: Provide Mode: (3)100baseTx-HD
[ 2330.088472] jz4730-eth 13100000.ethernet: Provide Mode: (4)100baseTx-FD
[ 2330.097267] jz_eth_curr_mode
[ 2330.101384] start_eth
[ 2330.106000] jz_init_hw ok
[ 2330.110998] jz_eth_open ok
[ 2330.116039] jz_set_multicast_list
[ 2330.119611] jz4730-eth 13100000.ethernet: ----------------------------
[ 2330.126593] jz4730-eth 13100000.ethernet: This is multicast hash table high bits [0000]
[ 2330.135121] jz4730-eth 13100000.ethernet: This is multicast hash table low bits [0000]
[ 2330.143699] jz4730-eth 13100000.ethernet: enter multicast mode!
[ 2330.149851] jz_set_multicast_list ok
[ 2330.158332] jz_set_multicast_list
[ 2330.161910] jz4730-eth 13100000.ethernet: ----------------------------
[ 2330.168901] jz4730-eth 13100000.ethernet: ----------------------------
[ 2330.175855] jz4730-eth 13100000.ethernet: This is multicast hash table high bits [40000000]
[ 2330.184735] jz4730-eth 13100000.ethernet: This is multicast hash table low bits [0000]
[ 2330.193263] jz4730-eth 13100000.ethernet: enter multicast mode!
[ 2330.199413] jz_set_multicast_list ok
[ 2330.212812] jz_set_multicast_list
[ 2330.216389] jz4730-eth 13100000.ethernet: ----------------------------
[ 2330.223366] jz4730-eth 13100000.ethernet: ----------------------------
[ 2330.230140] jz4730-eth 13100000.ethernet: ----------------------------
[ 2330.237098] jz4730-eth 13100000.ethernet: This is multicast hash table high bits [40000000]
[ 2330.245978] jz4730-eth 13100000.ethernet: This is multicast hash table low bits [80000000]
[ 2330.254852] jz4730-eth 13100000.ethernet: enter multicast mode!
[ 2330.261001] jz_set_multicast_list ok
root at letux:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:ef:a3:c1:00:03
inet addr:192.168.178.42 Bcast:192.168.178.255 Mask:255.255.255.0
inet6 addr: fe80::2ef:a3ff:fec1:3/64 Scope:Link
inet6 addr: 2001:16b8:26a4:e200:2ef:a3ff:fec1:3/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21 errors:0 dropped:8 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2376 (2.3 KiB) TX bytes:1625 (1.5 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:448 errors:0 dropped:0 overruns:0 frame:0
TX packets:448 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:36288 (35.4 KiB) TX bytes:36288 (35.4 KiB)
root at letux:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=119 time=31.2 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=119 time=359 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=119 time=45.9 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=119 time=1036 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=119 time=999 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=119 time=1414 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=119 time=963 ms
64 bytes from 8.8.8.8: icmp_seq=8 ttl=119 time=1085 ms
64 bytes from 8.8.8.8: icmp_seq=9 ttl=119 time=885 ms
^C
--- 8.8.8.8 ping statistics ---
10 packets transmitted, 9 received, 10% packet loss, time 9151ms
rtt min/avg/max/mdev = 31.226/757.779/1414.634/462.652 ms, pipe 2
root at letux:~#
There is also the scheduling issue we know from elsewhere...
ping should be in the 20-30ms range and not 1000.
And it seems to sometimes trigger
[ 3392.563764] WARNING: CPU: 0 PID: 2376 at net/sched/sch_generic.c:443 dev_watchdog+0x1ac/0x1f8
[ 3392.572859] NETDEV WATCHDOG: eth0 (jz4730-eth): transmit queue 0 timed out
>
> The gaps-to-success are now:
> * make the driver transmit & receive properly
seems to work now after fixing minor issues - and enabling IRQ *before* everything is set up
> * unmask the interrupt in time
has been solved by a hack...
another minor issue:
* where do we get the MAC address from?
- is there some EEPROM or NVRAM encoding the MAC address?
- the devices have a sticker with an individual MAC address printed on it - but that may just be the WiFI MAC
- in our good old l400-2.6 kernel there was a hack to call get_ethernet_addr() - have to research what it was doing
Latest code pushed :)
BR,
Nikolaus
More information about the Letux-kernel
mailing list