Skip to content

Commit 27f3a9c

Browse files
authored
sonic-sairedis: Add support to sonic-sairedis for gearbox phys (sonic-net#632)
* builds on support for multiple switches in sonic-sairedis * new vslib switch BCM81724 implements a virtual gearbox phy. * support for launching second (BCM81724 is supported by its own syncd) * simple refactoring of tests to support switches by part number, still working with sairedis to support multiple switch in tests so BCM81724 will be a separate pull request) * changed example context_config.json to reflect renaming of phy REDIS tables (see sonic-swss-common commit 292b08a3a80b24b23663020b37e6260039a311c0) Note that a future commit to sonic-buildimage will be required to trigger launch of physyncd (launching is based on device config files which are currently not present in sonic-buildimage). Testing done in multiple environments (broadcom fork and pure upstream). Example CLI output based on changes pushed to sonic-utilities (commit a6c4456f6965b79bf9d02ff1962070a5eae6ea55) running in VS switch supporting BCM81724: root@sonic:/home/admin# show gearbox interfaces status PHY Id Interface MAC Lanes MAC Lane Speed PHY Lanes PHY Lane Speed Line Lanes Line Lane Speed Oper Admin -------- ----------- ----------- ---------------- ----------- ---------------- ------------ ----------------- ------ ------- 1 Ethernet0 25,26,27,28 10G 200,201 20G 206 40G up up 1 Ethernet4 29,30,31,32 10G 202,203 20G 207 40G up up 1 Ethernet8 33,34,35,36 10G 204,205 20G 208 40G up up HLD is located at https://github.com/Azure/SONiC/blob/master/doc/gearbox/gearbox_mgr_design.md Signed-off-by: [email protected]
1 parent 7580944 commit 27f3a9c

File tree

76 files changed

+747
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+747
-13
lines changed

lib/src/context_config.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
{
2222
"guid" : 1,
2323
"name" : "syncd1",
24-
"dbAsic" : "ASIC_DB2",
25-
"dbCounters" : "COUNTERS_DB2",
26-
"dbFlex": "FLEX_COUNTER_DB2",
27-
"dbState" : "STATE_DB2",
24+
"dbAsic" : "GB_ASIC_DB",
25+
"dbCounters" : "GB_COUNTERS_DB",
26+
"dbFlex": "GB_FLEX_COUNTER_DB",
27+
"dbState" : "STATE_DB",
2828
"switches": [
2929
{
3030
"index" : 0,

lib/src/sai_redis_switch.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
#include "sai_redis.h"
22

3+
sai_status_t redis_switch_mdio_read(
4+
_In_ sai_object_id_t switch_id,
5+
_In_ uint32_t device_addr,
6+
_In_ uint32_t start_reg_addr,
7+
_In_ uint32_t number_of_registers,
8+
_Out_ uint32_t *reg_val)
9+
{
10+
SWSS_LOG_ENTER();
11+
12+
return SAI_STATUS_NOT_IMPLEMENTED;
13+
}
14+
15+
sai_status_t redis_switch_mdio_write(
16+
_In_ sai_object_id_t switch_id,
17+
_In_ uint32_t device_addr,
18+
_In_ uint32_t start_reg_addr,
19+
_In_ uint32_t number_of_registers,
20+
_In_ const uint32_t *reg_val)
21+
{
22+
SWSS_LOG_ENTER();
23+
24+
return SAI_STATUS_NOT_IMPLEMENTED;
25+
}
26+
327
REDIS_GENERIC_QUAD(SWITCH,switch);
428
REDIS_GENERIC_STATS(SWITCH,switch);
529

syncd/SaiSwitch.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,19 @@ SaiSwitch::SaiSwitch(
5959

6060
helperInternalOids();
6161

62-
helperCheckLaneMap();
62+
if (getSwitchType() == SAI_SWITCH_TYPE_NPU)
63+
{
64+
helperCheckLaneMap();
65+
}
6366

6467
helperLoadColdVids();
6568

6669
helperPopulateWarmBootVids();
6770

68-
saiGetMacAddress(m_default_mac_address);
71+
if (getSwitchType() == SAI_SWITCH_TYPE_NPU)
72+
{
73+
saiGetMacAddress(m_default_mac_address);
74+
}
6975

7076
if (warmBoot)
7177
{
@@ -131,6 +137,26 @@ void SaiSwitch::getDefaultMacAddress(
131137
memcpy(mac, m_default_mac_address, sizeof(sai_mac_t));
132138
}
133139

140+
sai_switch_type_t SaiSwitch::getSwitchType() const
141+
{
142+
SWSS_LOG_ENTER();
143+
144+
sai_attribute_t attr;
145+
146+
attr.id = SAI_SWITCH_ATTR_TYPE;
147+
148+
sai_status_t status = m_vendorSai->get(SAI_OBJECT_TYPE_SWITCH, m_switch_rid, 1, &attr);
149+
150+
if (status != SAI_STATUS_SUCCESS)
151+
{
152+
SWSS_LOG_THROW("failed to get switch type");
153+
}
154+
155+
SWSS_LOG_ERROR("switch type: '%s'", (attr.value.s32 == SAI_SWITCH_TYPE_NPU ? "SAI_SWITCH_TYPE_NPU" : "SAI_SWITCH_TYPE_PHY"));
156+
157+
return (sai_switch_type_t) attr.value.s32;
158+
}
159+
134160
#define MAX_HARDWARE_INFO_LENGTH 0x1000
135161

136162
std::string SaiSwitch::saiGetHardwareInfo() const
@@ -885,7 +911,7 @@ void SaiSwitch::helperPopulateWarmBootVids()
885911
{
886912
sai_object_id_t vid = m_translator->translateRidToVid(rid, m_switch_vid);
887913

888-
m_warmBootDiscoveredVids.insert(vid);
914+
m_warmBootDiscoveredVids.insert(vid);
889915
}
890916
}
891917

syncd/SaiSwitch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace syncd
4141
sai_object_id_t getVid() const;
4242
sai_object_id_t getRid() const;
4343

44+
sai_switch_type_t getSwitchType() const;
4445
std::string getHardwareInfo() const;
4546

4647
std::unordered_map<sai_object_id_t, sai_object_id_t> getVidToRidMap() const;

syncd/scripts/physyncd_start.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Script to start syncd using supervisord
4+
#
5+
6+
exec "/usr/bin/physyncd_startup.py"
7+

syncd/scripts/physyncd_startup.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/python
2+
3+
'''
4+
Copyright 2019 Broadcom. The term "Broadcom" refers to Broadcom Inc.
5+
and/or its subsidiaries.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
'''
19+
import os
20+
import json
21+
import subprocess
22+
23+
24+
def physyncd_enable(gearbox_config):
25+
i = 1
26+
for phy in gearbox_config['phys']:
27+
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)
28+
i += 1
29+
30+
def main():
31+
32+
# Only privileged users can execute this command
33+
if os.geteuid() != 0:
34+
sys.exit("Root privileges required for this operation")
35+
36+
""" Loads json file """
37+
try:
38+
with open('/usr/share/sonic/hwsku/gearbox_config.json') as file_object:
39+
gearbox_config=json.load(file_object)
40+
except:
41+
sys.exit("No external PHY / gearbox supported on this platform, existing physycd application")
42+
43+
physyncd_enable(gearbox_config)
44+
45+
46+
if __name__== "__main__":
47+
main()
48+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)