Bug 264855 - axe: axe usb driver, AX88772, fails to perform autoselect when the axe interface is changed from forced mode to autoselect mode
Summary: axe: axe usb driver, AX88772, fails to perform autoselect when the axe interf...
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: arm64 Any
: --- Affects Some People
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-23 18:00 UTC by Jiahao LI
Modified: 2022-06-23 18:34 UTC (History)
1 user (show)

See Also:


Attachments
Preliminary fix patch for restarting autoselect mode in AX88772 (594 bytes, patch)
2022-06-23 18:00 UTC, Jiahao LI
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiahao LI 2022-06-23 18:00:09 UTC
Created attachment 234897 [details]
Preliminary fix patch for restarting autoselect mode in AX88772

Test is based on the current release of Freebsd.

root@generic:~ # uname -a
FreeBSD generic 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n254961-b91a48693a5: Thu Apr 21 09:35:51 UTC 2022     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/arm64.aarch64/sys/GENERIC arm64

I use RockPro64 LPDDR4:4G to perform the following test. The axe interface is directly connected to a Linux host interface, enp0s31f6.

1. The axe interface and enp0s31f6 are set to their highest speed and full duplex mode when autonegotiation is enable in both interface after booting up

root@generic:~ # ifconfig -m ue0
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=80008<VLAN_MTU,LINKSTATE>
        capabilities=80008<VLAN_MTU,LINKSTATE>
        ether 00:80:c8:3a:ba:f1
        inet 192.168.3.76 netmask 0xffffff00 broadcast 192.168.3.255
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
        supported media:
                media autoselect
                media 100baseTX mediaopt full-duplex
                media 100baseTX
                media 10baseT/UTP mediaopt full-duplex
                media 10baseT/UTP
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

$ sudo ethtool enp0s31f6
[sudo] password for jiahali: 
Settings for enp0s31f6:
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Speed: 100Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	MDI-X: on (auto)
	Supports Wake-on: pumbg
	Wake-on: d
	Current message level: 0x00000007 (7)
			       drv probe link
	Link detected: yes

2. Changing the axe interface to a forced mode. The enp0s31f6 is set as same speed but half-duplex mode

root@generic:~ # ifconfig -m ue0 media 10baseT/UTP mediaopt full-duplex
root@generic:~ # ifconfig -m ue0
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=80008<VLAN_MTU,LINKSTATE>
        capabilities=80008<VLAN_MTU,LINKSTATE>
        ether 00:80:c8:3a:ba:f1
        inet 192.168.3.76 netmask 0xffffff00 broadcast 192.168.3.255
        media: Ethernet 10baseT/UTP <full-duplex>
        status: active
        supported media:
                media autoselect
                media 100baseTX mediaopt full-duplex
                media 100baseTX
                media 10baseT/UTP mediaopt full-duplex
                media 10baseT/UTP
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

$ sudo ethtool enp0s31f6
Settings for enp0s31f6:
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Speed: 10Mb/s
	Duplex: Half
	Port: Twisted Pair
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	MDI-X: on (auto)
	Supports Wake-on: pumbg
	Wake-on: d
	Current message level: 0x00000007 (7)
			       drv probe link
	Link detected: yes

3. Changing the axe interface back to autoselect mode. The axe interface and enp0s31f6 fail to perform autoselect to configure both interfaces to their highest speed and best duplex mode, 100Mb/s and full-duplex in this case.

root@generic:~ # ifconfig -m ue0 media autoselect
root@generic:~ # ifconfig -m ue0
ue0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=80008<VLAN_MTU,LINKSTATE>
        capabilities=80008<VLAN_MTU,LINKSTATE>
        ether 00:80:c8:3a:ba:f1
        inet 192.168.3.76 netmask 0xffffff00 broadcast 192.168.3.255
        media: Ethernet autoselect (10baseT/UTP <full-duplex>)
        status: active
        supported media:
                media autoselect
                media 100baseTX mediaopt full-duplex
                media 100baseTX
                media 10baseT/UTP mediaopt full-duplex
                media 10baseT/UTP
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

$ sudo ethtool enp0s31f6
Settings for enp0s31f6:
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Speed: 10Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	MDI-X: on (auto)
	Supports Wake-on: pumbg
	Wake-on: d
	Current message level: 0x00000007 (7)
			       drv probe link
	Link detected: yes

Analysis:

I tried to fix this issue in my target, where my developemnt environment is based on FreeBSD 13.0-RELEASE-p11. The fix patch is attached.

The AX88772 usb ethernet controller in axe interface uses rlphy as its phy interface in rockpro64. The rlphy will use the common subroutines, mii_physubr.c, in io-sock to set its media's type.

The AX88772 in axe shows that it supports media autoselect mode. But, in mii_physubr.c/mii_phy_setmedia(), the mii device should be tagged with MIIF_DOPAUSE or MIIF_FORCEANEG to enable autoselct mode when the autonegotiation is enabled in rlphy's control register.

In if_axe.c, AX88772 is tagged with neither the MIIF_DOPAUSE nor MIIF_FORCEANEG now. According to the source code commit in Freebsd, commit id cdc2a5ec78b4a8b1520351def4a6e7280502ec89, the author does not want to enable flow control in AX88772 because of the lack of test. Thus, MIIF_FORCEANEG should be used to turn on the autoselect mode when the bit of enabling auto-negotiation in rlphy's control register is turned on.