blob: d790db42a180e549ad1c79b41b0f66a402ae6bb1 [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
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020054/* Maximum number of IFM/OFM file descriptors per network */
55#define ETHOSU_FD_MAX 16
56
Kristofer Jonsson116a6352020-08-20 17:25:23 +020057/****************************************************************************
58 * Types
59 ****************************************************************************/
60
61/**
62 * enum ethosu_uapi_status - Status
63 */
64enum ethosu_uapi_status {
65 ETHOSU_UAPI_STATUS_OK,
66 ETHOSU_UAPI_STATUS_ERROR
67};
68
69/**
70 * struct ethosu_uapi_buffer_create - Create buffer request
71 * @capacity: Maximum capacity of the buffer
72 */
73struct ethosu_uapi_buffer_create {
74 __u32 capacity;
75};
76
77/**
78 * struct ethosu_uapi_buffer - Buffer descriptor
79 * @offset: Offset to where the data starts
80 * @size: Size of the data
81 *
82 * 'offset + size' must not exceed the capacity of the buffer.
83 */
84struct ethosu_uapi_buffer {
85 __u32 offset;
86 __u32 size;
87};
88
89/**
90 * struct ethosu_uapi_network_create - Create network request
91 * @fd: Buffer file descriptor
92 */
93struct ethosu_uapi_network_create {
94 __u32 fd;
95};
96
97/**
98 * struct ethosu_uapi_inference_create - Create network request
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020099 * @ifm_count: Number of IFM file descriptors
100 * @ifm_fd: IFM buffer file descriptors
101 * @ofm_count: Number of OFM file descriptors
102 * @ofm_fd: OFM buffer file descriptors
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200103 */
104struct ethosu_uapi_inference_create {
Kristofer Jonssonb74492c2020-09-10 13:26:01 +0200105 __u32 ifm_count;
106 __u32 ifm_fd[ETHOSU_FD_MAX];
107 __u32 ofm_count;
108 __u32 ofm_fd[ETHOSU_FD_MAX];
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200109};
110
111#endif