Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 6b7d777

Browse files
authored
Merge pull request #4 from Azure/master
sync from Azure to Project-arlo
2 parents 23c4b77 + b92d980 commit 6b7d777

File tree

139 files changed

+1920
-2430
lines changed

Some content is hidden

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

139 files changed

+1920
-2430
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# OS-generated files
2+
.DS_Store
3+
14
# Build system related
25
.platform
36
.screen

Makefile.work

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ SLAVE_IMAGE = sonic-slave-$(USER)
6161
SLAVE_DIR = sonic-slave
6262
endif
6363

64-
OVERLAY_MODULE_CHECK := lsmod | grep "^overlay " > /dev/null 2>&1 || (echo "ERROR: Module 'overlay' not loaded. Try running 'sudo modprobe overlay'."; exit 1)
64+
OVERLAY_MODULE_CHECK := \
65+
lsmod | grep -q "^overlay " &>/dev/null || \
66+
zgrep -q 'CONFIG_OVERLAY_FS=y' /proc/config.gz &>/dev/null || \
67+
grep -q 'CONFIG_OVERLAY_FS=y' /boot/config-$(shell uname -r) &>/dev/null || \
68+
(echo "ERROR: Module 'overlay' not loaded. Try running 'sudo modprobe overlay'."; exit 1)
6569

6670
BUILD_TIMESTAMP := $(shell date +%Y%m%d\.%H%M%S)
6771

@@ -117,6 +121,7 @@ SONIC_BUILD_INSTRUCTION := make \
117121
PASSWORD=$(PASSWORD) \
118122
USERNAME=$(USERNAME) \
119123
SONIC_BUILD_JOBS=$(SONIC_BUILD_JOBS) \
124+
SONIC_USE_DOCKER_BUILDKIT=$(SONIC_USE_DOCKER_BUILDKIT) \
120125
VS_PREPARE_MEM=$(VS_PREPARE_MEM) \
121126
KERNEL_PROCURE_METHOD=$(KERNEL_PROCURE_METHOD) \
122127
HTTP_PROXY=$(http_proxy) \

build_debian.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ set -x -e
3030

3131
## docker engine version (with platform)
3232
DOCKER_VERSION=5:18.09.2~3-0~debian-stretch
33-
LINUX_KERNEL_VERSION=4.9.0-8-2
33+
LINUX_KERNEL_VERSION=4.9.0-9-2
3434

3535
## Working directory to prepare the file system
3636
FILESYSTEM_ROOT=./fsroot
@@ -121,7 +121,7 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/initramfs-tools_*.deb || \
121121
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/linux-image-${LINUX_KERNEL_VERSION}-amd64_*.deb || \
122122
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install -f
123123
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install acl
124-
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install dmidecode
124+
sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install dmidecode
125125

126126
## Update initramfs for booting with squashfs+overlay
127127
cat files/initramfs-tools/modules | sudo tee -a $FILESYSTEM_ROOT/etc/initramfs-tools/modules > /dev/null
@@ -409,7 +409,7 @@ fi
409409
## Organization specific extensions such as Configuration & Scripts for features like AAA, ZTP...
410410
if [ "${enable_organization_extensions}" = "y" ]; then
411411
if [ -f files/build_templates/organization_extensions.sh ]; then
412-
sudo chmod 755 files/build_templates/organization_extensions.sh
412+
sudo chmod 755 files/build_templates/organization_extensions.sh
413413
./files/build_templates/organization_extensions.sh -f $FILESYSTEM_ROOT -h $HOSTNAME
414414
fi
415415
fi

device/accton/x86_64-accton_as7726_32x-r0/plugins/sfputil.py

+59-5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
try:
77
import time
8+
import string
9+
from ctypes import create_string_buffer
810
from sonic_sfp.sfputilbase import SfpUtilBase
911
except ImportError as e:
1012
raise ImportError("%s - required module not found" % str(e))
@@ -110,11 +112,63 @@ def get_presence(self, port_num):
110112

111113
return False
112114

113-
def get_low_power_mode(self, port_num):
114-
raise NotImplementedError
115-
116-
def set_low_power_mode(self, port_num, lpmode):
117-
raise NotImplementedError
115+
def get_low_power_mode(self, port_num):
116+
# Check for invalid port_num
117+
if port_num < self.port_start or port_num > self.port_end:
118+
return False
119+
120+
try:
121+
eeprom = None
122+
123+
if not self.get_presence(port_num):
124+
return False
125+
126+
eeprom = open(self.port_to_eeprom_mapping[port_num], "rb")
127+
eeprom.seek(93)
128+
lpmode = ord(eeprom.read(1))
129+
130+
if ((lpmode & 0x3) == 0x3):
131+
return True # Low Power Mode if "Power override" bit is 1 and "Power set" bit is 1
132+
else:
133+
return False # High Power Mode if one of the following conditions is matched:
134+
# 1. "Power override" bit is 0
135+
# 2. "Power override" bit is 1 and "Power set" bit is 0
136+
except IOError as e:
137+
print "Error: unable to open file: %s" % str(e)
138+
return False
139+
finally:
140+
if eeprom is not None:
141+
eeprom.close()
142+
time.sleep(0.01)
143+
144+
def set_low_power_mode(self, port_num, lpmode):
145+
# Check for invalid port_num
146+
if port_num < self.port_start or port_num > self.port_end:
147+
return False
148+
149+
try:
150+
eeprom = None
151+
152+
if not self.get_presence(port_num):
153+
return False # Port is not present, unable to set the eeprom
154+
155+
# Fill in write buffer
156+
regval = 0x3 if lpmode else 0x1 # 0x3:Low Power Mode, 0x1:High Power Mode
157+
buffer = create_string_buffer(1)
158+
buffer[0] = chr(regval)
159+
160+
# Write to eeprom
161+
eeprom = open(self.port_to_eeprom_mapping[port_num], "r+b")
162+
eeprom.seek(93)
163+
eeprom.write(buffer[0])
164+
return True
165+
except IOError as e:
166+
print "Error: unable to open file: %s" % str(e)
167+
return False
168+
finally:
169+
if eeprom is not None:
170+
eeprom.close()
171+
time.sleep(0.01)
118172

119173
def reset(self, port_num):
120174
if port_num < self.port_start or port_num > self.port_end:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"instance": 0,
3+
"chip_list": [
4+
{
5+
"id": "asic-0",
6+
"chip_family": "Tofino",
7+
"instance": 0,
8+
"pcie_sysfs_prefix": "/sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0",
9+
"pcie_domain": 0,
10+
"pcie_bus": 5,
11+
"pcie_fn": 0,
12+
"pcie_dev": 0,
13+
"pcie_int_mode": 1,
14+
"sds_fw_path": "share/tofino_sds_fw/avago/firmware"
15+
}
16+
],
17+
"p4_devices": [
18+
{
19+
"device-id": 0,
20+
"p4_programs": [
21+
{
22+
"p4_pipelines": [
23+
{
24+
"p4_pipeline_name": "pipe",
25+
"config": "share/tofinopd/switch/pipe/tofino.bin",
26+
"context": "share/tofinopd/switch/pipe/context.json"
27+
}
28+
],
29+
"program-name": "switch",
30+
"switchsai": "lib/libswitchsai.so",
31+
"bfrt-config": "share/tofinopd/switch/bf-rt.json",
32+
"model_json_path" : "share/switch/aug_model.json",
33+
"switchapi_port_add": false,
34+
"non_default_port_ppgs": 5
35+
}
36+
]
37+
}
38+
]
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"instance": 0,
3+
"chip_list": [
4+
{
5+
"id": "asic-0",
6+
"chip_family": "Tofino",
7+
"instance": 0,
8+
"pcie_sysfs_prefix": "/sys/devices/pci0000:00/0000:00:03.0/0000:05:00.0",
9+
"pcie_domain": 0,
10+
"pcie_bus": 5,
11+
"pcie_fn": 0,
12+
"pcie_dev": 0,
13+
"pcie_int_mode": 1,
14+
"sds_fw_path": "share/tofino_sds_fw/avago/firmware"
15+
}
16+
],
17+
"p4_devices": [
18+
{
19+
"device-id": 0,
20+
"p4_programs": [
21+
{
22+
"p4_pipelines": [
23+
{
24+
"p4_pipeline_name": "pipe",
25+
"config": "share/tofinopd/switch/pipe/tofino.bin",
26+
"context": "share/tofinopd/switch/pipe/context.json"
27+
}
28+
],
29+
"program-name": "switch",
30+
"switchsai": "lib/libswitchsai.so",
31+
"bfrt-config": "share/tofinopd/switch/bf-rt.json",
32+
"model_json_path" : "share/switch/aug_model.json",
33+
"switchapi_port_add": false,
34+
"non_default_port_ppgs": 5
35+
}
36+
]
37+
}
38+
]
39+
}

device/celestica/x86_64-cel_e1031-r0/sonic_platform/chassis.py

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
try:
1818
from sonic_platform_base.chassis_base import ChassisBase
1919
from sonic_platform.fan import Fan
20+
from sonic_platform.psu import Psu
2021
except ImportError as e:
2122
raise ImportError(str(e) + "- required module not found")
2223

@@ -26,6 +27,7 @@
2627
SMC_CPLD_PATH = "/sys/devices/platform/e1031.smc/version"
2728
MMC_CPLD_PATH = "/sys/devices/platform/e1031.smc/getreg"
2829
NUM_FAN = 3
30+
NUM_PSU = 2
2931

3032

3133
class Chassis(ChassisBase):
@@ -36,6 +38,9 @@ def __init__(self):
3638
for index in range(0, NUM_FAN):
3739
fan = Fan(index)
3840
self._fan_list.append(fan)
41+
for index in range(0, NUM_PSU):
42+
psu = Psu(index)
43+
self._psu_list.append(psu)
3944
ChassisBase.__init__(self)
4045

4146
def __get_register_value(self, path, register):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
3+
#############################################################################
4+
# Celestica
5+
#
6+
# Module contains an implementation of SONiC Platform Base API and
7+
# provides the PSUs status which are available in the platform
8+
#
9+
#############################################################################
10+
11+
import os.path
12+
import sonic_platform
13+
14+
try:
15+
from sonic_platform_base.psu_base import PsuBase
16+
from sonic_platform.fan import Fan
17+
except ImportError as e:
18+
raise ImportError(str(e) + "- required module not found")
19+
20+
FAN_E1031_SPEED_PATH = "/sys/class/hwmon/hwmon{}/fan1_input"
21+
FAN_MAX_RPM = 11000
22+
23+
24+
class Psu(PsuBase):
25+
"""Platform-specific Psu class"""
26+
27+
def __init__(self, psu_index):
28+
PsuBase.__init__(self)
29+
self.index = psu_index
30+
31+
def get_fan(self):
32+
"""
33+
Retrieves object representing the fan module contained in this PSU
34+
Returns:
35+
An object dervied from FanBase representing the fan module
36+
contained in this PSU
37+
"""
38+
fan_speed_path = FAN_E1031_SPEED_PATH.format(
39+
str(self.index+3))
40+
try:
41+
with open(fan_speed_path) as fan_speed_file:
42+
fan_speed_rpm = int(fan_speed_file.read())
43+
except IOError:
44+
fan_speed = 0
45+
46+
fan_speed = float(fan_speed_rpm)/FAN_MAX_RPM * 100
47+
fan = Fan(0)
48+
fan.fan_speed = int(fan_speed) if int(fan_speed) <= 100 else 100
49+
return fan
50+
51+
def set_status_led(self, color):
52+
"""
53+
Sets the state of the PSU status LED
54+
Args:
55+
color: A string representing the color with which to set the PSU status LED
56+
Note: Only support green and off
57+
Returns:
58+
bool: True if status LED state is set successfully, False if not
59+
"""
60+
# Hardware not supported
61+
return False

device/celestica/x86_64-cel_seastone-r0/sonic_platform/chassis.py

+5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
try:
1818
from sonic_platform_base.chassis_base import ChassisBase
1919
from sonic_platform.fan import Fan
20+
from sonic_platform.psu import Psu
2021
except ImportError as e:
2122
raise ImportError(str(e) + "- required module not found")
2223

2324
BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version"
2425
GETREG_PATH = "/sys/devices/platform/dx010_cpld/getreg"
2526
CONFIG_DB_PATH = "/etc/sonic/config_db.json"
2627
NUM_FAN = 5
28+
NUM_PSU = 2
2729
CPLD_ADDR_MAPPING = {
2830
"CPLD1": "0x100",
2931
"CPLD2": "0x200",
@@ -41,6 +43,9 @@ def __init__(self):
4143
for index in range(0, NUM_FAN):
4244
fan = Fan(index)
4345
self._fan_list.append(fan)
46+
for index in range(0, NUM_PSU):
47+
psu = Psu(index)
48+
self._psu_list.append(psu)
4449
ChassisBase.__init__(self)
4550

4651
def __get_register_value(self, path, register):

0 commit comments

Comments
 (0)