Martin Jocić
af1752ecdc
can: kvaser_pciefd: Add additional Xilinx interrupts
...
Since Xilinx-based adapters now support up to eight CAN channels, the
TX interrupt mask array must have eight elements.
Signed-off-by: Martin Jocic <martin.jocic@kvaser.com >
Link: https://lore.kernel.org/all/2ab3c0585c3baba272ede0487182a423a420134b.camel@kvaser.com
Fixes: 9b221ba452 ("can: kvaser_pciefd: Add support for Kvaser PCIe 8xCAN")
[mkl: replace Link by Fixes tag]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2024-03-19 15:26:01 +01:00
Martin Jocić
9b221ba452
can: kvaser_pciefd: Add support for Kvaser PCIe 8xCAN
...
Add support for new Kvaser pciefd device, PCIe 8xCAN, based on Xilinx FPGA.
Signed-off-by: Martin Jocic <martin.jocic@kvaser.com >
Link: https://lore.kernel.org/all/2b2c720a788e1904283e354abb320adb5b631d26.camel@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2024-03-04 08:38:34 +01:00
Jimmy Assarsson
85216f56bd
can: kvaser_pciefd: Add support for Kvaser M.2 PCIe 4xCAN
...
Add support for new Kvaser pciefd device, M.2 PCIe 4xCAN, based on
Xilinx FPGA.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/all/20231113134717.515037-1-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2024-02-12 17:23:51 +01:00
Jimmy Assarsson
f33ad6776b
can: kvaser_pciefd: Add support for new Kvaser pciefd devices
...
Add support for new Kvaser pciefd devices, based on SmartFusion2 SoC.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/all/20230622151153.294844-3-extja@kvaser.com
[mkl: mark structs as static]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-07-19 09:03:10 +02:00
Jimmy Assarsson
c2ad812956
can: kvaser_pciefd: Move hardware specific constants and functions into a driver_data struct
...
Move hardware specific address offsets, interrupt masks and DMA mapping
function, into struct kvaser_pciefd_driver_data, as a step towards adding
new devices based on different hardware.
Co-developed-by: Martin Jocic <majoc@kvaser.com >
Signed-off-by: Martin Jocic <majoc@kvaser.com >
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/all/20230622151153.294844-2-extja@kvaser.com
[mkl: mark structs as static]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-07-19 09:01:21 +02:00
Jimmy Assarsson
6fdcd64ec3
can: kvaser_pciefd: Use TX FIFO size read from CAN controller
...
Use the TX FIFO size read from CAN controller register, instead of using
hard coded value.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-15-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:30 +02:00
Jimmy Assarsson
f4845741e4
can: kvaser_pciefd: Refactor code
...
Refactor code;
- Format code
- Rename variables and macros
- Remove intermediate variables
- Add/remove blank lines
- Reduce scope of variables
- Add helper functions
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-14-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:29 +02:00
Jimmy Assarsson
f07008a213
can: kvaser_pciefd: Add len8_dlc support
...
Add support for the Classical CAN raw DLC functionality to send and receive
DLC values from 9 .. 15.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-13-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:29 +02:00
Jimmy Assarsson
954fb21268
can: kvaser_pciefd: Use FIELD_{GET,PREP} and GENMASK where appropriate
...
Replace opencoded masking and shifting, with GENMASK, FIELD_GET and
FIELD_PREP macros.
Suggested-by: Vincent MAILHOL <mailhol.vincent@wanadoo.fr >
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-12-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:29 +02:00
Jimmy Assarsson
69335013c4
can: kvaser_pciefd: Sort register definitions
...
Sort the registers defines, in the same order as the register bits/fields
are defined.
Sort register bits/fields in MSB-to-LSB order.
Update and add comments.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-11-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:29 +02:00
Jimmy Assarsson
24aecf5537
can: kvaser_pciefd: Change return type for kvaser_pciefd_{receive,transmit,set_tx}_irq()
...
Change return type to void for kvaser_pciefd_transmit_irq(),
kvaser_pciefd_receive_irq() and kvaser_pciefd_set_tx_irq().
These functions always return zero.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-10-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:29 +02:00
Jimmy Assarsson
488c07b441
can: kvaser_pciefd: Rename device ID defines
...
Rename device ID defines to better match the product name of the supported
device.
Use 16 bit hexadecimal values for device IDs.
And format kvaser_pciefd_id_table using clang-format.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-9-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:29 +02:00
Jimmy Assarsson
1b83d0ba1c
can: kvaser_pciefd: Sort includes in alphabetic order
...
Sort the includes in alphabetic order.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-8-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:29 +02:00
Jimmy Assarsson
c496adafee
can: kvaser_pciefd: Remove SPI flash parameter read functionality
...
Remove SPI flash parameter read functionality, since it's only used for
reading the interface CAN controller count.
This information is already read from a register, making the information
redundant.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-7-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:29 +02:00
Jimmy Assarsson
2c470dbbd3
can: kvaser_pciefd: Define unsigned constants with type suffix 'U'
...
Define unsigned constants with type suffix 'U'
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-6-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:28 +02:00
Jimmy Assarsson
ec681b91be
can: kvaser_pciefd: Set hardware timestamp on transmitted packets
...
Set hardware timestamp on transmitted packets.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-5-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:28 +02:00
Jimmy Assarsson
2d55e9f9b4
can: kvaser_pciefd: Add function to set skb hwtstamps
...
Add new function, kvaser_pciefd_set_skb_timestamp(), to set skb hwtstamps.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-4-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:28 +02:00
Jimmy Assarsson
76c66ddf7f
can: kvaser_pciefd: Remove handler for unused KVASER_PCIEFD_PACK_TYPE_EFRAME_ACK
...
The Kvaser KCAN controller got a feature to send error frames on request.
The packet KVASER_PCIEFD_PACK_TYPE_EFRAME_ACK signals that the requested
error frame was transmitted.
Since this feature is not supported by the driver, drop the handler and add
KVASER_PCIEFD_PACK_TYPE_EFRAME_ACK to the list of unexpected packet types.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-3-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:28 +02:00
Jimmy Assarsson
7c921556c0
can: kvaser_pciefd: Remove useless write to interrupt register
...
The PCI interrupt register, KVASER_PCIEFD_IRQ_REG, is level triggered.
Writing to the register doesn't affect it.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20230529134248.752036-2-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-06-22 09:44:28 +02:00
Jimmy Assarsson
11164bc394
can: kvaser_pciefd: Disable interrupts in probe error path
...
Disable interrupts in error path of probe function.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Cc: stable@vger.kernel.org
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/r/20230516134318.104279-7-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-05-17 09:02:40 +02:00
Jimmy Assarsson
262d7a52ba
can: kvaser_pciefd: Do not send EFLUSH command on TFD interrupt
...
Under certain circumstances we send two EFLUSH commands, resulting in two
EFLUSH ack packets, while only expecting a single EFLUSH ack.
This can cause the driver Tx flush completion to get out of sync.
To avoid this problem, don't enable the "Transmit buffer flush done" (TFD)
interrupt and remove the code handling it.
Now we only send EFLUSH command after receiving status packet with
"Init detected" (IDET) bit set.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Cc: stable@vger.kernel.org
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/r/20230516134318.104279-6-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-05-17 09:02:40 +02:00
Jimmy Assarsson
c589557dd1
can: kvaser_pciefd: Empty SRB buffer in probe
...
Empty the "Shared receive buffer" (SRB) in probe, to assure we start in a
known state, and don't process any irrelevant packets.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Cc: stable@vger.kernel.org
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/r/20230516134318.104279-5-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-05-17 09:02:40 +02:00
Jimmy Assarsson
84762d8da8
can: kvaser_pciefd: Call request_irq() before enabling interrupts
...
Make sure the interrupt handler is registered before enabling interrupts.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Cc: stable@vger.kernel.org
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/r/20230516134318.104279-4-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-05-17 09:02:40 +02:00
Jimmy Assarsson
bf7ac55e99
can: kvaser_pciefd: Clear listen-only bit if not explicitly requested
...
The listen-only bit was never cleared, causing the controller to
always use listen-only mode, if previously set.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Cc: stable@vger.kernel.org
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/r/20230516134318.104279-3-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-05-17 09:02:40 +02:00
Jimmy Assarsson
aed0e6ca7d
can: kvaser_pciefd: Set CAN_STATE_STOPPED in kvaser_pciefd_stop()
...
Set can.state to CAN_STATE_STOPPED in kvaser_pciefd_stop().
Without this fix, wrong CAN state was repported after the interface was
brought down.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Cc: stable@vger.kernel.org
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/r/20230516134318.104279-2-extja@kvaser.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-05-17 09:02:39 +02:00
Cai Huoqing
8db931835f
can: kvaser_pciefd: Remove redundant pci_clear_master
...
Remove pci_clear_master to simplify the code,
the bus-mastering is also cleared in do_pci_disable_device,
like this:
./drivers/pci/pci.c:2197
static void do_pci_disable_device(struct pci_dev *dev)
{
u16 pci_command;
pci_read_config_word(dev, PCI_COMMAND, &pci_command);
if (pci_command & PCI_COMMAND_MASTER) {
pci_command &= ~PCI_COMMAND_MASTER;
pci_write_config_word(dev, PCI_COMMAND, pci_command);
}
pcibios_disable_device(dev);
}.
And dev->is_busmaster is set to 0 in pci_disable_device.
Signed-off-by: Cai Huoqing <cai.huoqing@linux.dev >
Link: https://lore.kernel.org/all/20230323113318.9473-3-cai.huoqing@linux.dev
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2023-03-24 19:11:20 +01:00
Oliver Hartkopp
ae64438be1
can: dev: fix skb drop check
...
In commit a6d190f8c7 ("can: skb: drop tx skb if in listen only
mode") the priv->ctrlmode element is read even on virtual CAN
interfaces that do not create the struct can_priv at startup. This
out-of-bounds read may lead to CAN frame drops for virtual CAN
interfaces like vcan and vxcan.
This patch mainly reverts the original commit and adds a new helper
for CAN interface drivers that provide the required information in
struct can_priv.
Fixes: a6d190f8c7 ("can: skb: drop tx skb if in listen only mode")
Reported-by: Dariusz Stojaczyk <Dariusz.Stojaczyk@opensynergy.com >
Cc: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Cc: Max Staudt <max@enpas.org >
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net >
Acked-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20221102095431.36831-1-socketcan@hartkopp.net
Cc: stable@vger.kernel.org # 6.0.x
[mkl: patch pch_can, too]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2022-11-07 14:00:27 +01:00
Jinpeng Cui
7912fc9905
can: kvaser_pciefd: remove redundant variable ret
...
Return value directly from readl_poll_timeout() instead of
getting value from redundant variable ret.
Reported-by: Zeal Robot <zealci@zte.com.cn >
Signed-off-by: Jinpeng Cui <cui.jinpeng2@zte.com.cn >
Link: https://lore.kernel.org/all/20220831150805.305106-1-cui.jinpeng2@zte.com.cn
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2022-09-05 22:00:43 +02:00
Vincent Mailhol
fa5cc7e115
can: kvaser_pciefd: advertise timestamping capabilities and add ioctl support
...
Currently, userland has no method to query which timestamping features
are supported by the kvaser_pciefd driver (aside maybe of getting RX
messages and observe whether or not hardware timestamps stay at zero).
The canonical way for a network driver to advertise what kind of
timestamping it supports is to implement
ethtool_ops::get_ts_info(). Here, we use the CAN specific
can_ethtool_op_get_ts_info_hwts() function to achieve this.
In addition, the driver currently does not support the hardware
timestamps ioctls. According to [1], SIOCSHWTSTAMP is "must" and
SIOCGHWTSTAMP is "should". This patch fills up that gap by
implementing net_device_ops::ndo_eth_ioctl() using the CAN specific
function can_eth_ioctl_hwts().
[1] kernel doc Timestamping, section 3.1: "Hardware Timestamping
Implementation: Device Drivers"
Link: https://docs.kernel.org/networking/timestamping.html#hardware-timestamping-implementation-device-drivers
CC: Jimmy Assarsson <extja@kvaser.com >
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/all/20220727101641.198847-12-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2022-07-28 11:44:30 +02:00
Vincent Mailhol
3e5c291c79
can: add CAN_ERR_CNT flag to notify availability of error counter
...
Add a dedicated flag in uapi/linux/can/error.h to notify the userland
that fields data[6] and data[7] of the CAN error frame were
respectively populated with the tx and rx error counters.
For all driver tree-wide, set up this flags whenever needed.
Link: https://lore.kernel.org/all/20220719143550.3681-12-mailhol.vincent@wanadoo.fr
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2022-07-20 09:27:37 +02:00
Vincent Mailhol
8e674ca742
can: do not increase rx_bytes statistics for RTR frames
...
The actual payload length of the CAN Remote Transmission Request (RTR)
frames is always 0, i.e. no payload is transmitted on the wire.
However, those RTR frames still use the DLC to indicate the length of
the requested frame.
As such, net_device_stats::rx_bytes should not be increased for the
RTR frames.
This patch fixes all the CAN drivers.
Link: https://lore.kernel.org/all/20211207121531.42941-5-mailhol.vincent@wanadoo.fr
Cc: Marc Kleine-Budde <mkl@pengutronix.de >
Cc: Nicolas Ferre <nicolas.ferre@microchip.com >
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com >
Cc: Ludovic Desroches <ludovic.desroches@microchip.com >
Cc: Chandrasekar Ramakrishnan <rcsekar@samsung.com >
Cc: Maxime Ripard <mripard@kernel.org >
Cc: Chen-Yu Tsai <wens@csie.org >
Cc: Jernej Skrabec <jernej.skrabec@gmail.com >
Cc: Yasushi SHOJI <yashi@spacecubics.com >
Cc: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com >
Cc: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com >
Cc: Michal Simek <michal.simek@xilinx.com >
Cc: Stephane Grosjean <s.grosjean@peak-system.com >
Tested-by: Jimmy Assarsson <extja@kvaser.com > # kvaser
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Acked-by: Stefan Mätje <stefan.maetje@esd.eu > # esd_usb2
Tested-by: Stefan Mätje <stefan.maetje@esd.eu > # esd_usb2
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2022-01-05 12:09:05 +01:00
Vincent Mailhol
676068db69
can: do not increase rx statistics when generating a CAN rx error message frame
...
The CAN error message frames (i.e. error skb) are an interface
specific to socket CAN. The payload of the CAN error message frames
does not correspond to any actual data sent on the wire. Only an error
flag and a delimiter are transmitted when an error occurs (c.f. ISO
11898-1 section 10.4.4.2 "Error flag").
For this reason, it makes no sense to increment the rx_packets and
rx_bytes fields of struct net_device_stats because no actual payload
were transmitted on the wire.
This patch fixes all the CAN drivers.
Link: https://lore.kernel.org/all/20211207121531.42941-2-mailhol.vincent@wanadoo.fr
CC: Marc Kleine-Budde <mkl@pengutronix.de >
CC: Nicolas Ferre <nicolas.ferre@microchip.com >
CC: Alexandre Belloni <alexandre.belloni@bootlin.com >
CC: Ludovic Desroches <ludovic.desroches@microchip.com >
CC: Chandrasekar Ramakrishnan <rcsekar@samsung.com >
CC: Maxime Ripard <mripard@kernel.org >
CC: Chen-Yu Tsai <wens@csie.org >
CC: Jernej Skrabec <jernej.skrabec@gmail.com >
CC: Appana Durga Kedareswara rao <appana.durga.rao@xilinx.com >
CC: Naga Sureshkumar Relli <naga.sureshkumar.relli@xilinx.com >
CC: Michal Simek <michal.simek@xilinx.com >
CC: Stephane Grosjean <s.grosjean@peak-system.com >
Tested-by: Jimmy Assarsson <extja@kvaser.com > # kvaser
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Acked-by: Stefan Mätje <stefan.maetje@esd.eu > # esd_usb2
Tested-by: Stefan Mätje <stefan.maetje@esd.eu > # esd_usb2
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2022-01-05 12:09:05 +01:00
Jimmy Assarsson
36aea60fc8
can: kvaser_pciefd: kvaser_pciefd_rx_error_frame(): increase correct stats->{rx,tx}_errors counter
...
Check the direction bit in the error frame packet (EPACK) to determine
which net_device_stats {rx,tx}_errors counter to increase.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Link: https://lore.kernel.org/all/20211208152122.250852-1-extja@kvaser.com
Cc: stable@vger.kernel.org
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2021-12-09 09:01:43 +01:00
Jimmy Assarsson
7c6e6bce08
can: kvaser_pciefd: Always disable bus load reporting
...
Under certain circumstances, when switching from Kvaser's linuxcan driver
(kvpciefd) to the SocketCAN driver (kvaser_pciefd), the bus load reporting
is not disabled.
This is flooding the kernel log with prints like:
[3485.574677] kvaser_pciefd 0000:02:00.0: Received unexpected packet type 0x00000009
Always put the controller in the expected state, instead of assuming that
bus load reporting is inactive.
Note: If bus load reporting is enabled when the driver is loaded, you will
still get a number of bus load packages (and printouts), before it is
disabled.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Link: https://lore.kernel.org/r/20210309091724.31262-1-jimmyassarsson@gmail.com
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2021-03-16 08:41:26 +01:00
Marc Kleine-Budde
9420e1d495
can: dev: can_get_echo_skb(): extend to return can frame length
...
In order to implement byte queue limits (bql) in CAN drivers, the length of the
CAN frame needs to be passed into the networking stack after queueing and after
transmission completion.
To avoid to calculate this length twice, extend can_get_echo_skb() to return
that value. Convert all users of this function, too.
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/r/20210111141930.693847-14-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2021-01-14 08:43:43 +01:00
Vincent Mailhol
1dcb6e57db
can: dev: can_put_echo_skb(): extend to handle frame_len
...
Add a frame_len argument to can_put_echo_skb() which is used to save length of
the CAN frame into field frame_len of struct can_skb_priv so that it can be
later used after transmission completion. Convert all users of this function,
too.
Drivers which implement BQL call can_put_echo_skb() with the output of
can_skb_get_frame_len(skb) and drivers which do not simply pass zero as an
input (in the same way that NULL would be given to can_get_echo_skb()). This
way, we have a nice symmetry between the two echo functions.
Link: https://lore.kernel.org/r/20210111061335.39983-1-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Link: https://lore.kernel.org/r/20210111141930.693847-13-mkl@pengutronix.de
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
2021-01-14 08:43:43 +01:00
Jakub Kicinski
55fd59b003
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
...
Conflicts:
drivers/net/ethernet/ibm/ibmvnic.c
Signed-off-by: Jakub Kicinski <kuba@kernel.org >
2020-12-03 15:44:09 -08:00
Zhang Qilong
13a84cf37a
can: kvaser_pciefd: kvaser_pciefd_open(): fix error handling
...
If kvaser_pciefd_bus_on() failed, we should call close_candev() to avoid
reference leak.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com >
Link: https://lore.kernel.org/r/20201128133922.3276973-3-zhangqilong3@huawei.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2020-11-30 12:43:55 +01:00
Oliver Hartkopp
3ab4ce0d6f
can: rename CAN FD related can_len2dlc and can_dlc2len helpers
...
The helper functions can_len2dlc and can_dlc2len are only relevant for
CAN FD data length code (DLC) conversion.
To fit the introduced can_cc_dlc2len for Classical CAN we rename:
can_dlc2len -> can_fd_dlc2len to get the payload length from the DLC
can_len2dlc -> can_fd_len2dlc to get the DLC from the payload length
Suggested-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr >
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net >
Link: https://lore.kernel.org/r/20201110101852.1973-6-socketcan@hartkopp.net
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2020-11-20 12:05:14 +01:00
Oliver Hartkopp
c7b7496779
can: replace can_dlc as variable/element for payload length
...
The naming of can_dlc as element of struct can_frame and also as variable
name is misleading as it claims to be a 'data length CODE' but in reality
it always was a plain data length.
With the indroduction of a new 'len' element in struct can_frame we can now
remove can_dlc as name and make clear which of the former uses was a plain
length (-> 'len') or a data length code (-> 'dlc') value.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net >
Link: https://lore.kernel.org/r/20201120100444.3199-1-socketcan@hartkopp.net
[mkl: gs_usb: keep struct gs_host_frame::can_dlc as is]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2020-11-20 12:04:12 +01:00
Jimmy Assarsson
470e14c00c
can: kvaser_pciefd: Fix KCAN bittiming limits
...
Use correct bittiming limits for the KCAN CAN controller.
Fixes: 26ad340e58 ("can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices")
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Link: https://lore.kernel.org/r/20201115163027.16851-1-jimmyassarsson@gmail.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2020-11-18 09:06:35 +01:00
Christer Beskow
ec44dd5790
can: kvaser_pciefd: the PWM generator is running at the bus frequency of the system.
...
The system clock frequency for the bus connected to the PCIe controller
shall be used when calculating the frequency of the PWM, not the CAN
system clock frequency.
Signed-off-by: Christer Beskow <chbe@kvaser.com >
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2019-09-03 10:23:57 +02:00
YueHaibing
5549369cfd
can: kvaser_pciefd: Remove unused including <linux/version.h>
...
Remove including <linux/version.h> that don't need it.
Reported-by: Hulk Robot <hulkci@huawei.com >
Signed-off-by: YueHaibing <yuehaibing@huawei.com >
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2019-08-13 16:37:03 +02:00
Christer Beskow
1910cd8853
can: kvaser_pciefd: kvaser_pciefd_pwm_stop(): remove unnecessary code when setting pwm duty cycle to zero
...
To set the duty cycle to zero (i.e. pwm_stop), the trigger value shall
be equal to the top value.
This is achieved by reading the value of the top bit field from the pwm
register and then writing back this value to the trigger and top bit
fields.
Addresses-Coverity: ("Logically dead code")
Reported-by: Colin Ian King <colin.king@canonical.com >
Signed-off-by: Christer Beskow <chbe@kvaser.com >
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2019-08-13 16:36:52 +02:00
Henning Colliander
26ad340e58
can: kvaser_pciefd: Add driver for Kvaser PCIEcan devices
...
This patch adds support for Kvaser PCIEcan devices. This includes
support for up to 4 CAN channels on a single card, depending on device.
Signed-off-by: Henning Colliander <henning.colliander@evidente.se >
Signed-off-by: Jimmy Assarsson <extja@kvaser.com >
Signed-off-by: Christer Beskow <chbe@kvaser.com >
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de >
2019-07-24 10:31:53 +02:00