|
147 | 147 | #define PCIE_FPGA_I2C_CONTROL_RTC0_CONFIG_0 0x2050
|
148 | 148 | #define PCIE_FPGA_I2C_CONTROL_RTC0_CONFIG_1 0x2054
|
149 | 149 | #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 |
150 | 153 |
|
151 | 154 | /* I2C RTC Data Block */
|
152 | 155 | #define PCIE_FPGA_I2C_RTC_WRITE_DATA_REG_0 0x5000
|
@@ -1779,6 +1782,27 @@ static int get_port_present_status(struct bin_attribute *attr)
|
1779 | 1782 | return present;
|
1780 | 1783 | }
|
1781 | 1784 |
|
| 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 | + |
1782 | 1806 | static ssize_t
|
1783 | 1807 | sfp_eeprom_read(struct file *filp, struct kobject *kobj,
|
1784 | 1808 | struct bin_attribute *attr,
|
@@ -1871,6 +1895,10 @@ sfp_eeprom_read(struct file *filp, struct kobject *kobj,
|
1871 | 1895 | return count;
|
1872 | 1896 |
|
1873 | 1897 | exit_err:
|
| 1898 | + if( (state == RTC0_STATUS_0_ERROR) && |
| 1899 | + (get_filter_unpresent_case(attr)) ) { /*Filter xcvr unplug error case*/ |
| 1900 | + return -ENXIO; |
| 1901 | + } |
1874 | 1902 | pcie_err("%s ERROR(%d): Port%d pcie get done status failed!!", show_date_time(), state, pdata->port_num);
|
1875 | 1903 |
|
1876 | 1904 | return -EBUSY;
|
@@ -1946,6 +1974,10 @@ static ssize_t sfp_bin_read(struct file *filp, struct kobject *kobj,
|
1946 | 1974 | return retval;
|
1947 | 1975 |
|
1948 | 1976 | exit_err:
|
| 1977 | + if( (state == RTC0_STATUS_0_ERROR) && |
| 1978 | + (get_filter_unpresent_case(attr)) ) { /*Filter xcvr unplug error case*/ |
| 1979 | + return -ENXIO; |
| 1980 | + } |
1949 | 1981 | pcie_err("%s ERROR(%d): Port%d pcie get done status failed!!", show_date_time(), state, pdata->port_num);
|
1950 | 1982 |
|
1951 | 1983 | return -EBUSY;
|
@@ -1992,6 +2024,10 @@ sfp_eeprom_write(struct bin_attribute *attr, char *buf, loff_t off, size_t count
|
1992 | 2024 | return count;
|
1993 | 2025 |
|
1994 | 2026 | exit_err:
|
| 2027 | + if( (state == RTC0_STATUS_0_ERROR) && |
| 2028 | + (get_filter_unpresent_case(attr)) ) { /*Filter xcvr unplug error case*/ |
| 2029 | + return -ENXIO; |
| 2030 | + } |
1995 | 2031 | pcie_err("%s ERROR(%d): Port%d pcie set failed!!", show_date_time(), state, pdata->port_num);
|
1996 | 2032 |
|
1997 | 2033 | return -EBUSY;
|
|
0 commit comments