@@ -1135,60 +1135,35 @@ bool PortsOrch::getPortAdminStatus(sai_object_id_t id, bool &up)
1135
1135
return true ;
1136
1136
}
1137
1137
1138
- bool PortsOrch::getPortMtu (sai_object_id_t id, sai_uint32_t &mtu)
1139
- {
1140
- SWSS_LOG_ENTER ();
1141
-
1142
- sai_attribute_t attr;
1143
- attr.id = SAI_PORT_ATTR_MTU;
1144
-
1145
- sai_status_t status = sai_port_api->get_port_attribute (id, 1 , &attr);
1146
-
1147
- if (status != SAI_STATUS_SUCCESS)
1148
- {
1149
- task_process_status handle_status = handleSaiGetStatus (SAI_API_PORT, status);
1150
- if (handle_status != task_success)
1151
- {
1152
- return parseHandleSaiStatusFailure (handle_status);
1153
- }
1154
- }
1155
-
1156
- mtu = attr.value .u32 - (uint32_t )(sizeof (struct ether_header ) + FCS_LEN + VLAN_TAG_LEN);
1157
-
1158
- if (isMACsecPort (id))
1159
- {
1160
- mtu -= MAX_MACSEC_SECTAG_SIZE;
1161
- }
1162
-
1163
- return true ;
1164
- }
1165
-
1166
- bool PortsOrch::setPortMtu (sai_object_id_t id, sai_uint32_t mtu)
1138
+ bool PortsOrch::setPortMtu (const Port& port, sai_uint32_t mtu)
1167
1139
{
1168
1140
SWSS_LOG_ENTER ();
1169
1141
1170
1142
sai_attribute_t attr;
1171
1143
attr.id = SAI_PORT_ATTR_MTU;
1172
1144
/* mtu + 14 + 4 + 4 = 22 bytes */
1173
- attr.value .u32 = (uint32_t )(mtu + sizeof (struct ether_header ) + FCS_LEN + VLAN_TAG_LEN);
1145
+ mtu += (uint32_t )(sizeof (struct ether_header ) + FCS_LEN + VLAN_TAG_LEN);
1146
+ attr.value .u32 = mtu;
1174
1147
1175
- if (isMACsecPort (id ))
1148
+ if (isMACsecPort (port. m_port_id ))
1176
1149
{
1177
1150
attr.value .u32 += MAX_MACSEC_SECTAG_SIZE;
1178
1151
}
1179
1152
1180
- sai_status_t status = sai_port_api->set_port_attribute (id , &attr);
1153
+ sai_status_t status = sai_port_api->set_port_attribute (port. m_port_id , &attr);
1181
1154
if (status != SAI_STATUS_SUCCESS)
1182
1155
{
1183
1156
SWSS_LOG_ERROR (" Failed to set MTU %u to port pid:%" PRIx64 " , rv:%d" ,
1184
- attr.value .u32 , id , status);
1157
+ attr.value .u32 , port. m_port_id , status);
1185
1158
task_process_status handle_status = handleSaiSetStatus (SAI_API_PORT, status);
1186
1159
if (handle_status != task_success)
1187
1160
{
1188
1161
return parseHandleSaiStatusFailure (handle_status);
1189
1162
}
1190
1163
}
1191
- SWSS_LOG_INFO (" Set MTU %u to port pid:%" PRIx64, attr.value .u32 , id);
1164
+
1165
+ setGearboxPortsAttr (port, SAI_PORT_ATTR_MTU, &mtu);
1166
+ SWSS_LOG_INFO (" Set MTU %u to port pid:%" PRIx64, attr.value .u32 , port.m_port_id );
1192
1167
return true ;
1193
1168
}
1194
1169
@@ -2021,7 +1996,7 @@ void PortsOrch::initPortSupportedSpeeds(const std::string& alias, sai_object_id_
2021
1996
/*
2022
1997
* If Gearbox is enabled and this is a Gearbox port then set the attributes accordingly.
2023
1998
*/
2024
- bool PortsOrch::setGearboxPortsAttr (Port &port, sai_port_attr_t id, void *value)
1999
+ bool PortsOrch::setGearboxPortsAttr (const Port &port, sai_port_attr_t id, void *value)
2025
2000
{
2026
2001
bool status = false ;
2027
2002
@@ -2039,7 +2014,7 @@ bool PortsOrch::setGearboxPortsAttr(Port &port, sai_port_attr_t id, void *value)
2039
2014
* If Gearbox is enabled and this is a Gearbox port then set the specific lane attribute.
2040
2015
* Note: the appl_db is also updated (Gearbox config_db tables are TBA).
2041
2016
*/
2042
- bool PortsOrch::setGearboxPortAttr (Port &port, dest_port_type_t port_type, sai_port_attr_t id, void *value)
2017
+ bool PortsOrch::setGearboxPortAttr (const Port &port, dest_port_type_t port_type, sai_port_attr_t id, void *value)
2043
2018
{
2044
2019
sai_status_t status = SAI_STATUS_SUCCESS;
2045
2020
sai_object_id_t dest_port_id;
@@ -2093,6 +2068,15 @@ bool PortsOrch::setGearboxPortAttr(Port &port, dest_port_type_t port_type, sai_p
2093
2068
}
2094
2069
SWSS_LOG_NOTICE (" BOX: Set %s lane %s %d" , port.m_alias .c_str (), speed_attr.c_str (), speed);
2095
2070
break ;
2071
+ case SAI_PORT_ATTR_MTU:
2072
+ attr.id = id;
2073
+ attr.value .u32 = *static_cast <sai_uint32_t *>(value);
2074
+ if (LINE_PORT_TYPE == port_type && isMACsecPort (dest_port_id))
2075
+ {
2076
+ attr.value .u32 += MAX_MACSEC_SECTAG_SIZE;
2077
+ }
2078
+ SWSS_LOG_NOTICE (" BOX: Set %s MTU %d" , port.m_alias .c_str (), attr.value .u32 );
2079
+ break ;
2096
2080
default :
2097
2081
return false ;
2098
2082
}
@@ -3302,7 +3286,7 @@ void PortsOrch::doPortTask(Consumer &consumer)
3302
3286
3303
3287
if (mtu != 0 && mtu != p.m_mtu )
3304
3288
{
3305
- if (setPortMtu (p. m_port_id , mtu))
3289
+ if (setPortMtu (p, mtu))
3306
3290
{
3307
3291
p.m_mtu = mtu;
3308
3292
m_portList[alias] = p;
@@ -6686,6 +6670,8 @@ bool PortsOrch::initGearboxPort(Port &port)
6686
6670
SWSS_LOG_NOTICE (" BOX: Connected Gearbox ports; system-side:0x%" PRIx64 " to line-side:0x%" PRIx64, systemPort, linePort);
6687
6671
m_gearboxPortListLaneMap[port.m_port_id ] = make_tuple (systemPort, linePort);
6688
6672
port.m_line_side_id = linePort;
6673
+ saiOidToAlias[systemPort] = port.m_alias ;
6674
+ saiOidToAlias[linePort] = port.m_alias ;
6689
6675
6690
6676
/* Add gearbox system/line port name map to counter table */
6691
6677
FieldValueTuple tuple (port.m_alias + " _system" , sai_serialize_object_id (systemPort));
@@ -7192,6 +7178,13 @@ void PortsOrch::setMACsecEnabledState(sai_object_id_t port_id, bool enabled)
7192
7178
{
7193
7179
SWSS_LOG_ENTER ();
7194
7180
7181
+ Port p;
7182
+ if (!getPort (port_id, p))
7183
+ {
7184
+ SWSS_LOG_ERROR (" Failed to get port object for port id 0x%" PRIx64, port_id);
7185
+ return ;
7186
+ }
7187
+
7195
7188
if (enabled)
7196
7189
{
7197
7190
m_macsecEnabledPorts.insert (port_id);
@@ -7200,6 +7193,8 @@ void PortsOrch::setMACsecEnabledState(sai_object_id_t port_id, bool enabled)
7200
7193
{
7201
7194
m_macsecEnabledPorts.erase (port_id);
7202
7195
}
7196
+
7197
+ setPortMtu (p, p.m_mtu );
7203
7198
}
7204
7199
7205
7200
bool PortsOrch::isMACsecPort (sai_object_id_t port_id) const
0 commit comments