From 2c05932416e5f6b421f79a3250d88ffe4ce495c2 Mon Sep 17 00:00:00 2001 From: Vasyl Vavrychuk Date: Tue, 1 Nov 2022 22:04:36 +0100 Subject: virtualization: Add virtio-can driver as external module. This driver should conform RFC spec draft v2 [1]. This driver is based on RFC version [2]. Imported from internal OpenSynergy's revision: 3918336a7caab95a72442c33945a193ca893d5e8 Supply build file `Kbuild` and do not supply makefile [3] since external kernel module could be built without it. On the other hand, module BitBake class relies on wrapper makefile presence, therefore `MAKE_TARGETS` and `MODULES_INSTALL_TARGET` had to be set to specify arguments per [3]. Add driver as an external module to avoid unnecessary kernel rebuild and simplify future updates. [1]: https://lists.oasis-open.org/archives/virtio-dev/202208/msg00159.html [2]: https://lists.oasis-open.org/archives/virtio-dev/202208/msg00160.html [3]: https://www.kernel.org/doc/html/v6.0/kbuild/modules.html Change-Id: I9b654f58cc0c34983cd4103a5f7836263db79ec7 Bug-AGL: SPEC-4597 Signed-off-by: Vasyl Vavrychuk --- .../kernel-module-virtio-can/files/virtio_can.h | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 meta-egvirt/recipes-kernel/kernel-module-virtio-can/files/virtio_can.h (limited to 'meta-egvirt/recipes-kernel/kernel-module-virtio-can/files/virtio_can.h') diff --git a/meta-egvirt/recipes-kernel/kernel-module-virtio-can/files/virtio_can.h b/meta-egvirt/recipes-kernel/kernel-module-virtio-can/files/virtio_can.h new file mode 100644 index 00000000..0ca75c7a --- /dev/null +++ b/meta-egvirt/recipes-kernel/kernel-module-virtio-can/files/virtio_can.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Copyright (C) 2021 OpenSynergy GmbH + */ +#ifndef _LINUX_VIRTIO_VIRTIO_CAN_H +#define _LINUX_VIRTIO_VIRTIO_CAN_H + +#include +#include +#include +#include + +/* Feature bit numbers */ +#define VIRTIO_CAN_F_CAN_CLASSIC 0u +#define VIRTIO_CAN_F_CAN_FD 1u +#define VIRTIO_CAN_F_LATE_TX_ACK 2u +#define VIRTIO_CAN_F_RTR_FRAMES 3u + +/* CAN Result Types */ +#define VIRTIO_CAN_RESULT_OK 0u +#define VIRTIO_CAN_RESULT_NOT_OK 1u + +/* CAN flags to determine type of CAN Id */ +#define VIRTIO_CAN_FLAGS_EXTENDED 0x8000u +#define VIRTIO_CAN_FLAGS_FD 0x4000u +#define VIRTIO_CAN_FLAGS_RTR 0x2000u + +/* TX queue message types */ +struct virtio_can_tx_out { +#define VIRTIO_CAN_TX 0x0001u + __le16 msg_type; + __le16 reserved; + __le32 flags; + __le32 can_id; + __u8 sdu[64u]; +}; + +struct virtio_can_tx_in { + __u8 result; +}; + +/* RX queue message types */ +struct virtio_can_rx { +#define VIRTIO_CAN_RX 0x0101u + __le16 msg_type; + __le16 reserved; + __le32 flags; + __le32 can_id; + __u8 sdu[64u]; +}; + +/* Control queue message types */ +struct virtio_can_control_out { +#define VIRTIO_CAN_SET_CTRL_MODE_START 0x0201u +#define VIRTIO_CAN_SET_CTRL_MODE_STOP 0x0202u + __le16 msg_type; +}; + +struct virtio_can_control_in { + __u8 result; +}; + +/* Indication queue message types */ +struct virtio_can_event_ind { +#define VIRTIO_CAN_BUSOFF_IND 0x0301u + __le16 msg_type; +}; + +#endif /* #ifndef _LINUX_VIRTIO_VIRTIO_CAN_H */ -- cgit 1.2.3-korg