Skip to content

Commit 04912ad

Browse files
authored
[bulker] add support for neighbor bulking (#2768)
Adding support for sai_neighbor_api_t bulking in bulker.h
1 parent 9d4a3ad commit 04912ad

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

orchagent/bulker.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ static inline bool operator==(const sai_inseg_entry_t& a, const sai_inseg_entry_
9696
;
9797
}
9898

99+
static inline bool operator==(const sai_neighbor_entry_t& a, const sai_neighbor_entry_t& b)
100+
{
101+
return a.switch_id == b.switch_id
102+
&& a.rif_id == b.rif_id
103+
&& a.ip_address == b.ip_address
104+
;
105+
}
106+
99107
static inline bool operator==(const sai_inbound_routing_entry_t& a, const sai_inbound_routing_entry_t& b)
100108
{
101109
return a.switch_id == b.switch_id
@@ -203,6 +211,19 @@ namespace std
203211
}
204212
};
205213

214+
template <>
215+
struct hash<sai_neighbor_entry_t>
216+
{
217+
size_t operator()(const sai_neighbor_entry_t& a) const noexcept
218+
{
219+
size_t seed = 0;
220+
boost::hash_combine(seed, a.switch_id);
221+
boost::hash_combine(seed, a.rif_id);
222+
boost::hash_combine(seed, a.ip_address);
223+
return seed;
224+
}
225+
};
226+
206227
template <>
207228
struct hash<sai_outbound_ca_to_pa_entry_t>
208229
{
@@ -334,6 +355,19 @@ struct SaiBulkerTraits<sai_mpls_api_t>
334355
using bulk_set_entry_attribute_fn = sai_bulk_set_inseg_entry_attribute_fn;
335356
};
336357

358+
template<>
359+
struct SaiBulkerTraits<sai_neighbor_api_t>
360+
{
361+
using entry_t = sai_neighbor_entry_t;
362+
using api_t = sai_neighbor_api_t;
363+
using create_entry_fn = sai_create_neighbor_entry_fn;
364+
using remove_entry_fn = sai_remove_neighbor_entry_fn;
365+
using set_entry_attribute_fn = sai_set_neighbor_entry_attribute_fn;
366+
using bulk_create_entry_fn = sai_bulk_create_neighbor_entry_fn;
367+
using bulk_remove_entry_fn = sai_bulk_remove_neighbor_entry_fn;
368+
using bulk_set_entry_attribute_fn = sai_bulk_set_neighbor_entry_attribute_fn;
369+
};
370+
337371
template<>
338372
struct SaiBulkerTraits<sai_dash_vnet_api_t>
339373
{
@@ -811,6 +845,15 @@ inline EntityBulker<sai_mpls_api_t>::EntityBulker(sai_mpls_api_t *api, size_t ma
811845
set_entries_attribute = api->set_inseg_entries_attribute;
812846
}
813847

848+
template <>
849+
inline EntityBulker<sai_neighbor_api_t>::EntityBulker(sai_neighbor_api_t *api, size_t max_bulk_size) :
850+
max_bulk_size(max_bulk_size)
851+
{
852+
create_entries = api->create_neighbor_entries;
853+
remove_entries = api->remove_neighbor_entries;
854+
set_entries_attribute = api->set_neighbor_entries_attribute;
855+
}
856+
814857
template <>
815858
inline EntityBulker<sai_dash_inbound_routing_api_t>::EntityBulker(sai_dash_inbound_routing_api_t *api, size_t max_bulk_size) : max_bulk_size(max_bulk_size)
816859
{

0 commit comments

Comments
 (0)