sja1105q_2024-01-24_14_45_54.log attached file is the log file when power up
if l take out sja1105, connect soc rgmii interface to phy rtl8211f directly, the network is ok.
so l think the problem caused by the config file of switch.
1. my question is how can l know the work status of sja1105
2, l check pin with oscilloscope, TX_CTL and RX_CTL of port0 have signal, but TX_CTL and RX_CTL of port1 have no signal,
3, RX_CLK and TX_CLK of all port is ok.
kernel dts is as follows
ðernet2 {
phy-handle = <ð_phy0>;
phy-mode = "rgmii-id";
status = "okay";
mdio2: mdio@4 {
compatible = "snps,dwmac-mdio";
#address-cells = <1>;
#size-cells = <0>;
eth_phy0: ethernet-phy@4 {
reg = < 0x4 >;
max-speed = <0x64>;
};
eth_phy1: ethernet-phy@5 {
reg = < 0x5 >;
};
eth_phy3: ethernet-phy@2 {
reg = < 0x2 >;
max-speed = <0x64>;
};
eth_phy4: ethernet-phy@1 {
reg = < 0x1 >;
max-speed = <0x64>;
};
};
};
&spi7 {
status = "okay";
num-cs = <1>;
enable_dma = <1>;
dmas = <&dmac4 X9_DMA_SLV_ID_SPI8_TX>, <&dmac4 X9_DMA_SLV_ID_SPI8_RX>;
dma-names = "tx", "rx";
sja1105p@0 {
compatible = "nxp,sja1105p-switch";
firmware_name = "sja1105p-1_cfg.bin"; // optional
spi-max-frequency = <1000000>;
spi-cpha;
reg = <0>;
rst-gpios=<&port4d 26 GPIO_ACTIVE_HIGH>;
status = "okay";
port-0 {
is-host = <0x1>;
null-phy = <0x1>;
phy-ref = < 0 >;
logical-port-num = < 0 >;
rx-delay = < 810 >;
tx-delay = < 810 >;
};
port-1 {
is-host = <0x0>;
null-phy = <0x0>;
phy-ref = < ð_phy0 >;
logical-port-num = < 1 >;
};
port-2 {
is-host = <0x0>;
null-phy = <0x0>;
phy-ref = < ð_phy1 >;
logical-port-num = < 2 >;
};
port-3 {
is-host = <0x0>;
null-phy = <0x0>;
phy-ref = < ð_phy3 >;
logical-port-num = < 3 >;
};
port-4 {
is-host = <0x0>;
null-phy = <0x0>;
phy-ref = < ð_phy4 >;
logical-port-num = < 4 >;
};
};
};
Hi Pengfeng,
Thankyou for the detailed description.
As the first step, It would be really great if you could share your python script with me
to see if everything was configured correctly.
BR,
Abdullah
Hi Abdullah .
happy to see u. l changed my kernel dts file as follows, cfg_applicationBoard.py is in attached file, all the clock is 125M,include TXC and RXC in port0. port1 , port2. but TXC and RXC in port3 and port4 is 25M. cuz the max-speed max-speed = <0x64> .
all the ports is rgmii, when l config eth0 up, l ping 192.168.1.1,
l find ENET1_RGMII_TX_CTL in soc is high level output voltage, but ENET1_RGMII_RX_CTL is low level voltage, so soc do have data send to sja1105q but sja1105q have no data send to soc.
also l find TXCTL in phy is low level , but RXCTL/PHYAD2 is high level, so there is data send to sja1105q from phy , but no data send to phy from sja1105q
ðernet2 {
phy-mode = "rgmii-id";
status = "okay";
fixed-link {
speed = <1000>;
full-duplex;
};
mdio {
compatible = "snps,dwmac-mdio";
#address-cells = <1>;
#size-cells = <0>;
eth_phy1: ethernet-phy@4 {
reg = < 0x4 >;
};
eth_phy2: ethernet-phy@5 {
reg = < 0x5 >;
};
eth_phy3: ethernet-phy@2 {
reg = < 0x2 >;
max-speed = <0x64>;
};
eth_phy4: ethernet-phy@1 {
reg = < 0x1 >;
max-speed = <0x64>;
};
};
};
&spi7 {
status = "okay";
num-cs = <1>;
enable_dma = <1>;
dmas = <&dmac4 X9_DMA_SLV_ID_SPI8_TX>, <&dmac4 X9_DMA_SLV_ID_SPI8_RX>;
dma-names = "tx", "rx";
sja1105p@0 {
compatible = "nxp,sja1105p-switch";
firmware_name = "sja1105p-1_cfg.bin"; // optional
spi-max-frequency = <1000000>;
spi-cpha;
reg = <0>;
rst-gpios=<&port4d 26 GPIO_ACTIVE_HIGH>;
status = "okay";
port-0 {
is-host = <0x1>;
null-phy = <0x1>;
phy-ref = < 0 >;
logical-port-num = < 0 >;
rx-delay = < 810 >;
tx-delay = < 810 >;
};
port-1 {
is-host = <0x0>;
null-phy = <0x0>;
phy-ref = < ð_phy1 >;
logical-port-num = < 1 >;
};
port-2 {
is-host = <0x0>;
null-phy = <0x0>;
phy-ref = < ð_phy2 >;
logical-port-num = < 2 >;
};
port-3 {
is-host = <0x0>;
null-phy = <0x0>;
phy-ref = < ð_phy3 >;
logical-port-num = < 3 >;
};
port-4 {
is-host = <0x0>;
null-phy = <0x0>;
phy-ref = < ð_phy4 >;
logical-port-num = < 4 >;
};
};
};
Hi Abdullah .
great to see you, cfg_applicationBoard.py is as follows
import os
from ethsw.configuration import *
from ethsw.tables_sja1105pqrs import *
NO_CBS_BLOCKS = 16
NO_ETH_PORTS = 5
NO_PRIORITIES = 8
c = Configuration()
#############################################################################
# General Parameters
#############################################################################
general_parameters = make_table_by_layout(general_parameters_table_layout, layoutid_map)
c.append(general_parameters)
general_parameters.append({
"VLLUPFORMAT": 0,
"MIRR_PTACU": 1,
"SWITCHID": 0,
"HOSTPRIO": 5,
"MAC_FLTRES[0]": 0x0180C200000E,
"MAC_FLTRES[1]": 0x0180C2000003,
"MAC_FLT[0]": 0xFFFFFF0000FF,
"MAC_FLT[1]": 0xFFFFFF0000FF,
"INCL_SRCPT[0]": 1,
"INCL_SRCPT[1]": 1,
"SEND_META[0]": 1,
"SEND_META[1]": 0,
# "CASC_PORT": 6,
"CASC_PORT": 7,
"MIRR_PORT": 6,
"HOST_PORT": 0,
"VIMARKER": 0xFFFFFFFF,
"VIMASK": 0xFFFFFFFF,
"TPID": 0x88A8,
"IGNORE2STF": 0,
"TPID2": 0x8100,
"QUEUE_TS": 0,
"EGRMIRRVID": 0,
"EGRMIRRPCP": 0,
"EGRMIRRDEI": 0,
"REPLAY_PORT": 7
})
#############################################################################
# MAC Configuration Table
#############################################################################
SPEED_HOST = 0 # speed set by host during run-time
SPEED_1GBPS = 1
SPEED_100MBPS = 2
SPEED_10MBPS = 3
speed = [SPEED_1GBPS, SPEED_100MBPS, SPEED_100MBPS, SPEED_100MBPS, SPEED_100MBPS]
speed_Mbps = [10 ** (4 - x) for x in speed]
default_vlan = 0xFFF # Default VLAN ID on all ports for untagged frames
queue_enable = [1, 1, 1, 1, 1, 1, 1, 1]
prio_queue0 = [0, 63]
prio_queue1 = [64, 127]
prio_queue2 = [128, 191]
prio_queue3 = [192, 255]
prio_queue4 = [256, 319]
prio_queue5 = [320, 383]
prio_queue6 = [384, 447]
prio_queue7 = [448, 511]
mac_configuration_table = make_table_by_layout(mac_configuration_table_layout, layoutid_map)
c.append(mac_configuration_table)
for i in range(NO_ETH_PORTS):
mac_configuration_table.append({
"INGMIRRDEI": 0,
"INGMIRRPCP": 0,
"INGMIRRVID": 0,
"MIRRCETAG": 0,
"MIRRCIE": 0,
"INGRESS": 1,
"EGRESS": 1,
"DYN_LEARN": 1,
"DRPNONA664": 0,
"EGR_MIRR": 0,
"ING_MIRR": 0,
"VLANID": default_vlan,
"VLANPRIO": 0,
"MAXAGE": 255,
"TP_DELOUT": 0,
"TP_DELIN": 0,
"SPEED": speed[i],
"IFG": 0,
"ENABLED[0]": queue_enable[0], # enable the queue
"BASE[0]": prio_queue0[0], # start
"TOP[0]": prio_queue0[1], # set the size of the queue to maximum size
"ENABLED[1]": queue_enable[1],
"BASE[1]": prio_queue1[0],
"TOP[1]": prio_queue1[1],
"ENABLED[2]": queue_enable[2],
"BASE[2]": prio_queue2[0],
"TOP[2]": prio_queue2[1],
"ENABLED[3]": queue_enable[3],
"BASE[3]": prio_queue3[0],
"TOP[3]": prio_queue3[1],
"ENABLED[4]": queue_enable[4],
"BASE[4]": prio_queue4[0],
"TOP[4]": prio_queue4[1],
"ENABLED[5]": queue_enable[5],
"BASE[5]": prio_queue5[0],
"TOP[5]": prio_queue5[1],
"ENABLED[6]": queue_enable[6],
"BASE[6]": prio_queue6[0],
"TOP[6]": prio_queue6[1],
"ENABLED[7]": queue_enable[7],
"BASE[7]": prio_queue7[0],
"TOP[7]": prio_queue7[1]})
#############################################################################
# Credit-Based Shaping Table
#############################################################################
# bandwidth given in Mbit/s
# Example configuration for 4 shapers in port 0
# shapers = [
# {"bandwidth": 0.5, "prio": 7, "port": 0},
# {"bandwidth": 5, "prio": 6, "port": 0},
# {"bandwidth": 10, "prio": 5, "port": 0},
# {"bandwidth": 20, "prio": 4, "port": 0}]
shapers = []
if len(shapers) > 0:
credit_based_shaping_table = make_table_by_layout(credit_based_shaping_table_layout, layoutid_map)
c.append(credit_based_shaping_table)
assert len(shapers) <= NO_CBS_BLOCKS, "No of shapers configured exceeds %d" % (
NO_CBS_BLOCKS)
for shaper in shapers:
idle_slope = shaper[
"bandwidth"] / 8.0 * 10 ** 6 # conversion from Mbit/s to byte/s
rate = speed_Mbps[
shaper["port"]] / 8.0 * 10 ** 6 # rate at the port in byte/s
send_slope = rate - idle_slope
credit_based_shaping_table.append({
"IDLE_SLOPE": long(idle_slope),
"SEND_SLOPE": long(send_slope),
"CREDIT_HI": 0x6FFFFFFF,
"CREDIT_LO": 0x6FFFFFFF,
"CBS_PRIO": shaper["prio"],
"CBS_PORT": shaper["port"]})
print(idle_slope)
#############################################################################
# VLAN Lookup Table
#############################################################################
vlan_lookup_table = make_table_by_layout(vlan_lookup_table_layout, layoutid_map)
c.append(vlan_lookup_table)
# Default VLAN
vlan_lookup_table.append({
"VING_MIRR": 0,
"VEGR_MIRR": 0,
"VMEMB_PORT": 0x1F, # All ports are member of the VLAN
"VLAN_BC": 0x1F, # Broadcast domain for the VLAN
"TAG_PORT": 0x00, # Egress frames are untagged
"VLANID": default_vlan})
# Enable VLANs 0 to 15
for i in range(16):
vlan_lookup_table.append({
"VING_MIRR": 0,
"VEGR_MIRR": 0,
"VMEMB_PORT": 0x1F, # all ports are member
"VLAN_BC": 0x1F, # Broadcast domain
"TAG_PORT": 0x1F, # Egress frames are tagged
"VLANID": i})
#############################################################################
# L2 Lookup Parameters Table
#############################################################################
l2_lookup_parameters_table = make_table_by_layout(l2_lookup_parameters_table_layout, layoutid_map)
c.append(l2_lookup_parameters_table)
l2_lookup_parameters_table.append({
"LEARN_ONCE": 0,
"OWR_DYN": 0,
"USE_STATIC": 0,
"NO_MGMT_LEARN": 1,
"NO_ENF_HOSTPRT": 0,
"DRPNOLEARN": 0,
"START_DYNSPC": 0,
"MAXAGE": 0,
"MAXADDRP[0]": 1024,
"MAXADDRP[1]": 1024,
"MAXADDRP[2]": 1024,
"MAXADDRP[3]": 1024,
"MAXADDRP[4]": 1024,
"DRPUNI": 0,
"DRPMC": 0,
"DRPBC": 0})
#############################################################################
# L2 Address Lookup Table
#############################################################################
l2_address_lookup_table = make_table_by_layout(l2_address_lookup_table_layout, layoutid_map)
c.append(l2_address_lookup_table)
l2_address_lookup_table.append(
{
"INDEX": 0,
"ENFPORT": 0,
"DESTPORTS": 1 << 0,
"MACADDR": 0x001094000001,
"VLANID": 555,
"IOTAG": 0,
"MASK_MACADDR": 0xFFFFFFFFFFFF,
"MASK_VLANID": 0xFFF,
"MASK_IOTAG": 0x1,
"RETAG": 0,
"MIRR": 0,
"TAKETS": 0,
"MIRRVLAN": 0,
"TSREG": 0}
)
#############################################################################
# L2 Policing Table
#############################################################################
l2_policing_table = make_table_by_layout(l2_policing_table_layout, layoutid_map)
c.append(l2_policing_table)
# In this example, every port/priority is assigned a dedicated policer.
# By use of SHARINDX, multiple ports/priorities can be mapped to a single policer.
# defines the ratio of available bandwidth that is admitted for a prio/port combination in %
# a value of 100 means that no policing is performed
ratio = [[100, 100, 100, 100, 100, 100, 100, 100], # Port 0 - no policing
[100, 100, 100, 100, 100, 100, 100, 100], # Port 1 - no policing
[100, 100, 100, 100, 100, 100, 100, 100], # Port 2 - no policing
[100, 100, 100, 100, 100, 100, 100, 100], # Port 3 - no policing
[100, 100, 100, 100, 100, 100, 100, 100]] # Port 4 - no policing
for port in range(NO_ETH_PORTS):
for prio in range(NO_PRIORITIES):
l2_policing_table.append({
"SHARINDX": port * NO_PRIORITIES + prio, # individual policing block for each priority
"SMAX": 10 * 1526, # Maximum burst as 10 maximum sized, double tagged frames
"RATE": long(speed_Mbps[port] * ratio[port][prio] / 100.0 * 1000 / 15.625), # Unit: [15.625 kbps]
"MAXLEN": 1526,
"PARTITION": prio}) # memory is partitioned towards the priorities
# Broadcast Storm Prevention
# Defines the ratio of available bandwidth that is admitted for a port
# ratio = [port 0, port 1, ..., port 4]
ratio = [100, 100, 100, 100, 100] # All ports admit up to 100% broadcast traffic
for port in range(5):
l2_policing_table.append({
"SHARINDX": 40 + port, # individual policing block for each priority
"SMAX": 10 * 1526, # Maximum burst as 10 maximum sized, double tagged frames
"RATE": long(speed_Mbps[port] * ratio[port] / 100.0 * 1000 / 15.625), # Unit: [15.625 kbps]
"MAXLEN": 1526,
"PARTITION": 0}) # memory is partitioned towards the priorities
############################################################################
# L2 Forwarding Table
#############################################################################
l2_forwarding_table = make_table_by_layout(l2_forwarding_table_layout, layoutid_map)
c.append(l2_forwarding_table)
# retain the priority of the frames at ingress
for i in range(NO_ETH_PORTS):
if (i == general_parameters.entries[0]["HOST_PORT"]):
reachable_ports = 0x1F # host port is reachable by itself, needed for hybrid AVB implementation with endpoint and bridge stack on a single host
else:
reachable_ports = 0x1F & ~(1 << i)
broadcast_domain = 0x1F & ~(1 << i)
default_route = 0x1F & ~(1 << i)
# Priority regeneration
priority_map = [0,1,2,3,4,5,6,7] # No PCP modification
l2_forwarding_table.append({
"FL_DOMAIN" : default_route,
"BC_DOMAIN" : broadcast_domain,
"REACH_PORT" : reachable_ports,
"VLAN_PMAP[0]" : priority_map[0],
"VLAN_PMAP[1]" : priority_map[1],
"VLAN_PMAP[2]" : priority_map[2],
"VLAN_PMAP[3]" : priority_map[3],
"VLAN_PMAP[4]" : priority_map[4],
"VLAN_PMAP[5]" : priority_map[5],
"VLAN_PMAP[6]" : priority_map[6],
"VLAN_PMAP[7]" : priority_map[7]})
# Output PCP to queue mapping
# map priority i to queue i on all ports
for i in range(NO_PRIORITIES):
l2_forwarding_table.append({
"VLAN_PMAP[0]" : i,
"VLAN_PMAP[1]" : i,
"VLAN_PMAP[2]" : i,
"VLAN_PMAP[3]" : i,
"VLAN_PMAP[4]" : i})
#############################################################################
# L2 Forwarding Parameters Table
#############################################################################
l2_forwarding_parameters_table = make_table_by_layout(l2_forwarding_parameters_table_layout, layoutid_map)
c.append(l2_forwarding_parameters_table)
l2_forwarding_parameters_table.append({
"MAX_DYNP" : 0,
"PART_SPC[7]" : 100,
"PART_SPC[6]" : 100,
"PART_SPC[5]" : 100,
"PART_SPC[4]" : 100,
"PART_SPC[3]" : 100,
"PART_SPC[2]" : 100,
"PART_SPC[1]" : 100,
"PART_SPC[0]" : 210}
)
assert sum([l2_forwarding_parameters_table.entries[0]["PART_SPC[%d]" % i] for i in range(8)]) <= 910, 'sum of paritions must not exceed 910 (if retagging used)'
#############################################################################
# AVB Parameters
#############################################################################
avb_parameters = make_table_by_layout(avb_parameters_table_layout, layoutid_map)
c.append(avb_parameters)
avb_parameters.append({
"SRCMETA" : 0x026037C0FFEE,
"DESTMETA" : 0x026037DECADE,
"CAS_MASTER": 1,
"L2CBS" : 0
})
#############################################################################
# MII Mode Control Parameters
#############################################################################
mii_mode_parameters = make_table_by_layout(mii_mode_parameters_table_layout, layoutid_map)
c.append(mii_mode_parameters)
MII = 0
RMII = 1
RGMII = 2
UNUSED = 3
SGMII = 3
PHY_MODE = 1
MAC_MODE = 0
mii_mode_parameters.append({
"xMII_MODE[0]": RGMII,
"PHY_MAC[0]": MAC_MODE, # not applicable for RGMII,
"xMII_MODE[1]": RGMII,
"PHY_MAC[1]": MAC_MODE,
"xMII_MODE[2]": RGMII,
"PHY_MAC[2]": MAC_MODE,
"xMII_MODE[3]": RGMII,
"PHY_MAC[3]": MAC_MODE,
"xMII_MODE[4]": RGMII,
"PHY_MAC[4]": MAC_MODE, # not applicable for RGMII,
})
#############################################################################
# Write out hex file
#############################################################################
filename = os.path.basename(__file__)
filename = filename.replace(".py", ".hex")
c.deviceid = 0xae00030e
c.to_hex("output/" + filename)
#############################################################################
# Executive Summary
#############################################################################
print "Number of bytes: %d" %(len(c.to_bytes()))
print "======================"
Hi,
1) Do you know where the frames are lost? Are they lost on the RGMII link (MAC -> Port ) or in the switch or on the MII link (Port -> Eth Phy)? This can be checked by looking at the drop and MII/CRC error counters of these ports. Are there problems between other combinations of link partners? E.g. can Port 0 or 1 exchange ping/packets with Port 2 and 3? The provided .py scripts do not show any configuration of CGU registers.
2) Could you measure the clock for the port and see if it is as per expectation? It would be nice if you could share the scope plots aswell. One possiblity of configuring CGU is to do it before hand and then download the static config, would be great if you could try that out. Please consult section 2.4 of the software user manual for more details.
3)Without knowing where the frames are lost, we cannot debug the issue. So far I have two guesses: the CGU is not configured correctly. the frames are forwarded with VLAN ID = 0 (tagged) but the station connected to port 3 does not accept such frames.
BR,
Abdullah
hi Abdullah:
1) The provided .py scripts do not show any configuration of CGU registers, please check log file in attached files, there is log about CGU register as below
registerAddress=00100016 registerValue=0b000800
registerAddress=0010001c registerValue=12000800
do you think registerValue is ok? l think CGU is ok.
2) how to check and look at the drop and MII/CRC error counters of these ports, is there some registers record the number of frames received and thansimitted per port?
Hi Pengfeng,
On page 56 of the software user manual, you should find table 72 " Ethernet port status - MAC-level diagnostic counters (offset 0h)", try reading that out for the respective ports when there is a loss of frames. This should narrow down the issue.
Secondly, In one of your comments, you mentioned that after initial flash, everything works as per expectations but after power reset, there is a loss of frame. To me that sounds like there is no valid configuration on the switch after the reset. Maybe you could try reading out valid config flag after power reset and see if the switch has a valid configuration after the reset.
BR,
Abdullah
HI Abdullah,
happy to see you, when l ping 192.168.1.1, failed
then cd /sys/kernel/debug/sja1105p-0/ethernet
then cat mac-level .
result as follows, so Is it a hardware problem or software problem?
Hi Abdullah
1) l have measured the clock for the all the 5 ports (include rxc and txc), the clock is as per expectation, l think all the clock is ok
2) hardware schematic diagram is in attached files, could you check it for me?
3) let me tell you something, several times i have only exchange packages between port0 and port1,sja1105q worked very well, i can ping 192.168.1.1 successfully, but if l reset the board, l cannot ping 192168.1.1 anymore.
HI, Abdullah
1) I don,t know how to check and look at the drop and MII/CRC error counters of these ports. l think this is the key.
Port 0 or 1 cannot exchange ping/packets with Port 2 and 3 , like sja1105 is not work. if take out sja1105 from board, connect port0 to phy (rtl8211f)directly, l can ping 192.168.1.1,, and network is ok.
2) first step of my mission is exhange packeges in port0 and port1 successfully, but l have measured all the clock for the port0 ,port1 , port2, port3, port4.
for port0: txc and rxc in port0 is always 125m , scope plots is port0_txc.jpg in attached files.
for port1: rxc in port1 is 2.5m, if connect RJ45 Plug into port1, rxc will change to 125m, TXC in port1 is alway 25m.
for port2: the same as port1
for port3,port4. txc and rxc is always 25m, cuz phy YT8010A is 100m rgmii.
3) l think this project donnot need vlan
4) "Please consult section 2.4 of the software user manual for more details". l can not find any detail content about the static CGU config, only have a Configuration Flow Figure, software user manual is a file named UM11040.pdf ?