Skip to content

Commit 2d1972f

Browse files
prabhataravindtheasianpianist
authored andcommitted
(conflict)orchagent: DASH changes (sonic-net#2459)
* orchagent: DASH changes * Introduce DASH specific orchs - DashOrch, DashVnetOrch and DashRouteOrch * Introduce changes to handle various DASH table schemas and operations * Changes in bulker to introduce new constructors for DASH-related Entity/Object bulkers * Changes to support new DASH tables and orchs in orchdaemon * Changes to support new DASH APIs in saihelper * Makefile changes to support compilation * References: https://github.com/Azure/DASH/blob/main/documentation/general/dash-sonic-hld.md * Verifications done: Manual testing with configurations referenced in the HLD above as well as automated vstests Signed-off-by: Prabhat Aravind <[email protected]>
1 parent acf0fe4 commit 2d1972f

File tree

12 files changed

+2614
-1
lines changed

12 files changed

+2614
-1
lines changed

orchagent/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ orchagent_SOURCES = \
104104
bfdorch.cpp \
105105
srv6orch.cpp \
106106
response_publisher.cpp \
107-
nvgreorch.cpp
107+
nvgreorch.cpp \
108+
dash/dashorch.cpp \
109+
dash/dashrouteorch.cpp \
110+
dash/dashvnetorch.cpp
108111

109112
orchagent_SOURCES += flex_counter/flex_counter_manager.cpp flex_counter/flex_counter_stat_manager.cpp flex_counter/flow_counter_handler.cpp flex_counter/flowcounterrouteorch.cpp
110113
orchagent_SOURCES += debug_counter/debug_counter.cpp debug_counter/drop_counter.cpp

orchagent/bulker.h

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,34 @@
1111
#include "logger.h"
1212
#include "sai_serialize.h"
1313

14+
typedef sai_status_t (*sai_bulk_set_outbound_ca_to_pa_entry_attribute_fn) (
15+
_In_ uint32_t object_count,
16+
_In_ const sai_outbound_ca_to_pa_entry_t *entry,
17+
_In_ const sai_attribute_t *attr_list,
18+
_In_ sai_bulk_op_error_mode_t mode,
19+
_Out_ sai_status_t *object_statuses);
20+
21+
typedef sai_status_t (*sai_bulk_set_pa_validation_entry_attribute_fn) (
22+
_In_ uint32_t object_count,
23+
_In_ const sai_pa_validation_entry_t *entry,
24+
_In_ const sai_attribute_t *attr_list,
25+
_In_ sai_bulk_op_error_mode_t mode,
26+
_Out_ sai_status_t *object_statuses);
27+
28+
typedef sai_status_t (*sai_bulk_set_outbound_routing_entry_attribute_fn) (
29+
_In_ uint32_t object_count,
30+
_In_ const sai_outbound_routing_entry_t *entry,
31+
_In_ const sai_attribute_t *attr_list,
32+
_In_ sai_bulk_op_error_mode_t mode,
33+
_Out_ sai_status_t *object_statuses);
34+
35+
typedef sai_status_t (*sai_bulk_set_inbound_routing_entry_attribute_fn) (
36+
_In_ uint32_t object_count,
37+
_In_ const sai_inbound_routing_entry_t *entry,
38+
_In_ const sai_attribute_t *attr_list,
39+
_In_ sai_bulk_op_error_mode_t mode,
40+
_Out_ sai_status_t *object_statuses);
41+
1442
static inline bool operator==(const sai_ip_prefix_t& a, const sai_ip_prefix_t& b)
1543
{
1644
if (a.addr_family != b.addr_family) return false;
@@ -33,6 +61,26 @@ static inline bool operator==(const sai_ip_prefix_t& a, const sai_ip_prefix_t& b
3361
}
3462
}
3563

64+
static inline bool operator==(const sai_ip_address_t& a, const sai_ip_address_t& b)
65+
{
66+
if (a.addr_family != b.addr_family) return false;
67+
68+
if (a.addr_family == SAI_IP_ADDR_FAMILY_IPV4)
69+
{
70+
return a.addr.ip4 == b.addr.ip4
71+
;
72+
}
73+
else if (a.addr_family == SAI_IP_ADDR_FAMILY_IPV6)
74+
{
75+
return memcmp(a.addr.ip6, b.addr.ip6, sizeof(a.addr.ip6)) == 0
76+
;
77+
}
78+
else
79+
{
80+
throw std::invalid_argument("a has invalid addr_family");
81+
}
82+
}
83+
3684
static inline bool operator==(const sai_route_entry_t& a, const sai_route_entry_t& b)
3785
{
3886
return a.switch_id == b.switch_id
@@ -48,6 +96,41 @@ static inline bool operator==(const sai_inseg_entry_t& a, const sai_inseg_entry_
4896
;
4997
}
5098

99+
static inline bool operator==(const sai_inbound_routing_entry_t& a, const sai_inbound_routing_entry_t& b)
100+
{
101+
return a.switch_id == b.switch_id
102+
&& a.eni_id == b.eni_id
103+
&& a.vni == b.vni
104+
&& a.sip == b.sip
105+
&& a.sip_mask == b.sip_mask
106+
&& a.priority == b.priority
107+
;
108+
}
109+
110+
static inline bool operator==(const sai_outbound_ca_to_pa_entry_t& a, const sai_outbound_ca_to_pa_entry_t& b)
111+
{
112+
return a.switch_id == b.switch_id
113+
&& a.dst_vnet_id == b.dst_vnet_id
114+
&& a.dip == b.dip
115+
;
116+
}
117+
118+
static inline bool operator==(const sai_pa_validation_entry_t& a, const sai_pa_validation_entry_t& b)
119+
{
120+
return a.switch_id == b.switch_id
121+
&& a.vnet_id == b.vnet_id
122+
&& a.sip == b.sip
123+
;
124+
}
125+
126+
static inline bool operator==(const sai_outbound_routing_entry_t& a, const sai_outbound_routing_entry_t& b)
127+
{
128+
return a.switch_id == b.switch_id
129+
&& a.eni_id == b.eni_id
130+
&& a.destination == b.destination
131+
;
132+
}
133+
51134
static inline std::size_t hash_value(const sai_ip_prefix_t& a)
52135
{
53136
size_t seed = 0;
@@ -65,6 +148,21 @@ static inline std::size_t hash_value(const sai_ip_prefix_t& a)
65148
return seed;
66149
}
67150

151+
static inline std::size_t hash_value(const sai_ip_address_t& a)
152+
{
153+
size_t seed = 0;
154+
boost::hash_combine(seed, a.addr_family);
155+
if (a.addr_family == SAI_IP_ADDR_FAMILY_IPV4)
156+
{
157+
boost::hash_combine(seed, a.addr.ip4);
158+
}
159+
else if (a.addr_family == SAI_IP_ADDR_FAMILY_IPV6)
160+
{
161+
boost::hash_combine(seed, a.addr.ip6);
162+
}
163+
return seed;
164+
}
165+
68166
namespace std
69167
{
70168
template <>
@@ -104,6 +202,59 @@ namespace std
104202
return seed;
105203
}
106204
};
205+
206+
template <>
207+
struct hash<sai_outbound_ca_to_pa_entry_t>
208+
{
209+
size_t operator()(const sai_outbound_ca_to_pa_entry_t& a) const noexcept
210+
{
211+
size_t seed = 0;
212+
boost::hash_combine(seed, a.switch_id);
213+
boost::hash_combine(seed, a.dst_vnet_id);
214+
boost::hash_combine(seed, a.dip);
215+
return seed;
216+
}
217+
};
218+
219+
template <>
220+
struct hash<sai_pa_validation_entry_t>
221+
{
222+
size_t operator()(const sai_pa_validation_entry_t& a) const noexcept
223+
{
224+
size_t seed = 0;
225+
boost::hash_combine(seed, a.switch_id);
226+
boost::hash_combine(seed, a.vnet_id);
227+
boost::hash_combine(seed, a.sip);
228+
return seed;
229+
}
230+
};
231+
232+
template <>
233+
struct hash<sai_outbound_routing_entry_t>
234+
{
235+
size_t operator()(const sai_outbound_routing_entry_t& a) const noexcept
236+
{
237+
size_t seed = 0;
238+
boost::hash_combine(seed, a.switch_id);
239+
boost::hash_combine(seed, a.eni_id);
240+
boost::hash_combine(seed, a.destination);
241+
return seed;
242+
}
243+
};
244+
245+
template <>
246+
struct hash<sai_inbound_routing_entry_t>
247+
{
248+
size_t operator()(const sai_inbound_routing_entry_t& a) const noexcept
249+
{
250+
size_t seed = 0;
251+
boost::hash_combine(seed, a.switch_id);
252+
boost::hash_combine(seed, a.eni_id);
253+
boost::hash_combine(seed, a.vni);
254+
boost::hash_combine(seed, a.sip);
255+
return seed;
256+
}
257+
};
107258
}
108259

109260
// SAI typedef which is not available in SAI 1.5
@@ -183,6 +334,70 @@ struct SaiBulkerTraits<sai_mpls_api_t>
183334
using bulk_set_entry_attribute_fn = sai_bulk_set_inseg_entry_attribute_fn;
184335
};
185336

337+
template<>
338+
struct SaiBulkerTraits<sai_dash_vnet_api_t>
339+
{
340+
using entry_t = sai_object_id_t;
341+
using api_t = sai_dash_vnet_api_t;
342+
using create_entry_fn = sai_create_vnet_fn;
343+
using remove_entry_fn = sai_remove_vnet_fn;
344+
using set_entry_attribute_fn = sai_set_vnet_attribute_fn;
345+
using bulk_create_entry_fn = sai_bulk_object_create_fn;
346+
using bulk_remove_entry_fn = sai_bulk_object_remove_fn;
347+
};
348+
349+
template<>
350+
struct SaiBulkerTraits<sai_dash_inbound_routing_api_t>
351+
{
352+
using entry_t = sai_inbound_routing_entry_t;
353+
using api_t = sai_dash_inbound_routing_api_t;
354+
using create_entry_fn = sai_create_inbound_routing_entry_fn;
355+
using remove_entry_fn = sai_remove_inbound_routing_entry_fn;
356+
using set_entry_attribute_fn = sai_set_inbound_routing_entry_attribute_fn;
357+
using bulk_create_entry_fn = sai_bulk_create_inbound_routing_entry_fn;
358+
using bulk_remove_entry_fn = sai_bulk_remove_inbound_routing_entry_fn;
359+
using bulk_set_entry_attribute_fn = sai_bulk_set_inbound_routing_entry_attribute_fn;
360+
};
361+
362+
template<>
363+
struct SaiBulkerTraits<sai_dash_outbound_ca_to_pa_api_t>
364+
{
365+
using entry_t = sai_outbound_ca_to_pa_entry_t;
366+
using api_t = sai_dash_outbound_ca_to_pa_api_t;
367+
using create_entry_fn = sai_create_outbound_ca_to_pa_entry_fn;
368+
using remove_entry_fn = sai_remove_outbound_ca_to_pa_entry_fn;
369+
using set_entry_attribute_fn = sai_set_outbound_ca_to_pa_entry_attribute_fn;
370+
using bulk_create_entry_fn = sai_bulk_create_outbound_ca_to_pa_entry_fn;
371+
using bulk_remove_entry_fn = sai_bulk_remove_outbound_ca_to_pa_entry_fn;
372+
using bulk_set_entry_attribute_fn = sai_bulk_set_outbound_ca_to_pa_entry_attribute_fn;
373+
};
374+
375+
template<>
376+
struct SaiBulkerTraits<sai_dash_pa_validation_api_t>
377+
{
378+
using entry_t = sai_pa_validation_entry_t;
379+
using api_t = sai_dash_pa_validation_api_t;
380+
using create_entry_fn = sai_create_pa_validation_entry_fn;
381+
using remove_entry_fn = sai_remove_pa_validation_entry_fn;
382+
using set_entry_attribute_fn = sai_set_pa_validation_entry_attribute_fn;
383+
using bulk_create_entry_fn = sai_bulk_create_pa_validation_entry_fn;
384+
using bulk_remove_entry_fn = sai_bulk_remove_pa_validation_entry_fn;
385+
using bulk_set_entry_attribute_fn = sai_bulk_set_pa_validation_entry_attribute_fn;
386+
};
387+
388+
template<>
389+
struct SaiBulkerTraits<sai_dash_outbound_routing_api_t>
390+
{
391+
using entry_t = sai_outbound_routing_entry_t;
392+
using api_t = sai_dash_outbound_routing_api_t;
393+
using create_entry_fn = sai_create_outbound_routing_entry_fn;
394+
using remove_entry_fn = sai_remove_outbound_routing_entry_fn;
395+
using set_entry_attribute_fn = sai_set_outbound_routing_entry_attribute_fn;
396+
using bulk_create_entry_fn = sai_bulk_create_outbound_routing_entry_fn;
397+
using bulk_remove_entry_fn = sai_bulk_remove_outbound_routing_entry_fn;
398+
using bulk_set_entry_attribute_fn = sai_bulk_set_outbound_routing_entry_attribute_fn;
399+
};
400+
186401
template <typename T>
187402
class EntityBulker
188403
{
@@ -596,6 +811,38 @@ inline EntityBulker<sai_mpls_api_t>::EntityBulker(sai_mpls_api_t *api, size_t ma
596811
set_entries_attribute = api->set_inseg_entries_attribute;
597812
}
598813

814+
template <>
815+
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)
816+
{
817+
create_entries = api->create_inbound_routing_entries;
818+
remove_entries = api->remove_inbound_routing_entries;
819+
set_entries_attribute = nullptr;
820+
}
821+
822+
template <>
823+
inline EntityBulker<sai_dash_outbound_ca_to_pa_api_t>::EntityBulker(sai_dash_outbound_ca_to_pa_api_t *api, size_t max_bulk_size) : max_bulk_size(max_bulk_size)
824+
{
825+
create_entries = api->create_outbound_ca_to_pa_entries;
826+
remove_entries = api->remove_outbound_ca_to_pa_entries;
827+
set_entries_attribute = nullptr;
828+
}
829+
830+
template <>
831+
inline EntityBulker<sai_dash_pa_validation_api_t>::EntityBulker(sai_dash_pa_validation_api_t *api, size_t max_bulk_size) : max_bulk_size(max_bulk_size)
832+
{
833+
create_entries = api->create_pa_validation_entries;
834+
remove_entries = api->remove_pa_validation_entries;
835+
set_entries_attribute = nullptr;
836+
}
837+
838+
template <>
839+
inline EntityBulker<sai_dash_outbound_routing_api_t>::EntityBulker(sai_dash_outbound_routing_api_t *api, size_t max_bulk_size) : max_bulk_size(max_bulk_size)
840+
{
841+
create_entries = api->create_outbound_routing_entries;
842+
remove_entries = api->remove_outbound_routing_entries;
843+
set_entries_attribute = nullptr;
844+
}
845+
599846
template <typename T>
600847
class ObjectBulker
601848
{
@@ -926,3 +1173,12 @@ inline ObjectBulker<sai_next_hop_group_api_t>::ObjectBulker(SaiBulkerTraits<sai_
9261173
// TODO: wait until available in SAI
9271174
//set_entries_attribute = ;
9281175
}
1176+
1177+
template <>
1178+
inline ObjectBulker<sai_dash_vnet_api_t>::ObjectBulker(SaiBulkerTraits<sai_dash_vnet_api_t>::api_t *api, sai_object_id_t switch_id, size_t max_bulk_size) :
1179+
switch_id(switch_id),
1180+
max_bulk_size(max_bulk_size)
1181+
{
1182+
create_entries = api->create_vnets;
1183+
remove_entries = api->remove_vnets;
1184+
}

0 commit comments

Comments
 (0)