This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM57x external Marvell Ethernet switch and CPSW

Other Parts Discussed in Thread: AM5726

We have build a prototype board using the Sitara AM5726 with a Marvell Switch 88E6350R.
We are using the latest Linux RT AM57xx Processor SDK 3.01.00.06 running on Linux Kernel rt-4.4.19.

The Sitara CPSW Swich should work in Dual EMAC mode for our application.
EMAC0 is connected via RGMII without a PHY to a FPGA, but is not in use at the moment.
EMAC1 is connected via RGMII without a PHY to Port 5 of the Marvell Switch. The Marvel Switch is configured in single device mode, Port 5 in configured in RGMII mode.
The DSA device driver and the Marvell driver are configured in the kernel configuration. The Pin Mapping is the same as in the AM57xx EVM board (Beagle X-15)

We have the following issues with this constellation:
1. We cannot send or receive messages when the CPSW switch is configured in dual EMAC mode. How can we tell the DSA driver to use the cpsw_emac1 (rgmii1) interface?

2. In Switch mode we can see broadcast messages send from the Sitara board when capturing with Wireshark. But we can not receive any packages with ifconfig.
  We can see clock, control and data traffic on the rx lines on port 5 of the Marvell switch, but no received packet in ifconfig.
  We have tried all combinations of phy-mode = rgmii with/without internal delay on rx/tx without any success. What can we do now?


Here is a block diagram of our board:

                                  +---------------------+
                                  |                     |
                                  |                     |
                                  |                     |
                              +---+       FPGA          |
+------------------------+    |   |                     |
|                        |    |   |                     |
|    AM5726     +--------+    |   +---------------------+
|               |        +----+
|               | EMAC0  |  RGMII
|               +--------+
|               +--------+        +---------------------+
|               |        +---RGMII|                     |
|               | EMAC1  |    |   |        Marvell   P1 +----+ lan1
|               +--------+    +---+P5      88E6350R     |
|                        +--+     |                     |
+------------------------+  |     |                  P3 +----+ lan2
                            +-----+                     |
                             MDIO +---------------------+

The Marvell switch is succesfully detected at startup and the DSA driver is running.
Here is the startup log with some debug messages added to the mdio and DSA driver:

[    1.572819] libphy: Fixed MDIO Bus: probed
[    1.578611] --- in davinci_mdio_probe ---
[    1.627348] davinci_mdio 48485000.mdio: davinci mdio revision 1.6
[    1.633473] libphy: 48485000.mdio: probed
[    1.637504] mdio_bus 48485000.mdio: /ocp/ethernet@48484000/mdio@48485000/dsa@0 has invalid PHY address
[    1.646856] mdio_bus 48485000.mdio: scan phy dsa at address 0
[    1.653285] mdio_bus 48485000.mdio: scan phy dsa at address 1
[    1.660043] mdio_bus 48485000.mdio: scan phy dsa at address 2
[    1.666802] mdio_bus 48485000.mdio: scan phy dsa at address 3
[    1.673562] mdio_bus 48485000.mdio: scan phy dsa at address 4
[    1.680322] mdio_bus 48485000.mdio: scan phy dsa at address 5
[    1.687082] mdio_bus 48485000.mdio: scan phy dsa at address 6
[    1.693844] mdio_bus 48485000.mdio: scan phy dsa at address 7
[    1.700603] mdio_bus 48485000.mdio: scan phy dsa at address 8
[    1.707361] mdio_bus 48485000.mdio: scan phy dsa at address 9
[    1.714122] mdio_bus 48485000.mdio: scan phy dsa at address 10
[    1.720883] mdio_bus 48485000.mdio: scan phy dsa at address 11
[    1.727642] mdio_bus 48485000.mdio: scan phy dsa at address 12
[    1.734401] mdio_bus 48485000.mdio: scan phy dsa at address 13
[    1.741163] mdio_bus 48485000.mdio: scan phy dsa at address 14
[    1.747922] mdio_bus 48485000.mdio: scan phy dsa at address 15
[    1.754682] mdio_bus 48485000.mdio: scan phy dsa at address 16
[    1.772877] mdio_bus 48485000.mdio: scan phy dsa at address 17
[    1.780920] mdio_bus 48485000.mdio: scan phy dsa at address 18
[    1.788716] mdio_bus 48485000.mdio: scan phy dsa at address 19
[    1.796512] mdio_bus 48485000.mdio: scan phy dsa at address 20
[    1.804311] mdio_bus 48485000.mdio: scan phy dsa at address 21
[    1.812119] mdio_bus 48485000.mdio: scan phy dsa at address 22
[    1.819915] mdio_bus 48485000.mdio: scan phy dsa at address 23
[    1.826442] mdio_bus 48485000.mdio: scan phy dsa at address 24
[    1.833203] mdio_bus 48485000.mdio: scan phy dsa at address 25
[    1.839963] mdio_bus 48485000.mdio: scan phy dsa at address 26
[    1.846722] mdio_bus 48485000.mdio: scan phy dsa at address 27
[    1.854759] mdio_bus 48485000.mdio: scan phy dsa at address 28
[    1.862323] mdio_bus 48485000.mdio: scan phy dsa at address 29
[    1.869084] mdio_bus 48485000.mdio: scan phy dsa at address 30
[    1.875842] mdio_bus 48485000.mdio: scan phy dsa at address 31
[    1.882601] --- of_mdiobus_register returns 0
[    1.886803] davinci_mdio 48485000.mdio: phy[16]: device 48485000.mdio:10, driver unknown
[    1.895112] davinci_mdio 48485000.mdio: phy[17]: device 48485000.mdio:11, driver unknown
[    1.903241] davinci_mdio 48485000.mdio: phy[18]: device 48485000.mdio:12, driver unknown
[    1.911369] davinci_mdio 48485000.mdio: phy[19]: device 48485000.mdio:13, driver unknown
[    1.919498] davinci_mdio 48485000.mdio: phy[20]: device 48485000.mdio:14, driver unknown
[    1.927626] davinci_mdio 48485000.mdio: phy[21]: device 48485000.mdio:15, driver unknown
[    1.935753] davinci_mdio 48485000.mdio: phy[22]: device 48485000.mdio:16, driver unknown
[    1.943882] davinci_mdio 48485000.mdio: phy[27]: device 48485000.mdio:1b, driver unknown
[    1.952977] cpsw 48484000.ethernet: Detected MACID = fc:0f:4b:7a:c8:c8
[    1.960292] cpsw 48484000.ethernet: cpsw: Detected MACID = fc:0f:4b:7a:c8:c9

[    2.131114] NET: Registered protocol family 10
[    2.146579] sit: IPv6 over IPv4 tunneling driver
[    2.151762] NET: Registered protocol family 17
[    2.156439] Distributed Switch Architecture driver version 0.1
[    2.162298] --- in dsa_probe ---
[    2.165538] --- in dsa_of_probe ---
[    2.169074] --- in of_mdio_find_bus ---
[    2.172928] --- of_mdio_find_bus device ---
[    2.177167] --- dsa_of_probe OK
[    2.180322] --- in dsa_setup_dst ---
[    2.185246] mdio_bus 48485000.mdio: unknown revision 2, using base switch 0x3710
[    2.192680] cpsw 48484000.ethernet eth0: [0]: detected a Marvell 88E6350 switch
[    2.665427] libphy: dsa slave smi: probed
[    2.850429] --- dsa_probe OK


This is part of the device tree we use:

    mac: ethernet@48484000 {
      compatible = "ti,dra7-cpsw","ti,cpsw";
      ti,hwmods = "gmac";
      clocks = <&dpll_gmac_ck>, <&gmac_gmii_ref_clk_div>;
      clock-names = "fck", "cpts";
      cpdma_channels = <8>;
      ale_entries = <1024>;
      bd_ram_size = <0x2000>;
      no_bd_ram = <0>;
      mac_control = <0x20>;
      slaves = <2>;
      active_slave = <0>;
      cpts_clock_mult = <0x80000000>;
      cpts_clock_shift = <29>;
      reg = <0x48484000 0x1000
             0x48485200 0x2E00>;
      #address-cells = <1>;
      #size-cells = <1>;
      dual_emac;   // comment out for switch mode

      ti,no-idle;

      /*
       * rx_thresh_pend
       * rx_pend
       * tx_pend
       * misc_pend
       */
      interrupts = <GIC_SPI 334 IRQ_TYPE_LEVEL_HIGH>,
             <GIC_SPI 335 IRQ_TYPE_LEVEL_HIGH>,
             <GIC_SPI 336 IRQ_TYPE_LEVEL_HIGH>,
             <GIC_SPI 337 IRQ_TYPE_LEVEL_HIGH>;
      ranges;
      syscon = <&scm_conf>;
      status = "disabled";

      davinci_mdio: mdio@48485000 {
        compatible = "ti,cpsw-mdio";
        #address-cells = <1>;
        #size-cells = <0>;
        ti,hwmods = "davinci_mdio";
        bus_freq = <1000000>;
        reg = <0x48485000 0x100>;
        dsa@0 {     // fake phy entry, to avoid 'no mdiobus' error,
                    // at dsa driver startup
        };
      };


      cpsw_emac0: slave@48480200 {
        phy_id = <&davinci_mdio>, <1>;
        phy-mode = "rgmii";
        dual_emac_res_vlan = <1>;   // comment out for switch mode
        /* Filled in by U-Boot */
        mac-address = [ 00 00 00 00 00 00 ];
        fixed-link {
          speed = <1000>;
          full-duplex;
        };
      };

      cpsw_emac1: slave@48480300 {
        phy_id = <&davinci_mdio>, <2>;
        phy-mode = "rgmii";     // tested with rgmii-id, rgmii-txid,
                                // rgmii-rxid (no success)
        dual_emac_res_vlan = <2>;   // comment out for switch mode
        /* Filled in by U-Boot */
        mac-address = [ 00 00 00 00 00 00 ];
        fixed-link {
          speed = <1000>;
          full-duplex;
        };
      };

      phy_sel: cpsw-phy-sel@4a002554 {
        compatible = "ti,dra7xx-cpsw-phy-sel";
        reg= <0x4a002554 0x4>;
        reg-names = "gmii-sel";
      };
    };

    dsa@0 {
      compatible = "marvell,dsa";
      #address-cells = <2>;
      #size-cells = <0>;

      interrupts = <10>;
      dsa,ethernet = <&mac>;    // cpsw_emac1 brings ' no ethernet
                                // device' error, at dsa driver startup
      dsa,mii-bus = <&davinci_mdio>;

      switch@0 {
        #address-cells = <1>;
        #size-cells = <0>;
        reg = <0 0>;          // MDIO address 0, switch 0 in tree

        port@0 {
          reg = <0>;
          label = "lan1";
        };

        port@2 {
          reg = <2>;
          label = "lan2";
        };

        port@5 {
          reg = <5>;
          label = "cpu";
          fixed-link {
            speed = <1000>;
            full-duplex;
          };
        };
      };
    };
 

We need to make some "strange" modifications in the device tree to get the DSA and Marvell switch drivers up and running:
1. we need to add a fake phy device named dsa@0 to get rid of error message 'no mdiobus' when DSA driver starts .
2. We need to use <&mac> for dsa,ethernet in dsa section to get rid off error message 'no ethernet' when DSA driver starts.

Because there are no PHY between Sitara and Marvell switch we use fixed link nodes in cpsw_emac1 and in dsa@0 port@5 section.

We can use ifup to bring up lan1 and lan2. Have tested static and dhcp configuration. We can see link port messages when plug/unplug the network cable on lan1/lan2.
Ethtool -d lan1/lan2 brings up correct register dumps of the Marvell switch ports. So we guess, that the MDIO interface is working properly.

Any suggestions?

Regards Peter

  • The Ethernet experts have been notified. They will respond here.
  • Thank you Biser,

    We have done some deeper investigations with ethtool. It seems that we have a problem on the receive lines. We will need to check this with our hardware department.

    Here are the ethtool logs for lan2 port of the Marvell switch (configured for DHCP) and the eth0 port of the Sitara:

    root@am57xx-evm:~# ethtool -S lan2
    NIC statistics:
         tx_packets: 15
         tx_bytes: 1802
         rx_packets: 0
         rx_bytes: 0
         in_good_octets: 235626
         in_bad_octets: 0
         in_unicast: 2
         in_broadcasts: 1
         in_multicasts: 676
         in_pause: 0
         in_undersize: 0
         in_fragments: 0
         in_oversize: 0
         in_jabber: 0
         in_rx_error: 0
         in_fcs_error: 0
         out_octets: 1862
         out_unicast: 0
         out_broadcasts: 2
         out_multicasts: 13
         out_pause: 0
         excessive: 0
         collisions: 0
         deferred: 0
         single: 0
         multiple: 0
         out_fcs_error: 0
         late: 0
         hist_64bytes: 8
         hist_65_127bytes: 8
         hist_128_255bytes: 0
         hist_256_511bytes: 635
         hist_512_1023bytes: 0
         hist_1024_max_bytes: 0
    root@am57xx-evm:~# ethtool -S eth0
    NIC statistics:
         Good Rx Frames: 0
         Broadcast Rx Frames: 0
         Multicast Rx Frames: 0
         Pause Rx Frames: 0
         Rx CRC Errors: 0
         Rx Align/Code Errors: 718
         Oversize Rx Frames: 0
         Rx Jabbers: 0
         Undersize (Short) Rx Frames: 0
         Rx Fragments: 0
         Rx Octets: 0
         Good Tx Frames: 142
         Broadcast Tx Frames: 50
         Multicast Tx Frames: 92
         Pause Tx Frames: 0
         Deferred Tx Frames: 0
         Collisions: 0
         Single Collision Tx Frames: 0
         Multiple Collision Tx Frames: 0
         Excessive Collisions: 0
         Late Collisions: 0
         Tx Underrun: 0
         Carrier Sense Errors: 0
         Tx Octets: 26732
         Rx + Tx 64 Octet Frames: 0
         Rx + Tx 65-127 Octet Frames: 110
         Rx + Tx 128-255 Octet Frames: 0
         Rx + Tx 256-511 Octet Frames: 748
         Rx + Tx 512-1023 Octet Frames: 2
         Rx + Tx 1024-Up Octet Frames: 0
         Net Octets: 282614
         Rx Start of Frame Overruns: 0
         Rx Middle of Frame Overruns: 0
         Rx DMA Overruns: 0
         Rx DMA chan: head_enqueue: 1
         Rx DMA chan: tail_enqueue: 127
         Rx DMA chan: pad_enqueue: 0
         Rx DMA chan: misqueued: 0
         Rx DMA chan: desc_alloc_fail: 0
         Rx DMA chan: pad_alloc_fail: 0
         Rx DMA chan: runt_receive_buf: 0
         Rx DMA chan: runt_transmit_buf: 0
         Rx DMA chan: empty_dequeue: 0
         Rx DMA chan: busy_dequeue: 0
         Rx DMA chan: good_dequeue: 0
         Rx DMA chan: requeue: 0
         Rx DMA chan: teardown_dequeue: 0
         Tx DMA chan: head_enqueue: 70
         Tx DMA chan: tail_enqueue: 1
         Tx DMA chan: pad_enqueue: 0
         Tx DMA chan: misqueued: 1
         Tx DMA chan: desc_alloc_fail: 0
         Tx DMA chan: pad_alloc_fail: 0
         Tx DMA chan: runt_receive_buf: 0
         Tx DMA chan: runt_transmit_buf: 0
         Tx DMA chan: empty_dequeue: 70
         Tx DMA chan: busy_dequeue: 0
         Tx DMA chan: good_dequeue: 71
         Tx DMA chan: requeue: 70
         Tx DMA chan: teardown_dequeue: 0
    root@am57xx-evm:~#
     

    Best regards Peter

  • Here is feedback from the factory team: Direct MAC to MAC connections are not a TI-supported use case. I'm sorry, we cannot help on this.
  • Hi Biser,

    Thank you for your reply.

    We figured it out how to make it work  at least in CPSW switch mode.  If anyone else stumbled about a similar problem.

    The trick is, to add the needed tx/rx delay at the dsa switch side in the device tree, in our case phymode = "rgmii-id"

            port@5 {
              reg = <5>;
              label = "cpu"; 

              phy-mode = "rgmii-id";

              fixed-link {
                speed = <1000>;
                full-duplex;
              };
            };

    Now we get a DHCP lease and can ping the Sitara. But one problem remains:

    We can not get it work in dual-emac mode. It only works in switch mode. In my opinion, this problem has nothing to do with the MAC-MAC connection.

    We tried to switch the primary interface to the second port, as suggested in the Wiki, but without any success. It seems that the trafiic is always be routed over emac0.

    Any hints on this?

    Best regards

    Peter