@@ -13,6 +13,8 @@ extern "C" {
13
13
#include < getopt.h>
14
14
#include < unistd.h>
15
15
#include < inttypes.h>
16
+ #include < stdlib.h>
17
+ #include < string.h>
16
18
17
19
#include < sys/time.h>
18
20
#include " timestamp.h"
@@ -49,6 +51,7 @@ bool gSwssRecord = true;
49
51
bool gLogRotate = false ;
50
52
bool gSaiRedisLogRotate = false ;
51
53
bool gSyncMode = false ;
54
+ char *gAsicInstance = NULL ;
52
55
53
56
extern bool gIsNatSupported ;
54
57
@@ -57,7 +60,7 @@ string gRecordFile;
57
60
58
61
void usage ()
59
62
{
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;
61
64
cout << " -h: display this message" << endl;
62
65
cout << " -r record_type: record orchagent logs with type (default 3)" << endl;
63
66
cout << " 0: do not record logs" << endl;
@@ -67,6 +70,7 @@ void usage()
67
70
cout << " -d record_location: set record logs folder location (default .)" << endl;
68
71
cout << " -b batch_size: set consumer table pop operation batch size (default 128)" << endl;
69
72
cout << " -m MAC: set switch MAC address" << endl;
73
+ cout << " -i INST_ID: set the ASIC instance_id in multi-asic platform" << endl;
70
74
cout << " -s: enable synchronous mode" << endl;
71
75
}
72
76
@@ -116,13 +120,17 @@ int main(int argc, char **argv)
116
120
117
121
string record_location = " ." ;
118
122
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 )
120
124
{
121
125
switch (opt)
122
126
{
123
127
case ' b' :
124
128
gBatchSize = atoi (optarg );
125
129
break ;
130
+ case ' i' :
131
+ gAsicInstance = (char *)calloc (strlen (optarg )+1 , sizeof (char ));
132
+ memcpy (gAsicInstance , optarg , strlen (optarg ));
133
+ break ;
126
134
case ' m' :
127
135
gMacAddress = MacAddress (optarg );
128
136
break ;
@@ -182,7 +190,6 @@ int main(int argc, char **argv)
182
190
attr.id = SAI_SWITCH_ATTR_INIT_SWITCH;
183
191
attr.value .booldata = true ;
184
192
attrs.push_back (attr);
185
-
186
193
attr.id = SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY;
187
194
attr.value .ptr = (void *)on_fdb_event;
188
195
attrs.push_back (attr);
@@ -226,6 +233,13 @@ int main(int argc, char **argv)
226
233
sai_switch_api->set_switch_attribute (gSwitchId , &attr);
227
234
}
228
235
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
+ }
229
243
230
244
status = sai_switch_api->create_switch (&gSwitchId , (uint32_t )attrs.size (), attrs.data ());
231
245
if (status != SAI_STATUS_SUCCESS)
0 commit comments