Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multi-AISC] Pass the asic instance as SAI attribute during switch_create #1269

Merged
merged 4 commits into from
Apr 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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