Skip to content

Commit 5756332

Browse files
Prabhu SreenivasanPrabhuSreenivasan
Prabhu Sreenivasan
authored andcommitted
Switch Capability support
Signed-off-by: Prabhu Sreenivasan <[email protected]>
1 parent 86e1171 commit 5756332

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-0
lines changed

orchagent/main.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ sai_object_id_t gUnderlayIfId;
4646
sai_object_id_t gSwitchId = SAI_NULL_OBJECT_ID;
4747
MacAddress gMacAddress;
4848
MacAddress gVxlanMacAddress;
49+
extern int32_t gSupportedObjectTypeList[SAI_OBJECT_TYPE_MAX];
50+
extern uint32_t gSupportedObjectTypeListCount;
4951

5052
#define DEFAULT_BATCH_SIZE 128
5153
int gBatchSize = DEFAULT_BATCH_SIZE;
@@ -364,6 +366,27 @@ int main(int argc, char **argv)
364366

365367
SWSS_LOG_NOTICE("Created underlay router interface ID %" PRIx64, gUnderlayIfId);
366368

369+
sai_attribute_t obj_attr_get;
370+
obj_attr_get.id = SAI_SWITCH_ATTR_SUPPORTED_OBJECT_TYPE_LIST;
371+
obj_attr_get.value.s32list.count = SAI_OBJECT_TYPE_MAX;
372+
obj_attr_get.value.s32list.list= gSupportedObjectTypeList;
373+
374+
status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &obj_attr_get);
375+
if (SAI_STATUS_SUCCESS != status)
376+
{
377+
SWSS_LOG_ERROR("get_switch_attribute failed with error %d\n", status);
378+
exit(EXIT_FAILURE);
379+
}
380+
381+
gSupportedObjectTypeListCount = obj_attr_get.value.s32list.count;
382+
383+
SWSS_LOG_DEBUG("Adapter supports %d object types\n", obj_attr_get.value.s32list.count);
384+
385+
for (uint32_t iter = 0; iter < gSupportedObjectTypeListCount; iter++)
386+
{
387+
SWSS_LOG_DEBUG("gSupportedObjectTypeList[%d] = %d\n", iter, gSupportedObjectTypeList[iter]);
388+
}
389+
367390
/* Initialize orchestration components */
368391
DBConnector appl_db("APPL_DB", 0);
369392
DBConnector config_db("CONFIG_DB", 0);

orchagent/orch.h

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ const char state_db_key_delimiter = '|';
4242
#define DEFAULT_KEY_SEPARATOR ":"
4343
#define VLAN_SUB_INTERFACE_SEPARATOR "."
4444

45+
#define SNAPSHOT_SUPPORTED_FIELD "snapshot_supported"
46+
47+
#define THRESHOLD_SUPPORTED_FIELD "threshold_supported"
48+
4549
const int default_orch_pri = 0;
4650

4751
typedef enum

orchagent/orchdaemon.cpp

+104
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,27 @@ using namespace swss;
1717
#define SELECT_TIMEOUT 1000
1818
#define PFC_WD_POLL_MSECS 100
1919

20+
/* Switch table key */
21+
#define SWITCH_TABLE_KEY "switch"
22+
2023
extern sai_switch_api_t* sai_switch_api;
2124
extern sai_object_id_t gSwitchId;
2225
extern bool gSaiRedisLogRotate;
2326

2427
extern void syncd_apply_view();
28+
29+
/*
30+
* Global supported objects variables
31+
*/
32+
int32_t gSupportedObjectTypeList[SAI_OBJECT_TYPE_MAX];
33+
uint32_t gSupportedObjectTypeListCount;
34+
35+
/* Global Snapshot support flag */
36+
bool gIsSnapshotSupported = false;
37+
38+
/* Global Threshold support flag */
39+
bool gIsThresholdSupported = false;
40+
2541
/*
2642
* Global orch daemon variables
2743
*/
@@ -46,6 +62,94 @@ OrchDaemon::OrchDaemon(DBConnector *applDb, DBConnector *configDb, DBConnector *
4662
m_stateDb(stateDb)
4763
{
4864
SWSS_LOG_ENTER();
65+
66+
SWSS_LOG_DEBUG("gSupportedObjectTypeListCount %d object types\n", gSupportedObjectTypeListCount);
67+
if (gSupportedObjectTypeListCount)
68+
{
69+
bool isTamCollectorSupported = false;
70+
bool isTamReportSupported = false;
71+
bool isTamTransportSupported = false;
72+
bool isTamSupported = false;
73+
bool isTamTelemetrySupported = false;
74+
bool isTamEventThresholdSupported = false;
75+
76+
/* Run through supported objects and check if all objects needed for IFA feature are supported or not */
77+
for (uint32_t iter = 0; iter < gSupportedObjectTypeListCount; iter++)
78+
{
79+
switch (gSupportedObjectTypeList[iter])
80+
{
81+
case SAI_OBJECT_TYPE_TAM_COLLECTOR:
82+
{
83+
isTamCollectorSupported = true;
84+
break;
85+
}
86+
case SAI_OBJECT_TYPE_TAM_REPORT:
87+
{
88+
isTamReportSupported = true;
89+
break;
90+
}
91+
case SAI_OBJECT_TYPE_TAM_TRANSPORT:
92+
{
93+
isTamTransportSupported = true;
94+
break;
95+
}
96+
case SAI_OBJECT_TYPE_TAM:
97+
{
98+
isTamSupported = true;
99+
break;
100+
}
101+
case SAI_OBJECT_TYPE_TAM_TELEMETRY:
102+
{
103+
isTamTelemetrySupported = true;
104+
break;
105+
}
106+
case SAI_OBJECT_TYPE_TAM_EVENT_THRESHOLD:
107+
{
108+
isTamEventThresholdSupported = true;
109+
break;
110+
}
111+
}
112+
}
113+
114+
/* Snapshot support */
115+
if (isTamCollectorSupported && isTamSupported && isTamTelemetrySupported &&
116+
isTamReportSupported && isTamTransportSupported)
117+
{
118+
if (isTamSupported && isTamTelemetrySupported)
119+
SWSS_LOG_DEBUG("TAM and telemetry objects supported.");
120+
121+
/* Added snapshot supported field in APP DB's switch table */
122+
Table m_appSwitchTable(m_applDb, APP_SWITCH_TABLE_NAME);
123+
string key = SWITCH_TABLE_KEY;
124+
vector<FieldValueTuple> fvVector;
125+
FieldValueTuple snapshot_supported(SNAPSHOT_SUPPORTED_FIELD, "True");
126+
fvVector.push_back(snapshot_supported);
127+
128+
m_appSwitchTable.set(key, fvVector);
129+
130+
SWSS_LOG_DEBUG("APP Switch Table updated with snapshot supported entry\n");
131+
132+
gIsSnapshotSupported = true;
133+
}
134+
135+
/* Threshold support */
136+
if (isTamCollectorSupported && isTamSupported && isTamTelemetrySupported &&
137+
isTamReportSupported && isTamTransportSupported && isTamEventThresholdSupported)
138+
{
139+
/* Added threshold_supported field in APP DB's switch table */
140+
Table m_appSwitchTable(m_applDb, APP_SWITCH_TABLE_NAME);
141+
string key = SWITCH_TABLE_KEY;
142+
vector<FieldValueTuple> fvVector;
143+
FieldValueTuple threshold_supported(THRESHOLD_SUPPORTED_FIELD, "True");
144+
fvVector.push_back(threshold_supported);
145+
146+
m_appSwitchTable.set(key, fvVector);
147+
148+
SWSS_LOG_DEBUG("APP Switch Table updated with threshold_supported entry\n");
149+
150+
gIsThresholdSupported = true;
151+
}
152+
}
49153
}
50154

51155
OrchDaemon::~OrchDaemon()

0 commit comments

Comments
 (0)