@@ -4737,3 +4737,154 @@ void meta_sai_on_fdb_event(
47374737 meta_sai_on_fdb_event_single (data[i]);
47384738 }
47394739}
4740+
4741+ // FDB FLUSH
4742+
4743+ sai_status_t meta_sai_flush_fdb_entries (
4744+ _In_ sai_object_id_t switch_id,
4745+ _In_ uint32_t attr_count,
4746+ _In_ const sai_attribute_t *attr_list,
4747+ _In_ sai_flush_fdb_entries_fn flush_fdb_entries)
4748+ {
4749+ SWSS_LOG_ENTER ();
4750+
4751+ if (flush_fdb_entries == NULL )
4752+ {
4753+ SWSS_LOG_ERROR (" function pointer is NULL" );
4754+
4755+ return SAI_STATUS_INVALID_PARAMETER;
4756+ }
4757+
4758+ if (attr_count > MAX_LIST_COUNT)
4759+ {
4760+ SWSS_LOG_ERROR (" create attribute count is too large %u > then max list count %u" , attr_count, MAX_LIST_COUNT);
4761+
4762+ return SAI_STATUS_INVALID_PARAMETER;
4763+ }
4764+
4765+ if (attr_count != 0 && attr_list == NULL )
4766+ {
4767+ SWSS_LOG_ERROR (" attribute list is NULL" );
4768+
4769+ return SAI_STATUS_INVALID_PARAMETER;
4770+ }
4771+
4772+ sai_object_type_t swot = sai_object_type_query (switch_id);
4773+
4774+ if (swot != SAI_OBJECT_TYPE_SWITCH)
4775+ {
4776+ SWSS_LOG_ERROR (" object type for switch_id %s is %s" ,
4777+ sai_serialize_object_id (switch_id).c_str (),
4778+ sai_serialize_object_type (swot).c_str ());
4779+
4780+ return SAI_STATUS_INVALID_PARAMETER;
4781+ }
4782+
4783+ if (!object_reference_exists (switch_id))
4784+ {
4785+ SWSS_LOG_ERROR (" switch id %s don't exists" ,
4786+ sai_serialize_object_id (switch_id).c_str ());
4787+
4788+ return SAI_STATUS_INVALID_PARAMETER;
4789+ }
4790+
4791+ // validate attributes
4792+ // - attribute list can be empty
4793+ // - validation is similar to "create" action but there is no
4794+ // post create step and no references are updated
4795+ // - fdb entries are updated in fdb notification
4796+
4797+ std::unordered_map<sai_attr_id_t , const sai_attribute_t *> attrs;
4798+
4799+ SWSS_LOG_DEBUG (" attr count = %u" , attr_count);
4800+
4801+ for (uint32_t idx = 0 ; idx < attr_count; ++idx)
4802+ {
4803+ const sai_attribute_t * attr = &attr_list[idx];
4804+
4805+ auto mdp = sai_metadata_get_attr_metadata (SAI_OBJECT_TYPE_FDB_FLUSH, attr->id );
4806+
4807+ if (mdp == NULL )
4808+ {
4809+ SWSS_LOG_ERROR (" unable to find attribute metadata SAI_OBJECT_TYPE_FDB_FLUSH:%d" , attr->id );
4810+
4811+ return SAI_STATUS_INVALID_PARAMETER;
4812+ }
4813+
4814+ const sai_attribute_value_t & value = attr->value ;
4815+
4816+ const sai_attr_metadata_t & md = *mdp;
4817+
4818+ META_LOG_DEBUG (md, " (fdbflush)" );
4819+
4820+ if (attrs.find (attr->id ) != attrs.end ())
4821+ {
4822+ META_LOG_ERROR (md, " attribute id (%u) is defined on attr list multiple times" , attr->id );
4823+
4824+ return SAI_STATUS_INVALID_PARAMETER;
4825+ }
4826+
4827+ attrs[attr->id ] = attr;
4828+
4829+ if (md.flags != SAI_ATTR_FLAGS_CREATE_ONLY)
4830+ {
4831+ META_LOG_ERROR (md, " attr is expected to be marked as CREATE_ONLY" );
4832+
4833+ return SAI_STATUS_INVALID_PARAMETER;
4834+ }
4835+
4836+ if (md.isconditional || md.validonlylength > 0 )
4837+ {
4838+ META_LOG_ERROR (md, " attr should not be conditional or validonly" );
4839+
4840+ return SAI_STATUS_INVALID_PARAMETER;
4841+ }
4842+
4843+ switch (md.attrvaluetype )
4844+ {
4845+ case SAI_ATTR_VALUE_TYPE_UINT16:
4846+
4847+ if (md.isvlan && (value.u16 >= 0xFFF || value.u16 == 0 ))
4848+ {
4849+ META_LOG_ERROR (md, " is vlan id but has invalid id %u" , value.u16 );
4850+
4851+ return SAI_STATUS_INVALID_PARAMETER;
4852+ }
4853+
4854+ break ;
4855+
4856+ case SAI_ATTR_VALUE_TYPE_INT32:
4857+
4858+ if (md.isenum && !sai_metadata_is_allowed_enum_value (&md, value.s32 ))
4859+ {
4860+ META_LOG_ERROR (md, " is enum, but value %d not found on allowed values list" , value.s32 );
4861+
4862+ return SAI_STATUS_INVALID_PARAMETER;
4863+ }
4864+
4865+ break ;
4866+
4867+ case SAI_ATTR_VALUE_TYPE_OBJECT_ID:
4868+
4869+ {
4870+ sai_status_t status = meta_generic_validation_objlist (md, switch_id, 1 , &value.oid );
4871+
4872+ if (status != SAI_STATUS_SUCCESS)
4873+ {
4874+ return status;
4875+ }
4876+
4877+ break ;
4878+ }
4879+
4880+ default :
4881+
4882+ META_LOG_THROW (md, " serialization type is not supported yet FIXME" );
4883+ }
4884+ }
4885+
4886+ // there are no mandatory attributes
4887+ // there are no conditional attributes
4888+
4889+ return flush_fdb_entries (switch_id, attr_count, attr_list);
4890+ }
0 commit comments