Skip to content

Commit 05e0e90

Browse files
[Edgecore][device][platform] Filter fpga error message when user manual removal xcvr
Signed-off-by: michael_shih <[email protected]>
1 parent 85022ad commit 05e0e90

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

platform/broadcom/sonic-platform-modules-accton/as9736-64d/modules/accton_as9736_64d_fpga.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
#define PCIE_FPGA_I2C_CONTROL_RTC0_CONFIG_0 0x2050
148148
#define PCIE_FPGA_I2C_CONTROL_RTC0_CONFIG_1 0x2054
149149
#define PCIE_FPGA_I2C_CONTROL_RTC0_STATUS_0 0x2060
150+
#define RTC0_STATUS_0_DONE 0x1
151+
#define RTC0_STATUS_0_ERROR 0x2
152+
#define RTC0_STATUS_0_BUSY 0x4
150153

151154
/* I2C RTC Data Block */
152155
#define PCIE_FPGA_I2C_RTC_WRITE_DATA_REG_0 0x5000
@@ -1779,6 +1782,27 @@ static int get_port_present_status(struct bin_attribute *attr)
17791782
return present;
17801783
}
17811784

1785+
static int get_filter_unpresent_case(struct bin_attribute *attr)
1786+
{
1787+
int present = 0;
1788+
int err_cnt = 0;
1789+
1790+
while(err_cnt < 2)
1791+
{
1792+
msleep(400); /*delay 0.4 second*/
1793+
present = get_port_present_status(attr);
1794+
1795+
if(present) {
1796+
err_cnt++;
1797+
continue;
1798+
} else { /*unpresent*/
1799+
return 1;
1800+
}
1801+
}
1802+
1803+
return 0;
1804+
}
1805+
17821806
static ssize_t
17831807
sfp_eeprom_read(struct file *filp, struct kobject *kobj,
17841808
struct bin_attribute *attr,
@@ -1871,6 +1895,10 @@ sfp_eeprom_read(struct file *filp, struct kobject *kobj,
18711895
return count;
18721896

18731897
exit_err:
1898+
if( (state == RTC0_STATUS_0_ERROR) &&
1899+
(get_filter_unpresent_case(attr)) ) { /*Filter xcvr unplug error case*/
1900+
return -ENXIO;
1901+
}
18741902
pcie_err("%s ERROR(%d): Port%d pcie get done status failed!!", show_date_time(), state, pdata->port_num);
18751903

18761904
return -EBUSY;
@@ -1946,6 +1974,10 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj,
19461974
return retval;
19471975

19481976
exit_err:
1977+
if( (state == RTC0_STATUS_0_ERROR) &&
1978+
(get_filter_unpresent_case(attr)) ) { /*Filter xcvr unplug error case*/
1979+
return -ENXIO;
1980+
}
19491981
pcie_err("%s ERROR(%d): Port%d pcie get done status failed!!", show_date_time(), state, pdata->port_num);
19501982

19511983
return -EBUSY;
@@ -1992,6 +2024,10 @@ sfp_eeprom_write(struct bin_attribute *attr, char *buf, loff_t off, size_t count
19922024
return count;
19932025

19942026
exit_err:
2027+
if( (state == RTC0_STATUS_0_ERROR) &&
2028+
(get_filter_unpresent_case(attr)) ) { /*Filter xcvr unplug error case*/
2029+
return -ENXIO;
2030+
}
19952031
pcie_err("%s ERROR(%d): Port%d pcie set failed!!", show_date_time(), state, pdata->port_num);
19962032

19972033
return -EBUSY;

0 commit comments

Comments
 (0)