From 42fa1204ec026ba16526ef4bca85dfa9ed2d6225 Mon Sep 17 00:00:00 2001 From: Timos Ampelikiotis Date: Tue, 9 Jan 2024 14:38:17 +0000 Subject: [PATCH] vhost-device-can: Add initial implementation This implementation supports the exchange of CAN/CANFD messages virtual ("vcan") and real HW CAN device ("can0"). It was tested with: a) virtio-can driver found in the following patch serie: - https://lwn.net/Articles/934187/ b) QEMU's vhost-user-can device: 1) Option 1: Upstream QEMU's vhost-user-device qemu-system-x86_64 \ -m 4096 \ -numa node,memdev=mem \ -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \ -chardev socket,id=char1,path=/tmp/can.sock \ -device vhost-user-device-pci,chardev=char1,virtio-id=36,num_vqs=3,config_size=16 \ ... 2) Option 2: A new QEMU vhost-user-can device can be found in the following repo: - https://github.com/virtualopensystems/qemu/tree/vhu-can-rfc For more information, please check the README.md file under "staging/vhost-device-can/". Signed-off-by: Timos Ampelikiotis --- README.md | 1 + staging/Cargo.toml | 1 + staging/coverage_config_x86_64.json | 2 +- staging/vhost-device-can/CHANGELOG.md | 15 + staging/vhost-device-can/Cargo.toml | 41 + staging/vhost-device-can/LICENSE-APACHE | 1 + staging/vhost-device-can/LICENSE-BSD-3-Clause | 1 + staging/vhost-device-can/README.md | 147 ++ staging/vhost-device-can/src/backend.rs | 268 ++ staging/vhost-device-can/src/can.rs | 393 +++ staging/vhost-device-can/src/main.rs | 96 + staging/vhost-device-can/src/vhu_can.rs | 2145 +++++++++++++++++ staging/vhost-device-can/src/virtio_can.rs | 144 ++ 13 files changed, 3254 insertions(+), 1 deletion(-) create mode 100644 staging/vhost-device-can/CHANGELOG.md create mode 100644 staging/vhost-device-can/Cargo.toml create mode 120000 staging/vhost-device-can/LICENSE-APACHE create mode 120000 staging/vhost-device-can/LICENSE-BSD-3-Clause create mode 100644 staging/vhost-device-can/README.md create mode 100644 staging/vhost-device-can/src/backend.rs create mode 100644 staging/vhost-device-can/src/can.rs create mode 100644 staging/vhost-device-can/src/main.rs create mode 100644 staging/vhost-device-can/src/vhu_can.rs create mode 100644 staging/vhost-device-can/src/virtio_can.rs diff --git a/README.md b/README.md index 6f864e8..f3fb8cd 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ More information may be found in its [README file](./staging/README.md). Here is the list of device backends in **staging**: - [Video](https://github.com/rust-vmm/vhost-device/blob/main/staging/vhost-device-video/README.md) +- [Can](https://github.com/rust-vmm/vhost-device/blob/main/staging/vhost-device-can/README.md)