Skip to content

Commit

Permalink
[DellEMC S5232f] Updates and bug fixes for platform
Browse files Browse the repository at this point in the history
  * Fix platform sensors
  * fpga driver update for bug fixes
  * Update fixes for API 2.0 code
  • Loading branch information
srideepDell committed Nov 10, 2020
1 parent ad2e18e commit d472dd2
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 166 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"skip_ledd": true,
"skip_thermalctld": true
"skip_ledd": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ struct fpgapci_dev {
unsigned int irq_first;
unsigned int irq_length;
unsigned int irq_assigned;
unsigned int xcvr_intr_count;
};

static int use_irq = 1;
Expand Down Expand Up @@ -227,13 +226,6 @@ enum {
#define I2C_PCI_BUS_NUM_12 12
#define I2C_PCI_BUS_NUM_16 16

#define IRQ_LTCH_STS 0x20
#define PRSNT_LTCH_STS 0x10

#define PORT_CTRL_OFFSET 0x4000
#define PORT_STS_OFFSET 0x4004
#define PORT_IRQ_STS_OFFSET 0x4008
#define PORT_IRQ_EN_OFFSET 0x400C
#define MB_BRD_REV_TYPE 0x0008
#define MB_BRD_REV_MASK 0x00f0
#define MB_BRD_REV_00 0x0000
Expand Down Expand Up @@ -292,8 +284,6 @@ enum {
#define MSI_VECTOR_REV_00 16
#define MSI_VECTOR_REV_01 32

#define FPGA_MSI_VECTOR_ID_4 4
#define FPGA_MSI_VECTOR_ID_5 5
#define FPGA_MSI_VECTOR_ID_8 8
#define FPGA_MSI_VECTOR_ID_9 9
#define FPGA_MSI_VECTOR_ID_10 10
Expand Down Expand Up @@ -516,72 +506,6 @@ static int fpgai2c_poll(struct fpgalogic_i2c *i2c)
return 0;
}

static ssize_t get_mod_msi(struct device *dev, struct device_attribute *devattr, char *buf)
{
int ind = 0, port_status=0, port_irq_status=0;
struct fpgapci_dev *fpgapci = (struct fpgapci_dev*) dev_get_drvdata(dev);
PRINT("%s:xcvr_intr_count:%u\n", __FUNCTION__, fpgapci->xcvr_intr_count);
for(ind=0;ind<64;ind++)
{
port_status = ioread32(fpga_ctl_addr + PORT_STS_OFFSET + (ind*16));
port_irq_status = ioread32(fpga_ctl_addr + PORT_IRQ_STS_OFFSET + (ind*16));
PRINT("%s:port:%d, port_status:%#x, port_irq_status:%#x\n", __FUNCTION__, ind, port_status, port_irq_status);
}
return sprintf(buf,"0x%04x\n",fpgapci->xcvr_intr_count);
}
static DEVICE_ATTR(port_msi, S_IRUGO, get_mod_msi, NULL);

static struct attribute *port_attrs[] = {
&dev_attr_port_msi.attr,
NULL,
};

static struct attribute_group port_attr_grp = {
.attrs = port_attrs,
};


static irqreturn_t fpgaport_1_32_isr(int irq, void *dev)
{
struct pci_dev *pdev = dev;
struct fpgapci_dev *fpgapci = (struct fpgapci_dev*) dev_get_drvdata(&pdev->dev);
int ind = 0, port_status=0, port_irq_status=0;
for(ind=0;ind<32;ind++)
{
port_irq_status = ioread32(fpga_ctl_addr + PORT_IRQ_STS_OFFSET + (ind*16));
if(port_irq_status&(IRQ_LTCH_STS|PRSNT_LTCH_STS))
{
PRINT("%s:port:%d, port_status:%#x, port_irq_status:%#x\n", __FUNCTION__, ind, port_status, port_irq_status);
//write on clear
iowrite32( IRQ_LTCH_STS|PRSNT_LTCH_STS,fpga_ctl_addr + PORT_IRQ_STS_OFFSET + (ind*16));
}
}
fpgapci->xcvr_intr_count++;
PRINT("%s: xcvr_intr_count:%u\n", __FUNCTION__, fpgapci->xcvr_intr_count);
sysfs_notify(&pdev->dev.kobj, NULL, "port_msi");
return IRQ_HANDLED;
}

static irqreturn_t fpgaport_33_64_isr(int irq, void *dev)
{
struct pci_dev *pdev = dev;
struct fpgapci_dev *fpgapci = (struct fpgapci_dev*) dev_get_drvdata(&pdev->dev);
int ind = 0, port_status=0, port_irq_status=0;
for(ind=32;ind<64;ind++)
{
port_irq_status = ioread32(fpga_ctl_addr + PORT_IRQ_STS_OFFSET + (ind*16));
if(port_irq_status| (IRQ_LTCH_STS|PRSNT_LTCH_STS))
{
PRINT("%s:port:%d, port_status:%#x, port_irq_status:%#x\n", __FUNCTION__, ind, port_status, port_irq_status);
iowrite32( IRQ_LTCH_STS|PRSNT_LTCH_STS,fpga_ctl_addr + PORT_IRQ_STS_OFFSET + (ind*16));
}
}
fpgapci->xcvr_intr_count++;
PRINT("%s: xcvr_intr_count:%u\n", __FUNCTION__, fpgapci->xcvr_intr_count);
sysfs_notify(&pdev->dev.kobj, NULL, "port_msi");
return IRQ_HANDLED;
}

static void fpgai2c_process(struct fpgalogic_i2c *i2c)
{
struct i2c_msg *msg = i2c->msg;
Expand Down Expand Up @@ -806,12 +730,12 @@ static int fpgai2c_init(struct fpgalogic_i2c *i2c)
fpgai2c_reg_set(i2c, FPGAI2C_REG_PREHIGH, prescale >> 8);

/* Init the device */
fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_IACK);
if (!use_irq)
fpgai2c_reg_set(i2c, FPGAI2C_REG_CONTROL, ctrl | FPGAI2C_REG_CTRL_EN);
else
fpgai2c_reg_set(i2c, FPGAI2C_REG_CONTROL, ctrl | FPGAI2C_REG_CTRL_IEN | FPGAI2C_REG_CTRL_EN);

fpgai2c_reg_set(i2c, FPGAI2C_REG_CMD, FPGAI2C_REG_CMD_IACK);
fpgai2c_dump(i2c);

/* Initialize interrupt handlers if not already done */
Expand Down Expand Up @@ -906,7 +830,8 @@ static int i2c_pci_init (void)
break;
}
} else {
printk("Wrong board_rev_type 0x%x\n", board_rev_type);
printk("unknown board_rev_type 0x%x\n", board_rev_type);
num_bus = I2C_PCI_BUS_NUM_8;
}
}

Expand Down Expand Up @@ -1106,20 +1031,6 @@ static int register_intr_handler(struct pci_dev *dev, int irq_num_id)
* alternatively function will be called from free_irq as well
* with flag IRQF_SHARED */
switch(irq_num_id) {
/* Currently we only support test vector 2 for FPGA Logic I2C channel
* controller 1-7 interrupt*/
case FPGA_MSI_VECTOR_ID_4:
err = request_irq(dev->irq + irq_num_id, fpgaport_1_32_isr, IRQF_EARLY_RESUME,
FPGA_PCI_NAME, dev);
PRINT ( "%d: fpgapci_dev: irq: %d, %d\n", __LINE__, dev->irq, irq_num_id);
fpgapci->irq_assigned++;
break;
case FPGA_MSI_VECTOR_ID_5:
err = request_irq(dev->irq + irq_num_id, fpgaport_33_64_isr, IRQF_EARLY_RESUME,
FPGA_PCI_NAME, dev);
PRINT ( "%d: fpgapci_dev: irq: %d, %d\n", __LINE__, dev->irq, irq_num_id);
fpgapci->irq_assigned++;
break;
case FPGA_MSI_VECTOR_ID_8:
err = request_irq(dev->irq + irq_num_id, fpgai2c_isr, IRQF_EARLY_RESUME,
FPGA_PCI_NAME, &fpgalogic_i2c[0]);
Expand Down Expand Up @@ -1166,18 +1077,6 @@ static int register_intr_handler(struct pci_dev *dev, int irq_num_id)
((board_rev_type & MB_BRD_REV_MASK) == MB_BRD_REV_03)) {
/* FPGA SPEC 4.3.1.34, First i2c channel mapped to vector 8 */
switch (irq_num_id) {
case FPGA_MSI_VECTOR_ID_4:
err = request_irq(dev->irq + irq_num_id, fpgaport_1_32_isr, IRQF_EARLY_RESUME,
FPGA_PCI_NAME, dev);
PRINT ( "%d: fpgapci_dev: irq: %d, %d\n", __LINE__, dev->irq, irq_num_id);
fpgapci->irq_assigned++;
break;
case FPGA_MSI_VECTOR_ID_5:
err = request_irq(dev->irq + irq_num_id, fpgaport_33_64_isr, IRQF_EARLY_RESUME,
FPGA_PCI_NAME, dev);
PRINT ( "%d: fpgapci_dev: irq: %d, %d\n", __LINE__, dev->irq, irq_num_id);
fpgapci->irq_assigned++;
break;
case FPGA_MSI_VECTOR_ID_8:
err = request_irq(dev->irq + irq_num_id, fpgai2c_isr, IRQF_EARLY_RESUME,
FPGA_PCI_NAME, &fpgalogic_i2c[0]);
Expand Down Expand Up @@ -1491,7 +1390,6 @@ static int fpgapci_configure_msi(struct fpgapci_dev *fpgapci,struct pci_dev *dev
static int fpgapci_probe(struct pci_dev *dev, const struct pci_device_id *id)
{
struct fpgapci_dev *fpgapci = 0;
int status = 0;

#ifdef TEST
PRINT ( " vendor = 0x%x, device = 0x%x, class = 0x%x, bus:slot.func = %02x:%02x.%02x\n",
Expand All @@ -1508,18 +1406,16 @@ static int fpgapci_probe(struct pci_dev *dev, const struct pci_device_id *id)
fpgapci->pci_dev = dev;
dev_set_drvdata(&dev->dev, (void*)fpgapci);

status = sysfs_create_group(&dev->dev.kobj, &port_attr_grp);
if (status) {
printk(KERN_INFO "%s:Cannot create sysfs\n", __FUNCTION__);
}

fpgapci->upstream = find_upstream_dev (dev);

if(fpgapci_setup_device(fpgapci,dev)) {
goto error_no_device;
}

printk("%s:MSI-irq disabled \n", __FUNCTION__);
if (use_irq) {
printk("%s:MSI-irq enabled\n", __FUNCTION__);
if(fpgapci_configure_msi(fpgapci,dev)) {
goto error_cannot_configure;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import sys
import logging
import subprocess

S5232F_MAX_FAN_TRAYS = 4
S5232F_MAX_PSUS = 2
Expand Down Expand Up @@ -85,7 +84,7 @@ def get_psu_airflow(psu_id):
if line.startswith('FRU Device Description') and fru_id in line.split(':')[1]:
found_fru = True
if found_fru and line.startswith(' Board Product '):
return ' B2F' if 'PS/IO' in line else ' F2B'
return 'Intake' if 'PS/IO' in line else 'Exhaust'
return ''

# Fetch FRU on given offset
Expand All @@ -98,7 +97,7 @@ def fetch_raw_fru(dev_id, offset):


def get_fan_airflow(fan_id):
Airflow_Direction = [' F2B', ' B2F']
Airflow_Direction = ['Exhaust', 'Intake']
return Airflow_Direction[fetch_raw_fru(fan_id+2, 0x46)]

# Print the information for temperature sensors
Expand All @@ -119,6 +118,7 @@ def print_temperature_sensors():
print(' CPU Temp: ',
get_pmc_register('CPU_temp'))

subprocess.getstatusoutput('echo 0 > /sys/module/ipmi_si/parameters/kipmid_max_busy_us')
ipmi_sensor_dump()

print_temperature_sensors()
Expand Down Expand Up @@ -329,3 +329,5 @@ def print_psu(psu):

print('\n Total Power: ',
get_pmc_register('PSU_Total_watt'))

subprocess.getstatusoutput('echo 1000 > /sys/module/ipmi_si/parameters/kipmid_max_busy_us')
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,6 @@ platform_firmware_versions() {
r_maj=`/usr/sbin/i2cget -y 600 0x31 0x1 | sed ' s/.*\(0x..\)$/\1/'`
echo "Slave CPLD 2: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE

#Slave CPLD 3 0x32 on i2c bus 600 ( physical FPGA I2C-1)
r_min=`/usr/sbin/i2cget -y 600 0x32 0x0 | sed ' s/.*\(0x..\)$/\1/'`
r_maj=`/usr/sbin/i2cget -y 600 0x32 0x1 | sed ' s/.*\(0x..\)$/\1/'`
echo "Slave CPLD 3: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE

#Slave CPLD 3 0x32 on i2c bus 600 ( physical FPGA I2C-1)
r_min=`/usr/sbin/i2cget -y 600 0x33 0x0 | sed ' s/.*\(0x..\)$/\1/'`
r_maj=`/usr/sbin/i2cget -y 600 0x33 0x1 | sed ' s/.*\(0x..\)$/\1/'`
echo "Slave CPLD 4: $((r_maj)).$((r_min))" >> $FIRMWARE_VERSION_FILE
}

install_python_api_package() {
Expand All @@ -176,16 +167,47 @@ remove_python_api_package() {
fi
}

get_reboot_cause() {
REBOOT_REASON_FILE="/host/reboot-cause/platform/reboot_reason"
resource="/sys/bus/pci/devices/0000:04:00.0/resource0"

mkdir -p $(dirname $REBOOT_REASON_FILE)

# Handle First Boot into software version with reboot cause determination support
if [[ ! -e $REBOOT_REASON_FILE ]]; then
echo "0" > $REBOOT_REASON_FILE
else
/usr/bin/pcisysfs.py --get --offset 0x18 --res $resource | sed '1d; s/.*:\(.*\)$/\1/;' > $REBOOT_REASON_FILE
fi
/usr/bin/pcisysfs.py --set --val 0x0 --offset 0x18 --res $resource
}

get_reboot_cause() {
REBOOT_REASON_FILE="/host/reboot-cause/platform/reboot_reason"
resource="/sys/bus/pci/devices/0000:04:00.0/resource0"

mkdir -p $(dirname $REBOOT_REASON_FILE)

# Handle First Boot into software version with reboot cause determination support
if [[ ! -e $REBOOT_REASON_FILE ]]; then
echo "0" > $REBOOT_REASON_FILE
else
/usr/bin/pcisysfs.py --get --offset 0x18 --res $resource | sed '1d; s/.*:\(.*\)$/\1/;' > $REBOOT_REASON_FILE
fi
/usr/bin/pcisysfs.py --set --val 0x0 --offset 0x18 --res $resource
}

init_devnum

if [ "$1" == "init" ]; then
modprobe i2c-dev
modprobe i2c-mux-pca954x force_deselect_on_exit=1
modprobe ipmi_devintf
modprobe ipmi_si
modprobe ipmi_si kipmid_max_busy_us=1000
modprobe i2c_ocores
modprobe dell_s5232f_fpga_ocores
sys_eeprom "new_device"
get_reboot_cause
switch_board_qsfp_mux "new_device"
switch_board_qsfp "new_device"
switch_board_sfp "new_device"
Expand All @@ -194,6 +216,7 @@ if [ "$1" == "init" ]; then
install_python_api_package
/usr/bin/qsfp_irq_enable.py
platform_firmware_versions
echo 1000 > /sys/module/ipmi_si/parameters/kipmid_max_busy_us

elif [ "$1" == "deinit" ]; then
sys_eeprom "delete_device"
Expand All @@ -203,6 +226,8 @@ elif [ "$1" == "deinit" ]; then
modprobe -r i2c-mux-pca954x
modprobe -r i2c-dev
remove_python_api_package
modprobe -r ipmi_devintf
modprobe -r ipmi_si
else
echo "s5232f_platform : Invalid option !"
fi
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

__all__ = ["platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer"]
from sonic_platform import *
Loading

0 comments on commit d472dd2

Please sign in to comment.