pull-request: can-next 2024-02-20
Subsystems (8)
Marc Kleine-Budde
maintainercover pull-request: can-next 2024-02-20
Hello netdev-team,
this is a pull request of 9 patches for net-next/master.
The first patch is by Francesco Dolcini and removes a redundant check for pm_clock_support from the m_can driver.
Martin Hundebøll contributes 3 patches to the m_can/tcan4x5x driver to allow resume upon RX of a CAN frame.
3 patches by Srinivas Goud add support for ECC statistics to the xilinx_can driver.
The last 2 patches are by Oliver Hartkopp and me, target the CAN RAW protocol and fix an error in the getsockopt() for CAN-XL introduced in the previous pull request to net-next (linux-can-next-for-6.9-20240213).
regards,
Marc
---
The following changes since commit e1a00373e1305578cd09526aa056940409e6b877:
Merge tag 'linux-can-next-for-6.9-20240213' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next (2024-02-14 10:00:35 +0000)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git tags/linux-can-next-for-6.9-20240220
for you to fetch changes up to 00bf80c437dcbbd808d61cc2866c8f065ff436bd:
can: raw: raw_getsockopt(): reduce scope of err (2024-02-20 09:40:46 +0100)
----------------------------------------------------------------
linux-can-next-for-6.9-20240220
----------------------------------------------------------------
Francesco Dolcini (1):
can: m_can: remove redundant check for pm_clock_support
Marc Kleine-Budde (3):
Merge patch series "can: tcan4x5x: support resume upon rx can frame"
Merge patch series "Add ECC feature support to Tx and Rx FIFOs for Xilinx CAN Controller."
can: raw: raw_getsockopt(): reduce scope of err
Martin Hundebøll (3):
dt-bindings: can: tcan4x5x: Document the wakeup-source flag
can: m_can: allow keeping the transceiver running in suspend
can: tcan4x5x: support resuming from rx interrupt signal
Oliver Hartkopp (1):
can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
Srinivas Goud (3):
dt-bindings: can: xilinx_can: Add 'xlnx,has-ecc' optional property
can: xilinx_can: Add ECC support
can: xilinx_can: Add ethtool stats interface for ECC errors
.../devicetree/bindings/net/can/tcan4x5x.txt | 3 + .../devicetree/bindings/net/can/xilinx,can.yaml | 5 + drivers/net/can/m_can/m_can.c | 30 ++-- drivers/net/can/m_can/m_can.h | 1 + drivers/net/can/m_can/m_can_pci.c | 1 + drivers/net/can/m_can/m_can_platform.c | 1 + drivers/net/can/m_can/tcan4x5x-core.c | 33 +++- drivers/net/can/xilinx_can.c | 169 ++++++++++++++++++++- net/can/raw.c | 17 ++- 9 files changed, 239 insertions(+), 21 deletions(-)
Marc Kleine-Budde
maintainerPATCH 1/9 can: m_can: remove redundant check for pm_clock_support
From: Francesco Dolcini <[email protected]>
m_can_clk_start() already skip starting the clock when clock support is disabled, remove the redundant check in m_can_class_register().
This also solves the imbalance with m_can_clk_stop() that is called afterward in the same function before the return.
--- drivers/net/can/m_can/m_can.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/can/m_can/m_can.c +3 -5
@@ -2312,11 +2312,9 @@ int m_can_class_register(struct m_can_classdev *cdev) } } -if (cdev->pm_clock_support) { - ret =m_can_clk_start (cdev); -if (ret) -return ret; - } + ret =m_can_clk_start (cdev); +if (ret) +return ret;if (cdev->is_peripheral) { ret = can_rx_offload_add_manual(cdev->net, &cdev->offload,
base-commit: e1a00373e1305578cd09526aa056940409e6b877
Signature · 1 line
2.43.0
Re: [PATCH net-next 1/9] can: m_can: remove redundant check for pm_clock_support
This series was applied to netdev/net-next.git (main) by Marc Kleine-Budde <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Marc Kleine-Budde <[email protected]>:
Quoted 10 lines · On Tue, 20 Feb 2024 09:46:03 +0100 you wrote:
From: Francesco Dolcini <[email protected]>
m_can_clk_start()already skip starting the clock when clock support is disabled, remove the redundant check inm_can_class_register().This also solves the imbalance with
m_can_clk_stop()that is called afterward in the same function before the return.[...]
Here is the summary with links:
- [net-next,1/9] can: m_can: remove redundant check for pm_clock_support
https://git.kernel.org/netdev/net-next/c/e517293fd72d - [net-next,2/9] dt-bindings: can: tcan4x5x: Document the wakeup-source flag https://git.kernel.org/netdev/net-next/c/b00cf4f62969 - [net-next,3/9] can: m_can: allow keeping the transceiver running in suspend https://git.kernel.org/netdev/net-next/c/4a94d7e31cf5 - [net-next,4/9] can: tcan4x5x: support resuming from rx interrupt signal https://git.kernel.org/netdev/net-next/c/b6b640c04446 - [net-next,5/9] dt-bindings: can: xilinx_can: Add 'xlnx,has-ecc' optional property https://git.kernel.org/netdev/net-next/c/7075d733b8e4 - [net-next,6/9] can: xilinx_can: Add ECC support https://git.kernel.org/netdev/net-next/c/8e6fbf7f66dc - [net-next,7/9] can: xilinx_can: Add ethtool stats interface for ECC errors https://git.kernel.org/netdev/net-next/c/e1d1698eb36c - [net-next,8/9] can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS https://git.kernel.org/netdev/net-next/c/c8fba5d6df5e - [net-next,9/9] can: raw: raw_getsockopt(): reduce scope of err https://git.kernel.org/netdev/net-next/c/00bf80c437dc
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Marc Kleine-Budde
maintainerPATCH 2/9 dt-bindings: can: tcan4x5x: Document the wakeup-source flag
In reply to Marc Kleine-BuddeFrom: Martin Hundebøll <[email protected]>
Let it be known that the tcan4x5x device can now be configured to wake the host from suspend when a can frame is received.
--- Documentation/devicetree/bindings/net/can/tcan4x5x.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/can/tcan4x5x.txt +3 -0
@@ -28,6 +28,8 @@ Optional properties: available with tcan4552/4553. - device-wake-gpios: Wake up GPIO to wake up the TCAN device. Not available with tcan4552/4553. + - wakeup-source: Leave the chip running when suspended, and configure + the RX interrupt to wake up the device. Example: tcan4x5x: tcan4x5x@0 {
@@ -42,4 +44,5 @@ tcan4x5x: tcan4x5x@0 { device-state-gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>; device-wake-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH>; reset-gpios = <&gpio1 27 GPIO_ACTIVE_HIGH>; + wakeup-source; };
Signature · 1 line
2.43.0
Marc Kleine-Budde
maintainerPATCH 3/9 can: m_can: allow keeping the transceiver running in suspend
In reply to Marc Kleine-BuddeFrom: Martin Hundebøll <[email protected]>
Add a flag to the device class structure that leaves the chip in a running state with rx interrupt enabled, so that an m_can device driver can configure and use the interrupt as a wakeup source.
--- drivers/net/can/m_can/m_can.c | 22 +++++++++++++++++----- drivers/net/can/m_can/m_can.h | 1 + drivers/net/can/m_can/m_can_pci.c | 1 + drivers/net/can/m_can/m_can_platform.c | 1 + drivers/net/can/m_can/tcan4x5x-core.c | 1 + 5 files changed, 21 insertions(+), 5 deletions(-)
drivers/net/can/m_can/m_can.c +17 -5
@@ -2382,7 +2382,15 @@ int m_can_class_suspend(struct device *dev)if (netif_running (ndev)) {netif_stop_queue (ndev);netif_device_detach (ndev); -m_can_stop (ndev); + +/* leave the chip running with rx interrupt enabled if it is +* used as a wake-up source. +*/ +if (cdev->pm_wake_source) +m_can_write (cdev,M_CAN_IE ,IR_RF0N ); +else +m_can_stop (ndev); +m_can_clk_stop (cdev); }
@@ -2409,11 +2417,15 @@ int m_can_class_resume(struct device *dev) ret =m_can_clk_start (cdev);if (ret)return ret; - ret =m_can_start (ndev); -if (ret) { -m_can_clk_stop (cdev); -return ret; +if (cdev->pm_wake_source) { +m_can_write (cdev,M_CAN_IE , cdev->active_interrupts); + }else { + ret =m_can_start (ndev); +if (ret) { +m_can_clk_stop (cdev); +return ret; + } }netif_device_attach (ndev);
drivers/net/can/m_can/m_can.h +1 -0
@@ -97,6 +97,7 @@ struct m_can_classdev {u32 irqstatus;int pm_clock_support; +int pm_wake_source;int is_peripheral;// Cached M_CAN_IE register content
drivers/net/can/m_can/m_can_pci.c +1 -0
@@ -125,6 +125,7 @@ static int m_can_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) mcan_class->dev = &pci->dev; mcan_class->net->irq =pci_irq_vector (pci,0 ); mcan_class->pm_clock_support =1 ; + mcan_class->pm_wake_source =0 ; mcan_class->can.clock.freq = id->driver_data; mcan_class->ops = &m_can_pci_ops;
drivers/net/can/m_can/m_can_platform.c +1 -0
@@ -139,6 +139,7 @@ static int m_can_plat_probe(struct platform_device *pdev) mcan_class->net->irq = irq; mcan_class->pm_clock_support =1 ; + mcan_class->pm_wake_source =0 ; mcan_class->can.clock.freq =clk_get_rate (mcan_class->cclk); mcan_class->dev = &pdev->dev; mcan_class->transceiver = transceiver;
drivers/net/can/m_can/tcan4x5x-core.c +1 -0
@@ -411,6 +411,7 @@ static int tcan4x5x_can_probe(struct spi_device *spi) priv->spi = spi; mcan_class->pm_clock_support =0 ; + mcan_class->pm_wake_source =0 ; mcan_class->can.clock.freq = freq; mcan_class->dev = &spi->dev; mcan_class->ops = &tcan4x5x_ops;
Signature · 1 line
2.43.0
Marc Kleine-Budde
maintainerPATCH 4/9 can: tcan4x5x: support resuming from rx interrupt signal
In reply to Marc Kleine-BuddeFrom: Martin Hundebøll <[email protected]>
Implement the "wakeup-source" device tree property, so the chip is left running when suspending, and its rx interrupt is used as a wakeup source to resume operation.
--- drivers/net/can/m_can/tcan4x5x-core.c | 34 +++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
drivers/net/can/m_can/tcan4x5x-core.c +32 -2
@@ -411,7 +411,7 @@ static int tcan4x5x_can_probe(struct spi_device *spi) priv->spi = spi; mcan_class->pm_clock_support =0 ; - mcan_class->pm_wake_source =0 ; + mcan_class->pm_wake_source =device_property_read_bool (&spi->dev,"wakeup-source" ); mcan_class->can.clock.freq = freq; mcan_class->dev = &spi->dev; mcan_class->ops = &tcan4x5x_ops;
@@ -460,6 +460,9 @@ static int tcan4x5x_can_probe(struct spi_device *spi) goto out_power; } +if (mcan_class->pm_wake_source) +device_init_wakeup (&spi->dev, true); + ret =m_can_class_register (mcan_class);if (ret) { dev_err(&spi->dev, "Failed registering m_can device %pe\n",
@@ -488,6 +491,29 @@ static void tcan4x5x_can_remove(struct spi_device *spi)m_can_class_free_dev (priv->cdev.net); } +static int __maybe_unused tcan4x5x_suspend (struct device *dev) +{ +struct m_can_classdev *cdev =dev_get_drvdata (dev); +struct spi_device *spi =to_spi_device (dev); + +if (cdev->pm_wake_source) +enable_irq_wake (spi->irq); + +return m_can_class_suspend (dev); +} + +static int __maybe_unused tcan4x5x_resume (struct device *dev) +{ +struct m_can_classdev *cdev =dev_get_drvdata (dev); +struct spi_device *spi =to_spi_device (dev); +int ret =m_can_class_resume (dev); + +if (cdev->pm_wake_source) +disable_irq_wake (spi->irq); + +return ret; +} +static const struct of_device_id tcan4x5x_of_match[] = { { .compatible ="ti,tcan4x5x" ,
@@ -506,11 +532,15 @@ static const struct spi_device_id tcan4x5x_id_table[] = { };MODULE_DEVICE_TABLE (spi, tcan4x5x_id_table); +static const struct dev_pm_ops tcan4x5x_pm_ops = { +SET_SYSTEM_SLEEP_PM_OPS (tcan4x5x_suspend, tcan4x5x_resume) +}; +static struct spi_driver tcan4x5x_can_driver = { .driver = { .name =KBUILD_MODNAME , .of_match_table = tcan4x5x_of_match, - .pm =NULL , + .pm = &tcan4x5x_pm_ops, }, .id_table = tcan4x5x_id_table, .probe = tcan4x5x_can_probe,
Signature · 1 line
2.43.0
Marc Kleine-Budde
maintainerPATCH 5/9 dt-bindings: can: xilinx_can: Add 'xlnx,has-ecc' optional property
In reply to Marc Kleine-BuddeFrom: Srinivas Goud <[email protected]>
ECC feature added to CAN TX_OL, TX_TL and RX FIFOs of Xilinx AXI CAN Controller.
ECC is an IP configuration option where counter registers are added in IP for 1bit/2bit ECC errors.
'xlnx,has-ecc' is an optional property and added to Xilinx AXI CAN Controller node if ECC block enabled in the HW
--- Documentation/devicetree/bindings/net/can/xilinx,can.yaml | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/net/can/xilinx,can.yaml +5 -0
@@ -49,6 +49,10 @@ properties: resets: maxItems: 1 + xlnx,has-ecc: + $ref: /schemas/types.yaml#/definitions/flag + description: CAN TX_OL, TX_TL and RX FIFOs have ECC support(AXI CAN) + required: - compatible - reg
@@ -137,6 +141,7 @@ examples: interrupts = <GIC_SPI 59 IRQ_TYPE_EDGE_RISING>; tx-fifo-depth = <0x40>; rx-fifo-depth = <0x40>; + xlnx,has-ecc; }; - |
Signature · 1 line
2.43.0
Marc Kleine-Budde
maintainerPATCH 6/9 can: xilinx_can: Add ECC support
In reply to Marc Kleine-BuddeFrom: Srinivas Goud <[email protected]>
Add ECC support for Xilinx CAN Controller, so this driver reports 1bit/2bit ECC errors for FIFO's based on ECC error interrupt. ECC feature for Xilinx CAN Controller selected through 'xlnx,has-ecc' DT property
--- drivers/net/can/xilinx_can.c | 105 +++++++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 4 deletions(-)
drivers/net/can/xilinx_can.c +101 -4
@@ -31,6 +31,7 @@#include <linux/phy/phy.h> #include <linux/pm_runtime.h> #include <linux/reset.h> +#include <linux/u64_stats_sync.h> #define DRIVER_NAME "xilinx_can"
@@ -58,6 +59,13 @@ enum xcan_reg {*/ XCAN_F_BTR_OFFSET =0x08C ,/* Data Phase Bit Timing */ XCAN_TRR_OFFSET =0x0090 ,/* TX Buffer Ready Request */ + +/* only on AXI CAN cores */ +XCAN_ECC_CFG_OFFSET =0xC8 ,/* ECC Configuration */ +XCAN_TXTLFIFO_ECC_OFFSET =0xCC ,/* TXTL FIFO ECC error counter */ +XCAN_TXOLFIFO_ECC_OFFSET =0xD0 ,/* TXOL FIFO ECC error counter */ +XCAN_RXFIFO_ECC_OFFSET =0xD4 ,/* RX FIFO ECC error counter */ +XCAN_AFR_EXT_OFFSET =0x00E0 ,/* Acceptance Filter */ XCAN_FSR_OFFSET =0x00E8 ,/* RX FIFO Status */ XCAN_TXMSG_BASE_OFFSET = 0x0100, /* TX Message Space */
@@ -124,6 +132,18 @@ enum xcan_reg {#define XCAN_IXR_TXFLL_MASK 0x00000004/* Tx FIFO Full intr */ #define XCAN_IXR_TXOK_MASK 0x00000002/* TX successful intr */ #define XCAN_IXR_ARBLST_MASK 0x00000001/* Arbitration lost intr */ +#define XCAN_IXR_E2BERX_MASK BIT(23)/* RX FIFO two bit ECC error */ +#define XCAN_IXR_E1BERX_MASK BIT(22)/* RX FIFO one bit ECC error */ +#define XCAN_IXR_E2BETXOL_MASK BIT(21)/* TXOL FIFO two bit ECC error */ +#define XCAN_IXR_E1BETXOL_MASK BIT(20)/* TXOL FIFO One bit ECC error */ +#define XCAN_IXR_E2BETXTL_MASK BIT(19)/* TXTL FIFO Two bit ECC error */ +#define XCAN_IXR_E1BETXTL_MASK BIT(18)/* TXTL FIFO One bit ECC error */ +#define XCAN_IXR_ECC_MASK (XCAN_IXR_E2BERX_MASK | \ + XCAN_IXR_E1BERX_MASK | \ + XCAN_IXR_E2BETXOL_MASK | \ + XCAN_IXR_E1BETXOL_MASK | \ + XCAN_IXR_E2BETXTL_MASK | \ + XCAN_IXR_E1BETXTL_MASK)#define XCAN_IDR_ID1_MASK 0xFFE00000/* Standard msg identifier */ #define XCAN_IDR_SRR_MASK 0x00100000/* Substitute remote TXreq */ #define XCAN_IDR_IDE_MASK 0x00080000/* Identifier extension */
@@ -137,6 +157,11 @@ enum xcan_reg {#define XCAN_2_FSR_RI_MASK 0x0000003F/* RX Read Index */ #define XCAN_DLCR_EDL_MASK 0x08000000/* EDL Mask in DLC */ #define XCAN_DLCR_BRS_MASK 0x04000000/* BRS Mask in DLC */ +#define XCAN_ECC_CFG_REECRX_MASK BIT(2)/* Reset RX FIFO ECC error counters */ +#define XCAN_ECC_CFG_REECTXOL_MASK BIT(1)/* Reset TXOL FIFO ECC error counters */ +#define XCAN_ECC_CFG_REECTXTL_MASK BIT(0)/* Reset TXTL FIFO ECC error counters */ +#define XCAN_ECC_1BIT_CNT_MASK GENMASK(15, 0)/* FIFO ECC 1bit count mask */ +#define XCAN_ECC_2BIT_CNT_MASK GENMASK(31, 16)/* FIFO ECC 2bit count mask */ /* CAN register bit shift - XCAN_<REG>_<BIT>_SHIFT */ #define XCAN_BRPR_TDC_ENABLE BIT(16)/* Transmitter Delay Compensation (TDC) Enable */
@@ -202,6 +227,13 @@ struct xcan_devtype_data {* @devtype: Device type specific constants * @transceiver: Optional pointer to associated CAN transceiver * @rstc: Pointer to reset control +* @ecc_enable: ECC enable flag +* @ecc_rx_2_bit_errors: RXFIFO 2bit ECC count +* @ecc_rx_1_bit_errors: RXFIFO 1bit ECC count +* @ecc_txol_2_bit_errors: TXOLFIFO 2bit ECC count +* @ecc_txol_1_bit_errors: TXOLFIFO 1bit ECC count +* @ecc_txtl_2_bit_errors: TXTLFIFO 2bit ECC count +* @ecc_txtl_1_bit_errors: TXTLFIFO 1bit ECC count */ struct xcan_priv {struct can_priv can;
@@ -221,6 +253,13 @@ struct xcan_priv {struct xcan_devtype_data devtype;struct phy *transceiver;struct reset_control *rstc; +bool ecc_enable; +u64_stats_t ecc_rx_2_bit_errors; +u64_stats_t ecc_rx_1_bit_errors; +u64_stats_t ecc_txol_2_bit_errors; +u64_stats_t ecc_txol_1_bit_errors; +u64_stats_t ecc_txtl_2_bit_errors; +u64_stats_t ecc_txtl_1_bit_errors; };/* CAN Bittiming constants as per Xilinx CAN specs */
@@ -523,6 +562,9 @@ static int xcan_chip_start(struct net_device *ndev)XCAN_IXR_ERROR_MASK |XCAN_IXR_RXOFLW_MASK |XCAN_IXR_ARBLST_MASK |xcan_rx_int_mask (priv); +if (priv->ecc_enable) + ier |=XCAN_IXR_ECC_MASK ; +if (priv->devtype.flags &XCAN_FLAG_RXMNF ) ier |=XCAN_IXR_RXMNF_MASK ;
@@ -1127,6 +1169,50 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr) priv->can.can_stats.bus_error++; } +if (priv->ecc_enable && isr &XCAN_IXR_ECC_MASK ) { +u32 reg_rx_ecc, reg_txol_ecc, reg_txtl_ecc; + + reg_rx_ecc = priv->read_reg (priv,XCAN_RXFIFO_ECC_OFFSET ); + reg_txol_ecc = priv->read_reg (priv,XCAN_TXOLFIFO_ECC_OFFSET ); + reg_txtl_ecc = priv->read_reg (priv,XCAN_TXTLFIFO_ECC_OFFSET ); + +/* The counter reaches its maximum at 0xffff and does not overflow. +* Accept the small race window between reading and resetting ECC counters. +*/ + priv->write_reg (priv,XCAN_ECC_CFG_OFFSET ,XCAN_ECC_CFG_REECRX_MASK | +XCAN_ECC_CFG_REECTXOL_MASK |XCAN_ECC_CFG_REECTXTL_MASK ); + +if (isr &XCAN_IXR_E2BERX_MASK ) { +u64_stats_add (&priv->ecc_rx_2_bit_errors, +FIELD_GET (XCAN_ECC_2BIT_CNT_MASK , reg_rx_ecc)); + } + +if (isr &XCAN_IXR_E1BERX_MASK ) { +u64_stats_add (&priv->ecc_rx_1_bit_errors, +FIELD_GET (XCAN_ECC_1BIT_CNT_MASK , reg_rx_ecc)); + } + +if (isr &XCAN_IXR_E2BETXOL_MASK ) { +u64_stats_add (&priv->ecc_txol_2_bit_errors, +FIELD_GET (XCAN_ECC_2BIT_CNT_MASK , reg_txol_ecc)); + } + +if (isr &XCAN_IXR_E1BETXOL_MASK ) { +u64_stats_add (&priv->ecc_txol_1_bit_errors, +FIELD_GET (XCAN_ECC_1BIT_CNT_MASK , reg_txol_ecc)); + } + +if (isr &XCAN_IXR_E2BETXTL_MASK ) { +u64_stats_add (&priv->ecc_txtl_2_bit_errors, +FIELD_GET (XCAN_ECC_2BIT_CNT_MASK , reg_txtl_ecc)); + } + +if (isr &XCAN_IXR_E1BETXTL_MASK ) { +u64_stats_add (&priv->ecc_txtl_1_bit_errors, +FIELD_GET (XCAN_ECC_1BIT_CNT_MASK , reg_txtl_ecc)); + } + } +if (cf.can_id) {struct can_frame *skb_cf;struct sk_buff *skb =alloc_can_err_skb (ndev, &skb_cf);
@@ -1354,8 +1440,8 @@ static irqreturn_t xcan_interrupt(int irq, void *dev_id) {struct net_device *ndev = (struct net_device *)dev_id;struct xcan_priv *priv =netdev_priv (ndev); +u32 isr_errors, mask;u32 isr, ier; -u32 isr_errors;u32 rx_int_mask =xcan_rx_int_mask (priv);/* Get the interrupt status from Xilinx CAN */
@@ -1374,10 +1460,15 @@ static irqreturn_t xcan_interrupt(int irq, void *dev_id)if (isr &XCAN_IXR_TXOK_MASK )xcan_tx_interrupt (ndev, isr); + mask =XCAN_IXR_ERROR_MASK |XCAN_IXR_RXOFLW_MASK | +XCAN_IXR_BSOFF_MASK |XCAN_IXR_ARBLST_MASK | +XCAN_IXR_RXMNF_MASK ; + +if (priv->ecc_enable) + mask |=XCAN_IXR_ECC_MASK ; +/* Check for the type of error interrupt and Processing it */ - isr_errors = isr & (XCAN_IXR_ERROR_MASK |XCAN_IXR_RXOFLW_MASK | -XCAN_IXR_BSOFF_MASK |XCAN_IXR_ARBLST_MASK | -XCAN_IXR_RXMNF_MASK ); + isr_errors = isr & mask;if (isr_errors) { priv->write_reg (priv,XCAN_ICR_OFFSET , isr_errors);xcan_err_interrupt (ndev, isr);
@@ -1793,6 +1884,7 @@ static int xcan_probe(struct platform_device *pdev)return -ENOMEM ; priv =netdev_priv (ndev); + priv->ecc_enable =of_property_read_bool (pdev->dev.of_node,"xlnx,has-ecc" ); priv->dev = &pdev->dev; priv->can.bittiming_const = devtype->bittiming_const; priv->can.do_set_mode = xcan_do_set_mode;
@@ -1909,6 +2001,11 @@ static int xcan_probe(struct platform_device *pdev) priv->reg_base, ndev->irq, priv->can.clock.freq, hw_tx_max, priv->tx_max); +if (priv->ecc_enable) { +/* Reset FIFO ECC counters */ + priv->write_reg (priv,XCAN_ECC_CFG_OFFSET ,XCAN_ECC_CFG_REECRX_MASK | +XCAN_ECC_CFG_REECTXOL_MASK |XCAN_ECC_CFG_REECTXTL_MASK ); + }return 0 ; err_disableclks:
Signature · 1 line
2.43.0
Marc Kleine-Budde
maintainerPATCH 7/9 can: xilinx_can: Add ethtool stats interface for ECC errors
In reply to Marc Kleine-BuddeFrom: Srinivas Goud <[email protected]>
Add ethtool stats interface for reading FIFO 1bit/2bit ECC errors information.
--- drivers/net/can/xilinx_can.c | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
drivers/net/can/xilinx_can.c +64 -0
@@ -228,6 +228,7 @@ struct xcan_devtype_data {* @transceiver: Optional pointer to associated CAN transceiver * @rstc: Pointer to reset control * @ecc_enable: ECC enable flag +* @syncp: synchronization for ECC error stats * @ecc_rx_2_bit_errors: RXFIFO 2bit ECC count * @ecc_rx_1_bit_errors: RXFIFO 1bit ECC count * @ecc_txol_2_bit_errors: TXOLFIFO 2bit ECC count
@@ -254,6 +255,7 @@ struct xcan_priv {struct phy *transceiver;struct reset_control *rstc;bool ecc_enable; +struct u64_stats_sync syncp;u64_stats_t ecc_rx_2_bit_errors;u64_stats_t ecc_rx_1_bit_errors;u64_stats_t ecc_txol_2_bit_errors;
@@ -347,6 +349,24 @@ static const struct can_tdc_const xcan_tdc_const_canfd2 = { .tdcf_max = 0, }; +enum xcan_stats_type { +XCAN_ECC_RX_2_BIT_ERRORS , +XCAN_ECC_RX_1_BIT_ERRORS , +XCAN_ECC_TXOL_2_BIT_ERRORS , +XCAN_ECC_TXOL_1_BIT_ERRORS , +XCAN_ECC_TXTL_2_BIT_ERRORS , +XCAN_ECC_TXTL_1_BIT_ERRORS , +}; + +static const char xcan_priv_flags_strings[][ETH_GSTRING_LEN ] = { + [XCAN_ECC_RX_2_BIT_ERRORS ] ="ecc_rx_2_bit_errors" , + [XCAN_ECC_RX_1_BIT_ERRORS ] ="ecc_rx_1_bit_errors" , + [XCAN_ECC_TXOL_2_BIT_ERRORS ] ="ecc_txol_2_bit_errors" , + [XCAN_ECC_TXOL_1_BIT_ERRORS ] ="ecc_txol_1_bit_errors" , + [XCAN_ECC_TXTL_2_BIT_ERRORS ] ="ecc_txtl_2_bit_errors" , + [XCAN_ECC_TXTL_1_BIT_ERRORS ] ="ecc_txtl_1_bit_errors" , +}; +/** * xcan_write_reg_le - Write a value to the device register little endian * @priv: Driver private data structure
@@ -1182,6 +1202,8 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr) priv->write_reg (priv,XCAN_ECC_CFG_OFFSET ,XCAN_ECC_CFG_REECRX_MASK |XCAN_ECC_CFG_REECTXOL_MASK |XCAN_ECC_CFG_REECTXTL_MASK ); +u64_stats_update_begin (&priv->syncp); +if (isr &XCAN_IXR_E2BERX_MASK ) {u64_stats_add (&priv->ecc_rx_2_bit_errors,FIELD_GET (XCAN_ECC_2BIT_CNT_MASK , reg_rx_ecc));
@@ -1211,6 +1233,8 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr)u64_stats_add (&priv->ecc_txtl_1_bit_errors,FIELD_GET (XCAN_ECC_1BIT_CNT_MASK , reg_txtl_ecc)); } + +u64_stats_update_end (&priv->syncp); }if (cf.can_id) {
@@ -1637,6 +1661,43 @@ static int xcan_get_auto_tdcv(const struct net_device *ndev, u32 *tdcv)return 0 ; } +static void xcan_get_strings (struct net_device *ndev,u32 stringset,u8 *buf) +{ +switch (stringset) { +case ETH_SS_STATS : +memcpy (buf, &xcan_priv_flags_strings, +sizeof (xcan_priv_flags_strings)); + } +} + +static int xcan_get_sset_count (struct net_device *netdev,int sset) +{ +switch (sset) { +case ETH_SS_STATS : +return ARRAY_SIZE (xcan_priv_flags_strings); +default : +return -EOPNOTSUPP ; + } +} + +static void xcan_get_ethtool_stats (struct net_device *ndev, +struct ethtool_stats *stats,u64 *data) +{ +struct xcan_priv *priv =netdev_priv (ndev); +unsigned int start; + +do { + start =u64_stats_fetch_begin (&priv->syncp); + + data[XCAN_ECC_RX_2_BIT_ERRORS ] =u64_stats_read (&priv->ecc_rx_2_bit_errors); + data[XCAN_ECC_RX_1_BIT_ERRORS ] =u64_stats_read (&priv->ecc_rx_1_bit_errors); + data[XCAN_ECC_TXOL_2_BIT_ERRORS ] =u64_stats_read (&priv->ecc_txol_2_bit_errors); + data[XCAN_ECC_TXOL_1_BIT_ERRORS ] =u64_stats_read (&priv->ecc_txol_1_bit_errors); + data[XCAN_ECC_TXTL_2_BIT_ERRORS ] =u64_stats_read (&priv->ecc_txtl_2_bit_errors); + data[XCAN_ECC_TXTL_1_BIT_ERRORS ] =u64_stats_read (&priv->ecc_txtl_1_bit_errors); + }while (u64_stats_fetch_retry (&priv->syncp, start)); +} +static const struct net_device_ops xcan_netdev_ops = { .ndo_open = xcan_open, .ndo_stop = xcan_close,
@@ -1646,6 +1707,9 @@ static const struct net_device_ops xcan_netdev_ops = {static const struct ethtool_ops xcan_ethtool_ops = { .get_ts_info = ethtool_op_get_ts_info, + .get_strings = xcan_get_strings, + .get_sset_count = xcan_get_sset_count, + .get_ethtool_stats = xcan_get_ethtool_stats, };/**
Signature · 1 line
2.43.0
Marc Kleine-Budde
maintainerPATCH 8/9 can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
In reply to Marc Kleine-BuddeFrom: Oliver Hartkopp <[email protected]>
The code for the CAN_RAW_XL_VCID_OPTS getsockopt() was incompletely adopted from the CAN_RAW_FILTER getsockopt().
Add the missing put_user() and return statements.
Flagged by Smatch.
--- net/can/raw.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/can/raw.c +3 -1
@@ -835,7 +835,9 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,if (copy_to_user (optval, &ro->raw_vcid_opts, len)) err = -EFAULT ; } -break ; +if (!err) + err =put_user (len, optlen); +return err;case CAN_RAW_JOIN_FILTERS :if (len >sizeof (int ))
Signature · 1 line
2.43.0
Marc Kleine-Budde
maintainerPATCH 9/9 can: raw: raw_getsockopt(): reduce scope of err
In reply to Marc Kleine-BuddeReduce the scope of the variable "err" to the individual cases. This is to avoid the mistake of setting "err" in the mistaken belief that it will be evaluated later.
--- net/can/raw.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
net/can/raw.c +8 -5
@@ -756,7 +756,6 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,struct raw_sock *ro =raw_sk (sk);int len;void *val; -int err =0 ;if (level !=SOL_CAN_RAW )return -EINVAL ;
@@ -766,7 +765,9 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,return -EINVAL ;switch (optname) { -case CAN_RAW_FILTER : +case CAN_RAW_FILTER : { +int err =0 ; +lock_sock (sk);if (ro->count >0 ) {int fsize = ro->count *sizeof (struct can_filter );
@@ -791,7 +792,7 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,if (!err) err =put_user (len, optlen);return err; - + }case CAN_RAW_ERR_FILTER :if (len >sizeof (can_err_mask_t)) len =sizeof (can_err_mask_t);
@@ -822,7 +823,9 @@ static int raw_getsockopt(struct socket *sock, int level, int optname, val = &ro->xl_frames;break ; -case CAN_RAW_XL_VCID_OPTS : +case CAN_RAW_XL_VCID_OPTS : { +int err =0 ; +/* user space buffer to small for VCID opts? */ if (len <sizeof (ro->raw_vcid_opts)) {/* return -ERANGE and needed space in optlen */
@@ -838,7 +841,7 @@ static int raw_getsockopt(struct socket *sock, int level, int optname,if (!err) err =put_user (len, optlen);return err; - + }case CAN_RAW_JOIN_FILTERS :if (len >sizeof (int )) len =sizeof (int );
Signature · 1 line
2.43.0