Skip to content

Commit 693a02c

Browse files
[gearbox] Add support for "hwinfo" field (sonic-net#1547)
This commit propagates the new "hwinfo" field parsed from gearbox_config.json to the create_switch SAI PHY call. This information is currently expected to be used to propagate the MDIO interface/phy_id to be used for a particular PHY by the SAI. Signed-off-by: Baptiste Covolato <[email protected]>
1 parent 7e3b2c6 commit 693a02c

28 files changed

+176
-46
lines changed

gearsyncd/gearboxparser.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,14 @@ bool GearboxParser::parse()
143143
val = phy["bus_id"];
144144
attr = std::make_pair("bus_id", std::to_string(val.get<int>()));
145145
attrs.push_back(attr);
146+
if (phy.find("hwinfo") == phy.end())
147+
{
148+
SWSS_LOG_ERROR("missing 'hwinfo' field in 'phys' item %d in gearbox configuration", iter);
149+
return false;
150+
}
151+
val = phy["hwinfo"];
152+
attr = std::make_pair("hwinfo", std::string(val.get<std::string>()));
153+
attrs.push_back(attr);
146154
std::string key;
147155
key = "phy:" + std::to_string(phyId);
148156
if (getWriteToDb() == true)

gearsyncd/tests/configs/negative/gearbox_config_empty_ethernet_line_lanes.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_empty_ethernet_system_lanes.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_invalid_array.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_invalid_json.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_invalid_phy_config_file.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy_config_does_not_exist.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_index.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_line_lane_speed.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_line_lanes.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_phy_id.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_system_lane_speed.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/3"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_ethernet_system_lanes.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
],
2628
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_interfaces.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"config_file": "tests/configs/positive/phy1_config_1.json",
1010
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
1111
"phy_access": "mdio",
12-
"bus_id": 0
12+
"bus_id": 0,
13+
"hwinfo": "mdio0/0"
1314
},
1415
{
1516
"phy_id": 1,
@@ -20,7 +21,8 @@
2021
"config_file": "tests/configs/positive/phy2_config_1.json",
2122
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
2223
"phy_access": "i2c",
23-
"bus_id": 1
24+
"bus_id": 1,
25+
"hwinfo": ""
2426
}
2527
]
2628
}

gearsyncd/tests/configs/negative/gearbox_config_missing_phy_address.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"firmware_path": "/tmp/phy-example1.bin",
88
"config_file": "tests/configs/positive/phy1_config_1.json",
99
"phy_access": "MDIO(NPU)",
10-
"bus_id": 0
10+
"bus_id": 0,
11+
"hwinfo": "mdio0/0"
1112
},
1213
{
1314
"phy_id": 1,
@@ -17,7 +18,8 @@
1718
"firmware_path": "/tmp/phy-example2.bin",
1819
"config_file": "tests/configs/positive/phy2_config_1.json",
1920
"phy_access": "I2C",
20-
"bus_id": 1
21+
"bus_id": 1,
22+
"hwinfo": ""
2123
}
2224
],
2325
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_phy_bus_id.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"lib_name": "libsai_phy_example1.so",
88
"firmware_path": "/tmp/phy-example1.bin",
99
"config_file": "tests/configs/positive/phy1_config_1.json",
10-
"phy_access": "MDIO(NPU)"
10+
"phy_access": "MDIO(NPU)",
11+
"hwinfo": "mdio0/0"
1112
},
1213
{
1314
"phy_id": 1,
@@ -17,7 +18,8 @@
1718
"firmware_path": "/tmp/phy-example2.bin",
1819
"config_file": "tests/configs/positive/phy2_config_1.json",
1920
"phy_access": "I2C",
20-
"bus_id": 1
21+
"bus_id": 1,
22+
"hwinfo": ""
2123
}
2224
],
2325
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_phy_config_file.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"lib_name": "libsai_phy_example1.so",
88
"firmware_path": "/tmp/phy-example1.bin",
99
"phy_access": "MDIO(NPU)",
10-
"bus_id": 0
10+
"bus_id": 0,
11+
"hwinfo": "mdio0/0"
1112
},
1213
{
1314
"phy_id": 1,
@@ -17,7 +18,8 @@
1718
"firmware_path": "/tmp/phy-example2.bin",
1819
"config_file": "tests/configs/positive/phy2_config_1.json",
1920
"phy_access": "I2C",
20-
"bus_id": 1
21+
"bus_id": 1,
22+
"hwinfo": ""
2123
}
2224
],
2325
"interfaces": [

gearsyncd/tests/configs/negative/gearbox_config_missing_phy_firmware_path.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"lib_name": "libsai_phy_example1.so",
88
"config_file": "tests/configs/positive/phy1_config_1.json",
99
"phy_access": "MDIO(NPU)",
10-
"bus_id": 0
10+
"bus_id": 0,
11+
"hwinfo": "mdio0/0"
1112
},
1213
{
1314
"phy_id": 1,
@@ -17,7 +18,8 @@
1718
"firmware_path": "/tmp/phy-example2.bin",
1819
"config_file": "tests/configs/positive/phy2_config_1.json",
1920
"phy_access": "I2C",
20-
"bus_id": 1
21+
"bus_id": 1,
22+
"hwinfo": ""
2123
}
2224
],
2325
"interfaces": [
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"phys": [
3+
{
4+
"phy_id": 0,
5+
"name": "example-1",
6+
"address": "0x1000",
7+
"lib_name": "libsai_phy_example1.so",
8+
"firmware_path": "/tmp/phy-example1.bin",
9+
"config_file": "tests/configs/positive/phy1_config_1.json",
10+
"phy_access": "mdio",
11+
"bus_id": 0
12+
},
13+
{
14+
"phy_id": 1,
15+
"name": "example-2",
16+
"address": "0x2000",
17+
"lib_name": "libsai_phy_example2.so",
18+
"firmware_path": "/tmp/phy-example2.bin",
19+
"config_file": "tests/configs/positive/phy2_config_1.json",
20+
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
21+
"phy_access": "i2c",
22+
"bus_id": 1,
23+
"hwinfo": ""
24+
}
25+
],
26+
"interfaces": [
27+
{
28+
"index": 1,
29+
"phy_id" : 0,
30+
"system_lanes": [38,39],
31+
"line_lanes": [30,31,32,33]
32+
},
33+
{
34+
"index": 1,
35+
"phy_id" : 0,
36+
"system_lanes": [40,41],
37+
"line_lanes": [34,35,36,37]
38+
},
39+
{
40+
"index": 1,
41+
"phy_id" : 1,
42+
"system_lanes": [4,5],
43+
"line_lanes": [0,1,2,3]
44+
}
45+
]
46+
}

0 commit comments

Comments
 (0)