blob: 2eca2c44753e910ae64df66a70c520aae15b24aa [file] [log] [blame]
Kristofer Jonsson116a6352020-08-20 17:25:23 +02001/*
2 * (C) COPYRIGHT 2020 ARM Limited. All rights reserved.
3 *
4 * This program is free software and is provided to you under the terms of the
5 * GNU General Public License version 2 as published by the Free Software
6 * Foundation, and any use by you of this program is subject to the terms
7 * of such GNU licence.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, you can access it online at
16 * http://www.gnu.org/licenses/gpl-2.0.html.
17 *
18 * SPDX-License-Identifier: GPL-2.0-only
19 */
20
21#ifndef ETHOSU_H
22#define ETHOSU_H
23
24/****************************************************************************
25 * Includes
26 ****************************************************************************/
27
28#include <linux/ioctl.h>
29#include <linux/types.h>
30
31/****************************************************************************
32 * Defines
33 ****************************************************************************/
34
35#define ETHOSU_IOCTL_BASE 0x01
36#define ETHOSU_IO(nr) _IO(ETHOSU_IOCTL_BASE, nr)
37#define ETHOSU_IOR(nr, type) _IOR(ETHOSU_IOCTL_BASE, nr, type)
38#define ETHOSU_IOW(nr, type) _IOW(ETHOSU_IOCTL_BASE, nr, type)
39#define ETHOSU_IOWR(nr, type) _IOWR(ETHOSU_IOCTL_BASE, nr, type)
40
41#define ETHOSU_IOCTL_PING ETHOSU_IO(0x00)
42#define ETHOSU_IOCTL_BUFFER_CREATE ETHOSU_IOR(0x10, \
43 struct ethosu_uapi_buffer_create)
44#define ETHOSU_IOCTL_BUFFER_SET ETHOSU_IOR(0x11, \
45 struct ethosu_uapi_buffer)
46#define ETHOSU_IOCTL_BUFFER_GET ETHOSU_IOW(0x12, \
47 struct ethosu_uapi_buffer)
48#define ETHOSU_IOCTL_NETWORK_CREATE ETHOSU_IOR(0x20, \
49 struct ethosu_uapi_network_create)
50#define ETHOSU_IOCTL_INFERENCE_CREATE ETHOSU_IOR(0x30, \
51 struct ethosu_uapi_inference_create)
52#define ETHOSU_IOCTL_INFERENCE_STATUS ETHOSU_IO(0x31)
53
54/****************************************************************************
55 * Types
56 ****************************************************************************/
57
58/**
59 * enum ethosu_uapi_status - Status
60 */
61enum ethosu_uapi_status {
62 ETHOSU_UAPI_STATUS_OK,
63 ETHOSU_UAPI_STATUS_ERROR
64};
65
66/**
67 * struct ethosu_uapi_buffer_create - Create buffer request
68 * @capacity: Maximum capacity of the buffer
69 */
70struct ethosu_uapi_buffer_create {
71 __u32 capacity;
72};
73
74/**
75 * struct ethosu_uapi_buffer - Buffer descriptor
76 * @offset: Offset to where the data starts
77 * @size: Size of the data
78 *
79 * 'offset + size' must not exceed the capacity of the buffer.
80 */
81struct ethosu_uapi_buffer {
82 __u32 offset;
83 __u32 size;
84};
85
86/**
87 * struct ethosu_uapi_network_create - Create network request
88 * @fd: Buffer file descriptor
89 */
90struct ethosu_uapi_network_create {
91 __u32 fd;
92};
93
94/**
95 * struct ethosu_uapi_inference_create - Create network request
96 * @ifm_fd: IFM buffer file descriptor
97 * @ofm_fd: OFM buffer file descriptor
98 */
99struct ethosu_uapi_inference_create {
100 __u32 ifm_fd;
101 __u32 ofm_fd;
102};
103
104#endif