diff options
| -rw-r--r-- | drivers/soc/qcom/hab/hab.h | 1 | ||||
| -rw-r--r-- | include/linux/habmm.h | 307 | ||||
| -rw-r--r-- | include/uapi/linux/Kbuild | 3 | ||||
| -rw-r--r-- | include/uapi/linux/hab_ioctl.h | 101 | ||||
| -rw-r--r-- | include/uapi/linux/habmm.h | 177 | ||||
| -rw-r--r-- | include/uapi/linux/habmmid.h | 60 |
6 files changed, 458 insertions, 191 deletions
diff --git a/drivers/soc/qcom/hab/hab.h b/drivers/soc/qcom/hab/hab.h index dcf2c751df30..72635e70c94c 100644 --- a/drivers/soc/qcom/hab/hab.h +++ b/drivers/soc/qcom/hab/hab.h @@ -21,6 +21,7 @@ #include <linux/types.h> #include <linux/habmm.h> +#include <linux/hab_ioctl.h> #include <linux/kernel.h> #include <linux/interrupt.h> diff --git a/include/linux/habmm.h b/include/linux/habmm.h index 1c27ee4f14f7..b4b31dc36faf 100644 --- a/include/linux/habmm.h +++ b/include/linux/habmm.h @@ -10,30 +10,311 @@ * GNU General Public License for more details. * */ -#include <uapi/linux/habmm.h> -#ifndef _HABMM_H -#define _HABMM_H +#ifndef HABMM_H +#define HABMM_H + +#include <uapi/linux/habmmid.h> + +#define HAB_API_VER_DEF(_MAJOR_, _MINOR_) \ + ((_MAJOR_&0xFF)<<16 | (_MINOR_&0xFFF)) +#define HAB_API_VER HAB_API_VER_DEF(1, 0) + +#include <linux/types.h> + +/* habmm_socket_open + * + * Description: + * + * Establish a communication channel between Virtual Machines. Blocks + * until the connection is established between sender and receiver. + * Client can call this APImultiple times with the same name to connect + * to the same communication channel, the function returns a different context + * for every open for proper resource allocation and client identification. + * + * Params: + * out handle - An opaque handle associated with a successful virtual channel + * creation in MM_ID - multimedia ID used to allocate the physical channels to + * service all the virtual channels created through this open + * in timeout - timeout value specified by the client to avoid forever block + * in flags - future extension + * + * Return: + * status (success/failure/timeout) + * + */ + +/* single FE-BE connection multi-to-multi point to point matching (default) */ +#define HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_SINGLE_FE 0x00000000 +/* one BE for one domU */ +#define HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_SINGLE_DOMU 0x00000001 +/* one BE for all the domUs */ +#define HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_MULTI_DOMUS 0x00000002 int32_t habmm_socket_open(int32_t *handle, uint32_t mm_ip_id, - uint32_t timeout, uint32_t flags); + uint32_t timeout, uint32_t flags); + +/* habmm_socket_close + * + * Description: + * + * Tear down the virtual channel that was established through habmm_socket_open + * and release all resources associated with it. + * + * Params: + * + * in handle - handle to the virtual channel created by habmm_socket_open + * + * Return: + * status - (success/failure) + * + * + */ + int32_t habmm_socket_close(int32_t handle); + + +/* habmm_socket_send + * + * Description: + * + * Send data over the virtual channel + * + * Params: + * + * in handle - handle created by habmm_socket_open + * in src_buff - data to be send across the virtual channel + * inout size_bytes - size of the data to be send. Either the whole packet is + * sent or not + * in flags - future extension + * + * Return: + * status (success/fail/disconnected) + * + */ + +/* Non-blocking mode: function will return immediately with HAB_AGAIN + * if the send operation cannot be completed without blocking. + */ +#define HABMM_SOCKET_SEND_FLAGS_NON_BLOCKING 0x00000001 + +/* Collect cross-VM stats: client provides stat-buffer large enough to allow 2 + * sets of a 2-uint64_t pair to collect seconds and nano-seconds at the + * beginning of the stat-buffer. Stats are collected when the stat-buffer leaves + * VM1, then enters VM2 + */ +#define HABMM_SOCKET_SEND_FLAGS_XING_VM_STAT 0x00000002 + +struct habmm_xing_vm_stat { + uint64_t tx_sec; + uint64_t tx_usec; + uint64_t rx_sec; + uint64_t rx_usec; +}; + int32_t habmm_socket_send(int32_t handle, void *src_buff, uint32_t size_bytes, - uint32_t flags); + uint32_t flags); + + +/* habmm_socket_recv + * + * Description: + * + * Receive data over the virtual channel created by habmm_socket_open. + * Blocking until actual data is received or timeout value expires + * + * Params: + * + * in handle - communication channel created by habmm_socket_open + * inout dst_buff - buffer pointer to store received data + * inout size_bytes - size of the dst_buff. returned value shows the actual + * bytes received. + * in timeout - timeout value specified by the client to avoid forever block + * in flags - future extension + * + * + * Return: + * status (success/failure/timeout/disconnected) + * + */ + +/* Non-blocking mode: function will return immediately if there is no data + * available. Supported only for kernel clients. + */ +#define HABMM_SOCKET_RECV_FLAGS_NON_BLOCKING 0x00000001 + int32_t habmm_socket_recv(int32_t handle, void *dst_buff, uint32_t *size_bytes, - uint32_t timeout, uint32_t flags); + uint32_t timeout, uint32_t flags); + +/* habmm_socket_sendto + * + * Description: + * + * This is for backend only. Send data over the virtual channel to remote + * frontend virtual channel for multi-FEs-to-single-BE model when + * the BE virtual channel is created using + * HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_SINGLE_DOMU or + * HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_MULTI_DOMUS + * + * Params: + * + * in handle - handle created by habmm_socket_open + * in src_buff - data to be send across the virtual channel + * inout size_bytes - size of the data to be send. The packet is fully sent on + * success,or not sent at all upon any failure + * in remote_handle - the destination of this send using remote FE's virtual + * channel handle + * in flags - future extension + * + * Return: + * status (success/fail/disconnected) + */ int32_t habmm_socket_sendto(int32_t handle, void *src_buff, uint32_t size_bytes, - int32_t remote_handle, uint32_t flags); + int32_t remote_handle, uint32_t flags); + + +/* habmm_socket_recvfrom + * + * Description: + * + * Receive data over the virtual channel created by habmm_socket_open. + * Returned is the remote FE's virtual channel handle to be used for sendto. + * Blocking until actual data is received or timeout value expires. This is for + * BE running in multi-FEs-to-single-BE model when the BE virtual channel is + * created using HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_SINGLE_DOMU or + * HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_MULTI_DOMUS. + * + * Params: + * + * in handle - communication channel created by habmm_socket_open + * inout dst_buff - buffer pointer to store received data + * inout size_bytes - size of the dst_buff. returned value shows the actual + * bytes received. + * in timeout - timeout value specified by the client to avoid forever block + * in remote_handle - the FE who sent this message through the + * connected virtual channel to BE. + * in flags - future extension + * + * Return: + * status (success/failure/timeout/disconnected) + * + */ int32_t habmm_socket_recvfrom(int32_t handle, void *dst_buff, - uint32_t *size_bytes, uint32_t timeout, - int32_t *remote_handle, uint32_t flags); + uint32_t *size_bytes, uint32_t timeout, + int32_t *remote_handle, uint32_t flags); + +/* exporting memory type DMA : This is platform dependent for user mode. If it + * does exist, HAB needs to use DMA method to retrieve the memory for exporting. + * If it does not exist, this flag is ignored. + */ +#define HABMM_EXP_MEM_TYPE_DMA 0x00000001 + +#define HAB_MAX_EXPORT_SIZE 0x8000000 + +/* + * Description: + * + * Prepare the sharing of the buffer on the exporter side. The returned + * reference ID needs to be sent to importer separately. + * During sending the HAB will attach the actual exporting buffer information. + * The exporting is per process space. + * + * Params: + * + * in handle - communication channel created by habmm_socket_open + * in buff_to_share - buffer to be exported + * in size_bytes - size of the exporting buffer in bytes + * out export_id - to be returned by this call upon success + * in flags - future extension + * + * Return: + * status (success/failure) + * + */ int32_t habmm_export(int32_t handle, void *buff_to_share, uint32_t size_bytes, - uint32_t *export_id, uint32_t flags); + uint32_t *export_id, uint32_t flags); + +/* + * Description: + * + * Free any allocated resource associated with this export IDin on local side. + * Params: + * + * in handle - communication channel created by habmm_socket_open + * in export_id - all resource allocated with export_id are to be freed + * in flags - future extension + * + * Return: + * status (success/failure) + * + */ int32_t habmm_unexport(int32_t handle, uint32_t export_id, uint32_t flags); + +/* + * Description: + * + * Import the exporter's shared reference ID. + * The importing is per process space. + * + * Params: + * + * in handle - communication channel created by habmm_socket_open + * out buff_shared - buffer to be imported. returned upon success + * in size_bytes - size of the imported buffer in bytes. It should match the + * original exported buffer size + * in export_id - received when exporter sent its exporting ID through + * habmm_socket_send() previously + * in flags - future extension + * + * Return: + * status (success/failure) + * + */ + +/* Non-blocking mode: function will return immediately if there is no data + * available. Supported only for kernel clients. + */ +#define HABMM_IMPORT_FLAGS_CACHED 0x00000001 + int32_t habmm_import(int32_t handle, void **buff_shared, uint32_t size_bytes, - uint32_t export_id, uint32_t flags); + uint32_t export_id, uint32_t flags); + +/* + * Description: + * + * Release any resource associated with the export ID on the importer side. + * + * Params: + * + * in handle - communication channel created by habmm_socket_open + * in export_id - received when exporter sent its exporting ID through + * habmm_socket_send() previously + * in buff_shared - received from habmm_import() together with export_id + * in flags - future extension + * + * Return: + * status (success/failure) + * + */ int32_t habmm_unimport(int32_t handle, uint32_t export_id, void *buff_shared, - uint32_t flags); + uint32_t flags); + +/* + * Description: + * + * Query various information of the opened hab socket. + * + * Params: + * + * in handle - communication channel created by habmm_socket_open + * in habmm_socket_info - retrieve socket information regarding local and remote + * VMs + * in flags - future extension + * + * Return: + * status (success/failure) + * + */ struct hab_socket_info { int32_t vmid_remote; /* habmm's vmid */ @@ -46,4 +327,4 @@ struct hab_socket_info { int32_t habmm_socket_query(int32_t handle, struct hab_socket_info *info, uint32_t flags); -#endif +#endif /* HABMM_H */ diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild index a9a804bdd7a1..2604d3f387ba 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild @@ -529,4 +529,5 @@ header-y += ipa_qmi_service_v01.h header-y += rmnet_ipa_fd_ioctl.h header-y += msm_ipa.h header-y += smcinvoke.h -header-y += habmm.h +header-y += habmmid.h +header-y += hab_ioctl.h diff --git a/include/uapi/linux/hab_ioctl.h b/include/uapi/linux/hab_ioctl.h new file mode 100644 index 000000000000..83b5da236888 --- /dev/null +++ b/include/uapi/linux/hab_ioctl.h @@ -0,0 +1,101 @@ +#ifndef _HAB_IOCTL_H +#define _HAB_IOCTL_H + +#include <linux/types.h> + +struct hab_send { + __u64 data; + __s32 vcid; + __u32 sizebytes; + __u32 flags; +}; + +struct hab_recv { + __u64 data; + __s32 vcid; + __u32 sizebytes; + __u32 flags; +}; + +struct hab_open { + __s32 vcid; + __u32 mmid; + __u32 timeout; + __u32 flags; +}; + +struct hab_close { + __s32 vcid; + __u32 flags; +}; + +struct hab_export { + __u64 buffer; + __s32 vcid; + __u32 sizebytes; + __u32 exportid; + __u32 flags; +}; + +struct hab_import { + __u64 index; + __u64 kva; + __s32 vcid; + __u32 sizebytes; + __u32 exportid; + __u32 flags; +}; + +struct hab_unexport { + __s32 vcid; + __u32 exportid; + __u32 flags; +}; + + +struct hab_unimport { + __s32 vcid; + __u32 exportid; + __u64 kva; + __u32 flags; +}; + +struct hab_info { + __s32 vcid; + __u64 ids; /* high part remote; low part local */ + __u64 names; + __u32 namesize; /* single name length */ + __u32 flags; +}; + +#define HAB_IOC_TYPE 0x0A +#define HAB_MAX_MSG_SIZEBYTES 0x1000 + +#define IOCTL_HAB_SEND \ + _IOW(HAB_IOC_TYPE, 0x2, struct hab_send) + +#define IOCTL_HAB_RECV \ + _IOWR(HAB_IOC_TYPE, 0x3, struct hab_recv) + +#define IOCTL_HAB_VC_OPEN \ + _IOWR(HAB_IOC_TYPE, 0x4, struct hab_open) + +#define IOCTL_HAB_VC_CLOSE \ + _IOW(HAB_IOC_TYPE, 0x5, struct hab_close) + +#define IOCTL_HAB_VC_EXPORT \ + _IOWR(HAB_IOC_TYPE, 0x6, struct hab_export) + +#define IOCTL_HAB_VC_IMPORT \ + _IOWR(HAB_IOC_TYPE, 0x7, struct hab_import) + +#define IOCTL_HAB_VC_UNEXPORT \ + _IOW(HAB_IOC_TYPE, 0x8, struct hab_unexport) + +#define IOCTL_HAB_VC_UNIMPORT \ + _IOW(HAB_IOC_TYPE, 0x9, struct hab_unimport) + +#define IOCTL_HAB_VC_QUERY \ + _IOWR(HAB_IOC_TYPE, 0xA, struct hab_info) + +#endif /* _HAB_IOCTL_H */ diff --git a/include/uapi/linux/habmm.h b/include/uapi/linux/habmm.h deleted file mode 100644 index b1b6561f2552..000000000000 --- a/include/uapi/linux/habmm.h +++ /dev/null @@ -1,177 +0,0 @@ -#ifndef HABMM_H -#define HABMM_H - -#include <linux/types.h> - -struct hab_send { - __u64 data; - __s32 vcid; - __u32 sizebytes; - __u32 flags; -}; - -struct hab_recv { - __u64 data; - __s32 vcid; - __u32 sizebytes; - __u32 flags; -}; - -struct hab_open { - __s32 vcid; - __u32 mmid; - __u32 timeout; - __u32 flags; -}; - -struct hab_close { - __s32 vcid; - __u32 flags; -}; - -struct hab_export { - __u64 buffer; - __s32 vcid; - __u32 sizebytes; - __u32 exportid; - __u32 flags; -}; - -struct hab_import { - __u64 index; - __u64 kva; - __s32 vcid; - __u32 sizebytes; - __u32 exportid; - __u32 flags; -}; - -struct hab_unexport { - __s32 vcid; - __u32 exportid; - __u32 flags; -}; - -struct hab_unimport { - __s32 vcid; - __u32 exportid; - __u64 kva; - __u32 flags; -}; - -struct hab_info { - __s32 vcid; - __u64 ids; /* high part remote; low part local */ - __u64 names; - __u32 namesize; /* single name length */ - __u32 flags; -}; - -#define HAB_IOC_TYPE 0x0A -#define HAB_MAX_MSG_SIZEBYTES 0x1000 -#define HAB_MAX_EXPORT_SIZE 0x8000000 - -#define HAB_MMID_CREATE(major, minor) ((major&0xFFFF) | ((minor&0xFF)<<16)) - -#define MM_AUD_START 100 -#define MM_AUD_1 101 -#define MM_AUD_2 102 -#define MM_AUD_3 103 -#define MM_AUD_4 104 -#define MM_AUD_END 105 - -#define MM_CAM_START 200 -#define MM_CAM_1 201 -#define MM_CAM_2 202 -#define MM_CAM_END 203 - -#define MM_DISP_START 300 -#define MM_DISP_1 301 -#define MM_DISP_2 302 -#define MM_DISP_3 303 -#define MM_DISP_4 304 -#define MM_DISP_5 305 -#define MM_DISP_END 306 - -#define MM_GFX_START 400 -#define MM_GFX 401 -#define MM_GFX_END 402 - -#define MM_VID_START 500 -#define MM_VID 501 -#define MM_VID_END 502 - -#define MM_MISC_START 600 -#define MM_MISC 601 -#define MM_MISC_END 602 - -#define MM_QCPE_START 700 -#define MM_QCPE_VM1 701 -#define MM_QCPE_VM2 702 -#define MM_QCPE_VM3 703 -#define MM_QCPE_VM4 704 -#define MM_QCPE_END 705 - -#define MM_CLK_START 800 -#define MM_CLK_VM1 801 -#define MM_CLK_VM2 802 -#define MM_CLK_END 803 - -#define MM_FDE_START 900 -#define MM_FDE_1 901 -#define MM_FDE_END 902 - -#define MM_BUFFERQ_START 1000 -#define MM_BUFFERQ_1 1001 -#define MM_BUFFERQ_END 1002 - -#define MM_ID_MAX 1003 - -#define HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_SINGLE_FE 0x00000000 -#define HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_SINGLE_DOMU 0x00000001 -#define HABMM_SOCKET_OPEN_FLAGS_SINGLE_BE_MULTI_DOMUS 0x00000002 - -#define HABMM_SOCKET_SEND_FLAGS_NON_BLOCKING 0x00000001 - -/* - * Collect cross-VM stats: client provides stat-buffer large enough to allow 2 - * ets of a 2-uint64_t pair to collect seconds and nano-seconds at the - * beginning of the stat-buffer. Stats are collected when the stat-buffer leaves - * VM1, then enters VM2 - */ -#define HABMM_SOCKET_SEND_FLAGS_XING_VM_STAT 0x00000002 - -#define HABMM_SOCKET_RECV_FLAGS_NON_BLOCKING 0x00000001 - -#define HABMM_EXP_MEM_TYPE_DMA 0x00000001 - -#define HABMM_IMPORT_FLAGS_CACHED 0x00000001 - -#define IOCTL_HAB_SEND \ - _IOW(HAB_IOC_TYPE, 0x2, struct hab_send) - -#define IOCTL_HAB_RECV \ - _IOWR(HAB_IOC_TYPE, 0x3, struct hab_recv) - -#define IOCTL_HAB_VC_OPEN \ - _IOWR(HAB_IOC_TYPE, 0x4, struct hab_open) - -#define IOCTL_HAB_VC_CLOSE \ - _IOW(HAB_IOC_TYPE, 0x5, struct hab_close) - -#define IOCTL_HAB_VC_EXPORT \ - _IOWR(HAB_IOC_TYPE, 0x6, struct hab_export) - -#define IOCTL_HAB_VC_IMPORT \ - _IOWR(HAB_IOC_TYPE, 0x7, struct hab_import) - -#define IOCTL_HAB_VC_UNEXPORT \ - _IOW(HAB_IOC_TYPE, 0x8, struct hab_unexport) - -#define IOCTL_HAB_VC_UNIMPORT \ - _IOW(HAB_IOC_TYPE, 0x9, struct hab_unimport) - -#define IOCTL_HAB_VC_QUERY \ - _IOWR(HAB_IOC_TYPE, 0xA, struct hab_info) - -#endif /* HABMM_H */ diff --git a/include/uapi/linux/habmmid.h b/include/uapi/linux/habmmid.h new file mode 100644 index 000000000000..4f79506dd971 --- /dev/null +++ b/include/uapi/linux/habmmid.h @@ -0,0 +1,60 @@ +#ifndef HABMMID_H +#define HABMMID_H + +#define HAB_MMID_CREATE(major, minor) ((major&0xFFFF) | ((minor&0xFF)<<16)) + +#define MM_AUD_START 100 +#define MM_AUD_1 101 +#define MM_AUD_2 102 +#define MM_AUD_3 103 +#define MM_AUD_4 104 +#define MM_AUD_END 105 + +#define MM_CAM_START 200 +#define MM_CAM_1 201 +#define MM_CAM_2 202 +#define MM_CAM_END 203 + +#define MM_DISP_START 300 +#define MM_DISP_1 301 +#define MM_DISP_2 302 +#define MM_DISP_3 303 +#define MM_DISP_4 304 +#define MM_DISP_5 305 +#define MM_DISP_END 306 + +#define MM_GFX_START 400 +#define MM_GFX 401 +#define MM_GFX_END 402 + +#define MM_VID_START 500 +#define MM_VID 501 +#define MM_VID_END 502 + +#define MM_MISC_START 600 +#define MM_MISC 601 +#define MM_MISC_END 602 + +#define MM_QCPE_START 700 +#define MM_QCPE_VM1 701 +#define MM_QCPE_VM2 702 +#define MM_QCPE_VM3 703 +#define MM_QCPE_VM4 704 +#define MM_QCPE_END 705 + +#define MM_CLK_START 800 +#define MM_CLK_VM1 801 +#define MM_CLK_VM2 802 +#define MM_CLK_END 803 + +#define MM_FDE_START 900 +#define MM_FDE_1 901 +#define MM_FDE_END 902 + +#define MM_BUFFERQ_START 1000 +#define MM_BUFFERQ_1 1001 +#define MM_BUFFERQ_END 1002 + +#define MM_ID_MAX 1003 + +#endif /* HABMMID_H */ |
