| // Copyright 2018 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef _LINUX_VIRTIO_MAGMA_H |
| #define _LINUX_VIRTIO_MAGMA_H |
| |
| #include <linux/virtio_ids.h> |
| #include <linux/virtio_config.h> |
| #include <linux/virtmagma.h> |
| |
| |
| |
| |
| enum virtio_magma_ctrl_type { |
| /* magma commands */ |
| VIRTIO_MAGMA_CMD_GET_DRIVER = 0x0400, |
| VIRTIO_MAGMA_CMD_QUERY, |
| VIRTIO_MAGMA_CMD_CREATE_CONNECTION, |
| VIRTIO_MAGMA_CMD_RELEASE_CONNECTION, |
| VIRTIO_MAGMA_CMD_GET_ERROR, |
| VIRTIO_MAGMA_CMD_CREATE_CONTEXT, |
| VIRTIO_MAGMA_CMD_RELEASE_CONTEXT, |
| VIRTIO_MAGMA_CMD_CREATE_BUFFER, |
| VIRTIO_MAGMA_CMD_RELEASE_BUFFER, |
| VIRTIO_MAGMA_CMD_GET_BUFFER_ID, |
| VIRTIO_MAGMA_CMD_GET_BUFFER_SIZE, |
| VIRTIO_MAGMA_CMD_CLEAN_CACHE, |
| VIRTIO_MAGMA_CMD_SET_CACHE_POLICY, |
| VIRTIO_MAGMA_CMD_MAP, |
| VIRTIO_MAGMA_CMD_MAP_ALIGNED, |
| VIRTIO_MAGMA_CMD_MAP_SPECIFIC, |
| VIRTIO_MAGMA_CMD_UNMAP, |
| VIRTIO_MAGMA_CMD_MAP_BUFFER_GPU, |
| VIRTIO_MAGMA_CMD_UNMAP_BUFFER_GPU, |
| VIRTIO_MAGMA_CMD_COMMIT_BUFFER, |
| VIRTIO_MAGMA_CMD_EXPORT, |
| VIRTIO_MAGMA_CMD_IMPORT, |
| VIRTIO_MAGMA_CMD_CREATE_COMMAND_BUFFER, |
| VIRTIO_MAGMA_CMD_RELEASE_COMMAND_BUFFER, |
| VIRTIO_MAGMA_CMD_SUBMIT_COMMAND_BUFFER, |
| VIRTIO_MAGMA_CMD_EXECUTE_IMMEDIATE_COMMANDS, |
| VIRTIO_MAGMA_CMD_CREATE_SEMAPHORE, |
| VIRTIO_MAGMA_CMD_RELEASE_SEMAPHORE, |
| VIRTIO_MAGMA_CMD_GET_SEMAPHORE_ID, |
| VIRTIO_MAGMA_CMD_SIGNAL_SEMAPHORE, |
| VIRTIO_MAGMA_CMD_RESET_SEMAPHORE, |
| VIRTIO_MAGMA_CMD_WAIT_SEMAPHORES, |
| VIRTIO_MAGMA_CMD_EXPORT_SEMAPHORE, |
| VIRTIO_MAGMA_CMD_IMPORT_SEMAPHORE, |
| VIRTIO_MAGMA_CMD_READ_NOTIFICATION_CHANNEL, |
| /* magma success responses */ |
| VIRTIO_MAGMA_RESP_GET_DRIVER = 0x1180, |
| VIRTIO_MAGMA_RESP_QUERY, |
| VIRTIO_MAGMA_RESP_CREATE_CONNECTION, |
| VIRTIO_MAGMA_RESP_RELEASE_CONNECTION, |
| VIRTIO_MAGMA_RESP_GET_ERROR, |
| VIRTIO_MAGMA_RESP_CREATE_CONTEXT, |
| VIRTIO_MAGMA_RESP_RELEASE_CONTEXT, |
| VIRTIO_MAGMA_RESP_CREATE_BUFFER, |
| VIRTIO_MAGMA_RESP_RELEASE_BUFFER, |
| VIRTIO_MAGMA_RESP_GET_BUFFER_ID, |
| VIRTIO_MAGMA_RESP_GET_BUFFER_SIZE, |
| VIRTIO_MAGMA_RESP_CLEAN_CACHE, |
| VIRTIO_MAGMA_RESP_SET_CACHE_POLICY, |
| VIRTIO_MAGMA_RESP_MAP, |
| VIRTIO_MAGMA_RESP_MAP_ALIGNED, |
| VIRTIO_MAGMA_RESP_MAP_SPECIFIC, |
| VIRTIO_MAGMA_RESP_UNMAP, |
| VIRTIO_MAGMA_RESP_MAP_BUFFER_GPU, |
| VIRTIO_MAGMA_RESP_UNMAP_BUFFER_GPU, |
| VIRTIO_MAGMA_RESP_COMMIT_BUFFER, |
| VIRTIO_MAGMA_RESP_EXPORT, |
| VIRTIO_MAGMA_RESP_IMPORT, |
| VIRTIO_MAGMA_RESP_CREATE_COMMAND_BUFFER, |
| VIRTIO_MAGMA_RESP_RELEASE_COMMAND_BUFFER, |
| VIRTIO_MAGMA_RESP_SUBMIT_COMMAND_BUFFER, |
| VIRTIO_MAGMA_RESP_EXECUTE_IMMEDIATE_COMMANDS, |
| VIRTIO_MAGMA_RESP_CREATE_SEMAPHORE, |
| VIRTIO_MAGMA_RESP_RELEASE_SEMAPHORE, |
| VIRTIO_MAGMA_RESP_GET_SEMAPHORE_ID, |
| VIRTIO_MAGMA_RESP_SIGNAL_SEMAPHORE, |
| VIRTIO_MAGMA_RESP_RESET_SEMAPHORE, |
| VIRTIO_MAGMA_RESP_WAIT_SEMAPHORES, |
| VIRTIO_MAGMA_RESP_EXPORT_SEMAPHORE, |
| VIRTIO_MAGMA_RESP_IMPORT_SEMAPHORE, |
| VIRTIO_MAGMA_RESP_READ_NOTIFICATION_CHANNEL, |
| /* magma error responses */ |
| VIRTIO_MAGMA_RESP_ERR_UNIMPLEMENTED = 0x1280, |
| VIRTIO_MAGMA_RESP_ERR_INTERNAL, |
| VIRTIO_MAGMA_RESP_ERR_HOST_DISCONNECTED, |
| VIRTIO_MAGMA_RESP_ERR_OUT_OF_MEMORY, |
| VIRTIO_MAGMA_RESP_ERR_INVALID_COMMAND, |
| VIRTIO_MAGMA_RESP_ERR_INVALID_ARGUMENT, |
| }; |
| |
| struct virtio_magma_ctrl_hdr { |
| __le32 type; |
| __le32 flags; |
| }; |
| |
| struct virtio_magma_get_driver { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le32 page_size; |
| }; |
| |
| struct virtio_magma_get_driver_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 pfn; |
| __le64 size; |
| }; |
| |
| struct virtio_magma_query { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 field_id; |
| }; |
| |
| struct virtio_magma_query_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 field_value_out; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_create_connection { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_create_connection_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection_return; |
| }; |
| |
| struct virtio_magma_release_connection { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| }; |
| |
| struct virtio_magma_release_connection_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_get_error { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| }; |
| |
| struct virtio_magma_get_error_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_create_context { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| }; |
| |
| struct virtio_magma_create_context_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le32 context_id_out; |
| }; |
| |
| struct virtio_magma_release_context { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le32 context_id; |
| }; |
| |
| struct virtio_magma_release_context_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_create_buffer { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 size; |
| }; |
| |
| struct virtio_magma_create_buffer_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 size_out; |
| __le64 buffer_out; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_release_buffer { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| }; |
| |
| struct virtio_magma_release_buffer_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_get_buffer_id { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 buffer; |
| }; |
| |
| struct virtio_magma_get_buffer_id_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 id_return; |
| }; |
| |
| struct virtio_magma_get_buffer_size { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 buffer; |
| }; |
| |
| struct virtio_magma_get_buffer_size_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 size_return; |
| }; |
| |
| struct virtio_magma_clean_cache { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 buffer; |
| __le64 offset; |
| __le64 size; |
| __le32 operation; |
| }; |
| |
| struct virtio_magma_clean_cache_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_set_cache_policy { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 buffer; |
| __le32 policy; |
| }; |
| |
| struct virtio_magma_set_cache_policy_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_map { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| }; |
| |
| struct virtio_magma_map_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 addr_out; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_map_aligned { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| __le64 alignment; |
| }; |
| |
| struct virtio_magma_map_aligned_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 addr_out; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_map_specific { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| __le64 addr; |
| }; |
| |
| struct virtio_magma_map_specific_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_unmap { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| }; |
| |
| struct virtio_magma_unmap_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_map_buffer_gpu { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| __le64 page_offset; |
| __le64 page_count; |
| __le64 gpu_va; |
| __le64 map_flags; |
| }; |
| |
| struct virtio_magma_map_buffer_gpu_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_unmap_buffer_gpu { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| __le64 gpu_va; |
| }; |
| |
| struct virtio_magma_unmap_buffer_gpu_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_commit_buffer { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| __le64 page_offset; |
| __le64 page_count; |
| }; |
| |
| struct virtio_magma_commit_buffer_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_export { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| }; |
| |
| struct virtio_magma_export_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le32 buffer_handle_out; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_import { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| }; |
| |
| struct virtio_magma_import_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 buffer_out; |
| __le32 buffer_handle; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_create_command_buffer { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 size; |
| }; |
| |
| struct virtio_magma_create_command_buffer_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 buffer_out; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_release_command_buffer { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 command_buffer; |
| }; |
| |
| struct virtio_magma_release_command_buffer_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_submit_command_buffer { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 command_buffer; |
| __le32 context_id; |
| }; |
| |
| struct virtio_magma_submit_command_buffer_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_execute_immediate_commands { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 command_count; |
| __le64 commands; // magma_system_inline_command_buffer[command_count] |
| __le32 context_id; |
| }; |
| |
| struct virtio_magma_execute_immediate_commands_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_create_semaphore { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| }; |
| |
| struct virtio_magma_create_semaphore_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 semaphore_out; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_release_semaphore { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 semaphore; |
| }; |
| |
| struct virtio_magma_release_semaphore_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_get_semaphore_id { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 semaphore; |
| }; |
| |
| struct virtio_magma_get_semaphore_id_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 id_return; |
| }; |
| |
| struct virtio_magma_signal_semaphore { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 semaphore; |
| }; |
| |
| struct virtio_magma_signal_semaphore_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_reset_semaphore { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 semaphore; |
| }; |
| |
| struct virtio_magma_reset_semaphore_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_wait_semaphores { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 timeout_ms; |
| __le64 semaphores; // magma_semaphore_t[count] |
| __le32 count; |
| __le32 status_return; |
| char wait_all; |
| }; |
| |
| struct virtio_magma_wait_semaphores_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| }; |
| |
| struct virtio_magma_export_semaphore { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 semaphore; |
| __le64 connection; |
| }; |
| |
| struct virtio_magma_export_semaphore_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le32 semaphore_handle_out; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_import_semaphore { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le32 semaphore_handle; |
| }; |
| |
| struct virtio_magma_import_semaphore_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 semaphore_out; |
| __le32 status_return; |
| }; |
| |
| struct virtio_magma_read_notification_channel { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 connection; |
| __le64 buffer; |
| __le64 buffer_size; |
| }; |
| |
| struct virtio_magma_read_notification_channel_resp { |
| struct virtio_magma_ctrl_hdr hdr; |
| __le64 buffer_size_out; |
| __le32 status_return; |
| }; |
| |
| |
| #endif // _LINUX_VIRTIO_MAGMA_H |