@@ -382,24 +382,27 @@ class MACsecOrchContext
382
382
return m_macsec_sa;
383
383
}
384
384
385
- private:
386
- MACsecOrchContext (MACsecOrch *orch) : m_orch(orch),
387
- m_port_name (nullptr ),
388
- m_direction(SAI_MACSEC_DIRECTION_EGRESS),
389
- m_sci(nullptr ),
390
- m_an(nullptr ),
391
- m_port(nullptr ),
392
- m_macsec_obj(nullptr ),
393
- m_port_id(nullptr ),
394
- m_switch_id(nullptr ),
395
- m_macsec_port(nullptr ),
396
- m_acl_table(nullptr ),
397
- m_macsec_sc(nullptr ),
398
- m_macsec_sa(nullptr )
385
+ const gearbox_phy_t * get_gearbox_phy ()
399
386
{
387
+ if (m_gearbox_phy)
388
+ {
389
+ return m_gearbox_phy;
390
+ }
391
+ auto switch_id = get_switch_id ();
392
+ if (switch_id == nullptr || get_port () == nullptr )
393
+ {
394
+ SWSS_LOG_ERROR (" Switch/Port wasn't provided" );
395
+ return nullptr ;
396
+ }
397
+ if (*switch_id == gSwitchId )
398
+ {
399
+ return nullptr ;
400
+ }
401
+ m_gearbox_phy = m_orch->m_port_orch ->getGearboxPhy (*get_port ());
402
+ return m_gearbox_phy;
400
403
}
401
404
402
- const Port *get_port ()
405
+ Port *get_port ()
403
406
{
404
407
if (m_port == nullptr )
405
408
{
@@ -424,6 +427,24 @@ class MACsecOrchContext
424
427
return m_port.get ();
425
428
}
426
429
430
+ private:
431
+ MACsecOrchContext (MACsecOrch *orch) : m_orch(orch),
432
+ m_port_name (nullptr ),
433
+ m_direction(SAI_MACSEC_DIRECTION_EGRESS),
434
+ m_sci(nullptr ),
435
+ m_an(nullptr ),
436
+ m_port(nullptr ),
437
+ m_macsec_obj(nullptr ),
438
+ m_port_id(nullptr ),
439
+ m_switch_id(nullptr ),
440
+ m_macsec_port(nullptr ),
441
+ m_acl_table(nullptr ),
442
+ m_macsec_sc(nullptr ),
443
+ m_macsec_sa(nullptr ),
444
+ m_gearbox_phy(nullptr )
445
+ {
446
+ }
447
+
427
448
MACsecOrch *m_orch;
428
449
std::shared_ptr<std::string> m_port_name;
429
450
sai_macsec_direction_t m_direction;
@@ -440,6 +461,7 @@ class MACsecOrchContext
440
461
441
462
MACsecOrch::MACsecSC *m_macsec_sc;
442
463
sai_object_id_t *m_macsec_sa;
464
+ const gearbox_phy_t *m_gearbox_phy;
443
465
};
444
466
445
467
/* MACsec Orchagent */
@@ -592,7 +614,9 @@ task_process_status MACsecOrch::taskUpdateMACsecPort(
592
614
port_attr,
593
615
*ctx.get_macsec_obj (),
594
616
*ctx.get_port_id (),
595
- *ctx.get_switch_id ()))
617
+ *ctx.get_switch_id (),
618
+ *ctx.get_port (),
619
+ ctx.get_gearbox_phy ()))
596
620
{
597
621
return task_failed;
598
622
}
@@ -602,7 +626,9 @@ task_process_status MACsecOrch::taskUpdateMACsecPort(
602
626
*macsec_port_itr->second ,
603
627
port_name,
604
628
*ctx.get_macsec_obj (),
605
- *ctx.get_port_id ());
629
+ *ctx.get_port_id (),
630
+ *ctx.get_port (),
631
+ ctx.get_gearbox_phy ());
606
632
});
607
633
}
608
634
if (!updateMACsecPort (*ctx.get_macsec_port (), port_attr))
@@ -644,7 +670,9 @@ task_process_status MACsecOrch::taskDisableMACsecPort(
644
670
*ctx.get_macsec_port (),
645
671
port_name,
646
672
*ctx.get_macsec_obj (),
647
- *ctx.get_port_id ()))
673
+ *ctx.get_port_id (),
674
+ *ctx.get_port (),
675
+ ctx.get_gearbox_phy ()))
648
676
{
649
677
result = task_failed;
650
678
}
@@ -906,16 +934,18 @@ bool MACsecOrch::createMACsecPort(
906
934
const std::string &port_name,
907
935
const TaskArgs &port_attr,
908
936
const MACsecObject &macsec_obj,
909
- sai_object_id_t line_port_id,
910
- sai_object_id_t switch_id)
937
+ sai_object_id_t port_id,
938
+ sai_object_id_t switch_id,
939
+ Port &port,
940
+ const gearbox_phy_t * phy)
911
941
{
912
942
SWSS_LOG_ENTER ();
913
943
914
944
RecoverStack recover;
915
945
916
946
if (!createMACsecPort (
917
947
macsec_port.m_egress_port_id ,
918
- line_port_id ,
948
+ port_id ,
919
949
switch_id,
920
950
SAI_MACSEC_DIRECTION_EGRESS))
921
951
{
@@ -929,7 +959,7 @@ bool MACsecOrch::createMACsecPort(
929
959
930
960
if (!createMACsecPort (
931
961
macsec_port.m_ingress_port_id ,
932
- line_port_id ,
962
+ port_id ,
933
963
switch_id,
934
964
SAI_MACSEC_DIRECTION_INGRESS))
935
965
{
@@ -982,38 +1012,52 @@ bool MACsecOrch::createMACsecPort(
982
1012
983
1013
if (!initMACsecACLTable (
984
1014
macsec_port.m_egress_acl_table ,
985
- line_port_id ,
1015
+ port_id ,
986
1016
switch_id,
987
1017
SAI_MACSEC_DIRECTION_EGRESS,
988
1018
macsec_port.m_sci_in_sectag ))
989
1019
{
990
1020
SWSS_LOG_WARN (" Cannot init the ACL Table at the port %s." , port_name.c_str ());
991
1021
return false ;
992
1022
}
993
- recover.add_action ([this , &macsec_port, line_port_id ]() {
1023
+ recover.add_action ([this , &macsec_port, port_id ]() {
994
1024
this ->deinitMACsecACLTable (
995
1025
macsec_port.m_egress_acl_table ,
996
- line_port_id ,
1026
+ port_id ,
997
1027
SAI_MACSEC_DIRECTION_EGRESS);
998
1028
});
999
1029
1000
1030
if (!initMACsecACLTable (
1001
1031
macsec_port.m_ingress_acl_table ,
1002
- line_port_id ,
1032
+ port_id ,
1003
1033
switch_id,
1004
1034
SAI_MACSEC_DIRECTION_INGRESS,
1005
1035
macsec_port.m_sci_in_sectag ))
1006
1036
{
1007
1037
SWSS_LOG_WARN (" Cannot init the ACL Table at the port %s." , port_name.c_str ());
1008
1038
return false ;
1009
1039
}
1010
- recover.add_action ([this , &macsec_port, line_port_id ]() {
1040
+ recover.add_action ([this , &macsec_port, port_id ]() {
1011
1041
this ->deinitMACsecACLTable (
1012
1042
macsec_port.m_ingress_acl_table ,
1013
- line_port_id ,
1043
+ port_id ,
1014
1044
SAI_MACSEC_DIRECTION_INGRESS);
1015
1045
});
1016
1046
1047
+ if (phy && phy->macsec_ipg != 0 )
1048
+ {
1049
+ if (!m_port_orch->getPortIPG (port.m_port_id , macsec_port.m_original_ipg ))
1050
+ {
1051
+ SWSS_LOG_WARN (" Cannot get Port IPG at the port %s" , port_name.c_str ());
1052
+ return false ;
1053
+ }
1054
+ if (!m_port_orch->setPortIPG (port.m_port_id , phy->macsec_ipg ))
1055
+ {
1056
+ SWSS_LOG_WARN (" Cannot set MACsec IPG to %u at the port %s" , phy->macsec_ipg , port_name.c_str ());
1057
+ return false ;
1058
+ }
1059
+ }
1060
+
1017
1061
SWSS_LOG_NOTICE (" MACsec port %s is created." , port_name.c_str ());
1018
1062
1019
1063
std::vector<FieldValueTuple> fvVector;
@@ -1026,7 +1070,7 @@ bool MACsecOrch::createMACsecPort(
1026
1070
1027
1071
bool MACsecOrch::createMACsecPort (
1028
1072
sai_object_id_t &macsec_port_id,
1029
- sai_object_id_t line_port_id ,
1073
+ sai_object_id_t port_id ,
1030
1074
sai_object_id_t switch_id,
1031
1075
sai_macsec_direction_t direction)
1032
1076
{
@@ -1039,7 +1083,7 @@ bool MACsecOrch::createMACsecPort(
1039
1083
attr.value .s32 = direction;
1040
1084
attrs.push_back (attr);
1041
1085
attr.id = SAI_MACSEC_PORT_ATTR_PORT_ID;
1042
- attr.value .oid = line_port_id ;
1086
+ attr.value .oid = port_id ;
1043
1087
attrs.push_back (attr);
1044
1088
sai_status_t status = sai_macsec_api->create_macsec_port (
1045
1089
&macsec_port_id,
@@ -1141,7 +1185,9 @@ bool MACsecOrch::deleteMACsecPort(
1141
1185
const MACsecPort &macsec_port,
1142
1186
const std::string &port_name,
1143
1187
const MACsecObject &macsec_obj,
1144
- sai_object_id_t line_port_id)
1188
+ sai_object_id_t port_id,
1189
+ Port &port,
1190
+ const gearbox_phy_t * phy)
1145
1191
{
1146
1192
SWSS_LOG_ENTER ();
1147
1193
@@ -1179,13 +1225,13 @@ bool MACsecOrch::deleteMACsecPort(
1179
1225
}
1180
1226
}
1181
1227
1182
- if (!deinitMACsecACLTable (macsec_port.m_ingress_acl_table , line_port_id , SAI_MACSEC_DIRECTION_INGRESS))
1228
+ if (!deinitMACsecACLTable (macsec_port.m_ingress_acl_table , port_id , SAI_MACSEC_DIRECTION_INGRESS))
1183
1229
{
1184
1230
SWSS_LOG_WARN (" Cannot deinit ingress ACL table at the port %s." , port_name.c_str ());
1185
1231
result &= false ;
1186
1232
}
1187
1233
1188
- if (!deinitMACsecACLTable (macsec_port.m_egress_acl_table , line_port_id , SAI_MACSEC_DIRECTION_EGRESS))
1234
+ if (!deinitMACsecACLTable (macsec_port.m_egress_acl_table , port_id , SAI_MACSEC_DIRECTION_EGRESS))
1189
1235
{
1190
1236
SWSS_LOG_WARN (" Cannot deinit egress ACL table at the port %s." , port_name.c_str ());
1191
1237
result &= false ;
@@ -1203,6 +1249,15 @@ bool MACsecOrch::deleteMACsecPort(
1203
1249
result &= false ;
1204
1250
}
1205
1251
1252
+ if (phy && phy->macsec_ipg != 0 )
1253
+ {
1254
+ if (!m_port_orch->setPortIPG (port.m_port_id , macsec_port.m_original_ipg ))
1255
+ {
1256
+ SWSS_LOG_WARN (" Cannot set MACsec IPG to %u at the port %s" , macsec_port.m_original_ipg , port_name.c_str ());
1257
+ result &= false ;
1258
+ }
1259
+ }
1260
+
1206
1261
m_state_macsec_port.del (port_name);
1207
1262
1208
1263
return true ;
0 commit comments