-
Notifications
You must be signed in to change notification settings - Fork 367
sonic-sairedis: Add support to sonic-sairedis for gearbox phys #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4942ac1
8695a23
4d93ea9
9e2d0c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Script to start syncd using supervisord | ||
| # | ||
|
|
||
| exec "/usr/bin/physyncd_startup.py" | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #!/usr/bin/python | ||
|
|
||
| ''' | ||
| Copyright 2019 Broadcom. The term "Broadcom" refers to Broadcom Inc. | ||
| and/or its subsidiaries. | ||
|
|
||
| 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 json | ||
| import subprocess | ||
|
|
||
|
|
||
| def physyncd_enable(gearbox_config): | ||
| i = 1 | ||
| for phy in gearbox_config['phys']: | ||
| subprocess.Popen(["/bin/bash", "-c", "/bin/bash -c {}".format('"exec /usr/bin/syncd -p /etc/sai.d/pai.profile -x /usr/share/sonic/hwsku/context_config.json -g {}"'.format(i))], close_fds=True) | ||
| i += 1 | ||
|
|
||
| def main(): | ||
|
|
||
| # Only privileged users can execute this command | ||
| if os.geteuid() != 0: | ||
| sys.exit("Root privileges required for this operation") | ||
|
|
||
| """ Loads json file """ | ||
| try: | ||
| with open('/usr/share/sonic/hwsku/gearbox_config.json') as file_object: | ||
| gearbox_config=json.load(file_object) | ||
| except: | ||
| sys.exit("No external PHY / gearbox supported on this platform, existing physycd application") | ||
|
|
||
| physyncd_enable(gearbox_config) | ||
|
|
||
|
|
||
| if __name__== "__main__": | ||
| main() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
|
|
||
| Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or | ||
| its subsidiaries. | ||
|
|
||
| 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. | ||
|
|
||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include "SwitchStateBase.h" | ||
|
|
||
| namespace saivs | ||
| { | ||
| class SwitchBCM81724: | ||
| public SwitchStateBase | ||
| { | ||
| public: | ||
|
|
||
| SwitchBCM81724( | ||
| _In_ sai_object_id_t switch_id, | ||
| _In_ std::shared_ptr<RealObjectIdManager> manager, | ||
| _In_ std::shared_ptr<SwitchConfig> config); | ||
|
|
||
| SwitchBCM81724( | ||
| _In_ sai_object_id_t switch_id, | ||
| _In_ std::shared_ptr<RealObjectIdManager> manager, | ||
| _In_ std::shared_ptr<SwitchConfig> config, | ||
| _In_ std::shared_ptr<WarmBootState> warmBootState); | ||
|
|
||
| virtual ~SwitchBCM81724(); | ||
|
|
||
| protected: | ||
|
|
||
| virtual sai_status_t create_port_dependencies(_In_ sai_object_id_t port_id) override; | ||
|
|
||
| virtual sai_status_t create_qos_queues_per_port(_In_ sai_object_id_t port_id) override; | ||
|
|
||
| virtual sai_status_t create_qos_queues() override; | ||
|
|
||
| virtual sai_status_t set_switch_mac_address() override; | ||
|
|
||
| virtual sai_status_t create_default_vlan() override; | ||
|
|
||
| virtual sai_status_t create_default_1q_bridge() override; | ||
|
|
||
| virtual sai_status_t create_default_virtual_router() override; | ||
|
|
||
| virtual sai_status_t create_default_stp_instance() override; | ||
|
|
||
| virtual sai_status_t create_default_trap_group() override; | ||
|
|
||
| virtual sai_status_t create_ingress_priority_groups_per_port( | ||
| _In_ sai_object_id_t port_id) override; | ||
|
|
||
| virtual sai_status_t create_ingress_priority_groups() override; | ||
|
|
||
| virtual sai_status_t create_vlan_members() override; | ||
|
|
||
| virtual sai_status_t create_bridge_ports() override; | ||
|
|
||
| virtual sai_status_t set_acl_entry_min_prio() override; | ||
|
|
||
| virtual sai_status_t set_acl_capabilities() override; | ||
|
|
||
| virtual sai_status_t set_maximum_number_of_childs_per_scheduler_group() override; | ||
|
|
||
| virtual sai_status_t set_number_of_ecmp_groups() override; | ||
|
|
||
| virtual sai_status_t create_cpu_port(); | ||
|
|
||
| virtual sai_status_t create_ports(); | ||
|
|
||
| protected : // refresh | ||
|
|
||
| virtual sai_status_t refresh_port_list( | ||
| _In_ const sai_attr_metadata_t *meta) override; | ||
|
|
||
| virtual sai_status_t refresh_bridge_port_list( | ||
| _In_ const sai_attr_metadata_t *meta, | ||
| _In_ sai_object_id_t bridge_id) override; | ||
|
|
||
| virtual sai_status_t refresh_vlan_member_list( | ||
| _In_ const sai_attr_metadata_t *meta, | ||
| _In_ sai_object_id_t vlan_id) override; | ||
|
|
||
| protected: | ||
|
|
||
| virtual sai_status_t refresh_read_only( _In_ const sai_attr_metadata_t *meta, _In_ sai_object_id_t object_id) override; | ||
| virtual sai_status_t set_switch_default_attributes(); | ||
| virtual sai_status_t initialize_default_objects() override; | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,10 @@ extern "C" { | |
| } | ||
|
|
||
| #define SAI_KEY_VS_SWITCH_TYPE "SAI_VS_SWITCH_TYPE" | ||
| #define SAI_KEY_VS_SAI_SWITCH_TYPE "SAI_VS_SAI_SWITCH_TYPE" | ||
|
|
||
| #define SAI_VALUE_SAI_SWITCH_TYPE_NPU "SAI_SWITCH_TYPE_NPU" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why you need this ? if i understand correctly this is attribute on switch_create |
||
| #define SAI_VALUE_SAI_SWITCH_TYPE_PHY "SAI_SWITCH_TYPE_PHY" | ||
|
|
||
| /** | ||
| * @def SAI_KEY_VS_INTERFACE_LANE_MAP_FILE | ||
|
|
@@ -31,6 +35,7 @@ extern "C" { | |
| #define SAI_KEY_VS_HOSTIF_USE_TAP_DEVICE "SAI_VS_HOSTIF_USE_TAP_DEVICE" | ||
|
|
||
| #define SAI_VALUE_VS_SWITCH_TYPE_BCM56850 "SAI_VS_SWITCH_TYPE_BCM56850" | ||
| #define SAI_VALUE_VS_SWITCH_TYPE_BCM81724 "SAI_VS_SWITCH_TYPE_BCM81724" | ||
| #define SAI_VALUE_VS_SWITCH_TYPE_MLNX2700 "SAI_VS_SWITCH_TYPE_MLNX2700" | ||
|
|
||
| /* | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,19 @@ sai_status_t Sai::initialize( | |
| return SAI_STATUS_FAILURE; | ||
| } | ||
|
|
||
| auto sai_switch_type = service_method_table->profile_get_value(0, SAI_KEY_VS_SAI_SWITCH_TYPE); | ||
| sai_switch_type_t saiSwitchType; | ||
|
|
||
| if (sai_switch_type == NULL) | ||
| { | ||
| SWSS_LOG_NOTICE("failed to obtain service method table value: %s", SAI_KEY_VS_SAI_SWITCH_TYPE); | ||
| saiSwitchType = SAI_SWITCH_TYPE_NPU; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why you need this, i though this is switch_create attribute
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need, at this early state, to know if this is NPU, which supports the starting of fdb agent thread, or is PHY, which does not. We experienced failures if we start this thread for phy, and it is not desireable anyway. Introducing the switch type in the ini file as in this example, is how we determine type. SAI_WARM_BOOT_READ_FILE=./sai_warmboot.bin Another option would be to hard code a mapping of part number to type somewhere, but that hardly seems like a good solution (might as well put it here, where the switch resource is defined). The field is considered optional (default is NPU) since that is the dominant switch type, and for backwards compatibility. Effectively, at this point, making it a boolean "isPhy" but if you consider that downstream there might be a third or fourth class of "switch", better to call it out explicitly. |
||
| } | ||
| else if (!SwitchConfig::parseSaiSwitchType(sai_switch_type, saiSwitchType)) | ||
| { | ||
| return SAI_STATUS_FAILURE; | ||
| } | ||
|
|
||
| auto *laneMapFile = service_method_table->profile_get_value(0, SAI_KEY_VS_INTERFACE_LANE_MAP_FILE); | ||
|
|
||
| m_laneMapContainer = LaneMapFileParser::parseLaneMapFile(laneMapFile); | ||
|
|
@@ -128,6 +141,7 @@ sai_status_t Sai::initialize( | |
|
|
||
| auto sc = std::make_shared<SwitchConfig>(); | ||
|
|
||
| sc->m_saiSwitchType = saiSwitchType; | ||
| sc->m_switchType = switchType; | ||
| sc->m_bootType = bootType; | ||
| sc->m_switchIndex = 0; | ||
|
|
@@ -161,7 +175,10 @@ sai_status_t Sai::initialize( | |
|
|
||
| startUnittestThread(); | ||
|
|
||
| startFdbAgingThread(); | ||
| if (saiSwitchType == SAI_SWITCH_TYPE_NPU) | ||
| { | ||
| startFdbAgingThread(); | ||
| } | ||
|
|
||
| m_apiInitialized = true; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.