Limit Ethernet to 100MBits

  • We use the efusA9 as a replacement for an old CPU board. For ethernet we use an RJ45 connector which only supports 100Mbits (4 wires).
    As the efusA9 supports 1GBits I don't know what will happen if we use a 1Gbit switch (we only have 1Gbit network). How can we limit
    the device to only use 100MBit?

  • We also want to use only 4 wires with a legacy device. With the actual BSP this doesn't work with a 1 Gbit network because the auto negotiation for ETH leads to an attempt to establish a 1 Gbit connection (8 wires needed). (As workaround you can connect via a 100 Mbit router.)


    F&S announces the 100MBit support in its roadmap of Windows CE for Version 1.90:
    - 0002778: [Ethernet] Add possibility to limit transfer speed to 100MBit - new


    You can check with F&S if they can provide the same functionality for Linux.

  • In arch/arm/mach-mx6/board-mx6_efusa9.c, look for function mx6_fec_phy_init(). Add the following lines at the end of the function (before the return 0):


    Code
    1. /* Reduce speed to 100MHz */
    2. val = phy_read(phydev, 0x9);
    3. val &= ~0x0300;
    4. phy_write(phydev, 0x9, val);


    Then recompile the kernel.


    This modification clears the bits in the PHY register that advertise the 1000MBit connection during auto negotiation.


    If you also need this modification in U-Boot, you can modify this setting at runtime. Issue the following commands before doing any network transfers.


    Code
    1. mdio write FEC 9 0
    2. mdio write FEC 0 3300
    3. sleep 1


    The first command clears again the advertise-bits. The second restarts auto negotiation. The third waits until negotiation is complete. I'm not sure if the sleep is necessary, you can also try without.


    Your F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

    Edited 2 times, last by fs-support_HK ().

  • I applied the kernel patch and tested it. Nothing changed.... link speed is still 1000MBit.



    PHY: 1:04 - Link is Up - 1000/Full
    ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready


    I didn't change the rate in u-boot.....


    Any ideas?


    I also see a different in U-Boot and C example:
    val &= ~0x0300; vs
    dio write FEC 0 3300

  • Please look again. In Linux, we are modifying register 9. And in U-Boot, we write 0 to register 9, so we also clear the appropriate bits. In fact only one of these two bits is active in register 9, so clearing it results in value 0, which is what we write to this register in U-Boot.


    The value 3300 written to register 0 triggers the auto-negotiation again. Without this, the 1000 MBit/s remains active.


    Maybe this is the reason why your Linux link also shows the high rate. You have to start the link in Linux anew. I'm not sure what happens if the link remains active from U-Boot to Linux. So either keep network off and only start it in Linux, or toggle your network DOWN and UP again.


    And are you really sure that the setting is active? You can add a printk() message to the above settings. If you see the message at runtime, it should work. If not, then you are doing something wrong when compiling or downloading the new kernel to your board.


    Your F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • This is the code which is used...



    Kernel output.... check first line and last lines



    Limiting the speed in U-Boot works as you suggested. But as soon as the kernel is started it switches back to 1GBits.

  • How do you start the network? Have you added an additional package like NetworkManager?


    Are you already on fsimx6-V2.1 or still on V2.0?


    Your F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.

  • I use fsimx6-V2.1 we also added some packages based on the minimal configuration.


    Network is initialized over the /etc/network/interfaces.conf:


    This is my buildroot configuration:

  • I don't have any deep knowledge of the kernel but after some code research I found the following lines in drivers/net/fec.c:

    Code
    1. /* mask with MAC supported features */
    2. if (cpu_is_mx6q() || cpu_is_mx6dl())
    3. phy_dev->supported &= PHY_BASIC_FEATURES;
    4. else
    5. phy_dev->supported &= PHY_BASIC_FEATURES;


    I changed it to:

    Code
    1. /* mask with MAC supported features */
    2. if (cpu_is_mx6q() || cpu_is_mx6dl())
    3. //phy_dev->supported &= PHY_GBIT_FEATURES;
    4. phy_dev->supported &= PHY_BASIC_FEATURES;
    5. else
    6. phy_dev->supported &= PHY_BASIC_FEATURES;


    As I can see ethernet is now running on 100MBits. I don't think that this is a "good" solution so maybe you have a better idea.
    [Update]
    Both patches must be applied, if not, network is running on 100MBit but it has many RX errors and no connection can be established.

  • On device trees, there is already a feature to limit the transfer speed. Unfortunately this is part of the PHY which is not explicitly defined in our default device tree yet. Please try to modify the fec node in arch/arm/boot/dts/efusa9qdl.dtsi as follows. Then recompile the dtb file and download it to the board.



    I haven't tested it though. So can you please give some feedback whether this works or not? Thanks.


    Your F&S Support Team

    F&S Elektronik Systeme GmbH
    As this is an international forum, please try to post in English.
    Da dies ein internationales Forum ist, bitten wir darum, Beiträge möglichst in Englisch zu verfassen.