Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions vslib/vpp/SwitchVpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ SwitchVpp::SwitchVpp(
vpp_dp_initialize();
}

SwitchVpp::~SwitchVpp()
{
SWSS_LOG_ENTER();

// Signal the vpp events thread to stop
m_run_vpp_events_thread = false;

// Wait for the thread to finish gracefully
if (m_vpp_thread && m_vpp_thread->joinable()) {
m_vpp_thread->join();
}

SWSS_LOG_NOTICE("SwitchVpp destructor completed");
}

sai_status_t SwitchVpp::create_qos_queues_per_port(
_In_ sai_object_id_t port_id)
{
Expand Down Expand Up @@ -1219,6 +1234,49 @@ sai_status_t SwitchVpp::setPort(
return set_internal(SAI_OBJECT_TYPE_PORT, sid, attr);
}

sai_status_t SwitchVpp::setLag(
_In_ sai_object_id_t lagId,
_In_ const sai_attribute_t* lagAttr)
{
SWSS_LOG_ENTER();

auto attr_type = sai_metadata_get_attr_by_id(SAI_LAG_ATTR_INGRESS_ACL, 1, lagAttr);

if (attr_type != NULL)
{
if (attr_type->value.oid == SAI_NULL_OBJECT_ID) {
sai_attribute_t attr;

attr.id = SAI_LAG_ATTR_INGRESS_ACL;
if (get(SAI_OBJECT_TYPE_LAG, lagId, 1, &attr) != SAI_STATUS_SUCCESS) {
aclBindUnbindPort(lagId, attr.value.oid, true, false);
}
} else {
aclBindUnbindPort(lagId, attr_type->value.oid, true, true);
}
}

attr_type = sai_metadata_get_attr_by_id(SAI_LAG_ATTR_EGRESS_ACL, 1, lagAttr);

if (attr_type != NULL)
{
if (attr_type->value.oid == SAI_NULL_OBJECT_ID) {
sai_attribute_t attr;

attr.id = SAI_LAG_ATTR_EGRESS_ACL;
if (get(SAI_OBJECT_TYPE_LAG, lagId, 1, &attr) != SAI_STATUS_SUCCESS) {
aclBindUnbindPort(lagId, attr.value.oid, false, false);
}
} else {
aclBindUnbindPort(lagId, attr_type->value.oid, false, true);
}
}

auto sid = sai_serialize_object_id(lagId);

return set_internal(SAI_OBJECT_TYPE_LAG, sid, lagAttr);
}

sai_status_t SwitchVpp::setAclEntry(
_In_ sai_object_id_t entry_id,
_In_ const sai_attribute_t* attr)
Expand Down Expand Up @@ -1315,6 +1373,13 @@ sai_status_t SwitchVpp::set(
return setMACsecSA(objectId, attr);
}

if (objectType == SAI_OBJECT_TYPE_LAG)
{
sai_object_id_t objectId;
sai_deserialize_object_id(serializedObjectId, objectId);
return setLag(objectId, attr);
}

return set_internal(objectType, serializedObjectId, attr);
}

Expand Down
62 changes: 23 additions & 39 deletions vslib/vpp/SwitchVpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace saivs
_In_ std::shared_ptr<SwitchConfig> config,
_In_ std::shared_ptr<WarmBootState> warmBootState);

virtual ~SwitchVpp() = default;
virtual ~SwitchVpp();

protected:

Expand Down Expand Up @@ -247,6 +247,11 @@ namespace saivs
_In_ sai_object_id_t switch_id,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list);

virtual sai_status_t setLag(
_In_ sai_object_id_t lagId,
_In_ const sai_attribute_t* attr);

sai_status_t vpp_create_lag(
_In_ sai_object_id_t lag_id,
_In_ uint32_t attr_count,
Expand Down Expand Up @@ -604,7 +609,8 @@ namespace saivs
sai_object_id_t tbl_oid;
sai_object_id_t ace_oid;
uint32_t acl_index;
uint32_t ace_index;
uint32_t vpp_rule_base_index;
uint32_t num_rules;

} vpp_ace_cntr_info_t;

Expand All @@ -616,6 +622,9 @@ namespace saivs
std::map<sai_object_id_t, std::list<sai_object_id_t>> m_acl_tbl_grp_ports_map;
std::map<sai_object_id_t, vpp_ace_cntr_info_t> m_ace_cntr_info_map;

uint32_t m_acl_default_swindex = 0;
bool m_acl_default_created = false;

protected: // VPP

sai_status_t createAclEntry(
Expand Down Expand Up @@ -677,19 +686,21 @@ namespace saivs
_In_ vpp_tunterm_acl_t *&tunterm_acl);

/**
* @brief Fills ACL and tunnel termination ACL rules based on the provided ACEs.
* @brief Converts ACE entries into ACL and tunnel termination ACL rules.
*
* @param[in] aces Pointer to ACEs.
* @param[in] ordered_aces Reference to Ordered ACE list.
* @param[in] acl Pointer to the allocated VS ACL.
* @param[in] tunterm_acl Pointer to the allocated VS tunnel termination ACL.
* @param[out] acl_rules Reference to list of converted ACL rules.
* @param[out] tunterm_acl_rules Reference to list of converted tunnel termination ACL rules.
* @return SAI_STATUS_SUCCESS on success, or an appropriate error code otherwise.
*
* @note If protocol is not set but port or port_range is set, creates 2 rules: one with UDP and one with TCP.
*/
sai_status_t fill_acl_rules(
_In_ acl_tbl_entries_t *aces,
_In_ std::list<ordered_ace_list_t> &ordered_aces,
_In_ vpp_acl_t *acl,
_In_ vpp_tunterm_acl_t *tunterm_acl);
_Out_ std::list<vpp_acl_rule_t> &acl_rules,
_Out_ std::list<vpp_tunterm_acl_rule_t> &tunterm_acl_rules);

/**
* @brief Creates or replaces the provided ACL in VS.
Expand All @@ -706,36 +717,6 @@ namespace saivs
_In_ acl_tbl_entries_t *aces,
_In_ std::list<ordered_ace_list_t> &ordered_aces);

/**
* @brief Allocates memory for VS ACL.
*
* @param[in] n_entries Number of entries in the ACL.
* @param[in] tbl_oid Object ID of the table to which the ACL belongs.
* @param[out] acl_name Name of the allocated ACL.
* @param[out] acl Pointer to the allocated ACL.
* @return SAI_STATUS_SUCCESS on success, or an appropriate error code otherwise.
*/
sai_status_t allocate_acl(
_In_ size_t n_entries,
_In_ sai_object_id_t tbl_oid,
_Out_ char (&acl_name)[64],
_Out_ vpp_acl_t *&acl);

/**
* @brief Allocates memory for VS tunnel termination ACL.
*
* @param[in] n_tunterm_entries Number of tunnel termination entries to allocate.
* @param[in] tbl_oid Object ID of the ACL table.
* @param[out] acl_name Name of the allocated ACL.
* @param[out] tunterm_acl Pointer to the allocated tunnel termination ACL.
* @return SAI_STATUS_SUCCESS on success, or an appropriate error code otherwise.
*/
sai_status_t allocate_tunterm_acl(
_In_ size_t n_tunterm_entries,
_In_ sai_object_id_t tbl_oid,
_Out_ char (&acl_name)[64],
_Out_ vpp_tunterm_acl_t *&tunterm_acl);

/**
* @brief Counts the total number of ACL rules and tunnel termination ACL rules, and sets is_tunterm in the ordered ACE list.
*
Expand Down Expand Up @@ -826,9 +807,11 @@ namespace saivs
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list);

sai_status_t aclDefaultAllowConfigure(
sai_status_t emptyAclCreate(
_In_ sai_object_id_t tbl_oid);

sai_status_t aclDefaultCreate();

sai_status_t acl_rule_range_get(
_In_ const sai_object_list_t *range_list,
_Out_ sai_u32_range_t *range_limit_list,
Expand Down Expand Up @@ -892,7 +875,8 @@ namespace saivs
sai_status_t aclGetVppIndices(
_In_ sai_object_id_t ace_oid,
_Out_ uint32_t *acl_index,
_Out_ uint32_t *ace_index);
_Out_ uint32_t *vpp_rule_base_index,
_Out_ uint32_t *num_rules);

bool vpp_get_hwif_name (
_In_ sai_object_id_t object_id,
Expand Down
Loading
Loading