diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 3238ee795e..b776d9fd5c 100755 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -1800,9 +1800,7 @@ bool PortsOrch::setGearboxPortAttr(Port &port, dest_port_type_t port_type, sai_p sai_object_id_t dest_port_id; sai_attribute_t attr; string speed_attr; - uint32_t lane_speed = 0; sai_uint32_t speed = 0; - uint32_t lanes = 0; SWSS_LOG_ENTER(); @@ -1826,36 +1824,29 @@ bool PortsOrch::setGearboxPortAttr(Port &port, dest_port_type_t port_type, sai_p switch (port_type) { case PHY_PORT_TYPE: - lanes = static_cast(m_gearboxInterfaceMap[port.m_index].system_lanes.size()); speed_attr = "system_speed"; break; case LINE_PORT_TYPE: - lanes = static_cast(m_gearboxInterfaceMap[port.m_index].line_lanes.size()); speed_attr = "line_speed"; break; default: return false; } - // Gearbox expects speed per lane speed = *static_cast(value); - if (speed % lanes == 0) - { - lane_speed = speed / lanes; - } - if (isSpeedSupported(port.m_alias, dest_port_id, lane_speed)) + if (isSpeedSupported(port.m_alias, dest_port_id, speed)) { // Gearbox may not implement speed check, so // invalidate speed if it doesn't make sense. - if (to_string(lane_speed).size() < 5) + if (to_string(speed).size() < 5) { - lane_speed = 0; + speed = 0; } attr.id = SAI_PORT_ATTR_SPEED; - attr.value.u32 = lane_speed; + attr.value.u32 = speed; } - SWSS_LOG_NOTICE("BOX: Set %s lane %s %d", port.m_alias.c_str(), speed_attr.c_str(), lane_speed); + SWSS_LOG_NOTICE("BOX: Set %s lane %s %d", port.m_alias.c_str(), speed_attr.c_str(), speed); break; default: return false; @@ -1867,8 +1858,8 @@ bool PortsOrch::setGearboxPortAttr(Port &port, dest_port_type_t port_type, sai_p if (id == SAI_PORT_ATTR_SPEED) { string key = "phy:"+to_string(m_gearboxInterfaceMap[port.m_index].phy_id)+":ports:"+to_string(port.m_index); - m_gearboxTable->hset(key, speed_attr, to_string(lane_speed)); - SWSS_LOG_NOTICE("BOX: Updated APPL_DB key:%s %s %d", key.c_str(), speed_attr.c_str(), lane_speed); + m_gearboxTable->hset(key, speed_attr, to_string(speed)); + SWSS_LOG_NOTICE("BOX: Updated APPL_DB key:%s %s %d", key.c_str(), speed_attr.c_str(), speed); } } else @@ -5657,8 +5648,19 @@ bool PortsOrch::initGearboxPort(Port &port) attr.value.booldata = port.m_admin_state_up; attrs.push_back(attr); + attr.id = SAI_PORT_ATTR_HW_LANE_LIST; + lanes.assign(m_gearboxInterfaceMap[port.m_index].system_lanes.begin(), m_gearboxInterfaceMap[port.m_index].system_lanes.end()); + attr.value.u32list.list = lanes.data(); + attr.value.u32list.count = static_cast(lanes.size()); + attrs.push_back(attr); + + for (uint32_t i = 0; i < attr.value.u32list.count; i++) + { + SWSS_LOG_DEBUG("BOX: list[%d] = %d", i, attr.value.u32list.list[i]); + } + attr.id = SAI_PORT_ATTR_SPEED; - attr.value.u32 = (uint32_t) m_gearboxPortMap[port.m_index].system_speed; + attr.value.u32 = (uint32_t) m_gearboxPortMap[port.m_index].system_speed * (uint32_t) lanes.size(); if (isSpeedSupported(port.m_alias, port.m_port_id, attr.value.u32)) { attrs.push_back(attr); @@ -5680,17 +5682,6 @@ bool PortsOrch::initGearboxPort(Port &port) attr.value.booldata = m_gearboxPortMap[port.m_index].system_training; attrs.push_back(attr); - attr.id = SAI_PORT_ATTR_HW_LANE_LIST; - lanes.assign(m_gearboxInterfaceMap[port.m_index].system_lanes.begin(), m_gearboxInterfaceMap[port.m_index].system_lanes.end()); - attr.value.u32list.list = lanes.data(); - attr.value.u32list.count = static_cast(lanes.size()); - attrs.push_back(attr); - - for (uint32_t i = 0; i < attr.value.u32list.count; i++) - { - SWSS_LOG_DEBUG("BOX: list[%d] = %d", i, attr.value.u32list.list[i]); - } - status = sai_port_api->create_port(&systemPort, phyOid, static_cast(attrs.size()), attrs.data()); if (status != SAI_STATUS_SUCCESS) { @@ -5712,8 +5703,19 @@ bool PortsOrch::initGearboxPort(Port &port) attr.value.booldata = port.m_admin_state_up; attrs.push_back(attr); + attr.id = SAI_PORT_ATTR_HW_LANE_LIST; + lanes.assign(m_gearboxInterfaceMap[port.m_index].line_lanes.begin(), m_gearboxInterfaceMap[port.m_index].line_lanes.end()); + attr.value.u32list.list = lanes.data(); + attr.value.u32list.count = static_cast(lanes.size()); + attrs.push_back(attr); + + for (uint32_t i = 0; i < attr.value.u32list.count; i++) + { + SWSS_LOG_DEBUG("BOX: list[%d] = %d", i, attr.value.u32list.list[i]); + } + attr.id = SAI_PORT_ATTR_SPEED; - attr.value.u32 = (uint32_t) m_gearboxPortMap[port.m_index].line_speed; + attr.value.u32 = (uint32_t) m_gearboxPortMap[port.m_index].line_speed * (uint32_t) lanes.size(); if (isSpeedSupported(port.m_alias, port.m_port_id, attr.value.u32)) { attrs.push_back(attr); @@ -5767,17 +5769,6 @@ bool PortsOrch::initGearboxPort(Port &port) attr.value.u32 = media_type_map[m_gearboxPortMap[port.m_index].line_adver_media_type]; attrs.push_back(attr); - attr.id = SAI_PORT_ATTR_HW_LANE_LIST; - lanes.assign(m_gearboxInterfaceMap[port.m_index].line_lanes.begin(), m_gearboxInterfaceMap[port.m_index].line_lanes.end()); - attr.value.u32list.list = lanes.data(); - attr.value.u32list.count = static_cast(lanes.size()); - attrs.push_back(attr); - - for (uint32_t i = 0; i < attr.value.u32list.count; i++) - { - SWSS_LOG_DEBUG("BOX: list[%d] = %d", i, attr.value.u32list.list[i]); - } - status = sai_port_api->create_port(&linePort, phyOid, static_cast(attrs.size()), attrs.data()); if (status != SAI_STATUS_SUCCESS) {