Skip to content

Commit

Permalink
Add missing object types to virtual switch (#364)
Browse files Browse the repository at this point in the history
Refactor common code
  • Loading branch information
kcudnik authored and lguohan committed Oct 29, 2018
1 parent 1fdaf47 commit 4d9aa18
Show file tree
Hide file tree
Showing 22 changed files with 1,613 additions and 324 deletions.
1,140 changes: 1,130 additions & 10 deletions meta/sai_meta.cpp

Large diffs are not rendered by default.

108 changes: 40 additions & 68 deletions meta/sai_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,74 +84,46 @@ extern sai_status_t meta_sai_get_stats_oid(
_Inout_ uint64_t *counter_list,
_In_ sai_get_generic_stats_fn<T> get);

// META FDB

extern sai_status_t meta_sai_create_fdb_entry(
_In_ const sai_fdb_entry_t* fdb_entry,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list,
_In_ sai_create_fdb_entry_fn create);

extern sai_status_t meta_sai_remove_fdb_entry(
_In_ const sai_fdb_entry_t* fdb_entry,
_In_ sai_remove_fdb_entry_fn remove);

extern sai_status_t meta_sai_set_fdb_entry(
_In_ const sai_fdb_entry_t* fdb_entry,
_In_ const sai_attribute_t *attr,
_In_ sai_set_fdb_entry_attribute_fn set);

extern sai_status_t meta_sai_get_fdb_entry(
_In_ const sai_fdb_entry_t* fdb_entry,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list,
_In_ sai_get_fdb_entry_attribute_fn get);

// META NEIGHBOR

extern sai_status_t meta_sai_create_neighbor_entry(
_In_ const sai_neighbor_entry_t* neighbor_entry,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list,
_In_ sai_create_neighbor_entry_fn create);

extern sai_status_t meta_sai_remove_neighbor_entry(
_In_ const sai_neighbor_entry_t* neighbor_entry,
_In_ sai_remove_neighbor_entry_fn remove);

extern sai_status_t meta_sai_set_neighbor_entry(
_In_ const sai_neighbor_entry_t* neighbor_entry,
_In_ const sai_attribute_t *attr,
_In_ sai_set_neighbor_entry_attribute_fn set);

extern sai_status_t meta_sai_get_neighbor_entry(
_In_ const sai_neighbor_entry_t* neighbor_entry,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list,
_In_ sai_get_neighbor_entry_attribute_fn get);

// META ROUTE

extern sai_status_t meta_sai_create_route_entry(
_In_ const sai_route_entry_t* route_entry,
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list,
_In_ sai_create_route_entry_fn create);

extern sai_status_t meta_sai_remove_route_entry(
_In_ const sai_route_entry_t* route_entry,
_In_ sai_remove_route_entry_fn remove);

extern sai_status_t meta_sai_set_route_entry(
_In_ const sai_route_entry_t* route_entry,
_In_ const sai_attribute_t *attr,
_In_ sai_set_route_entry_attribute_fn set);

extern sai_status_t meta_sai_get_route_entry(
_In_ const sai_route_entry_t* route_entry,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list,
_In_ sai_get_route_entry_attribute_fn get);
// META ENTRY QUAD

#define META_CREATE_ENTRY(ot) \
extern sai_status_t meta_sai_create_ ## ot( \
_In_ const sai_ ## ot ## _t* ot, \
_In_ uint32_t attr_count, \
_In_ const sai_attribute_t *attr_list, \
_In_ sai_create_ ## ot ## _fn create);

#define META_REMOVE_ENTRY(ot) \
extern sai_status_t meta_sai_remove_ ## ot( \
_In_ const sai_ ## ot ## _t* ot, \
_In_ sai_remove_ ## ot ##_fn remove);

#define META_SET_ENTRY(ot) \
extern sai_status_t meta_sai_set_ ## ot( \
_In_ const sai_ ## ot ## _t* ot, \
_In_ const sai_attribute_t *attr, \
_In_ sai_set_ ## ot ## _attribute_fn set);

#define META_GET_ENTRY(ot) \
extern sai_status_t meta_sai_get_ ## ot( \
_In_ const sai_ ## ot ## _t* ot, \
_In_ uint32_t attr_count, \
_Inout_ sai_attribute_t *attr_list, \
_In_ sai_get_ ## ot ## _attribute_fn get);

#define META_QUAD_ENTRY(ot) \
META_CREATE_ENTRY(ot); \
META_REMOVE_ENTRY(ot); \
META_SET_ENTRY(ot); \
META_GET_ENTRY(ot)

META_QUAD_ENTRY(fdb_entry);
META_QUAD_ENTRY(inseg_entry);
META_QUAD_ENTRY(ipmc_entry);
META_QUAD_ENTRY(l2mc_entry);
META_QUAD_ENTRY(mcast_fdb_entry);
META_QUAD_ENTRY(neighbor_entry);
META_QUAD_ENTRY(route_entry);

// NOTIFICATIONS

Expand Down
34 changes: 34 additions & 0 deletions meta/sai_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ std::string sai_serialize_neighbor_entry(
std::string sai_serialize_route_entry(
_In_ const sai_route_entry_t &route_entry);

std::string sai_serialize_inseg_entry(
_In_ const sai_inseg_entry_t &inseg_entry);

std::string sai_serialize_l2mc_entry(
_In_ const sai_l2mc_entry_t &l2mc_entry);

std::string sai_serialize_ipmc_entry(
_In_ const sai_ipmc_entry_t &ipmc_entry);

std::string sai_serialize_mcast_fdb_entry(
_In_ const sai_mcast_fdb_entry_t &mcast_fdb_entry);

std::string sai_serialize_fdb_entry(
_In_ const sai_fdb_entry_t &fdb_entry);

Expand Down Expand Up @@ -117,6 +129,12 @@ std::string sai_serialize_mac(
std::string sai_serialize_port_oper_status(
_In_ sai_port_oper_status_t status);

std::string sai_serialize_l2mc_entry_type(
_In_ const sai_l2mc_entry_type_t type);

std::string sai_serialize_ipmc_entry_type(
_In_ const sai_ipmc_entry_type_t type);

// serialize ntf

std::string sai_serialize_fdb_event_ntf(
Expand Down Expand Up @@ -171,6 +189,22 @@ void sai_deserialize_route_entry(
_In_ const std::string& s,
_In_ sai_route_entry_t &route_entry);

void sai_deserialize_inseg_entry(
_In_ const std::string& s,
_In_ sai_inseg_entry_t &inseg_entry);

void sai_deserialize_l2mc_entry(
_In_ const std::string& s,
_In_ sai_l2mc_entry_t &l2mc_entry);

void sai_deserialize_ipmc_entry(
_In_ const std::string& s,
_In_ sai_ipmc_entry_t &ipmc_entry);

void sai_deserialize_mcast_fdb_entry(
_In_ const std::string& s,
_In_ sai_mcast_fdb_entry_t &mcast_fdb_entry);

void sai_deserialize_vlan_id(
_In_ const std::string& s,
_In_ sai_vlan_id_t& vlan_id);
Expand Down
75 changes: 75 additions & 0 deletions meta/saiserialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,65 @@ std::string sai_serialize_route_entry(
return j.dump();
}

std::string sai_serialize_ipmc_entry(
_In_ const sai_ipmc_entry_t& ipmc_entry)
{
SWSS_LOG_ENTER();

json j;

j["switch_id"] = sai_serialize_object_id(ipmc_entry.switch_id);
j["vr_id"] = sai_serialize_object_id(ipmc_entry.vr_id);
j["type"] = sai_serialize_ipmc_entry_type(ipmc_entry.type);
j["destination"] = sai_serialize_ip_address(ipmc_entry.destination);
j["sourte"] = sai_serialize_ip_address(ipmc_entry.source);

return j.dump();
}

std::string sai_serialize_l2mc_entry(
_In_ const sai_l2mc_entry_t& l2mc_entry)
{
SWSS_LOG_ENTER();

json j;

j["switch_id"] = sai_serialize_object_id(l2mc_entry.switch_id);
j["bv_id"] = sai_serialize_object_id(l2mc_entry.bv_id);
j["type"] = sai_serialize_l2mc_entry_type(l2mc_entry.type);
j["destination"] = sai_serialize_ip_address(l2mc_entry.destination);
j["sourte"] = sai_serialize_ip_address(l2mc_entry.source);

return j.dump();
}

std::string sai_serialize_mcast_fdb_entry(
_In_ const sai_mcast_fdb_entry_t& mcast_fdb_entry)
{
SWSS_LOG_ENTER();

json j;

j["switch_id"] = sai_serialize_object_id(mcast_fdb_entry.switch_id);
j["bv_id"] = sai_serialize_object_id(mcast_fdb_entry.bv_id);
j["mac_address"] = sai_serialize_mac(mcast_fdb_entry.mac_address);

return j.dump();
}

std::string sai_serialize_inseg_entry(
_In_ const sai_inseg_entry_t& inseg_entry)
{
SWSS_LOG_ENTER();

json j;

j["switch_id"] = sai_serialize_object_id(inseg_entry.switch_id);
j["label"] = sai_serialize_number(inseg_entry.label);

return j.dump();
}

std::string sai_serialize_fdb_entry(
_In_ const sai_fdb_entry_t& fdb_entry)
{
Expand All @@ -723,6 +782,22 @@ std::string sai_serialize_fdb_entry(
return j.dump();
}

std::string sai_serialize_l2mc_entry_type(
_In_ const sai_l2mc_entry_type_t type)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(type, &sai_metadata_enum_sai_l2mc_entry_type_t);
}

std::string sai_serialize_ipmc_entry_type(
_In_ const sai_ipmc_entry_type_t type)
{
SWSS_LOG_ENTER();

return sai_serialize_enum(type, &sai_metadata_enum_sai_ipmc_entry_type_t);
}

std::string sai_serialize_port_stat(
_In_ const sai_port_stat_t counter)
{
Expand Down
Loading

0 comments on commit 4d9aa18

Please sign in to comment.