Skip to content

Commit

Permalink
[gearbox] Add support for "hwinfo" field (sonic-net#1547)
Browse files Browse the repository at this point in the history
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 <baptiste@arista.com>
  • Loading branch information
Nakrez committed Jan 8, 2021
1 parent 7e3b2c6 commit 693a02c
Show file tree
Hide file tree
Showing 28 changed files with 176 additions and 46 deletions.
8 changes: 8 additions & 0 deletions gearsyncd/gearboxparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ bool GearboxParser::parse()
val = phy["bus_id"];
attr = std::make_pair("bus_id", std::to_string(val.get<int>()));
attrs.push_back(attr);
if (phy.find("hwinfo") == phy.end())
{
SWSS_LOG_ERROR("missing 'hwinfo' field in 'phys' item %d in gearbox configuration", iter);
return false;
}
val = phy["hwinfo"];
attr = std::make_pair("hwinfo", std::string(val.get<std::string>()));
attrs.push_back(attr);
std::string key;
key = "phy:" + std::to_string(phyId);
if (getWriteToDb() == true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy_config_does_not_exist.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/3"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"config_file": "tests/configs/positive/phy1_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-1.bcm",
"phy_access": "mdio",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -20,7 +21,8 @@
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"firmware_path": "/tmp/phy-example1.bin",
"config_file": "tests/configs/positive/phy1_config_1.json",
"phy_access": "MDIO(NPU)",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -17,7 +18,8 @@
"firmware_path": "/tmp/phy-example2.bin",
"config_file": "tests/configs/positive/phy2_config_1.json",
"phy_access": "I2C",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"lib_name": "libsai_phy_example1.so",
"firmware_path": "/tmp/phy-example1.bin",
"config_file": "tests/configs/positive/phy1_config_1.json",
"phy_access": "MDIO(NPU)"
"phy_access": "MDIO(NPU)",
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -17,7 +18,8 @@
"firmware_path": "/tmp/phy-example2.bin",
"config_file": "tests/configs/positive/phy2_config_1.json",
"phy_access": "I2C",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"lib_name": "libsai_phy_example1.so",
"firmware_path": "/tmp/phy-example1.bin",
"phy_access": "MDIO(NPU)",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -17,7 +18,8 @@
"firmware_path": "/tmp/phy-example2.bin",
"config_file": "tests/configs/positive/phy2_config_1.json",
"phy_access": "I2C",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"lib_name": "libsai_phy_example1.so",
"config_file": "tests/configs/positive/phy1_config_1.json",
"phy_access": "MDIO(NPU)",
"bus_id": 0
"bus_id": 0,
"hwinfo": "mdio0/0"
},
{
"phy_id": 1,
Expand All @@ -17,7 +18,8 @@
"firmware_path": "/tmp/phy-example2.bin",
"config_file": "tests/configs/positive/phy2_config_1.json",
"phy_access": "I2C",
"bus_id": 1
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"phys": [
{
"phy_id": 0,
"name": "example-1",
"address": "0x1000",
"lib_name": "libsai_phy_example1.so",
"firmware_path": "/tmp/phy-example1.bin",
"config_file": "tests/configs/positive/phy1_config_1.json",
"phy_access": "mdio",
"bus_id": 0
},
{
"phy_id": 1,
"name": "example-2",
"address": "0x2000",
"lib_name": "libsai_phy_example2.so",
"firmware_path": "/tmp/phy-example2.bin",
"config_file": "tests/configs/positive/phy2_config_1.json",
"sai_init_config_file": "/usr/share/sonic/hwsku/example-2.bcm",
"phy_access": "i2c",
"bus_id": 1,
"hwinfo": ""
}
],
"interfaces": [
{
"index": 1,
"phy_id" : 0,
"system_lanes": [38,39],
"line_lanes": [30,31,32,33]
},
{
"index": 1,
"phy_id" : 0,
"system_lanes": [40,41],
"line_lanes": [34,35,36,37]
},
{
"index": 1,
"phy_id" : 1,
"system_lanes": [4,5],
"line_lanes": [0,1,2,3]
}
]
}
Loading

0 comments on commit 693a02c

Please sign in to comment.