@@ -13,6 +13,8 @@ extern "C" {
1313#include < getopt.h>
1414#include < unistd.h>
1515#include < inttypes.h>
16+ #include < stdlib.h>
17+ #include < string.h>
1618
1719#include < sys/time.h>
1820#include " timestamp.h"
@@ -49,6 +51,7 @@ bool gSwssRecord = true;
4951bool gLogRotate = false ;
5052bool gSaiRedisLogRotate = false ;
5153bool gSyncMode = false ;
54+ char *gAsicInstance = NULL ;
5255
5356extern bool gIsNatSupported ;
5457
@@ -57,7 +60,7 @@ string gRecordFile;
5760
5861void usage ()
5962{
60- cout << " usage: orchagent [-h] [-r record_type] [-d record_location] [-b batch_size] [-m MAC] [-s]" << endl;
63+ cout << " usage: orchagent [-h] [-r record_type] [-d record_location] [-b batch_size] [-m MAC] [-i INST_ID] [- s]" << endl;
6164 cout << " -h: display this message" << endl;
6265 cout << " -r record_type: record orchagent logs with type (default 3)" << endl;
6366 cout << " 0: do not record logs" << endl;
@@ -67,6 +70,7 @@ void usage()
6770 cout << " -d record_location: set record logs folder location (default .)" << endl;
6871 cout << " -b batch_size: set consumer table pop operation batch size (default 128)" << endl;
6972 cout << " -m MAC: set switch MAC address" << endl;
73+ cout << " -i INST_ID: set the ASIC instance_id in multi-asic platform" << endl;
7074 cout << " -s: enable synchronous mode" << endl;
7175}
7276
@@ -116,13 +120,17 @@ int main(int argc, char **argv)
116120
117121 string record_location = " ." ;
118122
119- while ((opt = getopt (argc, argv, " b:m:r:d:hs" )) != -1 )
123+ while ((opt = getopt (argc, argv, " b:m:r:d:i: hs" )) != -1 )
120124 {
121125 switch (opt)
122126 {
123127 case ' b' :
124128 gBatchSize = atoi (optarg);
125129 break ;
130+ case ' i' :
131+ gAsicInstance = (char *)calloc (strlen (optarg)+1 , sizeof (char ));
132+ memcpy (gAsicInstance , optarg, strlen (optarg));
133+ break ;
126134 case ' m' :
127135 gMacAddress = MacAddress (optarg);
128136 break ;
@@ -182,7 +190,6 @@ int main(int argc, char **argv)
182190 attr.id = SAI_SWITCH_ATTR_INIT_SWITCH;
183191 attr.value .booldata = true ;
184192 attrs.push_back (attr);
185-
186193 attr.id = SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY;
187194 attr.value .ptr = (void *)on_fdb_event;
188195 attrs.push_back (attr);
@@ -226,6 +233,13 @@ int main(int argc, char **argv)
226233 sai_switch_api->set_switch_attribute (gSwitchId , &attr);
227234 }
228235
236+ if (gAsicInstance )
237+ {
238+ attr.id = SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO;
239+ attr.value .s8list .count = (uint32_t )(strlen (gAsicInstance )+1 );
240+ attr.value .s8list .list = (int8_t *)gAsicInstance ;
241+ attrs.push_back (attr);
242+ }
229243
230244 status = sai_switch_api->create_switch (&gSwitchId , (uint32_t )attrs.size (), attrs.data ());
231245 if (status != SAI_STATUS_SUCCESS)
0 commit comments