Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 1 | /* |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 2 | * SPDX-FileCopyrightText: Copyright 2020-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the License); you may |
| 7 | * not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 14 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #include <ethosu.hpp> |
| 20 | #include <uapi/ethosu.h> |
| 21 | |
| 22 | #include <algorithm> |
Mikael Olsson | 99429e1 | 2023-08-16 15:22:19 +0200 | [diff] [blame^] | 23 | #include <cerrno> |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 24 | #include <cstdlib> |
Mikael Olsson | 99429e1 | 2023-08-16 15:22:19 +0200 | [diff] [blame^] | 25 | #include <cstring> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 26 | #include <exception> |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 27 | #include <fstream> |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 28 | #include <iomanip> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 29 | #include <iostream> |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 30 | #include <utility> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 31 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 32 | #include <fcntl.h> |
| 33 | #include <poll.h> |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 34 | #include <signal.h> |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 35 | #include <sys/ioctl.h> |
| 36 | #include <sys/mman.h> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 37 | #include <unistd.h> |
| 38 | |
| 39 | using namespace std; |
| 40 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 41 | namespace { |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 42 | std::string driverVersionToString(const EthosU::ethosu_uapi_kernel_driver_version &version) { |
| 43 | return std::to_string(version.major) + "." + std::to_string(version.minor) + "." + std::to_string(version.patch); |
| 44 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 45 | |
| 46 | enum class Severity { Error, Warning, Info, Debug }; |
| 47 | |
| 48 | class Log { |
| 49 | public: |
| 50 | Log(const Severity _severity = Severity::Error) : severity(_severity) {} |
| 51 | |
| 52 | ~Log() = default; |
| 53 | |
| 54 | template <typename T> |
| 55 | const Log &operator<<(const T &d) const { |
| 56 | if (level >= severity) { |
| 57 | cout << d; |
| 58 | } |
| 59 | |
| 60 | return *this; |
| 61 | } |
| 62 | |
| 63 | const Log &operator<<(ostream &(*manip)(ostream &)) const { |
| 64 | if (level >= severity) { |
| 65 | manip(cout); |
| 66 | } |
| 67 | |
| 68 | return *this; |
| 69 | } |
| 70 | |
| 71 | private: |
| 72 | static Severity getLogLevel() { |
| 73 | if (const char *e = getenv("ETHOSU_LOG_LEVEL")) { |
| 74 | const string env(e); |
| 75 | |
| 76 | if (env == "Error") { |
| 77 | return Severity::Error; |
| 78 | } else if (env == "Warning") { |
| 79 | return Severity::Warning; |
| 80 | } else if (env == "Info") { |
| 81 | return Severity::Info; |
| 82 | } else if (env == "Debug") { |
| 83 | return Severity::Debug; |
| 84 | } else { |
| 85 | cerr << "Unsupported log level '" << env << "'" << endl; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | return Severity::Warning; |
| 90 | } |
| 91 | |
| 92 | static const Severity level; |
| 93 | const Severity severity; |
| 94 | }; |
| 95 | |
| 96 | const Severity Log::level = Log::getLogLevel(); |
| 97 | |
| 98 | } // namespace |
| 99 | |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 100 | namespace EthosU { |
Mikael Olsson | e9c3f07 | 2023-06-12 15:58:10 +0200 | [diff] [blame] | 101 | |
| 102 | const SemanticVersion getLibraryVersion() { |
| 103 | return {DRIVER_LIBRARY_VERSION_MAJOR, DRIVER_LIBRARY_VERSION_MINOR, DRIVER_LIBRARY_VERSION_PATCH}; |
| 104 | } |
| 105 | |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 106 | __attribute__((weak)) int eioctl(int fd, unsigned long cmd, void *data = nullptr) { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 107 | int ret = ::ioctl(fd, cmd, data); |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 108 | if (ret < 0) { |
Mikael Olsson | 99429e1 | 2023-08-16 15:22:19 +0200 | [diff] [blame^] | 109 | throw EthosU::Exception(string("IOCTL cmd=").append(to_string(cmd) + " failed: " + strerror(errno)).c_str()); |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 110 | } |
| 111 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 112 | Log(Severity::Debug) << "ioctl. fd=" << fd << ", cmd=" << setw(8) << setfill('0') << hex << cmd << ", ret=" << ret |
| 113 | << endl; |
| 114 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 115 | return ret; |
| 116 | } |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 117 | |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 118 | __attribute__((weak)) int eopen(const char *pathname, int flags) { |
| 119 | int fd = ::open(pathname, flags); |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 120 | if (fd < 0) { |
| 121 | throw Exception("Failed to open device"); |
| 122 | } |
| 123 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 124 | Log(Severity::Debug) << "open. fd=" << fd << ", path='" << pathname << "', flags=" << flags << endl; |
| 125 | |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 126 | return fd; |
| 127 | } |
| 128 | |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 129 | __attribute__((weak)) int |
| 130 | eppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmo_p, const sigset_t *sigmask) { |
| 131 | int result = ::ppoll(fds, nfds, tmo_p, sigmask); |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 132 | if (result < 0) { |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 133 | throw Exception("Failed to wait for ppoll event or signal"); |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | return result; |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | __attribute__((weak)) int eclose(int fd) { |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 140 | Log(Severity::Debug) << "close. fd=" << fd << endl; |
| 141 | |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 142 | int result = ::close(fd); |
| 143 | if (result < 0) { |
| 144 | throw Exception("Failed to close file"); |
| 145 | } |
| 146 | |
| 147 | return result; |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 148 | } |
| 149 | __attribute((weak)) void *emmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 150 | void *ptr = ::mmap(addr, length, prot, flags, fd, offset); |
| 151 | if (ptr == MAP_FAILED) { |
| 152 | throw Exception("Failed to mmap file"); |
| 153 | } |
| 154 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 155 | Log(Severity::Debug) << "map. fd=" << fd << ", addr=" << setfill('0') << addr << ", length=" << dec << length |
| 156 | << ", ptr=" << hex << ptr << endl; |
| 157 | |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 158 | return ptr; |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | __attribute__((weak)) int emunmap(void *addr, size_t length) { |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 162 | Log(Severity::Debug) << "unmap. addr=" << setfill('0') << addr << ", length=" << dec << length << endl; |
| 163 | |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 164 | int result = ::munmap(addr, length); |
| 165 | if (result < 0) { |
| 166 | throw Exception("Failed to munmap file"); |
| 167 | } |
| 168 | |
| 169 | return result; |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | } // namespace EthosU |
| 173 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 174 | namespace EthosU { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 175 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 176 | /**************************************************************************** |
| 177 | * Exception |
| 178 | ****************************************************************************/ |
| 179 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 180 | Exception::Exception(const char *msg) : msg(msg) {} |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 181 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 182 | Exception::~Exception() throw() {} |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 183 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 184 | const char *Exception::what() const throw() { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 185 | return msg.c_str(); |
| 186 | } |
| 187 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 188 | /**************************************************************************** |
Davide Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 189 | * Semantic Version |
| 190 | ****************************************************************************/ |
| 191 | |
| 192 | bool SemanticVersion::operator==(const SemanticVersion &other) { |
| 193 | return other.major == major && other.minor == minor && other.patch == patch; |
| 194 | } |
| 195 | |
| 196 | bool SemanticVersion::operator<(const SemanticVersion &other) { |
| 197 | if (other.major > major) |
| 198 | return true; |
| 199 | if (other.minor > minor) |
| 200 | return true; |
| 201 | return other.patch > patch; |
| 202 | } |
| 203 | |
| 204 | bool SemanticVersion::operator<=(const SemanticVersion &other) { |
| 205 | return *this < other || *this == other; |
| 206 | } |
| 207 | |
| 208 | bool SemanticVersion::operator!=(const SemanticVersion &other) { |
| 209 | return !(*this == other); |
| 210 | } |
| 211 | |
| 212 | bool SemanticVersion::operator>(const SemanticVersion &other) { |
| 213 | return !(*this <= other); |
| 214 | } |
| 215 | |
| 216 | bool SemanticVersion::operator>=(const SemanticVersion &other) { |
| 217 | return !(*this < other); |
| 218 | } |
| 219 | |
| 220 | ostream &operator<<(ostream &out, const SemanticVersion &v) { |
| 221 | return out << "{ major=" << unsigned(v.major) << ", minor=" << unsigned(v.minor) << ", patch=" << unsigned(v.patch) |
| 222 | << " }"; |
| 223 | } |
| 224 | |
| 225 | /**************************************************************************** |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 226 | * Device |
| 227 | ****************************************************************************/ |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 228 | Device::Device(const char *device) : fd(eopen(device, O_RDWR | O_NONBLOCK)) { |
| 229 | ethosu_uapi_kernel_driver_version version = {}; |
| 230 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 231 | Log(Severity::Info) << "Device(\"" << device << "\"). this=" << this << ", fd=" << fd << endl; |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 232 | |
| 233 | try { |
| 234 | eioctl(fd, ETHOSU_IOCTL_DRIVER_VERSION_GET, &version); |
| 235 | |
| 236 | if (MAX_SUPPORTED_KERNEL_DRIVER_MAJOR_VERSION < version.major || |
| 237 | MIN_SUPPORTED_KERNEL_DRIVER_MAJOR_VERSION > version.major) { |
| 238 | throw Exception( |
| 239 | std::string("Unsupported kernel driver version: ").append(driverVersionToString(version)).c_str()); |
| 240 | } |
| 241 | } catch (std::exception &e) { |
| 242 | try { |
| 243 | eclose(fd); |
| 244 | } catch (...) { std::throw_with_nested(e); } |
| 245 | throw; |
| 246 | } |
| 247 | |
| 248 | driverVersion = {version.major, version.minor, version.patch}; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 249 | } |
| 250 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 251 | Device::~Device() noexcept(false) { |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 252 | eclose(fd); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 253 | Log(Severity::Info) << "~Device(). this=" << this << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 254 | } |
| 255 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 256 | int Device::ioctl(unsigned long cmd, void *data) const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 257 | return eioctl(fd, cmd, data); |
| 258 | } |
| 259 | |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 260 | const SemanticVersion &Device::getDriverVersion() const { |
| 261 | return driverVersion; |
| 262 | } |
| 263 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 264 | Capabilities Device::capabilities() const { |
Davide Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 265 | ethosu_uapi_device_capabilities uapi; |
| 266 | (void)eioctl(fd, ETHOSU_IOCTL_CAPABILITIES_REQ, static_cast<void *>(&uapi)); |
| 267 | |
| 268 | Capabilities capabilities( |
| 269 | HardwareId(uapi.hw_id.version_status, |
| 270 | SemanticVersion(uapi.hw_id.version_major, uapi.hw_id.version_minor), |
| 271 | SemanticVersion(uapi.hw_id.product_major), |
| 272 | SemanticVersion(uapi.hw_id.arch_major_rev, uapi.hw_id.arch_minor_rev, uapi.hw_id.arch_patch_rev)), |
Davide Grohmann | 40e23d1 | 2021-06-17 09:59:40 +0200 | [diff] [blame] | 273 | HardwareConfiguration(uapi.hw_cfg.macs_per_cc, uapi.hw_cfg.cmd_stream_version, bool(uapi.hw_cfg.custom_dma)), |
Davide Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 274 | SemanticVersion(uapi.driver_major_rev, uapi.driver_minor_rev, uapi.driver_patch_rev)); |
| 275 | return capabilities; |
| 276 | } |
| 277 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 278 | /**************************************************************************** |
| 279 | * Buffer |
| 280 | ****************************************************************************/ |
| 281 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 282 | Buffer::Buffer(const Device &device, const size_t capacity) : fd(-1), dataPtr(nullptr), dataCapacity(capacity) { |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 283 | ethosu_uapi_buffer_create uapi = {static_cast<uint32_t>(dataCapacity)}; |
| 284 | fd = device.ioctl(ETHOSU_IOCTL_BUFFER_CREATE, static_cast<void *>(&uapi)); |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 285 | |
Davide Grohmann | 2ba3c1d | 2021-11-08 15:08:48 +0100 | [diff] [blame] | 286 | void *d; |
| 287 | try { |
| 288 | d = emmap(nullptr, dataCapacity, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); |
| 289 | } catch (std::exception &e) { |
| 290 | try { |
| 291 | eclose(fd); |
| 292 | } catch (...) { std::throw_with_nested(e); } |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 293 | throw; |
Davide Grohmann | 2ba3c1d | 2021-11-08 15:08:48 +0100 | [diff] [blame] | 294 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 295 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 296 | dataPtr = reinterpret_cast<char *>(d); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 297 | |
| 298 | Log(Severity::Info) << "Buffer(" << &device << ", " << dec << capacity << "), this=" << this << ", fd=" << fd |
| 299 | << ", dataPtr=" << static_cast<void *>(dataPtr) << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 300 | } |
| 301 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 302 | Buffer::~Buffer() noexcept(false) { |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 303 | try { |
| 304 | emunmap(dataPtr, dataCapacity); |
| 305 | } catch (std::exception &e) { |
| 306 | try { |
| 307 | eclose(fd); |
| 308 | } catch (...) { std::throw_with_nested(e); } |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 309 | throw; |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 310 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 311 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 312 | eclose(fd); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 313 | |
| 314 | Log(Severity::Info) << "~Buffer(). this=" << this << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 315 | } |
| 316 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 317 | size_t Buffer::capacity() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 318 | return dataCapacity; |
| 319 | } |
| 320 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 321 | void Buffer::clear() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 322 | resize(0, 0); |
| 323 | } |
| 324 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 325 | char *Buffer::data() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 326 | return dataPtr + offset(); |
| 327 | } |
| 328 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 329 | void Buffer::resize(size_t size, size_t offset) const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 330 | ethosu_uapi_buffer uapi; |
| 331 | uapi.offset = offset; |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 332 | uapi.size = size; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 333 | eioctl(fd, ETHOSU_IOCTL_BUFFER_SET, static_cast<void *>(&uapi)); |
| 334 | } |
| 335 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 336 | size_t Buffer::offset() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 337 | ethosu_uapi_buffer uapi; |
| 338 | eioctl(fd, ETHOSU_IOCTL_BUFFER_GET, static_cast<void *>(&uapi)); |
| 339 | return uapi.offset; |
| 340 | } |
| 341 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 342 | size_t Buffer::size() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 343 | ethosu_uapi_buffer uapi; |
| 344 | eioctl(fd, ETHOSU_IOCTL_BUFFER_GET, static_cast<void *>(&uapi)); |
| 345 | return uapi.size; |
| 346 | } |
| 347 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 348 | int Buffer::getFd() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 349 | return fd; |
| 350 | } |
| 351 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 352 | /**************************************************************************** |
| 353 | * Network |
| 354 | ****************************************************************************/ |
| 355 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 356 | Network::Network(const Device &device, shared_ptr<Buffer> &buffer) : fd(-1), buffer(buffer) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 357 | // Create buffer handle |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 358 | ethosu_uapi_network_create uapi; |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 359 | uapi.type = ETHOSU_UAPI_NETWORK_BUFFER; |
| 360 | uapi.fd = buffer->getFd(); |
| 361 | fd = device.ioctl(ETHOSU_IOCTL_NETWORK_CREATE, static_cast<void *>(&uapi)); |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 362 | try { |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 363 | collectNetworkInfo(); |
| 364 | } catch (std::exception &e) { |
| 365 | try { |
| 366 | eclose(fd); |
| 367 | } catch (...) { std::throw_with_nested(e); } |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 368 | throw; |
Jonny Svärd | 2c01713 | 2021-04-12 15:56:44 +0200 | [diff] [blame] | 369 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 370 | |
| 371 | Log(Severity::Info) << "Network(" << &device << ", " << &*buffer << "), this=" << this << ", fd=" << fd << endl; |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 372 | } |
Jonny Svärd | 2c01713 | 2021-04-12 15:56:44 +0200 | [diff] [blame] | 373 | |
Kristofer Jonsson | 3c6a260 | 2022-03-10 11:17:29 +0100 | [diff] [blame] | 374 | Network::Network(const Device &device, const unsigned index) : fd(-1) { |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 375 | // Create buffer handle |
| 376 | ethosu_uapi_network_create uapi; |
| 377 | uapi.type = ETHOSU_UAPI_NETWORK_INDEX; |
| 378 | uapi.index = index; |
| 379 | fd = device.ioctl(ETHOSU_IOCTL_NETWORK_CREATE, static_cast<void *>(&uapi)); |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 380 | try { |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 381 | collectNetworkInfo(); |
| 382 | } catch (std::exception &e) { |
| 383 | try { |
| 384 | eclose(fd); |
| 385 | } catch (...) { std::throw_with_nested(e); } |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 386 | throw; |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 387 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 388 | |
| 389 | Log(Severity::Info) << "Network(" << &device << ", " << index << "), this=" << this << ", fd=" << fd << endl; |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 390 | } |
Kristofer Jonsson | 3c6a260 | 2022-03-10 11:17:29 +0100 | [diff] [blame] | 391 | |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 392 | void Network::collectNetworkInfo() { |
| 393 | ethosu_uapi_network_info info; |
| 394 | ioctl(ETHOSU_IOCTL_NETWORK_INFO, static_cast<void *>(&info)); |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 395 | |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 396 | for (uint32_t i = 0; i < info.ifm_count; i++) { |
| 397 | ifmDims.push_back(info.ifm_size[i]); |
| 398 | } |
| 399 | |
| 400 | for (uint32_t i = 0; i < info.ofm_count; i++) { |
| 401 | ofmDims.push_back(info.ofm_size[i]); |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 402 | } |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 403 | } |
| 404 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 405 | Network::~Network() noexcept(false) { |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 406 | eclose(fd); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 407 | Log(Severity::Info) << "~Network(). this=" << this << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 408 | } |
| 409 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 410 | int Network::ioctl(unsigned long cmd, void *data) { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 411 | return eioctl(fd, cmd, data); |
| 412 | } |
| 413 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 414 | shared_ptr<Buffer> Network::getBuffer() { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 415 | return buffer; |
| 416 | } |
| 417 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 418 | const std::vector<size_t> &Network::getIfmDims() const { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 419 | return ifmDims; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 420 | } |
| 421 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 422 | size_t Network::getIfmSize() const { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 423 | size_t size = 0; |
| 424 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 425 | for (auto s : ifmDims) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 426 | size += s; |
| 427 | } |
| 428 | |
| 429 | return size; |
| 430 | } |
| 431 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 432 | const std::vector<size_t> &Network::getOfmDims() const { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 433 | return ofmDims; |
| 434 | } |
| 435 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 436 | size_t Network::getOfmSize() const { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 437 | size_t size = 0; |
| 438 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 439 | for (auto s : ofmDims) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 440 | size += s; |
| 441 | } |
| 442 | |
| 443 | return size; |
| 444 | } |
| 445 | |
| 446 | /**************************************************************************** |
| 447 | * Inference |
| 448 | ****************************************************************************/ |
| 449 | |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 450 | ostream &operator<<(ostream &out, const InferenceStatus &status) { |
| 451 | switch (status) { |
| 452 | case InferenceStatus::OK: |
| 453 | return out << "ok"; |
| 454 | case InferenceStatus::ERROR: |
| 455 | return out << "error"; |
| 456 | case InferenceStatus::RUNNING: |
| 457 | return out << "running"; |
| 458 | case InferenceStatus::REJECTED: |
| 459 | return out << "rejected"; |
Davide Grohmann | 7e8f508 | 2022-03-23 12:48:45 +0100 | [diff] [blame] | 460 | case InferenceStatus::ABORTED: |
| 461 | return out << "aborted"; |
| 462 | case InferenceStatus::ABORTING: |
| 463 | return out << "aborting"; |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 464 | } |
| 465 | throw Exception("Unknown inference status"); |
| 466 | } |
| 467 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 468 | Inference::~Inference() noexcept(false) { |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 469 | eclose(fd); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 470 | Log(Severity::Info) << "~Inference(). this=" << this << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 471 | } |
| 472 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 473 | void Inference::create(std::vector<uint32_t> &counterConfigs, bool cycleCounterEnable = false) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 474 | ethosu_uapi_inference_create uapi; |
| 475 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 476 | if (ifmBuffers.size() > ETHOSU_FD_MAX) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 477 | throw Exception("IFM buffer overflow"); |
| 478 | } |
| 479 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 480 | if (ofmBuffers.size() > ETHOSU_FD_MAX) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 481 | throw Exception("OFM buffer overflow"); |
| 482 | } |
| 483 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 484 | if (counterConfigs.size() != ETHOSU_PMU_EVENT_MAX) { |
| 485 | throw Exception("Wrong size of counter configurations"); |
| 486 | } |
| 487 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 488 | uapi.ifm_count = 0; |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 489 | for (auto it : ifmBuffers) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 490 | uapi.ifm_fd[uapi.ifm_count++] = it->getFd(); |
| 491 | } |
| 492 | |
| 493 | uapi.ofm_count = 0; |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 494 | for (auto it : ofmBuffers) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 495 | uapi.ofm_fd[uapi.ofm_count++] = it->getFd(); |
| 496 | } |
| 497 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 498 | for (int i = 0; i < ETHOSU_PMU_EVENT_MAX; i++) { |
| 499 | uapi.pmu_config.events[i] = counterConfigs[i]; |
| 500 | } |
| 501 | |
| 502 | uapi.pmu_config.cycle_count = cycleCounterEnable; |
| 503 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 504 | fd = network->ioctl(ETHOSU_IOCTL_INFERENCE_CREATE, static_cast<void *>(&uapi)); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 505 | |
| 506 | Log(Severity::Info) << "Inference(" << &*network << "), this=" << this << ", fd=" << fd << endl; |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 507 | } |
| 508 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 509 | std::vector<uint32_t> Inference::initializeCounterConfig() { |
| 510 | return std::vector<uint32_t>(ETHOSU_PMU_EVENT_MAX, 0); |
| 511 | } |
| 512 | |
| 513 | uint32_t Inference::getMaxPmuEventCounters() { |
| 514 | return ETHOSU_PMU_EVENT_MAX; |
| 515 | } |
| 516 | |
Davide Grohmann | 7e8f508 | 2022-03-23 12:48:45 +0100 | [diff] [blame] | 517 | bool Inference::wait(int64_t timeoutNanos) const { |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 518 | struct pollfd pfd; |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 519 | pfd.fd = fd; |
| 520 | pfd.events = POLLIN | POLLERR; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 521 | pfd.revents = 0; |
| 522 | |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 523 | // if timeout negative wait forever |
| 524 | if (timeoutNanos < 0) { |
Davide Grohmann | f036423 | 2022-06-16 17:42:58 +0200 | [diff] [blame] | 525 | return eppoll(&pfd, 1, NULL, NULL) == 0; |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 526 | } |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 527 | |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 528 | struct timespec tmo_p; |
| 529 | int64_t nanosec = 1000000000; |
| 530 | tmo_p.tv_sec = timeoutNanos / nanosec; |
| 531 | tmo_p.tv_nsec = timeoutNanos % nanosec; |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 532 | |
Davide Grohmann | 7e8f508 | 2022-03-23 12:48:45 +0100 | [diff] [blame] | 533 | return eppoll(&pfd, 1, &tmo_p, NULL) == 0; |
| 534 | } |
| 535 | |
| 536 | bool Inference::cancel() const { |
| 537 | ethosu_uapi_cancel_inference_status uapi; |
| 538 | eioctl(fd, ETHOSU_IOCTL_INFERENCE_CANCEL, static_cast<void *>(&uapi)); |
| 539 | return uapi.status == ETHOSU_UAPI_STATUS_OK; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 540 | } |
| 541 | |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 542 | InferenceStatus Inference::status() const { |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 543 | ethosu_uapi_result_status uapi; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 544 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 545 | eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi)); |
| 546 | |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 547 | switch (uapi.status) { |
| 548 | case ETHOSU_UAPI_STATUS_OK: |
| 549 | return InferenceStatus::OK; |
| 550 | case ETHOSU_UAPI_STATUS_ERROR: |
| 551 | return InferenceStatus::ERROR; |
| 552 | case ETHOSU_UAPI_STATUS_RUNNING: |
| 553 | return InferenceStatus::RUNNING; |
| 554 | case ETHOSU_UAPI_STATUS_REJECTED: |
| 555 | return InferenceStatus::REJECTED; |
Davide Grohmann | 7e8f508 | 2022-03-23 12:48:45 +0100 | [diff] [blame] | 556 | case ETHOSU_UAPI_STATUS_ABORTED: |
| 557 | return InferenceStatus::ABORTED; |
| 558 | case ETHOSU_UAPI_STATUS_ABORTING: |
| 559 | return InferenceStatus::ABORTING; |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | throw Exception("Unknown inference status"); |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 563 | } |
| 564 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 565 | const std::vector<uint32_t> Inference::getPmuCounters() const { |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 566 | ethosu_uapi_result_status uapi; |
| 567 | std::vector<uint32_t> counterValues = std::vector<uint32_t>(ETHOSU_PMU_EVENT_MAX, 0); |
| 568 | |
| 569 | eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi)); |
| 570 | |
| 571 | for (int i = 0; i < ETHOSU_PMU_EVENT_MAX; i++) { |
| 572 | if (uapi.pmu_config.events[i]) { |
| 573 | counterValues.at(i) = uapi.pmu_count.events[i]; |
| 574 | } |
| 575 | } |
| 576 | |
| 577 | return counterValues; |
| 578 | } |
| 579 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 580 | uint64_t Inference::getCycleCounter() const { |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 581 | ethosu_uapi_result_status uapi; |
| 582 | |
| 583 | eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi)); |
| 584 | |
| 585 | return uapi.pmu_count.cycle_count; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 586 | } |
| 587 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 588 | int Inference::getFd() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 589 | return fd; |
| 590 | } |
| 591 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 592 | const shared_ptr<Network> Inference::getNetwork() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 593 | return network; |
| 594 | } |
| 595 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 596 | vector<shared_ptr<Buffer>> &Inference::getIfmBuffers() { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 597 | return ifmBuffers; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 598 | } |
| 599 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 600 | vector<shared_ptr<Buffer>> &Inference::getOfmBuffers() { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 601 | return ofmBuffers; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 602 | } |
| 603 | |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 604 | static_assert(MAX_SUPPORTED_KERNEL_DRIVER_MAJOR_VERSION >= ETHOSU_KERNEL_DRIVER_VERSION_MAJOR && |
| 605 | MIN_SUPPORTED_KERNEL_DRIVER_MAJOR_VERSION <= ETHOSU_KERNEL_DRIVER_VERSION_MAJOR, |
| 606 | "Unsupported major kernel driver version in UAPI"); |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 607 | } // namespace EthosU |