Skip to content

Commit e213523

Browse files
huseratgithubcscarpitta
authored andcommitted
[orchagent] TWAMP Light orchagent implementation (sonic-net#2927)
* [orchagent] TWAMP Light orchagent implementation. (sonic-net#2927) * What I did Implemented the TWAMP Light feature according to the SONiC TWAMP Light HLD(sonic-net/SONiC#1320).
1 parent 5ea3e9b commit e213523

18 files changed

+2509
-9
lines changed

orchagent/Makefile.am

+2-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ orchagent_SOURCES = \
113113
dash/dashaclorch.cpp \
114114
dash/dashaclgroupmgr.cpp \
115115
dash/dashtagmgr.cpp \
116-
dash/pbutils.cpp
116+
dash/pbutils.cpp \
117+
twamporch.cpp
117118

118119
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
119120
orchagent_SOURCES += debug_counter/debug_counter.cpp debug_counter/drop_counter.cpp

orchagent/crmorch.cpp

+14-5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const map<CrmResourceType, string> crmResTypeNameMap =
6464
{ CrmResourceType::CRM_DASH_IPV6_ACL_GROUP, "DASH_IPV6_ACL_GROUP" },
6565
{ CrmResourceType::CRM_DASH_IPV4_ACL_RULE, "DASH_IPV4_ACL_RULE" },
6666
{ CrmResourceType::CRM_DASH_IPV6_ACL_RULE, "DASH_IPV6_ACL_RULE" },
67+
{ CrmResourceType::CRM_TWAMP_ENTRY, "TWAMP_ENTRY" }
6768
};
6869

6970
const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
@@ -84,6 +85,7 @@ const map<CrmResourceType, uint32_t> crmResSaiAvailAttrMap =
8485
{ CrmResourceType::CRM_IPMC_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_IPMC_ENTRY},
8586
{ CrmResourceType::CRM_SNAT_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_SNAT_ENTRY },
8687
{ CrmResourceType::CRM_DNAT_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_DNAT_ENTRY },
88+
{ CrmResourceType::CRM_TWAMP_ENTRY, SAI_SWITCH_ATTR_AVAILABLE_TWAMP_SESSION }
8789
};
8890

8991
const map<CrmResourceType, sai_object_type_t> crmResSaiObjAttrMap =
@@ -125,6 +127,7 @@ const map<CrmResourceType, sai_object_type_t> crmResSaiObjAttrMap =
125127
{ CrmResourceType::CRM_DASH_IPV6_ACL_GROUP, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_GROUP },
126128
{ CrmResourceType::CRM_DASH_IPV4_ACL_RULE, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE },
127129
{ CrmResourceType::CRM_DASH_IPV6_ACL_RULE, (sai_object_type_t)SAI_OBJECT_TYPE_DASH_ACL_RULE },
130+
{ CrmResourceType::CRM_TWAMP_ENTRY, SAI_OBJECT_TYPE_NULL }
128131
};
129132

130133
const map<CrmResourceType, sai_attr_id_t> crmResAddrFamilyAttrMap =
@@ -185,7 +188,8 @@ const map<string, CrmResourceType> crmThreshTypeResMap =
185188
{ "dash_ipv4_acl_group_threshold_type", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
186189
{ "dash_ipv6_acl_group_threshold_type", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
187190
{ "dash_ipv4_acl_rule_threshold_type", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
188-
{ "dash_ipv6_acl_rule_threshold_type", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
191+
{ "dash_ipv6_acl_rule_threshold_type", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
192+
{ "twamp_entry_threshold_type", CrmResourceType::CRM_TWAMP_ENTRY }
189193
};
190194

191195
const map<string, CrmResourceType> crmThreshLowResMap =
@@ -226,7 +230,8 @@ const map<string, CrmResourceType> crmThreshLowResMap =
226230
{ "dash_ipv4_acl_group_low_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
227231
{ "dash_ipv6_acl_group_low_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
228232
{ "dash_ipv4_acl_rule_low_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
229-
{ "dash_ipv6_acl_rule_low_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
233+
{ "dash_ipv6_acl_rule_low_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
234+
{ "twamp_entry_low_threshold", CrmResourceType::CRM_TWAMP_ENTRY }
230235
};
231236

232237
const map<string, CrmResourceType> crmThreshHighResMap =
@@ -267,7 +272,8 @@ const map<string, CrmResourceType> crmThreshHighResMap =
267272
{ "dash_ipv4_acl_group_high_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
268273
{ "dash_ipv6_acl_group_high_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
269274
{ "dash_ipv4_acl_rule_high_threshold", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
270-
{ "dash_ipv6_acl_rule_high_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
275+
{ "dash_ipv6_acl_rule_high_threshold", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
276+
{ "twamp_entry_high_threshold", CrmResourceType::CRM_TWAMP_ENTRY }
271277
};
272278

273279
const map<string, CrmThresholdType> crmThreshTypeMap =
@@ -315,7 +321,8 @@ const map<string, CrmResourceType> crmAvailCntsTableMap =
315321
{ "crm_stats_dash_ipv4_acl_group_available", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
316322
{ "crm_stats_dash_ipv6_acl_group_available", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
317323
{ "crm_stats_dash_ipv4_acl_rule_available", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
318-
{ "crm_stats_dash_ipv6_acl_rule_available", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
324+
{ "crm_stats_dash_ipv6_acl_rule_available", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
325+
{ "crm_stats_twamp_entry_available", CrmResourceType::CRM_TWAMP_ENTRY }
319326
};
320327

321328
const map<string, CrmResourceType> crmUsedCntsTableMap =
@@ -356,7 +363,8 @@ const map<string, CrmResourceType> crmUsedCntsTableMap =
356363
{ "crm_stats_dash_ipv4_acl_group_used", CrmResourceType::CRM_DASH_IPV4_ACL_GROUP },
357364
{ "crm_stats_dash_ipv6_acl_group_used", CrmResourceType::CRM_DASH_IPV6_ACL_GROUP },
358365
{ "crm_stats_dash_ipv4_acl_rule_used", CrmResourceType::CRM_DASH_IPV4_ACL_RULE },
359-
{ "crm_stats_dash_ipv6_acl_rule_used", CrmResourceType::CRM_DASH_IPV6_ACL_RULE }
366+
{ "crm_stats_dash_ipv6_acl_rule_used", CrmResourceType::CRM_DASH_IPV6_ACL_RULE },
367+
{ "crm_stats_twamp_entry_used", CrmResourceType::CRM_TWAMP_ENTRY },
360368
};
361369

362370
CrmOrch::CrmOrch(DBConnector *db, string tableName):
@@ -877,6 +885,7 @@ void CrmOrch::getResAvailableCounters()
877885
case CrmResourceType::CRM_DASH_IPV6_OUTBOUND_CA_TO_PA:
878886
case CrmResourceType::CRM_DASH_IPV4_ACL_GROUP:
879887
case CrmResourceType::CRM_DASH_IPV6_ACL_GROUP:
888+
case CrmResourceType::CRM_TWAMP_ENTRY:
880889
{
881890
getResAvailability(res.first, res.second);
882891
break;

orchagent/crmorch.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ enum class CrmResourceType
4949
CRM_DASH_IPV4_ACL_GROUP,
5050
CRM_DASH_IPV6_ACL_GROUP,
5151
CRM_DASH_IPV4_ACL_RULE,
52-
CRM_DASH_IPV6_ACL_RULE
52+
CRM_DASH_IPV6_ACL_RULE,
53+
CRM_TWAMP_ENTRY
5354
};
5455

5556
enum class CrmThresholdType

orchagent/notifications.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ void on_bfd_session_state_change(uint32_t count, sai_bfd_session_state_notificat
2727
// which causes concurrency access to the DB
2828
}
2929

30+
void on_twamp_session_event(uint32_t count, sai_twamp_session_event_notification_data_t *data)
31+
{
32+
// don't use this event handler, because it runs by libsairedis in a separate thread
33+
// which causes concurrency access to the DB
34+
}
35+
3036
void on_switch_shutdown_request(sai_object_id_t switch_id)
3137
{
3238
SWSS_LOG_ENTER();

orchagent/notifications.h

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern "C" {
77
void on_fdb_event(uint32_t count, sai_fdb_event_notification_data_t *data);
88
void on_port_state_change(uint32_t count, sai_port_oper_status_notification_t *data);
99
void on_bfd_session_state_change(uint32_t count, sai_bfd_session_state_notification_t *data);
10+
void on_twamp_session_event(uint32_t count, sai_twamp_session_event_notification_data_t *data);
1011

1112
// The function prototype information can be found here:
1213
// https://github.com/sonic-net/sonic-sairedis/blob/master/meta/NotificationSwitchShutdownRequest.cpp#L49

orchagent/orchdaemon.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,11 @@ bool OrchDaemon::init()
727727
gP4Orch = new P4Orch(m_applDb, p4rt_tables, vrf_orch, gCoppOrch);
728728
m_orchList.push_back(gP4Orch);
729729

730+
TableConnector confDbTwampTable(m_configDb, CFG_TWAMP_SESSION_TABLE_NAME);
731+
TableConnector stateDbTwampTable(m_stateDb, STATE_TWAMP_SESSION_TABLE_NAME);
732+
TwampOrch *twamp_orch = new TwampOrch(confDbTwampTable, stateDbTwampTable, gSwitchOrch, gPortsOrch, vrf_orch);
733+
m_orchList.push_back(twamp_orch);
734+
730735
if (WarmStart::isWarmStart())
731736
{
732737
bool suc = warmRestoreAndSyncUp();

orchagent/orchdaemon.h

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "bfdorch.h"
4747
#include "srv6orch.h"
4848
#include "nvgreorch.h"
49+
#include "twamporch.h"
4950
#include "dash/dashaclorch.h"
5051
#include "dash/dashorch.h"
5152
#include "dash/dashrouteorch.h"

orchagent/saihelper.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ sai_dash_inbound_routing_api_t* sai_dash_inbound_routing_api;
8282
sai_dash_eni_api_t* sai_dash_eni_api;
8383
sai_dash_vip_api_t* sai_dash_vip_api;
8484
sai_dash_direction_lookup_api_t* sai_dash_direction_lookup_api;
85+
sai_twamp_api_t* sai_twamp_api;
8586
sai_tam_api_t* sai_tam_api;
8687

8788
extern sai_object_id_t gSwitchId;
@@ -218,7 +219,8 @@ void initSaiApi()
218219
sai_api_query((sai_api_t)SAI_API_DASH_ENI, (void**)&sai_dash_eni_api);
219220
sai_api_query((sai_api_t)SAI_API_DASH_VIP, (void**)&sai_dash_vip_api);
220221
sai_api_query((sai_api_t)SAI_API_DASH_DIRECTION_LOOKUP, (void**)&sai_dash_direction_lookup_api);
221-
sai_api_query(SAI_API_TAM, (void **)&sai_tam_api);
222+
sai_api_query(SAI_API_TWAMP, (void **)&sai_twamp_api);
223+
sai_api_query(SAI_API_TAM, (void **)&sai_tam_api);
222224

223225
sai_log_set(SAI_API_SWITCH, SAI_LOG_LEVEL_NOTICE);
224226
sai_log_set(SAI_API_BRIDGE, SAI_LOG_LEVEL_NOTICE);
@@ -258,6 +260,7 @@ void initSaiApi()
258260
sai_log_set(SAI_API_BFD, SAI_LOG_LEVEL_NOTICE);
259261
sai_log_set(SAI_API_MY_MAC, SAI_LOG_LEVEL_NOTICE);
260262
sai_log_set(SAI_API_GENERIC_PROGRAMMABLE, SAI_LOG_LEVEL_NOTICE);
263+
sai_log_set(SAI_API_TWAMP, SAI_LOG_LEVEL_NOTICE);
261264
sai_log_set(SAI_API_TAM, SAI_LOG_LEVEL_NOTICE);
262265
}
263266

0 commit comments

Comments
 (0)