On Wed, Oct 29, 2025 at 06:40:45PM +0100, Matias Ezequiel Vara Larsen wrote: > Add virtio CAN driver based on Virtio 1.4 specification (see > https://github.com/oasis-tcs/virtio-spec/tree/virtio-1.4). The driver > implements a complete CAN bus interface over Virtio transport, > supporting both CAN Classic and CAN-FD Ids. In term of frames, it > supports classic and CAN FD. RTR frames are only supported with classic > CAN. > > Usage: > - "ip link set up can0" - start controller > - "ip link set down can0" - stop controller > - "candump can0" - receive frames > - "cansend can0 123#DEADBEEF" - send frames > > Signed-off-by: Harald Mommer <[email protected]> > Signed-off-by: Mikhail Golubev-Ciuchea > <[email protected]> > Co-developed-by: Marc Kleine-Budde <[email protected]> > Signed-off-by: Marc Kleine-Budde <[email protected]> > Cc: Damir Shaikhutdinov <[email protected]> > Signed-off-by: Matias Ezequiel Vara Larsen <[email protected]> > --- > V6: > * Address nits (see > > https://lore.kernel.org/all/aO0JjDGk2zLlzB1E@fedora/T/#mc7221192856d557da9c0da2b47e4343dfea0ca2f) > * Check for error during register_virtio_can() > * Remove virtio_device_ready() > * Allocate virtio_can_rx rpkt[] at probe > * Define virtio_can_control struct > * Return VIRTIO_CAN_RESULT_NOT_OK after unlocking > * Define sdu[] as a flex array for both tx and rx. For rx, use > VIRTIO_CAN_F_CAN_FD to figure out the max len for sdu > * Fix statistics in virtio_can_read_tx_queue() and > how we indicate error to the user when getting > VIRTIO_CAN_RESULT_NOT_OK > * Fix syntax of virtio_find_vqs() > * Drop tx_list > * Fix values of VIRTIO_CAN_F_LATE_TX_ACK and VIRTIO_CAN_F_RTR_FRAMES > * Tested with vhost-device-can > (see > https://github.com/rust-vmm/vhost-device/tree/main/vhost-device-can) > and qemu (see > https://github.com/virtualopensystems/qemu/tree/vhu-can-rfc) > > V5: > * Re-base on top of linux-next (next-20240103) > * Tested with https://github.com/OpenSynergy/qemu/tree/virtio-can-spec-rfc-v3 > > RFC V4: > * Apply reverse Christmas tree style > * Add member *classic_dlc to RX and TX CAN frames > * Fix race causing a NETDEV_TX_BUSY return > * Fix TX queue going stuck on -ENOMEM > * Update stats.tx_dropped on kzalloc() failure > * Replace "(err != 0)" with "(unlikely(err))" > * Use "ARRAY_SIZE(sgs)" > * Refactor SGs in virtio_can_send_ctrl_msg() > * Tested with https://github.com/OpenSynergy/qemu/tree/virtio-can-spec-rfc-v3 > > RFC V3: > * Incorporate patch "[PATCH] can: virtio-can: cleanups" from > > https://lore.kernel.org/all/[email protected]/ > * Add missing can_free_echo_skb() > * Replace home-brewed ID allocator with the standard one from kernel > * Simplify flow control > * Tested with https://github.com/OpenSynergy/qemu/tree/virtio-can-spec-rfc-v3 > > RFC V2: > * Remove the event indication queue and use the config space instead, to > indicate a bus off condition > * Rework RX and TX messages having a length field and some more fields for CAN > EXT > --- > MAINTAINERS | 7 + > drivers/net/can/Kconfig | 12 + > drivers/net/can/Makefile | 1 + > drivers/net/can/virtio_can.c | 1022 +++++++++++++++++++++++++++++++ > include/uapi/linux/virtio_can.h | 78 +++ > 5 files changed, 1120 insertions(+) > create mode 100644 drivers/net/can/virtio_can.c > create mode 100644 include/uapi/linux/virtio_can.h > > diff --git a/MAINTAINERS b/MAINTAINERS > index 80cd3498c293..14a738b8ecb2 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -27068,6 +27068,13 @@ F: drivers/scsi/virtio_scsi.c > F: include/uapi/linux/virtio_blk.h > F: include/uapi/linux/virtio_scsi.h > > +VIRTIO CAN DRIVER > +M: "Harald Mommer" <[email protected]> > +L: [email protected] > +S: Maintained > +F: drivers/net/can/virtio_can.c > +F: include/uapi/linux/virtio_can.h > +
So how will maintainance look like for this? Don't you want to co-maintain it, given you are submitting it? The maintainer is supposed to interact with linux. Probably a good idea to have this under VIRTIO CORE AND NET DRIVERS at least additionally, or alternatively add L: [email protected] > VIRTIO CONSOLE DRIVER > M: Amit Shah <[email protected]> > L: [email protected] > diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig > index d43d56694667..7b5806f11853 100644 > --- a/drivers/net/can/Kconfig > +++ b/drivers/net/can/Kconfig > @@ -217,6 +217,18 @@ config CAN_XILINXCAN > Xilinx CAN driver. This driver supports both soft AXI CAN IP and > Zynq CANPS IP. > > +config CAN_VIRTIO_CAN > + depends on VIRTIO > + tristate "Virtio CAN device support" > + default n > + help > + Say Y here if you want to support for Virtio CAN. > + > + To compile this driver as a module, choose M here: the > + module will be called virtio-can. > + > + If unsure, say N. > + > source "drivers/net/can/c_can/Kconfig" > source "drivers/net/can/cc770/Kconfig" > source "drivers/net/can/ctucanfd/Kconfig" > diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile > index 56138d8ddfd2..2ddea733ed5d 100644
