Skip to content

Commit 017056a

Browse files
minionatworkvedganes
and
vedganes
authored
Support System ports config (#657)
This PR includes implementation of System ports initialization & orchestration, Interface & Neighbor Synchronization using GLOBAL_APP_DB, Inband Interface Configuration. HLD: sonic-net/SONiC#639 Dependency PR(sonic-swss-common): sonic-net/sonic-swss-common#380 Co-authored-by: vedganes <[email protected]>
1 parent 0f3668f commit 017056a

File tree

2 files changed

+208
-0
lines changed

2 files changed

+208
-0
lines changed

meta/Meta.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -3351,6 +3351,11 @@ void Meta::meta_generic_validation_post_remove(
33513351
// no special action required
33523352
break;
33533353

3354+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
3355+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
3356+
// no special action required
3357+
break;
3358+
33543359
default:
33553360
META_LOG_THROW(md, "serialization type is not supported yet FIXME");
33563361
}
@@ -4565,6 +4570,13 @@ sai_status_t Meta::meta_generic_validation_create(
45654570
break;
45664571
}
45674572

4573+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
4574+
VALIDATION_LIST(md, value.sysportconfiglist);
4575+
break;
4576+
4577+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
4578+
break;
4579+
45684580
default:
45694581

45704582
META_LOG_THROW(md, "serialization type is not supported yet FIXME");
@@ -5196,6 +5208,13 @@ sai_status_t Meta::meta_generic_validation_set(
51965208
VALIDATION_LIST(md, value.aclcapability.action_list);
51975209
break;
51985210

5211+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
5212+
VALIDATION_LIST(md, value.sysportconfiglist);
5213+
break;
5214+
5215+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
5216+
break;
5217+
51995218
default:
52005219

52015220
META_LOG_THROW(md, "serialization type is not supported yet FIXME");
@@ -5557,6 +5576,13 @@ sai_status_t Meta::meta_generic_validation_get(
55575576
VALIDATION_LIST(md, value.aclcapability.action_list);
55585577
break;
55595578

5579+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
5580+
break;
5581+
5582+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
5583+
VALIDATION_LIST(md, value.sysportconfiglist);
5584+
break;
5585+
55605586
default:
55615587

55625588
// acl capability will is more complex since is in/out we need to check stage
@@ -5798,6 +5824,13 @@ void Meta::meta_generic_validation_post_get(
57985824

57995825
break;
58005826

5827+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
5828+
break;
5829+
5830+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
5831+
VALIDATION_LIST_GET(md, value.sysportconfiglist);
5832+
break;
5833+
58015834
default:
58025835

58035836
META_LOG_THROW(md, "serialization type is not supported yet FIXME");
@@ -6679,6 +6712,11 @@ void Meta::meta_generic_validation_post_create(
66796712
// no special action required
66806713
break;
66816714

6715+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
6716+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
6717+
// no special action required
6718+
break;
6719+
66826720
default:
66836721

66846722
META_LOG_THROW(md, "serialization type is not supported yet FIXME");
@@ -6906,6 +6944,11 @@ void Meta::meta_generic_validation_post_set(
69066944
// no special action required
69076945
break;
69086946

6947+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
6948+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
6949+
// no special action required
6950+
break;
6951+
69096952
default:
69106953
META_LOG_THROW(md, "serialization type is not supported yet FIXME");
69116954
}

meta/saiserialize.cpp

+165
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,14 @@ sai_status_t transfer_attribute(
400400
RETURN_ON_ERROR(transfer_list(src_attr.value.aclcapability.action_list, dst_attr.value.aclcapability.action_list, countOnly));
401401
break;
402402

403+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
404+
transfer_primitive(src_attr.value.sysportconfig, dst_attr.value.sysportconfig);
405+
break;
406+
407+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
408+
RETURN_ON_ERROR(transfer_list(src_attr.value.sysportconfiglist, dst_attr.value.sysportconfiglist, countOnly));
409+
break;
410+
403411
default:
404412
return SAI_STATUS_NOT_IMPLEMENTED;
405413
}
@@ -1398,6 +1406,73 @@ std::string sai_serialize_acl_capability(
13981406
return mandatory + ":" + list;
13991407
}
14001408

1409+
std::string sai_serialize_system_port_config(
1410+
_In_ const sai_attr_metadata_t &meta,
1411+
_In_ const sai_system_port_config_t &sysportconfig)
1412+
{
1413+
SWSS_LOG_ENTER();
1414+
1415+
json j;
1416+
1417+
j["port_id"] = sai_serialize_number(sysportconfig.port_id, false);
1418+
j["attached_switch_id"] = sai_serialize_number(sysportconfig.attached_switch_id, false);
1419+
j["attached_core_index"] = sai_serialize_number(sysportconfig.attached_core_index, false);
1420+
j["attached_core_port_index"] = sai_serialize_number(sysportconfig.attached_core_port_index, false);
1421+
j["speed"] = sai_serialize_number(sysportconfig.speed, false);
1422+
j["num_voq"] = sai_serialize_number(sysportconfig.num_voq, false);
1423+
1424+
return j.dump();
1425+
}
1426+
1427+
json sai_serialize_system_port_cfg_list_item(
1428+
_In_ const sai_system_port_config_t &sysportconfig)
1429+
{
1430+
SWSS_LOG_ENTER();
1431+
1432+
json j;
1433+
1434+
j["port_id"] = sai_serialize_number(sysportconfig.port_id, false);
1435+
j["attached_switch_id"] = sai_serialize_number(sysportconfig.attached_switch_id, false);
1436+
j["attached_core_index"] = sai_serialize_number(sysportconfig.attached_core_index, false);
1437+
j["attached_core_port_index"] = sai_serialize_number(sysportconfig.attached_core_port_index, false);
1438+
j["speed"] = sai_serialize_number(sysportconfig.speed, false);
1439+
j["num_voq"] = sai_serialize_number(sysportconfig.num_voq, false);
1440+
1441+
return j;
1442+
}
1443+
1444+
std::string sai_serialize_system_port_config_list(
1445+
_In_ const sai_attr_metadata_t &meta,
1446+
_In_ const sai_system_port_config_list_t& sysportconfiglist,
1447+
_In_ bool countOnly)
1448+
{
1449+
SWSS_LOG_ENTER();
1450+
1451+
json j;
1452+
1453+
j["count"] = sysportconfiglist.count;
1454+
1455+
if (sysportconfiglist.list == NULL || countOnly)
1456+
{
1457+
j["list"] = nullptr;
1458+
1459+
return j.dump();
1460+
}
1461+
1462+
json arr = json::array();
1463+
1464+
for (uint32_t i = 0; i < sysportconfiglist.count; ++i)
1465+
{
1466+
json item = sai_serialize_system_port_cfg_list_item(sysportconfiglist.list[i]);
1467+
1468+
arr.push_back(item);
1469+
}
1470+
1471+
j["list"] = arr;
1472+
1473+
return j.dump();
1474+
}
1475+
14011476
std::string sai_serialize_attr_value(
14021477
_In_ const sai_attr_metadata_t& meta,
14031478
_In_ const sai_attribute_t &attr,
@@ -1533,6 +1608,12 @@ std::string sai_serialize_attr_value(
15331608
case SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY:
15341609
return sai_serialize_acl_capability(meta, attr.value.aclcapability, countOnly);
15351610

1611+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
1612+
return sai_serialize_system_port_config(meta, attr.value.sysportconfig);
1613+
1614+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
1615+
return sai_serialize_system_port_config_list(meta, attr.value.sysportconfiglist, countOnly);
1616+
15361617
default:
15371618
SWSS_LOG_THROW("FATAL: invalid serialization type %d", meta.attrvaluetype);
15381619
}
@@ -2566,6 +2647,77 @@ void sai_deserialize_acl_capability(
25662647
sai_deserialize_enum_list(list, &sai_metadata_enum_sai_acl_action_type_t, cap.action_list, false);
25672648
}
25682649

2650+
void sai_deserialize_system_port_config(
2651+
_In_ const std::string& s,
2652+
_Out_ sai_system_port_config_t& sysportconfig)
2653+
{
2654+
SWSS_LOG_ENTER();
2655+
2656+
json j = json::parse(s);
2657+
2658+
sai_deserialize_number(j["port_id"], sysportconfig.port_id, false);
2659+
sai_deserialize_number(j["attached_switch_id"], sysportconfig.attached_switch_id, false);
2660+
sai_deserialize_number(j["attached_core_index"], sysportconfig.attached_core_index, false);
2661+
sai_deserialize_number(j["attached_core_port_index"], sysportconfig.attached_core_port_index, false);
2662+
sai_deserialize_number(j["speed"], sysportconfig.speed, false);
2663+
sai_deserialize_number(j["num_voq"], sysportconfig.num_voq, false);
2664+
2665+
}
2666+
2667+
void sai_deserialize_system_port_cfg_list_item(
2668+
_In_ const json& j,
2669+
_Out_ sai_system_port_config_t& sysportconfig)
2670+
{
2671+
SWSS_LOG_ENTER();
2672+
2673+
sai_deserialize_number(j["port_id"], sysportconfig.port_id, false);
2674+
sai_deserialize_number(j["attached_switch_id"], sysportconfig.attached_switch_id, false);
2675+
sai_deserialize_number(j["attached_core_index"], sysportconfig.attached_core_index, false);
2676+
sai_deserialize_number(j["attached_core_port_index"], sysportconfig.attached_core_port_index, false);
2677+
sai_deserialize_number(j["speed"], sysportconfig.speed, false);
2678+
sai_deserialize_number(j["num_voq"], sysportconfig.num_voq, false);
2679+
}
2680+
2681+
void sai_deserialize_system_port_config_list(
2682+
_In_ const std::string& s,
2683+
_Out_ sai_system_port_config_list_t& sysportconfiglist,
2684+
_In_ bool countOnly)
2685+
{
2686+
SWSS_LOG_ENTER();
2687+
2688+
json j = json::parse(s);
2689+
2690+
sysportconfiglist.count = j["count"];
2691+
2692+
if (countOnly)
2693+
{
2694+
return;
2695+
}
2696+
2697+
if (j["list"] == nullptr)
2698+
{
2699+
sysportconfiglist.list = NULL;
2700+
return;
2701+
}
2702+
2703+
json arr = j["list"];
2704+
2705+
if (arr.size() != (size_t)sysportconfiglist.count)
2706+
{
2707+
SWSS_LOG_ERROR("system port config list count mismatch %lu vs %u", arr.size(), sysportconfiglist.count);
2708+
throw std::runtime_error("system port config list count mismatch");
2709+
}
2710+
2711+
sysportconfiglist.list = sai_alloc_n_of_ptr_type(sysportconfiglist.count, sysportconfiglist.list);
2712+
2713+
for (uint32_t i = 0; i < sysportconfiglist.count; ++i)
2714+
{
2715+
const json& item = arr[i];
2716+
2717+
sai_deserialize_system_port_cfg_list_item(item, sysportconfiglist.list[i]);
2718+
}
2719+
}
2720+
25692721
void sai_deserialize_attr_value(
25702722
_In_ const std::string& s,
25712723
_In_ const sai_attr_metadata_t& meta,
@@ -2704,6 +2856,12 @@ void sai_deserialize_attr_value(
27042856
case SAI_ATTR_VALUE_TYPE_ACL_CAPABILITY:
27052857
return sai_deserialize_acl_capability(s, attr.value.aclcapability);
27062858

2859+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
2860+
return sai_deserialize_system_port_config(s, attr.value.sysportconfig);
2861+
2862+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
2863+
return sai_deserialize_system_port_config_list(s, attr.value.sysportconfiglist, countOnly);
2864+
27072865
default:
27082866
SWSS_LOG_THROW("deserialize type %d is not supportd yet FIXME", meta.attrvaluetype);
27092867
}
@@ -3269,6 +3427,13 @@ void sai_deserialize_free_attribute_value(
32693427
sai_free_list(attr.value.aclcapability.action_list);
32703428
break;
32713429

3430+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG:
3431+
break;
3432+
3433+
case SAI_ATTR_VALUE_TYPE_SYSTEM_PORT_CONFIG_LIST:
3434+
sai_free_list(attr.value.sysportconfiglist);
3435+
break;
3436+
32723437
default:
32733438
SWSS_LOG_THROW("unsupported type %d on deserialize free, FIXME", type);
32743439
}

0 commit comments

Comments
 (0)