Skip to content

Commit

Permalink
[Multi-AISC] Pass the asic instance as SAI attribute during switch_cr…
Browse files Browse the repository at this point in the history
…eate (#1269)

* SAI 3.7 Supports multiple ASIC instances. This change is needed for orchagent to accept the
instance ID which is fills in HARDWARE_INFO and passes to switch create.

* Update the usage help string with the new option [-i INST_ID]
  • Loading branch information
judyjoseph committed Apr 23, 2020
1 parent 3c8289b commit d304673
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ extern "C" {
#include <getopt.h>
#include <unistd.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>

#include <sys/time.h>
#include "timestamp.h"
Expand Down Expand Up @@ -49,6 +51,7 @@ bool gSwssRecord = true;
bool gLogRotate = false;
bool gSaiRedisLogRotate = false;
bool gSyncMode = false;
char *gAsicInstance = NULL;

extern bool gIsNatSupported;

Expand All @@ -57,7 +60,7 @@ string gRecordFile;

void usage()
{
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-b batch_size] [-m MAC] [-s]" << endl;
cout << "usage: orchagent [-h] [-r record_type] [-d record_location] [-b batch_size] [-m MAC] [-i INST_ID] [-s]" << endl;
cout << " -h: display this message" << endl;
cout << " -r record_type: record orchagent logs with type (default 3)" << endl;
cout << " 0: do not record logs" << endl;
Expand All @@ -67,6 +70,7 @@ void usage()
cout << " -d record_location: set record logs folder location (default .)" << endl;
cout << " -b batch_size: set consumer table pop operation batch size (default 128)" << endl;
cout << " -m MAC: set switch MAC address" << endl;
cout << " -i INST_ID: set the ASIC instance_id in multi-asic platform" << endl;
cout << " -s: enable synchronous mode" << endl;
}

Expand Down Expand Up @@ -116,13 +120,17 @@ int main(int argc, char **argv)

string record_location = ".";

while ((opt = getopt(argc, argv, "b:m:r:d:hs")) != -1)
while ((opt = getopt(argc, argv, "b:m:r:d:i:hs")) != -1)
{
switch (opt)
{
case 'b':
gBatchSize = atoi(optarg);
break;
case 'i':
gAsicInstance = (char *)calloc(strlen(optarg)+1, sizeof(char));
memcpy(gAsicInstance, optarg, strlen(optarg));
break;
case 'm':
gMacAddress = MacAddress(optarg);
break;
Expand Down Expand Up @@ -182,7 +190,6 @@ int main(int argc, char **argv)
attr.id = SAI_SWITCH_ATTR_INIT_SWITCH;
attr.value.booldata = true;
attrs.push_back(attr);

attr.id = SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY;
attr.value.ptr = (void *)on_fdb_event;
attrs.push_back(attr);
Expand Down Expand Up @@ -226,6 +233,13 @@ int main(int argc, char **argv)
sai_switch_api->set_switch_attribute(gSwitchId, &attr);
}

if (gAsicInstance)
{
attr.id = SAI_SWITCH_ATTR_SWITCH_HARDWARE_INFO;
attr.value.s8list.count = (uint32_t)(strlen(gAsicInstance)+1);
attr.value.s8list.list = (int8_t*)gAsicInstance;
attrs.push_back(attr);
}

status = sai_switch_api->create_switch(&gSwitchId, (uint32_t)attrs.size(), attrs.data());
if (status != SAI_STATUS_SUCCESS)
Expand Down

0 comments on commit d304673

Please sign in to comment.