[devices]: DellEMC [s5232]: PSU detection and default led state support (#3185)
* [devices]: Add a new supported device DellEMC s5232f * Switch Vendor: DellEMC * Switch SKU: s5232F * ASIC Vendor: Broadcom * Swich ASIC: Trident3 * Port Configuration: 32x100G * SONiC Image: sonic-broadcom.bin * LED support for s5232f * Changes Include ipmitool implementation for platform_sensors script is inclued in pmon startup * Added 100G,25G,10G configruation ( 100G is default). * s5232[device] PSU detecttion and default led state support
This commit is contained in:
parent
6c4ec396ba
commit
ce5d16f858
@ -7,11 +7,13 @@
|
|||||||
import os.path
|
import os.path
|
||||||
import logging
|
import logging
|
||||||
import commands
|
import commands
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
S5232F_MAX_PSUS = 2
|
S5232F_MAX_PSUS = 2
|
||||||
IPMI_SENSOR_DATA = "docker exec -it pmon ipmitool sdr list"
|
IPMI_PSU_DATA = "docker exec -it pmon ipmitool sdr list"
|
||||||
PSU_PRESENCE = "PSU{0}_state"
|
IPMI_PSU_DATA_DOCKER = "ipmitool sdr list"
|
||||||
|
PSU_PRESENCE = "PSU{0}_stat"
|
||||||
# Use this for older firmware
|
# Use this for older firmware
|
||||||
# PSU_PRESENCE="PSU{0}_prsnt"
|
# PSU_PRESENCE="PSU{0}_prsnt"
|
||||||
ipmi_sdr_list = ""
|
ipmi_sdr_list = ""
|
||||||
@ -29,14 +31,24 @@ class PsuUtil(PsuBase):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
PsuBase.__init__(self)
|
PsuBase.__init__(self)
|
||||||
|
|
||||||
|
def isDockerEnv(self):
|
||||||
|
num_docker = open('/proc/self/cgroup', 'r').read().count(":/docker")
|
||||||
|
if num_docker > 0:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
# Fetch a BMC register
|
# Fetch a BMC register
|
||||||
def get_pmc_register(self, reg_name):
|
def get_pmc_register(self, reg_name):
|
||||||
|
|
||||||
status = 1
|
status = 1
|
||||||
global ipmi_sdr_list
|
global ipmi_sdr_list
|
||||||
ipmi_dev_node = "/dev/pmi0"
|
ipmi_dev_node = "/dev/pmi0"
|
||||||
|
ipmi_cmd = IPMI_PSU_DATA
|
||||||
|
dockerenv = self.isDockerEnv()
|
||||||
|
if dockerenv == True:
|
||||||
|
ipmi_cmd = IPMI_PSU_DATA_DOCKER
|
||||||
|
|
||||||
ipmi_cmd = IPMI_SENSOR_DATA
|
|
||||||
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
|
status, ipmi_sdr_list = commands.getstatusoutput(ipmi_cmd)
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
@ -48,7 +60,7 @@ class PsuUtil(PsuBase):
|
|||||||
output = item.strip()
|
output = item.strip()
|
||||||
|
|
||||||
if not output:
|
if not output:
|
||||||
print('\nFailed to fetch: ' + reg_name + ' sensor ')
|
print('\nFailed to fetch: ' + reg_name + ' sensor ')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
output = output.split('|')[1]
|
output = output.split('|')[1]
|
||||||
@ -56,8 +68,6 @@ class PsuUtil(PsuBase):
|
|||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_num_psus(self):
|
def get_num_psus(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the number of PSUs available on the device
|
Retrieves the number of PSUs available on the device
|
||||||
@ -74,11 +84,10 @@ class PsuUtil(PsuBase):
|
|||||||
:return: Boolean, True if PSU is operating properly, False if PSU is\
|
:return: Boolean, True if PSU is operating properly, False if PSU is\
|
||||||
faulty
|
faulty
|
||||||
"""
|
"""
|
||||||
#Until psu_status is implemented this is hardcoded temporarily
|
# Until psu_status is implemented this is hardcoded temporarily
|
||||||
|
|
||||||
status = 1
|
status = 1
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
|
||||||
def get_psu_presence(self, index):
|
def get_psu_presence(self, index):
|
||||||
"""
|
"""
|
||||||
@ -89,9 +98,10 @@ class PsuUtil(PsuBase):
|
|||||||
"""
|
"""
|
||||||
status = 0
|
status = 0
|
||||||
psu_reg_name = PSU_PRESENCE.format(index)
|
psu_reg_name = PSU_PRESENCE.format(index)
|
||||||
psu_status = int(self.get_pmc_register(psu_reg_name),16)
|
psu_status = int(self.get_pmc_register(psu_reg_name), 16)
|
||||||
if (psu_status != 'ERR'):
|
if (psu_status != 'ERR'):
|
||||||
# Check for PSU presence
|
# Check for PSU presence
|
||||||
if (psu_status):
|
if (psu_status == 0x00):
|
||||||
status = 1
|
status = 1
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
@ -85,6 +85,12 @@ switch_board_modsel() {
|
|||||||
python /usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
|
python /usr/bin/pcisysfs.py --set --offset $hex --val 0x10 --res $resource > /dev/null 2>&1
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#This enables the led control for CPU and default states
|
||||||
|
switch_board_led_default() {
|
||||||
|
resource="/sys/bus/pci/devices/0000:04:00.0/resource0"
|
||||||
|
python /usr/bin/pcisysfs.py --set --offset 0x24 --val 0x194 --res $resource > /dev/null 2>&1
|
||||||
|
}
|
||||||
init_devnum
|
init_devnum
|
||||||
|
|
||||||
if [ "$1" == "init" ]; then
|
if [ "$1" == "init" ]; then
|
||||||
@ -98,6 +104,7 @@ if [ "$1" == "init" ]; then
|
|||||||
switch_board_qsfp_mux "new_device"
|
switch_board_qsfp_mux "new_device"
|
||||||
switch_board_qsfp "new_device"
|
switch_board_qsfp "new_device"
|
||||||
switch_board_modsel
|
switch_board_modsel
|
||||||
|
switch_board_led_default
|
||||||
python /usr/bin/qsfp_irq_enable.py
|
python /usr/bin/qsfp_irq_enable.py
|
||||||
|
|
||||||
elif [ "$1" == "deinit" ]; then
|
elif [ "$1" == "deinit" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user