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

Cherry-pick of master PR #1931 to v1.10 #1936

Closed
wants to merge 27 commits into from
Closed

Cherry-pick of master PR #1931 to v1.10 #1936

wants to merge 27 commits into from

Conversation

saksarav-nokia
Copy link
Contributor

Cherry-pick of master PR #1931 to v1.10 to add sai-thrift support to read VOQ counters from SAI

JaiOCP and others added 27 commits April 4, 2022 17:34
* Ecmp Member Count

wo new Switch attributes are introduced.
Read Only:
SAI_SWITCH_ATTR_MAX_ECMP_MEMBER_COUNT
This attribute is queried during switch init to find out device specific max number of ecmp members supported.

CREATE_AND_SET (read/write):
SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT
This attribute is set based on the query for MAX_ECMP_MEMBER_COUNT and can be changed dynamically.
If the SAI adapter doesn't support dynamic change of this attribute based on certain conditions like if ECMP groups are already configured then MUST return error.

Expected behavior when SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT is set to a value < SAI_SWITCH_ATTR_MAX_ECMP_MEMBER_COUNT?
SAI adapter should allocate the ECMP member count as specified by SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT. This can be changed dynamically; SAI adapter may return OK or ERROR based on if HW supports dynamic change of ECMP member count or not.
Decreasing of ecmp member count MUST always return ERROR. Increasing of ecmp member can be supported by newer generation of HW and return OK if supported.

Typical Workflow:

Switch object create
Switch get SAI_SWITCH_ATTR_MAX_ECMP_MEMBER_COUNT: say SAI adapter returns 2k
Switch set SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT
If step 3 is invoked after the system is fully configured and forwarding traffic
SAI adapter MAY return error if HW is not capable of dynamically adjusting the ECMP group size

Can you please clarify what is the expected hardware behavior when SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT is set to a value < SAI_SWITCH_ATTR_MAX_ECMP_MEMBER_COUNT

* Max ECMP Member Capability/Configuration

Signed-off-by: Jai Kumar <jai.kumar@broadcom.com>
Updated header file path to fix sonic build issue

Signed-off-by: Vineet Mittal <vineetmittal@microsoft.com>
This reverts commit 5e32f5c.

Signed-off-by: Rita Hui Rita.Hui@microsoft.com
* Ecmp Member Count

wo new Switch attributes are introduced.
Read Only:
SAI_SWITCH_ATTR_MAX_ECMP_MEMBER_COUNT
This attribute is queried during switch init to find out device specific max number of ecmp members supported.

CREATE_AND_SET (read/write):
SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT
This attribute is set based on the query for MAX_ECMP_MEMBER_COUNT and can be changed dynamically.
If the SAI adapter doesn't support dynamic change of this attribute based on certain conditions like if ECMP groups are already configured then MUST return error.

Expected behavior when SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT is set to a value < SAI_SWITCH_ATTR_MAX_ECMP_MEMBER_COUNT?
SAI adapter should allocate the ECMP member count as specified by SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT. This can be changed dynamically; SAI adapter may return OK or ERROR based on if HW supports dynamic change of ECMP member count or not.
Decreasing of ecmp member count MUST always return ERROR. Increasing of ecmp member can be supported by newer generation of HW and return OK if supported.

Typical Workflow:

Switch object create
Switch get SAI_SWITCH_ATTR_MAX_ECMP_MEMBER_COUNT: say SAI adapter returns 2k
Switch set SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT
If step 3 is invoked after the system is fully configured and forwarding traffic
SAI adapter MAY return error if HW is not capable of dynamically adjusting the ECMP group size

Can you please clarify what is the expected hardware behavior when SAI_SWITCH_ATTR_ECMP_MEMBER_COUNT is set to a value < SAI_SWITCH_ATTR_MAX_ECMP_MEMBER_COUNT

* Max ECMP Member Capability/Configuration

Signed-off-by: Jai Kumar <jai.kumar@broadcom.com>
* Bulk API for setting Port Attributes

Signed-off-by: Jai Kumar <jai.kumar@broadcom.com>
…) (#1473)

Those features are no longer present on new doxygen versions and are not used by metadata parser

Signed-off-by: Alexander Allen <arallen@nvidia.com>
Currently Python 3.7 is hardcoded into the debian build system here. These code changes allow other versions of python.

This was tested on Python 3.9 on Debian 11.

Signed-off-by: Alexander Allen <arallen@nvidia.com>
Signed-off-by: Vivek Reddy <vkarri@nvidia.com>

Co-authored-by: Vivek Reddy Karri <vkarri@r-build-sonic06.mtr.labs.mlnx>
* Build saithrift with python3.9 in bullseye

Bullseye upgrade the python to python3.9 and other image, like buster still using python 2.7.
To build with different python in different image, add a condition for copy differernt install file in different type of image.

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* change the release name to version number and reuse existing files

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Co-authored-by: richardyu <richardyu@contoso.com>

Co-authored-by: richardyu <richardyu@contoso.com>
…#1552) (#1533) (#1514) (#1492) (#1558) (#1557)

* Added missing dependencies required to run gensairpc.pl (#1492)

Fixes #1490

Co-authored-by: Chris Sommers <chrispsommers@gmail.com>

* Add GEN_SAIRPC_OPTS to pass flags to gensairpc.pl from top-level Make… (#1514)

* [doc] Add SAI metadata introduction presentation (#1487)

Small presentation about SAI metadata features added in last time.

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Add GEN_SAIRPC_OPTS to pass flags to gensairpc.pl from top-level Makefile or meta/Makefile

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

Co-authored-by: Kamil Cudnik <kcudnik@gmail.com>
Co-authored-by: Chris Sommers <chrispsommers@gmail.com>

* Saithriftv2 fixes for extensions (#1533)

* [doc] Add SAI metadata introduction presentation (#1487)

Small presentation about SAI metadata features added in last time.

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Add GEN_SAIRPC_OPTS to pass flags to gensairpc.pl from top-level Makefile or meta/Makefile

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Add static_cast<> to sairpcgen templates to avoid type mismatches for SAI extensions.

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Add new env variable SAIRPC_EXTRA_LIBS which gets passed to final linkage of saiserver, so user can pass in additional libraries.

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Add experimental to include path.

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Add experimental headers to CPPFLAGS passed to ctypesgen.

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Add VLAN and PortChannel test plan (#1480)

* Add VLAN and PortChannel test plan

For vlan, it includes:
1. Vlan functionalities
   - Flooding
   - Forwarding
   - Trunk/Access
   - Tagging/Untagging(802.1Q)
   - VLAN interface (RIF/SVI)
2. SAI APIs operations
   - Vlan Counters
   - Vlan and member list operations

For PortChannel, it includes:
1. Lag functionalities
    - Loadbalance
2. Lag SAI APIs
    - create/check/remove lag and lag member

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* Update lag_test_plan.md

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* Update lag_test_plan.md

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* remove cases not related to T0

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* Update lag_test_plan.md

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* Add VLAN and Lag test plan and put topo config in seperated files

Signed-off-by: richardyu <richardyu@contoso.com>

* fix typo and more description more clear

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* fix lag test typo (#29)

Signed-off-by: zhoudongxu <Dongxu.Zhou@microsoft.com>

* refactor vlan test plan and config

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* refactor lag test plan (#33)

Signed-off-by: zhoudongxu <Dongxu.Zhou@microsoft.com>

* refactor pc and vlan test

Signed-off-by: zhoudongxu <Dongxu.Zhou@microsoft.com>

* Improve pc and vlan test Doc (#35)

* fix typo

Signed-off-by: zhoudongxu <Dongxu.Zhou@microsoft.com>

* remove some unnecessary comments

Signed-off-by: zhoudongxu <Dongxu.Zhou@microsoft.com>

* reformat and adjust the description of the tests

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* set hash algorithm (#36)

Signed-off-by: zhoudongxu <Dongxu.Zhou@microsoft.com>

* refine lag test (#37)

Signed-off-by: zhoudongxu <Dongxu.Zhou@microsoft.com>

* correct vlan interface test (#38)

Signed-off-by: zhoudongxu <Dongxu.Zhou@microsoft.com>

* workaround for the sequence number issue in github and correct typo
standardise the ip and mac naming in config

add lag test for ingress port indifferenate in lag hash
redesign the mac and ip namin convention and reformat
Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* adjust the case numbers and vlan id

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Co-authored-by: zhoudongxu <1315364814@qq.com>
Co-authored-by: richardyu <richardyu@contoso.com>
Co-authored-by: zhoudongxu <Dongxu.Zhou@microsoft.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* [SAI-PTF] SAI PTF test structure for T0 test and VLAN,FDB sample cases (#1499)

* [SAI-PTF] Add SAI ptf test structure for T0 test

Create SAI PTF test structure for T0
1. Create configuration structure for different components configu
2. Add FDB, PORT, switch, vlan configurations
3. Create Test structure base on PTF
4. Add T0 test case samples for FDB

Test Done:
Checked the ports functionality with port flooding
Checked port forwarding base on FDB configurations

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* add vlan config and vlan test sample case

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* add dx010 config

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* [meta] Add sai_status_t to ancestry check (#1501)

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* reset sleep time during turning up ports (#1502)

Signed-off-by: Yang Wang <yangwang1@microsoft.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* [saineighbor] Bulk API support for Neighbor entries (#1504)

* Bulk support for Neighbor entries

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* add vlan testcases from Group6 to Group10 (#1506)

Signed-off-by: Yang Wang <yangwang1@microsoft.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Support counters on IP MC route entries. This is similar to the support added earlier for Route counters. (#1497)

Support counters on IP MC route entries. This is similar to the support added earlier for Route counters.

API sequence:

sai_attribute_t counter_attr;
attr.id = SAI_COUNTER_ATTR_TYPE;
attr.value.s32 = SAI_COUNTER_TYPE_REGULAR;
sai_object_id_t counter_id;
sai_status_t rc = sai_counter_api->create_counter(&counter_id, g_switch_id, 1, &attr);
sai_attribute_t ipmc_attr;
attr.id = SAI_IPMC_ENTRY_ATTR_COUNTER_ID;
attr.value.oid = counter_id;
rc = sai_ipmc_api->set_ipmc_entry_attribute(route_entry, ipmc_attr);
sai_stat_id_t stat_ids[] = { SAI_COUNTER_STAT_PACKETS, SAI_COUNTER_STAT_BYTES };
uint64_t stats[2];
rc = sai_counter_api->sai_get_counter_stats_ext(counter_id, 2, stat_ids, stats);

Signed-off-by: rck-innovium <rck@innovium.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Add thr missing API into saithriftv2 missing for syncd (#1484)

saithriftv1 offers start_sai_thrift_rpc_server API to start the saithrift server and syncd is currently using that API https://github.com/Azure/sonic-sairedis/blob/master/syncd/syncd_main.cpp#L60

But this API is missing from the for saithriftv2.

Made the relevant changes to provide a similar API for saithriftv2 library

The start_sai_thrift_rpc_server API currently resides in saiserver.cpp which is not included in librpcserver.a and is not available for the users of the static library. Thus moved the function definition into sai_rpc_frontend.cpp for including it in the static library.

Signed-off-by: Vivek Reddy Karri <vkarri@nvidia.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* add vlan test case (#1510)

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>

add vlan test case

edit FilteringTest

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>

edit vlan test case

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* add more waiting time for test (#1511)

* add more waiting time for test

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* Update fdb_configer.py

increase the waiting time for fdb entries update

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* remove useless change

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* add read config_db.json (#1519)

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>

format

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>

addomment for each function

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>

add comment for each function

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* [Fix]Add necessary test data file for sai test (#1520)

In order to set up the port on different platforms, need to read the data for port configuration when turning on the admin state

This PR is a bug fix for adding the config_db into test resources folder.

Test Done:
Test within SONiC mgmt container

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Zitingguo/add lag test (#1522)

* add lag config

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* enable lag config in test base

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* fix lag config

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* add remove_lag_member in lag_configer

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* add sai_ipprefix() in utils

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* fix typo

Signed-off-by: zitingguo <736034564@qq.com>

* import LagConfiger in sai_test_base

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* add a simple lag test

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* fix typo

Signed-off-by: zitingguo <736034564@qq.com>

* fix a config error in lag

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* add lag lb test based on scr port

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* fix

Signed-off-by: zitingguo <736034564@qq.com>

* set lag v4 hash

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* add lag disable egress test case

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* add IndifferenceIngressPortTest

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* fix set hash function

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* separate route configuration from lag

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* disable setting lag hash

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* add virtual interface

Signed-off-by: Ziting Guo <zitingguo@microsoft.com>
Signed-off-by: zitingguo <736034564@qq.com>

* Config default v4&v6 route

Signed-off-by: zitingguo <736034564@qq.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* add teardown for testing multiple cases at a time (#1521)

* add read config_db.json

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>

format

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>

addomment for each function

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>

add comment for each function

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>

* tear down

Signed-off-by: ms-junyi <t-junyixiao@microsoft.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Added missing dependencies required to run gensairpc.pl (#1492)

Fixes #1490

Co-authored-by: Chris Sommers <chrispsommers@gmail.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Update saitam.h (#1496)

Attribute is introduced to configure IPFIX template reporting interval as per the RFC7011.

https://datatracker.ietf.org/doc/html/rfc7011#section-8.4

Signed-off-by: Jai Kumar <jai.kumar@broadcom.com>
Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Pass SAIRPC_EXTRA_LIBS flag in Makefile

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

* Removed changes to include paths for SAI extension headers;
as it turns out these changes were not required as originally reported in #1531.

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

Co-authored-by: Kamil Cudnik <kcudnik@gmail.com>
Co-authored-by: Chris Sommers <chrispsommers@gmail.com>
Co-authored-by: Richard.Yu <richard.yu@microsoft.com>
Co-authored-by: zhoudongxu <1315364814@qq.com>
Co-authored-by: richardyu <richardyu@contoso.com>
Co-authored-by: zhoudongxu <Dongxu.Zhou@microsoft.com>
Co-authored-by: Yang Wang <yangwang1@microsoft.com>
Co-authored-by: Prince Sunny <prince.sunny@microsoft.com>
Co-authored-by: Ravindranath C K <rck@innovium.com>
Co-authored-by: Vivek R <vivekreddykarri98@gmail.com>
Co-authored-by: ms-junyi <106718431+ms-junyi@users.noreply.github.com>
Co-authored-by: zitingguo-ms <736034564@qq.com>
Co-authored-by: Jai Kumar <jai.kumar@broadcom.com>

* [SAI-PTF]Align the sai rpc front name with swss and syncd (#1552)

In Syncd starting process, it will try to start the switch and assign the gSwtichId to the sai implementation.
In the syncd rpc container, in order to get the swtich id after syncd initalization, we need to get and check the switch id.

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* Check for NULL APIs returned by sai_api_query() before calling. (#1558)

Signed-off-by: Chris Sommers <chrispsommers@gmail.com>

Co-authored-by: Chris Sommers <chrispsommers@gmail.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Co-authored-by: Chris Sommers <31145757+chrispsommers@users.noreply.github.com>
Co-authored-by: Chris Sommers <chrispsommers@gmail.com>
Co-authored-by: Kamil Cudnik <kcudnik@gmail.com>
Co-authored-by: zhoudongxu <1315364814@qq.com>
Co-authored-by: richardyu <richardyu@contoso.com>
Co-authored-by: zhoudongxu <Dongxu.Zhou@microsoft.com>
Co-authored-by: Yang Wang <yangwang1@microsoft.com>
Co-authored-by: Prince Sunny <prince.sunny@microsoft.com>
Co-authored-by: Ravindranath C K <rck@innovium.com>
Co-authored-by: Vivek R <vivekreddykarri98@gmail.com>
Co-authored-by: ms-junyi <106718431+ms-junyi@users.noreply.github.com>
Co-authored-by: zitingguo-ms <736034564@qq.com>
Co-authored-by: Jai Kumar <jai.kumar@broadcom.com>
* [SAI-PTF] Add decorator for skipping test on specified error (#1609)

* [SAI-PTF] Add decorator for skipping test on specified error

Add decorator method in the perl template  for skipping test on specified error

details:
1. add decorator method in sai_adapter_utils.tt
2. use decorator when set parameters ``skip_error``
3. add parameters when building from template, like ``perl -Irpc gensairpc.pl  --skip_error=-2,-3``
4. remove the new added parameters, add more doc
Test done:
make  rpc

Signed-off-by: richardyu <richardyu@contoso.com>

* Update sai_fdb_test.py

remove unnecessary test

Signed-off-by: Richard.Yu <richard.yu@microsoft.com>

Signed-off-by: richardyu <richardyu@contoso.com>
Signed-off-by: Richard.Yu <richard.yu@microsoft.com>
Co-authored-by: richardyu <richardyu@contoso.com>

* [SAI-PTF] Enhance the function for getting counters in sai_adapter.py (#1626)

* [SAI-PTF] Enhance the function for getting counters in sai_adapter.py

    Resolve issue #1614

    For the auto-generated adapter, need to add a parameter for which counter_id/counter_ids we want, in order to compatiable with current code and reduce the modification, we can define a constant parameter as the list of counter_ids, and use this constant as the default.

    Before

    ```
    def sai_thrift_get_bfd_session_stats(client,
                                         bfd_session_oid):

        counter_ids = []
        counter_ids.append(SAI_BFD_SESSION_STAT_IN_PACKETS)
        counter_ids.append(SAI_BFD_SESSION_STAT_OUT_PACKETS)
        counter_ids.append(SAI_BFD_SESSION_STAT_DROP_PACKETS)

        counters = [0] * 3
        global status
        status = SAI_STATUS_SUCCESS
    ```

    After the refactor
    ```
    sai_get_bfd_session_stats_counter_ids = []
    sai_get_bfd_session_stats_counter_ids.append(SAI_BFD_SESSION_STAT_IN_PACKETS)
    sai_get_bfd_session_stats_counter_ids.append(SAI_BFD_SESSION_STAT_OUT_PACKETS)
    sai_get_bfd_session_stats_counter_ids.append(SAI_BFD_SESSION_STAT_DROP_PACKETS)

    def sai_thrift_get_bfd_session_stats(client,
                                         bfd_session_oid,
                                         counter_ids=sai_get_bfd_session_stats_counter_ids):

        counters = [0] * 3
        global status
        status = SAI_STATUS_SUCCESS
    ```

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* make some enhancement on the code, add dict which can get the enum name by id

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Co-authored-by: richardyu <richardyu@contoso.com>

Signed-off-by: richardyu <richardyu@contoso.com>
Signed-off-by: Richard.Yu <richard.yu@microsoft.com>
Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Co-authored-by: richardyu <richardyu@contoso.com>
…helper (#1636) (#1637)

Add uninit API support in SAI-PTF and enhance the platform helper
- add interface for SAI-PTF to uninitalize the sai interface
- use the uninitalize interface to triger the ASIC data dump
> this change picked parts of the change in #1440, but without the warm reboot part.

Test Done:
Local Docker build for building the saiserver
Local testing environment

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
* add invocation logger

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* reformat code

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
* [SAI-PTF]add conditional import for unit test

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* [SAI-PTF]add conditional import for unit test

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Fix issue when transfer make param GEN_SAIRPC_OPTS with space in it

when transfer GEN_SAIRPC_OPTS with multi parameters in it and use the
space to split it, there is a issue for translate from build system to
actual make system.
```
--adapter_logger --skip_error=-2
```

add quota when transfer the parameter

Test Done:
Verified in local container
Verified in build system

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Why
In order to track the SAI-API result and add the return value for each SAI_thrift api.

How
In sai_adapter, use the invocation_logger, log the return value when sai_thrift API returned

Test:
Unit test and DUT test

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Why
Base on some requirement, when logging the return value is a dict, need return the value for each key as a string.

For example,  returning this.
```
 "[{
'client': <sai_thrift.sai_rpc.Client object at 0x7fd9b46861d0>,
'port_oid': 4294967303,
'hw_lane_list': sai_thrift_object_list_t(count=100, idlist=[1,2,34])
}]"
```
 it returned as (see the ' around the value too below)
 ```
"[{
'client': '<sai_thrift.sai_rpc.Client object at 0x7fd9b46861d0>',
'port_oid': '4294967303',
'hw_lane_list': 'sai_thrift_object_list_t(count=100, idlist=[1,2,34])'
}]"
```

How
Convert the dict value to string

Test:
Unit test and DUT test

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Why
Base on some requirement, when logging the arg values, need return the value for each key as a string.

For example,  returning this.
```
sai_adapter_invoke func:[sai_thrift_create_route_entry] args: [{'client': <sai_thrift.sai_rpc.Client object at 0x7f9e07154438>, 'route_entry': sai_thrift_route_entry_t(switch_id=None, vr_id=12884901888, destination=sai_thrift_ip_prefix_t(addr_family=1, addr=sai_thrift_ip_addr_t(ip4=None, ip6='0000:0000:0000:0000:0000:0000:0000:0000'), mask=sai_thrift_ip_addr_t(ip4=None, ip6='0000:0000:0000:0000:0000:0000:0000:0000'))), 'packet_action': 0}]
```
 Turn into
 ```
sai_adapter_invoke func:[sai_thrift_create_route_entry] args: [{'client': '<sai_thrift.sai_rpc.Client object at 0x7f9e07154438>', 'route_entry': 'sai_thrift_route_entry_t(switch_id=None, vr_id=12884901888, destination=sai_thrift_ip_prefix_t(addr_family=1, addr=sai_thrift_ip_addr_t(ip4=None, ip6='0000:0000:0000:0000:0000:0000:0000:0000'), mask=sai_thrift_ip_addr_t(ip4=None, ip6='0000:0000:0000:0000:0000:0000:0000:0000')))', 'packet_action': '0'}]
```

How
Convert the dict value to string

Test:
Unit test and DUT test

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Why
When hit the expected error like SAI_STATUS_NOT_SUPPORTED = -2, then skip the test.
related to issue #1610

How
Add conditional exeption handler when return from sai api invocation

Test:
Test on brcm platform on case sainexthop.tunnelVrfTest

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
PR check will be enabled after this PR merged.

Signed-off-by: shilongliu <shilongliu@microsoft.com>
it allows to use two different 'experimental' dirs during integration check, one belongs to current repository and another to origin/master

Signed-off-by: Anton Parkhomenko <aparkhomenko@larch-networks.com>
Co-authored-by: aparkhomenko-xsight <112386115+aparkhomenko-xsight@users.noreply.github.com>
* Enhance the check enum lock script
Why
workaround fix for git --work-tree=temp/ checkout ...
after checkout from other branch, data will be left in git

then in when running command from sonic-buildimage/rules/sairedis.dep, it will report
```
sonic-buildimage/rules/sairedis.dep
```

How
clean up the git env

Verify
run script

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

* enhance

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>

---------

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
…en into pythoon enum class (#1760)

why
cherry-pick from #1758
When ctypesgen generated the python code for c++ enum, the python cannot be logged by it enum name, we need to change it to enum class.
the code like
```C++
/**
 * @brief SAI common API type
 */
typedef enum _sai_common_api_t
{
    SAI_COMMON_API_CREATE      = 0,
    SAI_COMMON_API_REMOVE      = 1,
    SAI_COMMON_API_SET         = 2,
    SAI_COMMON_API_GET         = 3,
    SAI_COMMON_API_BULK_CREATE = 4,
    SAI_COMMON_API_BULK_REMOVE = 5,
    SAI_COMMON_API_BULK_SET    = 6,
    SAI_COMMON_API_BULK_GET    = 7,
    SAI_COMMON_API_MAX         = 8,
} sai_common_api_t;
```
original converted by ctypesgen
```
enum__sai_common_api_t = c_int# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183

sai_common_api_t = enum__sai_common_api_t# /usr/include/sai/saitypes.h: 183

enum__sai_object_type_t = c_int# /usr/include/sai/saitypes.h: 294
```
new code
```
class sai_common_api(SAIEnum):

    SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183

    SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183

    SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183

    SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183

    SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183

    SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183

    SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183

    SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183

    SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183

SAI_COMMON_API_CREATE = sai_common_api.SAI_COMMON_API_CREATE
SAI_COMMON_API_REMOVE = sai_common_api.SAI_COMMON_API_REMOVE
SAI_COMMON_API_SET = sai_common_api.SAI_COMMON_API_SET
SAI_COMMON_API_GET = sai_common_api.SAI_COMMON_API_GET
SAI_COMMON_API_BULK_CREATE = sai_common_api.SAI_COMMON_API_BULK_CREATE
SAI_COMMON_API_BULK_REMOVE = sai_common_api.SAI_COMMON_API_BULK_REMOVE
SAI_COMMON_API_BULK_SET = sai_common_api.SAI_COMMON_API_BULK_SET
SAI_COMMON_API_BULK_GET = sai_common_api.SAI_COMMON_API_BULK_GET
SAI_COMMON_API_MAX = sai_common_api.SAI_COMMON_API_MAX
```

how
Convert the python code after generated from ctypesgen

verify
pipeline
local testing



reformat



refactor code

Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Cherry-pick of Master PR: #1814 in v1.10
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
…rt_id and read VOQ counters for system port (#1931)

For VOQ Chassis, the following two API's are added

Reads all the system ports in the switch from SAI and returns the sai_object_id of the system port requested by the sonic-mgmt.
Takes the sai_object_id of the system port and returns all the VOQs for that system port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants