Skip to content

Commit

Permalink
[vslib]: MACsec in Gearbox (#993)
Browse files Browse the repository at this point in the history
Add the placeholders of MACsec SAI in Gearbox BCM81724.

We don't really implement the MACsec in Gearbox but just make all MACsec related APIs in SAI that can be called successfully in SWSS.
  • Loading branch information
Pterosaur authored Mar 14, 2022
1 parent 7a2b824 commit 1ccda8d
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
101 changes: 101 additions & 0 deletions vslib/SwitchBCM81724.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,77 @@ sai_status_t SwitchBCM81724::initialize_default_objects(

CHECK_STATUS(set_switch_default_attributes());
CHECK_STATUS(create_default_trap_group());
CHECK_STATUS(set_acl_entry_min_prio());

return SAI_STATUS_SUCCESS;
}

sai_status_t SwitchBCM81724::set(
_In_ sai_object_type_t objectType,
_In_ sai_object_id_t objectId,
_In_ const sai_attribute_t* attr)
{
SWSS_LOG_ENTER();

return SwitchStateBase::set(objectType, objectId, attr);
}

sai_status_t SwitchBCM81724::create(
_In_ sai_object_type_t object_type,
_In_ const std::string &serializedObjectId,
_In_ sai_object_id_t switch_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list)
{
SWSS_LOG_ENTER();

// Bypass MACsec creating because the existing implementation of MACsec cannot be directly used by Gearbox
if (is_macsec_type(object_type))
{
SWSS_LOG_INFO("Bypass creating %s", sai_serialize_object_type(object_type));

return create_internal(object_type, serializedObjectId, switch_id, attr_count, attr_list);
}

return SwitchStateBase::create(object_type, serializedObjectId, switch_id, attr_count, attr_list);
}

sai_status_t SwitchBCM81724::remove(
_In_ sai_object_type_t object_type,
_In_ const std::string &serializedObjectId)
{
SWSS_LOG_ENTER();

// Bypass MACsec removing because the existing implementation of MACsec cannot be directly used by Gearbox
if (is_macsec_type(object_type))
{
SWSS_LOG_INFO("Bypass removing %s", sai_serialize_object_type(object_type));

return remove_internal(object_type, serializedObjectId);
}

return SwitchStateBase::remove(object_type, serializedObjectId);
}

sai_status_t SwitchBCM81724::set(
_In_ sai_object_type_t objectType,
_In_ const std::string &serializedObjectId,
_In_ const sai_attribute_t* attr)
{
SWSS_LOG_ENTER();

// Bypass MACsec setting because the existing implementation of MACsec cannot be directly used by Gearbox
if (is_macsec_type(objectType) ||
(objectType == SAI_OBJECT_TYPE_ACL_ENTRY && attr && attr->id == SAI_ACL_ENTRY_ATTR_ACTION_MACSEC_FLOW))
{
SWSS_LOG_INFO("Bypass setting %s", sai_serialize_object_type(objectType));

return set_internal(objectType, serializedObjectId, attr);;
}

return SwitchStateBase::set(objectType, serializedObjectId, attr);
}

sai_status_t SwitchBCM81724::refresh_port_list(
_In_ const sai_attr_metadata_t *meta)
{
Expand Down Expand Up @@ -183,6 +250,10 @@ sai_status_t SwitchBCM81724::refresh_read_only(
case SAI_SWITCH_ATTR_DEFAULT_TRAP_GROUP:
case SAI_SWITCH_ATTR_FIRMWARE_MAJOR_VERSION:
return SAI_STATUS_SUCCESS;

case SAI_SWITCH_ATTR_ACL_ENTRY_MINIMUM_PRIORITY:
case SAI_SWITCH_ATTR_ACL_ENTRY_MAXIMUM_PRIORITY:
return SAI_STATUS_SUCCESS;
}
}

Expand Down Expand Up @@ -211,6 +282,16 @@ sai_status_t SwitchBCM81724::refresh_read_only(
return SAI_STATUS_SUCCESS; // XXX not sure for gearbox
}

if (meta->objecttype == SAI_OBJECT_TYPE_MACSEC && meta->attrid == SAI_MACSEC_ATTR_SCI_IN_INGRESS_MACSEC_ACL)
{
return refresh_macsec_sci_in_ingress_macsec_acl(object_id);
}

if (meta->objecttype == SAI_OBJECT_TYPE_MACSEC_SA)
{
return refresh_macsec_sa_stat(object_id);
}

auto mmeta = m_meta.lock();

if (mmeta)
Expand Down Expand Up @@ -254,3 +335,23 @@ sai_status_t SwitchBCM81724::warm_boot_initialize_objects()

return SAI_STATUS_NOT_IMPLEMENTED;
}

bool SwitchBCM81724::is_macsec_type(_In_ sai_object_type_t object_type)
{
SWSS_LOG_ENTER();

switch(object_type)
{
case SAI_OBJECT_TYPE_MACSEC_PORT:

case SAI_OBJECT_TYPE_MACSEC_SC:

case SAI_OBJECT_TYPE_MACSEC_SA:

return true;

default: break;
}

return false;
}
29 changes: 29 additions & 0 deletions vslib/SwitchBCM81724.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@ namespace saivs

virtual sai_status_t create_default_trap_group() override;

protected:

virtual sai_status_t set(
_In_ sai_object_type_t objectType,
_In_ sai_object_id_t objectId,
_In_ const sai_attribute_t* attr);

public:

virtual sai_status_t create(
_In_ sai_object_type_t object_type,
_In_ const std::string &serializedObjectId,
_In_ sai_object_id_t switch_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list) override;

virtual sai_status_t remove(
_In_ sai_object_type_t object_type,
_In_ const std::string &serializedObjectId) override;

virtual sai_status_t set(
_In_ sai_object_type_t objectType,
_In_ const std::string &serializedObjectId,
_In_ const sai_attribute_t* attr) override;

protected : // refresh

virtual sai_status_t refresh_port_list(
Expand All @@ -49,5 +74,9 @@ namespace saivs
_In_ const sai_attribute_t *attr_list) override;

virtual sai_status_t warm_boot_initialize_objects() override;

private:

bool is_macsec_type(_In_ sai_object_type_t object_type);
};
}

0 comments on commit 1ccda8d

Please sign in to comment.