diff --git a/.azure-pipelines/official-build-cisco-8000.yml b/.azure-pipelines/official-build-cisco-8000.yml index bfeecbc81387..aeec64a848a1 100644 --- a/.azure-pipelines/official-build-cisco-8000.yml +++ b/.azure-pipelines/official-build-cisco-8000.yml @@ -44,7 +44,7 @@ stages: path: s/platform/cisco-8000 displayName: 'Checkout cisco-8000' - script: | - cisco_ref=(cat platform/checkout/cisco-8000.ini | grep '^ref=' | cut -d= -f2) + cisco_ref=$(cat platform/checkout/cisco-8000.ini | grep '^ref=' | cut -d= -f2) echo "The cisco 8000 release version is $cisco_ref" echo "##vso[task.setvariable variable=cisco.ref]$cisco_ref" displayName: 'Export cisco release version' diff --git a/.gitmodules b/.gitmodules index c4dca89b607a..c976fe6fab1b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -97,3 +97,6 @@ [submodule "platform/broadcom/sonic-platform-modules-nokia"] path = platform/broadcom/sonic-platform-modules-nokia url = https://github.com/nokia/sonic-platform.git +[submodule "src/linkmgrd"] + path = src/linkmgrd + url = https://github.com/Azure/sonic-linkmgrd.git diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/ACS-MSN2010/port_config.ini b/device/mellanox/x86_64-mlnx_msn2010-r0/ACS-MSN2010/port_config.ini index f9fa81669a13..7c67e9a482e1 100644 --- a/device/mellanox/x86_64-mlnx_msn2010-r0/ACS-MSN2010/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/ACS-MSN2010/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes index Ethernet0 0 1 Ethernet4 4 2 diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/ACS-MSN2010/sai_2010.xml b/device/mellanox/x86_64-mlnx_msn2010-r0/ACS-MSN2010/sai_2010.xml index 3383a5f406ef..6d8e9c910419 100644 --- a/device/mellanox/x86_64-mlnx_msn2010-r0/ACS-MSN2010/sai_2010.xml +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/ACS-MSN2010/sai_2010.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn2010-r0/pcie.yaml index ca73122aaa81..c5cd9b9666da 100644 --- a/device/mellanox/x86_64-mlnx_msn2010-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/pcie.yaml @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# - bus: '00' dev: '00' fn: '0' diff --git a/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py index 0d864849dc48..377232699ea3 100644 --- a/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2010-r0/plugins/psuutil.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/port_config.ini b/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/port_config.ini index c7ea79bbdbee..b6658dfba546 100644 --- a/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes index Ethernet0 0,1,2,3 1 Ethernet4 4,5,6,7 2 diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/qos.json.j2 index 3e548325ea30..0fab01e69a95 100644 --- a/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/qos.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/qos.json.j2 @@ -1 +1,17 @@ +{# + Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- include 'qos_config.j2' %} diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/sai_2100.xml b/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/sai_2100.xml index efa0ccd2721f..3460f80e074c 100644 --- a/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/sai_2100.xml +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/ACS-MSN2100/sai_2100.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn2100-r0/pcie.yaml index 63f09eecde7c..9202ae5515a2 100644 --- a/device/mellanox/x86_64-mlnx_msn2100-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/pcie.yaml @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# - bus: '00' dev: '00' fn: '0' diff --git a/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py index 2b4f87397bc4..a796b63dddec 100644 --- a/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2100-r0/plugins/psuutil.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/port_config.ini b/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/port_config.ini index 782949e5706a..6303cc593633 100644 --- a/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes index Ethernet0 0 1 Ethernet4 4 2 diff --git a/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/qos.json.j2 index 3e548325ea30..0fab01e69a95 100644 --- a/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/qos.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/qos.json.j2 @@ -1 +1,17 @@ +{# + Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- include 'qos_config.j2' %} diff --git a/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/sai_2410.xml b/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/sai_2410.xml index 03d694c97723..a4cb1df39571 100644 --- a/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/sai_2410.xml +++ b/device/mellanox/x86_64-mlnx_msn2410-r0/ACS-MSN2410/sai_2410.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers.json.j2 index 1083a6210fc9..434b2751f42c 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers.json.j2 @@ -1,2 +1,18 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- set default_topo = 't0' %} {%- include 'buffers_config.j2' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t0.j2 index 37230af25627..fa419e5a85e4 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '4580864' %} {% set ingress_lossy_pool_size = '4580864' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t1.j2 index 6adfd1f26f23..e1b3419283ef 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '3302912' %} {% set ingress_lossy_pool_size = '3302912' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_dynamic.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_dynamic.json.j2 index 5954cc77c114..3c7f67da0f41 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_dynamic.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_dynamic.json.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- set default_topo = 't0' %} {%- set dynamic_mode = 'true' %} {%- include 'buffers_config.j2' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/pg_profile_lookup.ini index 7abb2a058d1b..9cac7af8c2fa 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/pg_profile_lookup.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # PG lossless profiles. # speed cable size xon xoff threshold 10000 5m 49152 19456 29696 0 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/port_config.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/port_config.ini index c1e59909c0fb..3205ee7a66bd 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index Ethernet0 0,1,2,3 etp1 1 Ethernet4 4,5,6,7 etp2 2 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/qos.json.j2 index 3e548325ea30..68a41d8d5975 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/qos.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/qos.json.j2 @@ -1 +1,17 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- include 'qos_config.j2' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/sai_2700.xml b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/sai_2700.xml index f025df1d3ef0..fc3d46a4b057 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/sai_2700.xml +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/ACS-MSN2700/sai_2700.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/port_config.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/port_config.ini index 653a61ecc23c..a8372f7271b7 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed Ethernet0 0,1,2,3 etp1 1 100000 Ethernet4 4,5,6,7 etp2 2 100000 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/sai_2700_8x50g_28x100g.xml b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/sai_2700_8x50g_28x100g.xml index 3127518b21a9..d7e64e106454 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/sai_2700_8x50g_28x100g.xml +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/sai_2700_8x50g_28x100g.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/pg_profile_lookup.ini index cdd674e4e715..b73975ed89bc 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/pg_profile_lookup.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # PG lossless profiles. # speed cable size xon xoff threshold 10000 5m 19456 19456 22528 0 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/port_config.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/port_config.ini index b4072ceb32a1..d13e9a2c4433 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed Ethernet0 0 etp1a 1 10000 Ethernet1 1 etp1b 1 10000 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/qos.json.j2 index 3e548325ea30..0fab01e69a95 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/qos.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/qos.json.j2 @@ -1 +1,17 @@ +{# + Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- include 'qos_config.j2' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai_2700_8x100g_40x50g_8x10g.xml b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai_2700_8x100g_40x50g_8x10g.xml index bc2d1509fd36..ec4cdf11cad8 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai_2700_8x100g_40x50g_8x10g.xml +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai_2700_8x100g_40x50g_8x10g.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t0.j2 index db4d794ad3cd..0223726dc324 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '7719936' %} {% set ingress_lossless_pool_xoff = '1032192' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t1.j2 index 54e4aaa4b55d..facab67a7a95 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '9686016' %} {% set ingress_lossless_pool_xoff = '1179648' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/pg_profile_lookup.ini index b4bb2aaadb92..05cfe57a8ec2 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/pg_profile_lookup.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # PG lossless profiles. # speed cable size xon xoff threshold 10000 5m 19456 19456 22528 0 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/port_config.ini b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/port_config.ini index 830f558fb383..cb118d692d79 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed Ethernet0 0,1 etp1a 1 50000 Ethernet2 2,3 etp1b 1 50000 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 index 3e548325ea30..94bd7dda2c37 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/qos.json.j2 @@ -1 +1,17 @@ +{# + Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- include 'qos_config.j2' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/sai_2700_48x50g_8x100g.xml b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/sai_2700_48x50g_8x100g.xml index 5d92ffd45e91..44e1962fa110 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/sai_2700_48x50g_8x100g.xml +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/sai_2700_48x50g_8x100g.xml @@ -1,270 +1,286 @@ - - - - - - 00:02:03:04:05:00 - - - 1 - - - 32 - - - - - 1 - 4 - 16 - - - 3 - - - 3221487616 - 2 - - - 3 - 4 - 17 - 1 - 3221487616 - 2 - - - 5 - 4 - 18 - 3 - 3221487616 - 2 - - - 7 - 4 - 19 - 1 - 3221487616 - 2 - - - 9 - 4 - 20 - 3 - 3221487616 - 2 - - - 11 - 4 - 21 - 1 - 3221487616 - 2 - - - 13 - 4 - 22 - 3 - 11534336 - - - 15 - 4 - 23 - 1 - 11534336 - - - 17 - 4 - 24 - 3 - 11534336 - - - 19 - 4 - 25 - 1 - 11534336 - - - 21 - 4 - 26 - 3 - 3221487616 - 2 - - - 23 - 4 - 27 - 1 - 3221487616 - 2> - - - 25 - 4 - 28 - 3 - 3221487616 - 2 - - - 27 - 4 - 29 - 1 - 3221487616 - 2 - - - 29 - 4 - 30 - 3 - 3221487616 - 2 - - - 31 - 4 - 31 - 1 - 3221487616 - 2 - - - 33 - 4 - 14 - 3 - 3221487616 - 2 - - - 35 - 4 - 15 - 1 - 3221487616 - 2 - - - 37 - 4 - 12 - 3 - 3221487616 - 2 - - - 39 - 4 - 13 - 1 - 3221487616 - 2 - - - 41 - 4 - 10 - 3 - 3221487616 - 2 - - - 43 - 4 - 11 - 1 - 3221487616 - 2 - - - 45 - 4 - 8 - 3 - 11534336 - - - 47 - 4 - 9 - 1 - 11534336 - - - 49 - 4 - 6 - 3 - 11534336 - - - 51 - 4 - 7 - 1 - 11534336 - - - 53 - 4 - 4 - 3 - 3221487616 - 2 - - - 55 - 4 - 5 - 1 - 3221487616 - 2 - - - 57 - 4 - 2 - 3 - 3221487616 - 2 - - - 59 - 4 - 3 - 1 - 3221487616 - 2 - - - 61 - 4 - 0 - 3 - 3221487616 - 2 - - - 63 - 4 - 1 - 1 - 3221487616 - 2 - - - - + + + + + + + 00:02:03:04:05:00 + + + 1 + + + 32 + + + + + 1 + 4 + 16 + + + 3 + + + 3221487616 + 2 + + + 3 + 4 + 17 + 1 + 3221487616 + 2 + + + 5 + 4 + 18 + 3 + 3221487616 + 2 + + + 7 + 4 + 19 + 1 + 3221487616 + 2 + + + 9 + 4 + 20 + 3 + 3221487616 + 2 + + + 11 + 4 + 21 + 1 + 3221487616 + 2 + + + 13 + 4 + 22 + 3 + 11534336 + + + 15 + 4 + 23 + 1 + 11534336 + + + 17 + 4 + 24 + 3 + 11534336 + + + 19 + 4 + 25 + 1 + 11534336 + + + 21 + 4 + 26 + 3 + 3221487616 + 2 + + + 23 + 4 + 27 + 1 + 3221487616 + 2> + + + 25 + 4 + 28 + 3 + 3221487616 + 2 + + + 27 + 4 + 29 + 1 + 3221487616 + 2 + + + 29 + 4 + 30 + 3 + 3221487616 + 2 + + + 31 + 4 + 31 + 1 + 3221487616 + 2 + + + 33 + 4 + 14 + 3 + 3221487616 + 2 + + + 35 + 4 + 15 + 1 + 3221487616 + 2 + + + 37 + 4 + 12 + 3 + 3221487616 + 2 + + + 39 + 4 + 13 + 1 + 3221487616 + 2 + + + 41 + 4 + 10 + 3 + 3221487616 + 2 + + + 43 + 4 + 11 + 1 + 3221487616 + 2 + + + 45 + 4 + 8 + 3 + 11534336 + + + 47 + 4 + 9 + 1 + 11534336 + + + 49 + 4 + 6 + 3 + 11534336 + + + 51 + 4 + 7 + 1 + 11534336 + + + 53 + 4 + 4 + 3 + 3221487616 + 2 + + + 55 + 4 + 5 + 1 + 3221487616 + 2 + + + 57 + 4 + 2 + 3 + 3221487616 + 2 + + + 59 + 4 + 3 + 1 + 3221487616 + 2 + + + 61 + 4 + 0 + 3 + 3221487616 + 2 + + + 63 + 4 + 1 + 1 + 3221487616 + 2 + + + + diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t0.j2 index 0627adbbf202..a3ab8870f7f5 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '10177536' %} {% set ingress_lossless_pool_xoff = '688128' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t1.j2 index afc6ba46e0c9..5f58f631ed1b 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '8719360' %} {% set ingress_lossless_pool_xoff = '2146304' %} diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn2700-r0/pcie.yaml index 8796390b73c6..440afffc3256 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/pcie.yaml @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# - bus: '00' dev: '00' fn: '0' diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py index 0f20ffff3b53..768ee5e72183 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/eeprom.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/fanutil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/fanutil.py index ee6446e7c053..6d54455af408 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/fanutil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/fanutil.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py index 6da5770c294f..915c90bf25a6 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/psuutil.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmget.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmget.py index ca16c3573d06..c149d51bdde9 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmget.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmget.py @@ -1,4 +1,20 @@ #!/usr/bin/env python3 +# +# Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# """ This utility get the power mode of a given module. diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py index 61423880ac71..6fa34d9b71aa 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfplpmset.py @@ -1,4 +1,20 @@ #!/usr/bin/env python3 +# +# Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# """ This utility set the power mode of a given module. diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfpreset.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfpreset.py index af237b705e9f..e49186c10609 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfpreset.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfpreset.py @@ -1,4 +1,20 @@ #!/usr/bin/env python3 +# +# Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# """ This utility reset the given SFP module. diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py index 952620dc22f8..bef3a3e7a7b5 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/sfputil.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # sfputil.py # # Platform-specific SFP transceiver interface for SONiC diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/thermalutil.py b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/thermalutil.py index 980ef8a9fc38..8ee172feacdd 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/thermalutil.py +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/plugins/thermalutil.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/device/mellanox/x86_64-mlnx_msn2740-r0/ACS-MSN2740/port_config.ini b/device/mellanox/x86_64-mlnx_msn2740-r0/ACS-MSN2740/port_config.ini index 2ef052c68d52..6ade639701d8 100644 --- a/device/mellanox/x86_64-mlnx_msn2740-r0/ACS-MSN2740/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn2740-r0/ACS-MSN2740/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes index Ethernet0 0,1,2,3 1 Ethernet4 4,5,6,7 2 diff --git a/device/mellanox/x86_64-mlnx_msn2740-r0/ACS-MSN2740/sai_2740.xml b/device/mellanox/x86_64-mlnx_msn2740-r0/ACS-MSN2740/sai_2740.xml index a21dc696ddd9..fe584ea7a027 100644 --- a/device/mellanox/x86_64-mlnx_msn2740-r0/ACS-MSN2740/sai_2740.xml +++ b/device/mellanox/x86_64-mlnx_msn2740-r0/ACS-MSN2740/sai_2740.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn2740-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn2740-r0/pcie.yaml index ca73122aaa81..c5cd9b9666da 100644 --- a/device/mellanox/x86_64-mlnx_msn2740-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn2740-r0/pcie.yaml @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# - bus: '00' dev: '00' fn: '0' diff --git a/device/mellanox/x86_64-mlnx_msn3420-r0/ACS-MSN3420/port_config.ini b/device/mellanox/x86_64-mlnx_msn3420-r0/ACS-MSN3420/port_config.ini index 38441f21f003..ba1995749076 100644 --- a/device/mellanox/x86_64-mlnx_msn3420-r0/ACS-MSN3420/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn3420-r0/ACS-MSN3420/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index Ethernet0 0 etp1 1 Ethernet4 4 etp2 2 diff --git a/device/mellanox/x86_64-mlnx_msn3420-r0/ACS-MSN3420/sai_3420.xml b/device/mellanox/x86_64-mlnx_msn3420-r0/ACS-MSN3420/sai_3420.xml index 5064ee3ef81b..73ab81a18b1a 100644 --- a/device/mellanox/x86_64-mlnx_msn3420-r0/ACS-MSN3420/sai_3420.xml +++ b/device/mellanox/x86_64-mlnx_msn3420-r0/ACS-MSN3420/sai_3420.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t0.j2 index f795c2016843..58976bb6b16e 100644 --- a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '14542848' %} {% set ingress_lossy_pool_size = '14542848' %} diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t1.j2 index 68eaf2d7816a..a08431935327 100644 --- a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '11622400' %} {% set ingress_lossy_pool_size = '11622400' %} diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/pg_profile_lookup.ini index 2e420e15871a..85c3b15f29e7 100644 --- a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/pg_profile_lookup.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # PG lossless profiles. # speed cable size xon xoff threshold 10000 5m 52224 19456 32768 0 diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/sai_3700.xml b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/sai_3700.xml index a7ac42950668..4234a4c1d000 100644 --- a/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/sai_3700.xml +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/ACS-MSN3700/sai_3700.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn3700-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn3700-r0/pcie.yaml index f9c4a2573153..7f2f50aab240 100644 --- a/device/mellanox/x86_64-mlnx_msn3700-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn3700-r0/pcie.yaml @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# - bus: '00' dev: '00' fn: '0' diff --git a/device/mellanox/x86_64-mlnx_msn3700c-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn3700c-r0/pcie.yaml index 6daf5eefa130..3c3006b5b4c8 100644 --- a/device/mellanox/x86_64-mlnx_msn3700c-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn3700c-r0/pcie.yaml @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# - bus: '00' dev: '00' fn: '0' diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t0.j2 index 82631fa1b3f3..94c758ddbe49 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '13924352' %} {% set ingress_lossy_pool_size = '13924352' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t1.j2 index 44ef77cf93e9..22c6836a5842 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '12457984' %} {% set ingress_lossy_pool_size = '12457984' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/pg_profile_lookup.ini index 320daa45d29b..a025c159759e 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/pg_profile_lookup.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # PG lossless profiles. # speed cable size xon xoff threshold 10000 5m 54272 19456 34816 0 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/port_config.ini b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/port_config.ini index d43b11a22eb6..ad1883259f2a 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index Ethernet0 0,1,2,3 etp1 1 Ethernet4 4,5,6,7 etp2 2 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/sai_3800.xml b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/sai_3800.xml index 4d9cc3cf7f8c..85d33f9da6c8 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/sai_3800.xml +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/ACS-MSN3800/sai_3800.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t0.j2 index 7f7a7f7c7f7f..a1df6848c759 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '25866240' %} {% set ingress_lossless_pool_xoff = '2523136' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t1.j2 index 7ab2d7cddb3d..d7c057f7d293 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '24219648' %} {% set ingress_lossless_pool_xoff = '4169728' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t0.j2 index 51939d1ab3fc..ccaaff955bf5 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '20664320' %} {% set ingress_lossless_xoff_size = '3321856' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t1.j2 index 5327842e9d1b..5a45a617d539 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '19601408' %} {% set ingress_lossless_xoff_size = '4384768' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/port_config.ini b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/port_config.ini index 535556ebfb3b..e092e0810f6a 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed Ethernet0 0,1 etp1a 1 50000 Ethernet2 2,3 etp1b 1 50000 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/sai_3800_2x10g_100x50g_12x100g.xml b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/sai_3800_2x10g_100x50g_12x100g.xml index bf0fa4ca6909..b50bc30fb9a1 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/sai_3800_2x10g_100x50g_12x100g.xml +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/sai_3800_2x10g_100x50g_12x100g.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t0.j2 index 8b2f123f2e76..a741c0fe233b 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '20017152' %} {% set ingress_lossless_pool_xoff = '3440640' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t1.j2 index b6e9490fe28c..3b1265ec178f 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '19124224' %} {% set ingress_lossless_pool_xoff = '4333568' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/pg_profile_lookup.ini index fd98cbe468bc..84b2ea701961 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/pg_profile_lookup.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # PG lossless profiles. # speed cable size xon xoff threshold 10000 5m 19456 19456 25600 0 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/port_config.ini b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/port_config.ini index 8e40d6bd41ec..d3a100a8486d 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed Ethernet0 0,1 etp1a 1 50000 Ethernet2 2,3 etp1b 1 50000 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/sai_3800_112x50g_8x100g.xml b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/sai_3800_112x50g_8x100g.xml index a72edb85633d..585ccf044f9e 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/sai_3800_112x50g_8x100g.xml +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/sai_3800_112x50g_8x100g.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t0.j2 index dc5342b10a80..b4baab413ab4 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '24576000' %} {% set ingress_lossless_pool_xoff = '2756608' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t1.j2 index fefb9e60f870..d02d98764ca8 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '22597632' %} {% set ingress_lossless_pool_xoff = '4734976' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/port_config.ini b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/port_config.ini index 87d4485963f7..001b7c1aa400 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed Ethernet0 0,1,2,3 etp1 1 100000 Ethernet4 4,5,6,7 etp2 2 100000 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/sai_3800_24x50g_52x100g.xml b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/sai_3800_24x50g_52x100g.xml index 1b3c77ce381c..0ce4e0d8e66b 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/sai_3800_24x50g_52x100g.xml +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/sai_3800_24x50g_52x100g.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/buffers_defaults_t0.j2 index 974b747c6721..4e1560babbc3 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '24360960' %} {% set ingress_lossless_pool_xoff = '2795520' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/buffers_defaults_t1.j2 index cde3e85ba469..be58953df2e5 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '22380544' %} {% set ingress_lossless_pool_xoff = '4775936' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/port_config.ini b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/port_config.ini index 5f9a4de25b96..b80b308dd724 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed Ethernet0 0,1,2,3 etp1 1 100000 Ethernet4 4,5,6,7 etp2 2 100000 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/sai_3800_1x10g_28x50g_49x100g.xml b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/sai_3800_1x10g_28x50g_49x100g.xml index 5844f53f4c0a..ed308a83aabb 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/sai_3800_1x10g_28x50g_49x100g.xml +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/sai_3800_1x10g_28x50g_49x100g.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t0.j2 index ac6b58a305b0..8327f32a7c6c 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '24360960' %} {% set ingress_lossless_pool_xoff = '2795520' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t1.j2 index 7f2f4afc90cb..baeab2cc77e2 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '22380544' %} {% set ingress_lossless_pool_xoff = '4775936' %} diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/port_config.ini b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/port_config.ini index 95f42923c11f..1c03c123f906 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed Ethernet0 0,1,2,3 etp1 1 100000 Ethernet4 4,5,6,7 etp2 2 100000 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/sai_3800_28x50g_52x100g.xml b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/sai_3800_28x50g_52x100g.xml index 1b3c77ce381c..0ce4e0d8e66b 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/sai_3800_28x50g_52x100g.xml +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/sai_3800_28x50g_52x100g.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/port_peripheral_config.j2 b/device/mellanox/x86_64-mlnx_msn3800-r0/port_peripheral_config.j2 index 1cad105ed1ee..a89479dd14fe 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/port_peripheral_config.j2 +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/port_peripheral_config.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} [ {%- include 'peripheral_table.j2' %} , diff --git a/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini b/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini index 3df8315b49ef..deb97c92170e 100644 --- a/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index Ethernet0 0,1,2,3,4,5,6,7 etp1 1 Ethernet8 8,9,10,11,12,13,14,15 etp2 2 diff --git a/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/sai_4410.xml b/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/sai_4410.xml index 5e5b01cad626..cb721bd52c22 100644 --- a/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/sai_4410.xml +++ b/device/mellanox/x86_64-mlnx_msn4410-r0/ACS-MSN4410/sai_4410.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/port_config.ini b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/port_config.ini index 2e6212ef692c..9bfa94369ed3 100644 --- a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index Ethernet0 0,1,2,3 etp1 1 Ethernet4 8,9,10,11 etp2 2 diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai_4600.xml b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai_4600.xml index 96e09ce694f5..a16f49cb317d 100644 --- a/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai_4600.xml +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/ACS-MSN4600/sai_4600.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml index d110ef7c79cb..4356f48a250b 100644 --- a/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn4600-r0/pcie.yaml @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# - bus: '00' dev: '00' fn: '0' diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/ACS-MSN4600C/port_config.ini b/device/mellanox/x86_64-mlnx_msn4600c-r0/ACS-MSN4600C/port_config.ini index 2e6212ef692c..9bfa94369ed3 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/ACS-MSN4600C/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/ACS-MSN4600C/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index Ethernet0 0,1,2,3 etp1 1 Ethernet4 8,9,10,11 etp2 2 diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/ACS-MSN4600C/sai_4600C.xml b/device/mellanox/x86_64-mlnx_msn4600c-r0/ACS-MSN4600C/sai_4600C.xml index 02d0ed6ccd8e..88defea78508 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/ACS-MSN4600C/sai_4600C.xml +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/ACS-MSN4600C/sai_4600C.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 index 0ef452867df7..7495b010d3ce 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '53379072' %} {% set ingress_lossless_xoff_size = '1540096' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t1.j2 index 2bebd4a79954..aa8a9990bdf8 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '52723712' %} {% set ingress_lossless_xoff_size = '2195456' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t0.j2 index 74ee90a25ece..9c2309d88a5e 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '47587328' %} {% set ingress_lossless_xoff_size = '2400256' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t1.j2 index d6fe21de5d9b..249c60571497 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '46702592' %} {% set ingress_lossless_xoff_size = '3284992' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/pg_profile_lookup.ini index fdcf8c0c3050..d32deb3298aa 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/pg_profile_lookup.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # PG lossless profiles. # speed cable size xon xoff threshold 10000 5m 19456 19456 24576 0 diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/port_config.ini b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/port_config.ini index be2c7d9255ca..356e24c1339f 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed fec Ethernet0 0,1 etp1a 1 50000 none Ethernet2 2,3 etp1b 1 50000 none diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/sai_4600c_112x50g_8x100g.xml b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/sai_4600c_112x50g_8x100g.xml index 2016d0bdf297..b5aece3e266e 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/sai_4600c_112x50g_8x100g.xml +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/sai_4600c_112x50g_8x100g.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 index 8046720e1b13..3051dc09ac66 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '50995200' %} {% set ingress_lossless_xoff_size = '1810432' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t1.j2 index 35d338b0e5eb..4b1b6622295c 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '50143232' %} {% set ingress_lossless_xoff_size = '2662400' %} diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/port_config.ini b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/port_config.ini index f98cd3b232fa..b30fe0befcec 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index speed Ethernet0 0,1 etp1a 1 50000 Ethernet2 2,3 etp1b 1 50000 diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/sai_4600c_48x50g_40x100g.xml b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/sai_4600c_48x50g_40x100g.xml index bc26a518c08a..51d741cd5873 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/sai_4600c_48x50g_40x100g.xml +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/sai_4600c_48x50g_40x100g.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn4600c-r0/pcie.yaml index d110ef7c79cb..4356f48a250b 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/pcie.yaml @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# - bus: '00' dev: '00' fn: '0' diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t0.j2 index e886bea8f3c2..dd6bfe64cf75 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t0.j2 +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t0.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '26451968' %} {% set ingress_lossy_pool_size = '26451968' %} diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t1.j2 index 1d0209873642..c46d7be88387 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t1.j2 +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/buffers_defaults_t1.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {% set default_cable = '5m' %} {% set ingress_lossless_pool_size = '20627456' %} {% set ingress_lossy_pool_size = '20627456' %} diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/pg_profile_lookup.ini index 1fb3f9c328c9..b1b13a5c303c 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/pg_profile_lookup.ini +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/pg_profile_lookup.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # PG lossless profiles. # speed cable size xon xoff threshold 10000 5m 52224 19456 32768 0 diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/port_config.ini b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/port_config.ini index ea7219932624..cb3e7fd71094 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/port_config.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index Ethernet0 0,1,2,3,4,5,6,7 etp1 1 Ethernet8 8,9,10,11,12,13,14,15 etp2 2 diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/sai_4700.xml b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/sai_4700.xml index e3d0e4ea723d..83fc07b0c28b 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/sai_4700.xml +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/ACS-MSN4700/sai_4700.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/sensors.conf.a1 b/device/mellanox/x86_64-mlnx_msn4700-r0/sensors.conf.a1 index 9511fac1278e..87308be500ce 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/sensors.conf.a1 +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/sensors.conf.a1 @@ -1,5 +1,6 @@ ################################################################################ # Copyright (C) 20xx-2021 Mellanox Technologies, Ltd. ALL RIGHTS RESERVED. +## Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. # # Platform specific sensors config for SN4700 A0/A1 ################################################################################ diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/port_config.ini b/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/port_config.ini index 51c0ed3798cc..2978b24428cd 100644 --- a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/port_config.ini +++ b/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/port_config.ini @@ -1 +1,17 @@ +## +## Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # name lanes alias index diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/sai_4800.xml b/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/sai_4800.xml index 1625d5b60948..3ac8606ac2f0 100644 --- a/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/sai_4800.xml +++ b/device/mellanox/x86_64-mlnx_msn4800-r0/ACS-MSN4800/sai_4800.xml @@ -1,4 +1,20 @@ + diff --git a/device/mellanox/x86_64-mlnx_msn4800-r0/pcie.yaml b/device/mellanox/x86_64-mlnx_msn4800-r0/pcie.yaml index 15567004fb9d..89c452033b99 100644 --- a/device/mellanox/x86_64-mlnx_msn4800-r0/pcie.yaml +++ b/device/mellanox/x86_64-mlnx_msn4800-r0/pcie.yaml @@ -1,3 +1,19 @@ +# +# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# - bus: '00' dev: '00' fn: '0' diff --git a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/Nokia-IXR7250E-36x400G/0/port_config.ini b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/Nokia-IXR7250E-36x400G/0/port_config.ini index c05fc0a12dd2..8d017026081c 100644 --- a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/Nokia-IXR7250E-36x400G/0/port_config.ini +++ b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/Nokia-IXR7250E-36x400G/0/port_config.ini @@ -1,20 +1,20 @@ # name lanes alias index asic_port_name role speed coreid coreportid numvoq -Ethernet0 72,73,74,75,76,77,78,79 Ethernet0 1 Eth0-ASIC0 Ext 400000 1 0 8 -Ethernet1 80,81,82,83,84,85,86,87 Ethernet1 2 Eth1-ASIC0 Ext 400000 1 1 8 -Ethernet2 88,89,90,91,92,93,94,95 Ethernet2 3 Eth2-ASIC0 Ext 400000 1 2 8 -Ethernet3 96,97,98,99,100,101,102,103 Ethernet3 4 Eth3-ASIC0 Ext 400000 1 3 8 -Ethernet4 104,105,106,107,108,109,110,111 Ethernet4 5 Eth4-ASIC0 Ext 400000 1 4 8 -Ethernet5 112,113,114,115,116,117,118,119 Ethernet5 6 Eth5-ASIC0 Ext 400000 1 5 8 -Ethernet6 120,121,122,123,124,125,126,127 Ethernet6 7 Eth6-ASIC0 Ext 400000 1 6 8 -Ethernet7 128,129,130,131,132,133,134,135 Ethernet7 8 Eth7-ASIC0 Ext 400000 1 7 8 -Ethernet8 136,137,138,139,140,141,142,143 Ethernet8 9 Eth8-ASIC0 Ext 400000 1 8 8 -Ethernet9 64,65,66,67,68,69,70,71 Ethernet9 10 Eth9-ASIC0 Ext 400000 0 1 8 -Ethernet10 56,57,58,59,60,61,62,63 Ethernet10 11 Eth10-ASIC0 Ext 400000 0 2 8 -Ethernet11 48,49,50,51,52,53,54,55 Ethernet11 12 Eth11-ASIC0 Ext 400000 0 3 8 -Ethernet12 40,41,42,43,44,45,46,47 Ethernet12 13 Eth12-ASIC0 Ext 400000 0 4 8 -Ethernet13 32,33,34,35,36,37,38,39 Ethernet13 14 Eth13-ASIC0 Ext 400000 0 5 8 -Ethernet14 24,25,26,27,28,29,30,31 Ethernet14 15 Eth14-ASIC0 Ext 400000 0 6 8 -Ethernet15 16,17,18,19,20,21,22,23 Ethernet15 16 Eth15-ASIC0 Ext 400000 0 7 8 -Ethernet16 8,9,10,11,12,13,14,15 Ethernet16 17 Eth16-ASIC0 Ext 400000 0 8 8 -Ethernet17 0,1,2,3,4,5,6,7 Ethernet17 18 Eth17-ASIC0 Ext 400000 0 9 8 -Ethernet-IB0 115 Ethernet-IB0 37 Rcy-ASIC0 Int 10000 0 10 8 +Ethernet0 72,73,74,75,76,77,78,79 Ethernet0 1 Eth0-ASIC0 Ext 400000 1 1 8 +Ethernet1 80,81,82,83,84,85,86,87 Ethernet1 2 Eth1-ASIC0 Ext 400000 1 2 8 +Ethernet2 88,89,90,91,92,93,94,95 Ethernet2 3 Eth2-ASIC0 Ext 400000 1 3 8 +Ethernet3 96,97,98,99,100,101,102,103 Ethernet3 4 Eth3-ASIC0 Ext 400000 1 4 8 +Ethernet4 104,105,106,107,108,109,110,111 Ethernet4 5 Eth4-ASIC0 Ext 400000 1 5 8 +Ethernet5 112,113,114,115,116,117,118,119 Ethernet5 6 Eth5-ASIC0 Ext 400000 1 6 8 +Ethernet6 120,121,122,123,124,125,126,127 Ethernet6 7 Eth6-ASIC0 Ext 400000 1 7 8 +Ethernet7 128,129,130,131,132,133,134,135 Ethernet7 8 Eth7-ASIC0 Ext 400000 1 8 8 +Ethernet8 136,137,138,139,140,141,142,143 Ethernet8 9 Eth8-ASIC0 Ext 400000 1 9 8 +Ethernet9 64,65,66,67,68,69,70,71 Ethernet9 10 Eth9-ASIC0 Ext 400000 0 10 8 +Ethernet10 56,57,58,59,60,61,62,63 Ethernet10 11 Eth10-ASIC0 Ext 400000 0 11 8 +Ethernet11 48,49,50,51,52,53,54,55 Ethernet11 12 Eth11-ASIC0 Ext 400000 0 12 8 +Ethernet12 40,41,42,43,44,45,46,47 Ethernet12 13 Eth12-ASIC0 Ext 400000 0 13 8 +Ethernet13 32,33,34,35,36,37,38,39 Ethernet13 14 Eth13-ASIC0 Ext 400000 0 14 8 +Ethernet14 24,25,26,27,28,29,30,31 Ethernet14 15 Eth14-ASIC0 Ext 400000 0 15 8 +Ethernet15 16,17,18,19,20,21,22,23 Ethernet15 16 Eth15-ASIC0 Ext 400000 0 16 8 +Ethernet16 8,9,10,11,12,13,14,15 Ethernet16 17 Eth16-ASIC0 Ext 400000 0 17 8 +Ethernet17 0,1,2,3,4,5,6,7 Ethernet17 18 Eth17-ASIC0 Ext 400000 0 18 8 +Ethernet-IB0 115 Ethernet-IB0 37 Rcy-ASIC0 Int 10000 0 19 8 diff --git a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/Nokia-IXR7250E-36x400G/1/port_config.ini b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/Nokia-IXR7250E-36x400G/1/port_config.ini index 9f043d832eda..76fd968fec28 100644 --- a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/Nokia-IXR7250E-36x400G/1/port_config.ini +++ b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/Nokia-IXR7250E-36x400G/1/port_config.ini @@ -1,20 +1,20 @@ # name lanes alias index asic_port_name role speed coreid coreportid numvoq -Ethernet18 72,73,74,75,76,77,78,79 Ethernet18 19 Eth0-ASIC1 Ext 400000 1 0 8 -Ethernet19 80,81,82,83,84,85,86,87 Ethernet19 20 Eth1-ASIC1 Ext 400000 1 1 8 -Ethernet20 88,89,90,91,92,93,94,95 Ethernet20 21 Eth2-ASIC1 Ext 400000 1 2 8 -Ethernet21 96,97,98,99,100,101,102,103 Ethernet21 22 Eth3-ASIC1 Ext 400000 1 3 8 -Ethernet22 104,105,106,107,108,109,110,111 Ethernet22 23 Eth4-ASIC1 Ext 400000 1 4 8 -Ethernet23 112,113,114,115,116,117,118,119 Ethernet23 24 Eth5-ASIC1 Ext 400000 1 5 8 -Ethernet24 120,121,122,123,124,125,126,127 Ethernet24 25 Eth6-ASIC1 Ext 400000 1 6 8 -Ethernet25 128,129,130,131,132,133,134,135 Ethernet25 26 Eth7-ASIC1 Ext 400000 1 7 8 -Ethernet26 136,137,138,139,140,141,142,143 Ethernet26 27 Eth8-ASIC1 Ext 400000 1 8 8 -Ethernet27 64,65,66,67,68,69,70,71 Ethernet27 28 Eth9-ASIC1 Ext 400000 0 1 8 -Ethernet28 56,57,58,59,60,61,62,63 Ethernet28 29 Eth10-ASIC1 Ext 400000 0 2 8 -Ethernet29 48,49,50,51,52,53,54,55 Ethernet29 30 Eth11-ASIC1 Ext 400000 0 3 8 -Ethernet30 40,41,42,43,44,45,46,47 Ethernet30 31 Eth12-ASIC1 Ext 400000 0 4 8 -Ethernet31 32,33,34,35,36,37,38,39 Ethernet31 32 Eth13-ASIC1 Ext 400000 0 5 8 -Ethernet32 24,25,26,27,28,29,30,31 Ethernet32 33 Eth14-ASIC1 Ext 400000 0 6 8 -Ethernet33 16,17,18,19,20,21,22,23 Ethernet33 34 Eth15-ASIC1 Ext 400000 0 7 8 -Ethernet34 8,9,10,11,12,13,14,15 Ethernet34 35 Eth16-ASIC1 Ext 400000 0 8 8 -Ethernet35 0,1,2,3,4,5,6,7 Ethernet35 36 Eth17-ASIC1 Ext 400000 0 9 8 -Ethernet-IB1 115 Ethernet-IB1 38 Rcy-ASIC1 Int 10000 0 10 8 +Ethernet18 72,73,74,75,76,77,78,79 Ethernet18 19 Eth0-ASIC1 Ext 400000 1 1 8 +Ethernet19 80,81,82,83,84,85,86,87 Ethernet19 20 Eth1-ASIC1 Ext 400000 1 2 8 +Ethernet20 88,89,90,91,92,93,94,95 Ethernet20 21 Eth2-ASIC1 Ext 400000 1 3 8 +Ethernet21 96,97,98,99,100,101,102,103 Ethernet21 22 Eth3-ASIC1 Ext 400000 1 4 8 +Ethernet22 104,105,106,107,108,109,110,111 Ethernet22 23 Eth4-ASIC1 Ext 400000 1 5 8 +Ethernet23 112,113,114,115,116,117,118,119 Ethernet23 24 Eth5-ASIC1 Ext 400000 1 6 8 +Ethernet24 120,121,122,123,124,125,126,127 Ethernet24 25 Eth6-ASIC1 Ext 400000 1 7 8 +Ethernet25 128,129,130,131,132,133,134,135 Ethernet25 26 Eth7-ASIC1 Ext 400000 1 8 8 +Ethernet26 136,137,138,139,140,141,142,143 Ethernet26 27 Eth8-ASIC1 Ext 400000 1 9 8 +Ethernet27 64,65,66,67,68,69,70,71 Ethernet27 28 Eth9-ASIC1 Ext 400000 0 10 8 +Ethernet28 56,57,58,59,60,61,62,63 Ethernet28 29 Eth10-ASIC1 Ext 400000 0 11 8 +Ethernet29 48,49,50,51,52,53,54,55 Ethernet29 30 Eth11-ASIC1 Ext 400000 0 12 8 +Ethernet30 40,41,42,43,44,45,46,47 Ethernet30 31 Eth12-ASIC1 Ext 400000 0 13 8 +Ethernet31 32,33,34,35,36,37,38,39 Ethernet31 32 Eth13-ASIC1 Ext 400000 0 14 8 +Ethernet32 24,25,26,27,28,29,30,31 Ethernet32 33 Eth14-ASIC1 Ext 400000 0 15 8 +Ethernet33 16,17,18,19,20,21,22,23 Ethernet33 34 Eth15-ASIC1 Ext 400000 0 16 8 +Ethernet34 8,9,10,11,12,13,14,15 Ethernet34 35 Eth16-ASIC1 Ext 400000 0 17 8 +Ethernet35 0,1,2,3,4,5,6,7 Ethernet35 36 Eth17-ASIC1 Ext 400000 0 18 8 +Ethernet-IB1 115 Ethernet-IB1 38 Rcy-ASIC1 Int 10000 0 19 8 diff --git a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/chassisdb.conf b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/chassisdb.conf index cb602c6eb4d8..175c0bb2b769 100644 --- a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/chassisdb.conf +++ b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/chassisdb.conf @@ -1 +1,2 @@ chassis_db_address=10.0.5.16 +chassis_internal_intfs=enp12s0f2,enp5s0f4,enp5s0f4.2 diff --git a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/platform_ndk.json b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/platform_ndk.json index 92a206bb490b..5f0862c2e729 100644 --- a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/platform_ndk.json +++ b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/platform_ndk.json @@ -27,6 +27,10 @@ { "key": "sonic_bdb_mode", "intval": 0 + }, + { + "key": "update_asic_pvt", + "intval": 10 } ] } diff --git a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/platform_reboot b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/platform_reboot index 65cba5185eb1..d128455d40fc 100755 --- a/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/platform_reboot +++ b/device/nokia/x86_64-nokia_ixr7250e_36x400g-r0/platform_reboot @@ -5,5 +5,6 @@ sleep 2 echo "w" > /dev/watchdog kick_date=`date -u` echo "last watchdog kick $kick_date" > /var/log/nokia-watchdog-last.log +rm -f /sys/firmware/efi/efivars/dump-* sync /sbin/reboot diff --git a/device/nokia/x86_64-nokia_ixr7250e_sup-r0/pcie.yaml b/device/nokia/x86_64-nokia_ixr7250e_sup-r0/pcie.yaml index 7d587abbdab8..593c20beee61 100644 --- a/device/nokia/x86_64-nokia_ixr7250e_sup-r0/pcie.yaml +++ b/device/nokia/x86_64-nokia_ixr7250e_sup-r0/pcie.yaml @@ -91,7 +91,7 @@ - bus: '00' dev: '14' fn: '3' - id: 790e' + id: '790e' name: 'ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge (rev 51)' - bus: '00' dev: '18' @@ -130,7 +130,7 @@ name: 'Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 6' - bus: '00' dev: '18' - fn: '7 ' + fn: '7' id: '1467' name: 'Host bridge: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Data Fabric: Device 18h; Function 7' - bus: '01' @@ -153,57 +153,57 @@ fn: '1' id: '8454' name: 'Ethernet controller: Broadcom Limited Device 8454 (rev 01)' -- bus: '08' +- bus: '09' dev: '00' fn: '0' id: '145a' name: 'Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Zeppelin/Raven/Raven2 PCIe Dummy Function' -- bus: '08' +- bus: '09' dev: '00' fn: '2' id: '1456' name: 'Encryption controller: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) Platform Security Processor' -- bus: '08' +- bus: '09' dev: '00' fn: '3' id: '145f' name: 'USB controller: Advanced Micro Devices, Inc. [AMD] Zeppelin USB 3.0 Host controller' -- bus: '09' +- bus: '0a' dev: '00' fn: '0' id: '1455' name: 'Non-Essential Instrumentation [1300]: Advanced Micro Devices, Inc. [AMD] Zeppelin/Renoir PCIe Dummy Function' -- bus: '09' +- bus: '0a' dev: '00' fn: '1' id: '1468' name: 'Encryption controller: Advanced Micro Devices, Inc. [AMD] Zeppelin Cryptographic Coprocessor NTBCCP' -- bus: '09' +- bus: '0a' dev: '00' - fn: '2' + fn: '2' id: '7901' name: 'SATA controller: Advanced Micro Devices, Inc. [AMD] FCH SATA Controller [AHCI mode] (rev 51)' -- bus: '09' +- bus: '0a' dev: '00' fn: '3' id: '1457' name: 'Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 00h-0fh) HD Audio Controller' -- bus: '09' +- bus: '0a' dev: '00' fn: '4' id: '1458' name: 'Ethernet controller: Advanced Micro Devices, Inc. [AMD] Device 1458' -- bus: '09' +- bus: '0a' dev: '00' fn: '5' id: '1458' name: 'Ethernet controller: Advanced Micro Devices, Inc. [AMD] Device 1458' -- bus: '09' +- bus: '0a' dev: '00' fn: '6' id: '1459' name: 'Ethernet controller: Advanced Micro Devices, Inc. [AMD] Device 1459' -- bus: '09' +- bus: '0a' dev: '00' fn: '7' id: '1459' diff --git a/device/nokia/x86_64-nokia_ixr7250e_sup-r0/platform_reboot b/device/nokia/x86_64-nokia_ixr7250e_sup-r0/platform_reboot index 65cba5185eb1..d128455d40fc 100755 --- a/device/nokia/x86_64-nokia_ixr7250e_sup-r0/platform_reboot +++ b/device/nokia/x86_64-nokia_ixr7250e_sup-r0/platform_reboot @@ -5,5 +5,6 @@ sleep 2 echo "w" > /dev/watchdog kick_date=`date -u` echo "last watchdog kick $kick_date" > /var/log/nokia-watchdog-last.log +rm -f /sys/firmware/efi/efivars/dump-* sync /sbin/reboot diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers.json.j2 b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers.json.j2 new file mode 100644 index 000000000000..b67cf577ab75 --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers.json.j2 @@ -0,0 +1,3 @@ +{%- set default_topo = 't1' %} +{%- include 'buffers_config.j2' %} + diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers_defaults_def.j2 b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers_defaults_def.j2 new file mode 100644 index 000000000000..e9cbf161dafe --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers_defaults_def.j2 @@ -0,0 +1,45 @@ +{%- set default_cable = '0m' %} + +{%- macro generate_port_lists(PORT_ALL) %} + {# Generate list of ports #} + {% for port_idx in range(0,32) %} + {% if PORT_ALL.append("Ethernet%d" % (port_idx + 1)) %}{% endif %} + {% endfor %} +{%- endmacro %} + +{%- macro generate_buffer_pool_and_profiles() %} + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "12766208", + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "12766208", + "type": "egress", + "mode": "static" + }, + "egress_lossy_pool": { + "size": "7326924", + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "ingress_lossy_profile": { + "pool":"[BUFFER_POOL|ingress_lossless_pool]", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"[BUFFER_POOL|egress_lossless_pool]", + "size":"0", + "static_th":"12766208" + }, + "egress_lossy_profile": { + "pool":"[BUFFER_POOL|egress_lossy_pool]", + "size":"1518", + "dynamic_th":"3" + } + }, +{%- endmacro %} diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers_defaults_t0.j2 b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers_defaults_t0.j2 new file mode 100644 index 000000000000..e9cbf161dafe --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers_defaults_t0.j2 @@ -0,0 +1,45 @@ +{%- set default_cable = '0m' %} + +{%- macro generate_port_lists(PORT_ALL) %} + {# Generate list of ports #} + {% for port_idx in range(0,32) %} + {% if PORT_ALL.append("Ethernet%d" % (port_idx + 1)) %}{% endif %} + {% endfor %} +{%- endmacro %} + +{%- macro generate_buffer_pool_and_profiles() %} + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "12766208", + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "12766208", + "type": "egress", + "mode": "static" + }, + "egress_lossy_pool": { + "size": "7326924", + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "ingress_lossy_profile": { + "pool":"[BUFFER_POOL|ingress_lossless_pool]", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"[BUFFER_POOL|egress_lossless_pool]", + "size":"0", + "static_th":"12766208" + }, + "egress_lossy_profile": { + "pool":"[BUFFER_POOL|egress_lossy_pool]", + "size":"1518", + "dynamic_th":"3" + } + }, +{%- endmacro %} diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers_defaults_t1.j2 b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers_defaults_t1.j2 new file mode 100644 index 000000000000..e9cbf161dafe --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/buffers_defaults_t1.j2 @@ -0,0 +1,45 @@ +{%- set default_cable = '0m' %} + +{%- macro generate_port_lists(PORT_ALL) %} + {# Generate list of ports #} + {% for port_idx in range(0,32) %} + {% if PORT_ALL.append("Ethernet%d" % (port_idx + 1)) %}{% endif %} + {% endfor %} +{%- endmacro %} + +{%- macro generate_buffer_pool_and_profiles() %} + "BUFFER_POOL": { + "ingress_lossless_pool": { + "size": "12766208", + "type": "ingress", + "mode": "dynamic" + }, + "egress_lossless_pool": { + "size": "12766208", + "type": "egress", + "mode": "static" + }, + "egress_lossy_pool": { + "size": "7326924", + "type": "egress", + "mode": "dynamic" + } + }, + "BUFFER_PROFILE": { + "ingress_lossy_profile": { + "pool":"[BUFFER_POOL|ingress_lossless_pool]", + "size":"0", + "dynamic_th":"3" + }, + "egress_lossless_profile": { + "pool":"[BUFFER_POOL|egress_lossless_pool]", + "size":"0", + "static_th":"12766208" + }, + "egress_lossy_profile": { + "pool":"[BUFFER_POOL|egress_lossy_pool]", + "size":"1518", + "dynamic_th":"3" + } + }, +{%- endmacro %} diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/fabriclanemap.ini b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/fabriclanemap.ini new file mode 100644 index 000000000000..20ea8fe3a720 --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/fabriclanemap.ini @@ -0,0 +1,16 @@ +fabric1:1 +fabric2:2 +fabric3:3 +fabric4:4 +fabric5:5 +fabric6:6 +fabric7:7 +fabric8:8 +fabric9:9 +fabric10:10 +fabric11:11 +fabric12:12 +fabric13:13 +fabric14:14 +fabric15:15 +fabric16:16 diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/lanemap.ini b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/lanemap.ini new file mode 100644 index 000000000000..a42385bd42a9 --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/lanemap.ini @@ -0,0 +1,32 @@ +eth1:25,26,27,28 +eth2:29,30,31,32 +eth3:33,34,35,36 +eth4:37,38,39,40 +eth5:45,46,47,48 +eth6:41,42,43,44 +eth7:1,2,3,4 +eth8:5,6,7,8 +eth9:13,14,15,16 +eth10:9,10,11,12 +eth11:17,18,19,20 +eth12:21,22,23,24 +eth13:53,54,55,56 +eth14:49,50,51,52 +eth15:57,58,59,60 +eth16:61,62,63,64 +eth17:69,70,71,72 +eth18:65,66,67,68 +eth19:73,74,75,76 +eth20:77,78,79,80 +eth21:109,110,111,112 +eth22:105,106,107,108 +eth23:113,114,115,116 +eth24:117,118,119,120 +eth25:125,126,127,128 +eth26:121,122,123,124 +eth27:81,82,83,84 +eth28:85,86,87,88 +eth29:93,94,95,96 +eth30:89,90,91,92 +eth31:101,102,103,104 +eth32:97,98,99,100 diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/pai.profile b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/pai.profile new file mode 100644 index 000000000000..4c1c2d8c7c75 --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/pai.profile @@ -0,0 +1,5 @@ +SAI_VS_SWITCH_TYPE=SAI_VS_SWITCH_TYPE_BCM81724 +SAI_VS_SAI_SWITCH_TYPE=SAI_SWITCH_TYPE_PHY +SAI_VS_HOSTIF_USE_TAP_DEVICE=false +SAI_VS_USE_BCMSIM_LINK_MON=true +SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/pg_profile_lookup.ini b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/pg_profile_lookup.ini new file mode 100644 index 000000000000..9f2eacb6fc42 --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/pg_profile_lookup.ini @@ -0,0 +1,17 @@ +# PG lossless profiles. +# speed cable size xon xoff threshold xon_offset + 10000 5m 56368 18432 55120 -3 2496 + 25000 5m 56368 18432 55120 -3 2496 + 40000 5m 56368 18432 55120 -3 2496 + 50000 5m 56368 18432 55120 -3 2496 + 100000 5m 56368 18432 55120 -3 2496 + 10000 40m 56368 18432 55120 -3 2496 + 25000 40m 56368 18432 55120 -3 2496 + 40000 40m 56368 18432 55120 -3 2496 + 50000 40m 56368 18432 55120 -3 2496 + 100000 40m 56368 18432 55120 -3 2496 + 10000 300m 56368 18432 55120 -3 2496 + 25000 300m 56368 18432 55120 -3 2496 + 40000 300m 56368 18432 55120 -3 2496 + 50000 300m 56368 18432 55120 -3 2496 + 100000 300m 56368 18432 55120 -3 2496 diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/port_config.ini b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/port_config.ini new file mode 100644 index 000000000000..cadd9ae608bb --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/port_config.ini @@ -0,0 +1,33 @@ +# name lanes alias index speed +Ethernet1 25,26,27,28 fortyGigE0/0 0 40000 +Ethernet2 29,30,31,32 fortyGigE0/4 1 40000 +Ethernet3 33,34,35,36 fortyGigE0/8 2 40000 +Ethernet4 37,38,39,40 fortyGigE0/12 3 40000 +Ethernet5 45,46,47,48 fortyGigE0/16 4 40000 +Ethernet6 41,42,43,44 fortyGigE0/20 5 40000 +Ethernet7 1,2,3,4 fortyGigE0/24 6 40000 +Ethernet8 5,6,7,8 fortyGigE0/28 7 40000 +Ethernet9 13,14,15,16 fortyGigE0/32 8 40000 +Ethernet10 9,10,11,12 fortyGigE0/36 9 40000 +Ethernet11 17,18,19,20 fortyGigE0/40 10 40000 +Ethernet12 21,22,23,24 fortyGigE0/44 11 40000 +Ethernet13 53,54,55,56 fortyGigE0/48 12 40000 +Ethernet14 49,50,51,52 fortyGigE0/52 13 40000 +Ethernet15 57,58,59,60 fortyGigE0/56 14 40000 +Ethernet16 61,62,63,64 fortyGigE0/60 15 40000 +Ethernet17 69,70,71,72 fortyGigE0/64 16 40000 +Ethernet18 65,66,67,68 fortyGigE0/68 17 40000 +Ethernet19 73,74,75,76 fortyGigE0/72 18 40000 +Ethernet20 77,78,79,80 fortyGigE0/76 19 40000 +Ethernet21 109,110,111,112 fortyGigE0/80 20 40000 +Ethernet22 105,106,107,108 fortyGigE0/84 21 40000 +Ethernet23 113,114,115,116 fortyGigE0/88 22 40000 +Ethernet24 117,118,119,120 fortyGigE0/92 23 40000 +Ethernet25 125,126,127,128 fortyGigE0/96 24 40000 +Ethernet26 121,122,123,124 fortyGigE0/100 25 40000 +Ethernet27 81,82,83,84 fortyGigE0/104 26 40000 +Ethernet28 85,86,87,88 fortyGigE0/108 27 40000 +Ethernet29 93,94,95,96 fortyGigE0/112 28 40000 +Ethernet30 89,90,91,92 fortyGigE0/116 29 40000 +Ethernet31 101,102,103,104 fortyGigE0/120 30 40000 +Ethernet32 97,98,99,100 fortyGigE0/124 31 40000 diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/qos.json.j2 b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/qos.json.j2 new file mode 100644 index 000000000000..3e548325ea30 --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/qos.json.j2 @@ -0,0 +1 @@ +{%- include 'qos_config.j2' %} diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/sai.profile b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/sai.profile new file mode 100644 index 000000000000..ed9dd21bdcb5 --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/sai.profile @@ -0,0 +1,5 @@ +SAI_VS_SWITCH_TYPE=SAI_VS_SWITCH_TYPE_BCM56850 +SAI_VS_HOSTIF_USE_TAP_DEVICE=true +SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini +SAI_VS_CORE_PORT_INDEX_MAP_FILE=/usr/share/sonic/hwsku/coreportindexmap.ini +SAI_VS_INTERFACE_FABRIC_LANE_MAP_FILE=/usr/share/sonic/hwsku/fabriclanemap.ini diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/sai_mlnx.profile b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/sai_mlnx.profile new file mode 100644 index 000000000000..7b54438c4130 --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/sai_mlnx.profile @@ -0,0 +1,5 @@ +SAI_VS_SWITCH_TYPE=SAI_VS_SWITCH_TYPE_MLNX2700 +SAI_VS_HOSTIF_USE_TAP_DEVICE=true +SAI_VS_INTERFACE_LANE_MAP_FILE=/usr/share/sonic/hwsku/lanemap.ini +SAI_VS_CORE_PORT_INDEX_MAP_FILE=/usr/share/sonic/hwsku/coreportindexmap.ini +SAI_VS_INTERFACE_FABRIC_LANE_MAP_FILE=/usr/share/sonic/hwsku/fabriclanemap.ini diff --git a/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/td2-s6000-32x40G.config.bcm b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/td2-s6000-32x40G.config.bcm new file mode 100644 index 000000000000..2626674d67ca --- /dev/null +++ b/device/virtual/x86_64-kvm_x86_64-r0/SONiC-VM/td2-s6000-32x40G.config.bcm @@ -0,0 +1,649 @@ +# Old LPM only configuration +# l2_mem_entries=163840 +# l3_mem_entries=90112 +# l3_alpm_enable=0 +# ipv6_lpm_128b_enable=0 +# +# ALPM enable +l3_alpm_enable=2 +ipv6_lpm_128b_enable=1 +l2_mem_entries=32768 +l3_mem_entries=16384 + +# Disable Counting ACL Drop towards interface RX_DRP counter +sai_adjust_acl_drop_in_rx_drop=1 + +# From old config file +os=unix +higig2_hdr_mode=1 + +# Parity +parity_correction=1 +parity_enable=1 +stat_if_parity_enable=0 + +# +bcm_num_cos=10 +bcm_stat_interval=2000000 +l2xmsg_hostbuf_size=8192 +l2xmsg_mode=1 +lls_num_l2uc=12 +max_vp_lags=0 +miim_intr_enable=0 +mmu_lossless=0 +module_64ports=0 +schan_intr_enable=0 +stable_size=0x2000000 +tdma_timeout_usec=5000000 + +pbmp_oversubscribe=0x000007fffffffffffffffffffffffffe +pbmp_xport_xe=0x000007fffffffffffffffffffffffffe + +# Ports configuration +# xe0 (40G) +portmap_1=25:40 +xgxs_rx_lane_map_1=0x213 +xgxs_tx_lane_map_1=0x2031 +phy_xaui_rx_polarity_flip_1=0xe +phy_xaui_tx_polarity_flip_1=0x2 +serdes_driver_current_lane0_xe0=0x5 +serdes_driver_current_lane1_xe0=0x5 +serdes_driver_current_lane2_xe0=0x5 +serdes_driver_current_lane3_xe0=0x5 +serdes_pre_driver_current_lane0_xe0=0x5 +serdes_pre_driver_current_lane1_xe0=0x5 +serdes_pre_driver_current_lane2_xe0=0x5 +serdes_pre_driver_current_lane3_xe0=0x5 +serdes_preemphasis_lane0_xe0=0xcad0 +serdes_preemphasis_lane1_xe0=0xc6e0 +serdes_preemphasis_lane2_xe0=0xc6e0 +serdes_preemphasis_lane3_xe0=0xd2b0 + +# xe1 (40G) +portmap_2=29:40 +xgxs_rx_lane_map_2=0x213 +xgxs_tx_lane_map_2=0x213 +phy_xaui_rx_polarity_flip_2=0xc +phy_xaui_tx_polarity_flip_2=0x9 +serdes_driver_current_lane0_xe1=0x6 +serdes_driver_current_lane1_xe1=0x7 +serdes_driver_current_lane2_xe1=0x6 +serdes_driver_current_lane3_xe1=0x6 +serdes_pre_driver_current_lane0_xe1=0x6 +serdes_pre_driver_current_lane1_xe1=0x7 +serdes_pre_driver_current_lane2_xe1=0x6 +serdes_pre_driver_current_lane3_xe1=0x6 +serdes_preemphasis_lane0_xe1=0xc2f0 +serdes_preemphasis_lane1_xe1=0xd2b0 +serdes_preemphasis_lane2_xe1=0xc6e0 +serdes_preemphasis_lane3_xe1=0xc2f0 + +# xe2 (40G) +portmap_3=33:40 +xgxs_rx_lane_map_3=0x213 +xgxs_tx_lane_map_3=0x132 +phy_xaui_rx_polarity_flip_3=0xe +phy_xaui_tx_polarity_flip_3=0x2 +serdes_driver_current_lane0_xe2=0x4 +serdes_driver_current_lane1_xe2=0x4 +serdes_driver_current_lane2_xe2=0x4 +serdes_driver_current_lane3_xe2=0x4 +serdes_pre_driver_current_lane0_xe2=0x4 +serdes_pre_driver_current_lane1_xe2=0x4 +serdes_pre_driver_current_lane2_xe2=0x4 +serdes_pre_driver_current_lane3_xe2=0x4 +serdes_preemphasis_lane0_xe2=0xc6e0 +serdes_preemphasis_lane1_xe2=0xc6e0 +serdes_preemphasis_lane2_xe2=0xc6e0 +serdes_preemphasis_lane3_xe2=0xc6e0 + +# xe3 (40G) +portmap_4=37:40 +xgxs_rx_lane_map_4=0x213 +xgxs_tx_lane_map_4=0x1203 +phy_xaui_rx_polarity_flip_4=0x3 +phy_xaui_tx_polarity_flip_4=0xe +serdes_driver_current_lane0_xe3=0x4 +serdes_driver_current_lane1_xe3=0x4 +serdes_driver_current_lane2_xe3=0x4 +serdes_driver_current_lane3_xe3=0x4 +serdes_pre_driver_current_lane0_xe3=0x4 +serdes_pre_driver_current_lane1_xe3=0x4 +serdes_pre_driver_current_lane2_xe3=0x4 +serdes_pre_driver_current_lane3_xe3=0x4 +serdes_preemphasis_lane0_xe3=0xcad0 +serdes_preemphasis_lane1_xe3=0xcad0 +serdes_preemphasis_lane2_xe3=0xc2f0 +serdes_preemphasis_lane3_xe3=0xc2f0 + +# xe4 (40G) +portmap_5=45:40 +xgxs_rx_lane_map_5=0x213 +xgxs_tx_lane_map_5=0x213 +phy_xaui_rx_polarity_flip_5=0xe +phy_xaui_tx_polarity_flip_5=0x8 +serdes_driver_current_lane0_xe4=0x4 +serdes_driver_current_lane1_xe4=0x4 +serdes_driver_current_lane2_xe4=0x4 +serdes_driver_current_lane3_xe4=0x4 +serdes_pre_driver_current_lane0_xe4=0x4 +serdes_pre_driver_current_lane1_xe4=0x4 +serdes_pre_driver_current_lane2_xe4=0x4 +serdes_pre_driver_current_lane3_xe4=0x4 +serdes_preemphasis_lane0_xe4=0xc2f0 +serdes_preemphasis_lane1_xe4=0xc2f0 +serdes_preemphasis_lane2_xe4=0xc2f0 +serdes_preemphasis_lane3_xe4=0xc2f0 + +# xe5 (40G) +portmap_6=41:40 +xgxs_rx_lane_map_6=0x213 +xgxs_tx_lane_map_6=0x3021 +phy_xaui_rx_polarity_flip_6=0x3 +phy_xaui_tx_polarity_flip_6=0xb +serdes_driver_current_lane0_xe5=0x4 +serdes_driver_current_lane1_xe5=0x4 +serdes_driver_current_lane2_xe5=0x4 +serdes_driver_current_lane3_xe5=0x4 +serdes_pre_driver_current_lane0_xe5=0x4 +serdes_pre_driver_current_lane1_xe5=0x4 +serdes_pre_driver_current_lane2_xe5=0x4 +serdes_pre_driver_current_lane3_xe5=0x4 +serdes_preemphasis_lane0_xe5=0xc6e0 +serdes_preemphasis_lane1_xe5=0xc2f0 +serdes_preemphasis_lane2_xe5=0xc2f0 +serdes_preemphasis_lane3_xe5=0xcad0 + +# xe6 (40G) +portmap_7=1:40 +xgxs_rx_lane_map_7=0x213 +xgxs_tx_lane_map_7=0x2031 +phy_xaui_rx_polarity_flip_7=0xe +phy_xaui_tx_polarity_flip_7=0xd +serdes_driver_current_lane0_xe6=0x5 +serdes_driver_current_lane1_xe6=0x5 +serdes_driver_current_lane2_xe6=0x5 +serdes_driver_current_lane3_xe6=0x5 +serdes_pre_driver_current_lane0_xe6=0x5 +serdes_pre_driver_current_lane1_xe6=0x5 +serdes_pre_driver_current_lane2_xe6=0x5 +serdes_pre_driver_current_lane3_xe6=0x5 +serdes_preemphasis_lane0_xe6=0xc6e0 +serdes_preemphasis_lane1_xe6=0xcad0 +serdes_preemphasis_lane2_xe6=0xc6e0 +serdes_preemphasis_lane3_xe6=0xcad0 + +# xe7 (40G) +portmap_8=5:40 +xgxs_rx_lane_map_8=0x213 +xgxs_tx_lane_map_8=0x1203 +phy_xaui_rx_polarity_flip_8=0xc +phy_xaui_tx_polarity_flip_8=0x1 +serdes_driver_current_lane0_xe7=0x4 +serdes_driver_current_lane1_xe7=0x4 +serdes_driver_current_lane2_xe7=0x4 +serdes_driver_current_lane3_xe7=0x4 +serdes_pre_driver_current_lane0_xe7=0x4 +serdes_pre_driver_current_lane1_xe7=0x4 +serdes_pre_driver_current_lane2_xe7=0x4 +serdes_pre_driver_current_lane3_xe7=0x4 +serdes_preemphasis_lane0_xe7=0xc6e0 +serdes_preemphasis_lane1_xe7=0xc6e0 +serdes_preemphasis_lane2_xe7=0xc6e0 +serdes_preemphasis_lane3_xe7=0xc6e0 + +# xe8 (40G) +portmap_9=13:40 +xgxs_rx_lane_map_9=0x213 +xgxs_tx_lane_map_9=0x132 +phy_xaui_rx_polarity_flip_9=0xe +phy_xaui_tx_polarity_flip_9=0x0 +serdes_driver_current_lane0_xe8=0x2 +serdes_driver_current_lane1_xe8=0x3 +serdes_driver_current_lane2_xe8=0x2 +serdes_driver_current_lane3_xe8=0x2 +serdes_pre_driver_current_lane0_xe8=0x2 +serdes_pre_driver_current_lane1_xe8=0x3 +serdes_pre_driver_current_lane2_xe8=0x2 +serdes_pre_driver_current_lane3_xe8=0x2 +serdes_preemphasis_lane0_xe8=0xb270 +serdes_preemphasis_lane1_xe8=0xbb10 +serdes_preemphasis_lane2_xe8=0xb720 +serdes_preemphasis_lane3_xe8=0xb720 + +# xe9 (40G) +portmap_10=9:40 +xgxs_rx_lane_map_10=0x3120 +xgxs_tx_lane_map_10=0x3021 +phy_xaui_rx_polarity_flip_10=0x0 +phy_xaui_tx_polarity_flip_10=0x4 +serdes_driver_current_lane0_xe9=0x3 +serdes_driver_current_lane1_xe9=0x3 +serdes_driver_current_lane2_xe9=0x3 +serdes_driver_current_lane3_xe9=0x3 +serdes_pre_driver_current_lane0_xe9=0x3 +serdes_pre_driver_current_lane1_xe9=0x3 +serdes_pre_driver_current_lane2_xe9=0x3 +serdes_pre_driver_current_lane3_xe9=0x3 +serdes_preemphasis_lane0_xe9=0xc2f0 +serdes_preemphasis_lane1_xe9=0xc6e0 +serdes_preemphasis_lane2_xe9=0xbf00 +serdes_preemphasis_lane3_xe9=0xc2f0 + +# xe10 (40G) +portmap_11=17:40 +xgxs_rx_lane_map_11=0x213 +xgxs_tx_lane_map_11=0x132 +phy_xaui_rx_polarity_flip_11=0xe +phy_xaui_tx_polarity_flip_11=0x0 +serdes_driver_current_lane0_xe10=0x2 +serdes_driver_current_lane1_xe10=0x2 +serdes_driver_current_lane2_xe10=0x2 +serdes_driver_current_lane3_xe10=0x2 +serdes_pre_driver_current_lane0_xe10=0x2 +serdes_pre_driver_current_lane1_xe10=0x2 +serdes_pre_driver_current_lane2_xe10=0x2 +serdes_pre_driver_current_lane3_xe10=0x2 +serdes_preemphasis_lane0_xe10=0xb330 +serdes_preemphasis_lane1_xe10=0xbb10 +serdes_preemphasis_lane2_xe10=0xbb10 +serdes_preemphasis_lane3_xe10=0xbb10 + +# xe11 (40G) +portmap_12=21:40 +xgxs_rx_lane_map_12=0x123 +xgxs_tx_lane_map_12=0x1203 +phy_xaui_rx_polarity_flip_12=0xc +phy_xaui_tx_polarity_flip_12=0xe +serdes_driver_current_lane0_xe11=0x2 +serdes_driver_current_lane1_xe11=0x2 +serdes_driver_current_lane2_xe11=0x2 +serdes_driver_current_lane3_xe11=0x2 +serdes_pre_driver_current_lane0_xe11=0x2 +serdes_pre_driver_current_lane1_xe11=0x2 +serdes_pre_driver_current_lane2_xe11=0x2 +serdes_pre_driver_current_lane3_xe11=0x2 +serdes_preemphasis_lane0_xe11=0xb330 +serdes_preemphasis_lane1_xe11=0xb330 +serdes_preemphasis_lane2_xe11=0xb330 +serdes_preemphasis_lane3_xe11=0xb330 + +# xe12 (40G) +portmap_13=53:40 +xgxs_rx_lane_map_13=0x213 +xgxs_tx_lane_map_13=0x231 +phy_xaui_rx_polarity_flip_13=0x1 +phy_xaui_tx_polarity_flip_13=0x0 +serdes_driver_current_lane0_xe12=0x2 +serdes_driver_current_lane1_xe12=0x2 +serdes_driver_current_lane2_xe12=0x2 +serdes_driver_current_lane3_xe12=0x2 +serdes_pre_driver_current_lane0_xe12=0x2 +serdes_pre_driver_current_lane1_xe12=0x2 +serdes_pre_driver_current_lane2_xe12=0x2 +serdes_pre_driver_current_lane3_xe12=0x2 +serdes_preemphasis_lane0_xe12=0xaf40 +serdes_preemphasis_lane1_xe12=0xaf40 +serdes_preemphasis_lane2_xe12=0xaf40 +serdes_preemphasis_lane3_xe12=0xaf40 + +# xe13 (40G) +portmap_14=49:40 +xgxs_rx_lane_map_14=0x1302 +xgxs_tx_lane_map_14=0x2031 +phy_xaui_rx_polarity_flip_14=0xb +phy_xaui_tx_polarity_flip_14=0x3 +serdes_driver_current_lane0_xe13=0x2 +serdes_driver_current_lane1_xe13=0x2 +serdes_driver_current_lane2_xe13=0x2 +serdes_driver_current_lane3_xe13=0x2 +serdes_pre_driver_current_lane0_xe13=0x2 +serdes_pre_driver_current_lane1_xe13=0x2 +serdes_pre_driver_current_lane2_xe13=0x2 +serdes_pre_driver_current_lane3_xe13=0x2 +serdes_preemphasis_lane0_xe13=0xa760 +serdes_preemphasis_lane1_xe13=0xa760 +serdes_preemphasis_lane2_xe13=0xa760 +serdes_preemphasis_lane3_xe13=0xa760 + +# xe14 (40G) +portmap_15=57:40 +xgxs_rx_lane_map_15=0x213 +xgxs_tx_lane_map_15=0x2031 +phy_xaui_rx_polarity_flip_15=0x1 +phy_xaui_tx_polarity_flip_15=0x0 +serdes_driver_current_lane0_xe14=0x1 +serdes_driver_current_lane1_xe14=0x1 +serdes_driver_current_lane2_xe14=0x1 +serdes_driver_current_lane3_xe14=0x1 +serdes_pre_driver_current_lane0_xe14=0x1 +serdes_pre_driver_current_lane1_xe14=0x1 +serdes_pre_driver_current_lane2_xe14=0x1 +serdes_pre_driver_current_lane3_xe14=0x1 +serdes_preemphasis_lane0_xe14=0xa760 +serdes_preemphasis_lane1_xe14=0xa760 +serdes_preemphasis_lane2_xe14=0xa760 +serdes_preemphasis_lane3_xe14=0xa760 + +# xe15 (40G) +portmap_16=61:40 +xgxs_rx_lane_map_16=0x132 +xgxs_tx_lane_map_16=0x213 +phy_xaui_rx_polarity_flip_16=0x0 +phy_xaui_tx_polarity_flip_16=0x0 +serdes_driver_current_lane0_xe15=0x2 +serdes_driver_current_lane1_xe15=0x2 +serdes_driver_current_lane2_xe15=0x2 +serdes_driver_current_lane3_xe15=0x2 +serdes_pre_driver_current_lane0_xe15=0x2 +serdes_pre_driver_current_lane1_xe15=0x2 +serdes_pre_driver_current_lane2_xe15=0x2 +serdes_pre_driver_current_lane3_xe15=0x2 +serdes_preemphasis_lane0_xe15=0xa760 +serdes_preemphasis_lane1_xe15=0xa760 +serdes_preemphasis_lane2_xe15=0xa760 +serdes_preemphasis_lane3_xe15=0xa760 + +# xe16 (40G) +portmap_17=69:40 +xgxs_rx_lane_map_17=0x213 +xgxs_tx_lane_map_17=0x2130 +phy_xaui_rx_polarity_flip_17=0x1 +phy_xaui_tx_polarity_flip_17=0xf +serdes_driver_current_lane0_xe16=0x1 +serdes_driver_current_lane1_xe16=0x1 +serdes_driver_current_lane2_xe16=0x1 +serdes_driver_current_lane3_xe16=0x1 +serdes_pre_driver_current_lane0_xe16=0x1 +serdes_pre_driver_current_lane1_xe16=0x1 +serdes_pre_driver_current_lane2_xe16=0x1 +serdes_pre_driver_current_lane3_xe16=0x1 +serdes_preemphasis_lane0_xe16=0xa760 +serdes_preemphasis_lane1_xe16=0xa760 +serdes_preemphasis_lane2_xe16=0xa760 +serdes_preemphasis_lane3_xe16=0xa760 + +# xe17 (40G) +portmap_18=65:40 +xgxs_rx_lane_map_18=0x132 +xgxs_tx_lane_map_18=0x2031 +phy_xaui_rx_polarity_flip_18=0x3 +phy_xaui_tx_polarity_flip_18=0x9 +serdes_driver_current_lane0_xe17=0x1 +serdes_driver_current_lane1_xe17=0x1 +serdes_driver_current_lane2_xe17=0x1 +serdes_driver_current_lane3_xe17=0x1 +serdes_pre_driver_current_lane0_xe17=0x1 +serdes_pre_driver_current_lane1_xe17=0x1 +serdes_pre_driver_current_lane2_xe17=0x1 +serdes_pre_driver_current_lane3_xe17=0x1 +serdes_preemphasis_lane0_xe17=0xa370 +serdes_preemphasis_lane1_xe17=0xa370 +serdes_preemphasis_lane2_xe17=0xa370 +serdes_preemphasis_lane3_xe17=0xa370 + +# xe18 (40G) +portmap_19=73:40 +xgxs_rx_lane_map_19=0x213 +xgxs_tx_lane_map_19=0x2031 +phy_xaui_rx_polarity_flip_19=0x1 +phy_xaui_tx_polarity_flip_19=0x0 +serdes_driver_current_lane0_xe18=0x2 +serdes_driver_current_lane1_xe18=0x2 +serdes_driver_current_lane2_xe18=0x2 +serdes_driver_current_lane3_xe18=0x2 +serdes_pre_driver_current_lane0_xe18=0x2 +serdes_pre_driver_current_lane1_xe18=0x2 +serdes_pre_driver_current_lane2_xe18=0x2 +serdes_pre_driver_current_lane3_xe18=0x2 +serdes_preemphasis_lane0_xe18=0xa760 +serdes_preemphasis_lane1_xe18=0xa760 +serdes_preemphasis_lane2_xe18=0xa760 +serdes_preemphasis_lane3_xe18=0xa760 + +# xe19 (40G) +portmap_20=77:40 +xgxs_rx_lane_map_20=0x123 +xgxs_tx_lane_map_20=0x1203 +phy_xaui_rx_polarity_flip_20=0x3 +phy_xaui_tx_polarity_flip_20=0xe +serdes_driver_current_lane0_xe19=0x2 +serdes_driver_current_lane1_xe19=0x2 +serdes_driver_current_lane2_xe19=0x2 +serdes_driver_current_lane3_xe19=0x2 +serdes_pre_driver_current_lane0_xe19=0x2 +serdes_pre_driver_current_lane1_xe19=0x2 +serdes_pre_driver_current_lane2_xe19=0x2 +serdes_pre_driver_current_lane3_xe19=0x2 +serdes_preemphasis_lane0_xe19=0xaf40 +serdes_preemphasis_lane1_xe19=0xaf40 +serdes_preemphasis_lane2_xe19=0xaf40 +serdes_preemphasis_lane3_xe19=0xaf40 + +# xe20 (40G) +portmap_21=109:40 +xgxs_rx_lane_map_21=0x132 +xgxs_tx_lane_map_21=0x132 +phy_xaui_rx_polarity_flip_21=0x8 +phy_xaui_tx_polarity_flip_21=0x0 +serdes_driver_current_lane0_xe20=0x1 +serdes_driver_current_lane1_xe20=0x1 +serdes_driver_current_lane2_xe20=0x1 +serdes_driver_current_lane3_xe20=0x2 +serdes_pre_driver_current_lane0_xe20=0x1 +serdes_pre_driver_current_lane1_xe20=0x1 +serdes_pre_driver_current_lane2_xe20=0x1 +serdes_pre_driver_current_lane3_xe20=0x2 +serdes_preemphasis_lane0_xe20=0xb330 +serdes_preemphasis_lane1_xe20=0xb330 +serdes_preemphasis_lane2_xe20=0xb330 +serdes_preemphasis_lane3_xe20=0xbff0 + +# xe21 (40G) +portmap_22=105:40 +xgxs_rx_lane_map_22=0x1320 +xgxs_tx_lane_map_22=0x3021 +phy_xaui_rx_polarity_flip_22=0xd +phy_xaui_tx_polarity_flip_22=0xb +serdes_driver_current_lane0_xe21=0x1 +serdes_driver_current_lane1_xe21=0x1 +serdes_driver_current_lane2_xe21=0x1 +serdes_driver_current_lane3_xe21=0x1 +serdes_pre_driver_current_lane0_xe21=0x1 +serdes_pre_driver_current_lane1_xe21=0x1 +serdes_pre_driver_current_lane2_xe21=0x1 +serdes_pre_driver_current_lane3_xe21=0x1 +serdes_preemphasis_lane0_xe21=0xb330 +serdes_preemphasis_lane1_xe21=0xb330 +serdes_preemphasis_lane2_xe21=0xb330 +serdes_preemphasis_lane3_xe21=0xb330 + +# xe22 (40G) +portmap_23=113:40 +xgxs_rx_lane_map_23=0x132 +xgxs_tx_lane_map_23=0x132 +phy_xaui_rx_polarity_flip_23=0x8 +phy_xaui_tx_polarity_flip_23=0x0 +serdes_driver_current_lane0_xe22=0x1 +serdes_driver_current_lane1_xe22=0x1 +serdes_driver_current_lane2_xe22=0x1 +serdes_driver_current_lane3_xe22=0x1 +serdes_pre_driver_current_lane0_xe22=0x1 +serdes_pre_driver_current_lane1_xe22=0x1 +serdes_pre_driver_current_lane2_xe22=0x1 +serdes_pre_driver_current_lane3_xe22=0x1 +serdes_preemphasis_lane0_xe22=0xbb10 +serdes_preemphasis_lane1_xe22=0xbb10 +serdes_preemphasis_lane2_xe22=0xbb10 +serdes_preemphasis_lane3_xe22=0xc2f0 + +# xe23 (40G) +portmap_24=117:40 +xgxs_rx_lane_map_24=0x231 +xgxs_tx_lane_map_24=0x1203 +phy_xaui_rx_polarity_flip_24=0x3 +phy_xaui_tx_polarity_flip_24=0xe +serdes_driver_current_lane0_xe23=0x3 +serdes_driver_current_lane1_xe23=0x5 +serdes_driver_current_lane2_xe23=0x3 +serdes_driver_current_lane3_xe23=0x3 +serdes_pre_driver_current_lane0_xe23=0x3 +serdes_pre_driver_current_lane1_xe23=0x5 +serdes_pre_driver_current_lane2_xe23=0x3 +serdes_pre_driver_current_lane3_xe23=0x3 +serdes_preemphasis_lane0_xe23=0xc6e0 +serdes_preemphasis_lane1_xe23=0xc6e0 +serdes_preemphasis_lane2_xe23=0xc6e0 +serdes_preemphasis_lane3_xe23=0xc6e0 + +# xe24 (40G) +portmap_25=125:40 +xgxs_rx_lane_map_25=0x132 +xgxs_tx_lane_map_25=0x132 +phy_xaui_rx_polarity_flip_25=0x8 +phy_xaui_tx_polarity_flip_25=0x0 +serdes_driver_current_lane0_xe24=0x4 +serdes_driver_current_lane1_xe24=0x4 +serdes_driver_current_lane2_xe24=0x4 +serdes_driver_current_lane3_xe24=0x4 +serdes_pre_driver_current_lane0_xe24=0x4 +serdes_pre_driver_current_lane1_xe24=0x4 +serdes_pre_driver_current_lane2_xe24=0x4 +serdes_pre_driver_current_lane3_xe24=0x4 +serdes_preemphasis_lane0_xe24=0xc6e0 +serdes_preemphasis_lane1_xe24=0xc6e0 +serdes_preemphasis_lane2_xe24=0xc6e0 +serdes_preemphasis_lane3_xe24=0xcec0 + +# xe25 (40G) +portmap_26=121:40 +xgxs_rx_lane_map_26=0x1320 +xgxs_tx_lane_map_26=0x3021 +phy_xaui_rx_polarity_flip_26=0xd +phy_xaui_tx_polarity_flip_26=0xb +serdes_driver_current_lane0_xe25=0x4 +serdes_driver_current_lane1_xe25=0x4 +serdes_driver_current_lane2_xe25=0x4 +serdes_driver_current_lane3_xe25=0x4 +serdes_pre_driver_current_lane0_xe25=0x4 +serdes_pre_driver_current_lane1_xe25=0x4 +serdes_pre_driver_current_lane2_xe25=0x4 +serdes_pre_driver_current_lane3_xe25=0x4 +serdes_preemphasis_lane0_xe25=0xc6e0 +serdes_preemphasis_lane1_xe25=0xc6e0 +serdes_preemphasis_lane2_xe25=0xc6e0 +serdes_preemphasis_lane3_xe25=0xc6e0 + +# xe26 (40G) +portmap_27=81:40 +xgxs_rx_lane_map_27=0x1320 +xgxs_tx_lane_map_27=0x2031 +phy_xaui_rx_polarity_flip_27=0x1 +phy_xaui_tx_polarity_flip_27=0x2 +serdes_driver_current_lane0_xe26=0x2 +serdes_driver_current_lane1_xe26=0x2 +serdes_driver_current_lane2_xe26=0x2 +serdes_driver_current_lane3_xe26=0x2 +serdes_pre_driver_current_lane0_xe26=0x2 +serdes_pre_driver_current_lane1_xe26=0x2 +serdes_pre_driver_current_lane2_xe26=0x2 +serdes_pre_driver_current_lane3_xe26=0x2 +serdes_preemphasis_lane0_xe26=0xbb10 +serdes_preemphasis_lane1_xe26=0xbb10 +serdes_preemphasis_lane2_xe26=0xbf00 +serdes_preemphasis_lane3_xe26=0xbb10 + +# xe27 (40G) +portmap_28=85:40 +xgxs_rx_lane_map_28=0x213 +xgxs_tx_lane_map_28=0x1203 +phy_xaui_rx_polarity_flip_28=0xc +phy_xaui_tx_polarity_flip_28=0xe +serdes_driver_current_lane0_xe27=0x4 +serdes_driver_current_lane1_xe27=0x5 +serdes_driver_current_lane2_xe27=0x4 +serdes_driver_current_lane3_xe27=0x5 +serdes_pre_driver_current_lane0_xe27=0x4 +serdes_pre_driver_current_lane1_xe27=0x5 +serdes_pre_driver_current_lane2_xe27=0x4 +serdes_pre_driver_current_lane3_xe27=0x5 +serdes_preemphasis_lane0_xe27=0xc2f0 +serdes_preemphasis_lane1_xe27=0xc6e0 +serdes_preemphasis_lane2_xe27=0xc6e0 +serdes_preemphasis_lane3_xe27=0xc6e0 + +# xe28 (40G) +portmap_29=93:40 +xgxs_rx_lane_map_29=0x1320 +xgxs_tx_lane_map_29=0x2031 +phy_xaui_rx_polarity_flip_29=0x1 +phy_xaui_tx_polarity_flip_29=0x2 +serdes_driver_current_lane0_xe28=0x4 +serdes_driver_current_lane1_xe28=0x4 +serdes_driver_current_lane2_xe28=0x4 +serdes_driver_current_lane3_xe28=0x4 +serdes_pre_driver_current_lane0_xe28=0x4 +serdes_pre_driver_current_lane1_xe28=0x4 +serdes_pre_driver_current_lane2_xe28=0x4 +serdes_pre_driver_current_lane3_xe28=0x4 +serdes_preemphasis_lane0_xe28=0xc2f0 +serdes_preemphasis_lane1_xe28=0xc2f0 +serdes_preemphasis_lane2_xe28=0xc2f0 +serdes_preemphasis_lane3_xe28=0xc2f0 + +# xe29 (40G) +portmap_30=89:40 +xgxs_rx_lane_map_30=0x1320 +xgxs_tx_lane_map_30=0x3021 +phy_xaui_rx_polarity_flip_30=0x2 +phy_xaui_tx_polarity_flip_30=0xb +serdes_driver_current_lane0_xe29=0x4 +serdes_driver_current_lane1_xe29=0x4 +serdes_driver_current_lane2_xe29=0x4 +serdes_driver_current_lane3_xe29=0x4 +serdes_pre_driver_current_lane0_xe29=0x4 +serdes_pre_driver_current_lane1_xe29=0x4 +serdes_pre_driver_current_lane2_xe29=0x4 +serdes_pre_driver_current_lane3_xe29=0x4 +serdes_preemphasis_lane0_xe29=0xcad0 +serdes_preemphasis_lane1_xe29=0xc6e0 +serdes_preemphasis_lane2_xe29=0xc6e0 +serdes_preemphasis_lane3_xe29=0xc6e0 + +# xe30 (40G) +portmap_31=101:40 +xgxs_rx_lane_map_31=0x1320 +xgxs_tx_lane_map_31=0x1203 +phy_xaui_rx_polarity_flip_31=0x1 +phy_xaui_tx_polarity_flip_31=0x6 +serdes_driver_current_lane0_xe30=0x6 +serdes_driver_current_lane1_xe30=0x6 +serdes_driver_current_lane2_xe30=0x6 +serdes_driver_current_lane3_xe30=0x7 +serdes_pre_driver_current_lane0_xe30=0x6 +serdes_pre_driver_current_lane1_xe30=0x6 +serdes_pre_driver_current_lane2_xe30=0x6 +serdes_pre_driver_current_lane3_xe30=0x7 +serdes_preemphasis_lane0_xe30=0xcec0 +serdes_preemphasis_lane1_xe30=0xcec0 +serdes_preemphasis_lane2_xe30=0xcad0 +serdes_preemphasis_lane3_xe30=0xc6e0 + +# xe31 (40G) +portmap_32=97:40 +xgxs_rx_lane_map_32=0x213 +xgxs_tx_lane_map_32=0x2031 +phy_xaui_rx_polarity_flip_32=0xc +phy_xaui_tx_polarity_flip_32=0x3 +serdes_driver_current_lane0_xe31=0x5 +serdes_driver_current_lane1_xe31=0x5 +serdes_driver_current_lane2_xe31=0x5 +serdes_driver_current_lane3_xe31=0x5 +serdes_pre_driver_current_lane0_xe31=0x5 +serdes_pre_driver_current_lane1_xe31=0x5 +serdes_pre_driver_current_lane2_xe31=0x5 +serdes_pre_driver_current_lane3_xe31=0x5 +serdes_preemphasis_lane0_xe31=0xcad0 +serdes_preemphasis_lane1_xe31=0xcad0 +serdes_preemphasis_lane2_xe31=0xcad0 +serdes_preemphasis_lane3_xe31=0xcad0 diff --git a/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py b/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py index 7b0d5097d2ec..b4e158ce7f79 100644 --- a/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py +++ b/dockers/docker-dhcp-relay/cli/clear/plugins/clear_dhcp6relay_counter.py @@ -1,7 +1,6 @@ import sys import click -sys.path.insert(0, '../../show/plugins/') -from show_dhcp6relay_counters import DHCPv6_Counter +from show.plugins.dhcprelay import DHCPv6_Counter import utilities_common.cli as clicommon @@ -15,7 +14,7 @@ def dhcp6relay_clear(): @click.option('-i', '--interface', required=False) def dhcp6relay_clear_counters(interface): """ Clear dhcp6relay message counts """ - + counter = DHCPv6_Counter() counter_intf = counter.get_interface() diff --git a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 index 7d6bc4ef04ae..1453d6fc8029 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2 @@ -33,7 +33,7 @@ ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq {{ loop.index * 5 }} permit {{ prefi {% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' or DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %} {% set multi_asic = True %} {% endif %} -{% if multi_asic is defined or DEVICE_METADATA['localhost']['switch_type'] == 'voq' %} +{% if multi_asic is defined or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} route-map HIDE_INTERNAL permit 10 set community no-export {% if constants.bgp.peers is defined and constants.bgp.peers.internal is defined and constants.bgp.peers.internal.community is defined %} @@ -63,7 +63,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} {% endif %} ! {# set router-id #} -{% if DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' or DEVICE_METADATA['localhost']['switch_type'] == 'voq' %} +{% if DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }} {% else %} bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }} @@ -71,7 +71,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} ! {# advertise loopback #} network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/32 -{% if multi_asic is defined or DEVICE_METADATA['localhost']['switch_type'] == 'voq' %} +{% if multi_asic is defined or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/32 route-map HIDE_INTERNAL {% endif %} ! @@ -80,7 +80,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/64 exit-address-family {% endif %} -{% if multi_asic is defined or DEVICE_METADATA['localhost']['switch_type'] == 'voq'%} +{% if multi_asic is defined or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} {% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") != 'None' %} address-family ipv6 network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/128 route-map HIDE_INTERNAL @@ -102,7 +102,7 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} {% endblock vlan_advertisement %} ! ! -{% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' or DEVICE_METADATA['localhost']['switch_type'] == 'voq' %} +{% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' or DEVICE_METADATA['localhost']['switch_type'] == 'voq' or DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} address-family ipv4 redistribute connected route-map HIDE_INTERNAL exit-address-family diff --git a/dockers/docker-fpm-frr/frr/bgpd/templates/internal/peer-group.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/templates/internal/peer-group.conf.j2 index c0ee4d99b796..c5f3f0b2f3a9 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/templates/internal/peer-group.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/templates/internal/peer-group.conf.j2 @@ -1,10 +1,15 @@ ! ! template: bgpd/templates/internal/peer-group.conf.j2 +{% from "common/functions.conf.j2" import get_ipv4_loopback_address %} +{% from "common/functions.conf.j2" import get_ipv6_loopback_address %} ! neighbor INTERNAL_PEER_V4 peer-group neighbor INTERNAL_PEER_V6 peer-group address-family ipv4 -{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %} + +{% if CONFIG_DB__DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} + neighbor INTERNAL_PEER_V4 update-source {{ get_ipv4_loopback_address(CONFIG_DB__LOOPBACK_INTERFACE, "Loopback4096") | ip }} +{% elif CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %} neighbor INTERNAL_PEER_V4 route-reflector-client {% endif %} neighbor INTERNAL_PEER_V4 soft-reconfiguration inbound @@ -13,7 +18,9 @@ neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out exit-address-family address-family ipv6 -{% if CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %} +{% if CONFIG_DB__DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} + neighbor INTERNAL_PEER_V4 update-source {{ get_ipv6_loopback_address(CONFIG_DB__LOOPBACK_INTERFACE, "Loopback4096") | ip }} +{% elif CONFIG_DB__DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd' %} neighbor INTERNAL_PEER_V6 route-reflector-client {% endif %} neighbor INTERNAL_PEER_V6 soft-reconfiguration inbound diff --git a/dockers/docker-mux/supervisord.conf b/dockers/docker-mux/supervisord.conf index e4eff7c351b0..87903f28e155 100644 --- a/dockers/docker-mux/supervisord.conf +++ b/dockers/docker-mux/supervisord.conf @@ -38,4 +38,3 @@ stdout_logfile=syslog stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=rsyslogd:running - diff --git a/files/image_config/copp/copp-config.service b/files/image_config/copp/copp-config.service index 8eed2353eddf..bd15de80bc5f 100644 --- a/files/image_config/copp/copp-config.service +++ b/files/image_config/copp/copp-config.service @@ -2,10 +2,12 @@ Description=Update CoPP configuration Requires=updategraph.service After=updategraph.service +BindsTo=sonic.target +After=sonic.target [Service] Type=oneshot ExecStart=/usr/bin/copp-config.sh [Install] -WantedBy=multi-user.target +WantedBy=sonic.target diff --git a/files/scripts/write_standby.py b/files/scripts/write_standby.py index 1dfc8c19e2a1..4c5455803fac 100755 --- a/files/scripts/write_standby.py +++ b/files/scripts/write_standby.py @@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import logging import time from sonic_py_common import logger as log from swsscommon.swsscommon import ConfigDBConnector, DBConnector, FieldValuePairs, ProducerStateTable, SonicV2Connector -from swsscommon.swsscommon import APPL_DB, ASIC_DB +from swsscommon.swsscommon import APPL_DB logger = log.Logger('write_standby') @@ -15,7 +14,7 @@ def create_fvs(**kwargs): return FieldValuePairs(list(kwargs.items())) -class MuxStateWriter: +class MuxStateWriter(object): """ Class used to write standby mux state to APP DB """ diff --git a/platform/marvell/sai.mk b/platform/marvell/sai.mk index ac05bc8f0470..602f922968bd 100644 --- a/platform/marvell/sai.mk +++ b/platform/marvell/sai.mk @@ -1,6 +1,6 @@ # Marvell SAI -export MRVL_SAI_VERSION = 1.5.1 +export MRVL_SAI_VERSION = 1.8.1-1 export MRVL_SAI = mrvllibsai_amd64_$(MRVL_SAI_VERSION).deb $(MRVL_SAI)_SRC_PATH = $(PLATFORM_PATH)/sai diff --git a/platform/mellanox/asic_table.j2 b/platform/mellanox/asic_table.j2 index 77f62e3b3689..78f8aec07f89 100644 --- a/platform/mellanox/asic_table.j2 +++ b/platform/mellanox/asic_table.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost']['platform'] is defined %} {%- set platform = DEVICE_METADATA['localhost']['platform'] %} {%- else -%} diff --git a/platform/mellanox/docker-saiserver-mlnx.mk b/platform/mellanox/docker-saiserver-mlnx.mk index 4f15ed82e6c8..4d49b337e7e4 100644 --- a/platform/mellanox/docker-saiserver-mlnx.mk +++ b/platform/mellanox/docker-saiserver-mlnx.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # docker image for mlnx saiserver DOCKER_SAISERVER_MLNX = docker-saiserver-mlnx.gz diff --git a/platform/mellanox/docker-saiserver-mlnx/Dockerfile.j2 b/platform/mellanox/docker-saiserver-mlnx/Dockerfile.j2 index 39223131ee43..1444c7a24d62 100644 --- a/platform/mellanox/docker-saiserver-mlnx/Dockerfile.j2 +++ b/platform/mellanox/docker-saiserver-mlnx/Dockerfile.j2 @@ -1,3 +1,19 @@ +## +## Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## FROM docker-config-engine-stretch ARG docker_container_name diff --git a/platform/mellanox/docker-saiserver-mlnx/portmap.ini b/platform/mellanox/docker-saiserver-mlnx/portmap.ini index 4d3be08ce5f8..9643de59afa3 100644 --- a/platform/mellanox/docker-saiserver-mlnx/portmap.ini +++ b/platform/mellanox/docker-saiserver-mlnx/portmap.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## # alias lanes Ethernet1 0,1,2,3 Ethernet2 4,5,6,7 diff --git a/platform/mellanox/docker-saiserver-mlnx/profile.ini b/platform/mellanox/docker-saiserver-mlnx/profile.ini index c67be49f3c45..3315af1fe11d 100644 --- a/platform/mellanox/docker-saiserver-mlnx/profile.ini +++ b/platform/mellanox/docker-saiserver-mlnx/profile.ini @@ -1 +1,17 @@ -SAI_INIT_CONFIG_FILE=/usr/share/sai_2700.xml \ No newline at end of file +## +## Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +SAI_INIT_CONFIG_FILE=/usr/share/sai_2700.xml diff --git a/platform/mellanox/docker-saiserver-mlnx/sai_2700.xml b/platform/mellanox/docker-saiserver-mlnx/sai_2700.xml index 42b576311453..84e6c9909394 100644 --- a/platform/mellanox/docker-saiserver-mlnx/sai_2700.xml +++ b/platform/mellanox/docker-saiserver-mlnx/sai_2700.xml @@ -1,4 +1,20 @@ + diff --git a/platform/mellanox/docker-saiserver-mlnx/start.sh b/platform/mellanox/docker-saiserver-mlnx/start.sh index 58a0c316add3..d5ac04c5e323 100755 --- a/platform/mellanox/docker-saiserver-mlnx/start.sh +++ b/platform/mellanox/docker-saiserver-mlnx/start.sh @@ -1,4 +1,20 @@ #!/usr/bin/env bash +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# start_mlnx() { diff --git a/platform/mellanox/docker-syncd-mlnx-rpc.mk b/platform/mellanox/docker-syncd-mlnx-rpc.mk index fe2ff5916493..674b7a03b31b 100644 --- a/platform/mellanox/docker-syncd-mlnx-rpc.mk +++ b/platform/mellanox/docker-syncd-mlnx-rpc.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # docker image for mlnx syncd with rpc DOCKER_SYNCD_MLNX_RPC = docker-syncd-mlnx-rpc.gz diff --git a/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 index b48d4ac3c793..50850039c01d 100644 --- a/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx-rpc/Dockerfile.j2 @@ -1,3 +1,19 @@ +## +## Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} FROM docker-syncd-mlnx diff --git a/platform/mellanox/docker-syncd-mlnx.mk b/platform/mellanox/docker-syncd-mlnx.mk index 5f04399d20a0..f24845655ae7 100644 --- a/platform/mellanox/docker-syncd-mlnx.mk +++ b/platform/mellanox/docker-syncd-mlnx.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # docker image for mlnx syncd DOCKER_SYNCD_PLATFORM_CODE = mlnx diff --git a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 index 011931b2ff4b..404db43c70aa 100755 --- a/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 +++ b/platform/mellanox/docker-syncd-mlnx/Dockerfile.j2 @@ -1,3 +1,19 @@ +## +## Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## {% from "dockers/dockerfile-macros.j2" import install_debian_packages, install_python_wheels, copy_files %} FROM docker-config-engine-buster diff --git a/platform/mellanox/fw.mk b/platform/mellanox/fw.mk index 6b9790374d40..58a3f3d1b460 100644 --- a/platform/mellanox/fw.mk +++ b/platform/mellanox/fw.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # mellanox asic firmware MLNX_FW_BASE_PATH = $(MLNX_SDK_BASE_PATH) diff --git a/platform/mellanox/hw-management.mk b/platform/mellanox/hw-management.mk index 6dc1f2655629..df8886abe06d 100644 --- a/platform/mellanox/hw-management.mk +++ b/platform/mellanox/hw-management.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # Mellanox HW Management MLNX_HW_MANAGEMENT_VERSION = 7.0010.2344 diff --git a/platform/mellanox/issu-version.mk b/platform/mellanox/issu-version.mk index db368ffd8c10..21e8d94a2206 100644 --- a/platform/mellanox/issu-version.mk +++ b/platform/mellanox/issu-version.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # ISSU version ISSU_VERSION_FILE = issu-version diff --git a/platform/mellanox/issu-version/Makefile b/platform/mellanox/issu-version/Makefile index 1f7d7fba3a3f..fbb21af74902 100644 --- a/platform/mellanox/issu-version/Makefile +++ b/platform/mellanox/issu-version/Makefile @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# .ONESHELL: SHELL = /bin/bash .SHELLFLAGS += -e diff --git a/platform/mellanox/libsaithrift-dev.mk b/platform/mellanox/libsaithrift-dev.mk index b0ef5746db73..03daf65fac84 100644 --- a/platform/mellanox/libsaithrift-dev.mk +++ b/platform/mellanox/libsaithrift-dev.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # libsaithrift-dev package SAI_VER = 0.9.4 diff --git a/platform/mellanox/mft.mk b/platform/mellanox/mft.mk index 5e9644b5703c..01af61e6f6a7 100644 --- a/platform/mellanox/mft.mk +++ b/platform/mellanox/mft.mk @@ -1,7 +1,23 @@ +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # Mellanox SAI -MFT_VERSION = 4.17.0 -MFT_REVISION = 106 +MFT_VERSION = 4.17.2 +MFT_REVISION = 12 export MFT_VERSION MFT_REVISION diff --git a/platform/mellanox/mft/Makefile b/platform/mellanox/mft/Makefile index 84a587730386..755ef4afc220 100644 --- a/platform/mellanox/mft/Makefile +++ b/platform/mellanox/mft/Makefile @@ -1,3 +1,19 @@ +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# .ONESHELL: SHELL = /bin/bash .SHELLFLAGS += -e diff --git a/platform/mellanox/mlnx-ffb.mk b/platform/mellanox/mlnx-ffb.mk index 6c3c925b5996..64fad0858f48 100755 --- a/platform/mellanox/mlnx-ffb.mk +++ b/platform/mellanox/mlnx-ffb.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # mellanox fast fast boot script MLNX_FFB_SCRIPT = mlnx-ffb.sh diff --git a/platform/mellanox/mlnx-ffb.sh b/platform/mellanox/mlnx-ffb.sh index d0bef9d57761..afe42c819870 100755 --- a/platform/mellanox/mlnx-ffb.sh +++ b/platform/mellanox/mlnx-ffb.sh @@ -1,4 +1,20 @@ #!/bin/bash +# +# Copyright (c) 2018-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# FFB_SUCCESS=0 FFB_FAILURE=1 diff --git a/platform/mellanox/mlnx-onie-fw-update.mk b/platform/mellanox/mlnx-onie-fw-update.mk index 13f68ce4671f..af8e7299c9d2 100644 --- a/platform/mellanox/mlnx-onie-fw-update.mk +++ b/platform/mellanox/mlnx-onie-fw-update.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # onie update tool MLNX_ONIE_FW_UPDATE = mlnx-onie-fw-update.sh diff --git a/platform/mellanox/mlnx-onie-fw-update.sh b/platform/mellanox/mlnx-onie-fw-update.sh index 0abc55ef76b4..b1b85f5fb42d 100755 --- a/platform/mellanox/mlnx-onie-fw-update.sh +++ b/platform/mellanox/mlnx-onie-fw-update.sh @@ -1,9 +1,21 @@ #!/bin/bash - -# Copyright (C) 2019 Mellanox Technologies Ltd. -# Copyright (C) 2019 Michael Shych # -# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + this_script="$(basename $(realpath ${0}))" lock_file="/var/run/${this_script%.*}.lock" diff --git a/platform/mellanox/mlnx-platform-api.mk b/platform/mellanox/mlnx-platform-api.mk index e7e36c1f67b8..0dc7e0c2cd6e 100644 --- a/platform/mellanox/mlnx-platform-api.mk +++ b/platform/mellanox/mlnx-platform-api.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # SONIC_PLATFORM_API_PY2 package SONIC_PLATFORM_API_PY2 = mlnx_platform_api-1.0-py2-none-any.whl diff --git a/platform/mellanox/mlnx-platform-api/pytest.ini b/platform/mellanox/mlnx-platform-api/pytest.ini index c24fe5bb9e65..4c699c515652 100644 --- a/platform/mellanox/mlnx-platform-api/pytest.ini +++ b/platform/mellanox/mlnx-platform-api/pytest.ini @@ -1,3 +1,19 @@ +## +## Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## [pytest] filterwarnings = ignore::DeprecationWarning diff --git a/platform/mellanox/mlnx-platform-api/setup.py b/platform/mellanox/mlnx-platform-api/setup.py index df1a8cadbb09..31dba9d2ae00 100644 --- a/platform/mellanox/mlnx-platform-api/setup.py +++ b/platform/mellanox/mlnx-platform-api/setup.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# from setuptools import setup setup( diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/__init__.py b/platform/mellanox/mlnx-platform-api/sonic_platform/__init__.py index d82f3749319c..4d778682cdd5 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/__init__.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/__init__.py @@ -1,2 +1,18 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# __all__ = ["platform", "chassis"] from sonic_platform import * diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py index 2c54b9539376..e3d826358702 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/chassis.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/component.py b/platform/mellanox/mlnx-platform-api/sonic_platform/component.py index 0e7a024cca14..4a252db72d72 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/component.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/component.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # @@ -351,7 +367,7 @@ def auto_update_firmware(self, image_path, boot_action): return FW_AUTO_ERR_IMAGE if boot_action in default_supported_boot: - if self.install_firmware(image_path): + if self.update_firmware(image_path): # Successful update return FW_AUTO_INSTALLED # Failed update (unknown reason) @@ -405,10 +421,6 @@ def _check_file_validity(self, image_path): if name_list[1] != self.image_ext_name: print("ERROR: Extend name of file {} is wrong. Image for {} should have extend name {}".format(image_path, self.name, self.image_ext_name)) return False - else: - if name_list[1]: - print("ERROR: Extend name of file {} is wrong. Image for {} shouldn't have extension".format(image_path, self.name)) - return False return True @@ -520,7 +532,7 @@ def auto_update_firmware(self, image_path, boot_action): return FW_AUTO_ERR_UKNOWN if boot_action in supported_boot: - if self.install_firmware(image_path): + if self.update_firmware(image_path): # Successful update return FW_AUTO_INSTALLED # Failed update (unknown reason) diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py b/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py index e1124d0d55e3..0b42b6fa4f42 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/device_data.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# DEVICE_DATA = { 'x86_64-mlnx_msn2700-r0': { 'thermal': { diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py b/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py index 3bc169843a39..bd2711633d87 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/eeprom.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py b/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py index 7eb0ce946b17..0128bbb54282 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/fan.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/fan_drawer.py b/platform/mellanox/mlnx-platform-api/sonic_platform/fan_drawer.py index d73b52368100..23ecba001946 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/fan_drawer.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/fan_drawer.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/led.py b/platform/mellanox/mlnx-platform-api/sonic_platform/led.py index d67cbb1d9557..2d8b16177016 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/led.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/led.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# import os diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/pcie.py b/platform/mellanox/mlnx-platform-api/sonic_platform/pcie.py index 96d590e5e2e3..f814583dcca0 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/pcie.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/pcie.py @@ -1,6 +1,20 @@ -######################################################################## # -# Copyright (C) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +######################################################################## # # Module contains a platform specific implementation of SONiC Platform # Base PCIe class diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/platform.py b/platform/mellanox/mlnx-platform-api/sonic_platform/platform.py index 6e18d1fbd854..3b26e7ede403 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/platform.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/platform.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py index dbc395ba935f..8dd8bea2dc24 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/psu.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py index 42876adf3c6c..874ebaa8dee0 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py index 2c77e6d5651b..6f00d4252982 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/sfp_event.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ''' listen to the SDK for the SFP change event and return to chassis. ''' diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py index d28eabdbe6a4..85523fd5ac0e 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################# # Mellanox # diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py index e7436bd0a5b7..f9e2c55328b0 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_actions.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# from sonic_platform_base.sonic_thermal_control.thermal_action_base import ThermalPolicyActionBase from sonic_platform_base.sonic_thermal_control.thermal_json_object import thermal_json_object from .thermal import logger diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py index a682061d12a8..6c82fb752171 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_conditions.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# from sonic_platform_base.sonic_thermal_control.thermal_condition_base import ThermalPolicyConditionBase from sonic_platform_base.sonic_thermal_control.thermal_json_object import thermal_json_object diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_infos.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_infos.py index df262557c417..19bbfdd5caf5 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_infos.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_infos.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# from sonic_platform_base.sonic_thermal_control.thermal_info_base import ThermalPolicyInfoBase from sonic_platform_base.sonic_thermal_control.thermal_json_object import thermal_json_object diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_manager.py b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_manager.py index c2acf49a2245..cfcd911b9c9a 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_manager.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/thermal_manager.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# import os from sonic_platform_base.sonic_thermal_control.thermal_manager_base import ThermalManagerBase from sonic_platform_base.sonic_thermal_control.thermal_policy import ThermalPolicy diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/utils.py b/platform/mellanox/mlnx-platform-api/sonic_platform/utils.py index cee6d27b63fa..0dd29e11dbc8 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/utils.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/utils.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# import functools import subprocess diff --git a/platform/mellanox/mlnx-platform-api/sonic_platform/watchdog.py b/platform/mellanox/mlnx-platform-api/sonic_platform/watchdog.py index 0737b0446671..879aabfd3530 100644 --- a/platform/mellanox/mlnx-platform-api/sonic_platform/watchdog.py +++ b/platform/mellanox/mlnx-platform-api/sonic_platform/watchdog.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2019-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# """ Mellanox diff --git a/platform/mellanox/mlnx-platform-api/tests/__init__.py b/platform/mellanox/mlnx-platform-api/tests/__init__.py index e69de29bb2d1..9afd76ba9fd9 100644 --- a/platform/mellanox/mlnx-platform-api/tests/__init__.py +++ b/platform/mellanox/mlnx-platform-api/tests/__init__.py @@ -0,0 +1,16 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/platform/mellanox/mlnx-platform-api/tests/mock_platform.py b/platform/mellanox/mlnx-platform-api/tests/mock_platform.py index 1cd8f89d4805..044f26c01dbe 100644 --- a/platform/mellanox/mlnx-platform-api/tests/mock_platform.py +++ b/platform/mellanox/mlnx-platform-api/tests/mock_platform.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# class MockFan: speed = 60 def __init__(self): diff --git a/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py b/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py index bb9ee7e125a2..fe3b7c9494f9 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_fan_api.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# import os import sys import pytest diff --git a/platform/mellanox/mlnx-platform-api/tests/test_firmware.py b/platform/mellanox/mlnx-platform-api/tests/test_firmware.py index cdd68fa70505..6e24bdf07d24 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_firmware.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_firmware.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# import os import sys import pytest @@ -16,10 +32,10 @@ FW_AUTO_ERR_IMAGE, \ FW_AUTO_ERR_UKNOWN -def mock_install_firmware_success(image_path): +def mock_update_firmware_success(image_path): return True -def mock_install_firmware_fail(image_path): +def mock_update_firmware_fail(image_path): return False def mock_update_notification_cold_boot(image_path): @@ -34,29 +50,29 @@ def mock_update_notification_error(image_path): test_data_default = [ (None, False, None, FW_AUTO_ERR_IMAGE), (None, True, 'warm', FW_AUTO_ERR_BOOT_TYPE), - (mock_install_firmware_fail, True, 'cold', FW_AUTO_ERR_UKNOWN), - (mock_install_firmware_success, True, 'cold', FW_AUTO_INSTALLED) + (mock_update_firmware_fail, True, 'cold', FW_AUTO_ERR_UKNOWN), + (mock_update_firmware_success, True, 'cold', FW_AUTO_INSTALLED) ] test_data_ssd = [ (None, None, False, None, FW_AUTO_ERR_IMAGE), (None, mock_update_notification_error, True, None, FW_AUTO_ERR_UKNOWN), - (mock_install_firmware_fail, mock_update_notification_cold_boot, True, 'cold', FW_AUTO_ERR_UKNOWN), - (mock_install_firmware_success, mock_update_notification_cold_boot, True, 'warm', FW_AUTO_ERR_BOOT_TYPE), - (mock_install_firmware_success, mock_update_notification_cold_boot, True, 'cold', FW_AUTO_INSTALLED), - (mock_install_firmware_success, mock_update_notification_warm_boot, True, 'warm', FW_AUTO_INSTALLED), - (mock_install_firmware_success, mock_update_notification_warm_boot, True, 'cold', FW_AUTO_INSTALLED) + (mock_update_firmware_fail, mock_update_notification_cold_boot, True, 'cold', FW_AUTO_ERR_UKNOWN), + (mock_update_firmware_success, mock_update_notification_cold_boot, True, 'warm', FW_AUTO_ERR_BOOT_TYPE), + (mock_update_firmware_success, mock_update_notification_cold_boot, True, 'cold', FW_AUTO_INSTALLED), + (mock_update_firmware_success, mock_update_notification_warm_boot, True, 'warm', FW_AUTO_INSTALLED), + (mock_update_firmware_success, mock_update_notification_warm_boot, True, 'cold', FW_AUTO_INSTALLED) ] -@pytest.mark.parametrize('install_func, image_found, boot_type, expect', test_data_default) -def test_auto_update_firmware_default(monkeypatch, install_func, image_found, boot_type, expect): +@pytest.mark.parametrize('update_func, image_found, boot_type, expect', test_data_default) +def test_auto_update_firmware_default(monkeypatch, update_func, image_found, boot_type, expect): def mock_path_exists(path): return image_found test_component = Component() - monkeypatch.setattr(test_component, 'install_firmware', install_func) + monkeypatch.setattr(test_component, 'update_firmware', update_func) monkeypatch.setattr(os.path, 'exists', mock_path_exists) result = test_component.auto_update_firmware(None, boot_type) @@ -64,15 +80,15 @@ def mock_path_exists(path): assert result == expect -@pytest.mark.parametrize('install_func, notify, image_found, boot_type, expect', test_data_ssd) -def test_auto_update_firmware_default(monkeypatch, install_func, notify, image_found, boot_type, expect): +@pytest.mark.parametrize('update_func, notify, image_found, boot_type, expect', test_data_ssd) +def test_auto_update_firmware_default(monkeypatch, update_func, notify, image_found, boot_type, expect): def mock_path_exists(path): return image_found test_component_ssd = ComponentSSD() - monkeypatch.setattr(test_component_ssd, 'install_firmware', install_func) + monkeypatch.setattr(test_component_ssd, 'update_firmware', update_func) monkeypatch.setattr(test_component_ssd, 'get_firmware_update_notification', notify) monkeypatch.setattr(os.path, 'exists', mock_path_exists) diff --git a/platform/mellanox/mlnx-platform-api/tests/test_sfp.py b/platform/mellanox/mlnx-platform-api/tests/test_sfp.py index 405a48a77b79..f85d1891ae7e 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_sfp.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_sfp.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# import os import sys import pytest diff --git a/platform/mellanox/mlnx-platform-api/tests/test_sfp_event.py b/platform/mellanox/mlnx-platform-api/tests/test_sfp_event.py index 3edcc362a5e6..461b2417e598 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_sfp_event.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_sfp_event.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# import os import select import sys diff --git a/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py b/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py index e2fb26cf6083..27f512f048eb 100644 --- a/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py +++ b/platform/mellanox/mlnx-platform-api/tests/test_thermal_policy.py @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# import os import sys import pytest diff --git a/platform/mellanox/mlnx-ssd-fw-update.mk b/platform/mellanox/mlnx-ssd-fw-update.mk index 024710efbf9b..b39056eb5a6b 100644 --- a/platform/mellanox/mlnx-ssd-fw-update.mk +++ b/platform/mellanox/mlnx-ssd-fw-update.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # ssd update tool MLNX_SSD_FW_UPDATE = mlnx-ssd-fw-update.sh diff --git a/platform/mellanox/mlnx-ssd-fw-update.sh b/platform/mellanox/mlnx-ssd-fw-update.sh index 4a2204adacf8..e453aa24ebb5 100755 --- a/platform/mellanox/mlnx-ssd-fw-update.sh +++ b/platform/mellanox/mlnx-ssd-fw-update.sh @@ -1,36 +1,22 @@ #!/bin/bash -######################################################################## -# Copyright (c) 2020 Mellanox Technologies. All rights reserved. # -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: +# Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 # -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the names of the copyright holders nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# Alternatively, this software may be distributed under the terms of the -# GNU General Public License ("GPL") version 2 as published by the Free -# Software Foundation. +# http://www.apache.org/licenses/LICENSE-2.0 # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # + #==============================================================================# #= Global variable # #= diff --git a/platform/mellanox/one-image.mk b/platform/mellanox/one-image.mk index 0f69b7335bf1..ad912e260d1e 100644 --- a/platform/mellanox/one-image.mk +++ b/platform/mellanox/one-image.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2017-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # sonic mellanox one image installer SONIC_ONE_IMAGE = sonic-mellanox.bin diff --git a/platform/mellanox/peripheral_table.j2 b/platform/mellanox/peripheral_table.j2 index 730fd681bc61..d2c1d5e9059a 100644 --- a/platform/mellanox/peripheral_table.j2 +++ b/platform/mellanox/peripheral_table.j2 @@ -1,3 +1,19 @@ +{# + Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. + Apache-2.0 + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +#} {%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost']['platform'] is defined %} {%- set platform = DEVICE_METADATA['localhost']['platform'] %} {%- endif -%} diff --git a/platform/mellanox/rules.mk b/platform/mellanox/rules.mk index 179e20f3fff5..be046bed91eb 100644 --- a/platform/mellanox/rules.mk +++ b/platform/mellanox/rules.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# include $(PLATFORM_PATH)/sdk.mk include $(PLATFORM_PATH)/fw.mk include $(PLATFORM_PATH)/mft.mk diff --git a/platform/mellanox/sdk.mk b/platform/mellanox/sdk.mk index 3c5a46a76767..1e26f53b918c 100644 --- a/platform/mellanox/sdk.mk +++ b/platform/mellanox/sdk.mk @@ -1,3 +1,19 @@ +# +# Copyright (c) 2016-2021 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# MLNX_SDK_BASE_PATH = $(PLATFORM_PATH)/sdk-src/sx-kernel/Switch-SDK-drivers/bin/ MLNX_SDK_PKG_BASE_PATH = $(MLNX_SDK_BASE_PATH)/$(BLDENV)/ MLNX_SDK_VERSION = 4.4.3326 diff --git a/rules/config b/rules/config index f8d16f0a04b9..47c784e61006 100644 --- a/rules/config +++ b/rules/config @@ -208,3 +208,6 @@ REGISTRY_SERVER ?= sonicdev-microsoft.azurecr.io # BUILD_MULTIASIC_KVM - if set to y multi-asic KVM images will be generated. BUILD_MULTIASIC_KVM = n + +# INCLUDE_MUX - build docker-mux for dual ToR (Gemini) +INCLUDE_MUX = y diff --git a/rules/docker-mux.mk b/rules/docker-mux.mk index 725e9a8b2929..6f3b3b986418 100644 --- a/rules/docker-mux.mk +++ b/rules/docker-mux.mk @@ -14,6 +14,11 @@ $(DOCKER_MUX)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PA $(DOCKER_MUX)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BUSTER) +$(DOCKER_MUX)_VERSION = 1.0.0 +$(DOCKER_MUX)_PACKAGE_NAME = mux +$(DOCKER_MUX)_WARM_SHUTDOWN_BEFORE = swss +$(DOCKER_MUX)_FAST_SHUTDOWN_BEFORE = swss + ifeq ($(INCLUDE_MUX), y) SONIC_DOCKER_IMAGES += $(DOCKER_MUX) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_MUX) @@ -24,9 +29,6 @@ SONIC_DOCKER_DBG_IMAGES += $(DOCKER_MUX_DBG) SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_MUX_DBG) endif -$(DOCKER_MUX)_VERSION = 1.0.0 -$(DOCKER_MUX)_PACKAGE_NAME = linkmgr - $(DOCKER_MUX)_CONTAINER_NAME = mux $(DOCKER_MUX)_RUN_OPT += --privileged -t $(DOCKER_MUX)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro diff --git a/rules/linkmgrd.dep b/rules/linkmgrd.dep index d94e328bf399..31894e46d298 100644 --- a/rules/linkmgrd.dep +++ b/rules/linkmgrd.dep @@ -2,8 +2,10 @@ SPATH := $($(SONIC_LINKMGRD)_SRC_PATH) DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/linkmgrd.mk rules/linkmgrd.dep DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) -DEP_FILES += $(shell git ls-files $(SPATH)) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) $(SONIC_LINKMGRD)_CACHE_MODE := GIT_CONTENT_SHA $(SONIC_LINKMGRD)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) $(SONIC_LINKMGRD)_DEP_FILES := $(DEP_FILES) +$(SONIC_LINKMGRD)_SMDEP_FILES := $(SMDEP_FILES) +$(SONIC_LINKMGRD)_SMDEP_PATHS := $(SPATH) diff --git a/slave.mk b/slave.mk index d55e7ad8d797..7b193c8d9d38 100644 --- a/slave.mk +++ b/slave.mk @@ -1021,6 +1021,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export components="$(foreach component,$(notdir $^),\ $(shell [[ ! -z '$($(component)_VERSION)' && ! -z '$($(component)_NAME)' ]] && \ echo $($(component)_NAME)==$($(component)_VERSION)))" + export include_mux="$(INCLUDE_MUX)" $(foreach docker, $($*_DOCKERS),\ export docker_image="$(docker)" export docker_image_name="$(basename $(docker))" diff --git a/sonic-slave-bullseye/Dockerfile.j2 b/sonic-slave-bullseye/Dockerfile.j2 index 8a6e68b0546a..2396b892bbcf 100644 --- a/sonic-slave-bullseye/Dockerfile.j2 +++ b/sonic-slave-bullseye/Dockerfile.j2 @@ -22,8 +22,8 @@ RUN echo "deb [arch=armhf] http://deb.debian.org/debian bullseye main contrib no echo "deb-src [arch=armhf] http://deb.debian.org/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=armhf] http://deb.debian.org/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \ echo "deb-src [arch=armhf] http://deb.debian.org/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \ - echo "deb [arch=armhf] http://security.debian.org bullseye/updates main contrib non-free" >> /etc/apt/sources.list && \ - echo "deb-src [arch=armhf] http://security.debian.org bullseye/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb [arch=armhf] http://security.debian.org/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src [arch=armhf] http://security.debian.org/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list && \ echo 'deb [arch=armhf] http://ftp.debian.org/debian bullseye-backports main' >> /etc/apt/sources.list && \ echo "deb [arch=armhf] http://packages.trafficmanager.net/debian/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=armhf] http://packages.trafficmanager.net/debian/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list @@ -32,8 +32,8 @@ RUN echo "deb [arch=arm64] http://deb.debian.org/debian bullseye main contrib no echo "deb-src [arch=arm64] http://deb.debian.org/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://deb.debian.org/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \ echo "deb-src [arch=arm64] http://deb.debian.org/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list && \ - echo "deb [arch=arm64] http://security.debian.org bullseye/updates main contrib non-free" >> /etc/apt/sources.list && \ - echo "deb-src [arch=arm64] http://security.debian.org bullseye/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb [arch=arm64] http://security.debian.org/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src [arch=arm64] http://security.debian.org/debian-security bullseye-security main contrib non-free" >> /etc/apt/sources.list && \ echo 'deb [arch=arm64] http://ftp.debian.org/debian bullseye-backports main' >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://packages.trafficmanager.net/debian/debian bullseye main contrib non-free" >> /etc/apt/sources.list && \ echo "deb [arch=arm64] http://packages.trafficmanager.net/debian/debian bullseye-updates main contrib non-free" >> /etc/apt/sources.list diff --git a/src/dhcpmon/src/dhcp_device.c b/src/dhcpmon/src/dhcp_device.c index 3078295e49a4..e4fbc7f56909 100644 --- a/src/dhcpmon/src/dhcp_device.c +++ b/src/dhcpmon/src/dhcp_device.c @@ -121,6 +121,8 @@ static struct sock_fprog dhcp_sock_bfp = { */ static dhcp_device_context_t aggregate_dev = {0}; +static dhcp_device_context_t *mgmt_intf = NULL; + /** Monitored DHCPv4 message type */ static dhcpv4_message_type_t v4_monitored_msgs[] = { DHCPv4_MESSAGE_TYPE_DISCOVER, @@ -176,6 +178,11 @@ static void handle_dhcp_option_53(dhcp_device_context_t *context, if ((context->giaddr_ip == giaddr && context->is_uplink && dir == DHCP_TX) || (!context->is_uplink && dir == DHCP_RX && iphdr->ip_dst.s_addr == INADDR_BROADCAST)) { context->counters.v4counters[DHCP_COUNTERS_CURRENT][dir][dhcp_option[2]]++; + // If the packet recieved on the mgmt interface, we don't want to increment the aggregate device + if (context == mgmt_intf) + { + break; + } aggregate_dev.counters.v4counters[DHCP_COUNTERS_CURRENT][dir][dhcp_option[2]]++; } break; @@ -186,6 +193,11 @@ static void handle_dhcp_option_53(dhcp_device_context_t *context, if ((context->giaddr_ip == iphdr->ip_dst.s_addr && context->is_uplink && dir == DHCP_RX) || (!context->is_uplink && dir == DHCP_TX)) { context->counters.v4counters[DHCP_COUNTERS_CURRENT][dir][dhcp_option[2]]++; + // If the packet recieved on the mgmt interface, we don't want to increment the aggregate device + if (context == mgmt_intf) + { + break; + } aggregate_dev.counters.v4counters[DHCP_COUNTERS_CURRENT][dir][dhcp_option[2]]++; } break; @@ -224,6 +236,11 @@ static void handle_dhcpv6_option(dhcp_device_context_t *context, case DHCPv6_MESSAGE_TYPE_RECONFIGURE: case DHCPv6_MESSAGE_TYPE_INFORMATION_REQUEST: context->counters.v6counters[DHCP_COUNTERS_CURRENT][dir][dhcp_option]++; + // If the packet recieved on the mgmt interface, we don't want to increment the aggregate device + if (context == mgmt_intf) + { + break; + } aggregate_dev.counters.v6counters[DHCP_COUNTERS_CURRENT][dir][dhcp_option]++; break; default: @@ -309,7 +326,7 @@ static void read_callback(int fd, short event, void *arg) } } else if (!is_ipv4 && dhcpv6_enabled && (buffer_sz > UDPv6_START_OFFSET + sizeof(struct udphdr) + DHCPv6_TYPE_LENGTH)) { - const u_char* dhcp_option = context->buffer + dhcp_option_offset; + const u_char* dhcp_header = context->buffer + dhcp_option_offset; dhcp_packet_direction_t dir = (ethhdr->ether_shost[0] == context->mac[0] && ethhdr->ether_shost[1] == context->mac[1] && ethhdr->ether_shost[2] == context->mac[2] && @@ -319,23 +336,25 @@ static void read_callback(int fd, short event, void *arg) DHCP_TX : DHCP_RX; int offset = 0; uint16_t option = 0; + uint16_t current_option_len = 0; // Get to inner DHCP header from encapsulated RELAY_FORWARD or RELAY_REPLY header - while (dhcp_option[offset] == DHCPv6_MESSAGE_TYPE_RELAY_FORWARD || dhcp_option[offset] == DHCPv6_MESSAGE_TYPE_RELAY_REPLY) + while (dhcp_header[offset] == DHCPv6_MESSAGE_TYPE_RELAY_FORWARD || dhcp_header[offset] == DHCPv6_MESSAGE_TYPE_RELAY_REPLY) { // Get to DHCPv6_OPTION_RELAY_MSG from all options offset += DHCPv6_RELAY_MSG_OPTIONS_OFFSET; - option = htons(*((uint16_t*)(&(dhcp_option[offset])))); + option = htons(*((uint16_t*)(&(dhcp_header[offset])))); while (option != DHCPv6_OPTION_RELAY_MSG) { - offset += DHCPv6_OPTION_LENGTH; // Add to offset the option length and get the next option ID - offset += htons(*((uint16_t*)(&(dhcp_option[offset])))); - option = htons(*((uint16_t*)(&(dhcp_option[offset])))); + current_option_len = htons(*((uint16_t*)(&(dhcp_header[offset + DHCPv6_OPTION_LENGTH])))); + offset += DHCPv6_OPTION_LENGTH + DHCPv6_OPTION_LEN_LENGTH + current_option_len; + option = htons(*((uint16_t*)(&(dhcp_header[offset])))); } + // Set the offset to DHCP-relay-message data offset += DHCPv6_OPTION_LENGTH + DHCPv6_OPTION_LEN_LENGTH; } - handle_dhcpv6_option(context, dhcp_option[offset], dir); + handle_dhcpv6_option(context, dhcp_header[offset], dir); } else { syslog(LOG_WARNING, "read_callback(%s): read length (%ld) is too small to capture DHCP options", context->intf, buffer_sz); @@ -554,7 +573,7 @@ static dhcp_mon_status_t dhcp_device_check_health(dhcp_mon_check_t check_type, { dhcp_mon_status_t rv = DHCP_MON_STATUS_HEALTHY; - if (dhcp_device_is_dhcp_inactive(aggregate_dev.counters.v4counters, aggregate_dev.counters.v6counters, type)) { + if (dhcp_device_is_dhcp_inactive(v4counters, v6counters, type)) { rv = DHCP_MON_STATUS_INDETERMINATE; } else if (check_type == DHCP_MON_CHECK_POSITIVE) { rv = dhcp_device_check_positive_health(v4counters, v6counters, type); @@ -948,3 +967,13 @@ void dhcp_device_active_types(bool dhcpv4, bool dhcpv6) dhcpv4_enabled = dhcpv4; dhcpv6_enabled = dhcpv6; } + +/** + * @code dhcp_device_init_mgmt_intf(mgmt_intf_context); + * + * @brief assign context address of mgmt interface + */ +void dhcp_device_init_mgmt_intf(dhcp_device_context_t *mgmt_intf_context) +{ + mgmt_intf = mgmt_intf_context; +} diff --git a/src/dhcpmon/src/dhcp_device.h b/src/dhcpmon/src/dhcp_device.h index f8aa874bfcce..433eb0907626 100644 --- a/src/dhcpmon/src/dhcp_device.h +++ b/src/dhcpmon/src/dhcp_device.h @@ -255,4 +255,15 @@ void dhcp_device_print_status(dhcp_device_context_t *context, dhcp_counters_type * @return none */ void dhcp_device_active_types(bool dhcpv4, bool dhcpv6); + +/** + * @code dhcp_device_init_mgmt_intf(mgmt_intf_context); + * + * @brief assign context address of mgmt interface + * + * @param mgmt_intf_context MGMT interface context struct address + * + * @return none + */ +void dhcp_device_init_mgmt_intf(dhcp_device_context_t *mgmt_intf_context); #endif /* DHCP_DEVICE_H_ */ diff --git a/src/dhcpmon/src/dhcp_devman.c b/src/dhcpmon/src/dhcp_devman.c index e7a25322207f..b36d926c1d5b 100644 --- a/src/dhcpmon/src/dhcp_devman.c +++ b/src/dhcpmon/src/dhcp_devman.c @@ -148,6 +148,9 @@ int dhcp_devman_add_intf(const char *name, char intf_type) strncpy(agg_dev->intf + sizeof(AGG_DEV_PREFIX) - 1, name, sizeof(agg_dev->intf) - sizeof(AGG_DEV_PREFIX)); agg_dev->intf[sizeof(agg_dev->intf) - 1] = '\0'; } + else if (rv == 0 && intf_type == 'm') { + dhcp_device_init_mgmt_intf(dev->dev_context); + } LIST_INSERT_HEAD(&intfs, dev, entry); } diff --git a/src/linkmgrd b/src/linkmgrd new file mode 160000 index 000000000000..97cba3e90977 --- /dev/null +++ b/src/linkmgrd @@ -0,0 +1 @@ +Subproject commit 97cba3e909774f252394a30c826adbea32fe9132 diff --git a/src/linkmgrd/.gitignore b/src/linkmgrd/.gitignore deleted file mode 100644 index 09a2736df782..000000000000 --- a/src/linkmgrd/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -**/*.o -**/*.d -**/*.gcda -**/*.gcno -**/*.gcov -**/*.html -debian/debhelper-build-stamp -debian/sonic-linkmgrd/ -linkmgrd -linkmgrd-test - diff --git a/src/linkmgrd/Makefile b/src/linkmgrd/Makefile deleted file mode 100644 index ffa83252cccd..000000000000 --- a/src/linkmgrd/Makefile +++ /dev/null @@ -1,115 +0,0 @@ --include ../makefile.init - -GCOVR := gcovr -FIND := find -MAKE := make -RM := rm -rf -LINKMGRD_TARGET := linkmgrd -LINKMGRD_TEST_TARGET := linkmgrd-test -CP := cp -MKDIR := mkdir -CC := g++ -MV := mv -BOOST_MACROS = -DBOOST_LOG_USE_NATIVE_SYSLOG -DBOOST_LOG_DYN_LINK -GCOV_FLAGS := -fprofile-use -fprofile-arcs -ftest-coverage -fprofile-generate -TOPDIR := $(dir $(firstword $(MAKEFILE_LIST))) -MAKE_PID := $(shell echo $$PPID) -JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)"))) -JOBS := $(subst -j,,$(JOB_FLAG)) - -release-targets: CPP_FLAGS := -O3 -Wall -c -fmessage-length=0 -fPIC -flto -test-targets: CPP_FLAGS = -O0 -Wall -c -fmessage-length=0 -fPIC $(GCOV_FLAGS) - -INCLUDES := \ - -I"$(TOPDIR)/src" \ - -I"/usr/include/libnl3/" - -# All of the sources participating in the build are defined here --include sources.mk --include test/subdir.mk --include src/mux_state/subdir.mk --include src/link_state/subdir.mk --include src/link_prober/subdir.mk --include src/link_manager/subdir.mk --include src/common/subdir.mk --include src/subdir.mk --include subdir.mk --include objects.mk - -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(strip $(CC_DEPS)),) --include $(CC_DEPS) -endif -ifneq ($(strip $(C++_DEPS)),) --include $(C++_DEPS) -endif -ifneq ($(strip $(C_UPPER_DEPS)),) --include $(C_UPPER_DEPS) -endif -ifneq ($(strip $(CXX_DEPS)),) --include $(CXX_DEPS) -endif -ifneq ($(strip $(CPP_DEPS)),) --include $(CPP_DEPS) -endif -ifneq ($(strip $(C_DEPS)),) --include $(C_DEPS) -endif -endif - --include ../makefile.defs - -# Add inputs and outputs from these tool invocations to the build variables - -# All Target -all: sonic-linkmgrd - -# Tool invocations -release-targets: $(OBJS) $(USER_OBJS) $(OBJS_LINKMGRD) - @echo 'Building target: $@' - @echo 'Invoking: GCC C++ Linker' - $(CC) -pthread -o "$(LINKMGRD_TARGET)" $(OBJS) $(OBJS_LINKMGRD) $(USER_OBJS) $(LIBS) - @echo 'Finished building target: $@' - @echo ' ' - -sonic-linkmgrd: clean-targets - $(MAKE) -j $(JOBS) release-targets - -# test Target -test-targets: $(OBJS) $(USER_OBJS) $(OBJS_LINKMGRD_TEST) - @echo 'Building target: $@' - @echo 'Invoking: GCC C++ Linker' - $(CC) -pthread -fprofile-generate -lgcov -o "$(LINKMGRD_TEST_TARGET)" $(OBJS) $(OBJS_LINKMGRD_TEST) $(USER_OBJS) $(LIBS) $(LIBS_TEST) - @echo 'Executing test target: $@' - LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.5 ./$(LINKMGRD_TEST_TARGET) - $(GCOVR) -r ./ --html --html-details -o $(LINKMGRD_TEST_TARGET)-result.html - @echo 'Finished building target: $@' - @echo ' ' - -test: clean-targets - $(MAKE) -j $(JOBS) test-targets - -install: - $(MKDIR) -p $(DESTDIR)/usr/sbin - $(MV) $(LINKMGRD_TARGET) $(DESTDIR)/usr/sbin - $(RM) $(CC_DEPS) $(C++_DEPS) $(EXECUTABLES) $(C_UPPER_DEPS) $(CXX_DEPS) $(OBJS) $(CPP_DEPS) $(C_DEPS) \ - $(LINKMGRD_TARGET) $(LINKMGRD_TEST_TARGET) $(OBJS_LINKMGRD) $(OBJS_LINKMGRD_TEST) - -deinstall: - $(RM) $(DESTDIR)/usr/sbin/$(LINKMGRD_TARGET) - $(RM) -rf $(DESTDIR)/usr/sbin - -clean-targets: - $(RM) $(CC_DEPS) $(C++_DEPS) $(EXECUTABLES) $(C_UPPER_DEPS) $(CXX_DEPS) $(OBJS) $(CPP_DEPS) $(C_DEPS) \ - $(OBJS_LINKMGRD) $(OBJS_LINKMGRD_TEST) - -clean: clean-targets - $(RM) $(LINKMGRD_TARGET) $(LINKMGRD_TEST_TARGET) *.html - $(FIND) . -name *.gcda -exec rm -f {} \; - $(FIND) . -name *.gcno -exec rm -f {} \; - $(FIND) . -name *.gcov -exec rm -f {} \; - @echo ' ' - -.PHONY: all clean dependents - --include ../makefile.targets diff --git a/src/linkmgrd/debian/changelog b/src/linkmgrd/debian/changelog deleted file mode 100644 index 0b89b2123a9f..000000000000 --- a/src/linkmgrd/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -sonic-linkmgrd (1.0.0-1) UNRELEASED; urgency=medium - - * Initial release. - - -- Tamer Ahmed Mon, 26 Oct 2020 12:00:00 -0700 diff --git a/src/linkmgrd/debian/compat b/src/linkmgrd/debian/compat deleted file mode 100644 index f599e28b8ab0..000000000000 --- a/src/linkmgrd/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/src/linkmgrd/debian/control b/src/linkmgrd/debian/control deleted file mode 100644 index 7ee5499f8ab1..000000000000 --- a/src/linkmgrd/debian/control +++ /dev/null @@ -1,18 +0,0 @@ -Source: sonic-linkmgrd -Section: devel -Priority: optional -Maintainer: Tamer Ahmed -Build-Depends: debhelper (>= 8.0.0), - dh-systemd -Standards-Version: 3.9.3 -Homepage: https://github.com/Azure/sonic-buildimage -XS-Go-Import-Path: github.com/Azure/sonic-buildimage - -Package: sonic-linkmgrd -Architecture: any -Built-Using: ${misc:Built-Using} -Depends: libboost-program-options1.71.0, - libboost-thread1.71.0, - libboost-date-time1.71.0, - libboost-log1.71.0 -Description: SONiC LINK ManaGeR Daemon (linkmgrd) diff --git a/src/linkmgrd/debian/rules b/src/linkmgrd/debian/rules deleted file mode 100755 index 60a99a3a8fc6..000000000000 --- a/src/linkmgrd/debian/rules +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/make -f - -%: - dh $@ --parallel - - \ No newline at end of file diff --git a/src/linkmgrd/objects.mk b/src/linkmgrd/objects.mk deleted file mode 100644 index 17c9aef76a32..000000000000 --- a/src/linkmgrd/objects.mk +++ /dev/null @@ -1,16 +0,0 @@ - -USER_OBJS := - -LIBS := \ - -lswsscommon \ - -lboost_date_time \ - -lboost_thread \ - -lboost_log \ - -lboost_log_setup \ - -lboost_program_options \ - -lnl-3 \ - -lnl-route-3 - -LIBS_TEST := \ - -lgtest_main \ - -lgtest diff --git a/src/linkmgrd/sources.mk b/src/linkmgrd/sources.mk deleted file mode 100644 index e15b1077b8f8..000000000000 --- a/src/linkmgrd/sources.mk +++ /dev/null @@ -1,30 +0,0 @@ - -C_UPPER_SRCS := -CXX_SRCS := -C++_SRCS := -OBJ_SRCS := -CC_SRCS := -ASM_SRCS := -CPP_SRCS := -C_SRCS := -O_SRCS := -S_UPPER_SRCS := -CC_DEPS := -C++_DEPS := -EXECUTABLES := -C_UPPER_DEPS := -CXX_DEPS := -OBJS := -CPP_DEPS := -C_DEPS := - -# Every subdirectory with source files must be described here -SUBDIRS := \ - src \ - src/common \ - src/link_manager \ - src/link_prober \ - src/link_state \ - src/mux_state \ - test \ - diff --git a/src/linkmgrd/src/DbInterface.cpp b/src/linkmgrd/src/DbInterface.cpp deleted file mode 100644 index 66ac185dd4df..000000000000 --- a/src/linkmgrd/src/DbInterface.cpp +++ /dev/null @@ -1,796 +0,0 @@ -/* - * DbInterface.cpp - * - * Created on: Oct 23, 2020 - * Author: tamer - */ - -#include -#include - -#include -#include -#include -#include - -#include "swss/netdispatcher.h" -#include "swss/netlink.h" -#include "swss/macaddress.h" -#include "swss/select.h" - -#include "DbInterface.h" -#include "MuxManager.h" -#include "common/MuxLogger.h" -#include "common/MuxException.h" -#include "NetMsgInterface.h" - -namespace mux -{ -constexpr auto DEFAULT_TIMEOUT_MSEC = 1000; -std::vector DbInterface::mMuxState = {"active", "standby", "unknown", "Error"}; -std::vector DbInterface::mMuxLinkmgrState = {"uninitialized", "unhealthy", "healthy"}; -std::vector DbInterface::mMuxMetrics = {"start", "end"}; - -// -// ---> DbInterface(mux::MuxManager *muxManager); -// -// class constructor -// -DbInterface::DbInterface(mux::MuxManager *muxManager, boost::asio::io_service *ioService) : - mMuxManagerPtr(muxManager), - mBarrier(2), - mStrand(*ioService) -{ -} - - -// -// ---> getMuxState(const std::string &portName); -// -// retrieve the current MUX state -// -void DbInterface::getMuxState(const std::string &portName) -{ - MUXLOGDEBUG(portName); - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &DbInterface::handleGetMuxState, - this, - portName - ))); -} - -// -// ---> setMuxState(const std::string &portName, mux_state::MuxState::Label label); -// -// set MUX state in APP DB for orchagent processing -// -void DbInterface::setMuxState(const std::string &portName, mux_state::MuxState::Label label) -{ - MUXLOGDEBUG(boost::format("%s: setting mux to %s") % portName % mMuxState[label]); - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &DbInterface::handleSetMuxState, - this, - portName, - label - ))); -} - -// -// ---> probeMuxState(const std::string &portName) -// -// trigger xcvrd to read MUX state using i2c -// -void DbInterface::probeMuxState(const std::string &portName) -{ - MUXLOGDEBUG(portName); - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &DbInterface::handleProbeMuxState, - this, - portName - ))); -} - -// -// ---> setMuxLinkmgrState(const std::string &portName, link_manager::LinkManagerStateMachine::Label label); -// -// set MUX LinkMgr state in State DB for cli processing -// -void DbInterface::setMuxLinkmgrState(const std::string &portName, link_manager::LinkManagerStateMachine::Label label) -{ - MUXLOGDEBUG(boost::format("%s: setting mux linkmgr to %s") % portName % mMuxLinkmgrState[static_cast (label)]); - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &DbInterface::handleSetMuxLinkmgrState, - this, - portName, - label - ))); -} - -// -// ---> postMetricsEvent( -// const std::string &portName, -// link_manager::LinkManagerStateMachine::Metrics metrics -// mux_state::MuxState::Label label); -// -// post MUX metrics event -// -void DbInterface::postMetricsEvent( - const std::string &portName, - link_manager::LinkManagerStateMachine::Metrics metrics, - mux_state::MuxState::Label label -) -{ - MUXLOGDEBUG(boost::format("%s: posting mux metrics event linkmgrd_switch_%s_%s") % - portName % - mMuxState[label] % - mMuxMetrics[static_cast (metrics)] - ); - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &DbInterface::handlePostMuxMetrics, - this, - portName, - metrics, - label, - boost::posix_time::microsec_clock::universal_time() - ))); -} - -// -// ---> initialize(); -// -// initialize DB tables and start SWSS listening thread -// -void DbInterface::initialize() -{ - try { - mAppDbPtr = std::make_shared ("APPL_DB", 0); - mStateDbPtr = std::make_shared ("STATE_DB", 0); - - mAppDbMuxTablePtr = std::make_shared ( - mAppDbPtr.get(), APP_MUX_CABLE_TABLE_NAME - ); - mAppDbMuxCommandTablePtr = std::make_shared ( - mAppDbPtr.get(), APP_MUX_CABLE_COMMAND_TABLE_NAME - ); - mStateDbMuxLinkmgrTablePtr = std::make_shared ( - mStateDbPtr.get(), STATE_MUX_LINKMGR_TABLE_NAME - ); - mStateDbMuxMetricsTablePtr = std::make_shared ( - mStateDbPtr.get(), STATE_MUX_METRICS_TABLE_NAME - ); - mMuxStateTablePtr = std::make_shared (mStateDbPtr.get(), STATE_MUX_CABLE_TABLE_NAME); - - mSwssThreadPtr = std::make_shared (&DbInterface::handleSwssNotification, this); - } - catch (const std::bad_alloc &ex) { - std::ostringstream errMsg; - errMsg << "Failed allocate memory. Exception details: " << ex.what(); - - throw MUX_ERROR(BadAlloc, errMsg.str()); - } -} - -// -// ---> deinitialize(); -// -// deinitialize DB interface and join SWSS listening thread -// -void DbInterface::deinitialize() -{ - mSwssThreadPtr->join(); -} - -// -// ---> updateServerMacAddress(boost::asio::ip::address serverIp, uint8_t *serverMac); -// -// Update Server MAC address behind a MUX port -// -void DbInterface::updateServerMacAddress(boost::asio::ip::address serverIp, const uint8_t *serverMac) -{ - MUXLOGDEBUG(boost::format("server IP: %s") % serverIp.to_string()); - - ServerIpPortMap::const_iterator cit = mServerIpPortMap.find(serverIp); - if (cit != mServerIpPortMap.cend()) { - std::array macAddress; - - memcpy(macAddress.data(), serverMac, macAddress.size()); - - mMuxManagerPtr->processGetServerMacAddress(cit->second, macAddress); - } -} - -// -// ---> handleGetMuxState(const std::string portName); -// -// get state db MUX state -// -void DbInterface::handleGetMuxState(const std::string portName) -{ - MUXLOGDEBUG(portName); - - std::string state; - if (mMuxStateTablePtr->hget(portName, "state", state)) { - mMuxManagerPtr->processGetMuxState(portName, state); - } -} - -// -// ---> handleSetMuxState(const std::string portName, mux_state::MuxState::Label label); -// -// set MUX state in APP DB for orchagent processing -// -void DbInterface::handleSetMuxState(const std::string portName, mux_state::MuxState::Label label) -{ - MUXLOGDEBUG(boost::format("%s: setting mux state to %s") % portName % mMuxState[label]); - - if (label <= mux_state::MuxState::Label::Unknown) { - std::vector values = { - {"state", mMuxState[label]}, - }; - mAppDbMuxTablePtr->set(portName, values); - } -} - -// -// ---> handleProbeMuxState(const std::string portName) -// -// trigger xcvrd to read MUX state using i2c -// -void DbInterface::handleProbeMuxState(const std::string portName) -{ - MUXLOGDEBUG(portName); - - mAppDbMuxCommandTablePtr->hset(portName, "command", "probe"); -} - -// -// ---> handleSetMuxLinkmgrState(const std::string portName, link_manager::LinkManagerStateMachine::Label label); -// -// set MUX LinkMgr state in State DB for cli processing -// -void DbInterface::handleSetMuxLinkmgrState( - const std::string portName, - link_manager::LinkManagerStateMachine::Label label -) -{ - MUXLOGDEBUG(boost::format("%s: setting mux linkmgr state to %s") % portName % mMuxLinkmgrState[static_cast (label)]); - - if (label < link_manager::LinkManagerStateMachine::Label::Count) { - mStateDbMuxLinkmgrTablePtr->hset(portName, "state", mMuxLinkmgrState[static_cast (label)]); - } -} - -// -// ---> handlePostMuxMetrics( -// const std::string portName, -// link_manager::LinkManagerStateMachine::Metrics metrics, -// mux_state::MuxState::Label label, -// boost::posix_time::ptime time); -// -// set MUX metrics to state db -// -void DbInterface::handlePostMuxMetrics( - const std::string portName, - link_manager::LinkManagerStateMachine::Metrics metrics, - mux_state::MuxState::Label label, - boost::posix_time::ptime time -) -{ - MUXLOGDEBUG(boost::format("%s: posting mux metrics event linkmgrd_switch_%s_%s") % - portName % - mMuxState[label] % - mMuxMetrics[static_cast (metrics)] - ); - - if (metrics == link_manager::LinkManagerStateMachine::Metrics::SwitchingStart) { - mStateDbMuxMetricsTablePtr->del(portName); - } - - mStateDbMuxMetricsTablePtr->hset( - portName, - "linkmgrd_switch_" + mMuxState[label] + "_" + mMuxMetrics[static_cast (metrics)], - boost::posix_time::to_simple_string(time) - ); -} - -// -// ---> processTorMacAddress(std::string& mac); -// -// retrieve ToR MAC address information -// -void DbInterface::processTorMacAddress(std::string& mac) -{ - try { - swss::MacAddress swssMacAddress(mac); - std::array macAddress; - - memcpy(macAddress.data(), swssMacAddress.getMac(), macAddress.size()); - mMuxManagerPtr->setTorMacAddress(macAddress); - } - catch (const std::invalid_argument &invalidArgument) { - throw MUX_ERROR(ConfigNotFound, "Invalid ToR MAC address " + mac); - } -} - -// -// ---> getTorMacAddress(std::shared_ptr configDbConnector); -// -// retrieve ToR MAC address information -// -void DbInterface::getTorMacAddress(std::shared_ptr configDbConnector) -{ - MUXLOGINFO("Reading ToR MAC Address"); - - swss::Table configDbMetadataTable(configDbConnector.get(), CFG_DEVICE_METADATA_TABLE_NAME); - const std::string localhost = "localhost"; - const std::string key = "mac"; - std::string mac; - - if (configDbMetadataTable.hget(localhost, key, mac)) { - processTorMacAddress(mac); - } else { - throw MUX_ERROR(ConfigNotFound, "ToR MAC address is not found"); - } -} - -// -// ---> processLoopback2InterfaceInfo(std::vector &loopbackIntfs) -// -// process Loopback2 interface information -// -void DbInterface::processLoopback2InterfaceInfo(std::vector &loopbackIntfs) -{ - const std::string loopback2 = "Loopback2|"; - bool loopback2IPv4Found = false; - - for (auto &loopbackIntf: loopbackIntfs) { - size_t pos = loopbackIntf.find(loopback2); - if (pos != std::string::npos) { - std::string ip = loopbackIntf.substr(loopback2.size(), loopbackIntf.size() - loopback2.size()); - MUXLOGINFO(boost::format("configDb Loopback2: ip: %s") % ip); - - pos = ip.find("/"); - if (pos != std::string::npos) { - ip.erase(pos); - } - boost::system::error_code errorCode; - boost::asio::ip::address ipAddress = boost::asio::ip::make_address(ip, errorCode); - if (!errorCode) { - if (ipAddress.is_v4()) { - mMuxManagerPtr->setLoopbackIpv4Address(ipAddress); - loopback2IPv4Found = true; - } else if (ipAddress.is_v6()) { - // handle IPv6 probing - } - } else { - MUXLOGFATAL(boost::format("Received Loopback2 IP: %s, error code: %d") % ip % errorCode); - } - } - } - - if (!loopback2IPv4Found) { - throw MUX_ERROR(ConfigNotFound, "Loopback2 IPv4 address missing"); - } -} - -// -// ---> getLoopback2InterfaceInfo(std::shared_ptr configDbConnector); -// -// retrieve Loopback2 interface information and block until it shows as OK in the state db -// -void DbInterface::getLoopback2InterfaceInfo(std::shared_ptr configDbConnector) -{ - MUXLOGINFO("Reading Loopback2 interface information"); - swss::Table configDbLoopbackTable(configDbConnector.get(), CFG_LOOPBACK_INTERFACE_TABLE_NAME); - std::vector loopbackIntfs; - - configDbLoopbackTable.getKeys(loopbackIntfs); - processLoopback2InterfaceInfo(loopbackIntfs); -} - -// -// ---> processServerIpAddress(std::vector &entries); -// -// process server/blades IP address and builds a map of IP to port name -// -void DbInterface::processServerIpAddress(std::vector &entries) -{ - for (auto &entry: entries) { - std::string portName = kfvKey(entry); - std::string operation = kfvOp(entry); - std::vector fieldValues = kfvFieldsValues(entry); - - std::vector::const_iterator cit = std::find_if( - fieldValues.cbegin(), - fieldValues.cend(), - [] (const swss::FieldValueTuple &fv) {return fvField(fv) == "server_ipv4";} - ); - if (cit != fieldValues.cend()) { - const std::string f = cit->first; - std::string smartNicIpAddress = cit->second; - - MUXLOGDEBUG(boost::format("port: %s, %s = %s") % portName % f % smartNicIpAddress); - - size_t pos = smartNicIpAddress.find("/"); - if (pos != std::string::npos) { - smartNicIpAddress.erase(pos); - } - - boost::system::error_code errorCode; - boost::asio::ip::address ipAddress = boost::asio::ip::make_address(smartNicIpAddress, errorCode); - if (!errorCode) { - mMuxManagerPtr->addOrUpdateMuxPort(portName, ipAddress); - mServerIpPortMap[ipAddress] = portName; - } else { - MUXLOGFATAL(boost::format("%s: Received invalid server IP: %s, error code: %d") % - portName % - smartNicIpAddress % - errorCode - ); - } - } - } -} - -// -// ---> getServerIpAddress(std::shared_ptr configDbConnector); -// -// retrieve server/blades IP address and builds a map of IP to port name -// -void DbInterface::getServerIpAddress(std::shared_ptr configDbConnector) -{ - MUXLOGINFO("Reading MUX Server IPs"); - swss::Table configDbMuxCableTable(configDbConnector.get(), CFG_MUX_CABLE_TABLE_NAME); - std::vector entries; - - configDbMuxCableTable.getContent(entries); - processServerIpAddress(entries); -} - -// -// ---> processMuxPortConfigNotifiction(std::deque &entries); -// -// process MUX port configuration change notification -// -void DbInterface::processMuxPortConfigNotifiction(std::deque &entries) -{ - for (auto &entry: entries) { - std::string port = kfvKey(entry); - std::string operation = kfvOp(entry); - std::vector fieldValues = kfvFieldsValues(entry); - - std::vector::const_iterator cit = std::find_if( - fieldValues.cbegin(), - fieldValues.cend(), - [] (const swss::FieldValueTuple &fv) {return fvField(fv) == "state";} - ); - if (cit != fieldValues.cend()) { - const std::string f = cit->first; - const std::string v = cit->second; - - MUXLOGDEBUG(boost::format("key: %s, Operation: %s, f: %s, v: %s") % - port % - operation % - f % - v - ); - mMuxManagerPtr->updateMuxPortConfig(port, v); - } - } -} - -// -// ---> handleMuxPortConfigNotifiction(swss::SubscriberStateTable &configMuxTable); -// -// handles MUX port configuration change notification -// -void DbInterface::handleMuxPortConfigNotifiction(swss::SubscriberStateTable &configMuxTable) -{ - std::deque entries; - - configMuxTable.pops(entries); - processMuxPortConfigNotifiction(entries); -} - -// -// ---> processMuxLinkmgrConfigNotifiction(std::deque &entries); -// -// process MUX Linkmgr configuration change notification -// -void DbInterface::processMuxLinkmgrConfigNotifiction(std::deque &entries) -{ - for (auto &entry: entries) { - std::string key = kfvKey(entry); - if (key == "LINK_PROBER") { - std::string operation = kfvOp(entry); - std::vector fieldValues = kfvFieldsValues(entry); - - try { - for (auto &fieldValue: fieldValues) { - std::string f = fvField(fieldValue); - std::string v = fvValue(fieldValue); - if (f == "interval_v4") { - mMuxManagerPtr->setTimeoutIpv4_msec(boost::lexical_cast (v)); - } else if (f == "interval_v6") { - mMuxManagerPtr->setTimeoutIpv6_msec(boost::lexical_cast (v)); - } else if (f == "positive_signal_count") { - mMuxManagerPtr->setPositiveStateChangeRetryCount(boost::lexical_cast (v)); - } else if (f == "negative_signal_count") { - mMuxManagerPtr->setNegativeStateChangeRetryCount(boost::lexical_cast (v)); - } else if (f == "suspend_timer") { - mMuxManagerPtr->setSuspendTimeout_msec(boost::lexical_cast (v)); - } - - MUXLOGINFO(boost::format("key: %s, Operation: %s, f: %s, v: %s") % - key % - operation % - f % - v - ); - } - } - catch (boost::bad_lexical_cast const &badLexicalCast) { - MUXLOGWARNING(boost::format("bad lexical cast: %s") % badLexicalCast.what()); - } - } else if (key == "MUXLOGGER") { - std::string operation = kfvOp(entry); - std::vector fieldValues = kfvFieldsValues(entry); - - for (auto &fieldValue: fieldValues) { - std::string f = fvField(fieldValue); - std::string v = fvValue(fieldValue); - if (f == "log_verbosity") { - mMuxManagerPtr->updateLogVerbosity(v); - } - - MUXLOGINFO(boost::format("key: %s, Operation: %s, f: %s, v: %s") % - key % - operation % - f % - v - ); - } - } - } -} - -// -// ---> handleMuxLinkmgrConfigNotifiction(swss::SubscriberStateTable &configLocalhostTable); -// -// handles MUX linkmgr configuration change notification -// -void DbInterface::handleMuxLinkmgrConfigNotifiction(swss::SubscriberStateTable &configMuxLinkmgrTable) -{ - std::deque entries; - - configMuxLinkmgrTable.pops(entries); - processMuxLinkmgrConfigNotifiction(entries); -} - -// -// ---> processLinkStateNotifiction(std::deque &entries); -// -// process link state change notification -// -void DbInterface::processLinkStateNotifiction(std::deque &entries) -{ - for (auto &entry: entries) { - std::string port = kfvKey(entry); - std::string operation = kfvOp(entry); - std::vector fieldValues = kfvFieldsValues(entry); - - std::vector::const_iterator cit = std::find_if( - fieldValues.cbegin(), - fieldValues.cend(), - [] (const swss::FieldValueTuple &fv) {return fvField(fv) == "oper_status";} - ); - if (cit != fieldValues.cend()) { - const std::string f = cit->first; - const std::string v = cit->second; - - MUXLOGDEBUG(boost::format("port: %s, operation: %s, f: %s, v: %s") % - port % - operation % - f % - v - ); - mMuxManagerPtr->addOrUpdateMuxPortLinkState(port, v); - } - } -} - -// -// ---> handleLinkStateNotifiction(swss::SubscriberStateTable &appdbPortTable); -// -// handles link state change notification -// -void DbInterface::handleLinkStateNotifiction(swss::SubscriberStateTable &appdbPortTable) -{ - std::deque entries; - - appdbPortTable.pops(entries); - processLinkStateNotifiction(entries); -} - -// -// ---> processMuxResponseNotifiction(std::deque &entries); -// -// process MUX response (from xcvrd) notification -// -void DbInterface::processMuxResponseNotifiction(std::deque &entries) -{ - for (auto &entry: entries) { - std::string port = kfvKey(entry); - std::string oprtation = kfvOp(entry); - std::vector fieldValues = kfvFieldsValues(entry); - - std::vector::const_iterator cit = std::find_if( - fieldValues.cbegin(), - fieldValues.cend(), - [] (const swss::FieldValueTuple &fv) {return fvField(fv) == "response";} - ); - if (cit != fieldValues.cend()) { - const std::string f = cit->first; - const std::string v = cit->second; - - MUXLOGDEBUG(boost::format("port: %s, operation: %s, f: %s, v: %s") % - port % - oprtation % - f % - v - ); -// swss::Table table(mAppDbPtr.get(), APP_MUX_CABLE_RESPONSE_TABLE_NAME); -// table.hdel(port, "response"); - mMuxManagerPtr->processProbeMuxState(port, v); - } - } -} - -// -// ---> handleMuxResponseNotifiction(swss::SubscriberStateTable &appdbPortTable); -// -// handles MUX response (from xcvrd) notification -// -void DbInterface::handleMuxResponseNotifiction(swss::SubscriberStateTable &appdbPortTable) -{ - std::deque entries; - - appdbPortTable.pops(entries); - processMuxResponseNotifiction(entries); -} - -// -// ---> processMuxStateNotifiction(std::deque &entries); -// -// processes MUX state (from orchagent) notification -// -void DbInterface::processMuxStateNotifiction(std::deque &entries) -{ - for (auto &entry: entries) { - std::string port = kfvKey(entry); - std::string oprtation = kfvOp(entry); - std::vector fieldValues = kfvFieldsValues(entry); - - std::vector::const_iterator cit = std::find_if( - fieldValues.cbegin(), - fieldValues.cend(), - [] (const swss::FieldValueTuple &fv) {return fvField(fv) == "state";} - ); - if (cit != fieldValues.cend()) { - const std::string f = cit->first; - const std::string v = cit->second; - - MUXLOGDEBUG(boost::format("port: %s, operation: %s, f: %s, v: %s") % - port % - oprtation % - f % - v - ); - mMuxManagerPtr->addOrUpdateMuxPortMuxState(port, v); - } - } -} - -// -// ---> handleMuxStateNotifiction(swss::SubscriberStateTable &statedbPortTable); -// -// handles MUX state (from orchagent) notification -// -void DbInterface::handleMuxStateNotifiction(swss::SubscriberStateTable &statedbPortTable) -{ - std::deque entries; - - statedbPortTable.pops(entries); - processMuxStateNotifiction(entries); -} - -// -// ---> handleSwssNotification(); -// -// main thread method for handling SWSS notification -// -void DbInterface::handleSwssNotification() -{ - std::shared_ptr configDbPtr = std::make_shared ("CONFIG_DB", 0); - std::shared_ptr appDbPtr = std::make_shared ("APPL_DB", 0); - std::shared_ptr stateDbPtr = std::make_shared ("STATE_DB", 0); - - // For reading Link Prober configurations from the MUX linkmgr table name - swss::SubscriberStateTable configDbMuxLinkmgrTable(configDbPtr.get(), CFG_MUX_LINKMGR_TABLE_NAME); - - swss::SubscriberStateTable configDbMuxTable(configDbPtr.get(), CFG_MUX_CABLE_TABLE_NAME); - - // for link up/down, should be in state db down the road - swss::SubscriberStateTable appDbPortTable(appDbPtr.get(), APP_PORT_TABLE_NAME); - // for command responses from the driver - swss::SubscriberStateTable appDbMuxResponseTable(appDbPtr.get(), APP_MUX_CABLE_RESPONSE_TABLE_NAME); - // for getting state db MUX state when orchagent updates it - swss::SubscriberStateTable stateDbPortTable(stateDbPtr.get(), STATE_MUX_CABLE_TABLE_NAME); - - getTorMacAddress(configDbPtr); - getLoopback2InterfaceInfo(configDbPtr); - getServerIpAddress(configDbPtr); - - NetMsgInterface netMsgInterface(*this); - swss::NetDispatcher::getInstance().registerMessageHandler(RTM_NEWNEIGH, &netMsgInterface); - swss::NetDispatcher::getInstance().registerMessageHandler(RTM_DELNEIGH, &netMsgInterface); - - swss::NetLink netlinkNeighbor; - netlinkNeighbor.registerGroup(RTNLGRP_NEIGH); - netlinkNeighbor.dumpRequest(RTM_GETNEIGH); - - swss::Select swssSelect; - swssSelect.addSelectable(&configDbMuxLinkmgrTable); - swssSelect.addSelectable(&configDbMuxTable); - swssSelect.addSelectable(&appDbPortTable); - swssSelect.addSelectable(&appDbMuxResponseTable); - swssSelect.addSelectable(&stateDbPortTable); - swssSelect.addSelectable(&netlinkNeighbor); - - while (mPollSwssNotifcation) { - swss::Selectable *selectable; - int ret = swssSelect.select(&selectable, DEFAULT_TIMEOUT_MSEC); - - if (ret == swss::Select::ERROR) { - MUXLOGERROR("Error had been returned in select"); - continue; - } else if (ret == swss::Select::TIMEOUT) { - continue; - } else if (ret != swss::Select::OBJECT) { - MUXLOGERROR(boost::format("Unknown return value from Select: %d") % ret); - continue; - } - - if (selectable == static_cast (&configDbMuxLinkmgrTable)) { - handleMuxLinkmgrConfigNotifiction(configDbMuxLinkmgrTable); - } else if (selectable == static_cast (&configDbMuxTable)) { - handleMuxPortConfigNotifiction(configDbMuxTable); - } else if (selectable == static_cast (&appDbPortTable)) { - handleLinkStateNotifiction(appDbPortTable); - } else if (selectable == static_cast (&appDbMuxResponseTable)) { - handleMuxResponseNotifiction(appDbMuxResponseTable); - } else if (selectable == static_cast (&stateDbPortTable)) { - handleMuxStateNotifiction(stateDbPortTable); - } else if (selectable == static_cast (&netlinkNeighbor)) { - continue; - } else { - MUXLOGERROR("Unknown object returned by select"); - } - } - - mBarrier.wait(); - mBarrier.wait(); - mMuxManagerPtr->terminate(); -} - -} /* namespace common */ diff --git a/src/linkmgrd/src/DbInterface.h b/src/linkmgrd/src/DbInterface.h deleted file mode 100644 index d54e91104333..000000000000 --- a/src/linkmgrd/src/DbInterface.h +++ /dev/null @@ -1,482 +0,0 @@ -/* - * DbInterface.h - * - * Created on: Oct 23, 2020 - * Author: tamer - */ - -#ifndef DBINTERFACE_H_ -#define DBINTERFACE_H_ - -#include -#include - -#include -#include -#include - -#include "swss/dbconnector.h" -#include "swss/producerstatetable.h" -#include "swss/subscriberstatetable.h" - -#include "link_manager/LinkManagerStateMachine.h" -#include "mux_state/MuxState.h" - -namespace test { -class MuxManagerTest; -} - -namespace mux -{ -class MuxManager; -using ServerIpPortMap = std::map; - -/** - *@class DbInterface - * - *@brief DbInterface interfaces with Redis DB, reads MUX config, and - * listens to updates posted to the subscriber tables. - */ -class DbInterface -{ -public: - /** - *@method DbInterface - * - *@brief class default constructor - */ - DbInterface() = delete; - - /** - *@method DbInterface - * - *@brief class copy constructor - * - *@param DbInterface (in) reference to DbInterface object to be copied - */ - DbInterface(const DbInterface &) = delete; - - /** - *@method DbInterface - * - *@brief class constructor - * - *@param muxManager (in) pointer to MuxManager object - *@param ioService (in) pointer to Boost IO Service - */ - DbInterface(mux::MuxManager *muxManager, boost::asio::io_service *ioService); - - /** - *@method ~DbInterface - * - *@brief class destructor - */ - virtual ~DbInterface() = default; - - /** - *@method getBarrier - * - *@brief getter for Boost barrier object - * - *@return reference to Boost barrier object - */ - inline boost::barrier& getBarrier() {return mBarrier;}; - - /** - *@method getStrand - * - *@brief getter for Boost strand object - * - *@return reference to Boost strand object - */ - inline boost::asio::io_service::strand& getStrand() {return mStrand;}; - - /** - *@method getMuxState - * - *@brief retrieve the current MUX state - * - *@param portName (in) MUX/port name - * - *@return none - */ - virtual void getMuxState(const std::string &portName); - - /** - *@method setMuxState - * - *@brief set MUX state in APP DB for orchagent processing - * - *@param portName (in) MUX/port name - *@param label (in) label of target state - * - *@return none - */ - virtual void setMuxState(const std::string &portName, mux_state::MuxState::Label label); - - /** - *@method probeMuxState - * - *@brief trigger xcvrd to read MUX state using i2c - * - *@param portName (in) MUX/port name - * - *@return label of MUX state - */ - virtual void probeMuxState(const std::string &portName); - - /** - *@method setMuxLinkmgrState - * - *@brief set MUX LinkMgr state in State DB for cli processing - * - *@param portName (in) MUX/port name - *@param label (in) label of target state - * - *@return none - */ - virtual void setMuxLinkmgrState(const std::string &portName, link_manager::LinkManagerStateMachine::Label label); - - /** - *@method postMetricsEvent - * - *@brief post MUX metrics event - * - *@param portName (in) MUX/port name - *@param metrics (in) metrics data - *@param label (in) label of target state - * - *@return none - */ - virtual void postMetricsEvent( - const std::string &portName, - link_manager::LinkManagerStateMachine::Metrics metrics, - mux_state::MuxState::Label label - ); - - /** - *@method initialize - * - *@brief initialize DB and start SWSS listening thread - * - *@return none - */ - void initialize(); - - /** - *@method deinitialize - * - *@brief deinitialize DB interface and join SWSS listening thread - * - *@return none - */ - void deinitialize(); - - /** - *@method updateServerMacAddress - * - *@brief Update Server MAC address behind a MUX port - * - *@param serverIp (in) Server IP address - *@param serverMac (in) Server MAC address - * - *@return none - */ - void updateServerMacAddress(boost::asio::ip::address serverIp, const uint8_t *serverMac); - - /** - *@method stopSwssNotificationPoll - * - *@brief stop SWSS listening thread - * - *@return none - */ - void stopSwssNotificationPoll() {mPollSwssNotifcation = false;}; - -private: - friend class test::MuxManagerTest; - - /** - *@method handleGetMuxState - * - *@brief get state db MUX state - * - *@param portName (in) MUX/port name - * - *@return none - */ - void handleGetMuxState(const std::string portName); - - /** - *@method handleSetMuxState - * - *@brief set MUX state in APP DB for orchagent processing - * - *@param portName (in) MUX/port name - *@param label (in) label of target state - * - *@return none - */ - void handleSetMuxState(const std::string portName, mux_state::MuxState::Label label); - - /** - *@method handleProbeMuxState - * - *@brief trigger xcvrd to read MUX state using i2c - * - *@param portName (in) MUX/port name - * - *@return label of MUX state - */ - void handleProbeMuxState(const std::string portName); - - /** - *@method handleSetMuxLinkmgrState - * - *@brief set MUX LinkMgr state in State DB for cli processing - * - *@param portName (in) MUX/port name - *@param label (in) label of target state - * - *@return none - */ - void handleSetMuxLinkmgrState(const std::string portName, link_manager::LinkManagerStateMachine::Label label); - - /** - *@method handlePostMuxMetrics - * - *@brief set MUX metrics to state db - * - *@param portName (in) MUX/port name - *@param metrics (in) metrics data - *@param label (in) label of target state - *@param time (in) current time - * - *@return none - */ - void handlePostMuxMetrics( - const std::string portName, - link_manager::LinkManagerStateMachine::Metrics metrics, - mux_state::MuxState::Label label, - boost::posix_time::ptime time - ); - - /** - *@method processTorMacAddress - * - *@brief retrieve ToR MAC address information - * - *@param mac (in) ToR mac address - * - *@return none - */ - inline void processTorMacAddress(std::string& mac); - - /** - *@method getTorMacAddress - * - *@brief retrieve ToR MAC address information - * - *@param configDbConnector config db connector - * - *@return none - */ - void getTorMacAddress(std::shared_ptr configDbConnector); - - /** - *@method processLoopback2InterfaceInfo - * - *@brief process Loopback2 interface information - * - *@param loopbackIntfs config_db Loopback2 entries - * - *@return none - */ - inline void processLoopback2InterfaceInfo(std::vector &loopbackIntfs); - - /** - *@method getLoopback2InterfaceInfo - * - *@brief retrieve Loopback2 interface information - * - *@param configDbConnector config db connector - * - *@return none - */ - void getLoopback2InterfaceInfo(std::shared_ptr configDbConnector); - - /** - *@method processServerIpAddress - * - *@brief process server/blades IP address and builds a map of IP to port name - * - *@param entries config_db MUX_CABLE entries - * - *@return none - */ - inline void processServerIpAddress(std::vector &entries); - - /** - *@method getServerIpAddress - * - *@brief retrieve server/blades IP address and builds a map of IP to port name - * - *@param configDbConnector config db connector - * - *@return none - */ - void getServerIpAddress(std::shared_ptr configDbConnector); - - /** - *@method processMuxPortConfigNotifiction - * - *@brief process MUX port configuration change notification - * - *@param entries (in) reference to changed entries of MUX config table - * - *@return none - */ - inline void processMuxPortConfigNotifiction(std::deque &entries); - - /** - *@method handleMuxPortConfigNotifiction - * - *@brief handles MUX port configuration change notification - * - *@param configMuxTable (in) reference to MUX config table - * - *@return none - */ - void handleMuxPortConfigNotifiction(swss::SubscriberStateTable &configMuxTable); - - /** - *@method processMuxLinkmgrConfigNotifiction - * - *@brief process MUX Linkmgr configuration change notification - * - *@param entries (in) reference to MUX linkmgr config entries - * - *@return none - */ - inline void processMuxLinkmgrConfigNotifiction(std::deque &entries); - - /** - *@method handleMuxLinkmgrConfigNotifiction - * - *@brief handles MUX Linkmgr configuration change notification - * - *@param configLocalhostTable (in) reference to MUX linkmgr config table - * - *@return none - */ - void handleMuxLinkmgrConfigNotifiction(swss::SubscriberStateTable &configLocalhostTable); - - /** - *@method processLinkStateNotifiction - * - *@brief process link state change notification - * - *@param entries (in) reference to app db port table - * - *@return none - */ - inline void processLinkStateNotifiction(std::deque &entries); - - /** - *@method handleLinkStateNotifiction - * - *@brief handles link state change notification - * - *@param appdbPortTable (in) reference to app db port table - * - *@return none - */ - void handleLinkStateNotifiction(swss::SubscriberStateTable &appdbPortTable); - - /** - *@method processMuxResponseNotifiction - * - *@brief process MUX response (from xcvrd) notification - * - *@param entries (in) reference to app db port entries - * - *@return none - */ - inline void processMuxResponseNotifiction(std::deque &entries); - - /** - *@method handleMuxResponseNotifiction - * - *@brief handles MUX response (from xcvrd) notification - * - *@param appdbPortTable (in) reference to app db port table - * - *@return none - */ - void handleMuxResponseNotifiction(swss::SubscriberStateTable &appdbPortTable); - - /** - *@method processMuxStateNotifiction - * - *@brief processes MUX state (from orchagent) notification - * - *@param entries (in) reference to state db port entries - * - *@return none - */ - inline void processMuxStateNotifiction(std::deque &entries); - - /** - *@method handleMuxStateNotifiction - * - *@brief handles MUX state (from orchagent) notification - * - *@param statedbPortTable (in) reference to state db port table - * - *@return none - */ - void handleMuxStateNotifiction(swss::SubscriberStateTable &statedbPortTable); - - /** - *@method handleSwssNotification - * - *@brief main thread method for handling SWSS notification - * - *@return none - */ - void handleSwssNotification(); - -private: - static std::vector mMuxState; - static std::vector mMuxLinkmgrState; - static std::vector mMuxMetrics; - -private: - mux::MuxManager *mMuxManagerPtr; - bool mPollSwssNotifcation = true; - - std::shared_ptr mAppDbPtr; - std::shared_ptr mStateDbPtr; - std::shared_ptr mMuxStateTablePtr; - - // for communicating with orchagent - std::shared_ptr mAppDbMuxTablePtr; - // for communicating with the driver (probing the mux) - std::shared_ptr mAppDbMuxCommandTablePtr; - // for writing the current mux linkmgr health - std::shared_ptr mStateDbMuxLinkmgrTablePtr; - // for writing mux metrics - std::shared_ptr mStateDbMuxMetricsTablePtr; - - std::shared_ptr mSwssThreadPtr; - - boost::barrier mBarrier; - - boost::asio::io_service::strand mStrand; - - ServerIpPortMap mServerIpPortMap; -}; - -} /* namespace common */ - -#endif /* DBINTERFACE_H_ */ diff --git a/src/linkmgrd/src/LinkMgrdMain.cpp b/src/linkmgrd/src/LinkMgrdMain.cpp deleted file mode 100644 index 5ed6142d2472..000000000000 --- a/src/linkmgrd/src/LinkMgrdMain.cpp +++ /dev/null @@ -1,105 +0,0 @@ -//============================================================================ -// Name : linkMgrdMain.cpp -// Author : Tamer Ahmed -// Version : -// Copyright : Your copyright notice -// Description : Main program for dual ToR (Gemini Project) -//============================================================================ - -#include - -#include -#include - -#include "MuxManager.h" -#include "MuxPort.h" -#include "common/MuxConfig.h" -#include "common/MuxLogger.h" -#include "link_manager/LinkManagerStateMachine.h" -#include "link_prober/LinkProberStateMachine.h" -#include "link_prober/LinkProber.h" -#include "link_prober/IcmpPayload.h" - -// Private namespace for this module -namespace { - // Some namespace and type aliases... - namespace program_options = boost::program_options; - - static auto DEFAULT_LOGGING_FILTER_LEVEL = boost::log::trivial::debug; - - void InitializeLogger(std::string execName, boost::log::trivial::severity_level level) - { - std::string progName = execName.substr(execName.find_last_of('/') + 1); - std::string logFile = "/var/log/mux/" + progName + ".log"; - - common::MuxLogger::getInstance()->initialize(progName, logFile, level); - } - -} // end namespace - - -// -// Main program entry point for Gemini MUX Manager (aka linkmgrd). -// -int main(int argc, const char* argv[]) -{ - int retValue = EXIT_SUCCESS; - - // - // Constants for command line argument strings: - // - boost::log::trivial::severity_level level; - - program_options::options_description description("linkmgrd options"); - description.add_options() - ("help,h", - "Print usage information.") - ("verbosity,v", - program_options::value(&level)->value_name("")-> - default_value(DEFAULT_LOGGING_FILTER_LEVEL), - "Logging verbosity level.") - ; - - // - // Actually parse options, print verbose usage when it fails - // - program_options::variables_map variableMap; - try { - store(parse_command_line(argc, argv, description), variableMap); - program_options::notify(variableMap); - } - catch (program_options::error_with_option_name& e) { - std::cerr << "Command Line Syntax Error: " << e.what() << std::endl; - std::cout << description << "\n"; - retValue = EXIT_FAILURE; - } - catch (program_options::error& e) { - std::cerr << "Command Line Error: " << e.what() << std::endl; - std::cout << description << "\n"; - retValue = EXIT_FAILURE; - } - - if (retValue == EXIT_SUCCESS && variableMap.count("help")) { - std::cout << description << "\n"; - - retValue = EXIT_FAILURE; - } - - if (retValue == EXIT_SUCCESS) { - InitializeLogger(argv[0], level); - std::stringstream ss; - ss << "level: " << level; - MUXLOGINFO(ss.str()); - - // initialize static data - link_prober::IcmpPayload::generateGuid(); - link_manager::LinkManagerStateMachine::initializeTransitionFunctionTable(); - - std::shared_ptr muxManagerPtr = std::make_shared (); - muxManagerPtr->initialize(); - muxManagerPtr->run(); - muxManagerPtr->deinitialize(); - } - - return retValue; -} diff --git a/src/linkmgrd/src/MuxManager.cpp b/src/linkmgrd/src/MuxManager.cpp deleted file mode 100644 index b3dcd1b38fed..000000000000 --- a/src/linkmgrd/src/MuxManager.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/* - * MuxManager.cpp - * - * Created on: Oct 4, 2020 - * Author: tamer - */ -#include -#include -#include -#include - -#include - -#include "common/MuxException.h" -#include "common/MuxLogger.h" -#include "MuxManager.h" - -namespace mux -{ -// -// ---> MuxManager(); -// -// class constructor -// -MuxManager::MuxManager() : - mMuxConfig(), - mWork(mIoService), - mSignalSet(boost::asio::signal_set(mIoService, SIGINT, SIGTERM)), - mDbInterfacePtr(std::make_shared (this, &mIoService)) -{ - mSignalSet.add(SIGUSR1); - mSignalSet.add(SIGUSR2); - mSignalSet.async_wait(boost::bind(&MuxManager::handleSignal, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::signal_number - )); -} - -// -// ---> initialize(); -// -// initialize MuxManager class and creates DbInterface instance that reads/listen from/to Redis db -// -void MuxManager::initialize() -{ - for (uint8_t i = 0; (mMuxConfig.getNumberOfThreads() > 2) && - (i < mMuxConfig.getNumberOfThreads() - 2); i++) { - mThreadGroup.create_thread( - boost::bind(&boost::asio::io_service::run, &mIoService) - ); - } - - mDbInterfacePtr->initialize(); -} - -// -// ---> deinitialize(); -// -// deinitialize MuxManager class and deinitialize DbInterface instance -// -void MuxManager::deinitialize() -{ - mDbInterfacePtr->deinitialize(); -} - -// -// ---> run(); -// -// start Boost IO Service event loop -// -void MuxManager::run() -{ - mIoService.run(); -} - -// -// ---> terminate(); -// -// stop and terminate Boost IO Service event loop -// -void MuxManager::terminate() -{ - mIoService.stop(); - mThreadGroup.join_all(); -} - -// -// ---> updateLogVerbosity(std::string &verbosity); -// -// update current log verbosity -// -void MuxManager::updateLogVerbosity(std::string &verbosity) -{ - boost::log::trivial::severity_level level = boost::log::trivial::warning; - - if (verbosity == "trace") { - level = boost::log::trivial::trace; - } else if (verbosity == "debug") { - level = boost::log::trivial::debug; - } else if (verbosity == "info") { - level = boost::log::trivial::info; - } else if (verbosity == "error") { - level = boost::log::trivial::error; - } else if (verbosity == "fatal") { - level = boost::log::trivial::fatal; - } - - common::MuxLogger::getInstance()->setLevel(level); - MUXLOGFATAL(boost::format("Updated log level to: %s") % level); -} - -// -// ---> addOrUpdateMuxPort(const std::string &portName, boost::asio::ip::address address); -// -// update MUX port server/blade IPv4 Address. If port is not found, create new MuxPort object -// -void MuxManager::addOrUpdateMuxPort(const std::string &portName, boost::asio::ip::address address) -{ - MUXLOGWARNING(boost::format("%s: server IP: %s") % portName % address); - - std::shared_ptr muxPortPtr = getMuxPortPtrOrThrow(portName); - - if (address.is_v4()) { - muxPortPtr->handleBladeIpv4AddressUpdate(address); - } else if (address.is_v6()) { - // handle IPv6 probing - } -} - -// -// ---> updateMuxPortConfig(const std::string &portName, const std::string &config); -// -// update MUX port server/blade IPv4 Address. If port is not found, create new MuxPort object -// -void MuxManager::updateMuxPortConfig(const std::string &portName, const std::string &config) -{ - MUXLOGWARNING(boost::format("%s: Mux port config: %s") % portName % config); - - PortMapIterator portMapIterator = mPortMap.find(portName); - if (portMapIterator != mPortMap.end()) { - portMapIterator->second->handleMuxConfig(config); - } -} - -// -// ---> addOrUpdateMuxPortLinkState(const std::string &portName, const std::string &linkState); -// -// update MUX port server/blade IPv4 Address. If port is not found, create new MuxPort object -// -void MuxManager::addOrUpdateMuxPortLinkState(const std::string &portName, const std::string &linkState) -{ - MUXLOGWARNING(boost::format("%s: link state: %s") % portName % linkState); - - std::shared_ptr muxPortPtr = getMuxPortPtrOrThrow(portName); - muxPortPtr->handleLinkState(linkState); -} - -// -// ---> addOrUpdateMuxPortMuxState(const std::string &portName, const std::string &muxState); -// -// update MUX port state db notification -// -void MuxManager::addOrUpdateMuxPortMuxState(const std::string &portName, const std::string &muxState) -{ - MUXLOGWARNING(boost::format("%s: state db mux state: %s") % portName % muxState); - - std::shared_ptr muxPortPtr = getMuxPortPtrOrThrow(portName); - muxPortPtr->handleMuxState(muxState); -} - -// -// ---> processGetServerMacAddress(const std::string &portName, const std::array &address); -// -// update MUX port server MAC address -// -void MuxManager::processGetServerMacAddress( - const std::string &portName, - const std::array &address -) -{ - MUXLOGDEBUG(portName); - - PortMapIterator portMapIterator = mPortMap.find(portName); - if (portMapIterator != mPortMap.end()) { - portMapIterator->second->handleGetServerMacAddress(address); - } -} - -// -// ---> processGetMuxState(const std::string &portName, const std::string &muxState); -// -// update MUX port state db notification -// -void MuxManager::processGetMuxState(const std::string &portName, const std::string &muxState) -{ - MUXLOGDEBUG(boost::format("%s: state db mux state: %s") % portName % muxState); - - PortMapIterator portMapIterator = mPortMap.find(portName); - if (portMapIterator != mPortMap.end()) { - portMapIterator->second->handleGetMuxState(muxState); - } -} - -// -// ---> processProbeMuxState(const std::string &portName, const std::string &muxState); -// -// update MUX port app db notification -// -void MuxManager::processProbeMuxState(const std::string &portName, const std::string &muxState) -{ - MUXLOGINFO(boost::format("%s: app db mux state: %s") % portName % muxState); - - PortMapIterator portMapIterator = mPortMap.find(portName); - if (portMapIterator != mPortMap.end()) { - portMapIterator->second->handleProbeMuxState(muxState); - } -} - -// -// ---> getMuxPortPtrOrThrow(const std::string &portName); -// -// retrieve a pointer to MuxPort if it exist or create a new MuxPort object -// -std::shared_ptr MuxManager::getMuxPortPtrOrThrow(const std::string &portName) -{ - std::shared_ptr muxPortPtr; - - try { - PortMapIterator portMapIterator = mPortMap.find(portName); - if (portMapIterator == mPortMap.end()) { - uint16_t serverId = atoi(portName.substr(portName.find_last_not_of("0123456789") + 1).c_str()); - muxPortPtr = std::make_shared ( - mDbInterfacePtr, - mMuxConfig, - portName, - serverId, - mIoService - ); - mPortMap.insert({portName, muxPortPtr}); - } - else { - muxPortPtr = portMapIterator->second; - } - } - catch (const std::bad_alloc &ex) { - std::ostringstream errMsg; - errMsg << "Failed allocate memory. Exception details: " << ex.what(); - - throw MUX_ERROR(BadAlloc, errMsg.str()); - } - - return muxPortPtr; -} - -// -// ---> handleSignal(const boost::system::error_code errorCode, int signalNumber)' -// -// handles system signal -// -void MuxManager::handleSignal(const boost::system::error_code errorCode, int signalNumber) -{ - MUXLOGFATAL(boost::format("Got signal: %d") % signalNumber); - - if (signalNumber == SIGINT || signalNumber == SIGTERM) { - mSignalSet.clear(); - handleProcessTerminate(); - } else { - mSignalSet.async_wait(boost::bind(&MuxManager::handleSignal, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::signal_number - )); - } -} - -// -// ---> handleProcessTerminate(); -// -// stop DB interface thread and stop boost io service -// -void MuxManager::handleProcessTerminate() -{ - mDbInterfacePtr->stopSwssNotificationPoll(); - mDbInterfacePtr->getBarrier().wait(); - mIoService.stop(); - mDbInterfacePtr->getBarrier().wait(); -} - -} /* namespace mux */ diff --git a/src/linkmgrd/src/MuxManager.h b/src/linkmgrd/src/MuxManager.h deleted file mode 100644 index f69e1865d26c..000000000000 --- a/src/linkmgrd/src/MuxManager.h +++ /dev/null @@ -1,351 +0,0 @@ -/* - * MuxManager.h - * - * Created on: Oct 4, 2020 - * Author: tamer - */ - -#ifndef MUXMANAGER_H_ -#define MUXMANAGER_H_ - -#include -#include - -#include -#include - -#include "MuxPort.h" -#include "common/MuxConfig.h" -#include "DbInterface.h" - -namespace test { -class MuxManagerTest; -} - -namespace mux -{ -using PortMap = std::map>; -using PortMapIterator = PortMap::iterator; - -/** - *@class MuxManager - * - *@brief host collection MuxPort object, each has MuxPort configuration, LinkManagerStateMachine. - */ -class MuxManager -{ -public: - /** - *@method MuxManager - * - *@brief class default constructor - */ - MuxManager(); - - /** - *@method MuxManager - * - *@brief class copy constructor - * - *@param MuxManager (in) reference to MuxManager object to be copied - */ - MuxManager(const MuxManager &) = delete; - - /** - *@method ~MuxManager - * - *@brief class destructor - */ - virtual ~MuxManager() = default; - -public: - /** - *@method getIoService - * - *@brief getter for Boost IO Service/Context object - * - *@return reference to Boost IO Service/Context object - */ - inline boost::asio::io_service& getIoService() {return mIoService;}; - - /** - *@method getDbInterface - * - *@brief getter for DbInterface object - * - *@return reference to DbInterface object - */ - inline std::shared_ptr getDbInterfacePtr() {return mDbInterfacePtr;}; - - /** - *@method setTimeoutIpv4_msec - * - *@brief setter for IPv4 LinkProber timeout in msec - * - *@param timeout_msec (in) timeout in msec - * - *@return none - */ - inline void setTimeoutIpv4_msec(uint32_t timeout_msec) {mMuxConfig.setTimeoutIpv4_msec(timeout_msec);}; - - /** - *@method setTimeoutIpv6_msec - * - *@brief setter for IPv6 LinkProber timeout in msec - * - *@param timeout_msec (in) timeout in msec - * - *@return none - */ - inline void setTimeoutIpv6_msec(uint32_t timeout_msec) {mMuxConfig.setTimeoutIpv6_msec(timeout_msec);}; - - /** - *@method setPositiveStateChangeRetryCount - * - *@brief setter for LinkProber positive state change retry count - * - *@param stateChangeRetryCount (in) state change retry count - * - *@return none - */ - inline void setPositiveStateChangeRetryCount(uint32_t stateChangeRetryCount) { - mMuxConfig.setPositiveStateChangeRetryCount(stateChangeRetryCount); - }; - - /** - *@method setNegativeStateChangeRetryCount - * - *@brief setter for LinkProber negative state change retry count - * - *@param stateChangeRetryCount (in) state change retry count - * - *@return none - */ - inline void setNegativeStateChangeRetryCount(uint32_t stateChangeRetryCount) { - mMuxConfig.setNegativeStateChangeRetryCount(stateChangeRetryCount); - }; - - /** - *@method setSuspendTimeout_msec - * - *@brief setter for LinkProber suspend timer timeout - * - *@param suspendTimeout_msec (in) suspend timer timeout - * - *@return none - */ - inline void setSuspendTimeout_msec(uint32_t suspendTimeout_msec) {mMuxConfig.setSuspendTimeout_msec(suspendTimeout_msec);}; - - /** - *@method setSuspendTimeout_msec - * - *@brief setter for LinkProber suspend timer timeout - * - *@param suspendTimeout_msec (in) suspend timer timeout - * - *@return none - */ - inline void setTorMacAddress(std::array &address) {mMuxConfig.setTorMacAddress(address);}; - - /** - *@method setSuspendTimeout_msec - * - *@brief setter for LinkProber suspend timer timeout - * - *@param suspendTimeout_msec (in) suspend timer timeout - * - *@return none - */ - inline void setLoopbackIpv4Address(boost::asio::ip::address& address) {mMuxConfig.setLoopbackIpv4Address(address);}; - - /** - *@method initialize - * - *@brief initialize MuxManager class and creates DbInterface instance that reads/listen from/to Redis db - * - *@return none - */ - void initialize(); - - /** - *@method deinitialize - * - *@brief deinitialize MuxManager class and deinitialize DbInterface instance - * - *@return none - */ - void deinitialize(); - - /** - *@method run - * - *@brief start Boost IO Service event loop - * - *@return none - */ - void run(); - - /** - *@method terminate - * - *@brief stop and terminate Boost IO Service event loop - * - *@return none - */ - void terminate(); - - /** - *@method updateLogVerbosity - * - *@brief update current log verbosity - * - *@param verbosity (in) log verbosity - * - *@return none - */ - void updateLogVerbosity(std::string &verbosity); - - /** - *@method addOrUpdateMuxPort - * - *@brief update MUX port server/blade IPv4 Address. If port is not found, create new MuxPort object - * - *@param portName (in) Mux port name - *@param address (in) server/blade IP address - * - *@return none - */ - void addOrUpdateMuxPort(const std::string &portName, boost::asio::ip::address address); - - /** - *@method updateMuxPortConfig - * - *@brief update MUX port server/blade IPv4 Address. If port is not found, create new MuxPort object - * - *@param portName (in) Mux port name - *@param linkState (in) Mux port link state - * - *@return none - */ - void updateMuxPortConfig(const std::string &portName, const std::string &linkState); - - /** - *@method addOrUpdateMuxPortLinkState - * - *@brief update MUX port server/blade IPv4 Address. If port is not found, create new MuxPort object - * - *@param portName (in) Mux port name - *@param linkState (in) Mux port link state - * - *@return none - */ - void addOrUpdateMuxPortLinkState(const std::string &portName, const std::string &linkState); - - /** - *@method addOrUpdateMuxPortMuxState - * - *@brief update MUX port state db notification - * - *@param portName (in) Mux port name - *@param muxState (in) Mux port state - * - *@return none - */ - void addOrUpdateMuxPortMuxState(const std::string &portName, const std::string &muxState); - - /** - *@method processGetServerMacAddress - * - *@brief update MUX port server MAC address - * - *@param portName (in) Mux port name - *@param address (in) Server MAC address - * - *@return none - */ - void processGetServerMacAddress(const std::string &portName, const std::array &address); - - /** - *@method processGetMuxState - * - *@brief update MUX port app db notification - * - *@param portName (in) Mux port name - *@param muxState (in) Mux port state - * - *@return none - */ - void processGetMuxState(const std::string &portName, const std::string &muxState); - - /** - *@method processProbeMuxState - * - *@brief update MUX port app db notification - * - *@param portName (in) Mux port name - *@param muxState (in) Mux port state - * - *@return none - */ - void processProbeMuxState(const std::string &portName, const std::string &muxState); - -private: - /** - *@method getMuxPortPtrOrThrow - * - *@brief retrieve a pointer to MuxPort if it exist or create a new MuxPort object - * - *@param portName (in) Mux port name - * - *@return pointer to MuxPort object - */ - std::shared_ptr getMuxPortPtrOrThrow(const std::string &portName); - - /** - *@method handleSignal - * - *@brief handles system signal - * - *@param errorCode (in) Boost error code - *@param signalNumber (in) Signal number - * - *@return none - */ - void handleSignal(const boost::system::error_code errorCode, int signalNumber); - - /** - *@method handleProcessTerminate - * - *@brief stop DB interface thread and stop boost io service - * - *@return none - */ - void handleProcessTerminate(); - -private: - friend class test::MuxManagerTest; - /** - *@method setDbInterfacePtr - * - *@brief set DbInterface to an external instance and is solely used for unit tests - * - *@return none - */ - void setDbInterfacePtr(std::shared_ptr dbInterfacePtr) {mDbInterfacePtr = dbInterfacePtr;}; - -private: - common::MuxConfig mMuxConfig; - - boost::asio::io_service mIoService; - boost::asio::io_service::work mWork; - boost::thread_group mThreadGroup; - boost::asio::signal_set mSignalSet; - - std::shared_ptr mDbInterfacePtr; - - PortMap mPortMap; -}; - -} /* namespace mux */ - -#endif /* MUXMANAGER_H_ */ diff --git a/src/linkmgrd/src/MuxPort.cpp b/src/linkmgrd/src/MuxPort.cpp deleted file mode 100644 index fac15c05d87e..000000000000 --- a/src/linkmgrd/src/MuxPort.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * MuxPort.cpp - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "MuxPort.h" -#include "common/MuxLogger.h" - -namespace mux -{ -// -// ---> MuxPort( -// mux::DbInterface *dbInterface, -// common::MuxConfig &muxConfig, -// const std::string &portName, -// uint16_t serverId, -// boost::asio::io_service &ioService -// ); -// -// class constructor -// -MuxPort::MuxPort( - std::shared_ptr dbInterfacePtr, - common::MuxConfig &muxConfig, - const std::string &portName, - uint16_t serverId, - boost::asio::io_service &ioService -) : - mDbInterfacePtr(dbInterfacePtr), - mMuxPortConfig( - muxConfig, - portName, - serverId - ), - mStrand(ioService), - mLinkManagerStateMachine( - this, - mStrand, - mMuxPortConfig - ) -{ - assert(dbInterfacePtr != nullptr); -} - -void MuxPort::handleBladeIpv4AddressUpdate(boost::asio::ip::address address) -{ - MUXLOGDEBUG(boost::format("port: %s") % mMuxPortConfig.getPortName()); - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleSwssBladeIpv4AddressUpdate, - &mLinkManagerStateMachine, - address - ))); -} - -// -// ---> handleLinkState(const std::string &linkState); -// -// handles link state updates -// -void MuxPort::handleLinkState(const std::string &linkState) -{ - MUXLOGDEBUG(boost::format("port: %s, state db link state: %s") % mMuxPortConfig.getPortName() % linkState); - - link_state::LinkState::Label label = link_state::LinkState::Label::Down; - if (linkState == "up") { - label = link_state::LinkState::Label::Up; - } - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleSwssLinkStateNotification, - &mLinkManagerStateMachine, - label - ))); -} - -// -// ---> handleGetServerMacAddress(const std::array &address) -// -// handles get Server MAC address -// -void MuxPort::handleGetServerMacAddress(const std::array &address) -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleGetServerMacAddressNotification, - &mLinkManagerStateMachine, - address - ))); -} - -// -// ---> handleGetMuxState(const std::string &muxState); -// -// handles MUX state updates -// -void MuxPort::handleGetMuxState(const std::string &muxState) -{ - MUXLOGDEBUG(boost::format("port: %s, state db mux state: %s") % mMuxPortConfig.getPortName() % muxState); - - mux_state::MuxState::Label label = mux_state::MuxState::Label::Unknown; - if (muxState == "active") { - label = mux_state::MuxState::Label::Active; - } else if (muxState == "standby") { - label = mux_state::MuxState::Label::Standby; - } else if (muxState == "error") { - label = mux_state::MuxState::Label::Error; - } - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleGetMuxStateNotification, - &mLinkManagerStateMachine, - label - ))); -} - -// -// ---> handleProbeMuxState(const std::string &muxState); -// -// handles MUX state updates -// -void MuxPort::handleProbeMuxState(const std::string &muxState) -{ - MUXLOGDEBUG(boost::format("port: %s, state db mux state: %s") % mMuxPortConfig.getPortName() % muxState); - - mux_state::MuxState::Label label = mux_state::MuxState::Label::Unknown; - if (muxState == "active") { - label = mux_state::MuxState::Label::Active; - } else if (muxState == "standby") { - label = mux_state::MuxState::Label::Standby; - } - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleProbeMuxStateNotification, - &mLinkManagerStateMachine, - label - ))); -} - -// -// ---> handleMuxState(const std::string &muxState); -// -// handles MUX state updates -// -void MuxPort::handleMuxState(const std::string &muxState) -{ - MUXLOGDEBUG(boost::format("port: %s, state db mux state: %s") % mMuxPortConfig.getPortName() % muxState); - - mux_state::MuxState::Label label = mux_state::MuxState::Label::Unknown; - if (muxState == "active") { - label = mux_state::MuxState::Label::Active; - } else if (muxState == "standby") { - label = mux_state::MuxState::Label::Standby; - } else if (muxState == "error") { - label = mux_state::MuxState::Label::Error; - } - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleMuxStateNotification, - &mLinkManagerStateMachine, - label - ))); -} - -// -// ---> handleMuxConfig(const std::string &config); -// -// handles MUX config updates when switching between auto/active -// -void MuxPort::handleMuxConfig(const std::string &config) -{ - MUXLOGDEBUG(boost::format("port: %s, config db mux config: %s") % mMuxPortConfig.getPortName() % config); - - common::MuxPortConfig::Mode mode = common::MuxPortConfig::Auto; - if (config == "active") { - mode = common::MuxPortConfig::Active; - } else if (config == "manual") { - mode = common::MuxPortConfig::Manual; - } else if (config == "standby") { - mode = common::MuxPortConfig::Standby; - } - - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleMuxConfigNotification, - &mLinkManagerStateMachine, - mode - ))); -} - -} /* namespace mux */ diff --git a/src/linkmgrd/src/MuxPort.h b/src/linkmgrd/src/MuxPort.h deleted file mode 100644 index 4e49b0099601..000000000000 --- a/src/linkmgrd/src/MuxPort.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - * MuxPort.h - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#ifndef MUXPORT_H_ -#define MUXPORT_H_ - -#include -#include - -#include "link_prober/LinkProber.h" -#include "link_prober/LinkProberStateMachine.h" -#include "link_manager/LinkManagerStateMachine.h" - -#include "common/MuxPortConfig.h" -#include "DbInterface.h" - -namespace test { -class MuxManagerTest; -class FakeMuxPort; -} - -namespace mux -{ - -/** - *@class MuxPort - * - *@brief Hold MUX configuration data, state machines and link prober - */ -class MuxPort: public std::enable_shared_from_this -{ -public: - /** - *@method MuxPort - * - *@brief class default constructor - */ - MuxPort() = delete; - - /** - *@method MuxPort - * - *@brief class copy constructor - * - *@param MuxPort (in) reference to MuxPort object to be copied - */ - MuxPort(const MuxPort &) = delete; - - /** - *@method MuxPort - * - *@brief class constructor - * - *@param dbInterfacePtr (in) pointer to DbInterface object - *@param muxConfig (in) reference to MuxConfig object - *@param portName (in) reference to port name - *@param serverId (in) server/blade id - *@param ioService (in) reference to Boost IO Service object - */ - MuxPort( - std::shared_ptr dbInterfacePtr, - common::MuxConfig &muxConfig, - const std::string &portName, - uint16_t serverId, - boost::asio::io_service &ioService - ); - - /** - *@method ~MuxPort - * - *@brief class destructor - */ - virtual ~MuxPort() = default; - - /** - *@method getMuxPortConfig - * - *@brief getter for MuxPortConfig object - * - *@return reference to MuxPortConfig object - */ - inline const common::MuxPortConfig& getMuxPortConfig() const {return mMuxPortConfig;}; - - /** - *@method setMuxState - * - *@brief set MUX state in APP DB for orchagent processing - * - *@param label (in) label of target state - * - *@return none - */ - inline void setMuxState(mux_state::MuxState::Label label) {mDbInterfacePtr->setMuxState(mMuxPortConfig.getPortName(), label);}; - - /** - *@method getMuxState - * - *@brief retrieve the current MUX state - * - *@param portName (in) MUX/port name - * - *@return none - */ - inline void getMuxState() {mDbInterfacePtr->getMuxState(mMuxPortConfig.getPortName());}; - - /** - *@method probeMuxState - * - *@brief trigger xcvrd to read MUX state using i2c - * - *@param portName (in) MUX/port name - * - *@return label of MUX state - */ - inline void probeMuxState() {mDbInterfacePtr->probeMuxState(mMuxPortConfig.getPortName());}; - - /** - *@method setMuxLinkmgrState - * - *@brief set MUX LinkMgr state in State DB for cli processing - * - *@param label (in) label of target state - * - *@return none - */ - inline void setMuxLinkmgrState(link_manager::LinkManagerStateMachine::Label label) { - mDbInterfacePtr->setMuxLinkmgrState(mMuxPortConfig.getPortName(), label); - }; - - /** - *@method postMetricsEvent - * - *@brief post MUX metrics event - * - *@param metrics (in) metrics to post - *@param label (in) label of target state - * - *@return none - */ - inline void postMetricsEvent( - link_manager::LinkManagerStateMachine::Metrics metrics, - mux_state::MuxState::Label label - ) { - mDbInterfacePtr->postMetricsEvent(mMuxPortConfig.getPortName(), metrics, label); - }; - - /** - *@method setServerIpv4Address - * - *@brief setter for server/blade IPv4 address - * - *@param address (in) server IPv4 address - * - *@return none - */ - inline void setServerIpv4Address(const boost::asio::ip::address &address) {mMuxPortConfig.setBladeIpv4Address(address);}; - - /** - *@method handleBladeIpv4AddressUpdate - * - *@brief update server/blade IPv4 Address - * - *@param addres (in) server/blade IP address - * - *@return none - */ - void handleBladeIpv4AddressUpdate(boost::asio::ip::address addres); - - /** - *@method handleLinkState - * - *@brief handles link state updates - * - *@param linkState (in) link state - * - *@return none - */ - void handleLinkState(const std::string &linkState); - - /** - *@method handleGetServerMacAddress - * - *@brief handles get Server MAC address - * - *@param address (in) Server MAC address - * - *@return none - */ - void handleGetServerMacAddress(const std::array &address); - - /** - *@method handleGetMuxState - * - *@brief handles get MUX state updates - * - *@param muxState (in) link state - * - *@return none - */ - void handleGetMuxState(const std::string &muxState); - - /** - *@method handleProbeMuxState - * - *@brief handles probe MUX state updates - * - *@param muxState (in) link state - * - *@return none - */ - void handleProbeMuxState(const std::string &muxState); - - /** - *@method handleMuxState - * - *@brief handles MUX state updates - * - *@param muxState (in) link state - * - *@return none - */ - void handleMuxState(const std::string &muxState); - - /** - *@method handleMuxConfig - * - *@brief handles MUX config updates when switching between auto/active/manual - * - *@param config (in) MUX new config; auto/active/manual - * - *@return none - */ - void handleMuxConfig(const std::string &config); - -protected: - friend class test::MuxManagerTest; - friend class test::FakeMuxPort; - /** - *@method getLinkManagerStateMachine - * - *@brief getter for LinkManagerStateMachine object (used during unit test) - * - *@return pointer to LinkManagerStateMachine object - */ - link_manager::LinkManagerStateMachine* getLinkManagerStateMachine() {return &mLinkManagerStateMachine;}; - - /** - *@method setComponentInitState - * - *@brief setter for state machine component initial state (used during unit test) - * - *@param component (in) component index - */ - void setComponentInitState(uint8_t component) {mLinkManagerStateMachine.setComponentInitState(component);}; - -private: - std::shared_ptr mDbInterfacePtr = nullptr; - common::MuxPortConfig mMuxPortConfig; - boost::asio::io_service::strand mStrand; - - link_manager::LinkManagerStateMachine mLinkManagerStateMachine; -}; - -} /* namespace mux */ - -#endif /* MUXPORT_H_ */ diff --git a/src/linkmgrd/src/NetMsgInterface.cpp b/src/linkmgrd/src/NetMsgInterface.cpp deleted file mode 100644 index 802962d21d23..000000000000 --- a/src/linkmgrd/src/NetMsgInterface.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * NetMsgInterface.cpp - * - * Created on: Jan 12, 2021 - * Author: taahme - */ - -#include -#include -#include -#include -#include -#include - -#include "swss/linkcache.h" -#include "swss/macaddress.h" - -#include "NetMsgInterface.h" -#include "common/MuxLogger.h" -#include "common/MuxException.h" - -namespace mux -{ - -// -// ---> NetMsgInterface(DbInterface &dbInterface); -// -// class constructor -// -NetMsgInterface::NetMsgInterface(DbInterface &dbInterface) : - mDbInterface(dbInterface) -{ -} - -// -// ---> onMsg(int msgType, NetlinkObject *netlinkObject); -// -// handle received net link messages -// -void NetMsgInterface::onMsg(int msgType, NetlinkObject *netlinkObject) -{ - static auto constexpr NONE_MAC = "none"; - - if ((msgType == RTM_NEWNEIGH) || (msgType == RTM_GETNEIGH) || (msgType == RTM_DELNEIGH)) { - RouteNetlinkNeighbor *routeNetlinkNeighbor = reinterpret_cast (netlinkObject); - if (rtnl_neigh_get_family(routeNetlinkNeighbor) == AF_INET || - rtnl_neigh_get_family(routeNetlinkNeighbor) == AF_INET6) { - std::string portName = swss::LinkCache::getInstance().ifindexToName( - rtnl_neigh_get_ifindex(routeNetlinkNeighbor) - ); - - std::array macStr; - nl_addr2str(rtnl_neigh_get_lladdr(routeNetlinkNeighbor), macStr.data(), macStr.size() - 1); - - if (strncmp(macStr.data(), NONE_MAC, strlen(NONE_MAC))) { - std::array ipStr; - nl_addr2str(rtnl_neigh_get_dst(routeNetlinkNeighbor), ipStr.data(), ipStr.size() - 1); - - updateMacAddress(portName, ipStr, macStr); - } - } - } -} - -// -// ---> updateMacAddress( -// std::string &port, -// std::array &ip, -// std::array &mac -// ); -// -// update server MAC address -// -void NetMsgInterface::updateMacAddress( - std::string &port, - std::array &ip, - std::array &mac -) -{ - MUXLOGDEBUG(boost::format("%s: interface IP '%s', MAC '%s'") % - port % ip.data() % mac.data() - ); - - boost::system::error_code errorCode; - boost::asio::ip::address ipAddress = boost::asio::ip::make_address(ip.data(), errorCode); - if (!errorCode) { - try { - swss::MacAddress macAddress(mac.data()); - mDbInterface.updateServerMacAddress(ipAddress, macAddress.getMac()); - } - catch (const std::invalid_argument &invalidArgument) { - MUXLOGWARNING(boost::format("%s: invalid argument for interface IP '%s', MAC '%s'") % - port % ip.data() % mac.data() - ); - } - } -} - -} /* namespace mux */ diff --git a/src/linkmgrd/src/NetMsgInterface.h b/src/linkmgrd/src/NetMsgInterface.h deleted file mode 100644 index 91d340e0dabe..000000000000 --- a/src/linkmgrd/src/NetMsgInterface.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * NetMsgInterface.h - * - * Created on: Jan 12, 2021 - * Author: taahme - */ - -#ifndef _NETMSGINTERFACE_H_ -#define _NETMSGINTERFACE_H_ - -#include "swss/netmsg.h" -#include "DbInterface.h" - -#define MAX_ADDR_SIZE 64 - -namespace test { -class MuxManagerTest; -} - -namespace mux -{ -using NetlinkObject = struct nl_object; -using RouteNetlinkNeighbor = struct rtnl_neigh; -//using RouteNetlinkLink = struct rtnl_link; - -class NetMsgInterface: public swss::NetMsg -{ -public: - /** - *@method NetMsgInterface - * - *@brief class default constructor - */ - NetMsgInterface() = delete; - - /** - *@method NetMsgInterface - * - *@brief class copy constructor - * - *@param DbInterface (in) reference to DbInterface object to be copied - */ - NetMsgInterface(const NetMsgInterface &) = delete; - - /** - *@method NetMsgInterface - * - *@brief class constructor - * - *@param dbInterface (in) reference to DB interface instance - */ - NetMsgInterface(DbInterface &dbInterface); - - /** - *@method ~NetMsgInterface - * - *@brief class destructor - */ - virtual ~NetMsgInterface() = default; - - /** - *@method onMsg - * - *@brief handle received net link messages - * - *@param msgType (in) netlink message type - *@param netlinkObject (in) pointer to netlink message object - * - *@return none - */ - virtual void onMsg(int msgType, NetlinkObject *netlinkObject) override; - -private: - friend class test::MuxManagerTest; - - /** - *@method updateMacAddress - * - *@brief update server MAC address - * - *@param port (in) port name server is connected to - *@param ip (in) server IP address - *@param mac (in) server MAC address - * - *@return none - */ - inline void updateMacAddress( - std::string &port, - std::array &ip, - std::array &mac - ); - -private: - DbInterface &mDbInterface; -}; - -} /* namespace mux */ - -#endif /* _NETMSGINTERFACE_H_ */ diff --git a/src/linkmgrd/src/common/MuxConfig.h b/src/linkmgrd/src/common/MuxConfig.h deleted file mode 100644 index 1c03a36c848f..000000000000 --- a/src/linkmgrd/src/common/MuxConfig.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - * MuxConfig.h - * - * Created on: Oct 9, 2020 - * Author: tamer - */ - -#ifndef MUXCONFIG_H_ -#define MUXCONFIG_H_ - -#include -#include - -#include - -namespace common -{ - -/** - *@class MuxConfig - * - *@brief Holds MUX configuration - */ -class MuxConfig -{ -public: - /** - *@method MuxConfig - * - *@brief class default constructor - */ - MuxConfig() = default; - - /** - *@method MuxConfig - * - *@brief class copy constructor - * - *@param MuxConfig (in) reference to MuxConfig object to be copied - */ - MuxConfig(const MuxConfig &) = delete; - - /** - *@method ~MuxConfig - * - *@brief class destructor - */ - virtual ~MuxConfig() = default; - - /** - *@method setNumberOfThreads - * - *@brief setter for number of threads - * - *@param numberOfThreads (in) number of threads of linkmgrd - * - *@return none - */ - inline void setNumberOfThreads(uint8_t numberOfThreads) {mNumberOfThreads = numberOfThreads;}; - - /** - *@method setTimeoutIpv4_msec - * - *@brief setter for IPv4 LinkProber timeout in msec - * - *@param timeout_msec (in) timeout in msec - * - *@return none - */ - inline void setTimeoutIpv4_msec(uint32_t timeout_msec) {mTimeoutIpv4_msec = timeout_msec;}; - - /** - *@method setTimeoutIpv6_msec - * - *@brief setter for IPv6 LinkProber timeout in msec - * - *@param timeout_msec (in) timeout in msec - * - *@return none - */ - inline void setTimeoutIpv6_msec(uint32_t timeout_msec) {mTimeoutIpv6_msec = timeout_msec;}; - - /** - *@method setPositiveStateChangeRetryCount - * - *@brief setter for LinkProber positive state change retry count - * - *@param stateChangeRetryCount (in) state change retry count - * - *@return none - */ - inline void setPositiveStateChangeRetryCount(uint32_t stateChangeRetryCount) { - mPositiveStateChangeRetryCount = stateChangeRetryCount; - }; - - /** - *@method setNegativeStateChangeRetryCount - * - *@brief setter for LinkProber negative state change retry count - * - *@param stateChangeRetryCount (in) state change retry count - * - *@return none - */ - inline void setNegativeStateChangeRetryCount(uint32_t stateChangeRetryCount) { - mNegativeStateChangeRetryCount = stateChangeRetryCount; - }; - - /** - *@method setSuspendTimeout_msec - * - *@brief setter for LinkProber suspend timer timeout - * - *@param suspendTimeout_msec (in) suspend timer timeout - * - *@return none - */ - inline void setSuspendTimeout_msec(uint32_t suspendTimeout_msec) {mSuspendTimeout_msec = suspendTimeout_msec;}; - - /** - *@method setMuxStateChangeRetryCount - * - *@brief setter for MuxState state change retry count - * - *@param muxStateChangeRetryCount (in) state change retry count - * - *@return none - */ - inline void setMuxStateChangeRetryCount(uint32_t muxStateChangeRetryCount) {mMuxStateChangeRetryCount = muxStateChangeRetryCount;}; - - /** - *@method setLinkStateChangeRetryCount - * - *@brief setter for LinkeState change retry count - * - *@param linkStateChangeRetryCount (in) state change retry count - * - *@return none - */ - inline void setLinkStateChangeRetryCount(uint32_t linkStateChangeRetryCount) {mLinkStateChangeRetryCount = linkStateChangeRetryCount;}; - - /** - *@method setTorMacAddress - * - *@brief setter for ToR MAC address - * - *@param address (in) ToR MAC address - * - *@return none - */ - inline void setTorMacAddress(const std::array &address) {mTorMacAddress = address;}; - - /** - *@method setLoopbackIpv4Address - * - *@brief setter for Loopback IPv4 address - * - *@param address (in) IPv4 address - * - *@return none - */ - inline void setLoopbackIpv4Address(boost::asio::ip::address& address) {mLoopbackIpv4Address = address;}; - - /** - *@method getNumberOfThreads - * - *@brief getter for logging severity level - * - *@return number of linkmgrd/application threads - */ - inline uint8_t getNumberOfThreads() const {return mNumberOfThreads;}; - - /** - *@method getTimeoutIpv4_msec - * - *@brief getter for IPv4 LinkProber timeout in msec - * - *@return timeout in msec - */ - inline uint32_t getTimeoutIpv4_msec() const {return mTimeoutIpv4_msec;}; - - /** - *@method getTimeoutIpv6_msec - * - *@brief getter for IPv6 LinkProber timeout in msec - * - *@return timeout in msec - */ - inline uint32_t getTimeoutIpv6_msec() const {return mTimeoutIpv6_msec;}; - - /** - *@method getPositiveStateChangeRetryCount - * - *@brief getter for LinkProber positive state change retry count - * - *@return state change retry count - */ - inline uint32_t getPositiveStateChangeRetryCount() const {return mPositiveStateChangeRetryCount;}; - - /** - *@method getNegativeStateChangeRetryCount - * - *@brief getter for LinkProber negative state change retry count - * - *@return state change retry count - */ - inline uint32_t getNegativeStateChangeRetryCount() const {return mNegativeStateChangeRetryCount;}; - - /** - *@method getSuspendTimeout_msec - * - *@brief getter for LinkProber suspend timer timeout - * - *@return suspend timer timeout - */ - inline uint32_t getSuspendTimeout_msec() const {return (mNegativeStateChangeRetryCount + 1) * mTimeoutIpv4_msec;}; - - /** - *@method getMuxStateChangeRetryCount - * - *@brief getter for MuxState state change retry count - * - *@return state change retry count - */ - inline uint32_t getMuxStateChangeRetryCount() const {return mMuxStateChangeRetryCount;}; - - /** - *@method getLinkStateChangeRetryCount - * - *@brief getter for LinkeState change retry count - * - *@return state change retry count - */ - inline uint32_t getLinkStateChangeRetryCount() const {return mLinkStateChangeRetryCount;}; - - /** - *@method getTorMacAddress - * - *@brief getter for ToR MAC address - * - *@return ToR MAC address - */ - inline const std::array& getTorMacAddress() const {return mTorMacAddress;}; - - /** - *@method getLoopbackIpv4Address - * - *@brief getter for Loopback IPv4 address - * - *@return IPv4 address - */ - inline boost::asio::ip::address getLoopbackIpv4Address() {return mLoopbackIpv4Address;}; - -private: - uint8_t mNumberOfThreads = 5; - uint32_t mTimeoutIpv4_msec = 100; - uint32_t mTimeoutIpv6_msec = 1000; - uint32_t mPositiveStateChangeRetryCount = 1; - uint32_t mNegativeStateChangeRetryCount = 3; - uint32_t mSuspendTimeout_msec = 500; - uint32_t mMuxStateChangeRetryCount = 1; - uint32_t mLinkStateChangeRetryCount = 1; - - std::array mTorMacAddress; - boost::asio::ip::address mLoopbackIpv4Address = boost::asio::ip::make_address("10.212.64.0"); -}; - -} /* namespace common */ - -#endif /* MUXCONFIG_H_ */ diff --git a/src/linkmgrd/src/common/MuxException.h b/src/linkmgrd/src/common/MuxException.h deleted file mode 100644 index 51fca9b572fc..000000000000 --- a/src/linkmgrd/src/common/MuxException.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * MuxException.h - * - * Created on: Oct 4, 2020 - * Author: tamer - */ - -#ifndef MUXEXCEPTION_H_ -#define MUXEXCEPTION_H_ - -#include -#include - -#include "MuxLogger.h" - -/** - * A macro for generating an MuxException with file path and line number. - */ -#define MUX_ERROR(name, msg) common::name##Exception(msg, __FILE__, __LINE__) - -namespace common -{ - -class MuxException : public std::exception { -public: - MuxException( - std::string excStr, - const char *excFile, - unsigned int excLine - ) noexcept { - mExcStr = std::string(excFile) + ":" + std::to_string(excLine) + ": " + excStr; - MUXLOGERROR(mExcStr); - } - - virtual const char* what() const throw() { - return mExcStr.c_str(); - } - - virtual ~MuxException () noexcept {}; - -private: - std::string mExcStr; -}; - -/** -* Exception for Runtime Expression -* -* This is thrown when a runtime exception is detected -*/ -class RunTimeErrorException : public MuxException { -public: - using MuxException::MuxException; - - virtual ~RunTimeErrorException () noexcept {}; -}; - -/** -* Exception for missing configuration. -* -* This is thrown when required configuration is missing. -*/ -class ConfigNotFoundException : public RunTimeErrorException { -public: - using RunTimeErrorException::RunTimeErrorException; - - virtual ~ConfigNotFoundException () noexcept {}; -}; - -/** -* Exception for MUX Logger -* -* This is thrown when boost logger report exceptions -*/ -class MuxLoggerException : public RunTimeErrorException { -public: - using RunTimeErrorException::RunTimeErrorException; - - virtual ~MuxLoggerException () noexcept {}; -}; - -/** -* Exception for Bad Memory Alloc -* -* This is thrown when failing to allocated memory -*/ -class BadAllocException : public RunTimeErrorException { -public: - using RunTimeErrorException::RunTimeErrorException; - - virtual ~BadAllocException () noexcept {}; -}; - -/** -* Exception for Socket Errors -* -* This is thrown when socket operation fails -*/ -class SocketErrorException : public RunTimeErrorException { -public: - using RunTimeErrorException::RunTimeErrorException; - - virtual ~SocketErrorException () noexcept {}; -}; - -} /* namespace common */ - -#endif /* MUXEXCEPTION_H_ */ diff --git a/src/linkmgrd/src/common/MuxLogger.cpp b/src/linkmgrd/src/common/MuxLogger.cpp deleted file mode 100644 index 707b6888af1d..000000000000 --- a/src/linkmgrd/src/common/MuxLogger.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * MuxLogger.cpp - * - * Created on: Oct 4, 2020 - * Author: tamer - */ - -#include -#include -#include -#include "boost/log/utility/setup/from_settings.hpp" -#include -#include - -#include "MuxException.h" -#include "MuxLogger.h" - -namespace common -{ - -// -// ---> operator()(const boost::log::runtime_error &ex); -// -// handles runtime error exceptions -// -void MuxLoggerExceptionHandler::operator()(const boost::log::runtime_error &ex) const -{ - std::ostringstream errMsg; - errMsg << "MUX Logger exception!!" << ". Exception details: " << ex.what(); - - throw MUX_ERROR(MuxLogger, errMsg.str()); -} - -// -// ---> operator()(const std::exception &ex); -// -// handles std exceptions -// -void MuxLoggerExceptionHandler::operator()(const std::exception &ex) const -{ - std::ostringstream errMsg; - errMsg << "MUX Logger exception!!" << ". Exception details: " << ex.what(); - - throw MUX_ERROR(MuxLogger, errMsg.str()); -} - -// -// ---> getInstance(); -// -// constructs MuxLogger singleton instance -// -MuxLoggerPtr MuxLogger::getInstance() -{ - static std::shared_ptr MuxLoggerPtr = nullptr; - - if (MuxLoggerPtr == nullptr) { - MuxLoggerPtr = std::shared_ptr (new MuxLogger); - } - - return MuxLoggerPtr; -} - -// -// ---> initialize(std::string &prog, -// std::string &path, -// boost::log::trivial::severity_level level); -// -// initialize MUX logging class -// -void MuxLogger::initialize( - std::string &prog, - std::string &path, - boost::log::trivial::severity_level level -) -{ - namespace trivial = boost::log::trivial; - namespace keywords = boost::log::keywords; - - mLevel = level; - - boost::log::register_simple_formatter_factory ("Severity"); - - boost::log::settings settings; - boost::log::init_from_settings(settings); - -// boost::filesystem::remove(path); - -// boost::log::add_file_log( -// keywords::file_name = path, -// keywords::format = "[%TimeStamp%] [%Severity%] %Message%" -// ); - - boost::log::add_common_attributes(); - boost::log::core::get()->set_exception_handler( - boost::log::make_exception_handler (MuxLoggerExceptionHandler()) - ); - - addSyslogSink(prog); -} - -// -// ---> setLevel(const boost::log::trivial::severity_level level); -// -// set logger frontend and backend filter level -// -void MuxLogger::setLevel(const boost::log::trivial::severity_level level) -{ - namespace trivial = boost::log::trivial; - - mLevel = level; - boost::log::core::get()->set_filter(trivial::severity >= level); -} - -// -// ---> addSyslogSink(std::string &prog); -// -// Add syslog sink -// -void MuxLogger::addSyslogSink(std::string &prog) -{ - namespace sinks = boost::log::sinks; - try { - // Create a syslog sink - boost::shared_ptr sink(new sinks::syslog_backend( - boost::log::keywords::facility = sinks::syslog::user, - boost::log::keywords::use_impl = sinks::syslog::native - )); - - // Create and fill in another level translator for "Severity" attribute of type string - sinks::syslog::custom_severity_mapping mapping("Severity"); - mapping[boost::log::trivial::trace] = sinks::syslog::debug; - mapping[boost::log::trivial::debug] = sinks::syslog::debug; - mapping[boost::log::trivial::info] = sinks::syslog::info; - mapping[boost::log::trivial::warning] = sinks::syslog::warning; - mapping[boost::log::trivial::error] = sinks::syslog::error; - mapping[boost::log::trivial::fatal] = sinks::syslog::alert; - sink->set_severity_mapper(mapping); - - // Add the sink to the core - boost::log::core::get()->add_sink(boost::make_shared> (sink)); - } - catch (std::exception& ex) { - std::ostringstream errMsg; - errMsg << "MUX Logger exception!!" << ". Exception details: " << ex.what(); - - throw MUX_ERROR(MuxLogger, errMsg.str()); - } -} - -} /* namespace common */ diff --git a/src/linkmgrd/src/common/MuxLogger.h b/src/linkmgrd/src/common/MuxLogger.h deleted file mode 100644 index 4be79abcfd48..000000000000 --- a/src/linkmgrd/src/common/MuxLogger.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * MuxLogger.h - * - * Created on: Oct 4, 2020 - * Author: tamer - */ - -#ifndef MUXLOGGER_H_ -#define MUXLOGGER_H_ - -#include - -#include -#include -#include -#include - - -namespace common -{ -class MuxLogger; -using MuxLoggerPtr = std::shared_ptr; - -/** - *@class MuxLoggerExceptionHandler - * - *@brief Handles exception generated by boost logging framework - */ -class MuxLoggerExceptionHandler -{ -public: - /** - *@method operator() - * - *@brief handles runtime error exceptions - * - *@param ex (in) runtime error exception - * - *@throw MUX logger exception corresponding to exception received - */ - void operator()(const boost::log::runtime_error &ex) const; - - - /** - *@method operator() - * - *@brief handles std exceptions - * - *@param ex (in) std exception - * - *@throw MUX logger exception corresponding to exception received - */ - void operator()(const std::exception &ex) const; -}; - -/** - *@class MuxLogger - * - *@brief MUX Logger class wraps boost logging framework. It is a singleton - * class that manages MUX Logging - */ -class MuxLogger -{ -public: - /** - *@method MuxLogger - * - *@brief class copy constructor - * - *@param muxLogger (in) reference to muxLogger object to be copied - */ - MuxLogger(const MuxLogger &) = delete; - - /** - *@method ~MuxLogger - * - *@brief class destructor - * - */ - virtual ~MuxLogger() = default; - - /** - *@method getInstance - * - *@brief constructs MuxLogger singleton instance - * - *@return shared pointer to MuxLogger singleton instance - */ - static MuxLoggerPtr getInstance(); - - /** - *@method initialize - * - *@brief initialize MUX logging class - * - *@param prog (in) program name to be used when logging - *@param path (in) path on file system to MUX logging file - *@param level (in) minimum logging severity level - * - *@return none - */ - void initialize(std::string &prog, std::string &path, boost::log::trivial::severity_level level); - - /** - *@method setLevel - * - *@brief setter for logging severity level - * - *@param level (in) severity level for log messages that would follow - * - *@return none - */ - void setLevel(const boost::log::trivial::severity_level level); - - /** - *@method getLevel - * - *@brief getter for logging severity level - * - *@return current logging severity level - */ - boost::log::trivial::severity_level getLevel() const {return mLevel;}; - - /** - *@method getLogger - * - *@brief getter for Severity Logger - * - *@return severity logger instance - */ - boost::log::sources::severity_logger_mt& - getLogger() {return mSeverityLogger;}; - -private: - friend class std::shared_ptr; - friend MuxLoggerPtr std::make_shared (); - - /** - *@method MuxLogger - * - *@brief class constructor - * - */ - MuxLogger() = default; - - void addSyslogSink(std::string &prog); - -private: - boost::log::trivial::severity_level mLevel = boost::log::trivial::info; - - boost::log::sources::severity_logger_mt mSeverityLogger; -}; - -} /* namespace common */ - -#define XSTR(x) STR(x) -#define STR(x) #x - -/** - * MUXLOG macro prepends file name, line number, and function to logged message - * - *@param level (in) logging severity level - *@param msg (in) message to be logged - */ -#define MUXLOG(level, msg) \ - do { \ - if (level >= common::MuxLogger::getInstance()->getLevel()) { \ - BOOST_LOG_SEV(common::MuxLogger::getInstance()->getLogger(), level) \ - << XSTR(__FILENAME__) << ":" << __LINE__ << " " << __FUNCTION__ << ": " \ - << msg; \ - } \ - } while (0) - -/** - * MUXLOGTRACE handy macro that logs with trace severity level and appends file - * name, line number, function to the message being logged - * - *@param msg (in) message to be logged - */ -#define MUXLOGTRACE(msg) MUXLOG(boost::log::trivial::trace, msg) - -/** - * MUXLOGDEBUG handy macro that logs with debug severity level and appends file - * name, line number, function to the message being logged - * - *@param msg (in) message to be logged - */ -#define MUXLOGDEBUG(msg) MUXLOG(boost::log::trivial::debug, msg) - -/** - * MUXLOGINFO handy macro that logs with info severity level and appends file - * name, line number, function to the message being logged - * - *@param msg (in) message to be logged - */ -#define MUXLOGINFO(msg) MUXLOG(boost::log::trivial::info, msg) - -/** - * MUXLOGWARNING handy macro that logs with warning severity level and appends file - * name, line number, function to the message being logged - * - *@param msg (in) message to be logged - */ -#define MUXLOGWARNING(msg) MUXLOG(boost::log::trivial::warning, msg) - -/** - * MUXLOGERROR handy macro that logs with error severity level and appends file - * name, line number, function to the message being logged - * - *@param msg (in) message to be logged - */ -#define MUXLOGERROR(msg) MUXLOG(boost::log::trivial::error, msg) - -/** - * MUXLOGFATAL handy macro that logs with fatal severity level and appends file - * name, line number, function to the message being logged - * - *@param msg (in) message to be logged - */ -#define MUXLOGFATAL(msg) MUXLOG(boost::log::trivial::fatal, msg) - -#endif /* MUXLOGGER_H_ */ diff --git a/src/linkmgrd/src/common/MuxPortConfig.cpp b/src/linkmgrd/src/common/MuxPortConfig.cpp deleted file mode 100644 index 78f0e1e4543b..000000000000 --- a/src/linkmgrd/src/common/MuxPortConfig.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * MuxPortConfig.cpp - * - * Created on: Oct 21, 2020 - * Author: tamer - */ - -#include "common/MuxPortConfig.h" - -namespace common -{ - -// -// ---> MuxPortConfig(MuxConfig &muxConfig, const std::string &portName, uint16_t serverId); -// -// class constructor -// -MuxPortConfig::MuxPortConfig( - MuxConfig &muxConfig, - const std::string &portName, - uint16_t serverId -) : - mMuxConfig(muxConfig), - mPortName(portName), - mServerId(serverId) -{ -} - -} /* namespace common */ diff --git a/src/linkmgrd/src/common/MuxPortConfig.h b/src/linkmgrd/src/common/MuxPortConfig.h deleted file mode 100644 index 0c3846e38906..000000000000 --- a/src/linkmgrd/src/common/MuxPortConfig.h +++ /dev/null @@ -1,249 +0,0 @@ -/* - * MuxPortConfig.h - * - * Created on: Oct 21, 2020 - * Author: tamer - */ - -#ifndef MUXPORTCONFIG_H_ -#define MUXPORTCONFIG_H_ - -#include -#include -#include - -#include "MuxConfig.h" - -namespace common -{ - -/** - *@class MuxPortConfig - * - *@brief Holds MUX port configuration - */ -class MuxPortConfig -{ -public: - /** - *@enum Mode - * - *@brief MUX config mode - */ - enum Mode { - Auto, - Manual, - Active, - Standby - }; - -public: - /** - *@method MuxPortConfig - * - *@brief class default constructor - */ - MuxPortConfig() = delete; - - /** - *@method MuxPortConfig - * - *@brief class copy constructor - * - *@param MuxPortConfig (in) reference to MuxPortConfig object to be copied - */ - MuxPortConfig(const MuxPortConfig &) = delete; - - /** - *@method MuxPortConfig - * - *@brief class constructor - * - *@param muxConfig (in) reference to MuxConfig object - *@param portname (in) reference to port name - *@param serverId (in) server Id - */ - MuxPortConfig( - MuxConfig &muxConfig, - const std::string &portName, - uint16_t serverId - ); - - /** - *@method ~MuxPortConfig - * - *@brief class destructor - */ - virtual ~MuxPortConfig() = default; - - /** - *@method setBladeIpv4Address - * - *@brief setter for server/blade IPv4 address - * - *@param address (in) server IPv4 address - * - *@return none - */ - inline void setBladeIpv4Address(const boost::asio::ip::address &address) {mBladeIpv4Address = address;}; - - /** - *@method setBladeMacAddress - * - *@brief setter for server/blade MAC address - * - *@param address (in) server MAC address - * - *@return none - */ - inline void setBladeMacAddress(const std::array &address) {mBladeMacAddress = address;}; - - /** - *@method setMode - * - *@brief setter for MUX mode - * - *@param mode (in) MUX config mode - * - *@return none - */ - inline void setMode(const Mode mode) {mMode = mode;}; - - /** - *@method getTimeoutIpv4_msec - * - *@brief getter for IPv4 LinkProber timeout in msec - * - *@return timeout in msec - */ - inline uint32_t getTimeoutIpv4_msec() const {return mMuxConfig.getTimeoutIpv4_msec();}; - - /** - *@method getTimeoutIpv6_msec - * - *@brief getter for IPv6 LinkProber timeout in msec - * - *@return timeout in msec - */ - inline uint32_t getTimeoutIpv6_msec() const {return mMuxConfig.getTimeoutIpv6_msec();}; - - /** - *@method getPositiveStateChangeRetryCount - * - *@brief getter for LinkProber positive state change retry count - * - *@return state change retry count - */ - inline uint32_t getPositiveStateChangeRetryCount() const {return mMuxConfig.getPositiveStateChangeRetryCount();}; - - /** - *@method getNegativeStateChangeRetryCount - * - *@brief getter for LinkProber negative state change retry count - * - *@return state change retry count - */ - inline uint32_t getNegativeStateChangeRetryCount() const {return mMuxConfig.getNegativeStateChangeRetryCount();}; - - /** - *@method getSuspendTimeout_msec - * - *@brief getter for LinkProber suspend timer timeout - * - *@return suspend timer timeout - */ - inline uint32_t getLinkWaitTimeout_msec() const {return mMuxConfig.getSuspendTimeout_msec();}; - - /** - *@method getMuxStateChangeRetryCount - * - *@brief getter for MuxState state change retry count - * - *@return state change retry count - */ - inline uint32_t getMuxStateChangeRetryCount() const {return mMuxConfig.getMuxStateChangeRetryCount();}; - - /** - *@method getLinkStateChangeRetryCount - * - *@brief getter for LinkeState change retry count - * - *@return state change retry count - */ - inline uint32_t getLinkStateChangeRetryCount() const {return mMuxConfig.getLinkStateChangeRetryCount();}; - - /** - *@method getTorMacAddress - * - *@brief getter for ToR MAC address - * - *@return ToR MAC address - */ - inline const std::array& getTorMacAddress() const {return mMuxConfig.getTorMacAddress();}; - - /** - *@method getLoopbackIpv4Address - * - *@brief getter for Loopback IPv4 address - * - *@return IPv4 address - */ - inline boost::asio::ip::address getLoopbackIpv4Address() const {return mMuxConfig.getLoopbackIpv4Address();}; - - /** - *@method getPortName - * - *@brief getter for port name - * - *@return port name - */ - inline const std::string& getPortName() const {return mPortName;}; - - /** - *@method getBladeIpv4Address - * - *@brief getter for server/blade IPv4 address - * - *@return IPv4 address - */ - inline const boost::asio::ip::address& getBladeIpv4Address() const {return mBladeIpv4Address;}; - - /** - *@method getBladeMacAddress - * - *@brief getter for server/blade MAC address - * - *@return MAC address - */ - inline const std::array& getBladeMacAddress() const {return mBladeMacAddress;}; - - /** - *@method getServerId - * - *@brief getter for server id - * - *@return server id - */ - inline uint16_t getServerId() const {return mServerId;}; - - /** - *@method getMode - * - *@brief getter for MUX mode - * - *@return MUX mode - */ - inline Mode getMode() const {return mMode;}; - -private: - MuxConfig &mMuxConfig; - std::string mPortName; - boost::asio::ip::address mBladeIpv4Address; - std::array mBladeMacAddress = {0, 0, 0, 0, 0, 0}; - uint16_t mServerId; - Mode mMode = Manual; -}; - -} /* namespace common */ - -#endif /* MUXPORTCONFIG_H_ */ diff --git a/src/linkmgrd/src/common/State.cpp b/src/linkmgrd/src/common/State.cpp deleted file mode 100644 index 95bd68559546..000000000000 --- a/src/linkmgrd/src/common/State.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * State.cpp - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#include -#include "MuxLogger.h" - -namespace common -{ - -// -// ---> State(StateMachine &stateMachine, MuxPortConfig &muxPortConfig); -// -// class constructor -// -State::State( - StateMachine &stateMachine, - MuxPortConfig &muxPortConfig -) : - mStateMachine(stateMachine), - mMuxPortConfig(muxPortConfig) -{ -} - -} /* namespace common */ diff --git a/src/linkmgrd/src/common/State.h b/src/linkmgrd/src/common/State.h deleted file mode 100644 index 15cddd6207ff..000000000000 --- a/src/linkmgrd/src/common/State.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * State.h - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#ifndef STATE_H_ -#define STATE_H_ - -#include -#include "common/MuxPortConfig.h" - -namespace common -{ -class StateMachine; - -/** - *@class State - * - *@brief Maintains common state functionality - */ -class State -{ -public: - /** - *@method State - * - *@brief class default constructor - */ - State() = delete; - - /** - *@method State - * - *@brief class copy constructor - * - *@param State (in) reference to State object to be copied - */ - State(const State &) = delete; - - /** - *@method State - * - *@brief class constructor - * - *@param stateMachine (in) reference to StateMachine object - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - State( - StateMachine &stateMachine, - MuxPortConfig &muxPortConfig - ); - - /** - *@method ~State - * - *@brief class destructor - */ - virtual ~State() = default; - - /** - *@method getStateMachine - * - *@brief getter for StateMachine object - * - *@return StateMacine object - */ - StateMachine* getStateMachine() {return &mStateMachine;}; - - /** - *@method getMuxPortConfig - * - *@brief getter for MuxPortConfig object - * - *@return MuxPortConfig object - */ - const MuxPortConfig& getMuxPortConfig() const {return mMuxPortConfig;}; - - /** - *@method resetState - * - *@brief reset current state attributes. It is called when transitioning into State. - * - *@param address (in) server IPv4 address - * - *@return none - */ - virtual void resetState() = 0; - -private: - StateMachine &mStateMachine; - MuxPortConfig &mMuxPortConfig; -}; - -} /* namespace common */ - -#endif /* STATE_H_ */ diff --git a/src/linkmgrd/src/common/StateMachine.cpp b/src/linkmgrd/src/common/StateMachine.cpp deleted file mode 100644 index 9a8df8f99369..000000000000 --- a/src/linkmgrd/src/common/StateMachine.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * StateMachine.cpp - * - * Created on: Oct 4, 2020 - * Author: tamer - */ - -#include -#include -#include "MuxLogger.h" - - -namespace common -{ - -// -// ---> StateMachine(boost::asio::io_service::strand &strand, MuxPortConfig &muxPortConfig); -// -// class constructor -// -StateMachine::StateMachine( - boost::asio::io_service::strand &strand, - MuxPortConfig &muxPortConfig -) : - mStrand(strand), - mMuxPortConfig(muxPortConfig) -{ -} - -// -// ---> setCurrentState(common::State* state); -// -// setter for current state, reset state when changed -// -void StateMachine::setCurrentState(common::State* state) -{ - if (mCurrentState != state) { - mCurrentState = state; - mCurrentState->resetState(); - } -}; - -} /* namespace common */ diff --git a/src/linkmgrd/src/common/StateMachine.h b/src/linkmgrd/src/common/StateMachine.h deleted file mode 100644 index 8101ff6c72e7..000000000000 --- a/src/linkmgrd/src/common/StateMachine.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * StateMachine.h - * - * Created on: Oct 4, 2020 - * Author: tamer - */ - -#ifndef STATEMACHINE_H_ -#define STATEMACHINE_H_ - -#include - -#include - -#include "common/MuxPortConfig.h" - -namespace link_manager { -class LinkManagerStateMachine; -} - -namespace link_prober { -class LinkProberStateMachine; -} - -namespace mux_state { -class MuxStateMachine; -} - -namespace link_state { -class LinkStateMachine; -} - -namespace common -{ -class State; - -/** - *@class StateMachine - * - *@brief Maintains common state machine functionality; current state, - * serialization object (strand,) and MuxPortConfig object - */ -class StateMachine -{ -public: - /** - *@method StateMachine - * - *@brief class default constructor - */ - StateMachine() = delete; - - /** - *@method StateMachine - * - *@brief class copy constructor - * - *@param StateMachine (in) reference to StateMachine object to be copied - */ - StateMachine(const StateMachine &) = delete; - - /** - *@method StateMachine - * - *@brief class constructor - * - *@param strand (in) boost serialization object - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - StateMachine( - boost::asio::io_service::strand &strand, - MuxPortConfig &muxPortConfig - ); - - /** - *@method ~StateMachine - * - *@brief class destructor - */ - virtual ~StateMachine() = default; - - /** - *@method getStrand - * - *@brief getter for boost serialization object - * - *@return reference to boost serialization object - */ - boost::asio::io_service::strand& getStrand() {return mStrand;}; - -private: - friend class link_manager::LinkManagerStateMachine; - friend class link_prober::LinkProberStateMachine; - friend class mux_state::MuxStateMachine; - friend class link_state::LinkStateMachine; - - /** - *@method setCurrentState - * - *@brief setter for current state - * - *@param state (in) current state of the state machine - * - *@return none - */ - void setCurrentState(State* state); - - /** - *@method getCurrentState - * - *@brief getter for current state - * - *@return current state of the state machine - */ - State* getCurrentState() {return mCurrentState;}; - - /** - *@method getMuxPortConfig - * - *@brief getter MuxPortConfig object - * - *@return reference to MuxPortConfig object - */ - const MuxPortConfig& getMuxPortConfig() const {return mMuxPortConfig;}; - -private: - boost::asio::io_service::strand mStrand; - State *mCurrentState = nullptr; - MuxPortConfig &mMuxPortConfig; -}; - -} /* namespace common */ - -#endif /* STATEMACHINE_H_ */ diff --git a/src/linkmgrd/src/common/subdir.mk b/src/linkmgrd/src/common/subdir.mk deleted file mode 100644 index 3bc7143441a0..000000000000 --- a/src/linkmgrd/src/common/subdir.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ - ./src/common/MuxLogger.cpp \ - ./src/common/MuxPortConfig.cpp \ - ./src/common/State.cpp \ - ./src/common/StateMachine.cpp - -OBJS += \ - ./src/common/MuxLogger.o \ - ./src/common/MuxPortConfig.o \ - ./src/common/State.o \ - ./src/common/StateMachine.o - -CPP_DEPS += \ - ./src/common/MuxLogger.d \ - ./src/common/MuxPortConfig.d \ - ./src/common/State.d \ - ./src/common/StateMachine.d - - -# Each subdirectory must supply rules for building sources it contributes -src/common/%.o: src/common/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - $(CC) -std=c++17 -D__FILENAME__="$(subst src/,,$<)" $(BOOST_MACROS) $(INCLUDES) $(CPP_FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/src/linkmgrd/src/link_manager/LinkManagerStateMachine.cpp b/src/linkmgrd/src/link_manager/LinkManagerStateMachine.cpp deleted file mode 100644 index 79dcb83ac5f1..000000000000 --- a/src/linkmgrd/src/link_manager/LinkManagerStateMachine.cpp +++ /dev/null @@ -1,1189 +0,0 @@ -/* - * LinkManagerStateMachine.cpp - * - * Created on: Oct 18, 2020 - * Author: tamer - */ - -#include - -#include "link_manager/LinkManagerStateMachine.h" -#include "common/MuxLogger.h" -#include "common/MuxException.h" -#include "MuxPort.h" - -#define LOG_MUX_STATE_TRANSITION(level, portName, currentState, nextState) \ - do { \ - MUXLOG##level(boost::format("%s: (P: %s, M: %s, L: %s) -> (P: %s, M: %s, L: %s)") % \ - portName % \ - mLinkProberStateName[ps(currentState)] % \ - mMuxStateName[ms(currentState)] % \ - mLinkStateName[ls(currentState)] % \ - mLinkProberStateName[ps(nextState)] % \ - mMuxStateName[ms(nextState)] % \ - mLinkStateName[ls(nextState)] \ - ); \ - } while (0) - -#define LOGWARNING_MUX_STATE_TRANSITION(portName, currentState, nextState) \ - LOG_MUX_STATE_TRANSITION(WARNING, portName, currentState, nextState) - -#define LOGINFO_MUX_STATE_TRANSITION(portName, currentState, nextState) \ - LOG_MUX_STATE_TRANSITION(INFO, portName, currentState, nextState) - -#define MUXLOGTIMEOUT(portname, msg, currentState) \ - do { \ - MUXLOGWARNING(boost::format("%s: %s, current state: (P: %s, M: %s, L: %s)") % \ - portname % \ - msg % \ - mLinkProberStateName[ps(currentState)] % \ - mMuxStateName[ms(currentState)] % \ - mLinkStateName[ls(currentState)] \ - ); \ - } while (0) - -namespace link_manager -{ - -constexpr auto MAX_BACKOFF_FACTOR = 8; - -LinkManagerStateMachine::TransitionFunction - LinkManagerStateMachine::mStateTransitionHandler[link_prober::LinkProberState::Label::Count] - [mux_state::MuxState::Label::Count] - [link_state::LinkState::Label::Count]; - -LinkProberEvent LinkManagerStateMachine::mLinkProberEvent; -MuxStateEvent LinkManagerStateMachine::mMuxStateEvent; -LinkStateEvent LinkManagerStateMachine::mLinkStateEvent; - -std::vector LinkManagerStateMachine::mLinkProberStateName = {"Active", "Standby", "Unknown", "Wait"}; -std::vector LinkManagerStateMachine::mMuxStateName = {"Active", "Standby", "Unknown", "Error", "Wait"}; -std::vector LinkManagerStateMachine::mLinkStateName = {"Up", "Down"}; -std::vector LinkManagerStateMachine::mLinkHealthName = {"Uninitialized", "Unhealthy", "Healthy"}; - -// -// ---> LinkManagerStateMachine( -// mux::MuxPort *muxPortPtr, -// boost::asio::io_service::strand &strand, -// common::MuxPortConfig &muxPortConfig -// ); -// -// class constructor -// -LinkManagerStateMachine::LinkManagerStateMachine( - mux::MuxPort *muxPortPtr, - boost::asio::io_service::strand &strand, - common::MuxPortConfig &muxPortConfig -) : - StateMachine(strand, muxPortConfig), - mMuxPortPtr(muxPortPtr), - mLinkProberStateMachine(*this, strand, muxPortConfig, ps(mCompositeState)), - mMuxStateMachine(*this, strand, muxPortConfig, ms(mCompositeState)), - mLinkStateMachine(*this, strand, muxPortConfig, ls(mCompositeState)), - mDeadlineTimer(strand.context()), - mWaitTimer(strand.context()) -{ - assert(muxPortPtr != nullptr); - mMuxStateMachine.setWaitStateCause(mux_state::WaitState::WaitStateCause::SwssUpdate); - mMuxPortPtr->setMuxLinkmgrState(mLabel); -} - -// -// ---> initializeTransitionFunctionTable() -// -// initialize static transition function table -// -void LinkManagerStateMachine::initializeTransitionFunctionTable() -{ - MUXLOGWARNING("Initializing State Transition Table..."); - for (uint8_t linkProberState = link_prober::LinkProberState::Label::Active; - linkProberState < link_prober::LinkProberState::Label::Count; linkProberState++) { - for (uint8_t muxState = mux_state::MuxState::Label::Active; - muxState < mux_state::MuxState::Label::Count; muxState++) { - for (uint8_t linkState = link_state::LinkState::Label::Up; - linkState < link_state::LinkState::Label::Count; linkState++) { - mStateTransitionHandler[linkProberState][muxState][linkState] = - boost::bind( - &LinkManagerStateMachine::noopTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - } - } - } - - mStateTransitionHandler[link_prober::LinkProberState::Label::Standby] - [mux_state::MuxState::Label::Active] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberStandbyMuxActiveLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Unknown] - [mux_state::MuxState::Label::Active] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberUnknownMuxActiveLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Active] - [mux_state::MuxState::Label::Standby] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberActiveMuxStandbyLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Unknown] - [mux_state::MuxState::Label::Standby] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberUnknownMuxStandbyLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Active] - [mux_state::MuxState::Label::Unknown] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberActiveMuxUnknownLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Standby] - [mux_state::MuxState::Label::Unknown] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberStandbyMuxUnknownLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Unknown] - [mux_state::MuxState::Label::Unknown] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberUnknownMuxUnknownLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Active] - [mux_state::MuxState::Label::Error] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberActiveMuxErrorLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Standby] - [mux_state::MuxState::Label::Error] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberStandbyMuxErrorLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Wait] - [mux_state::MuxState::Label::Active] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberWaitMuxActiveLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Wait] - [mux_state::MuxState::Label::Standby] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberWaitMuxStandbyLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Wait] - [mux_state::MuxState::Label::Unknown] - [link_state::LinkState::Label::Up] = - boost::bind( - &LinkManagerStateMachine::LinkProberWaitMuxUnknownLinkUpTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Unknown] - [mux_state::MuxState::Label::Active] - [link_state::LinkState::Label::Down] = - boost::bind( - &LinkManagerStateMachine::LinkProberUnknownMuxActiveLinkDownTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Unknown] - [mux_state::MuxState::Label::Standby] - [link_state::LinkState::Label::Down] = - boost::bind( - &LinkManagerStateMachine::LinkProberUnknownMuxStandbyLinkDownTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Unknown] - [mux_state::MuxState::Label::Unknown] - [link_state::LinkState::Label::Down] = - boost::bind( - &LinkManagerStateMachine::LinkProberUnknownMuxUnknownLinkDownTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Wait] - [mux_state::MuxState::Label::Active] - [link_state::LinkState::Label::Down] = - boost::bind( - &LinkManagerStateMachine::LinkProberWaitMuxActiveLinkDownTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Wait] - [mux_state::MuxState::Label::Standby] - [link_state::LinkState::Label::Down] = - boost::bind( - &LinkManagerStateMachine::LinkProberWaitMuxStandbyLinkDownTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); - mStateTransitionHandler[link_prober::LinkProberState::Label::Wait] - [mux_state::MuxState::Label::Unknown] - [link_state::LinkState::Label::Down] = - boost::bind( - &LinkManagerStateMachine::LinkProberWaitMuxUnknownLinkDownTransitionFunction, - boost::placeholders::_1, - boost::placeholders::_2 - ); -} - -// -// ---> setLabel(Label label); -// -// sets linkmgr State db state -// -void LinkManagerStateMachine::setLabel(Label label) { - if (mLabel != label) { - mLabel = label; - mMuxPortPtr->setMuxLinkmgrState(label); - - MUXLOGWARNING(boost::format("%s: Linkmgrd state is: %s %s") % - mMuxPortConfig.getPortName() % - mMuxStateName[ms(mCompositeState)] % - mLinkHealthName[static_cast (label)] - ); - } -}; - -// -// ---> enterLinkProberState(CompositeState &nextState, link_prober::LinkProberState::Label label); -// -// force LinkProberState to switch state -// -void LinkManagerStateMachine::enterLinkProberState(CompositeState &nextState, link_prober::LinkProberState::Label label) -{ - mLinkProberStateMachine.enterState(label); - ps(nextState) = label; -} - -// -// ---> enterMuxState(CompositeState &nextState, mux_state::MuxState::Label label); -// -// force MuxState to switch state -// -void LinkManagerStateMachine::enterMuxState(CompositeState &nextState, mux_state::MuxState::Label label) -{ - mMuxStateMachine.enterState(label); - ms(nextState) = label; -} - -// -// ---> enterLinkState(CompositeState &nextState, link_state::LinkState::Label label); -// -// force LinkState to switch state -// -void LinkManagerStateMachine::enterLinkState(CompositeState &nextState, link_state::LinkState::Label label) -{ - mLinkStateMachine.enterState(label); - ls(nextState) = label; -} - -// -// ---> enterMuxWaitState(CompositeState &nextState); -// -// force MuxState to switch to WaitState -// -void LinkManagerStateMachine::enterMuxWaitState(CompositeState &nextState) -{ - enterMuxState(nextState, mux_state::MuxState::Label::Wait); - mMuxStateMachine.setWaitStateCause(mux_state::WaitState::WaitStateCause::DriverUpdate); - mMuxPortPtr->probeMuxState(); - startMuxWaitTimer(); -} - -// -// ---> switchMuxState(CompositeState &nextState, mux_state::MuxState::Label label, bool forceSwitch); -// -// switch Mux to switch via xcvrd to state label provider -// -void LinkManagerStateMachine::switchMuxState( - CompositeState &nextState, - mux_state::MuxState::Label label, - bool forceSwitch -) -{ - if (forceSwitch || mMuxPortConfig.getMode() == common::MuxPortConfig::Mode::Auto) { - MUXLOGWARNING(boost::format("%s: Switching MUX state to '%s'") % - mMuxPortConfig.getPortName() % - mMuxStateName[label] - ); - enterMuxState(nextState, mux_state::MuxState::Label::Wait); - mMuxStateMachine.setWaitStateCause(mux_state::WaitState::WaitStateCause::SwssUpdate); - mMuxPortPtr->postMetricsEvent(Metrics::SwitchingStart, label); - mMuxPortPtr->setMuxState(label); - mDeadlineTimer.cancel(); - startMuxWaitTimer(); - } else { - enterMuxWaitState(nextState); - } -} - -// -// ---> handleSwssBladeIpv4AddressUpdate(boost::asio::ip::address address); -// -// initialize LinkProber component. Note if this is the last component to be initialized, -// state machine will be activated -// -void LinkManagerStateMachine::handleSwssBladeIpv4AddressUpdate(boost::asio::ip::address address) -{ - if (!mComponentInitState.test(LinkProberComponent)) { - mMuxPortConfig.setBladeIpv4Address(address); - - try { - mLinkProberPtr = std::make_shared ( - mMuxPortConfig, - getStrand().context(), - mLinkProberStateMachine - ); - mInitializeProberFnPtr = boost::bind( - &link_prober::LinkProber::initialize, mLinkProberPtr.get() - ); - mStartProbingFnPtr = boost::bind( - &link_prober::LinkProber::startProbing, mLinkProberPtr.get() - ); - mUpdateEthernetFrameFnPtr = boost::bind( - &link_prober::LinkProber::updateEthernetFrame, mLinkProberPtr.get() - ); - mProbePeerTorFnPtr = boost::bind( - &link_prober::LinkProber::probePeerTor, mLinkProberPtr.get() - ); - mSuspendTxFnPtr = boost::bind( - &link_prober::LinkProber::suspendTxProbes, mLinkProberPtr.get(), boost::placeholders::_1 - ); - mResumeTxFnPtr = boost::bind( - &link_prober::LinkProber::resumeTxProbes, mLinkProberPtr.get() - ); - mSendPeerSwitchCommandFnPtr = boost::bind( - &link_prober::LinkProber::sendPeerSwitchCommand, mLinkProberPtr.get() - ); - mComponentInitState.set(LinkProberComponent); - - activateStateMachine(); - } - catch (const std::bad_alloc &ex) { - std::ostringstream errMsg; - errMsg << "Failed allocate memory. Exception details: " << ex.what(); - - throw MUX_ERROR(BadAlloc, errMsg.str()); - } - } else if (address != mMuxPortConfig.getBladeIpv4Address()){ - mMuxPortConfig.setBladeIpv4Address(address); - - mUpdateEthernetFrameFnPtr(); - } -} - -// -// ---> activateStateMachine(); -// -// activate the state machine by starting the LinkProber. This should be done after all -// components have been initialized. -// -void LinkManagerStateMachine::activateStateMachine() -{ - if (mComponentInitState.all()) { - std::array macAddress = mMuxPortConfig.getBladeMacAddress(); - std::array macAddressStr = {0}; - - snprintf( - macAddressStr.data(), macAddressStr.size(), "%02x:%02x:%02x:%02x:%02x:%02x", - macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5] - ); - - MUXLOGWARNING(boost::format("%s: MUX port link prober initialized with server IP: %s, server MAC: %s") % - mMuxPortConfig.getPortName() % - mMuxPortConfig.getBladeIpv4Address().to_string() % - macAddressStr.data() - ); - // make link prober state match the MUX state since the state machine is activated for the first time - CompositeState nextState = mCompositeState; - initLinkProberState(nextState); - LOGWARNING_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState); - mCompositeState = nextState; - - mInitializeProberFnPtr(); - mStartProbingFnPtr(); - - updateMuxLinkmgrState(); - } -} - -// -// ---> handleStateChange(LinkProberEvent &event, link_prober::LinkProberState::Label state); -// -// handles LinkProverEvent -// -void LinkManagerStateMachine::handleStateChange(LinkProberEvent &event, link_prober::LinkProberState::Label state) -{ - if ((dynamic_cast (mLinkProberStateMachine.getCurrentState()))->getStateLabel() == state) { - MUXLOGWARNING(boost::format("%s: Received link prober event, new state: %s") % - mMuxPortConfig.getPortName() % - mLinkProberStateName[state] - ); - - CompositeState nextState = mCompositeState; - ps(nextState) = state; - mStateTransitionHandler[ps(nextState)][ms(nextState)][ls(nextState)](this, nextState); - LOGWARNING_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState); - mCompositeState = nextState; - } - - if (ps(mCompositeState) != link_prober::LinkProberState::Unknown) { - mResumeTxFnPtr(); - } - - updateMuxLinkmgrState(); -} - -// -// ---> handleStateChange(MuxStateEvent &event, mux_state::MuxState::Label state); -// -// handles MuxStateEvent -// -void LinkManagerStateMachine::handleStateChange(MuxStateEvent &event, mux_state::MuxState::Label state) -{ - if ((dynamic_cast (mMuxStateMachine.getCurrentState()))->getStateLabel() == state) { - MUXLOGINFO(boost::format("%s: Received mux state event, new state: %s") % - mMuxPortConfig.getPortName() % - mMuxStateName[state] - ); - - CompositeState nextState = mCompositeState; - ms(nextState) = state; - mStateTransitionHandler[ps(nextState)][ms(nextState)][ls(nextState)](this, nextState); - LOGINFO_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState); - mCompositeState = nextState; - } - - if (ms(mCompositeState) != mux_state::MuxState::Wait) { - // Verify if state db MUX state matches the driver/current MUX state - mMuxPortPtr->getMuxState(); - } - - if (ms(mCompositeState) != mux_state::MuxState::Unknown) { - mMuxUnknownBackoffFactor = 1; - } - - updateMuxLinkmgrState(); -} - -// -// ---> handleStateChange(LinkStateEvent &event, link_state::LinkState::Label state); -// -// handles LinkStateEvent -// -void LinkManagerStateMachine::handleStateChange(LinkStateEvent &event, link_state::LinkState::Label state) -{ - if ((dynamic_cast (mLinkStateMachine.getCurrentState()))->getStateLabel() == state) { - MUXLOGWARNING(boost::format("%s: Received link state event, new state: %s") % - mMuxPortConfig.getPortName() % - mLinkStateName[state] - ); - - CompositeState nextState = mCompositeState; - ls(nextState) = state; - if (ls(mCompositeState) == link_state::LinkState::Down && - ls(nextState) == link_state::LinkState::Up) { - // start fresh when the link transition from Down to UP state - // and so the link prober will initially match the MUX state - // There is a problem with this approach as it will hide link flaps that result in lost heart-beats. - initLinkProberState(nextState); -// enterMuxWaitState(nextState); - } else if (ls(mCompositeState) == link_state::LinkState::Up && - ls(nextState) == link_state::LinkState::Down && - ms(mCompositeState) == mux_state::MuxState::Label::Active) { - // switch MUX to standby since we are entering LinkDown state - switchMuxState(nextState, mux_state::MuxState::Label::Standby); - } else { - mStateTransitionHandler[ps(nextState)][ms(nextState)][ls(nextState)](this, nextState); - } - LOGWARNING_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState); - mCompositeState = nextState; - } - - updateMuxLinkmgrState(); -} - -// -// ---> handleGetServerMacAddressNotification(std::array address); -// -// handle get Server MAC address -// -void LinkManagerStateMachine::handleGetServerMacAddressNotification(std::array address) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - if (address != mMuxPortConfig.getBladeMacAddress()) { - mMuxPortConfig.setBladeMacAddress(address); - if (mUpdateEthernetFrameFnPtr) { - mUpdateEthernetFrameFnPtr(); - } else { - std::array addressStr = {0}; - snprintf( - addressStr.data(), addressStr.size(), "%02x:%02x:%02x:%02x:%02x:%02x", - address[0], address[1], address[2], address[3], address[4], address[5] - ); - - MUXLOGERROR(boost::format("%s: failed to update Ethernet frame with mac '%s', link prober init state: %d") % - mMuxPortConfig.getPortName() % - addressStr.data() % - mComponentInitState.test(LinkProberComponent) - ); - } - } -} - -// -// ---> handleGetMuxStateNotification(mux_state::MuxState::Label label); -// -// handle get MUX state notification -// -void LinkManagerStateMachine::handleGetMuxStateNotification(mux_state::MuxState::Label label) -{ - MUXLOGINFO(boost::format("%s: state db mux state: %s") % mMuxPortConfig.getPortName() % mMuxStateName[label]); - - if (mComponentInitState.all() && ms(mCompositeState) != label && - ms(mCompositeState) != mux_state::MuxState::Wait && - ms(mCompositeState) != mux_state::MuxState::Error) { - // notify swss of mux state change - MUXLOGWARNING(boost::format("%s: Switching MUX state from '%s' to '%s' to match linkmgrd/xcvrd state") % - mMuxPortConfig.getPortName() % - mMuxStateName[label] % - mMuxStateName[ms(mCompositeState)] - ); - switchMuxState(mCompositeState, ms(mCompositeState), true); - } -} - -// -// ---> handleProbeMuxStateNotification(mux_state::MuxState::Label label); -// -// handle MUX state notification. Source of notification could be app_db via xcvrd -// -void LinkManagerStateMachine::handleProbeMuxStateNotification(mux_state::MuxState::Label label) -{ - MUXLOGINFO(boost::format("%s: app db mux state: %s") % mMuxPortConfig.getPortName() % mMuxStateName[label]); - - mWaitTimer.cancel(); - - if (mComponentInitState.all()) { - if (mMuxStateMachine.getWaitStateCause() != mux_state::WaitState::WaitStateCause::DriverUpdate) { - MUXLOGERROR(boost::format("%s: Received unsolicited MUX state probe notification!") % - mMuxPortConfig.getPortName() - ); - } - - postMuxStateEvent(label); - } else if (label != mux_state::MuxState::Unknown) { - MUXLOGWARNING(boost::format("%s: Initializing MUX state '%s' to match xcvrd state") % - mMuxPortConfig.getPortName() % - mMuxStateName[label] - ); - - // mux state was probed during initialization, update the mux state - enterMuxState(mCompositeState, mux_state::MuxState::Label::Wait); - mMuxStateMachine.setWaitStateCause(mux_state::WaitState::WaitStateCause::SwssUpdate); - mMuxPortPtr->setMuxState(label); - } else { - MUXLOGWARNING(boost::format("%s: xcvrd reports MUX state as '%s' during init. phase! Is there a functioning MUX?") % - mMuxPortConfig.getPortName() % - mMuxStateName[label] - ); - - enterMuxState(mCompositeState, label); - mComponentInitState.set(MuxStateComponent); - activateStateMachine(); - } -} - -// -// ---> handleMuxStateNotification(mux_state::MuxState::Label label); -// -// handle MUX state notification -// -void LinkManagerStateMachine::handleMuxStateNotification(mux_state::MuxState::Label label) -{ - MUXLOGWARNING(boost::format("%s: state db mux state: %s") % mMuxPortConfig.getPortName() % mMuxStateName[label]); - - mWaitTimer.cancel(); - - if (mComponentInitState.all()) { - if (mMuxStateMachine.getWaitStateCause() != mux_state::WaitState::WaitStateCause::SwssUpdate || - ms(mCompositeState) != mux_state::MuxState::Wait) { - MUXLOGERROR(boost::format("%s: Received unsolicited MUX state change notification!") % - mMuxPortConfig.getPortName() - ); - } - mProbePeerTorFnPtr(); - postMuxStateEvent(label); - mMuxPortPtr->postMetricsEvent(Metrics::SwitchingEnd, label); - } else if (label == mux_state::MuxState::Unknown) { - // state db may not have been initialized with up-to-date mux state - // probe xcvrd to read the current mux state - enterMuxWaitState(mCompositeState); - } else { - enterMuxState(mCompositeState, label); - - mComponentInitState.set(MuxStateComponent); - activateStateMachine(); - } -} - -// -// ---> handleSwssLinkStateNotification(const link_state::LinkState::Label label); -// -// handle link state change notification -// -void LinkManagerStateMachine::handleSwssLinkStateNotification(const link_state::LinkState::Label label) -{ - MUXLOGINFO(boost::format("%s: state db link state: %s") % mMuxPortConfig.getPortName() % mLinkStateName[label]); - - if (mComponentInitState.all()) { - if (label == link_state::LinkState::Label::Up) { - mLinkStateMachine.postLinkStateEvent(link_state::LinkStateMachine::getUpEvent()); - } else if (label == link_state::LinkState::Label::Down) { - mLinkStateMachine.postLinkStateEvent(link_state::LinkStateMachine::getDownEvent()); - } - } else { - enterLinkState(mCompositeState, label); - - mComponentInitState.set(LinkStateComponent); - activateStateMachine(); - } -} - -// -// ---> handleMuxConfigNotification(const common::MuxPortConfig::Mode mode); -// -// handle MUX configuration change notification -// -void LinkManagerStateMachine::handleMuxConfigNotification(const common::MuxPortConfig::Mode mode) -{ - if (mComponentInitState.all()) { - if (mode == common::MuxPortConfig::Mode::Active && - ms(mCompositeState) != mux_state::MuxState::Label::Active && - ms(mCompositeState) != mux_state::MuxState::Label::Wait) { - CompositeState nextState = mCompositeState; - enterLinkProberState(nextState, link_prober::LinkProberState::Wait); - switchMuxState(nextState, mux_state::MuxState::Label::Active); - LOGWARNING_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState); - mCompositeState = nextState; - } else if(mode == common::MuxPortConfig::Mode::Standby && - ms(mCompositeState) != mux_state::MuxState::Label::Standby && - ms(mCompositeState) != mux_state::MuxState::Label::Wait) { - mSendPeerSwitchCommandFnPtr(); - } else { - mMuxStateMachine.setWaitStateCause(mux_state::WaitState::WaitStateCause::DriverUpdate); - mMuxPortPtr->probeMuxState(); - } - - updateMuxLinkmgrState(); - } - - mMuxPortConfig.setMode(mode); -} - -// -// ---> handleSuspendTimerExpiry(); -// -// handle suspend timer expiry notification from LinkProber -// -void LinkManagerStateMachine::handleSuspendTimerExpiry() -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - // Note: suspend timer is started when Mux state is active and link is in unknown state. - // If standby (peer) ToR fails to pull the link, this ToR will loop between those states - // Prober: Unknown, Mux: Active, Link: Up --Suspend Timer Expires--> Wait, Wait, UP -> (probe) - // Unknown, Active, Up or Unknown, Standby, UP or Unknown, Unknown, UP - if (ps(mCompositeState) == link_prober::LinkProberState::Label::Unknown && - ms(mCompositeState) == mux_state::MuxState::Label::Active && - ls(mCompositeState) == link_state::LinkState::Label::Up) { - CompositeState currState = mCompositeState; - enterMuxWaitState(mCompositeState); - LOGINFO_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), currState, mCompositeState); - } -} - -// -// ---> handleSwitchActiveCommandCompletion(); -// -// handle completion of sending switch command to peer ToR -// -void LinkManagerStateMachine::handleSwitchActiveCommandCompletion() -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - if (ms(mCompositeState) != mux_state::MuxState::Label::Standby && - ms(mCompositeState) != mux_state::MuxState::Label::Wait) { - CompositeState nextState = mCompositeState; - enterLinkProberState(nextState, link_prober::LinkProberState::Wait); - switchMuxState(nextState, mux_state::MuxState::Label::Standby); - LOGWARNING_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState); - mCompositeState = nextState; - } -} - -// -// ---> handleSwitchActiveRequestEvent(); -// -// handle switch active request from peer ToR -// -void LinkManagerStateMachine::handleSwitchActiveRequestEvent() -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - if (ms(mCompositeState) != mux_state::MuxState::Label::Active && - ms(mCompositeState) != mux_state::MuxState::Label::Wait) { - CompositeState nextState = mCompositeState; - enterLinkProberState(nextState, link_prober::LinkProberState::Wait); - switchMuxState(nextState, mux_state::MuxState::Label::Active); - LOGWARNING_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), mCompositeState, nextState); - mCompositeState = nextState; - } -} - -// -// ---> updateMuxLinkmgrState(); -// -// Update State DB MUX LinkMgr state -// -void LinkManagerStateMachine::updateMuxLinkmgrState() -{ - Label label = Label::Unhealthy; - if (ls(mCompositeState) == link_state::LinkState::Label::Up && - ((ps(mCompositeState) == link_prober::LinkProberState::Label::Active && - ms(mCompositeState) == mux_state::MuxState::Label::Active) || - (ps(mCompositeState) == link_prober::LinkProberState::Label::Standby && - ms(mCompositeState) == mux_state::MuxState::Label::Standby))) { - label = Label::Healthy; - } - - setLabel(label); -} - -// -// ---> startMuxProbeTimer(uint32_t factor); -// -// start a timer to monitor the MUX state -// -void LinkManagerStateMachine::startMuxProbeTimer(uint32_t factor) -{ - mDeadlineTimer.expires_from_now(boost::posix_time::milliseconds( - factor * mMuxPortConfig.getNegativeStateChangeRetryCount() * mMuxPortConfig.getTimeoutIpv4_msec() - )); - mDeadlineTimer.async_wait(getStrand().wrap(boost::bind( - &LinkManagerStateMachine::handleMuxProbeTimeout, - this, - boost::asio::placeholders::error - ))); -} - -// -// ---> handleMuxProbeTimeout(boost::system::error_code errorCode); -// -// handle when LinkProber heartbeats were lost due link down, bad cable or server down -// -void LinkManagerStateMachine::handleMuxProbeTimeout(boost::system::error_code errorCode) -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - if (errorCode == boost::system::errc::success && - (ps(mCompositeState) == link_prober::LinkProberState::Label::Wait || - ms(mCompositeState) == mux_state::MuxState::Label::Unknown || - ls(mCompositeState) == link_state::LinkState::Label::Down)) { - CompositeState currState = mCompositeState; - enterMuxWaitState(mCompositeState); - LOGINFO_MUX_STATE_TRANSITION(mMuxPortConfig.getPortName(), currState, mCompositeState); - } -} - -// -// ---> startMuxWaitTimer(uint32_t factor); -// -// start a timer to monitor the MUX state -// -void LinkManagerStateMachine::startMuxWaitTimer(uint32_t factor) -{ - mWaitTimer.expires_from_now(boost::posix_time::milliseconds( - factor * mMuxPortConfig.getNegativeStateChangeRetryCount() * mMuxPortConfig.getTimeoutIpv4_msec() - )); - mWaitTimer.async_wait(getStrand().wrap(boost::bind( - &LinkManagerStateMachine::handleMuxWaitTimeout, - this, - boost::asio::placeholders::error - ))); -} - -// -// ---> handleMuxWaitTimeout(boost::system::error_code errorCode); -// -// handle when xcrvrd/orchagent has timed out responding to linkmgrd. -// -void LinkManagerStateMachine::handleMuxWaitTimeout(boost::system::error_code errorCode) -{ - if (errorCode == boost::system::errc::success) { - if (mMuxStateMachine.getWaitStateCause() == mux_state::WaitState::WaitStateCause::SwssUpdate) { - MUXLOGTIMEOUT(mMuxPortConfig.getPortName(), "orchagent timed out responding to linkmgrd", mCompositeState); - } else if (mMuxStateMachine.getWaitStateCause() == mux_state::WaitState::WaitStateCause::DriverUpdate) { - MUXLOGTIMEOUT(mMuxPortConfig.getPortName(), "xcvrd timed out responding to linkmgrd", mCompositeState); - } else { - MUXLOGTIMEOUT(mMuxPortConfig.getPortName(), "Unknown timeout reason!!!", mCompositeState); - } - startMuxWaitTimer(MAX_BACKOFF_FACTOR); - } -} - -// -// ---> initLinkProberState(CompositeState &compositeState); -// -// initialize LinkProberState when configuring the composite state machine -// -void LinkManagerStateMachine::initLinkProberState(CompositeState &compositeState) -{ - switch (ms(compositeState)) { - case mux_state::MuxState::Label::Active: - enterLinkProberState(compositeState, link_prober::LinkProberState::Label::Active); - break; - case mux_state::MuxState::Label::Standby: - enterLinkProberState(compositeState, link_prober::LinkProberState::Label::Standby); - break; - case mux_state::MuxState::Label::Unknown: - enterLinkProberState(compositeState, link_prober::LinkProberState::Label::Unknown); - break; - case mux_state::MuxState::Label::Error: - enterLinkProberState(compositeState, link_prober::LinkProberState::Label::Wait); - break; - case mux_state::MuxState::Label::Wait: - enterLinkProberState(compositeState, link_prober::LinkProberState::Label::Unknown); - break; - default: - break; - } -} - -// -// ---> postMuxStateEvent(mux_state::MuxState::Label label) -// -// post event to MUX state machine to change state -// -void LinkManagerStateMachine::postMuxStateEvent(mux_state::MuxState::Label label) -{ - switch (label) { - case mux_state::MuxState::Label::Active: - mMuxStateMachine.postMuxStateEvent(mux_state::MuxStateMachine::getActiveEvent()); - break; - case mux_state::MuxState::Label::Standby: - mMuxStateMachine.postMuxStateEvent(mux_state::MuxStateMachine::getStandbyEvent()); - break; - case mux_state::MuxState::Label::Unknown: - mMuxStateMachine.postMuxStateEvent(mux_state::MuxStateMachine::getUnknownEvent()); - break; - case mux_state::MuxState::Label::Error: - mMuxStateMachine.postMuxStateEvent(mux_state::MuxStateMachine::getErrorEvent()); - break; - default: - break; - } -} - -// -// ---> noopTransitionFunction(CompositeState &nextState); -// -// No-op transition function -// -void LinkManagerStateMachine::noopTransitionFunction(CompositeState &nextState) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); -} - -// -// ---> LinkProberStandbyMuxActiveLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberStandby, MuxActive, LinkUp} state -// -void LinkManagerStateMachine::LinkProberStandbyMuxActiveLinkUpTransitionFunction( - CompositeState &nextState -) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - // Probe the MUX state as internal MUX state is active while LP reports standby link - enterMuxWaitState(nextState); -} - -// -// ---> LinkProberUnknownMuxActiveLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberUnknown, MuxActive, LinkUp} state -// -void LinkManagerStateMachine::LinkProberUnknownMuxActiveLinkUpTransitionFunction( - CompositeState &nextState -) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - // Suspend TX probes to help peer ToR takes over in case active link is bad - mSuspendTxFnPtr(mMuxPortConfig.getLinkWaitTimeout_msec()); - mWaitActiveUpCount = 0; -} - -// -// ---> LinkProberActiveMuxStandbyLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberActive, MuxStandby, LinkUp} state -// -void LinkManagerStateMachine::LinkProberActiveMuxStandbyLinkUpTransitionFunction( - CompositeState &nextState -) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - enterMuxWaitState(nextState); -} - -// -// ---> LinkProberUnknownMuxStandbyLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberUnknown, MuxStandby, LinkUp} state -// -void LinkManagerStateMachine::LinkProberUnknownMuxStandbyLinkUpTransitionFunction( - CompositeState &nextState -) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - enterLinkProberState(nextState, link_prober::LinkProberState::Wait); - - // Start switching MUX to active state as we lost HB from active ToR - switchMuxState(nextState, mux_state::MuxState::Label::Active); - mDeadlineTimer.cancel(); - mWaitActiveUpCount = 0; -} - -// -// ---> LinkProberActiveMuxUnknownLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberActive, MuxUnknown, LinkUp} state -// -void LinkManagerStateMachine::LinkProberActiveMuxUnknownLinkUpTransitionFunction( - CompositeState &nextState -) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - enterMuxWaitState(nextState); -} - -// -// ---> LinkProberStandbyMuxUnknownLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberStandby, MuxUnknown, LinkUp} state -// -void LinkManagerStateMachine::LinkProberStandbyMuxUnknownLinkUpTransitionFunction( - CompositeState &nextState -) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - enterMuxWaitState(nextState); -} - -// -// ---> LinkProberUnknownMuxUnknownLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberUnknown, MuxUnknown, LinkUp} state -// -void LinkManagerStateMachine::LinkProberUnknownMuxUnknownLinkUpTransitionFunction( - CompositeState &nextState -) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(mMuxUnknownBackoffFactor); - mMuxUnknownBackoffFactor <<= 1; - mMuxUnknownBackoffFactor = mMuxUnknownBackoffFactor > MAX_BACKOFF_FACTOR ? MAX_BACKOFF_FACTOR : mMuxUnknownBackoffFactor; -} - -// -// ---> LinkProberActiveMuxErrorLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberActive, MuxError, LinkUp} state -// -void LinkManagerStateMachine::LinkProberActiveMuxErrorLinkUpTransitionFunction( - CompositeState &nextState -) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - if ((ps(mCompositeState) != ps(nextState)) && - (ps(nextState) == link_prober::LinkProberState::Label::Active || - ps(nextState) == link_prober::LinkProberState::Label::Standby)) { - enterMuxWaitState(nextState); - } -} - -// -// ---> LinkProberStandbyMuxErrorLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberStandby, MuxError, LinkUp} state -// -void LinkManagerStateMachine::LinkProberStandbyMuxErrorLinkUpTransitionFunction( - CompositeState &nextState -) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - if ((ps(mCompositeState) != ps(nextState)) && - (ps(nextState) == link_prober::LinkProberState::Label::Active || - ps(nextState) == link_prober::LinkProberState::Label::Standby)) { - enterMuxWaitState(nextState); - } -} - -// -// ---> LinkProberWaitMuxActiveLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberWait, MuxActive, LinkUp} state -// -void LinkManagerStateMachine::LinkProberWaitMuxActiveLinkUpTransitionFunction(CompositeState &nextState) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(); - - if (mWaitActiveUpCount++ & 0x1) { - mSuspendTxFnPtr(mMuxPortConfig.getLinkWaitTimeout_msec()); - } -} - -// -// ---> LinkProberWaitMuxStandbyLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberWait, MuxStandby, LinkUp} state -// -void LinkManagerStateMachine::LinkProberWaitMuxStandbyLinkUpTransitionFunction(CompositeState &nextState) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(); -} - -// -// ---> LinkProberWaitMuxUnknownLinkUpTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberWait, MuxUnknown, LinkUp} state -// -void LinkManagerStateMachine::LinkProberWaitMuxUnknownLinkUpTransitionFunction(CompositeState &nextState) -{ - MUXLOGERROR(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(mMuxUnknownBackoffFactor); - mMuxUnknownBackoffFactor <<= 1; - mMuxUnknownBackoffFactor = mMuxUnknownBackoffFactor > MAX_BACKOFF_FACTOR ? MAX_BACKOFF_FACTOR : mMuxUnknownBackoffFactor; -} - -// -// ---> LinkProberUnknownMuxActiveLinkDownTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberUnknown, MuxActive, LinkDown} state -// -void LinkManagerStateMachine::LinkProberUnknownMuxActiveLinkDownTransitionFunction(CompositeState &nextState) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(); -} - -// -// ---> LinkProberUnknownMuxStandbyLinkDownTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberUnknown, MuxStandby, LinkDown} state -// -void LinkManagerStateMachine::LinkProberUnknownMuxStandbyLinkDownTransitionFunction(CompositeState &nextState) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(); -} - -// -// ---> LinkProberUnknownMuxUnknownLinkDownTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberUnknown, MuxUnknown, LinkDown} state -// -void LinkManagerStateMachine::LinkProberUnknownMuxUnknownLinkDownTransitionFunction(CompositeState &nextState) -{ - MUXLOGERROR(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(mMuxUnknownBackoffFactor); - mMuxUnknownBackoffFactor <<= 1; - mMuxUnknownBackoffFactor = mMuxUnknownBackoffFactor > MAX_BACKOFF_FACTOR ? MAX_BACKOFF_FACTOR : mMuxUnknownBackoffFactor; -} - -// -// ---> LinkProberWaitMuxActiveLinkDownTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberWait, MuxActive, LinkDown} state -// -void LinkManagerStateMachine::LinkProberWaitMuxActiveLinkDownTransitionFunction(CompositeState &nextState) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(); -} - -// -// ---> LinkProberWaitMuxStandbyLinkDownTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberWait, MuxStandby, LinkDown} state -// -void LinkManagerStateMachine::LinkProberWaitMuxStandbyLinkDownTransitionFunction(CompositeState &nextState) -{ - MUXLOGINFO(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(); -} - -// -// ---> LinkProberWaitMuxUnknownLinkDownTransitionFunction(CompositeState &nextState); -// -// transition function when entering {LinkProberWait, MuxUnknown, LinkDown} state -// -void LinkManagerStateMachine::LinkProberWaitMuxUnknownLinkDownTransitionFunction(CompositeState &nextState) -{ - MUXLOGERROR(mMuxPortConfig.getPortName()); - - startMuxProbeTimer(mMuxUnknownBackoffFactor); - mMuxUnknownBackoffFactor <<= 1; - mMuxUnknownBackoffFactor = mMuxUnknownBackoffFactor > MAX_BACKOFF_FACTOR ? MAX_BACKOFF_FACTOR : mMuxUnknownBackoffFactor; -} - -} /* namespace link_manager */ diff --git a/src/linkmgrd/src/link_manager/LinkManagerStateMachine.h b/src/linkmgrd/src/link_manager/LinkManagerStateMachine.h deleted file mode 100644 index 82317422dfee..000000000000 --- a/src/linkmgrd/src/link_manager/LinkManagerStateMachine.h +++ /dev/null @@ -1,912 +0,0 @@ -/* - * LinkManagerStateMachine.h - * - * Created on: Oct 18, 2020 - * Author: tamer - */ - -#ifndef LINK_MANAGER_LINKMANAGERSTATEMACHINE_H_ -#define LINK_MANAGER_LINKMANAGERSTATEMACHINE_H_ - -#include -#include -#include -#include -#include -#include - -#include "link_prober/LinkProber.h" -#include "link_prober/LinkProberState.h" -#include "link_state/LinkState.h" -#include "link_state/LinkStateMachine.h" -#include "mux_state/MuxState.h" -#include "mux_state/MuxStateMachine.h" - -namespace test { -class FakeMuxPort; -class MuxManagerTest; -} - -namespace mux { -#define ps(compositeState) std::get<0>(compositeState) -#define ms(compositeState) std::get<1>(compositeState) -#define ls(compositeState) std::get<2>(compositeState) - -class MuxPort; -} - -namespace link_manager -{ - -/** - *@class LinkProberEvent - * - *@brief signals a LinkeProber event to the composite state machine - */ -class LinkProberEvent { -public: - LinkProberEvent() = default; - ~LinkProberEvent() = default; -}; - -/** - *@class MuxStateEvent - * - *@brief signals a MuxState event to the composite state machine - */ -class MuxStateEvent { -public: - MuxStateEvent() = default; - ~MuxStateEvent() = default; -}; - -/** - *@class LinkStateEvent - * - *@brief signals a LinkState event to the composite state machine - */ -class LinkStateEvent { -public: - LinkStateEvent() = default; - ~LinkStateEvent() = default; -}; - -/** - *@class LinkManagerStateMachine - * - *@brief Composite state machine of LinkProberState, MuxState, and LinkState - */ -class LinkManagerStateMachine: public common::StateMachine, - public std::enable_shared_from_this -{ -public: - /** - *@enum Label - * - *@brief Label corresponding to each LINKMGR Health State - */ - enum class Label { - Uninitialized, - Unhealthy, - Healthy, - - Count - }; - - /** - *@enum Metrics - * - *@brief Metrics Data to be written to MUX_METRICS state db table - */ - enum class Metrics { - SwitchingStart, - SwitchingEnd, - - Count - }; - -private: - /** - *@enum anonymous - * - *@brief used to reference bits corresponding to respective state machine init state - */ - enum { - LinkProberComponent, - MuxStateComponent, - LinkStateComponent, - - ComponentCount - }; - -public: - using CompositeState = std::tuple< - link_prober::LinkProberState::Label, - mux_state::MuxState::Label, - link_state::LinkState::Label - >; - using TransitionFunction = std::function; - -public: - /** - *@method LinkManagerStateMachine - * - *@brief class default constructor - */ - LinkManagerStateMachine() = delete; - - /** - *@method LinkManagerStateMachine - * - *@brief class copy constructor - * - *@param LinkManagerStateMachine (in) reference to LinkManagerStateMachine object to be copied - */ - LinkManagerStateMachine(const LinkManagerStateMachine &) = delete; - - /** - *@method LinkManagerStateMachine - * - *@brief class constructor - * - *@param muxPortPtr (in) pointer to container MuxPort object - *@param strand (in) boost serialization object - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - LinkManagerStateMachine( - mux::MuxPort *muxPortPtr, - boost::asio::io_service::strand &strand, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~LinkManagerStateMachine - * - *@brief class destructor - */ - virtual ~LinkManagerStateMachine() = default; - - /** - *@method initializeTransitionFunctionTable - * - *@brief initialize static transition function table - * - *@return none - */ - static void initializeTransitionFunctionTable(); - - /** - *@method getLinkProberEvent - * - *@brief getter for LinkProberEvent object - * - *@return reference to LinkProberEvent object - */ - static LinkProberEvent& getLinkProberEvent() {return mLinkProberEvent;}; - - /** - *@method getMuxStateEvent - * - *@brief getter for MuxStateEvent object - * - *@return reference to MuxStateEvent object - */ - static MuxStateEvent& getMuxStateEvent() {return mMuxStateEvent;}; - - /** - *@method getLinkStateEvent - * - *@brief getter for LinkStateEvent object - * - *@return reference to LinkStateEvent object - */ - static LinkStateEvent& getLinkStateEvent() {return mLinkStateEvent;}; - - /** - *@method getCompositeState - * - *@brief getter for CompositeState object - * - *@return reference to CompositeState object - */ - const CompositeState& getCompositeState() {return mCompositeState;}; - - /** - *@method getLinkProberStateMachine - * - *@brief getter for LinkProberStateMachine object - * - *@return reference to LinkProberStateMachine object - */ - link_prober::LinkProberStateMachine& getLinkProberStateMachine() {return mLinkProberStateMachine;}; - - /** - *@method getMuxStateMachine - * - *@brief getter for MuxStateMachine object - * - *@return reference to MuxStateMachine object - */ - mux_state::MuxStateMachine& getMuxStateMachine() {return mMuxStateMachine;}; - - /** - *@method getLinkStateMachine - * - *@brief getter for LinkStateMachine object - * - *@return reference to LinkStateMachine object - */ - link_state::LinkStateMachine& getLinkStateMachine() {return mLinkStateMachine;}; - -private: - /** - *@method setLabel - * - *@brief sets linkmgr State db state - * - *@return none - */ - inline void setLabel(Label label); - - /** - *@method enterLinkProberState - * - *@brief force LinkProberState to switch state - * - *@param nextState (in, out) reference to composite state, the state linkProber - * entry will be changed to align with state label provided - *@param label (in) state to switch to - * - *@return none - */ - inline void enterLinkProberState(CompositeState &nextState, link_prober::LinkProberState::Label label); - - /** - *@method enterMuxState - * - *@brief force MuxState to switch state - * - *@param nextState (in, out) reference to composite state, the state MuxState - * entry will be changed to align with state label provided - *@param label (in) state to switch to - * - *@return none - */ - inline void enterMuxState(CompositeState &nextState, mux_state::MuxState::Label label); - - /** - *@method enterLinkState - * - *@brief force LinkState to switch state - * - *@param nextState (in, out) reference to composite state, the state LinkState - * entry will be changed to align with state label provided - *@param label (in) state to switch to - * - *@return none - */ - inline void enterLinkState(CompositeState &nextState, link_state::LinkState::Label label); - - /** - *@method enterMuxWaitState - * - *@brief force MuxState to switch to WaitState - * - *@param nextState (in, out) reference to composite state, the state MuxState - * entry will be changed to WaitState - * - *@return none - */ - inline void enterMuxWaitState(CompositeState &nextState); - - /** - *@method switchMuxState - * - *@brief switch Mux to switch via xcvrd to state label provider - * - *@param nextState (in, out) reference to composite state, the state MuxState - * entry will be changed to align with state label provided - *@param label (in) state to switch to - *@param forceSwitch (in) Force switch mux state, used to match the driver state only - * - *@return none - */ - inline void switchMuxState(CompositeState &nextState, mux_state::MuxState::Label label, bool forceSwitch = false); - -public: - /** - *@method handleSwssBladeIpv4AddressUpdate - * - *@brief initialize LinkProber component. Note if this is the last component to be initialized, - * state machine will be activated - * - *@return none - */ - void handleSwssBladeIpv4AddressUpdate(boost::asio::ip::address address); - - /** - *@method activateStateMachine - * - *@brief activate the state machine by starting the LinkProber. This should be done after all - * components have been initialized. - * - *@return none - */ - void activateStateMachine(); - - /** - *@method handleStateChange - * - *@brief handles LinkProverEvent - * - *@param state (in) new LinkProberState label - * - *@return none - */ - void handleStateChange(LinkProberEvent &event, link_prober::LinkProberState::Label state); - - /** - *@method handleStateChange - * - *@brief handles MuxStateEvent - * - *@param state (in) new MuxState label - * - *@return none - */ - void handleStateChange(MuxStateEvent &event, mux_state::MuxState::Label state); - - /** - *@method handleStateChange - * - *@brief handles LinkStateEvent - * - *@param state (in) new LinkState label - * - *@return none - */ - void handleStateChange(LinkStateEvent &event, link_state::LinkState::Label state); - - /** - *@method handleGetServerMacNotification - * - *@brief handle get Server MAC address - * - *@param address (in) Server MAC address - * - *@return none - */ - void handleGetServerMacAddressNotification(std::array address); - - /** - *@method handleGetMuxStateNotification - * - *@brief handle get MUX state notification - * - *@param label (in) new MuxState label - * - *@return none - */ - void handleGetMuxStateNotification(mux_state::MuxState::Label label); - - /** - *@method handleProbeMuxStateNotification - * - *@brief handle probe MUX state notification - * - *@param label (in) new MuxState label - * - *@return none - */ - void handleProbeMuxStateNotification(mux_state::MuxState::Label label); - - /** - *@method handleMuxStateNotification - * - *@brief handle MUX state notification - * - *@param label (in) new MuxState label - * - *@return none - */ - void handleMuxStateNotification(mux_state::MuxState::Label label); - - /** - *@method handleSwssLinkStateNotification - * - *@brief handle link state change notification - * - *@param label (in) new LinkState label - * - *@return none - */ - void handleSwssLinkStateNotification(const link_state::LinkState::Label label); - - /** - *@method handleMuxConfigNotification - * - *@brief handle MUX configuration change notification - * - *@param mode (in) new MUX config mode - * - *@return none - */ - void handleMuxConfigNotification(const common::MuxPortConfig::Mode mode); - - /** - *@method handleSuspendTimerExpiry - * - *@brief handle suspend timer expiry notification from LinkProber - * - *@return none - */ - void handleSuspendTimerExpiry(); - - /** - *@method handleSwitchActiveCommandCompletion - * - *@brief handle completion of sending switch command to peer ToR - * - *@return none - */ - void handleSwitchActiveCommandCompletion(); - - /** - *@method handleSwitchActiveRequestEvent - * - *@brief handle switch active request from peer ToR - * - *@return none - */ - void handleSwitchActiveRequestEvent(); - -private: - /** - *@method updateMuxLinkmgrState - * - *@brief Update State DB MUX LinkMgr state - * - *@return none - */ - void updateMuxLinkmgrState(); - - /** - *@method startMuxProbeTimer - * - *@brief start a timer to monitor the MUX state - * - *@param factor factor used to scale the timeout - * - *@return none - */ - inline void startMuxProbeTimer(uint32_t factor = 1); - - /** - *@method handleLinkWaitTimeout - * - *@brief handle when LinkProber heartbeats were lost due link down, bad cable or server down - * - *@param errorCode (in) timer error code - * - *@return none - */ - void handleMuxProbeTimeout(boost::system::error_code errorCode); - - /** - *@method startMuxWaitTimer - * - *@brief start a timer to timeout xcvrd/orchagent - * - *@param factor factor used to scale the timeout - * - *@return none - */ - inline void startMuxWaitTimer(uint32_t factor = 1); - - /** - *@method handleMuxWaitTimeout - * - *@brief handle when xcrvrd/orchagent has timed out responding to linkmgrd. - * - *@param errorCode (in) timer error code - * - *@return none - */ - void handleMuxWaitTimeout(boost::system::error_code errorCode); - - /** - *@method initLinkProberState - * - *@brief initialize LinkProberState when configuring the composite state machine - * - *@param compositeState (in, out) reference to composite state, the state linkProber - * entry will be changed to align with MuxState - * - *@return none - */ - void initLinkProberState(CompositeState &compositeState); - - /** - *@method postMuxStateEvent - * - *@brief post event to MUX state machine to change state - * - *@param label (in) new state label to post event for - * - * - *@return none - */ - void postMuxStateEvent(mux_state::MuxState::Label label); - - /** - *@method noopTransitionFunction - * - *@brief No-op transition function - * - *@param nextState (in, out) reference to composite - * - *@return none - */ - void noopTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberStandbyMuxActiveLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberStandby, MuxActive, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberStandbyMuxActiveLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberUnknownMuxActiveLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberUnknown, MuxActive, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberUnknownMuxActiveLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberActiveMuxStandbyLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberActive, MuxStandby, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberActiveMuxStandbyLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberUnknownMuxStandbyLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberUnknown, MuxStandby, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberUnknownMuxStandbyLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberActiveMuxUnknownLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberActive, MuxUnknown, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberActiveMuxUnknownLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberStandbyMuxUnknownLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberStandby, MuxUnknown, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberStandbyMuxUnknownLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberUnknownMuxUnknownLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberUnknown, MuxUnknown, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberUnknownMuxUnknownLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberActiveMuxErrorLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberActive, MuxError, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberActiveMuxErrorLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberStandbyMuxErrorLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberStandby, MuxError, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberStandbyMuxErrorLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberWaitMuxActiveLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberWait, MuxActive, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberWaitMuxActiveLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberWaitMuxStandbyLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberWait, MuxStandby, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberWaitMuxStandbyLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberWaitMuxUnknownLinkUpTransitionFunction - * - *@brief transition function when entering {LinkProberWait, MuxUnknown, LinkUp} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberWaitMuxUnknownLinkUpTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberUnknownMuxActiveLinkDownTransitionFunction - * - *@brief transition function when entering {LinkProberUnknown, MuxActive, LinkDown} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberUnknownMuxActiveLinkDownTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberUnknownMuxStandbyLinkDownTransitionFunction - * - *@brief transition function when entering {LinkProberUnknown, MuxStandby, LinkDown} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberUnknownMuxStandbyLinkDownTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberUnknownMuxUnknownLinkDownTransitionFunction - * - *@brief transition function when entering {LinkProberUnknown, MuxUnknown, LinkDown} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberUnknownMuxUnknownLinkDownTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberWaitMuxActiveLinkDownTransitionFunction - * - *@brief transition function when entering {LinkProberWait, MuxActive, LinkDown} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberWaitMuxActiveLinkDownTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberWaitMuxStandbyLinkDownTransitionFunction - * - *@brief transition function when entering {LinkProberWait, MuxStandby, LinkDown} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberWaitMuxStandbyLinkDownTransitionFunction(CompositeState &nextState); - - /** - *@method LinkProberWaitMuxUnknownLinkDownTransitionFunction - * - *@brief transition function when entering {LinkProberWait, MuxUnknown, LinkDown} state - * - *@param nextState (in, out) reference to composite state, the state will be changed - * to reflect next new state. - * - *@return none - */ - void LinkProberWaitMuxUnknownLinkDownTransitionFunction(CompositeState &nextState); - -private: - // This is used for testing... - friend class mux::MuxPort; - friend class test::FakeMuxPort; - friend class test::MuxManagerTest; - - /** - *@method setInitializeProberFnPtr - * - *@brief set new InitializeProberFnPtr for the state machine. This method is used for testing - * - *@param initializeProberFnPtr (in) pointer to new InitializeProberFnPtr - * - *@return none - */ - void setInitializeProberFnPtr(boost::function initializeProberFnPtr) {mInitializeProberFnPtr = initializeProberFnPtr;}; - - /** - *@method setStartProbingFnPtr - * - *@brief set new StartProbingFnPtr for the state machine. This method is used for testing - * - *@param startProbingFnPtr (in) pointer to new StartProbingFnPtr - * - *@return none - */ - void setStartProbingFnPtr(boost::function startProbingFnPtr) {mStartProbingFnPtr = startProbingFnPtr;}; - - /** - *@method setUpdateEthernetFrameFnPtr - * - *@brief set new UpdateEthernetFrameFnPtr for the state machine. This method is used for testing - * - *@param updateEthernetFrameFnPtr (in) pointer to new UpdateEthernetFrameFnPtr - * - *@return none - */ - void setUpdateEthernetFrameFnPtr(boost::function updateEthernetFrameFnPtr) {mUpdateEthernetFrameFnPtr = updateEthernetFrameFnPtr;}; - - /** - *@method setProbePeerTorFnPtr - * - *@brief set new ProbePeerTorFnPtr for the state machine. This method is used for testing - * - *@param probePeerTorFnPtr (in) pointer to new ProbePeerTorFnPtr - * - *@return none - */ - void setProbePeerTorFnPtr(boost::function probePeerTorFnPtr) {mProbePeerTorFnPtr = probePeerTorFnPtr;}; - - /** - *@method setSuspendTxFnPtr - * - *@brief set new SuspendTXFnPtr for the state machine. This method is used for testing - * - *@param suspendTxFnPtr (in) pointer to new SuspendTxFnPtr - * - *@return none - */ - void setSuspendTxFnPtr(boost::function suspendTxFnPtr) {mSuspendTxFnPtr = suspendTxFnPtr;}; - - /** - *@method setResumeTxFnPtr - * - *@brief set new ResumeTXFnPtr for the state machine. This method is used for testing - * - *@param resumeTxFnPtr (in) pointer to new ResumeTxFnPtr - * - *@return none - */ - void setResumeTxFnPtr(boost::function resumeTxFnPtr) {mResumeTxFnPtr = resumeTxFnPtr;}; - - /** - *@method setSendPeerSwitchCommandFnPtr - * - *@brief set new SendPeerSwitchCommandFnPtr for the state machine. This method is used for testing - * - *@param sendPeerSwitchCommandFnPtr (in) pointer to new ResumeTxFnPtr - * - *@return none - */ - void setSendPeerSwitchCommandFnPtr(boost::function sendPeerSwitchCommandFnPtr) { - mSendPeerSwitchCommandFnPtr = sendPeerSwitchCommandFnPtr; - }; - - /** - *@method setComponentInitState - * - *@brief set component inti state. This method is used for testing - * - *@param component (in) component index - * - *@return none - */ - void setComponentInitState(uint8_t component) {mComponentInitState.set(component);}; - -private: - static TransitionFunction mStateTransitionHandler[link_prober::LinkProberState::Label::Count] - [mux_state::MuxState::Label::Count] - [link_state::LinkState::Label::Count]; - - static LinkProberEvent mLinkProberEvent; - static MuxStateEvent mMuxStateEvent; - static LinkStateEvent mLinkStateEvent; - - // To print human readable state name - static std::vector mLinkProberStateName; - static std::vector mMuxStateName; - static std::vector mLinkStateName; - static std::vector mLinkHealthName; - -private: - CompositeState mCompositeState = { - link_prober::LinkProberState::Label::Unknown, - mux_state::MuxState::Label::Wait, - link_state::LinkState::Label::Down - }; - - mux::MuxPort *mMuxPortPtr; - link_prober::LinkProberStateMachine mLinkProberStateMachine; - std::shared_ptr mLinkProberPtr = nullptr; - mux_state::MuxStateMachine mMuxStateMachine; - link_state::LinkStateMachine mLinkStateMachine; - - boost::asio::deadline_timer mDeadlineTimer; - boost::asio::deadline_timer mWaitTimer; - - boost::function mInitializeProberFnPtr; - boost::function mStartProbingFnPtr; - boost::function mUpdateEthernetFrameFnPtr; - boost::function mProbePeerTorFnPtr; - boost::function mSuspendTxFnPtr; - boost::function mResumeTxFnPtr; - boost::function mSendPeerSwitchCommandFnPtr; - - uint32_t mWaitActiveUpCount = 0; - uint32_t mMuxUnknownBackoffFactor = 1; - - std::bitset mComponentInitState = {0}; - Label mLabel = Label::Uninitialized; -}; - -} /* namespace link_manager */ - -#endif /* LINK_MANAGER_LINKMANAGERSTATEMACHINE_H_ */ diff --git a/src/linkmgrd/src/link_manager/subdir.mk b/src/linkmgrd/src/link_manager/subdir.mk deleted file mode 100644 index 0bbdbd367765..000000000000 --- a/src/linkmgrd/src/link_manager/subdir.mk +++ /dev/null @@ -1,20 +0,0 @@ -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ - ./src/link_manager/LinkManagerStateMachine.cpp - -OBJS += \ - ./src/link_manager/LinkManagerStateMachine.o - -CPP_DEPS += \ - ./src/link_manager/LinkManagerStateMachine.d - - -# Each subdirectory must supply rules for building sources it contributes -src/link_manager/%.o: src/link_manager/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - $(CC) -std=c++17 -D__FILENAME__="$(subst src/,,$<)" $(BOOST_MACROS) $(INCLUDES) $(CPP_FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/src/linkmgrd/src/link_prober/ActiveState.cpp b/src/linkmgrd/src/link_prober/ActiveState.cpp deleted file mode 100644 index cd43b45d7cde..000000000000 --- a/src/linkmgrd/src/link_prober/ActiveState.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ActiveState.cpp - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#include "link_prober/ActiveState.h" -#include "link_prober/StandbyState.h" -#include "link_prober/UnknownState.h" -#include "link_prober/LinkProberStateMachine.h" - -#include "common/MuxLogger.h" - -namespace link_prober -{ - -// -// ---> ActiveState(LinkProberStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -ActiveState::ActiveState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - LinkProberState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(IcmpPeerEvent &event); -// -// handle IcmpPeerEvent from LinkProber -// -LinkProberState* ActiveState::handleEvent(IcmpPeerEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState; - - mUnknownEventCount = 0; - if (++mPeerEventCount >= getMuxPortConfig().getPositiveStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - else { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - - return nextState; -} - -// -// ---> handleEvent(IcmpSelfEvent &event); -// -// handle IcmpSelfEvent from LinkProber -// -LinkProberState* ActiveState::handleEvent(IcmpSelfEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState = dynamic_cast (stateMachine->getActiveState()); - - resetState(); - - return nextState; -} - -// -// ---> handleEvent(IcmpUnknownEvent &event); -// -// handle IcmpUnknownEvent from LinkProber -// -LinkProberState* ActiveState::handleEvent(IcmpUnknownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState; - - mPeerEventCount = 0; - if (++mUnknownEventCount >= getMuxPortConfig().getNegativeStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - else { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - - return nextState; -} - -// -// ---> resetState(); -// -// reset current state attributes -// -void ActiveState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - mPeerEventCount = 0; - mUnknownEventCount = 0; -} - -} /* namespace link_prober */ diff --git a/src/linkmgrd/src/link_prober/ActiveState.h b/src/linkmgrd/src/link_prober/ActiveState.h deleted file mode 100644 index 00de25c457ba..000000000000 --- a/src/linkmgrd/src/link_prober/ActiveState.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * ActiveState.h - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#ifndef LINK_PROBER_ACTIVESTATE_H_ -#define LINK_PROBER_ACTIVESTATE_H_ - -#include "LinkProberState.h" - -namespace link_prober -{ -class LinkProberStateMachine; - -/** - *@class ActiveState - * - *@brief maintains Active state of LinkProber - */ -class ActiveState: public LinkProberState -{ -public: - /** - *@method ActiveState - * - *@brief class default constructor - */ - ActiveState() = delete; - - /** - *@method ActiveState - * - *@brief class copy constructor - * - *@param ActiveState (in) reference to ActiveState object to be copied - */ - ActiveState(const ActiveState &) = delete; - - /** - *@method ActiveState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkProberStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - ActiveState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~ActiveState - * - *@brief class destructor - */ - virtual ~ActiveState() = default; - - /** - *@method handleEvent - * - *@brief handle IcmpPeerEvent from LinkProber - * - *@param event (in) reference to IcmpPeerEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpPeerEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle IcmpSelfEvent from LinkProber - * - *@param event (in) reference to IcmpSelfEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpSelfEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle IcmpUnknownEvent from LinkProber - * - *@param event (in) reference to IcmpUnknownEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpUnknownEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for LinkeProberState label - * - *@return LinkProberState Active label - */ - virtual LinkProberState::Label getStateLabel() override {return LinkProberState::Label::Active;}; - -private: - uint8_t mPeerEventCount = 0; - uint8_t mUnknownEventCount = 0; -}; - -} /* namespace link_prober */ - -#endif /* LINK_PROBER_ACTIVESTATE_H_ */ diff --git a/src/linkmgrd/src/link_prober/IcmpPayload.cpp b/src/linkmgrd/src/link_prober/IcmpPayload.cpp deleted file mode 100644 index 65c0422d89b6..000000000000 --- a/src/linkmgrd/src/link_prober/IcmpPayload.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * IcmpPayload.cpp - * - * Created on: Oct 9, 2020 - * Author: tamer - */ - -#include - -#include -#include - -#include "IcmpPayload.h" -#include "common/MuxLogger.h" - -namespace link_prober -{ -// -// static members -// -boost::uuids::uuid IcmpPayload::mGuid; -uint32_t IcmpPayload::mCookie = 0x47656d69; -uint32_t IcmpPayload::mVersion = 0; - -// -// ---> IcmpPayload(); -// -// class constructor -// -IcmpPayload::IcmpPayload() : - cookie(htonl(mCookie)), - version(htonl(mVersion)), - command(htonl(static_cast (Command::COMMAND_NONE))) -{ - memcpy(un.uuid.data, mGuid.data, sizeof(un.uuid.data)); -} - -// -// ---> generateGuid() -// -// generate GUID for the current instance of linkmgrd -// -void IcmpPayload::generateGuid() -{ - boost::uuids::random_generator gen; - mGuid = gen(); - - MUXLOGWARNING(boost::format("Link Prober generated GUID: {%s}") % boost::uuids::to_string(mGuid)); -} - -} /* namespace link_prober */ diff --git a/src/linkmgrd/src/link_prober/IcmpPayload.h b/src/linkmgrd/src/link_prober/IcmpPayload.h deleted file mode 100644 index 500f5a873444..000000000000 --- a/src/linkmgrd/src/link_prober/IcmpPayload.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * IcmpPayload.h - * - * Created on: Oct 9, 2020 - * Author: tamer - */ - -#ifndef ICMPPAYLOAD_H_ -#define ICMPPAYLOAD_H_ - -#pragma pack(push, 1) - -#include -#include -#include -#include -#include - -#include - -#include - -#define MUX_MAX_ICMP_BUFFER_SIZE 128 - -__BEGIN_DECLS - -namespace link_prober -{ - -/** - *@enum Command - * - *@brief Command to be sent to peer device - */ -enum class Command: uint32_t { - COMMAND_NONE, - COMMAND_SWITCH_ACTIVE, - - Count -}; - -/** - *@struct IcmpPayload - * - *@brief Build ICMP packet to sent to server - */ -struct IcmpPayload { - uint32_t cookie; - uint32_t version; - union { - uint64_t guid[2]; - boost::uuids::uuid uuid; - } un; - uint32_t command; - - /** - *@method IcmpPayload - * - *@brief class default constructor - */ - IcmpPayload(); - - /** - *@method generateGuid - * - *@brief generate GUID for the current instance of linkmgrd - * - *@return none - */ - static void generateGuid(); - - /** - *@method getGuidData - * - *@brief getter for GUID data - * - *@return pointer to current GUID data - */ - static uint8_t* getGuidData() {return reinterpret_cast (mGuid.data);}; - - /** - *@method getGuid - * - *@brief getter for GUID object - * - *@return reference to current GUID object - */ - static boost::uuids::uuid& getGuid() {return mGuid;}; - - /** - *@method getCookie - * - *@brief getter for ICMP cookie - * - *@return ICMP coolie - */ - static uint32_t getCookie() {return mCookie;}; - - /** - *@method getVersion - * - *@brief getter for current version - * - *@return current version - */ - static uint32_t getVersion() {return mVersion;}; - -private: - static uint32_t mCookie; - static uint32_t mVersion; - static boost::uuids::uuid mGuid; -} __attribute__((packed)); - -static_assert(sizeof(IcmpPayload) % 2 == 0, - "ICMP Payload size should be even sized, please add zero padding"); - -static_assert(sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr) + sizeof(IcmpPayload) < MUX_MAX_ICMP_BUFFER_SIZE, - "Buffer Size doesn't fit Link Prober ICMP packet with its payload"); - -} /* namespace link_prober */ - -__END_DECLS - -#pragma pack(pop) - -#endif /* ICMPPAYLOAD_H_ */ diff --git a/src/linkmgrd/src/link_prober/LinkProber.cpp b/src/linkmgrd/src/link_prober/LinkProber.cpp deleted file mode 100644 index ec9320d9672e..000000000000 --- a/src/linkmgrd/src/link_prober/LinkProber.cpp +++ /dev/null @@ -1,578 +0,0 @@ -/* - * LinkProber.cpp - * - * Created on: Oct 4, 2020 - * Author: tamer - */ - -#include -#include -#include -#include - -#include - -#include "common/MuxLogger.h" -#include "LinkProber.h" -#include "common/MuxException.h" - -namespace link_prober -{ - -// -// Berkeley Packet Filter program that captures incoming ICMP traffic -// -SockFilter LinkProber::mIcmpFilter[] = { - [0] = {.code = 0x28, .jt = 0, .jf = 0, .k = 0x0000000c}, - [1] = {.code = 0x15, .jt = 0, .jf = 10, .k = 0x00000800}, - [2] = {.code = 0x20, .jt = 0, .jf = 0, .k = 0x0000001a}, - [3] = {.code = 0x15, .jt = 0, .jf = 8, .k = 0x00000000}, - [4] = {.code = 0x30, .jt = 0, .jf = 0, .k = 0x00000017}, - [5] = {.code = 0x15, .jt = 0, .jf = 6, .k = 0x00000001}, - [6] = {.code = 0x28, .jt = 0, .jf = 0, .k = 0x00000014}, - [7] = {.code = 0x45, .jt = 4, .jf = 0, .k = 0x00001fff}, - [8] = {.code = 0xb1, .jt = 0, .jf = 0, .k = 0x0000000e}, - [9] = {.code = 0x50, .jt = 0, .jf = 0, .k = 0x0000000e}, - [10] = {.code = 0x15, .jt = 0, .jf = 1, .k = 0x00000000}, - [11] = {.code = 0x6, .jt = 0, .jf = 0, .k = 0x00040000}, - [12] = {.code = 0x6, .jt = 0, .jf = 0, .k = 0x00000000}, -}; - -// -// ---> LinkProber( -// common::MuxPortConfig &muxPortConfig, -// boost::asio::io_service &ioService, -// LinkProberStateMachine &linkProberStateMachine -// ); -// -// class constructor -// -LinkProber::LinkProber( - common::MuxPortConfig &muxPortConfig, - boost::asio::io_service &ioService, - LinkProberStateMachine &linkProberStateMachine -) : - mMuxPortConfig(muxPortConfig), - mIoService(ioService), - mLinkProberStateMachine(linkProberStateMachine), - mStrand(mIoService), - mDeadlineTimer(mIoService), - mSuspendTimer(mIoService), - mStream(mIoService) -{ - try { - mSockFilterPtr = std::shared_ptr ( - new SockFilter[sizeof(mIcmpFilter) / sizeof(*mIcmpFilter)], - std::default_delete() - ); - memcpy(mSockFilterPtr.get(), mIcmpFilter, sizeof(mIcmpFilter)); - - mSockFilterProg.len = sizeof(mIcmpFilter) / sizeof(*mIcmpFilter); - mSockFilterProg.filter = mSockFilterPtr.get(); - } - catch (const std::bad_alloc& ex) { - std::ostringstream errMsg; - errMsg << "Failed allocate memory. Exception details: " << ex.what(); - - throw MUX_ERROR(BadAlloc, errMsg.str()); - } -} - -// -// ---> initialize(); -// -// initialize link prober sockets and builds ICMP packet -// -void LinkProber::initialize() -{ - mSocket = socket(AF_PACKET, SOCK_RAW | SOCK_NONBLOCK, IPPROTO_ICMP); - if (mSocket < 0) { - std::ostringstream errMsg; - errMsg << "Failed to open socket with '" << strerror(errno) << "'" - << std::endl; - throw MUX_ERROR(SocketError, errMsg.str()); - } - - SockAddrLinkLayer addr; - memset(&addr, 0, sizeof(addr)); - - addr.sll_ifindex = if_nametoindex(mMuxPortConfig.getPortName().c_str()); - addr.sll_family = AF_PACKET; - addr.sll_protocol = htons(ETH_P_ALL); - if (bind(mSocket, (struct sockaddr *) &addr, sizeof(addr))) { - std::ostringstream errMsg; - errMsg << "Failed to bind to interface '" << mMuxPortConfig.getPortName() << "' with '" - << strerror(errno) << "'" << std::endl; - throw MUX_ERROR(SocketError, errMsg.str()); - } - - mSockFilterPtr.get()[3].k = mMuxPortConfig.getBladeIpv4Address().to_v4().to_uint(); - if (setsockopt(mSocket, SOL_SOCKET, SO_ATTACH_FILTER, &mSockFilterProg, sizeof(mSockFilterProg)) != 0) { - std::ostringstream errMsg; - errMsg << "Failed to attach filter with '" << strerror(errno) << "'" - << std::endl; - throw MUX_ERROR(SocketError, errMsg.str()); - } - - mStream.assign(mSocket); - initializeSendBuffer(); - - startInitRecv(); -} - -// -// ---> startProbing(); -// -// start sending ICMP ECHOREQUEST packets -// -void LinkProber::startProbing() -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - mStream.cancel(); - sendHeartbeat(); - startRecv(); - startTimer(); -} - -// -// ---> suspendTxProbes(uint32_t suspendTime_msec); -// -// suspend sending ICMP ECHOREQUEST packets -// -void LinkProber::suspendTxProbes(uint32_t suspendTime_msec) -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - mSuspendTimer.expires_from_now(boost::posix_time::milliseconds(suspendTime_msec)); - mSuspendTimer.async_wait(mStrand.wrap(boost::bind( - &LinkProber::handleSuspendTimeout, - this, - boost::asio::placeholders::error - ))); - - mSuspendTx = true; -} - -// -// ---> resumeTxProbes(); -// -// resume sending ICMP ECHOREQUEST packets -// -void LinkProber::resumeTxProbes() -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - mSuspendTimer.cancel(); -} - -// -// ---> updateEthernetFrame(); -// -// update Ethernet frame of Tx Buffer -// -void LinkProber::updateEthernetFrame() -{ - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind(&LinkProber::handleUpdateEthernetFrame, this))); -} - -// -// ---> probePeerTor(); -// -// send an early HB to peer ToR -// -void LinkProber::probePeerTor() -{ - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind(&LinkProber::sendHeartbeat, this))); -} - -// -// ---> sendPeerSwitchCommand(); -// -// send send peer switch command -// -void LinkProber::sendPeerSwitchCommand() -{ - boost::asio::io_service &ioService = mStrand.context(); - ioService.post(mStrand.wrap(boost::bind(&LinkProber::handleSendSwitchCommand, this))); -} - -// -// ---> handleUpdateEthernetFrame(); -// -// update Ethernet frame of Tx Buffer -// -void LinkProber::handleUpdateEthernetFrame() -{ - initializeSendBuffer(); -} - -// -// ---> handleSendSwitchCommand(); -// -// send switch command to peer ToR -// -void LinkProber::handleSendSwitchCommand() -{ - IcmpPayload *icmpPayload = reinterpret_cast ( - mTxBuffer.data() + sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr) - ); - icmpPayload->command = htonl(static_cast (Command::COMMAND_SWITCH_ACTIVE)); - - icmphdr *icmpHeader = reinterpret_cast (mTxBuffer.data() + sizeof(ether_header) + sizeof(iphdr)); - computeChecksum(icmpHeader, sizeof(icmphdr) + sizeof(*icmpPayload)); - - sendHeartbeat(); - - icmpPayload->command = htonl(static_cast (Command::COMMAND_NONE)); - computeChecksum(icmpHeader, sizeof(icmphdr) + sizeof(*icmpPayload)); - - // inform the composite state machine about commend send completion - boost::asio::io_service::strand &strand = mLinkProberStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&LinkProberStateMachine::processEvent), - &mLinkProberStateMachine, - LinkProberStateMachine::getSwitchActiveCommandCompleteEvent() - ))); -} - -// -// ---> sendHeartbeat() -// -// send ICMP ECHOREQUEST packet -// -void LinkProber::sendHeartbeat() -{ - MUXLOGTRACE(mMuxPortConfig.getPortName()); - - // check if suspend timer is running - if (!mSuspendTx) { - updateIcmpSequenceNo(); - boost::system::error_code errorCode; - mStream.write_some( - boost::asio::buffer( - mTxBuffer.data(), sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr) + sizeof(IcmpPayload) - ), - errorCode - ); - - if (errorCode) { - MUXLOGTRACE(mMuxPortConfig.getPortName() + ": Failed to send heartbeat!"); - } else { - MUXLOGTRACE(mMuxPortConfig.getPortName() + ": Done sending data"); - } - } -} - -// -// ---> handleRecv(const boost::system::error_code& errorCode, size_t bytesTransferred); -// -// handle packet reception -// -void LinkProber::handleRecv( - const boost::system::error_code& errorCode, - size_t bytesTransferred -) -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - if (errorCode != boost::asio::error::operation_aborted) { - iphdr *ipHeader = reinterpret_cast (mRxBuffer.data() + sizeof(ether_header)); - icmphdr *icmpHeader = reinterpret_cast ( - mRxBuffer.data() + sizeof(ether_header) + sizeof(iphdr) - ); - - IcmpPayload *icmpPayload = reinterpret_cast ( - mRxBuffer.data() + sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr) - ); - - if (ntohl(icmpPayload->cookie) == IcmpPayload::getCookie() && - ntohl(icmpPayload->version) <= IcmpPayload::getVersion() && - ntohs(icmpHeader->un.echo.id) == mMuxPortConfig.getServerId()) { - MUXLOGTRACE(boost::format("%s: Valid ICMP Packet from %s") % - mMuxPortConfig.getPortName() % - mMuxPortConfig.getBladeIpv4Address().to_string() - ); - if (memcmp(icmpPayload->un.uuid.data, IcmpPayload::getGuidData(), - IcmpPayload::getGuid().size()) == 0) { - MUXLOGTRACE(boost::format("%s: Matching Guid") % mMuxPortConfig.getPortName()); - // echo reply for an echo request generated by this/active ToR - mRxSelfSeqNo = mTxSeqNo; - mLinkProberStateMachine.postLinkProberStateEvent(LinkProberStateMachine::getIcmpSelfEvent()); - } else { - // echo reply for an echo request generated by peer ToR - mRxPeerSeqNo = mTxSeqNo; - mLinkProberStateMachine.postLinkProberStateEvent(LinkProberStateMachine::getIcmpPeerEvent()); - if (ntohl(icmpPayload->command) == static_cast (Command::COMMAND_SWITCH_ACTIVE)) { - boost::asio::io_service::strand &strand = mLinkProberStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&LinkProberStateMachine::processEvent), - &mLinkProberStateMachine, - LinkProberStateMachine::getSwitchActiveRequestEvent() - ))); - } - } - } else { - // Unknown ICMP packet, ignore. - } - - MUXLOGTRACE(boost::format("%s: Got data from: %s, size: %d") % - mMuxPortConfig.getPortName() % - boost::asio::ip::address_v4(ntohl(ipHeader->saddr)).to_string() % - (bytesTransferred - sizeof(iphdr) - sizeof(ether_header)) - ); - // start another receive to consume as much as possible of backlog packets if any - startRecv(); - } -} - -// -// ---> handleInitRecv(const boost::system::error_code& errorCode, size_t bytesTransferred); -// -// handle packet reception -// -void LinkProber::handleInitRecv( - const boost::system::error_code& errorCode, - size_t bytesTransferred -) -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - if (errorCode != boost::asio::error::operation_aborted) { - ether_header *ethHeader = reinterpret_cast (mRxBuffer.data()); - std::array macAddress; - - memcpy(macAddress.data(), ethHeader->ether_shost, macAddress.size()); - - boost::asio::io_service::strand &strand = mLinkProberStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - &LinkProberStateMachine::handleMackAddressUpdate, - &mLinkProberStateMachine, - macAddress - ))); - } -} - -// -// ---> handleTimeout(boost::system::error_code ec); -// -// handle ICMP packet reception timeout -// -void LinkProber::handleTimeout(boost::system::error_code errorCode) -{ - MUXLOGTRACE(boost::format("%s: server: %d, mRxSelfSeqNo: %d, mTxSeqNo: %d") % - mMuxPortConfig.getPortName() % - mMuxPortConfig.getServerId() % - mRxSelfSeqNo % - mTxSeqNo - ); - - mStream.cancel(); - if (mTxSeqNo != mRxSelfSeqNo && mTxSeqNo != mRxPeerSeqNo) { - // post unknown event - mLinkProberStateMachine.postLinkProberStateEvent(LinkProberStateMachine::getIcmpUnknownEvent()); - } - - // start another cycle of send/recv - startProbing(); -} - -// -// ---> handleSuspendTimeout(boost::system::error_code errorCode); -// -// handle suspend timer timeout -// -void LinkProber::handleSuspendTimeout(boost::system::error_code errorCode) -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - - mSuspendTx = false; - - if (errorCode == boost::system::errc::success) { - // inform the composite state machine about Suspend timer expiry - boost::asio::io_service::strand &strand = mLinkProberStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&LinkProberStateMachine::processEvent), - &mLinkProberStateMachine, - LinkProberStateMachine::getSuspendTimerExpiredEvent() - ))); - } -} - -// -// ---> startRecv(); -// -// start ICMP ECHOREPLY reception -// -void LinkProber::startRecv() -{ - MUXLOGTRACE(mMuxPortConfig.getPortName()); - - mStream.async_read_some( - boost::asio::buffer(mRxBuffer, MUX_MAX_ICMP_BUFFER_SIZE), - mStrand.wrap(boost::bind( - &LinkProber::handleRecv, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred - )) - ); -} - -// -// ---> startInitRecv(); -// -// start ICMP ECHOREPLY reception -// -void LinkProber::startInitRecv() -{ - MUXLOGTRACE(mMuxPortConfig.getPortName()); - - mStream.async_read_some( - boost::asio::buffer(mRxBuffer, MUX_MAX_ICMP_BUFFER_SIZE), - mStrand.wrap(boost::bind( - &LinkProber::handleInitRecv, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred - )) - ); -} - -// -// ---> startTimer(); -// -// start ICMP ECHOREPLY timeout timer -// -void LinkProber::startTimer() -{ - MUXLOGDEBUG(mMuxPortConfig.getPortName()); - // time out these heartbeats - mDeadlineTimer.expires_from_now(boost::posix_time::milliseconds(mMuxPortConfig.getTimeoutIpv4_msec())); - mDeadlineTimer.async_wait(mStrand.wrap(boost::bind( - &LinkProber::handleTimeout, - this, - boost::asio::placeholders::error - ))); -} - -// -// ---> calculateChecksum(uint16_t *data, size_t size); -// -// calculate ICMP payload checksum -// -uint32_t LinkProber::calculateChecksum(uint16_t *data, size_t size) -{ - uint32_t sum = 0; - size_t offset = 0; - - do { - sum += ntohs(data[offset++]); - } while (offset < size); - - return sum; -} - -// -// ---> addChecksumCarryover(uint16_t *checksum, uint32_t sum); -// -// add checksum carryover -// -void LinkProber::addChecksumCarryover(uint16_t *checksum, uint32_t sum) -{ - sum = (sum >> 16) + (sum & 0xFFFF); - sum += (sum >> 16); - *checksum = htons(~sum); -} - -// -// ---> computeChecksum(icmphdr *icmpHeader, size_t size); -// -// compute ICMP checksum -// -void LinkProber::computeChecksum(icmphdr *icmpHeader, size_t size) -{ - icmpHeader->checksum = 0; - mIcmpChecksum = calculateChecksum( - reinterpret_cast (icmpHeader), size / 2 - ); - addChecksumCarryover(&icmpHeader->checksum, mIcmpChecksum); -} - -// -// ---> computeChecksum(iphdr *ipHeader, size_t size); -// -// compute IPv4 checksum -// -void LinkProber::computeChecksum(iphdr *ipHeader, size_t size) -{ - ipHeader->check = 0; - mIpChecksum = calculateChecksum( - reinterpret_cast (ipHeader), size / 2 - ); - addChecksumCarryover(&ipHeader->check, mIpChecksum); -} - -// -// ---> initializeSendBuffer(); -// -// initialize ICMP packet once -// -void LinkProber::initializeSendBuffer() -{ - ether_header *ethHeader = reinterpret_cast (mTxBuffer.data()); - memcpy(ethHeader->ether_dhost, mMuxPortConfig.getBladeMacAddress().data(), sizeof(ethHeader->ether_dhost)); - memcpy(ethHeader->ether_shost, mMuxPortConfig.getTorMacAddress().data(), sizeof(ethHeader->ether_shost)); - ethHeader->ether_type = htons(ETHERTYPE_IP); - - iphdr *ipHeader = reinterpret_cast (mTxBuffer.data() + sizeof(ether_header)); - ipHeader->ihl = sizeof(iphdr) >> 2; - ipHeader->version = IPVERSION; - ipHeader->tos = 0xb8; - ipHeader->tot_len = htons(sizeof(iphdr) + sizeof(icmphdr) + sizeof(IcmpPayload)); - ipHeader->id = static_cast (rand()); - ipHeader->frag_off = 0; - ipHeader->ttl = 64; - ipHeader->protocol = IPPROTO_ICMP; - ipHeader->check = 0; - ipHeader->saddr = htonl(mMuxPortConfig.getLoopbackIpv4Address().to_v4().to_uint()); - ipHeader->daddr = htonl(mMuxPortConfig.getBladeIpv4Address().to_v4().to_uint()); - computeChecksum(ipHeader, ipHeader->ihl << 2); - - icmphdr *icmpHeader = reinterpret_cast (mTxBuffer.data() + sizeof(ether_header) + sizeof(iphdr)); - icmpHeader->type = ICMP_ECHO; - icmpHeader->code = 0; - icmpHeader->un.echo.id = htons(mMuxPortConfig.getServerId()); - icmpHeader->un.echo.sequence = htons(mTxSeqNo); - - IcmpPayload *icmpPayload = new (mTxBuffer.data() + sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr)) IcmpPayload(); - computeChecksum(icmpHeader, sizeof(icmphdr) + sizeof(*icmpPayload)); -} - -// -// ---> updateIcmpSequenceNo(); -// -// update ICMP packet checksum, used before sending new heartbeat -// -void LinkProber::updateIcmpSequenceNo() -{ - // update received sequence to avoid reporting invalid ICMP event when sequence number rolls over - mRxPeerSeqNo = mTxSeqNo; - mRxSelfSeqNo = mTxSeqNo; - - icmphdr *icmpHeader = reinterpret_cast (mTxBuffer.data() + sizeof(ether_header) + sizeof(iphdr)); - icmpHeader->un.echo.sequence = htons(++mTxSeqNo); - mIcmpChecksum += mTxSeqNo ? 1 : 0; - addChecksumCarryover(&icmpHeader->checksum, mIcmpChecksum); -} - -} /* namespace link_prober */ diff --git a/src/linkmgrd/src/link_prober/LinkProber.h b/src/linkmgrd/src/link_prober/LinkProber.h deleted file mode 100644 index 2411c9e54b07..000000000000 --- a/src/linkmgrd/src/link_prober/LinkProber.h +++ /dev/null @@ -1,364 +0,0 @@ -/* - * LinkProber.h - * - * Created on: Oct 4, 2020 - * Author: tamer - */ - -#ifndef LINKPROBER_H_ -#define LINKPROBER_H_ - -#include -#include -#include -#include - -#include - -#include "IcmpPayload.h" -#include "LinkProberStateMachine.h" -#include "common/MuxPortConfig.h" - -namespace test { -class LinkProberTest; -} - -namespace link_prober -{ -using SockFilter = struct sock_filter; -using SockFilterProg = struct sock_fprog; -using SockAddrLinkLayer = struct sockaddr_ll; - -/** - *@class LinkProber - * - *@brief probes the server sing ICMP ECHPREQUEST packet. The packet payload - * holds GUID that identifies this ToR. Reception of this ToR's GUID - * indicate that the link is in Active state. Reception of unknown - * GUID will indicate standby state. Lack of ICMP packets will signal - * that the link state is unknown. - */ -class LinkProber -{ -public: - /** - *@method LinkProber - * - *@brief class default constructor - */ - LinkProber() = delete; - - /** - *@method LinkProber - * - *@brief class copy constructor - * - *@param LinkProber (in) reference to LinkProber object to be copied - */ - LinkProber(const LinkProber &) = delete; - - /** - *@method LinkProber - * - *@brief class constructor - * - *@param muxPortConfig (in) reference to MuxPortConfig object - *@param ioService (in) reference to boost io_service object - *@param linkProberStateMachine (in) reference to LinkProberStateMachine object - */ - LinkProber( - common::MuxPortConfig &muxPortConfig, - boost::asio::io_service &ioService, - LinkProberStateMachine &linkProberStateMachine - ); - - /** - *@method ~LinkProber - * - *@brief class destructor - */ - virtual ~LinkProber() = default; - - /** - *@method initialize - * - *@brief initialize link prober sockets and builds ICMP packet - * - *@return none - */ - void initialize(); - - /** - *@method startProbing - * - *@brief start probing server/blade using ICMP ECHOREQUEST - * - *@return none - */ - void startProbing(); - - /** - *@method suspendTxProbes - * - *@brief suspend sending ICMP ECHOREQUEST packets - * - *@param suspendTime_msec suspension time in msec - * - *@return none - */ - void suspendTxProbes(uint32_t suspendTime_msec); - - /** - *@method resumeTxProbes - * - *@brief resume sending ICMP ECHOREQUEST packets - * - *@return none - */ - void resumeTxProbes(); - - /** - *@method updateEthernetFrame - * - *@brief update Ethernet frame of Tx Buffer - * - *@return none - */ - void updateEthernetFrame(); - - /** - *@method probePeerTor - * - *@brief send an early HB to peer ToR - * - *@return none - */ - void probePeerTor(); - - /** - *@method sendPeerSwitchCommand - * - *@brief send switch command to peer ToR - * - *@return none - */ - void sendPeerSwitchCommand(); - -private: - /** - *@method handleUpdateEthernetFrame - * - *@brief update Ethernet frame of Tx Buffer - * - *@return none - */ - void handleUpdateEthernetFrame(); - - /** - *@method handleSendSwitchCommand - * - *@brief send switch command to peer ToR - * - *@return none - */ - void handleSendSwitchCommand(); - - /** - *@method sendHeartbeat - * - *@brief send ICMP ECHOREQUEST packet - * - *@return none - */ - void sendHeartbeat(); - - /** - *@method handleRecv - * - *@brief handle packet reception - * - *@param errorCode (in) socket error code - *@param bytesTransferred (in) number of bytes received - * - *@return none - */ - void handleRecv( - const boost::system::error_code &errorCode, - size_t bytesTransferred - ); - - /** - *@method handleInitRecv - * - *@brief handle packet reception - * - *@param errorCode (in) socket error code - *@param bytesTransferred (in) number of bytes received - * - *@return none - */ - void handleInitRecv( - const boost::system::error_code &errorCode, - size_t bytesTransferred - ); - - /** - *@method handleTimeout - * - *@brief handle ICMP packet reception timeout - * - *@param errorCode (in) socket error code - * - *@return none - */ - void handleTimeout(boost::system::error_code errorCode); - - /** - *@method handleSuspendTimeout - * - *@brief handle suspend timer timeout - * - *@param errorCode (in) socket error code - * - *@return none - */ - void handleSuspendTimeout(boost::system::error_code errorCode); - - /** - *@method startRecv - * - *@brief start ICMP ECHOREPLY reception - * - *@return none - */ - void startRecv(); - - /** - *@method startInitRecv - * - *@brief start ICMP ECHOREPLY reception - * - *@return none - */ - void startInitRecv(); - - /** - *@method startTimer - * - *@brief start ICMP ECHOREPLY timeout timer - * - *@return none - */ - void startTimer(); - - /** - *@method calculateChecksum - * - *@brief calculate ICMP payload checksum - * - *@param data (in) pointer to data buffer - *@param size (in) size of data buffer - * - *@return CRC checksum - */ - uint32_t calculateChecksum(uint16_t *data, size_t size); - - /** - *@method addChecksumCarryover - * - *@brief add checksum carryover - * - *@param checksum (out) pointer to checksum field - *@param sum (in) current sum of the buffer payload - * - *@return CRC checksum - */ - void addChecksumCarryover(uint16_t *checksum, uint32_t sum); - - /** - *@method computeChecksum - * - *@brief compute ICMP checksum - * - *@param icmpHeader (in, out) pointer ICMP header - *@param size (in) size of ICMP payload - * - *@return CRC checksum - */ - void computeChecksum(icmphdr *icmpHeader, size_t size); - - /** - *@method computeChecksum - * - *@brief compute IPv4 checksum - * - *@param ipHeader (in, out) pointer IPv4 header - *@param size (in) size of IPv4 header - * - *@return CRC checksum - */ - void computeChecksum(iphdr *ipHeader, size_t size); - - /** - *@method initializeSendBuffer - * - *@brief initialize ICMP packet once - * - *@return CRC checksum - */ - void initializeSendBuffer(); - - /** - *@method updateIcmpSequenceNo - * - *@brief update ICMP packet checksum, used before sending new heartbeat - * - *@return CRC checksum - */ - void updateIcmpSequenceNo(); - - /** - *@method getTxBuffer - * - *@brief getter for TxBuffer used for testing - * - *@return CRC checksum - */ - std::array getTxBuffer() {return mTxBuffer;}; - - friend class test::LinkProberTest; - -private: - static SockFilter mIcmpFilter[]; - -private: - common::MuxPortConfig &mMuxPortConfig; - boost::asio::io_service &mIoService; - LinkProberStateMachine &mLinkProberStateMachine; - - uint16_t mTxSeqNo = 0xffff; - uint16_t mRxSelfSeqNo = 0; - uint16_t mRxPeerSeqNo = 0; - - uint32_t mIcmpChecksum = 0; - uint32_t mIpChecksum = 0; - - boost::asio::io_service::strand mStrand; - boost::asio::deadline_timer mDeadlineTimer; - boost::asio::deadline_timer mSuspendTimer; - boost::asio::posix::stream_descriptor mStream; - - std::shared_ptr mSockFilterPtr; - SockFilterProg mSockFilterProg; - - int mSocket = 0; - - std::array mTxBuffer; - std::array mRxBuffer; - - bool mSuspendTx = false; -}; - -} /* namespace link_prober */ - -#endif /* LINKPROBER_H_ */ diff --git a/src/linkmgrd/src/link_prober/LinkProberState.cpp b/src/linkmgrd/src/link_prober/LinkProberState.cpp deleted file mode 100644 index 69d2802d5f26..000000000000 --- a/src/linkmgrd/src/link_prober/LinkProberState.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * LinkProberState.cpp - * - * Created on: Oct 8, 2020 - * Author: tamer - */ - - -#include -#include - -namespace link_prober -{ - -// -// ---> LinkProberState(LinkProberStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -LinkProberState::LinkProberState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - common::State( - *dynamic_cast (&stateMachine), - muxPortConfig - ) -{ -} - -} /* namespace link_prober */ diff --git a/src/linkmgrd/src/link_prober/LinkProberState.h b/src/linkmgrd/src/link_prober/LinkProberState.h deleted file mode 100644 index 20d8c5fcde03..000000000000 --- a/src/linkmgrd/src/link_prober/LinkProberState.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * LinkProberState.h - * - * Created on: Oct 8, 2020 - * Author: tamer - */ - -#ifndef LINK_PROBER_LINKPROBERSTATE_H_ -#define LINK_PROBER_LINKPROBERSTATE_H_ - -#include - -namespace link_prober -{ -class LinkProberStateMachine; -class IcmpPeerEvent; -class IcmpSelfEvent; -class IcmpUnknownEvent; -class SuspendTimerExpiredEvent; - -/** - *@class LinkProberState - * - *@brief base class for different LinkProber states - */ -class LinkProberState: public common::State -{ -public: - /** - *@enum Label - * - *@brief Label corresponding to each LinkProber State - */ - enum Label { - Active, - Standby, - Unknown, - Wait, - - Count - }; - -public: - /** - *@method LinkProberState - * - *@brief class default constructor - */ - LinkProberState() = delete; - - /** - *@method LinkProberState - * - *@brief class copy constructor - * - *@param LinkProberState (in) reference to LinkProberState object to be copied - */ - LinkProberState(const LinkProberState &) = delete; - - /** - *@method LinkProberState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkProberStateMachine object - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - LinkProberState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~LinkProber - * - *@brief class destructor - */ - virtual ~LinkProberState() = default; - - /** - *@method handleEvent - * - *@brief handle IcmpPeerEvent from LinkProber - * - *@param event (in) reference to IcmpPeerEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpPeerEvent &event) = 0; - - /** - *@method handleEvent - * - *@brief handle IcmpSelfEvent from LinkProber - * - *@param event (in) reference to IcmpSelfEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpSelfEvent &event) = 0; - - /** - *@method handleEvent - * - *@brief handle IcmpUnknownEvent from LinkProber - * - *@param event (in) reference to IcmpUnknownEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpUnknownEvent &event) = 0; - - /** - *@method getStateLabel - * - *@brief getter for LinkeProberState label - * - *@return LinkProberState Active label - */ - virtual LinkProberState::Label getStateLabel() = 0; -}; - -} /* namespace link_prober */ - -#endif /* LINK_PROBER_LINKPROBERSTATE_H_ */ diff --git a/src/linkmgrd/src/link_prober/LinkProberStateMachine.cpp b/src/linkmgrd/src/link_prober/LinkProberStateMachine.cpp deleted file mode 100644 index a69a3ee60ea7..000000000000 --- a/src/linkmgrd/src/link_prober/LinkProberStateMachine.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - * LinkProberStateMachine.cpp - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#include - -#include "link_prober/LinkProberStateMachine.h" -#include "link_manager/LinkManagerStateMachine.h" -#include "common/MuxLogger.h" -#include "LinkProberState.h" - -namespace link_prober -{ - -// -// static members -// -IcmpSelfEvent LinkProberStateMachine::mIcmpSelfEvent; -IcmpPeerEvent LinkProberStateMachine::mIcmpPeerEvent; -IcmpUnknownEvent LinkProberStateMachine::mIcmpUnknownEvent; -SuspendTimerExpiredEvent LinkProberStateMachine::mSuspendTimerExpiredEvent; -SwitchActiveCommandCompleteEvent LinkProberStateMachine::mSwitchActiveCommandCompleteEvent; -SwitchActiveRequestEvent LinkProberStateMachine::mSwitchActiveRequestEvent; - -// -// ---> LinkProberStateMachine( -// link_manager::LinkManagerStateMachine &linkManagerStateMachine, -// boost::asio::io_service::strand &strand, -// common::MuxPortConfig &muxPortConfig, -// LinkProberState::Label label -// ); -// -// class constructor -// -LinkProberStateMachine::LinkProberStateMachine( - link_manager::LinkManagerStateMachine &linkManagerStateMachine, - boost::asio::io_service::strand &strand, - common::MuxPortConfig &muxPortConfig, - LinkProberState::Label label -) : - StateMachine(strand, muxPortConfig), - mLinkManagerStateMachine(linkManagerStateMachine), - mActiveState(*this, muxPortConfig), - mStandbyState(*this, muxPortConfig), - mUnknownState(*this, muxPortConfig), - mWaitState(*this, muxPortConfig) -{ - enterState(label); -} - -// -// ---> enterState(LinkProberState::Label label); -// -// force the state machine to enter a given state -// -void LinkProberStateMachine::enterState(LinkProberState::Label label) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - switch (label) { - case LinkProberState::Label::Active: - setCurrentState(dynamic_cast (getActiveState())); - break; - case LinkProberState::Label::Standby: - setCurrentState(dynamic_cast (getStandbyState())); - break; - case LinkProberState::Label::Unknown: - setCurrentState(dynamic_cast (getUnknownState())); - break; - case LinkProberState::Label::Wait: - setCurrentState(dynamic_cast (getWaitState())); - break; - default: - break; - } -} - -// -// ---> postLinkManagerEvent(LinkProberState* linkProberState); -// -// post LinkProberState change event to LinkManager state machine -// -inline -void LinkProberStateMachine::postLinkManagerEvent(LinkProberState* linkProberState) -{ - boost::asio::io_service::strand &strand = mLinkManagerStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&link_manager::LinkManagerStateMachine::handleStateChange), - &mLinkManagerStateMachine, - link_manager::LinkManagerStateMachine::getLinkProberEvent(), - linkProberState->getStateLabel() - ))); -} - -// -// ---> LinkProberStateMachine::postLinkProberStateEvent(E &e); -// -// post LinkProberState event to the state machine -// -template -void LinkProberStateMachine::postLinkProberStateEvent(E &e) -{ - boost::asio::io_service::strand &strand = getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&LinkProberStateMachine::processEvent), - this, - e - ))); -} - -// -// ---> LinkProberStateMachine::postLinkProberStateEvent(IcmpSelfEvent &e); -// -// post LinkProberState IcmpSelfEvent to the state machine -// -template -void LinkProberStateMachine::postLinkProberStateEvent(IcmpSelfEvent &event); - -// -// ---> LinkProberStateMachine::postLinkProberStateEvent(IcmpPeerEvent &e); -// -// post LinkProberState IcmpPeerEvent to the state machine -// -template -void LinkProberStateMachine::postLinkProberStateEvent(IcmpPeerEvent &event); - -// -// ---> LinkProberStateMachine::postLinkProberStateEvent(IcmpUnknownEvent &e); -// -// post LinkProberState IcmpUnknownEvent to the state machine -// -template -void LinkProberStateMachine::postLinkProberStateEvent(IcmpUnknownEvent &event); - -// -// ---> LinkProberStateMachine::processEvent(T &t); -// -// process LinkProberState event -// -template -void LinkProberStateMachine::processEvent(T &t) -{ - LinkProberState *currentLinkProberState = dynamic_cast (getCurrentState()); - LinkProberState *nextLinkProberState = currentLinkProberState->handleEvent(t); - if (nextLinkProberState != currentLinkProberState) { - postLinkManagerEvent(nextLinkProberState); - } - setCurrentState(nextLinkProberState); -} - -// -// ---> LinkProberStateMachine::processEvent(IcmpSelfEvent &t); -// -// process LinkProberState IcmpSelfEvent -// -template -void LinkProberStateMachine::processEvent(IcmpSelfEvent &event); - -// -// ---> LinkProberStateMachine::processEvent(IcmpPeerEvent &t); -// -// process LinkProberState IcmpPeerEvent -// -template -void LinkProberStateMachine::processEvent(IcmpPeerEvent &event); - -// -// ---> LinkProberStateMachine::processEvent(IcmpUnknownEvent &t); -// -// process LinkProberState IcmpUnknownEvent -// -template -void LinkProberStateMachine::processEvent(IcmpUnknownEvent &event); - -// -// ---> processEvent(SuspendTimerExpiredEvent &suspendTimerExpiredEvent); -// -// process LinkProberState suspend timer expiry event -// -void LinkProberStateMachine::processEvent(SuspendTimerExpiredEvent &suspendTimerExpiredEvent) -{ - boost::asio::io_service::strand &strand = mLinkManagerStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleSuspendTimerExpiry, - &mLinkManagerStateMachine - ))); -} - -// -// ---> processEvent(SwitchActiveCommandCompleteEvent &switchActiveCommandCompleteEvent); -// -// process LinkProberState switch active complete event -// -void LinkProberStateMachine::processEvent(SwitchActiveCommandCompleteEvent &switchActiveCommandCompleteEvent) -{ - boost::asio::io_service::strand &strand = mLinkManagerStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleSwitchActiveCommandCompletion, - &mLinkManagerStateMachine - ))); -} - -// -// ---> processEvent(SwitchActiveRequestEvent &switchActiveRequestEvent); -// -// process LinkProberState switch active request event -// -void LinkProberStateMachine::processEvent(SwitchActiveRequestEvent &switchActiveRequestEvent) -{ - boost::asio::io_service::strand &strand = mLinkManagerStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleSwitchActiveRequestEvent, - &mLinkManagerStateMachine - ))); -} - -// -// ---> handleMackAddressUpdate(const std::array address); -// -// process LinkProberState MAC address update event -// -void LinkProberStateMachine::handleMackAddressUpdate(const std::array address) -{ - boost::asio::io_service::strand &strand = mLinkManagerStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - &link_manager::LinkManagerStateMachine::handleGetServerMacAddressNotification, - &mLinkManagerStateMachine, - address - ))); -} - -} /* namespace link_prober */ diff --git a/src/linkmgrd/src/link_prober/LinkProberStateMachine.h b/src/linkmgrd/src/link_prober/LinkProberStateMachine.h deleted file mode 100644 index 216c6ff8b4e3..000000000000 --- a/src/linkmgrd/src/link_prober/LinkProberStateMachine.h +++ /dev/null @@ -1,336 +0,0 @@ -/* - * LinkProberStateMachine.h - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#ifndef LINK_PROBER_LINKPROBERSTATEMACHINE_H_ -#define LINK_PROBER_LINKPROBERSTATEMACHINE_H_ - -#include -#include "link_prober/ActiveState.h" -#include "link_prober/StandbyState.h" -#include "link_prober/UnknownState.h" -#include "link_prober/WaitState.h" - -namespace link_manager { -class LinkManagerStateMachine; -} /* namespace link_manager */ - -namespace link_prober -{ -/** - *@class IcmpSelfEvent - * - *@brief signals a IcmpSelfEvent event to LinkProber state machine - */ -class IcmpSelfEvent { -public: - IcmpSelfEvent() = default; - ~IcmpSelfEvent() = default; -}; - -/** - *@class IcmpPeerEvent - * - *@brief signals a IcmpPeerEvent event to LinkProber state machine - */ -class IcmpPeerEvent { -public: - IcmpPeerEvent() = default; - ~IcmpPeerEvent() = default; -}; - -/** - *@class IcmpUnknownEvent - * - *@brief signals a IcmpUnknownEvent event to LinkProber state machine - */ -class IcmpUnknownEvent { -public: - IcmpUnknownEvent() = default; - ~IcmpUnknownEvent() = default; -}; - -/** - *@class SuspendTimerExpiredEvent - * - *@brief signals a SuspendTimerExpiredEvent event to LinkProber state machine - */ -class SuspendTimerExpiredEvent { -public: - SuspendTimerExpiredEvent() = default; - ~SuspendTimerExpiredEvent() = default; -}; - -/** - *@class SwitchActiveCommandCompleteEvent - * - *@brief signals a SwitchActiveCommandCompleteEvent event to LinkProber state machine - */ -class SwitchActiveCommandCompleteEvent { -public: - SwitchActiveCommandCompleteEvent() = default; - ~SwitchActiveCommandCompleteEvent() = default; -}; - -/** - *@class SwitchActiveRequestEvent - * - *@brief signals a SwitchActiveRequestEvent event to LinkProber state machine - */ -class SwitchActiveRequestEvent { -public: - SwitchActiveRequestEvent() = default; - ~SwitchActiveRequestEvent() = default; -}; - -/** - *@class LinkProberStateMachine - * - *@brief maintains LinkProber state machine - */ -class LinkProberStateMachine: public common::StateMachine -{ -public: - /** - *@method LinkProberStateMachine - * - *@brief class default constructor - */ - LinkProberStateMachine() = delete; - - /** - *@method LinkProberStateMachine - * - *@brief class copy constructor - * - *@param LinkProberStateMachine (in) reference to LinkProberStateMachine object to be copied - */ - LinkProberStateMachine(const LinkProberStateMachine &) = delete; - - /** - *@method LinkProberStateMachine - * - *@brief class constructor - * - *@param linkManagerStateMachine (in) reference to LinkManagerStateMachine - *@param strand (in) reference to boost serialization object - *@param muxPortConfig (in) reference to MuxPortConfig object - *@param label (in) state machine initial state - */ - LinkProberStateMachine( - link_manager::LinkManagerStateMachine &linkManagerStateMachine, - boost::asio::io_service::strand &strand, - common::MuxPortConfig &muxPortConfig, - LinkProberState::Label label - ); - - /** - *@method ~LinkProberStateMachine - * - *@brief class destructor - */ - virtual ~LinkProberStateMachine() = default; - - /** - *@method enterState - * - *@brief force the state machine to enter a given state - * - *@param label (in) label of target state - * - *@return none - */ - void enterState(LinkProberState::Label label); - - /** - *@method postLinkProberStateEvent - * - *@brief post LinkProberState event to the state machine - * - *@param e (in) reference to the LinkProberState event - * - *@return none - */ - template - void postLinkProberStateEvent(E &e); - - /** - *@method processEvent - * - *@brief process LinkProberState event - * - *@param t (in) reference to the LinkProberState event - * - *@return none - */ - template - void processEvent(T &t); - - /** - *@method processEvent - * - *@brief process LinkProberState suspend timer expiry event - * - *@param suspendTimerExpiredEvent (in) reference to the SuspendTimerExpiredEvent event - * - *@return none - */ - void processEvent(SuspendTimerExpiredEvent &suspendTimerExpiredEvent); - - /** - *@method processEvent - * - *@brief process LinkProberState send switch command completion - * - *@param switchActiveCommandCompleteEvent (in) reference to the SwitchActiveCommandCompleteEvent event - * - *@return none - */ - void processEvent(SwitchActiveCommandCompleteEvent &switchActiveCommandCompleteEvent); - - /** - *@method processEvent - * - *@brief process LinkProberState switch active request - * - *@param switchActiveRequestEvent (in) reference to the SwitchActiveRequestEvent event - * - *@return none - */ - void processEvent(SwitchActiveRequestEvent &switchActiveRequestEvent); - - /** - *@method handleMackAddressUpdate - * - *@brief process LinkProberState MAC address update event - * - *@param address (in) Server MAC address - * - *@return none - */ - void handleMackAddressUpdate(const std::array address); - - /** - *@method getActiveState - * - *@brief getter for ActiveState object - * - *@return pointer to ActiveState object - */ - ActiveState* getActiveState() {return &mActiveState;}; - - /** - *@method getStandbyState - * - *@brief getter for StandbyState object - * - *@return pointer to StandbyState object - */ - StandbyState* getStandbyState() {return &mStandbyState;}; - - /** - *@method getUnknownState - * - *@brief getter for UnknownState object - * - *@return pointer to UnknownState object - */ - UnknownState* getUnknownState() {return &mUnknownState;}; - - /** - *@method getWaitState - * - *@brief getter for WaitState object - * - *@return pointer to WaitState object - */ - WaitState* getWaitState() {return &mWaitState;}; - - /** - *@method getIcmpSelfEvent - * - *@brief getter for IcmpSelfEvent object - * - *@return pointer to IcmpSelfEvent object - */ - static IcmpSelfEvent& getIcmpSelfEvent() {return mIcmpSelfEvent;}; - - /** - *@method getIcmpPeerEvent - * - *@brief getter for IcmpPeerEvent object - * - *@return pointer to IcmpPeerEvent object - */ - static IcmpPeerEvent& getIcmpPeerEvent() {return mIcmpPeerEvent;}; - - /** - *@method getIcmpUnknownEvent - * - *@brief getter for IcmpUnknownEvent object - * - *@return pointer to IcmpUnknownEvent object - */ - static IcmpUnknownEvent& getIcmpUnknownEvent() {return mIcmpUnknownEvent;}; - - /** - *@method getSuspendTimerExpiredEvent - * - *@brief getter for SuspendTimerExpiredEvent object - * - *@return pointer to SuspendTimerExpiredEvent object - */ - static SuspendTimerExpiredEvent& getSuspendTimerExpiredEvent() {return mSuspendTimerExpiredEvent;}; - - /** - *@method getSwitchActiveCommandCompleteEvent - * - *@brief getter for SwitchActiveCommandCompleteEvent object - * - *@return pointer to SwitchActiveCommandCompleteEvent object - */ - static SwitchActiveCommandCompleteEvent& getSwitchActiveCommandCompleteEvent() {return mSwitchActiveCommandCompleteEvent;}; - - /** - *@method getSwitchActiveRequestEvent - * - *@brief getter for SwitchActiveRequestEvent object - * - *@return pointer to SwitchActiveRequestEvent object - */ - static SwitchActiveRequestEvent& getSwitchActiveRequestEvent() {return mSwitchActiveRequestEvent;}; - -private: - /** - *@method postLinkManagerEvent - * - *@brief post LinkProberState change event to LinkManager state machine - * - *@param linkProberState (in) pointer to current LinkProberState - * - *@return none - */ - inline void postLinkManagerEvent(LinkProberState* linkProberState); - -private: - static IcmpSelfEvent mIcmpSelfEvent; - static IcmpPeerEvent mIcmpPeerEvent; - static IcmpUnknownEvent mIcmpUnknownEvent; - static SuspendTimerExpiredEvent mSuspendTimerExpiredEvent; - static SwitchActiveCommandCompleteEvent mSwitchActiveCommandCompleteEvent; - static SwitchActiveRequestEvent mSwitchActiveRequestEvent; - -private: - link_manager::LinkManagerStateMachine &mLinkManagerStateMachine; - ActiveState mActiveState; - StandbyState mStandbyState; - UnknownState mUnknownState; - WaitState mWaitState; -}; - -} /* namespace link_prober */ - -#endif /* LINK_PROBER_LINKPROBERSTATEMACHINE_H_ */ diff --git a/src/linkmgrd/src/link_prober/StandbyState.cpp b/src/linkmgrd/src/link_prober/StandbyState.cpp deleted file mode 100644 index a7aac51c7136..000000000000 --- a/src/linkmgrd/src/link_prober/StandbyState.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * StandbyState.cpp - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#include "link_prober/ActiveState.h" -#include "link_prober/StandbyState.h" -#include "link_prober/UnknownState.h" -#include "link_prober/LinkProberStateMachine.h" - -#include "common/MuxLogger.h" - -namespace link_prober -{ - -// -// ---> StandbyState(LinkProberStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -StandbyState::StandbyState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - LinkProberState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(IcmpPeerEvent &event); -// -// handle IcmpPeerEvent from LinkProber -// -LinkProberState* StandbyState::handleEvent(IcmpPeerEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState = - dynamic_cast (stateMachine->getStandbyState()); - - resetState(); - - return nextState; -} - -// -// ---> handleEvent(IcmpSelfEvent &event); -// -// handle IcmpSelfEvent from LinkProber -// -LinkProberState* StandbyState::handleEvent(IcmpSelfEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState; - - mUnknownEventCount = 0; - if (++mSelfEventCount >= getMuxPortConfig().getPositiveStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - else { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - - return nextState; -} - -// -// ---> handleEvent(IcmpUnknownEvent &event); -// -// handle IcmpUnknownEvent from LinkProber -// -LinkProberState* StandbyState::handleEvent(IcmpUnknownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState; - - mSelfEventCount = 0; - if (++mUnknownEventCount >= getMuxPortConfig().getNegativeStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - else { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - - return nextState; -} - -// -// ---> resetState(); -// -// reset current state attributes -// -void StandbyState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - mSelfEventCount = 0; - mUnknownEventCount = 0; -} - -} /* namespace link_prober */ diff --git a/src/linkmgrd/src/link_prober/StandbyState.h b/src/linkmgrd/src/link_prober/StandbyState.h deleted file mode 100644 index e3a2d4c8b98e..000000000000 --- a/src/linkmgrd/src/link_prober/StandbyState.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * StandbyState.h - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#ifndef LINK_PROBER_STANDBYSTATE_H_ -#define LINK_PROBER_STANDBYSTATE_H_ - -#include "LinkProberState.h" - -namespace link_prober -{ -class LinkProberStateMachine; - -/** - *@class StandbyState - * - *@brief maintains Standby state of LinkProber - */ -class StandbyState : public LinkProberState -{ -public: - /** - *@method StandbyState - * - *@brief class default constructor - */ - StandbyState() = delete; - - /** - *@method StandbyState - * - *@brief class copy constructor - * - *@param StandbyState (in) reference to StandbyState object to be copied - */ - StandbyState(const StandbyState &) = delete; - - /** - *@method StandbyState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkProberStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - StandbyState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~StandbyState - * - *@brief class destructor - */ - virtual ~StandbyState() = default; - - /** - *@method handleEvent - * - *@brief handle IcmpPeerEvent from LinkProber - * - *@param event (in) reference to IcmpPeerEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpPeerEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle IcmpSelfEvent from LinkProber - * - *@param event (in) reference to IcmpSelfEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpSelfEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle IcmpUnknownEvent from LinkProber - * - *@param event (in) reference to IcmpUnknownEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpUnknownEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for LinkeProberState label - * - *@return LinkProberState Standby label - */ - virtual LinkProberState::Label getStateLabel() override {return LinkProberState::Label::Standby;}; - -private: - uint8_t mSelfEventCount = 0; - uint8_t mUnknownEventCount = 0; -}; - -} /* namespace link_prober */ - -#endif /* LINK_PROBER_STANDBYSTATE_H_ */ diff --git a/src/linkmgrd/src/link_prober/UnknownState.cpp b/src/linkmgrd/src/link_prober/UnknownState.cpp deleted file mode 100644 index 0da56f31221b..000000000000 --- a/src/linkmgrd/src/link_prober/UnknownState.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * UnknownState.cpp - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#include "link_prober/ActiveState.h" -#include "link_prober/StandbyState.h" -#include "link_prober/UnknownState.h" -#include "link_prober/LinkProberStateMachine.h" - -#include "common/MuxLogger.h" - -namespace link_prober -{ - -// -// ---> UnknownState(LinkProberStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -UnknownState::UnknownState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - LinkProberState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(IcmpPeerEvent &event); -// -// handle IcmpPeerEvent from LinkProber -// -LinkProberState* UnknownState::handleEvent(IcmpPeerEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - LinkProberState *nextState; - - mSelfEventCount = 0; - if (++mPeerEventCount >= getMuxPortConfig().getPositiveStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - else { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - - return nextState; -} - -// -// ---> handleEvent(IcmpSelfEvent &event); -// -// handle IcmpSelfEvent from LinkProber -// -LinkProberState* UnknownState::handleEvent(IcmpSelfEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - LinkProberState *nextState; - - mPeerEventCount = 0; - if (++mSelfEventCount >= getMuxPortConfig().getPositiveStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - else { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - - return nextState; -} - -// -// ---> handleEvent(IcmpUnknownEvent &event); -// -// handle IcmpUnknownEvent from LinkProber -// -LinkProberState* UnknownState::handleEvent(IcmpUnknownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState = dynamic_cast (stateMachine->getUnknownState()); - - resetState(); - - return nextState; -} - -// -// ---> resetState(); -// -// reset current state attributes -// -void UnknownState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - mSelfEventCount = 0; - mPeerEventCount = 0; -} - -} /* namespace link_prober */ diff --git a/src/linkmgrd/src/link_prober/UnknownState.h b/src/linkmgrd/src/link_prober/UnknownState.h deleted file mode 100644 index 4f2544b29e6d..000000000000 --- a/src/linkmgrd/src/link_prober/UnknownState.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * UnknownState.h - * - * Created on: Oct 7, 2020 - * Author: tamer - */ - -#ifndef LINK_PROBER_UNKNOWNSTATE_H_ -#define LINK_PROBER_UNKNOWNSTATE_H_ - -#include - -#include "LinkProberState.h" - -namespace link_prober -{ -class LinkProberStateMachine; - -/** - *@class UnknownState - * - *@brief maintains Unknown state of LinkProber - */ -class UnknownState : public LinkProberState -{ -public: - /** - *@method UnknownState - * - *@brief class default constructor - */ - UnknownState() = delete; - - /** - *@method UnknownState - * - *@brief class copy constructor - * - *@param UnknownState (in) reference to UnknownState object to be copied - */ - UnknownState(const UnknownState &) = delete; - - /** - *@method UnknownState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkProberStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - UnknownState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~UnknownState - * - *@brief class destructor - */ - virtual ~UnknownState() = default; - - /** - *@method handleEvent - * - *@brief handle IcmpPeerEvent from LinkProber - * - *@param event (in) reference to IcmpPeerEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpPeerEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle IcmpSelfEvent from LinkProber - * - *@param event (in) reference to IcmpSelfEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpSelfEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle IcmpUnknownEvent from LinkProber - * - *@param event (in) reference to IcmpUnknownEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpUnknownEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for LinkeProberState label - * - *@return LinkProberState Unknown label - */ - virtual LinkProberState::Label getStateLabel() override {return LinkProberState::Label::Unknown;}; - -private: - uint8_t mSelfEventCount = 0; - uint8_t mPeerEventCount = 0; -}; - -} /* namespace link_prober */ - -#endif /* LINK_PROBER_UNKNOWNSTATE_H_ */ diff --git a/src/linkmgrd/src/link_prober/WaitState.cpp b/src/linkmgrd/src/link_prober/WaitState.cpp deleted file mode 100644 index 574b3620eb37..000000000000 --- a/src/linkmgrd/src/link_prober/WaitState.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * WaitState.cpp - * - * Created on: Oct 18, 2020 - * Author: tamer - */ - -#include "link_prober/ActiveState.h" -#include "link_prober/StandbyState.h" -#include "link_prober/WaitState.h" -#include "link_prober/LinkProberStateMachine.h" - -#include "common/MuxLogger.h" - -namespace link_prober -{ - -// -// ---> WaitState(LinkProberStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -WaitState::WaitState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - LinkProberState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(IcmpPeerEvent &event); -// -// handle IcmpPeerEvent from LinkProber -// -LinkProberState* WaitState::handleEvent(IcmpPeerEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState; - - mSelfEventCount = 0; - if (++mPeerEventCount >= getMuxPortConfig().getPositiveStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - else { - nextState = dynamic_cast (stateMachine->getWaitState()); - } - - return nextState; -} - -// -// ---> handleEvent(IcmpSelfEvent &event); -// -// handle IcmpSelfEvent from LinkProber -// -LinkProberState* WaitState::handleEvent(IcmpSelfEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState; - - mPeerEventCount = 0; - if (++mSelfEventCount >= getMuxPortConfig().getPositiveStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - else { - nextState = dynamic_cast (stateMachine->getWaitState()); - } - - return nextState; -} - -// -// ---> handleEvent(IcmpUnknownEvent &event); -// -// handle IcmpUnknownEvent from LinkProber -// -LinkProberState* WaitState::handleEvent(IcmpUnknownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkProberStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkProberState *nextState = dynamic_cast (stateMachine->getWaitState()); - - resetState(); - - return nextState; -} - -// -// ---> resetState(); -// -// reset current state attributes -// -void WaitState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - mSelfEventCount = 0; - mPeerEventCount = 0; -} - -} /* namespace link_prober */ diff --git a/src/linkmgrd/src/link_prober/WaitState.h b/src/linkmgrd/src/link_prober/WaitState.h deleted file mode 100644 index 6f3a8e2a1c97..000000000000 --- a/src/linkmgrd/src/link_prober/WaitState.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * WaitState.h - * - * Created on: Oct 18, 2020 - * Author: tamer - */ - -#ifndef LINK_PROBER_WAITSTATE_H_ -#define LINK_PROBER_WAITSTATE_H_ - -#include - -#include "LinkProberState.h" - -namespace link_prober -{ -class LinkProberStateMachine; - -/** - *@class WaitState - * - *@brief maintains Wait state of LinkProber - */ -class WaitState : public LinkProberState -{ -public: - /** - *@method WaitState - * - *@brief class default constructor - */ - WaitState() = delete; - - /** - *@method WaitState - * - *@brief class copy constructor - * - *@param WaitState (in) reference to WaitState object to be copied - */ - WaitState(const WaitState &) = delete; - - /** - *@method WaitState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkProberStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - WaitState( - LinkProberStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~WaitState - * - *@brief class destructor - */ - virtual ~WaitState() = default; - - /** - *@method handleEvent - * - *@brief handle IcmpPeerEvent from LinkProber - * - *@param event (in) reference to IcmpPeerEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpPeerEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle IcmpSelfEvent from LinkProber - * - *@param event (in) reference to IcmpSelfEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpSelfEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle IcmpUnknownEvent from LinkProber - * - *@param event (in) reference to IcmpUnknownEvent - * - *@return pointer to next LinkProberState - */ - virtual LinkProberState* handleEvent(IcmpUnknownEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for LinkeProberState label - * - *@return LinkProberState Wait label - */ - virtual LinkProberState::Label getStateLabel() override {return LinkProberState::Label::Wait;}; - -private: - uint8_t mSelfEventCount = 0; - uint8_t mPeerEventCount = 0; -}; - -} /* namespace link_prober */ - -#endif /* LINK_PROBER_WAITSTATE_H_ */ diff --git a/src/linkmgrd/src/link_prober/subdir.mk b/src/linkmgrd/src/link_prober/subdir.mk deleted file mode 100644 index 351ce222637b..000000000000 --- a/src/linkmgrd/src/link_prober/subdir.mk +++ /dev/null @@ -1,41 +0,0 @@ -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ - ./src/link_prober/ActiveState.cpp \ - ./src/link_prober/IcmpPayload.cpp \ - ./src/link_prober/LinkProber.cpp \ - ./src/link_prober/LinkProberState.cpp \ - ./src/link_prober/LinkProberStateMachine.cpp \ - ./src/link_prober/StandbyState.cpp \ - ./src/link_prober/UnknownState.cpp \ - ./src/link_prober/WaitState.cpp - -OBJS += \ - ./src/link_prober/ActiveState.o \ - ./src/link_prober/IcmpPayload.o \ - ./src/link_prober/LinkProber.o \ - ./src/link_prober/LinkProberState.o \ - ./src/link_prober/LinkProberStateMachine.o \ - ./src/link_prober/StandbyState.o \ - ./src/link_prober/UnknownState.o \ - ./src/link_prober/WaitState.o - -CPP_DEPS += \ - ./src/link_prober/ActiveState.d \ - ./src/link_prober/IcmpPayload.d \ - ./src/link_prober/LinkProber.d \ - ./src/link_prober/LinkProberState.d \ - ./src/link_prober/LinkProberStateMachine.d \ - ./src/link_prober/StandbyState.d \ - ./src/link_prober/UnknownState.d \ - ./src/link_prober/WaitState.d - - -# Each subdirectory must supply rules for building sources it contributes -src/link_prober/%.o: src/link_prober/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - $(CC) -std=c++17 -D__FILENAME__="$(subst src/,,$<)" $(BOOST_MACROS) $(INCLUDES) $(CPP_FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/src/linkmgrd/src/link_state/DownState.cpp b/src/linkmgrd/src/link_state/DownState.cpp deleted file mode 100644 index e99833f7d76c..000000000000 --- a/src/linkmgrd/src/link_state/DownState.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * DownState.cpp - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#include "common/MuxLogger.h" -#include "link_state/DownState.h" -#include "link_state/UpState.h" -#include "link_state/LinkStateMachine.h" - -namespace link_state -{ - -// -// ---> DownState(LinkStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -DownState::DownState( - LinkStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - LinkState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(UpEvent &event); -// -// handle UpEvent from state db -// -LinkState* DownState::handleEvent(UpEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkState *nextState; - - if (++mUpEventCount >= getMuxPortConfig().getLinkStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getUpState()); - } - else { - nextState = dynamic_cast (stateMachine->getDownState()); - } - - return nextState; -} - -// -// ---> handleEvent(DownEvent &event); -// -// handle DownEvent from state db -// -LinkState* DownState::handleEvent(DownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkState *nextState = dynamic_cast (stateMachine->getDownState()); - - resetState(); - - return nextState; -} - -// -// ---> resetState(); -// -// reset current state attributes -// -void DownState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - mUpEventCount = 0; -} - -} /* namespace link_state */ diff --git a/src/linkmgrd/src/link_state/DownState.h b/src/linkmgrd/src/link_state/DownState.h deleted file mode 100644 index 9c4dfa325882..000000000000 --- a/src/linkmgrd/src/link_state/DownState.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * DownState.h - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#ifndef LINK_STATE_DOWNSTATE_H_ -#define LINK_STATE_DOWNSTATE_H_ - -#include - -namespace link_state -{ - -/** - *@class DownState - * - *@brief maintains DownState state of LinkState - */ -class DownState: public LinkState -{ -public: - /** - *@method DownState - * - *@brief class default constructor - */ - DownState() = delete; - - /** - *@method DownState - * - *@brief class copy constructor - * - *@param DownState (in) reference to DownState object to be copied - */ - DownState(const DownState &) = delete; - - /** - *@method DownState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - DownState( - LinkStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~DownState - * - *@brief class destructor - */ - virtual ~DownState() = default; - - /** - *@method handleEvent - * - *@brief handle UpEvent from state db - * - *@param event (in) reference to UpEvent - * - *@return pointer to next LinkState - */ - virtual LinkState* handleEvent(UpEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle DownEvent from state db - * - *@param event (in) reference to DownEvent - * - *@return pointer to next LinkState - */ - virtual LinkState* handleEvent(DownEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for LinkState label - * - *@return LinkState Down label - */ - virtual LinkState::Label getStateLabel() override {return LinkState::Label::Down;}; - -private: - uint8_t mUpEventCount = 0; -}; - -} /* namespace link_state */ - -#endif /* LINK_STATE_DOWNSTATE_H_ */ diff --git a/src/linkmgrd/src/link_state/LinkState.cpp b/src/linkmgrd/src/link_state/LinkState.cpp deleted file mode 100644 index 036e5020b1f7..000000000000 --- a/src/linkmgrd/src/link_state/LinkState.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * LinkState.cpp - * - * Created on: Oct 18, 2020 - * Author: tamer - */ - -#include -#include - -namespace link_state -{ - -// -// ---> LinkState(LinkStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -LinkState::LinkState( - LinkStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - common::State( - *dynamic_cast (&stateMachine), - muxPortConfig - ) -{ -} - -} /* namespace link_state */ diff --git a/src/linkmgrd/src/link_state/LinkState.h b/src/linkmgrd/src/link_state/LinkState.h deleted file mode 100644 index ba2319fd9fde..000000000000 --- a/src/linkmgrd/src/link_state/LinkState.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * LinkState.h - * - * Created on: Oct 18, 2020 - * Author: tamer - */ - -#ifndef LINK_STATE_LINKSTATE_H_ -#define LINK_STATE_LINKSTATE_H_ - -#include - -namespace link_state -{ -class LinkStateMachine; -class UpEvent; -class DownEvent; - -/** - *@class LinkState - * - *@brief base class for different LinkState states - */ -class LinkState: public common::State -{ -public: - /** - *@enum Label - * - *@brief Label corresponding to each LinkState State - */ - enum Label { - Up, - Down, - - Count - }; - -public: - /** - *@method LinkState - * - *@brief class default constructor - */ - LinkState() = delete; - - /** - *@method LinkState - * - *@brief class copy constructor - * - *@param LinkState (in) reference to LinkState object to be copied - */ - LinkState(const LinkState &) = delete; - - /** - *@method LinkState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkProberStateMachine object - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - LinkState( - LinkStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~LinkProber - * - *@brief class destructor - */ - virtual ~LinkState() = default; - - /** - *@method handleEvent - * - *@brief handle UpEvent from state db - * - *@param event (in) reference to UpEvent - * - *@return pointer to next LinkState - */ - virtual LinkState* handleEvent(UpEvent &event) = 0; - - /** - *@method handleEvent - * - *@brief handle DownEvent from state db - * - *@param event (in) reference to DownEvent - * - *@return pointer to next LinkState - */ - virtual LinkState* handleEvent(DownEvent &event) = 0; - - /** - *@method getStateLabel - * - *@brief getter for LinkState label - * - *@return LinkState Down label - */ - virtual LinkState::Label getStateLabel() = 0; -}; - -} /* namespace link_state */ - -#endif /* LINK_STATE_LINKSTATE_H_ */ diff --git a/src/linkmgrd/src/link_state/LinkStateMachine.cpp b/src/linkmgrd/src/link_state/LinkStateMachine.cpp deleted file mode 100644 index ae039b864ecb..000000000000 --- a/src/linkmgrd/src/link_state/LinkStateMachine.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* - * LinkStateMachine.cpp - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#include - -#include "common/MuxLogger.h" -#include "link_state/LinkStateMachine.h" -#include "link_manager/LinkManagerStateMachine.h" - - -namespace link_state -{ -// -// static members -// -UpEvent LinkStateMachine::mUpEvent; -DownEvent LinkStateMachine::mDownEvent; - -// -// ---> LinkStateMachine( -// link_manager::LinkManagerStateMachine &linkManagerStateMachine, -// boost::asio::io_service::strand &strand, -// common::MuxPortConfig &muxPortConfig, -// LinkState::Label label -// ); -// -// class constructor -// -LinkStateMachine::LinkStateMachine( - link_manager::LinkManagerStateMachine &linkManagerStateMachine, - boost::asio::io_service::strand &strand, - common::MuxPortConfig &muxPortConfig, - LinkState::Label label -) : - common::StateMachine(strand, muxPortConfig), - mLinkManagerStateMachine(linkManagerStateMachine), - mUpState(*this, muxPortConfig), - mDownState(*this, muxPortConfig) -{ - enterState(label); -} - -// -// ---> enterState(LinkState::Label label); -// -// force the state machine to enter a given state -// -void LinkStateMachine::enterState(LinkState::Label label) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - switch (label) { - case LinkState::Label::Up: - setCurrentState(dynamic_cast (getUpState())); - break; - case LinkState::Label::Down: - setCurrentState(dynamic_cast (getDownState())); - break; - default: - break; - } -} - -// -// ---> postLinkManagerEvent(LinkState* linkState); -// -// post LinkState change event to LinkManager state machine -// -inline -void LinkStateMachine::postLinkManagerEvent(LinkState* linkState) -{ - boost::asio::io_service::strand &strand = mLinkManagerStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&link_manager::LinkManagerStateMachine::handleStateChange), - &mLinkManagerStateMachine, - link_manager::LinkManagerStateMachine::getLinkStateEvent(), - linkState->getStateLabel() - ))); -} - -// -// ---> LinkStateMachine::postLinkStateEvent(E &e); -// -// post LinkState event to the state machine -// -template -void LinkStateMachine::postLinkStateEvent(E &e) -{ - boost::asio::io_service::strand &strand = getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&LinkStateMachine::processEvent), - this, - e - ))); -} - -// -// ---> postLinkStateEvent(UpEvent &e); -// -// post LinkState event to the state machine -// -template -void LinkStateMachine::postLinkStateEvent(UpEvent &e); - -// -// ---> postLinkStateEvent(DownEvent &e); -// -// post LinkState event to the state machine -// -template -void LinkStateMachine::postLinkStateEvent(DownEvent &e); - -// -// ---> processEvent(T &t); -// -// process LinkState event -// -template -void LinkStateMachine::processEvent(T &t) -{ - LinkState *currentLinkState = dynamic_cast (getCurrentState()); - LinkState *nextLinkState = currentLinkState->handleEvent(t); - if (nextLinkState != currentLinkState) { - postLinkManagerEvent(nextLinkState); - } - setCurrentState(nextLinkState); -} - -// -// ---> processEvent(UpEvent &event); -// -// process LinkState event -// -template -void LinkStateMachine::processEvent(UpEvent &event); - -// -// ---> processEvent(DownEvent &event); -// -// process LinkState event -// -template -void LinkStateMachine::processEvent(DownEvent &event); - -} /* namespace link_state */ diff --git a/src/linkmgrd/src/link_state/LinkStateMachine.h b/src/linkmgrd/src/link_state/LinkStateMachine.h deleted file mode 100644 index 3561db1381f2..000000000000 --- a/src/linkmgrd/src/link_state/LinkStateMachine.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * LinkStateMachine.h - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#ifndef LINK_STATE_LINKSTATEMACHINE_H_ -#define LINK_STATE_LINKSTATEMACHINE_H_ - -#include "common/StateMachine.h" -#include "DownState.h" -#include "UpState.h" - -namespace link_manager { -class LinkManagerStateMachine; -} /* namespace link_manager */ - -namespace link_state -{ -/** - *@class UpEvent - * - *@brief signals a UpEvent event to LinkState state machine - */ -class UpEvent { -public: - UpEvent() = default; - ~UpEvent() = default; -}; - -/** - *@class DownEvent - * - *@brief signals a DownEvent event to LinkState state machine - */ -class DownEvent { -public: - DownEvent() = default; - ~DownEvent() = default; -}; - -/** - *@class LinkStateMachine - * - *@brief maintains LineState state machine - */ -class LinkStateMachine: public common::StateMachine -{ -public: - /** - *@method LinkStateMachine - * - *@brief class default constructor - */ - LinkStateMachine() = delete; - - /** - *@method LinkStateMachine - * - *@brief class copy constructor - * - *@param LinkStateMachine (in) reference to LinkStateMachine object to be copied - */ - LinkStateMachine(const LinkStateMachine &) = delete; - - /** - *@method LinkStateMachine - * - *@brief class constructor - * - *@param linkManagerStateMachine (in) reference to LinkManagerStateMachine - *@param strand (in) reference to boost serialization object - *@param muxPortConfig (in) reference to MuxPortConfig object - *@param label (in) state machine initial state - */ - LinkStateMachine( - link_manager::LinkManagerStateMachine &linkManagerStateMachine, - boost::asio::io_service::strand &strand, - common::MuxPortConfig &muxPortConfig, - LinkState::Label label - ); - - /** - *@method ~LinkStateMachine - * - *@brief class destructor - */ - virtual ~LinkStateMachine() = default; - - /** - *@method enterState - * - *@brief force the state machine to enter a given state - * - *@param label (in) label of target state - * - *@return none - */ - void enterState(LinkState::Label label); - - /** - *@method postLinkStateEvent - * - *@brief post LinkState event to the state machine - * - *@param e (in) reference to the LinkState event - * - *@return none - */ - template - void postLinkStateEvent(E &e); - - /** - *@method processEvent - * - *@brief process LinkState event - * - *@param t (in) reference to the LinkState event - * - *@return none - */ - template - void processEvent(T &t); - - /** - *@method getUpState - * - *@brief getter for UpState object - * - *@return pointer to UpState object - */ - UpState* getUpState() {return &mUpState;}; - - /** - *@method getDownState - * - *@brief getter for DownState object - * - *@return pointer to DownState object - */ - DownState* getDownState() {return &mDownState;}; - - /** - *@method getUpEvent - * - *@brief getter for UpEvent object - * - *@return pointer to UpEvent object - */ - static UpEvent& getUpEvent() {return mUpEvent;}; - - /** - *@method getDownEvent - * - *@brief getter for DownEvent object - * - *@return pointer to DownEvent object - */ - static DownEvent& getDownEvent() {return mDownEvent;}; - -private: - /** - *@method postLinkManagerEvent - * - *@brief post LinkState change event to LinkManager state machine - * - *@param LinkState (in) pointer to current LinkState - * - *@return none - */ - inline void postLinkManagerEvent(LinkState* linkState); - -private: - static UpEvent mUpEvent; - static DownEvent mDownEvent; - -private: - link_manager::LinkManagerStateMachine &mLinkManagerStateMachine; - UpState mUpState; - DownState mDownState; -}; - -} /* namespace link_state */ - -#endif /* LINK_STATE_LINKSTATEMACHINE_H_ */ diff --git a/src/linkmgrd/src/link_state/UpState.cpp b/src/linkmgrd/src/link_state/UpState.cpp deleted file mode 100644 index 5f2efda2be48..000000000000 --- a/src/linkmgrd/src/link_state/UpState.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * UpState.cpp - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#include "common/MuxLogger.h" -#include "link_state/DownState.h" -#include "link_state/UpState.h" -#include "link_state/LinkStateMachine.h" - -namespace link_state -{ - -// -// ---> UpState(LinkStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -UpState::UpState( - LinkStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - LinkState(stateMachine, muxPortConfig) -{ -} - -// -// --->handleEvent(UpEvent &event); -// -// handle UpEvent from state db -// -LinkState* UpState::handleEvent(UpEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkState *nextState = dynamic_cast (stateMachine->getUpState()); - - resetState(); - - return nextState; -} - -// -// --->handleEvent(DownEvent &event); -// -// handle UpEvent from state db -// -LinkState* UpState::handleEvent(DownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - LinkStateMachine *stateMachine = dynamic_cast (getStateMachine()); - LinkState *nextState; - - if (++mDownEventCount >= getMuxPortConfig().getLinkStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getDownState()); - } - else { - nextState = dynamic_cast (stateMachine->getUpState()); - } - - return nextState; -} - -// -// --->resetState(); -// -// reset current state attributes -// -void UpState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - mDownEventCount = 0; -} - -} /* namespace link_state */ diff --git a/src/linkmgrd/src/link_state/UpState.h b/src/linkmgrd/src/link_state/UpState.h deleted file mode 100644 index 7cbb867b2314..000000000000 --- a/src/linkmgrd/src/link_state/UpState.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * UpState.h - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#ifndef LINK_STATE_UPSTATE_H_ -#define LINK_STATE_UPSTATE_H_ - -#include - -namespace link_state -{ - -/** - *@class DownState - * - *@brief maintains DownState state of LinkState - */ -class UpState: public LinkState -{ -public: - /** - *@method UpState - * - *@brief class default constructor - */ - UpState() = delete; - - /** - *@method UpState - * - *@brief class copy constructor - * - *@param UpState (in) reference to UpState object to be copied - */ - UpState(const UpState &) = delete; - - /** - *@method UpState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - UpState( - LinkStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~UpState - * - *@brief class destructor - */ - virtual ~UpState() = default; - - /** - *@method handleEvent - * - *@brief handle UpEvent from state db - * - *@param event (in) reference to UpEvent - * - *@return pointer to next LinkState - */ - virtual LinkState* handleEvent(UpEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle DownEvent from state db - * - *@param event (in) reference to DownEvent - * - *@return pointer to next LinkState - */ - virtual LinkState* handleEvent(DownEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for LinkState label - * - *@return LinkState Up label - */ - virtual LinkState::Label getStateLabel() override {return LinkState::Label::Up;}; - -private: - uint8_t mDownEventCount = 0; -}; - -} /* namespace link_state */ - -#endif /* LINK_STATE_UPSTATE_H_ */ diff --git a/src/linkmgrd/src/link_state/subdir.mk b/src/linkmgrd/src/link_state/subdir.mk deleted file mode 100644 index ad532a9af1ce..000000000000 --- a/src/linkmgrd/src/link_state/subdir.mk +++ /dev/null @@ -1,29 +0,0 @@ -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ - ./src/link_state/DownState.cpp \ - ./src/link_state/LinkState.cpp \ - ./src/link_state/LinkStateMachine.cpp \ - ./src/link_state/UpState.cpp - -OBJS += \ - ./src/link_state/DownState.o \ - ./src/link_state/LinkState.o \ - ./src/link_state/LinkStateMachine.o \ - ./src/link_state/UpState.o - -CPP_DEPS += \ - ./src/link_state/DownState.d \ - ./src/link_state/LinkState.d \ - ./src/link_state/LinkStateMachine.d \ - ./src/link_state/UpState.d - - -# Each subdirectory must supply rules for building sources it contributes -src/link_state/%.o: src/link_state/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - $(CC) -std=c++17 -D__FILENAME__="$(subst src/,,$<)" $(BOOST_MACROS) $(INCLUDES) $(CPP_FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/src/linkmgrd/src/mux_state/ActiveState.cpp b/src/linkmgrd/src/mux_state/ActiveState.cpp deleted file mode 100644 index d2d03c61b29a..000000000000 --- a/src/linkmgrd/src/mux_state/ActiveState.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * ActiveState.cpp - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#include "mux_state/ActiveState.h" -#include "mux_state/StandbyState.h" -#include "mux_state/MuxStateMachine.h" - -#include "common/MuxLogger.h" -#include "UnknownState.h" - -namespace mux_state -{ - -// -// ---> ActiveState(MuxStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -ActiveState::ActiveState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - MuxState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(ActiveEvent &event); -// -// handle ActiveEvent from state db/xcvrd -// -MuxState* ActiveState::handleEvent(ActiveEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = dynamic_cast (getStateMachine()); - MuxState *nextState = - dynamic_cast (stateMachine->getActiveState()); - - resetState(); - - return nextState; -} - -// -// ---> handleEvent(StandbyEvent &event); -// -// handle StandbyEvent from state db/xcvrd -// -MuxState* ActiveState::handleEvent(StandbyEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = dynamic_cast (getStateMachine()); - MuxState *nextState; - - mUnknownEventCount = 0; - mErrorEventCount = 0; - if (++mStandbyEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - else { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - - return nextState; -} - -// -// ---> handleEvent(UnknownEvent &event); -// -// handle UnknownEvent from state db/xcvrd -// -MuxState* ActiveState::handleEvent(UnknownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = dynamic_cast (getStateMachine()); - MuxState *nextState; - - mStandbyEventCount = 0; - mErrorEventCount = 0; - if (++mUnknownEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - else { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - - return nextState; -} - -// -// ---> handleEvent(ErrorEvent &event); -// -// handle ErrorEvent from state db -// -MuxState* ActiveState::handleEvent(ErrorEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mStandbyEventCount = 0; - mUnknownEventCount = 0; - if (++mErrorEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getErrorState()); - } - else { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - - return nextState; -} - -// -// ---> resetState(); -// -// reset current state attributes -// -void ActiveState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - mStandbyEventCount = 0; - mUnknownEventCount = 0; - mErrorEventCount = 0; -} - -} /* namespace mux_state */ diff --git a/src/linkmgrd/src/mux_state/ActiveState.h b/src/linkmgrd/src/mux_state/ActiveState.h deleted file mode 100644 index 9caafc376d32..000000000000 --- a/src/linkmgrd/src/mux_state/ActiveState.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * ActiveState.h - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#ifndef MUX_STATE_ACTIVESTATE_H_ -#define MUX_STATE_ACTIVESTATE_H_ - -#include - -namespace mux_state -{ - -/** - *@class ActiveState - * - *@brief maintains ActiveState state of MuxState - */ -class ActiveState: public MuxState -{ -public: - /** - *@method ActiveState - * - *@brief class default constructor - */ - ActiveState() = delete; - - /** - *@method ActiveState - * - *@brief class copy constructor - * - *@param ActiveState (in) reference to ActiveState object to be copied - */ - ActiveState(const ActiveState &) = delete; - - /** - *@method DownState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - ActiveState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~ActiveState - * - *@brief class destructor - */ - virtual ~ActiveState() = default; - - /** - *@method handleEvent - * - *@brief handle ActiveEvent from state db/xcvrd - * - *@param event (in) reference to ActiveEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ActiveEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle StandbyEvent from state db/xcvrd - * - *@param event (in) reference to StandbyEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(StandbyEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle UnknownEvent from state db/xcvrd - * - *@param event (in) reference to UnknownEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(UnknownEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle ErrorEvent from state db - * - *@param event (in) reference to ErrorEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ErrorEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for MuxState label - * - *@return MuxState Active label - */ - virtual MuxState::Label getStateLabel() override {return MuxState::Label::Active;}; - -private: - uint8_t mStandbyEventCount = 0; - uint8_t mUnknownEventCount = 0; - uint8_t mErrorEventCount = 0; -}; - -} /* namespace mux_state */ - -#endif /* MUX_STATE_ACTIVESTATE_H_ */ diff --git a/src/linkmgrd/src/mux_state/ErrorState.cpp b/src/linkmgrd/src/mux_state/ErrorState.cpp deleted file mode 100644 index 17dac721e7be..000000000000 --- a/src/linkmgrd/src/mux_state/ErrorState.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * ErrorState.cpp - * - * Created on: Mar 1, 2021 - * Author: taahme - */ - -#include "mux_state/ActiveState.h" -#include "mux_state/ErrorState.h" -#include "mux_state/StandbyState.h" -#include "mux_state/UnknownState.h" -#include "mux_state/MuxStateMachine.h" - -#include "common/MuxLogger.h" - -namespace mux_state -{ - -// -// ---> ErrorState(MuxStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -ErrorState::ErrorState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - MuxState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(ActiveEvent &event); -// -// handle ActiveEvent from state db/xcvrd -// -MuxState* ErrorState::handleEvent(ActiveEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mStandbyEventCount = 0; - mUnknownEventCount = 0; - if (++mActiveEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - else { - nextState = dynamic_cast (stateMachine->getErrorState()); - } - - return nextState; -} - -// -// ---> handleEvent(StandbyEvent &event); -// -// handle StandbyEvent from state db/xcvrd -// -MuxState* ErrorState::handleEvent(StandbyEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mActiveEventCount = 0; - mUnknownEventCount = 0; - if (++mStandbyEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - else { - nextState = dynamic_cast (stateMachine->getErrorState()); - } - - return nextState; -} - -// -// ---> handleEvent(UnknownEvent &event); -// -// handle UnknownEvent from state db/xcvrd -// -MuxState* ErrorState::handleEvent(UnknownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mActiveEventCount = 0; - mStandbyEventCount = 0; - if (++mUnknownEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - else { - nextState = dynamic_cast (stateMachine->getErrorState()); - } - - return nextState; -} - -// -// ---> handleEvent(ErrorEvent &event); -// -// handle ErrorEvent from state db -// -MuxState* ErrorState::handleEvent(ErrorEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = dynamic_cast (getStateMachine()); - MuxState *nextState = - dynamic_cast (stateMachine->getErrorState()); - - resetState(); - - return nextState; -} - -// -// ---> resetState(); -// -// reset current state attributes -// -void ErrorState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - mActiveEventCount = 0; - mStandbyEventCount = 0; - mUnknownEventCount = 0; -} - -} /* namespace mux_state */ diff --git a/src/linkmgrd/src/mux_state/ErrorState.h b/src/linkmgrd/src/mux_state/ErrorState.h deleted file mode 100644 index d938efb4e6e4..000000000000 --- a/src/linkmgrd/src/mux_state/ErrorState.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * ErrorState.h - * - * Created on: Mar 1, 2021 - * Author: taahme - */ - -#ifndef MUX_STATE_ERRORSTATE_H_ -#define MUX_STATE_ERRORSTATE_H_ - -#include - -namespace mux_state -{ -/** - *@class ErrorState - * - *@brief maintains ErrorState state of MuxState - */ -class ErrorState: public MuxState -{ -public: - /** - *@method ErrorState - * - *@brief class default constructor - */ - ErrorState() = delete; - - /** - *@method ErrorState - * - *@brief class copy constructor - * - *@param ErrorState (in) reference to ErrorState object to be copied - */ - ErrorState(const ErrorState &) = delete; - - /** - *@method ErrorState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - ErrorState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~ErrorState - * - *@brief class destructor - */ - virtual ~ErrorState() = default; - - /** - *@method handleEvent - * - *@brief handle ActiveEvent from state db/xcvrd - * - *@param event (in) reference to ActiveEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ActiveEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle StandbyEvent from state db/xcvrd - * - *@param event (in) reference to StandbyEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(StandbyEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle UnknownEvent from state db/xcvrd - * - *@param event (in) reference to UnknownEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(UnknownEvent &event) override; - - /** - *@method ErrorEvent - * - *@brief handle ErrorEvent from state db - * - *@param event (in) reference to ErrorEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ErrorEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for MuxState label - * - *@return MuxState Wait label - */ - virtual MuxState::Label getStateLabel() override {return MuxState::Label::Error;}; - -private: - uint8_t mActiveEventCount = 0; - uint8_t mStandbyEventCount = 0; - uint8_t mUnknownEventCount = 0; -}; - -} /* namespace mux_state */ - -#endif /* MUX_STATE_ERRORSTATE_H_ */ diff --git a/src/linkmgrd/src/mux_state/MuxState.cpp b/src/linkmgrd/src/mux_state/MuxState.cpp deleted file mode 100644 index e98213ff8aeb..000000000000 --- a/src/linkmgrd/src/mux_state/MuxState.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * MuxState.cpp - * - * Created on: Oct 18, 2020 - * Author: tamer - */ - -#include -#include - -namespace mux_state -{ - -// -// ---> MuxState(MuxStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -MuxState::MuxState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -): - common::State( - *dynamic_cast (&stateMachine), - muxPortConfig - ) -{ -} - -} /* namespace mux_state */ diff --git a/src/linkmgrd/src/mux_state/MuxState.h b/src/linkmgrd/src/mux_state/MuxState.h deleted file mode 100644 index 3e423c8ed1f1..000000000000 --- a/src/linkmgrd/src/mux_state/MuxState.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * MuxState.h - * - * Created on: Oct 18, 2020 - * Author: tamer - */ - -#ifndef MUX_STATE_MUXSTATE_H_ -#define MUX_STATE_MUXSTATE_H_ - -#include - -namespace mux_state -{ -class MuxStateMachine; -class ActiveEvent; -class StandbyEvent; -class UnknownEvent; -class ErrorEvent; - -/** - *@class MuxState - * - *@brief base class for different Mux states - */ -class MuxState: public common::State -{ -public: - /** - *@enum Label - * - *@brief Label corresponding to each MuxState State - */ - enum Label { - Active, - Standby, - Unknown, - Error, - Wait, - - Count - }; - -public: - /** - *@method MuxState - * - *@brief class default constructor - */ - MuxState() = delete; - - /** - *@method MuxState - * - *@brief class copy constructor - * - *@param MuxState (in) reference to MuxState object to be copied - */ - MuxState(const MuxState &) = delete; - - /** - *@method MuxState - * - *@brief class constructor - * - *@param stateMachine (in) reference to MuxStateMachine object - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - MuxState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~MuxState - * - *@brief class destructor - */ - virtual ~MuxState() = default; - - /** - *@method handleEvent - * - *@brief handle ActiveEvent from state db/xcvrd - * - *@param event (in) reference to ActiveEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ActiveEvent &event) = 0; - - /** - *@method handleEvent - * - *@brief handle StandbyEvent from state db/xcvrd - * - *@param event (in) reference to StandbyEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(StandbyEvent &event) = 0; - - /** - *@method handleEvent - * - *@brief handle UnknownEvent from state db/xcvrd - * - *@param event (in) reference to UnknownEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(UnknownEvent &event) = 0; - - /** - *@method handleEvent - * - *@brief handle ErrorEvent from state db - * - *@param event (in) reference to ErrorEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ErrorEvent &event) = 0; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual MuxState::Label getStateLabel() = 0; -}; - -} /* namespace mux_state */ - -#endif /* MUX_STATE_MUXSTATE_H_ */ diff --git a/src/linkmgrd/src/mux_state/MuxStateMachine.cpp b/src/linkmgrd/src/mux_state/MuxStateMachine.cpp deleted file mode 100644 index 19b62f6b0f25..000000000000 --- a/src/linkmgrd/src/mux_state/MuxStateMachine.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - * MuxStateMachine.cpp - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#include - -#include "mux_state/MuxStateMachine.h" -#include "link_manager/LinkManagerStateMachine.h" -#include "common/MuxLogger.h" -#include "MuxState.h" - -namespace mux_state -{ -// -// static members -// -ActiveEvent MuxStateMachine::mActiveEvent; -StandbyEvent MuxStateMachine::mStandbyEvent; -UnknownEvent MuxStateMachine::mUnknownEvent; -ErrorEvent MuxStateMachine::mErrorEvent; - -// -// ---> MuxStateMachine( -// link_manager::LinkManagerStateMachine &linkManagerStateMachine, -// boost::asio::io_service::strand &strand, -// common::MuxPortConfig &muxPortConfig, -// MuxState::Label label -// ); -// -// class constructor -// -MuxStateMachine::MuxStateMachine( - link_manager::LinkManagerStateMachine &linkManagerStateMachine, - boost::asio::io_service::strand &strand, - common::MuxPortConfig &muxPortConfig, - MuxState::Label label -) : - common::StateMachine(strand, muxPortConfig), - mLinkManagerStateMachine(linkManagerStateMachine), - mActiveState(*this, muxPortConfig), - mStandbyState(*this, muxPortConfig), - mUnknownState(*this, muxPortConfig), - mErrorState(*this, muxPortConfig), - mWaitState(*this, muxPortConfig) -{ - enterState(label); -} - -// -// ---> enterState(MuxState::Label label); -// -// force the state machine to enter a given state -// -void MuxStateMachine::enterState(MuxState::Label label) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - switch (label) { - case MuxState::Label::Active: - setCurrentState(dynamic_cast (getActiveState())); - break; - case MuxState::Label::Standby: - setCurrentState(dynamic_cast (getStandbyState())); - break; - case MuxState::Label::Unknown: - setCurrentState(dynamic_cast (getUnknownState())); - break; - case MuxState::Label::Error: - setCurrentState(dynamic_cast (getErrorState())); - break; - case MuxState::Label::Wait: - setCurrentState(dynamic_cast (getWaitState())); - break; - default: - break; - } -} - -// -// ---> postLinkManagerEvent(MuxState* muxState); -// -// post MuxState change event to LinkManager state machine -// -inline -void MuxStateMachine::postLinkManagerEvent(MuxState* muxState) -{ - boost::asio::io_service::strand &strand = mLinkManagerStateMachine.getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&link_manager::LinkManagerStateMachine::handleStateChange), - &mLinkManagerStateMachine, - link_manager::LinkManagerStateMachine::getMuxStateEvent(), - muxState->getStateLabel() - ))); -} - -// -// ---> postMuxStateEvent(E &e); -// -// post MuxState event to the state machine -// -template -void MuxStateMachine::postMuxStateEvent(E &e) -{ - boost::asio::io_service::strand &strand = getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&MuxStateMachine::processEvent), - this, - e - ))); -} - -// -// ---> postMuxStateEvent(ActiveEvent &e); -// -// post MuxState event to the state machine -// -template -void MuxStateMachine::postMuxStateEvent(ActiveEvent &e); - -// -// ---> postMuxStateEvent(StandbyEvent &e); -// -// post MuxState event to the state machine -// -template -void MuxStateMachine::postMuxStateEvent(StandbyEvent &e); - -// -// ---> postMuxStateEvent(UnknownEvent &e); -// -// post MuxState event to the state machine -// -template -void MuxStateMachine::postMuxStateEvent(UnknownEvent &e); - -// -// ---> postMuxStateEvent(ErrorEvent &e); -// -// post MuxState event to the state machine -// -template -void MuxStateMachine::postMuxStateEvent(ErrorEvent &e); - -// -// ---> processEvent(T &t); -// -// process MuxState event -// -template -void MuxStateMachine::processEvent(T &t) -{ - MuxState *currentMuxState = dynamic_cast (getCurrentState()); - MuxState *nextMuxState = currentMuxState->handleEvent(t); - if (nextMuxState != currentMuxState) { - postLinkManagerEvent(nextMuxState); - } - setCurrentState(nextMuxState); -} - -// -// ---> processEvent(ActiveEvent &event); -// -// process MuxState event -// -template -void MuxStateMachine::processEvent(ActiveEvent &event); - -// -// ---> processEvent(StandbyEvent &event); -// -// process MuxState event -// -template -void MuxStateMachine::processEvent(StandbyEvent &event); - -// -// ---> processEvent(UnknownEvent &event); -// -// process MuxState event -// -template -void MuxStateMachine::processEvent(UnknownEvent &event); - -} /* namespace mux_state */ diff --git a/src/linkmgrd/src/mux_state/MuxStateMachine.h b/src/linkmgrd/src/mux_state/MuxStateMachine.h deleted file mode 100644 index 20271e92af0e..000000000000 --- a/src/linkmgrd/src/mux_state/MuxStateMachine.h +++ /dev/null @@ -1,281 +0,0 @@ -/* - * MuxStateMachine.h - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#ifndef MUX_STATE_MUXSTATEMACHINE_H_ -#define MUX_STATE_MUXSTATEMACHINE_H_ - -#include "common/StateMachine.h" -#include "mux_state/ActiveState.h" -#include "mux_state/ErrorState.h" -#include "mux_state/StandbyState.h" -#include "mux_state/WaitState.h" -#include "mux_state/UnknownState.h" - -namespace link_manager { -class LinkManagerStateMachine; -} /* namespace link_manager */ - -namespace mux_state -{ -/** - *@class ActiveEvent - * - *@brief signals a ActiveEvent event to MuxState state machine - */ -class ActiveEvent { -public: - ActiveEvent() = default; - ~ActiveEvent() = default; -}; - -/** - *@class StandbyEvent - * - *@brief signals a StandbyEvent event to MuxState state machine - */ -class StandbyEvent { -public: - StandbyEvent() = default; - ~StandbyEvent() = default; -}; - -/** - *@class UnknownEvent - * - *@brief signals a UnknownEvent event to MuxState state machine - */ -class UnknownEvent { -public: - UnknownEvent() = default; - ~UnknownEvent() = default; -}; - -/** - *@class ErrorEvent - * - *@brief signals a ErrorEvent event to MuxState state machine - */ -class ErrorEvent { -public: - ErrorEvent() = default; - ~ErrorEvent() = default; -}; - -/** - *@class MuxStateMachine - * - *@brief maintains MuxState state machine - */ -class MuxStateMachine: public common::StateMachine -{ -public: - /** - *@method MuxStateMachine - * - *@brief class default constructor - */ - MuxStateMachine() = delete; - - /** - *@method MuxStateMachine - * - *@brief class copy constructor - * - *@param MuxStateMachine (in) reference to MuxStateMachine object to be copied - */ - MuxStateMachine(const MuxStateMachine &) = delete; - - /** - *@method MuxStateMachine - * - *@brief class constructor - * - *@param linkManagerStateMachine (in) reference to LinkManagerStateMachine - *@param strand (in) reference to boost serialization object - *@param muxPortConfig (in) reference to MuxPortConfig object - *@param label (in) state machine initial state - */ - MuxStateMachine( - link_manager::LinkManagerStateMachine &linkManagerStateMachine, - boost::asio::io_service::strand &strand, - common::MuxPortConfig &muxPortConfig, - MuxState::Label label - ); - - /** - *@method ~MuxStateMachine - * - *@brief class destructor - */ - virtual ~MuxStateMachine() = default; - - /** - *@method enterState - * - *@brief force the state machine to enter a given state - * - *@param label (in) label of target state - * - *@return none - */ - void enterState(MuxState::Label label); - - /** - *@method postMuxStateEvent - * - *@brief post MuxState event to the state machine - * - *@param e (in) reference to the MuxState event - * - *@return none - */ - template - void postMuxStateEvent(E &e); - - /** - *@method processEvent - * - *@brief process MuxState event - * - *@param t (in) reference to the MuxState event - * - *@return none - */ - template - void processEvent(T &t); - - /** - *@method getActiveState - * - *@brief getter for ActiveState object - * - *@return pointer to ActiveState object - */ - ActiveState* getActiveState() {return &mActiveState;}; - - /** - *@method getStandbyState - * - *@brief getter for StandbyState object - * - *@return pointer to StandbyState object - */ - StandbyState* getStandbyState() {return &mStandbyState;}; - - /** - *@method getUnknownState - * - *@brief getter for UnknownState object - * - *@return pointer to UnknownState object - */ - UnknownState* getUnknownState() {return &mUnknownState;}; - - /** - *@method getErrorState - * - *@brief getter for ErrorState object - * - *@return pointer to ErrorState object - */ - ErrorState* getErrorState() {return &mErrorState;}; - - /** - *@method getWaitState - * - *@brief getter for WaitState object - * - *@return pointer to WaitState object - */ - WaitState* getWaitState() {return &mWaitState;}; - - /** - *@method getActiveEvent - * - *@brief getter for ActiveEvent object - * - *@return pointer to ActiveEvent object - */ - static ActiveEvent& getActiveEvent() {return mActiveEvent;}; - - /** - *@method getStandbyEvent - * - *@brief getter for StandbyEvent object - * - *@return pointer to StandbyEvent object - */ - static StandbyEvent& getStandbyEvent() {return mStandbyEvent;}; - - /** - *@method getUnknownEvent - * - *@brief getter for UnknownEvent object - * - *@return pointer to UnknownEvent object - */ - static UnknownEvent& getUnknownEvent() {return mUnknownEvent;}; - - /** - *@method getErrorEvent - * - *@brief getter for ErrorEvent object - * - *@return pointer to ErrorEvent object - */ - static ErrorEvent& getErrorEvent() {return mErrorEvent;}; - - /** - *@method setWaitStateCause - * - *@brief setter Wait Cause - * - *@param waitStateCause (in) cause for entering wait state - * - *@return none - */ - void setWaitStateCause(WaitState::WaitStateCause waitStateCause) {mWaitState.setWaitStateCause(waitStateCause);}; - - /** - *@method getWaitOnSwssNotification - * - *@brief getter Wait Cause - * - *@return cause for entering wait state - */ - WaitState::WaitStateCause getWaitStateCause() const {return mWaitState.getWaitStateCause();}; - -private: - /** - *@method postLinkManagerEvent - * - *@brief post MuxState change event to LinkManager state machine - * - *@param muxState (in) pointer to current MuxState - * - *@return none - */ - inline void postLinkManagerEvent(MuxState* muxState); - -private: - static ActiveEvent mActiveEvent; - static StandbyEvent mStandbyEvent; - static UnknownEvent mUnknownEvent; - static ErrorEvent mErrorEvent; - -private: - link_manager::LinkManagerStateMachine &mLinkManagerStateMachine; - ActiveState mActiveState; - StandbyState mStandbyState; - UnknownState mUnknownState; - ErrorState mErrorState; - WaitState mWaitState; -}; - -} /* namespace mux_state */ - -#endif /* MUX_STATE_MUXSTATEMACHINE_H_ */ diff --git a/src/linkmgrd/src/mux_state/StandbyState.cpp b/src/linkmgrd/src/mux_state/StandbyState.cpp deleted file mode 100644 index 3e7514e9860f..000000000000 --- a/src/linkmgrd/src/mux_state/StandbyState.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * StandbyState.cpp - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#include "mux_state/ActiveState.h" -#include "mux_state/StandbyState.h" -#include "mux_state/MuxStateMachine.h" - -#include "common/MuxLogger.h" -#include "UnknownState.h" - -namespace mux_state -{ - -// -// ---> StandbyState(MuxStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -StandbyState::StandbyState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - MuxState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(ActiveEvent &event); -// -// handle ActiveEvent from state db/xcvrd -// -MuxState* StandbyState::handleEvent(ActiveEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = dynamic_cast (getStateMachine()); - MuxState *nextState; - - mUnknownEventCount = 0; - mErrorEventCount = 0; - if (++mActiveEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - else { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - - return nextState; -} - -// -// ---> handleEvent(StandbyEvent &event); -// -// handle StandbyEvent from state db/xcvrd -// -MuxState* StandbyState::handleEvent(StandbyEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = dynamic_cast (getStateMachine()); - MuxState *nextState = dynamic_cast (stateMachine->getStandbyState()); - - resetState(); - - return nextState; -} - -// -// ---> handleEvent(UnknownEvent &event); -// -// handle UnknownEvent from state db/xcvrd -// -MuxState* StandbyState::handleEvent(UnknownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = dynamic_cast (getStateMachine()); - MuxState *nextState; - - mActiveEventCount = 0; - mErrorEventCount = 0; - if (++mUnknownEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - else { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - - return nextState; -} - -// -// ---> handleEvent(ErrorEvent &event); -// -// handle ErrorEvent from state db -// -MuxState* StandbyState::handleEvent(ErrorEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mActiveEventCount = 0; - mUnknownEventCount = 0; - if (++mErrorEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getErrorState()); - } - else { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - - return nextState; -} - -// -// ---> resetState(); -// -// reset current state attributes -// -void StandbyState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - mActiveEventCount = 0; - mUnknownEventCount = 0; - mErrorEventCount = 0; -} - -} /* namespace mux_state */ diff --git a/src/linkmgrd/src/mux_state/StandbyState.h b/src/linkmgrd/src/mux_state/StandbyState.h deleted file mode 100644 index 8fe4a1430aef..000000000000 --- a/src/linkmgrd/src/mux_state/StandbyState.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * StandbyState.h - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#ifndef MUX_STATE_STANDBYSTATE_H_ -#define MUX_STATE_STANDBYSTATE_H_ - -#include - -namespace mux_state -{ - -/** - *@class StandbyState - * - *@brief maintains StandbyState state of MuxState - */ -class StandbyState: public MuxState -{ -public: - /** - *@method StandbyState - * - *@brief class default constructor - */ - StandbyState() = delete; - - /** - *@method StandbyState - * - *@brief class copy constructor - * - *@param StandbyState (in) reference to StandbyState object to be copied - */ - StandbyState(const StandbyState &) = delete; - - /** - *@method StandbyState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - StandbyState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~StandbyState - * - *@brief class destructor - */ - virtual ~StandbyState() = default; - - /** - *@method handleEvent - * - *@brief handle ActiveEvent from state db/xcvrd - * - *@param event (in) reference to ActiveEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ActiveEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle StandbyEvent from state db/xcvrd - * - *@param event (in) reference to StandbyEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(StandbyEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle UnknownEvent from state db/xcvrd - * - *@param event (in) reference to UnknownEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(UnknownEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle ErrorEvent from state db - * - *@param event (in) reference to ErrorEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ErrorEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for MuxState label - * - *@return MuxState Standby label - */ - virtual MuxState::Label getStateLabel() override {return MuxState::Label::Standby;}; - -private: - uint8_t mActiveEventCount = 0; - uint8_t mUnknownEventCount = 0; - uint8_t mErrorEventCount = 0; -}; - -} /* namespace mux_state */ - -#endif /* MUX_STATE_STANDBYSTATE_H_ */ diff --git a/src/linkmgrd/src/mux_state/UnknownState.cpp b/src/linkmgrd/src/mux_state/UnknownState.cpp deleted file mode 100644 index 467471b5f641..000000000000 --- a/src/linkmgrd/src/mux_state/UnknownState.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * FailedState.cpp - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#include "UnknownState.h" - -#include "mux_state/ActiveState.h" -#include "mux_state/StandbyState.h" -#include "mux_state/MuxStateMachine.h" - -#include "common/MuxLogger.h" - -namespace mux_state -{ - -// -// ---> UnknownState(MuxStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -UnknownState::UnknownState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - MuxState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(ActiveEvent &event); -// -// handle ActiveEvent from state db/xcvrd -// -MuxState* UnknownState::handleEvent(ActiveEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = dynamic_cast (getStateMachine()); - MuxState *nextState; - - mStandbyEventCount = 0; - mErrorEventCount = 0; - if (++mActiveEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - else { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - - return nextState; -} - -// -// ---> handleEvent(StandbyEvent &event); -// -// handle StandbyEvent from state db/xcvrd -// -MuxState* UnknownState::handleEvent(StandbyEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = dynamic_cast (getStateMachine()); - MuxState *nextState; - - mActiveEventCount = 0; - mErrorEventCount = 0; - if (++mStandbyEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - else { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - - return nextState; -} - -// -// ---> handleEvent(UnknownEvent &event); -// -// handle UnknownEvent from state db/xcvrd -// -MuxState* UnknownState::handleEvent(UnknownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState = - dynamic_cast (stateMachine->getUnknownState()); - - resetState(); - - return nextState; -} - -// -// ---> handleEvent(ErrorEvent &event); -// -// handle ErrorEvent from state db -// -MuxState* UnknownState::handleEvent(ErrorEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mActiveEventCount = 0; - mStandbyEventCount = 0; - if (++mErrorEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getErrorState()); - } - else { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - - return nextState; -} - -// -// ---> resetState() -// -// reset current state attributes -// -void UnknownState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - mActiveEventCount = 0; - mStandbyEventCount = 0; - mErrorEventCount = 0; -} - -} /* namespace mux_state */ diff --git a/src/linkmgrd/src/mux_state/UnknownState.h b/src/linkmgrd/src/mux_state/UnknownState.h deleted file mode 100644 index 75b5773ab6e0..000000000000 --- a/src/linkmgrd/src/mux_state/UnknownState.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * UnknownState.h - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#ifndef MUX_STATE_UNKNOWNSTATE_H_ -#define MUX_STATE_UNKNOWNSTATE_H_ - -#include - -namespace mux_state -{ - -/** - *@class UnknownState - * - *@brief maintains UnknownState state of MuxState - */ -class UnknownState: public MuxState -{ -public: - /** - *@method UnknownState - * - *@brief class default constructor - */ - UnknownState() = delete; - - /** - *@method UnknownState - * - *@brief class copy constructor - * - *@param UnknownState (in) reference to UnknownState object to be copied - */ - UnknownState(const UnknownState &) = delete; - - /** - *@method UnknownState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - UnknownState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~UnknownState - * - *@brief class destructor - */ - virtual ~UnknownState() = default; - - /** - *@method handleEvent - * - *@brief handle ActiveEvent from state db/xcvrd - * - *@param event (in) reference to ActiveEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ActiveEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle StandbyEvent from state db/xcvrd - * - *@param event (in) reference to StandbyEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(StandbyEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle UnknownEvent from state db/xcvrd - * - *@param event (in) reference to UnknownEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(UnknownEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle ErrorEvent from state db - * - *@param event (in) reference to ErrorEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ErrorEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for MuxState label - * - *@return MuxState Unknown label - */ - virtual MuxState::Label getStateLabel() override {return MuxState::Label::Unknown;}; - -private: - uint8_t mActiveEventCount = 0; - uint8_t mStandbyEventCount = 0; - uint8_t mErrorEventCount = 0; -}; - -} /* namespace mux_state */ - -#endif /* MUX_STATE_UNKNOWNSTATE_H_ */ diff --git a/src/linkmgrd/src/mux_state/WaitState.cpp b/src/linkmgrd/src/mux_state/WaitState.cpp deleted file mode 100644 index 6e4ee6d87c24..000000000000 --- a/src/linkmgrd/src/mux_state/WaitState.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * WaitState.cpp - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#include "mux_state/ActiveState.h" -#include "mux_state/StandbyState.h" -#include "mux_state/MuxStateMachine.h" - -#include "common/MuxLogger.h" -#include "UnknownState.h" - -namespace mux_state -{ - -// -// ---> WaitState(MuxStateMachine &stateMachine, common::MuxPortConfig &muxPortConfig); -// -// class constructor -// -WaitState::WaitState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig -) : - MuxState(stateMachine, muxPortConfig) -{ -} - -// -// ---> handleEvent(ActiveEvent &event); -// -// handle ActiveEvent from state db/xcvrd -// -MuxState* WaitState::handleEvent(ActiveEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mUnknownEventCount = 0; - mStandbyEventCount = 0; - mErrorEventCount = 0; - if (++mActiveEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getActiveState()); - } - else { - nextState = dynamic_cast (stateMachine->getWaitState()); - } - - return nextState; -} - -// -// ---> handleEvent(StandbyEvent &event); -// -// handle StandbyEvent from state db/xcvrd -// -MuxState* WaitState::handleEvent(StandbyEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mActiveEventCount = 0; - mUnknownEventCount = 0; - mErrorEventCount = 0; - if (++mStandbyEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getStandbyState()); - } - else { - nextState = dynamic_cast (stateMachine->getWaitState()); - } - - return nextState; -} - -// -// ---> handleEvent(UnknownEvent &event); -// -// handle UnknownEvent from state db/xcvrd -// -MuxState* WaitState::handleEvent(UnknownEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mActiveEventCount = 0; - mStandbyEventCount = 0; - mErrorEventCount = 0; - if (++mUnknownEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getUnknownState()); - } - else { - nextState = dynamic_cast (stateMachine->getWaitState()); - } - - return nextState; -} - -// -// ---> handleEvent(ErrorEvent &event); -// -// handle ErrorEvent from state db -// -MuxState* WaitState::handleEvent(ErrorEvent &event) -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - MuxStateMachine *stateMachine = - dynamic_cast (getStateMachine()); - MuxState *nextState; - - mActiveEventCount = 0; - mStandbyEventCount = 0; - mUnknownEventCount = 0; - if (++mErrorEventCount >= getMuxPortConfig().getMuxStateChangeRetryCount()) { - nextState = dynamic_cast (stateMachine->getErrorState()); - } - else { - nextState = dynamic_cast (stateMachine->getWaitState()); - } - - return nextState; -} - -// -// ---> resetState(); -// -// reset current state attributes -// -void WaitState::resetState() -{ - MUXLOGDEBUG(getMuxPortConfig().getPortName()); - - mActiveEventCount = 0; - mStandbyEventCount = 0; - mUnknownEventCount = 0; - mErrorEventCount = 0; -} - -} /* namespace mux_state */ diff --git a/src/linkmgrd/src/mux_state/WaitState.h b/src/linkmgrd/src/mux_state/WaitState.h deleted file mode 100644 index 9c3ada5f6d5d..000000000000 --- a/src/linkmgrd/src/mux_state/WaitState.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * WaitState.h - * - * Created on: Oct 20, 2020 - * Author: tamer - */ - -#ifndef MUX_STATE_WAITSTATE_H_ -#define MUX_STATE_WAITSTATE_H_ - -#include - -namespace mux_state -{ - -/** - *@class WaitState - * - *@brief maintains WaitState state of MuxState - */ -class WaitState: public MuxState -{ -public: - /** - *@enum WaitStateCause - * - *@brief WaitStateCause extends Wait state with cause attribute - */ - enum WaitStateCause { - CauseUnknown, - SwssUpdate, - DriverUpdate - }; - -public: - /** - *@method WaitState - * - *@brief class default constructor - */ - WaitState() = delete; - - /** - *@method WaitState - * - *@brief class copy constructor - * - *@param WaitState (in) reference to WaitState object to be copied - */ - WaitState(const WaitState &) = delete; - - /** - *@method WaitState - * - *@brief class constructor - * - *@param stateMachine (in) reference to LinkStateMachine - *@param muxPortConfig (in) reference to MuxPortConfig object - */ - WaitState( - MuxStateMachine &stateMachine, - common::MuxPortConfig &muxPortConfig - ); - - /** - *@method ~WaitState - * - *@brief class destructor - */ - virtual ~WaitState() = default; - - /** - *@method handleEvent - * - *@brief handle ActiveEvent from state db/xcvrd - * - *@param event (in) reference to ActiveEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ActiveEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle StandbyEvent from state db/xcvrd - * - *@param event (in) reference to StandbyEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(StandbyEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle UnknownEvent from state db/xcvrd - * - *@param event (in) reference to UnknownEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(UnknownEvent &event) override; - - /** - *@method handleEvent - * - *@brief handle ErrorEvent from state db - * - *@param event (in) reference to ErrorEvent - * - *@return pointer to next MuxState - */ - virtual MuxState* handleEvent(ErrorEvent &event) override; - - /** - *@method resetState - * - *@brief reset current state attributes - * - *@return none - */ - virtual void resetState() override; - - /** - *@method getStateLabel - * - *@brief getter for MuxState label - * - *@return MuxState Wait label - */ - virtual MuxState::Label getStateLabel() override {return MuxState::Label::Wait;}; - - /** - *@method setWaitStateCause - * - *@brief setter Wait Cause - * - *@param waitStateCause (in) cause for entering wait state - * - *@return none - */ - void setWaitStateCause(WaitStateCause waitStateCause) {mWaitStateCause = waitStateCause;}; - - /** - *@method getWaitOnSwssNotification - * - *@brief getter Wait Cause - * - *@return cause for entering wait state - */ - WaitStateCause getWaitStateCause() const {return mWaitStateCause;}; - -private: - uint8_t mActiveEventCount = 0; - uint8_t mStandbyEventCount = 0; - uint8_t mUnknownEventCount = 0; - uint8_t mErrorEventCount = 0; - - WaitStateCause mWaitStateCause = CauseUnknown; -}; - -} /* namespace mux_state */ - -#endif /* MUX_STATE_WAITSTATE_H_ */ diff --git a/src/linkmgrd/src/mux_state/subdir.mk b/src/linkmgrd/src/mux_state/subdir.mk deleted file mode 100644 index 0bba50a60cdb..000000000000 --- a/src/linkmgrd/src/mux_state/subdir.mk +++ /dev/null @@ -1,38 +0,0 @@ -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ - ./src/mux_state/ActiveState.cpp \ - ./src/mux_state/MuxState.cpp \ - ./src/mux_state/MuxStateMachine.cpp \ - ./src/mux_state/StandbyState.cpp \ - ./src/mux_state/UnknownState.cpp \ - ./src/mux_state/ErrorState.cpp \ - ./src/mux_state/WaitState.cpp - -OBJS += \ - ./src/mux_state/ActiveState.o \ - ./src/mux_state/MuxState.o \ - ./src/mux_state/MuxStateMachine.o \ - ./src/mux_state/StandbyState.o \ - ./src/mux_state/UnknownState.o \ - ./src/mux_state/ErrorState.o \ - ./src/mux_state/WaitState.o - -CPP_DEPS += \ - ./src/mux_state/ActiveState.d \ - ./src/mux_state/MuxState.d \ - ./src/mux_state/MuxStateMachine.d \ - ./src/mux_state/StandbyState.d \ - ./src/mux_state/UnknownState.d \ - ./src/mux_state/ErrorState.d \ - ./src/mux_state/WaitState.d - - -# Each subdirectory must supply rules for building sources it contributes -src/mux_state/%.o: src/mux_state/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - $(CC) -std=c++17 -D__FILENAME__="$(subst src/,,$<)" $(BOOST_MACROS) $(INCLUDES) $(CPP_FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/src/linkmgrd/src/subdir.mk b/src/linkmgrd/src/subdir.mk deleted file mode 100644 index ee287cdbec3d..000000000000 --- a/src/linkmgrd/src/subdir.mk +++ /dev/null @@ -1,34 +0,0 @@ -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ - ./src/DbInterface.cpp \ - ./src/LinkMgrdMain.cpp \ - ./src/MuxManager.cpp \ - ./src/MuxPort.cpp \ - ./src/NetMsgInterface.cpp - -OBJS += \ - ./src/DbInterface.o \ - ./src/MuxManager.o \ - ./src/MuxPort.o \ - ./src/NetMsgInterface.o - -OBJS_LINKMGRD += \ - ./src/LinkMgrdMain.o \ - -CPP_DEPS += \ - ./src/DbInterface.d \ - ./src/LinkMgrdMain.d \ - ./src/MuxManager.d \ - ./src/MuxPort.d \ - ./src/NetMsgInterface.d - - -# Each subdirectory must supply rules for building sources it contributes -src/%.o: src/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - $(CC) -std=c++17 -D__FILENAME__="$(subst src/,,$<)" $(BOOST_MACROS) $(INCLUDES) $(CPP_FLAGS) -Wall -c -fmessage-length=0 -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/src/linkmgrd/test/FakeDbInterface.cpp b/src/linkmgrd/test/FakeDbInterface.cpp deleted file mode 100644 index 9f6571408932..000000000000 --- a/src/linkmgrd/test/FakeDbInterface.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * FakeDbInterface.cpp - * - * Created on: Oct 23, 2020 - * Author: tamer - */ - -#include "FakeDbInterface.h" - -namespace test -{ - -FakeDbInterface::FakeDbInterface(boost::asio::io_service *ioService) : - mux::DbInterface(nullptr, ioService), - mNextMuxState(mux_state::MuxState::Label::Unknown) -{ -} - -FakeDbInterface::FakeDbInterface(mux::MuxManager *muxManager, boost::asio::io_service *ioService) : - mux::DbInterface(muxManager, ioService), - mNextMuxState(mux_state::MuxState::Label::Unknown) -{ -} - -void FakeDbInterface::setMuxState(const std::string &portName, mux_state::MuxState::Label label) -{ - mSetMuxStateInvokeCount++; -} - -void FakeDbInterface::getMuxState(const std::string &portName) -{ - mGetMuxStateInvokeCount++; -} - -void FakeDbInterface::probeMuxState(const std::string &portName) -{ - mProbeMuxStateInvokeCount++; -} - -void FakeDbInterface::setMuxLinkmgrState(const std::string &portName, link_manager::LinkManagerStateMachine::Label label) -{ - mSetMuxLinkmgrStateInvokeCount++; -} - -void FakeDbInterface::postMetricsEvent( - const std::string &portName, - link_manager::LinkManagerStateMachine::Metrics metrics, - mux_state::MuxState::Label label -) -{ - mPostMetricsInvokeCount++; -} - -} /* namespace test */ diff --git a/src/linkmgrd/test/FakeDbInterface.h b/src/linkmgrd/test/FakeDbInterface.h deleted file mode 100644 index da3155d3d3f1..000000000000 --- a/src/linkmgrd/test/FakeDbInterface.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * FakeDbInterface.h - * - * Created on: Oct 23, 2020 - * Author: tamer - */ - -#ifndef FAKEDBINTERFACE_H_ -#define FAKEDBINTERFACE_H_ - -#include "DbInterface.h" - -namespace test -{ - -class FakeDbInterface: public mux::DbInterface -{ -public: - FakeDbInterface(boost::asio::io_service *ioService); - FakeDbInterface(mux::MuxManager *muxManager, boost::asio::io_service *ioService); - virtual ~FakeDbInterface() = default; - - virtual void setMuxState(const std::string &portName, mux_state::MuxState::Label label) override; - virtual void getMuxState(const std::string &portName) override; - virtual void probeMuxState(const std::string &portName) override; - virtual void setMuxLinkmgrState( - const std::string &portName, - link_manager::LinkManagerStateMachine::Label label - ) override; - virtual void postMetricsEvent( - const std::string &portName, - link_manager::LinkManagerStateMachine::Metrics metrics, - mux_state::MuxState::Label label - ) override; - - void setNextMuxState(mux_state::MuxState::Label label) {mNextMuxState = label;}; - -public: - mux_state::MuxState::Label mNextMuxState; - - uint32_t mMuxStateRequest[mux_state::MuxState::Label::Count] = {0, 0, 0, 0}; - - uint32_t mSetMuxStateInvokeCount = 0; - uint32_t mGetMuxStateInvokeCount = 0; - uint32_t mProbeMuxStateInvokeCount = 0; - uint32_t mSetMuxLinkmgrStateInvokeCount = 0; - uint32_t mPostMetricsInvokeCount = 0; -}; - -} /* namespace test */ - -#endif /* FAKEDBINTERFACE_H_ */ diff --git a/src/linkmgrd/test/FakeLinkProber.cpp b/src/linkmgrd/test/FakeLinkProber.cpp deleted file mode 100644 index 0cd4a7310e85..000000000000 --- a/src/linkmgrd/test/FakeLinkProber.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * FakeLinkProber.cpp - * - * Created on: Oct 23, 2020 - * Author: tamer - */ - -#include -#include - -#include "FakeLinkProber.h" -#include "common/MuxLogger.h" - -namespace test -{ - -FakeLinkProber::FakeLinkProber( - link_prober::LinkProberStateMachine *linkProberStateMachine -) : - mLinkProberStateMachine(linkProberStateMachine) -{ -} - -template -void FakeLinkProber::postLinkProberEvent(E &e) -{ - boost::asio::io_service::strand& strand = mLinkProberStateMachine->getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&link_prober::LinkProberStateMachine::processEvent), - mLinkProberStateMachine, - e - ))); -} - -template -void FakeLinkProber::postLinkProberEvent(link_prober::IcmpSelfEvent &event); - -template -void FakeLinkProber::postLinkProberEvent(link_prober::IcmpPeerEvent &event); - -template -void FakeLinkProber::postLinkProberEvent(link_prober::IcmpUnknownEvent &event); - -void FakeLinkProber::postSuspendTimerExpiredEvent() -{ - // inform the composite state machine about Suspend timer expiry - boost::asio::io_service::strand& strand = mLinkProberStateMachine->getStrand(); - boost::asio::io_service &ioService = strand.context(); - ioService.post(strand.wrap(boost::bind( - static_cast - (&link_prober::LinkProberStateMachine::processEvent), - mLinkProberStateMachine, - link_prober::LinkProberStateMachine::getSuspendTimerExpiredEvent() - ))); -} - -void FakeLinkProber::initialize() -{ - MUXLOGINFO(""); - - mInitializeCallCount++; -} - -void FakeLinkProber::startProbing() -{ - MUXLOGINFO(""); - - mStartProbingCallCount++; -} - -void FakeLinkProber::updateEthernetFrame() -{ - MUXLOGINFO(""); - - mUpdateEthernetFrameCallCount++; -} - -void FakeLinkProber::probePeerTor() -{ - MUXLOGINFO(""); - - mProbePeerTorCallCount++; -} - -void FakeLinkProber::suspendTxProbes(uint32_t suspendTime_msec) -{ - MUXLOGINFO(""); - - mSuspendTxProbeCallCount++; -} - -void FakeLinkProber::resumeTxProbes() -{ - MUXLOGINFO(""); - - mResumeTxProbeCallCount++; -} - -void FakeLinkProber::sendPeerSwitchCommand() -{ - MUXLOGINFO(""); - - mSendPeerSwitchCommand++; -} - -} /* namespace test */ diff --git a/src/linkmgrd/test/FakeLinkProber.h b/src/linkmgrd/test/FakeLinkProber.h deleted file mode 100644 index 6ee5ff5e2888..000000000000 --- a/src/linkmgrd/test/FakeLinkProber.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * FakeLinkProber.h - * - * Created on: Oct 23, 2020 - * Author: tamer - */ - -#ifndef FAKELINKPROBER_H_ -#define FAKELINKPROBER_H_ - -#include "link_prober/LinkProberStateMachine.h" -namespace test -{ - -class FakeLinkProber -{ -public: - FakeLinkProber(link_prober::LinkProberStateMachine *linkProberStateMachine); - virtual ~FakeLinkProber() = default; - - template - void postLinkProberEvent(E &e); - - void postSuspendTimerExpiredEvent(); - - void initialize(); - void startProbing(); - void updateEthernetFrame(); - void probePeerTor(); - void suspendTxProbes(uint32_t suspendTime_msec); - void resumeTxProbes(); - void sendPeerSwitchCommand(); - -public: - uint32_t mInitializeCallCount = 0; - uint32_t mStartProbingCallCount = 0; - uint32_t mUpdateEthernetFrameCallCount = 0; - uint32_t mProbePeerTorCallCount = 0; - uint32_t mSuspendTxProbeCallCount = 0; - uint32_t mResumeTxProbeCallCount = 0; - uint32_t mSendPeerSwitchCommand = 0; - -private: - link_prober::LinkProberStateMachine *mLinkProberStateMachine; -}; - -} /* namespace test */ - -#endif /* FAKELINKPROBER_H_ */ diff --git a/src/linkmgrd/test/FakeMuxPort.cpp b/src/linkmgrd/test/FakeMuxPort.cpp deleted file mode 100644 index 77043b4a1ab3..000000000000 --- a/src/linkmgrd/test/FakeMuxPort.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * MuxPort.cpp - * - * Created on: Oct 23, 2020 - * Author: tamer - */ - -#include - -#include "common/MuxLogger.h" -#include "FakeMuxPort.h" -#include "FakeLinkProber.h" - -namespace test -{ - -FakeMuxPort::FakeMuxPort( - std::shared_ptr dbInterface, - common::MuxConfig &muxConfig, - std::string &portName, - uint16_t serverId, - boost::asio::io_service &ioService -) : - mux::MuxPort( - dbInterface, - muxConfig, - portName, - serverId, - ioService - ), - mFakeLinkProber( - std::make_shared (&getLinkManagerStateMachine()->getLinkProberStateMachine()) - ) -{ - std::string prog_name = "linkmgrd-test"; - std::string log_filename = "/tmp/" + prog_name + ".log"; - common::MuxLogger::getInstance()->initialize(prog_name, log_filename, boost::log::trivial::debug); - common::MuxLogger::getInstance()->setLevel(boost::log::trivial::trace); - link_manager::LinkManagerStateMachine::initializeTransitionFunctionTable(); - mMuxPortConfig.setMode(common::MuxPortConfig::Mode::Auto); - getLinkManagerStateMachine()->setInitializeProberFnPtr( - boost::bind(&FakeLinkProber::initialize, mFakeLinkProber.get()) - ); - getLinkManagerStateMachine()->setStartProbingFnPtr( - boost::bind(&FakeLinkProber::startProbing, mFakeLinkProber.get()) - ); - getLinkManagerStateMachine()->setUpdateEthernetFrameFnPtr( - boost::bind(&FakeLinkProber::updateEthernetFrame, mFakeLinkProber.get()) - ); - getLinkManagerStateMachine()->setProbePeerTorFnPtr( - boost::bind(&FakeLinkProber::probePeerTor, mFakeLinkProber.get()) - ); - getLinkManagerStateMachine()->setSuspendTxFnPtr( - boost::bind(&FakeLinkProber::suspendTxProbes, mFakeLinkProber.get(), boost::placeholders::_1) - ); - getLinkManagerStateMachine()->setResumeTxFnPtr( - boost::bind(&FakeLinkProber::resumeTxProbes, mFakeLinkProber.get()) - ); - getLinkManagerStateMachine()->setSendPeerSwitchCommandFnPtr( - boost::bind(&FakeLinkProber::resumeTxProbes, mFakeLinkProber.get()) - ); -} - -void FakeMuxPort::activateStateMachine() -{ - setComponentInitState(0); - setComponentInitState(1); - setComponentInitState(2); -} - -} /* namespace test */ diff --git a/src/linkmgrd/test/FakeMuxPort.h b/src/linkmgrd/test/FakeMuxPort.h deleted file mode 100644 index 5983e6009220..000000000000 --- a/src/linkmgrd/test/FakeMuxPort.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MuxPort.h - * - * Created on: Oct 23, 2020 - * Author: tamer - */ - -#ifndef FAKEMUXPORT_H_ -#define FAKEMUXPORT_H_ - -#include -#include - -#include "MuxPort.h" -#include "FakeDbInterface.h" -#include "FakeLinkProber.h" - -namespace test -{ - -class FakeMuxPort: public ::mux::MuxPort -{ -public: - FakeMuxPort( - std::shared_ptr dbInterface, - common::MuxConfig &muxConfig, - std::string &portName, - uint16_t serverId, - boost::asio::io_service &ioService - ); - virtual ~FakeMuxPort() = default; - - void activateStateMachine(); - - const link_manager::LinkManagerStateMachine::CompositeState& getCompositeState() {return getLinkManagerStateMachine()->getCompositeState();}; - link_prober::LinkProberStateMachine& getLinkProberStateMachine() {return getLinkManagerStateMachine()->getLinkProberStateMachine();}; - mux_state::MuxStateMachine& getMuxStateMachine() {return getLinkManagerStateMachine()->getMuxStateMachine();}; - link_state::LinkStateMachine& getLinkStateMachine() {return getLinkManagerStateMachine()->getLinkStateMachine();}; - - std::shared_ptr mFakeLinkProber; -}; - -} /* namespace test */ - -#endif /* FAKEMUXPORT_H_ */ diff --git a/src/linkmgrd/test/LinkManagerStateMachineTest.cpp b/src/linkmgrd/test/LinkManagerStateMachineTest.cpp deleted file mode 100644 index 51740074c502..000000000000 --- a/src/linkmgrd/test/LinkManagerStateMachineTest.cpp +++ /dev/null @@ -1,947 +0,0 @@ -/* - * LinkManagerStateMachineTest.cpp - * - * Created on: Oct 25, 2020 - * Author: tamer - */ - -#include "LinkManagerStateMachineTest.h" -#include "link_prober/LinkProberStateMachine.h" - -#define VALIDATE_STATE(p, m, l) \ - do { \ - mTestCompositeState = mFakeMuxPort.getCompositeState(); \ - EXPECT_EQ(ps(mTestCompositeState), link_prober::LinkProberState::Label::p); \ - EXPECT_EQ(ms(mTestCompositeState), mux_state::MuxState::Label::m); \ - EXPECT_EQ(ls(mTestCompositeState), link_state::LinkState::Label::l); \ - } while (0) - -namespace test -{ - -LinkManagerStateMachineTest::LinkManagerStateMachineTest() : - mDbInterfacePtr(std::make_shared (&mIoService)), - mFakeMuxPort( - mDbInterfacePtr, - mMuxConfig, - mPortName, - mServerId, - mIoService - ) -{ - mMuxConfig.setTimeoutIpv4_msec(10); - mMuxConfig.setPositiveStateChangeRetryCount(mPositiveUpdateCount); - mMuxConfig.setMuxStateChangeRetryCount(mPositiveUpdateCount); - mMuxConfig.setLinkStateChangeRetryCount(mPositiveUpdateCount); -} - -void LinkManagerStateMachineTest::runIoService(uint32_t count) -{ - if (count == 0) { - mIoService.run(); - mIoService.reset(); - } - - for (uint8_t i = 0; i < count; i++) { - mIoService.run_one(); - mIoService.reset(); - } -} - -void LinkManagerStateMachineTest::postLinkProberEvent(link_prober::LinkProberState::Label label, uint32_t count) -{ - switch (label) { - case link_prober::LinkProberState::Active: - for (uint8_t i = 0; i < mMuxConfig.getPositiveStateChangeRetryCount(); i++) { - mFakeMuxPort.mFakeLinkProber->postLinkProberEvent( - link_prober::LinkProberStateMachine::getIcmpSelfEvent() - ); - runIoService(count); - } - break; - case link_prober::LinkProberState::Standby: - for (uint8_t i = 0; i < mMuxConfig.getPositiveStateChangeRetryCount(); i++) { - mFakeMuxPort.mFakeLinkProber->postLinkProberEvent( - link_prober::LinkProberStateMachine::getIcmpPeerEvent() - ); - runIoService(count); - } - break; - case link_prober::LinkProberState::Unknown: - for (uint8_t i = 0; i < mMuxConfig.getNegativeStateChangeRetryCount(); i++) { - mFakeMuxPort.mFakeLinkProber->postLinkProberEvent( - link_prober::LinkProberStateMachine::getIcmpUnknownEvent() - ); - runIoService(count); - } - break; - default: - break; - } -} - -void LinkManagerStateMachineTest::postMuxEvent(mux_state::MuxState::Label label, uint32_t count) -{ - mux_state::MuxStateMachine& muxStateMachine = mFakeMuxPort.getMuxStateMachine(); - for (uint8_t i = 0; i < mMuxConfig.getMuxStateChangeRetryCount(); i++) { - switch (label) { - case mux_state::MuxState::Active: - muxStateMachine.postMuxStateEvent(mux_state::MuxStateMachine::getActiveEvent()); - break; - case mux_state::MuxState::Standby: - muxStateMachine.postMuxStateEvent(mux_state::MuxStateMachine::getStandbyEvent()); - break; - case mux_state::MuxState::Unknown: - muxStateMachine.postMuxStateEvent(mux_state::MuxStateMachine::getUnknownEvent()); - break; - case mux_state::MuxState::Error: - muxStateMachine.postMuxStateEvent(mux_state::MuxStateMachine::getErrorEvent()); - break; - default: - break; - } - runIoService(count); - } -} - -void LinkManagerStateMachineTest::postLinkEvent(link_state::LinkState::Label label, uint32_t count) -{ - link_state::LinkStateMachine& linkStateMachine = mFakeMuxPort.getLinkStateMachine(); - for (uint8_t i = 0; i < mMuxConfig.getLinkStateChangeRetryCount(); i++) { - switch (label) { - case link_state::LinkState::Up: - linkStateMachine.postLinkStateEvent(link_state::LinkStateMachine::getUpEvent()); - break; - case link_state::LinkState::Down: - linkStateMachine.postLinkStateEvent(link_state::LinkStateMachine::getDownEvent()); - break; - default: - break; - } - runIoService(count); - } -} - -void LinkManagerStateMachineTest::postSuspendTimerExpiredEvent(uint32_t count) -{ - mFakeMuxPort.mFakeLinkProber->postSuspendTimerExpiredEvent(); - runIoService(count); -} - -void LinkManagerStateMachineTest::handleMuxState(std::string state, uint32_t count) -{ - for (uint8_t i = 0; i < mPositiveUpdateCount; i++) { - mFakeMuxPort.handleMuxState(state); - runIoService(count); - } -} - -void LinkManagerStateMachineTest::handleGetMuxState(std::string state, uint32_t count) -{ - mFakeMuxPort.handleGetMuxState(state); - runIoService(count); -} - -void LinkManagerStateMachineTest::handleProbeMuxState(std::string state, uint32_t count) -{ - for (uint8_t i = 0; i < mPositiveUpdateCount; i++) { - mFakeMuxPort.handleProbeMuxState(state); - runIoService(count); - } -} - -void LinkManagerStateMachineTest::handleLinkState(std::string linkState, uint32_t count) -{ - for (uint8_t i = 0; i < mMuxConfig.getLinkStateChangeRetryCount(); i++) { - mFakeMuxPort.handleLinkState(linkState); - runIoService(count); - } -} - -void LinkManagerStateMachineTest::handleMuxConfig(std::string config, uint32_t count) -{ - mFakeMuxPort.handleMuxConfig(config); - runIoService(count); -} - -void LinkManagerStateMachineTest::activateStateMachine() -{ - mFakeMuxPort.activateStateMachine(); -} - -void LinkManagerStateMachineTest::setMuxActive() -{ - activateStateMachine(); - VALIDATE_STATE(Unknown, Wait, Down); - - postLinkEvent(link_state::LinkState::Up); - VALIDATE_STATE(Unknown, Wait, Up); - - // change state to active - postLinkProberEvent(link_prober::LinkProberState::Active); - VALIDATE_STATE(Active, Wait, Up); - - // change state to active - postLinkProberEvent(link_prober::LinkProberState::Active); - VALIDATE_STATE(Active, Wait, Up); - - // switch mux to active state - postMuxEvent(mux_state::MuxState::Active); - VALIDATE_STATE(Active, Active, Up); -} - -void LinkManagerStateMachineTest::setMuxStandby() -{ - activateStateMachine(); - VALIDATE_STATE(Unknown, Wait, Down); - - postLinkEvent(link_state::LinkState::Down); - VALIDATE_STATE(Unknown, Wait, Down); - - postLinkEvent(link_state::LinkState::Up); - VALIDATE_STATE(Unknown, Wait, Up); - - // change state to active - postLinkProberEvent(link_prober::LinkProberState::Standby); - VALIDATE_STATE(Standby, Wait, Up); - - // switch mux to active state - postMuxEvent(mux_state::MuxState::Standby); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActiveSwitchOver) -{ - setMuxActive(); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - postLinkProberEvent(link_prober::LinkProberState::Standby, 2); - VALIDATE_STATE(Standby, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 1); - - // fake mux statedb state to be active - mDbInterfacePtr->setNextMuxState(mux_state::MuxState::Active); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - // driver notification - handleProbeMuxState("standby", 4); - VALIDATE_STATE(Standby, Standby, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 2); - - // get state db mux state - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - handleGetMuxState("active", 2); - VALIDATE_STATE(Standby, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // swss notification - handleMuxState("standby", 3); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActiveRemoteSwitchOver) -{ - setMuxActive(); - - // swss notification - handleMuxState("active", 3); - VALIDATE_STATE(Active, Active, Up); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - VALIDATE_STATE(Unknown, Active, Up); - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - - // fake mux statedb state to be active - mDbInterfacePtr->setNextMuxState(mux_state::MuxState::Active); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - // driver notification - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Wait, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - - // get state db mux state - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - handleGetMuxState("active", 2); - VALIDATE_STATE(Wait, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - postLinkProberEvent(link_prober::LinkProberState::Standby, 2); - VALIDATE_STATE(Standby, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - - // swss notification - handleMuxState("standby", 3); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandbyRemoteSwitchOver) -{ - setMuxStandby(); - - // swss notification - handleMuxState("standby", 3); - VALIDATE_STATE(Standby, Standby, Up); - - handleLinkState("down"); - VALIDATE_STATE(Standby, Standby, Down); - - handleMuxState("active", 3); - VALIDATE_STATE(Standby, Active, Down); - - handleMuxState("standby", 3); - VALIDATE_STATE(Standby, Standby, Down); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 3); - postLinkProberEvent(link_prober::LinkProberState::Unknown, 3); - VALIDATE_STATE(Unknown, Wait, Down); - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 1); - - // fake mux statedb state to be active - mDbInterfacePtr->setNextMuxState(mux_state::MuxState::Standby); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 3); - // driver notification - handleProbeMuxState("active", 4); - VALIDATE_STATE(Unknown, Wait, Down); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 4); - - postLinkProberEvent(link_prober::LinkProberState::Active, 2); - VALIDATE_STATE(Active, Wait, Down); - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 2); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandbySwitchOver) -{ - setMuxStandby(); - - // Verify posting extra standby won't change link prober state - postLinkProberEvent(link_prober::LinkProberState::Standby, 2); - VALIDATE_STATE(Standby, Standby, Up); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - postLinkProberEvent(link_prober::LinkProberState::Active, 2); - VALIDATE_STATE(Active, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 1); - - // fake mux statedb state to be standby - mDbInterfacePtr->setNextMuxState(mux_state::MuxState::Standby); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - // driver notification - handleProbeMuxState("active", 3); - VALIDATE_STATE(Active, Active, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 2); - - // get state db mux state - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - handleGetMuxState("standby", 2); - VALIDATE_STATE(Active, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // swss notification - handleMuxState("active", 3); - VALIDATE_STATE(Active, Active, Up); - - postLinkEvent(link_state::LinkState::Up); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActiveCliSwitchOver) -{ - setMuxActive(); - - handleMuxConfig("active"); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActiveCliAuto) -{ - setMuxActive(); - - handleMuxConfig("auto"); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxAStandbyCliAuto) -{ - setMuxStandby(); - - handleMuxConfig("auto"); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActiveCliManual) -{ - setMuxActive(); - - handleMuxConfig("manual"); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxAStandbyCliManual) -{ - setMuxStandby(); - - handleMuxConfig("manual"); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandbyCliSwitchOverMuxFirst) -{ - setMuxStandby(); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - handleMuxConfig("active", 2); - - VALIDATE_STATE(Wait, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // swss notification - handleMuxState("active", 3); - VALIDATE_STATE(Wait, Active, Up); - - // change state to active - postLinkProberEvent(link_prober::LinkProberState::Active, 2); - VALIDATE_STATE(Active, Wait, Up); - - // xcvrd notification - handleProbeMuxState("active", 4); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandbyCliSwitchOverLinkProberFirst) -{ - setMuxStandby(); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - handleMuxConfig("active", 4); - - VALIDATE_STATE(Wait, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // change state to active - postLinkProberEvent(link_prober::LinkProberState::Active, 3); - VALIDATE_STATE(Active, Wait, Up); - - // swss notification - handleMuxState("active", 3); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActiveLinkDown) -{ - setMuxActive(); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - handleLinkState("down", 3); - - VALIDATE_STATE(Active, Wait, Down); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // swss notification - handleMuxState("standby", 4); - VALIDATE_STATE(Active, Standby, Down); - - handleLinkState("up"); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandbyLinkDown) -{ - setMuxStandby(); - - handleLinkState("down", 3); - VALIDATE_STATE(Standby, Standby, Down); - - handleLinkState("up"); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActiveLinkProberUnknownPeerOvertakeLink) -{ - setMuxActive(); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - VALIDATE_STATE(Unknown, Active, Up); - EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mSuspendTxProbeCallCount, 1); - - postSuspendTimerExpiredEvent(2); - VALIDATE_STATE(Unknown, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 1); - - // Verify posting extra unknown won't change link prober state - postLinkProberEvent(link_prober::LinkProberState::Unknown, 3); - VALIDATE_STATE(Unknown, Wait, Up); - - postLinkProberEvent(link_prober::LinkProberState::Standby, 2); - VALIDATE_STATE(Standby, Wait, Up); - - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Standby, Standby, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 2); -} - -TEST_F(LinkManagerStateMachineTest, MuxActiveLinkProberUnknownReturnActive) -{ - setMuxActive(); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - VALIDATE_STATE(Unknown, Active, Up); - EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mSuspendTxProbeCallCount, 1); - - postSuspendTimerExpiredEvent(2); - VALIDATE_STATE(Unknown, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 1); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Wait, Wait, Up); - - // ensure link prober stays in wait state if unknown event was posted - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - VALIDATE_STATE(Wait, Wait, Up); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - // swss notification - handleMuxState("active", 3); - VALIDATE_STATE(Wait, Active, Up); - - // change state to active - postLinkProberEvent(link_prober::LinkProberState::Active, 2); - VALIDATE_STATE(Active, Wait, Up); - - // xcvrd notification - handleProbeMuxState("active", 4); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandbyLinkProberUnknown) -{ - setMuxStandby(); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - VALIDATE_STATE(Wait, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // swss notification - handleMuxState("active", 3); - VALIDATE_STATE(Wait, Active, Up); - - // change state to active - postLinkProberEvent(link_prober::LinkProberState::Active, 2); - VALIDATE_STATE(Active, Wait, Up); - - // xcvrd notification - handleProbeMuxState("active", 4); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandbyLinkProberUnknownReturnStandby) -{ - setMuxStandby(); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - VALIDATE_STATE(Wait, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // swss notification - handleMuxState("standby", 3); - VALIDATE_STATE(Wait, Standby, Up); - - // change state to standby - postLinkProberEvent(link_prober::LinkProberState::Standby, 2); - VALIDATE_STATE(Standby, Wait, Up); - - // xcvrd notification - handleProbeMuxState("standby", 4); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActiveAsymetricLinkDrop) -{ - setMuxActive(); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - postLinkProberEvent(link_prober::LinkProberState::Unknown); - VALIDATE_STATE(Unknown, Active, Up); - EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mSuspendTxProbeCallCount, 1); - - postSuspendTimerExpiredEvent(2); - VALIDATE_STATE(Unknown, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 1); - - // Peer took over the link - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Wait, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - // swss notification - handleMuxState("active", 3); - VALIDATE_STATE(Wait, Active, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 2); - - runIoService(2); - VALIDATE_STATE(Wait, Wait, Up); - - handleProbeMuxState("active", 3); - VALIDATE_STATE(Wait, Active, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 3); - EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mSuspendTxProbeCallCount, 2); - - runIoService(2); - VALIDATE_STATE(Wait, Wait, Up); - - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Wait, Standby, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 4); - EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mSuspendTxProbeCallCount, 2); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandbyAsymetricLinkDrop) -{ - setMuxStandby(); - - // verify MUX enters wait state and that the diver is being probed - EXPECT_EQ(mDbInterfacePtr->mProbeMuxStateInvokeCount, 0); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 1); - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - VALIDATE_STATE(Wait, Wait, Up); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - // swss notification - handleMuxState("active", 3); - VALIDATE_STATE(Wait, Active, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 2); - - runIoService(2); - VALIDATE_STATE(Wait, Wait, Up); - - handleProbeMuxState("active", 3); - VALIDATE_STATE(Wait, Active, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 3); - EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mSuspendTxProbeCallCount, 1); - - runIoService(2); - VALIDATE_STATE(Wait, Wait, Up); - - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Wait, Standby, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 4); - EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mSuspendTxProbeCallCount, 1); -} - -TEST_F(LinkManagerStateMachineTest, ActiveStateToProberUnknownMuxUnknownLinkUp) -{ - setMuxActive(); - - postMuxEvent(mux_state::MuxState::Unknown, 2); - VALIDATE_STATE(Active, Wait, Up); - - // xcvrd notification - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Active, Wait, Up); - - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Unknown, Unknown, Up); - - runIoService(2); - VALIDATE_STATE(Unknown, Wait, Up); - - // xcvrd notification - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Unknown, Unknown, Up); - - runIoService(2); - VALIDATE_STATE(Unknown, Wait, Up); - - handleProbeMuxState("active", 3); - VALIDATE_STATE(Unknown, Active, Up); - EXPECT_EQ(mDbInterfacePtr->mGetMuxStateInvokeCount, 4); - EXPECT_EQ(mFakeMuxPort.mFakeLinkProber->mSuspendTxProbeCallCount, 1); - - postLinkProberEvent(link_prober::LinkProberState::Active, 2); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, StandbyStateToProberUnknownMuxUnknownLinkUp) -{ - setMuxStandby(); - - postMuxEvent(mux_state::MuxState::Unknown, 2); - VALIDATE_STATE(Standby, Wait, Up); - - // xcvrd notification - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Standby, Wait, Up); - - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Unknown, Unknown, Up); - - runIoService(2); - VALIDATE_STATE(Unknown, Wait, Up); - - // xcvrd notification - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Unknown, Unknown, Up); - - runIoService(2); - VALIDATE_STATE(Unknown, Wait, Up); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Wait, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // swss notification - handleMuxState("unknown", 4); - VALIDATE_STATE(Wait, Wait, Up); - - postLinkProberEvent(link_prober::LinkProberState::Active, 2); - VALIDATE_STATE(Active, Wait, Up); - - // xcvrd notification - handleProbeMuxState("active", 3); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, ProberUnknownMuxUnknownLinkDown) -{ - setMuxActive(); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - handleLinkState("down", 3); - - VALIDATE_STATE(Active, Wait, Down); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // swss notification - handleMuxState("unknown", 4); - VALIDATE_STATE(Active, Unknown, Down); - - postLinkProberEvent(link_prober::LinkProberState::Unknown, 3); - VALIDATE_STATE(Unknown, Wait, Down); - - handleProbeMuxState("unknown", 4); - VALIDATE_STATE(Unknown, Wait, Down); -} - -TEST_F(LinkManagerStateMachineTest, ProberWaitMuxUnknownLinkDown) -{ - setMuxStandby(); - - postMuxEvent(mux_state::MuxState::Unknown, 2); - VALIDATE_STATE(Standby, Wait, Up); - - // xcvrd notification - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Standby, Wait, Up); - - postLinkProberEvent(link_prober::LinkProberState::Unknown, 2); - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Unknown, Unknown, Up); - - runIoService(2); - VALIDATE_STATE(Unknown, Wait, Up); - - // xcvrd notification - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Unknown, Unknown, Up); - - runIoService(2); - VALIDATE_STATE(Unknown, Wait, Up); - - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 0); - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Wait, Wait, Up); - EXPECT_EQ(mDbInterfacePtr->mSetMuxStateInvokeCount, 1); - - // swss notification - handleMuxState("unknown", 4); - VALIDATE_STATE(Wait, Wait, Up); - - handleLinkState("down", 3); - VALIDATE_STATE(Wait, Wait, Down); - - // xcvrd notification - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Wait, Unknown, Down); - - runIoService(2); - VALIDATE_STATE(Wait, Wait, Down); - -} - -TEST_F(LinkManagerStateMachineTest, MuxActive2Error2Active) -{ - setMuxActive(); - - // fake mux statedb state to be active - mDbInterfacePtr->setNextMuxState(mux_state::MuxState::Error); - - handleMuxState("error", 3); - VALIDATE_STATE(Active, Error, Up); - - handleMuxState("error", 3); - VALIDATE_STATE(Active, Error, Up); - - handleProbeMuxState("active", 3); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActive2ErrorStandby) -{ - setMuxActive(); - - handleMuxState("error", 3); - VALIDATE_STATE(Active, Error, Up); - - handleMuxState("error", 3); - VALIDATE_STATE(Active, Error, Up); - - postLinkProberEvent(link_prober::LinkProberState::Standby, 2); - VALIDATE_STATE(Standby, Wait, Up); - - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandby2Error2Standby) -{ - setMuxStandby(); - - // fake mux statedb state to be active - mDbInterfacePtr->setNextMuxState(mux_state::MuxState::Error); - - handleMuxState("error", 3); - VALIDATE_STATE(Standby, Error, Up); - - handleMuxState("error", 3); - VALIDATE_STATE(Standby, Error, Up); - - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Standby, Standby, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandby2ErrorActive) -{ - setMuxStandby(); - - handleMuxState("error", 3); - VALIDATE_STATE(Standby, Error, Up); - - handleMuxState("error", 3); - VALIDATE_STATE(Standby, Error, Up); - - postLinkProberEvent(link_prober::LinkProberState::Active, 2); - VALIDATE_STATE(Active, Wait, Up); - - handleProbeMuxState("active", 3); - VALIDATE_STATE(Active, Active, Up); -} - -TEST_F(LinkManagerStateMachineTest, MuxActive2Error2Unknown) -{ - setMuxActive(); - - postLinkEvent(link_state::LinkState::Down, 2); - VALIDATE_STATE(Active, Wait, Down); - - // fake mux statedb state to be active - mDbInterfacePtr->setNextMuxState(mux_state::MuxState::Error); - - handleMuxState("error", 4); - VALIDATE_STATE(Active, Error, Down); - - handleMuxState("error", 3); - VALIDATE_STATE(Active, Error, Down); - - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Active, Unknown, Down); - - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Active, Unknown, Down); - - handleProbeMuxState("active", 3); - VALIDATE_STATE(Active, Active, Down); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandby2Error2Unknown) -{ - setMuxStandby(); - - postLinkEvent(link_state::LinkState::Down, 2); - VALIDATE_STATE(Standby, Standby, Down); - - // fake mux statedb state to be active - mDbInterfacePtr->setNextMuxState(mux_state::MuxState::Error); - - handleMuxState("error", 3); - VALIDATE_STATE(Standby, Error, Down); - - handleMuxState("error", 3); - VALIDATE_STATE(Standby, Error, Down); - - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Standby, Unknown, Down); - - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Standby, Unknown, Down); - - handleProbeMuxState("standby", 3); - VALIDATE_STATE(Standby, Standby, Down); -} - -TEST_F(LinkManagerStateMachineTest, MuxActive2Unknown2Error) -{ - setMuxActive(); - - postLinkEvent(link_state::LinkState::Down, 2); - VALIDATE_STATE(Active, Wait, Down); - - handleProbeMuxState("unknown", 4); - VALIDATE_STATE(Active, Unknown, Down); - - handleMuxState("error", 3); - VALIDATE_STATE(Active, Error, Down); -} - -TEST_F(LinkManagerStateMachineTest, MuxStandby2Unknown2Error) -{ - setMuxStandby(); - - postLinkEvent(link_state::LinkState::Down, 2); - VALIDATE_STATE(Standby, Standby, Down); - - handleProbeMuxState("unknown", 3); - VALIDATE_STATE(Standby, Unknown, Down); - - handleMuxState("error", 3); - VALIDATE_STATE(Standby, Error, Down); -} - -} /* namespace test */ diff --git a/src/linkmgrd/test/LinkManagerStateMachineTest.h b/src/linkmgrd/test/LinkManagerStateMachineTest.h deleted file mode 100644 index e86038a3d1c1..000000000000 --- a/src/linkmgrd/test/LinkManagerStateMachineTest.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * LinkManagerStateMachineTest.h - * - * Created on: Oct 25, 2020 - * Author: tamer - */ - -#ifndef LINKMANAGERSTATEMACHINETEST_H_ -#define LINKMANAGERSTATEMACHINETEST_H_ - -#include "gtest/gtest.h" - -#include "FakeMuxPort.h" -#include "FakeLinkProber.h" - -namespace test -{ - -class LinkManagerStateMachineTest: public ::testing::Test -{ -public: - LinkManagerStateMachineTest(); - virtual ~LinkManagerStateMachineTest() = default; - - void runIoService(uint32_t count = 0); - void postLinkProberEvent(link_prober::LinkProberState::Label label, uint32_t count = 0); - void postMuxEvent(mux_state::MuxState::Label label, uint32_t count = 0); - void postLinkEvent(link_state::LinkState::Label label, uint32_t count = 0); - void postSuspendTimerExpiredEvent(uint32_t count = 0); - void handleMuxState(std::string, uint32_t count = 0); - void handleGetMuxState(std::string, uint32_t count = 0); - void handleProbeMuxState(std::string, uint32_t count = 0); - void handleLinkState(std::string linkState, uint32_t count = 0); - void handleMuxConfig(std::string config, uint32_t count = 0); - void activateStateMachine(); - void setMuxActive(); - void setMuxStandby(); - -public: - boost::asio::io_service mIoService; - common::MuxConfig mMuxConfig; - std::shared_ptr mDbInterfacePtr; - std::string mPortName = "EtherTest01"; - std::string mSmartNicIpAddress = "192.168.1.20"; - uint16_t mServerId = 01; - - FakeMuxPort mFakeMuxPort; - link_manager::LinkManagerStateMachine::CompositeState mTestCompositeState; - - uint8_t mPositiveUpdateCount = 2; -}; - -} /* namespace test */ - -#endif /* LINKMANAGERSTATEMACHINETEST_H_ */ diff --git a/src/linkmgrd/test/LinkProberTest.cpp b/src/linkmgrd/test/LinkProberTest.cpp deleted file mode 100644 index efb37401511f..000000000000 --- a/src/linkmgrd/test/LinkProberTest.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * LinkProberTest.cpp - * - * Created on: May 12, 2021 - * Author: taahme - */ - -#include -#include - -#include "common/MuxException.h" -#include "link_prober/IcmpPayload.h" -#include "LinkProberTest.h" - -namespace test -{ - -LinkProberTest::LinkProberTest() : - mDbInterfacePtr(std::make_shared (&mIoService)), - mFakeMuxPort( - mDbInterfacePtr, - mMuxConfig, - mPortName, - mServerId, - mIoService - ), - mLinkProber(const_cast ( - mFakeMuxPort.getMuxPortConfig()), - mIoService, - mFakeMuxPort.getLinkProberStateMachine() - ) -{ - mMuxConfig.setTimeoutIpv4_msec(1); -} - -TEST_F(LinkProberTest, InitializeSendBuffer) -{ - initializeSendBuffer(); - std::array txBuffer = getTxBuffer(); - - ether_header *ethHeader = reinterpret_cast (txBuffer.data()); - EXPECT_TRUE(memcmp( - ethHeader->ether_dhost, - mFakeMuxPort.getMuxPortConfig().getBladeMacAddress().data(), - sizeof(ethHeader->ether_dhost) - ) == 0); - EXPECT_TRUE(ethHeader->ether_type == htons(ETHERTYPE_IP)); - - iphdr *ipHeader = reinterpret_cast (txBuffer.data() + sizeof(ether_header)); - EXPECT_TRUE(ipHeader->ihl == sizeof(iphdr) >> 2); - EXPECT_TRUE(ipHeader->version == IPVERSION); - EXPECT_TRUE(ipHeader->tos == 0xb8); - EXPECT_TRUE(ipHeader->tot_len == htons(sizeof(iphdr) + sizeof(icmphdr) + sizeof(link_prober::IcmpPayload))); - EXPECT_TRUE(ipHeader->frag_off == 0); - EXPECT_TRUE(ipHeader->ttl == 64); - EXPECT_TRUE(ipHeader->protocol == IPPROTO_ICMP); - EXPECT_TRUE(ipHeader->check == 62663); - EXPECT_TRUE(ipHeader->saddr == htonl(mFakeMuxPort.getMuxPortConfig().getLoopbackIpv4Address().to_v4().to_uint())); - EXPECT_TRUE(ipHeader->daddr == htonl(mFakeMuxPort.getMuxPortConfig().getBladeIpv4Address().to_v4().to_uint())); - - icmphdr *icmpHeader = reinterpret_cast (txBuffer.data() + sizeof(ether_header) + sizeof(iphdr)); - EXPECT_TRUE(icmpHeader->type == ICMP_ECHO); - EXPECT_TRUE(icmpHeader->code == 0); - EXPECT_TRUE(icmpHeader->un.echo.id == htons(mFakeMuxPort.getMuxPortConfig().getServerId())); - EXPECT_TRUE(icmpHeader->un.echo.sequence == htons(0xffff)); - - link_prober::IcmpPayload *icmpPayload = new ( - txBuffer.data() + sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr) - ) link_prober::IcmpPayload(); - - EXPECT_TRUE(icmpPayload->cookie == htonl(link_prober::IcmpPayload::getCookie())); - EXPECT_TRUE(icmpPayload->version == htonl(link_prober::IcmpPayload::getVersion())); - EXPECT_TRUE(memcmp( - icmpPayload->un.uuid.data, - link_prober::IcmpPayload::getGuidData(), - link_prober::IcmpPayload::getGuid().size() - ) == 0); -} - -TEST_F(LinkProberTest, CalculateChecksum) -{ - link_prober::IcmpPayload *icmpPayload = new ( - getTxBuffer().data() + sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr) - ) link_prober::IcmpPayload(); - boost::uuids::uuid guid = boost::lexical_cast ("44f49d86-c312-414b-b6a1-be82901ac459"); - memcpy(icmpPayload->un.uuid.data, guid.data, guid.size()); - initializeSendBuffer(); - - icmphdr *icmpHeader = reinterpret_cast (getTxBuffer().data() + sizeof(ether_header) + sizeof(iphdr)); - EXPECT_TRUE(icmpHeader->checksum == 12355); -} - -TEST_F(LinkProberTest, UpdateEthernetFrame) -{ - link_prober::IcmpPayload *icmpPayload = new ( - getTxBuffer().data() + sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr) - ) link_prober::IcmpPayload(); - boost::uuids::uuid guid = boost::lexical_cast ("44f49d86-c312-414b-b6a1-be82901ac459"); - memcpy(icmpPayload->un.uuid.data, guid.data, guid.size()); - handleUpdateEthernetFrame(); - - icmphdr *icmpHeader = reinterpret_cast (getTxBuffer().data() + sizeof(ether_header) + sizeof(iphdr)); - EXPECT_TRUE(icmpHeader->checksum == 12355); -} - -TEST_F(LinkProberTest, UpdateSequenceNo) -{ - link_prober::IcmpPayload *icmpPayload = new ( - getTxBuffer().data() + sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr) - ) link_prober::IcmpPayload(); - boost::uuids::uuid guid = boost::lexical_cast ("44f49d86-c312-414b-b6a1-be82901ac459"); - memcpy(icmpPayload->un.uuid.data, guid.data, guid.size()); - - handleUpdateEthernetFrame(); - - // update sequence number twice as we start with 0xffff - handleUpdateSequenceNumber(); - handleUpdateSequenceNumber(); - - icmphdr *icmpHeader = reinterpret_cast (getTxBuffer().data() + sizeof(ether_header) + sizeof(iphdr)); - EXPECT_TRUE(icmpHeader->checksum == 12099); - - EXPECT_TRUE(getRxSelfSeqNo() + 1 == ntohs(icmpHeader->un.echo.sequence)); - EXPECT_TRUE(getRxPeerSeqNo() + 1 == ntohs(icmpHeader->un.echo.sequence)); -} - -TEST_F(LinkProberTest, GenerateGuid) -{ - link_prober::IcmpPayload::generateGuid(); - initializeSendBuffer(); - - std::array txBuffer = getTxBuffer(); - link_prober::IcmpPayload *icmpPayload = new ( - txBuffer.data() + sizeof(ether_header) + sizeof(iphdr) + sizeof(icmphdr) - ) link_prober::IcmpPayload(); - EXPECT_TRUE(memcmp( - icmpPayload->un.uuid.data, - link_prober::IcmpPayload::getGuidData(), - link_prober::IcmpPayload::getGuid().size() - ) == 0); -} - -TEST_F(LinkProberTest, UpdateToRMac) -{ - link_prober::IcmpPayload::generateGuid(); - - std::array torMac = {0, 'b', 2, 'd', 4, 'f'}; - mMuxConfig.setTorMacAddress(torMac); - - boost::asio::ip::address ipAddress = boost::asio::ip::address::from_string("192.168.1.100"); - mFakeMuxPort.setServerIpv4Address(ipAddress); - - initializeSendBuffer(); - - std::array txBuffer = getTxBuffer(); - ether_header *ethHeader = reinterpret_cast (txBuffer.data()); - - EXPECT_TRUE(ethHeader->ether_shost[0] == torMac[0]); - EXPECT_TRUE(ethHeader->ether_shost[1] == torMac[1]); - EXPECT_TRUE(ethHeader->ether_shost[2] == torMac[2]); - EXPECT_TRUE(ethHeader->ether_shost[3] == torMac[3]); - EXPECT_TRUE(ethHeader->ether_shost[4] == torMac[4]); - EXPECT_TRUE(ethHeader->ether_shost[5] == torMac[5]); - - iphdr *ipHeader = reinterpret_cast (txBuffer.data() + sizeof(ether_header)); - - EXPECT_TRUE(ipHeader->daddr == htonl(ipAddress.to_v4().to_uint())); -} - -TEST_F(LinkProberTest, InitializeException) -{ - EXPECT_THROW(initialize(), common::SocketErrorException); -} - -} /* namespace test */ diff --git a/src/linkmgrd/test/LinkProberTest.h b/src/linkmgrd/test/LinkProberTest.h deleted file mode 100644 index 39e02eb35f65..000000000000 --- a/src/linkmgrd/test/LinkProberTest.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * LinkProberTest.h - * - * Created on: May 12, 2021 - * Author: taahme - */ - -#ifndef LINKPROBERTEST_H_ -#define LINKPROBERTEST_H_ - -#include "gtest/gtest.h" - -#include "FakeMuxPort.h" -#include "link_prober/LinkProber.h" - -namespace test -{ - -class LinkProberTest: public ::testing::Test -{ -public: - LinkProberTest(); - virtual ~LinkProberTest() = default; - - void initialize() {mLinkProber.initialize();}; - void initializeSendBuffer() {mLinkProber.initializeSendBuffer();}; - void handleUpdateEthernetFrame() {mLinkProber.handleUpdateEthernetFrame();}; - void handleUpdateSequenceNumber() {mLinkProber.updateIcmpSequenceNo();}; - std::array getTxBuffer() {return mLinkProber.getTxBuffer();}; - - uint16_t getRxSelfSeqNo() {return mLinkProber.mRxSelfSeqNo;}; - uint16_t getRxPeerSeqNo() {return mLinkProber.mRxPeerSeqNo;}; - - boost::asio::io_service mIoService; - common::MuxConfig mMuxConfig; - std::shared_ptr mDbInterfacePtr; - std::string mPortName = "EtherTest01"; - std::string mSmartNicIpAddress = "192.168.1.20"; - uint16_t mServerId = 01; - - FakeMuxPort mFakeMuxPort; - link_prober::LinkProber mLinkProber; -}; - -} /* namespace test */ - -#endif /* LINKPROBERTEST_H_ */ diff --git a/src/linkmgrd/test/MuxManagerTest.cpp b/src/linkmgrd/test/MuxManagerTest.cpp deleted file mode 100644 index 19cb39561dfa..000000000000 --- a/src/linkmgrd/test/MuxManagerTest.cpp +++ /dev/null @@ -1,463 +0,0 @@ -/* - * MuxManagerTest.cpp - * - * Created on: Jun 4, 2021 - * Author: taahme - */ - -#include "common/MuxException.h" -#include "swss/macaddress.h" - -#include "MuxManager.h" -#include "MuxManagerTest.h" - -namespace test -{ - -MuxManagerTest::MuxManagerTest() : - mMuxManagerPtr(std::make_shared ()), - mDbInterfacePtr(std::make_shared (mMuxManagerPtr.get(), &mMuxManagerPtr->getIoService())), - mNetMsgInterface(*mDbInterfacePtr) -{ - mMuxManagerPtr->setDbInterfacePtr(mDbInterfacePtr); - - link_prober::IcmpPayload::generateGuid(); - link_manager::LinkManagerStateMachine::initializeTransitionFunctionTable(); -} - -void MuxManagerTest::runIoService(uint32_t count) -{ - for (uint32_t i = 0; i < count; i++) { - mMuxManagerPtr->getIoService().run_one(); - mMuxManagerPtr->getIoService().reset(); - } -} - -common::MuxPortConfig::Mode MuxManagerTest::getMode(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->mMuxPortConfig.getMode(); -} - -uint32_t MuxManagerTest::getPositiveStateChangeRetryCount(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->mMuxPortConfig.getPositiveStateChangeRetryCount(); -} - -uint32_t MuxManagerTest::getNegativeStateChangeRetryCount(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->mMuxPortConfig.getNegativeStateChangeRetryCount(); -} - -uint32_t MuxManagerTest::getTimeoutIpv4_msec(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - return muxPortPtr->mMuxPortConfig.getTimeoutIpv4_msec(); -} - -uint32_t MuxManagerTest::getTimeoutIpv6_msec(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->mMuxPortConfig.getTimeoutIpv6_msec(); -} - -uint32_t MuxManagerTest::getLinkWaitTimeout_msec(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->mMuxPortConfig.getLinkWaitTimeout_msec(); -} - -boost::asio::ip::address MuxManagerTest::getBladeIpv4Address(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->mMuxPortConfig.getBladeIpv4Address(); -} - -std::array MuxManagerTest::getBladeMacAddress(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->mMuxPortConfig.getBladeMacAddress(); -} - -boost::asio::ip::address MuxManagerTest::getLoopbackIpv4Address(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->mMuxPortConfig.getLoopbackIpv4Address(); -} - -std::array MuxManagerTest::getTorMacAddress(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->mMuxPortConfig.getTorMacAddress(); -} - -void MuxManagerTest::processMuxPortConfigNotifiction(std::deque &entries) -{ - mDbInterfacePtr->processMuxPortConfigNotifiction(entries); -} - -link_manager::LinkManagerStateMachine::CompositeState MuxManagerTest::getCompositeStateMachineState(std::string port) -{ - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap[port]; - - return muxPortPtr->getLinkManagerStateMachine()->getCompositeState(); -} - -void MuxManagerTest::processServerIpAddress(std::vector &servers) -{ - mDbInterfacePtr->processServerIpAddress(servers); - - EXPECT_TRUE(mMuxManagerPtr->mPortMap.size() == 1); -} - -void MuxManagerTest::processServerMacAddress( - std::string port, - std::array ip, - std::array mac -) -{ - mNetMsgInterface.updateMacAddress(port, ip, mac); -} - -void MuxManagerTest::processLoopback2InterfaceInfo(std::vector &loopbackIntfs) -{ - mDbInterfacePtr->processLoopback2InterfaceInfo(loopbackIntfs); -} - -void MuxManagerTest::processTorMacAddress(std::string &mac) -{ - mDbInterfacePtr->processTorMacAddress(mac); -} - -void MuxManagerTest::processMuxResponseNotifiction(std::deque &entries) -{ - mDbInterfacePtr->processMuxResponseNotifiction(entries); -} - -void MuxManagerTest::processMuxLinkmgrConfigNotifiction(std::deque &entries) -{ - mDbInterfacePtr->processMuxLinkmgrConfigNotifiction(entries); -} - -void MuxManagerTest::updateServerMacAddress(boost::asio::ip::address serverIp, const uint8_t *serverMac) -{ - mDbInterfacePtr->updateServerMacAddress(serverIp, serverMac); -} - -void MuxManagerTest::processGetMuxState(const std::string &portName, const std::string &muxState) -{ - mMuxManagerPtr->processGetMuxState(portName, muxState); -} - -void MuxManagerTest::createPort(std::string port) -{ - EXPECT_TRUE(mMuxManagerPtr->mPortMap.size() == 0); - - std::deque entries = { - {port, "SET", {{"oper_status", "up"}}}, - }; - - mDbInterfacePtr->processLinkStateNotifiction(entries); - std::shared_ptr muxPortPtr = mMuxManagerPtr->mPortMap["Ethernet0"]; - link_manager::LinkManagerStateMachine* linkManagerStateMachine = muxPortPtr->getLinkManagerStateMachine(); - - EXPECT_TRUE(mMuxManagerPtr->mPortMap.size() == 1); - EXPECT_TRUE(linkManagerStateMachine->mComponentInitState.test(link_manager::LinkManagerStateMachine::LinkStateComponent) == 0); - - runIoService(); - - EXPECT_TRUE(linkManagerStateMachine->mComponentInitState.test(link_manager::LinkManagerStateMachine::LinkStateComponent) == 1); - - // Initialize a FakeLinkProber - mFakeLinkProber = std::make_shared (&linkManagerStateMachine->getLinkProberStateMachine()); - linkManagerStateMachine->setInitializeProberFnPtr( - boost::bind(&FakeLinkProber::initialize, mFakeLinkProber.get()) - ); - linkManagerStateMachine->setStartProbingFnPtr( - boost::bind(&FakeLinkProber::startProbing, mFakeLinkProber.get()) - ); - linkManagerStateMachine->setUpdateEthernetFrameFnPtr( - boost::bind(&FakeLinkProber::updateEthernetFrame, mFakeLinkProber.get()) - ); - linkManagerStateMachine->setSuspendTxFnPtr( - boost::bind(&FakeLinkProber::suspendTxProbes, mFakeLinkProber.get(), boost::placeholders::_1) - ); - - linkManagerStateMachine->mComponentInitState.set(0); - - std::string ipAddress = "192.168.0.1"; - std::vector servers; - servers = { - {port, "SET", {{"server_ipv4", ipAddress + "/32"}, {"server_ipv6", "2603:10e1:100:f::1/128"}}}, - {"Ethernet1234", "SET", {{"server_ipv4", "250.260.270.280/32"}}}, - }; - - processServerIpAddress(servers); - - runIoService(); - - entries.clear(); - entries = { - {port, "SET", {{"state", "active"}}}, - }; - - mDbInterfacePtr->processMuxStateNotifiction(entries); - EXPECT_TRUE(mMuxManagerPtr->mPortMap.size() == 1); - EXPECT_TRUE(linkManagerStateMachine->mComponentInitState.test(link_manager::LinkManagerStateMachine::MuxStateComponent) == 0); - - runIoService(); - - EXPECT_TRUE(linkManagerStateMachine->mComponentInitState.test(link_manager::LinkManagerStateMachine::MuxStateComponent) == 1); -} - -TEST_F(MuxManagerTest, AddPort) -{ - std::string port = "Ethernet0"; - std::string ipAddress = "192.168.0.1"; - - createPort(port); - - std::array serverMac = {0, 'b', 2, 'd', 4, 'f'}; - boost::asio::ip::address serverAddress = boost::asio::ip::address::from_string(ipAddress); - - updateServerMacAddress(serverAddress, serverMac.data()); - - runIoService(); - - std::array bladeMacAddress = getBladeMacAddress(port); - - EXPECT_TRUE(bladeMacAddress == serverMac); - EXPECT_TRUE(getBladeIpv4Address(port).to_string() == ipAddress); -} - -TEST_F(MuxManagerTest, Loopback2Address) -{ - std::string port = "Ethernet0"; - - createPort(port); - - std::string ipAddress = "10.10.10.2"; - std::vector loopbackIntfs = { - "Loopback2|2603:10e1:100:d::1/128", - "Loopback2|" + ipAddress + "/32", - "Loopback2" - }; - - processLoopback2InterfaceInfo(loopbackIntfs); - - EXPECT_TRUE(getLoopbackIpv4Address(port).to_string() == ipAddress); -} - -TEST_F(MuxManagerTest, Loopback2AddressException) -{ - std::string port = "Ethernet0"; - - createPort(port); - - std::vector loopbackIntfs = { - "Loopback2|2603:10e1:100:d::1/128", - "Loopback2|250.260.270.280/32", - "Loopback2" - }; - - EXPECT_THROW(processLoopback2InterfaceInfo(loopbackIntfs), common::ConfigNotFoundException); -} - -TEST_F(MuxManagerTest, ToRMacAddress) -{ - std::string port = "Ethernet0"; - - createPort(port); - - std::string mac = "0a:b1:2c:d3:4e:f5"; - swss::MacAddress swssMacAddress(mac); - std::array macAddress; - memcpy(macAddress.data(), swssMacAddress.getMac(), macAddress.size()); - - processTorMacAddress(mac); - - std::array torMac = getTorMacAddress(port); - - EXPECT_TRUE(torMac == macAddress); -} - -TEST_F(MuxManagerTest, ToRMacAddressException) -{ - std::string port = "Ethernet0"; - - createPort(port); - - std::string mac = "invalid mac"; - - EXPECT_THROW(processTorMacAddress(mac), common::ConfigNotFoundException); -} - -TEST_F(MuxManagerTest, ServerMacAddress) -{ - std::string port = "Ethernet0"; - std::string ipAddress = "192.168.0.1"; - - createPort(port); - - std::string mac = "a0:1b:c2:3d:e4:5f"; - std::array macAddress = {0}; - memcpy(macAddress.data(), mac.c_str(), mac.size()); - std::array serverIpAddress = {0}; - memcpy(serverIpAddress.data(), ipAddress.c_str(), ipAddress.size()); - - processServerMacAddress(port, serverIpAddress, macAddress); - - runIoService(); - - std::array serverMac = getBladeMacAddress(port); - - swss::MacAddress swssMacAddress(mac); - std::array expectedMac; - memcpy(expectedMac.data(), swssMacAddress.getMac(), expectedMac.size()); - - EXPECT_TRUE(serverMac == expectedMac); -} - -TEST_F(MuxManagerTest, ServerMacAddressException) -{ - std::string port = "Ethernet0"; - std::string ipAddress = "192.168.0.1"; - - createPort(port); - - std::string mac = "invalid mac"; - std::array macAddress = {0}; - memcpy(macAddress.data(), mac.c_str(), mac.size()); - std::array serverIpAddress = {0}; - memcpy(serverIpAddress.data(), ipAddress.c_str(), ipAddress.size()); - - std::array serverMacBefore = getBladeMacAddress(port); - - processServerMacAddress(port, serverIpAddress, macAddress);; - - std::array serverMacAfter = getBladeMacAddress(port); - - EXPECT_TRUE(serverMacBefore == serverMacAfter); -} - -TEST_F(MuxManagerTest, LinkmgrdConfig) -{ - std::string port = "Ethernet0"; - - createPort(port); - - uint32_t v4PorbeInterval = 70; - uint32_t v6ProveInterval = 700; - uint32_t positiveSignalCount = 2; - uint32_t negativeSignalCount = 3; - uint32_t suspendTimer = 5; - std::deque entries = { - {"LINK_PROBER", "SET", {{"interval_v4", boost::lexical_cast (v4PorbeInterval)}}}, - {"LINK_PROBER", "SET", {{"interval_v6", boost::lexical_cast (v6ProveInterval)}}}, - {"LINK_PROBER", "SET", {{"positive_signal_count", boost::lexical_cast (positiveSignalCount)}}}, - {"LINK_PROBER", "SET", {{"negative_signal_count", boost::lexical_cast (negativeSignalCount)}}}, - {"LINK_PROBER", "SET", {{"suspend_timer", boost::lexical_cast (suspendTimer)}}}, - {"LINK_PROBER", "SET", {{"interval_v4", "abc"}}}, - {"MUXLOGGER", "SET", {{"log_verbosity", "warning"}}}, - }; - processMuxLinkmgrConfigNotifiction(entries); - - EXPECT_TRUE(getTimeoutIpv4_msec(port) == v4PorbeInterval); - EXPECT_TRUE(getTimeoutIpv6_msec(port) == v6ProveInterval); - EXPECT_TRUE(getPositiveStateChangeRetryCount(port) == positiveSignalCount); - EXPECT_TRUE(getNegativeStateChangeRetryCount(port) == negativeSignalCount); - EXPECT_TRUE(getLinkWaitTimeout_msec(port) == (negativeSignalCount + 1) * v4PorbeInterval); - EXPECT_TRUE(common::MuxLogger::getInstance()->getLevel() == boost::log::trivial::warning); -} - -TEST_P(MuxResponseTest, MuxResponse) -{ - std::string port = "Ethernet0"; - - createPort(port); - - std::deque entries = { - {port, "SET", {{"response", std::get<0> (GetParam())}}}, - }; - processMuxResponseNotifiction(entries); - - runIoService(std::get<1> (GetParam())); - - EXPECT_TRUE(ms(getCompositeStateMachineState(port)) == std::get<2> (GetParam())); -} - -INSTANTIATE_TEST_CASE_P( - MuxState, - MuxResponseTest, - ::testing::Values( - std::make_tuple("active", 1, mux_state::MuxState::Label::Active), - std::make_tuple("standby", 3, mux_state::MuxState::Label::Wait), - std::make_tuple("unknown", 3, mux_state::MuxState::Label::Wait), - std::make_tuple("error", 3, mux_state::MuxState::Label::Wait) - ) -); - -TEST_P(GetMuxStateTest, GetMuxState) -{ - std::string port = "Ethernet0"; - - createPort(port); - - std::string state = std::get<0> (GetParam()); - - processGetMuxState(port, state); - - runIoService(); - - EXPECT_TRUE(ms(getCompositeStateMachineState(port)) == std::get<1> (GetParam())); -} - -INSTANTIATE_TEST_CASE_P( - MuxState, - GetMuxStateTest, - ::testing::Values( - std::make_tuple("active", mux_state::MuxState::Label::Active), - std::make_tuple("standby", mux_state::MuxState::Label::Wait), - std::make_tuple("unknown", mux_state::MuxState::Label::Wait), - std::make_tuple("error", mux_state::MuxState::Label::Wait) - ) -); - -TEST_P(MuxConfigUpdateTest, MuxPortConfigUpdate) -{ - std::string port = "Ethernet0"; - - createPort("Ethernet0"); - - std::string state = std::get<0> (GetParam()); - std::deque entries = { - {port, "SET", {{"state", state}}}, - }; - processMuxPortConfigNotifiction(entries); - runIoService(); - - EXPECT_TRUE(getMode("Ethernet0") == std::get<1> (GetParam())); -} - -INSTANTIATE_TEST_CASE_P( - AutoActiveManual, - MuxConfigUpdateTest, - ::testing::Values( - std::make_tuple("auto", common::MuxPortConfig::Mode::Auto), - std::make_tuple("active", common::MuxPortConfig::Mode::Active), - std::make_tuple("manual", common::MuxPortConfig::Mode::Manual) - ) -); - -} /* namespace test */ diff --git a/src/linkmgrd/test/MuxManagerTest.h b/src/linkmgrd/test/MuxManagerTest.h deleted file mode 100644 index e2c413dde9e1..000000000000 --- a/src/linkmgrd/test/MuxManagerTest.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * MuxManagerTest.h - * - * Created on: Jun 4, 2021 - * Author: taahme - */ - -#ifndef MUXMANAGERTEST_H_ -#define MUXMANAGERTEST_H_ - -#include -#include -#include "gtest/gtest.h" - -#include "FakeDbInterface.h" -#include "FakeLinkProber.h" -#include "NetMsgInterface.h" - -namespace mux { -class MuxManager; -} - -namespace test -{ - -class MuxManagerTest: public testing::Test -{ -public: - MuxManagerTest(); - virtual ~MuxManagerTest() = default; - - void runIoService(uint32_t count = 1); - common::MuxPortConfig::Mode getMode(std::string port); - uint32_t getPositiveStateChangeRetryCount(std::string port); - uint32_t getNegativeStateChangeRetryCount(std::string port); - uint32_t getTimeoutIpv4_msec(std::string port); - uint32_t getTimeoutIpv6_msec(std::string port); - uint32_t getLinkWaitTimeout_msec(std::string port); - boost::asio::ip::address getBladeIpv4Address(std::string port); - std::array getBladeMacAddress(std::string port); - boost::asio::ip::address getLoopbackIpv4Address(std::string port); - std::array getTorMacAddress(std::string port); - void processMuxPortConfigNotifiction(std::deque &entries); - link_manager::LinkManagerStateMachine::CompositeState getCompositeStateMachineState(std::string port); - void processServerIpAddress(std::vector &servers); - void processServerMacAddress(std::string port, std::array ip, std::array mac); - void processLoopback2InterfaceInfo(std::vector &loopbackIntfs); - void processTorMacAddress(std::string &mac); - void processMuxResponseNotifiction(std::deque &entries); - void processMuxLinkmgrConfigNotifiction(std::deque &entries); - void updateServerMacAddress(boost::asio::ip::address serverIp, const uint8_t *serverMac); - void processGetMuxState(const std::string &portName, const std::string &muxState); - void createPort(std::string port); - -public: - std::shared_ptr mMuxManagerPtr; - std::shared_ptr mDbInterfacePtr; - mux::NetMsgInterface mNetMsgInterface; - - std::shared_ptr mFakeLinkProber; -}; - -class MuxResponseTest: public MuxManagerTest, - public testing::WithParamInterface> -{ -}; - -class GetMuxStateTest: public MuxManagerTest, - public testing::WithParamInterface> -{ -}; - -class MuxConfigUpdateTest: public MuxManagerTest, - public testing::WithParamInterface> -{ -}; - -} /* namespace test */ - -#endif /* MUXMANAGERTEST_H_ */ diff --git a/src/linkmgrd/test/subdir.mk b/src/linkmgrd/test/subdir.mk deleted file mode 100644 index a5782d2dc1f7..000000000000 --- a/src/linkmgrd/test/subdir.mk +++ /dev/null @@ -1,34 +0,0 @@ -# Add inputs and outputs from these tool invocations to the build variables -CPP_SRCS += \ - ./test/FakeDbInterface.cpp \ - ./test/FakeLinkProber.cpp \ - ./test/FakeMuxPort.cpp \ - ./test/LinkManagerStateMachineTest.cpp \ - ./test/LinkProberTest.cpp \ - ./test/MuxManagerTest.cpp - -OBJS_LINKMGRD_TEST += \ - ./test/FakeDbInterface.o \ - ./test/FakeLinkProber.o \ - ./test/FakeMuxPort.o \ - ./test/LinkManagerStateMachineTest.o \ - ./test/LinkProberTest.o \ - ./test/MuxManagerTest.o - -CPP_DEPS += \ - ./test/FakeDbInterface.d \ - ./test/FakeLinkProber.d \ - ./test/FakeMuxPort.d \ - ./test/LinkManagerStateMachineTest.d \ - ./test/LinkProberTest.d \ - ./test/MuxManagerTest.d - -# Each subdirectory must supply rules for building sources it contributes -test/%.o: test/%.cpp - @echo 'Building file: $<' - @echo 'Invoking: GCC C++ Compiler' - g++ -std=c++17 -D__FILENAME__="$(subst src/,,$<)" -DBOOST_LOG_DYN_LINK $(INCLUDES) $(CPP_FLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" - @echo 'Finished building: $<' - @echo ' ' - - diff --git a/src/redis-dump-load.patch/0003-use-redis-3.5.3.patch b/src/redis-dump-load.patch/0003-use-redis-3.5.3.patch new file mode 100644 index 000000000000..a58c2059e81a --- /dev/null +++ b/src/redis-dump-load.patch/0003-use-redis-3.5.3.patch @@ -0,0 +1,25 @@ +Pin the redis package to version 3.5.3 (the last version that supports both +Python 2 and 3). + +Signed-off-by: Saikrishna Arcot + +diff --git a/requirements.txt b/requirements.txt +index 7800f0f..3fc0632 100644 +--- a/requirements.txt ++++ b/requirements.txt +@@ -1 +1 @@ +-redis ++redis==3.5.3 +diff --git a/setup.py b/setup.py +index 8ccf31f..6db9ec4 100644 +--- a/setup.py ++++ b/setup.py +@@ -17,7 +17,7 @@ setup(name=package_name, + author_email='oleg@bsdpower.com', + url='http://github.com/p/redis-dump-load', + py_modules=['redisdl'], +- install_requires=['redis'], ++ install_requires=['redis==3.5.3'], + data_files=[ + (doc_dir, data_files), + ], diff --git a/src/redis-dump-load.patch/series b/src/redis-dump-load.patch/series index c73c3b5caa97..50beb71a677f 100644 --- a/src/redis-dump-load.patch/series +++ b/src/redis-dump-load.patch/series @@ -1,2 +1,3 @@ 0001-Use-pipelines-when-dumping-52.patch 0002-Fix-setup.py-for-test-and-bdist_wheel.patch +0003-use-redis-3.5.3.patch diff --git a/src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py b/src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py index 3ab7dba4f612..c787ae2abe69 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py +++ b/src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py @@ -125,6 +125,9 @@ def __init__(self, common_objs, db_name, table_name, peer_type, check_neig_meta) if self.check_deployment_id: deps.append(("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME, "localhost/deployment_id")) + if self.peer_type == 'internal': + deps.append(("CONFIG_DB", swsscommon.CFG_LOOPBACK_INTERFACE_TABLE_NAME, "Loopback4096")) + super(BGPPeerMgrBase, self).__init__( common_objs, deps, @@ -160,11 +163,17 @@ def add_peer(self, vrf, nbr, data): print_data = vrf, nbr, data bgp_asn = self.directory.get_slot("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME)["localhost"]["bgp_asn"] # - lo0_ipv4 = self.get_lo0_ipv4() + lo0_ipv4 = self.get_lo_ipv4("Loopback0|") if lo0_ipv4 is None: log_warn("Loopback0 ipv4 address is not presented yet") return False # + if self.peer_type == 'internal': + lo4096_ipv4 = self.get_lo_ipv4("Loopback4096|") + if lo4096_ipv4 is None: + log_warn("Loopback4096 ipv4 address is not presented yet") + return False + if "local_addr" not in data: log_warn("Peer %s. Missing attribute 'local_addr'" % nbr) else: @@ -299,15 +308,15 @@ def apply_op(self, cmd, vrf): self.cfg_mgr.push(cmd) return True - def get_lo0_ipv4(self): + def get_lo_ipv4(self, loopback_str): """ Extract Loopback0 ipv4 address from the Directory :return: ipv4 address for Loopback0, None if nothing found """ loopback0_ipv4 = None for loopback in self.directory.get_slot("CONFIG_DB", swsscommon.CFG_LOOPBACK_INTERFACE_TABLE_NAME).keys(): - if loopback.startswith("Loopback0|"): - loopback0_prefix_str = loopback.replace("Loopback0|", "") + if loopback.startswith(loopback_str): + loopback0_prefix_str = loopback.replace(loopback_str, "") loopback0_ip_str = loopback0_prefix_str[:loopback0_prefix_str.find('/')] if TemplateFabric.is_ipv4(loopback0_ip_str): loopback0_ipv4 = loopback0_ip_str diff --git a/src/sonic-bgpcfgd/bgpcfgd/template.py b/src/sonic-bgpcfgd/bgpcfgd/template.py index e88073881171..a2b476e6b2c9 100644 --- a/src/sonic-bgpcfgd/bgpcfgd/template.py +++ b/src/sonic-bgpcfgd/bgpcfgd/template.py @@ -75,7 +75,7 @@ def prefix_attr(attr, value): return None else: try: - prefix = netaddr.IPNetwork(str(value)) + prefix = netaddr.IPNetwork(str(value).strip()) except (netaddr.NotRegisteredError, netaddr.AddrFormatError, netaddr.AddrConversionError): return None return str(getattr(prefix, attr)) @@ -105,4 +105,4 @@ def pfx_filter(value): log_err("'%s' is invalid ip address" % ip_address) else: table[key] = val - return table \ No newline at end of file + return table diff --git a/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/param_chasiss_packet.json b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/param_chasiss_packet.json new file mode 100644 index 000000000000..956758febcfe --- /dev/null +++ b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/param_chasiss_packet.json @@ -0,0 +1,13 @@ +{ + "CONFIG_DB__DEVICE_METADATA": { + "localhost": { + "type": "SpineRouter", + "sub_role": "BackEnd", + "switch_type": "chassis-packet" + } + }, + "CONFIG_DB__LOOPBACK_INTERFACE": { + "Loopback4096|10.10.10.10/32": {}, + "Loopback4096|2603:10e2:400::3/128": {} + } +} diff --git a/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_chasiss_packet.conf b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_chasiss_packet.conf new file mode 100644 index 000000000000..08ef259e0899 --- /dev/null +++ b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_chasiss_packet.conf @@ -0,0 +1,22 @@ +! +! template: bgpd/templates/internal/peer-group.conf.j2 +! + neighbor INTERNAL_PEER_V4 peer-group + neighbor INTERNAL_PEER_V6 peer-group + address-family ipv4 + neighbor INTERNAL_PEER_V4 update-source 10.10.10.10 + neighbor INTERNAL_PEER_V4 soft-reconfiguration inbound + neighbor INTERNAL_PEER_V4 allowas-in 1 + neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in + neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out + exit-address-family + address-family ipv6 + neighbor INTERNAL_PEER_V4 update-source 2603:10e2:400::3 + neighbor INTERNAL_PEER_V6 soft-reconfiguration inbound + neighbor INTERNAL_PEER_V6 allowas-in 1 + neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in + neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out + exit-address-family +! +! end of template: bgpd/templates/internal/peer-group.conf.j2 +! diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf new file mode 100644 index 000000000000..b48617a6d840 --- /dev/null +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.conf @@ -0,0 +1,67 @@ +! +! template: bgpd/bgpd.main.conf.j2 +! +! bgp multiple-instance +! +! BGP configuration +! +! TSA configuration +! +ip prefix-list PL_LoopbackV4 permit 55.55.55.55/32 +! +ipv6 prefix-list PL_LoopbackV6 permit fc00::/64 +! +ip prefix-list LOCAL_VLAN_IPV4_PREFIX seq 5 permit 10.10.10.0/24 +! +ipv6 prefix-list LOCAL_VLAN_IPV6_PREFIX seq 10 permit fc01::/64 +! +route-map HIDE_INTERNAL permit 10 + set community no-export +! +! +router bgp 55555 +! + bgp log-neighbor-changes + no bgp default ipv4-unicast + no bgp ebgp-requires-policy +! + bgp bestpath as-path multipath-relax +! + bgp graceful-restart restart-time 240 + bgp graceful-restart + bgp graceful-restart preserve-fw-state + bgp graceful-restart select-defer-time 45 +! + bgp router-id 55.55.55.56 +! + network 55.55.55.55/32 + network 55.55.55.56/32 route-map HIDE_INTERNAL +! + address-family ipv6 + network fc00::1/64 + exit-address-family + address-family ipv6 + network fc00::2/128 route-map HIDE_INTERNAL + exit-address-family +! + network 10.10.10.1/24 + address-family ipv6 + network fc01::1/64 + exit-address-family +! + address-family ipv4 + redistribute connected route-map HIDE_INTERNAL + exit-address-family + address-family ipv6 + redistribute connected route-map HIDE_INTERNAL + exit-address-family +! + address-family ipv4 + maximum-paths 64 + exit-address-family + address-family ipv6 + maximum-paths 64 + exit-address-family +! +! end of template: bgpd/bgpd.main.conf.j2 +! diff --git a/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json new file mode 100644 index 000000000000..418a62266d8d --- /dev/null +++ b/src/sonic-bgpcfgd/tests/data/sonic-cfggen/bgpd.main.conf.j2/packet_chassis.json @@ -0,0 +1,35 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "bgp_asn": "55555", + "sub_role": "FrontEnd", + "switch_type": "chassis-packet" + } + }, + "LOOPBACK_INTERFACE": { + "Loopback0|55.55.55.55/32": {}, + "Loopback0|fc00::1/128": {}, + "Loopback4096|55.55.55.56/32": {}, + "Loopback4096|fc00::2/128": {} + }, + "VLAN_INTERFACE": { + "Vlan10|10.10.10.1/24": {}, + "Vlan10|fc01::1/64": {}, + "Vlan20": {"vnet_name": "Vnet1"}, + "Vlan20|20.20.20.1/24": {}, + "Vlan20|fd01::1/64": {} + }, + "constants": { + "bgp": { + "multipath_relax": { + "enabled": true + }, + "graceful_restart": { + "enabled": true + }, + "maximum_paths": { + "enabled": true + } + } + } +} diff --git a/src/sonic-bgpcfgd/tests/test_sonic-cfggen.py b/src/sonic-bgpcfgd/tests/test_sonic-cfggen.py index ff9b30ea3906..30498001199d 100644 --- a/src/sonic-bgpcfgd/tests/test_sonic-cfggen.py +++ b/src/sonic-bgpcfgd/tests/test_sonic-cfggen.py @@ -51,6 +51,12 @@ def test_bgpd_main_conf_voq_chassis(): "bgpd.main.conf.j2/voq_chassis.json", "bgpd.main.conf.j2/voq_chassis.conf") +def test_bgpd_main_conf_packet_chassis(): + run_test("Chassi packet bgpd.main.conf.j2", + "bgpd/bgpd.main.conf.j2", + "bgpd.main.conf.j2/packet_chassis.json", + "bgpd.main.conf.j2/packet_chassis.conf") + def test_tsa_isolate(): run_test("tsa/bgpd.tsa.isolate.conf.j2", "bgpd/tsa/bgpd.tsa.isolate.conf.j2", diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index f22c0b4bb2c6..ef5c7cfb3a2e 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -497,6 +497,7 @@ def parse_dpg(dpg, hname): nhg_int = "" nhportlist = [] dpg_ecmp_content = {} + static_routes = {} ipnhs = child.find(str(QName(ns, "IPNextHops"))) if ipnhs is not None: for ipnh in ipnhs.findall(str(QName(ns, "IPNextHop"))): @@ -508,8 +509,12 @@ def parse_dpg(dpg, hname): port_nhipv4_map[ipnhfmbr] = ipnhaddr elif ":" in ipnhaddr: port_nhipv6_map[ipnhfmbr] = ipnhaddr + elif ipnh.find(str(QName(ns, "Type"))).text == 'StaticRoute': + prefix = ipnh.find(str(QName(ns, "AttachTo"))).text + nexthop = ipnh.find(str(QName(ns, "Address"))).text + static_routes[prefix] = {'nexthop': nexthop } - if port_nhipv4_map is not None and port_nhipv6_map is not None: + if port_nhipv4_map and port_nhipv6_map: subnet_check_ip = list(port_nhipv4_map.values())[0] for subnet_range in ip_intfs_map: if ("." in subnet_range): @@ -701,8 +706,10 @@ def parse_dpg(dpg, hname): if mg_key in mg_tunnel.attrib: tunnelintfs[tunnel_type][tunnel_name][table_key] = mg_tunnel.attrib[mg_key] - return intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnelintfs, dpg_ecmp_content - return None, None, None, None, None, None, None, None, None, None, None, None, None + return intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnelintfs, dpg_ecmp_content, static_routes + return None, None, None, None, None, None, None, None, None, None, None, None, None, None, None + + def parse_host_loopback(dpg, hname): for child in dpg: @@ -738,10 +745,13 @@ def parse_cpg(cpg, hname, local_devices=[]): nhopself = 1 if session.find(str(QName(ns, "NextHopSelf"))) is not None else 0 # choose the right table and admin_status for the peer - voq_chassis = session.find(str(QName(ns, "VoQChassisInternal"))) - if voq_chassis is not None and voq_chassis.text == "true": + chassis_internal_ibgp = session.find(str(QName(ns, "ChassisInternal"))) + if chassis_internal_ibgp is not None and chassis_internal_ibgp.text == "voq": table = bgp_voq_chassis_sessions admin_status = 'up' + elif chassis_internal_ibgp is not None and chassis_internal_ibgp.text == "chassis-packet": + table = bgp_internal_sessions + admin_status = 'up' elif end_router.lower() in local_devices and start_router.lower() in local_devices: table = bgp_internal_sessions admin_status = 'up' @@ -1207,6 +1217,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw is_storage_device = False local_devices = [] kube_data = {} + static_routes = {} hwsku_qn = QName(ns, "HwSku") hostname_qn = QName(ns, "Hostname") @@ -1229,7 +1240,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw for child in root: if asic_name is None: if child.tag == str(QName(ns, "DpgDec")): - (intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnel_intfs, dpg_ecmp_content) = parse_dpg(child, hostname) + (intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnel_intfs, dpg_ecmp_content, static_routes) = parse_dpg(child, hostname) elif child.tag == str(QName(ns, "CpgDec")): (bgp_sessions, bgp_internal_sessions, bgp_voq_chassis_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, hostname) elif child.tag == str(QName(ns, "PngDec")): @@ -1244,7 +1255,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw (port_speeds_default, port_descriptions, sys_ports) = parse_deviceinfo(child, hwsku) else: if child.tag == str(QName(ns, "DpgDec")): - (intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnel_intfs, dpg_ecmp_content) = parse_dpg(child, asic_name) + (intfs, lo_intfs, mvrf, mgmt_intf, voq_inband_intfs, vlans, vlan_members, dhcp_relay_table, pcs, pc_members, acls, vni, tunnel_intfs, dpg_ecmp_content, static_routes) = parse_dpg(child, asic_name) host_lo_intfs = parse_host_loopback(child, hostname) elif child.tag == str(QName(ns, "CpgDec")): (bgp_sessions, bgp_internal_sessions, bgp_voq_chassis_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name, local_devices) @@ -1395,12 +1406,12 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw } else: vlan_intfs[vlan_invert_mapping[intf[0]]] = {} - elif intf[0][0:11] == 'PortChannel': - pc_intfs[intf] = {} - pc_intfs[intf[0]] = {} elif VLAN_SUB_INTERFACE_SEPARATOR in intf[0]: vlan_sub_intfs[intf] = {} vlan_sub_intfs[intf[0]] = {'admin_status': 'up'} + elif intf[0][0:11] == 'PortChannel': + pc_intfs[intf] = {} + pc_intfs[intf[0]] = {} else: phyport_intfs[intf] = {} phyport_intfs[intf[0]] = {} @@ -1568,6 +1579,9 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw results['VLAN_SUB_INTERFACE'] = vlan_sub_intfs elif resource_type is not None and 'Storage' in resource_type: is_storage_device = True + elif bool(vlan_sub_intfs): + results['VLAN_SUB_INTERFACE'] = vlan_sub_intfs + if is_storage_device: results['DEVICE_METADATA']['localhost']['storage_device'] = "true" @@ -1579,6 +1593,9 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw results['MUX_CABLE'] = get_mux_cable_entries(mux_cable_ports, neighbors, devices) + if static_routes: + results['STATIC_ROUTE'] = static_routes + for nghbr in list(neighbors.keys()): # remove port not in port_config.ini if nghbr not in ports: diff --git a/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml b/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml new file mode 100644 index 000000000000..96726b2a3fb0 --- /dev/null +++ b/src/sonic-config-engine/tests/sample-chassis-packet-lc-graph.xml @@ -0,0 +1,456 @@ + + + + + + false + str2-8808-lc2-1 + 27.1.1.1 + IXIA-EBGP + 27.1.1.2 + 1 + 10 + 3 + + + false + ASIC1 + 27.1.1.1 + IXIA-EBGP + 27.1.1.2 + 1 + 10 + 3 + + + ASIC1 + 8.0.0.3 + str2-8808-lc0-ASIC1 + 8.0.0.1 + 1 + 0 + 0 + chassis-packet + + + + + 65100 + str2-8808-lc2-1 + + +
27.1.1.2
+ + + +
+
+ +
+ + 69007 + IXIA-EBGP + + + + 65100 + str2-8808-lc0-ASIC1 + + + + 65100 + ASIC1 + + +
27.1.1.2
+ + + +
+ +
8.0.0.1
+ + + +
+
+ +
+
+
+ + + + + + HostIP + Loopback0 + + 10.0.1.6/32 + + 10.0.1.6/32 + + + + + HostIP + eth0 + + 10.3.147.97/23 + + 10.3.147.97/23 + + + + + + + str2-88 + + + + + + Eth1/1/47 + 27.1.1.1/24 + + + + + + + + + + + + + HostIP + Loopback0 + + 10.0.1.6/32 + + 10.0.1.6/32 + + + HostIP1 + Loopback4096 + + 8.0.0.3/32 + + 8.0.0.3/32 + + + + + HostIP + eth0 + + 10.3.147.97/23 + + 10.3.147.97/23 + + + + + + + ASIC1 + + + PortChannel32 + Eth2504-ASIC1;Eth2508-ASIC1;Eth2510-ASIC1 + + + + PortChannel33 + Eth2320-ASIC1;Eth2502-ASIC1;Eth2506-ASIC1;Eth2518-ASIC1 + + + + + + + + + PortChannel32 + 2 + dot1q + 192.168.1.4/24 + + + + PortChannel33 + 2 + dot1q + 192.168.2.4/24 + 10 + + + + + + Eth1/1/47 + 27.1.1.1/24 + + + + + + + IPNextHop + + 8.0.0.1/32 +
192.168.1.2,192.168.2.2
+ StaticRoute +
+
+
+
+ + + + DeviceInterfaceLink + IXIA-EBGP + Ethernet1 + str2-8808-lc2-1 + Eth1/1/47 + + + DeviceInterfaceLink + 100000 + true + str2-8808-sup + Ethernet1 + true + ASIC1 + Eth2502-ASIC1 + true + + + DeviceInterfaceLink + 100000 + true + str2-8808-sup + Ethernet2 + true + ASIC1 + Eth2504-ASIC1 + true + + + DeviceInterfaceLink + 100000 + true + str2-8808-sup + Ethernet3 + true + ASIC1 + Eth2506-ASIC1 + true + + + DeviceInterfaceLink + 100000 + true + str2-8808-sup + Ethernet4 + true + ASIC1 + Eth2508-ASIC1 + true + + + DeviceInterfaceLink + 100000 + true + str2-8808-sup + Ethernet5 + true + ASIC1 + Eth2510-ASIC1 + true + + + DeviceInterfaceLink + 100000 + true + str2-8808-sup + Ethernet6 + true + ASIC1 + Eth2516-ASIC1 + true + + + DeviceInterfaceLink + 100000 + true + str2-8808-sup + Ethernet7 + true + ASIC1 + Eth2320-ASIC1 + true + + + + + str2-8808-lc2-1 + 8800-LC-48H-O +
+ 10.0.1.6/32 +
+ + 10.3.147.97/23 + +
+ + IXIA-EBGP + IXIA +
+ 0.0.0.0/0 +
+ + 0.0.0.0/0 + +
+ + str2-8808-sup + 8800-RP-O +
+ 0.0.0.0/0 +
+ + 10.3.147.95/23 + +
+ + Asic +
+ 8.0.0.3/32 +
+ + + + + + + + + 0.0.0.0/0 + + + ASIC1 + 8800-LC-48H-O +
+
+
+ + + true + + + DeviceInterface + + true + true + 1 + Ethernet1/1/47 + + false + 47 + 0 + 100000 + Ethernet47 + + + true + 0 + 8800-LC-48H-O + + + + + + + str2-8808-lc2-1 + + + SwitchType + + chassis_packet + + + DeploymentId + + 1 + + + QosProfile + + Profile0 + + + DhcpResources + + 192.0.0.1;192.0.0.2;192.0.0.3;192.0.0.4;192.0.0.5;192.0.0.6;192.0.0.7;192.0.0.8;192.0.0.9;192.0.0.10;192.0.0.11;192.0.0.12;192.0.0.13;192.0.0.14;192.0.0.15;192.0.0.16;192.0.0.17;192.0.0.18;192.0.0.19;192.0.0.20;192.0.0.21;192.0.0.22;192.0.0.23;192.0.0.24;192.0.0.25;192.0.0.26;192.0.0.27;192.0.0.28;192.0.0.29;192.0.0.30;192.0.0.31;192.0.0.32;192.0.0.33;192.0.0.34;192.0.0.35;192.0.0.36;192.0.0.37;192.0.0.38;192.0.0.39;192.0.0.40;192.0.0.41;192.0.0.42;192.0.0.43;192.0.0.44;192.0.0.45;192.0.0.46;192.0.0.47;192.0.0.48 + + + NtpResources + + 10.20.8.129;10.20.8.130 + + + SnmpResources + + 10.3.145.98 + + + SyslogResources + + 10.3.145.8;100.127.20.21 + + + TacacsGroup + + Starlab + + + TacacsServer + + 100.127.20.21 + + + ForcedMgmtRoutes + + 10.3.145.98/31;10.3.145.8;100.127.20.16/28;10.3.149.170/31;40.122.216.24;13.91.48.226;10.3.145.14;10.64.246.0/24;10.3.146.0/23;10.64.5.5 + + + ErspanDestinationIpv4 + + 10.20.6.16 + + + + + ASIC1 + + + SubRole + + FrontEnd + + + SwitchType + + chassis_packet + + + + + + + str2-8808-lc2-1 + 8800-LC-48H-O +
diff --git a/src/sonic-config-engine/tests/sample-chassis-packet-lc-port-config.ini b/src/sonic-config-engine/tests/sample-chassis-packet-lc-port-config.ini new file mode 100644 index 000000000000..ed0f52a1adf5 --- /dev/null +++ b/src/sonic-config-engine/tests/sample-chassis-packet-lc-port-config.ini @@ -0,0 +1,60 @@ +# name lanes alias index speed asic_port_name role source_npu target_npu +Ethernet13 1280,1281,1282,1283 Eth1/1/13 13 100000 Eth13-ASIC1 Ext +Ethernet14 1284,1285,1286,1287 Eth1/1/14 14 100000 Eth14-ASIC1 Ext +Ethernet16 1288,1289,1290,1291 Eth1/1/16 16 100000 Eth16-ASIC1 Ext +Ethernet17 1292,1293,1294,1295 Eth1/1/17 17 100000 Eth17-ASIC1 Ext +Ethernet19 1024,1025,1026,1027 Eth1/1/19 19 100000 Eth19-ASIC1 Ext +Ethernet20 1036,1037,1038,1039 Eth1/1/20 20 100000 Eth20-ASIC1 Ext +Ethernet22 1028,1029,1030,1031 Eth1/1/22 22 100000 Eth22-ASIC1 Ext +Ethernet23 1032,1033,1034,1035 Eth1/1/23 23 100000 Eth23-ASIC1 Ext +Ethernet25 768,769,770,771 Eth1/1/25 25 100000 Eth25-ASIC1 Ext +Ethernet26 772,773,774,775 Eth1/1/26 26 100000 Eth26-ASIC1 Ext +Ethernet28 776,777,778,779 Eth1/1/28 28 100000 Eth28-ASIC1 Ext +Ethernet29 780,781,782,783 Eth1/1/29 29 100000 Eth29-ASIC1 Ext +Ethernet31 512,513,514,515 Eth1/1/31 31 100000 Eth31-ASIC1 Ext +Ethernet32 516,517,518,519 Eth1/1/32 32 100000 Eth32-ASIC1 Ext +Ethernet34 520,521,522,523 Eth1/1/34 34 100000 Eth34-ASIC1 Ext +Ethernet35 524,525,526,527 Eth1/1/35 35 100000 Eth35-ASIC1 Ext +Ethernet37 256,257,258,259 Eth1/1/37 37 100000 Eth37-ASIC1 Ext +Ethernet38 260,261,262,263 Eth1/1/38 38 100000 Eth38-ASIC1 Ext +Ethernet40 268,269,270,271 Eth1/1/40 40 100000 Eth40-ASIC1 Ext +Ethernet41 264,265,266,267 Eth1/1/41 41 100000 Eth41-ASIC1 Ext +Ethernet43 12,13,14,15 Eth1/1/43 43 100000 Eth43-ASIC1 Ext +Ethernet44 8,9,10,11 Eth1/1/44 44 100000 Eth44-ASIC1 Ext +Ethernet46 4,5,6,7 Eth1/1/46 46 100000 Eth46-ASIC1 Ext +Ethernet47 0,1,2,3 Eth1/1/47 47 100000 Eth47-ASIC1 Ext +Ethernet2320 16,17 Eth2320-ASIC1 2320 100000 Eth2320-ASIC1 Int +Ethernet2452 2052,2053 Eth2452-ASIC1 2452 100000 Eth2452-ASIC1 Int +Ethernet2454 2054,2055 Eth2454-ASIC1 2454 100000 Eth2454-ASIC1 Int +Ethernet2456 2056,2057 Eth2456-ASIC1 2456 100000 Eth2456-ASIC1 Int +Ethernet2458 2058,2059 Eth2458-ASIC1 2458 100000 Eth2458-ASIC1 Int +Ethernet2460 2060,2061 Eth2460-ASIC1 2460 100000 Eth2460-ASIC1 Int +Ethernet2462 2062,2063 Eth2462-ASIC1 2462 100000 Eth2462-ASIC1 Int +Ethernet2464 2064,2065 Eth2464-ASIC1 2464 100000 Eth2464-ASIC1 Int +Ethernet2466 2304,2305 Eth2466-ASIC1 2466 100000 Eth2466-ASIC1 Int +Ethernet2468 2306,2307 Eth2468-ASIC1 2468 100000 Eth2468-ASIC1 Int +Ethernet2470 2308,2309 Eth2470-ASIC1 2470 100000 Eth2470-ASIC1 Int +Ethernet2472 2310,2311 Eth2472-ASIC1 2472 100000 Eth2472-ASIC1 Int +Ethernet2474 2312,2313 Eth2474-ASIC1 2474 100000 Eth2474-ASIC1 Int +Ethernet2476 2314,2315 Eth2476-ASIC1 2476 100000 Eth2476-ASIC1 Int +Ethernet2478 2316,2317 Eth2478-ASIC1 2478 100000 Eth2478-ASIC1 Int +Ethernet2480 2318,2319 Eth2480-ASIC1 2480 100000 Eth2480-ASIC1 Int +Ethernet2482 2320,2321 Eth2482-ASIC1 2482 100000 Eth2482-ASIC1 Int +Ethernet2484 2560,2561 Eth2484-ASIC1 2484 100000 Eth2484-ASIC1 Int +Ethernet2486 2562,2563 Eth2486-ASIC1 2486 100000 Eth2486-ASIC1 Int +Ethernet2488 2564,2565 Eth2488-ASIC1 2488 100000 Eth2488-ASIC1 Int +Ethernet2490 2566,2567 Eth2490-ASIC1 2490 100000 Eth2490-ASIC1 Int +Ethernet2492 2568,2569 Eth2492-ASIC1 2492 100000 Eth2492-ASIC1 Int +Ethernet2494 2570,2571 Eth2494-ASIC1 2494 100000 Eth2494-ASIC1 Int +Ethernet2496 2572,2573 Eth2496-ASIC1 2496 100000 Eth2496-ASIC1 Int +Ethernet2498 2574,2575 Eth2498-ASIC1 2498 100000 Eth2498-ASIC1 Int +Ethernet2500 2576,2577 Eth2500-ASIC1 2500 100000 Eth2500-ASIC1 Int +Ethernet2502 2816,2817 Eth2502-ASIC1 2502 100000 Eth2502-ASIC1 Int +Ethernet2504 2818,2819 Eth2504-ASIC1 2504 100000 Eth2504-ASIC1 Int +Ethernet2506 2820,2821 Eth2506-ASIC1 2506 100000 Eth2506-ASIC1 Int +Ethernet2508 2822,2823 Eth2508-ASIC1 2508 100000 Eth2508-ASIC1 Int +Ethernet2510 2824,2825 Eth2510-ASIC1 2510 100000 Eth2510-ASIC1 Int +Ethernet2512 2826,2827 Eth2512-ASIC1 2512 100000 Eth2512-ASIC1 Int +Ethernet2514 2828,2829 Eth2514-ASIC1 2514 100000 Eth2514-ASIC1 Int +Ethernet2516 2830,2831 Eth2516-ASIC1 2516 100000 Eth2516-ASIC1 Int +Ethernet2518 2832,2833 Eth2518-ASIC1 2518 100000 Eth2518-ASIC1 Int diff --git a/src/sonic-config-engine/tests/sample-graph-resource-type.xml b/src/sonic-config-engine/tests/sample-graph-resource-type.xml index 12961059251d..ab486b51cb69 100644 --- a/src/sonic-config-engine/tests/sample-graph-resource-type.xml +++ b/src/sonic-config-engine/tests/sample-graph-resource-type.xml @@ -20,7 +20,6 @@ 1 180 60 - false switch-t0 @@ -68,7 +67,7 @@ 1 180 60 - true + voq diff --git a/src/sonic-config-engine/tests/sample-graph-subintf.xml b/src/sonic-config-engine/tests/sample-graph-subintf.xml index f487b989a138..06a6cf2fd665 100644 --- a/src/sonic-config-engine/tests/sample-graph-subintf.xml +++ b/src/sonic-config-engine/tests/sample-graph-subintf.xml @@ -20,7 +20,6 @@ 1 180 60 - false switch-t0 @@ -68,7 +67,7 @@ 1 180 60 - true + voq diff --git a/src/sonic-config-engine/tests/simple-sample-graph.xml b/src/sonic-config-engine/tests/simple-sample-graph.xml index 90abd1885bcb..e1c4b87fc3ab 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph.xml @@ -20,7 +20,6 @@ 1 180 60 - false switch-t0 @@ -68,7 +67,7 @@ 1 180 60 - true + voq diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index 5be4bb7b75c8..4f86a71fc1d1 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -32,6 +32,8 @@ def setUp(self): self.sample_resource_graph = os.path.join(self.test_dir, 'sample-graph-resource-type.xml') self.sample_subintf_graph = os.path.join(self.test_dir, 'sample-graph-subintf.xml') self.voq_port_config = os.path.join(self.test_dir, 'voq-sample-port-config.ini') + self.packet_chassis_graph = os.path.join(self.test_dir, 'sample-chassis-packet-lc-graph.xml') + self.packet_chassis_port_ini = os.path.join(self.test_dir, 'sample-chassis-packet-lc-port-config.ini') # To ensure that mock config_db data is used for unit-test cases os.environ["CFGGEN_UNIT_TESTING"] = "2" @@ -831,5 +833,28 @@ def test_minigraph_dhcp(self): "'Vlan2000': {'dhcpv6_servers': ['fc02:2000::3', 'fc02:2000::4']}}" ) ) - - \ No newline at end of file + + def test_minigraph_bgp_packet_chassis_peer(self): + argument = '-m "' + self.packet_chassis_graph + '" -p "' + self.packet_chassis_port_ini + '" -n "' + "asic1" + '" -v "BGP_INTERNAL_NEIGHBOR[\'8.0.0.1\']"' + output = self.run_script(argument) + self.assertEqual( + utils.to_dict(output.strip()), + utils.to_dict("{'rrclient': 0, 'name': 'str2-8808-lc0-ASIC1', 'local_addr': '8.0.0.3', 'nhopself': 0, 'admin_status': 'up', 'holdtime': '0', 'asn': '65100', 'keepalive': '0'}") + ) + + def test_minigraph_bgp_packet_chassis_static_route(self): + argument = '-m "' + self.packet_chassis_graph + '" -p "' + self.packet_chassis_port_ini + '" -n "' + "asic1" + '" -v "STATIC_ROUTE"' + output = self.run_script(argument) + self.assertEqual( + utils.to_dict(output.strip()), + utils.to_dict("{'8.0.0.1/32': {'nexthop': '192.168.1.2,192.168.2.2'}}") + ) + + def test_minigraph_bgp_packet_chassis_vlan_subintf(self): + argument = '-m "' + self.packet_chassis_graph + '" -p "' + self.packet_chassis_port_ini + '" -n "' + "asic1" + '" -v "VLAN_SUB_INTERFACE"' + output = self.run_script(argument) + self.assertEqual( + utils.to_dict(output.strip()), + utils.to_dict("{('PortChannel32.2', '192.168.1.4/24'): {}, 'PortChannel32.2': {'admin_status': 'up'}, ('PortChannel33.2', '192.168.2.4/24'): {}, 'PortChannel33.2': {'admin_status': 'up'}}") + ) + diff --git a/src/sonic-host-services-data/debian/sonic-host-services-data.determine-reboot-cause.service b/src/sonic-host-services-data/debian/sonic-host-services-data.determine-reboot-cause.service index a6c58d4c9818..f0d9e91fe991 100644 --- a/src/sonic-host-services-data/debian/sonic-host-services-data.determine-reboot-cause.service +++ b/src/sonic-host-services-data/debian/sonic-host-services-data.determine-reboot-cause.service @@ -1,7 +1,7 @@ [Unit] Description=Reboot cause determination service -Requires=rc-local.service -After=rc-local.service +Requires=rc-local.service database.service +After=rc-local.service database.service [Service] Type=simple diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 78f36138e14e..ecb95a813e08 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 78f36138e14e1ed0f0f772950f03420327ef1b1c +Subproject commit ecb95a813e08fab1c45fc8125eca672b7ad8ad89 diff --git a/src/sonic-swss b/src/sonic-swss index c7eeecf3751a..f248e2666aec 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit c7eeecf3751a0d3bbd3e0d700e2ee233ee4c73bb +Subproject commit f248e2666aec833f762a0109a01fe171afecd161 diff --git a/src/sonic-swss-common b/src/sonic-swss-common index b5027436c267..31f4253832d4 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit b5027436c267638709d4f9a1be4b5a2d07c94893 +Subproject commit 31f4253832d433cf9a49f15e3d1240f64742f179 diff --git a/src/sonic-utilities.patch/0002-Stopping-all-BGP-SLB-neighbors-if-they-re-presented-.patch b/src/sonic-utilities.patch/0002-Stopping-all-BGP-SLB-neighbors-if-they-re-presented-.patch index cf2796dd381e..6e3404c46ddf 100644 --- a/src/sonic-utilities.patch/0002-Stopping-all-BGP-SLB-neighbors-if-they-re-presented-.patch +++ b/src/sonic-utilities.patch/0002-Stopping-all-BGP-SLB-neighbors-if-they-re-presented-.patch @@ -13,10 +13,10 @@ Index: sonic-utilities/scripts/fast-reboot --- sonic-utilities.orig/scripts/fast-reboot +++ sonic-utilities/scripts/fast-reboot @@ -36,6 +36,7 @@ EXIT_ORCHAGENT_SHUTDOWN=10 - EXIT_SYNCD_SHUTDOWN=11 - EXIT_FAST_REBOOT_DUMP_FAILURE=12 EXIT_FILTER_FDB_ENTRIES_FAILURE=13 -+EXIT_HANDLE_SLB_NEIGHBORS=15 + EXIT_COUNTERPOLL_DELAY_FAILURE=14 + EXIT_DB_INTEGRITY_FAILURE=15 ++EXIT_HANDLE_SLB_NEIGHBORS=16 EXIT_NO_CONTROL_PLANE_ASSISTANT=20 EXIT_SONIC_INSTALLER_VERIFY_REBOOT=21 diff --git a/src/sonic-yang-mgmt/sonic_yang_ext.py b/src/sonic-yang-mgmt/sonic_yang_ext.py index 5438c81fb745..845588d70dbd 100644 --- a/src/sonic-yang-mgmt/sonic_yang_ext.py +++ b/src/sonic-yang-mgmt/sonic_yang_ext.py @@ -4,11 +4,17 @@ from __future__ import print_function import yang as ly import syslog - from json import dump, dumps, loads from xmltodict import parse from glob import glob +qos_maps_model = ['DSCP_TO_TC_MAP_LIST', + 'DOT1P_TO_TC_MAP_LIST', + 'TC_TO_PRIORITY_GROUP_MAP_LIST', + 'TC_TO_QUEUE_MAP_LIST', + 'MAP_PFC_PRIORITY_TO_QUEUE_LIST', + 'PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST'] + """ This is the Exception thrown out of all public function of this class. """ @@ -406,6 +412,108 @@ def _yangConvert(val): return vValue + """ + Xlate a Qos Maps list + This function will xlate from a dict in config DB to a Yang JSON list + using yang model. Output will be go in self.xlateJson + + Note: Exceptions from this function are collected in exceptionList and + are displayed only when an entry is not xlated properly from ConfigDB + to sonic_yang.json. + + QOS MAPS Yang has inner list, which is diffrent from config DB. + Each field value in config db should be converted to inner list with + key and value. + Example: + + Config DB: + "DSCP_TO_TC_MAP": { + "Dscp_to_tc_map1": { + "1": "1", + "2": "2" + } + } + + YANG Model: + module: sonic-dscp-tc-map + +--rw sonic-dscp-tc-map + +--rw DSCP_TO_TC_MAP + +--rw DSCP_TO_TC_MAP_LIST* [name] + +--rw name string + +--rw DSCP_TO_TC_MAP* [dscp] + +--rw dscp string + +--rw tc? string + + YANG JSON: + "sonic-dscp-tc-map:sonic-dscp-tc-map": { + "sonic-dscp-tc-map:DSCP_TO_TC_MAP": { + "DSCP_TO_TC_MAP_LIST": [ + { + "name": "map3", + "DSCP_TO_TC_MAP": [ + { + "dscp": "64", + "tc": "1" + }, + { + "dscp":"2", + "tc":"2" + } + ] + } + ] + } + } + """ + def _xlateQosMapList(self, model, yang, config, table, exceptionList): + + #create a dict to map each key under primary key with a dict yang model. + #This is done to improve performance of mapping from values of TABLEs in + #config DB to leaf in YANG LIST. + inner_clist = model.get('list') + if inner_clist: + inner_listKey = inner_clist['key']['@value'] + inner_leafDict = self._createLeafDict(inner_clist, table) + for lkey in inner_leafDict: + if inner_listKey != lkey: + inner_listVal = lkey + + # get keys from YANG model list itself + listKeys = model['key']['@value'] + self.sysLog(msg="xlateList keyList:{}".format(listKeys)) + primaryKeys = list(config.keys()) + for pkey in primaryKeys: + try: + vKey = None + self.sysLog(syslog.LOG_DEBUG, "xlateList Extract pkey:{}".\ + format(pkey)) + # Find and extracts key from each dict in config + keyDict = self._extractKey(pkey, listKeys) + + if inner_clist: + inner_yang_list = list() + for vKey in config[pkey]: + inner_keyDict = dict() + self.sysLog(syslog.LOG_DEBUG, "xlateList Key {} vkey {} Val {} vval {}".\ + format(inner_listKey, str(vKey), inner_listVal, str(config[pkey][vKey]))) + inner_keyDict[inner_listKey] = str(vKey) + inner_keyDict[inner_listVal] = str(config[pkey][vKey]) + inner_yang_list.append(inner_keyDict) + + keyDict[inner_clist['@name']] = inner_yang_list + yang.append(keyDict) + # delete pkey from config, done to match one key with one list + del config[pkey] + + except Exception as e: + # log debug, because this exception may occur with multilists + self.sysLog(msg="xlateList Exception:{}".format(str(e)), \ + debug=syslog.LOG_DEBUG, doPrint=True) + exceptionList.append(str(e)) + # with multilist, we continue matching other keys. + continue + return + """ Xlate a list This function will xlate from a dict in config DB to a Yang JSON list @@ -416,16 +524,22 @@ def _yangConvert(val): to sonic_yang.json. """ def _xlateList(self, model, yang, config, table, exceptionList): + + #Qos Map lists needs special handling because of inner yang list and + #config db format. + if model['@name'] in qos_maps_model: + self.sysLog(msg="_xlateQosMapList: {}".format(model['@name'])) + self._xlateQosMapList(model, yang,config, table, exceptionList) + return #create a dict to map each key under primary key with a dict yang model. #This is done to improve performance of mapping from values of TABLEs in #config DB to leaf in YANG LIST. - leafDict = self._createLeafDict(model, table) + leafDict = self._createLeafDict(model, table) # get keys from YANG model list itself listKeys = model['key']['@value'] self.sysLog(msg="xlateList keyList:{}".format(listKeys)) - primaryKeys = list(config.keys()) for pkey in primaryKeys: try: @@ -459,7 +573,6 @@ def _xlateList(self, model, yang, config, table, exceptionList): """ def _xlateListInContainer(self, model, yang, configC, table, exceptionList): clist = model - #print(clist['@name']) yang[clist['@name']] = list() self.sysLog(msg="xlateProcessListOfContainer: {}".format(clist['@name'])) self._xlateList(clist, yang[clist['@name']], configC, table, exceptionList) @@ -629,10 +742,93 @@ def _revYangConvert(val): return vValue + """ + Rev xlate from _LIST to table in config DB + QOS MAP Yang has inner list, each inner list key:val should + be mapped to field:value in Config DB. + Example: + + YANG: + module: sonic-dscp-tc-map + +--rw sonic-dscp-tc-map + +--rw DSCP_TO_TC_MAP + +--rw DSCP_TO_TC_MAP_LIST* [name] + +--rw name string + +--rw DSCP_TO_TC_MAP* [dscp] + +--rw dscp string + +--rw tc? string + + YANG JSON: + "sonic-dscp-tc-map:sonic-dscp-tc-map": { + "sonic-dscp-tc-map:DSCP_TO_TC_MAP": { + "DSCP_TO_TC_MAP_LIST": [ + { + "name": "map3", + "DSCP_TO_TC_MAP": [ + { + "dscp": "64", + "tc": "1" + }, + { + "dscp":"2", + "tc":"2" + } + ] + } + ] + } + } + + Config DB: + "DSCP_TO_TC_MAP": { + "Dscp_to_tc_map1": { + "1": "1", + "2": "2" + } + } + """ + + def _revQosMapXlateList(self, model, yang, config, table): + # get keys from YANG model list itself + listKeys = model['key']['@value'] + # create a dict to map each key under primary key with a dict yang model. + # This is done to improve performance of mapping from values of TABLEs in + # config DB to leaf in YANG LIST. + + # Gather inner list key and value from model + inner_clist = model.get('list') + if inner_clist: + inner_listKey = inner_clist['key']['@value'] + inner_leafDict = self._createLeafDict(inner_clist, table) + for lkey in inner_leafDict: + if inner_listKey != lkey: + inner_listVal = lkey + + # list with name _LIST should be removed, + if "_LIST" in model['@name']: + for entry in yang: + # create key of config DB table + pkey, pkeydict = self._createKey(entry, listKeys) + self.sysLog(syslog.LOG_DEBUG, "revXlateList pkey:{}".format(pkey)) + config[pkey]= dict() + # fill rest of the entries + inner_list = entry[inner_clist['@name']] + for index in range(len(inner_list)): + self.sysLog(syslog.LOG_DEBUG, "revXlateList fkey:{} fval {}".\ + format(str(inner_list[index][inner_listKey]),\ + str(inner_list[index][inner_listVal]))) + config[pkey][str(inner_list[index][inner_listKey])] = str(inner_list[index][inner_listVal]) + return + """ Rev xlate from
_LIST to table in config DB """ def _revXlateList(self, model, yang, config, table): + + # special processing for QOS Map table. + if model['@name'] in qos_maps_model: + self._revQosMapXlateList(model, yang, config, table) + return # get keys from YANG model list itself listKeys = model['key']['@value'] diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 51c190e495d4..a5a74f1b4cba 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -76,6 +76,16 @@ './yang-models/sonic-vrf.yang', './yang-models/sonic-warm-restart.yang', './yang-models/sonic-lldp.yang', + './yang-models/sonic-scheduler.yang', + './yang-models/sonic-wred-profile.yang', + './yang-models/sonic-queue.yang', + './yang-models/sonic-dscp-tc-map.yang', + './yang-models/sonic-dot1p-tc-map.yang', + './yang-models/sonic-tc-priority-group-map.yang', + './yang-models/sonic-tc-queue-map.yang', + './yang-models/sonic-pfc-priority-queue-map.yang', + './yang-models/sonic-pfc-priority-priority-group-map.yang', + './yang-models/sonic-port-qos-map.yang', './yang-models/sonic_yang_tree']), ], zip_safe=False, diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index bd7aff24b554..35cb22074106 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1138,6 +1138,143 @@ "high_mem_alert": "disabled", "state": "enabled" } + }, + + "SCHEDULER": { + "TEST@0": { + "cbs": "256", + "cir": "1250000", + "meter_type": "bytes", + "pbs": "1024", + "pir": "25000000", + "type": "DWRR", + "weight": "20" + }, + + "TEST@1": { + "cbs": "1024", + "cir": "1280000", + "meter_type": "bytes", + "pbs": "2048", + "pir": "2560000", + "type": "STRICT" + } + }, + + "WRED_PROFILE": { + "Wred1": { + "ecn": "ecn_all", + "green_drop_probability": "50", + "green_max_threshold": "2048000", + "green_min_threshold": "1024000", + "wred_green_enable": "true", + "yellow_drop_probability": "50", + "yellow_max_threshold": "2048000", + "yellow_min_threshold": "1024000", + "wred_yellow_enable": "true", + "red_drop_probability": "50", + "red_max_threshold": "2048000", + "red_min_threshold": "1024000", + "wred_red_enable": "true" + } + }, + + "QUEUE": { + "Ethernet0|0": { + "scheduler": "TEST@0", + "wred_profile": "Wred1" + }, + "Ethernet0|1": { + "scheduler": "TEST@1", + "wred_profile": "Wred1" + } + }, + + "DSCP_TO_TC_MAP": { + "Dscp_to_tc_map1": { + "1": "1", + "2": "2" + }, + "Dscp_to_tc_map2": { + "3": "3", + "4": "4" + } + }, + + "DOT1P_TO_TC_MAP": { + "Dot1p_to_tc_map1": { + "1": "1", + "2": "2" + }, + "Dot1p_to_tc_map2": { + "3": "3", + "4": "4" + } + }, + + "TC_TO_PRIORITY_GROUP_MAP": { + "tc_to_pg_map1": { + "1": "1", + "2": "2" + }, + "tc_to_pg_map2": { + "3": "3", + "4": "4" + } + }, + + "TC_TO_QUEUE_MAP": { + "tc_to_q_map1": { + "1": "1", + "2": "2" + }, + "tc_to_q_map2": { + "3": "3", + "4": "4" + } + }, + + "MAP_PFC_PRIORITY_TO_QUEUE": { + "pfc_prio_to_q_map1": { + "1": "1", + "2": "2" + }, + "pfc_prio_to_q_map2": { + "3": "3", + "4": "4" + } + }, + + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": { + "pfc_prio_to_pg_map1": { + "1": "1", + "2": "2" + }, + "pfc_prio_to_pg_map2": { + "3": "3", + "4": "4" + } + }, + + "PORT_QOS_MAP": { + "Ethernet0": { + "dot1p_to_tc_map" : "Dot1p_to_tc_map1", + "dscp_to_tc_map": "Dscp_to_tc_map1", + "tc_to_queue_map": "tc_to_q_map1", + "tc_to_pg_map": "tc_to_pg_map1", + "pfc_to_queue_map": "pfc_prio_to_q_map1", + "pfc_to_pg_map" : "pfc_prio_to_pg_map1", + "pfc_enable" : "3,4" + }, + "Ethernet4": { + "dot1p_to_tc_map" : "Dot1p_to_tc_map2", + "dscp_to_tc_map": "Dscp_to_tc_map2", + "tc_to_queue_map": "tc_to_q_map2", + "tc_to_pg_map": "tc_to_pg_map2", + "pfc_to_queue_map": "pfc_prio_to_q_map2", + "pfc_to_pg_map" : "pfc_prio_to_pg_map2", + "pfc_enable" : "3,4" + } } }, @@ -1146,5 +1283,4 @@ "Error": "This Table is for testing, This Table does not have YANG models." } } - } diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/qos.json b/src/sonic-yang-models/tests/yang_model_tests/tests/qos.json new file mode 100644 index 000000000000..96b7b4b8d94c --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/qos.json @@ -0,0 +1,85 @@ +{ + "SCHEDULER_VALID": { + "desc": "Configure SCHEDULER table." + }, + + "SCHEDULER_UNDEFINED_TYPE": { + "desc": "Configure undefined type in SCHEDULER table.", + "eStrKey" : "InvalidValue", + "eStr": ["type"] + }, + + "SCHEDULER_INVALID_WEIGHT": { + "desc": "Configure outof range weight in SCHEDULER table.", + "eStrKey" : "Pattern" + }, + + "SCHEDULER_INVALID_METER_TYPE": { + "desc": "Configure unsuported meter type in SCHEDULER table.", + "eStrKey": "InvalidValue", + "eStr": ["meter_type"] + }, + + "SCHEDULER_CBS_NO_CIR": { + "desc": "Configure CBS without CIR.", + "eStr": ["cbs can't be configured without cir"] + }, + + "SCHEDULER_PIR_NO_CIR": { + "desc": "Configure PIR without CIR.", + "eStr": ["pir can't be configured without cir"] + }, + + "SCHEDULER_PIR_VS_CIR": { + "desc": "Configure PIR vs CIR.", + "eStr": ["pir must be greater than or equal to cir"] + }, + + "WRED_PROFILE_EMPTY": { + "desc": "Configure Empty WRED profile." + }, + + "WRED_PROFILE_VALID": { + "desc": "Configure WRED profile." + }, + + "WRED_PROFILE_INVALID_DROP_PROBABILITY": { + "desc": "Configure invalid drop probability in WRED profile.", + "eStrKey" : "Pattern" + }, + + "WRED_PROFILE_INVALID_GREEN_THRESHOLD": { + "desc": "Configure green maximum threshold less than min threshold in WRED profile.", + "eStr": ["Green max threshold must be greater than or equal to min threshold"] + }, + + "WRED_PROFILE_INVALID_YELLOW_THRESHOLD": { + "desc": "Configure yellow maximum threshold less than min threshold in WRED profile.", + "eStr": ["Yellow max threshold must be greater than or equal to min threshold"] + }, + + "WRED_PROFILE_INVALID_RED_THRESHOLD": { + "desc": "Configure red maximum threshold less than min threshold in WRED profile.", + "eStr": ["Red max threshold must be greater than or equal to min threshold"] + }, + + + "QUEUE_VALID": { + "desc": "Attach scheduler and wred profiles to QUEUE." + }, + + "QUEUE_PORT_NOT_EXIST": { + "desc": "Referring non-existing PORT table.", + "eStrKey": "InvalidValue" + }, + + "QUEUE_SCHEDULER_NOT_EXIST": { + "desc": "Referring non-existing SCHEDULER table.", + "eStrKey" : "LeafRef" + }, + + "QUEUE_WRED_NOT_EXIST": { + "desc": "Referring non-existing WRED table.", + "eStrKey" : "LeafRef" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json b/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json new file mode 100644 index 000000000000..90344d8f119d --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/qosmaps.json @@ -0,0 +1,104 @@ +{ + "DSCP_TO_TC_MAP_CRETAE": { + "desc": "Configure a DSCP to Traffic class map." + }, + + "DSCP_TO_TC_MAP_CREATE_INVALID_DSCP": { + "desc": "Configure a DSCP to Traffic class map with invalid key.", + "eStr": "Invalid DSCP" + }, + + "DSCP_TO_TC_MAP_CREATE_INVALID_TC": { + "desc": "Configure a DSCP to Traffic class map with invalid value.", + "eStr": "Invalid Traffic Class" + }, + + "DOT1P_TO_TC_MAP_CRETAE": { + "desc": "Configure a DOT1P to Traffic class map." + }, + + "DOT1P_TO_TC_MAP_CREATE_INVALID_DOT1P": { + "desc": "Configure a DOT1P to Traffic class map with invalid key.", + "eStr": "Invalid DOT1P" + }, + + "DOT1P_TO_TC_MAP_CREATE_INVALID_TC": { + "desc": "Configure a DOT1P to Traffic class map with invalid value.", + "eStr": "Invalid Traffic Class" + }, + + "TC_TO_QUEUE_MAP_CRETAE": { + "desc": "Configure a Traffic Class to Queue map." + }, + + "TC_TO_QUEUE_MAP_CREATE_INVALID_TC": { + "desc": "Configure a Traffic class to Queue map with invalid key.", + "eStr": "Invalid Traffic Class" + }, + + "TC_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": { + "desc": "Configure a Traffic class to Queue map with invalid value.", + "eStr": "Invalid queue index" + }, + + "TC_TO_PRIORITY_GROUP_MAP_CRETAE": { + "desc": "Configure a Traffic Class to Priority Group map." + }, + + "TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_TC": { + "desc": "Configure a Traffic class to Priority Group map with invalid key.", + "eStr": "Invalid Traffic Class" + }, + + "TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": { + "desc": "Configure a Traffic class to Priority Group map with invalid value.", + "eStr": "Invalid Priority Group" + }, + + "PFC_PRIORITY_TO_QUEUE_MAP_CRETAE": { + "desc": "Configure a PFC priority to Queue map." + }, + + "PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_PFC_PRIORITY": { + "desc": "Configure a PFC priority to Queue map with invalid key.", + "eStr": "Invalid pfc priority" + }, + + "PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": { + "desc": "Configure a PFC priority to Queue map with invalid value.", + "eStr": "Invalid queue index" + }, + + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CRETAE": { + "desc": "Configure a PFC priority to Priority Group map." + }, + + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PFC_PRIORITY": { + "desc": "Configure a PFC priority to Priority Group map with invalid key.", + "eStr": "Invalid pfc priority" + }, + + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": { + "desc": "Configure a PFC priority to Priority Group map with invalid value.", + "eStr": "Invalid Priority Group" + }, + + "PORT_QOS_MAP_APPLY_MAPS": { + "desc": "Configure qos maps on port." + }, + + "PORT_QOS_MAP_APPLY_NON_EXISTS_MAPS": { + "desc": "Configure non exists qos maps on port.", + "eStrKey": "LeafRef" + }, + + "PORT_QOS_MAP_APPLY_NON_EXISTS_PORT": { + "desc": "Configure port qos map entry on non exists port.", + "eStrKey": "LeafRef" + }, + + "PORT_QOS_MAP_APPLY_INVALID_PFC": { + "desc": "Configure port pfc enable with invalid pfc priority.", + "eStrKey": "Pattern" + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/qos.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qos.json new file mode 100644 index 000000000000..481990b4d657 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qos.json @@ -0,0 +1,477 @@ +{ + "SCHEDULER_VALID": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "DWRR", + "weight": 10 + }, + { + "name":"Test@1", + "cbs": 1024, + "cir": 1280000, + "meter_type": "bytes", + "pbs": 2048, + "pir": 2560000, + "type": "STRICT", + "priority": 0 + }, + { + "name":"Test@2", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "WRR", + "weight": 20 + } + ] + } + } + }, + + "SCHEDULER_UNDEFINED_TYPE": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "type": "invalid" + } + ] + } + } + }, + + "SCHEDULER_INVALID_WEIGHT": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "weight": 120 + } + ] + } + } + }, + + "SCHEDULER_INVALID_METER_TYPE": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "meter_type": "invalid" + } + ] + } + } + }, + + "SCHEDULER_CBS_NO_CIR": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 1024 + } + ] + } + } + }, + + "SCHEDULER_PIR_NO_CIR": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "pir": 1024 + } + ] + } + } + }, + + "SCHEDULER_PIR_VS_CIR": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cir": 2048, + "pir": 1024 + } + ] + } + } + }, + + + "WRED_PROFILE_EMPTY": { + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred1" + } + ] + } + } + }, + + "WRED_PROFILE_VALID": { + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred2", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_none", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + }, + { + "name":"Wred3", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_all", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + }, + { + "name":"Wred4", + "green_min_threshold": 4096, + "green_max_threshold": 8192, + "ecn": "ecn_all", + "wred_green_enable": true + } + ] + } + } + }, + + "WRED_PROFILE_INVALID_DROP_PROBABILITY": { + "sonic-wred-profile:sonic-wred-profile": { + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred4", + "red_min_threshold": 1024, + "red_max_threshold": 2048, + "wred_red_enable": true, + "red_drop_probability": 125, + "green_drop_probability": 25, + "yellow_drop_probability": 25, + "ecn": "ecn_all" + } + ] + } + } + }, + + "WRED_PROFILE_INVALID_GREEN_THRESHOLD": { + "sonic-wred-profile:sonic-wred-profile": { + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred4", + "green_min_threshold": 4096, + "green_max_threshold": 2048, + "wred_green_enable": true, + "green_drop_probability": 25, + "ecn": "ecn_all" + } + ] + } + } + }, + + "WRED_PROFILE_INVALID_YELLOW_THRESHOLD": { + "sonic-wred-profile:sonic-wred-profile": { + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred4", + "yellow_min_threshold": 4096, + "yellow_max_threshold": 2048, + "wred_yellow_enable": true, + "yellow_drop_probability": 25, + "ecn": "ecn_all" + } + ] + } + } + }, + + "WRED_PROFILE_INVALID_RED_THRESHOLD": { + "sonic-wred-profile:sonic-wred-profile": { + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred4", + "red_min_threshold": 4096, + "red_max_threshold": 2048, + "wred_red_enable": true, + "red_drop_probability": 25, + "ecn": "ecn_all" + } + ] + } + } + }, + + + "QUEUE_VALID": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "DWRR", + "weight": 10 + } + ] + } + }, + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred1", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_none", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + } + ] + } + }, + + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet0", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet0", + "speed": 25000 + } + ] + } + }, + + "sonic-queue:sonic-queue": { + "sonic-queue:QUEUE": { + "QUEUE_LIST": [ + { + "ifname": "Ethernet0", + "qindex": "0", + "scheduler": "Test@0", + "wred_profile": "Wred1" + } + ] + } + } + }, + + "QUEUE_PORT_NOT_EXIST": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "DWRR", + "weight": 10 + } + ] + } + }, + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred1", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_none", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + } + ] + } + }, + + "sonic-queue:sonic-queue": { + "sonic-queue:QUEUE": { + "QUEUE_LIST": [ + { + "ifname": "Ethernet0", + "qindex": "0", + "scheduler": "Test@0", + "wred_profile": "Wred1" + } + ] + } + } + }, + + "QUEUE_SCHEDULER_NOT_EXIST": { + "sonic-wred-profile:sonic-wred-profile":{ + "sonic-wred-profile:WRED_PROFILE": { + "WRED_PROFILE_LIST": [ + { + "name":"Wred1", + "yellow_min_threshold": 2048, + "green_min_threshold": 4096, + "red_min_threshold": 1024, + "yellow_max_threshold": 4096, + "green_max_threshold": 8192, + "red_max_threshold": 2048, + "ecn": "ecn_none", + "wred_green_enable": true, + "wred_yellow_enable": true, + "wred_red_enable": true, + "yellow_drop_probability": 50, + "green_drop_probability": 25, + "red_drop_probability": 100 + } + ] + } + }, + + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet4", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet4", + "speed": 25000 + } + ] + } + }, + + "sonic-queue:sonic-queue": { + "sonic-queue:QUEUE": { + "QUEUE_LIST": [ + { + "ifname": "Ethernet4", + "qindex": "0", + "scheduler": "Test@0", + "wred_profile": "Wred1" + } + ] + } + } + }, + + "QUEUE_WRED_NOT_EXIST": { + "sonic-scheduler:sonic-scheduler":{ + "sonic-scheduler:SCHEDULER": { + "SCHEDULER_LIST": [ + { + "name":"Test@0", + "cbs": 256, + "cir": 1250000, + "meter_type": "bytes", + "pbs": 1024, + "pir": 25000000, + "type": "DWRR", + "weight": 10 + } + ] + } + }, + + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth8", + "description": "Ethernet8", + "lanes": "65", + "mtu": 9000, + "name": "Ethernet8", + "speed": 25000 + } + ] + } + }, + + "sonic-queue:sonic-queue": { + "sonic-queue:QUEUE": { + "QUEUE_LIST": [ + { + "ifname": "Ethernet8", + "qindex": "0", + "scheduler": "Test@0", + "wred_profile": "Wred1" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json new file mode 100644 index 000000000000..fe085ee3c7f9 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/qosmaps.json @@ -0,0 +1,724 @@ +{ + "DSCP_TO_TC_MAP_CRETAE": { + "sonic-dscp-tc-map:sonic-dscp-tc-map": { + "sonic-dscp-tc-map:DSCP_TO_TC_MAP": { + "DSCP_TO_TC_MAP_LIST": [ + { + "name": "map1", + "DSCP_TO_TC_MAP": [ + { + "dscp": "1", + "tc": "1" + }, + { + "dscp":"2", + "tc":"2" + } + ] + }, + { + "name": "map2", + "DSCP_TO_TC_MAP": [ + { + "dscp": "1", + "tc": "1" + }, + { + "dscp":"2", + "tc":"2" + } + ] + } + ] + } + } + }, + + "DSCP_TO_TC_MAP_CREATE_INVALID_DSCP": { + "sonic-dscp-tc-map:sonic-dscp-tc-map": { + "sonic-dscp-tc-map:DSCP_TO_TC_MAP": { + "DSCP_TO_TC_MAP_LIST": [ + { + "name": "map3", + "DSCP_TO_TC_MAP": [ + { + "dscp": "64", + "tc": "1" + }, + { + "dscp":"2", + "tc":"2" + } + ] + } + ] + } + } + }, + + "DSCP_TO_TC_MAP_CREATE_INVALID_TC": { + "sonic-dscp-tc-map:sonic-dscp-tc-map": { + "sonic-dscp-tc-map:DSCP_TO_TC_MAP": { + "DSCP_TO_TC_MAP_LIST": [ + { + "name": "map3", + "DSCP_TO_TC_MAP": [ + { + "dscp": "1", + "tc": "8" + }, + { + "dscp":"2", + "tc":"2" + } + ] + } + ] + } + } + }, + + "DOT1P_TO_TC_MAP_CRETAE": { + "sonic-dot1p-tc-map:sonic-dot1p-tc-map": { + "sonic-dot1p-tc-map:DOT1P_TO_TC_MAP": { + "DOT1P_TO_TC_MAP_LIST": [ + { + "name": "map1", + "DOT1P_TO_TC_MAP": [ + { + "dot1p": "1", + "tc": "1" + }, + { + "dot1p":"2", + "tc":"2" + } + ] + }, + { + "name": "map2", + "DOT1P_TO_TC_MAP": [ + { + "dot1p": "1", + "tc": "1" + }, + { + "dot1p":"2", + "tc":"2" + } + ] + } + ] + } + } + }, + + "DOT1P_TO_TC_MAP_CREATE_INVALID_DOT1P": { + "sonic-dot1p-tc-map:sonic-dot1p-tc-map": { + "sonic-dot1p-tc-map:DOT1P_TO_TC_MAP": { + "DOT1P_TO_TC_MAP_LIST": [ + { + "name": "map3", + "DOT1P_TO_TC_MAP": [ + { + "dot1p": "64", + "tc": "1" + }, + { + "dot1p":"2", + "tc":"2" + } + ] + } + ] + } + } + }, + + "DOT1P_TO_TC_MAP_CREATE_INVALID_TC": { + "sonic-dot1p-tc-map:sonic-dot1p-tc-map": { + "sonic-dot1p-tc-map:DOT1P_TO_TC_MAP": { + "DOT1P_TO_TC_MAP_LIST": [ + { + "name": "map3", + "DOT1P_TO_TC_MAP": [ + { + "dot1p": "1", + "tc": "8" + }, + { + "dot1p":"2", + "tc":"2" + } + ] + } + ] + } + } + }, + + "TC_TO_QUEUE_MAP_CRETAE": { + "sonic-tc-queue-map:sonic-tc-queue-map": { + "sonic-tc-queue-map:TC_TO_QUEUE_MAP": { + "TC_TO_QUEUE_MAP_LIST": [ + { + "name": "map1", + "TC_TO_QUEUE_MAP": [ + { + "tc": "1", + "qindex": "1" + }, + { + "tc":"2", + "qindex":"2" + } + ] + }, + { + "name": "map2", + "TC_TO_QUEUE_MAP": [ + { + "tc": "1", + "qindex": "1" + }, + { + "tc":"2", + "qindex":"2" + } + ] + } + ] + } + } + }, + + "TC_TO_QUEUE_MAP_CREATE_INVALID_TC": { + "sonic-tc-queue-map:sonic-tc-queue-map": { + "sonic-tc-queue-map:TC_TO_QUEUE_MAP": { + "TC_TO_QUEUE_MAP_LIST": [ + { + "name": "map3", + "TC_TO_QUEUE_MAP": [ + { + "tc": "64", + "qindex": "1" + }, + { + "tc":"2", + "qindex":"2" + } + ] + } + ] + } + } + }, + + "TC_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": { + "sonic-tc-queue-map:sonic-tc-queue-map": { + "sonic-tc-queue-map:TC_TO_QUEUE_MAP": { + "TC_TO_QUEUE_MAP_LIST": [ + { + "name": "map3", + "TC_TO_QUEUE_MAP": [ + { + "tc": "1", + "qindex": "8" + }, + { + "tc":"2", + "qindex":"2" + } + ] + } + ] + } + } + }, + + "TC_TO_PRIORITY_GROUP_MAP_CRETAE": { + "sonic-tc-priority-group-map:sonic-tc-priority-group-map": { + "sonic-tc-priority-group-map:TC_TO_PRIORITY_GROUP_MAP": { + "TC_TO_PRIORITY_GROUP_MAP_LIST": [ + { + "name": "map1", + "TC_TO_PRIORITY_GROUP_MAP": [ + { + "tc": "1", + "pg": "1" + }, + { + "tc":"2", + "pg":"2" + } + ] + }, + { + "name": "map2", + "TC_TO_PRIORITY_GROUP_MAP": [ + { + "tc": "1", + "pg": "1" + }, + { + "tc":"2", + "pg":"2" + } + ] + } + ] + } + } + }, + + "TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_TC": { + "sonic-tc-priority-group-map:sonic-tc-priority-group-map": { + "sonic-tc-priority-group-map:TC_TO_PRIORITY_GROUP_MAP": { + "TC_TO_PRIORITY_GROUP_MAP_LIST": [ + { + "name": "map3", + "TC_TO_PRIORITY_GROUP_MAP": [ + { + "tc": "64", + "pg": "1" + }, + { + "tc":"2", + "pg":"2" + } + ] + } + ] + } + } + }, + + "TC_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": { + "sonic-tc-priority-group-map:sonic-tc-priority-group-map": { + "sonic-tc-priority-group-map:TC_TO_PRIORITY_GROUP_MAP": { + "TC_TO_PRIORITY_GROUP_MAP_LIST": [ + { + "name": "map3", + "TC_TO_PRIORITY_GROUP_MAP": [ + { + "tc": "1", + "pg": "8" + }, + { + "tc":"2", + "pg":"2" + } + ] + } + ] + } + } + }, + + "PFC_PRIORITY_TO_QUEUE_MAP_CRETAE": { + "sonic-pfc-priority-queue-map:sonic-pfc-priority-queue-map": { + "sonic-pfc-priority-queue-map:MAP_PFC_PRIORITY_TO_QUEUE": { + "MAP_PFC_PRIORITY_TO_QUEUE_LIST": [ + { + "name": "map1", + "MAP_PFC_PRIORITY_TO_QUEUE": [ + { + "pfc_priority": "1", + "qindex": "1" + }, + { + "pfc_priority":"2", + "qindex":"2" + } + ] + }, + { + "name": "map2", + "MAP_PFC_PRIORITY_TO_QUEUE": [ + { + "pfc_priority": "1", + "qindex": "1" + }, + { + "pfc_priority":"2", + "qindex":"2" + } + ] + } + ] + } + } + }, + + "PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_PFC_PRIORITY": { + "sonic-pfc-priority-queue-map:sonic-pfc-priority-queue-map": { + "sonic-pfc-priority-queue-map:MAP_PFC_PRIORITY_TO_QUEUE": { + "MAP_PFC_PRIORITY_TO_QUEUE_LIST": [ + { + "name": "map3", + "MAP_PFC_PRIORITY_TO_QUEUE": [ + { + "pfc_priority": "64", + "qindex": "1" + }, + { + "pfc_priority":"2", + "qindex":"2" + } + ] + } + ] + } + } + }, + + "PFC_PRIORITY_TO_QUEUE_MAP_CREATE_INVALID_QUEUE": { + "sonic-pfc-priority-queue-map:sonic-pfc-priority-queue-map": { + "sonic-pfc-priority-queue-map:MAP_PFC_PRIORITY_TO_QUEUE": { + "MAP_PFC_PRIORITY_TO_QUEUE_LIST": [ + { + "name": "map3", + "MAP_PFC_PRIORITY_TO_QUEUE": [ + { + "pfc_priority": "1", + "qindex": "8" + }, + { + "pfc_priority":"2", + "qindex":"2" + } + ] + } + ] + } + } + }, + + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CRETAE": { + "sonic-pfc-priority-priority-group-map:sonic-pfc-priority-priority-group-map": { + "sonic-pfc-priority-priority-group-map:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": { + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST": [ + { + "name": "map1", + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [ + { + "pfc_priority": "1", + "pg": "1" + }, + { + "pfc_priority":"2", + "pg":"2" + } + ] + }, + { + "name": "map2", + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [ + { + "pfc_priority": "1", + "pg": "1" + }, + { + "pfc_priority":"2", + "pg":"2" + } + ] + } + ] + } + } + }, + + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PFC_PRIORITY": { + "sonic-pfc-priority-priority-group-map:sonic-pfc-priority-priority-group-map": { + "sonic-pfc-priority-priority-group-map:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": { + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST": [ + { + "name": "map3", + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [ + { + "pfc_priority": "64", + "pg": "1" + }, + { + "pfc_priority":"2", + "pg":"2" + } + ] + } + ] + } + } + }, + + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_CREATE_INVALID_PRIORITY_GROUP": { + "sonic-pfc-priority-priority-group-map:sonic-pfc-priority-priority-group-map": { + "sonic-pfc-priority-priority-group-map:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": { + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST": [ + { + "name": "map3", + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [ + { + "pfc_priority": "1", + "pg": "8" + }, + { + "pfc_priority":"2", + "pg":"2" + } + ] + } + ] + } + } + }, + + "PORT_QOS_MAP_APPLY_MAPS": { + "sonic-dscp-tc-map:sonic-dscp-tc-map": { + "sonic-dscp-tc-map:DSCP_TO_TC_MAP": { + "DSCP_TO_TC_MAP_LIST": [ + { + "name": "map1", + "DSCP_TO_TC_MAP": [ + { + "dscp": "1", + "tc": "1" + }, + { + "dscp":"2", + "tc":"2" + } + ] + } + ] + } + }, + + "sonic-dot1p-tc-map:sonic-dot1p-tc-map": { + "sonic-dot1p-tc-map:DOT1P_TO_TC_MAP": { + "DOT1P_TO_TC_MAP_LIST": [ + { + "name": "map1", + "DOT1P_TO_TC_MAP": [ + { + "dot1p": "1", + "tc": "1" + }, + { + "dot1p":"2", + "tc":"2" + } + ] + } + ] + } + }, + + "sonic-tc-queue-map:sonic-tc-queue-map": { + "sonic-tc-queue-map:TC_TO_QUEUE_MAP": { + "TC_TO_QUEUE_MAP_LIST": [ + { + "name": "map1", + "TC_TO_QUEUE_MAP": [ + { + "tc": "1", + "qindex": "1" + }, + { + "tc":"2", + "qindex":"2" + } + ] + } + ] + } + }, + "sonic-tc-priority-group-map:sonic-tc-priority-group-map": { + "sonic-tc-priority-group-map:TC_TO_PRIORITY_GROUP_MAP": { + "TC_TO_PRIORITY_GROUP_MAP_LIST": [ + { + "name": "map1", + "TC_TO_PRIORITY_GROUP_MAP": [ + { + "tc": "1", + "pg": "1" + }, + { + "tc":"2", + "pg":"2" + } + ] + } + ] + } + }, + + "sonic-pfc-priority-queue-map:sonic-pfc-priority-queue-map": { + "sonic-pfc-priority-queue-map:MAP_PFC_PRIORITY_TO_QUEUE": { + "MAP_PFC_PRIORITY_TO_QUEUE_LIST": [ + { + "name": "map1", + "MAP_PFC_PRIORITY_TO_QUEUE": [ + { + "pfc_priority": "1", + "qindex": "1" + }, + { + "pfc_priority":"2", + "qindex":"2" + } + ] + } + ] + } + }, + + "sonic-pfc-priority-priority-group-map:sonic-pfc-priority-priority-group-map": { + "sonic-pfc-priority-priority-group-map:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": { + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST": [ + { + "name": "map1", + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP": [ + { + "pfc_priority": "1", + "pg": "1" + }, + { + "pfc_priority":"2", + "pg":"2" + } + ] + } + ] + } + }, + + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet0", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-port-qos-map:sonic-port-qos-map": { + "sonic-port-qos-map:PORT_QOS_MAP": { + "PORT_QOS_MAP_LIST": [ + { + "ifname": "Ethernet0", + "dscp_to_tc_map": "map1", + "tc_to_pg_map": "map1", + "tc_to_queue_map": "map1", + "pfc_to_queue_map": "map1", + "pfc_to_pg_map": "map1", + "dscp_to_tc_map": "map1", + "dot1p_to_tc_map": "map1", + "pfc_enable": "3,4" + } + ] + } + } + }, + + "PORT_QOS_MAP_APPLY_NON_EXISTS_MAPS": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet0", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet0", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-port-qos-map:sonic-port-qos-map": { + "sonic-port-qos-map:PORT_QOS_MAP": { + "PORT_QOS_MAP_LIST": [ + { + "ifname": "Ethernet0", + "dscp_to_tc_map": "map2", + "tc_to_pg_map": "map2", + "tc_to_queue_map": "map2", + "pfc_to_queue_map": "map2", + "pfc_to_pg_map": "map2", + "dscp_to_tc_map": "map2", + "dot1p_to_tc_map": "map2", + "pfc_enable": "3,4" + } + ] + } + } + }, + + "PORT_QOS_MAP_APPLY_NON_EXISTS_PORT": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-port-qos-map:sonic-port-qos-map": { + "sonic-port-qos-map:PORT_QOS_MAP": { + "PORT_QOS_MAP_LIST": [ + { + "ifname": "Ethernet0" + } + ] + } + } + }, + + "PORT_QOS_MAP_APPLY_INVALID_PFC": { + "sonic-port:sonic-port": { + "sonic-port:PORT": { + "PORT_LIST": [ + { + "admin_status": "up", + "alias": "eth0", + "description": "Ethernet4", + "lanes": "65", + "mtu": "9000", + "name": "Ethernet4", + "tpid": "0x8100", + "speed": "25000" + } + ] + } + }, + "sonic-port-qos-map:sonic-port-qos-map": { + "sonic-port-qos-map:PORT_QOS_MAP": { + "PORT_QOS_MAP_LIST": [ + { + "ifname": "Ethernet4", + "pfc_enable": "8" + } + ] + } + } + } + +} diff --git a/src/sonic-yang-models/yang-models/sonic-dot1p-tc-map.yang b/src/sonic-yang-models/yang-models/sonic-dot1p-tc-map.yang new file mode 100644 index 000000000000..0a756298c97e --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-dot1p-tc-map.yang @@ -0,0 +1,68 @@ +module sonic-dot1p-tc-map { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-dot1p-tc-map"; + + prefix dot1ptm; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "DOT1P_TO_TC_MAP yang Module for SONiC OS"; + + revision 2021-04-15 { + description + "Initial revision."; + } + + container sonic-dot1p-tc-map { + + container DOT1P_TO_TC_MAP { + + description "DOT1P_TO_TC_MAP part of config_db.json"; + + list DOT1P_TO_TC_MAP_LIST { + + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})'; + length 1..32 { + error-message "Invalid length for map name."; + error-app-tag map-name-invalid-length; + } + } + } + + list DOT1P_TO_TC_MAP { //this is list inside list for storing mapping between two fields + + key "dot1p"; + + leaf dot1p { + type string { + pattern "[0-7]?" { + error-message "Invalid DOT1P"; + error-app-tag dot1p-invalid; + } + } + } + + leaf tc { + type string { + pattern "[0-7]?"{ + error-message "Invalid Traffic Class"; + error-app-tag tc-invalid; + } + } + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-dscp-tc-map.yang b/src/sonic-yang-models/yang-models/sonic-dscp-tc-map.yang new file mode 100644 index 000000000000..71d9fcd4884d --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-dscp-tc-map.yang @@ -0,0 +1,68 @@ +module sonic-dscp-tc-map { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-dscp-tc-map"; + + prefix dtm; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "DSCP_TO_TC_MAP yang Module for SONiC OS"; + + revision 2021-04-15 { + description + "Initial revision."; + } + + container sonic-dscp-tc-map { + + container DSCP_TO_TC_MAP { + + description "DSCP_TO_TC_MAP part of config_db.json"; + + list DSCP_TO_TC_MAP_LIST { + + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})'; + length 1..32 { + error-message "Invalid length for map name."; + error-app-tag map-name-invalid-length; + } + } + } + + list DSCP_TO_TC_MAP { //this is list inside list for storing mapping between two fields + + key "dscp"; + + leaf dscp { + type string { + pattern "6[0-3]|[1-5][0-9]?|[0-9]?" { + error-message "Invalid DSCP"; + error-app-tag dscp-invalid; + } + } + } + + leaf tc { + type string { + pattern "[0-7]?" { + error-message "Invalid Traffic Class"; + error-app-tag tc-invalid; + } + } + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-pfc-priority-priority-group-map.yang b/src/sonic-yang-models/yang-models/sonic-pfc-priority-priority-group-map.yang new file mode 100644 index 000000000000..ccc86c064efb --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-pfc-priority-priority-group-map.yang @@ -0,0 +1,68 @@ +module sonic-pfc-priority-priority-group-map { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-pfc-priority-priority-group-map"; + + prefix pppgm; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP yang Module for SONiC OS"; + + revision 2021-04-15 { + description + "Initial revision."; + } + + container sonic-pfc-priority-priority-group-map { + + container PFC_PRIORITY_TO_PRIORITY_GROUP_MAP { + + description "PFC_PRIORITY_TO_PRIORITY_GROUP_MAP part of config_db.json"; + + list PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST { + + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})'; + length 1..32 { + error-message "Invalid length for map name."; + error-app-tag map-name-invalid-length; + } + } + } + + list PFC_PRIORITY_TO_PRIORITY_GROUP_MAP { //this is list inside list for storing mapping between two fields + + key "pfc_priority"; + + leaf pfc_priority { + type string { + pattern "[0-7]?" { + error-message "Invalid pfc priority"; + error-app-tag pfc-priority-invalid; + } + } + } + + leaf pg { + type string { + pattern "[0-7]?" { + error-message "Invalid Priority Group"; + error-app-tag pg-invalid; + } + } + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-pfc-priority-queue-map.yang b/src/sonic-yang-models/yang-models/sonic-pfc-priority-queue-map.yang new file mode 100644 index 000000000000..fb659d89bb4b --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-pfc-priority-queue-map.yang @@ -0,0 +1,68 @@ +module sonic-pfc-priority-queue-map { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-pfc-priority-queue-map"; + + prefix ppqm; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "PFC_PRIORITY_TO_QUEUE_MAP yang Module for SONiC OS"; + + revision 2021-04-15 { + description + "Initial revision."; + } + + container sonic-pfc-priority-queue-map { + + container MAP_PFC_PRIORITY_TO_QUEUE { + + description "MAP_PFC_PRIORITY_TO_QUEUE part of config_db.json"; + + list MAP_PFC_PRIORITY_TO_QUEUE_LIST { + + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})'; + length 1..32 { + error-message "Invalid length for map name."; + error-app-tag map-name-invalid-length; + } + } + } + + list MAP_PFC_PRIORITY_TO_QUEUE { //this is list inside list for storing mapping between two fields + + key "pfc_priority"; + + leaf pfc_priority { + type string { + pattern "[0-7]?" { + error-message "Invalid pfc priority"; + error-app-tag pfc-priority-invalid; + } + } + } + + leaf qindex { + type string { + pattern "[0-7]?" { + error-message "Invalid queue index"; + error-app-tag queue-index-invalid; + } + } + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang b/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang new file mode 100644 index 000000000000..b29e2f547087 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-port-qos-map.yang @@ -0,0 +1,110 @@ +module sonic-port-qos-map { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-port-qos-map"; + + prefix pqm; + + import sonic-port { + prefix prt; + } + + import sonic-tc-priority-group-map { + prefix tpgm; + } + + import sonic-tc-queue-map { + prefix tqm; + } + + import sonic-pfc-priority-queue-map { + prefix ppqm; + } + + import sonic-pfc-priority-priority-group-map { + prefix pppgm; + } + + import sonic-dscp-tc-map { + prefix dtm; + } + + import sonic-dot1p-tc-map { + prefix dot1ptm; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SONIC PORT_QOS_MAP"; + + revision 2019-05-15 { + description + "Initial revision."; + } + + container sonic-port-qos-map { + + container PORT_QOS_MAP { + list PORT_QOS_MAP_LIST { + + key "ifname"; + + leaf ifname { + type leafref { + path "/prt:sonic-port/prt:PORT/prt:PORT_LIST/prt:name"; + } + description + "Reference of port on which QOS MAPS to be configured."; + } + + leaf tc_to_pg_map { + type leafref { + path "/tpgm:sonic-tc-priority-group-map/tpgm:TC_TO_PRIORITY_GROUP_MAP/tpgm:TC_TO_PRIORITY_GROUP_MAP_LIST/tpgm:name"; + } + } + + leaf tc_to_queue_map { + type leafref { + path "/tqm:sonic-tc-queue-map/tqm:TC_TO_QUEUE_MAP/tqm:TC_TO_QUEUE_MAP_LIST/tqm:name"; + } + } + + leaf pfc_enable { + type string { + pattern "[0-7](,[0-7])?"; + } + } + + leaf pfc_to_queue_map { + type leafref { + path "/ppqm:sonic-pfc-priority-queue-map/ppqm:MAP_PFC_PRIORITY_TO_QUEUE/ppqm:MAP_PFC_PRIORITY_TO_QUEUE_LIST/ppqm:name"; + } + } + + leaf pfc_to_pg_map { + type leafref { + path "/pppgm:sonic-pfc-priority-priority-group-map/pppgm:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP/pppgm:PFC_PRIORITY_TO_PRIORITY_GROUP_MAP_LIST/pppgm:name"; + } + } + + leaf dscp_to_tc_map { + type leafref { + path "/dtm:sonic-dscp-tc-map/dtm:DSCP_TO_TC_MAP/dtm:DSCP_TO_TC_MAP_LIST/dtm:name"; + } + } + + leaf dot1p_to_tc_map { + type leafref { + path "/dot1ptm:sonic-dot1p-tc-map/dot1ptm:DOT1P_TO_TC_MAP/dot1ptm:DOT1P_TO_TC_MAP_LIST/dot1ptm:name"; + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-queue.yang b/src/sonic-yang-models/yang-models/sonic-queue.yang new file mode 100644 index 000000000000..8e24faa72cb0 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-queue.yang @@ -0,0 +1,88 @@ +module sonic-queue { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-queue"; + + prefix squeue; + + import sonic-extension { + prefix sonic-ext; + } + + import sonic-port { + prefix port; + } + + import sonic-scheduler { + prefix sch; + } + + import sonic-wred-profile { + prefix wrd; + } + + organization + "SONiC"; + + contact + "SONiC"; + + description + "QUEUE yang Module for SONiC OS"; + + revision 2021-04-01 { + description + "Initial revision"; + } + + container sonic-queue { + + container QUEUE { + + description "QUEUE part of config_db.json"; + + list QUEUE_LIST { + + key "ifname qindex"; + + // sonic-ext:key-pattern "QUEUE|{ifname}|{qindex}"; //special pattern used for extracting keys from redis-key and populate the yang instance + // Total list instances = number(key1) * number(key2) * number(key3) + + leaf ifname { + type union { + type leafref { + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + } + type string { + pattern "CPU"; + } + } + description "Interface name."; + } + // qindex format is (X) | (X-Y). X is start and Y is end index. + // X and Y value depends on platform, example for physical ports 0-7 and + // for CPU port 0-48. Example qindex is 3-4 + leaf qindex { + // sonic-ext:custom-validation ValidateQindexPattern; + type string; + description "Queue index on the interface."; + } + + leaf scheduler { + type leafref { + path "/sch:sonic-scheduler/sch:SCHEDULER/sch:SCHEDULER_LIST/sch:name"; //Reference to SCHEDULER table + } + description "Scheduler for queue."; + } + + leaf wred_profile { + type leafref { + path "/wrd:sonic-wred-profile/wrd:WRED_PROFILE/wrd:WRED_PROFILE_LIST/wrd:name"; // Reference to WRED_PROFILE table + } + description "Wred profile for queue."; + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-scheduler.yang b/src/sonic-yang-models/yang-models/sonic-scheduler.yang new file mode 100644 index 000000000000..e6d1b7468f90 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-scheduler.yang @@ -0,0 +1,148 @@ +module sonic-scheduler { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-scheduler"; + + prefix sch; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "SCHEDULER yang Module for SONiC OS"; + + revision 2021-04-01 { + description + "Initial revision"; + } + + container sonic-scheduler { + + container SCHEDULER { + + description "SCHEDULER part of config_db.json"; + + list SCHEDULER_LIST { + + key "name"; + + leaf name { + + type string { + pattern "[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})|[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})([@]{1})([0-9]{1,3})"; + length 1..36 { + error-message "Invalid length for scheduler name."; + error-app-tag scheduler-name-invalid-length; + } + } + description "Scheduler name"; + } + + leaf type { + type enumeration { + enum DWRR { + description "Deficit Weighted Round-Robin Scheduling"; + } + enum WRR { + description "Weighted Round-Robin Scheduling"; + } + enum STRICT { + description "Strict Scheduling"; + } + } + default WRR; + description "Scheduling algorithm type"; + } + + leaf weight { + type uint8 { + range "1..100"; + } + default 1; + description "Scheduling algorithm weight"; + } + + leaf priority { + type uint8 { + range "0..9"; + } + description "Scheduler priority"; + } + + leaf meter_type { + type enumeration { + enum packets { + description "Metering is based on packets"; + } + enum bytes { + description "Metering is based on bytes"; + } + } + default bytes; + description "meter type"; + } + + leaf cir { + type uint64; + description + "Committed information rate for the dual-rate token + bucket policer.This value represents the rate at which + tokens are added to the primary bucket.nt Units is + Bps(Bytes per second) for meter type is bytes else + Pps(packets per second) for meter type is packets"; + } + + leaf pir { + must "((current()/../cir) and (current()/../cir > 0))" { + error-message "pir can't be configured without cir."; + } + must "(current() >= current()/../cir)" { + error-message "pir must be greater than or equal to cir"; + } + type uint64; + description + "Peak information rate for the dual-rate token bucket + policer.This value represents the rate at which tokens + are added to the secondary bucket.Unit is Bps(Bytes + per second) for meter type bytes else Pps(packets per + second) for meter type is packets"; + } + + leaf cbs { + + must "((current()/../cir) and (current()/../cir > 0))" { + error-message "cbs can't be configured without cir."; + } + + type uint32; + description + "Committed burst size for the dual-rate token bucket + policer.This value represents the depth of the token + bucket.Unit is bytes for meter type bytes else packets + for meter type is packets"; + } + + leaf pbs { + must "((current()/../pir) and (current()/../pir > 0))" { + error-message "pbs can't be configured without pir."; + } + + must "((not(current()/../cbs)) or (current() >= current()/../cbs))" { + error-message "pbs must be greater than or equal to cbs"; + } + + type uint32; + description + "Excess burst size for the dual-rate token bucket policer. + This value represents the depth of the secondary bucket. + Unit is bytes for meter type bytes else packets for meter type + is packets"; + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-tc-priority-group-map.yang b/src/sonic-yang-models/yang-models/sonic-tc-priority-group-map.yang new file mode 100644 index 000000000000..4290b79c3ee7 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-tc-priority-group-map.yang @@ -0,0 +1,68 @@ +module sonic-tc-priority-group-map { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-tc-priority-group-map"; + + prefix tpgm; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "TC_TO_PRIORITY_GROUP_MAP yang Module for SONiC OS"; + + revision 2021-04-15 { + description + "Initial revision."; + } + + container sonic-tc-priority-group-map { + + container TC_TO_PRIORITY_GROUP_MAP { + + description "TC_TO_PRIORITY_GROUP_MAP part of config_db.json"; + + list TC_TO_PRIORITY_GROUP_MAP_LIST { + + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})'; + length 1..32 { + error-message "Invalid length for map name."; + error-app-tag map-name-invalid-length; + } + } + } + + list TC_TO_PRIORITY_GROUP_MAP { //this is list inside list for storing mapping between two fields + + key "tc"; + + leaf tc { + type string { + pattern "[0-7]?" { + error-message "Invalid Traffic Class"; + error-app-tag tc-invalid; + } + } + } + + leaf pg { + type string { + pattern "[0-7]?" { + error-message "Invalid Priority Group"; + error-app-tag pg-invalid; + } + } + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-tc-queue-map.yang b/src/sonic-yang-models/yang-models/sonic-tc-queue-map.yang new file mode 100644 index 000000000000..fa22a8331294 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-tc-queue-map.yang @@ -0,0 +1,68 @@ +module sonic-tc-queue-map { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-tc-queue-map"; + + prefix tqm; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "TC_TO_QUEUE_MAP yang Module for SONiC OS"; + + revision 2021-04-15 { + description + "Initial revision."; + } + + container sonic-tc-queue-map { + + container TC_TO_QUEUE_MAP { + + description "TC_TO_QUEUE_MAP part of config_db.json"; + + list TC_TO_QUEUE_MAP_LIST { + + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})'; + length 1..32 { + error-message "Invalid length for map name."; + error-app-tag map-name-invalid-length; + } + } + } + + list TC_TO_QUEUE_MAP { //this is list inside list for storing mapping between two fields + + key "tc"; + + leaf tc { + type string { + pattern "[0-7]?" { + error-message "Invalid Traffic Class"; + error-app-tag tc-invalid; + } + } + } + + leaf qindex { + type string { + pattern "[0-7]?" { + error-message "Invalid queue index"; + error-app-tag queue-index-invalid; + } + } + } + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-wred-profile.yang b/src/sonic-yang-models/yang-models/sonic-wred-profile.yang new file mode 100644 index 000000000000..2ca7be26ca0f --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-wred-profile.yang @@ -0,0 +1,177 @@ +module sonic-wred-profile { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-wred-profile"; + + prefix wrd; + + organization + "SONiC"; + + contact + "SONiC"; + + description + "WRED_PROFILE yang Module for SONiC OS"; + + revision 2021-04-01 { + description + "Initial revision."; + } + + container sonic-wred-profile { + + container WRED_PROFILE { + + description "WRED_PROFILE part of config_db.json"; + + list WRED_PROFILE_LIST { + + key "name"; + + leaf name { + type string { + pattern '[a-zA-Z0-9]{1}([-a-zA-Z0-9_]{0,31})'; + length 1..32 { + error-message "Invalid length for wred profile name."; + error-app-tag wred-profile-name-invalid-length; + } + } + description "WRED profile name"; + } + + leaf yellow_min_threshold { + type uint64; + units bytes; + description "Yellow minimum threshold bytes"; + } + + leaf green_min_threshold { + type uint64; + units bytes; + description "Green minimum threshold bytes"; + } + + leaf red_min_threshold { + type uint64; + units bytes; + description "Red minimum threshold bytes"; + } + + leaf yellow_max_threshold { + type uint64; + units bytes; + must "(current() >= current()/../yellow_min_threshold)" { + error-message "Yellow max threshold must be greater than or equal to min threshold"; + } + description "Yellow maximum threshold bytes"; + } + + leaf green_max_threshold { + type uint64; + units bytes; + must "(current() >= current()/../green_min_threshold)" { + error-message "Green max threshold must be greater than or equal to min threshold"; + } + description "Green maximum threshold bytes"; + } + + leaf red_max_threshold { + type uint64; + units bytes; + must "(current() >= current()/../red_min_threshold)" { + error-message "Red max threshold must be greater than or equal to min threshold"; + } + description "Red maximum threshold bytes"; + } + + leaf ecn { + + type enumeration { + + enum ecn_none { + description "Disable ECN marking for all colors."; + } + + enum ecn_green { + description "Enable ECN marking for green color. Yellow and red are disabled."; + } + + enum ecn_yellow { + description "Enable ECN marking for yellow color. Green and red are disabled."; + } + + enum ecn_red { + description "Enable ECN marking for red color. Green and red are disabled."; + } + + enum ecn_green_yellow { + description "Enable ECN marking for green and yellow colors. Red is disabled."; + } + + enum ecn_green_red { + description "Enable ECN marking for green and red colors. Yellow is disabled."; + } + + enum ecn_yellow_red { + description "Enable ECN marking for yellow and red colors. Green is disabled."; + } + + enum ecn_all { + description "Enable ECN marking for all colors."; + + } + } + default ecn_none; + description "ECN mode"; + } + + leaf wred_green_enable { + type boolean; + default false; + description "Green enable"; + } + + leaf wred_yellow_enable { + type boolean; + default false; + description "Yellow enable"; + } + + leaf wred_red_enable { + type boolean; + default false; + description "Red enable"; + } + + leaf yellow_drop_probability { + type uint64 { + range "0..100"; + } + units percent; + default 100; + description "Yellow drop probability"; + } + + leaf green_drop_probability { + type uint64 { + range "0..100"; + } + units percent; + default 100; + description "Green drop probability"; + } + + leaf red_drop_probability { + type uint64 { + range "0..100"; + } + units percent; + default 100; + description "Red drop probability"; + } + } + } + } +} diff --git a/src/tacacs/pam/0006-Add-support-for-source-ip-address.patch b/src/tacacs/pam/0006-Add-support-for-source-ip-address.patch index 280cfeee28fb..8230b34e0d1a 100644 --- a/src/tacacs/pam/0006-Add-support-for-source-ip-address.patch +++ b/src/tacacs/pam/0006-Add-support-for-source-ip-address.patch @@ -1,16 +1,16 @@ -From 9c26e734cf9e5cec950dc8b8f474f89d87833bcd Mon Sep 17 00:00:00 2001 +From 49526a27e90647ed4e48c1d1d88e0c75a1ce221b Mon Sep 17 00:00:00 2001 From: Venkatesan Mahalingam -Date: Wed, 1 Jul 2020 18:57:28 -0700 -Subject: [PATCH] Add support to specify source address for TACACS+ +Date: Thu, 2 Jul 2020 09:57:28 +0800 +Subject: [PATCH 1/4] Add support to specify source address for TACACS+ --- pam_tacplus.c | 8 ++++---- - support.c | 31 +++++++++++++++++++++++++++++++ + support.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-- support.h | 1 + - 3 files changed, 36 insertions(+), 4 deletions(-) + 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/pam_tacplus.c b/pam_tacplus.c -index 38e2a70..ec8ea27 100644 +index 7544b2e..9fc6be7 100644 --- a/pam_tacplus.c +++ b/pam_tacplus.c @@ -177,7 +177,7 @@ int _pam_account(pam_handle_t *pamh, int argc, const char **argv, @@ -50,7 +50,7 @@ index 38e2a70..ec8ea27 100644 _pam_log(LOG_ERR, "connection failed srv %d: %m", srv_i); continue; diff --git a/support.c b/support.c -index 7c00618..3e55e2f 100644 +index 8f42a0c..164df62 100644 --- a/support.c +++ b/support.c @@ -37,6 +37,8 @@ char tac_service[64]; @@ -62,31 +62,76 @@ index 7c00618..3e55e2f 100644 void _pam_log(int err, const char *format,...) { char msg[256]; -@@ -183,6 +185,12 @@ int _pam_parse (int argc, const char **argv) { +@@ -171,6 +173,44 @@ int tacacs_get_password (pam_handle_t * pamh, int flags + return PAM_SUCCESS; + } + ++/* set source ip address for the outgoing tacacs packets */ ++void set_source_ip(const char *tac_source_ip) { ++ /* ++ addrinfo created by getaddrinfo must be released with freeaddrinfo. ++ so source ip address will be stored in following static variables. ++ */ ++ static struct addrinfo tac_source_address; ++ static struct sockaddr tac_source_sock_addr; ++ static struct sockaddr_in6 tac_source_sock6_addr; ++ ++ struct addrinfo hints, *source_address; ++ int rv; ++ ++ /* set the source ip address for the tacacs packets */ ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_family = AF_UNSPEC; ++ hints.ai_socktype = SOCK_STREAM; ++ if ((rv = getaddrinfo(tac_source_ip, NULL, &hints, ++ &source_address)) != 0) { ++ _pam_log(LOG_ERR, "error setting the source ip information"); ++ } else { ++ tac_source_addr = &tac_source_address; ++ memcpy(tac_source_addr, source_address, sizeof(struct addrinfo)); ++ ++ if (source_address->ai_family == AF_INET6) { ++ tac_source_addr->ai_addr = (struct sockaddr *)&(tac_source_sock6_addr); ++ memcpy(tac_source_addr->ai_addr, source_address->ai_addr, sizeof(struct sockaddr_in6)); ++ } ++ else { ++ tac_source_addr->ai_addr = &(tac_source_sock_addr); ++ memcpy(tac_source_addr->ai_addr, source_address->ai_addr, sizeof(struct sockaddr)); ++ } ++ ++ freeaddrinfo(source_address); ++ _pam_log(LOG_DEBUG, "source ip is set"); ++ } ++} ++ + int _pam_parse (int argc, const char **argv) { + int ctrl = 0; + const char *current_secret = NULL; +@@ -183,6 +223,12 @@ int _pam_parse (int argc, const char **argv) { tac_protocol[0] = 0; tac_prompt[0] = 0; tac_login[0] = 0; + tac_source_ip[0] = 0; + + if (tac_source_addr != NULL) { -+ freeaddrinfo(tac_source_addr); ++ /* reset source address */ + tac_source_addr = NULL; + } for (ctrl = 0; argc-- > 0; ++argv) { if (!strcmp (*argv, "debug")) { /* all */ -@@ -274,6 +282,10 @@ int _pam_parse (int argc, const char **argv) { +@@ -274,6 +320,10 @@ int _pam_parse (int argc, const char **argv) { } } else if(!strncmp(*argv, "vrf=", 4)) { __vrfname = strdup(*argv + 4); + } else if (!strncmp (*argv, "source_ip=", strlen("source_ip="))) { + /* source ip for the packets */ + strncpy (tac_source_ip, *argv + strlen("source_ip="), sizeof(tac_source_ip)); -+ set_source_ip (tac_source_ip, &tac_source_addr); ++ set_source_ip(tac_source_ip); } else { _pam_log (LOG_WARNING, "unrecognized option: %s", *argv); } -@@ -292,8 +304,27 @@ int _pam_parse (int argc, const char **argv) { +@@ -292,8 +342,8 @@ int _pam_parse (int argc, const char **argv) { _pam_log(LOG_DEBUG, "tac_protocol='%s'", tac_protocol); _pam_log(LOG_DEBUG, "tac_prompt='%s'", tac_prompt); _pam_log(LOG_DEBUG, "tac_login='%s'", tac_login); @@ -94,28 +139,12 @@ index 7c00618..3e55e2f 100644 } return ctrl; - } /* _pam_parse */ - -+/* set source ip address for the outgoing tacacs packets */ -+void set_source_ip(const char *tac_source_ip, -+ struct addrinfo **source_address) { -+ -+ struct addrinfo hints; -+ int rv; -+ -+ /* set the source ip address for the tacacs packets */ -+ memset(&hints, 0, sizeof(hints)); -+ hints.ai_family = AF_UNSPEC; -+ hints.ai_socktype = SOCK_STREAM; -+ if ((rv = getaddrinfo(tac_source_ip, NULL, &hints, -+ source_address)) != 0) { -+ _pam_log(LOG_ERR, "error setting the source ip information"); -+ } else { -+ _pam_log(LOG_DEBUG, "source ip is set"); -+ } -+} +-} /* _pam_parse */ +- ++} /* _pam_parse */ +\ No newline at end of file diff --git a/support.h b/support.h -index 9cbd040..09b8a85 100644 +index 9cbd040..b1faf43 100644 --- a/support.h +++ b/support.h @@ -37,6 +37,7 @@ extern int tac_srv_no; @@ -127,5 +156,5 @@ index 9cbd040..09b8a85 100644 int _pam_parse (int, const char **); unsigned long _resolve_name (char *); -- -2.7.4 +2.17.1.windows.2 diff --git a/src/tacacs/pam/0007-Fix-memory-leak-when-parse-configuration.patch b/src/tacacs/pam/0007-Fix-memory-leak-when-parse-configuration.patch new file mode 100644 index 000000000000..f79521d9028d --- /dev/null +++ b/src/tacacs/pam/0007-Fix-memory-leak-when-parse-configuration.patch @@ -0,0 +1,124 @@ +From 99eeeccd14c905b7ad77210343bb07334eb0e8d1 Mon Sep 17 00:00:00 2001 +From: liuh-80 <58683130+liuh-80@users.noreply.github.com> +Date: Tue, 12 Oct 2021 10:05:28 +0800 +Subject: [PATCH 2/4] Fix memory leak when parse configuration. +The fix code in this patch are copy from upstream project: https://github.com/kravietz/pam_tacplus/blob/master/support.c + +--- + pam_tacplus.c | 6 ++++-- + support.c | 37 +++++++++++++++++++++++++++++++++---- + support.h | 2 +- + 3 files changed, 38 insertions(+), 7 deletions(-) + +diff --git a/pam_tacplus.c b/pam_tacplus.c +index 9fc6be7..d062359 100644 +--- a/pam_tacplus.c ++++ b/pam_tacplus.c +@@ -323,7 +323,8 @@ int pam_sm_authenticate (pam_handle_t * pamh, int flags, + status = PAM_SUCCESS; + communicating = 0; + active_server.addr = tac_srv[srv_i].addr; +- active_server.key = tac_srv[srv_i].key; ++ /* copy secret to key */ ++ snprintf(active_server.key, sizeof(active_server.key), "%s", tac_srv[srv_i].key); + + if (ctrl & PAM_TAC_DEBUG) + syslog(LOG_DEBUG, "%s: active srv %d", __FUNCTION__, srv_i); +@@ -820,7 +821,8 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, + communicating = 0; + + active_server.addr = tac_srv[srv_i].addr; +- active_server.key = tac_srv[srv_i].key; ++ /* copy secret to key */ ++ snprintf(active_server.key, sizeof(active_server.key), "%s", tac_srv[srv_i].key); + + if (ctrl & PAM_TAC_DEBUG) + syslog(LOG_DEBUG, "%s: active srv %d", __FUNCTION__, srv_i); +diff --git a/support.c b/support.c +index 164df62..e22fa31 100644 +--- a/support.c ++++ b/support.c +@@ -30,7 +30,12 @@ + #include + #include + ++/* tacacs server information */ + tacplus_server_t tac_srv[TAC_PLUS_MAXSERVERS]; ++struct addrinfo tac_srv_addr[TAC_PLUS_MAXSERVERS]; ++struct sockaddr tac_sock_addr[TAC_PLUS_MAXSERVERS]; ++struct sockaddr_in6 tac_sock6_addr[TAC_PLUS_MAXSERVERS]; ++ + int tac_srv_no = 0; + + char tac_service[64]; +@@ -173,6 +178,26 @@ int tacacs_get_password (pam_handle_t * pamh, int flags + return PAM_SUCCESS; + } + ++/* ++ * Set tacacs server addrinfo. ++ */ ++void set_tacacs_server_addr(int tac_srv_no, struct addrinfo* server) { ++ tac_srv[tac_srv_no].addr = &(tac_srv_addr[tac_srv_no]); ++ memcpy(tac_srv[tac_srv_no].addr, server, sizeof(struct addrinfo)); ++ ++ if (server->ai_family == AF_INET6) { ++ tac_srv[tac_srv_no].addr->ai_addr = (struct sockaddr *)&(tac_sock6_addr[tac_srv_no]); ++ memcpy(tac_srv[tac_srv_no].addr->ai_addr, server->ai_addr, sizeof(struct sockaddr_in6)); ++ } ++ else { ++ tac_srv[tac_srv_no].addr->ai_addr = &(tac_sock_addr[tac_srv_no]); ++ memcpy(tac_srv[tac_srv_no].addr->ai_addr, server->ai_addr, sizeof(struct sockaddr)); ++ } ++ ++ tac_srv[tac_srv_no].addr->ai_canonname = NULL; ++ tac_srv[tac_srv_no].addr->ai_next = NULL; ++} ++ + /* set source ip address for the outgoing tacacs packets */ + void set_source_ip(const char *tac_source_ip) { + /* +@@ -284,8 +309,11 @@ int _pam_parse (int argc, const char **argv) { + } + if ((rv = getaddrinfo(server_name, (port == NULL) ? "49" : port, &hints, &servers)) == 0) { + for(server = servers; server != NULL && tac_srv_no < TAC_PLUS_MAXSERVERS; server = server->ai_next) { +- tac_srv[tac_srv_no].addr = server; +- tac_srv[tac_srv_no].key = current_secret; ++ /* set server address with allocate memory */ ++ set_tacacs_server_addr(tac_srv_no, server); ++ ++ /* copy secret to key */ ++ snprintf(tac_srv[tac_srv_no].key, sizeof(tac_srv[tac_srv_no].key), "%s", current_secret); + tac_srv_no++; + } + } else { +@@ -304,10 +332,11 @@ int _pam_parse (int argc, const char **argv) { + + /* if 'secret=' was given after a 'server=' parameter, fill in the current secret */ + for(i = tac_srv_no-1; i >= 0; i--) { +- if (tac_srv[i].key != NULL) ++ if (tac_srv[i].key[0] != 0) + break; + +- tac_srv[i].key = current_secret; ++ /* copy secret to key */ ++ snprintf(tac_srv[i].key, sizeof(tac_srv[i].key), "%s", current_secret); + } + } else if (!strncmp (*argv, "timeout=", 8)) { + /* FIXME atoi() doesn't handle invalid numeric strings well */ +diff --git a/support.h b/support.h +index b1faf43..6bcb07f 100644 +--- a/support.h ++++ b/support.h +@@ -28,7 +28,7 @@ + + typedef struct { + struct addrinfo *addr; +- const char *key; ++ char key[256]; + } tacplus_server_t; + + extern tacplus_server_t tac_srv[TAC_PLUS_MAXSERVERS]; +-- +2.17.1.windows.2 + diff --git a/src/tacacs/pam/0008-Extract-tacacs-support-functions-into-library.patch b/src/tacacs/pam/0008-Extract-tacacs-support-functions-into-library.patch new file mode 100644 index 000000000000..139c49564c00 --- /dev/null +++ b/src/tacacs/pam/0008-Extract-tacacs-support-functions-into-library.patch @@ -0,0 +1,446 @@ +From d820001f60e0a9f5e5df83b1edb229be5212e0b5 Mon Sep 17 00:00:00 2001 +From: liuh-80 <58683130+liuh-80@users.noreply.github.com> +Date: Tue, 12 Oct 2021 10:09:10 +0800 +Subject: [PATCH 3/4] Extract tacacs support functions into library. + +--- + Makefile.am | 16 ++- + configure.ac | 3 +- + libtacsupport.pc.in | 11 ++ + pam_tacplus.c | 3 - + pam_tacplus.h | 6 -- + support.c | 255 ++++++++++++++++++++++++++------------------ + support.h | 14 +++ + 7 files changed, 194 insertions(+), 114 deletions(-) + create mode 100644 libtacsupport.pc.in + +diff --git a/Makefile.am b/Makefile.am +index c90c582..2ac9ea0 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -20,7 +20,7 @@ libtac/include/tacplus.h \ + libtac/include/libtac.h \ + libtac/include/cdefs.h + +-lib_LTLIBRARIES = libtac.la ++lib_LTLIBRARIES = libtac.la libtacsupport.la + libtac_la_SOURCES = \ + libtac/lib/acct_r.c \ + libtac/lib/acct_s.c \ +@@ -48,6 +48,16 @@ $(libtac_include_HEADERS) + libtac_la_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/libtac/include + libtac_la_LDFLAGS = -version-info 2:0:0 -shared + ++libtacsupport_includedir = $(includedir)/libtac ++libtacsupport_include_HEADERS = \ ++support.h ++ ++libtacsupport_la_SOURCES = \ ++support.c \ ++$(libtacsupport_include_HEADERS) ++libtacsupport_la_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir) -I $(top_srcdir)/libtac/include ++libtacsupport_la_LDFLAGS = -version-info 2:0:0 -shared ++ + moduledir = @pamdir@ + module_LTLIBRARIES = pam_tacplus.la + pam_tacplus_la_SOURCES = pam_tacplus.h \ +@@ -58,7 +68,7 @@ pam_tacplus_la_CFLAGS = $(AM_CFLAGS) -I $(top_srcdir)/libtac/include + pam_tacplus_la_LDFLAGS = -module -avoid-version + pam_tacplus_la_LIBADD = libtac.la + +-EXTRA_DIST = pam_tacplus.spec libtac.pc.in ++EXTRA_DIST = pam_tacplus.spec libtac.pc.in libtacsupport.pc.in + if DOC + dist_doc_DATA = sample.pam README.md AUTHORS ChangeLog + endif +@@ -68,5 +78,5 @@ MAINTAINERCLEANFILES = Makefile.in config.h.in configure aclocal.m4 \ + config/install-sh config/ltmain.sh config/missing + + pkgconfigdir = $(libdir)/pkgconfig +-pkgconfig_DATA = libtac.pc ++pkgconfig_DATA = libtac.pc libtacsupport.pc + +diff --git a/configure.ac b/configure.ac +index f67e2ba..0f917a8 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -95,6 +95,7 @@ AM_CONDITIONAL(DOC, test "x$enable_doc" != "xno") + dnl -------------------------------------------------------------------- + dnl Generate made files + AC_CONFIG_FILES([Makefile +- libtac.pc ++ libtac.pc ++ libtacsupport.pc + pam_tacplus.spec]) + AC_OUTPUT +diff --git a/libtacsupport.pc.in b/libtacsupport.pc.in +new file mode 100644 +index 0000000..1f12fe0 +--- /dev/null ++++ b/libtacsupport.pc.in +@@ -0,0 +1,11 @@ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++libdir=@libdir@ ++includedir=@includedir@/libtac ++ ++Name: libtacsupport ++Description: TACACS+ support lib implementation ++URL: https://github.com/jeroennijhof/pam_tacplus ++Version: @VERSION@ ++Libs: -L${libdir} -ltacsupport ++Cflags: -I${includedir} +diff --git a/pam_tacplus.c b/pam_tacplus.c +index d062359..2a484f0 100644 +--- a/pam_tacplus.c ++++ b/pam_tacplus.c +@@ -53,9 +53,6 @@ static tacplus_server_t active_server; + /* accounting task identifier */ + static short int task_id = 0; + +-extern char *__vrfname; +- +- + /* Helper functions */ + int _pam_send_account(int tac_fd, int type, const char *user, char *tty, + char *r_addr, char *cmd) { +diff --git a/pam_tacplus.h b/pam_tacplus.h +index bc71b54..e7b30f7 100644 +--- a/pam_tacplus.h ++++ b/pam_tacplus.h +@@ -31,12 +31,6 @@ + #include + #include + +-/* pam_tacplus command line options */ +-#define PAM_TAC_DEBUG 0x01 +-#define PAM_TAC_ACCT 0x02 /* account on all specified servers */ +-#define PAM_TAC_USE_FIRST_PASS 0x04 +-#define PAM_TAC_TRY_FIRST_PASS 0x08 +- + /* pam_tacplus major, minor and patchlevel version numbers */ + #define PAM_TAC_VMAJ 1 + #define PAM_TAC_VMIN 3 +diff --git a/support.c b/support.c +index e22fa31..5b6e1fa 100644 +--- a/support.c ++++ b/support.c +@@ -29,6 +29,7 @@ + + #include + #include ++#include /* isspace() */ + + /* tacacs server information */ + tacplus_server_t tac_srv[TAC_PLUS_MAXSERVERS]; +@@ -236,9 +237,160 @@ void set_source_ip(const char *tac_source_ip) { + } + } + ++/* ++ * Parse one arguments. ++ * Use this method for both: ++ * 1. command line parameter ++ * 2. config file ++ */ ++int _pam_parse_arg (const char *arg, char* current_secret, uint current_secret_buffer_size) { ++ int ctrl = 0; ++ ++ if (!strcmp (arg, "debug")) { /* all */ ++ ctrl |= PAM_TAC_DEBUG; ++ } else if (!strcmp (arg, "use_first_pass")) { ++ ctrl |= PAM_TAC_USE_FIRST_PASS; ++ } else if (!strcmp (arg, "try_first_pass")) { ++ ctrl |= PAM_TAC_TRY_FIRST_PASS; ++ } else if (!strncmp (arg, "service=", 8)) { /* author & acct */ ++ xstrcpy (tac_service, arg + 8, sizeof(tac_service)); ++ } else if (!strncmp (arg, "protocol=", 9)) { /* author & acct */ ++ xstrcpy (tac_protocol, arg + 9, sizeof(tac_protocol)); ++ } else if (!strncmp (arg, "prompt=", 7)) { /* authentication */ ++ xstrcpy (tac_prompt, arg + 7, sizeof(tac_prompt)); ++ /* Replace _ with space */ ++ int chr; ++ for (chr = 0; chr < strlen(tac_prompt); chr++) { ++ if (tac_prompt[chr] == '_') { ++ tac_prompt[chr] = ' '; ++ } ++ } ++ } else if (!strncmp (arg, "login=", 6)) { ++ xstrcpy (tac_login, arg + 6, sizeof(tac_login)); ++ } else if (!strcmp (arg, "acct_all")) { ++ ctrl |= PAM_TAC_ACCT; ++ } else if (!strncmp (arg, "server=", 7)) { /* authen & acct */ ++ if(tac_srv_no < TAC_PLUS_MAXSERVERS) { ++ struct addrinfo hints, *servers, *server; ++ int rv; ++ char *close_bracket, *server_name, *port, server_buf[256]; ++ ++ memset(&hints, 0, sizeof hints); ++ hints.ai_family = AF_UNSPEC; /* use IPv4 or IPv6, whichever */ ++ hints.ai_socktype = SOCK_STREAM; ++ ++ if (strlen(arg + 7) >= sizeof(server_buf)) { ++ _pam_log(LOG_ERR, "server address too long, sorry"); ++ return ctrl; ++ } ++ strcpy(server_buf, arg + 7); ++ ++ if (*server_buf == '[' && (close_bracket = strchr(server_buf, ']')) != NULL) { /* Check for URI syntax */ ++ server_name = server_buf + 1; ++ port = strrchr(close_bracket, ':'); ++ *close_bracket = '\0'; ++ } else { /* Fall back to traditional syntax */ ++ server_name = server_buf; ++ port = strrchr(server_buf, ':'); ++ } ++ if (port != NULL) { ++ *port = '\0'; ++ port++; ++ } ++ if ((rv = getaddrinfo(server_name, (port == NULL) ? "49" : port, &hints, &servers)) == 0) { ++ for(server = servers; server != NULL && tac_srv_no < TAC_PLUS_MAXSERVERS; server = server->ai_next) { ++ /* set server address with allocate memory */ ++ set_tacacs_server_addr(tac_srv_no, server); ++ ++ /* copy secret to key */ ++ snprintf(tac_srv[tac_srv_no].key, sizeof(tac_srv[tac_srv_no].key), "%s", current_secret); ++ tac_srv_no++; ++ } ++ ++ /* release servers memory */ ++ freeaddrinfo(servers); ++ } else { ++ _pam_log (LOG_ERR, ++ "skip invalid server: %s (getaddrinfo: %s)", ++ server_name, gai_strerror(rv)); ++ } ++ } else { ++ _pam_log(LOG_ERR, "maximum number of servers (%d) exceeded, skipping", ++ TAC_PLUS_MAXSERVERS); ++ } ++ } else if (!strncmp (arg, "secret=", 7)) { ++ int i; ++ ++ /* points right into arg (which is const) */ ++ snprintf(current_secret, current_secret_buffer_size, "%s", arg + 7); ++ ++ /* if 'secret=' was given after a 'server=' parameter, fill in the current secret */ ++ for(i = tac_srv_no-1; i >= 0; i--) { ++ if (tac_srv[i].key[0] != 0) ++ break; ++ ++ /* copy secret to key */ ++ snprintf(tac_srv[i].key, sizeof(tac_srv[i].key), "%s", current_secret); ++ } ++ } else if (!strncmp (arg, "timeout=", 8)) { ++ /* FIXME atoi() doesn't handle invalid numeric strings well */ ++ tac_timeout = atoi(arg + 8); ++ ++ if (tac_timeout < 0) { ++ tac_timeout = 0; ++ } else { ++ tac_readtimeout_enable = 1; ++ } ++ } else if(!strncmp(arg, "vrf=", 4)) { ++ __vrfname = strdup(arg + 4); ++ } else if (!strncmp (arg, "source_ip=", strlen("source_ip="))) { ++ /* source ip for the packets */ ++ strncpy (tac_source_ip, arg + strlen("source_ip="), sizeof(tac_source_ip)); ++ set_source_ip (tac_source_ip); ++ } else { ++ _pam_log (LOG_WARNING, "unrecognized option: %s", arg); ++ } ++ ++ return ctrl; ++} /* _pam_parse_arg */ ++ ++ ++/* ++ * Parse config file. ++ */ ++int parse_config_file(const char *file) { ++ FILE *config_file; ++ char line_buffer[256]; ++ int ctrl = 0; ++ ++ config_file = fopen(file, "r"); ++ if(config_file == NULL) { ++ _pam_log(LOG_ERR, "Failed to open config file %s: %m", file); ++ return 0; ++ } ++ ++ if (tac_source_addr != NULL) { ++ /* reset source address */ ++ tac_source_addr = NULL; ++ } ++ ++ char current_secret[256]; ++ memset(current_secret, 0, sizeof(current_secret)); ++ while (fgets(line_buffer, sizeof line_buffer, config_file)) { ++ if(*line_buffer == '#' || isspace(*line_buffer)) ++ continue; /* skip comments and blank line. */ ++ strtok(line_buffer, " \t\n\r\f"); ++ ctrl |= _pam_parse_arg(line_buffer, current_secret, sizeof(current_secret)); ++ } ++ ++ fclose(config_file); ++ return ctrl; ++} ++ + int _pam_parse (int argc, const char **argv) { + int ctrl = 0; +- const char *current_secret = NULL; ++ char current_secret[256]; ++ memset(current_secret, 0, sizeof(current_secret)); + + /* otherwise the list will grow with each call */ + memset(tac_srv, 0, sizeof(tacplus_server_t) * TAC_PLUS_MAXSERVERS); +@@ -256,106 +408,7 @@ int _pam_parse (int argc, const char **argv) { + } + + for (ctrl = 0; argc-- > 0; ++argv) { +- if (!strcmp (*argv, "debug")) { /* all */ +- ctrl |= PAM_TAC_DEBUG; +- } else if (!strcmp (*argv, "use_first_pass")) { +- ctrl |= PAM_TAC_USE_FIRST_PASS; +- } else if (!strcmp (*argv, "try_first_pass")) { +- ctrl |= PAM_TAC_TRY_FIRST_PASS; +- } else if (!strncmp (*argv, "service=", 8)) { /* author & acct */ +- xstrcpy (tac_service, *argv + 8, sizeof(tac_service)); +- } else if (!strncmp (*argv, "protocol=", 9)) { /* author & acct */ +- xstrcpy (tac_protocol, *argv + 9, sizeof(tac_protocol)); +- } else if (!strncmp (*argv, "prompt=", 7)) { /* authentication */ +- xstrcpy (tac_prompt, *argv + 7, sizeof(tac_prompt)); +- /* Replace _ with space */ +- int chr; +- for (chr = 0; chr < strlen(tac_prompt); chr++) { +- if (tac_prompt[chr] == '_') { +- tac_prompt[chr] = ' '; +- } +- } +- } else if (!strncmp (*argv, "login=", 6)) { +- xstrcpy (tac_login, *argv + 6, sizeof(tac_login)); +- } else if (!strcmp (*argv, "acct_all")) { +- ctrl |= PAM_TAC_ACCT; +- } else if (!strncmp (*argv, "server=", 7)) { /* authen & acct */ +- if(tac_srv_no < TAC_PLUS_MAXSERVERS) { +- struct addrinfo hints, *servers, *server; +- int rv; +- char *close_bracket, *server_name, *port, server_buf[256]; +- +- memset(&hints, 0, sizeof hints); +- hints.ai_family = AF_UNSPEC; /* use IPv4 or IPv6, whichever */ +- hints.ai_socktype = SOCK_STREAM; +- +- if (strlen(*argv + 7) >= sizeof(server_buf)) { +- _pam_log(LOG_ERR, "server address too long, sorry"); +- continue; +- } +- strcpy(server_buf, *argv + 7); +- +- if (*server_buf == '[' && (close_bracket = strchr(server_buf, ']')) != NULL) { /* Check for URI syntax */ +- server_name = server_buf + 1; +- port = strrchr(close_bracket, ':'); +- *close_bracket = '\0'; +- } else { /* Fall back to traditional syntax */ +- server_name = server_buf; +- port = strrchr(server_buf, ':'); +- } +- if (port != NULL) { +- *port = '\0'; +- port++; +- } +- if ((rv = getaddrinfo(server_name, (port == NULL) ? "49" : port, &hints, &servers)) == 0) { +- for(server = servers; server != NULL && tac_srv_no < TAC_PLUS_MAXSERVERS; server = server->ai_next) { +- /* set server address with allocate memory */ +- set_tacacs_server_addr(tac_srv_no, server); +- +- /* copy secret to key */ +- snprintf(tac_srv[tac_srv_no].key, sizeof(tac_srv[tac_srv_no].key), "%s", current_secret); +- tac_srv_no++; +- } +- } else { +- _pam_log (LOG_ERR, +- "skip invalid server: %s (getaddrinfo: %s)", +- server_name, gai_strerror(rv)); +- } +- } else { +- _pam_log(LOG_ERR, "maximum number of servers (%d) exceeded, skipping", +- TAC_PLUS_MAXSERVERS); +- } +- } else if (!strncmp (*argv, "secret=", 7)) { +- int i; +- +- current_secret = *argv + 7; /* points right into argv (which is const) */ +- +- /* if 'secret=' was given after a 'server=' parameter, fill in the current secret */ +- for(i = tac_srv_no-1; i >= 0; i--) { +- if (tac_srv[i].key[0] != 0) +- break; +- +- /* copy secret to key */ +- snprintf(tac_srv[i].key, sizeof(tac_srv[i].key), "%s", current_secret); +- } +- } else if (!strncmp (*argv, "timeout=", 8)) { +- /* FIXME atoi() doesn't handle invalid numeric strings well */ +- tac_timeout = atoi(*argv + 8); +- +- if (tac_timeout < 0) { +- tac_timeout = 0; +- } else { +- tac_readtimeout_enable = 1; +- } +- } else if(!strncmp(*argv, "vrf=", 4)) { +- __vrfname = strdup(*argv + 4); +- } else if (!strncmp (*argv, "source_ip=", strlen("source_ip="))) { +- /* source ip for the packets */ +- strncpy (tac_source_ip, *argv + strlen("source_ip="), sizeof(tac_source_ip)); +- set_source_ip(tac_source_ip); +- } else { +- _pam_log (LOG_WARNING, "unrecognized option: %s", *argv); +- } ++ ctrl |= _pam_parse_arg(*argv, current_secret, sizeof(current_secret)); + } + + if (ctrl & PAM_TAC_DEBUG) { +diff --git a/support.h b/support.h +index 6bcb07f..569172e 100644 +--- a/support.h ++++ b/support.h +@@ -26,6 +26,14 @@ + + #include + ++/* pam_tacplus command line options */ ++#define PAM_TAC_DEBUG 0x01 ++#define PAM_TAC_ACCT 0x02 ++ ++/* account on all specified servers */ ++#define PAM_TAC_USE_FIRST_PASS 0x04 ++#define PAM_TAC_TRY_FIRST_PASS 0x08 ++ + typedef struct { + struct addrinfo *addr; + char key[256]; +@@ -33,6 +41,7 @@ typedef struct { + + extern tacplus_server_t tac_srv[TAC_PLUS_MAXSERVERS]; + extern int tac_srv_no; ++extern char *__vrfname; + + extern char tac_service[64]; + extern char tac_protocol[64]; +@@ -50,5 +59,10 @@ char *_pam_get_user(pam_handle_t *); + char *_pam_get_terminal(pam_handle_t *); + char *_pam_get_rhost(pam_handle_t *); + ++/* ++ * Parse config file. ++ */ ++int parse_config_file(const char *file); ++ + #endif /* PAM_TACPLUS_SUPPORT_H */ + +-- +2.17.1.windows.2 + diff --git a/src/tacacs/pam/0009-Add-setting-flag-for-authorization-and-accounting.patch b/src/tacacs/pam/0009-Add-setting-flag-for-authorization-and-accounting.patch new file mode 100644 index 000000000000..824db59f5ba0 --- /dev/null +++ b/src/tacacs/pam/0009-Add-setting-flag-for-authorization-and-accounting.patch @@ -0,0 +1,51 @@ +From 8ffcdaf2154943c9034a32876571face842b805c Mon Sep 17 00:00:00 2001 +From: liuh-80 <58683130+liuh-80@users.noreply.github.com> +Date: Tue, 12 Oct 2021 10:10:03 +0800 +Subject: [PATCH 4/4] Add setting flag for authorization and accounting. + +--- + support.c | 8 ++++++++ + support.h | 8 ++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/support.c b/support.c +index 5b6e1fa..788ae22 100644 +--- a/support.c ++++ b/support.c +@@ -347,6 +347,14 @@ int _pam_parse_arg (const char *arg, char* current_secret, uint current_secret_b + /* source ip for the packets */ + strncpy (tac_source_ip, arg + strlen("source_ip="), sizeof(tac_source_ip)); + set_source_ip (tac_source_ip); ++ } else if (!strcmp (arg, "local_accounting")) { ++ ctrl |= ACCOUNTING_FLAG_LOCAL; ++ } else if (!strcmp (arg, "tacacs_accounting")) { ++ ctrl |= ACCOUNTING_FLAG_TACACS; ++ } else if (!strcmp (arg, "local_authorization")) { ++ ctrl |= AUTHORIZATION_FLAG_LOCAL; ++ } else if (!strcmp (arg, "tacacs_authorization")) { ++ ctrl |= AUTHORIZATION_FLAG_TACACS; + } else { + _pam_log (LOG_WARNING, "unrecognized option: %s", arg); + } +diff --git a/support.h b/support.h +index 569172e..2b556a7 100644 +--- a/support.h ++++ b/support.h +@@ -34,6 +34,14 @@ + #define PAM_TAC_USE_FIRST_PASS 0x04 + #define PAM_TAC_TRY_FIRST_PASS 0x08 + ++/* accounting setting flag */ ++#define ACCOUNTING_FLAG_LOCAL 0x10 ++#define ACCOUNTING_FLAG_TACACS 0x20 ++ ++/* authorization setting flag */ ++#define AUTHORIZATION_FLAG_LOCAL 0x40 ++#define AUTHORIZATION_FLAG_TACACS 0x80 ++ + typedef struct { + struct addrinfo *addr; + char key[256]; +-- +2.17.1.windows.2 + diff --git a/src/tacacs/pam/Makefile b/src/tacacs/pam/Makefile index 3bab11b4ea82..4a3caa709f98 100644 --- a/src/tacacs/pam/Makefile +++ b/src/tacacs/pam/Makefile @@ -20,6 +20,9 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : git apply ../0004-management-vrf-support.patch git apply ../0005-pam-Modify-parsing-of-IP-address-and-port-number-to-.patch git apply ../0006-Add-support-for-source-ip-address.patch + git apply ../0007-Fix-memory-leak-when-parse-configuration.patch + git apply ../0008-Extract-tacacs-support-functions-into-library.patch + git apply ../0009-Add-setting-flag-for-authorization-and-accounting.patch # Apply patch for private patch git apply ../I001-Add-private-DeviceType-attribute.patch