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
1 change: 1 addition & 0 deletions orchagent/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ orchagent_SOURCES = \
dash/dashtunnelorch.cpp \
dash/pbutils.cpp \
dash/dashhaorch.cpp \
dash/dashportmaporch.cpp \
twamporch.cpp \
stporch.cpp

Expand Down
64 changes: 62 additions & 2 deletions orchagent/bulker.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ typedef sai_status_t (*sai_bulk_set_inbound_routing_entry_attribute_fn) (
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

typedef sai_status_t (*sai_bulk_set_outbound_port_map_port_range_entry_attribute_fn) (
_In_ uint32_t object_count,
_In_ const sai_outbound_port_map_port_range_entry_t *entry,
_In_ const sai_attribute_t *attr_list,
_In_ sai_bulk_op_error_mode_t mode,
_Out_ sai_status_t *object_statuses);

static inline bool operator==(const sai_ip_prefix_t& a, const sai_ip_prefix_t& b)
{
if (a.addr_family != b.addr_family) return false;
Expand Down Expand Up @@ -139,6 +146,15 @@ static inline bool operator==(const sai_outbound_routing_entry_t& a, const sai_o
;
}

static inline bool operator==(const sai_outbound_port_map_port_range_entry_t& a, const sai_outbound_port_map_port_range_entry_t& b)
{
return a.switch_id == b.switch_id
&& a.outbound_port_map_id == b.outbound_port_map_id
&& a.dst_port_range.min == b.dst_port_range.min
&& a.dst_port_range.max == b.dst_port_range.max
;
}

static inline std::size_t hash_value(const sai_ip_prefix_t& a)
{
size_t seed = 0;
Expand Down Expand Up @@ -276,6 +292,20 @@ namespace std
return seed;
}
};

template <>
struct hash<sai_outbound_port_map_port_range_entry_t>
{
size_t operator()(const sai_outbound_port_map_port_range_entry_t& a) const noexcept
{
size_t seed = 0;
boost::hash_combine(seed, a.switch_id);
boost::hash_combine(seed, a.outbound_port_map_id);
boost::hash_combine(seed, a.dst_port_range.min);
boost::hash_combine(seed, a.dst_port_range.max);
return seed;
}
};
}

// SAI typedef which is not available in SAI 1.5
Expand Down Expand Up @@ -467,6 +497,19 @@ struct SaiBulkerTraits<sai_dash_tunnel_api_t>
using bulk_remove_entry_fn = sai_bulk_object_remove_fn;
};

template<>
struct SaiBulkerTraits<sai_dash_outbound_port_map_api_t>
{
// Need to bulk port map objects and port map range entries from the same DASH API
// entry_t, bulk_create/remove_entry_fn are only used by EntityBulker so we can use them for
// port map port range bulking w/o affecting port map object bulking
using api_t = sai_dash_outbound_port_map_api_t;
using entry_t = sai_outbound_port_map_port_range_entry_t;
using bulk_create_entry_fn = sai_bulk_create_outbound_port_map_port_range_entry_fn;
using bulk_remove_entry_fn = sai_bulk_remove_outbound_port_map_port_range_entry_fn;
using bulk_set_entry_attribute_fn = sai_bulk_set_outbound_port_map_port_range_entry_attribute_fn;
};

template <typename T>
class EntityBulker
{
Expand Down Expand Up @@ -921,6 +964,14 @@ inline EntityBulker<sai_dash_outbound_routing_api_t>::EntityBulker(sai_dash_outb
set_entries_attribute = nullptr;
}

template <>
inline EntityBulker<sai_dash_outbound_port_map_api_t>::EntityBulker(sai_dash_outbound_port_map_api_t *api, size_t max_bulk_size) : max_bulk_size(max_bulk_size)
{
create_entries = api->create_outbound_port_map_port_range_entries;
remove_entries = api->remove_outbound_port_map_port_range_entries;
set_entries_attribute = nullptr;
}

template <typename T>
class ObjectBulker
{
Expand Down Expand Up @@ -1146,8 +1197,8 @@ class ObjectBulker
// object_id -> object_status
std::unordered_map<sai_object_id_t, sai_status_t *> removing_entries;

typename Ts::bulk_create_entry_fn create_entries;
typename Ts::bulk_remove_entry_fn remove_entries;
sai_bulk_object_create_fn create_entries;
sai_bulk_object_remove_fn remove_entries;
// TODO: wait until available in SAI
//typename Ts::bulk_set_entry_attribute_fn set_entries_attribute;

Expand Down Expand Up @@ -1321,3 +1372,12 @@ inline ObjectBulker<sai_dash_tunnel_api_t>::ObjectBulker(SaiBulkerTraits<sai_das
throw std::invalid_argument(ss.str());
}
}

template <>
inline ObjectBulker<sai_dash_outbound_port_map_api_t>::ObjectBulker(SaiBulkerTraits<sai_dash_outbound_port_map_api_t>::api_t *api, sai_object_id_t switch_id, size_t max_bulk_size) :
switch_id(switch_id),
max_bulk_size(max_bulk_size)
{
create_entries = api->create_outbound_port_maps;
remove_entries = api->remove_outbound_port_maps;
}
Loading
Loading