blob: 86e10ac210e9f62ac43a31649e720baa623c5a94 [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
Per Åstrandf7e407a2020-10-23 21:25:05 +020033/** Maximum number of PMU counters to be returned for inference */
34#define ETHOSU_CORE_PMU_MAX 4
35
Kristofer Jonsson116a6352020-08-20 17:25:23 +020036/**
37 * enum ethosu_core_msg_type - Message types
38 *
39 * Types for the messages sent between the host and the core subsystem.
40 */
41enum ethosu_core_msg_type {
42 ETHOSU_CORE_MSG_PING = 1,
43 ETHOSU_CORE_MSG_PONG,
44 ETHOSU_CORE_MSG_INFERENCE_REQ,
45 ETHOSU_CORE_MSG_INFERENCE_RSP,
46 ETHOSU_CORE_MSG_MAX
47};
48
49/**
50 * struct ethosu_core_msg - Message header
51 */
52struct ethosu_core_msg {
53 uint32_t type;
54 uint32_t length;
55};
56
57/**
58 * struct ethosu_core_queue_header - Message queue header
59 */
60struct ethosu_core_queue_header {
61 uint32_t size;
62 uint32_t read;
63 uint32_t write;
64};
65
66/**
67 * struct ethosu_core_queue - Message queue
68 *
69 * Dynamically sized message queue.
70 */
71struct ethosu_core_queue {
72 struct ethosu_core_queue_header header;
73 uint8_t data[];
74};
75
76enum ethosu_core_status {
77 ETHOSU_CORE_STATUS_OK,
78 ETHOSU_CORE_STATUS_ERROR
79};
80
81struct ethosu_core_buffer {
82 uint32_t ptr;
83 uint32_t size;
84};
85
86struct ethosu_core_inference_req {
87 uint64_t user_arg;
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020088 uint32_t ifm_count;
89 struct ethosu_core_buffer ifm[ETHOSU_CORE_BUFFER_MAX];
90 uint32_t ofm_count;
91 struct ethosu_core_buffer ofm[ETHOSU_CORE_BUFFER_MAX];
Kristofer Jonsson116a6352020-08-20 17:25:23 +020092 struct ethosu_core_buffer network;
Per Åstrandf7e407a2020-10-23 21:25:05 +020093 uint8_t pmu_event_config[ETHOSU_CORE_PMU_MAX];
94 uint32_t pmu_cycle_counter_enable;
Kristofer Jonsson116a6352020-08-20 17:25:23 +020095};
96
97struct ethosu_core_inference_rsp {
98 uint64_t user_arg;
Kristofer Jonssonb74492c2020-09-10 13:26:01 +020099 uint32_t ofm_count;
100 uint32_t ofm_size[ETHOSU_CORE_BUFFER_MAX];
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200101 uint32_t status;
Per Åstrandf7e407a2020-10-23 21:25:05 +0200102 uint8_t pmu_event_config[ETHOSU_CORE_PMU_MAX];
103 uint32_t pmu_event_count[ETHOSU_CORE_PMU_MAX];
104 uint32_t pmu_cycle_counter_enable;
105 uint64_t pmu_cycle_counter_count;
Kristofer Jonsson116a6352020-08-20 17:25:23 +0200106};
107
108#endif