@@ -412,6 +412,7 @@ bool PortsOrch::getPortByBridgePortId(sai_object_id_t bridge_port_id, Port &port
412
412
return false ;
413
413
}
414
414
415
+ // TODO: move this into AclOrch
415
416
bool PortsOrch::getAclBindPortId (string alias, sai_object_id_t &port_id)
416
417
{
417
418
SWSS_LOG_ENTER ();
@@ -651,21 +652,20 @@ bool PortsOrch::bindAclTable(sai_object_id_t id, sai_object_id_t table_oid, sai_
651
652
652
653
if (acl_stage == ACL_STAGE_UNKNOWN)
653
654
{
654
- SWSS_LOG_ERROR (" Unknown Acl stage for Acl table %lx" , table_oid);
655
+ SWSS_LOG_ERROR (" Unknown ACL stage for ACL table %lx" , table_oid);
655
656
return false ;
656
657
}
657
658
658
659
sai_status_t status;
659
660
sai_object_id_t groupOid;
660
661
661
- Port p ;
662
- if (!getPort (id, p ))
662
+ Port port ;
663
+ if (!getPort (id, port ))
663
664
{
665
+ SWSS_LOG_ERROR (" Failed to get port by port ID %lx" , id);
664
666
return false ;
665
667
}
666
668
667
- auto &port = m_portList.find (p.m_alias )->second ;
668
-
669
669
if (acl_stage == ACL_STAGE_INGRESS && port.m_ingress_acl_table_group_id != 0 )
670
670
{
671
671
groupOid = port.m_ingress_acl_table_group_id ;
@@ -674,19 +674,14 @@ bool PortsOrch::bindAclTable(sai_object_id_t id, sai_object_id_t table_oid, sai_
674
674
{
675
675
groupOid = port.m_egress_acl_table_group_id ;
676
676
}
677
+ // If port ACL table group does not exist, create one
677
678
else if (acl_stage == ACL_STAGE_INGRESS or acl_stage == ACL_STAGE_EGRESS)
678
679
{
679
680
bool ingress = acl_stage == ACL_STAGE_INGRESS ? true : false ;
680
- // If port ACL table group does not exist, create one
681
-
682
- Port p;
683
- if (!getPort (id, p))
684
- {
685
- return false ;
686
- }
687
681
688
682
sai_acl_bind_point_type_t bind_type;
689
- switch (p.m_type ) {
683
+ switch (port.m_type )
684
+ {
690
685
case Port::PHY:
691
686
bind_type = SAI_ACL_BIND_POINT_TYPE_PORT;
692
687
break ;
@@ -697,7 +692,8 @@ bool PortsOrch::bindAclTable(sai_object_id_t id, sai_object_id_t table_oid, sai_
697
692
bind_type = SAI_ACL_BIND_POINT_TYPE_VLAN;
698
693
break ;
699
694
default :
700
- SWSS_LOG_ERROR (" Failed to bind ACL table to port %s with unknown type %d" , p.m_alias .c_str (), p.m_type );
695
+ SWSS_LOG_ERROR (" Failed to bind ACL table to port %s with unknown type %d" ,
696
+ port.m_alias .c_str (), port.m_type );
701
697
return false ;
702
698
}
703
699
@@ -735,60 +731,65 @@ bool PortsOrch::bindAclTable(sai_object_id_t id, sai_object_id_t table_oid, sai_
735
731
port.m_egress_acl_table_group_id = groupOid;
736
732
}
737
733
734
+ setPort (port.m_alias , port);
735
+
738
736
gCrmOrch ->incCrmAclUsedCounter (CrmResourceType::CRM_ACL_GROUP, ingress ? SAI_ACL_STAGE_INGRESS : SAI_ACL_STAGE_EGRESS, SAI_ACL_BIND_POINT_TYPE_PORT);
739
737
740
738
switch (port.m_type )
741
739
{
742
- case Port::PHY:
743
- {
744
- // Bind this ACL group to physical port
745
- sai_attribute_t port_attr;
746
- port_attr.id = ingress ? SAI_PORT_ATTR_INGRESS_ACL : SAI_PORT_ATTR_EGRESS_ACL;
747
- port_attr.value .oid = groupOid;
748
-
749
- status = sai_port_api->set_port_attribute (port.m_port_id , &port_attr);
750
- if (status != SAI_STATUS_SUCCESS)
740
+ case Port::PHY:
751
741
{
752
- SWSS_LOG_ERROR (" Failed to bind port %s to ACL table group %lx, rv:%d" ,
753
- port.m_alias .c_str (), groupOid, status);
754
- return status;
755
- }
756
- break ;
757
- }
758
- case Port::LAG:
759
- {
760
- // Bind this ACL group to LAG
761
- sai_attribute_t lag_attr;
762
- lag_attr.id = ingress ? SAI_LAG_ATTR_INGRESS_ACL : SAI_LAG_ATTR_EGRESS_ACL;
763
- lag_attr.value .oid = groupOid;
742
+ // Bind this ACL group to physical port
743
+ sai_attribute_t port_attr;
744
+ port_attr.id = ingress ? SAI_PORT_ATTR_INGRESS_ACL : SAI_PORT_ATTR_EGRESS_ACL;
745
+ port_attr.value .oid = groupOid;
764
746
765
- status = sai_lag_api->set_lag_attribute (port.m_lag_id , &lag_attr);
766
- if (status != SAI_STATUS_SUCCESS)
747
+ status = sai_port_api->set_port_attribute (port.m_port_id , &port_attr);
748
+ if (status != SAI_STATUS_SUCCESS)
749
+ {
750
+ SWSS_LOG_ERROR (" Failed to bind port %s to ACL table group %lx, rv:%d" ,
751
+ port.m_alias .c_str (), groupOid, status);
752
+ return status;
753
+ }
754
+ break ;
755
+ }
756
+ case Port::LAG:
767
757
{
768
- SWSS_LOG_ERROR (" Failed to bind LAG %s to ACL table group %lx, rv:%d" ,
769
- port.m_alias .c_str (), groupOid, status);
770
- return status;
758
+ // Bind this ACL group to LAG
759
+ sai_attribute_t lag_attr;
760
+ lag_attr.id = ingress ? SAI_LAG_ATTR_INGRESS_ACL : SAI_LAG_ATTR_EGRESS_ACL;
761
+ lag_attr.value .oid = groupOid;
762
+
763
+ status = sai_lag_api->set_lag_attribute (port.m_lag_id , &lag_attr);
764
+ if (status != SAI_STATUS_SUCCESS)
765
+ {
766
+ SWSS_LOG_ERROR (" Failed to bind LAG %s to ACL table group %lx, rv:%d" ,
767
+ port.m_alias .c_str (), groupOid, status);
768
+ return status;
769
+ }
770
+ break ;
771
771
}
772
- break ;
773
- }
774
- case Port::VLAN:
775
- // Bind this ACL group to VLAN
776
- sai_attribute_t vlan_attr;
777
- vlan_attr.id = ingress ? SAI_VLAN_ATTR_INGRESS_ACL : SAI_VLAN_ATTR_EGRESS_ACL;
778
- vlan_attr.value .oid = groupOid;
772
+ case Port::VLAN:
773
+ {
774
+ // Bind this ACL group to VLAN
775
+ sai_attribute_t vlan_attr;
776
+ vlan_attr.id = ingress ? SAI_VLAN_ATTR_INGRESS_ACL : SAI_VLAN_ATTR_EGRESS_ACL;
777
+ vlan_attr.value .oid = groupOid;
779
778
780
- status = sai_vlan_api->set_vlan_attribute (port.m_vlan_info .vlan_oid , &vlan_attr);
781
- if (status != SAI_STATUS_SUCCESS)
779
+ status = sai_vlan_api->set_vlan_attribute (port.m_vlan_info .vlan_oid , &vlan_attr);
780
+ if (status != SAI_STATUS_SUCCESS)
781
+ {
782
+ SWSS_LOG_ERROR (" Failed to bind VLAN %s to ACL table group %lx, rv:%d" ,
783
+ port.m_alias .c_str (), groupOid, status);
784
+ return status;
785
+ }
786
+ break ;
787
+ }
788
+ default :
782
789
{
783
- SWSS_LOG_ERROR (" Failed to bind VLAN %s to ACL table group %lx, rv:%d" ,
784
- port.m_alias .c_str (), groupOid, status);
785
- return status;
790
+ SWSS_LOG_ERROR (" Failed to bind %s port with type %d" , port.m_alias .c_str (), port.m_type );
791
+ return SAI_STATUS_FAILURE;
786
792
}
787
-
788
- break ;
789
- default :
790
- SWSS_LOG_ERROR (" Failed to bind %s port with type %d" , port.m_alias .c_str (), port.m_type );
791
- return SAI_STATUS_FAILURE;
792
793
}
793
794
794
795
SWSS_LOG_NOTICE (" Create ACL table group and bind port %s to it" , port.m_alias .c_str ());
@@ -811,7 +812,8 @@ bool PortsOrch::bindAclTable(sai_object_id_t id, sai_object_id_t table_oid, sai_
811
812
member_attrs.push_back (member_attr);
812
813
813
814
status = sai_acl_api->create_acl_table_group_member (&group_member_oid, gSwitchId , (uint32_t )member_attrs.size (), member_attrs.data ());
814
- if (status != SAI_STATUS_SUCCESS) {
815
+ if (status != SAI_STATUS_SUCCESS)
816
+ {
815
817
SWSS_LOG_ERROR (" Failed to create member in ACL table group %lx for ACL table group %lx, rv:%d" ,
816
818
table_oid, groupOid, status);
817
819
return false ;
@@ -2994,4 +2996,4 @@ void PortsOrch::refreshPortStatus()
2994
2996
updatePortOperStatus (p, status);
2995
2997
}
2996
2998
}
2997
- }
2999
+ }
0 commit comments