Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gearbox] Set context for phys based on context_id #1826

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("context_id") == phy.end())
{
SWSS_LOG_ERROR("missing 'context_id' field in 'phys' item %d in gearbox configuration", iter);
return false;
}
val = phy["context_id"];
attr = std::make_pair("context_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);
Expand Down
4 changes: 4 additions & 0 deletions lib/gearboxutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ std::map<int, gearbox_phy_t> GearboxUtils::loadPhyMap(Table *gearboxTable)
{
phy.bus_id = std::stoi(val.second);
}
else if (val.first == "context_id")
{
phy.context_id = std::stoi(val.second);
}
}
gearboxPhyMap[phy.phy_id] = phy;
}
Expand Down
1 change: 1 addition & 0 deletions lib/gearboxutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef struct
std::string hwinfo;
uint32_t address;
uint32_t bus_id;
uint32_t context_id;
} gearbox_phy_t;

typedef struct
Expand Down
2 changes: 1 addition & 1 deletion orchagent/saihelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ sai_status_t initSaiPhyApi(swss::gearbox_phy_t *phy)

/* Must be last Attribute */
attr.id = SAI_REDIS_SWITCH_ATTR_CONTEXT;
attr.value.u64 = phy->phy_id;
attr.value.u64 = phy->context_id;
attrs.push_back(attr);

status = sai_switch_api->create_switch(&phyOid, (uint32_t)attrs.size(), attrs.data());
Expand Down