Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e0870a7
Add support as9716 platform
jostar-yang Jun 12, 2019
b580e8a
Merge branch 'master' of https://github.com/jostar-yang/sonic-buildimage
jostar-yang Jun 12, 2019
7973485
remove as9716
jostar-yang Jun 12, 2019
78f4fc3
remove as9716 needed mk
jostar-yang Jun 12, 2019
8a6c679
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jun 17, 2019
f7826e3
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jun 20, 2019
94006a5
Add to support as9716 platform
jostar-yang Jul 17, 2019
a893a68
Add support build as9716 platform to mk file
jostar-yang Jul 17, 2019
4c21d0a
Add support AS5835_54T platform
jostar-yang Jul 17, 2019
f3220df
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jul 19, 2019
2e2b8ac
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Aug 5, 2019
c517556
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Sep 5, 2019
5ded80f
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Sep 11, 2019
e9aba06
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Sep 25, 2019
c148f54
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Oct 25, 2019
fa793e0
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jan 6, 2020
48a537c
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Jan 7, 2020
531f583
Merge branch 'master' of https://github.com/Azure/sonic-buildimage
jostar-yang Mar 5, 2020
9002b0f
Merge remote-tracking branch 'upstream/master'
Apr 8, 2021
8e4a74c
[as9716-32d] Add to support PDDF
Feb 26, 2021
ba07f2c
[as9716-32d] Fix LGTM alerts and add new files
Feb 26, 2021
2d9013c
[as9716-32d] Modify sonic_platform to support py3
Mar 2, 2021
21b257e
Modify thermal plan to support py3 and modify json file for mux
Mar 8, 2021
6fe6411
[as9716-32d] Fix LGTM alerts
Mar 8, 2021
c7db096
[as9716-32d] Add get_change_evt function
Mar 17, 2021
1bb73f3
[as9716-32d] use presence bit instead of interrupt_status bit
Mar 22, 2021
48659a6
Modify control file for error line
Apr 9, 2021
e1887b7
Fix pddf_util.py conflict issue
Apr 9, 2021
eecfe64
Fix pddf_util.py conflict
Apr 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions device/accton/x86_64-accton_as9716_32d-r0/pddf/pd-plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{

"XCVR":
{
"xcvr_present":
{
"i2c":
{
"valmap-SFP28": {"1":true, "0":false },
"valmap-QSFP28": {"1":true, "0":false}
}
}
},
"PSU":
{
"psu_present":
{
"i2c":
{
"valmap": { "1":true, "0":false }
}
},

"psu_power_good":
{
"i2c":
{
"valmap": { "1": true, "0":false }
}
},

"psu_fan_dir":
{
"i2c":
{
"valmap": { "F2B":"EXHAUST", "B2F":"INTAKE" }
}
},

"PSU_FAN_MAX_SPEED":"18000"
},

"FAN":
{
"direction":
{
"i2c":
{
"valmap": {"1":"INTAKE", "0":"EXHAUST"}
}
},

"present":
{
"i2c":
{
"valmap": {"1":true, "0":false}
}
},

"duty_cycle_to_pwm": "lambda dc: ((dc*100)/625 - 1)",

"pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625)/100)"
}

}
1,948 changes: 1,948 additions & 0 deletions device/accton/x86_64-accton_as9716_32d-r0/pddf/pddf-device.json

Large diffs are not rendered by default.

Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ifneq ($(KERNELRELEASE),)
obj-m:= accton_as9716_32d_cpld.o accton_as9716_32d_fan.o \
accton_as9716_32d_leds.o accton_as9716_32d_psu.o accton_i2c_psu.o
accton_as9716_32d_leds.o accton_as9716_32d_psu.o accton_i2c_psu.o \
pddf_custom_psu.o

else
ifeq (,$(KERNEL_SRC))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#include <linux/module.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
#include <linux/slab.h>
#include <linux/dmi.h>
#include "../../../../pddf/i2c/modules/include/pddf_psu_defs.h"

ssize_t pddf_show_custom_psu_v_out(struct device *dev, struct device_attribute *da, char *buf);
extern PSU_SYSFS_ATTR_DATA access_psu_v_out;

static int two_complement_to_int(u16 data, u8 valid_bit, int mask)
{
u16 valid_data = data & mask;
bool is_negative = valid_data >> (valid_bit - 1);

return is_negative ? (-(((~valid_data) & mask) + 1)) : valid_data;
}

static u8 psu_get_vout_mode(struct i2c_client *client)
{
u8 status = 0, retry = 10;
uint8_t offset = 0x20; // VOUT_MODE

while (retry) {
status = i2c_smbus_read_byte_data((struct i2c_client *)client, offset);
if (unlikely(status < 0)) {
msleep(60);
retry--;
continue;
}
break;
}

if (status < 0)
{
printk(KERN_ERR "%s: Get PSU Vout mode failed\n", __func__);
return 0;
}
else
{
/*printk(KERN_ERR "%s: vout_mode reg value 0x%x\n", __func__, status);*/
return status;
}
}

static u16 psu_get_v_out(struct i2c_client *client)
{
u16 status = 0, retry = 10;
uint8_t offset = 0x8b; // READ_VOUT

while (retry) {
status = i2c_smbus_read_word_data((struct i2c_client *)client, offset);
if (unlikely(status < 0)) {
msleep(60);
retry--;
continue;
}
break;
}

if (status < 0)
{
printk(KERN_ERR "%s: Get PSU Vout failed\n", __func__);
return 0;
}
else
{
/*printk(KERN_ERR "%s: vout reg value 0x%x\n", __func__, status);*/
return status;
}
}

ssize_t pddf_show_custom_psu_v_out(struct device *dev, struct device_attribute *da, char *buf)
{
struct i2c_client *client = to_i2c_client(dev);
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
int exponent, mantissa;
int multiplier = 1000;

u16 value = psu_get_v_out(client);
u8 vout_mode = psu_get_vout_mode(client);

if ((vout_mode >> 5) == 0)
exponent = two_complement_to_int(vout_mode & 0x1f, 5, 0x1f);
else
{
printk(KERN_ERR "%s: Only support linear mode for vout mode\n", __func__);
exponent = 0;
}
mantissa = value;
if (exponent >= 0)
return sprintf(buf, "%d\n", (mantissa << exponent) * multiplier);
else
return sprintf(buf, "%d\n", (mantissa * multiplier) / (1 << -exponent));
}



static int __init pddf_custom_psu_init(void)
{
access_psu_v_out.show = pddf_show_custom_psu_v_out;
access_psu_v_out.do_get = NULL;
printk(KERN_ERR "pddf_custom_psu_init\n");
return 0;
}

static void __exit pddf_custom_psu_exit(void)
{
printk(KERN_ERR "pddf_custom_psu_exit\n");
return;
}

MODULE_AUTHOR("Broadcom");
MODULE_DESCRIPTION("pddf custom psu api");
MODULE_LICENSE("GPL");

module_init(pddf_custom_psu_init);
module_exit(pddf_custom_psu_exit);

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Accton AS9716-32D Platform Monitoring service
Before=pmon.service
After=pddf-platform-init.service
DefaultDependencies=no

[Service]
ExecStart=/usr/local/bin/accton_as9716_32d_pddf_monitor.py
KillSignal=SIGKILL
SuccessExitStatus=SIGKILL

# Resource Limitations
LimitCORE=infinity

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# All the derived classes for PDDF
__all__ = ["platform", "chassis", "sfp", "psu", "thermal", "fan"]
from . import platform

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python

#############################################################################
# PDDF
# Module contains an implementation of SONiC Chassis API
#
#############################################################################

try:
import time
from sonic_platform_pddf_base.pddf_chassis import PddfChassis
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


class Chassis(PddfChassis):
"""
PDDF Platform-specific Chassis class
"""

def __init__(self, pddf_data=None, pddf_plugin_data=None):
PddfChassis.__init__(self, pddf_data, pddf_plugin_data)

# Provide the functions/variables below for which implementation is to be overwritten
sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0}
def get_change_event(self, timeout=2000):
now = time.time()
port_dict = {}
change_dict = {}
change_dict['sfp'] = port_dict

if timeout < 1000:
timeout = 1000
timeout = timeout / float(1000) # Convert to secs

if now < (self.sfp_change_event_data['last'] + timeout) and self.sfp_change_event_data['valid']:
return True, change_dict

bitmap = 0
for i in range(34):
modpres = self.get_sfp(i).get_presence()
if modpres:
bitmap = bitmap | (1 << i)

changed_ports = self.sfp_change_event_data['present'] ^ bitmap
if changed_ports:
for i in range(34):
if (changed_ports & (1 << i)):
if (bitmap & (1 << i)) == 0:
port_dict[i+1] = '0'
else:
port_dict[i+1] = '1'


# Update teh cache dict
self.sfp_change_event_data['present'] = bitmap
self.sfp_change_event_data['last'] = now
self.sfp_change_event_data['valid'] = 1
return True, change_dict
else:
return True, change_dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python

try:
from sonic_platform_pddf_base.pddf_eeprom import PddfEeprom
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


class Eeprom(PddfEeprom):

def __init__(self, pddf_data=None, pddf_plugin_data=None):
PddfEeprom.__init__(self, pddf_data, pddf_plugin_data)

# Provide the functions/variables below for which implementation is to be overwritten
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python


try:
from sonic_platform_pddf_base.pddf_fan import PddfFan
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


class Fan(PddfFan):
"""PDDF Platform-Specific Fan class"""

def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, is_psu_fan=False, psu_index=0):
# idx is 0-based
PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index)

# Provide the functions/variables below for which implementation is to be overwritten
# Since psu_fan airflow direction cant be read from sysfs, it is fixed as 'F2B' or 'intake'
def get_direction(self):
"""
Retrieves the direction of fan

Returns:
A string, either FAN_DIRECTION_INTAKE or FAN_DIRECTION_EXHAUST
depending on fan direction
"""
if self.is_psu_fan:
direction = self.FAN_DIRECTION_EXHAUST

else:
idx = (self.fantray_index-1)*self.platform['num_fans_pertray'] + self.fan_index
attr = "fan" + str(idx) + "_direction"
output = self.pddf_obj.get_attr_name_output("FAN-CTRL", attr)
if not output:
return False

mode = output['mode']
val = output['status']

val = val.rstrip()
vmap = self.plugin_data['FAN']['direction'][mode]['valmap']
if val in vmap:
direction = vmap[val]
else:
direction = val

return direction

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python

#############################################################################
# PDDF
# Module contains an implementation of SONiC Platform Base API and
# provides the platform information
#
#############################################################################


try:
from sonic_platform_pddf_base.pddf_platform import PddfPlatform
except ImportError as e:
raise ImportError(str(e) + "- required module not found")


class Platform(PddfPlatform):
"""
PDDF Platform-Specific Platform Class
"""

def __init__(self):
PddfPlatform.__init__(self)

# Provide the functions/variables below for which implementation is to be overwritten
Loading