blob: 0dd19967462932f76caf1302d16359717c64b9a6 [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_CORE_INTERFACE_H
22#define ETHOSU_CORE_INTERFACE_H
23
24#ifdef __KERNEL__
25#include <linux/types.h>
26#else
27#include <stdint.h>
28#endif
29
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020030/** Maximum number of IFM/OFM buffers per inference */
31#define ETHOSU_CORE_BUFFER_MAX 16
32
Kristofer Jonsson116a6352020-08-20 17:25:23 +020033/**
34 * enum ethosu_core_msg_type - Message types
35 *
36 * Types for the messages sent between the host and the core subsystem.
37 */
38enum ethosu_core_msg_type {
39 ETHOSU_CORE_MSG_PING = 1,
40 ETHOSU_CORE_MSG_PONG,
41 ETHOSU_CORE_MSG_INFERENCE_REQ,
42 ETHOSU_CORE_MSG_INFERENCE_RSP,
43 ETHOSU_CORE_MSG_MAX
44};
45
46/**
47 * struct ethosu_core_msg - Message header
48 */
49struct ethosu_core_msg {
50 uint32_t type;
51 uint32_t length;
52};
53
54/**
55 * struct ethosu_core_queue_header - Message queue header
56 */
57struct ethosu_core_queue_header {
58 uint32_t size;
59 uint32_t read;
60 uint32_t write;
61};
62
63/**
64 * struct ethosu_core_queue - Message queue
65 *
66 * Dynamically sized message queue.
67 */
68struct ethosu_core_queue {
69 struct ethosu_core_queue_header header;
70 uint8_t data[];
71};
72
73enum ethosu_core_status {
74 ETHOSU_CORE_STATUS_OK,
75 ETHOSU_CORE_STATUS_ERROR
76};
77
78struct ethosu_core_buffer {
79 uint32_t ptr;
80 uint32_t size;
81};
82
83struct ethosu_core_inference_req {
84 uint64_t user_arg;
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020085 uint32_t ifm_count;
86 struct ethosu_core_buffer ifm[ETHOSU_CORE_BUFFER_MAX];
87 uint32_t ofm_count;
88 struct ethosu_core_buffer ofm[ETHOSU_CORE_BUFFER_MAX];
Kristofer Jonsson116a6352020-08-20 17:25:23 +020089 struct ethosu_core_buffer network;
90};
91
92struct ethosu_core_inference_rsp {
93 uint64_t user_arg;
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020094 uint32_t ofm_count;
95 uint32_t ofm_size[ETHOSU_CORE_BUFFER_MAX];
Kristofer Jonsson116a6352020-08-20 17:25:23 +020096 uint32_t status;
97};
98
99#endif