SJA1105S linux driver: mode 1 configuration

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

SJA1105S linux driver: mode 1 configuration

ソリューションへジャンプ
7,264件の閲覧回数
choll
Contributor II

Hi,

on a custom board, based on STM32MP1, we want to use the NXP SJA1105S switch together with Linux 5.10. We have already included the corresponding driver via menuconfig as a kernel module. As far as I can see, this driver tries to enable a VLAN-based port configuration(mode 2) at startup. Unfortunately it looks like, that the STM32MP1 mac driver do not support this, because it prints the message "Only single VLAN ID supported" as soon as we load the SJA1105 kernel module. Is it possible to configure the switch for operation mode 1 by Linux? 

Further we need to configure the exact tx and rx delays(in ns) for the RGMII interface(MAC-MAC) between the MPU and the switch. How can we archive this? Is there a possibility in the device tree?

0 件の賞賛
返信
1 解決策
7,033件の閲覧回数
choll
Contributor II

Hi,

The cause of the problems was an incompatibility between the SJA1105 DSA driver and the MAC driver from ST. We are now using this a bit older driver and were able to put the switch into operation.

Thank you and best regards

choll

元の投稿で解決策を見る

0 件の賞賛
返信
8 返答(返信)
7,034件の閲覧回数
choll
Contributor II

Hi,

The cause of the problems was an incompatibility between the SJA1105 DSA driver and the MAC driver from ST. We are now using this a bit older driver and were able to put the switch into operation.

Thank you and best regards

choll

0 件の賞賛
返信
7,223件の閲覧回数
bpe
NXP Employee
NXP Employee

 

NXP have released several drivers for SJA1105P/Q/R/S, each part of an SDK or BSP
for a certain reference or development board. These drivers differ in supported
configurations and the ways they can be adjusted, to meet the specific of the
board central chip and it's primary applications. Without knowing which
driver or BSP you are working with, the only suggestion I can give is, consult
at the documentation of the BSP/SDK you have taken the driver from for supported
configuration options and methods.

Regarding RGMII delays, they are adjustable via CFG_PAD_MIIx_ID register
which is discussed in SJA1105PQRS Application Hints, Section 6.1.13.2.
Again, methods to access this register depend on your driver.

 

Best Regards,
Platon

 

0 件の賞賛
返信
7,216件の閲覧回数
choll
Contributor II

Hi Platon,

we use the standard build-in driver of Linux Kernel 5.10.10. This is part of the ST BSP "OpenSTLinux5.10-dunfell-mp1-21-03-31. 

Previous documentations that I have consulted:

https://www.nxp.com/docs/en/user-guide/UM11040.pdf

https://www.nxp.com/docs/en/user-manual/AH1704.pdf

https://github.com/torvalds/linux/blob/v5.10/Documentation/devicetree/bindings/net/dsa/sja1105.txt

https://github.com/torvalds/linux/blob/v5.10/Documentation/networking/dsa/sja1105.rst

Unfortunately these documentations do not treat the Linux driver and its functionalities adequately enough for our problem. Again, we need to load the driver without a VLAN-based configuration. Below you can see an example of the current output when the driver is starting.

[  80.801160] sja1105 spi2.0: Probed switch chip: SJA1105S

[  80.934971] sja1105 spi2.0: Updating VLAN 1025

[  80.943584] sja1105 spi2.0: Updating VLAN 1025

[  80.952858] sja1105 spi2.0: Updating VLAN 1025

[  80.961709] sja1105 spi2.0: Updating VLAN 1025

[  80.967525] sja1105 spi2.0: Updating VLAN 1025

[  80.977959] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  80.983877] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  80.995737] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.004256] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.012844] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.021277] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.030518] sja1105 spi2.0: Updating VLAN 2049

[  81.039485] sja1105 spi2.0: Updating VLAN 2049

[  81.048265] sja1105 spi2.0: Updating VLAN 1026

[  81.057550] sja1105 spi2.0: Updating VLAN 1026

[  81.066966] sja1105 spi2.0: Updating VLAN 1026

[  81.076340] sja1105 spi2.0: Updating VLAN 1026

[  81.085989] sja1105 spi2.0: Updating VLAN 1026

[  81.091785] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.102420] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.110977] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.119447] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.127888] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.136362] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.144868] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

[  81.153432] stm32-dwmac 5800a000.ethernet eth0: Only single VLAN ID supported

...

A new approach from us is to load a configuration file via spidev to the switch and do not use the driver. As a starting point we customize the Python script 'examplePQRS.py', found in the Switch Configuration tool for SJA1105x , to our needs. Do you know, what the best way is to update the switch with the generated .bin/.hex file? A call of the spidev_test command with -i flag possibly?

Thanks and best regards

0 件の賞賛
返信
7,192件の閲覧回数
bpe
NXP Employee
NXP Employee

The driver you are trying to use is for DSA. Make sure you are familiar with
the basics of this kernel subsystem. SJA1105 does not support DSA-specific tags,
thus it has to use VLAN tagging to allow the rest of DSA code recognize the slave
port the frame comes from or is to be sent to. The driver implementation details are
given in this document. For the reason explained above, you cannot completely
disable VLAN tagging. However, VLAN tags utilized by DSA should not be visible
to the rest of the kernel. If your host network interface driver complains about unexpected or
unsupported VLAN tags, it may happen because either DSA is not fully configured
in the kernel or because your host network card driver has certain limitations
that affect DSA operation. Consult at the driver maintainer for additional information.

If the task is to configure the SJA1105 as a generic L2 switch with the DSA driver,
consult at these documents:

https://github.com/torvalds/linux/blob/v5.10/Documentation/networking/dsa/configuration.rst

https://github.com/torvalds/linux/blob/v5.10/Documentation/networking/bridge.rst

If you do not want to get into DSA complexities, you can just download the
switch static configuration at the boot time, which can be done in either
Linux or the bootloader, whatever is more convenient. If you decide to follow
this way, disable the DSA driver for SJA1105 completely to avoid unexpected
interaction. One visible drawback of this approach is, that you will lose Linux
level control over PHYs connected to the switch because they will not be visible
to Linux without a driver.

Hope this helps,
Platon

 

0 件の賞賛
返信
7,160件の閲覧回数
choll
Contributor II

Hi Platon,

thank you for your answer. For our application, it would be sufficient if the SJA1105 was configured as a generic L2 switch. Because of that, I followed the instructions in this link already. Below you can see the commands I entered and the subsequent output messages.

 

ip link add name br0 type bridge
ip link set dev swp3 master br0
[   94.865191] br0: port 1(swp3) entered blocking state
[   94.877273] br0: port 1(swp3) entered disabled state
[   94.890018] device swp3 entered promiscuous mode
ip addr add 192.168.1.12/24 dev br0
ip link set dev br0 up
[   96.362545] br0: port 1(swp3) entered blocking state
[   96.366159] br0: port 1(swp3) entered forwarding state
[   96.393642] IPv6: ADDRCONF(NETDEV_CHANGE): br0: link becomes ready

 

Is everything correct up to this point? 

Output of ifconfig:

 

 ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.1.12  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::90db:5aff:fed1:1154  prefixlen 64  scopeid 0x20<link>
        ether 92:db:5a:d1:11:54  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 19  bytes 1570 (1.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1504  metric 1
        inet 192.168.1.11  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 2e:64:07:f7:a9:30  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 53  bytes 7668 (7.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 38  base 0x6000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

swp3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet6 fe80::2c64:7ff:fef7:a930  prefixlen 64  scopeid 0x20<link>
        ether 2e:64:07:f7:a9:30  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 33  bytes 2766 (2.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

Unfortunately I still can neither ping 192.168.1.11 nor 192.168.1.12. Maybe there is still something wrong with my device tree?

 

&ethernet0{
  pinctrl-names = "default", "sleep";
  pinctrl-0 = <&eth1_pins_mx>;
  pinctrl-1 = <&eth1_sleep_pins_mx>;
  status = "okay";

  /* USER CODE BEGIN ethernet0 */
  st,eth-clk-sel;
  phy-connection-type = "rgmii-txid"; 

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

  mdio0 {
    #address-cells = <1>;
    #size-cells = <0>;
    compatible = "snps,dwmac-mdio";

    rgmii_phy5: ethernet-phy@5 {
      compatible = "ethernet-phy-id2000.a284", "ethernet-phy-ieee802.3-c22";
      reg = <5>;
    }; 

    rgmii_phy4: ethernet-phy@4 {
      compatible = "ethernet-phy-id2000.a284", "ethernet-phy-ieee802.3-c22";
      reg = <4>;
    };

    rgmii_phy0: ethernet-phy@0 {
      rx-internal-delay-ps = <2000>;
      tx-internal-delay-ps = <2000>;
      reg = <0>;
    };
  };

....

&spi4{
  pinctrl-names = "default", "sleep";
  pinctrl-0 = <&spi4_pins_mx>;
  pinctrl-1 = <&spi4_sleep_pins_mx>;
  status = "okay";

  /* USER CODE BEGIN spi4 */
  cs-gpios = <&gpiob 12 GPIO_ACTIVE_LOW>,
         <&gpiof 15 GPIO_ACTIVE_LOW>;

  sja1105@0 {
    compatible = "nxp,sja1105s";
    reg = <0>;
    spi-max-frequency = <16000000>;/* max 24 MHz according to the data sheet */

    #address-cells = <1>;
    #size-cells = <0>;
    fsl,spi-cs-sck-delay = <1000>;
    fsl,spi-sck-cs-delay = <1000>;
    spi-cpha;
    status = "okay";

    ports {
      #address-cells = <1>;
      #size-cells = <0>;

      port@0 {
        label = "cpu";
        ethernet = <&ethernet0>;
        phy-mode = "rgmii-rxid"; /* no PCB serpentine traces on the board */
        reg = <0>;

        /* Implicit "sja1105,role-phy;" */
        fixed-link {
          speed = <1000>;
          full-duplex;
        };
      };

      port@1 {
        label = "swp1";
        phy-handle = <&rgmii_phy5>;
        phy-mode = "rgmii-id";
        reg = <1>;

        /* Implicit "sja1105,role-mac;" */
      };

      port@2 {
        label = "swp2";
        phy-handle = <&rgmii_phy4>;
        phy-mode = "rgmii-id";
        reg = <2>;

        /* Implicit "sja1105,role-mac;" */
      };

      port@3 {
        label = "swp3";
        phy-handle = <&rgmii_phy0>;
        phy-mode = "rgmii-rxid";
        reg = <3>; 

        /* Implicit "sja1105,role-mac;" */
      };

      port@4 {
        label = "swp4";
        phy-mode = "rgmii-id";
        sja1105,role-mac;
        reg = <4>;

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

        /* this port is unused!*/
      };
    };
  };

  fram: cy15v102qn@1 {
    compatible = "jedec,spi-nor";
    reg = <1>;
    spi-max-frequency = <32000000>;
    #address-cells = <1>;
    #size-cells = <1>;
    m25p,fast-read;
    status = "okay";
 
    partitions {
      compatible = "fixed-partitions";
      #address-cells = <1>;
      #size-cells = <1>;

      partition@0 {
        label = "spi-fram";
        reg = <0x0 0x40000>;  /* 2 Mbit => 256k * 8 => 262144 * 8 */
      };
    };
  };

  /* USER CODE END spi4 */
};

 

I am thankful for any advice.

0 件の賞賛
返信
7,136件の閲覧回数
bpe
NXP Employee
NXP Employee

There are at least two problems visible on the surface:

  • You created a switch which has only one physical port, and that port
    is a slave port. Your switch has no clue where to forward the traffic. Obviously,
    it cannot respond to your echo requests by itself, nor it can generate them.
    Add the master port to the switch.
  • You have two Ethernet interfaces on a single host sitting on one IP subnet, 192.168.1.0/24.
    This configuration is not valid and can confuse the kernel IP stack. If you
    looked at this document carefully, you would have noticed that the examples
    given there assign different ports to different IP subnets.

 

Best Regards,
Platon

 

0 件の賞賛
返信
7,088件の閲覧回数
choll
Contributor II

Hi Platon,

yes you are right, regarding the same subnet. I am sorry, it was my fault. Here you can see my corrected IP config:

 ifconfig
br0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500  metric 1
        inet 192.168.2.11  netmask 255.255.255.0  broadcast 0.0.0.0
        ether 5a:6a:ee:19:ef:49  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1504  metric 1
        inet 192.168.1.11  netmask 255.255.255.0  broadcast 192.168.1.255
        ether ee:ae:9f:b5:52:24  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 4600 (4.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 38  base 0x6000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

port3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.169.3.11  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::ecae:9fff:feb5:5224  prefixlen 64  scopeid 0x20<link>
        ether ee:ae:9f:b5:52:24  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20  bytes 1988 (1.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Do we even need to assign an IP address to eth0, br0 and port3 in order to bring the switch into an operational state? Remember, we need only the L2 features of the switch.

Regarding your first comment: unfortunately we can not add eth0 directly to the bridge.

ip link set dev eth0 master br0
[  690.518942] br0: port 1(eth0) entered blocking state
[  690.523117] br0: port 1(eth0) entered disabled state
[  690.540760] stm32-dwmac 5800a000.ethernet eth0: Adding VLAN in promisc mode not supported
[  690.561127] stm32-dwmac 5800a000.ethernet eth0: failed to initialize vlan filtering on this port
RTNETLINK answers: Operation not permitted

Following the link, I have to create a VLAN for eth0 first. But if I insert the corresponding command, I get an error message too:

 ip link add link eth0 name eth0.1 type vlan id 1
[ 1010.345817] stm32-dwmac 5800a000.ethernet eth0: Adding VLAN in promisc mode not supported
RTNETLINK answers: Operation not permitted

It seems so, that the Ethernet-MAC driver does not permit adding VLANs to eth0. So I ask the question of my first post again, is it possible to use the DSA driver without adding any VLAN settings in the Linux shell?

Thank you and best regards

choll

0 件の賞賛
返信
7,088件の閲覧回数
choll
Contributor II

Hi Platon,

yes, you are right regarding the different IP subnets. It was a bad example, I am sorry. That should fit better:

 

ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet 192.168.1.11  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::90db:5aff:fed1:1154  prefixlen 64  scopeid 0x20<link>
        ether 92:db:5a:d1:11:54  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 20  bytes 2068 (2.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1504  metric 1
        inet 192.168.2.11  netmask 255.255.255.0  broadcast 192.168.2.255
        ether 2e:64:07:f7:a9:30  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 44  bytes 5784 (5.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 38  base 0x6000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536  metric 1
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 80  bytes 6080 (5.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 80  bytes 6080 (5.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

swp3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500  metric 1
        inet6 fe80::2c64:7ff:fef7:a930  prefixlen 64  scopeid 0x20<link>
        ether 2e:64:07:f7:a9:30  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 3124 (3.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

Following the example, I still have to add eth0 to the switch as a master port, using a VLAN. But as soon as I insert the corresponding command, I get the following error messages:

 

ip link add link eth0 name eth0.1 type vlan id 1
[  786.048015] 8021q: 802.1Q VLAN Support v1.8
[  786.051006] 8021q: adding VLAN 0 to HW filter on device eth0
[  786.060444] stm32-dwmac 5800a000.ethernet eth0: Adding VLAN in promisc mode not supported
[  786.074229] stm32-dwmac 5800a000.ethernet eth0: Adding VLAN in promisc mode not supported
RTNETLINK answers: Operation not permitted

 

It seems so, that the Ethernet-MAC driver does not support adding VLANs. So my question still is, if is there a way to put the switch into working operation without using any VLANs?

Best regards and have a nice weekend

choll

0 件の賞賛
返信