Some internal kernel virtio API functions are inline macros, so define their symbols in a helper file.
Signed-off-by: Manos Pitsidianakis <[email protected]> --- MAINTAINERS | 6 ++++++ rust/helpers/helpers.c | 3 +++ rust/helpers/virtio.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index d1cc0e12fe1f004da89b1aa339116908f642e894..48c9c666d90b5a256ab6fae1f42508b789a0ce50 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -27930,6 +27930,12 @@ F: include/uapi/linux/virtio_*.h F: net/vmw_vsock/virtio* F: tools/virtio/ +VIRTIO CORE API BINDINGS [RUST] +M: Manos Pitsidianakis <[email protected]> +L: [email protected] +S: Maintained +F: rust/helpers/virtio.c + VIRTIO CRYPTO DRIVER M: Gonglei <[email protected]> L: [email protected] diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c index a3c42e51f00a0990bea81ebce6e99bb397ce7533..84b54690d95be37699ef9a9c4d7cedec0bbae6d3 100644 --- a/rust/helpers/helpers.c +++ b/rust/helpers/helpers.c @@ -62,6 +62,9 @@ #include "uaccess.c" #include "usb.c" #include "vmalloc.c" +#if defined(CONFIG_VIRTIO) +#include "virtio.c" +#endif /* defined(CONFIG_VIRTIO) */ #include "wait.c" #include "workqueue.c" #include "xarray.c" diff --git a/rust/helpers/virtio.c b/rust/helpers/virtio.c new file mode 100644 index 0000000000000000000000000000000000000000..cd8a811d59960e7b6aea1c08016f4154b29d5a97 --- /dev/null +++ b/rust/helpers/virtio.c @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/virtio_config.h> + +__rust_helper bool +rust_helper_virtio_has_feature(const struct virtio_device *vdev, + unsigned int fbit) +{ + return virtio_has_feature(vdev, fbit); +} +__rust_helper void rust_helper_virtio_get_features(struct virtio_device *vdev, + u64 *features_out) +{ + return virtio_get_features(vdev, features_out); +} + +__rust_helper int rust_helper_virtio_find_vqs(struct virtio_device *vdev, + unsigned int nvqs, + struct virtqueue *vqs[], + struct virtqueue_info vqs_info[], + struct irq_affinity *desc) +{ + return virtio_find_vqs(vdev, nvqs, vqs, vqs_info, desc); +} + +__rust_helper void rust_helper_virtio_device_ready(struct virtio_device *dev) +{ + return virtio_device_ready(dev); +} + +__rust_helper bool +rust_helper_virtio_is_little_endian(struct virtio_device *vdev) +{ + return virtio_is_little_endian(vdev); +} -- 2.47.3

