diff --git a/gearsyncd/gearboxparser.cpp b/gearsyncd/gearboxparser.cpp index 863ee57dabf1..1ae8118266c7 100644 --- a/gearsyncd/gearboxparser.cpp +++ b/gearsyncd/gearboxparser.cpp @@ -143,6 +143,14 @@ bool GearboxParser::parse() val = phy["bus_id"]; attr = std::make_pair("bus_id", std::to_string(val.get())); 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())); + attrs.push_back(attr); if (phy.find("hwinfo") == phy.end()) { SWSS_LOG_ERROR("missing 'hwinfo' field in 'phys' item %d in gearbox configuration", iter); diff --git a/lib/gearboxutils.cpp b/lib/gearboxutils.cpp index 989de4d22f7c..30c89ab494ce 100644 --- a/lib/gearboxutils.cpp +++ b/lib/gearboxutils.cpp @@ -185,6 +185,10 @@ std::map 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; } diff --git a/lib/gearboxutils.h b/lib/gearboxutils.h index 0a70c62d77f2..b28b7b1080ab 100644 --- a/lib/gearboxutils.h +++ b/lib/gearboxutils.h @@ -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 diff --git a/orchagent/saihelper.cpp b/orchagent/saihelper.cpp index dac7b1e92f9b..15febdb5183a 100644 --- a/orchagent/saihelper.cpp +++ b/orchagent/saihelper.cpp @@ -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());