PCIe driver: enable RS-FEC correction; expose CMAC RX and RS-FEC status in sysfs

The driver turned RS-FEC on (0x107C) but never wrote
RSFEC_CONFIG_INDICATION_CORRECTION (0x1000), whose correction and
indication bits default to off, so the CMAC framed RS-FEC without
correcting errors. Write 0x3 there before enabling RS-FEC.

Add read-only sysfs attributes cmac_rx_status (STAT_RX_STATUS, 0x0204) and
cmac_rsfec_status (STAT_RSFEC_STATUS, 0x1004), so the state of a link that
does not come up (e.g. a switch port left in auto-negotiation) can be read
without a register tool. Both return -ENODEV on non-100G variants.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
jungfrauandClaude Opus 5.5 authored and Filip Leonarski committed 2026-11-24 16:20:00 +01:00
1 parent e88ae4a3ac
commit 59b9be5de1
2 files changed
+25

No files matched your search

+3
View File
@@ -21,6 +21,9 @@ int jfjoch_cmac_100g_enable(struct jfjoch_drvdata *drvdata, u32 net_if) {
if (net_if != 0)
return -EINVAL;
// Enable RS_FEC error correction and indication
iowrite32(0x03, drvdata->bar0 + ptr + 0x1000);
// Enable RS_FEC
iowrite32(0x03, drvdata->bar0 + ptr + 0x107C);
+22
View File
@@ -89,6 +89,26 @@ static ssize_t eth_aligned_show(struct device *dev,
return scnprintf(buf, PAGE_SIZE, "0x%02x", jfjoch_network_check_link(drvdata));
}
static ssize_t cmac_rx_status_show(struct device *dev,
struct device_attribute *attr,
char *buf) {
struct miscdevice* miscdev = dev_get_drvdata(dev);
struct jfjoch_drvdata* drvdata = container_of(miscdev, struct jfjoch_drvdata, miscdev);
if (drvdata->fpga_variant != JFJOCH_FPGA_VARIANT_100G)
return -ENODEV;
return scnprintf(buf, PAGE_SIZE, "0x%08x", ioread32(drvdata->bar0 + MAC_100G_0_OFFSET + 0x0204));
}
static ssize_t cmac_rsfec_status_show(struct device *dev,
struct device_attribute *attr,
char *buf) {
struct miscdevice* miscdev = dev_get_drvdata(dev);
struct jfjoch_drvdata* drvdata = container_of(miscdev, struct jfjoch_drvdata, miscdev);
if (drvdata->fpga_variant != JFJOCH_FPGA_VARIANT_100G)
return -ENODEV;
return scnprintf(buf, PAGE_SIZE, "0x%08x", ioread32(drvdata->bar0 + MAC_100G_0_OFFSET + 0x1004));
}
static ssize_t git_sha1_show(struct device *dev,
struct device_attribute *attr,
char *buf) {
@@ -204,6 +224,8 @@ static struct device_attribute device_attrs[] = {
__ATTR_RO(revision),
__ATTR_RO(max_modules),
__ATTR_RO(eth_aligned),
__ATTR_RO(cmac_rx_status),
__ATTR_RO(cmac_rsfec_status),
__ATTR_RO(active_handles),
__ATTR_RO(fpga_serial_number),
__ATTR_RO(version),